@react-native-windows/cli 0.66.2 → 0.68.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 (62) hide show
  1. package/README.md +1 -1
  2. package/lib-commonjs/config/configUtils.js +1 -1
  3. package/lib-commonjs/config/configUtils.js.map +1 -1
  4. package/lib-commonjs/config/dependencyConfig.js +6 -4
  5. package/lib-commonjs/config/dependencyConfig.js.map +1 -1
  6. package/lib-commonjs/config/projectConfig.js +2 -2
  7. package/lib-commonjs/config/projectConfig.js.map +1 -1
  8. package/lib-commonjs/e2etest/autolink.test.d.ts +5 -0
  9. package/lib-commonjs/e2etest/autolink.test.js +109 -12
  10. package/lib-commonjs/e2etest/autolink.test.js.map +1 -1
  11. package/lib-commonjs/e2etest/dependencyConfig.test.js +17 -17
  12. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -1
  13. package/lib-commonjs/e2etest/projectConfig.test.js +18 -20
  14. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -1
  15. package/lib-commonjs/e2etest/projectConfig.utils.js +6 -13
  16. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -1
  17. package/lib-commonjs/e2etest/runWindows.test.js +52 -13
  18. package/lib-commonjs/e2etest/runWindows.test.js.map +1 -1
  19. package/lib-commonjs/generator-common/index.js +8 -8
  20. package/lib-commonjs/generator-common/index.js.map +1 -1
  21. package/lib-commonjs/generator-windows/index.js +34 -77
  22. package/lib-commonjs/generator-windows/index.js.map +1 -1
  23. package/lib-commonjs/healthChecks.js +22 -4
  24. package/lib-commonjs/healthChecks.js.map +1 -1
  25. package/lib-commonjs/index.js +10 -61
  26. package/lib-commonjs/index.js.map +1 -1
  27. package/lib-commonjs/runWindows/runWindows.d.ts +0 -1
  28. package/lib-commonjs/runWindows/runWindows.js +124 -145
  29. package/lib-commonjs/runWindows/runWindows.js.map +1 -1
  30. package/lib-commonjs/runWindows/runWindowsOptions.d.ts +8 -8
  31. package/lib-commonjs/runWindows/runWindowsOptions.js +7 -12
  32. package/lib-commonjs/runWindows/runWindowsOptions.js.map +1 -1
  33. package/lib-commonjs/runWindows/utils/autolink.d.ts +16 -5
  34. package/lib-commonjs/runWindows/utils/autolink.js +118 -57
  35. package/lib-commonjs/runWindows/utils/autolink.js.map +1 -1
  36. package/lib-commonjs/runWindows/utils/build.js +4 -4
  37. package/lib-commonjs/runWindows/utils/build.js.map +1 -1
  38. package/lib-commonjs/runWindows/utils/checkRequirements.js +2 -2
  39. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +1 -1
  40. package/lib-commonjs/runWindows/utils/commandWithProgress.d.ts +8 -1
  41. package/lib-commonjs/runWindows/utils/commandWithProgress.js +30 -8
  42. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +1 -1
  43. package/lib-commonjs/runWindows/utils/deploy.d.ts +1 -1
  44. package/lib-commonjs/runWindows/utils/deploy.js +88 -37
  45. package/lib-commonjs/runWindows/utils/deploy.js.map +1 -1
  46. package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +1 -0
  47. package/lib-commonjs/runWindows/utils/msbuildtools.js +30 -23
  48. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +1 -1
  49. package/lib-commonjs/runWindows/utils/telemetryHelpers.d.ts +29 -0
  50. package/lib-commonjs/runWindows/utils/telemetryHelpers.js +109 -0
  51. package/lib-commonjs/runWindows/utils/telemetryHelpers.js.map +1 -0
  52. package/lib-commonjs/runWindows/utils/version.js +1 -1
  53. package/lib-commonjs/runWindows/utils/version.js.map +1 -1
  54. package/lib-commonjs/runWindows/utils/vsInstalls.js +3 -3
  55. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +1 -1
  56. package/lib-commonjs/runWindows/utils/vstools.js +4 -4
  57. package/lib-commonjs/runWindows/utils/vstools.js.map +1 -1
  58. package/lib-commonjs/runWindows/utils/winappdeploytool.js +7 -7
  59. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +1 -1
  60. package/package.json +17 -13
  61. package/CHANGELOG.json +0 -1585
  62. package/CHANGELOG.md +0 -713
@@ -19,7 +19,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
19
19
  var __importStar = (this && this.__importStar) || function (mod) {
20
20
  if (mod && mod.__esModule) return mod;
21
21
  var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
23
  __setModuleDefault(result, mod);
24
24
  return result;
25
25
  };
@@ -27,66 +27,80 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.runWindowsCommand = exports.getAnonymizedProjectName = void 0;
31
- const crypto_1 = __importDefault(require("crypto"));
32
- const fs_1 = __importDefault(require("fs"));
30
+ exports.runWindowsCommand = void 0;
31
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
33
32
  const path_1 = __importDefault(require("path"));
34
33
  const telemetry_1 = require("@react-native-windows/telemetry");
35
34
  const build = __importStar(require("./utils/build"));
36
35
  const chalk_1 = __importDefault(require("chalk"));
37
36
  const deploy = __importStar(require("./utils/deploy"));
38
37
  const commandWithProgress_1 = require("./utils/commandWithProgress");
38
+ const telemetryHelpers_1 = require("./utils/telemetryHelpers");
39
39
  const info = __importStar(require("./utils/info"));
40
40
  const msbuildtools_1 = __importDefault(require("./utils/msbuildtools"));
41
41
  const runWindowsOptions_1 = require("./runWindowsOptions");
42
42
  const autolink_1 = require("./utils/autolink");
43
- const os_1 = require("os");
44
- function setExitProcessWithError(error, loggingWasEnabled) {
45
- if (!loggingWasEnabled) {
46
- console.log(`Re-run the command with ${chalk_1.default.bold('--logging')} for more information`);
47
- if (telemetry_1.Telemetry.client) {
48
- console.log(`Your session id was ${telemetry_1.Telemetry.client.commonProperties.sessionId}`);
49
- }
50
- }
51
- if (error instanceof telemetry_1.CodedError) {
52
- process.exitCode = telemetry_1.CodedErrors[error.name];
53
- }
54
- else {
55
- process.exitCode = 1;
43
+ /**
44
+ * Sanitizes the given option for telemetery.
45
+ * @param key The key of the option.
46
+ * @param value The unsanitized value of the option.
47
+ * @returns The sanitized value of the option.
48
+ */
49
+ // eslint-disable-next-line complexity
50
+ function optionSanitizer(key, value) {
51
+ // Do not add a default case here.
52
+ // Strings risking PII should just return true if present, false otherwise.
53
+ // All others should return the value (or false if undefined).
54
+ switch (key) {
55
+ case 'root':
56
+ case 'target':
57
+ case 'sln':
58
+ case 'proj':
59
+ case 'buildLogDirectory':
60
+ return value === undefined ? false : true; // Strip PII
61
+ case 'msbuildprops':
62
+ return value === undefined ? 0 : value.split(',').length; // Convert to count
63
+ case 'release':
64
+ case 'arch':
65
+ case 'singleproc':
66
+ case 'emulator':
67
+ case 'device':
68
+ case 'remoteDebugging':
69
+ case 'logging':
70
+ case 'packager':
71
+ case 'bundle':
72
+ case 'launch':
73
+ case 'autolink':
74
+ case 'build':
75
+ case 'deploy':
76
+ case 'deployFromLayout':
77
+ case 'info':
78
+ case 'directDebugging':
79
+ case 'telemetry':
80
+ return value === undefined ? false : value; // Return value
56
81
  }
57
82
  }
58
- function getPkgVersion(pkgName) {
59
- try {
60
- const pkgJsonPath = require.resolve(`${pkgName}/package.json`, {
61
- paths: [process.cwd(), __dirname],
62
- });
63
- const pkgJson = JSON.parse(fs_1.default.readFileSync(pkgJsonPath).toString());
64
- if (pkgJson.name === pkgName && pkgJson.version !== undefined) {
65
- return pkgJson.version;
66
- }
67
- }
68
- catch (_a) { }
69
- commandWithProgress_1.newWarn(`Could not determine ${pkgName} version`);
70
- return '';
83
+ /**
84
+ * Get the extra props to add to the `run-windows` telemetry event.
85
+ * @returns The extra props.
86
+ */
87
+ async function getExtraProps() {
88
+ const extraProps = {
89
+ phase: runWindowsPhase,
90
+ hasRunRnwDependencies,
91
+ };
92
+ return extraProps;
71
93
  }
72
94
  let runWindowsPhase = 'None';
95
+ let hasRunRnwDependencies = false;
73
96
  /**
74
- * Performs build deploy and launch of RNW apps.
97
+ * The function run when calling `react-native run-windows`.
75
98
  * @param args Unprocessed args passed from react-native CLI.
76
99
  * @param config Config passed from react-native CLI.
77
100
  * @param options Options passed from react-native CLI.
78
101
  */
79
102
  async function runWindows(args, config, options) {
80
- var _a, _b;
81
- if (!options.telemetry) {
82
- if (options.logging) {
83
- console.log('Disabling telemetry');
84
- }
85
- telemetry_1.Telemetry.disable();
86
- }
87
- else {
88
- telemetry_1.Telemetry.setup();
89
- }
103
+ await (0, telemetryHelpers_1.startTelemetrySession)('run-windows', config, options, (0, telemetryHelpers_1.getDefaultOptions)(config, runWindowsOptions_1.runWindowsOptions), optionSanitizer);
90
104
  // https://github.com/yarnpkg/yarn/issues/8334 - Yarn on Windows breaks apps that read from the environment variables
91
105
  // Yarn will run node via CreateProcess and pass npm_config_* variables in lowercase without unifying their value
92
106
  // with their possibly existing uppercase counterparts. This breaks programs that read from the environment block
@@ -95,103 +109,56 @@ async function runWindows(args, config, options) {
95
109
  // uppercase variable values one if there are no overrides.
96
110
  delete process.env.NPM_CONFIG_CACHE;
97
111
  delete process.env.NPM_CONFIG_PREFIX;
98
- const hasRunRnwDependencies = process.env.LocalAppData &&
99
- fs_1.default.existsSync(path_1.default.join(process.env.LocalAppData, 'rnw-dependencies.txt')); // CODESYNC \vnext\scripts\rnw-dependencies.ps1
112
+ if (process.env.LocalAppData) {
113
+ hasRunRnwDependencies = fs_1.default.existsSync(path_1.default.join(process.env.LocalAppData, 'rnw-dependencies.txt')); // CODESYNC \vnext\scripts\rnw-dependencies.ps1
114
+ }
115
+ let runWindowsError;
100
116
  if (options.info) {
101
117
  try {
102
118
  const output = await info.getEnvironmentInfo();
103
119
  console.log(output.trimEnd());
104
120
  console.log(' Installed UWP SDKs:');
105
121
  const sdks = msbuildtools_1.default.getAllAvailableUAPVersions();
106
- sdks.forEach(version => console.log(' ' + version));
107
- return;
122
+ sdks.forEach((version) => console.log(' ' + version));
108
123
  }
109
- catch (e) {
110
- telemetry_1.Telemetry.trackException(e);
111
- commandWithProgress_1.newError('Unable to print environment info.\n' + e.toString());
112
- return setExitProcessWithError(e, options.logging);
124
+ catch (ex) {
125
+ runWindowsError =
126
+ ex instanceof Error ? ex : new Error(String(ex));
127
+ telemetry_1.Telemetry.trackException(runWindowsError);
128
+ (0, commandWithProgress_1.newError)('Unable to print environment info.\n' + runWindowsError.toString());
113
129
  }
130
+ await (0, telemetryHelpers_1.endTelemetrySession)(runWindowsError, getExtraProps);
131
+ (0, commandWithProgress_1.setExitProcessWithError)(options.logging, runWindowsError);
132
+ return;
114
133
  }
115
- let runWindowsError;
116
134
  try {
117
135
  await runWindowsInternal(args, config, options);
118
136
  }
119
- catch (e) {
120
- telemetry_1.Telemetry.trackException(e);
121
- runWindowsError = e;
137
+ catch (ex) {
138
+ runWindowsError =
139
+ ex instanceof Error ? ex : new Error(String(ex));
140
+ telemetry_1.Telemetry.trackException(runWindowsError);
122
141
  if (!hasRunRnwDependencies) {
123
142
  const rnwPkgJsonPath = require.resolve('react-native-windows/package.json', {
124
143
  paths: [process.cwd(), __dirname],
125
144
  });
126
145
  const rnwDependenciesPath = path_1.default.join(path_1.default.dirname(rnwPkgJsonPath), 'scripts/rnw-dependencies.ps1');
127
- commandWithProgress_1.newError(`It is possible your installation is missing required software dependencies. Dependencies can be automatically installed by running ${rnwDependenciesPath} from an elevated PowerShell prompt.\nFor more information, go to http://aka.ms/rnw-deps`);
146
+ (0, commandWithProgress_1.newError)(`It is possible your installation is missing required software dependencies. Dependencies can be automatically installed by running ${rnwDependenciesPath} from an elevated PowerShell prompt.\nFor more information, go to http://aka.ms/rnw-deps`);
128
147
  }
129
- return setExitProcessWithError(e, options.logging);
130
- }
131
- finally {
132
- (_a = telemetry_1.Telemetry.client) === null || _a === void 0 ? void 0 : _a.trackEvent({
133
- name: 'run-windows',
134
- properties: {
135
- release: options.release,
136
- arch: options.arch,
137
- singleproc: options.singleproc,
138
- emulator: options.emulator,
139
- device: options.device,
140
- target: options.target,
141
- remoteDebugging: options.remoteDebugging,
142
- logging: options.logging,
143
- packager: options.packager,
144
- bundle: options.bundle,
145
- launch: options.launch,
146
- autolink: options.autolink,
147
- build: options.bundle,
148
- deploy: options.deploy,
149
- sln: options.sln !== undefined,
150
- proj: options.proj !== undefined,
151
- msBuildProps: options.msbuildprops !== undefined
152
- ? options.msbuildprops.split(',').length
153
- : 0,
154
- info: options.info,
155
- directDebugging: options.directDebugging,
156
- 'react-native-windows': getPkgVersion('react-native-windows'),
157
- 'react-native': getPkgVersion('react-native'),
158
- 'cli-version': getPkgVersion('@react-native-windows/cli'),
159
- msftInternal: telemetry_1.isMSFTInternal(),
160
- durationInSecs: process.uptime(),
161
- success: runWindowsError === undefined,
162
- phase: runWindowsPhase,
163
- totalMem: os_1.totalmem(),
164
- diskFree: telemetry_1.getDiskFreeSpace(__dirname),
165
- cpus: os_1.cpus().length,
166
- project: await getAnonymizedProjectName(config.root),
167
- hasRunRnwDependencies: hasRunRnwDependencies,
168
- },
169
- });
170
- (_b = telemetry_1.Telemetry.client) === null || _b === void 0 ? void 0 : _b.flush();
171
- }
172
- }
173
- async function getAnonymizedProjectName(projectRoot) {
174
- const projectJsonPath = path_1.default.join(projectRoot, 'package.json');
175
- if (!fs_1.default.existsSync(projectJsonPath)) {
176
- return null;
177
148
  }
178
- const projectJson = JSON.parse((await fs_1.default.promises.readFile(projectJsonPath)).toString());
179
- const projectName = projectJson.name;
180
- if (typeof projectName !== 'string') {
181
- return null;
182
- }
183
- // Ensure the project name cannot be reverse engineered to avoid leaking PII
184
- return crypto_1.default
185
- .createHash('sha256')
186
- .update(projectName)
187
- .digest('hex')
188
- .toString();
149
+ await (0, telemetryHelpers_1.endTelemetrySession)(runWindowsError, getExtraProps);
150
+ (0, commandWithProgress_1.setExitProcessWithError)(options.logging, runWindowsError);
189
151
  }
190
- exports.getAnonymizedProjectName = getAnonymizedProjectName;
152
+ /**
153
+ * Performs build deploy and launch of RNW apps.
154
+ * @param args Unprocessed args passed from react-native CLI.
155
+ * @param config Config passed from react-native CLI.
156
+ * @param options Options passed from react-native CLI.
157
+ */
191
158
  async function runWindowsInternal(args, config, options) {
192
- const verbose = options.logging;
159
+ const verbose = options.logging === true;
193
160
  if (verbose) {
194
- commandWithProgress_1.newInfo('Verbose: ON');
161
+ (0, commandWithProgress_1.newInfo)('Verbose: ON');
195
162
  }
196
163
  // Get the solution file
197
164
  let slnFile;
@@ -199,7 +166,32 @@ async function runWindowsInternal(args, config, options) {
199
166
  slnFile = build.getAppSolutionFile(options, config);
200
167
  }
201
168
  catch (e) {
202
- commandWithProgress_1.newError(`Couldn't get app solution information. ${e.message}`);
169
+ (0, commandWithProgress_1.newError)(`Couldn't get app solution information. ${e.message}`);
170
+ throw e;
171
+ }
172
+ let buildTools;
173
+ runWindowsPhase = 'FindBuildTools';
174
+ try {
175
+ buildTools = msbuildtools_1.default.findAvailableVersion(options.arch, verbose);
176
+ }
177
+ catch (error) {
178
+ (0, commandWithProgress_1.newWarn)('No public VS release found');
179
+ // Try prerelease
180
+ try {
181
+ (0, commandWithProgress_1.newInfo)('Trying pre-release VS');
182
+ buildTools = msbuildtools_1.default.findAvailableVersion(options.arch, verbose, true);
183
+ }
184
+ catch (e) {
185
+ (0, commandWithProgress_1.newError)(e.message);
186
+ throw error;
187
+ }
188
+ }
189
+ // Restore packages.config files for dependencies that don't support PackageReference.
190
+ try {
191
+ await buildTools.restorePackageConfigs(slnFile);
192
+ }
193
+ catch (e) {
194
+ (0, commandWithProgress_1.newError)(`Couldn't restore found packages.config instances. ${e.message}`);
203
195
  throw e;
204
196
  }
205
197
  try {
@@ -208,41 +200,26 @@ async function runWindowsInternal(args, config, options) {
208
200
  const autolinkConfig = config;
209
201
  const autoLinkOptions = {
210
202
  logging: options.logging,
203
+ check: false,
211
204
  proj: options.proj,
212
205
  sln: options.sln,
206
+ telemetry: options.telemetry,
213
207
  };
214
208
  runWindowsPhase = 'AutoLink';
215
- await autolink_1.autoLinkCommand.func(autolinkArgs, autolinkConfig, autoLinkOptions);
209
+ await (0, autolink_1.autolinkWindowsInternal)(autolinkArgs, autolinkConfig, autoLinkOptions);
216
210
  }
217
211
  else {
218
- commandWithProgress_1.newInfo('Autolink step is skipped');
212
+ (0, commandWithProgress_1.newInfo)('Autolink step is skipped');
219
213
  }
220
214
  }
221
215
  catch (e) {
222
- commandWithProgress_1.newError(`Autolinking failed. ${e.message}`);
216
+ (0, commandWithProgress_1.newError)(`Autolinking failed. ${e.message}`);
223
217
  throw e;
224
218
  }
225
- let buildTools;
226
- runWindowsPhase = 'FindBuildTools';
227
- try {
228
- buildTools = msbuildtools_1.default.findAvailableVersion(options.arch, verbose);
229
- }
230
- catch (error) {
231
- commandWithProgress_1.newWarn('No public VS release found');
232
- // Try prerelease
233
- try {
234
- commandWithProgress_1.newInfo('Trying pre-release VS');
235
- buildTools = msbuildtools_1.default.findAvailableVersion(options.arch, verbose, true);
236
- }
237
- catch (e) {
238
- commandWithProgress_1.newError(e.message);
239
- throw error;
240
- }
241
- }
242
219
  if (options.build) {
243
220
  runWindowsPhase = 'FindSolution';
244
221
  if (!slnFile) {
245
- commandWithProgress_1.newError('Visual Studio Solution file not found. Maybe run "npx react-native-windows-init" first?');
222
+ (0, commandWithProgress_1.newError)('Visual Studio Solution file not found. Maybe run "npx react-native-windows-init" first?');
246
223
  throw new telemetry_1.CodedError('NoSolution', 'Cannot find solution file');
247
224
  }
248
225
  // Get build/deploy options
@@ -255,7 +232,7 @@ async function runWindowsInternal(args, config, options) {
255
232
  await build.buildSolution(buildTools, slnFile, buildType, options.arch, msBuildProps, verbose, 'build', options.buildLogDirectory, options.singleproc);
256
233
  }
257
234
  catch (e) {
258
- commandWithProgress_1.newError(`Build failed with message ${e.message}. Check your build configuration.`);
235
+ (0, commandWithProgress_1.newError)(`Build failed with message ${e.message}. Check your build configuration.`);
259
236
  if (e.logfile) {
260
237
  console.log('See', chalk_1.default.bold(e.logfile));
261
238
  }
@@ -263,7 +240,7 @@ async function runWindowsInternal(args, config, options) {
263
240
  }
264
241
  }
265
242
  else {
266
- commandWithProgress_1.newInfo('Build step is skipped');
243
+ (0, commandWithProgress_1.newInfo)('Build step is skipped');
267
244
  }
268
245
  if (shouldLaunchPackager(options)) {
269
246
  await deploy.startServerInNewWindow(options, verbose);
@@ -271,29 +248,31 @@ async function runWindowsInternal(args, config, options) {
271
248
  if (options.deploy) {
272
249
  runWindowsPhase = 'FindSolution';
273
250
  if (!slnFile) {
274
- commandWithProgress_1.newError('Visual Studio Solution file not found. Maybe run "npx react-native-windows-init" first?');
251
+ (0, commandWithProgress_1.newError)('Visual Studio Solution file not found. Maybe run "npx react-native-windows-init" first?');
275
252
  throw new telemetry_1.CodedError('NoSolution', 'Cannot find solution file');
276
253
  }
277
254
  try {
278
255
  runWindowsPhase = 'Deploy';
279
256
  if (options.device || options.emulator || options.target) {
280
- await deploy.deployToDevice(options, verbose);
257
+ await deploy.deployToDevice(options, verbose, config);
281
258
  }
282
259
  else {
283
260
  await deploy.deployToDesktop(options, verbose, config, buildTools);
284
261
  }
285
262
  }
286
263
  catch (e) {
287
- commandWithProgress_1.newError(`Failed to deploy${e ? `: ${e.message}` : ''}`);
264
+ (0, commandWithProgress_1.newError)(`Failed to deploy${e ? `: ${e.message}` : ''}`);
288
265
  throw e;
289
266
  }
290
267
  }
291
268
  else {
292
- commandWithProgress_1.newInfo('Deploy step is skipped');
269
+ (0, commandWithProgress_1.newInfo)('Deploy step is skipped');
293
270
  }
294
271
  }
295
272
  function shouldLaunchPackager(options) {
296
- return options.packager && options.launch && options.release !== true;
273
+ return (options.packager === true &&
274
+ options.launch === true &&
275
+ options.release !== true);
297
276
  }
298
277
  /*
299
278
  // Example of running the Windows Command
@@ -1 +1 @@
1
- {"version":3,"file":"runWindows.js","sourceRoot":"","sources":["../../src/runWindows/runWindows.ts"],"names":[],"mappings":";AA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C,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACzD,MAAM,CAAC,CAAC;SACT;KACF;SAAM;QACL,6BAAO,CAAC,wBAAwB,CAAC,CAAC;KACnC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,OAA0B;IACtD,OAAO,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC;AACxE,CAAC;AAED;;;;;;;;EAQE;AAEF;;GAEG;AACU,QAAA,iBAAiB,GAAY;IACxC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,kFAAkF;IACpF,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,qCAAiB;CAC3B,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport crypto from 'crypto';\nimport fs from 'fs';\nimport path from 'path';\nimport {\n Telemetry,\n isMSFTInternal,\n getDiskFreeSpace,\n CodedError,\n CodedErrorType,\n CodedErrors,\n} from '@react-native-windows/telemetry';\n\nimport * as build from './utils/build';\nimport chalk from 'chalk';\nimport * as deploy from './utils/deploy';\nimport {newError, newInfo, newWarn} from './utils/commandWithProgress';\nimport * as info from './utils/info';\nimport MSBuildTools from './utils/msbuildtools';\n\nimport {Command, Config} from '@react-native-community/cli-types';\nimport {runWindowsOptions, RunWindowsOptions} from './runWindowsOptions';\n\nimport {autoLinkCommand} from './utils/autolink';\nimport {totalmem, cpus} from 'os';\n\nfunction setExitProcessWithError(\n error: Error,\n loggingWasEnabled: boolean,\n): void {\n if (!loggingWasEnabled) {\n console.log(\n `Re-run the command with ${chalk.bold('--logging')} for more information`,\n );\n if (Telemetry.client) {\n console.log(\n `Your session id was ${Telemetry.client.commonProperties.sessionId}`,\n );\n }\n }\n if (error instanceof CodedError) {\n process.exitCode = CodedErrors[error.name as CodedErrorType];\n } else {\n process.exitCode = 1;\n }\n}\n\nfunction getPkgVersion(pkgName: string): string {\n try {\n const pkgJsonPath = require.resolve(`${pkgName}/package.json`, {\n paths: [process.cwd(), __dirname],\n });\n const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath).toString());\n if (pkgJson.name === pkgName && pkgJson.version !== undefined) {\n return pkgJson.version;\n }\n } catch {}\n newWarn(`Could not determine ${pkgName} version`);\n return '';\n}\n\n/**\n * Labels used by telemtry to represent current operation\n */\ntype RunWindowsPhase =\n | 'None'\n | 'AutoLink'\n | 'FindBuildTools'\n | 'FindSolution'\n | 'Deploy';\n\nlet runWindowsPhase: RunWindowsPhase = 'None';\n/**\n * Performs build deploy and launch of RNW apps.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindows(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n if (!options.telemetry) {\n if (options.logging) {\n console.log('Disabling telemetry');\n }\n Telemetry.disable();\n } else {\n Telemetry.setup();\n }\n\n // https://github.com/yarnpkg/yarn/issues/8334 - Yarn on Windows breaks apps that read from the environment variables\n // Yarn will run node via CreateProcess and pass npm_config_* variables in lowercase without unifying their value\n // with their possibly existing uppercase counterparts. This breaks programs that read from the environment block\n // and write to a case-insensitive dictionary since they expect to encounter each variable only once.\n // The values of the lowercase variables are the one npm actually wants to use, plus they are seeded from the\n // uppercase variable values one if there are no overrides.\n delete process.env.NPM_CONFIG_CACHE;\n delete process.env.NPM_CONFIG_PREFIX;\n\n const hasRunRnwDependencies =\n process.env.LocalAppData &&\n fs.existsSync(path.join(process.env.LocalAppData, 'rnw-dependencies.txt')); // CODESYNC \\vnext\\scripts\\rnw-dependencies.ps1\n\n if (options.info) {\n try {\n const output = await info.getEnvironmentInfo();\n console.log(output.trimEnd());\n console.log(' Installed UWP SDKs:');\n const sdks = MSBuildTools.getAllAvailableUAPVersions();\n sdks.forEach(version => console.log(' ' + version));\n return;\n } catch (e) {\n Telemetry.trackException(e);\n newError('Unable to print environment info.\\n' + e.toString());\n return setExitProcessWithError(e, options.logging);\n }\n }\n\n let runWindowsError;\n try {\n await runWindowsInternal(args, config, options);\n } catch (e) {\n Telemetry.trackException(e);\n runWindowsError = e;\n if (!hasRunRnwDependencies) {\n const rnwPkgJsonPath = require.resolve(\n 'react-native-windows/package.json',\n {\n paths: [process.cwd(), __dirname],\n },\n );\n const rnwDependenciesPath = path.join(\n path.dirname(rnwPkgJsonPath),\n 'scripts/rnw-dependencies.ps1',\n );\n\n newError(\n `It is possible your installation is missing required software dependencies. Dependencies can be automatically installed by running ${rnwDependenciesPath} from an elevated PowerShell prompt.\\nFor more information, go to http://aka.ms/rnw-deps`,\n );\n }\n return setExitProcessWithError(e, options.logging);\n } finally {\n Telemetry.client?.trackEvent({\n name: 'run-windows',\n properties: {\n release: options.release,\n arch: options.arch,\n singleproc: options.singleproc,\n emulator: options.emulator,\n device: options.device,\n target: options.target,\n remoteDebugging: options.remoteDebugging,\n logging: options.logging,\n packager: options.packager,\n bundle: options.bundle,\n launch: options.launch,\n autolink: options.autolink,\n build: options.bundle,\n deploy: options.deploy,\n sln: options.sln !== undefined,\n proj: options.proj !== undefined,\n msBuildProps:\n options.msbuildprops !== undefined\n ? options.msbuildprops!.split(',').length\n : 0,\n info: options.info,\n directDebugging: options.directDebugging,\n 'react-native-windows': getPkgVersion('react-native-windows'),\n 'react-native': getPkgVersion('react-native'),\n 'cli-version': getPkgVersion('@react-native-windows/cli'),\n msftInternal: isMSFTInternal(),\n durationInSecs: process.uptime(),\n success: runWindowsError === undefined,\n phase: runWindowsPhase,\n totalMem: totalmem(),\n diskFree: getDiskFreeSpace(__dirname),\n cpus: cpus().length,\n project: await getAnonymizedProjectName(config.root),\n hasRunRnwDependencies: hasRunRnwDependencies,\n },\n });\n Telemetry.client?.flush();\n }\n}\n\nexport async function getAnonymizedProjectName(\n projectRoot: string,\n): Promise<string | null> {\n const projectJsonPath = path.join(projectRoot, 'package.json');\n if (!fs.existsSync(projectJsonPath)) {\n return null;\n }\n\n const projectJson = JSON.parse(\n (await fs.promises.readFile(projectJsonPath)).toString(),\n );\n\n const projectName = projectJson.name;\n if (typeof projectName !== 'string') {\n return null;\n }\n\n // Ensure the project name cannot be reverse engineered to avoid leaking PII\n return crypto\n .createHash('sha256')\n .update(projectName)\n .digest('hex')\n .toString();\n}\n\nasync function runWindowsInternal(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n const verbose = options.logging;\n\n if (verbose) {\n newInfo('Verbose: ON');\n }\n\n // Get the solution file\n let slnFile;\n try {\n slnFile = build.getAppSolutionFile(options, config);\n } catch (e) {\n newError(`Couldn't get app solution information. ${e.message}`);\n throw e;\n }\n\n try {\n if (options.autolink) {\n const autolinkArgs: string[] = [];\n const autolinkConfig = config;\n const autoLinkOptions = {\n logging: options.logging,\n proj: options.proj,\n sln: options.sln,\n };\n runWindowsPhase = 'AutoLink';\n await autoLinkCommand.func(autolinkArgs, autolinkConfig, autoLinkOptions);\n } else {\n newInfo('Autolink step is skipped');\n }\n } catch (e) {\n newError(`Autolinking failed. ${e.message}`);\n throw e;\n }\n\n let buildTools: MSBuildTools;\n runWindowsPhase = 'FindBuildTools';\n try {\n buildTools = MSBuildTools.findAvailableVersion(options.arch, verbose);\n } catch (error) {\n newWarn('No public VS release found');\n // Try prerelease\n try {\n newInfo('Trying pre-release VS');\n buildTools = MSBuildTools.findAvailableVersion(\n options.arch,\n verbose,\n true, // preRelease\n );\n } catch (e) {\n newError(e.message);\n throw error;\n }\n }\n\n if (options.build) {\n runWindowsPhase = 'FindSolution';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx react-native-windows-init\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n // Get build/deploy options\n const buildType = deploy.getBuildConfiguration(options);\n const msBuildProps = build.parseMsBuildProps(options);\n\n // Disable the autolink check since we just ran it\n msBuildProps.RunAutolinkCheck = 'false';\n\n try {\n runWindowsPhase = 'FindSolution';\n await build.buildSolution(\n buildTools,\n slnFile!,\n buildType,\n options.arch,\n msBuildProps,\n verbose,\n 'build',\n options.buildLogDirectory,\n options.singleproc,\n );\n } catch (e) {\n newError(\n `Build failed with message ${e.message}. Check your build configuration.`,\n );\n if (e.logfile) {\n console.log('See', chalk.bold(e.logfile));\n }\n throw e;\n }\n } else {\n newInfo('Build step is skipped');\n }\n\n if (shouldLaunchPackager(options)) {\n await deploy.startServerInNewWindow(options, verbose);\n }\n\n if (options.deploy) {\n runWindowsPhase = 'FindSolution';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx react-native-windows-init\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n try {\n runWindowsPhase = 'Deploy';\n if (options.device || options.emulator || options.target) {\n await deploy.deployToDevice(options, verbose);\n } else {\n await deploy.deployToDesktop(options, verbose, config, buildTools);\n }\n } catch (e) {\n newError(`Failed to deploy${e ? `: ${e.message}` : ''}`);\n throw e;\n }\n } else {\n newInfo('Deploy step is skipped');\n }\n}\n\nfunction shouldLaunchPackager(options: RunWindowsOptions): boolean {\n return options.packager && options.launch && options.release !== true;\n}\n\n/*\n// Example of running the Windows Command\nrunWindows({\n root: 'C:\\\\github\\\\hack\\\\myapp',\n debug: true,\n arch: 'x86',\n nugetPath: 'C:\\\\github\\\\react\\\\react-native-windows\\\\local-cli\\\\runWindows\\\\.nuget\\\\nuget.exe'\n});\n*/\n\n/**\n * Starts the app on a connected Windows emulator or mobile device.\n */\nexport const runWindowsCommand: Command = {\n name: 'run-windows',\n description:\n 'builds your app and starts it on a connected Windows desktop, emulator or device',\n func: runWindows,\n options: runWindowsOptions,\n};\n"]}
1
+ {"version":3,"file":"runWindows.js","sourceRoot":"","sources":["../../src/runWindows/runWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,+DAAsE;AAEtE,qDAA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B;IACtD,OAAO,CACL,OAAO,CAAC,QAAQ,KAAK,IAAI;QACzB,OAAO,CAAC,MAAM,KAAK,IAAI;QACvB,OAAO,CAAC,OAAO,KAAK,IAAI,CACzB,CAAC;AACJ,CAAC;AAED;;;;;;;;EAQE;AAEF;;GAEG;AACU,QAAA,iBAAiB,GAAY;IACxC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,kFAAkF;IACpF,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,qCAAiB;CAC3B,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\n\nimport * as build from './utils/build';\nimport chalk from 'chalk';\nimport * as deploy from './utils/deploy';\nimport {\n newError,\n newInfo,\n newWarn,\n setExitProcessWithError,\n} from './utils/commandWithProgress';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from './utils/telemetryHelpers';\nimport * as info from './utils/info';\nimport MSBuildTools from './utils/msbuildtools';\n\nimport {Command, Config} from '@react-native-community/cli-types';\nimport {runWindowsOptions, RunWindowsOptions} from './runWindowsOptions';\n\nimport {autolinkWindowsInternal, AutoLinkOptions} from './utils/autolink';\n\n/**\n * Sanitizes the given option for telemetery.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\n// eslint-disable-next-line complexity\nfunction optionSanitizer(key: keyof RunWindowsOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'root':\n case 'target':\n case 'sln':\n case 'proj':\n case 'buildLogDirectory':\n return value === undefined ? false : true; // Strip PII\n case 'msbuildprops':\n return value === undefined ? 0 : value.split(',').length; // Convert to count\n case 'release':\n case 'arch':\n case 'singleproc':\n case 'emulator':\n case 'device':\n case 'remoteDebugging':\n case 'logging':\n case 'packager':\n case 'bundle':\n case 'launch':\n case 'autolink':\n case 'build':\n case 'deploy':\n case 'deployFromLayout':\n case 'info':\n case 'directDebugging':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `run-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {\n phase: runWindowsPhase,\n hasRunRnwDependencies,\n };\n return extraProps;\n}\n\n/**\n * Labels used by telemetry to represent current operation\n */\ntype RunWindowsPhase =\n | 'None'\n | 'AutoLink'\n | 'FindBuildTools'\n | 'FindSolution'\n | 'Deploy';\n\nlet runWindowsPhase: RunWindowsPhase = 'None';\n\nlet hasRunRnwDependencies: boolean = false;\n\n/**\n * The function run when calling `react-native run-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindows(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n await startTelemetrySession(\n 'run-windows',\n config,\n options,\n getDefaultOptions(config, runWindowsOptions),\n optionSanitizer,\n );\n\n // https://github.com/yarnpkg/yarn/issues/8334 - Yarn on Windows breaks apps that read from the environment variables\n // Yarn will run node via CreateProcess and pass npm_config_* variables in lowercase without unifying their value\n // with their possibly existing uppercase counterparts. This breaks programs that read from the environment block\n // and write to a case-insensitive dictionary since they expect to encounter each variable only once.\n // The values of the lowercase variables are the one npm actually wants to use, plus they are seeded from the\n // uppercase variable values one if there are no overrides.\n delete process.env.NPM_CONFIG_CACHE;\n delete process.env.NPM_CONFIG_PREFIX;\n\n if (process.env.LocalAppData) {\n hasRunRnwDependencies = fs.existsSync(\n path.join(process.env.LocalAppData, 'rnw-dependencies.txt'),\n ); // CODESYNC \\vnext\\scripts\\rnw-dependencies.ps1\n }\n\n let runWindowsError: Error | undefined;\n if (options.info) {\n try {\n const output = await info.getEnvironmentInfo();\n console.log(output.trimEnd());\n console.log(' Installed UWP SDKs:');\n const sdks = MSBuildTools.getAllAvailableUAPVersions();\n sdks.forEach((version) => console.log(' ' + version));\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n newError(\n 'Unable to print environment info.\\n' + runWindowsError.toString(),\n );\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n return;\n }\n\n try {\n await runWindowsInternal(args, config, options);\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n if (!hasRunRnwDependencies) {\n const rnwPkgJsonPath = require.resolve(\n 'react-native-windows/package.json',\n {\n paths: [process.cwd(), __dirname],\n },\n );\n const rnwDependenciesPath = path.join(\n path.dirname(rnwPkgJsonPath),\n 'scripts/rnw-dependencies.ps1',\n );\n\n newError(\n `It is possible your installation is missing required software dependencies. Dependencies can be automatically installed by running ${rnwDependenciesPath} from an elevated PowerShell prompt.\\nFor more information, go to http://aka.ms/rnw-deps`,\n );\n }\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n}\n\n/**\n * Performs build deploy and launch of RNW apps.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindowsInternal(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n const verbose = options.logging === true;\n\n if (verbose) {\n newInfo('Verbose: ON');\n }\n\n // Get the solution file\n let slnFile;\n try {\n slnFile = build.getAppSolutionFile(options, config);\n } catch (e) {\n newError(`Couldn't get app solution information. ${(e as Error).message}`);\n throw e;\n }\n\n let buildTools: MSBuildTools;\n runWindowsPhase = 'FindBuildTools';\n try {\n buildTools = MSBuildTools.findAvailableVersion(options.arch, verbose);\n } catch (error) {\n newWarn('No public VS release found');\n // Try prerelease\n try {\n newInfo('Trying pre-release VS');\n buildTools = MSBuildTools.findAvailableVersion(\n options.arch,\n verbose,\n true, // preRelease\n );\n } catch (e) {\n newError((e as Error).message);\n throw error;\n }\n }\n\n // Restore packages.config files for dependencies that don't support PackageReference.\n try {\n await buildTools.restorePackageConfigs(slnFile);\n } catch (e) {\n newError(\n `Couldn't restore found packages.config instances. ${\n (e as Error).message\n }`,\n );\n throw e;\n }\n\n try {\n if (options.autolink) {\n const autolinkArgs: string[] = [];\n const autolinkConfig = config;\n const autoLinkOptions: AutoLinkOptions = {\n logging: options.logging,\n check: false,\n proj: options.proj,\n sln: options.sln,\n telemetry: options.telemetry,\n };\n runWindowsPhase = 'AutoLink';\n await autolinkWindowsInternal(\n autolinkArgs,\n autolinkConfig,\n autoLinkOptions,\n );\n } else {\n newInfo('Autolink step is skipped');\n }\n } catch (e) {\n newError(`Autolinking failed. ${(e as Error).message}`);\n throw e;\n }\n\n if (options.build) {\n runWindowsPhase = 'FindSolution';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx react-native-windows-init\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n // Get build/deploy options\n const buildType = deploy.getBuildConfiguration(options);\n const msBuildProps = build.parseMsBuildProps(options);\n\n // Disable the autolink check since we just ran it\n msBuildProps.RunAutolinkCheck = 'false';\n\n try {\n runWindowsPhase = 'FindSolution';\n await build.buildSolution(\n buildTools,\n slnFile!,\n buildType,\n options.arch,\n msBuildProps,\n verbose,\n 'build',\n options.buildLogDirectory,\n options.singleproc,\n );\n } catch (e) {\n newError(\n `Build failed with message ${\n (e as Error).message\n }. Check your build configuration.`,\n );\n if ((e as any).logfile) {\n console.log('See', chalk.bold((e as any).logfile));\n }\n throw e;\n }\n } else {\n newInfo('Build step is skipped');\n }\n\n if (shouldLaunchPackager(options)) {\n await deploy.startServerInNewWindow(options, verbose);\n }\n\n if (options.deploy) {\n runWindowsPhase = 'FindSolution';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx react-native-windows-init\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n try {\n runWindowsPhase = 'Deploy';\n if (options.device || options.emulator || options.target) {\n await deploy.deployToDevice(options, verbose, config);\n } else {\n await deploy.deployToDesktop(options, verbose, config, buildTools);\n }\n } catch (e) {\n newError(`Failed to deploy${e ? `: ${(e as Error).message}` : ''}`);\n throw e;\n }\n } else {\n newInfo('Deploy step is skipped');\n }\n}\n\nfunction shouldLaunchPackager(options: RunWindowsOptions): boolean {\n return (\n options.packager === true &&\n options.launch === true &&\n options.release !== true\n );\n}\n\n/*\n// Example of running the Windows Command\nrunWindows({\n root: 'C:\\\\github\\\\hack\\\\myapp',\n debug: true,\n arch: 'x86',\n nugetPath: 'C:\\\\github\\\\react\\\\react-native-windows\\\\local-cli\\\\runWindows\\\\.nuget\\\\nuget.exe'\n});\n*/\n\n/**\n * Starts the app on a connected Windows emulator or mobile device.\n */\nexport const runWindowsCommand: Command = {\n name: 'run-windows',\n description:\n 'builds your app and starts it on a connected Windows desktop, emulator or device',\n func: runWindows,\n options: runWindowsOptions,\n};\n"]}
@@ -37,19 +37,19 @@ export interface RunWindowsOptions {
37
37
  device?: boolean;
38
38
  target?: string;
39
39
  remoteDebugging?: string;
40
- logging: boolean;
41
- packager: boolean;
42
- bundle: boolean;
43
- launch: boolean;
44
- autolink: boolean;
45
- build: boolean;
46
- deploy: boolean;
40
+ logging?: boolean;
41
+ packager?: boolean;
42
+ bundle?: boolean;
43
+ launch?: boolean;
44
+ autolink?: boolean;
45
+ build?: boolean;
46
+ deploy?: boolean;
47
47
  deployFromLayout?: boolean;
48
48
  sln?: string;
49
49
  proj?: string;
50
50
  msbuildprops?: string;
51
51
  buildLogDirectory?: string;
52
- info: boolean;
52
+ info?: boolean;
53
53
  directDebugging?: number;
54
54
  telemetry?: boolean;
55
55
  }
@@ -4,8 +4,12 @@
4
4
  * Licensed under the MIT License.
5
5
  * @format
6
6
  */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
7
10
  Object.defineProperty(exports, "__esModule", { value: true });
8
11
  exports.runWindowsOptions = void 0;
12
+ const os_1 = __importDefault(require("os"));
9
13
  exports.runWindowsOptions = [
10
14
  {
11
15
  name: '--release',
@@ -14,12 +18,12 @@ exports.runWindowsOptions = [
14
18
  {
15
19
  name: '--root [string]',
16
20
  description: 'Override the root directory for the windows build which contains the windows folder.',
17
- default: config => config.root,
21
+ default: (config) => config.root,
18
22
  },
19
23
  {
20
24
  name: '--arch [string]',
21
25
  description: 'The build architecture (ARM64, x86, x64)',
22
- default: 'x86',
26
+ default: os_1.default.arch(),
23
27
  parse: parseBuildArch,
24
28
  },
25
29
  {
@@ -45,7 +49,6 @@ exports.runWindowsOptions = [
45
49
  {
46
50
  name: '--logging',
47
51
  description: 'Enables logging',
48
- default: false,
49
52
  },
50
53
  {
51
54
  name: '--no-packager',
@@ -54,32 +57,26 @@ exports.runWindowsOptions = [
54
57
  {
55
58
  name: '--bundle',
56
59
  description: 'Enable Bundle configuration and it would be ReleaseBundle/DebugBundle other than Release/Debug',
57
- default: false,
58
60
  },
59
61
  {
60
62
  name: '--no-launch',
61
63
  description: 'Do not launch the app after deployment',
62
- default: false,
63
64
  },
64
65
  {
65
66
  name: '--no-autolink',
66
67
  description: 'Do not run autolinking',
67
- default: false,
68
68
  },
69
69
  {
70
70
  name: '--no-build',
71
71
  description: 'Do not build the solution',
72
- default: false,
73
72
  },
74
73
  {
75
74
  name: '--no-deploy',
76
75
  description: 'Do not deploy the app',
77
- default: false,
78
76
  },
79
77
  {
80
78
  name: '--deploy-from-layout',
81
- description: 'Force deploy from layout, even in release builds',
82
- default: false,
79
+ description: 'Force deploy from layout',
83
80
  },
84
81
  {
85
82
  name: '--sln [string]',
@@ -102,7 +99,6 @@ exports.runWindowsOptions = [
102
99
  {
103
100
  name: '--info',
104
101
  description: 'Dump environment information',
105
- default: false,
106
102
  },
107
103
  {
108
104
  name: '--direct-debugging [number]',
@@ -112,7 +108,6 @@ exports.runWindowsOptions = [
112
108
  {
113
109
  name: '--no-telemetry',
114
110
  description: 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',
115
- default: true,
116
111
  },
117
112
  ];
118
113
  function parseBuildArch(arg) {
@@ -1 +1 @@
1
- {"version":3,"file":"runWindowsOptions.js","sourceRoot":"","sources":["../../src/runWindows/runWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAuDU,QAAA,iBAAiB,GAAoB;IAChD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,2BAA2B;KACzC;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,sFAAsF;QACxF,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI;KAC/B;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,0CAA0C;QACvD,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,cAAc;KACtB;IACD;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,2BAA2B;KACzC;IACD;QACE,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,gCAAgC;KAC9C;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,uCAAuC;KACrD;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,qDAAqD;KACnE;IACD;QACE,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,2CAA2C;KACzD;IACD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,iBAAiB;QAC9B,OAAO,EAAE,KAAK;KACf;IACD;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,uCAAuC;KACrD;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EACT,gGAAgG;QAClG,OAAO,EAAE,KAAK;KACf;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,wCAAwC;QACrD,OAAO,EAAE,KAAK;KACf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CAAC;AAED,SAAS,wBAAwB,CAAC,GAAW;IAC3C,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAE9B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;QAC1B,QAAQ,CAAC,uDAAuD,CAAC,CAAC;KACnE;IACD,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,IAAI,KAAK,EAAE;QAC9B,QAAQ,CAAC,uCAAuC,CAAC,CAAC;KACnD;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW;IAC3B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CommandOption} from '@react-native-community/cli-types';\n\nexport type BuildArch = 'x86' | 'x64' | 'ARM64';\nexport type BuildConfig = 'Debug' | 'DebugBundle' | 'Release' | 'ReleaseBundle';\n\n/**\n * * Options are the following:\n * release: Boolean - Specifies release build\n * root: String - The root of the application\n * arch: String - The build architecture (ARM64, x86, x64)\n * singleproc: Boolean - opt out of multi-proc builds\n * emulator: Boolean - Deploy to the emulator\n * device: Boolean - Deploy to a device\n * target: String - Device GUID to deploy to\n * remote-debugging: Boolean - Run using remote JS proxy\n * logging: Boolean - Enables logging\n * no-packager: Boolean - Do not launch packager while building\n * bundle: Boolean - Enable Bundle configuration.\n * no-launch: Boolean - Do not launch the app after deployment\n * no-build: Boolean - Do not build the solution\n * no-deploy: Boolean - Do not deploy the app\n * deploy-from-layout: Force deploy from layout, even in release builds\n * sln: String - Solution file to build\n * msbuildprops: String - Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2\n * direct-debugging: Number - Enable direct debugging on specified port\n * no-telemetry: Boolean - Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI\n */\nexport interface RunWindowsOptions {\n release?: boolean;\n root: string;\n arch: BuildArch;\n singleproc?: boolean;\n emulator?: boolean;\n device?: boolean;\n target?: string;\n remoteDebugging?: string;\n logging: boolean;\n packager: boolean;\n bundle: boolean;\n launch: boolean;\n autolink: boolean;\n build: boolean;\n deploy: boolean;\n deployFromLayout?: boolean;\n sln?: string;\n proj?: string;\n msbuildprops?: string;\n buildLogDirectory?: string;\n info: boolean;\n directDebugging?: number;\n telemetry?: boolean;\n}\n\nexport const runWindowsOptions: CommandOption[] = [\n {\n name: '--release',\n description: 'Specifies a release build',\n },\n {\n name: '--root [string]',\n description:\n 'Override the root directory for the windows build which contains the windows folder.',\n default: config => config.root,\n },\n {\n name: '--arch [string]',\n description: 'The build architecture (ARM64, x86, x64)',\n default: 'x86',\n parse: parseBuildArch,\n },\n {\n name: '--singleproc',\n description: 'Disables multi-proc build',\n },\n {\n name: '--emulator',\n description: 'Deploys the app to an emulator',\n },\n {\n name: '--device',\n description: 'Deploys the app to a connected device',\n },\n {\n name: '--target [string]',\n description: 'Deploys the app to the specified GUID for a device.',\n },\n {\n name: '--remote-debugging',\n description: 'Deploys the app in remote debugging mode.',\n },\n {\n name: '--logging',\n description: 'Enables logging',\n default: false,\n },\n {\n name: '--no-packager',\n description: 'Do not launch packager while building',\n },\n {\n name: '--bundle',\n description:\n 'Enable Bundle configuration and it would be ReleaseBundle/DebugBundle other than Release/Debug',\n default: false,\n },\n {\n name: '--no-launch',\n description: 'Do not launch the app after deployment',\n default: false,\n },\n {\n name: '--no-autolink',\n description: 'Do not run autolinking',\n default: false,\n },\n {\n name: '--no-build',\n description: 'Do not build the solution',\n default: false,\n },\n {\n name: '--no-deploy',\n description: 'Do not deploy the app',\n default: false,\n },\n {\n name: '--deploy-from-layout',\n description: 'Force deploy from layout, even in release builds',\n default: false,\n },\n {\n name: '--sln [string]',\n description:\n \"Override the app solution file determined by 'react-native config', e.g. windows\\\\myApp.sln\",\n default: undefined,\n },\n {\n name: '--proj [string]',\n description:\n \"Override the app project file determined by 'react-native config', e.g. windows\\\\myApp\\\\myApp.vcxproj\",\n default: undefined,\n },\n {\n name: '--msbuildprops [string]',\n description:\n 'Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2',\n },\n {\n name: '--buildLogDirectory [string]',\n description: 'Optional directory where msbuild log files should be stored',\n },\n {\n name: '--info',\n description: 'Dump environment information',\n default: false,\n },\n {\n name: '--direct-debugging [number]',\n description: 'Enable direct debugging on specified port',\n parse: parseDirectDebuggingPort,\n },\n {\n name: '--no-telemetry',\n description:\n 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',\n default: true,\n },\n];\n\nfunction parseBuildArch(arg: string): BuildArch {\n const supportedArches: BuildArch[] = ['x86', 'x64', 'ARM64'];\n for (const supported of supportedArches) {\n if (arg.toLowerCase() === supported.toLowerCase()) {\n return supported;\n }\n }\n\n errorOut(`Unrecognized --arch '${arg}'. Expected one of ${supportedArches}`);\n}\n\nfunction parseDirectDebuggingPort(arg: string): number {\n const num = parseInt(arg, 10);\n\n if (!Number.isInteger(num)) {\n errorOut(`Expected argument '--direct-debugging' to be a number`);\n }\n if (num < 1024 || num >= 65535) {\n errorOut('Direct debugging port it out of range');\n }\n\n return num;\n}\n\nfunction errorOut(arg: string): never {\n console.error(arg);\n process.exit(1);\n}\n"]}
1
+ {"version":3,"file":"runWindowsOptions.js","sourceRoot":"","sources":["../../src/runWindows/runWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,4CAAoB;AAsDP,QAAA,iBAAiB,GAAoB;IAChD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,2BAA2B;KACzC;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,sFAAsF;QACxF,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI;KACjC;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,0CAA0C;QACvD,OAAO,EA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,6BAA6B;QACnC,WAAW,EAAE,2CAA2C;QACxD,KAAK,EAAE,wBAAwB;KAChC;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uGAAuG;KAC1G;CACF,CAAC;AAEF,SAAS,cAAc,CAAC,GAAW;IACjC,MAAM,eAAe,GAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7D,KAAK,MAAM,SAAS,IAAI,eAAe,EAAE;QACvC,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,EAAE;YACjD,OAAO,SAAS,CAAC;SAClB;KACF;IAED,QAAQ,CAAC,wBAAwB,GAAG,sBAAsB,eAAe,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,wBAAwB,CAAC,GAAW;IAC3C,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAE9B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;QAC1B,QAAQ,CAAC,uDAAuD,CAAC,CAAC;KACnE;IACD,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,IAAI,KAAK,EAAE;QAC9B,QAAQ,CAAC,uCAAuC,CAAC,CAAC;KACnD;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW;IAC3B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport os from 'os';\nimport {CommandOption} from '@react-native-community/cli-types';\n\nexport type BuildArch = 'x86' | 'x64' | 'ARM64';\nexport type BuildConfig = 'Debug' | 'DebugBundle' | 'Release' | 'ReleaseBundle';\n\n/**\n * * Options are the following:\n * release: Boolean - Specifies release build\n * root: String - The root of the application\n * arch: String - The build architecture (ARM64, x86, x64)\n * singleproc: Boolean - opt out of multi-proc builds\n * emulator: Boolean - Deploy to the emulator\n * device: Boolean - Deploy to a device\n * target: String - Device GUID to deploy to\n * remote-debugging: Boolean - Run using remote JS proxy\n * logging: Boolean - Enables logging\n * no-packager: Boolean - Do not launch packager while building\n * bundle: Boolean - Enable Bundle configuration.\n * no-launch: Boolean - Do not launch the app after deployment\n * no-build: Boolean - Do not build the solution\n * no-deploy: Boolean - Do not deploy the app\n * deploy-from-layout: Force deploy from layout, even in release builds\n * sln: String - Solution file to build\n * msbuildprops: String - Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2\n * direct-debugging: Number - Enable direct debugging on specified port\n * no-telemetry: Boolean - Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI\n */\nexport interface RunWindowsOptions {\n release?: boolean;\n root: string;\n arch: BuildArch;\n singleproc?: boolean;\n emulator?: boolean;\n device?: boolean;\n target?: string;\n remoteDebugging?: string;\n logging?: boolean;\n packager?: boolean;\n bundle?: boolean;\n launch?: boolean;\n autolink?: boolean;\n build?: boolean;\n deploy?: boolean;\n deployFromLayout?: boolean;\n sln?: string;\n proj?: string;\n msbuildprops?: string;\n buildLogDirectory?: string;\n info?: boolean;\n directDebugging?: number;\n telemetry?: boolean;\n}\n\nexport const runWindowsOptions: CommandOption[] = [\n {\n name: '--release',\n description: 'Specifies a release build',\n },\n {\n name: '--root [string]',\n description:\n 'Override the root directory for the windows build which contains the windows folder.',\n default: (config) => config.root,\n },\n {\n name: '--arch [string]',\n description: 'The build architecture (ARM64, x86, x64)',\n default: os.arch(),\n parse: parseBuildArch,\n },\n {\n name: '--singleproc',\n description: 'Disables multi-proc build',\n },\n {\n name: '--emulator',\n description: 'Deploys the app to an emulator',\n },\n {\n name: '--device',\n description: 'Deploys the app to a connected device',\n },\n {\n name: '--target [string]',\n description: 'Deploys the app to the specified GUID for a device.',\n },\n {\n name: '--remote-debugging',\n description: 'Deploys the app in remote debugging mode.',\n },\n {\n name: '--logging',\n description: 'Enables logging',\n },\n {\n name: '--no-packager',\n description: 'Do not launch packager while building',\n },\n {\n name: '--bundle',\n description:\n 'Enable Bundle configuration and it would be ReleaseBundle/DebugBundle other than Release/Debug',\n },\n {\n name: '--no-launch',\n description: 'Do not launch the app after deployment',\n },\n {\n name: '--no-autolink',\n description: 'Do not run autolinking',\n },\n {\n name: '--no-build',\n description: 'Do not build the solution',\n },\n {\n name: '--no-deploy',\n description: 'Do not deploy the app',\n },\n {\n name: '--deploy-from-layout',\n description: 'Force deploy from layout',\n },\n {\n name: '--sln [string]',\n description:\n \"Override the app solution file determined by 'react-native config', e.g. windows\\\\myApp.sln\",\n default: undefined,\n },\n {\n name: '--proj [string]',\n description:\n \"Override the app project file determined by 'react-native config', e.g. windows\\\\myApp\\\\myApp.vcxproj\",\n default: undefined,\n },\n {\n name: '--msbuildprops [string]',\n description:\n 'Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2',\n },\n {\n name: '--buildLogDirectory [string]',\n description: 'Optional directory where msbuild log files should be stored',\n },\n {\n name: '--info',\n description: 'Dump environment information',\n },\n {\n name: '--direct-debugging [number]',\n description: 'Enable direct debugging on specified port',\n parse: parseDirectDebuggingPort,\n },\n {\n name: '--no-telemetry',\n description:\n 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',\n },\n];\n\nfunction parseBuildArch(arg: string): BuildArch {\n const supportedArches: BuildArch[] = ['x86', 'x64', 'ARM64'];\n for (const supported of supportedArches) {\n if (arg.toLowerCase() === supported.toLowerCase()) {\n return supported;\n }\n }\n\n errorOut(`Unrecognized --arch '${arg}'. Expected one of ${supportedArches}`);\n}\n\nfunction parseDirectDebuggingPort(arg: string): number {\n const num = parseInt(arg, 10);\n\n if (!Number.isInteger(num)) {\n errorOut(`Expected argument '--direct-debugging' to be a number`);\n }\n if (num < 1024 || num >= 65535) {\n errorOut('Direct debugging port it out of range');\n }\n\n return num;\n}\n\nfunction errorOut(arg: string): never {\n console.error(arg);\n process.exit(1);\n}\n"]}