Skip to content

Commit b951cbf

Browse files
author
Dimitar Kerezov
committed
WIP
1 parent 8110d11 commit b951cbf

32 files changed

+398
-246
lines changed

lib/bootstrap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $injector.require("projectNameService", "./services/project-name-service");
1919
$injector.require("tnsModulesService", "./services/tns-modules-service");
2020

2121
$injector.require("platformsData", "./platforms-data");
22-
$injector.require("platformService", "./services/platform-service");
22+
$injector.requirePublic("platformService", "./services/platform-service");
2323

2424
$injector.require("iOSDebugService", "./services/ios-debug-service");
2525
$injector.require("androidDebugService", "./services/android-debug-service");

lib/commands/add-platform.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
export class AddPlatformCommand implements ICommand {
22
public allowedParameters: ICommandParameter[] = [];
33

4-
constructor(private $platformService: IPlatformService,
4+
constructor(private $options: IOptions,
5+
private $platformService: IPlatformService,
56
private $errors: IErrors) { }
67

78
public async execute(args: string[]): Promise<void> {
8-
await this.$platformService.addPlatforms(args);
9+
await this.$platformService.addPlatforms(args, this.$options.platformTemplate);
910
}
1011

1112
public async canExecute(args: string[]): Promise<boolean> {

lib/commands/appstore-upload.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,26 @@ export class PublishIOS implements ICommand {
5454
if (!ipaFilePath) {
5555
let platform = this.$devicePlatformsConstants.iOS;
5656
// No .ipa path provided, build .ipa on out own.
57+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
5758
if (mobileProvisionIdentifier || codeSignIdentity) {
5859
let iOSBuildConfig: IiOSBuildConfig = {
60+
projectDir: this.$options.path,
61+
release: this.$options.release,
62+
device: this.$options.device,
63+
provision: this.$options.provision,
64+
teamId: this.$options.teamId,
5965
buildForDevice: true,
6066
mobileProvisionIdentifier,
6167
codeSignIdentity
6268
};
6369
this.$logger.info("Building .ipa with the selected mobile provision and/or certificate.");
6470
// This is not very correct as if we build multiple targets we will try to sign all of them using the signing identity here.
65-
await this.$platformService.preparePlatform(platform);
71+
await this.$platformService.preparePlatform(platform, appFilesUpdaterOptions, this.$options.platformTemplate);
6672
await this.$platformService.buildPlatform(platform, iOSBuildConfig);
6773
ipaFilePath = this.$platformService.lastOutputPath(platform, { isForDevice: iOSBuildConfig.buildForDevice });
6874
} else {
6975
this.$logger.info("No .ipa, mobile provision or certificate set. Perfect! Now we'll build .xcarchive and let Xcode pick the distribution certificate and provisioning profile for you when exporting .ipa for AppStore submission.");
70-
await this.$platformService.preparePlatform(platform);
76+
await this.$platformService.preparePlatform(platform, appFilesUpdaterOptions, this.$options.platformTemplate);
7177

7278
let platformData = this.$platformsData.getPlatformData(platform);
7379
let iOSProjectService = <IOSProjectService>platformData.platformProjectService;

lib/commands/build.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ export class BuildCommandBase {
55

66
public async executeCore(args: string[]): Promise<void> {
77
let platform = args[0].toLowerCase();
8-
await this.$platformService.preparePlatform(platform);
8+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
9+
await this.$platformService.preparePlatform(platform, appFilesUpdaterOptions, this.$options.platformTemplate);
910
this.$options.clean = true;
10-
await this.$platformService.buildPlatform(platform);
11+
const buildConfig: IBuildConfig = {
12+
buildForDevice: this.$options.forDevice,
13+
projectDir: this.$options.path,
14+
clean: this.$options.clean,
15+
release: this.$options.release
16+
};
17+
await this.$platformService.buildPlatform(platform, buildConfig);
1118
if (this.$options.copyTo) {
1219
this.$platformService.copyLastOutput(platform, this.$options.copyTo, { isForDevice: this.$options.forDevice });
1320
}

lib/commands/clean-app.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export class CleanAppCommandBase {
44

55
public async execute(args: string[]): Promise<void> {
66
let platform = args[0].toLowerCase();
7-
return this.$platformService.cleanDestinationApp(platform);
7+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
8+
return this.$platformService.cleanDestinationApp(platform, appFilesUpdaterOptions, this.$options.platformTemplate);
89
}
910
}
1011

lib/commands/debug.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@
1717
return this.debugService.debug();
1818
}
1919

20-
await this.$platformService.deployPlatform(this.$devicesService.platform);
20+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
21+
const deployOptions: IDeployPlatformOptions = {
22+
clean: this.$options.clean,
23+
device: this.$options.device,
24+
emulator: this.$options.emulator,
25+
platformTemplate: this.$options.platformTemplate,
26+
projectDir: this.$options.path,
27+
release: this.$options.release
28+
};
29+
await this.$platformService.deployPlatform(this.$devicesService.platform, appFilesUpdaterOptions, deployOptions);
2130
this.$config.debugLivesync = true;
2231
let applicationReloadAction = async (deviceAppData: Mobile.IDeviceAppData): Promise<void> => {
2332
let projectData: IProjectData = this.$injector.resolve("projectData");

lib/commands/deploy.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ export class DeployOnDeviceCommand implements ICommand {
88
private $mobileHelper: Mobile.IMobileHelper) { }
99

1010
public async execute(args: string[]): Promise<void> {
11-
return this.$platformService.deployPlatform(args[0], true);
11+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
12+
const deployOptions: IDeployPlatformOptions = {
13+
clean: this.$options.clean,
14+
device: this.$options.device,
15+
projectDir: this.$options.path,
16+
emulator: this.$options.emulator,
17+
platformTemplate: this.$options.platformTemplate,
18+
release: this.$options.release,
19+
forceInstall: true
20+
};
21+
return this.$platformService.deployPlatform(args[0], appFilesUpdaterOptions, deployOptions);
1222
}
1323

1424
public async canExecute(args: string[]): Promise<boolean> {

lib/commands/emulate.ts

+22-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
export class EmulateCommandBase {
2-
constructor(private $platformService: IPlatformService) { }
2+
constructor(private $options: IOptions,
3+
private $platformService: IPlatformService) { }
34

45
public async executeCore(args: string[]): Promise<void> {
5-
return this.$platformService.emulatePlatform(args[0]);
6+
this.$options.emulator = true;
7+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
8+
const emulateOptions: IEmulatePlatformOptions = {
9+
avd: this.$options.avd,
10+
clean: this.$options.clean,
11+
device: this.$options.device,
12+
release: this.$options.release,
13+
emulator: this.$options.emulator,
14+
projectDir: this.$options.path,
15+
justlaunch: this.$options.justlaunch,
16+
availableDevices: this.$options.availableDevices,
17+
platformTemplate: this.$options.platformTemplate
18+
}
19+
return this.$platformService.emulatePlatform(args[0], appFilesUpdaterOptions, emulateOptions);
620
}
721
}
822

923
export class EmulateIosCommand extends EmulateCommandBase implements ICommand {
1024
public allowedParameters: ICommandParameter[] = [];
1125

12-
constructor($platformService: IPlatformService,
26+
constructor($options: IOptions,
27+
$platformService: IPlatformService,
1328
private $platformsData: IPlatformsData) {
14-
super($platformService);
29+
super($options, $platformService);
1530
}
1631

1732
public async execute(args: string[]): Promise<void> {
@@ -22,9 +37,10 @@ export class EmulateIosCommand extends EmulateCommandBase implements ICommand {
2237
$injector.registerCommand("emulate|ios", EmulateIosCommand);
2338

2439
export class EmulateAndroidCommand extends EmulateCommandBase implements ICommand {
25-
constructor($platformService: IPlatformService,
40+
constructor($options: IOptions,
41+
$platformService: IPlatformService,
2642
private $platformsData: IPlatformsData) {
27-
super($platformService);
43+
super($options, $platformService);
2844
}
2945

3046
public allowedParameters: ICommandParameter[] = [];

lib/commands/install.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export class InstallCommand implements ICommand {
44
public enableHooks = false;
55
public allowedParameters: ICommandParameter[] = [this.$stringParameter];
66

7-
constructor(private $platformsData: IPlatformsData,
7+
constructor(private $options: IOptions,
8+
private $platformsData: IPlatformsData,
89
private $platformService: IPlatformService,
910
private $projectData: IProjectData,
1011
private $projectDataService: IProjectDataService,
@@ -29,7 +30,7 @@ export class InstallCommand implements ICommand {
2930
let frameworkPackageData = this.$projectDataService.getValue(platformData.frameworkPackageName);
3031
if (frameworkPackageData && frameworkPackageData.version) {
3132
try {
32-
await this.$platformService.addPlatforms([`${platform}@${frameworkPackageData.version}`]);
33+
await this.$platformService.addPlatforms([`${platform}@${frameworkPackageData.version}`], this.$options.platformTemplate);
3334
} catch (err) {
3435
error = `${error}${EOL}${err}`;
3536
}

lib/commands/livesync.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,17 @@ export class LivesyncCommand implements ICommand {
1313
this.$logger.warn('This command is deprecated. It will be removed in the next version of NativeScript CLI. Use "$ tns run" command instead.');
1414
}
1515

16-
await this.$platformService.deployPlatform(args[0]);
16+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
17+
const deployOptions: IDeployPlatformOptions = {
18+
clean: this.$options.clean,
19+
device: this.$options.device,
20+
emulator: this.$options.emulator,
21+
projectDir: this.$options.path,
22+
platformTemplate: this.$options.platformTemplate,
23+
release: this.$options.release
24+
};
25+
26+
await this.$platformService.deployPlatform(args[0], appFilesUpdaterOptions, deployOptions);
1727
return this.$usbLiveSyncService.liveSync(args[0]);
1828
}
1929

@@ -26,7 +36,7 @@ export class LivesyncCommand implements ICommand {
2636
if (platform) {
2737
return _.includes(this.$mobileHelper.platformNames, this.$mobileHelper.normalizePlatformName(platform)) && await this.$platformService.validateOptions(args[0]);
2838
} else {
29-
return await this.$platformService.validateOptions();
39+
return await this.$platformService.validateOptions(this.$options.provision);
3040
}
3141
}
3242
}

lib/commands/platform-clean.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
export class CleanCommand implements ICommand {
22
public allowedParameters: ICommandParameter[] = [];
33

4-
constructor(private $platformService: IPlatformService,
4+
constructor(private $options: IOptions,
5+
private $platformService: IPlatformService,
56
private $errors: IErrors) { }
67

78
public async execute(args: string[]): Promise<void> {
89
this.$platformService.removePlatforms(args);
9-
await this.$platformService.addPlatforms(args);
10+
await this.$platformService.addPlatforms(args, this.$options.platformTemplate);
1011
}
1112

1213
public async canExecute(args: string[]): Promise<boolean> {

lib/commands/prepare.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
export class PrepareCommand implements ICommand {
22
public allowedParameters = [this.$platformCommandParameter];
33

4-
constructor(private $platformService: IPlatformService,
4+
constructor(private $options: IOptions,
5+
private $platformService: IPlatformService,
56
private $platformCommandParameter: ICommandParameter) { }
67

78
public async execute(args: string[]): Promise<void> {
8-
await this.$platformService.preparePlatform(args[0]);
9+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
10+
await this.$platformService.preparePlatform(args[0], appFilesUpdaterOptions, this.$options.platformTemplate);
911
}
1012

1113
public async canExecute(args: string[]): Promise<boolean> {

lib/commands/run.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,29 @@ export class RunCommandBase {
44
protected $options: IOptions) { }
55

66
public async executeCore(args: string[]): Promise<void> {
7-
await this.$platformService.deployPlatform(args[0]);
7+
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
8+
const deployOptions: IDeployPlatformOptions = {
9+
clean: this.$options.clean,
10+
device: this.$options.device,
11+
emulator: this.$options.emulator,
12+
projectDir: this.$options.path,
13+
platformTemplate: this.$options.platformTemplate,
14+
release: this.$options.release
15+
};
16+
await this.$platformService.deployPlatform(args[0], appFilesUpdaterOptions, deployOptions);
817

918
if (this.$options.bundle) {
1019
this.$options.watch = false;
1120
}
1221

1322
if (this.$options.release) {
14-
return this.$platformService.runPlatform(args[0]);
23+
const deployOptions: IRunPlatformOptions = {
24+
device: this.$options.device,
25+
emulator: this.$options.emulator,
26+
justlaunch: this.$options.justlaunch,
27+
}
28+
29+
return this.$platformService.runPlatform(args[0], deployOptions);
1530
}
1631

1732
return this.$usbLiveSyncService.liveSync(args[0]);

lib/commands/update-platform.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
export class UpdatePlatformCommand implements ICommand {
22
public allowedParameters: ICommandParameter[] = [];
33

4-
constructor(private $platformService: IPlatformService,
4+
constructor(private $options: IOptions,
5+
private $platformService: IPlatformService,
56
private $errors: IErrors) { }
67

78
public async execute(args: string[]): Promise<void> {
8-
await this.$platformService.updatePlatforms(args);
9+
await this.$platformService.updatePlatforms(args, this.$options.platformTemplate);
910
}
1011

1112
public async canExecute(args: string[]): Promise<boolean> {

lib/commands/update.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import * as shelljs from "shelljs";
44
export class UpdateCommand implements ICommand {
55
public allowedParameters: ICommandParameter[] = [];
66

7-
constructor(private $projectData: IProjectData,
7+
constructor(private $options: IOptions,
8+
private $projectData: IProjectData,
89
private $platformService: IPlatformService,
910
private $platformsData: IPlatformsData,
1011
private $pluginsService: IPluginsService,
@@ -81,12 +82,12 @@ export class UpdateCommand implements ICommand {
8182
platforms = platforms.concat(packagePlatforms);
8283
if (args.length === 1) {
8384
for (let platform of platforms) {
84-
await this.$platformService.addPlatforms([platform + "@" + args[0]]);
85+
await this.$platformService.addPlatforms([platform + "@" + args[0]], this.$options.platformTemplate);
8586
}
8687

8788
await this.$pluginsService.add("tns-core-modules@" + args[0]);
8889
} else {
89-
await this.$platformService.addPlatforms(platforms);
90+
await this.$platformService.addPlatforms(platforms, this.$options.platformTemplate);
9091
await this.$pluginsService.add("tns-core-modules");
9192
}
9293

0 commit comments

Comments
 (0)