microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.14.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/windows/windowsPlatform.ts

81lines · modeblame

299883f9Artem Egorov8 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import * as Q from "q";
7bc455e9Artem Egorov8 years ago5import * as semver from "semver";
299883f9Artem Egorov8 years ago6
dd90a856Artem Egorov8 years ago7import {GeneralMobilePlatform, MobilePlatformDeps} from "../generalMobilePlatform";
299883f9Artem Egorov8 years ago8import {IWindowsRunOptions} from "../launchArgs";
9import {OutputVerifier, PatternToFailure} from "../../common/outputVerifier";
10import {TelemetryHelper} from "../../common/telemetryHelper";
11import {CommandExecutor} from "../../common/commandExecutor";
d7d405aeYuri Skorokhodov7 years ago12import { InternalErrorCode } from "../../common/error/internalErrorCode";
299883f9Artem Egorov8 years ago13
14/**
15* Windows specific platform implementation for debugging RN applications.
16*/
17export class WindowsPlatform extends GeneralMobilePlatform {
7bc455e9Artem Egorov8 years ago18protected static NO_PACKAGER_VERSION = "0.53.0";
299883f9Artem Egorov8 years ago19
20private static SUCCESS_PATTERNS = [
21"Installing new version of the app",
22"Starting the app",
23];
24private static FAILURE_PATTERNS: PatternToFailure[] = [
25{
26pattern: "Unrecognized command 'run-windows'",
d7d405aeYuri Skorokhodov7 years ago27errorCode: InternalErrorCode.WinRNMPPluginIsNotInstalled,
299883f9Artem Egorov8 years ago28},
29];
30
31constructor(protected runOptions: IWindowsRunOptions, platformDeps: MobilePlatformDeps = {}) {
32super(runOptions, platformDeps);
33}
34
35public runApp(enableDebug: boolean = true): Q.Promise<void> {
ba953e9fRedMickey6 years ago36let extProps = {
031832ffArtem Egorov8 years ago37platform: {
38value: "windows",
39isPii: false,
40},
41};
42
7fa90b3bRedMickey6 years ago43extProps = TelemetryHelper.addPropertyToTelemetryProperties(this.runOptions.reactNativeVersions.reactNativeVersion, "reactNativeVersion", extProps);
44extProps = TelemetryHelper.addPropertyToTelemetryProperties(this.runOptions.reactNativeVersions.reactNativeWindowsVersion, "reactNativeWindowsVersion", extProps);
ba953e9fRedMickey6 years ago45
031832ffArtem Egorov8 years ago46return TelemetryHelper.generate("WindowsPlatform.runApp", extProps, () => {
299883f9Artem Egorov8 years ago47const env = this.getEnvArgument();
48
49if (enableDebug) {
db6fd42aRuslan Bikkinin7 years ago50this.runArguments.push("--proxy");
299883f9Artem Egorov8 years ago51}
52
7fa90b3bRedMickey6 years ago53if (!semver.valid(this.runOptions.reactNativeVersions.reactNativeVersion) /*Custom RN implementations should support this flag*/ || semver.gte(this.runOptions.reactNativeVersions.reactNativeVersion, WindowsPlatform.NO_PACKAGER_VERSION)) {
54this.runArguments.push("--no-packager");
55}
299883f9Artem Egorov8 years ago56
7fa90b3bRedMickey6 years ago57const runWindowsSpawn = new CommandExecutor(this.projectPath, this.logger).spawnReactCommand(`run-${this.platformName}`, this.runArguments, {env});
58return new OutputVerifier(() => Q(WindowsPlatform.SUCCESS_PATTERNS), () => Q(WindowsPlatform.FAILURE_PATTERNS), this.platformName)
59.process(runWindowsSpawn);
299883f9Artem Egorov8 years ago60});
61}
62
63public prewarmBundleCache(): Q.Promise<void> {
64return this.packager.prewarmBundleCache("windows");
65}
66
cbc7ac5bArtem Egorov7 years ago67public getRunArguments(): string[] {
299883f9Artem Egorov8 years ago68let runArguments: string[] = [];
69
70if (this.runOptions.runArguments && this.runOptions.runArguments.length > 0) {
71runArguments.push(...this.runOptions.runArguments);
72} else {
dd90a856Artem Egorov8 years ago73let target = this.runOptions.target === WindowsPlatform.simulatorString ? "" : this.runOptions.target;
74if (target) {
75runArguments.push(`--${target}`);
299883f9Artem Egorov8 years ago76}
77}
78
79return runArguments;
80}
81}