@react-native-windows/cli 0.66.2 → 0.68.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +1 -1
  2. package/lib-commonjs/config/configUtils.js +1 -1
  3. package/lib-commonjs/config/configUtils.js.map +1 -1
  4. package/lib-commonjs/config/dependencyConfig.js +6 -4
  5. package/lib-commonjs/config/dependencyConfig.js.map +1 -1
  6. package/lib-commonjs/config/projectConfig.js +2 -2
  7. package/lib-commonjs/config/projectConfig.js.map +1 -1
  8. package/lib-commonjs/e2etest/autolink.test.d.ts +5 -0
  9. package/lib-commonjs/e2etest/autolink.test.js +109 -12
  10. package/lib-commonjs/e2etest/autolink.test.js.map +1 -1
  11. package/lib-commonjs/e2etest/dependencyConfig.test.js +17 -17
  12. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -1
  13. package/lib-commonjs/e2etest/projectConfig.test.js +18 -20
  14. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -1
  15. package/lib-commonjs/e2etest/projectConfig.utils.js +6 -13
  16. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -1
  17. package/lib-commonjs/e2etest/runWindows.test.js +52 -13
  18. package/lib-commonjs/e2etest/runWindows.test.js.map +1 -1
  19. package/lib-commonjs/generator-common/index.js +8 -8
  20. package/lib-commonjs/generator-common/index.js.map +1 -1
  21. package/lib-commonjs/generator-windows/index.js +34 -77
  22. package/lib-commonjs/generator-windows/index.js.map +1 -1
  23. package/lib-commonjs/healthChecks.js +22 -4
  24. package/lib-commonjs/healthChecks.js.map +1 -1
  25. package/lib-commonjs/index.js +10 -61
  26. package/lib-commonjs/index.js.map +1 -1
  27. package/lib-commonjs/runWindows/runWindows.d.ts +0 -1
  28. package/lib-commonjs/runWindows/runWindows.js +124 -145
  29. package/lib-commonjs/runWindows/runWindows.js.map +1 -1
  30. package/lib-commonjs/runWindows/runWindowsOptions.d.ts +8 -8
  31. package/lib-commonjs/runWindows/runWindowsOptions.js +7 -12
  32. package/lib-commonjs/runWindows/runWindowsOptions.js.map +1 -1
  33. package/lib-commonjs/runWindows/utils/autolink.d.ts +16 -5
  34. package/lib-commonjs/runWindows/utils/autolink.js +118 -57
  35. package/lib-commonjs/runWindows/utils/autolink.js.map +1 -1
  36. package/lib-commonjs/runWindows/utils/build.js +4 -4
  37. package/lib-commonjs/runWindows/utils/build.js.map +1 -1
  38. package/lib-commonjs/runWindows/utils/checkRequirements.js +2 -2
  39. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +1 -1
  40. package/lib-commonjs/runWindows/utils/commandWithProgress.d.ts +8 -1
  41. package/lib-commonjs/runWindows/utils/commandWithProgress.js +30 -8
  42. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +1 -1
  43. package/lib-commonjs/runWindows/utils/deploy.d.ts +1 -1
  44. package/lib-commonjs/runWindows/utils/deploy.js +88 -37
  45. package/lib-commonjs/runWindows/utils/deploy.js.map +1 -1
  46. package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +1 -0
  47. package/lib-commonjs/runWindows/utils/msbuildtools.js +30 -23
  48. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +1 -1
  49. package/lib-commonjs/runWindows/utils/telemetryHelpers.d.ts +29 -0
  50. package/lib-commonjs/runWindows/utils/telemetryHelpers.js +109 -0
  51. package/lib-commonjs/runWindows/utils/telemetryHelpers.js.map +1 -0
  52. package/lib-commonjs/runWindows/utils/version.js +1 -1
  53. package/lib-commonjs/runWindows/utils/version.js.map +1 -1
  54. package/lib-commonjs/runWindows/utils/vsInstalls.js +3 -3
  55. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +1 -1
  56. package/lib-commonjs/runWindows/utils/vstools.js +4 -4
  57. package/lib-commonjs/runWindows/utils/vstools.js.map +1 -1
  58. package/lib-commonjs/runWindows/utils/winappdeploytool.js +7 -7
  59. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +1 -1
  60. package/package.json +17 -13
  61. package/CHANGELOG.json +0 -1585
  62. package/CHANGELOG.md +0 -713
package/README.md CHANGED
@@ -17,7 +17,7 @@ Options:
17
17
  |-----------------------|--------------------------------------|--------------------------------------------------|
18
18
  | `--release` | Specifies a Release build | [boolean] |
19
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). default: x86 | [string] |
20
+ | `--arch` | The build architecture (ARM64, x86, x64). defaults to system architecture | [string] |
21
21
  | `--singleproc` | Disables multi-proc build | [boolean] |
22
22
  | `--emulator` | Deploys the app to an emulator | [boolean] |
23
23
  | `--device` | Deploys the app to a connected device | [boolean] |
@@ -9,7 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
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("fs"));
12
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
13
13
  const path_1 = __importDefault(require("path"));
14
14
  const glob_1 = __importDefault(require("glob"));
15
15
  const xmldom_1 = require("@xmldom/xmldom");
@@ -1 +1 @@
1
- {"version":3,"file":"configUtils.js","sourceRoot":"","sources":["../../src/config/configUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,4CAAoB;AACpB,gDAAwB;AACxB,gDAAwB;AAExB,2CAAyC;AACzC,kDAA0B;AAC1B,+DAA2D;AAE3D,MAAM,aAAa,GAAG,eAAK,CAAC,aAAa,CAAC;IACxC,OAAO,EAAE,qDAAqD;CAC/D,C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E,OAAO,SAAS,CAAC;KACpB;AACH,CAAC;AAdD,wCAcC;AAED;;;;;GAKG;AACH,SAAgB,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 '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\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 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 }\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"]}
1
+ {"version":3,"file":"configUtils.js","sourceRoot":"","sources":["../../src/config/configUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,gDAAwB;AAExB,2CAAyC;AACzC,kDAA0B;AAC1B,+DAA2D;AAE3D,MAAM,aAAa,GAAG,eAAK,CAAC,aAAa,CAAC;IACxC,OAAO,EAAE,qDAAqD;CAC/D,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,MAAc,EAAE,eAAuB;IAC/D,MAAM,KAAK,GAAG,cAAI,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,EAAE;QACxD,GAAG,EAAE,MAAM;QACX,MAAM,EAAE;YACN,iBAAiB;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AAC,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\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 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 }\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"]}
@@ -19,7 +19,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
19
19
  var __importStar = (this && this.__importStar) || function (mod) {
20
20
  if (mod && mod.__esModule) return mod;
21
21
  var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
23
  __setModuleDefault(result, mod);
24
24
  return result;
25
25
  };
@@ -43,7 +43,7 @@ const configUtils = __importStar(require("./configUtils"));
43
43
  // Disabled due to existing high cyclomatic complexity
44
44
  // eslint-disable-next-line complexity
45
45
  function dependencyConfigWindows(folder, userConfig = {}) {
46
- if (os_1.platform() !== 'win32') {
46
+ if ((0, os_1.platform)() !== 'win32') {
47
47
  return null;
48
48
  }
49
49
  if (userConfig === null) {
@@ -129,7 +129,7 @@ function dependencyConfigWindows(folder, userConfig = {}) {
129
129
  for (const project of result.projects) {
130
130
  // Verifying (req) items
131
131
  let errorFound = false;
132
- alwaysRequired.forEach(item => {
132
+ alwaysRequired.forEach((item) => {
133
133
  if (!(item in project)) {
134
134
  project[item] = `Error: ${item} is required for each project in react-native.config`;
135
135
  errorFound = true;
@@ -170,7 +170,9 @@ function dependencyConfigWindows(folder, userConfig = {}) {
170
170
  const projectFile = path_1.default.join(sourceDir, foundProject);
171
171
  const projectContents = configUtils.readProjectFile(projectFile);
172
172
  const projectType = configUtils.getProjectType(projectFile, projectContents);
173
- if (projectType === 'dynamiclibrary' || projectType === 'winmdobj') {
173
+ if (projectType === 'dynamiclibrary' ||
174
+ projectType === 'winmdobj' ||
175
+ projectType === 'library') {
174
176
  const projectLang = configUtils.getProjectLanguage(projectFile);
175
177
  const projectName = configUtils.getProjectName(projectFile, projectContents);
176
178
  const projectGuid = configUtils.getProjectGuid(projectContents);
@@ -1 +1 @@
1
- {"version":3,"file":"dependencyConfig.js","sourceRoot":"","sources":["../../src/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,aAAQ,EAAE,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,CA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D,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;oBAEzD,UAAU,CAAC,IAAI,CAAC,SAAS,WAAW,IAAI,CAAC,CAAC;oBAC1C,mBAAmB,CAAC,IAAI,CAAC,GAAG,YAAY,wBAAwB,CAAC,CAAC;oBAClE,YAAY,CAAC,IAAI,CAAC,GAAG,WAAW,EAAE,CAAC,CAAC;oBACpC,kBAAkB,CAAC,IAAI,CAAC,GAAG,WAAW,uBAAuB,CAAC,CAAC;iBAChE;gBAED,MAAM,CAAC,QAAQ,CAAC,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;AAhOD,0DAgOC","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 = configUtils.getProjectNamespace(\n projectContents,\n );\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 (projectType === 'dynamiclibrary' || projectType === 'winmdobj') {\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 = configUtils.getProjectNamespace(\n projectContents,\n );\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"]}
1
+ {"version":3,"file":"dependencyConfig.js","sourceRoot":"","sources":["../../src/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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,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"]}
@@ -19,7 +19,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
19
19
  var __importStar = (this && this.__importStar) || function (mod) {
20
20
  if (mod && mod.__esModule) return mod;
21
21
  var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
23
  __setModuleDefault(result, mod);
24
24
  return result;
25
25
  };
@@ -45,7 +45,7 @@ const configUtils = __importStar(require("./configUtils"));
45
45
  // eslint-disable-next-line complexity
46
46
  function projectConfigWindows(folder, userConfig = {}) {
47
47
  var _a;
48
- if (os_1.platform() !== 'win32') {
48
+ if ((0, os_1.platform)() !== 'win32') {
49
49
  return null;
50
50
  }
51
51
  if (userConfig === null) {
@@ -1 +1 @@
1
- {"version":3,"file":"projectConfig.js","sourceRoot":"","sources":["../../src/config/projectConfig.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6EAA6E;AAC7E,6EAA6E;AAC7E,0BAA0B;AAC1B,gEAAgE;AAEhE,2BAA4B;AAC5B,gDAAwB;AAExB,2DAA6C;AAiE7C;;;;;GAKG;AACH,sDAAsD;AACtD,sCAAsC;AACtC,SAAgB,oBAAoB,CAClC,MAAc,EACd,aAAmD,EAAE;;IAErD,IAAI,aAAQ,EAAE,KAAK,OAAO,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;IAED,IAAI,UAAU,KAAK,IAAI,EAAE;QACvB,OAAO,IAAI,CAAC;KACb;IAED,MAAM,mBAAmB,GAAG,WAAW,IAAI,UAAU,CAAC;IAEtD,MAAM,SAAS,GAAG,mBAAmB;QACnC,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,SAAU,CAAC;QAC1C,CAAC,CAAC,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IA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C,CAAC;AAxJD,oDAwJC","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 app projects that have a\nwindows implementation, as a target for auto-linking. This is done heuristically,\nso if the result isn't quite correct, app developers can provide a manual override\nfile: react-native.config.js.\n\nSchema for app projects:\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 app root folder, determined by react-native config, ex: 'c:\\path\\to\\my-app'\n sourceDir: string, // (req) Relative path to the Windows implementation under folder, ex: 'windows'\n solutionFile: string, // (req) Relative path to the app's VS solution file under sourceDir, ex: 'MyApp.sln'\n useWinUI3: boolean // (opt) If true, use WinUI 3. If false, use Windows XAML and WinUI 2.x. If missing, the value from rnwRoot\\PropertySheets\\ExperimentalFeatures.props will be used.\n project: { // (req)\n projectFile: string, // (req) Relative path to the VS project file under sourceDir, ex: 'MyApp\\MyApp.vcxproj' for 'c:\\path\\to\\my-app\\windows\\MyApp\\MyApp.vcxproj'\n projectName: string, // (auto) Name of the project, determined from projectFile, ex: 'MyApp'\n projectLang: string, // (auto) Language of the project, cpp or cs, determined from projectFile\n projectGuid: string, // (auto) Project identifier, determined from projectFile\n },\n experimentalFeatures: Record<String, string> // (auto) Properties extracted from ExperimentalFeatures.props\n}\n\nExample react-native.config.js for a 'MyApp':\n\nmodule.exports = {\n project: {\n windows: {\n sourceDir: 'windows',\n solutionFile: 'MyApp.sln',\n project: {\n projectFile: 'MyApp\\\\MyApp.vcxproj',\n },\n },\n },\n};\n\n*/\n\nexport interface Project {\n projectFile: string;\n projectName: string;\n projectLang: 'cpp' | 'cs' | null;\n projectGuid: string | null;\n projectTypeGuid?: string;\n}\n\nexport interface WindowsProjectConfig {\n folder: string;\n sourceDir: string;\n solutionFile: string;\n project: Project;\n useWinUI3?: boolean;\n experimentalFeatures?: Record<string, string>;\n}\n\ntype DeepPartial<T> = {[P in keyof T]?: DeepPartial<T[P]>};\n\n/**\n * Gets the config of any RNW apps under the target folder.\n * @param folder The absolute path to the target folder.\n * @param userConfig A manually specified override config.\n * @return The config if any RNW apps exist.\n */\n// Disabled due to existing high cyclomatic complexity\n// eslint-disable-next-line complexity\nexport function projectConfigWindows(\n folder: string,\n userConfig: Partial<WindowsProjectConfig> | null = {},\n): WindowsProjectConfig | null {\n if (platform() !== 'win32') {\n return null;\n }\n\n if (userConfig === null) {\n return null;\n }\n\n const usingManualOverride = 'sourceDir' in userConfig;\n\n const sourceDir = usingManualOverride\n ? path.join(folder, userConfig.sourceDir!)\n : configUtils.findWindowsFolder(folder);\n\n if (sourceDir === null) {\n // Nothing to look for here, bail\n return null;\n }\n\n const result: DeepPartial<WindowsProjectConfig> = {\n folder: folder,\n sourceDir: path.relative(folder, sourceDir),\n };\n\n let validSolution = false;\n let validProject = false;\n\n if (usingManualOverride) {\n // Manual override, try to use it for solutionFile\n if (!('solutionFile' in userConfig)) {\n result.solutionFile =\n 'Error: Solution file is required but not specified in react-native.config.';\n } else if (userConfig.solutionFile === null) {\n result.solutionFile =\n 'Error: Solution file is null in react-native.config.';\n } else {\n result.solutionFile = path.normalize(userConfig.solutionFile!);\n validSolution = true;\n }\n\n // Manual override, try to use it for project\n if (!('project' in userConfig)) {\n result.project = {\n projectFile:\n 'Error: Project is required but not specified in react-native.config.',\n };\n } else if (!userConfig.project) {\n result.project = {\n projectFile: 'Error: Project is null in react-native.config.',\n };\n } else {\n if (!('projectFile' in userConfig.project)) {\n result.project = {\n projectFile:\n 'Error: Project file is required for project in react-native.config.',\n };\n } else if (userConfig.project.projectFile === null) {\n result.project = {\n projectFile: 'Error: Project file is null in react-native.config.',\n };\n } else {\n result.project = {\n projectFile: path.normalize(userConfig.project.projectFile),\n };\n validProject = true;\n }\n }\n\n if ('useWinUI3' in userConfig) {\n result.useWinUI3 = userConfig.useWinUI3;\n }\n } else {\n // No manually provided solutionFile, try to find it\n const foundSolutions = configUtils.findSolutionFiles(sourceDir);\n if (foundSolutions.length === 0) {\n result.solutionFile =\n 'Error: No app solution file found, please specify in react-native.config.';\n } else if (foundSolutions.length > 1) {\n result.solutionFile =\n 'Error: Too many app solution files found, please specify in react-native.config.';\n } else {\n result.solutionFile = path.normalize(foundSolutions[0]);\n validSolution = true;\n }\n\n // No manually provided project, try to find it\n const foundProjects = configUtils.findAppProjectFiles(sourceDir);\n if (foundProjects.length === 0) {\n result.project = {\n projectFile:\n 'Error: No app project file found, please specify in react-native.config.',\n };\n } else if (foundProjects.length > 1) {\n result.project = {\n projectFile:\n 'Error: Too many app project files found, please specify in react-native.config.',\n };\n } else {\n result.project = {\n projectFile: path.normalize(foundProjects[0]),\n };\n validProject = true;\n }\n }\n\n if (validSolution) {\n result.solutionFile = path.relative(\n sourceDir,\n path.join(sourceDir, result.solutionFile),\n );\n\n // Populating experimental features from ExperimentalFeatures.props\n const experimentalFeatures = configUtils.getExperimentalFeatures(\n path.dirname(path.join(sourceDir, result.solutionFile)),\n );\n if (experimentalFeatures) {\n result.experimentalFeatures = experimentalFeatures;\n }\n }\n\n if (validProject) {\n const projectFile = path.join(sourceDir, result.project.projectFile!);\n const projectContents = configUtils.readProjectFile(projectFile);\n\n result.project.projectFile = path.relative(sourceDir, projectFile);\n\n // Add missing (auto) items\n result.project.projectName = configUtils.getProjectName(\n projectFile,\n projectContents,\n );\n result.project.projectLang = configUtils.getProjectLanguage(projectFile);\n result.project.projectGuid = configUtils.getProjectGuid(projectContents);\n\n // Since we moved the UseExperimentalNuget property from the project to the\n // ExperimentalFeatures.props file, we should should double-check the project file\n // in case it was made with an older template\n const useExperimentalNuget = configUtils.tryFindPropertyValue(\n projectContents,\n 'UseExperimentalNuget',\n );\n if (useExperimentalNuget) {\n result.experimentalFeatures = result.experimentalFeatures ?? {};\n result.experimentalFeatures.UseExperimentalNuget = useExperimentalNuget;\n }\n }\n\n return result as WindowsProjectConfig;\n}\n"]}
1
+ {"version":3,"file":"projectConfig.js","sourceRoot":"","sources":["../../src/config/projectConfig.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6EAA6E;AAC7E,6EAA6E;AAC7E,0BAA0B;AAC1B,gEAAgE;AAEhE,2BAA4B;AAC5B,gDAAwB;AAExB,2DAA6C;AAiE7C;;;;;GAKG;AACH,sDAAsD;AACtD,sCAAsC;AACtC,SAAgB,oBAAoB,CAClC,MAAc,EACd,aAAmD,EAAE;;IAErD,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,mBAAmB,GAAG,WAAW,IAAI,UAAU,CAAC;IAEtD,MAAM,SAAS,GAAG,mBAAmB;QACnC,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,SAAU,CAAC;QAC1C,CAAC,CAAC,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAE1C,IAAI,SAAS,KAAK,IAAI,EAAE;QACtB,iCAAiC;QACjC,OAAO,IAAI,CAAC;KACb;IAED,MAAM,MAAM,GAAsC;QAChD,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,cAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;KAC5C,CAAC;IAEF,IAAI,aAAa,GAAG,KAAK,CAAC;IAC1B,IAAI,YAAY,GAAG,KAAK,CAAC;IAEzB,IAAI,mBAAmB,EAAE;QACvB,kDAAkD;QAClD,IAAI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AED,IAAI,YAAY,EAAE;QAChB,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,WAAY,CAAC,CAAC;QACtE,MAAM,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;QAEjE,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,cAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAEnE,2BAA2B;QAC3B,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC,cAAc,CACrD,WAAW,EACX,eAAe,CAChB,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QACzE,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;QAEzE,2EAA2E;QAC3E,kFAAkF;QAClF,6CAA6C;QAC7C,MAAM,oBAAoB,GAAG,WAAW,CAAC,oBAAoB,CAC3D,eAAe,EACf,sBAAsB,CACvB,CAAC;QACF,IAAI,oBAAoB,EAAE;YACxB,MAAM,CAAC,oBAAoB,GAAG,MAAA,MAAM,CAAC,oBAAoB,mCAAI,EAAE,CAAC;YAChE,MAAM,CAAC,oBAAoB,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;SACzE;KACF;IAED,OAAO,MAA8B,CAAC;AACxC,CAAC;AAxJD,oDAwJC","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 app projects that have a\nwindows implementation, as a target for auto-linking. This is done heuristically,\nso if the result isn't quite correct, app developers can provide a manual override\nfile: react-native.config.js.\n\nSchema for app projects:\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 app root folder, determined by react-native config, ex: 'c:\\path\\to\\my-app'\n sourceDir: string, // (req) Relative path to the Windows implementation under folder, ex: 'windows'\n solutionFile: string, // (req) Relative path to the app's VS solution file under sourceDir, ex: 'MyApp.sln'\n useWinUI3: boolean // (opt) If true, use WinUI 3. If false, use Windows XAML and WinUI 2.x. If missing, the value from rnwRoot\\PropertySheets\\ExperimentalFeatures.props will be used.\n project: { // (req)\n projectFile: string, // (req) Relative path to the VS project file under sourceDir, ex: 'MyApp\\MyApp.vcxproj' for 'c:\\path\\to\\my-app\\windows\\MyApp\\MyApp.vcxproj'\n projectName: string, // (auto) Name of the project, determined from projectFile, ex: 'MyApp'\n projectLang: string, // (auto) Language of the project, cpp or cs, determined from projectFile\n projectGuid: string, // (auto) Project identifier, determined from projectFile\n },\n experimentalFeatures: Record<String, string> // (auto) Properties extracted from ExperimentalFeatures.props\n}\n\nExample react-native.config.js for a 'MyApp':\n\nmodule.exports = {\n project: {\n windows: {\n sourceDir: 'windows',\n solutionFile: 'MyApp.sln',\n project: {\n projectFile: 'MyApp\\\\MyApp.vcxproj',\n },\n },\n },\n};\n\n*/\n\nexport interface Project {\n projectFile: string;\n projectName: string;\n projectLang: 'cpp' | 'cs' | null;\n projectGuid: string | null;\n projectTypeGuid?: string;\n}\n\nexport interface WindowsProjectConfig {\n folder: string;\n sourceDir: string;\n solutionFile: string;\n project: Project;\n useWinUI3?: boolean;\n experimentalFeatures?: Record<string, string>;\n}\n\ntype DeepPartial<T> = {[P in keyof T]?: DeepPartial<T[P]>};\n\n/**\n * Gets the config of any RNW apps under the target folder.\n * @param folder The absolute path to the target folder.\n * @param userConfig A manually specified override config.\n * @return The config if any RNW apps exist.\n */\n// Disabled due to existing high cyclomatic complexity\n// eslint-disable-next-line complexity\nexport function projectConfigWindows(\n folder: string,\n userConfig: Partial<WindowsProjectConfig> | null = {},\n): WindowsProjectConfig | null {\n if (platform() !== 'win32') {\n return null;\n }\n\n if (userConfig === null) {\n return null;\n }\n\n const usingManualOverride = 'sourceDir' in userConfig;\n\n const sourceDir = usingManualOverride\n ? path.join(folder, userConfig.sourceDir!)\n : configUtils.findWindowsFolder(folder);\n\n if (sourceDir === null) {\n // Nothing to look for here, bail\n return null;\n }\n\n const result: DeepPartial<WindowsProjectConfig> = {\n folder: folder,\n sourceDir: path.relative(folder, sourceDir),\n };\n\n let validSolution = false;\n let validProject = false;\n\n if (usingManualOverride) {\n // Manual override, try to use it for solutionFile\n if (!('solutionFile' in userConfig)) {\n result.solutionFile =\n 'Error: Solution file is required but not specified in react-native.config.';\n } else if (userConfig.solutionFile === null) {\n result.solutionFile =\n 'Error: Solution file is null in react-native.config.';\n } else {\n result.solutionFile = path.normalize(userConfig.solutionFile!);\n validSolution = true;\n }\n\n // Manual override, try to use it for project\n if (!('project' in userConfig)) {\n result.project = {\n projectFile:\n 'Error: Project is required but not specified in react-native.config.',\n };\n } else if (!userConfig.project) {\n result.project = {\n projectFile: 'Error: Project is null in react-native.config.',\n };\n } else {\n if (!('projectFile' in userConfig.project)) {\n result.project = {\n projectFile:\n 'Error: Project file is required for project in react-native.config.',\n };\n } else if (userConfig.project.projectFile === null) {\n result.project = {\n projectFile: 'Error: Project file is null in react-native.config.',\n };\n } else {\n result.project = {\n projectFile: path.normalize(userConfig.project.projectFile),\n };\n validProject = true;\n }\n }\n\n if ('useWinUI3' in userConfig) {\n result.useWinUI3 = userConfig.useWinUI3;\n }\n } else {\n // No manually provided solutionFile, try to find it\n const foundSolutions = configUtils.findSolutionFiles(sourceDir);\n if (foundSolutions.length === 0) {\n result.solutionFile =\n 'Error: No app solution file found, please specify in react-native.config.';\n } else if (foundSolutions.length > 1) {\n result.solutionFile =\n 'Error: Too many app solution files found, please specify in react-native.config.';\n } else {\n result.solutionFile = path.normalize(foundSolutions[0]);\n validSolution = true;\n }\n\n // No manually provided project, try to find it\n const foundProjects = configUtils.findAppProjectFiles(sourceDir);\n if (foundProjects.length === 0) {\n result.project = {\n projectFile:\n 'Error: No app project file found, please specify in react-native.config.',\n };\n } else if (foundProjects.length > 1) {\n result.project = {\n projectFile:\n 'Error: Too many app project files found, please specify in react-native.config.',\n };\n } else {\n result.project = {\n projectFile: path.normalize(foundProjects[0]),\n };\n validProject = true;\n }\n }\n\n if (validSolution) {\n result.solutionFile = path.relative(\n sourceDir,\n path.join(sourceDir, result.solutionFile),\n );\n\n // Populating experimental features from ExperimentalFeatures.props\n const experimentalFeatures = configUtils.getExperimentalFeatures(\n path.dirname(path.join(sourceDir, result.solutionFile)),\n );\n if (experimentalFeatures) {\n result.experimentalFeatures = experimentalFeatures;\n }\n }\n\n if (validProject) {\n const projectFile = path.join(sourceDir, result.project.projectFile!);\n const projectContents = configUtils.readProjectFile(projectFile);\n\n result.project.projectFile = path.relative(sourceDir, projectFile);\n\n // Add missing (auto) items\n result.project.projectName = configUtils.getProjectName(\n projectFile,\n projectContents,\n );\n result.project.projectLang = configUtils.getProjectLanguage(projectFile);\n result.project.projectGuid = configUtils.getProjectGuid(projectContents);\n\n // Since we moved the UseExperimentalNuget property from the project to the\n // ExperimentalFeatures.props file, we should should double-check the project file\n // in case it was made with an older template\n const useExperimentalNuget = configUtils.tryFindPropertyValue(\n projectContents,\n 'UseExperimentalNuget',\n );\n if (useExperimentalNuget) {\n result.experimentalFeatures = result.experimentalFeatures ?? {};\n result.experimentalFeatures.UseExperimentalNuget = useExperimentalNuget;\n }\n }\n\n return result as WindowsProjectConfig;\n}\n"]}
@@ -1 +1,6 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
1
6
  export {};
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
2
7
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
9
  };
5
10
  Object.defineProperty(exports, "__esModule", { value: true });
6
11
  const path_1 = __importDefault(require("path"));
12
+ const telemetry_1 = require("@react-native-windows/telemetry");
7
13
  const projectConfig_1 = require("../config/projectConfig");
8
14
  const autolink_1 = require("../runWindows/utils/autolink");
9
15
  const xmldom_1 = require("@xmldom/xmldom");
@@ -30,10 +36,16 @@ class AutolinkTest extends autolink_1.AutolinkWindows {
30
36
  return this.windowsAppConfig;
31
37
  }
32
38
  getPackagesConfigXml() {
33
- return { path: 'packages.config', content: new xmldom_1.DOMParser().parseFromString(this.packagesConfig, 'application/xml') };
39
+ return {
40
+ path: 'packages.config',
41
+ content: new xmldom_1.DOMParser().parseFromString(this.packagesConfig, 'application/xml'),
42
+ };
34
43
  }
35
44
  getExperimentalFeaturesPropsXml() {
36
- return { path: 'ExperimentalFeatures.props', content: new xmldom_1.DOMParser().parseFromString(this.experimentalFeaturesProps, 'application/xml') };
45
+ return {
46
+ path: 'ExperimentalFeatures.props',
47
+ content: new xmldom_1.DOMParser().parseFromString(this.experimentalFeaturesProps, 'application/xml'),
48
+ };
37
49
  }
38
50
  async updateFile(filepath, content) {
39
51
  if (filepath === 'packages.config') {
@@ -69,7 +81,7 @@ test('autolink fixup proj', async (done) => {
69
81
  expect(autolink.getWindowsProjectConfig().solutionFile).toEqual('foo.sln');
70
82
  expect(autolink.getWindowsProjectConfig().project).toBeUndefined();
71
83
  const folder = path_1.default.resolve('src/e2etest/projects/', 'WithWinUI3');
72
- await projectConfig_utils_1.ensureWinUI3Project(folder);
84
+ await (0, projectConfig_utils_1.ensureWinUI3Project)(folder);
73
85
  expect(() => {
74
86
  autolink.validateRequiredProjectProperties();
75
87
  }).toThrow();
@@ -199,7 +211,7 @@ test('one valid cs autolink dependency', () => {
199
211
  test('ensureXAMLDialect - useWinUI3=true in react-native.config.js, useWinUI3=false in ExperimentalFeatures.props', async (done) => {
200
212
  const folder = path_1.default.resolve('src/e2etest/projects/WithWinUI3');
201
213
  const rnc = require(path_1.default.join(folder, 'react-native.config.js'));
202
- const config = projectConfig_1.projectConfigWindows(folder, rnc.project.windows);
214
+ const config = (0, projectConfig_1.projectConfigWindows)(folder, rnc.project.windows);
203
215
  const al = new AutolinkTest({ windows: config }, {}, {
204
216
  check: false,
205
217
  logging: false,
@@ -210,7 +222,7 @@ test('ensureXAMLDialect - useWinUI3=true in react-native.config.js, useWinUI3=fa
210
222
  expect(exd).toBeTruthy();
211
223
  const expectedExperimentalFeatures = '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>true</UseWinUI3></PropertyGroup></Project>';
212
224
  expect(al.experimentalFeaturesProps).toEqual(expectedExperimentalFeatures);
213
- // example packages.config:
225
+ // example packages.config:
214
226
  // <packages>
215
227
  // <package id="SuperPkg" version="42"/>
216
228
  // <package id="Microsoft.WinUI" version="3.0.0-preview3.201113.0" targetFramework="native"/>
@@ -224,7 +236,7 @@ test('ensureXAMLDialect - useWinUI3=true in react-native.config.js, useWinUI3=fa
224
236
  test('ensureXAMLDialect - useWinUI3=false in react-native.config.js, useWinUI3=true in ExperimentalFeatures.props', async (done) => {
225
237
  const folder = path_1.default.resolve('src/e2etest/projects/WithWinUI3');
226
238
  const rnc = require(path_1.default.join(folder, 'react-native.config.js'));
227
- const config = projectConfig_1.projectConfigWindows(folder, rnc.project.windows);
239
+ const config = (0, projectConfig_1.projectConfigWindows)(folder, rnc.project.windows);
228
240
  config.useWinUI3 = false;
229
241
  const al = new AutolinkTest({ windows: config }, {}, {
230
242
  check: false,
@@ -236,7 +248,7 @@ test('ensureXAMLDialect - useWinUI3=false in react-native.config.js, useWinUI3=t
236
248
  expect(exd).toBeTruthy();
237
249
  const expectedExperimentalFeatures = '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>false</UseWinUI3></PropertyGroup></Project>';
238
250
  expect(al.experimentalFeaturesProps).toEqual(expectedExperimentalFeatures);
239
- // example packages.config:
251
+ // example packages.config:
240
252
  // <packages>
241
253
  // <package id="SuperPkg" version="42"/>
242
254
  // <package id="Microsoft.WinUI" version="3.0.0-preview3.201113.0" targetFramework="native"/>
@@ -250,7 +262,7 @@ test('ensureXAMLDialect - useWinUI3=false in react-native.config.js, useWinUI3=t
250
262
  test('ensureXAMLDialect - useWinUI3 not in react-native.config.js, useWinUI3=true in ExperimentalFeatures.props', async (done) => {
251
263
  const folder = path_1.default.resolve('src/e2etest/projects/WithWinUI3');
252
264
  const rnc = require(path_1.default.join(folder, 'react-native.config.js'));
253
- const config = projectConfig_1.projectConfigWindows(folder, rnc.project.windows);
265
+ const config = (0, projectConfig_1.projectConfigWindows)(folder, rnc.project.windows);
254
266
  delete config.useWinUI3;
255
267
  const al = new AutolinkTest({ windows: config }, {}, {
256
268
  check: false,
@@ -262,7 +274,7 @@ test('ensureXAMLDialect - useWinUI3 not in react-native.config.js, useWinUI3=tru
262
274
  expect(exd).toBeTruthy();
263
275
  const expectedExperimentalFeatures = '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>true</UseWinUI3></PropertyGroup></Project>';
264
276
  expect(al.experimentalFeaturesProps).toEqual(expectedExperimentalFeatures);
265
- // example packages.config:
277
+ // example packages.config:
266
278
  // <packages>
267
279
  // <package id="SuperPkg" version="42"/>
268
280
  // <package id="Microsoft.WinUI" version="3.0.0-preview3.201113.0" targetFramework="native"/>
@@ -276,7 +288,7 @@ test('ensureXAMLDialect - useWinUI3 not in react-native.config.js, useWinUI3=tru
276
288
  test('ensureXAMLDialect - useWinUI3 not in react-native.config.js, useWinUI3=false in ExperimentalFeatures.props', async (done) => {
277
289
  const folder = path_1.default.resolve('src/e2etest/projects/WithWinUI3');
278
290
  const rnc = require(path_1.default.join(folder, 'react-native.config.js'));
279
- const config = projectConfig_1.projectConfigWindows(folder, rnc.project.windows);
291
+ const config = (0, projectConfig_1.projectConfigWindows)(folder, rnc.project.windows);
280
292
  delete config.useWinUI3;
281
293
  const al = new AutolinkTest({ windows: config }, {}, {
282
294
  check: false,
@@ -288,7 +300,7 @@ test('ensureXAMLDialect - useWinUI3 not in react-native.config.js, useWinUI3=fal
288
300
  expect(exd).toBeTruthy();
289
301
  const expectedExperimentalFeatures = '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>false</UseWinUI3></PropertyGroup></Project>';
290
302
  expect(al.experimentalFeaturesProps).toEqual(expectedExperimentalFeatures);
291
- // example packages.config:
303
+ // example packages.config:
292
304
  // <packages>
293
305
  // <package id="SuperPkg" version="42"/>
294
306
  // <package id="Microsoft.WinUI" version="3.0.0-preview4.210210.4" targetFramework="native"/>
@@ -299,6 +311,59 @@ test('ensureXAMLDialect - useWinUI3 not in react-native.config.js, useWinUI3=fal
299
311
  expect(al.packagesConfig).toContain('Microsoft.UI.Xaml');
300
312
  done();
301
313
  });
314
+ test('ensureXAMLDialect - WinUI2xVersion specified in ExperimentalFeatures.props', async (done) => {
315
+ const folder = path_1.default.resolve('src/e2etest/projects/WithWinUI3');
316
+ const rnc = require(path_1.default.join(folder, 'react-native.config.js'));
317
+ const config = (0, projectConfig_1.projectConfigWindows)(folder, rnc.project.windows);
318
+ delete config.useWinUI3;
319
+ const al = new AutolinkTest({ windows: config }, {}, {
320
+ check: false,
321
+ logging: false,
322
+ });
323
+ al.experimentalFeaturesProps = `<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>false</UseWinUI3><WinUI2xVersion>2.7.0-test</WinUI2xVersion></PropertyGroup></Project>`;
324
+ al.packagesConfig = `<packages><package id="SuperPkg" version="42"/></packages>`;
325
+ const exd = await al.ensureXAMLDialect();
326
+ expect(exd).toBeTruthy();
327
+ const expectedExperimentalFeatures = '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>false</UseWinUI3><WinUI2xVersion>2.7.0-test</WinUI2xVersion></PropertyGroup></Project>';
328
+ expect(al.experimentalFeaturesProps).toEqual(expectedExperimentalFeatures);
329
+ // example packages.config:
330
+ // <packages>
331
+ // <package id="SuperPkg" version="42"/>
332
+ // <package id="Microsoft.UI.XAML" version="2.7.0-test" targetFramework="native"/>
333
+ // </packages>
334
+ //
335
+ expect(al.packagesConfig).toContain('Microsoft.UI.Xaml');
336
+ expect(al.packagesConfig).toContain('2.7.0-test');
337
+ expect(al.packagesConfig).toContain('<package id="SuperPkg" version="42"/>');
338
+ expect(al.packagesConfig).not.toContain('Microsoft.WinUI');
339
+ done();
340
+ });
341
+ test('ensureXAMLDialect - WinUI3Version specified in ExperimentalFeatures.props', async (done) => {
342
+ const folder = path_1.default.resolve('src/e2etest/projects/WithWinUI3');
343
+ const rnc = require(path_1.default.join(folder, 'react-native.config.js'));
344
+ const config = (0, projectConfig_1.projectConfigWindows)(folder, rnc.project.windows);
345
+ const al = new AutolinkTest({ windows: config }, {}, {
346
+ check: false,
347
+ logging: false,
348
+ });
349
+ al.experimentalFeaturesProps = `<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>true</UseWinUI3><WinUI3Version>3.0.0-test</WinUI3Version></PropertyGroup></Project>`;
350
+ al.packagesConfig = `<packages><package id="SuperPkg" version="42"/></packages>`;
351
+ const exd = await al.ensureXAMLDialect();
352
+ expect(exd).toBeTruthy();
353
+ const expectedExperimentalFeatures = '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"><PropertyGroup><UseWinUI3>true</UseWinUI3><WinUI3Version>3.0.0-test</WinUI3Version></PropertyGroup></Project>';
354
+ expect(al.experimentalFeaturesProps).toEqual(expectedExperimentalFeatures);
355
+ // example packages.config:
356
+ // <packages>
357
+ // <package id="SuperPkg" version="42"/>
358
+ // <package id="Microsoft.WinUI" version="3.0.0-test" targetFramework="native"/>
359
+ // </packages>
360
+ //
361
+ expect(al.packagesConfig).toContain('Microsoft.WinUI');
362
+ expect(al.packagesConfig).toContain('3.0.0-test');
363
+ expect(al.packagesConfig).toContain('<package id="SuperPkg" version="42"/>');
364
+ expect(al.packagesConfig).not.toContain('Microsoft.UI.Xaml');
365
+ done();
366
+ });
302
367
  test('Indirect autolink dependency', () => {
303
368
  const autolink = new AutolinkTest({ windows: { folder: __dirname, sourceDir: '.', solutionFile: 'foo.sln' } }, {
304
369
  superModule: {
@@ -317,7 +382,7 @@ test('Indirect autolink dependency', () => {
317
382
  {
318
383
  directDependency: false,
319
384
  projectFile: 'indirect.vcxproj',
320
- }
385
+ },
321
386
  ],
322
387
  },
323
388
  },
@@ -335,4 +400,36 @@ test('Indirect autolink dependency', () => {
335
400
  expect(replacements.cppIncludes).toMatch(/#include <Snoopy.h>/);
336
401
  expect(replacements.cppPackageProviders).toContain('packageProviders.Append(winrt::FamousAnimalCartoons())');
337
402
  });
403
+ function validateOptionName(name, optionName) {
404
+ // Do not add a default case here. Every item must explicitly return true
405
+ switch (optionName) {
406
+ case 'check':
407
+ case 'logging':
408
+ case 'sln':
409
+ case 'proj':
410
+ case 'telemetry':
411
+ return true;
412
+ }
413
+ throw new Error(`Unable to find ${optionName} to match '${name}' in AutoLinkOptions.`);
414
+ }
415
+ test('autolinkOptions - validate options', () => {
416
+ for (const commandOption of autolink_1.autolinkOptions) {
417
+ // Validate names
418
+ expect(commandOption.name).not.toBeNull();
419
+ expect(commandOption.name.startsWith('--')).toBe(true);
420
+ expect(commandOption.name).toBe(commandOption.name.trim());
421
+ // Validate defaults
422
+ if (!commandOption.name.endsWith(' [string]') &&
423
+ !commandOption.name.endsWith(' [number]')) {
424
+ // Commander ignores defaults for flags, so leave undefined to prevent confusion
425
+ expect(commandOption.default).toBeUndefined();
426
+ }
427
+ // Validate description
428
+ expect(commandOption.description).not.toBeNull();
429
+ expect(commandOption.description).toBe(commandOption.description.trim());
430
+ // Validate all command options are present in AutoLinkOptions
431
+ const optionName = (0, telemetry_1.commanderNameToOptionName)(commandOption.name);
432
+ expect(validateOptionName(commandOption.name, optionName)).toBe(true);
433
+ }
434
+ });
338
435
  //# sourceMappingURL=autolink.test.js.map