Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/man_pages/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Command | Description
---|---
[create](project/creation/create.html) | Creates a new project for native development with NativeScript.
[clean](general/clean.html) | Cleans project artifacts.
[preview](project/testing/preview.html) | Generates a QR code that can be scanned by the NativeScript PlayGround app.
[platform add `<Platform>`](project/configuration/platform-add.html) | Configures the current project to target the selected platform.
[platform list](project/configuration/platform.html) | Lists all platforms that the project currently targets.
[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.
Expand Down
12 changes: 11 additions & 1 deletion lib/commands/create-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,17 @@ can skip this prompt next time using the --template option, or the --ng, --react
const { projectDir } = this.createdProjectData;
const relativePath = path.relative(process.cwd(), projectDir);
this.$logger.printMarkdown(
`Now you can navigate to your project with \`$ cd ${relativePath}\``
`Now you can navigate to your project with \`$ cd ${relativePath}\` and then:`
);
this.$logger.printMarkdown(
[
`- Run the project on iOS \`$ ns run ios\``,
`- Run the project on Android \`$ ns run android\``,
`- Debug the project on iOS \`$ ns debug ios\``,
`- Debug the project on Android \`$ ns debug android\``,
``,
`For more options consult the docs or run \`$ ns --help\``,
].join("\n")
);
// Commented as we may bring this back with a playground revision/rewrite
// this.$logger.printMarkdown(
Expand Down
132 changes: 72 additions & 60 deletions lib/commands/preview.ts
Original file line number Diff line number Diff line change
@@ -1,73 +1,85 @@
import { DEVICE_LOG_EVENT_NAME } from "../common/constants";
import { IProjectData } from "../definitions/project";
import { IMigrateController } from "../definitions/migrate";
import { INetworkConnectivityValidator, IOptions } from "../declarations";
import { ICommandParameter, ICommand } from "../common/definitions/commands";
import { IAnalyticsService, IErrors } from "../common/declarations";
import { ICleanupService } from "../definitions/cleanup-service";
import { IErrors } from "../common/declarations";
import { injector } from "../common/yok";

export class PreviewCommand implements ICommand {
public allowedParameters: ICommandParameter[] = [];
allowedParameters: ICommandParameter[] = [];

constructor(
private $analyticsService: IAnalyticsService,
private $errors: IErrors,
private $logger: ILogger,
private $migrateController: IMigrateController,
private $previewAppController: IPreviewAppController,
private $networkConnectivityValidator: INetworkConnectivityValidator,
private $projectData: IProjectData,
private $options: IOptions,
private $previewAppLogProvider: IPreviewAppLogProvider,
private $previewQrCodeService: IPreviewQrCodeService,
$cleanupService: ICleanupService
) {
this.$analyticsService.setShouldDispose(false);
$cleanupService.setShouldDispose(false);
}
constructor(private $errors: IErrors) {}

public async execute(): Promise<void> {
this.$previewAppLogProvider.on(
DEVICE_LOG_EVENT_NAME,
(deviceId: string, message: string) => {
this.$logger.info(message);
}
async execute(args: string[]): Promise<void> {
this.$errors.fail(
`The Preview service has been disabled until further notice.\n\n` +
`Configure local builds and use "ns run ${args.join(" ")}" instead.`
);

await this.$previewAppController.startPreview({
projectDir: this.$projectData.projectDir,
useHotModuleReload: this.$options.hmr,
env: this.$options.env,
});

await this.$previewQrCodeService.printLiveSyncQrCode({
projectDir: this.$projectData.projectDir,
useHotModuleReload: this.$options.hmr,
link: this.$options.link,
});
}

public async canExecute(args: string[]): Promise<boolean> {
if (args && args.length) {
this.$errors.failWithHelp(
`The ${args.length > 1 ? "arguments" : "argument"} '${args.join(
" "
)}' ${
args.length > 1 ? "are" : "is"
} not valid for the preview command.`
);
}

if (!this.$options.force) {
await this.$migrateController.validate({
projectDir: this.$projectData.projectDir,
platforms: [],
});
}

await this.$networkConnectivityValidator.validate();
async canExecute(args: string[]): Promise<boolean> {
return true;
}
}

// export class PreviewCommand implements ICommand {
// public allowedParameters: ICommandParameter[] = [];
//
// constructor(
// private $analyticsService: IAnalyticsService,
// private $errors: IErrors,
// private $logger: ILogger,
// private $migrateController: IMigrateController,
// private $previewAppController: IPreviewAppController,
// private $networkConnectivityValidator: INetworkConnectivityValidator,
// private $projectData: IProjectData,
// private $options: IOptions,
// private $previewAppLogProvider: IPreviewAppLogProvider,
// private $previewQrCodeService: IPreviewQrCodeService,
// $cleanupService: ICleanupService
// ) {
// this.$analyticsService.setShouldDispose(false);
// $cleanupService.setShouldDispose(false);
// }
//
// public async execute(): Promise<void> {
// this.$previewAppLogProvider.on(
// DEVICE_LOG_EVENT_NAME,
// (deviceId: string, message: string) => {
// this.$logger.info(message);
// }
// );
//
// await this.$previewAppController.startPreview({
// projectDir: this.$projectData.projectDir,
// useHotModuleReload: this.$options.hmr,
// env: this.$options.env,
// });
//
// await this.$previewQrCodeService.printLiveSyncQrCode({
// projectDir: this.$projectData.projectDir,
// useHotModuleReload: this.$options.hmr,
// link: this.$options.link,
// });
// }
//
// public async canExecute(args: string[]): Promise<boolean> {
// if (args && args.length) {
// this.$errors.failWithHelp(
// `The ${args.length > 1 ? "arguments" : "argument"} '${args.join(
// " "
// )}' ${
// args.length > 1 ? "are" : "is"
// } not valid for the preview command.`
// );
// }
//
// if (!this.$options.force) {
// await this.$migrateController.validate({
// projectDir: this.$projectData.projectDir,
// platforms: [],
// });
// }
//
// await this.$networkConnectivityValidator.validate();
// return true;
// }
// }
injector.registerCommand("preview", PreviewCommand);
1 change: 0 additions & 1 deletion lib/common/definitions/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ declare module Config {
ANALYTICS_INSTALLATION_ID_SETTING_NAME: string;
TRACK_FEATURE_USAGE_SETTING_NAME: string;
ERROR_REPORT_SETTING_NAME: string;
SYS_REQUIREMENTS_LINK: string;
version: string;
getAdbFilePath(): Promise<string>;
disableAnalytics?: boolean;
Expand Down
22 changes: 0 additions & 22 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,6 @@ export class StaticConfig implements IStaticConfig {
return true;
}

public get SYS_REQUIREMENTS_LINK(): string {
let linkToSysRequirements: string;
switch (process.platform) {
case "linux":
linkToSysRequirements =
"https://docs.nativescript.org/start/general-requirements#full-setup-requirements-linux";
break;
case "win32":
linkToSysRequirements =
"https://docs.nativescript.org/start/general-requirements#full-setup-requirements-windows";
break;
case "darwin":
linkToSysRequirements =
"https://docs.nativescript.org/start/general-requirements#full-setup-requirements-macos";
break;
default:
linkToSysRequirements = "";
}

return linkToSysRequirements;
}

public version = require("../package.json").version;

public get HTML_CLI_HELPERS_DIR(): string {
Expand Down
82 changes: 39 additions & 43 deletions lib/services/analytics/analytics-broker-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import * as fs from "fs";
import * as _ from "lodash";
import { AnalyticsBroker } from "./analytics-broker";
import { FileLogService } from "../../detached-processes/file-log-service";
import {
IAnalyticsBroker,
ITrackingInformation,
IPreviewAppTrackingInformation,
} from "./analytics";
import { IAnalyticsBroker, ITrackingInformation } from "./analytics";
import { injector } from "../../common/yok";
import { TrackingTypes } from "../../common/declarations";

Expand Down Expand Up @@ -56,43 +52,43 @@ const killCurrentProcessGracefully = () => {
process.exit();
};

const trackPreviewAppData = async (data: any) => {
const mobileHelper = injector.resolve<Mobile.IMobileHelper>("mobileHelper");
const devicesService = injector.resolve<Mobile.IDevicesService>(
"devicesService"
);
await devicesService.initialize({
platform: data.platform,
skipDeviceDetectionInterval: true,
skipEmulatorStart: true,
});

const devices = await devicesService.getDevicesForPlatform(data.platform);
_.each(devices, async (device: Mobile.IDevice) => {
try {
let previewAppFilePath = null;
if (mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {
previewAppFilePath = "/sdcard/org.nativescript.preview/device.json";
} else if (mobileHelper.isiOSPlatform(device.deviceInfo.platform)) {
previewAppFilePath = "Documents/device.json";
}

const previewAppFileContent = await device.fileSystem.getFileContent(
previewAppFilePath,
"org.nativescript.preview"
);
const previewAppDeviceId = JSON.parse(previewAppFileContent).id;
data.label += `_${previewAppDeviceId}`;

analyticsLoggingService.logData({
message: `analytics-broker-process will send the data from preview app: ${data}`,
});
await sendDataForTracking(data);
} catch (err) {
// ignore the error
}
});
};
// const trackPreviewAppData = async (data: any) => {
// const mobileHelper = injector.resolve<Mobile.IMobileHelper>("mobileHelper");
// const devicesService = injector.resolve<Mobile.IDevicesService>(
// "devicesService"
// );
// await devicesService.initialize({
// platform: data.platform,
// skipDeviceDetectionInterval: true,
// skipEmulatorStart: true,
// });
//
// const devices = await devicesService.getDevicesForPlatform(data.platform);
// _.each(devices, async (device: Mobile.IDevice) => {
// try {
// let previewAppFilePath = null;
// if (mobileHelper.isAndroidPlatform(device.deviceInfo.platform)) {
// previewAppFilePath = "/sdcard/org.nativescript.preview/device.json";
// } else if (mobileHelper.isiOSPlatform(device.deviceInfo.platform)) {
// previewAppFilePath = "Documents/device.json";
// }
//
// const previewAppFileContent = await device.fileSystem.getFileContent(
// previewAppFilePath,
// "org.nativescript.preview"
// );
// const previewAppDeviceId = JSON.parse(previewAppFileContent).id;
// data.label += `_${previewAppDeviceId}`;
//
// analyticsLoggingService.logData({
// message: `analytics-broker-process will send the data from preview app: ${data}`,
// });
// await sendDataForTracking(data);
// } catch (err) {
// // ignore the error
// }
// });
// };

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

if (data.type === TrackingTypes.PreviewAppData) {
await trackPreviewAppData(<IPreviewAppTrackingInformation>data);
// await trackPreviewAppData(<IPreviewAppTrackingInformation>data);
return;
}

Expand Down
38 changes: 19 additions & 19 deletions lib/services/analytics/analytics-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,25 +200,25 @@ export class AnalyticsService implements IAnalyticsService, IDisposable {
platform: string,
projectDir: string
): Promise<void> {
const customDimensions: IStringDictionary = {};
this.setProjectRelatedCustomDimensions(customDimensions, projectDir);

let label: string = "";
label = this.addDataToLabel(
label,
this.$mobileHelper.normalizePlatformName(platform)
);

const eventActionData = {
googleAnalyticsDataType: GoogleAnalyticsDataType.Event,
action: TrackActionNames.PreviewAppData,
platform,
label,
customDimensions,
type: TrackingTypes.PreviewAppData,
};

await this.trackInGoogleAnalytics(eventActionData);
// const customDimensions: IStringDictionary = {};
// this.setProjectRelatedCustomDimensions(customDimensions, projectDir);
//
// let label: string = "";
// label = this.addDataToLabel(
// label,
// this.$mobileHelper.normalizePlatformName(platform)
// );
//
// const eventActionData = {
// googleAnalyticsDataType: GoogleAnalyticsDataType.Event,
// action: TrackActionNames.PreviewAppData,
// platform,
// label,
// customDimensions,
// type: TrackingTypes.PreviewAppData,
// };
//
// await this.trackInGoogleAnalytics(eventActionData);
}

public async finishTracking(): Promise<void> {
Expand Down
Loading