@@ -11,14 +11,17 @@ export class ITMSTransporterService implements IITMSTransporterService {
11
11
private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
12
12
private $errors : IErrors ,
13
13
private $fs : IFileSystem ,
14
+ private $httpClient : Server . IHttpClient ,
14
15
private $platformService : IPlatformService ,
15
16
private $staticConfig : IStaticConfig ,
16
- private $sysInfo : ISysInfo ) { }
17
+ private $sysInfo : ISysInfo
18
+ /*private $xcodeSelectService: IXcodeSelectService*/ ) { }
17
19
18
- public upload ( appId : string , username : string , password : string , mobileProvisionIdentifier ?: string , codeSignIdentity ?: string ) : IFuture < void > {
20
+ public upload ( applicationName : string , username : string , password : string , mobileProvisionIdentifier ?: string , codeSignIdentity ?: string ) : IFuture < void > {
19
21
return ( ( ) => {
20
22
temp . track ( ) ;
21
- let itmsTransporterPath = this . getITMSTransporterPath ( ) . wait ( ) ,
23
+ let appId = this . getAppId ( applicationName , username , password ) . wait ( ) ,
24
+ itmsTransporterPath = this . getITMSTransporterPath ( ) . wait ( ) ,
22
25
ipaFileName = "app.ipa" ,
23
26
itmsDirectory = temp . mkdirSync ( "itms-" ) ,
24
27
innerDirectory = path . join ( itmsDirectory , "mybundle.itmsp" ) ,
@@ -31,39 +34,63 @@ export class ITMSTransporterService implements IITMSTransporterService {
31
34
codeSignIdentity : codeSignIdentity
32
35
} ;
33
36
34
- this . $fs . createDirectory ( innerDirectory ) . wait ( ) ;
37
+ // this.$fs.createDirectory(innerDirectory).wait();
35
38
36
- this . $platformService . preparePlatform ( platform ) . wait ( ) ;
37
- this . $platformService . buildPlatform ( platform , iosBuildConfig ) . wait ( ) ;
38
- this . $platformService . copyLastOutput ( platform , ipaFileLocation , { isForDevice : forDevice } ) . wait ( ) ;
39
+ // this.$platformService.preparePlatform(platform).wait();
40
+ // this.$platformService.buildPlatform(platform, iosBuildConfig).wait();
41
+ // this.$platformService.copyLastOutput(platform, ipaFileLocation, { isForDevice: forDevice }).wait();
39
42
40
- let ipaFileHash = md5 ( this . $fs . readFile ( ipaFileLocation ) . wait ( ) ) ,
41
- ipaFileSize = this . $fs . getFileSize ( ipaFileLocation ) . wait ( ) ,
42
- metadata = `<?xml version="1.0" encoding="UTF-8"?>
43
- <package version="software4.7" xmlns="http://apple.com/itunes/importer">
44
- <software_assets apple_id="${ appId } ">
45
- <asset type="bundle">
46
- <data_file>
47
- <file_name>${ ipaFileName } </file_name>
48
- <checksum type="md5">${ ipaFileHash } </checksum>
49
- <size>${ ipaFileSize } </size>
50
- </data_file>
51
- </asset>
52
- </software_assets>
53
- </package>` ;
43
+ // let ipaFileHash = md5(this.$fs.readFile(ipaFileLocation).wait()),
44
+ // ipaFileSize = this.$fs.getFileSize(ipaFileLocation).wait(),
45
+ // metadata = `<?xml version="1.0" encoding="UTF-8"?>
46
+ // <package version="software4.7" xmlns="http://apple.com/itunes/importer">
47
+ // <software_assets apple_id="${appId}">
48
+ // <asset type="bundle">
49
+ // <data_file>
50
+ // <file_name>${ipaFileName}</file_name>
51
+ // <checksum type="md5">${ipaFileHash}</checksum>
52
+ // <size>${ipaFileSize}</size>
53
+ // </data_file>
54
+ // </asset>
55
+ // </software_assets>
56
+ // </package>`;
54
57
55
- this . $fs . writeFile ( path . join ( innerDirectory , "metadata.xml" ) , metadata ) . wait ( ) ;
58
+ // this.$fs.writeFile(path.join(innerDirectory, "metadata.xml"), metadata).wait();
56
59
57
- this . $childProcess . spawnFromEvent ( itmsTransporterPath , [ "-m" , "upload" , "-f" , itmsDirectory , "-u" , username , "-p" , password , "-v" , "informational" ] , "close" , { stdio : "inherit" } ) . wait ( ) ;
60
+ // this.$childProcess.spawnFromEvent(itmsTransporterPath, ["-m", "upload", "-f", itmsDirectory, "-u", username, "-p", password, "-v", "informational"], "close", { stdio: "inherit" }).wait();
58
61
} ) . future < void > ( ) ( ) ;
59
62
}
60
63
64
+ private getAppId ( applicationName : string , username : string , password : string ) : IFuture < string > {
65
+ return ( ( ) => {
66
+ let result = this . $httpClient . httpRequest ( {
67
+ url : "https://contentdelivery.itunes.apple.com/WebObjects/MZLabelService.woa/json/MZITunesProducerService" ,
68
+ method : "POST" ,
69
+ body : JSON . stringify ( {
70
+ id : 1 , // magic number
71
+ jsonrpc : "2.0" ,
72
+ method : "lookupSoftwareApplications" ,
73
+ params : {
74
+ Username : username ,
75
+ Password : password ,
76
+ Version : "2.9.1(441)" ,
77
+ Application : "Application Loader" ,
78
+ OSIdentifier : "Mac OS X 10.8.5 (x86_64)"
79
+ }
80
+ } )
81
+ } ) . wait ( ) . body . result ;
82
+
83
+ console . log ( json . result ) ;
84
+ return "5" ;
85
+ } ) . future < string > ( ) ( ) ;
86
+ }
87
+
61
88
private getITMSTransporterPath ( ) : IFuture < string > {
62
89
return ( ( ) => {
63
90
if ( ! this . _itmsTransporterPath ) {
64
91
let sysInfo = this . $sysInfo . getSysInfo ( path . join ( __dirname , ".." , ".." , this . $staticConfig . PROJECT_FILE_NAME ) ) . wait ( ) ,
65
92
xcodeVersionMatch = sysInfo . xcodeVer . match ( / X c o d e ( .* ) / ) ,
66
- result = path . join ( "/Applications" , "Xcode.app" , "Contents ", "Applications" , "Application Loader.app" , "Contents" ) ;
93
+ result = path . join ( "this.$xcodeSelectService.getContentsDirectoryPath().wait() " , "Applications" , "Application Loader.app" , "Contents" ) ;
67
94
68
95
if ( xcodeVersionMatch && xcodeVersionMatch [ 1 ] ) {
69
96
let [ major , minor ] = xcodeVersionMatch [ 1 ] . split ( "." ) ;
0 commit comments