-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathpreview.ts
40 lines (35 loc) · 1.46 KB
/
preview.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
export class PreviewCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
private static MIN_SUPPORTED_WEBPACK_VERSION = "0.17.0";
constructor(private $bundleValidatorHelper: IBundleValidatorHelper,
private $errors: IErrors,
private $liveSyncService: ILiveSyncService,
private $networkConnectivityValidator: INetworkConnectivityValidator,
private $projectData: IProjectData,
private $options: IOptions,
private $previewQrCodeService: IPreviewQrCodeService) { }
public async execute(): Promise<void> {
await this.$liveSyncService.liveSync([], {
syncToPreviewApp: true,
projectDir: this.$projectData.projectDir,
skipWatcher: !this.$options.watch,
watchAllFiles: this.$options.syncAllFiles,
clean: this.$options.clean,
bundle: !!this.$options.bundle,
release: this.$options.release,
env: this.$options.env,
timeout: this.$options.timeout,
useHotModuleReload: this.$options.hmr
});
await this.$previewQrCodeService.printLiveSyncQrCode({ useHotModuleReload: this.$options.hmr, link: this.$options.link });
}
public async canExecute(args: string[]): Promise<boolean> {
if (args && args.length) {
this.$errors.fail(`The arguments '${args.join(" ")}' are not valid for the preview command.`);
}
await this.$networkConnectivityValidator.validate();
this.$bundleValidatorHelper.validate(PreviewCommand.MIN_SUPPORTED_WEBPACK_VERSION);
return true;
}
}
$injector.registerCommand("preview", PreviewCommand);