-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathlivesync.ts
49 lines (42 loc) · 1.94 KB
/
livesync.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
export class LivesyncCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
constructor(private $usbLiveSyncService: ILiveSyncService,
private $mobileHelper: Mobile.IMobileHelper,
private $platformService: IPlatformService,
private $projectData: IProjectData,
private $errors: IErrors,
private $logger: ILogger,
private $options: IOptions) {
this.$projectData.initializeProjectData();
}
public async execute(args: string[]): Promise<void> {
if (!this.$options.help && args[0]) {
this.$logger.warn('This command is deprecated. It will be removed in the next version of NativeScript CLI. Use "$ tns run" command instead.');
}
const appFilesUpdaterOptions: IAppFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
const deployOptions: IDeployPlatformOptions = {
clean: this.$options.clean,
device: this.$options.device,
emulator: this.$options.emulator,
projectDir: this.$options.path,
platformTemplate: this.$options.platformTemplate,
release: this.$options.release,
provision: this.$options.provision,
teamId: this.$options.teamId
};
await this.$platformService.deployPlatform(args[0], appFilesUpdaterOptions, deployOptions, this.$projectData, { provision: this.$options.provision, sdk: this.$options.sdk });
return this.$usbLiveSyncService.liveSync(args[0], this.$projectData);
}
public async canExecute(args: string[]): Promise<boolean> {
if (args.length >= 2) {
this.$errors.fail("Invalid number of arguments.");
}
let platform = args[0];
if (platform) {
return _.includes(this.$mobileHelper.platformNames, this.$mobileHelper.normalizePlatformName(platform)) && await this.$platformService.validateOptions(this.$options.provision, this.$projectData, args[0]);
} else {
return await this.$platformService.validateOptions(this.$options.provision, this.$projectData);
}
}
}
$injector.registerCommand("livesync", LivesyncCommand);