@react-native-windows/cli 0.0.0-canary.21 → 0.0.0-canary.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +87 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +661 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js.map +1 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +33 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js.map +1 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindows.js +206 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindows.js.map +1 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +23 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js.map +1 -0
- package/lib-commonjs/{config → commands/config}/configUtils.d.ts +123 -93
- package/lib-commonjs/commands/config/configUtils.js +381 -0
- package/lib-commonjs/commands/config/configUtils.js.map +1 -0
- package/lib-commonjs/{config → commands/config}/dependencyConfig.d.ts +37 -37
- package/lib-commonjs/commands/config/dependencyConfig.js +228 -0
- package/lib-commonjs/commands/config/dependencyConfig.js.map +1 -0
- package/lib-commonjs/{config → commands/config}/projectConfig.d.ts +27 -24
- package/lib-commonjs/{config → commands/config}/projectConfig.js +180 -120
- package/lib-commonjs/commands/config/projectConfig.js.map +1 -0
- package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -0
- package/lib-commonjs/commands/healthCheck/healthCheckList.js +21 -0
- package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -0
- package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -0
- package/lib-commonjs/commands/healthCheck/healthChecks.js +124 -0
- package/lib-commonjs/commands/healthCheck/healthChecks.js.map +1 -0
- package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -0
- package/lib-commonjs/commands/initWindows/initWindows.js +244 -0
- package/lib-commonjs/commands/initWindows/initWindows.js.map +1 -0
- package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -0
- package/lib-commonjs/commands/initWindows/initWindowsOptions.js +38 -0
- package/lib-commonjs/commands/initWindows/initWindowsOptions.js.map +1 -0
- package/lib-commonjs/{runWindows → commands/runWindows}/runWindows.d.ts +10 -10
- package/lib-commonjs/commands/runWindows/runWindows.js +322 -0
- package/lib-commonjs/commands/runWindows/runWindows.js.map +1 -0
- package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.d.ts +56 -52
- package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.js +132 -131
- package/lib-commonjs/commands/runWindows/runWindowsOptions.js.map +1 -0
- package/lib-commonjs/e2etest/autolink.test.d.ts +6 -0
- package/lib-commonjs/e2etest/autolink.test.js +367 -0
- package/lib-commonjs/e2etest/autolink.test.js.map +1 -0
- package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -0
- package/lib-commonjs/e2etest/dependencyConfig.test.js +130 -0
- package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -0
- package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -0
- package/lib-commonjs/e2etest/healthChecks.test.js +31 -0
- package/lib-commonjs/e2etest/healthChecks.test.js.map +1 -0
- package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -0
- package/lib-commonjs/e2etest/initWindows.test.js +43 -0
- package/lib-commonjs/e2etest/initWindows.test.js.map +1 -0
- package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -0
- package/lib-commonjs/e2etest/projectConfig.test.js +111 -0
- package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -0
- package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -0
- package/lib-commonjs/e2etest/projectConfig.utils.js +77 -0
- package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -0
- package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -0
- package/lib-commonjs/e2etest/runWindows.test.js +61 -0
- package/lib-commonjs/e2etest/runWindows.test.js.map +1 -0
- package/lib-commonjs/e2etest/typesUpToDate.test.d.ts +6 -0
- package/lib-commonjs/e2etest/typesUpToDate.test.js +21 -0
- package/lib-commonjs/e2etest/typesUpToDate.test.js.map +1 -0
- package/lib-commonjs/generator-common/index.d.ts +39 -23
- package/lib-commonjs/generator-common/index.js +242 -221
- package/lib-commonjs/generator-common/index.js.map +1 -1
- package/lib-commonjs/generator-windows/index.d.ts +10 -10
- package/lib-commonjs/generator-windows/index.js +316 -352
- package/lib-commonjs/generator-windows/index.js.map +1 -1
- package/lib-commonjs/index.d.ts +50 -46
- package/lib-commonjs/index.js +77 -39
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/{runWindows/utils → utils}/build.d.ts +12 -13
- package/lib-commonjs/{runWindows/utils → utils}/build.js +84 -91
- package/lib-commonjs/utils/build.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.d.ts +6 -6
- package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.js +69 -65
- package/lib-commonjs/utils/checkRequirements.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.d.ts +21 -13
- package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.js +149 -113
- package/lib-commonjs/utils/commandWithProgress.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/deploy.d.ts +12 -12
- package/lib-commonjs/utils/deploy.js +354 -0
- package/lib-commonjs/utils/deploy.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/info.d.ts +6 -6
- package/lib-commonjs/{runWindows/utils → utils}/info.js +28 -25
- package/lib-commonjs/utils/info.js.map +1 -0
- package/lib-commonjs/utils/msbuildtools.d.ts +28 -0
- package/lib-commonjs/utils/msbuildtools.js +274 -0
- package/lib-commonjs/utils/msbuildtools.js.map +1 -0
- package/lib-commonjs/utils/pathHelpers.d.ts +9 -0
- package/lib-commonjs/utils/pathHelpers.js +37 -0
- package/lib-commonjs/utils/pathHelpers.js.map +1 -0
- package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -0
- package/lib-commonjs/utils/telemetryHelpers.js +121 -0
- package/lib-commonjs/utils/telemetryHelpers.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/version.d.ts +19 -19
- package/lib-commonjs/{runWindows/utils → utils}/version.js +109 -109
- package/lib-commonjs/utils/version.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/vsInstalls.d.ts +34 -34
- package/lib-commonjs/utils/vsInstalls.js +100 -0
- package/lib-commonjs/utils/vsInstalls.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/vstools.d.ts +16 -15
- package/lib-commonjs/utils/vstools.js +190 -0
- package/lib-commonjs/utils/vstools.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.d.ts +24 -24
- package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.js +108 -105
- package/lib-commonjs/utils/winappdeploytool.js.map +1 -0
- package/package.json +50 -30
- package/{powershell → src/powershell}/Add-AppDevPackage.ps1 +2 -2
- package/src/powershell/Eval-MsBuildProperties.ps1 +156 -0
- package/{powershell → src/powershell}/WindowsStoreAppUtils.ps1 +10 -0
- package/CHANGELOG.json +0 -317
- package/CHANGELOG.md +0 -159
- package/lib-commonjs/config/configUtils.js +0 -253
- package/lib-commonjs/config/configUtils.js.map +0 -1
- package/lib-commonjs/config/dependencyConfig.js +0 -167
- package/lib-commonjs/config/dependencyConfig.js.map +0 -1
- package/lib-commonjs/config/projectConfig.js.map +0 -1
- package/lib-commonjs/runWindows/runWindows.js +0 -159
- package/lib-commonjs/runWindows/runWindows.js.map +0 -1
- package/lib-commonjs/runWindows/runWindowsOptions.js.map +0 -1
- package/lib-commonjs/runWindows/utils/autolink.d.ts +0 -7
- package/lib-commonjs/runWindows/utils/autolink.js +0 -353
- package/lib-commonjs/runWindows/utils/autolink.js.map +0 -1
- package/lib-commonjs/runWindows/utils/build.js.map +0 -1
- package/lib-commonjs/runWindows/utils/checkRequirements.js.map +0 -1
- package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +0 -1
- package/lib-commonjs/runWindows/utils/deploy.js +0 -247
- package/lib-commonjs/runWindows/utils/deploy.js.map +0 -1
- package/lib-commonjs/runWindows/utils/info.js.map +0 -1
- package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +0 -22
- package/lib-commonjs/runWindows/utils/msbuildtools.js +0 -195
- package/lib-commonjs/runWindows/utils/msbuildtools.js.map +0 -1
- package/lib-commonjs/runWindows/utils/version.js.map +0 -1
- package/lib-commonjs/runWindows/utils/vsInstalls.js +0 -70
- package/lib-commonjs/runWindows/utils/vsInstalls.js.map +0 -1
- package/lib-commonjs/runWindows/utils/vstools.js +0 -150
- package/lib-commonjs/runWindows/utils/vstools.js.map +0 -1
- package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +0 -1
|
@@ -1,66 +1,70 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Microsoft Corporation.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.isWinSdkPresent = void 0;
|
|
12
|
+
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const shelljs_1 = __importDefault(require("shelljs"));
|
|
16
|
+
const version_1 = __importDefault(require("./version"));
|
|
17
|
+
const REQUIRED_VERSIONS = {
|
|
18
|
+
'10.0': {
|
|
19
|
+
os: new version_1.default(6, 3),
|
|
20
|
+
msbuild: new version_1.default(14, 0),
|
|
21
|
+
visualstudio: new version_1.default(14, 0),
|
|
22
|
+
windowssdk: new version_1.default(10, 0),
|
|
23
|
+
phonesdk: new version_1.default(10, 0),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
function shortenVersion(version) {
|
|
27
|
+
return /^(\d+(?:\.\d+)?)/.exec(version.toString())[1];
|
|
28
|
+
}
|
|
29
|
+
function getMinimalRequiredVersionFor(requirement, windowsTargetVersion) {
|
|
30
|
+
return REQUIRED_VERSIONS[windowsTargetVersion][requirement];
|
|
31
|
+
}
|
|
32
|
+
function getInstalledWindowsSdks() {
|
|
33
|
+
const installedSdks = [];
|
|
34
|
+
const execString = 'reg query "HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows" /s /v InstallationFolder /reg:32';
|
|
35
|
+
let output;
|
|
36
|
+
try {
|
|
37
|
+
output = (0, child_process_1.execSync)(execString).toString();
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return installedSdks;
|
|
41
|
+
}
|
|
42
|
+
const re = /\\Microsoft SDKs\\Windows\\v(\d+\.\d+)\s*InstallationFolder\s+REG_SZ\s+(.*)/gim;
|
|
43
|
+
let match;
|
|
44
|
+
while ((match = re.exec(output))) {
|
|
45
|
+
const sdkPath = match[2];
|
|
46
|
+
if (shelljs_1.default.test('-e', path_1.default.join(sdkPath, 'SDKManifest.xml'))) {
|
|
47
|
+
const sdkVersion = version_1.default.tryParse(match[1]);
|
|
48
|
+
if (!sdkVersion) {
|
|
49
|
+
throw new telemetry_1.CodedError('BadSDKVersionFormat', `Unexpected SDK version format for '${match[1]}'`);
|
|
50
|
+
}
|
|
51
|
+
installedSdks.push(sdkVersion);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return installedSdks;
|
|
55
|
+
}
|
|
56
|
+
function checkWinSdk(windowsTargetVersion) {
|
|
57
|
+
const installedSdks = getInstalledWindowsSdks();
|
|
58
|
+
const requiredVersion = getMinimalRequiredVersionFor('windowssdk', windowsTargetVersion);
|
|
59
|
+
const hasSdkInstalled = installedSdks.some(installedSdk => installedSdk.eq(requiredVersion));
|
|
60
|
+
if (hasSdkInstalled) {
|
|
61
|
+
return shortenVersion(requiredVersion);
|
|
62
|
+
}
|
|
63
|
+
const shortenedVersion = shortenVersion(requiredVersion);
|
|
64
|
+
throw new telemetry_1.CodedError('NoSDK', `Windows SDK not found. Ensure that you have installed Windows ${shortenedVersion} SDK along with Visual Studio or install Windows ${shortenedVersion} SDK separately from https://dev.windows.com/en-us/downloads`);
|
|
65
|
+
}
|
|
66
|
+
function isWinSdkPresent(target) {
|
|
67
|
+
return checkWinSdk(target);
|
|
68
|
+
}
|
|
69
|
+
exports.isWinSdkPresent = isWinSdkPresent;
|
|
66
70
|
//# sourceMappingURL=checkRequirements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkRequirements.js","sourceRoot":"","sources":["../../src/utils/checkRequirements.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,+DAA2D;AAC3D,iDAAuC;AACvC,gDAAwB;AACxB,sDAA4B;AAC5B,wDAAgC;AAShC,MAAM,iBAAiB,GAAiD;IACtE,MAAM,EAAE;QACN,EAAE,EAAE,IAAI,iBAAO,CAAC,CAAC,EAAE,CAAC,CAAC;QACrB,OAAO,EAAE,IAAI,iBAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3B,YAAY,EAAE,IAAI,iBAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QAChC,UAAU,EAAE,IAAI,iBAAO,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9B,QAAQ,EAAE,IAAI,iBAAO,CAAC,EAAE,EAAE,CAAC,CAAC;KAC7B;CACF,CAAC;AAEF,SAAS,cAAc,CAAC,OAAgB;IACtC,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAE,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,4BAA4B,CACnC,WAAwB,EACxB,oBAAoD;IAEpD,OAAO,iBAAiB,CAAC,oBAAoB,CAAC,CAAC,WAAW,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,uBAAuB;IAC9B,MAAM,aAAa,GAAc,EAAE,CAAC;IAEpC,MAAM,UAAU,GACd,iGAAiG,CAAC;IACpG,IAAI,MAAc,CAAC;IACnB,IAAI;QACF,MAAM,GAAG,IAAA,wBAAQ,EAAC,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AAe,CAAC,MAAc;IAC5C,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC;AAFD,0CAEC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CodedError} from '@react-native-windows/telemetry';\nimport {execSync} from 'child_process';\nimport path from 'path';\nimport shell from 'shelljs';\nimport Version from './version';\n\ntype Requirement =\n | 'os'\n | 'msbuild'\n | 'visualstudio'\n | 'windowssdk'\n | 'phonesdk';\n\nconst REQUIRED_VERSIONS: Record<string, Record<Requirement, Version>> = {\n '10.0': {\n os: new Version(6, 3),\n msbuild: new Version(14, 0),\n visualstudio: new Version(14, 0),\n windowssdk: new Version(10, 0),\n phonesdk: new Version(10, 0),\n },\n};\n\nfunction shortenVersion(version: Version): string {\n return /^(\\d+(?:\\.\\d+)?)/.exec(version.toString())![1];\n}\n\nfunction getMinimalRequiredVersionFor(\n requirement: Requirement,\n windowsTargetVersion: keyof typeof REQUIRED_VERSIONS,\n): Version {\n return REQUIRED_VERSIONS[windowsTargetVersion][requirement];\n}\n\nfunction getInstalledWindowsSdks(): Version[] {\n const installedSdks: Version[] = [];\n\n const execString =\n 'reg query \"HKLM\\\\SOFTWARE\\\\Microsoft\\\\Microsoft SDKs\\\\Windows\" /s /v InstallationFolder /reg:32';\n let output: string;\n try {\n output = execSync(execString).toString();\n } catch (e) {\n return installedSdks;\n }\n\n const re =\n /\\\\Microsoft SDKs\\\\Windows\\\\v(\\d+\\.\\d+)\\s*InstallationFolder\\s+REG_SZ\\s+(.*)/gim;\n let match: RegExpExecArray | null;\n while ((match = re.exec(output))) {\n const sdkPath = match[2];\n if (shell.test('-e', path.join(sdkPath, 'SDKManifest.xml'))) {\n const sdkVersion = Version.tryParse(match[1]);\n if (!sdkVersion) {\n throw new CodedError(\n 'BadSDKVersionFormat',\n `Unexpected SDK version format for '${match[1]}'`,\n );\n }\n installedSdks.push(sdkVersion);\n }\n }\n\n return installedSdks;\n}\n\nfunction checkWinSdk(windowsTargetVersion: string): string {\n const installedSdks = getInstalledWindowsSdks();\n const requiredVersion = getMinimalRequiredVersionFor(\n 'windowssdk',\n windowsTargetVersion,\n );\n const hasSdkInstalled = installedSdks.some(installedSdk =>\n installedSdk.eq(requiredVersion),\n );\n\n if (hasSdkInstalled) {\n return shortenVersion(requiredVersion);\n }\n\n const shortenedVersion = shortenVersion(requiredVersion);\n throw new CodedError(\n 'NoSDK',\n `Windows SDK not found. Ensure that you have installed Windows ${shortenedVersion} SDK along with Visual Studio or install Windows ${shortenedVersion} SDK separately from https://dev.windows.com/en-us/downloads`,\n );\n}\n\nexport function isWinSdkPresent(target: string): string {\n return checkWinSdk(target);\n}\n"]}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
* @format
|
|
5
|
-
*/
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
export declare function
|
|
9
|
-
export declare
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
import ora from 'ora';
|
|
7
|
+
import { CodedErrorType } from '@react-native-windows/telemetry';
|
|
8
|
+
export declare function newSpinner(text: string): ora.Ora;
|
|
9
|
+
export declare const powershell: string;
|
|
10
|
+
export declare function runPowerShellScriptFunction(taskDescription: string, script: string | null, funcName: string, verbose: boolean, errorCategory: CodedErrorType): Promise<void>;
|
|
11
|
+
export declare function commandWithProgress(spinner: ora.Ora, taskDoingName: string, command: string, args: string[], verbose: boolean, errorCategory: CodedErrorType): Promise<void>;
|
|
12
|
+
export declare function newError(text: string): void;
|
|
13
|
+
export declare function newWarn(text: string): void;
|
|
14
|
+
export declare function newSuccess(text: string): void;
|
|
15
|
+
export declare function newInfo(text: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Sets the process exit code and offers some information at the end of a CLI command.
|
|
18
|
+
* @param loggingIsEnabled Is verbose logging enabled.
|
|
19
|
+
* @param error The error caught during the process, if any.
|
|
20
|
+
*/
|
|
21
|
+
export declare function setExitProcessWithError(loggingIsEnabled?: boolean, error?: Error): void;
|
|
@@ -1,114 +1,150 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Microsoft Corporation.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.setExitProcessWithError = exports.newInfo = exports.newSuccess = exports.newWarn = exports.newError = exports.commandWithProgress = exports.runPowerShellScriptFunction = exports.powershell = exports.newSpinner = void 0;
|
|
12
|
+
const child_process_1 = require("child_process");
|
|
13
|
+
const ora_1 = __importDefault(require("ora"));
|
|
14
|
+
const cli_spinners_1 = __importDefault(require("cli-spinners"));
|
|
15
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
16
|
+
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
17
|
+
function setSpinnerText(spinner, prefix, text) {
|
|
18
|
+
text = prefix + spinnerString(text);
|
|
19
|
+
spinner.text = text.length > 45 ? text.slice(0, 110) + '...' : text;
|
|
20
|
+
}
|
|
21
|
+
function spinnerString(msg) {
|
|
22
|
+
msg = msg.trim();
|
|
23
|
+
const lastLineIndex = msg.lastIndexOf('\n');
|
|
24
|
+
if (lastLineIndex > 0) {
|
|
25
|
+
msg = msg.slice(lastLineIndex + 1);
|
|
26
|
+
}
|
|
27
|
+
msg = msg.trim();
|
|
28
|
+
return msg;
|
|
29
|
+
}
|
|
30
|
+
function newSpinner(text) {
|
|
31
|
+
const options = {
|
|
32
|
+
text: text,
|
|
33
|
+
indent: 1,
|
|
34
|
+
// ora turns off emoji rendering by default on windows, since the default terminal
|
|
35
|
+
// doesn't render them. Turn them back on when running in the new windows terminal
|
|
36
|
+
...(process.env.WT_SESSION && { spinner: cli_spinners_1.default.dots }),
|
|
37
|
+
// By default, ora process.stderr as the output stream, however,the VS Code debugger
|
|
38
|
+
// Uses stdout to match success patterns
|
|
39
|
+
stream: process.stdout,
|
|
40
|
+
};
|
|
41
|
+
return (0, ora_1.default)(options).start();
|
|
42
|
+
}
|
|
43
|
+
exports.newSpinner = newSpinner;
|
|
44
|
+
exports.powershell = `${process.env.SystemRoot}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
45
|
+
async function runPowerShellScriptFunction(taskDescription, script, funcName, verbose, errorCategory) {
|
|
46
|
+
try {
|
|
47
|
+
const printException = verbose ? '$_;' : '';
|
|
48
|
+
const importScript = script ? `Import-Module "${script}"; ` : '';
|
|
49
|
+
await commandWithProgress(newSpinner(taskDescription), taskDescription, exports.powershell, [
|
|
50
|
+
'-NoProfile',
|
|
51
|
+
'-ExecutionPolicy',
|
|
52
|
+
'RemoteSigned',
|
|
53
|
+
`${importScript}try { ${funcName} -ErrorAction Stop; $lec = $LASTEXITCODE; } catch { $lec = 1; ${printException} }; exit $lec`,
|
|
54
|
+
], verbose, errorCategory);
|
|
55
|
+
}
|
|
56
|
+
catch (_a) {
|
|
57
|
+
// The error output from the process will be shown if verbose is set.
|
|
58
|
+
// We don't capture the process output if verbose is set, but at least we have the task name in text, so throw that.
|
|
59
|
+
throw new telemetry_1.CodedError(errorCategory, taskDescription);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.runPowerShellScriptFunction = runPowerShellScriptFunction;
|
|
63
|
+
function commandWithProgress(spinner, taskDoingName, command, args, verbose, errorCategory) {
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
const spawnOptions = verbose ? { stdio: 'inherit' } : {};
|
|
66
|
+
if (verbose) {
|
|
67
|
+
spinner.stop();
|
|
68
|
+
}
|
|
69
|
+
const cp = (0, child_process_1.spawn)(command, args, spawnOptions);
|
|
70
|
+
let firstErrorLine = null;
|
|
71
|
+
if (!verbose) {
|
|
72
|
+
cp.stdout.on('data', chunk => {
|
|
73
|
+
const text = chunk.toString();
|
|
74
|
+
setSpinnerText(spinner, taskDoingName + ': ', text);
|
|
75
|
+
});
|
|
76
|
+
cp.stderr.on('data', chunk => {
|
|
77
|
+
const text = chunk.toString();
|
|
78
|
+
if (!firstErrorLine) {
|
|
79
|
+
firstErrorLine = text;
|
|
80
|
+
}
|
|
81
|
+
if (text) {
|
|
82
|
+
setSpinnerText(spinner, taskDoingName + ': ERROR: ', firstErrorLine);
|
|
83
|
+
}
|
|
84
|
+
reject(new telemetry_1.CodedError(errorCategory, firstErrorLine, {
|
|
85
|
+
taskName: taskDoingName,
|
|
86
|
+
}));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
cp.on('error', e => {
|
|
90
|
+
if (verbose) {
|
|
91
|
+
console.error(chalk_1.default.red(e.toString()));
|
|
92
|
+
}
|
|
93
|
+
spinner.fail(e.toString());
|
|
94
|
+
const ce = new telemetry_1.CodedError(errorCategory, e.message);
|
|
95
|
+
ce.stack = e.stack;
|
|
96
|
+
reject(ce);
|
|
97
|
+
}).on('close', code => {
|
|
98
|
+
if (code === 0) {
|
|
99
|
+
spinner.succeed(taskDoingName);
|
|
100
|
+
resolve();
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
spinner.fail();
|
|
104
|
+
reject(new telemetry_1.CodedError(errorCategory, `${taskDoingName} - exit error code ${code}`, {
|
|
105
|
+
taskName: taskDoingName,
|
|
106
|
+
taskExitCode: code,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
exports.commandWithProgress = commandWithProgress;
|
|
113
|
+
function newError(text) {
|
|
114
|
+
newSpinner(text).fail(text);
|
|
115
|
+
}
|
|
116
|
+
exports.newError = newError;
|
|
117
|
+
function newWarn(text) {
|
|
118
|
+
newSpinner(text).warn(text);
|
|
119
|
+
}
|
|
120
|
+
exports.newWarn = newWarn;
|
|
121
|
+
function newSuccess(text) {
|
|
122
|
+
newSpinner(text).succeed(text);
|
|
123
|
+
}
|
|
124
|
+
exports.newSuccess = newSuccess;
|
|
125
|
+
function newInfo(text) {
|
|
126
|
+
newSpinner(text).info(text);
|
|
127
|
+
}
|
|
128
|
+
exports.newInfo = newInfo;
|
|
129
|
+
/**
|
|
130
|
+
* Sets the process exit code and offers some information at the end of a CLI command.
|
|
131
|
+
* @param loggingIsEnabled Is verbose logging enabled.
|
|
132
|
+
* @param error The error caught during the process, if any.
|
|
133
|
+
*/
|
|
134
|
+
function setExitProcessWithError(loggingIsEnabled, error) {
|
|
135
|
+
if (error) {
|
|
136
|
+
const errorType = error instanceof telemetry_1.CodedError ? error.type : 'Unknown';
|
|
137
|
+
process.exitCode = telemetry_1.CodedErrors[errorType];
|
|
138
|
+
if (loggingIsEnabled) {
|
|
139
|
+
console.log(`Command failed with error ${chalk_1.default.bold(errorType)}: ${error.message}`);
|
|
140
|
+
if (telemetry_1.Telemetry.isEnabled()) {
|
|
141
|
+
console.log(`Your telemetry sessionId was ${chalk_1.default.bold(telemetry_1.Telemetry.getSessionId())}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
console.log(`Command failed. Re-run the command with ${chalk_1.default.bold('--logging')} for more information.`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.setExitProcessWithError = setExitProcessWithError;
|
|
114
150
|
//# sourceMappingURL=commandWithProgress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandWithProgress.js","sourceRoot":"","sources":["../../src/utils/commandWithProgress.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,iDAAkD;AAClD,8CAAsB;AACtB,gEAAoC;AACpC,kDAA0B;AAC1B,+DAKyC;AAEzC,SAAS,cAAc,CAAC,OAAgB,EAAE,MAAc,EAAE,IAAY;IACpE,IAAI,GAAG,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACpC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACjB,MAAM,aAAa,GAAG,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,aAAa,GAAG,CAAC,EAAE;QACrB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,CAAC,CAAC;KACpC;IACD,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACjB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,UAAU,CAAC,IAAY;IACrC,MAAM,OAAO,GAAgB;QAC3B,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,CAAC;QAET,kFAAkF;QAClF,mFAAmF;QACnF,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,EAAC,OAAO,EAAE,sBAAQ,CAAC,IAAI,EAAC,CAAC;QAEvD,oFAAoF;QACpF,wCAAwC;QACxC,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC;IAEF,O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CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CACvE,CAAC;YACF,IAAI,qBAAS,CAAC,SAAS,EAAE,EAAE;gBACzB,OAAO,CAAC,GAAG,CACT,gCAAgC,eAAK,CAAC,IAAI,CACxC,qBAAS,CAAC,YAAY,EAAE,CACzB,EAAE,CACJ,CAAC;aACH;SACF;aAAM;YACL,OAAO,CAAC,GAAG,CACT,2CAA2C,eAAK,CAAC,IAAI,CACnD,WAAW,CACZ,wBAAwB,CAC1B,CAAC;SACH;KACF;AACH,CAAC;AA7BD,0DA6BC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {spawn, SpawnOptions} from 'child_process';\nimport ora from 'ora';\nimport spinners from 'cli-spinners';\nimport chalk from 'chalk';\nimport {\n Telemetry,\n CodedError,\n CodedErrors,\n CodedErrorType,\n} from '@react-native-windows/telemetry';\n\nfunction setSpinnerText(spinner: ora.Ora, prefix: string, text: string) {\n text = prefix + spinnerString(text);\n spinner.text = text.length > 45 ? text.slice(0, 110) + '...' : text;\n}\n\nfunction spinnerString(msg: string) {\n msg = msg.trim();\n const lastLineIndex = msg.lastIndexOf('\\n');\n if (lastLineIndex > 0) {\n msg = msg.slice(lastLineIndex + 1);\n }\n msg = msg.trim();\n return msg;\n}\n\nexport function newSpinner(text: string) {\n const options: ora.Options = {\n text: text,\n indent: 1,\n\n // ora turns off emoji rendering by default on windows, since the default terminal\n // doesn't render them. Turn them back on when running in the new windows terminal\n ...(process.env.WT_SESSION && {spinner: spinners.dots}),\n\n // By default, ora process.stderr as the output stream, however,the VS Code debugger\n // Uses stdout to match success patterns\n stream: process.stdout,\n };\n\n return ora(options).start();\n}\n\nexport const powershell = `${process.env.SystemRoot}\\\\System32\\\\WindowsPowerShell\\\\v1.0\\\\powershell.exe`;\n\nexport async function runPowerShellScriptFunction(\n taskDescription: string,\n script: string | null,\n funcName: string,\n verbose: boolean,\n errorCategory: CodedErrorType,\n) {\n try {\n const printException = verbose ? '$_;' : '';\n const importScript = script ? `Import-Module \"${script}\"; ` : '';\n await commandWithProgress(\n newSpinner(taskDescription),\n taskDescription,\n powershell,\n [\n '-NoProfile',\n '-ExecutionPolicy',\n 'RemoteSigned',\n `${importScript}try { ${funcName} -ErrorAction Stop; $lec = $LASTEXITCODE; } catch { $lec = 1; ${printException} }; exit $lec`,\n ],\n verbose,\n errorCategory,\n );\n } catch {\n // The error output from the process will be shown if verbose is set.\n // We don't capture the process output if verbose is set, but at least we have the task name in text, so throw that.\n throw new CodedError(errorCategory, taskDescription);\n }\n}\n\nexport function commandWithProgress(\n spinner: ora.Ora,\n taskDoingName: string,\n command: string,\n args: string[],\n verbose: boolean,\n errorCategory: CodedErrorType,\n) {\n return new Promise<void>((resolve, reject) => {\n const spawnOptions: SpawnOptions = verbose ? {stdio: 'inherit'} : {};\n\n if (verbose) {\n spinner.stop();\n }\n\n const cp = spawn(command, args, spawnOptions);\n let firstErrorLine: string | null = null;\n if (!verbose) {\n cp.stdout!.on('data', chunk => {\n const text = chunk.toString();\n setSpinnerText(spinner, taskDoingName + ': ', text);\n });\n cp.stderr!.on('data', chunk => {\n const text: string = chunk.toString();\n if (!firstErrorLine) {\n firstErrorLine = text;\n }\n if (text) {\n setSpinnerText(spinner, taskDoingName + ': ERROR: ', firstErrorLine);\n }\n reject(\n new CodedError(errorCategory, firstErrorLine, {\n taskName: taskDoingName,\n }),\n );\n });\n }\n cp.on('error', e => {\n if (verbose) {\n console.error(chalk.red(e.toString()));\n }\n spinner.fail(e.toString());\n const ce = new CodedError(errorCategory, e.message);\n ce.stack = e.stack;\n reject(ce);\n }).on('close', code => {\n if (code === 0) {\n spinner.succeed(taskDoingName);\n resolve();\n } else {\n spinner.fail();\n reject(\n new CodedError(\n errorCategory,\n `${taskDoingName} - exit error code ${code}`,\n {\n taskName: taskDoingName,\n taskExitCode: code,\n },\n ),\n );\n }\n });\n });\n}\n\nexport function newError(text: string) {\n newSpinner(text).fail(text);\n}\n\nexport function newWarn(text: string) {\n newSpinner(text).warn(text);\n}\n\nexport function newSuccess(text: string) {\n newSpinner(text).succeed(text);\n}\n\nexport function newInfo(text: string) {\n newSpinner(text).info(text);\n}\n\n/**\n * Sets the process exit code and offers some information at the end of a CLI command.\n * @param loggingIsEnabled Is verbose logging enabled.\n * @param error The error caught during the process, if any.\n */\nexport function setExitProcessWithError(\n loggingIsEnabled?: boolean,\n error?: Error,\n): void {\n if (error) {\n const errorType =\n error instanceof CodedError ? (error as CodedError).type : 'Unknown';\n\n process.exitCode = CodedErrors[errorType];\n\n if (loggingIsEnabled) {\n console.log(\n `Command failed with error ${chalk.bold(errorType)}: ${error.message}`,\n );\n if (Telemetry.isEnabled()) {\n console.log(\n `Your telemetry sessionId was ${chalk.bold(\n Telemetry.getSessionId(),\n )}`,\n );\n }\n } else {\n console.log(\n `Command failed. Re-run the command with ${chalk.bold(\n '--logging',\n )} for more information.`,\n );\n }\n }\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
* @format
|
|
5
|
-
*/
|
|
6
|
-
import { BuildConfig, RunWindowsOptions } from '../runWindowsOptions';
|
|
7
|
-
import MSBuildTools from './msbuildtools';
|
|
8
|
-
import { Config } from '@react-native-community/cli-types';
|
|
9
|
-
export declare function getBuildConfiguration(options: RunWindowsOptions): BuildConfig;
|
|
10
|
-
export declare function deployToDevice(options: RunWindowsOptions, verbose: boolean): Promise<void>;
|
|
11
|
-
export declare function deployToDesktop(options: RunWindowsOptions, verbose: boolean, config: Config, buildTools: MSBuildTools): Promise<void>;
|
|
12
|
-
export declare function startServerInNewWindow(options: RunWindowsOptions, verbose: boolean): Promise<void>;
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
import { BuildConfig, RunWindowsOptions } from '../commands/runWindows/runWindowsOptions';
|
|
7
|
+
import MSBuildTools from './msbuildtools';
|
|
8
|
+
import { Config } from '@react-native-community/cli-types';
|
|
9
|
+
export declare function getBuildConfiguration(options: RunWindowsOptions): BuildConfig;
|
|
10
|
+
export declare function deployToDevice(options: RunWindowsOptions, verbose: boolean, config: Config): Promise<void>;
|
|
11
|
+
export declare function deployToDesktop(options: RunWindowsOptions, verbose: boolean, config: Config, buildTools: MSBuildTools): Promise<void>;
|
|
12
|
+
export declare function startServerInNewWindow(options: RunWindowsOptions, verbose: boolean): Promise<void>;
|