@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.
Files changed (141) hide show
  1. package/README.md +47 -0
  2. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +87 -0
  3. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +661 -0
  4. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js.map +1 -0
  5. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -0
  6. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +33 -0
  7. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js.map +1 -0
  8. package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -0
  9. package/lib-commonjs/commands/codegenWindows/codegenWindows.js +206 -0
  10. package/lib-commonjs/commands/codegenWindows/codegenWindows.js.map +1 -0
  11. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -0
  12. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +23 -0
  13. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js.map +1 -0
  14. package/lib-commonjs/{config → commands/config}/configUtils.d.ts +123 -93
  15. package/lib-commonjs/commands/config/configUtils.js +381 -0
  16. package/lib-commonjs/commands/config/configUtils.js.map +1 -0
  17. package/lib-commonjs/{config → commands/config}/dependencyConfig.d.ts +37 -37
  18. package/lib-commonjs/commands/config/dependencyConfig.js +228 -0
  19. package/lib-commonjs/commands/config/dependencyConfig.js.map +1 -0
  20. package/lib-commonjs/{config → commands/config}/projectConfig.d.ts +27 -24
  21. package/lib-commonjs/{config → commands/config}/projectConfig.js +180 -120
  22. package/lib-commonjs/commands/config/projectConfig.js.map +1 -0
  23. package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -0
  24. package/lib-commonjs/commands/healthCheck/healthCheckList.js +21 -0
  25. package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -0
  26. package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -0
  27. package/lib-commonjs/commands/healthCheck/healthChecks.js +124 -0
  28. package/lib-commonjs/commands/healthCheck/healthChecks.js.map +1 -0
  29. package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -0
  30. package/lib-commonjs/commands/initWindows/initWindows.js +244 -0
  31. package/lib-commonjs/commands/initWindows/initWindows.js.map +1 -0
  32. package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -0
  33. package/lib-commonjs/commands/initWindows/initWindowsOptions.js +38 -0
  34. package/lib-commonjs/commands/initWindows/initWindowsOptions.js.map +1 -0
  35. package/lib-commonjs/{runWindows → commands/runWindows}/runWindows.d.ts +10 -10
  36. package/lib-commonjs/commands/runWindows/runWindows.js +322 -0
  37. package/lib-commonjs/commands/runWindows/runWindows.js.map +1 -0
  38. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.d.ts +56 -52
  39. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.js +132 -131
  40. package/lib-commonjs/commands/runWindows/runWindowsOptions.js.map +1 -0
  41. package/lib-commonjs/e2etest/autolink.test.d.ts +6 -0
  42. package/lib-commonjs/e2etest/autolink.test.js +367 -0
  43. package/lib-commonjs/e2etest/autolink.test.js.map +1 -0
  44. package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -0
  45. package/lib-commonjs/e2etest/dependencyConfig.test.js +130 -0
  46. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -0
  47. package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -0
  48. package/lib-commonjs/e2etest/healthChecks.test.js +31 -0
  49. package/lib-commonjs/e2etest/healthChecks.test.js.map +1 -0
  50. package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -0
  51. package/lib-commonjs/e2etest/initWindows.test.js +43 -0
  52. package/lib-commonjs/e2etest/initWindows.test.js.map +1 -0
  53. package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -0
  54. package/lib-commonjs/e2etest/projectConfig.test.js +111 -0
  55. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -0
  56. package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -0
  57. package/lib-commonjs/e2etest/projectConfig.utils.js +77 -0
  58. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -0
  59. package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -0
  60. package/lib-commonjs/e2etest/runWindows.test.js +61 -0
  61. package/lib-commonjs/e2etest/runWindows.test.js.map +1 -0
  62. package/lib-commonjs/e2etest/typesUpToDate.test.d.ts +6 -0
  63. package/lib-commonjs/e2etest/typesUpToDate.test.js +21 -0
  64. package/lib-commonjs/e2etest/typesUpToDate.test.js.map +1 -0
  65. package/lib-commonjs/generator-common/index.d.ts +39 -23
  66. package/lib-commonjs/generator-common/index.js +242 -221
  67. package/lib-commonjs/generator-common/index.js.map +1 -1
  68. package/lib-commonjs/generator-windows/index.d.ts +10 -10
  69. package/lib-commonjs/generator-windows/index.js +316 -352
  70. package/lib-commonjs/generator-windows/index.js.map +1 -1
  71. package/lib-commonjs/index.d.ts +50 -46
  72. package/lib-commonjs/index.js +77 -39
  73. package/lib-commonjs/index.js.map +1 -1
  74. package/lib-commonjs/{runWindows/utils → utils}/build.d.ts +12 -13
  75. package/lib-commonjs/{runWindows/utils → utils}/build.js +84 -91
  76. package/lib-commonjs/utils/build.js.map +1 -0
  77. package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.d.ts +6 -6
  78. package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.js +69 -65
  79. package/lib-commonjs/utils/checkRequirements.js.map +1 -0
  80. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.d.ts +21 -13
  81. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.js +149 -113
  82. package/lib-commonjs/utils/commandWithProgress.js.map +1 -0
  83. package/lib-commonjs/{runWindows/utils → utils}/deploy.d.ts +12 -12
  84. package/lib-commonjs/utils/deploy.js +354 -0
  85. package/lib-commonjs/utils/deploy.js.map +1 -0
  86. package/lib-commonjs/{runWindows/utils → utils}/info.d.ts +6 -6
  87. package/lib-commonjs/{runWindows/utils → utils}/info.js +28 -25
  88. package/lib-commonjs/utils/info.js.map +1 -0
  89. package/lib-commonjs/utils/msbuildtools.d.ts +28 -0
  90. package/lib-commonjs/utils/msbuildtools.js +274 -0
  91. package/lib-commonjs/utils/msbuildtools.js.map +1 -0
  92. package/lib-commonjs/utils/pathHelpers.d.ts +9 -0
  93. package/lib-commonjs/utils/pathHelpers.js +37 -0
  94. package/lib-commonjs/utils/pathHelpers.js.map +1 -0
  95. package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -0
  96. package/lib-commonjs/utils/telemetryHelpers.js +121 -0
  97. package/lib-commonjs/utils/telemetryHelpers.js.map +1 -0
  98. package/lib-commonjs/{runWindows/utils → utils}/version.d.ts +19 -19
  99. package/lib-commonjs/{runWindows/utils → utils}/version.js +109 -109
  100. package/lib-commonjs/utils/version.js.map +1 -0
  101. package/lib-commonjs/{runWindows/utils → utils}/vsInstalls.d.ts +34 -34
  102. package/lib-commonjs/utils/vsInstalls.js +100 -0
  103. package/lib-commonjs/utils/vsInstalls.js.map +1 -0
  104. package/lib-commonjs/{runWindows/utils → utils}/vstools.d.ts +16 -15
  105. package/lib-commonjs/utils/vstools.js +190 -0
  106. package/lib-commonjs/utils/vstools.js.map +1 -0
  107. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.d.ts +24 -24
  108. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.js +108 -105
  109. package/lib-commonjs/utils/winappdeploytool.js.map +1 -0
  110. package/package.json +50 -30
  111. package/{powershell → src/powershell}/Add-AppDevPackage.ps1 +2 -2
  112. package/src/powershell/Eval-MsBuildProperties.ps1 +156 -0
  113. package/{powershell → src/powershell}/WindowsStoreAppUtils.ps1 +10 -0
  114. package/CHANGELOG.json +0 -317
  115. package/CHANGELOG.md +0 -159
  116. package/lib-commonjs/config/configUtils.js +0 -253
  117. package/lib-commonjs/config/configUtils.js.map +0 -1
  118. package/lib-commonjs/config/dependencyConfig.js +0 -167
  119. package/lib-commonjs/config/dependencyConfig.js.map +0 -1
  120. package/lib-commonjs/config/projectConfig.js.map +0 -1
  121. package/lib-commonjs/runWindows/runWindows.js +0 -159
  122. package/lib-commonjs/runWindows/runWindows.js.map +0 -1
  123. package/lib-commonjs/runWindows/runWindowsOptions.js.map +0 -1
  124. package/lib-commonjs/runWindows/utils/autolink.d.ts +0 -7
  125. package/lib-commonjs/runWindows/utils/autolink.js +0 -353
  126. package/lib-commonjs/runWindows/utils/autolink.js.map +0 -1
  127. package/lib-commonjs/runWindows/utils/build.js.map +0 -1
  128. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +0 -1
  129. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +0 -1
  130. package/lib-commonjs/runWindows/utils/deploy.js +0 -247
  131. package/lib-commonjs/runWindows/utils/deploy.js.map +0 -1
  132. package/lib-commonjs/runWindows/utils/info.js.map +0 -1
  133. package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +0 -22
  134. package/lib-commonjs/runWindows/utils/msbuildtools.js +0 -195
  135. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +0 -1
  136. package/lib-commonjs/runWindows/utils/version.js.map +0 -1
  137. package/lib-commonjs/runWindows/utils/vsInstalls.js +0 -70
  138. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +0 -1
  139. package/lib-commonjs/runWindows/utils/vstools.js +0 -150
  140. package/lib-commonjs/runWindows/utils/vstools.js.map +0 -1
  141. 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
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.isWinSdkPresent = void 0;
9
- const child_process_1 = require("child_process");
10
- const path = require("path");
11
- const shell = require("shelljs");
12
- const version_1 = require("./version");
13
- const REQUIRED_VERSIONS = {
14
- '10.0': {
15
- os: new version_1.default(6, 3),
16
- msbuild: new version_1.default(14, 0),
17
- visualstudio: new version_1.default(14, 0),
18
- windowssdk: new version_1.default(10, 0),
19
- phonesdk: new version_1.default(10, 0),
20
- },
21
- };
22
- function shortenVersion(version) {
23
- return /^(\d+(?:\.\d+)?)/.exec(version.toString())[1];
24
- }
25
- function getMinimalRequiredVersionFor(requirement, windowsTargetVersion) {
26
- return REQUIRED_VERSIONS[windowsTargetVersion][requirement];
27
- }
28
- function getInstalledWindowsSdks() {
29
- const installedSdks = [];
30
- const execString = 'reg query "HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows" /s /v InstallationFolder /reg:32';
31
- let output;
32
- try {
33
- output = child_process_1.execSync(execString).toString();
34
- }
35
- catch (e) {
36
- return installedSdks;
37
- }
38
- const re = /\\Microsoft SDKs\\Windows\\v(\d+\.\d+)\s*InstallationFolder\s+REG_SZ\s+(.*)/gim;
39
- let match;
40
- while ((match = re.exec(output))) {
41
- const sdkPath = match[2];
42
- if (shell.test('-e', path.join(sdkPath, 'SDKManifest.xml'))) {
43
- const sdkVersion = version_1.default.tryParse(match[1]);
44
- if (!sdkVersion) {
45
- throw new Error(`Unexpected SDK version format for '${match[1]}'`);
46
- }
47
- installedSdks.push(sdkVersion);
48
- }
49
- }
50
- return installedSdks;
51
- }
52
- function checkWinSdk(windowsTargetVersion) {
53
- const installedSdks = getInstalledWindowsSdks();
54
- const requiredVersion = getMinimalRequiredVersionFor('windowssdk', windowsTargetVersion);
55
- const hasSdkInstalled = installedSdks.some(installedSdk => installedSdk.eq(requiredVersion));
56
- if (hasSdkInstalled) {
57
- return shortenVersion(requiredVersion);
58
- }
59
- const shortenedVersion = shortenVersion(requiredVersion);
60
- throw new Error(`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`);
61
- }
62
- function isWinSdkPresent(target) {
63
- return checkWinSdk(target);
64
- }
65
- exports.isWinSdkPresent = isWinSdkPresent;
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,C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,MAAM,aAAa,GAAG,uBAAuB,EAAE,CAAC;IAChD,MAAM,eAAe,GAAG,4BAA4B,CAClD,YAAY,EACZ,oBAAoB,CACrB,CAAC;IACF,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CACxD,YAAY,CAAC,EAAE,CAAC,eAAe,CAAC,CACjC,CAAC;IAEF,IAAI,eAAe,EAAE;QACnB,OAAO,cAAc,CAAC,eAAe,CAAC,CAAC;KACxC;IAED,MAAM,gBAAgB,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;IACzD,MAAM,IAAI,sBAAU,CAClB,OAAO,EACP,iEAAiE,gBAAgB,oDAAoD,gBAAgB,8DAA8D,CACpN,CAAC;AACJ,CAAC;AAED,SAAgB,eAAe,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 * as ora from 'ora';
7
- export declare function newSpinner(text: string): ora.Ora;
8
- export declare function runPowerShellScriptFunction(taskDescription: string, script: string | null, funcName: string, verbose: boolean): Promise<void>;
9
- export declare function commandWithProgress(spinner: ora.Ora, taskDoingName: string, command: string, args: string[], verbose: boolean): Promise<unknown>;
10
- export declare function newError(text: string): void;
11
- export declare function newWarn(text: string): void;
12
- export declare function newSuccess(text: string): void;
13
- export declare function newInfo(text: string): void;
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
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.newInfo = exports.newSuccess = exports.newWarn = exports.newError = exports.commandWithProgress = exports.runPowerShellScriptFunction = exports.newSpinner = void 0;
9
- const child_process_1 = require("child_process");
10
- const ora = require("ora");
11
- const spinners = require("cli-spinners");
12
- const chalk = require("chalk");
13
- function setSpinnerText(spinner, prefix, text) {
14
- text = prefix + spinnerString(text);
15
- spinner.text = text.length > 45 ? text.slice(0, 110) + '...' : text;
16
- }
17
- function spinnerString(msg) {
18
- msg = msg.trim();
19
- const lastLineIndex = msg.lastIndexOf('\n');
20
- if (lastLineIndex > 0) {
21
- msg = msg.slice(lastLineIndex + 1);
22
- }
23
- msg = msg.trim();
24
- return msg;
25
- }
26
- function newSpinner(text) {
27
- const options = Object.assign(Object.assign({ text: text, indent: 1 }, (process.env.WT_SESSION && { spinner: spinners.dots })), {
28
- // By default, ora process.stderr as the output stream, however,the VS Code debugger
29
- // Uses stdout to match success patterns
30
- stream: process.stdout });
31
- return ora(options).start();
32
- }
33
- exports.newSpinner = newSpinner;
34
- async function runPowerShellScriptFunction(taskDescription, script, funcName, verbose) {
35
- try {
36
- const printException = verbose ? '$_;' : '';
37
- const importScript = script ? `Import-Module "${script}"; ` : '';
38
- await commandWithProgress(newSpinner(taskDescription), taskDescription, 'powershell', [
39
- '-NoProfile',
40
- '-ExecutionPolicy',
41
- 'RemoteSigned',
42
- `${importScript}try { ${funcName} -ErrorAction Stop; $lec = $LASTEXITCODE; } catch { $lec = 1; ${printException} }; exit $lec`,
43
- ], verbose);
44
- }
45
- catch (_a) {
46
- // The error output from the process will be shown if verbose is set.
47
- // We don't capture the process output if verbose is set, but at least we have the task name in text, so throw that.
48
- throw new Error(taskDescription);
49
- }
50
- }
51
- exports.runPowerShellScriptFunction = runPowerShellScriptFunction;
52
- function commandWithProgress(spinner, taskDoingName, command, args, verbose) {
53
- return new Promise(function (resolve, reject) {
54
- const spawnOptions = verbose ? { stdio: 'inherit' } : {};
55
- if (verbose) {
56
- spinner.stop();
57
- }
58
- const cp = child_process_1.spawn(command, args, spawnOptions);
59
- let firstErrorLine = null;
60
- if (!verbose) {
61
- cp.stdout.on('data', chunk => {
62
- const text = chunk.toString();
63
- setSpinnerText(spinner, taskDoingName + ': ', text);
64
- });
65
- cp.stderr.on('data', chunk => {
66
- const text = chunk.toString();
67
- if (!firstErrorLine) {
68
- firstErrorLine = text;
69
- }
70
- if (verbose) {
71
- console.error(chalk.red(text));
72
- }
73
- if (text) {
74
- setSpinnerText(spinner, taskDoingName + ': ERROR: ', firstErrorLine);
75
- }
76
- reject(new Error(firstErrorLine));
77
- });
78
- }
79
- cp.on('error', e => {
80
- if (verbose) {
81
- console.error(chalk.red(e.toString()));
82
- }
83
- spinner.fail(e.toString());
84
- reject(e);
85
- }).on('close', function (code) {
86
- if (code === 0) {
87
- spinner.succeed(taskDoingName);
88
- resolve();
89
- }
90
- else {
91
- spinner.fail();
92
- reject();
93
- }
94
- });
95
- });
96
- }
97
- exports.commandWithProgress = commandWithProgress;
98
- function newError(text) {
99
- newSpinner(text).fail(text);
100
- }
101
- exports.newError = newError;
102
- function newWarn(text) {
103
- newSpinner(text).warn(text);
104
- }
105
- exports.newWarn = newWarn;
106
- function newSuccess(text) {
107
- newSpinner(text).succeed(text);
108
- }
109
- exports.newSuccess = newSuccess;
110
- function newInfo(text) {
111
- newSpinner(text).info(text);
112
- }
113
- exports.newInfo = newInfo;
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;Q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I,gBAAgB,EAAE;YACpB,OAAO,CAAC,GAAG,CACT,6BAA6B,eAAK,CAAC,IAAI,CAAC,SAAS,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>;