@react-native-windows/cli 0.0.0-canary.21 → 0.0.0-canary.211

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/README.md +47 -0
  2. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +87 -0
  3. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +661 -0
  4. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js.map +1 -0
  5. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -0
  6. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +33 -0
  7. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js.map +1 -0
  8. package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -0
  9. package/lib-commonjs/commands/codegenWindows/codegenWindows.js +206 -0
  10. package/lib-commonjs/commands/codegenWindows/codegenWindows.js.map +1 -0
  11. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -0
  12. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +23 -0
  13. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js.map +1 -0
  14. package/lib-commonjs/{config → commands/config}/configUtils.d.ts +123 -93
  15. package/lib-commonjs/commands/config/configUtils.js +381 -0
  16. package/lib-commonjs/commands/config/configUtils.js.map +1 -0
  17. package/lib-commonjs/{config → commands/config}/dependencyConfig.d.ts +37 -37
  18. package/lib-commonjs/commands/config/dependencyConfig.js +228 -0
  19. package/lib-commonjs/commands/config/dependencyConfig.js.map +1 -0
  20. package/lib-commonjs/{config → commands/config}/projectConfig.d.ts +27 -24
  21. package/lib-commonjs/{config → commands/config}/projectConfig.js +180 -120
  22. package/lib-commonjs/commands/config/projectConfig.js.map +1 -0
  23. package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -0
  24. package/lib-commonjs/commands/healthCheck/healthCheckList.js +21 -0
  25. package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -0
  26. package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -0
  27. package/lib-commonjs/commands/healthCheck/healthChecks.js +124 -0
  28. package/lib-commonjs/commands/healthCheck/healthChecks.js.map +1 -0
  29. package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -0
  30. package/lib-commonjs/commands/initWindows/initWindows.js +244 -0
  31. package/lib-commonjs/commands/initWindows/initWindows.js.map +1 -0
  32. package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -0
  33. package/lib-commonjs/commands/initWindows/initWindowsOptions.js +38 -0
  34. package/lib-commonjs/commands/initWindows/initWindowsOptions.js.map +1 -0
  35. package/lib-commonjs/{runWindows → commands/runWindows}/runWindows.d.ts +10 -10
  36. package/lib-commonjs/commands/runWindows/runWindows.js +322 -0
  37. package/lib-commonjs/commands/runWindows/runWindows.js.map +1 -0
  38. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.d.ts +56 -52
  39. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.js +132 -131
  40. package/lib-commonjs/commands/runWindows/runWindowsOptions.js.map +1 -0
  41. package/lib-commonjs/e2etest/autolink.test.d.ts +6 -0
  42. package/lib-commonjs/e2etest/autolink.test.js +367 -0
  43. package/lib-commonjs/e2etest/autolink.test.js.map +1 -0
  44. package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -0
  45. package/lib-commonjs/e2etest/dependencyConfig.test.js +130 -0
  46. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -0
  47. package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -0
  48. package/lib-commonjs/e2etest/healthChecks.test.js +31 -0
  49. package/lib-commonjs/e2etest/healthChecks.test.js.map +1 -0
  50. package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -0
  51. package/lib-commonjs/e2etest/initWindows.test.js +43 -0
  52. package/lib-commonjs/e2etest/initWindows.test.js.map +1 -0
  53. package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -0
  54. package/lib-commonjs/e2etest/projectConfig.test.js +111 -0
  55. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -0
  56. package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -0
  57. package/lib-commonjs/e2etest/projectConfig.utils.js +77 -0
  58. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -0
  59. package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -0
  60. package/lib-commonjs/e2etest/runWindows.test.js +61 -0
  61. package/lib-commonjs/e2etest/runWindows.test.js.map +1 -0
  62. package/lib-commonjs/e2etest/typesUpToDate.test.d.ts +6 -0
  63. package/lib-commonjs/e2etest/typesUpToDate.test.js +21 -0
  64. package/lib-commonjs/e2etest/typesUpToDate.test.js.map +1 -0
  65. package/lib-commonjs/generator-common/index.d.ts +39 -23
  66. package/lib-commonjs/generator-common/index.js +242 -221
  67. package/lib-commonjs/generator-common/index.js.map +1 -1
  68. package/lib-commonjs/generator-windows/index.d.ts +10 -10
  69. package/lib-commonjs/generator-windows/index.js +316 -352
  70. package/lib-commonjs/generator-windows/index.js.map +1 -1
  71. package/lib-commonjs/index.d.ts +50 -46
  72. package/lib-commonjs/index.js +77 -39
  73. package/lib-commonjs/index.js.map +1 -1
  74. package/lib-commonjs/{runWindows/utils → utils}/build.d.ts +12 -13
  75. package/lib-commonjs/{runWindows/utils → utils}/build.js +84 -91
  76. package/lib-commonjs/utils/build.js.map +1 -0
  77. package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.d.ts +6 -6
  78. package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.js +69 -65
  79. package/lib-commonjs/utils/checkRequirements.js.map +1 -0
  80. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.d.ts +21 -13
  81. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.js +149 -113
  82. package/lib-commonjs/utils/commandWithProgress.js.map +1 -0
  83. package/lib-commonjs/{runWindows/utils → utils}/deploy.d.ts +12 -12
  84. package/lib-commonjs/utils/deploy.js +354 -0
  85. package/lib-commonjs/utils/deploy.js.map +1 -0
  86. package/lib-commonjs/{runWindows/utils → utils}/info.d.ts +6 -6
  87. package/lib-commonjs/{runWindows/utils → utils}/info.js +28 -25
  88. package/lib-commonjs/utils/info.js.map +1 -0
  89. package/lib-commonjs/utils/msbuildtools.d.ts +28 -0
  90. package/lib-commonjs/utils/msbuildtools.js +274 -0
  91. package/lib-commonjs/utils/msbuildtools.js.map +1 -0
  92. package/lib-commonjs/utils/pathHelpers.d.ts +9 -0
  93. package/lib-commonjs/utils/pathHelpers.js +37 -0
  94. package/lib-commonjs/utils/pathHelpers.js.map +1 -0
  95. package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -0
  96. package/lib-commonjs/utils/telemetryHelpers.js +121 -0
  97. package/lib-commonjs/utils/telemetryHelpers.js.map +1 -0
  98. package/lib-commonjs/{runWindows/utils → utils}/version.d.ts +19 -19
  99. package/lib-commonjs/{runWindows/utils → utils}/version.js +109 -109
  100. package/lib-commonjs/utils/version.js.map +1 -0
  101. package/lib-commonjs/{runWindows/utils → utils}/vsInstalls.d.ts +34 -34
  102. package/lib-commonjs/utils/vsInstalls.js +100 -0
  103. package/lib-commonjs/utils/vsInstalls.js.map +1 -0
  104. package/lib-commonjs/{runWindows/utils → utils}/vstools.d.ts +16 -15
  105. package/lib-commonjs/utils/vstools.js +190 -0
  106. package/lib-commonjs/utils/vstools.js.map +1 -0
  107. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.d.ts +24 -24
  108. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.js +108 -105
  109. package/lib-commonjs/utils/winappdeploytool.js.map +1 -0
  110. package/package.json +50 -30
  111. package/{powershell → src/powershell}/Add-AppDevPackage.ps1 +2 -2
  112. package/src/powershell/Eval-MsBuildProperties.ps1 +156 -0
  113. package/{powershell → src/powershell}/WindowsStoreAppUtils.ps1 +10 -0
  114. package/CHANGELOG.json +0 -317
  115. package/CHANGELOG.md +0 -159
  116. package/lib-commonjs/config/configUtils.js +0 -253
  117. package/lib-commonjs/config/configUtils.js.map +0 -1
  118. package/lib-commonjs/config/dependencyConfig.js +0 -167
  119. package/lib-commonjs/config/dependencyConfig.js.map +0 -1
  120. package/lib-commonjs/config/projectConfig.js.map +0 -1
  121. package/lib-commonjs/runWindows/runWindows.js +0 -159
  122. package/lib-commonjs/runWindows/runWindows.js.map +0 -1
  123. package/lib-commonjs/runWindows/runWindowsOptions.js.map +0 -1
  124. package/lib-commonjs/runWindows/utils/autolink.d.ts +0 -7
  125. package/lib-commonjs/runWindows/utils/autolink.js +0 -353
  126. package/lib-commonjs/runWindows/utils/autolink.js.map +0 -1
  127. package/lib-commonjs/runWindows/utils/build.js.map +0 -1
  128. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +0 -1
  129. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +0 -1
  130. package/lib-commonjs/runWindows/utils/deploy.js +0 -247
  131. package/lib-commonjs/runWindows/utils/deploy.js.map +0 -1
  132. package/lib-commonjs/runWindows/utils/info.js.map +0 -1
  133. package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +0 -22
  134. package/lib-commonjs/runWindows/utils/msbuildtools.js +0 -195
  135. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +0 -1
  136. package/lib-commonjs/runWindows/utils/version.js.map +0 -1
  137. package/lib-commonjs/runWindows/utils/vsInstalls.js +0 -70
  138. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +0 -1
  139. package/lib-commonjs/runWindows/utils/vstools.js +0 -150
  140. package/lib-commonjs/runWindows/utils/vstools.js.map +0 -1
  141. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +0 -1
@@ -0,0 +1,322 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || function (mod) {
24
+ if (mod && mod.__esModule) return mod;
25
+ var result = {};
26
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
+ __setModuleDefault(result, mod);
28
+ return result;
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.runWindowsCommand = void 0;
35
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
36
+ const path_1 = __importDefault(require("path"));
37
+ const telemetry_1 = require("@react-native-windows/telemetry");
38
+ const build = __importStar(require("../../utils/build"));
39
+ const chalk_1 = __importDefault(require("chalk"));
40
+ const deploy = __importStar(require("../../utils/deploy"));
41
+ const commandWithProgress_1 = require("../../utils/commandWithProgress");
42
+ const telemetryHelpers_1 = require("../../utils/telemetryHelpers");
43
+ const pathHelpers = __importStar(require("../../utils/pathHelpers"));
44
+ const info = __importStar(require("../../utils/info"));
45
+ const msbuildtools_1 = __importDefault(require("../../utils/msbuildtools"));
46
+ const runWindowsOptions_1 = require("./runWindowsOptions");
47
+ const autolinkWindows_1 = require("../autolinkWindows/autolinkWindows");
48
+ /**
49
+ * Sanitizes the given option for telemetry.
50
+ * @param key The key of the option.
51
+ * @param value The unsanitized value of the option.
52
+ * @returns The sanitized value of the option.
53
+ */
54
+ // eslint-disable-next-line complexity
55
+ function optionSanitizer(key, value) {
56
+ // Do not add a default case here.
57
+ // Strings risking PII should just return true if present, false otherwise.
58
+ // All others should return the value (or false if undefined).
59
+ switch (key) {
60
+ case 'root':
61
+ case 'target':
62
+ case 'sln':
63
+ case 'proj':
64
+ case 'buildLogDirectory':
65
+ return value === undefined ? false : true; // Strip PII
66
+ case 'msbuildprops':
67
+ return value === undefined ? 0 : value.split(',').length; // Convert to count
68
+ case 'release':
69
+ case 'arch':
70
+ case 'singleproc':
71
+ case 'emulator':
72
+ case 'device':
73
+ case 'remoteDebugging':
74
+ case 'logging':
75
+ case 'packager':
76
+ case 'bundle':
77
+ case 'launch':
78
+ case 'autolink':
79
+ case 'build':
80
+ case 'deploy':
81
+ case 'deployFromLayout':
82
+ case 'info':
83
+ case 'directDebugging':
84
+ case 'telemetry':
85
+ return value === undefined ? false : value; // Return value
86
+ }
87
+ }
88
+ /**
89
+ * Get the extra props to add to the `run-windows` telemetry event.
90
+ * @returns The extra props.
91
+ */
92
+ async function getExtraProps() {
93
+ const extraProps = {
94
+ phase: runWindowsPhase,
95
+ hasRunRnwDependencies,
96
+ msBuildProps: evaluateMSBuildPropsCallback
97
+ ? evaluateMSBuildPropsCallback()
98
+ : {},
99
+ };
100
+ return extraProps;
101
+ }
102
+ let runWindowsPhase = 'None';
103
+ let hasRunRnwDependencies = false;
104
+ let evaluateMSBuildPropsCallback;
105
+ /**
106
+ * The function run when calling `react-native run-windows`.
107
+ * @param args Unprocessed args passed from react-native CLI.
108
+ * @param config Config passed from react-native CLI.
109
+ * @param options Options passed from react-native CLI.
110
+ */
111
+ async function runWindows(args, config, options) {
112
+ await (0, telemetryHelpers_1.startTelemetrySession)('run-windows', config, options, (0, telemetryHelpers_1.getDefaultOptions)(config, runWindowsOptions_1.runWindowsOptions), optionSanitizer);
113
+ // https://github.com/yarnpkg/yarn/issues/8334 - Yarn on Windows breaks apps that read from the environment variables
114
+ // Yarn will run node via CreateProcess and pass npm_config_* variables in lowercase without unifying their value
115
+ // with their possibly existing uppercase counterparts. This breaks programs that read from the environment block
116
+ // and write to a case-insensitive dictionary since they expect to encounter each variable only once.
117
+ // The values of the lowercase variables are the one npm actually wants to use, plus they are seeded from the
118
+ // uppercase variable values one if there are no overrides.
119
+ delete process.env.NPM_CONFIG_CACHE;
120
+ delete process.env.NPM_CONFIG_PREFIX;
121
+ if (process.env.LocalAppData) {
122
+ hasRunRnwDependencies = fs_1.default.existsSync(path_1.default.join(process.env.LocalAppData, 'rnw-dependencies.txt')); // CODESYNC \vnext\scripts\rnw-dependencies.ps1
123
+ }
124
+ let runWindowsError;
125
+ if (options.info) {
126
+ runWindowsPhase = 'Info';
127
+ try {
128
+ const output = await info.getEnvironmentInfo();
129
+ console.log(output.trimEnd());
130
+ console.log(' Installed UWP SDKs:');
131
+ const sdks = msbuildtools_1.default.getAllAvailableUAPVersions();
132
+ sdks.forEach(version => console.log(' ' + version));
133
+ }
134
+ catch (ex) {
135
+ runWindowsError =
136
+ ex instanceof Error ? ex : new Error(String(ex));
137
+ telemetry_1.Telemetry.trackException(runWindowsError);
138
+ (0, commandWithProgress_1.newError)('Unable to print environment info.\n' + runWindowsError.toString());
139
+ }
140
+ await (0, telemetryHelpers_1.endTelemetrySession)(runWindowsError, getExtraProps);
141
+ (0, commandWithProgress_1.setExitProcessWithError)(options.logging, runWindowsError);
142
+ return;
143
+ }
144
+ try {
145
+ await runWindowsInternal(args, config, options);
146
+ }
147
+ catch (ex) {
148
+ runWindowsError =
149
+ ex instanceof Error ? ex : new Error(String(ex));
150
+ telemetry_1.Telemetry.trackException(runWindowsError);
151
+ if (!hasRunRnwDependencies) {
152
+ const rnwDependenciesPath = path_1.default.join(pathHelpers.resolveRnwRoot([process.cwd(), __dirname]), 'scripts/rnw-dependencies.ps1');
153
+ (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`);
154
+ }
155
+ }
156
+ await (0, telemetryHelpers_1.endTelemetrySession)(runWindowsError, getExtraProps);
157
+ (0, commandWithProgress_1.setExitProcessWithError)(options.logging, runWindowsError);
158
+ }
159
+ /**
160
+ * Performs build deploy and launch of RNW apps.
161
+ * @param args Unprocessed args passed from react-native CLI.
162
+ * @param config Config passed from react-native CLI.
163
+ * @param options Options passed from react-native CLI.
164
+ */
165
+ async function runWindowsInternal(args, config, options) {
166
+ const verbose = options.logging === true;
167
+ if (verbose) {
168
+ (0, commandWithProgress_1.newInfo)('Verbose: ON');
169
+ }
170
+ // Get the solution file
171
+ let slnFile;
172
+ runWindowsPhase = 'FindSolution';
173
+ try {
174
+ slnFile = build.getAppSolutionFile(options, config);
175
+ }
176
+ catch (e) {
177
+ (0, commandWithProgress_1.newError)(`Couldn't get app solution information. ${e.message}`);
178
+ throw e;
179
+ }
180
+ let buildTools;
181
+ runWindowsPhase = 'FindBuildTools';
182
+ try {
183
+ buildTools = msbuildtools_1.default.findAvailableVersion(options.arch, verbose);
184
+ }
185
+ catch (error) {
186
+ (0, commandWithProgress_1.newWarn)('No public VS release found');
187
+ // Try prerelease
188
+ try {
189
+ (0, commandWithProgress_1.newInfo)('Trying pre-release VS');
190
+ buildTools = msbuildtools_1.default.findAvailableVersion(options.arch, verbose, true);
191
+ }
192
+ catch (e) {
193
+ (0, commandWithProgress_1.newError)(e.message);
194
+ throw error;
195
+ }
196
+ }
197
+ // Set up the callback to capture MSBuild properties after the command completes
198
+ evaluateMSBuildPropsCallback = () => {
199
+ const projectFile = build.getAppProjectFile(options, config);
200
+ if (projectFile) {
201
+ if (verbose) {
202
+ (0, commandWithProgress_1.newInfo)('Gathering MSBuild data for telemetry.');
203
+ }
204
+ const msBuildPropertiesJsonPath = path_1.default.resolve(path_1.default.dirname(projectFile), 'Generated Files', 'msbuildproperties.g.json');
205
+ if (fs_1.default.existsSync(msBuildPropertiesJsonPath)) {
206
+ if (verbose) {
207
+ (0, commandWithProgress_1.newInfo)('Loading properties from msbuildproperties.g.json');
208
+ }
209
+ return fs_1.default.readJsonFileSync(msBuildPropertiesJsonPath);
210
+ }
211
+ if (verbose) {
212
+ (0, commandWithProgress_1.newInfo)('Unable to find msbuildproperties.g.json');
213
+ }
214
+ }
215
+ return {};
216
+ };
217
+ // Restore packages.config files for dependencies that don't support PackageReference.
218
+ runWindowsPhase = 'RestorePackagesConfig';
219
+ const buildType = deploy.getBuildConfiguration(options);
220
+ try {
221
+ await buildTools.restorePackageConfigs(slnFile, options.arch, buildType);
222
+ }
223
+ catch (e) {
224
+ (0, commandWithProgress_1.newError)(`Couldn't restore found packages.config instances. ${e.message}`);
225
+ throw e;
226
+ }
227
+ if (options.autolink) {
228
+ runWindowsPhase = 'Autolink';
229
+ try {
230
+ const autolinkArgs = [];
231
+ const autolinkConfig = config;
232
+ const autolinkOptions = {
233
+ logging: options.logging,
234
+ check: false,
235
+ proj: options.proj,
236
+ sln: options.sln,
237
+ telemetry: options.telemetry,
238
+ };
239
+ await (0, autolinkWindows_1.autolinkWindowsInternal)(autolinkArgs, autolinkConfig, autolinkOptions);
240
+ }
241
+ catch (e) {
242
+ (0, commandWithProgress_1.newError)(`Autolinking failed. ${e.message}`);
243
+ throw e;
244
+ }
245
+ }
246
+ else {
247
+ (0, commandWithProgress_1.newInfo)('Autolink step is skipped');
248
+ }
249
+ if (options.build) {
250
+ runWindowsPhase = 'Build';
251
+ if (!slnFile) {
252
+ (0, commandWithProgress_1.newError)('Visual Studio Solution file not found. Maybe run "npx react-native-windows-init" first?');
253
+ throw new telemetry_1.CodedError('NoSolution', 'Cannot find solution file');
254
+ }
255
+ // Get build/deploy options
256
+ const msBuildProps = build.parseMsBuildProps(options);
257
+ // Disable the autolink check since we just ran it
258
+ msBuildProps.RunAutolinkCheck = 'false';
259
+ try {
260
+ await build.buildSolution(buildTools, slnFile, buildType, options.arch, msBuildProps, verbose, 'build', options.buildLogDirectory, options.singleproc);
261
+ }
262
+ catch (e) {
263
+ (0, commandWithProgress_1.newError)(`Build failed with message ${e.message}. Check your build configuration.`);
264
+ if (e.logfile) {
265
+ console.log('See', chalk_1.default.bold(e.logfile));
266
+ }
267
+ throw e;
268
+ }
269
+ }
270
+ else {
271
+ (0, commandWithProgress_1.newInfo)('Build step is skipped');
272
+ }
273
+ if (shouldLaunchPackager(options)) {
274
+ await deploy.startServerInNewWindow(options, verbose);
275
+ }
276
+ if (options.deploy) {
277
+ runWindowsPhase = 'Deploy';
278
+ if (!slnFile) {
279
+ (0, commandWithProgress_1.newError)('Visual Studio Solution file not found. Maybe run "npx react-native-windows-init" first?');
280
+ throw new telemetry_1.CodedError('NoSolution', 'Cannot find solution file');
281
+ }
282
+ try {
283
+ if (options.device || options.emulator || options.target) {
284
+ await deploy.deployToDevice(options, verbose, config);
285
+ }
286
+ else {
287
+ await deploy.deployToDesktop(options, verbose, config, buildTools);
288
+ }
289
+ }
290
+ catch (e) {
291
+ (0, commandWithProgress_1.newError)(`Failed to deploy${e ? `: ${e.message}` : ''}`);
292
+ throw e;
293
+ }
294
+ }
295
+ else {
296
+ (0, commandWithProgress_1.newInfo)('Deploy step is skipped');
297
+ }
298
+ }
299
+ function shouldLaunchPackager(options) {
300
+ return (options.packager === true &&
301
+ options.launch === true &&
302
+ options.release !== true);
303
+ }
304
+ /*
305
+ // Example of running the Windows Command
306
+ runWindows({
307
+ root: 'C:\\github\\hack\\myapp',
308
+ debug: true,
309
+ arch: 'x86',
310
+ nugetPath: 'C:\\github\\react\\react-native-windows\\local-cli\\runWindows\\.nuget\\nuget.exe'
311
+ });
312
+ */
313
+ /**
314
+ * Starts the app on a connected Windows emulator or mobile device.
315
+ */
316
+ exports.runWindowsCommand = {
317
+ name: 'run-windows',
318
+ description: 'Builds your app and starts it on a connected Windows desktop, emulator or device',
319
+ func: runWindows,
320
+ options: runWindowsOptions_1.runWindowsOptions,
321
+ };
322
+ //# sourceMappingURL=runWindows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runWindows.js","sourceRoot":"","sources":["../../../src/commands/runWindows/runWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AAExB,+DAAsE;AAGtE,yDAA2C;AAC3C,kDAA0B;AAC1B,2DAA6C;AAC7C,yEAKyC;AACzC,mEAIsC;AACtC,qEAAuD;AACvD,uDAAyC;AACzC,4EAAoD;AACpD,2DAAyE;AACzE,wEAA2E;AAG3E;;;;;GAKG;AACH,sCAAsC;AACtC,SAAS,eAAe,CAAC,GAA4B,EAAE,KAAU;IAC/D,kCAAkC;IAClC,2EAA2E;IAC3E,8DAA8D;IAC9D,QAAQ,GAAG,EAAE;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,mBAAmB;YACtB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;QACzD,KAAK,cAAc;YACjB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,mBAAmB;QAC/E,KAAK,SAAS,CAAC;QACf,KAAK,MAAM,CAAC;QACZ,KAAK,YAAY,CAAC;QAClB,KAAK,UAAU,CAAC;QAChB,KAAK,QAAQ,CAAC;QACd,KAAK,iBAAiB,CAAC;QACvB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,UAAU,CAAC;QAChB,KAAK,OAAO,CAAC;QACb,KAAK,QAAQ,CAAC;QACd,KAAK,kBAAkB,CAAC;QACxB,KAAK,MAAM,CAAC;Q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ACpF,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';\n\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport {Command, Config} from '@react-native-community/cli-types';\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 pathHelpers from '../../utils/pathHelpers';\nimport * as info from '../../utils/info';\nimport MSBuildTools from '../../utils/msbuildtools';\nimport {runWindowsOptions, RunWindowsOptions} from './runWindowsOptions';\nimport {autolinkWindowsInternal} from '../autolinkWindows/autolinkWindows';\nimport {AutoLinkOptions} from '../autolinkWindows/autolinkWindowsOptions';\n\n/**\n * Sanitizes the given option for telemetry.\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 msBuildProps: evaluateMSBuildPropsCallback\n ? evaluateMSBuildPropsCallback()\n : {},\n };\n return extraProps;\n}\n\n/**\n * Labels used by telemetry to represent current operation\n */\ntype RunWindowsPhase =\n | 'None'\n | 'Info'\n | 'FindSolution'\n | 'FindBuildTools'\n | 'Autolink'\n | 'RestorePackagesConfig'\n | 'Build'\n | 'Deploy';\n\nlet runWindowsPhase: RunWindowsPhase = 'None';\n\nlet hasRunRnwDependencies: boolean = false;\n\nlet evaluateMSBuildPropsCallback:\n | (() => Record<string, string> | null)\n | undefined;\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 runWindowsPhase = '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 rnwDependenciesPath = path.join(\n pathHelpers.resolveRnwRoot([process.cwd(), __dirname]),\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: string | null;\n runWindowsPhase = 'FindSolution';\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 // Set up the callback to capture MSBuild properties after the command completes\n evaluateMSBuildPropsCallback = () => {\n const projectFile = build.getAppProjectFile(options, config);\n if (projectFile) {\n if (verbose) {\n newInfo('Gathering MSBuild data for telemetry.');\n }\n\n const msBuildPropertiesJsonPath = path.resolve(\n path.dirname(projectFile),\n 'Generated Files',\n 'msbuildproperties.g.json',\n );\n\n if (fs.existsSync(msBuildPropertiesJsonPath)) {\n if (verbose) {\n newInfo('Loading properties from msbuildproperties.g.json');\n }\n return fs.readJsonFileSync(msBuildPropertiesJsonPath);\n }\n\n if (verbose) {\n newInfo('Unable to find msbuildproperties.g.json');\n }\n }\n\n return {};\n };\n\n // Restore packages.config files for dependencies that don't support PackageReference.\n runWindowsPhase = 'RestorePackagesConfig';\n const buildType = deploy.getBuildConfiguration(options);\n try {\n await buildTools.restorePackageConfigs(slnFile, options.arch, buildType);\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 if (options.autolink) {\n runWindowsPhase = 'Autolink';\n try {\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 await autolinkWindowsInternal(\n autolinkArgs,\n autolinkConfig,\n autolinkOptions,\n );\n } catch (e) {\n newError(`Autolinking failed. ${(e as Error).message}`);\n throw e;\n }\n } else {\n newInfo('Autolink step is skipped');\n }\n\n if (options.build) {\n runWindowsPhase = 'Build';\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 msBuildProps = build.parseMsBuildProps(options);\n\n // Disable the autolink check since we just ran it\n msBuildProps.RunAutolinkCheck = 'false';\n\n try {\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 = 'Deploy';\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 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"]}
@@ -1,52 +1,56 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- import { CommandOption } from '@react-native-community/cli-types';
7
- export declare type BuildArch = 'x86' | 'x64' | 'ARM' | 'ARM64';
8
- export declare type BuildConfig = 'Debug' | 'DebugBundle' | 'Release' | 'ReleaseBundle';
9
- /**
10
- * * Options are the following:
11
- * release: Boolean - Specifies release build
12
- * root: String - The root of the application
13
- * arch: String - The build architecture (x86, x64, ARM, Any CPU)
14
- * singleproc: Boolean - opt out of multi-proc builds
15
- * emulator: Boolean - Deploy to the emulator
16
- * device: Boolean - Deploy to a device
17
- * target: String - Device GUID to deploy to
18
- * remote-debugging: Boolean - Run using remote JS proxy
19
- * logging: Boolean - Enables logging
20
- * no-packager: Boolean - Do not launch packager while building
21
- * bundle: Boolean - Enable Bundle configuration.
22
- * no-launch: Boolean - Do not launch the app after deployment
23
- * no-build: Boolean - Do not build the solution
24
- * no-deploy: Boolean - Do not deploy the app
25
- * sln: String - Solution file to build
26
- * msbuildprops: String - Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2
27
- * direct-debugging: Number - Enable direct debugging on specified port
28
- */
29
- export interface RunWindowsOptions {
30
- release?: boolean;
31
- root: string;
32
- arch: BuildArch;
33
- singleproc?: boolean;
34
- emulator?: boolean;
35
- device?: boolean;
36
- target?: string;
37
- remoteDebugging?: string;
38
- logging: boolean;
39
- packager: boolean;
40
- bundle: boolean;
41
- launch: boolean;
42
- autolink: boolean;
43
- build: boolean;
44
- deploy: boolean;
45
- sln?: string;
46
- proj?: string;
47
- msbuildprops?: string;
48
- buildLogDirectory?: string;
49
- info: boolean;
50
- directDebugging?: number;
51
- }
52
- export declare const runWindowsOptions: CommandOption[];
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import { CommandOption } from '@react-native-community/cli-types';
7
+ export type BuildArch = 'x86' | 'x64' | 'ARM64';
8
+ export type BuildConfig = 'Debug' | 'DebugBundle' | 'Release' | 'ReleaseBundle';
9
+ /**
10
+ * * Options are the following:
11
+ * release: Boolean - Specifies release build
12
+ * root: String - The root of the application
13
+ * arch: String - The build architecture (ARM64, x86, x64)
14
+ * singleproc: Boolean - opt out of multi-proc builds
15
+ * emulator: Boolean - Deploy to the emulator
16
+ * device: Boolean - Deploy to a device
17
+ * target: String - Device GUID to deploy to
18
+ * remote-debugging: Boolean - Run using remote JS proxy
19
+ * logging: Boolean - Enables logging
20
+ * no-packager: Boolean - Do not launch packager while building
21
+ * bundle: Boolean - Enable Bundle configuration.
22
+ * no-launch: Boolean - Do not launch the app after deployment
23
+ * no-build: Boolean - Do not build the solution
24
+ * no-deploy: Boolean - Do not deploy the app
25
+ * deploy-from-layout: Force deploy from layout, even in release builds
26
+ * sln: String - Solution file to build
27
+ * msbuildprops: String - Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2
28
+ * direct-debugging: Number - Enable direct debugging on specified port
29
+ * no-telemetry: Boolean - Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI
30
+ */
31
+ export interface RunWindowsOptions {
32
+ release?: boolean;
33
+ root: string;
34
+ arch: BuildArch;
35
+ singleproc?: boolean;
36
+ emulator?: boolean;
37
+ device?: boolean;
38
+ target?: string;
39
+ remoteDebugging?: string;
40
+ logging?: boolean;
41
+ packager?: boolean;
42
+ bundle?: boolean;
43
+ launch?: boolean;
44
+ autolink?: boolean;
45
+ build?: boolean;
46
+ deploy?: boolean;
47
+ deployFromLayout?: boolean;
48
+ sln?: string;
49
+ proj?: string;
50
+ msbuildprops?: string;
51
+ buildLogDirectory?: string;
52
+ info?: boolean;
53
+ directDebugging?: number;
54
+ telemetry?: boolean;
55
+ }
56
+ export declare const runWindowsOptions: CommandOption[];