@react-native-windows/cli 0.79.3 → 0.80.0-preview.2
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.
- package/README.md +2 -1
- package/lib-commonjs/commands/config/configUtils.js +14 -4
- package/lib-commonjs/commands/config/configUtils.js.map +1 -1
- package/lib-commonjs/commands/initWindows/initWindows.js +3 -0
- package/lib-commonjs/commands/initWindows/initWindows.js.map +1 -1
- package/lib-commonjs/commands/runWindows/runWindows.js +6 -1
- package/lib-commonjs/commands/runWindows/runWindows.js.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -110,8 +110,9 @@ Here are the options that `npx @react-native-community/cli run-windows` takes:
|
|
|
110
110
|
| `--direct-debugging` | number | Enable direct debugging on specified port |
|
|
111
111
|
| `--no-telemetry` | boolean | Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI |
|
|
112
112
|
| `-h`, `--help` | boolean | Display help for command |
|
|
113
|
+
| `--client-logs` | boolean | Enable plain text JavaScript log streaming for all connected apps |
|
|
113
114
|
|
|
114
115
|
## Data Collection
|
|
115
116
|
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
|
|
116
117
|
|
|
117
|
-
This data collection notice only applies to the process of running the react-native-windows CLI (i.e. the commands above).
|
|
118
|
+
This data collection notice only applies to the process of running the react-native-windows CLI (i.e. the commands above).
|
|
@@ -403,17 +403,27 @@ function getExperimentalFeatures(solutionDir) {
|
|
|
403
403
|
}
|
|
404
404
|
exports.getExperimentalFeatures = getExperimentalFeatures;
|
|
405
405
|
function getRnwConfig(root, projectFile) {
|
|
406
|
-
var _a, _b;
|
|
406
|
+
var _a, _b, _c;
|
|
407
407
|
const pkgPath = path_1.default.join(root, 'package.json');
|
|
408
408
|
const pkgJson = fs_1.default.existsSync(pkgPath)
|
|
409
409
|
? require(path_1.default.join(root, 'package.json'))
|
|
410
410
|
: {};
|
|
411
411
|
const config = (_a = pkgJson['react-native-windows']) !== null && _a !== void 0 ? _a : {};
|
|
412
|
+
const info = getRawTemplateInfo(projectFile);
|
|
413
|
+
// inject raw templateInfo for later command use
|
|
414
|
+
if (info.projectArch) {
|
|
415
|
+
config.projectArch = info.projectArch;
|
|
416
|
+
}
|
|
417
|
+
if (info.projectLang) {
|
|
418
|
+
config.projectLang = info.projectLang;
|
|
419
|
+
}
|
|
420
|
+
if (info.projectType) {
|
|
421
|
+
config.projectType = info.projectType;
|
|
422
|
+
}
|
|
412
423
|
// if init-windows is missing (most existing projects), try to auto-calculate it
|
|
413
|
-
(_b = config['init-windows'])
|
|
414
|
-
if (!config['init-windows'].template) {
|
|
415
|
-
const info = getRawTemplateInfo(projectFile);
|
|
424
|
+
if (!((_b = config['init-windows']) === null || _b === void 0 ? void 0 : _b.template)) {
|
|
416
425
|
if (info.projectArch && info.projectLang && info.projectType) {
|
|
426
|
+
(_c = config['init-windows']) !== null && _c !== void 0 ? _c : (config['init-windows'] = {});
|
|
417
427
|
config['init-windows'].template = `${info.projectArch === 'old' ? 'old/uwp-' : ''}${info.projectLang}-${info.projectType}`;
|
|
418
428
|
}
|
|
419
429
|
}
|
|
@@ -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;A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AChB,CAAC;AAvBD,oCAuBC","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 // if init-windows is missing (most existing projects), try to auto-calculate it\n config['init-windows'] ??= {};\n if (!config['init-windows'].template) {\n const info = getRawTemplateInfo(projectFile);\n if (info.projectArch && info.projectLang && info.projectType) {\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,YAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAC5B,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AARD,8CAQC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,QAAgB;IAC5C,OAAO,CACL,YAAE;SACC,YAAY,CAAC,QAAQ,CAAC;SACtB,QAAQ,EAAE;SACV,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAC7B,CAAC;AACJ,CAAC;AAPD,sCAOC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,SAAiB;IACjD,gDAAgD;IAChD,MAAM,YAAY,GAAG,SA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M,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.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"]}
|
|
@@ -124,6 +124,9 @@ class InitWindows {
|
|
|
124
124
|
if (!this.templates.has(this.options.template.replace(/[\\]/g, '/'))) {
|
|
125
125
|
throw new telemetry_1.CodedError('InvalidTemplateName', `Unable to find template '${this.options.template}'.`);
|
|
126
126
|
}
|
|
127
|
+
if (this.options.template.startsWith('old')) {
|
|
128
|
+
spinner.warn(`The legacy '${this.options.template}' template targets the React Native Old Architecture, which will eventually be deprecated. See https://microsoft.github.io/react-native-windows/docs/new-architecture for details on switching to the New Architecture.`);
|
|
129
|
+
}
|
|
127
130
|
const templateConfig = this.templates.get(this.options.template);
|
|
128
131
|
// Check if there's a passed-in project name and if it's valid
|
|
129
132
|
if (this.options.name &&
|
|
@@ -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C;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 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 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\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 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 await endTelemetrySession(initWindowsError, getExtraProps);\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;AAEvD,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,CAAC;IAC1D,CAAC;IAES,cAAc,CAAC,OAAY;QACnC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAES,KAAK,CAAC,aAAa;QAC3B,MAAM,aAAa,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC3D,KAAK,MAAM,IAAI,IAAI,MAAM,IAAI,CAAC,uBAAuB,EAAE;YACrD,GAAG,EAAE,aAAa;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CAAC,CAAC;AAC7D,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,mBAAmB,CACvC,IAAc,EACd,MAAc,EACd,OAAoB;IAEpB,MAAM,SAAS,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;IACpC,MAAM,OAAO,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 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 if (this.options.template.startsWith('old')) {\n spinner.warn(\n `The legacy '${this.options.template}' template targets the React Native Old Architecture, which will eventually be deprecated. See https://microsoft.github.io/react-native-windows/docs/new-architecture for details on switching to the New Architecture.`,\n );\n }\n\n 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\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 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 await endTelemetrySession(initWindowsError, getExtraProps);\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"]}
|
|
@@ -32,6 +32,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
32
32
|
};
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
34
|
exports.runWindowsCommand = void 0;
|
|
35
|
+
/* eslint-disable complexity */
|
|
35
36
|
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
36
37
|
const path_1 = __importDefault(require("path"));
|
|
37
38
|
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
@@ -51,7 +52,6 @@ const autolinkWindows_1 = require("../autolinkWindows/autolinkWindows");
|
|
|
51
52
|
* @param value The unsanitized value of the option.
|
|
52
53
|
* @returns The sanitized value of the option.
|
|
53
54
|
*/
|
|
54
|
-
// eslint-disable-next-line complexity
|
|
55
55
|
function optionSanitizer(key, value) {
|
|
56
56
|
// Do not add a default case here.
|
|
57
57
|
// Strings risking PII should just return true if present, false otherwise.
|
|
@@ -163,10 +163,15 @@ async function runWindows(args, config, options) {
|
|
|
163
163
|
* @param options Options passed from react-native CLI.
|
|
164
164
|
*/
|
|
165
165
|
async function runWindowsInternal(args, config, options) {
|
|
166
|
+
var _a, _b;
|
|
166
167
|
const verbose = options.logging === true;
|
|
167
168
|
if (verbose) {
|
|
168
169
|
(0, commandWithProgress_1.newInfo)('Verbose: ON');
|
|
169
170
|
}
|
|
171
|
+
// Warn about old architecture projects
|
|
172
|
+
if (((_b = (_a = config.project.windows) === null || _a === void 0 ? void 0 : _a.rnwConfig) === null || _b === void 0 ? void 0 : _b.projectArch) === 'old') {
|
|
173
|
+
(0, commandWithProgress_1.newWarn)('This project is using the React Native (for Windows) Old Architecture, which will eventually be deprecated. See https://microsoft.github.io/react-native-windows/docs/new-architecture for details on switching to the New Architecture.');
|
|
174
|
+
}
|
|
170
175
|
// Get the solution file
|
|
171
176
|
let slnFile;
|
|
172
177
|
runWindowsPhase = 'FindSolution';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWindows.js","sourceRoot":"","sources":["../../../src/commands/runWindows/runWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AAExB,+DAAsE;AAGtE,yDAA2C;AAC3C,kDAA0B;AAC1B,2DAA6C;AAC7C,yEAKyC;AACzC,mEAIsC;AACtC,qEAAuD;AACvD,uDAAyC;AACzC,4EAAoD;AAEpD,2DAAsD;AACtD,wEAA2E;AAG3E;;;;;GAKG;AACH,sCAAsC;AACtC,SAAS,eAAe,CAAC,GAA4B,EAAE,KAAU;IAC/D,kCAAkC;IAClC,2EAA2E;IAC3E,8DAA8D;IAC9D,QAAQ,GAAG,EAAE;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,mBAAmB;YACtB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;QAC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C,EAAE;YACV,IAAA,8BAAQ,EAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,KAAM,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACpE,MAAM,CAAC,CAAC;SACT;KACF;SAAM;QACL,IAAA,6BAAO,EAAC,wBAAwB,CAAC,CAAC;KACnC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,OAA0B;IACtD,OAAO,CACL,OAAO,CAAC,QAAQ,KAAK,IAAI;QACzB,OAAO,CAAC,MAAM,KAAK,IAAI;QACvB,OAAO,CAAC,OAAO,KAAK,IAAI,CACzB,CAAC;AACJ,CAAC;AAED;;;;;;;;EAQE;AAEF;;GAEG;AACU,QAAA,iBAAiB,GAAY;IACxC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,sFAAsF;IACxF,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,qCAAiB;CAC3B,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\n\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport type {Command, Config} from '@react-native-community/cli-types';\n\nimport * as build from '../../utils/build';\nimport chalk from 'chalk';\nimport * as deploy from '../../utils/deploy';\nimport {\n newError,\n newInfo,\n newWarn,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport * as info from '../../utils/info';\nimport MSBuildTools from '../../utils/msbuildtools';\nimport type {RunWindowsOptions} from './runWindowsOptions';\nimport {runWindowsOptions} from './runWindowsOptions';\nimport {autolinkWindowsInternal} from '../autolinkWindows/autolinkWindows';\nimport type {AutoLinkOptions} from '../autolinkWindows/autolinkWindowsOptions';\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\n// eslint-disable-next-line complexity\nfunction optionSanitizer(key: keyof RunWindowsOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'root':\n case 'target':\n case 'sln':\n case 'proj':\n case 'buildLogDirectory':\n return value === undefined ? false : true; // Strip PII\n case 'msbuildprops':\n return typeof value === 'string' ? value.split(',').length : 0; // Convert to count\n case 'release':\n case 'arch':\n case 'singleproc':\n case 'emulator':\n case 'device':\n case 'remoteDebugging':\n case 'logging':\n case 'packager':\n case 'bundle':\n case 'launch':\n case 'autolink':\n case 'build':\n case 'deploy':\n case 'deployFromLayout':\n case 'info':\n case 'directDebugging':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `run-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {\n phase: runWindowsPhase,\n hasRunRnwDependencies,\n msBuildProps: evaluateMSBuildPropsCallback\n ? evaluateMSBuildPropsCallback()\n : {},\n };\n return extraProps;\n}\n\n/**\n * Labels used by telemetry to represent current operation\n */\ntype RunWindowsPhase =\n | 'None'\n | 'Info'\n | 'FindSolution'\n | 'FindBuildTools'\n | 'Autolink'\n | 'RestorePackagesConfig'\n | 'Build'\n | 'Deploy';\n\nlet runWindowsPhase: RunWindowsPhase = 'None';\n\nlet hasRunRnwDependencies: boolean = false;\n\nlet evaluateMSBuildPropsCallback:\n | (() => Record<string, string> | null)\n | undefined;\n\n/**\n * The function run when calling `npx @react-native-community/cli run-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindows(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n await startTelemetrySession(\n 'run-windows',\n config,\n options,\n getDefaultOptions(config, runWindowsOptions),\n optionSanitizer,\n );\n\n // https://github.com/yarnpkg/yarn/issues/8334 - Yarn on Windows breaks apps that read from the environment variables\n // Yarn will run node via CreateProcess and pass npm_config_* variables in lowercase without unifying their value\n // with their possibly existing uppercase counterparts. This breaks programs that read from the environment block\n // and write to a case-insensitive dictionary since they expect to encounter each variable only once.\n // The values of the lowercase variables are the one npm actually wants to use, plus they are seeded from the\n // uppercase variable values one if there are no overrides.\n delete process.env.NPM_CONFIG_CACHE;\n delete process.env.NPM_CONFIG_PREFIX;\n\n if (process.env.LocalAppData) {\n hasRunRnwDependencies = fs.existsSync(\n path.join(process.env.LocalAppData, 'rnw-dependencies.txt'),\n ); // CODESYNC \\vnext\\scripts\\rnw-dependencies.ps1\n }\n\n let runWindowsError: Error | undefined;\n if (options.info) {\n runWindowsPhase = 'Info';\n try {\n const output = await info.getEnvironmentInfo();\n console.log(output.trimEnd());\n console.log(' Installed UWP SDKs:');\n const sdks = MSBuildTools.getAllAvailableUAPVersions();\n sdks.forEach(version => console.log(' ' + version));\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n newError(\n 'Unable to print environment info.\\n' + runWindowsError.toString(),\n );\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n return;\n }\n\n try {\n await runWindowsInternal(args, config, options);\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n if (!hasRunRnwDependencies) {\n const rnwDependenciesPath = path.join(\n pathHelpers.resolveRnwRoot([process.cwd(), __dirname]),\n 'scripts/rnw-dependencies.ps1',\n );\n\n newError(\n `It is possible your installation is missing required software dependencies. Dependencies can be automatically installed by running ${rnwDependenciesPath} from an elevated PowerShell prompt.\\nFor more information, go to http://aka.ms/rnw-deps`,\n );\n }\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n}\n\n/**\n * Performs build deploy and launch of RNW apps.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindowsInternal(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n const verbose = options.logging === true;\n\n if (verbose) {\n newInfo('Verbose: ON');\n }\n\n // Get the solution file\n let slnFile: string | null;\n runWindowsPhase = 'FindSolution';\n try {\n slnFile = build.getAppSolutionFile(options, config);\n } catch (e) {\n newError(`Couldn't get app solution information. ${(e as Error).message}`);\n throw e;\n }\n\n let buildTools: MSBuildTools;\n runWindowsPhase = 'FindBuildTools';\n try {\n buildTools = MSBuildTools.findAvailableVersion(options.arch, verbose);\n } catch (error) {\n newWarn('No public VS release found');\n // Try prerelease\n try {\n newInfo('Trying pre-release VS');\n buildTools = MSBuildTools.findAvailableVersion(\n options.arch,\n verbose,\n true, // preRelease\n );\n } catch (e) {\n newError((e as Error).message);\n throw error;\n }\n }\n\n // Set up the callback to capture MSBuild properties after the command completes\n evaluateMSBuildPropsCallback = () => {\n const projectFile = build.getAppProjectFile(options, config);\n if (projectFile) {\n if (verbose) {\n newInfo('Gathering MSBuild data for telemetry.');\n }\n\n const msBuildPropertiesJsonPath = path.resolve(\n path.dirname(projectFile),\n 'Generated Files',\n 'msbuildproperties.g.json',\n );\n\n if (fs.existsSync(msBuildPropertiesJsonPath)) {\n if (verbose) {\n newInfo('Loading properties from msbuildproperties.g.json');\n }\n return fs.readJsonFileSync(msBuildPropertiesJsonPath);\n }\n\n if (verbose) {\n newInfo('Unable to find msbuildproperties.g.json');\n }\n }\n\n return {};\n };\n\n // Restore packages.config files for dependencies that don't support PackageReference.\n runWindowsPhase = 'RestorePackagesConfig';\n const buildType = deploy.getBuildConfiguration(options);\n try {\n await buildTools.restorePackageConfigs(slnFile, options.arch, buildType);\n } catch (e) {\n newError(\n `Couldn't restore found packages.config instances. ${\n (e as Error).message\n }`,\n );\n throw e;\n }\n\n if (options.autolink) {\n runWindowsPhase = 'Autolink';\n try {\n const autolinkArgs: string[] = [];\n const autolinkConfig = config;\n const autolinkOptions: AutoLinkOptions = {\n logging: options.logging,\n check: false,\n proj: options.proj,\n sln: options.sln,\n telemetry: options.telemetry,\n };\n await autolinkWindowsInternal(\n autolinkArgs,\n autolinkConfig,\n autolinkOptions,\n );\n } catch (e) {\n newError(`Autolinking failed. ${(e as Error).message}`);\n throw e;\n }\n } else {\n newInfo('Autolink step is skipped');\n }\n\n if (options.build) {\n runWindowsPhase = 'Build';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx @react-native-community/cli init-windows\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n // Get build/deploy options\n const msBuildProps = build.parseMsBuildProps(options);\n\n // Disable the autolink check since we just ran it\n msBuildProps.RunAutolinkCheck = 'false';\n\n try {\n await build.buildSolution(\n buildTools,\n slnFile!,\n buildType,\n options.arch,\n msBuildProps,\n verbose,\n 'build',\n options.buildLogDirectory,\n options.singleproc,\n );\n } catch (e) {\n newError(\n `Build failed with message ${\n (e as Error).message\n }. Check your build configuration.`,\n );\n if ((e as any).logfile) {\n console.log('See', chalk.bold((e as any).logfile));\n }\n throw e;\n }\n } else {\n newInfo('Build step is skipped');\n }\n\n if (shouldLaunchPackager(options)) {\n await deploy.startServerInNewWindow(options, verbose);\n }\n\n if (options.deploy) {\n runWindowsPhase = 'Deploy';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx @react-native-community/cli init-windows\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n try {\n if (options.device || options.emulator || options.target) {\n await deploy.deployToDevice(options, verbose, config);\n } else {\n await deploy.deployToDesktop(options, verbose, config, buildTools);\n }\n } catch (e) {\n newError(`Failed to deploy${e ? `: ${(e as Error).message}` : ''}`);\n throw e;\n }\n } else {\n newInfo('Deploy step is skipped');\n }\n}\n\nfunction shouldLaunchPackager(options: RunWindowsOptions): boolean {\n return (\n options.packager === true &&\n options.launch === true &&\n options.release !== true\n );\n}\n\n/*\n// Example of running the Windows Command\nrunWindows({\n root: 'C:\\\\github\\\\hack\\\\myapp',\n debug: true,\n arch: 'x86',\n nugetPath: 'C:\\\\github\\\\react\\\\react-native-windows\\\\local-cli\\\\runWindows\\\\.nuget\\\\nuget.exe'\n});\n*/\n\n/**\n * Starts the app on a connected Windows emulator or mobile device.\n */\nexport const runWindowsCommand: Command = {\n name: 'run-windows',\n description:\n 'Builds your RNW app and starts it on a connected Windows desktop, emulator or device',\n func: runWindows,\n options: runWindowsOptions,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"runWindows.js","sourceRoot":"","sources":["../../../src/commands/runWindows/runWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+BAA+B;AAE/B,kEAA0C;AAC1C,gDAAwB;AAExB,+DAAsE;AAGtE,yDAA2C;AAC3C,kDAA0B;AAC1B,2DAA6C;AAC7C,yEAKyC;AACzC,mEAIsC;AACtC,qEAAuD;AACvD,uDAAyC;AACzC,4EAAoD;AAEpD,2DAAsD;AACtD,wEAA2E;AAG3E;;;;;GAKG;AACH,SAAS,eAAe,CAAC,GAA4B,EAAE,KAAU;IAC/D,kCAAkC;IAClC,2EAA2E;IAC3E,8DAA8D;IAC9D,QAAQ,GAAG,EAAE;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,mBAAmB;YACtB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;QACzD,KAAK,cAAc;YACjB,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC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;QAAC,OAAO,CAAC,EAAE;YACV,IAAA,8BAAQ,EAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,KAAM,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACpE,MAAM,CAAC,CAAC;SACT;KACF;SAAM;QACL,IAAA,6BAAO,EAAC,wBAAwB,CAAC,CAAC;KACnC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,OAA0B;IACtD,OAAO,CACL,OAAO,CAAC,QAAQ,KAAK,IAAI;QACzB,OAAO,CAAC,MAAM,KAAK,IAAI;QACvB,OAAO,CAAC,OAAO,KAAK,IAAI,CACzB,CAAC;AACJ,CAAC;AAED;;;;;;;;EAQE;AAEF;;GAEG;AACU,QAAA,iBAAiB,GAAY;IACxC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,sFAAsF;IACxF,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,qCAAiB;CAC3B,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\n/* eslint-disable complexity */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\n\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport type {Command, Config} from '@react-native-community/cli-types';\n\nimport * as build from '../../utils/build';\nimport chalk from 'chalk';\nimport * as deploy from '../../utils/deploy';\nimport {\n newError,\n newInfo,\n newWarn,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport * as info from '../../utils/info';\nimport MSBuildTools from '../../utils/msbuildtools';\nimport type {RunWindowsOptions} from './runWindowsOptions';\nimport {runWindowsOptions} from './runWindowsOptions';\nimport {autolinkWindowsInternal} from '../autolinkWindows/autolinkWindows';\nimport type {AutoLinkOptions} from '../autolinkWindows/autolinkWindowsOptions';\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\nfunction optionSanitizer(key: keyof RunWindowsOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'root':\n case 'target':\n case 'sln':\n case 'proj':\n case 'buildLogDirectory':\n return value === undefined ? false : true; // Strip PII\n case 'msbuildprops':\n return typeof value === 'string' ? value.split(',').length : 0; // Convert to count\n case 'release':\n case 'arch':\n case 'singleproc':\n case 'emulator':\n case 'device':\n case 'remoteDebugging':\n case 'logging':\n case 'packager':\n case 'bundle':\n case 'launch':\n case 'autolink':\n case 'build':\n case 'deploy':\n case 'deployFromLayout':\n case 'info':\n case 'directDebugging':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `run-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {\n phase: runWindowsPhase,\n hasRunRnwDependencies,\n msBuildProps: evaluateMSBuildPropsCallback\n ? evaluateMSBuildPropsCallback()\n : {},\n };\n return extraProps;\n}\n\n/**\n * Labels used by telemetry to represent current operation\n */\ntype RunWindowsPhase =\n | 'None'\n | 'Info'\n | 'FindSolution'\n | 'FindBuildTools'\n | 'Autolink'\n | 'RestorePackagesConfig'\n | 'Build'\n | 'Deploy';\n\nlet runWindowsPhase: RunWindowsPhase = 'None';\n\nlet hasRunRnwDependencies: boolean = false;\n\nlet evaluateMSBuildPropsCallback:\n | (() => Record<string, string> | null)\n | undefined;\n\n/**\n * The function run when calling `npx @react-native-community/cli run-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindows(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n await startTelemetrySession(\n 'run-windows',\n config,\n options,\n getDefaultOptions(config, runWindowsOptions),\n optionSanitizer,\n );\n\n // https://github.com/yarnpkg/yarn/issues/8334 - Yarn on Windows breaks apps that read from the environment variables\n // Yarn will run node via CreateProcess and pass npm_config_* variables in lowercase without unifying their value\n // with their possibly existing uppercase counterparts. This breaks programs that read from the environment block\n // and write to a case-insensitive dictionary since they expect to encounter each variable only once.\n // The values of the lowercase variables are the one npm actually wants to use, plus they are seeded from the\n // uppercase variable values one if there are no overrides.\n delete process.env.NPM_CONFIG_CACHE;\n delete process.env.NPM_CONFIG_PREFIX;\n\n if (process.env.LocalAppData) {\n hasRunRnwDependencies = fs.existsSync(\n path.join(process.env.LocalAppData, 'rnw-dependencies.txt'),\n ); // CODESYNC \\vnext\\scripts\\rnw-dependencies.ps1\n }\n\n let runWindowsError: Error | undefined;\n if (options.info) {\n runWindowsPhase = 'Info';\n try {\n const output = await info.getEnvironmentInfo();\n console.log(output.trimEnd());\n console.log(' Installed UWP SDKs:');\n const sdks = MSBuildTools.getAllAvailableUAPVersions();\n sdks.forEach(version => console.log(' ' + version));\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n newError(\n 'Unable to print environment info.\\n' + runWindowsError.toString(),\n );\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n return;\n }\n\n try {\n await runWindowsInternal(args, config, options);\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n if (!hasRunRnwDependencies) {\n const rnwDependenciesPath = path.join(\n pathHelpers.resolveRnwRoot([process.cwd(), __dirname]),\n 'scripts/rnw-dependencies.ps1',\n );\n\n newError(\n `It is possible your installation is missing required software dependencies. Dependencies can be automatically installed by running ${rnwDependenciesPath} from an elevated PowerShell prompt.\\nFor more information, go to http://aka.ms/rnw-deps`,\n );\n }\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n}\n\n/**\n * Performs build deploy and launch of RNW apps.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindowsInternal(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n const verbose = options.logging === true;\n\n if (verbose) {\n newInfo('Verbose: ON');\n }\n\n // Warn about old architecture projects\n if (config.project.windows?.rnwConfig?.projectArch === 'old') {\n newWarn(\n 'This project is using the React Native (for Windows) Old Architecture, which will eventually be deprecated. See https://microsoft.github.io/react-native-windows/docs/new-architecture for details on switching to the New Architecture.',\n );\n }\n\n // Get the solution file\n let slnFile: string | null;\n runWindowsPhase = 'FindSolution';\n try {\n slnFile = build.getAppSolutionFile(options, config);\n } catch (e) {\n newError(`Couldn't get app solution information. ${(e as Error).message}`);\n throw e;\n }\n\n let buildTools: MSBuildTools;\n runWindowsPhase = 'FindBuildTools';\n try {\n buildTools = MSBuildTools.findAvailableVersion(options.arch, verbose);\n } catch (error) {\n newWarn('No public VS release found');\n // Try prerelease\n try {\n newInfo('Trying pre-release VS');\n buildTools = MSBuildTools.findAvailableVersion(\n options.arch,\n verbose,\n true, // preRelease\n );\n } catch (e) {\n newError((e as Error).message);\n throw error;\n }\n }\n\n // Set up the callback to capture MSBuild properties after the command completes\n evaluateMSBuildPropsCallback = () => {\n const projectFile = build.getAppProjectFile(options, config);\n if (projectFile) {\n if (verbose) {\n newInfo('Gathering MSBuild data for telemetry.');\n }\n\n const msBuildPropertiesJsonPath = path.resolve(\n path.dirname(projectFile),\n 'Generated Files',\n 'msbuildproperties.g.json',\n );\n\n if (fs.existsSync(msBuildPropertiesJsonPath)) {\n if (verbose) {\n newInfo('Loading properties from msbuildproperties.g.json');\n }\n return fs.readJsonFileSync(msBuildPropertiesJsonPath);\n }\n\n if (verbose) {\n newInfo('Unable to find msbuildproperties.g.json');\n }\n }\n\n return {};\n };\n\n // Restore packages.config files for dependencies that don't support PackageReference.\n runWindowsPhase = 'RestorePackagesConfig';\n const buildType = deploy.getBuildConfiguration(options);\n try {\n await buildTools.restorePackageConfigs(slnFile, options.arch, buildType);\n } catch (e) {\n newError(\n `Couldn't restore found packages.config instances. ${\n (e as Error).message\n }`,\n );\n throw e;\n }\n\n if (options.autolink) {\n runWindowsPhase = 'Autolink';\n try {\n const autolinkArgs: string[] = [];\n const autolinkConfig = config;\n const autolinkOptions: AutoLinkOptions = {\n logging: options.logging,\n check: false,\n proj: options.proj,\n sln: options.sln,\n telemetry: options.telemetry,\n };\n await autolinkWindowsInternal(\n autolinkArgs,\n autolinkConfig,\n autolinkOptions,\n );\n } catch (e) {\n newError(`Autolinking failed. ${(e as Error).message}`);\n throw e;\n }\n } else {\n newInfo('Autolink step is skipped');\n }\n\n if (options.build) {\n runWindowsPhase = 'Build';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx @react-native-community/cli init-windows\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n // Get build/deploy options\n const msBuildProps = build.parseMsBuildProps(options);\n\n // Disable the autolink check since we just ran it\n msBuildProps.RunAutolinkCheck = 'false';\n\n try {\n await build.buildSolution(\n buildTools,\n slnFile!,\n buildType,\n options.arch,\n msBuildProps,\n verbose,\n 'build',\n options.buildLogDirectory,\n options.singleproc,\n );\n } catch (e) {\n newError(\n `Build failed with message ${\n (e as Error).message\n }. Check your build configuration.`,\n );\n if ((e as any).logfile) {\n console.log('See', chalk.bold((e as any).logfile));\n }\n throw e;\n }\n } else {\n newInfo('Build step is skipped');\n }\n\n if (shouldLaunchPackager(options)) {\n await deploy.startServerInNewWindow(options, verbose);\n }\n\n if (options.deploy) {\n runWindowsPhase = 'Deploy';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx @react-native-community/cli init-windows\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n try {\n if (options.device || options.emulator || options.target) {\n await deploy.deployToDevice(options, verbose, config);\n } else {\n await deploy.deployToDesktop(options, verbose, config, buildTools);\n }\n } catch (e) {\n newError(`Failed to deploy${e ? `: ${(e as Error).message}` : ''}`);\n throw e;\n }\n } else {\n newInfo('Deploy step is skipped');\n }\n}\n\nfunction shouldLaunchPackager(options: RunWindowsOptions): boolean {\n return (\n options.packager === true &&\n options.launch === true &&\n options.release !== true\n );\n}\n\n/*\n// Example of running the Windows Command\nrunWindows({\n root: 'C:\\\\github\\\\hack\\\\myapp',\n debug: true,\n arch: 'x86',\n nugetPath: 'C:\\\\github\\\\react\\\\react-native-windows\\\\local-cli\\\\runWindows\\\\.nuget\\\\nuget.exe'\n});\n*/\n\n/**\n * Starts the app on a connected Windows emulator or mobile device.\n */\nexport const runWindowsCommand: Command = {\n name: 'run-windows',\n description:\n 'Builds your RNW app and starts it on a connected Windows desktop, emulator or device',\n func: runWindows,\n options: runWindowsOptions,\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-windows/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.0-preview.2",
|
|
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.
|
|
21
|
-
"@react-native-windows/fs": "0.
|
|
22
|
-
"@react-native-windows/package-utils": "0.
|
|
23
|
-
"@react-native-windows/telemetry": "0.
|
|
20
|
+
"@react-native-windows/codegen": "0.80.0-preview.1",
|
|
21
|
+
"@react-native-windows/fs": "0.80.0-preview.1",
|
|
22
|
+
"@react-native-windows/package-utils": "0.80.0-preview.1",
|
|
23
|
+
"@react-native-windows/telemetry": "0.80.0-preview.1",
|
|
24
24
|
"@xmldom/xmldom": "^0.7.7",
|
|
25
25
|
"chalk": "^4.1.0",
|
|
26
26
|
"cli-spinners": "^2.2.0",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"xpath": "^0.0.27"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@react-native-community/cli-doctor": "
|
|
44
|
-
"@react-native-community/cli-types": "
|
|
43
|
+
"@react-native-community/cli-doctor": "17.0.0",
|
|
44
|
+
"@react-native-community/cli-types": "17.0.0",
|
|
45
45
|
"@rnw-scripts/eslint-config": "1.2.36",
|
|
46
46
|
"@rnw-scripts/jest-unittest-config": "1.5.11",
|
|
47
|
-
"@rnw-scripts/just-task": "2.3.
|
|
47
|
+
"@rnw-scripts/just-task": "2.3.54",
|
|
48
48
|
"@rnw-scripts/ts-config": "2.0.5",
|
|
49
49
|
"@types/chalk": "^2.2.0",
|
|
50
50
|
"@types/jest": "^29.2.2",
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
"src/powershell"
|
|
74
74
|
],
|
|
75
75
|
"beachball": {
|
|
76
|
-
"defaultNpmTag": "
|
|
76
|
+
"defaultNpmTag": "preview",
|
|
77
77
|
"disallowedChangeTypes": [
|
|
78
78
|
"major",
|
|
79
79
|
"minor",
|
|
80
|
-
"
|
|
80
|
+
"patch",
|
|
81
81
|
"premajor",
|
|
82
82
|
"preminor",
|
|
83
83
|
"prepatch"
|