@react-native-windows/cli 0.0.0-canary.12 → 0.0.0-canary.122

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 (81) hide show
  1. package/README.md +47 -0
  2. package/lib-commonjs/config/configUtils.d.ts +25 -2
  3. package/lib-commonjs/config/configUtils.js +138 -30
  4. package/lib-commonjs/config/configUtils.js.map +1 -1
  5. package/lib-commonjs/config/dependencyConfig.js +105 -44
  6. package/lib-commonjs/config/dependencyConfig.js.map +1 -1
  7. package/lib-commonjs/config/projectConfig.d.ts +4 -1
  8. package/lib-commonjs/config/projectConfig.js +72 -12
  9. package/lib-commonjs/config/projectConfig.js.map +1 -1
  10. package/lib-commonjs/e2etest/autolink.test.d.ts +6 -0
  11. package/lib-commonjs/e2etest/autolink.test.js +386 -0
  12. package/lib-commonjs/e2etest/autolink.test.js.map +1 -0
  13. package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -0
  14. package/lib-commonjs/e2etest/dependencyConfig.test.js +130 -0
  15. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -0
  16. package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -0
  17. package/lib-commonjs/e2etest/projectConfig.test.js +111 -0
  18. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -0
  19. package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -0
  20. package/lib-commonjs/e2etest/projectConfig.utils.js +77 -0
  21. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -0
  22. package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -0
  23. package/lib-commonjs/e2etest/runWindows.test.js +61 -0
  24. package/lib-commonjs/e2etest/runWindows.test.js.map +1 -0
  25. package/lib-commonjs/generator-common/index.d.ts +16 -0
  26. package/lib-commonjs/generator-common/index.js +65 -44
  27. package/lib-commonjs/generator-common/index.js.map +1 -1
  28. package/lib-commonjs/generator-windows/index.d.ts +2 -2
  29. package/lib-commonjs/generator-windows/index.js +265 -182
  30. package/lib-commonjs/generator-windows/index.js.map +1 -1
  31. package/lib-commonjs/healthChecks.d.ts +2 -0
  32. package/lib-commonjs/healthChecks.js +88 -0
  33. package/lib-commonjs/healthChecks.js.map +1 -0
  34. package/lib-commonjs/index.d.ts +5 -0
  35. package/lib-commonjs/index.js +28 -8
  36. package/lib-commonjs/index.js.map +1 -1
  37. package/lib-commonjs/runWindows/runWindows.js +240 -53
  38. package/lib-commonjs/runWindows/runWindows.js.map +1 -1
  39. package/lib-commonjs/runWindows/runWindowsOptions.d.ts +14 -10
  40. package/lib-commonjs/runWindows/runWindowsOptions.js +16 -12
  41. package/lib-commonjs/runWindows/runWindowsOptions.js.map +1 -1
  42. package/lib-commonjs/runWindows/utils/autolink.d.ts +88 -1
  43. package/lib-commonjs/runWindows/utils/autolink.js +599 -265
  44. package/lib-commonjs/runWindows/utils/autolink.js.map +1 -1
  45. package/lib-commonjs/runWindows/utils/build.d.ts +1 -2
  46. package/lib-commonjs/runWindows/utils/build.js +25 -32
  47. package/lib-commonjs/runWindows/utils/build.js.map +1 -1
  48. package/lib-commonjs/runWindows/utils/checkRequirements.js +12 -8
  49. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +1 -1
  50. package/lib-commonjs/runWindows/utils/commandWithProgress.d.ts +11 -3
  51. package/lib-commonjs/runWindows/utils/commandWithProgress.js +60 -25
  52. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +1 -1
  53. package/lib-commonjs/runWindows/utils/deploy.d.ts +1 -1
  54. package/lib-commonjs/runWindows/utils/deploy.js +171 -85
  55. package/lib-commonjs/runWindows/utils/deploy.js.map +1 -1
  56. package/lib-commonjs/runWindows/utils/info.js +5 -2
  57. package/lib-commonjs/runWindows/utils/info.js.map +1 -1
  58. package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +11 -5
  59. package/lib-commonjs/runWindows/utils/msbuildtools.js +134 -61
  60. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +1 -1
  61. package/lib-commonjs/runWindows/utils/telemetryHelpers.d.ts +29 -0
  62. package/lib-commonjs/runWindows/utils/telemetryHelpers.js +113 -0
  63. package/lib-commonjs/runWindows/utils/telemetryHelpers.js.map +1 -0
  64. package/lib-commonjs/runWindows/utils/version.d.ts +4 -4
  65. package/lib-commonjs/runWindows/utils/version.js +1 -1
  66. package/lib-commonjs/runWindows/utils/version.js.map +1 -1
  67. package/lib-commonjs/runWindows/utils/vsInstalls.d.ts +4 -1
  68. package/lib-commonjs/runWindows/utils/vsInstalls.js +22 -7
  69. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +1 -1
  70. package/lib-commonjs/runWindows/utils/vstools.d.ts +1 -0
  71. package/lib-commonjs/runWindows/utils/vstools.js +42 -29
  72. package/lib-commonjs/runWindows/utils/vstools.js.map +1 -1
  73. package/lib-commonjs/runWindows/utils/winappdeploytool.d.ts +3 -3
  74. package/lib-commonjs/runWindows/utils/winappdeploytool.js +19 -16
  75. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +1 -1
  76. package/package.json +42 -25
  77. package/powershell/Add-AppDevPackage.ps1 +2 -2
  78. package/powershell/Eval-MsBuildProperties.ps1 +156 -0
  79. package/powershell/WindowsStoreAppUtils.ps1 +10 -0
  80. package/CHANGELOG.json +0 -170
  81. package/CHANGELOG.md +0 -85
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @react-native-windows/cli
2
+
3
+ CLI to build and run React Native for Windows apps.
4
+
5
+ ## Usage
6
+
7
+ Run this from an existing `react-native` project with React Native Windows to build and deploy apps.
8
+
9
+
10
+ Example usage
11
+ ```
12
+ npx react-native run-windows
13
+ ```
14
+
15
+ Options:
16
+ | option | description | type |
17
+ |-----------------------|--------------------------------------|--------------------------------------------------|
18
+ | `--release` | Specifies a Release build | [boolean] |
19
+ | `--root` | Override the root directory for the windows build which contains the windows folder. (default: "E:\\test63") | [string] |
20
+ | `--arch` | The build architecture (ARM64, x86, x64). defaults to system architecture | [string] |
21
+ | `--singleproc` | Disables multi-proc build | [boolean] |
22
+ | `--emulator` | Deploys the app to an emulator | [boolean] |
23
+ | `--device` | Deploys the app to a connected device | [boolean] |
24
+ | `--target` | Deploys the app to the specified GUID for a device | [string] |
25
+ | `--remote-debugging` | Deploys the app in remote debugging mode. | [boolean] |
26
+ | `--logging` | Enables logging | [boolean] |
27
+ | `--no-packager` | Do not launch packager while building | [boolean] |
28
+ | `--bundle` | Enable Bundle configuration and it would be ReleaseBundle/DebugBundle other than Release/Debug | [boolean] |
29
+ | `--no-launch` | Do not launch the app after deployment | [boolean] |
30
+ | `--no-autolink` | Do not run autolinking | [boolean] |
31
+ | `--no-build` | Do not build the solution | [boolean] |
32
+ | `--no-deploy` | Do not deploy the app | [boolean] |
33
+ | `--deploy-from-layout`| Force deploy from layout, even in release builds | [boolean] |
34
+ | `--sln` | Override the app solution file determined by 'react-native config', e.g. windows\myApp.sln | [string] |
35
+ | `--proj` | Override the app project file determined by 'react-native config', e.g. windows\myApp\myApp.vcxproj | [string] |
36
+ | `--msbuildprops` | Comma separated props to pass to MSBuild, eg: prop1=value1,prop2=value2 | [string] |
37
+ | `--buildLogDirectory` | Optional directory where MSBuild log files should be stored | [string] |
38
+ | `--info` | Dump environment information | [boolean] |
39
+ | `--direct-debugging` | Enable direct debugging on specified port | [number] |
40
+ | `--no-telemetry` | Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI | [boolean] |
41
+ | `-h`, `--help` | output usage information | [boolean] |
42
+
43
+
44
+ ## Data Collection
45
+ The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
46
+
47
+ This data collection notice only applies to the process of running the react-native-windows CLI (run-windows and related tools like autolinking).
@@ -64,7 +64,8 @@ export declare function readProjectFile(projectPath: string): Document;
64
64
  * @param propertyName The property to look for.
65
65
  * @return The value of the tag if it exists.
66
66
  */
67
- export declare function findPropertyValue(projectContents: Node, propertyName: string): string | null;
67
+ export declare function tryFindPropertyValue(projectContents: Node, propertyName: string): string | null;
68
+ export declare function findPropertyValue(projectContents: Node, propertyName: string, filePath: string): string;
68
69
  /**
69
70
  * Search for the given import project in the project contents and return if it exists.
70
71
  * @param projectContents The XML project contents.
@@ -72,13 +73,34 @@ export declare function findPropertyValue(projectContents: Node, propertyName: s
72
73
  * @return If the target exists.
73
74
  */
74
75
  export declare function importProjectExists(projectContents: Node, projectName: string): boolean;
76
+ export declare type ConfigurationType = 'application' | 'dynamiclibrary' | 'generic' | 'staticlibrary' | 'unknown';
77
+ /**
78
+ * Gets the configuration type of the project from the project contents.
79
+ * @param projectContents The XML project contents.
80
+ * @return The project configuration type.
81
+ */
82
+ export declare function getConfigurationType(projectContents: Node): ConfigurationType;
83
+ export declare type OutputType = 'appcontainerexe' | 'exe' | 'library' | 'module' | 'unknown' | 'winexe' | 'winmdobj';
84
+ /**
85
+ * Gets the output type of the project from the project contents.
86
+ * @param projectContents The XML project contents.
87
+ * @return The project output type.
88
+ */
89
+ export declare function getOutputType(projectContents: Node): OutputType;
90
+ /**
91
+ * Gets the type of the project from the project contents.
92
+ * @param projectPath The project file path to check.
93
+ * @param projectContents The XML project contents.
94
+ * @return The project type.
95
+ */
96
+ export declare function getProjectType(projectPath: string, projectContents: Node): ConfigurationType | OutputType;
75
97
  /**
76
98
  * Gets the name of the project from the project contents.
77
99
  * @param projectPath The project file path to check.
78
100
  * @param projectContents The XML project contents.
79
101
  * @return The project name.
80
102
  */
81
- export declare function getProjectName(projectContents: Node): string;
103
+ export declare function getProjectName(projectPath: string, projectContents: Node): string;
82
104
  /**
83
105
  * Gets the namespace of the project from the project contents.
84
106
  * @param projectContents The XML project contents.
@@ -91,3 +113,4 @@ export declare function getProjectNamespace(projectContents: Node): string | nul
91
113
  * @return The project guid.
92
114
  */
93
115
  export declare function getProjectGuid(projectContents: Node): string | null;
116
+ export declare function getExperimentalFeatures(solutionDir: string): Record<string, string> | undefined;
@@ -4,14 +4,18 @@
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
- exports.getProjectGuid = exports.getProjectNamespace = exports.getProjectName = exports.importProjectExists = exports.findPropertyValue = exports.readProjectFile = exports.getProjectLanguage = exports.findAppProjectFiles = exports.findDependencyProjectFiles = exports.isRnwDependencyProject = exports.findSolutionFiles = exports.isRnwSolution = exports.findWindowsFolder = exports.findFiles = void 0;
9
- const fs = require("fs");
10
- const path = require("path");
11
- const glob = require("glob");
12
- const xmldom_1 = require("xmldom");
13
- const xpath = require("xpath");
14
- const msbuildSelect = xpath.useNamespaces({
11
+ exports.getExperimentalFeatures = exports.getProjectGuid = exports.getProjectNamespace = exports.getProjectName = exports.getProjectType = exports.getOutputType = exports.getConfigurationType = exports.importProjectExists = exports.findPropertyValue = exports.tryFindPropertyValue = exports.readProjectFile = exports.getProjectLanguage = exports.findAppProjectFiles = exports.findDependencyProjectFiles = exports.isRnwDependencyProject = exports.findSolutionFiles = exports.isRnwSolution = exports.findWindowsFolder = exports.findFiles = void 0;
12
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
13
+ const path_1 = __importDefault(require("path"));
14
+ const glob_1 = __importDefault(require("glob"));
15
+ const xmldom_1 = require("@xmldom/xmldom");
16
+ const xpath_1 = __importDefault(require("xpath"));
17
+ const telemetry_1 = require("@react-native-windows/telemetry");
18
+ const msbuildSelect = xpath_1.default.useNamespaces({
15
19
  msbuild: 'http://schemas.microsoft.com/developer/msbuild/2003',
16
20
  });
17
21
  /**
@@ -21,13 +25,12 @@ const msbuildSelect = xpath.useNamespaces({
21
25
  * @return Return the array of relative file paths.
22
26
  */
23
27
  function findFiles(folder, filenamePattern) {
24
- const files = glob.sync(path.join('**', filenamePattern), {
28
+ const files = glob_1.default.sync(path_1.default.join('**', filenamePattern), {
25
29
  cwd: folder,
26
30
  ignore: [
27
31
  'node_modules/**',
28
32
  '**/Debug/**',
29
33
  '**/Release/**',
30
- '**/WinUI3/**',
31
34
  '**/Generated Files/**',
32
35
  '**/packages/**',
33
36
  ],
@@ -42,8 +45,8 @@ exports.findFiles = findFiles;
42
45
  */
43
46
  function findWindowsFolder(folder) {
44
47
  const winDir = 'windows';
45
- const joinedDir = path.join(folder, winDir);
46
- if (fs.existsSync(joinedDir)) {
48
+ const joinedDir = path_1.default.join(folder, winDir);
49
+ if (fs_1.default.existsSync(joinedDir)) {
47
50
  return joinedDir;
48
51
  }
49
52
  return null;
@@ -55,7 +58,7 @@ exports.findWindowsFolder = findWindowsFolder;
55
58
  * @return Whether the path is to a RNW solution file.
56
59
  */
57
60
  function isRnwSolution(filePath) {
58
- return (fs
61
+ return (fs_1.default
59
62
  .readFileSync(filePath)
60
63
  .toString()
61
64
  .search(/ReactNative/) > 0);
@@ -77,11 +80,11 @@ function findSolutionFiles(winFolder) {
77
80
  // If there is exactly one solution file, assume it's it
78
81
  return [allSolutions[0]];
79
82
  }
80
- var solutionFiles = [];
83
+ const solutionFiles = [];
81
84
  // Try to find any solution file that appears to be a React Native solution
82
85
  for (const solutionFile of allSolutions) {
83
- if (isRnwSolution(path.join(winFolder, solutionFile))) {
84
- solutionFiles.push(solutionFile);
86
+ if (isRnwSolution(path_1.default.join(winFolder, solutionFile))) {
87
+ solutionFiles.push(path_1.default.normalize(solutionFile));
85
88
  }
86
89
  }
87
90
  return solutionFiles;
@@ -118,16 +121,30 @@ function findDependencyProjectFiles(winFolder) {
118
121
  // If there're no project files, return 0
119
122
  return [];
120
123
  }
121
- var dependencyProjectFiles = [];
124
+ const dependencyProjectFiles = [];
122
125
  // Try to find any project file that appears to be a dependency project
123
126
  for (const projectFile of allProjects) {
124
- if (isRnwDependencyProject(path.join(winFolder, projectFile))) {
125
- dependencyProjectFiles.push(projectFile);
127
+ // A project is marked as a RNW dependency iff either:
128
+ // - If the project has the standard native module imports, or
129
+ // - If we only have a single project (and it doesn't have the standard native module imports),
130
+ // pick it and hope for the best. This enables autolinking for modules that were written
131
+ // before the standard native module template existed.
132
+ if (allProjects.length === 1 ||
133
+ isRnwDependencyProject(path_1.default.join(winFolder, projectFile))) {
134
+ dependencyProjectFiles.push(path_1.default.normalize(projectFile));
126
135
  }
127
136
  }
128
137
  return dependencyProjectFiles;
129
138
  }
130
139
  exports.findDependencyProjectFiles = findDependencyProjectFiles;
140
+ function getReactNativeProjectType(value) {
141
+ switch (value) {
142
+ case 'App-WinAppSDK':
143
+ return value;
144
+ default:
145
+ return 'unknown';
146
+ }
147
+ }
131
148
  /**
132
149
  * Checks if the target file path is a RNW app project file.
133
150
  * @param filePath The absolute file path to check.
@@ -135,6 +152,10 @@ exports.findDependencyProjectFiles = findDependencyProjectFiles;
135
152
  */
136
153
  function isRnwAppProject(filePath) {
137
154
  const projectContents = readProjectFile(filePath);
155
+ const rnProjectType = getReactNativeProjectType(tryFindPropertyValue(projectContents, 'ReactNativeProjectType'));
156
+ if (rnProjectType !== 'unknown') {
157
+ return true;
158
+ }
138
159
  const projectLang = getProjectLanguage(filePath);
139
160
  if (projectLang === 'cs') {
140
161
  return importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CSharpApp.targets');
@@ -158,11 +179,11 @@ function findAppProjectFiles(winFolder) {
158
179
  // If there're no project files, return 0
159
180
  return [];
160
181
  }
161
- var appProjectFiles = [];
182
+ const appProjectFiles = [];
162
183
  // Try to find any project file that appears to be an app project
163
184
  for (const projectFile of allProjects) {
164
- if (isRnwAppProject(path.join(winFolder, projectFile))) {
165
- appProjectFiles.push(projectFile);
185
+ if (isRnwAppProject(path_1.default.join(winFolder, projectFile))) {
186
+ appProjectFiles.push(path_1.default.normalize(projectFile));
166
187
  }
167
188
  }
168
189
  return appProjectFiles;
@@ -189,7 +210,7 @@ exports.getProjectLanguage = getProjectLanguage;
189
210
  * @return The project file contents.
190
211
  */
191
212
  function readProjectFile(projectPath) {
192
- const projectContents = fs.readFileSync(projectPath, 'utf8').toString();
213
+ const projectContents = fs_1.default.readFileSync(projectPath, 'utf8').toString();
193
214
  return new xmldom_1.DOMParser().parseFromString(projectContents, 'application/xml');
194
215
  }
195
216
  exports.readProjectFile = readProjectFile;
@@ -199,14 +220,29 @@ exports.readProjectFile = readProjectFile;
199
220
  * @param propertyName The property to look for.
200
221
  * @return The value of the tag if it exists.
201
222
  */
202
- function findPropertyValue(projectContents, propertyName) {
203
- var nodes = msbuildSelect(`//msbuild:PropertyGroup/msbuild:${propertyName}`, projectContents);
223
+ function tryFindPropertyValue(projectContents, propertyName) {
224
+ const nodes = msbuildSelect(`//msbuild:PropertyGroup/msbuild:${propertyName}`, projectContents);
204
225
  if (nodes.length > 0) {
205
226
  // Take the last one
206
227
  return nodes[nodes.length - 1].textContent;
207
228
  }
229
+ else {
230
+ const noNamespaceNodes = xpath_1.default.select(`//PropertyGroup/${propertyName}`, projectContents);
231
+ if (noNamespaceNodes.length > 0) {
232
+ return noNamespaceNodes[noNamespaceNodes.length - 1]
233
+ .textContent;
234
+ }
235
+ }
208
236
  return null;
209
237
  }
238
+ exports.tryFindPropertyValue = tryFindPropertyValue;
239
+ function findPropertyValue(projectContents, propertyName, filePath) {
240
+ const res = tryFindPropertyValue(projectContents, propertyName);
241
+ if (!res) {
242
+ throw new telemetry_1.CodedError('NoPropertyInProject', `Couldn't find property ${propertyName} from ${filePath}`, { propertyName: propertyName });
243
+ }
244
+ return res;
245
+ }
210
246
  exports.findPropertyValue = findPropertyValue;
211
247
  /**
212
248
  * Search for the given import project in the project contents and return if it exists.
@@ -215,19 +251,76 @@ exports.findPropertyValue = findPropertyValue;
215
251
  * @return If the target exists.
216
252
  */
217
253
  function importProjectExists(projectContents, projectName) {
218
- var nodes = msbuildSelect(`//msbuild:Import[contains(@Project,'${projectName}')]`, projectContents);
254
+ const nodes = msbuildSelect(`//msbuild:Import[contains(@Project,'${projectName}')]`, projectContents);
219
255
  return nodes.length > 0;
220
256
  }
221
257
  exports.importProjectExists = importProjectExists;
258
+ /**
259
+ * Gets the configuration type of the project from the project contents.
260
+ * @param projectContents The XML project contents.
261
+ * @return The project configuration type.
262
+ */
263
+ function getConfigurationType(projectContents) {
264
+ var _a;
265
+ const configurationType = (_a = tryFindPropertyValue(projectContents, 'ConfigurationType')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
266
+ switch (configurationType) {
267
+ case 'application':
268
+ case 'dynamiclibrary':
269
+ case 'generic':
270
+ case 'staticlibrary':
271
+ return configurationType;
272
+ default:
273
+ return 'unknown';
274
+ }
275
+ }
276
+ exports.getConfigurationType = getConfigurationType;
277
+ /**
278
+ * Gets the output type of the project from the project contents.
279
+ * @param projectContents The XML project contents.
280
+ * @return The project output type.
281
+ */
282
+ function getOutputType(projectContents) {
283
+ var _a;
284
+ const outputType = (_a = tryFindPropertyValue(projectContents, 'OutputType')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
285
+ switch (outputType) {
286
+ case 'appcontainerexe':
287
+ case 'exe':
288
+ case 'library':
289
+ case 'module':
290
+ case 'winexe':
291
+ case 'winmdobj':
292
+ return outputType;
293
+ default:
294
+ return 'unknown';
295
+ }
296
+ }
297
+ exports.getOutputType = getOutputType;
298
+ /**
299
+ * Gets the type of the project from the project contents.
300
+ * @param projectPath The project file path to check.
301
+ * @param projectContents The XML project contents.
302
+ * @return The project type.
303
+ */
304
+ function getProjectType(projectPath, projectContents) {
305
+ switch (getProjectLanguage(projectPath)) {
306
+ case 'cpp':
307
+ return getConfigurationType(projectContents);
308
+ case 'cs':
309
+ return getOutputType(projectContents);
310
+ default:
311
+ return 'unknown';
312
+ }
313
+ }
314
+ exports.getProjectType = getProjectType;
222
315
  /**
223
316
  * Gets the name of the project from the project contents.
224
317
  * @param projectPath The project file path to check.
225
318
  * @param projectContents The XML project contents.
226
319
  * @return The project name.
227
320
  */
228
- function getProjectName(projectContents) {
229
- const name = findPropertyValue(projectContents, 'ProjectName') ||
230
- findPropertyValue(projectContents, 'AssemblyName') ||
321
+ function getProjectName(projectPath, projectContents) {
322
+ const name = tryFindPropertyValue(projectContents, 'ProjectName') ||
323
+ path_1.default.parse(projectPath).name ||
231
324
  '';
232
325
  return name;
233
326
  }
@@ -238,7 +331,7 @@ exports.getProjectName = getProjectName;
238
331
  * @return The project namespace.
239
332
  */
240
333
  function getProjectNamespace(projectContents) {
241
- return findPropertyValue(projectContents, 'RootNamespace');
334
+ return tryFindPropertyValue(projectContents, 'RootNamespace');
242
335
  }
243
336
  exports.getProjectNamespace = getProjectNamespace;
244
337
  /**
@@ -247,7 +340,22 @@ exports.getProjectNamespace = getProjectNamespace;
247
340
  * @return The project guid.
248
341
  */
249
342
  function getProjectGuid(projectContents) {
250
- return findPropertyValue(projectContents, 'ProjectGuid');
343
+ return tryFindPropertyValue(projectContents, 'ProjectGuid');
251
344
  }
252
345
  exports.getProjectGuid = getProjectGuid;
346
+ function getExperimentalFeatures(solutionDir) {
347
+ const propsFile = path_1.default.join(solutionDir, 'ExperimentalFeatures.props');
348
+ if (!fs_1.default.existsSync(propsFile)) {
349
+ return undefined;
350
+ }
351
+ const result = {};
352
+ const propsContents = readProjectFile(propsFile);
353
+ const nodes = msbuildSelect(`//msbuild:PropertyGroup/msbuild:*`, propsContents);
354
+ for (const node of nodes) {
355
+ const propertyNode = node;
356
+ result[propertyNode.nodeName] = propertyNode.textContent;
357
+ }
358
+ return result;
359
+ }
360
+ exports.getExperimentalFeatures = getExperimentalFeatures;
253
361
  //# sourceMappingURL=configUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configUtils.js","sourceRoot":"","sources":["../../src/config/configUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,yBAAyB;AACzB,6BAA6B;AAC7B,6BAA6B;AAE7B,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B,cAAc,CAC5B,WAAmB,EACnB,eAAqB;IAErB,MAAM,IAAI,GACR,oBAAoB,CAAC,eAAe,EAAE,aAAa,CAAC;QACpD,cAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI;QAC5B,EAAE,CAAC;IAEL,OAAO,IAAI,CAAC;AACd,CAAC;AAVD,wCAUC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,eAAqB;IACvD,OAAO,oBAAoB,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;AAChE,CAAC;AAFD,kDAEC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,eAAqB;IAClD,OAAO,oBAAoB,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;AAC9D,CAAC;AAFD,wCAEC;AAED,SAAgB,uBAAuB,CACrC,WAAmB;IAEnB,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,4BAA4B,CAAC,CAAC;IAEvE,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC7B,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,MAAM,aAAa,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,aAAa,CACzB,mCAAmC,EACnC,aAAa,CACd,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,YAAY,GAAG,IAAY,CAAC;QAClC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC;KAC1D;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AApBD,0DAoBC","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 glob from 'glob';\n\nimport {DOMParser} from '@xmldom/xmldom';\nimport xpath from 'xpath';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nconst msbuildSelect = xpath.useNamespaces({\n msbuild: 'http://schemas.microsoft.com/developer/msbuild/2003',\n});\n\n/**\n * Search for files matching the pattern under the target folder.\n * @param folder The absolute path to target folder.\n * @param filenamePattern The pattern to search for.\n * @return Return the array of relative file paths.\n */\nexport function findFiles(folder: string, filenamePattern: string): string[] {\n const files = glob.sync(path.join('**', filenamePattern), {\n cwd: folder,\n ignore: [\n 'node_modules/**',\n '**/Debug/**',\n '**/Release/**',\n '**/Generated Files/**',\n '**/packages/**',\n ],\n });\n\n return files;\n}\n\n/**\n * Search for the windows sub-folder under the target folder.\n * @param folder The absolute path to the target folder.\n * @return The absolute path to the windows folder, if it exists.\n */\nexport function findWindowsFolder(folder: string): string | null {\n const winDir = 'windows';\n const joinedDir = path.join(folder, winDir);\n if (fs.existsSync(joinedDir)) {\n return joinedDir;\n }\n\n return null;\n}\n\n/**\n * Checks if the target file path is a RNW solution file by checking if it contains the string \"ReactNative\".\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW solution file.\n */\nexport function isRnwSolution(filePath: string): boolean {\n return (\n fs\n .readFileSync(filePath)\n .toString()\n .search(/ReactNative/) > 0\n );\n}\n\n/**\n * Search for the RNW solution files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findSolutionFiles(winFolder: string): string[] {\n // First search for all potential solution files\n const allSolutions = findFiles(winFolder, '*.sln');\n\n if (allSolutions.length === 0) {\n // If there're no solution files, return 0\n return [];\n } else if (allSolutions.length === 1) {\n // If there is exactly one solution file, assume it's it\n return [allSolutions[0]];\n }\n\n const solutionFiles = [];\n\n // Try to find any solution file that appears to be a React Native solution\n for (const solutionFile of allSolutions) {\n if (isRnwSolution(path.join(winFolder, solutionFile))) {\n solutionFiles.push(path.normalize(solutionFile));\n }\n }\n\n return solutionFiles;\n}\n\n/**\n * Checks if the target file path is a RNW lib project file.\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW lib project file.\n */\nexport function isRnwDependencyProject(filePath: string): boolean {\n const projectContents = readProjectFile(filePath);\n\n const projectLang = getProjectLanguage(filePath);\n if (projectLang === 'cs') {\n return importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpLib.targets',\n );\n } else if (projectLang === 'cpp') {\n return importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppLib.targets',\n );\n }\n\n return false;\n}\n\n/**\n * Search for the RNW lib project files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findDependencyProjectFiles(winFolder: string): string[] {\n // First, search for all potential project files\n const allCppProj = findFiles(winFolder, '*.vcxproj');\n const allCsProj = findFiles(winFolder, '*.csproj');\n\n const allProjects = allCppProj.concat(allCsProj);\n\n if (allProjects.length === 0) {\n // If there're no project files, return 0\n return [];\n }\n\n const dependencyProjectFiles = [];\n\n // Try to find any project file that appears to be a dependency project\n for (const projectFile of allProjects) {\n // A project is marked as a RNW dependency iff either:\n // - If the project has the standard native module imports, or\n // - If we only have a single project (and it doesn't have the standard native module imports),\n // pick it and hope for the best. This enables autolinking for modules that were written\n // before the standard native module template existed.\n if (\n allProjects.length === 1 ||\n isRnwDependencyProject(path.join(winFolder, projectFile))\n ) {\n dependencyProjectFiles.push(path.normalize(projectFile));\n }\n }\n\n return dependencyProjectFiles;\n}\n\ntype ReactNativeProjectType = 'unknown' | 'App-WinAppSDK';\n\nfunction getReactNativeProjectType(\n value: string | null,\n): ReactNativeProjectType {\n switch (value) {\n case 'App-WinAppSDK':\n return value;\n\n default:\n return 'unknown';\n }\n}\n\n/**\n * Checks if the target file path is a RNW app project file.\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW app project file.\n */\nfunction isRnwAppProject(filePath: string): boolean {\n const projectContents = readProjectFile(filePath);\n\n const rnProjectType = getReactNativeProjectType(\n tryFindPropertyValue(projectContents, 'ReactNativeProjectType'),\n );\n\n if (rnProjectType !== 'unknown') {\n return true;\n }\n\n const projectLang = getProjectLanguage(filePath);\n if (projectLang === 'cs') {\n return importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpApp.targets',\n );\n } else if (projectLang === 'cpp') {\n return importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppApp.targets',\n );\n }\n\n return false;\n}\n\n/**\n * Search for the RNW app project files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findAppProjectFiles(winFolder: string): string[] {\n // First, search for all potential project files\n const allCppProj = findFiles(winFolder, '*.vcxproj');\n const allCsProj = findFiles(winFolder, '*.csproj');\n\n const allProjects = allCppProj.concat(allCsProj);\n\n if (allProjects.length === 0) {\n // If there're no project files, return 0\n return [];\n }\n\n const appProjectFiles = [];\n\n // Try to find any project file that appears to be an app project\n for (const projectFile of allProjects) {\n if (isRnwAppProject(path.join(winFolder, projectFile))) {\n appProjectFiles.push(path.normalize(projectFile));\n }\n }\n\n return appProjectFiles;\n}\n\n/**\n * Returns the programming language of the project file.\n * @param projectPath The project file path to check.\n * @return The language string: cpp, cs, or null if unknown.\n */\nexport function getProjectLanguage(projectPath: string): 'cpp' | 'cs' | null {\n if (projectPath.endsWith('.vcxproj')) {\n return 'cpp';\n } else if (projectPath.endsWith('.csproj')) {\n return 'cs';\n }\n\n return null;\n}\n\n/**\n * Reads in the contents of the target project file.\n * @param projectPath The target project file path.\n * @return The project file contents.\n */\nexport function readProjectFile(projectPath: string) {\n const projectContents = fs.readFileSync(projectPath, 'utf8').toString();\n return new DOMParser().parseFromString(projectContents, 'application/xml');\n}\n\n/**\n * Search for the given property in the project contents and return its value.\n * @param projectContents The XML project contents.\n * @param propertyName The property to look for.\n * @return The value of the tag if it exists.\n */\nexport function tryFindPropertyValue(\n projectContents: Node,\n propertyName: string,\n): string | null {\n const nodes = msbuildSelect(\n `//msbuild:PropertyGroup/msbuild:${propertyName}`,\n projectContents,\n );\n\n if (nodes.length > 0) {\n // Take the last one\n return (nodes[nodes.length - 1] as Node).textContent;\n } else {\n const noNamespaceNodes = xpath.select(\n `//PropertyGroup/${propertyName}`,\n projectContents,\n );\n if (noNamespaceNodes.length > 0) {\n return (noNamespaceNodes[noNamespaceNodes.length - 1] as Node)\n .textContent;\n }\n }\n\n return null;\n}\n\nexport function findPropertyValue(\n projectContents: Node,\n propertyName: string,\n filePath: string,\n): string {\n const res = tryFindPropertyValue(projectContents, propertyName);\n if (!res) {\n throw new CodedError(\n 'NoPropertyInProject',\n `Couldn't find property ${propertyName} from ${filePath}`,\n {propertyName: propertyName},\n );\n }\n return res;\n}\n\n/**\n * Search for the given import project in the project contents and return if it exists.\n * @param projectContents The XML project contents.\n * @param projectName The project to look for.\n * @return If the target exists.\n */\nexport function importProjectExists(\n projectContents: Node,\n projectName: string,\n): boolean {\n const nodes = msbuildSelect(\n `//msbuild:Import[contains(@Project,'${projectName}')]`,\n projectContents,\n );\n\n return nodes.length > 0;\n}\n\nexport type ConfigurationType =\n | 'application'\n | 'dynamiclibrary'\n | 'generic'\n | 'staticlibrary'\n | 'unknown';\n\n/**\n * Gets the configuration type of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project configuration type.\n */\nexport function getConfigurationType(projectContents: Node): ConfigurationType {\n const configurationType = tryFindPropertyValue(\n projectContents,\n 'ConfigurationType',\n )?.toLowerCase();\n\n switch (configurationType) {\n case 'application':\n case 'dynamiclibrary':\n case 'generic':\n case 'staticlibrary':\n return configurationType;\n\n default:\n return 'unknown';\n }\n}\n\nexport type OutputType =\n | 'appcontainerexe'\n | 'exe'\n | 'library'\n | 'module'\n | 'unknown'\n | 'winexe'\n | 'winmdobj';\n\n/**\n * Gets the output type of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project output type.\n */\nexport function getOutputType(projectContents: Node): OutputType {\n const outputType = tryFindPropertyValue(\n projectContents,\n 'OutputType',\n )?.toLowerCase();\n\n switch (outputType) {\n case 'appcontainerexe':\n case 'exe':\n case 'library':\n case 'module':\n case 'winexe':\n case 'winmdobj':\n return outputType;\n\n default:\n return 'unknown';\n }\n}\n\n/**\n * Gets the type of the project from the project contents.\n * @param projectPath The project file path to check.\n * @param projectContents The XML project contents.\n * @return The project type.\n */\nexport function getProjectType(\n projectPath: string,\n projectContents: Node,\n): ConfigurationType | OutputType {\n switch (getProjectLanguage(projectPath)) {\n case 'cpp':\n return getConfigurationType(projectContents);\n\n case 'cs':\n return getOutputType(projectContents);\n\n default:\n return 'unknown';\n }\n}\n\n/**\n * Gets the name of the project from the project contents.\n * @param projectPath The project file path to check.\n * @param projectContents The XML project contents.\n * @return The project name.\n */\nexport function getProjectName(\n projectPath: string,\n projectContents: Node,\n): string {\n const name =\n tryFindPropertyValue(projectContents, 'ProjectName') ||\n path.parse(projectPath).name ||\n '';\n\n return name;\n}\n\n/**\n * Gets the namespace of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project namespace.\n */\nexport function getProjectNamespace(projectContents: Node): string | null {\n return tryFindPropertyValue(projectContents, 'RootNamespace');\n}\n\n/**\n * Gets the guid of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project guid.\n */\nexport function getProjectGuid(projectContents: Node): string | null {\n return tryFindPropertyValue(projectContents, 'ProjectGuid');\n}\n\nexport function getExperimentalFeatures(\n solutionDir: string,\n): Record<string, string> | undefined {\n const propsFile = path.join(solutionDir, 'ExperimentalFeatures.props');\n\n if (!fs.existsSync(propsFile)) {\n return undefined;\n }\n\n const result: Record<string, any> = {};\n const propsContents = readProjectFile(propsFile);\n const nodes = msbuildSelect(\n `//msbuild:PropertyGroup/msbuild:*`,\n propsContents,\n );\n for (const node of nodes) {\n const propertyNode = node as Node;\n result[propertyNode.nodeName] = propertyNode.textContent;\n }\n return result;\n}\n"]}