@react-native-windows/cli 0.0.0-canary.99 → 0.0.1-0

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 (131) hide show
  1. package/README.md +0 -2
  2. package/lib-commonjs/{runWindows/utils/autolink.d.ts → commands/autolinkWindows/autolinkWindows.d.ts} +87 -86
  3. package/lib-commonjs/{runWindows/utils/autolink.js → commands/autolinkWindows/autolinkWindows.js} +655 -625
  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 -116
  15. package/lib-commonjs/{config → commands/config}/configUtils.js +380 -341
  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/{config → commands/config}/dependencyConfig.js +227 -221
  19. package/lib-commonjs/commands/config/dependencyConfig.js.map +1 -0
  20. package/lib-commonjs/{config → commands/config}/projectConfig.d.ts +27 -27
  21. package/lib-commonjs/{config → commands/config}/projectConfig.js +180 -176
  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/{healthChecks.d.ts → commands/healthCheck/healthChecks.d.ts} +7 -2
  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 -11
  36. package/lib-commonjs/{runWindows → commands/runWindows}/runWindows.js +321 -318
  37. package/lib-commonjs/commands/runWindows/runWindows.js.map +1 -0
  38. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.d.ts +56 -56
  39. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.js +132 -135
  40. package/lib-commonjs/commands/runWindows/runWindowsOptions.js.map +1 -0
  41. package/lib-commonjs/e2etest/autolink.test.d.ts +6 -6
  42. package/lib-commonjs/e2etest/autolink.test.js +366 -418
  43. package/lib-commonjs/e2etest/autolink.test.js.map +1 -1
  44. package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -6
  45. package/lib-commonjs/e2etest/dependencyConfig.test.js +129 -161
  46. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -1
  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 -6
  54. package/lib-commonjs/e2etest/projectConfig.test.js +110 -124
  55. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -1
  56. package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -4
  57. package/lib-commonjs/e2etest/projectConfig.utils.js +76 -62
  58. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -1
  59. package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -6
  60. package/lib-commonjs/e2etest/runWindows.test.js +60 -39
  61. package/lib-commonjs/e2etest/runWindows.test.js.map +1 -1
  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 -39
  66. package/lib-commonjs/generator-common/index.js +242 -242
  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 -369
  70. package/lib-commonjs/generator-windows/index.js.map +1 -1
  71. package/lib-commonjs/index.d.ts +50 -50
  72. package/lib-commonjs/index.js +77 -106
  73. package/lib-commonjs/index.js.map +1 -1
  74. package/lib-commonjs/{runWindows/utils → utils}/build.d.ts +12 -12
  75. package/lib-commonjs/{runWindows/utils → utils}/build.js +84 -84
  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 -69
  79. package/lib-commonjs/utils/checkRequirements.js.map +1 -0
  80. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.d.ts +21 -15
  81. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.js +149 -127
  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/{runWindows/utils → utils}/deploy.js +353 -328
  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 -28
  88. package/lib-commonjs/utils/info.js.map +1 -0
  89. package/lib-commonjs/{runWindows/utils → utils}/msbuildtools.d.ts +28 -26
  90. package/lib-commonjs/{runWindows/utils → utils}/msbuildtools.js +273 -219
  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/{runWindows/utils → utils}/vsInstalls.js +99 -73
  103. package/lib-commonjs/utils/vsInstalls.js.map +1 -0
  104. package/lib-commonjs/{runWindows/utils → utils}/vstools.d.ts +16 -16
  105. package/lib-commonjs/{runWindows/utils → utils}/vstools.js +189 -162
  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 -108
  109. package/lib-commonjs/utils/winappdeploytool.js.map +1 -0
  110. package/package.json +27 -20
  111. package/src/powershell/Eval-MsBuildProperties.ps1 +156 -0
  112. package/lib-commonjs/config/configUtils.js.map +0 -1
  113. package/lib-commonjs/config/dependencyConfig.js.map +0 -1
  114. package/lib-commonjs/config/projectConfig.js.map +0 -1
  115. package/lib-commonjs/healthChecks.js +0 -88
  116. package/lib-commonjs/healthChecks.js.map +0 -1
  117. package/lib-commonjs/runWindows/runWindows.js.map +0 -1
  118. package/lib-commonjs/runWindows/runWindowsOptions.js.map +0 -1
  119. package/lib-commonjs/runWindows/utils/autolink.js.map +0 -1
  120. package/lib-commonjs/runWindows/utils/build.js.map +0 -1
  121. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +0 -1
  122. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +0 -1
  123. package/lib-commonjs/runWindows/utils/deploy.js.map +0 -1
  124. package/lib-commonjs/runWindows/utils/info.js.map +0 -1
  125. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +0 -1
  126. package/lib-commonjs/runWindows/utils/version.js.map +0 -1
  127. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +0 -1
  128. package/lib-commonjs/runWindows/utils/vstools.js.map +0 -1
  129. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +0 -1
  130. /package/{powershell → src/powershell}/Add-AppDevPackage.ps1 +0 -0
  131. /package/{powershell → src/powershell}/WindowsStoreAppUtils.ps1 +0 -0
@@ -1,128 +1,150 @@
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.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} - error code ${code}`, {
105
- errorCode: code,
106
- }));
107
- }
108
- });
109
- });
110
- }
111
- exports.commandWithProgress = commandWithProgress;
112
- function newError(text) {
113
- newSpinner(text).fail(text);
114
- }
115
- exports.newError = newError;
116
- function newWarn(text) {
117
- newSpinner(text).warn(text);
118
- }
119
- exports.newWarn = newWarn;
120
- function newSuccess(text) {
121
- newSpinner(text).succeed(text);
122
- }
123
- exports.newSuccess = newSuccess;
124
- function newInfo(text) {
125
- newSpinner(text).info(text);
126
- }
127
- 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;
128
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,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CAAC;AAFD,4BAEC;AAED,SAAgB,OAAO,CAAC,IAAY;IAClC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAFD,0BAEC;AAED,SAAgB,UAAU,CAAC,IAAY;IACrC,UAAU,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAFD,gCAEC;AAED,SAAgB,OAAO,CAAC,IAAY;IAClC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAFD,0BAEC;AAED;;;;GAIG;AACH,SAAgB,uBAAuB,CACrC,gBAA0B,EAC1B,KAAa;IAEb,IAAI,KAAK,EAAE;QACT,MAAM,SAAS,GACb,KAAK,YAAY,sBAAU,CAAC,CAAC,CAAE,KAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QAEvE,OAAO,CAAC,QAAQ,GAAG,uBAAW,CAAC,SAAS,CAAC,CAAC;QAE1C,IAAI,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, 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>;
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>;