Skip to content

Commit c61edbe

Browse files
authored
chore: disable preview (#5559)
* chore: disable preview * chore: cleanup * feat: better post-creation message
1 parent 9f844ea commit c61edbe

File tree

9 files changed

+480
-479
lines changed

9 files changed

+480
-479
lines changed

docs/man_pages/start.md

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Command | Description
3030
---|---
3131
[create](project/creation/create.html) | Creates a new project for native development with NativeScript.
3232
[clean](general/clean.html) | Cleans project artifacts.
33-
[preview](project/testing/preview.html) | Generates a QR code that can be scanned by the NativeScript PlayGround app.
3433
[platform add `<Platform>`](project/configuration/platform-add.html) | Configures the current project to target the selected platform.
3534
[platform list](project/configuration/platform.html) | Lists all platforms that the project currently targets.
3635
[platform remove `<Platform>`](project/configuration/platform-remove.html) | Removes the selected platform from the platforms that the project currently targets. This operation deletes all platform-specific files and subdirectories from your project.

lib/commands/create-project.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,17 @@ can skip this prompt next time using the --template option, or the --ng, --react
343343
const { projectDir } = this.createdProjectData;
344344
const relativePath = path.relative(process.cwd(), projectDir);
345345
this.$logger.printMarkdown(
346-
`Now you can navigate to your project with \`$ cd ${relativePath}\``
346+
`Now you can navigate to your project with \`$ cd ${relativePath}\` and then:`
347+
);
348+
this.$logger.printMarkdown(
349+
[
350+
`- Run the project on iOS \`$ ns run ios\``,
351+
`- Run the project on Android \`$ ns run android\``,
352+
`- Debug the project on iOS \`$ ns debug ios\``,
353+
`- Debug the project on Android \`$ ns debug android\``,
354+
``,
355+
`For more options consult the docs or run \`$ ns --help\``,
356+
].join("\n")
347357
);
348358
// Commented as we may bring this back with a playground revision/rewrite
349359
// this.$logger.printMarkdown(

lib/commands/preview.ts

+72-60
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,85 @@
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";
51
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";
83
import { injector } from "../common/yok";
94

105
export class PreviewCommand implements ICommand {
11-
public allowedParameters: ICommandParameter[] = [];
6+
allowedParameters: ICommandParameter[] = [];
127

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) {}
299

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.`
3614
);
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-
});
4915
}
5016

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> {
7018
return true;
7119
}
7220
}
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+
// }
7385
injector.registerCommand("preview", PreviewCommand);

lib/common/definitions/config.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ declare module Config {
99
ANALYTICS_INSTALLATION_ID_SETTING_NAME: string;
1010
TRACK_FEATURE_USAGE_SETTING_NAME: string;
1111
ERROR_REPORT_SETTING_NAME: string;
12-
SYS_REQUIREMENTS_LINK: string;
1312
version: string;
1413
getAdbFilePath(): Promise<string>;
1514
disableAnalytics?: boolean;

lib/config.ts

-22
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,6 @@ export class StaticConfig implements IStaticConfig {
6161
return true;
6262
}
6363

64-
public get SYS_REQUIREMENTS_LINK(): string {
65-
let linkToSysRequirements: string;
66-
switch (process.platform) {
67-
case "linux":
68-
linkToSysRequirements =
69-
"https://docs.nativescript.org/start/general-requirements#full-setup-requirements-linux";
70-
break;
71-
case "win32":
72-
linkToSysRequirements =
73-
"https://docs.nativescript.org/start/general-requirements#full-setup-requirements-windows";
74-
break;
75-
case "darwin":
76-
linkToSysRequirements =
77-
"https://docs.nativescript.org/start/general-requirements#full-setup-requirements-macos";
78-
break;
79-
default:
80-
linkToSysRequirements = "";
81-
}
82-
83-
return linkToSysRequirements;
84-
}
85-
8664
public version = require("../package.json").version;
8765

8866
public get HTML_CLI_HELPERS_DIR(): string {

lib/services/analytics/analytics-broker-process.ts

+39-43
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import * as fs from "fs";
44
import * as _ from "lodash";
55
import { AnalyticsBroker } from "./analytics-broker";
66
import { FileLogService } from "../../detached-processes/file-log-service";
7-
import {
8-
IAnalyticsBroker,
9-
ITrackingInformation,
10-
IPreviewAppTrackingInformation,
11-
} from "./analytics";
7+
import { IAnalyticsBroker, ITrackingInformation } from "./analytics";
128
import { injector } from "../../common/yok";
139
import { TrackingTypes } from "../../common/declarations";
1410

@@ -56,43 +52,43 @@ const killCurrentProcessGracefully = () => {
5652
process.exit();
5753
};
5854

59-
const trackPreviewAppData = async (data: any) => {
60-
const mobileHelper = injector.resolve<Mobile.IMobileHelper>("mobileHelper");
61-
const devicesService = injector.resolve<Mobile.IDevicesService>(
62-
"devicesService"
63-
);
64-
await devicesService.initialize({
65-
platform: data.platform,
66-
skipDeviceDetectionInterval: true,
67-
skipEmulatorStart: true,
68-
});
69-
70-
const devices = await devicesService.getDevicesForPlatform(data.platform);
71-
_.each(devices, async (device: Mobile.IDevice) => {
72-
try {
73-
let previewAppFilePath = null;
74-
if (mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {
75-
previewAppFilePath = "/sdcard/org.nativescript.preview/device.json";
76-
} else if (mobileHelper.isiOSPlatform(device.deviceInfo.platform)) {
77-
previewAppFilePath = "Documents/device.json";
78-
}
79-
80-
const previewAppFileContent = await device.fileSystem.getFileContent(
81-
previewAppFilePath,
82-
"org.nativescript.preview"
83-
);
84-
const previewAppDeviceId = JSON.parse(previewAppFileContent).id;
85-
data.label += `_${previewAppDeviceId}`;
86-
87-
analyticsLoggingService.logData({
88-
message: `analytics-broker-process will send the data from preview app: ${data}`,
89-
});
90-
await sendDataForTracking(data);
91-
} catch (err) {
92-
// ignore the error
93-
}
94-
});
95-
};
55+
// const trackPreviewAppData = async (data: any) => {
56+
// const mobileHelper = injector.resolve<Mobile.IMobileHelper>("mobileHelper");
57+
// const devicesService = injector.resolve<Mobile.IDevicesService>(
58+
// "devicesService"
59+
// );
60+
// await devicesService.initialize({
61+
// platform: data.platform,
62+
// skipDeviceDetectionInterval: true,
63+
// skipEmulatorStart: true,
64+
// });
65+
//
66+
// const devices = await devicesService.getDevicesForPlatform(data.platform);
67+
// _.each(devices, async (device: Mobile.IDevice) => {
68+
// try {
69+
// let previewAppFilePath = null;
70+
// if (mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {
71+
// previewAppFilePath = "/sdcard/org.nativescript.preview/device.json";
72+
// } else if (mobileHelper.isiOSPlatform(device.deviceInfo.platform)) {
73+
// previewAppFilePath = "Documents/device.json";
74+
// }
75+
//
76+
// const previewAppFileContent = await device.fileSystem.getFileContent(
77+
// previewAppFilePath,
78+
// "org.nativescript.preview"
79+
// );
80+
// const previewAppDeviceId = JSON.parse(previewAppFileContent).id;
81+
// data.label += `_${previewAppDeviceId}`;
82+
//
83+
// analyticsLoggingService.logData({
84+
// message: `analytics-broker-process will send the data from preview app: ${data}`,
85+
// });
86+
// await sendDataForTracking(data);
87+
// } catch (err) {
88+
// // ignore the error
89+
// }
90+
// });
91+
// };
9692

9793
process.on("message", async (data: ITrackingInformation) => {
9894
analyticsLoggingService.logData({
@@ -102,7 +98,7 @@ process.on("message", async (data: ITrackingInformation) => {
10298
});
10399

104100
if (data.type === TrackingTypes.PreviewAppData) {
105-
await trackPreviewAppData(<IPreviewAppTrackingInformation>data);
101+
// await trackPreviewAppData(<IPreviewAppTrackingInformation>data);
106102
return;
107103
}
108104

lib/services/analytics/analytics-service.ts

+19-19
Original file line numberDiff line numberDiff line change
@@ -200,25 +200,25 @@ export class AnalyticsService implements IAnalyticsService, IDisposable {
200200
platform: string,
201201
projectDir: string
202202
): Promise<void> {
203-
const customDimensions: IStringDictionary = {};
204-
this.setProjectRelatedCustomDimensions(customDimensions, projectDir);
205-
206-
let label: string = "";
207-
label = this.addDataToLabel(
208-
label,
209-
this.$mobileHelper.normalizePlatformName(platform)
210-
);
211-
212-
const eventActionData = {
213-
googleAnalyticsDataType: GoogleAnalyticsDataType.Event,
214-
action: TrackActionNames.PreviewAppData,
215-
platform,
216-
label,
217-
customDimensions,
218-
type: TrackingTypes.PreviewAppData,
219-
};
220-
221-
await this.trackInGoogleAnalytics(eventActionData);
203+
// const customDimensions: IStringDictionary = {};
204+
// this.setProjectRelatedCustomDimensions(customDimensions, projectDir);
205+
//
206+
// let label: string = "";
207+
// label = this.addDataToLabel(
208+
// label,
209+
// this.$mobileHelper.normalizePlatformName(platform)
210+
// );
211+
//
212+
// const eventActionData = {
213+
// googleAnalyticsDataType: GoogleAnalyticsDataType.Event,
214+
// action: TrackActionNames.PreviewAppData,
215+
// platform,
216+
// label,
217+
// customDimensions,
218+
// type: TrackingTypes.PreviewAppData,
219+
// };
220+
//
221+
// await this.trackInGoogleAnalytics(eventActionData);
222222
}
223223

224224
public async finishTracking(): Promise<void> {

0 commit comments

Comments
 (0)