|
1 |
| -import { DEVICE_LOG_EVENT_NAME } from "../common/constants"; |
2 |
| -import { IProjectData } from "../definitions/project"; |
3 |
| -import { IMigrateController } from "../definitions/migrate"; |
4 |
| -import { INetworkConnectivityValidator, IOptions } from "../declarations"; |
5 | 1 | import { ICommandParameter, ICommand } from "../common/definitions/commands";
|
6 |
| -import { IAnalyticsService, IErrors } from "../common/declarations"; |
7 |
| -import { ICleanupService } from "../definitions/cleanup-service"; |
| 2 | +import { IErrors } from "../common/declarations"; |
8 | 3 | import { injector } from "../common/yok";
|
9 | 4 |
|
10 | 5 | export class PreviewCommand implements ICommand {
|
11 |
| - public allowedParameters: ICommandParameter[] = []; |
| 6 | + allowedParameters: ICommandParameter[] = []; |
12 | 7 |
|
13 |
| - constructor( |
14 |
| - private $analyticsService: IAnalyticsService, |
15 |
| - private $errors: IErrors, |
16 |
| - private $logger: ILogger, |
17 |
| - private $migrateController: IMigrateController, |
18 |
| - private $previewAppController: IPreviewAppController, |
19 |
| - private $networkConnectivityValidator: INetworkConnectivityValidator, |
20 |
| - private $projectData: IProjectData, |
21 |
| - private $options: IOptions, |
22 |
| - private $previewAppLogProvider: IPreviewAppLogProvider, |
23 |
| - private $previewQrCodeService: IPreviewQrCodeService, |
24 |
| - $cleanupService: ICleanupService |
25 |
| - ) { |
26 |
| - this.$analyticsService.setShouldDispose(false); |
27 |
| - $cleanupService.setShouldDispose(false); |
28 |
| - } |
| 8 | + constructor(private $errors: IErrors) {} |
29 | 9 |
|
30 |
| - public async execute(): Promise<void> { |
31 |
| - this.$previewAppLogProvider.on( |
32 |
| - DEVICE_LOG_EVENT_NAME, |
33 |
| - (deviceId: string, message: string) => { |
34 |
| - this.$logger.info(message); |
35 |
| - } |
| 10 | + async execute(args: string[]): Promise<void> { |
| 11 | + this.$errors.fail( |
| 12 | + `The Preview service has been disabled until further notice.\n\n` + |
| 13 | + `Configure local builds and use "ns run ${args.join(" ")}" instead.` |
36 | 14 | );
|
37 |
| - |
38 |
| - await this.$previewAppController.startPreview({ |
39 |
| - projectDir: this.$projectData.projectDir, |
40 |
| - useHotModuleReload: this.$options.hmr, |
41 |
| - env: this.$options.env, |
42 |
| - }); |
43 |
| - |
44 |
| - await this.$previewQrCodeService.printLiveSyncQrCode({ |
45 |
| - projectDir: this.$projectData.projectDir, |
46 |
| - useHotModuleReload: this.$options.hmr, |
47 |
| - link: this.$options.link, |
48 |
| - }); |
49 | 15 | }
|
50 | 16 |
|
51 |
| - public async canExecute(args: string[]): Promise<boolean> { |
52 |
| - if (args && args.length) { |
53 |
| - this.$errors.failWithHelp( |
54 |
| - `The ${args.length > 1 ? "arguments" : "argument"} '${args.join( |
55 |
| - " " |
56 |
| - )}' ${ |
57 |
| - args.length > 1 ? "are" : "is" |
58 |
| - } not valid for the preview command.` |
59 |
| - ); |
60 |
| - } |
61 |
| - |
62 |
| - if (!this.$options.force) { |
63 |
| - await this.$migrateController.validate({ |
64 |
| - projectDir: this.$projectData.projectDir, |
65 |
| - platforms: [], |
66 |
| - }); |
67 |
| - } |
68 |
| - |
69 |
| - await this.$networkConnectivityValidator.validate(); |
| 17 | + async canExecute(args: string[]): Promise<boolean> { |
70 | 18 | return true;
|
71 | 19 | }
|
72 | 20 | }
|
| 21 | + |
| 22 | +// export class PreviewCommand implements ICommand { |
| 23 | +// public allowedParameters: ICommandParameter[] = []; |
| 24 | +// |
| 25 | +// constructor( |
| 26 | +// private $analyticsService: IAnalyticsService, |
| 27 | +// private $errors: IErrors, |
| 28 | +// private $logger: ILogger, |
| 29 | +// private $migrateController: IMigrateController, |
| 30 | +// private $previewAppController: IPreviewAppController, |
| 31 | +// private $networkConnectivityValidator: INetworkConnectivityValidator, |
| 32 | +// private $projectData: IProjectData, |
| 33 | +// private $options: IOptions, |
| 34 | +// private $previewAppLogProvider: IPreviewAppLogProvider, |
| 35 | +// private $previewQrCodeService: IPreviewQrCodeService, |
| 36 | +// $cleanupService: ICleanupService |
| 37 | +// ) { |
| 38 | +// this.$analyticsService.setShouldDispose(false); |
| 39 | +// $cleanupService.setShouldDispose(false); |
| 40 | +// } |
| 41 | +// |
| 42 | +// public async execute(): Promise<void> { |
| 43 | +// this.$previewAppLogProvider.on( |
| 44 | +// DEVICE_LOG_EVENT_NAME, |
| 45 | +// (deviceId: string, message: string) => { |
| 46 | +// this.$logger.info(message); |
| 47 | +// } |
| 48 | +// ); |
| 49 | +// |
| 50 | +// await this.$previewAppController.startPreview({ |
| 51 | +// projectDir: this.$projectData.projectDir, |
| 52 | +// useHotModuleReload: this.$options.hmr, |
| 53 | +// env: this.$options.env, |
| 54 | +// }); |
| 55 | +// |
| 56 | +// await this.$previewQrCodeService.printLiveSyncQrCode({ |
| 57 | +// projectDir: this.$projectData.projectDir, |
| 58 | +// useHotModuleReload: this.$options.hmr, |
| 59 | +// link: this.$options.link, |
| 60 | +// }); |
| 61 | +// } |
| 62 | +// |
| 63 | +// public async canExecute(args: string[]): Promise<boolean> { |
| 64 | +// if (args && args.length) { |
| 65 | +// this.$errors.failWithHelp( |
| 66 | +// `The ${args.length > 1 ? "arguments" : "argument"} '${args.join( |
| 67 | +// " " |
| 68 | +// )}' ${ |
| 69 | +// args.length > 1 ? "are" : "is" |
| 70 | +// } not valid for the preview command.` |
| 71 | +// ); |
| 72 | +// } |
| 73 | +// |
| 74 | +// if (!this.$options.force) { |
| 75 | +// await this.$migrateController.validate({ |
| 76 | +// projectDir: this.$projectData.projectDir, |
| 77 | +// platforms: [], |
| 78 | +// }); |
| 79 | +// } |
| 80 | +// |
| 81 | +// await this.$networkConnectivityValidator.validate(); |
| 82 | +// return true; |
| 83 | +// } |
| 84 | +// } |
73 | 85 | injector.registerCommand("preview", PreviewCommand);
|
0 commit comments