@react-native-windows/cli 0.73.1 → 0.74.0-preview.1

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 (76) hide show
  1. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +87 -87
  2. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +654 -654
  3. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -14
  4. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +32 -32
  5. package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -27
  6. package/lib-commonjs/commands/codegenWindows/codegenWindows.js +205 -205
  7. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -12
  8. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +22 -22
  9. package/lib-commonjs/commands/config/configUtils.d.ts +123 -123
  10. package/lib-commonjs/commands/config/configUtils.js +380 -380
  11. package/lib-commonjs/commands/config/dependencyConfig.d.ts +37 -37
  12. package/lib-commonjs/commands/config/dependencyConfig.js +227 -227
  13. package/lib-commonjs/commands/config/projectConfig.d.ts +27 -27
  14. package/lib-commonjs/commands/config/projectConfig.js +180 -180
  15. package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -6
  16. package/lib-commonjs/commands/healthCheck/healthCheckList.js +20 -20
  17. package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -1
  18. package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -7
  19. package/lib-commonjs/commands/healthCheck/healthChecks.js +123 -123
  20. package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -46
  21. package/lib-commonjs/commands/initWindows/initWindows.js +243 -243
  22. package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -15
  23. package/lib-commonjs/commands/initWindows/initWindowsOptions.js +37 -37
  24. package/lib-commonjs/commands/runWindows/runWindows.d.ts +10 -10
  25. package/lib-commonjs/commands/runWindows/runWindows.js +321 -321
  26. package/lib-commonjs/commands/runWindows/runWindowsOptions.d.ts +56 -56
  27. package/lib-commonjs/commands/runWindows/runWindowsOptions.js +132 -132
  28. package/lib-commonjs/e2etest/autolink.test.d.ts +6 -6
  29. package/lib-commonjs/e2etest/autolink.test.js +366 -366
  30. package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -6
  31. package/lib-commonjs/e2etest/dependencyConfig.test.js +129 -129
  32. package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -6
  33. package/lib-commonjs/e2etest/healthChecks.test.js +30 -30
  34. package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -6
  35. package/lib-commonjs/e2etest/initWindows.test.js +42 -42
  36. package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -6
  37. package/lib-commonjs/e2etest/projectConfig.test.js +110 -110
  38. package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -8
  39. package/lib-commonjs/e2etest/projectConfig.utils.js +76 -76
  40. package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -6
  41. package/lib-commonjs/e2etest/runWindows.test.js +60 -60
  42. package/lib-commonjs/e2etest/typesUpToDate.test.d.ts +6 -0
  43. package/lib-commonjs/e2etest/typesUpToDate.test.js +21 -0
  44. package/lib-commonjs/e2etest/typesUpToDate.test.js.map +1 -0
  45. package/lib-commonjs/generator-common/index.d.ts +39 -39
  46. package/lib-commonjs/generator-common/index.js +242 -242
  47. package/lib-commonjs/generator-windows/index.d.ts +10 -10
  48. package/lib-commonjs/generator-windows/index.js +316 -316
  49. package/lib-commonjs/index.d.ts +50 -50
  50. package/lib-commonjs/index.js +77 -77
  51. package/lib-commonjs/utils/build.d.ts +12 -12
  52. package/lib-commonjs/utils/build.js +84 -84
  53. package/lib-commonjs/utils/checkRequirements.d.ts +6 -6
  54. package/lib-commonjs/utils/checkRequirements.js +69 -69
  55. package/lib-commonjs/utils/commandWithProgress.d.ts +21 -21
  56. package/lib-commonjs/utils/commandWithProgress.js +149 -149
  57. package/lib-commonjs/utils/deploy.d.ts +12 -12
  58. package/lib-commonjs/utils/deploy.js +353 -353
  59. package/lib-commonjs/utils/info.d.ts +6 -6
  60. package/lib-commonjs/utils/info.js +28 -28
  61. package/lib-commonjs/utils/msbuildtools.d.ts +28 -28
  62. package/lib-commonjs/utils/msbuildtools.js +273 -273
  63. package/lib-commonjs/utils/msbuildtools.js.map +1 -1
  64. package/lib-commonjs/utils/pathHelpers.d.ts +9 -9
  65. package/lib-commonjs/utils/pathHelpers.js +36 -36
  66. package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -29
  67. package/lib-commonjs/utils/telemetryHelpers.js +120 -120
  68. package/lib-commonjs/utils/version.d.ts +19 -19
  69. package/lib-commonjs/utils/version.js +109 -109
  70. package/lib-commonjs/utils/vsInstalls.d.ts +34 -34
  71. package/lib-commonjs/utils/vsInstalls.js +99 -99
  72. package/lib-commonjs/utils/vstools.d.ts +16 -16
  73. package/lib-commonjs/utils/vstools.js +189 -189
  74. package/lib-commonjs/utils/winappdeploytool.d.ts +24 -24
  75. package/lib-commonjs/utils/winappdeploytool.js +108 -108
  76. package/package.json +16 -16
@@ -1,21 +1,21 @@
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
+ /**
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,150 +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.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;
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;
150
150
  //# sourceMappingURL=commandWithProgress.js.map
@@ -1,12 +1,12 @@
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>;
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>;