@react-native-windows/cli 0.0.0-canary.27 → 0.0.0-canary.271

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 (145) hide show
  1. package/README.md +118 -0
  2. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +88 -0
  3. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +705 -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 +211 -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 +141 -93
  15. package/lib-commonjs/commands/config/configUtils.js +433 -0
  16. package/lib-commonjs/commands/config/configUtils.js.map +1 -0
  17. package/lib-commonjs/{config → commands/config}/dependencyConfig.d.ts +38 -37
  18. package/lib-commonjs/commands/config/dependencyConfig.js +230 -0
  19. package/lib-commonjs/commands/config/dependencyConfig.js.map +1 -0
  20. package/lib-commonjs/{config → commands/config}/projectConfig.d.ts +28 -24
  21. package/lib-commonjs/commands/config/projectConfig.js +191 -0
  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 +121 -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 +278 -0
  31. package/lib-commonjs/commands/initWindows/initWindows.js.map +1 -0
  32. package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +16 -0
  33. package/lib-commonjs/commands/initWindows/initWindowsOptions.js +42 -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 +327 -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 +110 -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 +112 -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 +341 -364
  70. package/lib-commonjs/generator-windows/index.js.map +1 -1
  71. package/lib-commonjs/index.d.ts +50 -47
  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 +89 -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 +280 -0
  91. package/lib-commonjs/utils/msbuildtools.js.map +1 -0
  92. package/lib-commonjs/utils/nameHelpers.d.ts +9 -0
  93. package/lib-commonjs/utils/nameHelpers.js +46 -0
  94. package/lib-commonjs/utils/nameHelpers.js.map +1 -0
  95. package/lib-commonjs/utils/pathHelpers.d.ts +6 -0
  96. package/lib-commonjs/utils/pathHelpers.js +19 -0
  97. package/lib-commonjs/utils/pathHelpers.js.map +1 -0
  98. package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -0
  99. package/lib-commonjs/utils/telemetryHelpers.js +121 -0
  100. package/lib-commonjs/utils/telemetryHelpers.js.map +1 -0
  101. package/lib-commonjs/{runWindows/utils → utils}/version.d.ts +19 -19
  102. package/lib-commonjs/{runWindows/utils → utils}/version.js +109 -109
  103. package/lib-commonjs/utils/version.js.map +1 -0
  104. package/lib-commonjs/{runWindows/utils → utils}/vsInstalls.d.ts +34 -34
  105. package/lib-commonjs/utils/vsInstalls.js +102 -0
  106. package/lib-commonjs/utils/vsInstalls.js.map +1 -0
  107. package/lib-commonjs/{runWindows/utils → utils}/vstools.d.ts +16 -15
  108. package/lib-commonjs/utils/vstools.js +190 -0
  109. package/lib-commonjs/utils/vstools.js.map +1 -0
  110. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.d.ts +24 -24
  111. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.js +108 -105
  112. package/lib-commonjs/utils/winappdeploytool.js.map +1 -0
  113. package/package.json +50 -31
  114. package/{powershell → src/powershell}/Add-AppDevPackage.ps1 +2 -2
  115. package/src/powershell/Eval-MsBuildProperties.ps1 +156 -0
  116. package/{powershell → src/powershell}/WindowsStoreAppUtils.ps1 +10 -0
  117. package/CHANGELOG.json +0 -428
  118. package/CHANGELOG.md +0 -208
  119. package/lib-commonjs/config/configUtils.js +0 -253
  120. package/lib-commonjs/config/configUtils.js.map +0 -1
  121. package/lib-commonjs/config/dependencyConfig.js +0 -167
  122. package/lib-commonjs/config/dependencyConfig.js.map +0 -1
  123. package/lib-commonjs/config/projectConfig.js +0 -121
  124. package/lib-commonjs/config/projectConfig.js.map +0 -1
  125. package/lib-commonjs/runWindows/runWindows.js +0 -159
  126. package/lib-commonjs/runWindows/runWindows.js.map +0 -1
  127. package/lib-commonjs/runWindows/runWindowsOptions.js.map +0 -1
  128. package/lib-commonjs/runWindows/utils/autolink.d.ts +0 -7
  129. package/lib-commonjs/runWindows/utils/autolink.js +0 -353
  130. package/lib-commonjs/runWindows/utils/autolink.js.map +0 -1
  131. package/lib-commonjs/runWindows/utils/build.js.map +0 -1
  132. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +0 -1
  133. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +0 -1
  134. package/lib-commonjs/runWindows/utils/deploy.js +0 -247
  135. package/lib-commonjs/runWindows/utils/deploy.js.map +0 -1
  136. package/lib-commonjs/runWindows/utils/info.js.map +0 -1
  137. package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +0 -22
  138. package/lib-commonjs/runWindows/utils/msbuildtools.js +0 -195
  139. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +0 -1
  140. package/lib-commonjs/runWindows/utils/version.js.map +0 -1
  141. package/lib-commonjs/runWindows/utils/vsInstalls.js +0 -70
  142. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +0 -1
  143. package/lib-commonjs/runWindows/utils/vstools.js +0 -150
  144. package/lib-commonjs/runWindows/utils/vstools.js.map +0 -1
  145. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initWindowsOptions.js","sourceRoot":"","sources":["../../../src/commands/initWindows/initWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAcU,QAAA,WAAW,GAAoB;IAC1C;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,6BAA6B;QAC1C,OAAO,EAAE,iBAAiB;KAC3B;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,oFAAoF;QACtF,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EACT,4HAA4H;QAC9H,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,gDAAgD;KAC9D;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uGAAuG;KAC1G;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,oEAAoE;KACvE;CACF,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport type {CommandOption} from '@react-native-community/cli-types';\n\nexport interface InitOptions {\n logging?: boolean;\n template?: string;\n name?: string;\n namespace?: string;\n overwrite?: boolean;\n telemetry?: boolean;\n list?: boolean;\n}\n\nexport const initOptions: CommandOption[] = [\n {\n name: '--logging',\n description: 'Verbose output logging',\n },\n {\n name: '--template [string]',\n description: 'Specify the template to use',\n default: 'old/uwp-cpp-app',\n },\n {\n name: '--name [string]',\n description:\n 'The native project name. Defaults to the name property in app.json or package.json',\n default: undefined,\n },\n {\n name: '--namespace [string]',\n description:\n \"The native project namespace expressed using dots as separators, i.e. 'Level1.Level2.Level3'. Defaults to the same as name\",\n default: undefined,\n },\n {\n name: '--overwrite',\n description: 'Overwrite any existing files without prompting',\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 name: '--list',\n description:\n 'Shows a list with all available templates with their descriptions.',\n },\n];\n"]}
@@ -1,10 +1,10 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- import { Command } from '@react-native-community/cli-types';
7
- /**
8
- * Starts the app on a connected Windows emulator or mobile device.
9
- */
10
- export declare const runWindowsCommand: Command;
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import type { Command } from '@react-native-community/cli-types';
7
+ /**
8
+ * Starts the app on a connected Windows emulator or mobile device.
9
+ */
10
+ export declare const runWindowsCommand: Command;
@@ -0,0 +1,327 @@
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
+ /* eslint-disable complexity */
36
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
37
+ const path_1 = __importDefault(require("path"));
38
+ const telemetry_1 = require("@react-native-windows/telemetry");
39
+ const build = __importStar(require("../../utils/build"));
40
+ const chalk_1 = __importDefault(require("chalk"));
41
+ const deploy = __importStar(require("../../utils/deploy"));
42
+ const commandWithProgress_1 = require("../../utils/commandWithProgress");
43
+ const telemetryHelpers_1 = require("../../utils/telemetryHelpers");
44
+ const pathHelpers = __importStar(require("../../utils/pathHelpers"));
45
+ const info = __importStar(require("../../utils/info"));
46
+ const msbuildtools_1 = __importDefault(require("../../utils/msbuildtools"));
47
+ const runWindowsOptions_1 = require("./runWindowsOptions");
48
+ const autolinkWindows_1 = require("../autolinkWindows/autolinkWindows");
49
+ /**
50
+ * Sanitizes the given option for telemetry.
51
+ * @param key The key of the option.
52
+ * @param value The unsanitized value of the option.
53
+ * @returns The sanitized value of the option.
54
+ */
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 typeof value === 'string' ? value.split(',').length : 0; // 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 `npx @react-native-community/cli 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
+ var _a, _b;
167
+ const verbose = options.logging === true;
168
+ if (verbose) {
169
+ (0, commandWithProgress_1.newInfo)('Verbose: ON');
170
+ }
171
+ // Warn about old architecture projects
172
+ if (((_b = (_a = config.project.windows) === null || _a === void 0 ? void 0 : _a.rnwConfig) === null || _b === void 0 ? void 0 : _b.projectArch) === 'old') {
173
+ (0, commandWithProgress_1.newWarn)('This project is using the React Native (for Windows) Old Architecture, which will eventually be deprecated. See https://microsoft.github.io/react-native-windows/docs/new-architecture for details on switching to the New Architecture.');
174
+ }
175
+ // Get the solution file
176
+ let slnFile;
177
+ runWindowsPhase = 'FindSolution';
178
+ try {
179
+ slnFile = build.getAppSolutionFile(options, config);
180
+ }
181
+ catch (e) {
182
+ (0, commandWithProgress_1.newError)(`Couldn't get app solution information. ${e.message}`);
183
+ throw e;
184
+ }
185
+ let buildTools;
186
+ runWindowsPhase = 'FindBuildTools';
187
+ try {
188
+ buildTools = msbuildtools_1.default.findAvailableVersion(options.arch, verbose);
189
+ }
190
+ catch (error) {
191
+ (0, commandWithProgress_1.newWarn)('No public VS release found');
192
+ // Try prerelease
193
+ try {
194
+ (0, commandWithProgress_1.newInfo)('Trying pre-release VS');
195
+ buildTools = msbuildtools_1.default.findAvailableVersion(options.arch, verbose, true);
196
+ }
197
+ catch (e) {
198
+ (0, commandWithProgress_1.newError)(e.message);
199
+ throw error;
200
+ }
201
+ }
202
+ // Set up the callback to capture MSBuild properties after the command completes
203
+ evaluateMSBuildPropsCallback = () => {
204
+ const projectFile = build.getAppProjectFile(options, config);
205
+ if (projectFile) {
206
+ if (verbose) {
207
+ (0, commandWithProgress_1.newInfo)('Gathering MSBuild data for telemetry.');
208
+ }
209
+ const msBuildPropertiesJsonPath = path_1.default.resolve(path_1.default.dirname(projectFile), 'Generated Files', 'msbuildproperties.g.json');
210
+ if (fs_1.default.existsSync(msBuildPropertiesJsonPath)) {
211
+ if (verbose) {
212
+ (0, commandWithProgress_1.newInfo)('Loading properties from msbuildproperties.g.json');
213
+ }
214
+ return fs_1.default.readJsonFileSync(msBuildPropertiesJsonPath);
215
+ }
216
+ if (verbose) {
217
+ (0, commandWithProgress_1.newInfo)('Unable to find msbuildproperties.g.json');
218
+ }
219
+ }
220
+ return {};
221
+ };
222
+ // Restore packages.config files for dependencies that don't support PackageReference.
223
+ runWindowsPhase = 'RestorePackagesConfig';
224
+ const buildType = deploy.getBuildConfiguration(options);
225
+ try {
226
+ await buildTools.restorePackageConfigs(slnFile, options.arch, buildType);
227
+ }
228
+ catch (e) {
229
+ (0, commandWithProgress_1.newError)(`Couldn't restore found packages.config instances. ${e.message}`);
230
+ throw e;
231
+ }
232
+ if (options.autolink) {
233
+ runWindowsPhase = 'Autolink';
234
+ try {
235
+ const autolinkArgs = [];
236
+ const autolinkConfig = config;
237
+ const autolinkOptions = {
238
+ logging: options.logging,
239
+ check: false,
240
+ proj: options.proj,
241
+ sln: options.sln,
242
+ telemetry: options.telemetry,
243
+ };
244
+ await (0, autolinkWindows_1.autolinkWindowsInternal)(autolinkArgs, autolinkConfig, autolinkOptions);
245
+ }
246
+ catch (e) {
247
+ (0, commandWithProgress_1.newError)(`Autolinking failed. ${e.message}`);
248
+ throw e;
249
+ }
250
+ }
251
+ else {
252
+ (0, commandWithProgress_1.newInfo)('Autolink step is skipped');
253
+ }
254
+ if (options.build) {
255
+ runWindowsPhase = 'Build';
256
+ if (!slnFile) {
257
+ (0, commandWithProgress_1.newError)('Visual Studio Solution file not found. Maybe run "npx @react-native-community/cli init-windows" first?');
258
+ throw new telemetry_1.CodedError('NoSolution', 'Cannot find solution file');
259
+ }
260
+ // Get build/deploy options
261
+ const msBuildProps = build.parseMsBuildProps(options);
262
+ // Disable the autolink check since we just ran it
263
+ msBuildProps.RunAutolinkCheck = 'false';
264
+ try {
265
+ await build.buildSolution(buildTools, slnFile, buildType, options.arch, msBuildProps, verbose, 'build', options.buildLogDirectory, options.singleproc);
266
+ }
267
+ catch (e) {
268
+ (0, commandWithProgress_1.newError)(`Build failed with message ${e.message}. Check your build configuration.`);
269
+ if (e.logfile) {
270
+ console.log('See', chalk_1.default.bold(e.logfile));
271
+ }
272
+ throw e;
273
+ }
274
+ }
275
+ else {
276
+ (0, commandWithProgress_1.newInfo)('Build step is skipped');
277
+ }
278
+ if (shouldLaunchPackager(options)) {
279
+ await deploy.startServerInNewWindow(options, verbose);
280
+ }
281
+ if (options.deploy) {
282
+ runWindowsPhase = 'Deploy';
283
+ if (!slnFile) {
284
+ (0, commandWithProgress_1.newError)('Visual Studio Solution file not found. Maybe run "npx @react-native-community/cli init-windows" first?');
285
+ throw new telemetry_1.CodedError('NoSolution', 'Cannot find solution file');
286
+ }
287
+ try {
288
+ if (options.device || options.emulator || options.target) {
289
+ await deploy.deployToDevice(options, verbose, config);
290
+ }
291
+ else {
292
+ await deploy.deployToDesktop(options, verbose, config, buildTools);
293
+ }
294
+ }
295
+ catch (e) {
296
+ (0, commandWithProgress_1.newError)(`Failed to deploy${e ? `: ${e.message}` : ''}`);
297
+ throw e;
298
+ }
299
+ }
300
+ else {
301
+ (0, commandWithProgress_1.newInfo)('Deploy step is skipped');
302
+ }
303
+ }
304
+ function shouldLaunchPackager(options) {
305
+ return (options.packager === true &&
306
+ options.launch === true &&
307
+ options.release !== true);
308
+ }
309
+ /*
310
+ // Example of running the Windows Command
311
+ runWindows({
312
+ root: 'C:\\github\\hack\\myapp',
313
+ debug: true,
314
+ arch: 'x86',
315
+ nugetPath: 'C:\\github\\react\\react-native-windows\\local-cli\\runWindows\\.nuget\\nuget.exe'
316
+ });
317
+ */
318
+ /**
319
+ * Starts the app on a connected Windows emulator or mobile device.
320
+ */
321
+ exports.runWindowsCommand = {
322
+ name: 'run-windows',
323
+ description: 'Builds your RNW app and starts it on a connected Windows desktop, emulator or device',
324
+ func: runWindows,
325
+ options: runWindowsOptions_1.runWindowsOptions,
326
+ };
327
+ //# 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,+BAA+B;AAE/B,kEAA0C;AAC1C,gDAAwB;AAExB,+DAAsE;AAGtE,yDAA2C;AAC3C,kDAA0B;AAC1B,2DAA6C;AAC7C,yEAKyC;AACzC,mEAIsC;AACtC,qEAAuD;AACvD,uDAAyC;AACzC,4EAAoD;AAEpD,2DAAsD;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C,CAAC;KACvD;IAED,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,eAAe,GAAG,QAAQ,CAAC;QAC3B,IAAI,CAAC,OAAO,EAAE;YACZ,IAAA,8BAAQ,EACN,wGAAwG,CACzG,CAAC;YACF,MAAM,IAAI,sBAAU,CAAC,YAAY,EAAE,2BAA2B,CAAC,CAAC;SACjE;QAED,IAAI;YACF,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,MAAM,EAAE;gBACxD,MAAM,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;aACvD;iBAAM;gBACL,MAAM,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;aACpE;SACF;QAAC,OAAO,CAAC,EAAE;YACV,IAAA,8BAAQ,EAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,KAAM,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACpE,MAAM,CAAC,CAAC;SACT;KACF;SAAM;QACL,IAAA,6BAAO,EAAC,wBAAwB,CAAC,CAAC;KACnC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,OAA0B;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,sFAAsF;IACxF,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\n/* eslint-disable complexity */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\n\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport type {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 type {RunWindowsOptions} from './runWindowsOptions';\nimport {runWindowsOptions} from './runWindowsOptions';\nimport {autolinkWindowsInternal} from '../autolinkWindows/autolinkWindows';\nimport type {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 */\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 typeof value === 'string' ? value.split(',').length : 0; // 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 `npx @react-native-community/cli 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 // Warn about old architecture projects\n if (config.project.windows?.rnwConfig?.projectArch === 'old') {\n newWarn(\n 'This project is using the React Native (for Windows) Old Architecture, which will eventually be deprecated. See https://microsoft.github.io/react-native-windows/docs/new-architecture for details on switching to the New Architecture.',\n );\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-community/cli init-windows\" 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-community/cli init-windows\" 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 RNW 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 type { 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[];