@react-native-windows/cli 0.0.0-canary.19 → 0.0.0-canary.191

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 (138) 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 +25 -2
  15. package/lib-commonjs/{config → commands/config}/configUtils.js +142 -32
  16. package/lib-commonjs/commands/config/configUtils.js.map +1 -0
  17. package/lib-commonjs/commands/config/dependencyConfig.js +228 -0
  18. package/lib-commonjs/commands/config/dependencyConfig.js.map +1 -0
  19. package/lib-commonjs/{config → commands/config}/projectConfig.d.ts +4 -1
  20. package/lib-commonjs/{config → commands/config}/projectConfig.js +72 -12
  21. package/lib-commonjs/commands/config/projectConfig.js.map +1 -0
  22. package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -0
  23. package/lib-commonjs/commands/healthCheck/healthCheckList.js +21 -0
  24. package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -0
  25. package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -0
  26. package/lib-commonjs/commands/healthCheck/healthChecks.js +124 -0
  27. package/lib-commonjs/commands/healthCheck/healthChecks.js.map +1 -0
  28. package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -0
  29. package/lib-commonjs/commands/initWindows/initWindows.js +244 -0
  30. package/lib-commonjs/commands/initWindows/initWindows.js.map +1 -0
  31. package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -0
  32. package/lib-commonjs/commands/initWindows/initWindowsOptions.js +38 -0
  33. package/lib-commonjs/commands/initWindows/initWindowsOptions.js.map +1 -0
  34. package/lib-commonjs/commands/runWindows/runWindows.js +322 -0
  35. package/lib-commonjs/commands/runWindows/runWindows.js.map +1 -0
  36. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.d.ts +15 -11
  37. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.js +12 -11
  38. package/lib-commonjs/commands/runWindows/runWindowsOptions.js.map +1 -0
  39. package/lib-commonjs/e2etest/autolink.test.d.ts +6 -0
  40. package/lib-commonjs/e2etest/autolink.test.js +367 -0
  41. package/lib-commonjs/e2etest/autolink.test.js.map +1 -0
  42. package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -0
  43. package/lib-commonjs/e2etest/dependencyConfig.test.js +130 -0
  44. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -0
  45. package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -0
  46. package/lib-commonjs/e2etest/healthChecks.test.js +31 -0
  47. package/lib-commonjs/e2etest/healthChecks.test.js.map +1 -0
  48. package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -0
  49. package/lib-commonjs/e2etest/initWindows.test.js +43 -0
  50. package/lib-commonjs/e2etest/initWindows.test.js.map +1 -0
  51. package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -0
  52. package/lib-commonjs/e2etest/projectConfig.test.js +111 -0
  53. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -0
  54. package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -0
  55. package/lib-commonjs/e2etest/projectConfig.utils.js +77 -0
  56. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -0
  57. package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -0
  58. package/lib-commonjs/e2etest/runWindows.test.js +61 -0
  59. package/lib-commonjs/e2etest/runWindows.test.js.map +1 -0
  60. package/lib-commonjs/generator-common/index.d.ts +17 -1
  61. package/lib-commonjs/generator-common/index.js +61 -40
  62. package/lib-commonjs/generator-common/index.js.map +1 -1
  63. package/lib-commonjs/generator-windows/index.d.ts +2 -2
  64. package/lib-commonjs/generator-windows/index.js +159 -204
  65. package/lib-commonjs/generator-windows/index.js.map +1 -1
  66. package/lib-commonjs/index.d.ts +6 -2
  67. package/lib-commonjs/index.js +51 -13
  68. package/lib-commonjs/index.js.map +1 -1
  69. package/lib-commonjs/{runWindows/utils → utils}/build.d.ts +2 -3
  70. package/lib-commonjs/{runWindows/utils → utils}/build.js +24 -31
  71. package/lib-commonjs/utils/build.js.map +1 -0
  72. package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.js +11 -7
  73. package/lib-commonjs/utils/checkRequirements.js.map +1 -0
  74. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.d.ts +11 -3
  75. package/lib-commonjs/utils/commandWithProgress.js +150 -0
  76. package/lib-commonjs/utils/commandWithProgress.js.map +1 -0
  77. package/lib-commonjs/{runWindows/utils → utils}/deploy.d.ts +2 -2
  78. package/lib-commonjs/utils/deploy.js +354 -0
  79. package/lib-commonjs/utils/deploy.js.map +1 -0
  80. package/lib-commonjs/{runWindows/utils → utils}/info.js +5 -2
  81. package/lib-commonjs/utils/info.js.map +1 -0
  82. package/lib-commonjs/utils/msbuildtools.d.ts +28 -0
  83. package/lib-commonjs/utils/msbuildtools.js +274 -0
  84. package/lib-commonjs/utils/msbuildtools.js.map +1 -0
  85. package/lib-commonjs/utils/pathHelpers.d.ts +9 -0
  86. package/lib-commonjs/utils/pathHelpers.js +37 -0
  87. package/lib-commonjs/utils/pathHelpers.js.map +1 -0
  88. package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -0
  89. package/lib-commonjs/utils/telemetryHelpers.js +121 -0
  90. package/lib-commonjs/utils/telemetryHelpers.js.map +1 -0
  91. package/lib-commonjs/{runWindows/utils → utils}/version.d.ts +4 -4
  92. package/lib-commonjs/utils/version.js.map +1 -0
  93. package/lib-commonjs/{runWindows/utils → utils}/vsInstalls.d.ts +2 -2
  94. package/lib-commonjs/utils/vsInstalls.js +100 -0
  95. package/lib-commonjs/utils/vsInstalls.js.map +1 -0
  96. package/lib-commonjs/{runWindows/utils → utils}/vstools.d.ts +2 -1
  97. package/lib-commonjs/utils/vstools.js +190 -0
  98. package/lib-commonjs/utils/vstools.js.map +1 -0
  99. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.d.ts +3 -3
  100. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.js +17 -14
  101. package/lib-commonjs/utils/winappdeploytool.js.map +1 -0
  102. package/package.json +47 -29
  103. package/{powershell → src/powershell}/Add-AppDevPackage.ps1 +2 -2
  104. package/src/powershell/Eval-MsBuildProperties.ps1 +156 -0
  105. package/{powershell → src/powershell}/WindowsStoreAppUtils.ps1 +10 -0
  106. package/CHANGELOG.json +0 -287
  107. package/CHANGELOG.md +0 -143
  108. package/lib-commonjs/config/configUtils.js.map +0 -1
  109. package/lib-commonjs/config/dependencyConfig.js +0 -167
  110. package/lib-commonjs/config/dependencyConfig.js.map +0 -1
  111. package/lib-commonjs/config/projectConfig.js.map +0 -1
  112. package/lib-commonjs/runWindows/runWindows.js +0 -159
  113. package/lib-commonjs/runWindows/runWindows.js.map +0 -1
  114. package/lib-commonjs/runWindows/runWindowsOptions.js.map +0 -1
  115. package/lib-commonjs/runWindows/utils/autolink.d.ts +0 -7
  116. package/lib-commonjs/runWindows/utils/autolink.js +0 -353
  117. package/lib-commonjs/runWindows/utils/autolink.js.map +0 -1
  118. package/lib-commonjs/runWindows/utils/build.js.map +0 -1
  119. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +0 -1
  120. package/lib-commonjs/runWindows/utils/commandWithProgress.js +0 -114
  121. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +0 -1
  122. package/lib-commonjs/runWindows/utils/deploy.js +0 -247
  123. package/lib-commonjs/runWindows/utils/deploy.js.map +0 -1
  124. package/lib-commonjs/runWindows/utils/info.js.map +0 -1
  125. package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +0 -22
  126. package/lib-commonjs/runWindows/utils/msbuildtools.js +0 -195
  127. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +0 -1
  128. package/lib-commonjs/runWindows/utils/version.js.map +0 -1
  129. package/lib-commonjs/runWindows/utils/vsInstalls.js +0 -70
  130. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +0 -1
  131. package/lib-commonjs/runWindows/utils/vstools.js +0 -150
  132. package/lib-commonjs/runWindows/utils/vstools.js.map +0 -1
  133. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +0 -1
  134. /package/lib-commonjs/{config → commands/config}/dependencyConfig.d.ts +0 -0
  135. /package/lib-commonjs/{runWindows → commands/runWindows}/runWindows.d.ts +0 -0
  136. /package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.d.ts +0 -0
  137. /package/lib-commonjs/{runWindows/utils → utils}/info.d.ts +0 -0
  138. /package/lib-commonjs/{runWindows/utils → utils}/version.js +0 -0
@@ -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;
@@ -99,7 +102,8 @@ function isRnwDependencyProject(filePath) {
99
102
  return importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CSharpLib.targets');
100
103
  }
101
104
  else if (projectLang === 'cpp') {
102
- return importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppLib.targets');
105
+ return (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppLib.targets') ||
106
+ importProjectExists(projectContents, 'Microsoft.ReactNative.Composition.CppLib.targets'));
103
107
  }
104
108
  return false;
105
109
  }
@@ -118,16 +122,30 @@ function findDependencyProjectFiles(winFolder) {
118
122
  // If there're no project files, return 0
119
123
  return [];
120
124
  }
121
- var dependencyProjectFiles = [];
125
+ const dependencyProjectFiles = [];
122
126
  // Try to find any project file that appears to be a dependency project
123
127
  for (const projectFile of allProjects) {
124
- if (isRnwDependencyProject(path.join(winFolder, projectFile))) {
125
- dependencyProjectFiles.push(projectFile);
128
+ // A project is marked as a RNW dependency iff either:
129
+ // - If the project has the standard native module imports, or
130
+ // - If we only have a single project (and it doesn't have the standard native module imports),
131
+ // pick it and hope for the best. This enables autolinking for modules that were written
132
+ // before the standard native module template existed.
133
+ if (allProjects.length === 1 ||
134
+ isRnwDependencyProject(path_1.default.join(winFolder, projectFile))) {
135
+ dependencyProjectFiles.push(path_1.default.normalize(projectFile));
126
136
  }
127
137
  }
128
138
  return dependencyProjectFiles;
129
139
  }
130
140
  exports.findDependencyProjectFiles = findDependencyProjectFiles;
141
+ function getReactNativeProjectType(value) {
142
+ switch (value) {
143
+ case 'App-WinAppSDK':
144
+ return value;
145
+ default:
146
+ return 'unknown';
147
+ }
148
+ }
131
149
  /**
132
150
  * Checks if the target file path is a RNW app project file.
133
151
  * @param filePath The absolute file path to check.
@@ -135,12 +153,17 @@ exports.findDependencyProjectFiles = findDependencyProjectFiles;
135
153
  */
136
154
  function isRnwAppProject(filePath) {
137
155
  const projectContents = readProjectFile(filePath);
156
+ const rnProjectType = getReactNativeProjectType(tryFindPropertyValue(projectContents, 'ReactNativeProjectType'));
157
+ if (rnProjectType !== 'unknown') {
158
+ return true;
159
+ }
138
160
  const projectLang = getProjectLanguage(filePath);
139
161
  if (projectLang === 'cs') {
140
162
  return importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CSharpApp.targets');
141
163
  }
142
164
  else if (projectLang === 'cpp') {
143
- return importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppApp.targets');
165
+ return (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppApp.targets') ||
166
+ importProjectExists(projectContents, 'Microsoft.ReactNative.Composition.CppApp.targets'));
144
167
  }
145
168
  return false;
146
169
  }
@@ -158,11 +181,11 @@ function findAppProjectFiles(winFolder) {
158
181
  // If there're no project files, return 0
159
182
  return [];
160
183
  }
161
- var appProjectFiles = [];
184
+ const appProjectFiles = [];
162
185
  // Try to find any project file that appears to be an app project
163
186
  for (const projectFile of allProjects) {
164
- if (isRnwAppProject(path.join(winFolder, projectFile))) {
165
- appProjectFiles.push(projectFile);
187
+ if (isRnwAppProject(path_1.default.join(winFolder, projectFile))) {
188
+ appProjectFiles.push(path_1.default.normalize(projectFile));
166
189
  }
167
190
  }
168
191
  return appProjectFiles;
@@ -189,7 +212,7 @@ exports.getProjectLanguage = getProjectLanguage;
189
212
  * @return The project file contents.
190
213
  */
191
214
  function readProjectFile(projectPath) {
192
- const projectContents = fs.readFileSync(projectPath, 'utf8').toString();
215
+ const projectContents = fs_1.default.readFileSync(projectPath, 'utf8').toString();
193
216
  return new xmldom_1.DOMParser().parseFromString(projectContents, 'application/xml');
194
217
  }
195
218
  exports.readProjectFile = readProjectFile;
@@ -199,14 +222,29 @@ exports.readProjectFile = readProjectFile;
199
222
  * @param propertyName The property to look for.
200
223
  * @return The value of the tag if it exists.
201
224
  */
202
- function findPropertyValue(projectContents, propertyName) {
203
- var nodes = msbuildSelect(`//msbuild:PropertyGroup/msbuild:${propertyName}`, projectContents);
225
+ function tryFindPropertyValue(projectContents, propertyName) {
226
+ const nodes = msbuildSelect(`//msbuild:PropertyGroup/msbuild:${propertyName}`, projectContents);
204
227
  if (nodes.length > 0) {
205
228
  // Take the last one
206
229
  return nodes[nodes.length - 1].textContent;
207
230
  }
231
+ else {
232
+ const noNamespaceNodes = xpath_1.default.select(`//PropertyGroup/${propertyName}`, projectContents);
233
+ if (noNamespaceNodes.length > 0) {
234
+ return noNamespaceNodes[noNamespaceNodes.length - 1]
235
+ .textContent;
236
+ }
237
+ }
208
238
  return null;
209
239
  }
240
+ exports.tryFindPropertyValue = tryFindPropertyValue;
241
+ function findPropertyValue(projectContents, propertyName, filePath) {
242
+ const res = tryFindPropertyValue(projectContents, propertyName);
243
+ if (!res) {
244
+ throw new telemetry_1.CodedError('NoPropertyInProject', `Couldn't find property ${propertyName} from ${filePath}`, { propertyName: propertyName });
245
+ }
246
+ return res;
247
+ }
210
248
  exports.findPropertyValue = findPropertyValue;
211
249
  /**
212
250
  * Search for the given import project in the project contents and return if it exists.
@@ -215,19 +253,76 @@ exports.findPropertyValue = findPropertyValue;
215
253
  * @return If the target exists.
216
254
  */
217
255
  function importProjectExists(projectContents, projectName) {
218
- var nodes = msbuildSelect(`//msbuild:Import[contains(@Project,'${projectName}')]`, projectContents);
256
+ const nodes = msbuildSelect(`//msbuild:Import[contains(@Project,'${projectName}')]`, projectContents);
219
257
  return nodes.length > 0;
220
258
  }
221
259
  exports.importProjectExists = importProjectExists;
260
+ /**
261
+ * Gets the configuration type of the project from the project contents.
262
+ * @param projectContents The XML project contents.
263
+ * @return The project configuration type.
264
+ */
265
+ function getConfigurationType(projectContents) {
266
+ var _a;
267
+ const configurationType = (_a = tryFindPropertyValue(projectContents, 'ConfigurationType')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
268
+ switch (configurationType) {
269
+ case 'application':
270
+ case 'dynamiclibrary':
271
+ case 'generic':
272
+ case 'staticlibrary':
273
+ return configurationType;
274
+ default:
275
+ return 'unknown';
276
+ }
277
+ }
278
+ exports.getConfigurationType = getConfigurationType;
279
+ /**
280
+ * Gets the output type of the project from the project contents.
281
+ * @param projectContents The XML project contents.
282
+ * @return The project output type.
283
+ */
284
+ function getOutputType(projectContents) {
285
+ var _a;
286
+ const outputType = (_a = tryFindPropertyValue(projectContents, 'OutputType')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
287
+ switch (outputType) {
288
+ case 'appcontainerexe':
289
+ case 'exe':
290
+ case 'library':
291
+ case 'module':
292
+ case 'winexe':
293
+ case 'winmdobj':
294
+ return outputType;
295
+ default:
296
+ return 'unknown';
297
+ }
298
+ }
299
+ exports.getOutputType = getOutputType;
300
+ /**
301
+ * Gets the type of the project from the project contents.
302
+ * @param projectPath The project file path to check.
303
+ * @param projectContents The XML project contents.
304
+ * @return The project type.
305
+ */
306
+ function getProjectType(projectPath, projectContents) {
307
+ switch (getProjectLanguage(projectPath)) {
308
+ case 'cpp':
309
+ return getConfigurationType(projectContents);
310
+ case 'cs':
311
+ return getOutputType(projectContents);
312
+ default:
313
+ return 'unknown';
314
+ }
315
+ }
316
+ exports.getProjectType = getProjectType;
222
317
  /**
223
318
  * Gets the name of the project from the project contents.
224
319
  * @param projectPath The project file path to check.
225
320
  * @param projectContents The XML project contents.
226
321
  * @return The project name.
227
322
  */
228
- function getProjectName(projectContents) {
229
- const name = findPropertyValue(projectContents, 'ProjectName') ||
230
- findPropertyValue(projectContents, 'AssemblyName') ||
323
+ function getProjectName(projectPath, projectContents) {
324
+ const name = tryFindPropertyValue(projectContents, 'ProjectName') ||
325
+ path_1.default.parse(projectPath).name ||
231
326
  '';
232
327
  return name;
233
328
  }
@@ -238,7 +333,7 @@ exports.getProjectName = getProjectName;
238
333
  * @return The project namespace.
239
334
  */
240
335
  function getProjectNamespace(projectContents) {
241
- return findPropertyValue(projectContents, 'RootNamespace');
336
+ return tryFindPropertyValue(projectContents, 'RootNamespace');
242
337
  }
243
338
  exports.getProjectNamespace = getProjectNamespace;
244
339
  /**
@@ -247,7 +342,22 @@ exports.getProjectNamespace = getProjectNamespace;
247
342
  * @return The project guid.
248
343
  */
249
344
  function getProjectGuid(projectContents) {
250
- return findPropertyValue(projectContents, 'ProjectGuid');
345
+ return tryFindPropertyValue(projectContents, 'ProjectGuid');
251
346
  }
252
347
  exports.getProjectGuid = getProjectGuid;
348
+ function getExperimentalFeatures(solutionDir) {
349
+ const propsFile = path_1.default.join(solutionDir, 'ExperimentalFeatures.props');
350
+ if (!fs_1.default.existsSync(propsFile)) {
351
+ return undefined;
352
+ }
353
+ const result = {};
354
+ const propsContents = readProjectFile(propsFile);
355
+ const nodes = msbuildSelect(`//msbuild:PropertyGroup/msbuild:*`, propsContents);
356
+ for (const node of nodes) {
357
+ const propertyNode = node;
358
+ result[propertyNode.nodeName] = propertyNode.textContent;
359
+ }
360
+ return result;
361
+ }
362
+ exports.getExperimentalFeatures = getExperimentalFeatures;
253
363
  //# sourceMappingURL=configUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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;;;;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 (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppLib.targets',\n ) ||\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppLib.targets',\n )\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 (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppApp.targets',\n ) ||\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppApp.targets',\n )\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"]}
@@ -0,0 +1,228 @@
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.dependencyConfigWindows = void 0;
35
+ // Types in this file are inaccurate compared to usage in terms of falsiness.
36
+ // We should try to rewrite some of this to do automated schema validation to
37
+ // guarantee correct types
38
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition */
39
+ const os_1 = require("os");
40
+ const path_1 = __importDefault(require("path"));
41
+ const configUtils = __importStar(require("./configUtils"));
42
+ /**
43
+ * Gets the config of any RNW native modules under the target folder.
44
+ * @param userConfig A manually specified override config.
45
+ * @return The config if any RNW native modules exist.
46
+ */
47
+ // Disabled due to existing high cyclomatic complexity
48
+ // eslint-disable-next-line complexity
49
+ function dependencyConfigWindows(folder, userConfig = {}) {
50
+ if ((0, os_1.platform)() !== 'win32') {
51
+ return null;
52
+ }
53
+ if (userConfig === null) {
54
+ return null;
55
+ }
56
+ const usingManualProjectsOverride = 'projects' in userConfig && Array.isArray(userConfig.projects);
57
+ const usingManualNugetPackagesOverride = 'nugetPackages' in userConfig && Array.isArray(userConfig.nugetPackages);
58
+ const result = {
59
+ folder,
60
+ projects: usingManualProjectsOverride ? userConfig.projects : [],
61
+ solutionFile: null,
62
+ nugetPackages: usingManualNugetPackagesOverride
63
+ ? userConfig.nugetPackages
64
+ : [],
65
+ };
66
+ let sourceDir = null;
67
+ if (usingManualProjectsOverride && result.projects.length > 0) {
68
+ // Manually provided projects, so extract the sourceDir
69
+ if (!('sourceDir' in userConfig)) {
70
+ sourceDir =
71
+ 'Error: Source dir is required if projects are specified, but it is not specified in react-native.config.';
72
+ }
73
+ else if (userConfig.sourceDir === null) {
74
+ sourceDir =
75
+ 'Error: Source dir is required if projects are specified, but it is null in react-native.config.';
76
+ }
77
+ else {
78
+ sourceDir = path_1.default.join(folder, userConfig.sourceDir);
79
+ }
80
+ }
81
+ else if (!usingManualProjectsOverride) {
82
+ // No manually provided projects, try to find sourceDir
83
+ if ('sourceDir' in userConfig && userConfig.sourceDir !== null) {
84
+ sourceDir = path_1.default.join(folder, userConfig.sourceDir);
85
+ }
86
+ else {
87
+ sourceDir = configUtils.findWindowsFolder(folder);
88
+ }
89
+ }
90
+ if (sourceDir === null) {
91
+ // Try to salvage the missing sourceDir
92
+ if (result.projects.length === 0 && result.nugetPackages.length > 0) {
93
+ // Only nuget packages, no sourceDir required
94
+ return result;
95
+ }
96
+ else if (result.projects.length > 0) {
97
+ // Projects overridden but no sourceDir, assume the sourceDir === folder
98
+ sourceDir = folder;
99
+ }
100
+ }
101
+ else if (sourceDir.startsWith('Error: ')) {
102
+ // Source dir error, bail with error
103
+ result.sourceDir = sourceDir;
104
+ return result;
105
+ }
106
+ if (sourceDir === null) {
107
+ // After everything above, if sourceDir is still null,
108
+ // there's nothing more to look for here, bail
109
+ return null;
110
+ }
111
+ result.sourceDir = path_1.default.relative(folder, sourceDir);
112
+ const usingManualSolutionFile = 'solutionFile' in userConfig;
113
+ let solutionFile = null;
114
+ if (usingManualSolutionFile && userConfig.solutionFile !== null) {
115
+ // Manually provided solutionFile, so extract it
116
+ solutionFile = path_1.default.join(sourceDir, userConfig.solutionFile);
117
+ }
118
+ else if (!usingManualSolutionFile) {
119
+ // No manually provided solutionFile, try to find it
120
+ const foundSolutions = configUtils.findSolutionFiles(sourceDir);
121
+ if (foundSolutions.length === 1) {
122
+ solutionFile = path_1.default.join(sourceDir, foundSolutions[0]);
123
+ }
124
+ }
125
+ result.solutionFile =
126
+ solutionFile !== null ? path_1.default.relative(sourceDir, solutionFile) : null;
127
+ if (usingManualProjectsOverride) {
128
+ // react-native.config used, fill out (auto) items for each provided project, verify (req) items are present
129
+ const alwaysRequired = [
130
+ 'projectFile',
131
+ 'directDependency',
132
+ ];
133
+ for (const project of result.projects) {
134
+ // Verifying (req) items
135
+ let errorFound = false;
136
+ alwaysRequired.forEach(item => {
137
+ if (!(item in project)) {
138
+ project[item] = `Error: ${item} is required for each project in react-native.config`;
139
+ errorFound = true;
140
+ }
141
+ });
142
+ if (errorFound) {
143
+ break;
144
+ }
145
+ const projectFile = path_1.default.join(sourceDir, project.projectFile);
146
+ const projectContents = configUtils.readProjectFile(projectFile);
147
+ project.projectFile = path_1.default.relative(sourceDir, projectFile);
148
+ // Calculating (auto) items
149
+ project.projectName = configUtils.getProjectName(projectFile, projectContents);
150
+ project.projectLang = configUtils.getProjectLanguage(projectFile);
151
+ project.projectGuid = configUtils.getProjectGuid(projectContents);
152
+ if (project.directDependency) {
153
+ // Calculating more (auto) items
154
+ const projectNamespace = configUtils.getProjectNamespace(projectContents);
155
+ if (projectNamespace !== null) {
156
+ const cppNamespace = projectNamespace.replace(/\./g, '::');
157
+ const csNamespace = projectNamespace.replace(/::/g, '.');
158
+ project.cppHeaders = project.cppHeaders || [`winrt/${csNamespace}.h`];
159
+ project.cppPackageProviders = project.cppPackageProviders || [
160
+ `${cppNamespace}::ReactPackageProvider`,
161
+ ];
162
+ project.csNamespaces = project.csNamespaces || [`${csNamespace}`];
163
+ project.csPackageProviders = project.csPackageProviders || [
164
+ `${csNamespace}.ReactPackageProvider`,
165
+ ];
166
+ }
167
+ }
168
+ }
169
+ }
170
+ else {
171
+ // No react-native.config, try to heuristically find any projects
172
+ const foundProjects = configUtils.findDependencyProjectFiles(sourceDir);
173
+ for (const foundProject of foundProjects) {
174
+ const projectFile = path_1.default.join(sourceDir, foundProject);
175
+ const projectContents = configUtils.readProjectFile(projectFile);
176
+ const projectType = configUtils.getProjectType(projectFile, projectContents);
177
+ if (projectType === 'dynamiclibrary' ||
178
+ projectType === 'winmdobj' ||
179
+ projectType === 'library') {
180
+ const projectLang = configUtils.getProjectLanguage(projectFile);
181
+ const projectName = configUtils.getProjectName(projectFile, projectContents);
182
+ const projectGuid = configUtils.getProjectGuid(projectContents);
183
+ const projectNamespace = configUtils.getProjectNamespace(projectContents);
184
+ const directDependency = true;
185
+ const cppHeaders = [];
186
+ const cppPackageProviders = [];
187
+ const csNamespaces = [];
188
+ const csPackageProviders = [];
189
+ if (projectNamespace !== null) {
190
+ const cppNamespace = projectNamespace.replace(/\./g, '::');
191
+ const csNamespace = projectNamespace.replace(/::/g, '.');
192
+ cppHeaders.push(`winrt/${csNamespace}.h`);
193
+ cppPackageProviders.push(`${cppNamespace}::ReactPackageProvider`);
194
+ csNamespaces.push(`${csNamespace}`);
195
+ csPackageProviders.push(`${csNamespace}.ReactPackageProvider`);
196
+ }
197
+ result.projects.push({
198
+ projectFile: path_1.default.relative(sourceDir, projectFile),
199
+ projectName,
200
+ projectLang,
201
+ projectGuid,
202
+ directDependency,
203
+ cppHeaders,
204
+ cppPackageProviders,
205
+ csNamespaces,
206
+ csPackageProviders,
207
+ });
208
+ }
209
+ else {
210
+ const projectPath = path_1.default.relative(sourceDir, projectFile);
211
+ result.projects.push({
212
+ projectFile: `Error: ${projectPath} is type '${projectType}'`,
213
+ directDependency: false,
214
+ projectName: '',
215
+ projectLang: null,
216
+ projectGuid: null,
217
+ cppHeaders: [],
218
+ cppPackageProviders: [],
219
+ csNamespaces: [],
220
+ csPackageProviders: [],
221
+ });
222
+ }
223
+ }
224
+ }
225
+ return result;
226
+ }
227
+ exports.dependencyConfigWindows = dependencyConfigWindows;
228
+ //# sourceMappingURL=dependencyConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencyConfig.js","sourceRoot":"","sources":["../../../src/commands/config/dependencyConfig.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6EAA6E;AAC7E,6EAA6E;AAC7E,0BAA0B;AAC1B,gEAAgE;AAEhE,2BAA4B;AAC5B,gDAAwB;AAExB,2DAA6C;AA+F7C;;;;GAIG;AACH,sDAAsD;AACtD,sCAAsC;AACtC,SAAgB,uBAAuB,CACrC,MAAc,EACd,aAAsD,EAAE;IAExD,IAAI,IAAA,aAAQ,GAAE,KAAK,OAAO,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IAED,IAAI,UAAU,KAAK,IAAI,EAAE;QACvB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,2BAA2B,GAC/B,UAAU,IAAI,UAAU,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAEjE,MAAM,gCAAgC,GACpC,eAAe,IAAI,UAAU,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAE3E,MAAM,MAAM,GAA4B;QACtC,MAAM;QACN,QAAQ,EAAE,2BAA2B,CAAC,CAAC,CAAC,UAAU,CAAC,QAAS,CAAC,CAAC,CAAC,EAAE;QACjE,YAAY,EAAE,IAAI;QAClB,aAAa,EAAE,gCAAgC;YAC7C,CAAC,CAAC,UAAU,CAAC,aAAc;YAC3B,CAAC,CAAC,EAAE;KACP,CAAC;IAEF,IAAI,SAAS,GAAkB,IAAI,CAAC;IACpC,IAAI,2BAA2B,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7D,uDAAuD;QACvD,IAAI,CAAC,CAAC,WAAW,IAAI,UAAU,CAAC,EAAE;YAChC,SAAS;gBACP,0GAA0G,CAAC;SAC9G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AC,IAAI,CAAC;oBACnB,WAAW,EAAE,cAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;oBAClD,WAAW;oBACX,WAAW;oBACX,WAAW;oBACX,gBAAgB;oBAChB,UAAU;oBACV,mBAAmB;oBACnB,YAAY;oBACZ,kBAAkB;iBACnB,CAAC,CAAC;aACJ;iBAAM;gBACL,MAAM,WAAW,GAAG,cAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;gBAC1D,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACnB,WAAW,EAAE,UAAU,WAAW,aAAa,WAAW,GAAG;oBAC7D,gBAAgB,EAAE,KAAK;oBACvB,WAAW,EAAE,EAAE;oBACf,WAAW,EAAE,IAAI;oBACjB,WAAW,EAAE,IAAI;oBACjB,UAAU,EAAE,EAAE;oBACd,mBAAmB,EAAE,EAAE;oBACvB,YAAY,EAAE,EAAE;oBAChB,kBAAkB,EAAE,EAAE;iBACvB,CAAC,CAAC;aACJ;SACF;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAlOD,0DAkOC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\n// Types in this file are inaccurate compared to usage in terms of falsiness.\n// We should try to rewrite some of this to do automated schema validation to\n// guarantee correct types\n/* eslint-disable @typescript-eslint/no-unnecessary-condition */\n\nimport {platform} from 'os';\nimport path from 'path';\n\nimport * as configUtils from './configUtils';\n\n/*\n\nreact-native config will generate the following JSON for each native module dependency\nunder node_modules that has a Windows implementation, in order to support auto-linking.\nThis is done heuristically, so if the result isn't quite correct, native module developers\ncan provide a manual override file: react-native.config.js.\n\nSchema for dependencies:\n\nTags:\nauto - Item is always calculated by config. An override file should NEVER provide it.\nreq - Item is required. If an override file exists, it MUST provide it. If no override file exists, config will try to calculate it.\nopt - Item is optional. If an override file exists, it MAY provide it. If no override file exists, config may try to calculate it.\n\n{\n folder: string, // (auto) Absolute path to the module root folder, determined by react-native config, ex: 'c:\\path\\to\\app-name\\node_modules\\my-module'\n sourceDir: string, // (opt, req if projects defined) Relative path to the Windows implementation under folder, ex: 'windows'\n solutionFile: string, // (opt) Relative path to the module's VS solution file under sourceDir, ex: 'MyModule.sln'\n projects: [ // (opt) Array of VS projects that must be added to the consuming app's solution file, so they are built\n {\n projectFile: string, // (req) Relative path to the VS project file under sourceDir, ex: 'MyModule\\MyModule.vcxproj' for 'c:\\path\\to\\app-name\\node_modules\\my-module\\windows\\MyModule\\MyModule.vcxproj'\n directDependency: bool, // (req) Whether to add the project file as a dependency to the consuming app's project file. true for projects that provide native modules\n projectName: string, // (auto) Name of the project, determined from projectFile, ex: 'MyModule'\n projectLang: string, // (auto) Language of the project, cpp or cs, determined from projectFile\n projectGuid: string, // (auto) Project identifier, determined from projectFile\n cppHeaders: [], // (opt) Array of cpp header include lines, ie: 'winrt/MyModule.h', to be transformed into '#include <winrt/MyModule.h>'\n cppPackageProviders: [], // (opt) Array of fully qualified cpp IReactPackageProviders, ie: 'MyModule::ReactPackageProvider'\n csNamespaces: [], // (opt) Array of cs namespaces, ie: 'MyModule', to be transformed into 'using MyModule;'\n csPackageProviders: [], // (opt) Array of fully qualified cs IReactPackageProviders, ie: 'MyModule.ReactPackageProvider'\n },\n ],\n nugetPackages: [ // (opt) Array of nuget packages including native modules that must be added as a dependency to the consuming app. It can be empty, but by its nature it can't be calculated\n {\n packageName: string, // (req) Name of the nuget package to install\n packageVersion: string, // (req) Version of the nuget package to install\n cppHeaders: [], // (req) Array of cpp header include lines, ie: 'winrt/NugetModule.h', to be transformed into '#include <winrt/NugetModule.h>'\n cppPackageProviders: [], // (req) Array of fully qualified cpp IReactPackageProviders, ie: 'NugetModule::ReactPackageProvider'\n csNamespaces: [], // (req) Array of cs namespaces, ie: 'NugetModule', to be transformed into 'using NugetModule;'\n csPackageProviders: [], // (req) Array of fully qualified cs IReactPackageProviders, ie: 'NugetModule.ReactPackageProvider'\n },\n ],\n}\n\nExample react-native.config.js for a 'MyModule':\n\nmodule.exports = {\n dependency: {\n platforms: {\n windows: {\n sourceDir: 'windows',\n solutionFile: 'MyModule.sln',\n projects: [\n {\n projectFile: 'MyModule\\\\MyModule.vcxproj',\n directDependency: true,\n }\n ],\n },\n },\n },\n};\n\n*/\n\nexport interface ProjectDependency {\n projectFile: string;\n directDependency: boolean;\n projectName: string;\n projectLang: 'cpp' | 'cs' | null;\n projectGuid: string | null;\n cppHeaders: string[];\n cppPackageProviders: string[];\n csNamespaces: string[];\n csPackageProviders: string[];\n}\n\nexport interface NuGetPackageDependency {\n packageName: string;\n packageVersion: string;\n cppHeaders: string[];\n cppPackageProviders: string[];\n csNamespaces: string[];\n csPackageProviders: string[];\n}\n\nexport interface WindowsDependencyConfig {\n folder: string;\n sourceDir?: string;\n solutionFile?: string | null;\n projects: ProjectDependency[];\n nugetPackages: NuGetPackageDependency[];\n}\n\n/**\n * Gets the config of any RNW native modules under the target folder.\n * @param userConfig A manually specified override config.\n * @return The config if any RNW native modules exist.\n */\n// Disabled due to existing high cyclomatic complexity\n// eslint-disable-next-line complexity\nexport function dependencyConfigWindows(\n folder: string,\n userConfig: Partial<WindowsDependencyConfig> | null = {},\n): WindowsDependencyConfig | null {\n if (platform() !== 'win32') {\n return null;\n }\n\n if (userConfig === null) {\n return null;\n }\n\n const usingManualProjectsOverride =\n 'projects' in userConfig && Array.isArray(userConfig.projects);\n\n const usingManualNugetPackagesOverride =\n 'nugetPackages' in userConfig && Array.isArray(userConfig.nugetPackages);\n\n const result: WindowsDependencyConfig = {\n folder,\n projects: usingManualProjectsOverride ? userConfig.projects! : [],\n solutionFile: null,\n nugetPackages: usingManualNugetPackagesOverride\n ? userConfig.nugetPackages!\n : [],\n };\n\n let sourceDir: string | null = null;\n if (usingManualProjectsOverride && result.projects.length > 0) {\n // Manually provided projects, so extract the sourceDir\n if (!('sourceDir' in userConfig)) {\n sourceDir =\n 'Error: Source dir is required if projects are specified, but it is not specified in react-native.config.';\n } else if (userConfig.sourceDir === null) {\n sourceDir =\n 'Error: Source dir is required if projects are specified, but it is null in react-native.config.';\n } else {\n sourceDir = path.join(folder, userConfig.sourceDir!);\n }\n } else if (!usingManualProjectsOverride) {\n // No manually provided projects, try to find sourceDir\n if ('sourceDir' in userConfig && userConfig.sourceDir !== null) {\n sourceDir = path.join(folder, userConfig.sourceDir!);\n } else {\n sourceDir = configUtils.findWindowsFolder(folder);\n }\n }\n\n if (sourceDir === null) {\n // Try to salvage the missing sourceDir\n if (result.projects.length === 0 && result.nugetPackages.length > 0) {\n // Only nuget packages, no sourceDir required\n return result;\n } else if (result.projects.length > 0) {\n // Projects overridden but no sourceDir, assume the sourceDir === folder\n sourceDir = folder;\n }\n } else if (sourceDir.startsWith('Error: ')) {\n // Source dir error, bail with error\n result.sourceDir = sourceDir;\n return result;\n }\n\n if (sourceDir === null) {\n // After everything above, if sourceDir is still null,\n // there's nothing more to look for here, bail\n return null;\n }\n\n result.sourceDir = path.relative(folder, sourceDir);\n\n const usingManualSolutionFile = 'solutionFile' in userConfig;\n\n let solutionFile = null;\n if (usingManualSolutionFile && userConfig.solutionFile !== null) {\n // Manually provided solutionFile, so extract it\n solutionFile = path.join(sourceDir, userConfig.solutionFile!);\n } else if (!usingManualSolutionFile) {\n // No manually provided solutionFile, try to find it\n const foundSolutions = configUtils.findSolutionFiles(sourceDir);\n if (foundSolutions.length === 1) {\n solutionFile = path.join(sourceDir, foundSolutions[0]);\n }\n }\n\n result.solutionFile =\n solutionFile !== null ? path.relative(sourceDir, solutionFile) : null;\n\n if (usingManualProjectsOverride) {\n // react-native.config used, fill out (auto) items for each provided project, verify (req) items are present\n\n const alwaysRequired: Array<keyof ProjectDependency> = [\n 'projectFile',\n 'directDependency',\n ];\n\n for (const project of result.projects) {\n // Verifying (req) items\n let errorFound = false;\n\n alwaysRequired.forEach(item => {\n if (!(item in project)) {\n (project[\n item\n ] as string) = `Error: ${item} is required for each project in react-native.config`;\n errorFound = true;\n }\n });\n\n if (errorFound) {\n break;\n }\n\n const projectFile = path.join(sourceDir, project.projectFile);\n\n const projectContents = configUtils.readProjectFile(projectFile);\n\n project.projectFile = path.relative(sourceDir, projectFile);\n\n // Calculating (auto) items\n project.projectName = configUtils.getProjectName(\n projectFile,\n projectContents,\n );\n project.projectLang = configUtils.getProjectLanguage(projectFile);\n project.projectGuid = configUtils.getProjectGuid(projectContents);\n\n if (project.directDependency) {\n // Calculating more (auto) items\n\n const projectNamespace =\n configUtils.getProjectNamespace(projectContents);\n\n if (projectNamespace !== null) {\n const cppNamespace = projectNamespace!.replace(/\\./g, '::');\n const csNamespace = projectNamespace!.replace(/::/g, '.');\n\n project.cppHeaders = project.cppHeaders || [`winrt/${csNamespace}.h`];\n project.cppPackageProviders = project.cppPackageProviders || [\n `${cppNamespace}::ReactPackageProvider`,\n ];\n project.csNamespaces = project.csNamespaces || [`${csNamespace}`];\n project.csPackageProviders = project.csPackageProviders || [\n `${csNamespace}.ReactPackageProvider`,\n ];\n }\n }\n }\n } else {\n // No react-native.config, try to heuristically find any projects\n\n const foundProjects = configUtils.findDependencyProjectFiles(sourceDir);\n\n for (const foundProject of foundProjects) {\n const projectFile = path.join(sourceDir, foundProject);\n\n const projectContents = configUtils.readProjectFile(projectFile);\n\n const projectType = configUtils.getProjectType(\n projectFile,\n projectContents,\n );\n\n if (\n projectType === 'dynamiclibrary' ||\n projectType === 'winmdobj' ||\n projectType === 'library'\n ) {\n const projectLang = configUtils.getProjectLanguage(projectFile);\n\n const projectName = configUtils.getProjectName(\n projectFile,\n projectContents,\n );\n\n const projectGuid = configUtils.getProjectGuid(projectContents);\n\n const projectNamespace =\n configUtils.getProjectNamespace(projectContents);\n\n const directDependency = true;\n\n const cppHeaders: string[] = [];\n const cppPackageProviders: string[] = [];\n const csNamespaces: string[] = [];\n const csPackageProviders: string[] = [];\n\n if (projectNamespace !== null) {\n const cppNamespace = projectNamespace.replace(/\\./g, '::');\n const csNamespace = projectNamespace.replace(/::/g, '.');\n\n cppHeaders.push(`winrt/${csNamespace}.h`);\n cppPackageProviders.push(`${cppNamespace}::ReactPackageProvider`);\n csNamespaces.push(`${csNamespace}`);\n csPackageProviders.push(`${csNamespace}.ReactPackageProvider`);\n }\n\n result.projects.push({\n projectFile: path.relative(sourceDir, projectFile),\n projectName,\n projectLang,\n projectGuid,\n directDependency,\n cppHeaders,\n cppPackageProviders,\n csNamespaces,\n csPackageProviders,\n });\n } else {\n const projectPath = path.relative(sourceDir, projectFile);\n result.projects.push({\n projectFile: `Error: ${projectPath} is type '${projectType}'`,\n directDependency: false,\n projectName: '',\n projectLang: null,\n projectGuid: null,\n cppHeaders: [],\n cppPackageProviders: [],\n csNamespaces: [],\n csPackageProviders: [],\n });\n }\n }\n }\n\n return result;\n}\n"]}
@@ -8,12 +8,15 @@ export interface Project {
8
8
  projectName: string;
9
9
  projectLang: 'cpp' | 'cs' | null;
10
10
  projectGuid: string | null;
11
+ projectTypeGuid?: string;
11
12
  }
12
13
  export interface WindowsProjectConfig {
13
14
  folder: string;
14
15
  sourceDir: string;
15
16
  solutionFile: string;
16
17
  project: Project;
18
+ useWinUI3?: boolean;
19
+ experimentalFeatures?: Record<string, string>;
17
20
  }
18
21
  /**
19
22
  * Gets the config of any RNW apps under the target folder.
@@ -21,4 +24,4 @@ export interface WindowsProjectConfig {
21
24
  * @param userConfig A manually specified override config.
22
25
  * @return The config if any RNW apps exist.
23
26
  */
24
- export declare function projectConfigWindows(folder: string, userConfig?: Partial<WindowsProjectConfig>): WindowsProjectConfig | null;
27
+ export declare function projectConfigWindows(folder: string, userConfig?: Partial<WindowsProjectConfig> | null): WindowsProjectConfig | null;