@react-native-windows/cli 0.82.0-preview.2 → 0.82.0

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.
@@ -117,15 +117,7 @@ function getRawTemplateInfo(filePath) {
117
117
  }
118
118
  }
119
119
  else if (result.projectLang === 'cpp') {
120
- if (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppApp.targets')) {
121
- result.projectType = 'app';
122
- result.projectArch = 'old';
123
- }
124
- else if (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppLib.targets')) {
125
- result.projectType = 'lib';
126
- result.projectArch = 'old';
127
- }
128
- else if (importProjectExists(projectContents, 'Microsoft.ReactNative.Composition.CppApp.targets')) {
120
+ if (importProjectExists(projectContents, 'Microsoft.ReactNative.Composition.CppApp.targets')) {
129
121
  result.projectType = 'app';
130
122
  result.projectArch = 'new';
131
123
  }
@@ -137,6 +129,14 @@ function getRawTemplateInfo(filePath) {
137
129
  result.projectType = 'lib';
138
130
  result.projectArch = 'mixed';
139
131
  }
132
+ else if (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppApp.targets')) {
133
+ result.projectType = 'app';
134
+ result.projectArch = 'old';
135
+ }
136
+ else if (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppLib.targets')) {
137
+ result.projectType = 'lib';
138
+ result.projectArch = 'old';
139
+ }
140
140
  }
141
141
  return result;
142
142
  }
@@ -1 +1 @@
1
- {"version":3,"file":"configUtils.js","sourceRoot":"","sources":["../../../src/commands/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,MAA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qCAArB,MAAM,CAAC,cAAc,IAAM,EAAE,EAAC;YAC9B,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,GAAG,GAChC,IAAI,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAC5C,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;SAC3C;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AArCD,oCAqCC","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\nexport interface RawTemplateInfo {\n projectLang: 'cpp' | 'cs' | null;\n projectType: 'app' | 'lib' | null;\n projectArch: 'old' | 'new' | 'mixed' | null;\n}\n\n/**\n * Determines the RawTemplateInfo of the target project file.\n * @param filePath The absolute file path to check.\n * @return The RawTemplateInfo for the specific project.\n */\nexport function getRawTemplateInfo(filePath: string): RawTemplateInfo {\n const result: RawTemplateInfo = {\n projectLang: null,\n projectType: null,\n projectArch: null,\n };\n\n if (!fs.existsSync(filePath)) {\n return result;\n }\n\n result.projectLang = getProjectLanguage(filePath);\n\n const projectContents = readProjectFile(filePath);\n\n if (result.projectLang === 'cs') {\n if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'old';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'old';\n }\n } else if (result.projectLang === 'cpp') {\n if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'old';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'old';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'new';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'new';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'mixed';\n }\n }\n\n return result;\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 rawTemplateInfo = getRawTemplateInfo(filePath);\n return rawTemplateInfo.projectType === 'lib';\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 */\nexport function isRnwAppProject(filePath: string): boolean {\n const rawTemplateInfo = getRawTemplateInfo(filePath);\n return rawTemplateInfo.projectType === 'app';\n}\n\n/**\n * Search for the RNW app project files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findAppProjectFiles(winFolder: string): string[] {\n // First, search for all potential project files\n const allCppProj = findFiles(winFolder, '*.vcxproj');\n const allCsProj = findFiles(winFolder, '*.csproj');\n\n const allProjects = allCppProj.concat(allCsProj);\n\n if (allProjects.length === 0) {\n // If there're no project files, return 0\n return [];\n }\n\n const appProjectFiles = [];\n\n // Try to find any project file that appears to be an app project\n for (const projectFile of allProjects) {\n if (isRnwAppProject(path.join(winFolder, projectFile))) {\n appProjectFiles.push(path.normalize(projectFile));\n }\n }\n\n return appProjectFiles;\n}\n\n/**\n * Returns the programming language of the project file.\n * @param projectPath The project file path to check.\n * @return The language string: cpp, cs, or null if unknown.\n */\nexport function getProjectLanguage(projectPath: string): 'cpp' | 'cs' | null {\n if (projectPath.endsWith('.vcxproj')) {\n return 'cpp';\n } else if (projectPath.endsWith('.csproj')) {\n return 'cs';\n }\n\n return null;\n}\n\n/**\n * Reads in the contents of the target project file.\n * @param projectPath The target project file path.\n * @return The project file contents.\n */\nexport function readProjectFile(projectPath: string) {\n const projectContents = fs.readFileSync(projectPath, 'utf8').toString();\n return new DOMParser().parseFromString(projectContents, 'application/xml');\n}\n\n/**\n * Search for the given property in the project contents and return its value.\n * @param projectContents The XML project contents.\n * @param propertyName The property to look for.\n * @return The value of the tag if it exists.\n */\nexport function tryFindPropertyValue(\n projectContents: Node,\n propertyName: string,\n): string | null {\n const nodes = msbuildSelect(\n `//msbuild:PropertyGroup/msbuild:${propertyName}`,\n projectContents,\n );\n\n if (nodes.length > 0) {\n // Take the last one\n return (nodes[nodes.length - 1] as Node).textContent;\n } else {\n const noNamespaceNodes = xpath.select(\n `//PropertyGroup/${propertyName}`,\n projectContents,\n );\n if (noNamespaceNodes.length > 0) {\n return (noNamespaceNodes[noNamespaceNodes.length - 1] as Node)\n .textContent;\n }\n }\n\n return null;\n}\n\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 tryFindPropertyValueAsBoolean(\n projectContents: Node,\n propertyName: string,\n): boolean | null {\n const rawValue = tryFindPropertyValue(projectContents, propertyName);\n\n switch (rawValue) {\n case 'true':\n return true;\n case 'false':\n return false;\n default:\n return null;\n }\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\nexport function getRnwConfig(\n root: string,\n projectFile: string,\n): Record<string, any> | undefined {\n const pkgPath = path.join(root, 'package.json');\n const pkgJson = fs.existsSync(pkgPath)\n ? require(path.join(root, 'package.json'))\n : {};\n\n const config: Record<string, any> = pkgJson['react-native-windows'] ?? {};\n\n const info = getRawTemplateInfo(projectFile);\n\n // inject raw templateInfo for later command use\n if (info.projectArch) {\n config.projectArch = info.projectArch;\n }\n\n if (info.projectLang) {\n config.projectLang = info.projectLang;\n }\n\n if (info.projectType) {\n config.projectType = info.projectType;\n }\n\n // if init-windows is missing (most existing projects), try to auto-calculate it\n if (!config['init-windows']?.template) {\n if (info.projectArch && info.projectLang && info.projectType) {\n config['init-windows'] ??= {};\n config['init-windows'].template = `${\n info.projectArch === 'old' ? 'old/uwp-' : ''\n }${info.projectLang}-${info.projectType}`;\n }\n }\n\n return config;\n}\n"]}
1
+ {"version":3,"file":"configUtils.js","sourceRoot":"","sources":["../../../src/commands/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;YACjB,aAAa;YACb,eAAe;YACf,uBAAuB;YACvB,gBAAgB;SACjB;KACF,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAbD,8BAaC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,MAAc;IAC9C,MAAM,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,IAAI,Y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ACpC,CAAC,CAAC,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAC1C,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,MAAM,GAAwB,MAAA,OAAO,CAAC,sBAAsB,CAAC,mCAAI,EAAE,CAAC;IAE1E,MAAM,IAAI,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAE7C,gDAAgD;IAChD,IAAI,IAAI,CAAC,WAAW,EAAE;QACpB,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;KACvC;IAED,IAAI,IAAI,CAAC,WAAW,EAAE;QACpB,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;KACvC;IAED,IAAI,IAAI,CAAC,WAAW,EAAE;QACpB,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;KACvC;IAED,gFAAgF;IAChF,IAAI,CAAC,CAAA,MAAA,MAAM,CAAC,cAAc,CAAC,0CAAE,QAAQ,CAAA,EAAE;QACrC,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE;YAC5D,MAAA,MAAM,CAAC,cAAc,qCAArB,MAAM,CAAC,cAAc,IAAM,EAAE,EAAC;YAC9B,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,GAAG,GAChC,IAAI,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAC5C,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;SAC3C;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AArCD,oCAqCC","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\nexport interface RawTemplateInfo {\n projectLang: 'cpp' | 'cs' | null;\n projectType: 'app' | 'lib' | null;\n projectArch: 'old' | 'new' | 'mixed' | null;\n}\n\n/**\n * Determines the RawTemplateInfo of the target project file.\n * @param filePath The absolute file path to check.\n * @return The RawTemplateInfo for the specific project.\n */\nexport function getRawTemplateInfo(filePath: string): RawTemplateInfo {\n const result: RawTemplateInfo = {\n projectLang: null,\n projectType: null,\n projectArch: null,\n };\n\n if (!fs.existsSync(filePath)) {\n return result;\n }\n\n result.projectLang = getProjectLanguage(filePath);\n\n const projectContents = readProjectFile(filePath);\n\n if (result.projectLang === 'cs') {\n if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'old';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'old';\n }\n } else if (result.projectLang === 'cpp') {\n if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'new';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'new';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'mixed';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'old';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'old';\n }\n }\n\n return result;\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 rawTemplateInfo = getRawTemplateInfo(filePath);\n return rawTemplateInfo.projectType === 'lib';\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 */\nexport function isRnwAppProject(filePath: string): boolean {\n const rawTemplateInfo = getRawTemplateInfo(filePath);\n return rawTemplateInfo.projectType === 'app';\n}\n\n/**\n * Search for the RNW app project files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findAppProjectFiles(winFolder: string): string[] {\n // First, search for all potential project files\n const allCppProj = findFiles(winFolder, '*.vcxproj');\n const allCsProj = findFiles(winFolder, '*.csproj');\n\n const allProjects = allCppProj.concat(allCsProj);\n\n if (allProjects.length === 0) {\n // If there're no project files, return 0\n return [];\n }\n\n const appProjectFiles = [];\n\n // Try to find any project file that appears to be an app project\n for (const projectFile of allProjects) {\n if (isRnwAppProject(path.join(winFolder, projectFile))) {\n appProjectFiles.push(path.normalize(projectFile));\n }\n }\n\n return appProjectFiles;\n}\n\n/**\n * Returns the programming language of the project file.\n * @param projectPath The project file path to check.\n * @return The language string: cpp, cs, or null if unknown.\n */\nexport function getProjectLanguage(projectPath: string): 'cpp' | 'cs' | null {\n if (projectPath.endsWith('.vcxproj')) {\n return 'cpp';\n } else if (projectPath.endsWith('.csproj')) {\n return 'cs';\n }\n\n return null;\n}\n\n/**\n * Reads in the contents of the target project file.\n * @param projectPath The target project file path.\n * @return The project file contents.\n */\nexport function readProjectFile(projectPath: string) {\n const projectContents = fs.readFileSync(projectPath, 'utf8').toString();\n return new DOMParser().parseFromString(projectContents, 'application/xml');\n}\n\n/**\n * Search for the given property in the project contents and return its value.\n * @param projectContents The XML project contents.\n * @param propertyName The property to look for.\n * @return The value of the tag if it exists.\n */\nexport function tryFindPropertyValue(\n projectContents: Node,\n propertyName: string,\n): string | null {\n const nodes = msbuildSelect(\n `//msbuild:PropertyGroup/msbuild:${propertyName}`,\n projectContents,\n );\n\n if (nodes.length > 0) {\n // Take the last one\n return (nodes[nodes.length - 1] as Node).textContent;\n } else {\n const noNamespaceNodes = xpath.select(\n `//PropertyGroup/${propertyName}`,\n projectContents,\n );\n if (noNamespaceNodes.length > 0) {\n return (noNamespaceNodes[noNamespaceNodes.length - 1] as Node)\n .textContent;\n }\n }\n\n return null;\n}\n\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 tryFindPropertyValueAsBoolean(\n projectContents: Node,\n propertyName: string,\n): boolean | null {\n const rawValue = tryFindPropertyValue(projectContents, propertyName);\n\n switch (rawValue) {\n case 'true':\n return true;\n case 'false':\n return false;\n default:\n return null;\n }\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\nexport function getRnwConfig(\n root: string,\n projectFile: string,\n): Record<string, any> | undefined {\n const pkgPath = path.join(root, 'package.json');\n const pkgJson = fs.existsSync(pkgPath)\n ? require(path.join(root, 'package.json'))\n : {};\n\n const config: Record<string, any> = pkgJson['react-native-windows'] ?? {};\n\n const info = getRawTemplateInfo(projectFile);\n\n // inject raw templateInfo for later command use\n if (info.projectArch) {\n config.projectArch = info.projectArch;\n }\n\n if (info.projectLang) {\n config.projectLang = info.projectLang;\n }\n\n if (info.projectType) {\n config.projectType = info.projectType;\n }\n\n // if init-windows is missing (most existing projects), try to auto-calculate it\n if (!config['init-windows']?.template) {\n if (info.projectArch && info.projectLang && info.projectType) {\n config['init-windows'] ??= {};\n config['init-windows'].template = `${\n info.projectArch === 'old' ? 'old/uwp-' : ''\n }${info.projectLang}-${info.projectType}`;\n }\n }\n\n return config;\n}\n"]}
@@ -123,6 +123,12 @@ class InitWindows {
123
123
  (_a = (_l = this.options).template) !== null && _a !== void 0 ? _a : (_l.template = (_d = (_c = (_b = this.rnwConfig) === null || _b === void 0 ? void 0 : _b['init-windows']) === null || _c === void 0 ? void 0 : _c.template) !== null && _d !== void 0 ? _d : this.getDefaultTemplateName());
124
124
  spinner.info(`Using template '${this.options.template}'...`);
125
125
  if (!this.templates.has(this.options.template.replace(/[\\]/g, '/'))) {
126
+ // Check if user is trying to use an old architecture template
127
+ const isOldArchTemplate = this.options.template.startsWith('old');
128
+ if (isOldArchTemplate) {
129
+ (0, oldArchWarning_1.showOldArchitectureWarning)();
130
+ throw new telemetry_1.CodedError('InvalidTemplateName', `The template '${this.options.template}' is no longer available. Please use 'cpp-app' template instead.`);
131
+ }
126
132
  throw new telemetry_1.CodedError('InvalidTemplateName', `Unable to find template '${this.options.template}'.`);
127
133
  }
128
134
  const isOldArchTemplate = this.options.template.startsWith('old');
@@ -1 +1 @@
1
- {"version":3,"file":"initWindows.js","sourceRoot":"","sources":["../../../src/commands/initWindows/initWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,kDAA0B;AAC1B,+BAAsC;AAEtC,2CAAuC;AAEvC,gDAAwB;AAExB,MAAM,IAAI,GAAG,cAAI,CAAC,SAAS,CAAC,WAAQ,CAAC,CAAC;AAGtC,+DAAsE;AAEtE,yEAGyC;AACzC,qEAAuD;AACvD,mEAIsC;AACtC,6DAAyE;AACzE,qEAAuD;AACvD,+DAAsE;AAEtE,6DAAiD;AAoBjD,MAAa,WAAW;IAMtB,YAAqB,MAAc,EAAW,OAAoB;;QAA7C,WAAM,GAAN,MAAM,CAAQ;QAAW,YAAO,GAAP,OAAO,CAAa;QAH/C,cAAS,GAC1B,IAAI,GAAG,EAAE,CAAC;QAGV,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;Q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B,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAElC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,KAAK,CAAC,UAAU,CAAC,6BAA6B,IAAI,CAAC,KAAK,CAC/D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAK,CAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,KAAK,CAC7D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;QACF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AA3BD,kDA2BC;AAED;;GAEG;AACU,QAAA,WAAW,GAAY;IAClC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,qDAAqD;IAClE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,gCAAW;CACrB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport chalk from 'chalk';\nimport {glob as globFunc} from 'glob';\nimport _ from 'lodash';\nimport {performance} from 'perf_hooks';\nimport {Ora} from 'ora';\nimport util from 'util';\n\nconst glob = util.promisify(globFunc);\n\nimport type {Command, Config} from '@react-native-community/cli-types';\nimport {CodedError, Telemetry} from '@react-native-windows/telemetry';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport {copyAndReplaceWithChangedCallback} from '../../generator-common';\nimport * as nameHelpers from '../../utils/nameHelpers';\nimport {showOldArchitectureWarning} from '../../utils/oldArchWarning';\nimport type {InitOptions} from './initWindowsOptions';\nimport {initOptions} from './initWindowsOptions';\n\nexport interface TemplateFileMapping {\n from: string;\n to: string;\n replacements?: Record<string, any>;\n}\n\nexport interface InitWindowsTemplateConfig {\n name: string;\n description: string;\n isDefault?: boolean;\n preInstall?: (config: Config, options: InitOptions) => Promise<void>;\n getFileMappings?: (\n config: Config,\n options: InitOptions,\n ) => Promise<TemplateFileMapping[]>;\n postInstall?: (config: Config, options: InitOptions) => Promise<void>;\n}\n\nexport class InitWindows {\n protected readonly rnwPath: string;\n protected readonly rnwConfig?: Record<string, any>;\n protected readonly templates: Map<string, InitWindowsTemplateConfig> =\n new Map();\n\n constructor(readonly config: Config, readonly options: InitOptions) {\n this.rnwPath = pathHelpers.resolveRnwRoot(this.config.root);\n this.rnwConfig = this.config.project.windows?.rnwConfig;\n }\n\n protected verboseMessage(message: any) {\n verboseMessage(message, !!this.options.logging);\n }\n\n protected async loadTemplates() {\n const templatesRoot = path.join(this.rnwPath, 'templates');\n for (const file of await glob('**/template.config.js', {\n cwd: templatesRoot,\n })) {\n const templateName = path.dirname(file).replace(/[\\\\]/g, '/');\n const templateConfig: InitWindowsTemplateConfig = require(path.join(\n templatesRoot,\n file,\n ));\n this.templates.set(templateName, templateConfig);\n }\n if (this.templates.size === 0) {\n throw new CodedError(\n 'NoTemplatesFound',\n `No templates were found in ${templatesRoot}.`,\n );\n }\n }\n\n protected getDefaultTemplateName(): string {\n for (const [name, config] of this.templates) {\n if (config.isDefault) {\n return name;\n }\n }\n throw new CodedError(\n 'NoDefaultTemplate',\n 'No template specified and no default template found.',\n );\n }\n\n protected getReactNativeProjectName(projectDir: string): string {\n this.verboseMessage('Looking for project name in package.json...');\n const pkgJsonPath = path.join(projectDir, 'package.json');\n if (!fs.existsSync(pkgJsonPath)) {\n throw new CodedError(\n 'NoPackageJson',\n 'Unable to find package.json. This should be run from within an existing react-native project.',\n );\n }\n type PackageJson = {name: string};\n\n let name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n if (!name) {\n const appJsonPath = path.join(projectDir, 'app.json');\n if (fs.existsSync(appJsonPath)) {\n this.verboseMessage('Looking for project name in app.json...');\n name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n }\n }\n\n if (!name) {\n throw new CodedError(\n 'NoProjectName',\n 'Please specify name in package.json or app.json',\n );\n }\n\n return name;\n }\n\n protected printTemplateList() {\n if (this.templates.size === 0) {\n console.log('\\nNo templates found.\\n');\n return;\n }\n\n for (const [key, value] of this.templates.entries()) {\n const defaultLabel = value.isDefault ? chalk.yellow('[Default] ') : '';\n console.log(\n `\\n${key} - ${value.name}\\n ${defaultLabel}${value.description}`,\n );\n }\n console.log(`\\n`);\n }\n\n // eslint-disable-next-line complexity\n public async run(spinner: Ora) {\n await this.loadTemplates();\n\n spinner.info();\n\n if (this.options.list) {\n this.printTemplateList();\n return;\n }\n\n this.options.template ??=\n (this.rnwConfig?.['init-windows']?.template as string | undefined) ??\n this.getDefaultTemplateName();\n\n spinner.info(`Using template '${this.options.template}'...`);\n if (!this.templates.has(this.options.template.replace(/[\\\\]/g, '/'))) {\n throw new CodedError(\n 'InvalidTemplateName',\n `Unable to find template '${this.options.template}'.`,\n );\n }\n\n const isOldArchTemplate = this.options.template.startsWith('old');\n\n if (isOldArchTemplate) {\n showOldArchitectureWarning();\n }\n\n const templateConfig = this.templates.get(this.options.template)!;\n\n // Check if there's a passed-in project name and if it's valid\n if (\n this.options.name &&\n !nameHelpers.isValidProjectName(this.options.name)\n ) {\n throw new CodedError(\n 'InvalidProjectName',\n `The specified name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // If no project name is provided, check previously used name or calculate a name and clean if necessary\n if (!this.options.name) {\n const projectName =\n (this.rnwConfig?.['init-windows']?.name as string | undefined) ??\n this.getReactNativeProjectName(this.config.root);\n this.options.name = nameHelpers.isValidProjectName(projectName)\n ? projectName\n : nameHelpers.cleanName(projectName);\n }\n\n // Final check that the project name is valid\n if (!nameHelpers.isValidProjectName(this.options.name)) {\n throw new CodedError(\n 'InvalidProjectName',\n `The name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // Check if there's a passed-in project namespace and if it's valid\n if (\n this.options.namespace &&\n !nameHelpers.isValidProjectNamespace(this.options.namespace)\n ) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The specified namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n // If no project namespace is provided, check previously used namespace or use the project name and clean if necessary\n if (!this.options.namespace) {\n const namespace =\n (this.rnwConfig?.['init-windows']?.namespace as string | undefined) ??\n this.options.name;\n this.options.namespace = nameHelpers.isValidProjectNamespace(namespace)\n ? namespace\n : nameHelpers.cleanNamespace(namespace);\n }\n\n // Final check that the project namespace is valid\n if (!nameHelpers.isValidProjectNamespace(this.options.namespace)) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n if (templateConfig.preInstall) {\n spinner.info(`Running ${this.options.template} preInstall()...`);\n await templateConfig.preInstall(this.config, this.options);\n }\n\n // Get template files to copy and copy if available\n if (templateConfig.getFileMappings) {\n const fileMappings = await templateConfig.getFileMappings(\n this.config,\n this.options,\n );\n\n for (const fileMapping of fileMappings) {\n const targetDir = path.join(\n this.config.root,\n path.dirname(fileMapping.to),\n );\n\n if (!(await fs.exists(targetDir))) {\n await fs.mkdir(targetDir, {recursive: true});\n }\n\n await copyAndReplaceWithChangedCallback(\n fileMapping.from,\n this.config.root,\n fileMapping.to,\n fileMapping.replacements,\n this.options.overwrite,\n );\n }\n }\n\n if (templateConfig.postInstall) {\n spinner.info(`Running ${this.options.template} postInstall()...`);\n await templateConfig.postInstall(this.config, this.options);\n }\n\n spinner.succeed();\n }\n}\n\n/**\n * Logs the given message if verbose is True.\n * @param message The message to log.\n * @param verbose Whether or not verbose logging is enabled.\n */\nfunction verboseMessage(message: any, verbose?: boolean) {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\nfunction optionSanitizer(key: keyof InitOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'name':\n case 'namespace':\n return value === undefined ? false : true; // Strip PII\n case 'logging':\n case 'template':\n case 'overwrite':\n case 'telemetry':\n case 'list':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `init-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {};\n return extraProps;\n}\n\nfunction sanitizeOptions(\n opts: Record<string, any>,\n sanitizer: (key: keyof InitOptions, value: any) => any,\n): Record<string, any> {\n const sanitized: Record<string, any> = {};\n for (const key in opts) {\n if (Object.prototype.hasOwnProperty.call(opts, key)) {\n sanitized[key] = sanitizer(key as keyof InitOptions, opts[key]);\n }\n }\n return sanitized;\n}\n\n/**\n * The function run when calling `npx @react-native-community/cli init-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function initWindows(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n await startTelemetrySession(\n 'init-windows',\n config,\n options,\n getDefaultOptions(config, initOptions),\n optionSanitizer,\n );\n\n let initWindowsError: Error | undefined;\n\n try {\n await initWindowsInternal(args, config, options);\n } catch (ex) {\n initWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(initWindowsError);\n }\n\n // Now, instead of custom fields, just pass the final options object\n await endTelemetrySession(initWindowsError, getExtraProps, options, opts =>\n sanitizeOptions(opts, optionSanitizer),\n );\n\n setExitProcessWithError(options.logging, initWindowsError);\n}\n\n/**\n * Initializes a new RNW project from a given template.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nexport async function initWindowsInternal(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner('Running init-windows...');\n try {\n const codegen = new InitWindows(config, options);\n await codegen.run(spinner);\n const endTime = performance.now();\n\n console.log(\n `${chalk.green('Success:')} init-windows completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } catch (e) {\n spinner.fail();\n const endTime = performance.now();\n console.log(\n `${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n throw e;\n }\n}\n\n/**\n * Initializes a new RNW project from a given template.\n */\nexport const initCommand: Command = {\n name: 'init-windows',\n description: 'Initializes a new RNW project from a given template',\n func: initWindows,\n options: initOptions,\n};\n"]}
1
+ {"version":3,"file":"initWindows.js","sourceRoot":"","sources":["../../../src/commands/initWindows/initWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,kDAA0B;AAC1B,+BAAsC;AAEtC,2CAAuC;AAEvC,gDAAwB;AAExB,MAAM,IAAI,GAAG,cAAI,CAAC,SAAS,CAAC,WAAQ,CAAC,CAAC;AAGtC,+DAAsE;AAEtE,yEAGyC;AACzC,qEAAuD;AACvD,mEAIsC;AACtC,6DAAyE;AACzE,qEAAuD;AACvD,+DAAsE;AAEtE,6DAAiD;AAoBjD,MAAa,WAAW;IAMtB,YAAqB,MAAc,EAAW,OAAoB;;QAA7C,WAAM,GAAN,MAAM,CAAQ;QAAW,YAAO,GAAP,OAAO,CAAa;QAH/C,cAAS,GAC1B,IAAI,GAAG,EAAE,CAAC;QAGV,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,0CAAE,SAAS,C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GAAG,IAAA,gCAAU,EAAC,yBAAyB,CAAC,CAAC;IACtD,IAAI;QACF,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjD,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAElC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,KAAK,CAAC,UAAU,CAAC,6BAA6B,IAAI,CAAC,KAAK,CAC/D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAK,CAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,KAAK,CAC7D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;QACF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AA3BD,kDA2BC;AAED;;GAEG;AACU,QAAA,WAAW,GAAY;IAClC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,qDAAqD;IAClE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,gCAAW;CACrB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport chalk from 'chalk';\nimport {glob as globFunc} from 'glob';\nimport _ from 'lodash';\nimport {performance} from 'perf_hooks';\nimport {Ora} from 'ora';\nimport util from 'util';\n\nconst glob = util.promisify(globFunc);\n\nimport type {Command, Config} from '@react-native-community/cli-types';\nimport {CodedError, Telemetry} from '@react-native-windows/telemetry';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport {copyAndReplaceWithChangedCallback} from '../../generator-common';\nimport * as nameHelpers from '../../utils/nameHelpers';\nimport {showOldArchitectureWarning} from '../../utils/oldArchWarning';\nimport type {InitOptions} from './initWindowsOptions';\nimport {initOptions} from './initWindowsOptions';\n\nexport interface TemplateFileMapping {\n from: string;\n to: string;\n replacements?: Record<string, any>;\n}\n\nexport interface InitWindowsTemplateConfig {\n name: string;\n description: string;\n isDefault?: boolean;\n preInstall?: (config: Config, options: InitOptions) => Promise<void>;\n getFileMappings?: (\n config: Config,\n options: InitOptions,\n ) => Promise<TemplateFileMapping[]>;\n postInstall?: (config: Config, options: InitOptions) => Promise<void>;\n}\n\nexport class InitWindows {\n protected readonly rnwPath: string;\n protected readonly rnwConfig?: Record<string, any>;\n protected readonly templates: Map<string, InitWindowsTemplateConfig> =\n new Map();\n\n constructor(readonly config: Config, readonly options: InitOptions) {\n this.rnwPath = pathHelpers.resolveRnwRoot(this.config.root);\n this.rnwConfig = this.config.project.windows?.rnwConfig;\n }\n\n protected verboseMessage(message: any) {\n verboseMessage(message, !!this.options.logging);\n }\n\n protected async loadTemplates() {\n const templatesRoot = path.join(this.rnwPath, 'templates');\n for (const file of await glob('**/template.config.js', {\n cwd: templatesRoot,\n })) {\n const templateName = path.dirname(file).replace(/[\\\\]/g, '/');\n const templateConfig: InitWindowsTemplateConfig = require(path.join(\n templatesRoot,\n file,\n ));\n this.templates.set(templateName, templateConfig);\n }\n if (this.templates.size === 0) {\n throw new CodedError(\n 'NoTemplatesFound',\n `No templates were found in ${templatesRoot}.`,\n );\n }\n }\n\n protected getDefaultTemplateName(): string {\n for (const [name, config] of this.templates) {\n if (config.isDefault) {\n return name;\n }\n }\n throw new CodedError(\n 'NoDefaultTemplate',\n 'No template specified and no default template found.',\n );\n }\n\n protected getReactNativeProjectName(projectDir: string): string {\n this.verboseMessage('Looking for project name in package.json...');\n const pkgJsonPath = path.join(projectDir, 'package.json');\n if (!fs.existsSync(pkgJsonPath)) {\n throw new CodedError(\n 'NoPackageJson',\n 'Unable to find package.json. This should be run from within an existing react-native project.',\n );\n }\n type PackageJson = {name: string};\n\n let name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n if (!name) {\n const appJsonPath = path.join(projectDir, 'app.json');\n if (fs.existsSync(appJsonPath)) {\n this.verboseMessage('Looking for project name in app.json...');\n name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n }\n }\n\n if (!name) {\n throw new CodedError(\n 'NoProjectName',\n 'Please specify name in package.json or app.json',\n );\n }\n\n return name;\n }\n\n protected printTemplateList() {\n if (this.templates.size === 0) {\n console.log('\\nNo templates found.\\n');\n return;\n }\n\n for (const [key, value] of this.templates.entries()) {\n const defaultLabel = value.isDefault ? chalk.yellow('[Default] ') : '';\n console.log(\n `\\n${key} - ${value.name}\\n ${defaultLabel}${value.description}`,\n );\n }\n console.log(`\\n`);\n }\n\n // eslint-disable-next-line complexity\n public async run(spinner: Ora) {\n await this.loadTemplates();\n\n spinner.info();\n\n if (this.options.list) {\n this.printTemplateList();\n return;\n }\n\n this.options.template ??=\n (this.rnwConfig?.['init-windows']?.template as string | undefined) ??\n this.getDefaultTemplateName();\n\n spinner.info(`Using template '${this.options.template}'...`);\n if (!this.templates.has(this.options.template.replace(/[\\\\]/g, '/'))) {\n // Check if user is trying to use an old architecture template\n const isOldArchTemplate = this.options.template.startsWith('old');\n if (isOldArchTemplate) {\n showOldArchitectureWarning();\n throw new CodedError(\n 'InvalidTemplateName',\n `The template '${this.options.template}' is no longer available. Please use 'cpp-app' template instead.`,\n );\n }\n throw new CodedError(\n 'InvalidTemplateName',\n `Unable to find template '${this.options.template}'.`,\n );\n }\n\n const isOldArchTemplate = this.options.template.startsWith('old');\n\n if (isOldArchTemplate) {\n showOldArchitectureWarning();\n }\n\n const templateConfig = this.templates.get(this.options.template)!;\n\n // Check if there's a passed-in project name and if it's valid\n if (\n this.options.name &&\n !nameHelpers.isValidProjectName(this.options.name)\n ) {\n throw new CodedError(\n 'InvalidProjectName',\n `The specified name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // If no project name is provided, check previously used name or calculate a name and clean if necessary\n if (!this.options.name) {\n const projectName =\n (this.rnwConfig?.['init-windows']?.name as string | undefined) ??\n this.getReactNativeProjectName(this.config.root);\n this.options.name = nameHelpers.isValidProjectName(projectName)\n ? projectName\n : nameHelpers.cleanName(projectName);\n }\n\n // Final check that the project name is valid\n if (!nameHelpers.isValidProjectName(this.options.name)) {\n throw new CodedError(\n 'InvalidProjectName',\n `The name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // Check if there's a passed-in project namespace and if it's valid\n if (\n this.options.namespace &&\n !nameHelpers.isValidProjectNamespace(this.options.namespace)\n ) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The specified namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n // If no project namespace is provided, check previously used namespace or use the project name and clean if necessary\n if (!this.options.namespace) {\n const namespace =\n (this.rnwConfig?.['init-windows']?.namespace as string | undefined) ??\n this.options.name;\n this.options.namespace = nameHelpers.isValidProjectNamespace(namespace)\n ? namespace\n : nameHelpers.cleanNamespace(namespace);\n }\n\n // Final check that the project namespace is valid\n if (!nameHelpers.isValidProjectNamespace(this.options.namespace)) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n if (templateConfig.preInstall) {\n spinner.info(`Running ${this.options.template} preInstall()...`);\n await templateConfig.preInstall(this.config, this.options);\n }\n\n // Get template files to copy and copy if available\n if (templateConfig.getFileMappings) {\n const fileMappings = await templateConfig.getFileMappings(\n this.config,\n this.options,\n );\n\n for (const fileMapping of fileMappings) {\n const targetDir = path.join(\n this.config.root,\n path.dirname(fileMapping.to),\n );\n\n if (!(await fs.exists(targetDir))) {\n await fs.mkdir(targetDir, {recursive: true});\n }\n\n await copyAndReplaceWithChangedCallback(\n fileMapping.from,\n this.config.root,\n fileMapping.to,\n fileMapping.replacements,\n this.options.overwrite,\n );\n }\n }\n\n if (templateConfig.postInstall) {\n spinner.info(`Running ${this.options.template} postInstall()...`);\n await templateConfig.postInstall(this.config, this.options);\n }\n\n spinner.succeed();\n }\n}\n\n/**\n * Logs the given message if verbose is True.\n * @param message The message to log.\n * @param verbose Whether or not verbose logging is enabled.\n */\nfunction verboseMessage(message: any, verbose?: boolean) {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\nfunction optionSanitizer(key: keyof InitOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'name':\n case 'namespace':\n return value === undefined ? false : true; // Strip PII\n case 'logging':\n case 'template':\n case 'overwrite':\n case 'telemetry':\n case 'list':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `init-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {};\n return extraProps;\n}\n\nfunction sanitizeOptions(\n opts: Record<string, any>,\n sanitizer: (key: keyof InitOptions, value: any) => any,\n): Record<string, any> {\n const sanitized: Record<string, any> = {};\n for (const key in opts) {\n if (Object.prototype.hasOwnProperty.call(opts, key)) {\n sanitized[key] = sanitizer(key as keyof InitOptions, opts[key]);\n }\n }\n return sanitized;\n}\n\n/**\n * The function run when calling `npx @react-native-community/cli init-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function initWindows(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n await startTelemetrySession(\n 'init-windows',\n config,\n options,\n getDefaultOptions(config, initOptions),\n optionSanitizer,\n );\n\n let initWindowsError: Error | undefined;\n\n try {\n await initWindowsInternal(args, config, options);\n } catch (ex) {\n initWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(initWindowsError);\n }\n\n // Now, instead of custom fields, just pass the final options object\n await endTelemetrySession(initWindowsError, getExtraProps, options, opts =>\n sanitizeOptions(opts, optionSanitizer),\n );\n\n setExitProcessWithError(options.logging, initWindowsError);\n}\n\n/**\n * Initializes a new RNW project from a given template.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nexport async function initWindowsInternal(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner('Running init-windows...');\n try {\n const codegen = new InitWindows(config, options);\n await codegen.run(spinner);\n const endTime = performance.now();\n\n console.log(\n `${chalk.green('Success:')} init-windows completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } catch (e) {\n spinner.fail();\n const endTime = performance.now();\n console.log(\n `${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n throw e;\n }\n}\n\n/**\n * Initializes a new RNW project from a given template.\n */\nexport const initCommand: Command = {\n name: 'init-windows',\n description: 'Initializes a new RNW project from a given template',\n func: initWindows,\n options: initOptions,\n};\n"]}
@@ -14,9 +14,7 @@ const chalk_1 = __importDefault(require("chalk"));
14
14
  * Displays a warning message about the Old Architecture template.
15
15
  */
16
16
  function showOldArchitectureWarning() {
17
- console.log(chalk_1.default.yellow(`⚠️ This project is using the React Native (for Windows) Old Architecture. The old architecture will begin to be removed starting with react-native-windows@0.82.0.`));
18
- console.log();
19
- console.log(chalk_1.default.cyan('💡 It is strongly recommended to move to the new architecture as soon as possible to take advantage of improved performance, long-term support, and modern capabilities.'));
17
+ console.log(chalk_1.default.yellow(`⚠️ The old architecture (Paper) is not supported in RNW version v0.82. Please enable your projects using new architecture (Fabric).`));
20
18
  console.log();
21
19
  console.log(chalk_1.default.blue('🔗 Learn more: https://microsoft.github.io/react-native-windows/docs/new-architecture'));
22
20
  console.log();
@@ -1 +1 @@
1
- {"version":3,"file":"oldArchWarning.js","sourceRoot":"","sources":["../../src/utils/oldArchWarning.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kDAA0B;AAE1B;;GAEG;AACH,SAAgB,0BAA0B;IACxC,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,MAAM,CACV,oKAAoK,CACrK,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,0KAA0K,CAC3K,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,uFAAuF,CACxF,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,yIAAyI,CAC1I,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,wHAAwH,CACzH,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC;AA/BD,gEA+BC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport chalk from 'chalk';\n\n/**\n * Displays a warning message about the Old Architecture template.\n */\nexport function showOldArchitectureWarning(): void {\n console.log(\n chalk.yellow(\n `⚠️ This project is using the React Native (for Windows) Old Architecture. The old architecture will begin to be removed starting with react-native-windows@0.82.0.`,\n ),\n );\n console.log();\n console.log(\n chalk.cyan(\n '💡 It is strongly recommended to move to the new architecture as soon as possible to take advantage of improved performance, long-term support, and modern capabilities.',\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '🔗 Learn more: https://microsoft.github.io/react-native-windows/docs/new-architecture',\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '🔗 View the list of properties not yet supported in Fabric: https://microsoft.github.io/react-native-windows/docs/new-arch-missingProps',\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '💬 If you encounter missing properties, please open an issue: https://github.com/microsoft/react-native-windows/issues',\n ),\n );\n console.log();\n}\n"]}
1
+ {"version":3,"file":"oldArchWarning.js","sourceRoot":"","sources":["../../src/utils/oldArchWarning.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kDAA0B;AAE1B;;GAEG;AACH,SAAgB,0BAA0B;IACxC,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,MAAM,CACV,qIAAqI,CACtI,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,uFAAuF,CACxF,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,yIAAyI,CAC1I,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,wHAAwH,CACzH,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC;AAzBD,gEAyBC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport chalk from 'chalk';\n\n/**\n * Displays a warning message about the Old Architecture template.\n */\nexport function showOldArchitectureWarning(): void {\n console.log(\n chalk.yellow(\n `⚠️ The old architecture (Paper) is not supported in RNW version v0.82. Please enable your projects using new architecture (Fabric).`,\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '🔗 Learn more: https://microsoft.github.io/react-native-windows/docs/new-architecture',\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '🔗 View the list of properties not yet supported in Fabric: https://microsoft.github.io/react-native-windows/docs/new-arch-missingProps',\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '💬 If you encounter missing properties, please open an issue: https://github.com/microsoft/react-native-windows/issues',\n ),\n );\n console.log();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-windows/cli",
3
- "version": "0.82.0-preview.2",
3
+ "version": "0.82.0",
4
4
  "license": "MIT",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "repository": {
@@ -17,10 +17,10 @@
17
17
  "watch": "rnw-scripts watch"
18
18
  },
19
19
  "dependencies": {
20
- "@react-native-windows/codegen": "0.82.0-preview.2",
21
- "@react-native-windows/fs": "0.82.0-preview.1",
22
- "@react-native-windows/package-utils": "0.82.0-preview.1",
23
- "@react-native-windows/telemetry": "0.82.0-preview.1",
20
+ "@react-native-windows/codegen": "0.82.0",
21
+ "@react-native-windows/fs": "0.82.0",
22
+ "@react-native-windows/package-utils": "0.82.0",
23
+ "@react-native-windows/telemetry": "0.82.0",
24
24
  "@xmldom/xmldom": "^0.7.7",
25
25
  "chalk": "^4.1.0",
26
26
  "cli-spinners": "^2.2.0",
@@ -73,11 +73,11 @@
73
73
  "src/powershell"
74
74
  ],
75
75
  "beachball": {
76
- "defaultNpmTag": "preview",
76
+ "defaultNpmTag": "latest",
77
77
  "disallowedChangeTypes": [
78
78
  "major",
79
79
  "minor",
80
- "patch",
80
+ "prerelease",
81
81
  "premajor",
82
82
  "preminor",
83
83
  "prepatch"