@react-native-windows/cli 0.0.0-canary.223 → 0.0.0-canary.225

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 CHANGED
@@ -1,47 +1,117 @@
1
1
  # @react-native-windows/cli
2
2
 
3
- CLI to build and run React Native for Windows apps.
3
+ CLI to build and run React Native for Windows apps.
4
4
 
5
- ## Usage
5
+ ## `autolink-windows`
6
6
 
7
- Run this from an existing `react-native` project with React Native Windows to build and deploy apps.
7
+ The `autolink-windows` CLI command is used to link the native code and build systems for a React Native for Windows app with any native community modules it uses.
8
8
 
9
+ **Note:** Autolinking runs automatically as part of running the `run-windows` CLI command, unless the `--no-autolink` argument is used.
9
10
 
10
- Example usage
11
+ ### Usage
12
+ Runs Windows-specific autolinking for your RNW project.
13
+
14
+ ```bat
15
+ npx react-native autolink-windows
11
16
  ```
17
+ ### Options
18
+
19
+ Here are the options that `react-native autolink-windows` takes:
20
+ | Option | Input Type | Description |
21
+ |-----------------------|------------|--------------------------------------------------|
22
+ | `--logging` | boolean | Verbose output logging |
23
+ | `--check` | boolean | Only check whether any autolinked files need to change |
24
+ | `--sln` | string | Override the app solution file determined by 'react-native config', i.e. `windows\myApp.sln` |
25
+ | `--proj` | string | Override the app project file determined by 'react-native config', i.e. `windows\myApp\myApp.vcxproj` |
26
+ | `--no-telemetry` | boolean | Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI |
27
+ | `-h`, `--help` | boolean | Display help for command |
28
+
29
+ ## `codegen-windows`
30
+
31
+ The `codegen-windows` CLI command is used to generate some necessary Windows-specific native code for native modules.
32
+
33
+ ### Usage
34
+ Runs Windows-specific codegen for native modules.
35
+
36
+ ```bat
37
+ npx react-native codegen-windows
38
+ ```
39
+ ### Options
40
+
41
+ Here are the options that `react-native codegen-windows` takes:
42
+ | Option | Input Type | Description |
43
+ |-----------------------|------------|--------------------------------------------------|
44
+ | `--logging` | boolean | Verbose output logging |
45
+ | `--check` | boolean | Only check whether any codegen files need to change |
46
+ | `--no-telemetry` | boolean | Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI |
47
+ | `-h`, `--help` | boolean | Display help for command |
48
+
49
+ ## `init-windows`
50
+
51
+ The `init-windows` CLI command is used to initialize a new React Native for Windows project inside an existing React Native project.
52
+
53
+ ### Usage
54
+ Initializes a new RNW project from a given template.
55
+
56
+ ```bat
57
+ npx react-native init-windows
58
+ ```
59
+ ### Options
60
+
61
+ Here are the options that `react-native init-windows` takes:
62
+ | Option | Input Type | Description |
63
+ |-----------------------|------------|--------------------------------------------------|
64
+ | `--logging` | boolean | Verbose output logging |
65
+ | `--template` | string | Specify the template to use |
66
+ | `--name` | string | The native project name. Defaults to the name property in `app.json` or `package.json` |
67
+ | `--namespace` | string | The native project namespace, expressed using dots as separators, i.e. `Level1.Level2.Level3`. Defaults to the same as name |
68
+ | `--overwrite` | boolean | Overwrite any existing files without prompting |
69
+ | `--no-telemetry` | boolean | Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI |
70
+ | `-h`, `--help` | boolean | Display help for command |
71
+
72
+ ## `run-windows`
73
+
74
+ The `run-windows` CLI command is used to build and run React Native for Windows apps.
75
+
76
+ ### Usage
77
+ Builds your RNW app and starts it on a connected Windows desktop, emulator or device.
78
+
79
+ ```bat
12
80
  npx react-native run-windows
13
81
  ```
82
+ ### Options
14
83
 
15
- Options:
16
- | option | description | type |
17
- |-----------------------|--------------------------------------|--------------------------------------------------|
18
- | `--release` | Specifies a Release build | [boolean] |
19
- | `--root` | Override the root directory for the windows build which contains the windows folder. (default: "E:\\test63") | [string] |
20
- | `--arch` | The build architecture (ARM64, x86, x64). defaults to system architecture | [string] |
21
- | `--singleproc` | Disables multi-proc build | [boolean] |
22
- | `--emulator` | Deploys the app to an emulator | [boolean] |
23
- | `--device` | Deploys the app to a connected device | [boolean] |
24
- | `--target` | Deploys the app to the specified GUID for a device | [string] |
25
- | `--remote-debugging` | Deploys the app in remote debugging mode. | [boolean] |
26
- | `--logging` | Enables logging | [boolean] |
27
- | `--no-packager` | Do not launch packager while building | [boolean] |
28
- | `--bundle` | Enable Bundle configuration and it would be ReleaseBundle/DebugBundle other than Release/Debug | [boolean] |
29
- | `--no-launch` | Do not launch the app after deployment | [boolean] |
30
- | `--no-autolink` | Do not run autolinking | [boolean] |
31
- | `--no-build` | Do not build the solution | [boolean] |
32
- | `--no-deploy` | Do not deploy the app | [boolean] |
33
- | `--deploy-from-layout`| Force deploy from layout, even in release builds | [boolean] |
34
- | `--sln` | Override the app solution file determined by 'react-native config', e.g. windows\myApp.sln | [string] |
35
- | `--proj` | Override the app project file determined by 'react-native config', e.g. windows\myApp\myApp.vcxproj | [string] |
36
- | `--msbuildprops` | Comma separated props to pass to MSBuild, eg: prop1=value1,prop2=value2 | [string] |
37
- | `--buildLogDirectory` | Optional directory where MSBuild log files should be stored | [string] |
38
- | `--info` | Dump environment information | [boolean] |
39
- | `--direct-debugging` | Enable direct debugging on specified port | [number] |
40
- | `--no-telemetry` | Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI | [boolean] |
41
- | `-h`, `--help` | output usage information | [boolean] |
84
+ > **Note:** Remote Debugging was officially marked as [deprecated](https://github.com/react-native-community/discussions-and-proposals/discussions/734) in RN 0.73 and will be removed in a later release.
42
85
 
86
+ Here are the options that `react-native run-windows` takes:
87
+ | Option | Input Type | Description |
88
+ |-----------------------|------------|--------------------------------------------------|
89
+ | `--release` | boolean | Specifies a Release build |
90
+ | `--root` | string | Override the root directory for the project which contains the `windows` folder |
91
+ | `--arch` | string | The build architecture, i.e. `ARM64`, `x86`, `x64`. Defaults to system architecture |
92
+ | `--singleproc` | boolean | Disables multi-proc build |
93
+ | `--emulator` | boolean | Deploys the app to an emulator |
94
+ | `--device` | boolean | Deploys the app to a connected device |
95
+ | `--target` | string | Deploys the app to the specified `GUID` for a device |
96
+ | `--remote-debugging` | boolean | **(Deprecated)** Deploys the app in remote debugging mode |
97
+ | `--logging` | boolean | Verbose output logging |
98
+ | `--no-packager` | boolean | Do not launch the packager while building |
99
+ | `--bundle` | boolean | Enable Bundle configuration, i.e. `ReleaseBundle`/`DebugBundle` rather than `Release`/`Debug` |
100
+ | `--no-launch` | boolean | Do not launch the app after deployment |
101
+ | `--no-autolink` | boolean | Do not run autolinking |
102
+ | `--no-build` | boolean | Do not build the solution |
103
+ | `--no-deploy` | boolean | Do not deploy the app |
104
+ | `--deploy-from-layout`| boolean | Force deploy from layout even in Release builds |
105
+ | `--sln` | string | Override the app solution file determined by 'react-native config', i.e. `windows\myApp.sln` |
106
+ | `--proj` | string | Override the app project file determined by 'react-native config', i.e. `windows\myApp\myApp.vcxproj` |
107
+ | `--msbuildprops` | string | Comma separated props to pass to MSBuild, i.e. `prop1=value1,prop2=value2` |
108
+ | `--buildLogDirectory` | string | Optional directory where MSBuild log files should be stored |
109
+ | `--info` | boolean | Dump environment information |
110
+ | `--direct-debugging` | number | Enable direct debugging on specified port |
111
+ | `--no-telemetry` | boolean | Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI |
112
+ | `-h`, `--help` | boolean | Display help for command |
43
113
 
44
114
  ## Data Collection
45
115
  The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
46
116
 
47
- This data collection notice only applies to the process of running the react-native-windows CLI (run-windows and related tools like autolinking).
117
+ This data collection notice only applies to the process of running the react-native-windows CLI (i.e. the commands above).
@@ -654,7 +654,7 @@ exports.autolinkWindowsInternal = autolinkWindowsInternal;
654
654
  */
655
655
  exports.autolinkCommand = {
656
656
  name: 'autolink-windows',
657
- description: 'Runs Windows-specific autolinking',
657
+ description: 'Runs Windows-specific autolinking for your RNW project',
658
658
  func: autolinkWindows,
659
659
  options: autolinkWindowsOptions_1.autolinkOptions,
660
660
  };
@@ -1 +1 @@
1
- {"version":3,"file":"autolinkWindows.js","sourceRoot":"","sources":["../../../src/commands/autolinkWindows/autolinkWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6EAA6E;AAC7E,6EAA6E;AAC7E,0BAA0B;AAC1B,gEAAgE;AAEhE,kEAA0C;AAC1C,gDAAwB;AACxB,kDAA0B;AAC1B,2CAAuC;AACvC,2CAA6C;AAE7C,MAAM,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAQ3C,+DAAsE;AACtE,qEAA0E;AAE1E,yEAGyC;AACzC,6DAA+C;AAC/C,wEAA0D;AAC1D,mEAAqD;AACrD,qEAAuD;AACvD,mEAIsC;AAOtC,MAAa,eAAe;IAInB,gBAAgB;QACrB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAEO,gBAAgB;QACtB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAEO,eAAe;QACrB,OAAO,cAAI,CAAC,IAAI,CACd,IAAI,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAC9B,IAAI,CAAC,gBAAgB,EAAE,CAAC,SAAS,EACjC,IAAI,CAAC,gBAAgB,EAAE,CAAC,YAAY,CACrC,CAAC;IACJ,CAAC;IAED,YACW,aAA4B,EAC5B,kBAAqD,EACrD,OAAwB;QAFxB,kBAAa,GAAb,aAAa,CAAe;QAC5B,uBAAkB,GAAlB,kBAAkB,CAAmC;QACrD,YAAO,GAAP,OAAO,CAAiB;QAEjC,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC9B,IACE,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,aAAa,CAAC;YAClC,IAAI,CAAC,aAAa,CAAC,OAAO,KAAK,IAAI,EACnC;YACA,MAAM,IAAI,sBAAU,CA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;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;AA5DD,0DA4DC;AAED;;GAEG;AACU,QAAA,eAAe,GAAY;IACtC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,mCAAmC;IAChD,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,wCAAe;CACzB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\n// Types in this file are inaccurate compared to usage in terms of falsiness.\n// We should try to rewrite some of this to do automated schema validation to\n// guarantee correct types\n/* eslint-disable @typescript-eslint/no-unnecessary-condition */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport chalk from 'chalk';\nimport {performance} from 'perf_hooks';\nimport {XMLSerializer} from '@xmldom/xmldom';\nimport {Ora} from 'ora';\nconst formatter = require('xml-formatter');\n\nimport {\n Command,\n Config,\n DependencyConfig,\n ProjectConfig,\n} from '@react-native-community/cli-types';\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport {AutoLinkOptions, autolinkOptions} from './autolinkWindowsOptions';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport * as vstools from '../../utils/vstools';\nimport * as generatorCommon from '../../generator-common';\nimport * as configUtils from '../config/configUtils';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport {\n WindowsDependencyConfig,\n ProjectDependency,\n} from '../config/dependencyConfig';\nimport {Project, WindowsProjectConfig} from '../config/projectConfig';\n\nexport class AutoLinkWindows {\n private changesNecessary: boolean;\n protected windowsAppConfig: WindowsProjectConfig;\n\n public areChangesNeeded() {\n return this.changesNecessary;\n }\n\n private getWindowsConfig() {\n return this.windowsAppConfig;\n }\n\n private getSolutionFile() {\n return path.join(\n this.getWindowsConfig().folder,\n this.getWindowsConfig().sourceDir,\n this.getWindowsConfig().solutionFile,\n );\n }\n\n constructor(\n readonly projectConfig: ProjectConfig,\n readonly dependenciesConfig: {[key: string]: DependencyConfig},\n readonly options: AutoLinkOptions,\n ) {\n this.changesNecessary = false;\n if (\n !('windows' in this.projectConfig) ||\n this.projectConfig.windows === null\n ) {\n throw new CodedError(\n 'NoWindowsConfig',\n 'Windows auto-link only supported on Windows app projects',\n );\n }\n this.windowsAppConfig = projectConfig.windows;\n }\n\n public async run(spinner: Ora) {\n const verbose = this.options.logging;\n\n verboseMessage('', verbose);\n verboseMessage('Parsing project...', verbose);\n\n const rnwRoot = resolveRnwRoot(this.windowsAppConfig);\n const templateRoot = resolveTemplateRoot(this.windowsAppConfig);\n\n this.fixUpForSlnOption();\n this.fixUpForProjOption();\n\n verboseMessage('Found Windows app project, config:', verbose);\n verboseMessage(this.windowsAppConfig, verbose);\n\n this.validateRequiredAppProperties();\n\n const solutionFile = this.getSolutionFile();\n\n const windowsAppProjectConfig = this.windowsAppConfig.project;\n\n this.validateRequiredProjectProperties();\n\n const projectFile = this.getProjectFile();\n\n const projectDir = path.dirname(projectFile);\n const projectLang = windowsAppProjectConfig.projectLang!;\n\n verboseMessage('Parsing dependencies...', verbose);\n\n this.changesNecessary =\n (await this.ensureXAMLDialect()) || this.changesNecessary;\n\n // Generating cs/cpp files for app code consumption\n if (projectLang === 'cs') {\n this.changesNecessary =\n (await this.generateCSAutolinking(\n templateRoot,\n projectLang,\n projectDir,\n )) || this.changesNecessary;\n } else if (projectLang === 'cpp') {\n this.changesNecessary =\n (await this.generateCppAutolinking(\n templateRoot,\n projectLang,\n projectDir,\n )) || this.changesNecessary;\n }\n\n // Generating props for app project consumption\n let propertiesForProps = '';\n let csModuleNames: string[] = [];\n\n if (projectLang === 'cpp') {\n csModuleNames = this.getCSModules();\n\n if (csModuleNames.length > 0) {\n propertiesForProps += `\n <!-- Set due to dependency on C# module(s): ${csModuleNames.join()} -->\n <ConsumeCSharpModules Condition=\"'$(ConsumeCSharpModules)'==''\">true</ConsumeCSharpModules>`;\n }\n }\n\n this.changesNecessary =\n (await this.generateAutolinkProps(\n templateRoot,\n projectDir,\n propertiesForProps,\n )) || this.changesNecessary;\n\n // Generating targets for app project consumption\n this.changesNecessary =\n (await this.generateAutolinkTargets(projectDir, templateRoot)) ||\n this.changesNecessary;\n\n // Generating project entries for solution\n this.changesNecessary =\n this.updateSolution(rnwRoot, solutionFile) || this.changesNecessary;\n\n spinner.succeed();\n }\n\n /**\n * Handles the --proj command-line option by consuming its value into the windowsAppConfig\n */\n public fixUpForProjOption() {\n if (this.options.proj) {\n const projFile = path.join(\n this.windowsAppConfig.folder,\n this.options.proj,\n );\n\n const projectContents = configUtils.readProjectFile(projFile);\n\n this.windowsAppConfig.project = {\n projectFile: path.relative(\n path.join(\n this.windowsAppConfig.folder,\n this.windowsAppConfig.sourceDir,\n ),\n projFile,\n ),\n projectName: configUtils.getProjectName(projFile, projectContents),\n projectLang: configUtils.getProjectLanguage(projFile),\n projectGuid: configUtils.getProjectGuid(projectContents),\n };\n }\n }\n\n /**\n * Handles the --sln command-line option by consuming its value into the windowsAppConfig\n */\n public fixUpForSlnOption() {\n if (this.options.sln) {\n const slnFile = path.join(this.windowsAppConfig.folder, this.options.sln);\n this.windowsAppConfig.solutionFile = path.relative(\n path.join(\n this.windowsAppConfig.folder,\n this.windowsAppConfig.sourceDir,\n ),\n slnFile,\n );\n }\n }\n\n /** Validates the all of the required app (solution) properties are present and valid */\n public validateRequiredAppProperties() {\n const alwaysRequired: Array<keyof WindowsProjectConfig> = [\n 'folder',\n 'sourceDir',\n 'solutionFile',\n 'project',\n ];\n\n alwaysRequired.forEach(item => {\n if (\n !(item in this.windowsAppConfig) ||\n this.windowsAppConfig[item] === null\n ) {\n throw new CodedError(\n 'IncompleteConfig',\n `${item} is required but not specified by react-native config`,\n {item: item},\n );\n } else if (\n typeof this.windowsAppConfig[item] === 'string' &&\n (this.windowsAppConfig[item] as string).startsWith('Error: ')\n ) {\n throw new CodedError(\n 'InvalidConfig',\n `${item} invalid. ${this.windowsAppConfig[item]}`,\n {item: item},\n );\n }\n });\n }\n\n /** @return the full path to the project file (.vcxproj or .csproj) */\n private getProjectFile() {\n const windowsAppConfig = this.getWindowsConfig();\n return path.join(\n windowsAppConfig.folder,\n windowsAppConfig.sourceDir,\n windowsAppConfig.project.projectFile,\n );\n }\n\n /** Validates that all of the required app _project_ properties are present and valid */\n public validateRequiredProjectProperties() {\n const windowsAppProjectConfig = this.windowsAppConfig.project;\n const projectRequired: Array<keyof Project> = [\n 'projectFile',\n 'projectName',\n 'projectLang',\n 'projectGuid',\n ];\n\n projectRequired.forEach(item => {\n if (\n !(item in windowsAppProjectConfig) ||\n windowsAppProjectConfig[item] === null\n ) {\n throw new CodedError(\n 'IncompleteConfig',\n `project.${item} is required but not specified by react-native config`,\n {item: item},\n );\n } else if (\n typeof windowsAppProjectConfig[item] === 'string' &&\n windowsAppProjectConfig[item]!.startsWith('Error: ')\n ) {\n throw new CodedError(\n 'InvalidConfig',\n `project.${item} invalid. ${windowsAppProjectConfig[item]}`,\n {item: item},\n );\n }\n });\n }\n\n private async generateCppAutolinking(\n templateRoot: string,\n projectLang: string,\n projectDir: string,\n ) {\n const {cppPackageProviders, cppIncludes} = this.getCppReplacements();\n\n const cppFileName = 'AutolinkedNativeModules.g.cpp';\n\n const srcCppFile = path.join(\n templateRoot,\n `${projectLang}-app`,\n 'src',\n cppFileName,\n );\n\n const destCppFile = path.join(projectDir, cppFileName);\n\n verboseMessage(\n `Calculating ${chalk.bold(path.basename(destCppFile))}...`,\n this.options.logging,\n );\n\n const cppContents = generatorCommon.resolveContents(srcCppFile, {\n useMustache: true,\n autolinkCppIncludes: cppIncludes,\n autolinkCppPackageProviders: cppPackageProviders,\n });\n\n return await this.updateFile(destCppFile, cppContents);\n }\n\n public getCppReplacements() {\n let cppIncludes = '';\n let cppPackageProviders = '';\n const windowsDependencies = this.getWindowsDependencies();\n\n for (const dependencyName of Object.keys(windowsDependencies)) {\n windowsDependencies[dependencyName].projects.forEach(project => {\n if (project.directDependency) {\n cppIncludes += `\\n\\n// Includes from ${dependencyName}`;\n project.cppHeaders.forEach(header => {\n cppIncludes += `\\n#include <${header}>`;\n });\n\n cppPackageProviders += `\\n // IReactPackageProviders from ${dependencyName}`;\n project.cppPackageProviders.forEach(packageProvider => {\n cppPackageProviders += `\\n packageProviders.Append(winrt::${packageProvider}());`;\n });\n }\n });\n }\n\n if (cppPackageProviders === '') {\n // There are no windows dependencies, this would result in warning. C4100: 'packageProviders': unreferenced formal parameter.\n // therefore add a usage.\n cppPackageProviders = '\\n UNREFERENCED_PARAMETER(packageProviders);'; // CODESYNC: vnext\\local-cli\\generator-windows\\index.js\n }\n return {cppPackageProviders, cppIncludes};\n }\n\n private generateCSAutolinking(\n templateRoot: string,\n projectLang: string,\n projectDir: string,\n ) {\n const {csUsingNamespaces, csReactPackageProviders} =\n this.getCsReplacements();\n\n const csFileName = 'AutolinkedNativeModules.g.cs';\n\n const srcCsFile = path.join(\n templateRoot,\n `${projectLang}-app`,\n 'src',\n csFileName,\n );\n\n const destCsFile = path.join(projectDir, csFileName);\n\n verboseMessage(\n `Calculating ${chalk.bold(path.basename(destCsFile))}...`,\n this.options.logging,\n );\n\n const csContents = generatorCommon.resolveContents(srcCsFile, {\n useMustache: true,\n autolinkCsUsingNamespaces: csUsingNamespaces,\n autolinkCsReactPackageProviders: csReactPackageProviders,\n });\n\n return this.updateFile(destCsFile, csContents);\n }\n\n public getCsReplacements() {\n let csUsingNamespaces = '';\n let csReactPackageProviders = '';\n\n const windowsDependencies = this.getWindowsDependencies();\n for (const dependencyName of Object.keys(windowsDependencies)) {\n windowsDependencies[dependencyName].projects.forEach(project => {\n if (project.directDependency) {\n csUsingNamespaces += `\\n\\n// Namespaces from ${dependencyName}`;\n project.csNamespaces.forEach(namespace => {\n csUsingNamespaces += `\\nusing ${namespace};`;\n });\n\n csReactPackageProviders += `\\n // IReactPackageProviders from ${dependencyName}`;\n project.csPackageProviders.forEach(packageProvider => {\n csReactPackageProviders += `\\n packageProviders.Add(new ${packageProvider}());`;\n });\n }\n });\n }\n return {csUsingNamespaces, csReactPackageProviders};\n }\n\n /** Cache of dependencies */\n private windowsDependencies:\n | Record<string, WindowsDependencyConfig>\n | undefined;\n\n private getWindowsDependencies() {\n if (!this.windowsDependencies) {\n this.windowsDependencies = {};\n for (const dependencyName of Object.keys(this.dependenciesConfig)) {\n const windowsDependency: WindowsDependencyConfig | undefined =\n this.dependenciesConfig[dependencyName].platforms.windows;\n\n if (windowsDependency) {\n verboseMessage(\n `${chalk.bold(dependencyName)} has Windows implementation, config:`,\n this.options.logging,\n );\n verboseMessage(windowsDependency, this.options.logging);\n\n let dependencyIsValid = false;\n\n const hasValidSourceDir =\n 'sourceDir' in windowsDependency &&\n windowsDependency.sourceDir !== undefined &&\n !windowsDependency.sourceDir.startsWith('Error: ');\n\n const hasProjectsInProjectsArray =\n 'projects' in windowsDependency &&\n Array.isArray(windowsDependency.projects) &&\n windowsDependency.projects.length > 0;\n\n if (hasValidSourceDir && hasProjectsInProjectsArray) {\n // Module is source-based and has projects\n dependencyIsValid = true;\n\n // Validate each source project\n windowsDependency.projects.forEach(project => {\n const itemsToCheck: Array<keyof ProjectDependency> = [\n 'projectFile',\n 'directDependency',\n ];\n itemsToCheck.forEach(item => {\n dependencyIsValid = !!(\n dependencyIsValid &&\n item in project &&\n project[item] !== '' &&\n !project[item]!.toString().startsWith('Error: ')\n );\n });\n });\n }\n\n if (dependencyIsValid) {\n verboseMessage(\n `Adding ${chalk.bold(dependencyName)}.`,\n this.options.logging,\n );\n this.windowsDependencies[dependencyName] = windowsDependency;\n } else {\n verboseMessage(\n `Invalid dependency configuration for dependency ${dependencyName}`,\n this.options.logging,\n );\n }\n }\n }\n }\n return this.windowsDependencies;\n }\n\n /**\n * Updates the target file with the expected contents if it's different.\n * @param filePath Path to the target file to update.\n * @param expectedContents The expected contents of the file.\n * @return Whether any changes were necessary.\n */\n protected async updateFile(filePath: string, expectedContents: string) {\n const fileName = chalk.bold(path.basename(filePath));\n verboseMessage(`Reading ${fileName}...`, this.options.logging);\n const actualContents = fs.existsSync(filePath)\n ? (await fs.readFile(filePath)).toString()\n : '';\n\n const contentsChanged = expectedContents !== actualContents;\n\n if (contentsChanged) {\n verboseMessage(\n chalk.yellow(`${fileName} needs to be updated.`),\n this.options.logging,\n );\n if (!this.options.check) {\n verboseMessage(`Writing ${fileName}...`, this.options.logging);\n await fs.writeFile(filePath, expectedContents, {\n encoding: 'utf8',\n flag: 'w',\n });\n }\n } else {\n verboseMessage(`No changes to ${fileName}.`, this.options.logging);\n }\n\n return contentsChanged;\n }\n\n private generateAutolinkTargets(projectDir: string, templateRoot: string) {\n let projectReferencesForTargets = '';\n\n const windowsDependencies = this.getWindowsDependencies();\n for (const dependencyName of Object.keys(windowsDependencies)) {\n windowsDependencies[dependencyName].projects.forEach(project => {\n if (project.directDependency) {\n const dependencyProjectFile = path.join(\n windowsDependencies[dependencyName].folder,\n windowsDependencies[dependencyName].sourceDir!,\n project.projectFile,\n );\n\n const relDependencyProjectFile = path.relative(\n projectDir,\n dependencyProjectFile,\n );\n\n projectReferencesForTargets += `\n <!-- Projects from ${dependencyName} -->\n <ProjectReference Include=\"$(ProjectDir)${relDependencyProjectFile}\">\n <Project>${project.projectGuid}</Project>\n </ProjectReference>`;\n }\n });\n }\n\n const targetFileName = 'AutolinkedNativeModules.g.targets';\n\n const srcTargetFile = path.join(\n templateRoot,\n `shared-app`,\n 'src',\n targetFileName,\n );\n\n const destTargetFile = path.join(projectDir, targetFileName);\n\n verboseMessage(\n `Calculating ${chalk.bold(path.basename(destTargetFile))}...`,\n this.options.logging,\n );\n\n const targetContents = generatorCommon.resolveContents(srcTargetFile, {\n useMustache: true,\n autolinkProjectReferencesForTargets: projectReferencesForTargets,\n });\n\n return this.updateFile(destTargetFile, targetContents);\n }\n\n private generateAutolinkProps(\n templateRoot: string,\n projectDir: string,\n propertiesForProps: string,\n ) {\n const propsFileName = 'AutolinkedNativeModules.g.props';\n\n const srcPropsFile = path.join(\n templateRoot,\n `shared-app`,\n 'src',\n propsFileName,\n );\n\n const destPropsFile = path.join(projectDir, propsFileName);\n\n verboseMessage(\n `Calculating ${chalk.bold(path.basename(destPropsFile))}...`,\n this.options.logging,\n );\n\n const propsContents = generatorCommon.resolveContents(srcPropsFile, {\n useMustache: true,\n autolinkPropertiesForProps: propertiesForProps,\n });\n\n return this.updateFile(destPropsFile, propsContents);\n }\n\n private getCSModules() {\n const csModuleNames: string[] = [];\n const windowsDependencies = this.getWindowsDependencies();\n for (const dependencyName of Object.keys(windowsDependencies)) {\n windowsDependencies[dependencyName].projects.forEach(project => {\n if (project.directDependency && project.projectLang === 'cs') {\n csModuleNames.push(project.projectName);\n }\n });\n }\n return csModuleNames;\n }\n\n private updateSolution(rnwRoot: string, solutionFile: string) {\n const projectsForSolution: Project[] = [];\n const windowsDependencies = this.getWindowsDependencies();\n\n for (const dependencyName of Object.keys(windowsDependencies)) {\n // Process dependency projects\n windowsDependencies[dependencyName].projects.forEach(project => {\n const dependencyProjectFile = path.join(\n windowsDependencies[dependencyName].folder,\n windowsDependencies[dependencyName].sourceDir!,\n project.projectFile,\n );\n\n projectsForSolution.push({\n projectFile: dependencyProjectFile,\n projectName: project.projectName,\n projectLang: project.projectLang,\n projectGuid: project.projectGuid,\n });\n });\n }\n\n const csModuleNames = this.getCSModules();\n if (csModuleNames.length > 0) {\n // Add managed projects\n projectsForSolution.push({\n projectFile: path.join(\n rnwRoot,\n 'Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj',\n ),\n projectName: 'Microsoft.ReactNative.Managed',\n projectLang: 'cs',\n projectGuid: '{F2824844-CE15-4242-9420-308923CD76C3}',\n });\n projectsForSolution.push({\n projectFile: path.join(\n rnwRoot,\n 'Microsoft.ReactNative.Managed.CodeGen//Microsoft.ReactNative.Managed.CodeGen.csproj',\n ),\n projectName: 'Microsoft.ReactNative.Managed.CodeGen',\n projectLang: 'cs',\n projectGuid: '{ADED4FBE-887D-4271-AF24-F0823BCE7961}',\n projectTypeGuid: vstools.dotNetCoreProjectTypeGuid,\n });\n }\n\n verboseMessage(\n `Calculating ${chalk.bold(path.basename(solutionFile))} changes...`,\n this.options.logging,\n );\n\n let changesNecessary = false;\n projectsForSolution.forEach(project => {\n const contentsChanged = vstools.addProjectToSolution(\n solutionFile,\n project,\n this.options.logging,\n this.options.check,\n );\n changesNecessary = changesNecessary || contentsChanged;\n });\n return changesNecessary;\n }\n\n protected getExperimentalFeaturesPropsXml() {\n const experimentalFeaturesProps = path.join(\n path.dirname(this.getSolutionFile()),\n 'ExperimentalFeatures.props',\n );\n if (fs.existsSync(experimentalFeaturesProps)) {\n const experimentalFeaturesContents = configUtils.readProjectFile(\n experimentalFeaturesProps,\n );\n return {\n path: experimentalFeaturesProps,\n content: experimentalFeaturesContents,\n };\n }\n return undefined;\n }\n\n public async ensureXAMLDialect() {\n let changesNeeded = false;\n const useWinUI3FromConfig = this.getWindowsConfig().useWinUI3;\n const experimentalFeatures = this.getExperimentalFeaturesPropsXml();\n if (experimentalFeatures) {\n const useWinUI3FromExperimentalFeatures =\n configUtils\n .tryFindPropertyValue(experimentalFeatures.content, 'UseWinUI3')\n ?.toLowerCase() === 'true';\n // Check if WinUI2xVersion is specified in experimental features\n const targetWinUI2xVersion = configUtils.tryFindPropertyValue(\n experimentalFeatures.content,\n 'WinUI2xVersion',\n );\n // Check if WinUI3Version is specified in experimental features\n const targetWinUI3xVersion = configUtils.tryFindPropertyValue(\n experimentalFeatures.content,\n 'WinUI3Version',\n );\n // Use the UseWinUI3 value in react-native.config.js, or if not present, the value from ExperimentalFeatures.props\n changesNeeded = await this.updatePackagesConfigXAMLDialect(\n useWinUI3FromConfig !== undefined\n ? useWinUI3FromConfig\n : useWinUI3FromExperimentalFeatures,\n targetWinUI2xVersion,\n targetWinUI3xVersion,\n );\n if (useWinUI3FromConfig !== undefined) {\n // Make sure ExperimentalFeatures.props matches the value that comes from react-native.config.js\n const node =\n experimentalFeatures.content.getElementsByTagName('UseWinUI3');\n const newValue = useWinUI3FromConfig ? 'true' : 'false';\n changesNeeded = node.item(0)?.textContent !== newValue || changesNeeded;\n if (!this.options.check && changesNeeded) {\n node.item(0)!.textContent = newValue;\n const experimentalFeaturesOutput =\n new XMLSerializer().serializeToString(experimentalFeatures.content);\n await this.updateFile(\n experimentalFeatures.path,\n experimentalFeaturesOutput,\n );\n }\n }\n }\n return changesNeeded;\n }\n\n protected getPackagesConfigXml() {\n const projectFile = this.getProjectFile();\n const packagesConfig = path.join(\n path.dirname(projectFile),\n 'packages.config',\n );\n\n if (fs.existsSync(packagesConfig)) {\n return {\n path: packagesConfig,\n content: configUtils.readProjectFile(packagesConfig),\n };\n }\n return undefined;\n }\n\n private async updatePackagesConfigXAMLDialect(\n useWinUI3: boolean,\n targetWinUI2xVersion: string | null,\n targetWinUI3xVersion: string | null,\n ) {\n let changed = false;\n const packagesConfig = this.getPackagesConfigXml();\n if (packagesConfig) {\n // if we don't have a packages.config, then this is a C# project, in which case we use <PackageReference> and dynamically pick the right XAML package.\n const project = this.getWindowsConfig();\n\n const winUIPropsPath = path.join(\n resolveRnwRoot(project),\n 'PropertySheets/WinUI.props',\n );\n const winuiPropsContents = configUtils.readProjectFile(winUIPropsPath);\n\n // Use the given WinUI2xVersion, otherwise fallback to WinUI.props\n const winui2xVersion =\n targetWinUI2xVersion ??\n configUtils.tryFindPropertyValue(winuiPropsContents, 'WinUI2xVersion');\n\n // Use the given WinUI3Version, otherwise fallback to WinUI.props\n const winui3Version =\n targetWinUI3xVersion ??\n configUtils.tryFindPropertyValue(winuiPropsContents, 'WinUI3Version');\n\n const dialects = [\n {id: 'Microsoft.WindowsAppSDK', version: winui3Version!},\n {id: 'Microsoft.UI.Xaml', version: winui2xVersion!},\n ];\n const keepPkg = useWinUI3 ? dialects[0] : dialects[1];\n const removePkg = useWinUI3 ? dialects[1] : dialects[0];\n\n changed = this.updatePackagesConfig(\n packagesConfig,\n [removePkg],\n [keepPkg],\n );\n\n if (!this.options.check && changed) {\n const serializer = new XMLSerializer();\n const output = serializer.serializeToString(packagesConfig.content);\n const formattedXml = formatter(output, {indentation: ' '});\n await this.updateFile(packagesConfig.path, formattedXml);\n }\n }\n return changed;\n }\n\n private updatePackagesConfig(\n packagesConfig: {path: string; content: Document},\n removePkgs: {id: string; version: string}[],\n keepPkgs: {id: string; version: string}[],\n ) {\n let changed = false;\n const packageElements =\n packagesConfig.content.documentElement.getElementsByTagName('package');\n\n const nodesToRemove: Element[] = [];\n\n for (let i = 0; i < packageElements.length; i++) {\n const packageElement = packageElements.item(i)!;\n const idAttr = packageElement!.getAttributeNode('id');\n const id = idAttr!.value;\n const keepPkg = keepPkgs.find(pkg => pkg.id === id);\n if (removePkgs.find(pkg => pkg.id === id)) {\n nodesToRemove.push(packageElement);\n changed = true;\n } else if (keepPkg) {\n changed =\n changed || keepPkg.version !== packageElement.getAttribute('version');\n packageElement.setAttribute('version', keepPkg.version!);\n keepPkgs = keepPkgs.filter(pkg => pkg.id !== keepPkg.id);\n }\n }\n\n nodesToRemove.forEach(pkg =>\n packagesConfig.content.documentElement.removeChild(pkg),\n );\n\n keepPkgs.forEach(keepPkg => {\n const newPkg = packagesConfig.content.createElement('package');\n\n Object.entries(keepPkg).forEach(([attr, value]) => {\n newPkg.setAttribute(attr, value as string);\n });\n newPkg.setAttribute('targetFramework', 'native');\n packagesConfig.content.documentElement.appendChild(newPkg);\n changed = true;\n });\n return changed;\n }\n\n /** @return The CLI command to invoke autolink-windows independently */\n public getAutolinkWindowsCommand() {\n const folder = this.windowsAppConfig.folder;\n\n const autolinkCommand = 'npx react-native autolink-windows';\n const autolinkArgs = `--sln \"${path.relative(\n folder,\n this.getSolutionFile(),\n )}\" --proj \"${path.relative(folder, this.getProjectFile())}\"`;\n return `${autolinkCommand} ${autolinkArgs}`;\n }\n}\n\n/**\n * Locates the react-native-windows directory\n * @param config project configuration\n */\nfunction resolveRnwRoot(projectConfig: WindowsProjectConfig) {\n return pathHelpers.resolveRnwRoot(projectConfig.folder);\n}\n\n/**\n * Locates the react-native-windows directory containing template files\n * @param config project configuration\n */\nfunction resolveTemplateRoot(projectConfig: WindowsProjectConfig) {\n const rnwPackage = resolveRnwRoot(projectConfig);\n return path.join(rnwPackage, 'template');\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 AutoLinkOptions, 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 'sln':\n case 'proj':\n return value === undefined ? false : true; // Strip PII\n case 'logging':\n case 'check':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `autolink-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 `react-native autolink-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 autolinkWindows(\n args: string[],\n config: Config,\n options: AutoLinkOptions,\n) {\n await startTelemetrySession(\n 'autolink-windows',\n config,\n options,\n getDefaultOptions(config, autolinkOptions),\n optionSanitizer,\n );\n\n let autolinkWindowsError: Error | undefined;\n try {\n await autolinkWindowsInternal(args, config, options);\n } catch (ex) {\n autolinkWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(autolinkWindowsError);\n }\n\n await endTelemetrySession(autolinkWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, autolinkWindowsError);\n}\n\n/**\n * Performs auto-linking for RNW native modules and 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 */\nexport async function autolinkWindowsInternal(\n args: string[],\n config: Config,\n options: AutoLinkOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner(\n options.check ? 'Checking auto-linked files...' : 'Auto-linking...',\n );\n try {\n const autolink = new AutoLinkWindows(\n config.project,\n config.dependencies,\n options,\n );\n await autolink.run(spinner);\n const endTime = performance.now();\n\n if (!autolink.areChangesNeeded()) {\n console.log(\n `${chalk.green(\n 'Success:',\n )} No auto-linking changes necessary. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } else if (options.check) {\n const autolinkCommand = autolink.getAutolinkWindowsCommand();\n console.log(\n `${chalk.yellow(\n 'Warning:',\n )} Auto-linking changes were necessary but ${chalk.bold(\n '--check',\n )} specified. Run '${chalk.bold(\n `${autolinkCommand}`,\n )}' to apply the changes. (${Math.round(endTime - startTime)}ms)`,\n );\n throw new CodedError(\n 'NeedAutolinking',\n `Auto-linking changes were necessary but --check was specified. Run '${autolinkCommand}' to apply the changes`,\n );\n } else {\n console.log(\n `${chalk.green(\n 'Success:',\n )} Auto-linking changes completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\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 * Performs auto-linking for RNW native modules and apps.\n */\nexport const autolinkCommand: Command = {\n name: 'autolink-windows',\n description: 'Runs Windows-specific autolinking',\n func: autolinkWindows,\n options: autolinkOptions,\n};\n"]}
1
+ {"version":3,"file":"autolinkWindows.js","sourceRoot":"","sources":["../../../src/commands/autolinkWindows/autolinkWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6EAA6E;AAC7E,6EAA6E;AAC7E,0BAA0B;AAC1B,gEAAgE;AAEhE,kEAA0C;AAC1C,gDAAwB;AACxB,kDAA0B;AAC1B,2CAAuC;AACvC,2CAA6C;AAE7C,MAAM,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAQ3C,+DAAsE;AACtE,qEAA0E;AAE1E,yEAGyC;AACzC,6DAA+C;AAC/C,wEAA0D;AAC1D,mEAAqD;AACrD,qEAAuD;AACvD,mEAIsC;AAOtC,MAAa,eAAe;IAInB,gBAAgB;QACrB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAEO,gBAAgB;QACtB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAEO,eAAe;QACrB,OAAO,cAAI,CAAC,IAAI,CACd,IAAI,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAC9B,IAAI,CAAC,gBAAgB,EAAE,CAAC,SAAS,EACjC,IAAI,CAAC,gBAAgB,EAAE,CAAC,YAAY,CACrC,CAAC;IACJ,CAAC;IAED,YACW,aAA4B,EAC5B,kBAAqD,EACrD,OAAwB;QAFxB,kBAAa,GAAb,aAAa,CAAe;QAC5B,uBAAkB,GAAlB,kBAAkB,CAAmC;QACrD,YAAO,GAAP,OAAO,CAAiB;QAEjC,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC9B,IACE,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,aAAa,CAAC;YAClC,IAAI,CAAC,aAAa,CAAC,OAAO,KAAK,IAAI,EACnC;YACA,MAAM,IAAI,sBAAU,CAClB,iBAAiB,EACjB,0DAA0D,CAC3D,CAAC;SACH;QACD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AAO,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;AA5DD,0DA4DC;AAED;;GAEG;AACU,QAAA,eAAe,GAAY;IACtC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,wDAAwD;IACrE,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,wCAAe;CACzB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\n// Types in this file are inaccurate compared to usage in terms of falsiness.\n// We should try to rewrite some of this to do automated schema validation to\n// guarantee correct types\n/* eslint-disable @typescript-eslint/no-unnecessary-condition */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport chalk from 'chalk';\nimport {performance} from 'perf_hooks';\nimport {XMLSerializer} from '@xmldom/xmldom';\nimport {Ora} from 'ora';\nconst formatter = require('xml-formatter');\n\nimport {\n Command,\n Config,\n DependencyConfig,\n ProjectConfig,\n} from '@react-native-community/cli-types';\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport {AutoLinkOptions, autolinkOptions} from './autolinkWindowsOptions';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport * as vstools from '../../utils/vstools';\nimport * as generatorCommon from '../../generator-common';\nimport * as configUtils from '../config/configUtils';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport {\n WindowsDependencyConfig,\n ProjectDependency,\n} from '../config/dependencyConfig';\nimport {Project, WindowsProjectConfig} from '../config/projectConfig';\n\nexport class AutoLinkWindows {\n private changesNecessary: boolean;\n protected windowsAppConfig: WindowsProjectConfig;\n\n public areChangesNeeded() {\n return this.changesNecessary;\n }\n\n private getWindowsConfig() {\n return this.windowsAppConfig;\n }\n\n private getSolutionFile() {\n return path.join(\n this.getWindowsConfig().folder,\n this.getWindowsConfig().sourceDir,\n this.getWindowsConfig().solutionFile,\n );\n }\n\n constructor(\n readonly projectConfig: ProjectConfig,\n readonly dependenciesConfig: {[key: string]: DependencyConfig},\n readonly options: AutoLinkOptions,\n ) {\n this.changesNecessary = false;\n if (\n !('windows' in this.projectConfig) ||\n this.projectConfig.windows === null\n ) {\n throw new CodedError(\n 'NoWindowsConfig',\n 'Windows auto-link only supported on Windows app projects',\n );\n }\n this.windowsAppConfig = projectConfig.windows;\n }\n\n public async run(spinner: Ora) {\n const verbose = this.options.logging;\n\n verboseMessage('', verbose);\n verboseMessage('Parsing project...', verbose);\n\n const rnwRoot = resolveRnwRoot(this.windowsAppConfig);\n const templateRoot = resolveTemplateRoot(this.windowsAppConfig);\n\n this.fixUpForSlnOption();\n this.fixUpForProjOption();\n\n verboseMessage('Found Windows app project, config:', verbose);\n verboseMessage(this.windowsAppConfig, verbose);\n\n this.validateRequiredAppProperties();\n\n const solutionFile = this.getSolutionFile();\n\n const windowsAppProjectConfig = this.windowsAppConfig.project;\n\n this.validateRequiredProjectProperties();\n\n const projectFile = this.getProjectFile();\n\n const projectDir = path.dirname(projectFile);\n const projectLang = windowsAppProjectConfig.projectLang!;\n\n verboseMessage('Parsing dependencies...', verbose);\n\n this.changesNecessary =\n (await this.ensureXAMLDialect()) || this.changesNecessary;\n\n // Generating cs/cpp files for app code consumption\n if (projectLang === 'cs') {\n this.changesNecessary =\n (await this.generateCSAutolinking(\n templateRoot,\n projectLang,\n projectDir,\n )) || this.changesNecessary;\n } else if (projectLang === 'cpp') {\n this.changesNecessary =\n (await this.generateCppAutolinking(\n templateRoot,\n projectLang,\n projectDir,\n )) || this.changesNecessary;\n }\n\n // Generating props for app project consumption\n let propertiesForProps = '';\n let csModuleNames: string[] = [];\n\n if (projectLang === 'cpp') {\n csModuleNames = this.getCSModules();\n\n if (csModuleNames.length > 0) {\n propertiesForProps += `\n <!-- Set due to dependency on C# module(s): ${csModuleNames.join()} -->\n <ConsumeCSharpModules Condition=\"'$(ConsumeCSharpModules)'==''\">true</ConsumeCSharpModules>`;\n }\n }\n\n this.changesNecessary =\n (await this.generateAutolinkProps(\n templateRoot,\n projectDir,\n propertiesForProps,\n )) || this.changesNecessary;\n\n // Generating targets for app project consumption\n this.changesNecessary =\n (await this.generateAutolinkTargets(projectDir, templateRoot)) ||\n this.changesNecessary;\n\n // Generating project entries for solution\n this.changesNecessary =\n this.updateSolution(rnwRoot, solutionFile) || this.changesNecessary;\n\n spinner.succeed();\n }\n\n /**\n * Handles the --proj command-line option by consuming its value into the windowsAppConfig\n */\n public fixUpForProjOption() {\n if (this.options.proj) {\n const projFile = path.join(\n this.windowsAppConfig.folder,\n this.options.proj,\n );\n\n const projectContents = configUtils.readProjectFile(projFile);\n\n this.windowsAppConfig.project = {\n projectFile: path.relative(\n path.join(\n this.windowsAppConfig.folder,\n this.windowsAppConfig.sourceDir,\n ),\n projFile,\n ),\n projectName: configUtils.getProjectName(projFile, projectContents),\n projectLang: configUtils.getProjectLanguage(projFile),\n projectGuid: configUtils.getProjectGuid(projectContents),\n };\n }\n }\n\n /**\n * Handles the --sln command-line option by consuming its value into the windowsAppConfig\n */\n public fixUpForSlnOption() {\n if (this.options.sln) {\n const slnFile = path.join(this.windowsAppConfig.folder, this.options.sln);\n this.windowsAppConfig.solutionFile = path.relative(\n path.join(\n this.windowsAppConfig.folder,\n this.windowsAppConfig.sourceDir,\n ),\n slnFile,\n );\n }\n }\n\n /** Validates the all of the required app (solution) properties are present and valid */\n public validateRequiredAppProperties() {\n const alwaysRequired: Array<keyof WindowsProjectConfig> = [\n 'folder',\n 'sourceDir',\n 'solutionFile',\n 'project',\n ];\n\n alwaysRequired.forEach(item => {\n if (\n !(item in this.windowsAppConfig) ||\n this.windowsAppConfig[item] === null\n ) {\n throw new CodedError(\n 'IncompleteConfig',\n `${item} is required but not specified by react-native config`,\n {item: item},\n );\n } else if (\n typeof this.windowsAppConfig[item] === 'string' &&\n (this.windowsAppConfig[item] as string).startsWith('Error: ')\n ) {\n throw new CodedError(\n 'InvalidConfig',\n `${item} invalid. ${this.windowsAppConfig[item]}`,\n {item: item},\n );\n }\n });\n }\n\n /** @return the full path to the project file (.vcxproj or .csproj) */\n private getProjectFile() {\n const windowsAppConfig = this.getWindowsConfig();\n return path.join(\n windowsAppConfig.folder,\n windowsAppConfig.sourceDir,\n windowsAppConfig.project.projectFile,\n );\n }\n\n /** Validates that all of the required app _project_ properties are present and valid */\n public validateRequiredProjectProperties() {\n const windowsAppProjectConfig = this.windowsAppConfig.project;\n const projectRequired: Array<keyof Project> = [\n 'projectFile',\n 'projectName',\n 'projectLang',\n 'projectGuid',\n ];\n\n projectRequired.forEach(item => {\n if (\n !(item in windowsAppProjectConfig) ||\n windowsAppProjectConfig[item] === null\n ) {\n throw new CodedError(\n 'IncompleteConfig',\n `project.${item} is required but not specified by react-native config`,\n {item: item},\n );\n } else if (\n typeof windowsAppProjectConfig[item] === 'string' &&\n windowsAppProjectConfig[item]!.startsWith('Error: ')\n ) {\n throw new CodedError(\n 'InvalidConfig',\n `project.${item} invalid. ${windowsAppProjectConfig[item]}`,\n {item: item},\n );\n }\n });\n }\n\n private async generateCppAutolinking(\n templateRoot: string,\n projectLang: string,\n projectDir: string,\n ) {\n const {cppPackageProviders, cppIncludes} = this.getCppReplacements();\n\n const cppFileName = 'AutolinkedNativeModules.g.cpp';\n\n const srcCppFile = path.join(\n templateRoot,\n `${projectLang}-app`,\n 'src',\n cppFileName,\n );\n\n const destCppFile = path.join(projectDir, cppFileName);\n\n verboseMessage(\n `Calculating ${chalk.bold(path.basename(destCppFile))}...`,\n this.options.logging,\n );\n\n const cppContents = generatorCommon.resolveContents(srcCppFile, {\n useMustache: true,\n autolinkCppIncludes: cppIncludes,\n autolinkCppPackageProviders: cppPackageProviders,\n });\n\n return await this.updateFile(destCppFile, cppContents);\n }\n\n public getCppReplacements() {\n let cppIncludes = '';\n let cppPackageProviders = '';\n const windowsDependencies = this.getWindowsDependencies();\n\n for (const dependencyName of Object.keys(windowsDependencies)) {\n windowsDependencies[dependencyName].projects.forEach(project => {\n if (project.directDependency) {\n cppIncludes += `\\n\\n// Includes from ${dependencyName}`;\n project.cppHeaders.forEach(header => {\n cppIncludes += `\\n#include <${header}>`;\n });\n\n cppPackageProviders += `\\n // IReactPackageProviders from ${dependencyName}`;\n project.cppPackageProviders.forEach(packageProvider => {\n cppPackageProviders += `\\n packageProviders.Append(winrt::${packageProvider}());`;\n });\n }\n });\n }\n\n if (cppPackageProviders === '') {\n // There are no windows dependencies, this would result in warning. C4100: 'packageProviders': unreferenced formal parameter.\n // therefore add a usage.\n cppPackageProviders = '\\n UNREFERENCED_PARAMETER(packageProviders);'; // CODESYNC: vnext\\local-cli\\generator-windows\\index.js\n }\n return {cppPackageProviders, cppIncludes};\n }\n\n private generateCSAutolinking(\n templateRoot: string,\n projectLang: string,\n projectDir: string,\n ) {\n const {csUsingNamespaces, csReactPackageProviders} =\n this.getCsReplacements();\n\n const csFileName = 'AutolinkedNativeModules.g.cs';\n\n const srcCsFile = path.join(\n templateRoot,\n `${projectLang}-app`,\n 'src',\n csFileName,\n );\n\n const destCsFile = path.join(projectDir, csFileName);\n\n verboseMessage(\n `Calculating ${chalk.bold(path.basename(destCsFile))}...`,\n this.options.logging,\n );\n\n const csContents = generatorCommon.resolveContents(srcCsFile, {\n useMustache: true,\n autolinkCsUsingNamespaces: csUsingNamespaces,\n autolinkCsReactPackageProviders: csReactPackageProviders,\n });\n\n return this.updateFile(destCsFile, csContents);\n }\n\n public getCsReplacements() {\n let csUsingNamespaces = '';\n let csReactPackageProviders = '';\n\n const windowsDependencies = this.getWindowsDependencies();\n for (const dependencyName of Object.keys(windowsDependencies)) {\n windowsDependencies[dependencyName].projects.forEach(project => {\n if (project.directDependency) {\n csUsingNamespaces += `\\n\\n// Namespaces from ${dependencyName}`;\n project.csNamespaces.forEach(namespace => {\n csUsingNamespaces += `\\nusing ${namespace};`;\n });\n\n csReactPackageProviders += `\\n // IReactPackageProviders from ${dependencyName}`;\n project.csPackageProviders.forEach(packageProvider => {\n csReactPackageProviders += `\\n packageProviders.Add(new ${packageProvider}());`;\n });\n }\n });\n }\n return {csUsingNamespaces, csReactPackageProviders};\n }\n\n /** Cache of dependencies */\n private windowsDependencies:\n | Record<string, WindowsDependencyConfig>\n | undefined;\n\n private getWindowsDependencies() {\n if (!this.windowsDependencies) {\n this.windowsDependencies = {};\n for (const dependencyName of Object.keys(this.dependenciesConfig)) {\n const windowsDependency: WindowsDependencyConfig | undefined =\n this.dependenciesConfig[dependencyName].platforms.windows;\n\n if (windowsDependency) {\n verboseMessage(\n `${chalk.bold(dependencyName)} has Windows implementation, config:`,\n this.options.logging,\n );\n verboseMessage(windowsDependency, this.options.logging);\n\n let dependencyIsValid = false;\n\n const hasValidSourceDir =\n 'sourceDir' in windowsDependency &&\n windowsDependency.sourceDir !== undefined &&\n !windowsDependency.sourceDir.startsWith('Error: ');\n\n const hasProjectsInProjectsArray =\n 'projects' in windowsDependency &&\n Array.isArray(windowsDependency.projects) &&\n windowsDependency.projects.length > 0;\n\n if (hasValidSourceDir && hasProjectsInProjectsArray) {\n // Module is source-based and has projects\n dependencyIsValid = true;\n\n // Validate each source project\n windowsDependency.projects.forEach(project => {\n const itemsToCheck: Array<keyof ProjectDependency> = [\n 'projectFile',\n 'directDependency',\n ];\n itemsToCheck.forEach(item => {\n dependencyIsValid = !!(\n dependencyIsValid &&\n item in project &&\n project[item] !== '' &&\n !project[item]!.toString().startsWith('Error: ')\n );\n });\n });\n }\n\n if (dependencyIsValid) {\n verboseMessage(\n `Adding ${chalk.bold(dependencyName)}.`,\n this.options.logging,\n );\n this.windowsDependencies[dependencyName] = windowsDependency;\n } else {\n verboseMessage(\n `Invalid dependency configuration for dependency ${dependencyName}`,\n this.options.logging,\n );\n }\n }\n }\n }\n return this.windowsDependencies;\n }\n\n /**\n * Updates the target file with the expected contents if it's different.\n * @param filePath Path to the target file to update.\n * @param expectedContents The expected contents of the file.\n * @return Whether any changes were necessary.\n */\n protected async updateFile(filePath: string, expectedContents: string) {\n const fileName = chalk.bold(path.basename(filePath));\n verboseMessage(`Reading ${fileName}...`, this.options.logging);\n const actualContents = fs.existsSync(filePath)\n ? (await fs.readFile(filePath)).toString()\n : '';\n\n const contentsChanged = expectedContents !== actualContents;\n\n if (contentsChanged) {\n verboseMessage(\n chalk.yellow(`${fileName} needs to be updated.`),\n this.options.logging,\n );\n if (!this.options.check) {\n verboseMessage(`Writing ${fileName}...`, this.options.logging);\n await fs.writeFile(filePath, expectedContents, {\n encoding: 'utf8',\n flag: 'w',\n });\n }\n } else {\n verboseMessage(`No changes to ${fileName}.`, this.options.logging);\n }\n\n return contentsChanged;\n }\n\n private generateAutolinkTargets(projectDir: string, templateRoot: string) {\n let projectReferencesForTargets = '';\n\n const windowsDependencies = this.getWindowsDependencies();\n for (const dependencyName of Object.keys(windowsDependencies)) {\n windowsDependencies[dependencyName].projects.forEach(project => {\n if (project.directDependency) {\n const dependencyProjectFile = path.join(\n windowsDependencies[dependencyName].folder,\n windowsDependencies[dependencyName].sourceDir!,\n project.projectFile,\n );\n\n const relDependencyProjectFile = path.relative(\n projectDir,\n dependencyProjectFile,\n );\n\n projectReferencesForTargets += `\n <!-- Projects from ${dependencyName} -->\n <ProjectReference Include=\"$(ProjectDir)${relDependencyProjectFile}\">\n <Project>${project.projectGuid}</Project>\n </ProjectReference>`;\n }\n });\n }\n\n const targetFileName = 'AutolinkedNativeModules.g.targets';\n\n const srcTargetFile = path.join(\n templateRoot,\n `shared-app`,\n 'src',\n targetFileName,\n );\n\n const destTargetFile = path.join(projectDir, targetFileName);\n\n verboseMessage(\n `Calculating ${chalk.bold(path.basename(destTargetFile))}...`,\n this.options.logging,\n );\n\n const targetContents = generatorCommon.resolveContents(srcTargetFile, {\n useMustache: true,\n autolinkProjectReferencesForTargets: projectReferencesForTargets,\n });\n\n return this.updateFile(destTargetFile, targetContents);\n }\n\n private generateAutolinkProps(\n templateRoot: string,\n projectDir: string,\n propertiesForProps: string,\n ) {\n const propsFileName = 'AutolinkedNativeModules.g.props';\n\n const srcPropsFile = path.join(\n templateRoot,\n `shared-app`,\n 'src',\n propsFileName,\n );\n\n const destPropsFile = path.join(projectDir, propsFileName);\n\n verboseMessage(\n `Calculating ${chalk.bold(path.basename(destPropsFile))}...`,\n this.options.logging,\n );\n\n const propsContents = generatorCommon.resolveContents(srcPropsFile, {\n useMustache: true,\n autolinkPropertiesForProps: propertiesForProps,\n });\n\n return this.updateFile(destPropsFile, propsContents);\n }\n\n private getCSModules() {\n const csModuleNames: string[] = [];\n const windowsDependencies = this.getWindowsDependencies();\n for (const dependencyName of Object.keys(windowsDependencies)) {\n windowsDependencies[dependencyName].projects.forEach(project => {\n if (project.directDependency && project.projectLang === 'cs') {\n csModuleNames.push(project.projectName);\n }\n });\n }\n return csModuleNames;\n }\n\n private updateSolution(rnwRoot: string, solutionFile: string) {\n const projectsForSolution: Project[] = [];\n const windowsDependencies = this.getWindowsDependencies();\n\n for (const dependencyName of Object.keys(windowsDependencies)) {\n // Process dependency projects\n windowsDependencies[dependencyName].projects.forEach(project => {\n const dependencyProjectFile = path.join(\n windowsDependencies[dependencyName].folder,\n windowsDependencies[dependencyName].sourceDir!,\n project.projectFile,\n );\n\n projectsForSolution.push({\n projectFile: dependencyProjectFile,\n projectName: project.projectName,\n projectLang: project.projectLang,\n projectGuid: project.projectGuid,\n });\n });\n }\n\n const csModuleNames = this.getCSModules();\n if (csModuleNames.length > 0) {\n // Add managed projects\n projectsForSolution.push({\n projectFile: path.join(\n rnwRoot,\n 'Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj',\n ),\n projectName: 'Microsoft.ReactNative.Managed',\n projectLang: 'cs',\n projectGuid: '{F2824844-CE15-4242-9420-308923CD76C3}',\n });\n projectsForSolution.push({\n projectFile: path.join(\n rnwRoot,\n 'Microsoft.ReactNative.Managed.CodeGen//Microsoft.ReactNative.Managed.CodeGen.csproj',\n ),\n projectName: 'Microsoft.ReactNative.Managed.CodeGen',\n projectLang: 'cs',\n projectGuid: '{ADED4FBE-887D-4271-AF24-F0823BCE7961}',\n projectTypeGuid: vstools.dotNetCoreProjectTypeGuid,\n });\n }\n\n verboseMessage(\n `Calculating ${chalk.bold(path.basename(solutionFile))} changes...`,\n this.options.logging,\n );\n\n let changesNecessary = false;\n projectsForSolution.forEach(project => {\n const contentsChanged = vstools.addProjectToSolution(\n solutionFile,\n project,\n this.options.logging,\n this.options.check,\n );\n changesNecessary = changesNecessary || contentsChanged;\n });\n return changesNecessary;\n }\n\n protected getExperimentalFeaturesPropsXml() {\n const experimentalFeaturesProps = path.join(\n path.dirname(this.getSolutionFile()),\n 'ExperimentalFeatures.props',\n );\n if (fs.existsSync(experimentalFeaturesProps)) {\n const experimentalFeaturesContents = configUtils.readProjectFile(\n experimentalFeaturesProps,\n );\n return {\n path: experimentalFeaturesProps,\n content: experimentalFeaturesContents,\n };\n }\n return undefined;\n }\n\n public async ensureXAMLDialect() {\n let changesNeeded = false;\n const useWinUI3FromConfig = this.getWindowsConfig().useWinUI3;\n const experimentalFeatures = this.getExperimentalFeaturesPropsXml();\n if (experimentalFeatures) {\n const useWinUI3FromExperimentalFeatures =\n configUtils\n .tryFindPropertyValue(experimentalFeatures.content, 'UseWinUI3')\n ?.toLowerCase() === 'true';\n // Check if WinUI2xVersion is specified in experimental features\n const targetWinUI2xVersion = configUtils.tryFindPropertyValue(\n experimentalFeatures.content,\n 'WinUI2xVersion',\n );\n // Check if WinUI3Version is specified in experimental features\n const targetWinUI3xVersion = configUtils.tryFindPropertyValue(\n experimentalFeatures.content,\n 'WinUI3Version',\n );\n // Use the UseWinUI3 value in react-native.config.js, or if not present, the value from ExperimentalFeatures.props\n changesNeeded = await this.updatePackagesConfigXAMLDialect(\n useWinUI3FromConfig !== undefined\n ? useWinUI3FromConfig\n : useWinUI3FromExperimentalFeatures,\n targetWinUI2xVersion,\n targetWinUI3xVersion,\n );\n if (useWinUI3FromConfig !== undefined) {\n // Make sure ExperimentalFeatures.props matches the value that comes from react-native.config.js\n const node =\n experimentalFeatures.content.getElementsByTagName('UseWinUI3');\n const newValue = useWinUI3FromConfig ? 'true' : 'false';\n changesNeeded = node.item(0)?.textContent !== newValue || changesNeeded;\n if (!this.options.check && changesNeeded) {\n node.item(0)!.textContent = newValue;\n const experimentalFeaturesOutput =\n new XMLSerializer().serializeToString(experimentalFeatures.content);\n await this.updateFile(\n experimentalFeatures.path,\n experimentalFeaturesOutput,\n );\n }\n }\n }\n return changesNeeded;\n }\n\n protected getPackagesConfigXml() {\n const projectFile = this.getProjectFile();\n const packagesConfig = path.join(\n path.dirname(projectFile),\n 'packages.config',\n );\n\n if (fs.existsSync(packagesConfig)) {\n return {\n path: packagesConfig,\n content: configUtils.readProjectFile(packagesConfig),\n };\n }\n return undefined;\n }\n\n private async updatePackagesConfigXAMLDialect(\n useWinUI3: boolean,\n targetWinUI2xVersion: string | null,\n targetWinUI3xVersion: string | null,\n ) {\n let changed = false;\n const packagesConfig = this.getPackagesConfigXml();\n if (packagesConfig) {\n // if we don't have a packages.config, then this is a C# project, in which case we use <PackageReference> and dynamically pick the right XAML package.\n const project = this.getWindowsConfig();\n\n const winUIPropsPath = path.join(\n resolveRnwRoot(project),\n 'PropertySheets/WinUI.props',\n );\n const winuiPropsContents = configUtils.readProjectFile(winUIPropsPath);\n\n // Use the given WinUI2xVersion, otherwise fallback to WinUI.props\n const winui2xVersion =\n targetWinUI2xVersion ??\n configUtils.tryFindPropertyValue(winuiPropsContents, 'WinUI2xVersion');\n\n // Use the given WinUI3Version, otherwise fallback to WinUI.props\n const winui3Version =\n targetWinUI3xVersion ??\n configUtils.tryFindPropertyValue(winuiPropsContents, 'WinUI3Version');\n\n const dialects = [\n {id: 'Microsoft.WindowsAppSDK', version: winui3Version!},\n {id: 'Microsoft.UI.Xaml', version: winui2xVersion!},\n ];\n const keepPkg = useWinUI3 ? dialects[0] : dialects[1];\n const removePkg = useWinUI3 ? dialects[1] : dialects[0];\n\n changed = this.updatePackagesConfig(\n packagesConfig,\n [removePkg],\n [keepPkg],\n );\n\n if (!this.options.check && changed) {\n const serializer = new XMLSerializer();\n const output = serializer.serializeToString(packagesConfig.content);\n const formattedXml = formatter(output, {indentation: ' '});\n await this.updateFile(packagesConfig.path, formattedXml);\n }\n }\n return changed;\n }\n\n private updatePackagesConfig(\n packagesConfig: {path: string; content: Document},\n removePkgs: {id: string; version: string}[],\n keepPkgs: {id: string; version: string}[],\n ) {\n let changed = false;\n const packageElements =\n packagesConfig.content.documentElement.getElementsByTagName('package');\n\n const nodesToRemove: Element[] = [];\n\n for (let i = 0; i < packageElements.length; i++) {\n const packageElement = packageElements.item(i)!;\n const idAttr = packageElement!.getAttributeNode('id');\n const id = idAttr!.value;\n const keepPkg = keepPkgs.find(pkg => pkg.id === id);\n if (removePkgs.find(pkg => pkg.id === id)) {\n nodesToRemove.push(packageElement);\n changed = true;\n } else if (keepPkg) {\n changed =\n changed || keepPkg.version !== packageElement.getAttribute('version');\n packageElement.setAttribute('version', keepPkg.version!);\n keepPkgs = keepPkgs.filter(pkg => pkg.id !== keepPkg.id);\n }\n }\n\n nodesToRemove.forEach(pkg =>\n packagesConfig.content.documentElement.removeChild(pkg),\n );\n\n keepPkgs.forEach(keepPkg => {\n const newPkg = packagesConfig.content.createElement('package');\n\n Object.entries(keepPkg).forEach(([attr, value]) => {\n newPkg.setAttribute(attr, value as string);\n });\n newPkg.setAttribute('targetFramework', 'native');\n packagesConfig.content.documentElement.appendChild(newPkg);\n changed = true;\n });\n return changed;\n }\n\n /** @return The CLI command to invoke autolink-windows independently */\n public getAutolinkWindowsCommand() {\n const folder = this.windowsAppConfig.folder;\n\n const autolinkCommand = 'npx react-native autolink-windows';\n const autolinkArgs = `--sln \"${path.relative(\n folder,\n this.getSolutionFile(),\n )}\" --proj \"${path.relative(folder, this.getProjectFile())}\"`;\n return `${autolinkCommand} ${autolinkArgs}`;\n }\n}\n\n/**\n * Locates the react-native-windows directory\n * @param config project configuration\n */\nfunction resolveRnwRoot(projectConfig: WindowsProjectConfig) {\n return pathHelpers.resolveRnwRoot(projectConfig.folder);\n}\n\n/**\n * Locates the react-native-windows directory containing template files\n * @param config project configuration\n */\nfunction resolveTemplateRoot(projectConfig: WindowsProjectConfig) {\n const rnwPackage = resolveRnwRoot(projectConfig);\n return path.join(rnwPackage, 'template');\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 AutoLinkOptions, 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 'sln':\n case 'proj':\n return value === undefined ? false : true; // Strip PII\n case 'logging':\n case 'check':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `autolink-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 `react-native autolink-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 autolinkWindows(\n args: string[],\n config: Config,\n options: AutoLinkOptions,\n) {\n await startTelemetrySession(\n 'autolink-windows',\n config,\n options,\n getDefaultOptions(config, autolinkOptions),\n optionSanitizer,\n );\n\n let autolinkWindowsError: Error | undefined;\n try {\n await autolinkWindowsInternal(args, config, options);\n } catch (ex) {\n autolinkWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(autolinkWindowsError);\n }\n\n await endTelemetrySession(autolinkWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, autolinkWindowsError);\n}\n\n/**\n * Performs auto-linking for RNW native modules and 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 */\nexport async function autolinkWindowsInternal(\n args: string[],\n config: Config,\n options: AutoLinkOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner(\n options.check ? 'Checking auto-linked files...' : 'Auto-linking...',\n );\n try {\n const autolink = new AutoLinkWindows(\n config.project,\n config.dependencies,\n options,\n );\n await autolink.run(spinner);\n const endTime = performance.now();\n\n if (!autolink.areChangesNeeded()) {\n console.log(\n `${chalk.green(\n 'Success:',\n )} No auto-linking changes necessary. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } else if (options.check) {\n const autolinkCommand = autolink.getAutolinkWindowsCommand();\n console.log(\n `${chalk.yellow(\n 'Warning:',\n )} Auto-linking changes were necessary but ${chalk.bold(\n '--check',\n )} specified. Run '${chalk.bold(\n `${autolinkCommand}`,\n )}' to apply the changes. (${Math.round(endTime - startTime)}ms)`,\n );\n throw new CodedError(\n 'NeedAutolinking',\n `Auto-linking changes were necessary but --check was specified. Run '${autolinkCommand}' to apply the changes`,\n );\n } else {\n console.log(\n `${chalk.green(\n 'Success:',\n )} Auto-linking changes completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\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 * Performs auto-linking for RNW native modules and apps.\n */\nexport const autolinkCommand: Command = {\n name: 'autolink-windows',\n description: 'Runs Windows-specific autolinking for your RNW project',\n func: autolinkWindows,\n options: autolinkOptions,\n};\n"]}
@@ -17,12 +17,12 @@ exports.autolinkOptions = [
17
17
  },
18
18
  {
19
19
  name: '--sln [string]',
20
- description: "Override the app solution file determined by 'react-native config', e.g. windows\\myApp.sln",
20
+ description: "Override the app solution file determined by 'react-native config', i.e. windows\\myApp.sln",
21
21
  default: undefined,
22
22
  },
23
23
  {
24
24
  name: '--proj [string]',
25
- description: "Override the app project file determined by 'react-native config', e.g. windows\\myApp\\myApp.vcxproj",
25
+ description: "Override the app project file determined by 'react-native config', i.e. windows\\myApp\\myApp.vcxproj",
26
26
  default: undefined,
27
27
  },
28
28
  {
@@ -1 +1 @@
1
- {"version":3,"file":"autolinkWindowsOptions.js","sourceRoot":"","sources":["../../../src/commands/autolinkWindows/autolinkWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAYU,QAAA,eAAe,GAAoB;IAC9C;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,wDAAwD;KACtE;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,6FAA6F;QAC/F,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,uGAAuG;QACzG,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uGAAuG;KAC1G;CACF,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CommandOption} from '@react-native-community/cli-types';\n\nexport interface AutoLinkOptions {\n logging?: boolean;\n check?: boolean;\n sln?: string;\n proj?: string;\n telemetry?: boolean;\n}\n\nexport const autolinkOptions: CommandOption[] = [\n {\n name: '--logging',\n description: 'Verbose output logging',\n },\n {\n name: '--check',\n description: 'Only check whether any autolinked files need to change',\n },\n {\n name: '--sln [string]',\n description:\n \"Override the app solution file determined by 'react-native config', e.g. windows\\\\myApp.sln\",\n default: undefined,\n },\n {\n name: '--proj [string]',\n description:\n \"Override the app project file determined by 'react-native config', e.g. windows\\\\myApp\\\\myApp.vcxproj\",\n default: undefined,\n },\n {\n name: '--no-telemetry',\n description:\n 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',\n },\n];\n"]}
1
+ {"version":3,"file":"autolinkWindowsOptions.js","sourceRoot":"","sources":["../../../src/commands/autolinkWindows/autolinkWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAYU,QAAA,eAAe,GAAoB;IAC9C;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,wDAAwD;KACtE;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,6FAA6F;QAC/F,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,uGAAuG;QACzG,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uGAAuG;KAC1G;CACF,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CommandOption} from '@react-native-community/cli-types';\n\nexport interface AutoLinkOptions {\n logging?: boolean;\n check?: boolean;\n sln?: string;\n proj?: string;\n telemetry?: boolean;\n}\n\nexport const autolinkOptions: CommandOption[] = [\n {\n name: '--logging',\n description: 'Verbose output logging',\n },\n {\n name: '--check',\n description: 'Only check whether any autolinked files need to change',\n },\n {\n name: '--sln [string]',\n description:\n \"Override the app solution file determined by 'react-native config', i.e. windows\\\\myApp.sln\",\n default: undefined,\n },\n {\n name: '--proj [string]',\n description:\n \"Override the app project file determined by 'react-native config', i.e. windows\\\\myApp\\\\myApp.vcxproj\",\n default: undefined,\n },\n {\n name: '--no-telemetry',\n description:\n 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',\n },\n];\n"]}
@@ -199,7 +199,7 @@ exports.codegenWindowsInternal = codegenWindowsInternal;
199
199
  */
200
200
  exports.codegenCommand = {
201
201
  name: 'codegen-windows',
202
- description: 'Runs Windows-specific codegen',
202
+ description: 'Runs Windows-specific codegen for native modules',
203
203
  func: codegenWindows,
204
204
  options: codegenWindowsOptions_1.codegenOptions,
205
205
  };
@@ -1 +1 @@
1
- {"version":3,"file":"codegenWindows.js","sourceRoot":"","sources":["../../../src/commands/codegenWindows/codegenWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gDAAwB;AACxB,kDAA0B;AAC1B,2CAAuC;AAIvC,+DAAsE;AACtE,2DAIuC;AAEvC,yEAGyC;AACzC,mEAIsC;AACtC,mEAAuE;AAEvE,MAAa,cAAc;IAGlB,gBAAgB;QACrB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,YAAqB,IAAY,EAAW,OAAuB;QAA9C,SAAI,GAAJ,IAAI,CAAQ;QAAW,YAAO,GAAP,OAAO,CAAgB;QACjE,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,OAAY;;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAErC,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAE5B,cAAc,CAAC,yCAAyC,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;QAE9D,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;YAC1B,OAAO,CAAC,IAAI,CACV,MAAM,eAAK,CAAC,IAAI,CACd,eAAe,CAChB,gCAAgC,eAAK,CAAC,MAAM,CAC3C,0BAA0B,CAC3B,EAAE,CACJ,CAAC;YACF,OAAO;SACR;QAED,MAAM,iBAAiB,GA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I,EAAE,iBAAiB;IACvB,WAAW,EAAE,+BAA+B;IAC5C,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,sCAAc;CACxB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\nimport chalk from 'chalk';\nimport {performance} from 'perf_hooks';\nimport {Ora} from 'ora';\n\nimport {Command, Config} from '@react-native-community/cli-types';\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport {\n CodeGenOptions as RnwCodeGenOptions,\n CppStringTypes,\n runCodeGen,\n} from '@react-native-windows/codegen';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport {CodeGenOptions, codegenOptions} from './codegenWindowsOptions';\n\nexport class CodeGenWindows {\n private changesNecessary: boolean;\n\n public areChangesNeeded() {\n return this.changesNecessary;\n }\n\n constructor(readonly root: string, readonly options: CodeGenOptions) {\n this.changesNecessary = false;\n }\n\n public async run(spinner: Ora) {\n const verbose = this.options.logging;\n\n verboseMessage('', verbose);\n\n verboseMessage('Loading codegenConfig from package.json');\n const pkgJson = require(path.join(this.root, 'package.json'));\n\n if (!pkgJson.codegenConfig) {\n spinner.info(\n `No ${chalk.bold(\n 'codegenConfig',\n )} specified in package.json - ${chalk.yellow(\n 'Skipping codegen-windows',\n )}`,\n );\n return;\n }\n\n const codegenConfigType = pkgJson.codegenConfig.type;\n if (codegenConfigType !== 'modules' && codegenConfigType !== 'all') {\n spinner.info(\n `${chalk.bold(\n 'codegenConfig.type',\n )} in package.json is not ${chalk.bold('modules')} or ${chalk.bold(\n 'all',\n )} - ${chalk.yellow('Skipping codegen-windows')}`,\n );\n return;\n }\n\n if (!pkgJson.codegenConfig.windows) {\n spinner.info(\n `No ${chalk.bold(\n 'codegenConfig.windows',\n )} specified in package.json - ${chalk.yellow(\n 'Skipping codegen-windows',\n )}`,\n );\n return;\n }\n\n if (!pkgJson.codegenConfig.windows.namespace) {\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Missing ${chalk.bold(\n 'codegenConfig.windows.namespace',\n )} value in package.json`,\n );\n }\n\n let cppStringType: CppStringTypes = 'std::string';\n if (pkgJson.codegenConfig.windows.cppStringType) {\n switch (pkgJson.codegenConfig.windows.cppStringType) {\n case 'std::string':\n case 'std::wstring':\n cppStringType = pkgJson.codegenConfig.windows.cppStringType;\n break;\n default:\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Value of ${chalk.bold(\n 'codegenConfig.windows.cppStringType',\n )} in package.json should be either 'std::string' or 'std::wstring'`,\n );\n }\n }\n\n let separateDataTypes = false;\n if (pkgJson.codegenConfig.windows.separateDataTypes !== undefined) {\n switch (pkgJson.codegenConfig.windows.separateDataTypes) {\n case true:\n case false:\n separateDataTypes = pkgJson.codegenConfig.windows.separateDataTypes;\n break;\n default:\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Value of ${chalk.bold(\n 'codegenConfig.windows.separateDataTypes',\n )} in package.json should be either true or false`,\n );\n }\n }\n\n if (!pkgJson.codegenConfig.name) {\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Missing ${chalk.bold('codegenConfig.name')} value in package.json`,\n );\n }\n\n const projectName = pkgJson.codegenConfig.name.replace(/[^a-zA-Z]/g, '');\n const projectNamespace = pkgJson.codegenConfig.windows.namespace;\n const jsRootDir = pkgJson.codegenConfig.jsSrcsDir\n ? path.join(this.root, pkgJson.codegenConfig.jsSrcsDir)\n : this.root;\n const codegenOutputDir =\n pkgJson.codegenConfig.windows.outputDirectory ?? 'codegen';\n\n const generators = pkgJson.codegenConfig.windows.generators ?? [\n 'modulesWindows',\n ];\n\n const jsRootPathRelative = path.relative(process.cwd(), jsRootDir);\n const options: RnwCodeGenOptions = {\n files: [\n `${jsRootPathRelative}${\n jsRootPathRelative ? '/' : ''\n }**/*Native*.[jt]s`,\n ],\n cppStringType,\n separateDataTypes,\n libraryName: projectName,\n methodOnly: false,\n modulesCxx: generators.indexOf('modulesCxx') !== -1,\n modulesTypeScriptTypes:\n generators.indexOf('modulesTypeScriptTypes') !== -1,\n modulesWindows: generators.indexOf('modulesWindows') !== -1,\n namespace: projectNamespace,\n outputDirectory: path.join(this.root, codegenOutputDir),\n test: !!this.options.check,\n };\n\n verboseMessage(\n `Run codegen with options: \\n${JSON.stringify(options, null, 2)}`,\n verbose,\n );\n\n this.changesNecessary = runCodeGen(options);\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 CodeGenOptions, 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 'logging':\n case 'check':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `codegen-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 `react-native codegen-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 codegenWindows(\n args: string[],\n config: Config,\n options: CodeGenOptions,\n) {\n await startTelemetrySession(\n 'codegen-windows',\n config,\n options,\n getDefaultOptions(config, codegenOptions),\n optionSanitizer,\n );\n\n let codegenWindowsError: Error | undefined;\n try {\n await codegenWindowsInternal(args, config, options);\n } catch (ex) {\n codegenWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(codegenWindowsError);\n }\n\n await endTelemetrySession(codegenWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, codegenWindowsError);\n}\n\n/**\n * Performs codegen for RNW native modules and 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 */\nexport async function codegenWindowsInternal(\n args: string[],\n config: Config,\n options: CodeGenOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner(\n options.check\n ? 'Checking codegen-windows files...'\n : 'Running codegen-windows...',\n );\n try {\n const codegen = new CodeGenWindows(config.root, options);\n await codegen.run(spinner);\n const endTime = performance.now();\n\n if (!codegen.areChangesNeeded()) {\n console.log(\n `${chalk.green(\n 'Success:',\n )} No codegen-windows changes necessary. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } else if (options.check) {\n const codegenCommand = 'npx react-native codegen-windows';\n console.log(\n `${chalk.yellow(\n 'Warning:',\n )} Codegen-windows changes were necessary but ${chalk.bold(\n '--check',\n )} specified. Run '${chalk.bold(\n `${codegenCommand}`,\n )}' to apply the changes. (${Math.round(endTime - startTime)}ms)`,\n );\n throw new CodedError(\n 'NeedCodegen',\n `Codegen-windows changes were necessary but --check was specified. Run '${codegenCommand}' to apply the changes`,\n );\n } else {\n console.log(\n `${chalk.green(\n 'Success:',\n )} Codegen-windows changes completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\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 * Performs codegen for RNW native modules.\n */\nexport const codegenCommand: Command = {\n name: 'codegen-windows',\n description: 'Runs Windows-specific codegen',\n func: codegenWindows,\n options: codegenOptions,\n};\n"]}
1
+ {"version":3,"file":"codegenWindows.js","sourceRoot":"","sources":["../../../src/commands/codegenWindows/codegenWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gDAAwB;AACxB,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,GAAG,CACT,GAAG,eAAK,CAAC,MAAM,CACb,UAAU,CACX,+CAA+C,eAAK,CAAC,IAAI,CACxD,SAAS,CACV,oBAAoB,eAAK,CAAC,IAAI,CAC7B,GAAG,cAAc,EAAE,CACpB,4BAA4B,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,KAAK,CAClE,CAAC;YACF,MAAM,IAAI,sBAAU,CAClB,aAAa,EACb,0EAA0E,cAAc,wBAAwB,CACjH,CAAC;SACH;aAAM;YACL,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,KAAK,CACZ,UAAU,CACX,wCAAwC,IAAI,CAAC,KAAK,CACjD,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;SACH;KACF;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;AA1DD,wDA0DC;AAED;;GAEG;AACU,QAAA,cAAc,GAAY;IACrC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,kDAAkD;IAC/D,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,sCAAc;CACxB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\nimport chalk from 'chalk';\nimport {performance} from 'perf_hooks';\nimport {Ora} from 'ora';\n\nimport {Command, Config} from '@react-native-community/cli-types';\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport {\n CodeGenOptions as RnwCodeGenOptions,\n CppStringTypes,\n runCodeGen,\n} from '@react-native-windows/codegen';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport {CodeGenOptions, codegenOptions} from './codegenWindowsOptions';\n\nexport class CodeGenWindows {\n private changesNecessary: boolean;\n\n public areChangesNeeded() {\n return this.changesNecessary;\n }\n\n constructor(readonly root: string, readonly options: CodeGenOptions) {\n this.changesNecessary = false;\n }\n\n public async run(spinner: Ora) {\n const verbose = this.options.logging;\n\n verboseMessage('', verbose);\n\n verboseMessage('Loading codegenConfig from package.json');\n const pkgJson = require(path.join(this.root, 'package.json'));\n\n if (!pkgJson.codegenConfig) {\n spinner.info(\n `No ${chalk.bold(\n 'codegenConfig',\n )} specified in package.json - ${chalk.yellow(\n 'Skipping codegen-windows',\n )}`,\n );\n return;\n }\n\n const codegenConfigType = pkgJson.codegenConfig.type;\n if (codegenConfigType !== 'modules' && codegenConfigType !== 'all') {\n spinner.info(\n `${chalk.bold(\n 'codegenConfig.type',\n )} in package.json is not ${chalk.bold('modules')} or ${chalk.bold(\n 'all',\n )} - ${chalk.yellow('Skipping codegen-windows')}`,\n );\n return;\n }\n\n if (!pkgJson.codegenConfig.windows) {\n spinner.info(\n `No ${chalk.bold(\n 'codegenConfig.windows',\n )} specified in package.json - ${chalk.yellow(\n 'Skipping codegen-windows',\n )}`,\n );\n return;\n }\n\n if (!pkgJson.codegenConfig.windows.namespace) {\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Missing ${chalk.bold(\n 'codegenConfig.windows.namespace',\n )} value in package.json`,\n );\n }\n\n let cppStringType: CppStringTypes = 'std::string';\n if (pkgJson.codegenConfig.windows.cppStringType) {\n switch (pkgJson.codegenConfig.windows.cppStringType) {\n case 'std::string':\n case 'std::wstring':\n cppStringType = pkgJson.codegenConfig.windows.cppStringType;\n break;\n default:\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Value of ${chalk.bold(\n 'codegenConfig.windows.cppStringType',\n )} in package.json should be either 'std::string' or 'std::wstring'`,\n );\n }\n }\n\n let separateDataTypes = false;\n if (pkgJson.codegenConfig.windows.separateDataTypes !== undefined) {\n switch (pkgJson.codegenConfig.windows.separateDataTypes) {\n case true:\n case false:\n separateDataTypes = pkgJson.codegenConfig.windows.separateDataTypes;\n break;\n default:\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Value of ${chalk.bold(\n 'codegenConfig.windows.separateDataTypes',\n )} in package.json should be either true or false`,\n );\n }\n }\n\n if (!pkgJson.codegenConfig.name) {\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Missing ${chalk.bold('codegenConfig.name')} value in package.json`,\n );\n }\n\n const projectName = pkgJson.codegenConfig.name.replace(/[^a-zA-Z]/g, '');\n const projectNamespace = pkgJson.codegenConfig.windows.namespace;\n const jsRootDir = pkgJson.codegenConfig.jsSrcsDir\n ? path.join(this.root, pkgJson.codegenConfig.jsSrcsDir)\n : this.root;\n const codegenOutputDir =\n pkgJson.codegenConfig.windows.outputDirectory ?? 'codegen';\n\n const generators = pkgJson.codegenConfig.windows.generators ?? [\n 'modulesWindows',\n ];\n\n const jsRootPathRelative = path.relative(process.cwd(), jsRootDir);\n const options: RnwCodeGenOptions = {\n files: [\n `${jsRootPathRelative}${\n jsRootPathRelative ? '/' : ''\n }**/*Native*.[jt]s`,\n ],\n cppStringType,\n separateDataTypes,\n libraryName: projectName,\n methodOnly: false,\n modulesCxx: generators.indexOf('modulesCxx') !== -1,\n modulesTypeScriptTypes:\n generators.indexOf('modulesTypeScriptTypes') !== -1,\n modulesWindows: generators.indexOf('modulesWindows') !== -1,\n namespace: projectNamespace,\n outputDirectory: path.join(this.root, codegenOutputDir),\n test: !!this.options.check,\n };\n\n verboseMessage(\n `Run codegen with options: \\n${JSON.stringify(options, null, 2)}`,\n verbose,\n );\n\n this.changesNecessary = runCodeGen(options);\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 CodeGenOptions, 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 'logging':\n case 'check':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `codegen-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 `react-native codegen-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 codegenWindows(\n args: string[],\n config: Config,\n options: CodeGenOptions,\n) {\n await startTelemetrySession(\n 'codegen-windows',\n config,\n options,\n getDefaultOptions(config, codegenOptions),\n optionSanitizer,\n );\n\n let codegenWindowsError: Error | undefined;\n try {\n await codegenWindowsInternal(args, config, options);\n } catch (ex) {\n codegenWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(codegenWindowsError);\n }\n\n await endTelemetrySession(codegenWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, codegenWindowsError);\n}\n\n/**\n * Performs codegen for RNW native modules and 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 */\nexport async function codegenWindowsInternal(\n args: string[],\n config: Config,\n options: CodeGenOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner(\n options.check\n ? 'Checking codegen-windows files...'\n : 'Running codegen-windows...',\n );\n try {\n const codegen = new CodeGenWindows(config.root, options);\n await codegen.run(spinner);\n const endTime = performance.now();\n\n if (!codegen.areChangesNeeded()) {\n console.log(\n `${chalk.green(\n 'Success:',\n )} No codegen-windows changes necessary. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } else if (options.check) {\n const codegenCommand = 'npx react-native codegen-windows';\n console.log(\n `${chalk.yellow(\n 'Warning:',\n )} Codegen-windows changes were necessary but ${chalk.bold(\n '--check',\n )} specified. Run '${chalk.bold(\n `${codegenCommand}`,\n )}' to apply the changes. (${Math.round(endTime - startTime)}ms)`,\n );\n throw new CodedError(\n 'NeedCodegen',\n `Codegen-windows changes were necessary but --check was specified. Run '${codegenCommand}' to apply the changes`,\n );\n } else {\n console.log(\n `${chalk.green(\n 'Success:',\n )} Codegen-windows changes completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\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 * Performs codegen for RNW native modules.\n */\nexport const codegenCommand: Command = {\n name: 'codegen-windows',\n description: 'Runs Windows-specific codegen for native modules',\n func: codegenWindows,\n options: codegenOptions,\n};\n"]}
@@ -237,7 +237,7 @@ exports.initWindowsInternal = initWindowsInternal;
237
237
  */
238
238
  exports.initCommand = {
239
239
  name: 'init-windows',
240
- description: 'Initializes a new RNW project from a given template.',
240
+ description: 'Initializes a new RNW project from a given template',
241
241
  func: initWindows,
242
242
  options: initWindowsOptions_1.initOptions,
243
243
  };
@@ -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;AACtC,oDAAuB;AACvB,2CAAuC;AAEvC,gDAAwB;AAExB,MAAM,IAAI,GAAG,cAAI,CAAC,SAAS,CAAC,WAAQ,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,EAAE,sDAAsD;IACnE,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 {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 {InitOptions, 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 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 }\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 pascalCase(str: string): string {\n const camelCase = _.camelCase(str);\n return camelCase[0].toUpperCase() + camelCase.substr(1);\n }\n\n protected isValidProjectName(name: string): boolean {\n if (name.match(/^[a-z][a-z0-9]*$/gi)) {\n return true;\n }\n return false;\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 public async run(spinner: Ora) {\n await this.loadTemplates();\n\n spinner.info();\n\n this.options.template ??= 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 if (this.options.name && !this.isValidProjectName(this.options.name)) {\n throw new CodedError(\n 'InvalidProjectName',\n `The specified name is not a valid identifier`,\n );\n }\n\n if (!this.options.name) {\n const projectName = this.getReactNativeProjectName(this.config.root);\n this.options.name = this.isValidProjectName(projectName)\n ? projectName\n : this.pascalCase(projectName);\n }\n\n this.options.namespace ??= this.options.name;\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 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 `react-native 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;AACtC,oDAAuB;AACvB,2CAAuC;AAEvC,gDAAwB;AAExB,MAAM,IAAI,GAAG,cAAI,CAAC,SAAS,CAAC,WAAQ,CAAC,CA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DAAqD;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 {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 {InitOptions, 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 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 }\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 pascalCase(str: string): string {\n const camelCase = _.camelCase(str);\n return camelCase[0].toUpperCase() + camelCase.substr(1);\n }\n\n protected isValidProjectName(name: string): boolean {\n if (name.match(/^[a-z][a-z0-9]*$/gi)) {\n return true;\n }\n return false;\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 public async run(spinner: Ora) {\n await this.loadTemplates();\n\n spinner.info();\n\n this.options.template ??= 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 if (this.options.name && !this.isValidProjectName(this.options.name)) {\n throw new CodedError(\n 'InvalidProjectName',\n `The specified name is not a valid identifier`,\n );\n }\n\n if (!this.options.name) {\n const projectName = this.getReactNativeProjectName(this.config.root);\n this.options.name = this.isValidProjectName(projectName)\n ? projectName\n : this.pascalCase(projectName);\n }\n\n this.options.namespace ??= this.options.name;\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 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 `react-native 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"]}
@@ -18,12 +18,12 @@ exports.initOptions = [
18
18
  },
19
19
  {
20
20
  name: '--name [string]',
21
- description: 'The native project name. Defaults to the name property iin app.json or package.json',
21
+ description: 'The native project name. Defaults to the name property in app.json or package.json',
22
22
  default: undefined,
23
23
  },
24
24
  {
25
25
  name: '--namespace [string]',
26
- description: "The native project namespace. This should be expressed using dots as separators. i.e. 'Level1.Level2.Level3'. The generator will apply the correct syntax for the target language.",
26
+ description: "The native project namespace expressed using dots as separators, i.e. 'Level1.Level2.Level3'. Defaults to the same as name",
27
27
  default: undefined,
28
28
  },
29
29
  {
@@ -1 +1 @@
1
- {"version":3,"file":"initWindowsOptions.js","sourceRoot":"","sources":["../../../src/commands/initWindows/initWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAaU,QAAA,WAAW,GAAoB;IAC1C;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,6BAA6B;QAC1C,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,qFAAqF;QACvF,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EACT,oLAAoL;QACtL,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,gDAAgD;KAC9D;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uGAAuG;KAC1G;CACF,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CommandOption} from '@react-native-community/cli-types';\n\nexport interface InitOptions {\n logging?: boolean;\n template?: string;\n name?: string;\n namespace?: string;\n overwrite?: boolean;\n telemetry?: boolean;\n}\n\nexport const initOptions: CommandOption[] = [\n {\n name: '--logging',\n description: 'Verbose output logging',\n },\n {\n name: '--template [string]',\n description: 'Specify the template to use',\n default: undefined,\n },\n {\n name: '--name [string]',\n description:\n 'The native project name. Defaults to the name property iin app.json or package.json',\n default: undefined,\n },\n {\n name: '--namespace [string]',\n description:\n \"The native project namespace. This should be expressed using dots as separators. i.e. 'Level1.Level2.Level3'. The generator will apply the correct syntax for the target language.\",\n default: undefined,\n },\n {\n name: '--overwrite',\n description: 'Overwrite any existing files without prompting',\n },\n {\n name: '--no-telemetry',\n description:\n 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',\n },\n];\n"]}
1
+ {"version":3,"file":"initWindowsOptions.js","sourceRoot":"","sources":["../../../src/commands/initWindows/initWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAaU,QAAA,WAAW,GAAoB;IAC1C;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,6BAA6B;QAC1C,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,oFAAoF;QACtF,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EACT,4HAA4H;QAC9H,OAAO,EAAE,SAAS;KACnB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,gDAAgD;KAC9D;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uGAAuG;KAC1G;CACF,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CommandOption} from '@react-native-community/cli-types';\n\nexport interface InitOptions {\n logging?: boolean;\n template?: string;\n name?: string;\n namespace?: string;\n overwrite?: boolean;\n telemetry?: boolean;\n}\n\nexport const initOptions: CommandOption[] = [\n {\n name: '--logging',\n description: 'Verbose output logging',\n },\n {\n name: '--template [string]',\n description: 'Specify the template to use',\n default: undefined,\n },\n {\n name: '--name [string]',\n description:\n 'The native project name. Defaults to the name property in app.json or package.json',\n default: undefined,\n },\n {\n name: '--namespace [string]',\n description:\n \"The native project namespace expressed using dots as separators, i.e. 'Level1.Level2.Level3'. Defaults to the same as name\",\n default: undefined,\n },\n {\n name: '--overwrite',\n description: 'Overwrite any existing files without prompting',\n },\n {\n name: '--no-telemetry',\n description:\n 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',\n },\n];\n"]}
@@ -315,7 +315,7 @@ runWindows({
315
315
  */
316
316
  exports.runWindowsCommand = {
317
317
  name: 'run-windows',
318
- description: 'Builds your app and starts it on a connected Windows desktop, emulator or device',
318
+ description: 'Builds your RNW app and starts it on a connected Windows desktop, emulator or device',
319
319
  func: runWindows,
320
320
  options: runWindowsOptions_1.runWindowsOptions,
321
321
  };
@@ -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;AACpD,2DAAyE;AACzE,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;QACzD,KAAK,cAAc;YACjB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,mBAAmB;QAC/E,KAAK,SAAS,CAAC;QACf,KAAK,MAAM,CAAC;QACZ,KAAK,YAAY,CAAC;QAClB,KAAK,UAAU,CAAC;QAChB,KAAK,QAAQ,CAAC;QACd,KAAK,iBAAiB,CAAC;QACvB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,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K,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,kFAAkF;IACpF,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 {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 {runWindowsOptions, RunWindowsOptions} from './runWindowsOptions';\nimport {autolinkWindowsInternal} from '../autolinkWindows/autolinkWindows';\nimport {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 value === undefined ? 0 : value.split(',').length; // 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 `react-native 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-windows-init\" 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-windows-init\" 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 app and starts it on a connected Windows desktop, emulator or device',\n func: runWindows,\n options: runWindowsOptions,\n};\n"]}
1
+ {"version":3,"file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CAAiB;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 {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 {runWindowsOptions, RunWindowsOptions} from './runWindowsOptions';\nimport {autolinkWindowsInternal} from '../autolinkWindows/autolinkWindows';\nimport {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 value === undefined ? 0 : value.split(',').length; // 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 `react-native 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-windows-init\" 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-windows-init\" 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"]}
@@ -10,16 +10,16 @@ const telemetry_1 = require("@react-native-windows/telemetry");
10
10
  exports.runWindowsOptions = [
11
11
  {
12
12
  name: '--release',
13
- description: 'Specifies a release build',
13
+ description: 'Specifies a Release build',
14
14
  },
15
15
  {
16
16
  name: '--root [string]',
17
- description: 'Override the root directory for the windows build which contains the windows folder.',
17
+ description: 'Override the root directory for the project which contains the windows folder',
18
18
  default: config => config.root,
19
19
  },
20
20
  {
21
21
  name: '--arch [string]',
22
- description: 'The build architecture (ARM64, x86, x64)',
22
+ description: 'The build architecture, i.e. ARM64, x86, x64',
23
23
  default: parseBuildArch((0, telemetry_1.deviceArchitecture)()),
24
24
  parse: parseBuildArch,
25
25
  },
@@ -37,23 +37,23 @@ exports.runWindowsOptions = [
37
37
  },
38
38
  {
39
39
  name: '--target [string]',
40
- description: 'Deploys the app to the specified GUID for a device.',
40
+ description: 'Deploys the app to the specified GUID for a device',
41
41
  },
42
42
  {
43
43
  name: '--remote-debugging',
44
- description: 'Deploys the app in remote debugging mode.',
44
+ description: '(Deprecated) Deploys the app in remote debugging mode',
45
45
  },
46
46
  {
47
47
  name: '--logging',
48
- description: 'Enables logging',
48
+ description: 'Verbose output logging',
49
49
  },
50
50
  {
51
51
  name: '--no-packager',
52
- description: 'Do not launch packager while building',
52
+ description: 'Do not launch the packager while building',
53
53
  },
54
54
  {
55
55
  name: '--bundle',
56
- description: 'Enable Bundle configuration and it would be ReleaseBundle/DebugBundle other than Release/Debug',
56
+ description: 'Enable Bundle configuration, i.e. ReleaseBundle/DebugBundle rather than Release/Debug',
57
57
  },
58
58
  {
59
59
  name: '--no-launch',
@@ -73,25 +73,25 @@ exports.runWindowsOptions = [
73
73
  },
74
74
  {
75
75
  name: '--deploy-from-layout',
76
- description: 'Force deploy from layout',
76
+ description: 'Force deploy from layout even in Release builds',
77
77
  },
78
78
  {
79
79
  name: '--sln [string]',
80
- description: "Override the app solution file determined by 'react-native config', e.g. windows\\myApp.sln",
80
+ description: "Override the app solution file determined by 'react-native config', i.e. windows\\myApp.sln",
81
81
  default: undefined,
82
82
  },
83
83
  {
84
84
  name: '--proj [string]',
85
- description: "Override the app project file determined by 'react-native config', e.g. windows\\myApp\\myApp.vcxproj",
85
+ description: "Override the app project file determined by 'react-native config', i.e. windows\\myApp\\myApp.vcxproj",
86
86
  default: undefined,
87
87
  },
88
88
  {
89
89
  name: '--msbuildprops [string]',
90
- description: 'Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2',
90
+ description: 'Comma separated props to pass to MSBuild, eg: prop1=value1,prop2=value2',
91
91
  },
92
92
  {
93
93
  name: '--buildLogDirectory [string]',
94
- description: 'Optional directory where msbuild log files should be stored',
94
+ description: 'Optional directory where MSBuild log files should be stored',
95
95
  },
96
96
  {
97
97
  name: '--info',
@@ -1 +1 @@
1
- {"version":3,"file":"runWindowsOptions.js","sourceRoot":"","sources":["../../../src/commands/runWindows/runWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,+DAAmE;AAqDtD,QAAA,iBAAiB,GAAoB;IAChD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,2BAA2B;KACzC;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,sFAAsF;QACxF,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI;KAC/B;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,0CAA0C;QACvD,OAAO,EAAE,cAAc,CAAC,IAAA,8BAAkB,GAAE,CAAC;QAC7C,KAAK,EAAE,cAAc;KACtB;IACD;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,2BAA2B;KACzC;IACD;QACE,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,gCAAgC;KAC9C;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,uCAAuC;KACrD;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,qDAAqD;KACnE;IACD;QACE,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,2CAA2C;KACzD;IACD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,iBAAiB;KAC/B;IACD;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,uCAAuC;KACrD;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EACT,gGAAgG;KACnG;I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G,EAAE,EAAE,CAAC,CAAC;IAE9B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;QAC1B,QAAQ,CAAC,uDAAuD,CAAC,CAAC;KACnE;IACD,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,IAAI,KAAK,EAAE;QAC9B,QAAQ,CAAC,uCAAuC,CAAC,CAAC;KACnD;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW;IAC3B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CommandOption} from '@react-native-community/cli-types';\nimport {deviceArchitecture} from '@react-native-windows/telemetry';\n\nexport type BuildArch = 'x86' | 'x64' | 'ARM64';\nexport type BuildConfig = 'Debug' | 'DebugBundle' | 'Release' | 'ReleaseBundle';\n\n/**\n * * Options are the following:\n * release: Boolean - Specifies release build\n * root: String - The root of the application\n * arch: String - The build architecture (ARM64, x86, x64)\n * singleproc: Boolean - opt out of multi-proc builds\n * emulator: Boolean - Deploy to the emulator\n * device: Boolean - Deploy to a device\n * target: String - Device GUID to deploy to\n * remote-debugging: Boolean - Run using remote JS proxy\n * logging: Boolean - Enables logging\n * no-packager: Boolean - Do not launch packager while building\n * bundle: Boolean - Enable Bundle configuration.\n * no-launch: Boolean - Do not launch the app after deployment\n * no-build: Boolean - Do not build the solution\n * no-deploy: Boolean - Do not deploy the app\n * deploy-from-layout: Force deploy from layout, even in release builds\n * sln: String - Solution file to build\n * msbuildprops: String - Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2\n * direct-debugging: Number - Enable direct debugging on specified port\n * no-telemetry: Boolean - Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI\n */\nexport interface RunWindowsOptions {\n release?: boolean;\n root: string;\n arch: BuildArch;\n singleproc?: boolean;\n emulator?: boolean;\n device?: boolean;\n target?: string;\n remoteDebugging?: string;\n logging?: boolean;\n packager?: boolean;\n bundle?: boolean;\n launch?: boolean;\n autolink?: boolean;\n build?: boolean;\n deploy?: boolean;\n deployFromLayout?: boolean;\n sln?: string;\n proj?: string;\n msbuildprops?: string;\n buildLogDirectory?: string;\n info?: boolean;\n directDebugging?: number;\n telemetry?: boolean;\n}\n\nexport const runWindowsOptions: CommandOption[] = [\n {\n name: '--release',\n description: 'Specifies a release build',\n },\n {\n name: '--root [string]',\n description:\n 'Override the root directory for the windows build which contains the windows folder.',\n default: config => config.root,\n },\n {\n name: '--arch [string]',\n description: 'The build architecture (ARM64, x86, x64)',\n default: parseBuildArch(deviceArchitecture()),\n parse: parseBuildArch,\n },\n {\n name: '--singleproc',\n description: 'Disables multi-proc build',\n },\n {\n name: '--emulator',\n description: 'Deploys the app to an emulator',\n },\n {\n name: '--device',\n description: 'Deploys the app to a connected device',\n },\n {\n name: '--target [string]',\n description: 'Deploys the app to the specified GUID for a device.',\n },\n {\n name: '--remote-debugging',\n description: 'Deploys the app in remote debugging mode.',\n },\n {\n name: '--logging',\n description: 'Enables logging',\n },\n {\n name: '--no-packager',\n description: 'Do not launch packager while building',\n },\n {\n name: '--bundle',\n description:\n 'Enable Bundle configuration and it would be ReleaseBundle/DebugBundle other than Release/Debug',\n },\n {\n name: '--no-launch',\n description: 'Do not launch the app after deployment',\n },\n {\n name: '--no-autolink',\n description: 'Do not run autolinking',\n },\n {\n name: '--no-build',\n description: 'Do not build the solution',\n },\n {\n name: '--no-deploy',\n description: 'Do not deploy the app',\n },\n {\n name: '--deploy-from-layout',\n description: 'Force deploy from layout',\n },\n {\n name: '--sln [string]',\n description:\n \"Override the app solution file determined by 'react-native config', e.g. windows\\\\myApp.sln\",\n default: undefined,\n },\n {\n name: '--proj [string]',\n description:\n \"Override the app project file determined by 'react-native config', e.g. windows\\\\myApp\\\\myApp.vcxproj\",\n default: undefined,\n },\n {\n name: '--msbuildprops [string]',\n description:\n 'Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2',\n },\n {\n name: '--buildLogDirectory [string]',\n description: 'Optional directory where msbuild log files should be stored',\n },\n {\n name: '--info',\n description: 'Dump environment information',\n },\n {\n name: '--direct-debugging [number]',\n description: 'Enable direct debugging on specified port',\n parse: parseDirectDebuggingPort,\n },\n {\n name: '--no-telemetry',\n description:\n 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',\n },\n];\n\nfunction parseBuildArch(arg: string): BuildArch {\n const supportedArches: BuildArch[] = ['x86', 'x64', 'ARM64'];\n for (const supported of supportedArches) {\n if (arg.toLowerCase() === supported.toLowerCase()) {\n return supported;\n }\n }\n\n errorOut(`Unrecognized --arch '${arg}'. Expected one of ${supportedArches}`);\n}\n\nfunction parseDirectDebuggingPort(arg: string): number {\n const num = parseInt(arg, 10);\n\n if (!Number.isInteger(num)) {\n errorOut(`Expected argument '--direct-debugging' to be a number`);\n }\n if (num < 1024 || num >= 65535) {\n errorOut('Direct debugging port it out of range');\n }\n\n return num;\n}\n\nfunction errorOut(arg: string): never {\n console.error(arg);\n process.exit(1);\n}\n"]}
1
+ {"version":3,"file":"runWindowsOptions.js","sourceRoot":"","sources":["../../../src/commands/runWindows/runWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,+DAAmE;AAqDtD,QAAA,iBAAiB,GAAoB;IAChD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,2BAA2B;KACzC;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,+EAA+E;QACjF,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI;KAC/B;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,8CAA8C;QAC3D,OAAO,EAAE,cAAc,CAAC,IAAA,8BAAkB,GAAE,CAAC;QAC7C,KAAK,EAAE,cAAc;KACtB;IACD;QACE,IAAI,EAA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E,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uGAAuG;KAC1G;CACF,CAAC;AAEF,SAAS,cAAc,CAAC,GAAW;IACjC,MAAM,eAAe,GAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7D,KAAK,MAAM,SAAS,IAAI,eAAe,EAAE;QACvC,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,EAAE;YACjD,OAAO,SAAS,CAAC;SAClB;KACF;IAED,QAAQ,CAAC,wBAAwB,GAAG,sBAAsB,eAAe,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,wBAAwB,CAAC,GAAW;IAC3C,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAE9B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;QAC1B,QAAQ,CAAC,uDAAuD,CAAC,CAAC;KACnE;IACD,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,IAAI,KAAK,EAAE;QAC9B,QAAQ,CAAC,uCAAuC,CAAC,CAAC;KACnD;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW;IAC3B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CommandOption} from '@react-native-community/cli-types';\nimport {deviceArchitecture} from '@react-native-windows/telemetry';\n\nexport type BuildArch = 'x86' | 'x64' | 'ARM64';\nexport type BuildConfig = 'Debug' | 'DebugBundle' | 'Release' | 'ReleaseBundle';\n\n/**\n * * Options are the following:\n * release: Boolean - Specifies release build\n * root: String - The root of the application\n * arch: String - The build architecture (ARM64, x86, x64)\n * singleproc: Boolean - opt out of multi-proc builds\n * emulator: Boolean - Deploy to the emulator\n * device: Boolean - Deploy to a device\n * target: String - Device GUID to deploy to\n * remote-debugging: Boolean - Run using remote JS proxy\n * logging: Boolean - Enables logging\n * no-packager: Boolean - Do not launch packager while building\n * bundle: Boolean - Enable Bundle configuration.\n * no-launch: Boolean - Do not launch the app after deployment\n * no-build: Boolean - Do not build the solution\n * no-deploy: Boolean - Do not deploy the app\n * deploy-from-layout: Force deploy from layout, even in release builds\n * sln: String - Solution file to build\n * msbuildprops: String - Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2\n * direct-debugging: Number - Enable direct debugging on specified port\n * no-telemetry: Boolean - Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI\n */\nexport interface RunWindowsOptions {\n release?: boolean;\n root: string;\n arch: BuildArch;\n singleproc?: boolean;\n emulator?: boolean;\n device?: boolean;\n target?: string;\n remoteDebugging?: string;\n logging?: boolean;\n packager?: boolean;\n bundle?: boolean;\n launch?: boolean;\n autolink?: boolean;\n build?: boolean;\n deploy?: boolean;\n deployFromLayout?: boolean;\n sln?: string;\n proj?: string;\n msbuildprops?: string;\n buildLogDirectory?: string;\n info?: boolean;\n directDebugging?: number;\n telemetry?: boolean;\n}\n\nexport const runWindowsOptions: CommandOption[] = [\n {\n name: '--release',\n description: 'Specifies a Release build',\n },\n {\n name: '--root [string]',\n description:\n 'Override the root directory for the project which contains the windows folder',\n default: config => config.root,\n },\n {\n name: '--arch [string]',\n description: 'The build architecture, i.e. ARM64, x86, x64',\n default: parseBuildArch(deviceArchitecture()),\n parse: parseBuildArch,\n },\n {\n name: '--singleproc',\n description: 'Disables multi-proc build',\n },\n {\n name: '--emulator',\n description: 'Deploys the app to an emulator',\n },\n {\n name: '--device',\n description: 'Deploys the app to a connected device',\n },\n {\n name: '--target [string]',\n description: 'Deploys the app to the specified GUID for a device',\n },\n {\n name: '--remote-debugging',\n description: '(Deprecated) Deploys the app in remote debugging mode',\n },\n {\n name: '--logging',\n description: 'Verbose output logging',\n },\n {\n name: '--no-packager',\n description: 'Do not launch the packager while building',\n },\n {\n name: '--bundle',\n description:\n 'Enable Bundle configuration, i.e. ReleaseBundle/DebugBundle rather than Release/Debug',\n },\n {\n name: '--no-launch',\n description: 'Do not launch the app after deployment',\n },\n {\n name: '--no-autolink',\n description: 'Do not run autolinking',\n },\n {\n name: '--no-build',\n description: 'Do not build the solution',\n },\n {\n name: '--no-deploy',\n description: 'Do not deploy the app',\n },\n {\n name: '--deploy-from-layout',\n description: 'Force deploy from layout even in Release builds',\n },\n {\n name: '--sln [string]',\n description:\n \"Override the app solution file determined by 'react-native config', i.e. windows\\\\myApp.sln\",\n default: undefined,\n },\n {\n name: '--proj [string]',\n description:\n \"Override the app project file determined by 'react-native config', i.e. windows\\\\myApp\\\\myApp.vcxproj\",\n default: undefined,\n },\n {\n name: '--msbuildprops [string]',\n description:\n 'Comma separated props to pass to MSBuild, eg: prop1=value1,prop2=value2',\n },\n {\n name: '--buildLogDirectory [string]',\n description: 'Optional directory where MSBuild log files should be stored',\n },\n {\n name: '--info',\n description: 'Dump environment information',\n },\n {\n name: '--direct-debugging [number]',\n description: 'Enable direct debugging on specified port',\n parse: parseDirectDebuggingPort,\n },\n {\n name: '--no-telemetry',\n description:\n 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',\n },\n];\n\nfunction parseBuildArch(arg: string): BuildArch {\n const supportedArches: BuildArch[] = ['x86', 'x64', 'ARM64'];\n for (const supported of supportedArches) {\n if (arg.toLowerCase() === supported.toLowerCase()) {\n return supported;\n }\n }\n\n errorOut(`Unrecognized --arch '${arg}'. Expected one of ${supportedArches}`);\n}\n\nfunction parseDirectDebuggingPort(arg: string): number {\n const num = parseInt(arg, 10);\n\n if (!Number.isInteger(num)) {\n errorOut(`Expected argument '--direct-debugging' to be a number`);\n }\n if (num < 1024 || num >= 65535) {\n errorOut('Direct debugging port it out of range');\n }\n\n return num;\n}\n\nfunction errorOut(arg: string): never {\n console.error(arg);\n process.exit(1);\n}\n"]}
@@ -163,7 +163,7 @@ class MSBuildTools {
163
163
  'Microsoft.Component.MSBuild',
164
164
  getVCToolsByArch(buildArch),
165
165
  ];
166
- const minVersion = process.env.VisualStudioVersion || '17.0';
166
+ const minVersion = process.env.MinimumVisualStudioVersion || process.env.VisualStudioVersion || '17.0';
167
167
  const vsInstallation = (0, vsInstalls_1.findLatestVsInstall)({
168
168
  requires,
169
169
  minVersion,
@@ -171,7 +171,10 @@ class MSBuildTools {
171
171
  prerelease,
172
172
  });
173
173
  if (!vsInstallation) {
174
- if (process.env.VisualStudioVersion != null) {
174
+ if (process.env.MinimumVisualStudioVersion != null) {
175
+ throw new telemetry_1.CodedError('NoMSBuild', `MSBuild tools not found for version ${process.env.MinimumVisualStudioVersion} (from environment). Make sure all required components have been installed`, { MinimumVisualStudioVersionFromEnv: process.env.MinimumVisualStudioVersion });
176
+ }
177
+ else if (process.env.VisualStudioVersion != null) {
175
178
  throw new telemetry_1.CodedError('NoMSBuild', `MSBuild tools not found for version ${process.env.VisualStudioVersion} (from environment). Make sure all required components have been installed`, { VisualStudioVersionFromEnv: process.env.VisualStudioVersion });
176
179
  }
177
180
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"msbuildtools.js","sourceRoot":"","sources":["../../src/utils/msbuildtools.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2BAAiC;AACjC,kEAA0C;AAC1C,gDAAwB;AACxB,kEAA0C;AAC1C,kDAA0B;AAC1B,4CAAoB;AACpB,sDAA4B;AAC5B,wDAAgC;AAChC,uEAAyD;AACzD,+DAO+B;AAC/B,iDAAuC;AAEvC,6CAAiD;AACjD,+DAA2D;AAE3D,MAAqB,YAAY;IAC/B;;;;OAIG;IACH,YACkB,OAAe,EACf,gBAAwB,EACxB,mBAA2B;QAF3B,YAAO,GAAP,OAAO,CAAQ;QACf,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,wBAAmB,GAAnB,mBAAmB,CAAQ;IAC1C,C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*/\n\nimport {totalmem, EOL} from 'os';\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport child_process from 'child_process';\nimport chalk from 'chalk';\nimport os from 'os';\nimport shell from 'shelljs';\nimport Version from './version';\nimport * as checkRequirements from './checkRequirements';\nimport {\n commandWithProgress,\n newInfo,\n newSpinner,\n newSuccess,\n newError,\n powershell,\n} from './commandWithProgress';\nimport {execSync} from 'child_process';\nimport {BuildArch, BuildConfig} from '../commands/runWindows/runWindowsOptions';\nimport {findLatestVsInstall} from './vsInstalls';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nexport default class MSBuildTools {\n /**\n * @param version is something like 17.0 for 2022\n * @param installationPath Path to installation root\n * @param installationVersion is the full version e.g. 17.3.32929.385\n */\n constructor(\n public readonly version: string,\n public readonly installationPath: string,\n public readonly installationVersion: string,\n ) {}\n\n /**\n * @returns directory where x64 msbuild can be found\n */\n msbuildPath() {\n return path.join(this.installationPath, 'MSBuild/Current/Bin/amd64');\n }\n\n cleanProject(slnFile: string) {\n const cmd = `\"${path.join(\n this.msbuildPath(),\n 'msbuild.exe',\n )}\" \"${slnFile}\" /t:Clean`;\n const results = child_process.execSync(cmd).toString().split(EOL);\n results.forEach(result => console.log(chalk.white(result)));\n }\n\n async restorePackageConfigs(\n slnFile: any,\n buildArch: BuildArch,\n buildType: BuildConfig,\n ) {\n const text = 'Restoring NuGet packages ';\n const spinner = newSpinner(text);\n await commandWithProgress(\n spinner,\n text,\n path.join(this.msbuildPath(), 'msbuild.exe'),\n [\n slnFile,\n '/t:Restore',\n '/p:RestoreProjectStyle=PackagesConfig',\n '/p:RestorePackagesConfig=true',\n `/p:Platform=${buildArch}`,\n `/p:Configuration=${buildType}`,\n ],\n true,\n 'MSBuildError',\n );\n }\n\n async buildProject(\n slnFile: string,\n buildType: BuildConfig,\n buildArch: BuildArch,\n msBuildProps: Record<string, string>,\n verbose: boolean,\n target: 'build' | 'deploy',\n buildLogDirectory: string | undefined,\n singleproc?: boolean,\n ) {\n newSuccess(`Found Solution: ${slnFile}`);\n newInfo(`Build configuration: ${buildType}`);\n newInfo(`Build platform: ${buildArch}`);\n\n const verbosityOption = verbose ? 'normal' : 'minimal';\n const logPrefix = path.join(\n buildLogDirectory || os.tmpdir(),\n `msbuild_${process.pid}_${target}`,\n );\n\n const errorLog = logPrefix + '.err';\n const warnLog = logPrefix + '.wrn';\n\n const localBinLog = target === 'build' ? '' : ':deploy.binlog';\n const binlog = buildLogDirectory ? `:${logPrefix}.binlog` : localBinLog;\n\n const args = [\n `/clp:NoSummary;NoItemAndPropertyList;Verbosity=${verbosityOption}`,\n '/nologo',\n `/p:Configuration=${buildType}`,\n `/p:Platform=${buildArch}`,\n '/p:AppxBundle=Never',\n `/bl${binlog}`,\n `/flp1:errorsonly;logfile=${errorLog}`,\n `/flp2:warningsonly;logfile=${warnLog}`,\n ];\n\n // Building projects in parallel increases compiler memory usage and\n // doesn't lead to dramatic performance gains (See #4739). Only enable\n // parallel builds on machines with >16GB of memory to avoid OOM errors\n const highMemory = totalmem() > 16 * 1024 * 1024 * 1024;\n const enableParallelBuilds = singleproc === false || highMemory;\n\n if (enableParallelBuilds) {\n args.push('/maxCpuCount');\n }\n\n if (target === 'build') {\n args.push('/restore', '/p:RestorePackagesConfig=true');\n } else {\n args.push(`/t:Deploy`);\n }\n\n Object.keys(msBuildProps).forEach(key => {\n args.push(`/p:${key}=${msBuildProps[key]}`);\n });\n\n try {\n checkRequirements.isWinSdkPresent('10.0');\n } catch (e) {\n newError((e as Error).message);\n throw e;\n }\n\n if (verbose) {\n console.log(`Running MSBuild with args ${args.join(' ')}`);\n }\n\n const progressName =\n target === 'deploy' ? 'Deploying Solution' : 'Building Solution';\n const spinner = newSpinner(progressName);\n try {\n await commandWithProgress(\n spinner,\n progressName,\n path.join(this.msbuildPath(), 'msbuild.exe'),\n [slnFile].concat(args),\n verbose,\n 'MSBuildError',\n );\n } catch (e) {\n let error = e;\n if (e instanceof CodedError) {\n const origCodedError = e as CodedError;\n if (origCodedError.type === 'MSBuildError') {\n // Try to parse msbuild errors from errorLog\n const errorLogContents = (await fs.readFile(errorLog))\n .toString()\n .split(EOL)\n .filter(s => s)\n .map(s => s.trim());\n if (errorLogContents.length > 0) {\n const firstMessage = errorLogContents[0];\n error = new CodedError(\n 'MSBuildError',\n firstMessage,\n origCodedError.data,\n );\n // Hide error messages in a field that won't automatically get reported\n // with telemetry but is still available to be parsed and sanitized\n (error as any).msBuildErrorMessages = errorLogContents;\n }\n }\n }\n throw error;\n }\n // If we have no errors, delete the error log when we're done\n if ((await fs.stat(errorLog)).size === 0) {\n await fs.unlink(errorLog);\n }\n }\n\n static findAvailableVersion(\n buildArch: BuildArch,\n verbose: boolean,\n prerelease?: boolean,\n ): MSBuildTools {\n // https://aka.ms/vs/workloads\n const requires = [\n 'Microsoft.Component.MSBuild',\n getVCToolsByArch(buildArch),\n ];\n const minVersion = process.env.VisualStudioVersion || '17.0';\n const vsInstallation = findLatestVsInstall({\n requires,\n minVersion,\n verbose,\n prerelease,\n });\n\n if (!vsInstallation) {\n if (process.env.VisualStudioVersion != null) {\n throw new CodedError(\n 'NoMSBuild',\n `MSBuild tools not found for version ${process.env.VisualStudioVersion} (from environment). Make sure all required components have been installed`,\n {VisualStudioVersionFromEnv: process.env.VisualStudioVersion},\n );\n } else {\n throw new CodedError(\n 'NoMSBuild',\n `Could not find MSBuild with VCTools for Visual Studio ${minVersion} or later. Make sure all required components have been installed`,\n {minVersion: minVersion},\n );\n }\n }\n\n const toolsPath = path.join(\n vsInstallation.installationPath,\n 'MSBuild/Current/Bin/amd64',\n );\n\n if (fs.existsSync(toolsPath)) {\n if (verbose) {\n newSuccess(\n `Found compatible MSBuild at ${toolsPath} (${vsInstallation.installationVersion})`,\n );\n }\n return new MSBuildTools(\n minVersion,\n vsInstallation.installationPath,\n vsInstallation.installationVersion,\n );\n } else {\n throw new CodedError(\n 'NoMSBuild',\n `MSBuild path '${toolsPath} does not exist'`,\n );\n }\n }\n\n static getAllAvailableUAPVersions(): Version[] {\n const results: Version[] = [];\n\n const programFilesFolder =\n process.env['ProgramFiles(x86)'] || process.env.ProgramFiles;\n // No Program Files folder found, so we won't be able to find UAP SDK\n if (!programFilesFolder) {\n return results;\n }\n\n let uapFolderPath = path.join(\n programFilesFolder,\n 'Windows Kits',\n '10',\n 'Platforms',\n 'UAP',\n );\n\n if (!shell.test('-e', uapFolderPath)) {\n // Check other installation folder from reg\n const sdkFolder = getSDK10InstallationFolder();\n if (sdkFolder) {\n uapFolderPath = path.join(sdkFolder, 'Platforms', 'UAP');\n }\n }\n\n // No UAP SDK exists on this machine\n if (!shell.test('-e', uapFolderPath)) {\n return results;\n }\n\n shell\n .ls(uapFolderPath)\n .filter(uapDir => shell.test('-d', path.join(uapFolderPath, uapDir)))\n .map(Version.tryParse)\n .forEach(version => version && results.push(version));\n\n return results;\n }\n\n evaluateMSBuildProperties(\n solutionFile: string,\n projectFile: string,\n propertyNames?: string[],\n extraMsBuildProps?: Record<string, string>,\n ): Record<string, string> {\n const spinner = newSpinner('Running Eval-MsBuildProperties.ps1');\n\n try {\n const msbuildEvalScriptPath = path.resolve(\n __dirname,\n '..',\n '..',\n 'src',\n 'powershell',\n 'Eval-MsBuildProperties.ps1',\n );\n\n let command = `${powershell} -ExecutionPolicy Unrestricted -NoProfile \"${msbuildEvalScriptPath}\" -SolutionFile '${solutionFile}' -ProjectFile '${projectFile}' -MSBuildPath '${this.msbuildPath()}'`;\n\n if (propertyNames && propertyNames.length > 0) {\n command += ` -PropertyNames '${propertyNames.join(',')}'`;\n }\n\n if (extraMsBuildProps) {\n command += \" -ExtraMSBuildProps '\";\n for (const extraProp in extraMsBuildProps) {\n if (!(extraProp in Object.prototype)) {\n command += `,${extraProp}=${extraMsBuildProps[extraProp]}`;\n }\n }\n command += \"'\";\n }\n\n const commandOutput = execSync(command).toString();\n spinner.succeed();\n\n const properties = JSON.parse(commandOutput) as Record<string, string>;\n spinner.succeed();\n return properties;\n } catch (e) {\n spinner.fail(\n 'Running Eval-MsBuildProperties.ps1 failed: ' + (e as Error).message,\n );\n throw e;\n }\n }\n}\n\nfunction getVCToolsByArch(buildArch: BuildArch): string {\n switch (buildArch) {\n case 'x86':\n case 'x64':\n return 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64';\n case 'ARM64':\n return 'Microsoft.VisualStudio.Component.VC.Tools.ARM64';\n }\n}\n\nfunction getSDK10InstallationFolder(): string {\n const folder = '';\n\n const execString =\n 'reg query \"HKLM\\\\SOFTWARE\\\\Microsoft\\\\Microsoft SDKs\\\\Windows\\\\v10.0\" /s /v InstallationFolder /reg:32';\n let output;\n try {\n output = execSync(execString).toString();\n } catch (e) {\n return folder;\n }\n\n const re =\n /\\\\Microsoft SDKs\\\\Windows\\\\v10.0\\s*InstallationFolder\\s+REG_SZ\\s+(.*)/gim;\n const match = re.exec(output);\n if (match) {\n return match[1];\n }\n\n return folder;\n}\n"]}
1
+ {"version":3,"file":"msbuildtools.js","sourceRoot":"","sources":["../../src/utils/msbuildtools.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2BAAiC;AACjC,kEAA0C;AAC1C,gDAAwB;AACxB,kEAA0C;AAC1C,kDAA0B;AAC1B,4CAAoB;AACpB,sDAA4B;AAC5B,wDAAgC;AAChC,uEAAyD;AACzD,+DAO+B;AAC/B,iDAAuC;AAEvC,6CAAiD;AACjD,+DAA2D;AAE3D,MAAqB,YAAY;IAC/B;;;;OAIG;IACH,YACkB,OAAe,EACf,gBAAwB,EACxB,mBAA2B;QAF3B,YAAO,GAAP,OAAO,CAAQ;QACf,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,wBAAmB,GAAnB,mBAAmB,CAAQ;IAC1C,CAAC;IAEJ;;OAEG;IACH,WAAW;QACT,OAAO,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,2BAA2B,CAAC,CAAC;IACvE,CAAC;IAED,YAAY,CAAC,OAAe;QAC1B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AAC,CAAC,CAAC,CAAC;KACjB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {totalmem, EOL} from 'os';\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport child_process from 'child_process';\nimport chalk from 'chalk';\nimport os from 'os';\nimport shell from 'shelljs';\nimport Version from './version';\nimport * as checkRequirements from './checkRequirements';\nimport {\n commandWithProgress,\n newInfo,\n newSpinner,\n newSuccess,\n newError,\n powershell,\n} from './commandWithProgress';\nimport {execSync} from 'child_process';\nimport {BuildArch, BuildConfig} from '../commands/runWindows/runWindowsOptions';\nimport {findLatestVsInstall} from './vsInstalls';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nexport default class MSBuildTools {\n /**\n * @param version is something like 17.0 for 2022\n * @param installationPath Path to installation root\n * @param installationVersion is the full version e.g. 17.3.32929.385\n */\n constructor(\n public readonly version: string,\n public readonly installationPath: string,\n public readonly installationVersion: string,\n ) {}\n\n /**\n * @returns directory where x64 msbuild can be found\n */\n msbuildPath() {\n return path.join(this.installationPath, 'MSBuild/Current/Bin/amd64');\n }\n\n cleanProject(slnFile: string) {\n const cmd = `\"${path.join(\n this.msbuildPath(),\n 'msbuild.exe',\n )}\" \"${slnFile}\" /t:Clean`;\n const results = child_process.execSync(cmd).toString().split(EOL);\n results.forEach(result => console.log(chalk.white(result)));\n }\n\n async restorePackageConfigs(\n slnFile: any,\n buildArch: BuildArch,\n buildType: BuildConfig,\n ) {\n const text = 'Restoring NuGet packages ';\n const spinner = newSpinner(text);\n await commandWithProgress(\n spinner,\n text,\n path.join(this.msbuildPath(), 'msbuild.exe'),\n [\n slnFile,\n '/t:Restore',\n '/p:RestoreProjectStyle=PackagesConfig',\n '/p:RestorePackagesConfig=true',\n `/p:Platform=${buildArch}`,\n `/p:Configuration=${buildType}`,\n ],\n true,\n 'MSBuildError',\n );\n }\n\n async buildProject(\n slnFile: string,\n buildType: BuildConfig,\n buildArch: BuildArch,\n msBuildProps: Record<string, string>,\n verbose: boolean,\n target: 'build' | 'deploy',\n buildLogDirectory: string | undefined,\n singleproc?: boolean,\n ) {\n newSuccess(`Found Solution: ${slnFile}`);\n newInfo(`Build configuration: ${buildType}`);\n newInfo(`Build platform: ${buildArch}`);\n\n const verbosityOption = verbose ? 'normal' : 'minimal';\n const logPrefix = path.join(\n buildLogDirectory || os.tmpdir(),\n `msbuild_${process.pid}_${target}`,\n );\n\n const errorLog = logPrefix + '.err';\n const warnLog = logPrefix + '.wrn';\n\n const localBinLog = target === 'build' ? '' : ':deploy.binlog';\n const binlog = buildLogDirectory ? `:${logPrefix}.binlog` : localBinLog;\n\n const args = [\n `/clp:NoSummary;NoItemAndPropertyList;Verbosity=${verbosityOption}`,\n '/nologo',\n `/p:Configuration=${buildType}`,\n `/p:Platform=${buildArch}`,\n '/p:AppxBundle=Never',\n `/bl${binlog}`,\n `/flp1:errorsonly;logfile=${errorLog}`,\n `/flp2:warningsonly;logfile=${warnLog}`,\n ];\n\n // Building projects in parallel increases compiler memory usage and\n // doesn't lead to dramatic performance gains (See #4739). Only enable\n // parallel builds on machines with >16GB of memory to avoid OOM errors\n const highMemory = totalmem() > 16 * 1024 * 1024 * 1024;\n const enableParallelBuilds = singleproc === false || highMemory;\n\n if (enableParallelBuilds) {\n args.push('/maxCpuCount');\n }\n\n if (target === 'build') {\n args.push('/restore', '/p:RestorePackagesConfig=true');\n } else {\n args.push(`/t:Deploy`);\n }\n\n Object.keys(msBuildProps).forEach(key => {\n args.push(`/p:${key}=${msBuildProps[key]}`);\n });\n\n try {\n checkRequirements.isWinSdkPresent('10.0');\n } catch (e) {\n newError((e as Error).message);\n throw e;\n }\n\n if (verbose) {\n console.log(`Running MSBuild with args ${args.join(' ')}`);\n }\n\n const progressName =\n target === 'deploy' ? 'Deploying Solution' : 'Building Solution';\n const spinner = newSpinner(progressName);\n try {\n await commandWithProgress(\n spinner,\n progressName,\n path.join(this.msbuildPath(), 'msbuild.exe'),\n [slnFile].concat(args),\n verbose,\n 'MSBuildError',\n );\n } catch (e) {\n let error = e;\n if (e instanceof CodedError) {\n const origCodedError = e as CodedError;\n if (origCodedError.type === 'MSBuildError') {\n // Try to parse msbuild errors from errorLog\n const errorLogContents = (await fs.readFile(errorLog))\n .toString()\n .split(EOL)\n .filter(s => s)\n .map(s => s.trim());\n if (errorLogContents.length > 0) {\n const firstMessage = errorLogContents[0];\n error = new CodedError(\n 'MSBuildError',\n firstMessage,\n origCodedError.data,\n );\n // Hide error messages in a field that won't automatically get reported\n // with telemetry but is still available to be parsed and sanitized\n (error as any).msBuildErrorMessages = errorLogContents;\n }\n }\n }\n throw error;\n }\n // If we have no errors, delete the error log when we're done\n if ((await fs.stat(errorLog)).size === 0) {\n await fs.unlink(errorLog);\n }\n }\n\n static findAvailableVersion(\n buildArch: BuildArch,\n verbose: boolean,\n prerelease?: boolean,\n ): MSBuildTools {\n // https://aka.ms/vs/workloads\n const requires = [\n 'Microsoft.Component.MSBuild',\n getVCToolsByArch(buildArch),\n ];\n const minVersion = process.env.MinimumVisualStudioVersion || process.env.VisualStudioVersion || '17.0';\n const vsInstallation = findLatestVsInstall({\n requires,\n minVersion,\n verbose,\n prerelease,\n });\n\n if (!vsInstallation) {\n if (process.env.MinimumVisualStudioVersion != null) {\n throw new CodedError(\n 'NoMSBuild',\n `MSBuild tools not found for version ${process.env.MinimumVisualStudioVersion} (from environment). Make sure all required components have been installed`,\n {MinimumVisualStudioVersionFromEnv: process.env.MinimumVisualStudioVersion},\n );\n } else if (process.env.VisualStudioVersion != null) {\n throw new CodedError(\n 'NoMSBuild',\n `MSBuild tools not found for version ${process.env.VisualStudioVersion} (from environment). Make sure all required components have been installed`,\n {VisualStudioVersionFromEnv: process.env.VisualStudioVersion},\n );\n } else {\n throw new CodedError(\n 'NoMSBuild',\n `Could not find MSBuild with VCTools for Visual Studio ${minVersion} or later. Make sure all required components have been installed`,\n {minVersion: minVersion},\n );\n }\n }\n\n const toolsPath = path.join(\n vsInstallation.installationPath,\n 'MSBuild/Current/Bin/amd64',\n );\n\n if (fs.existsSync(toolsPath)) {\n if (verbose) {\n newSuccess(\n `Found compatible MSBuild at ${toolsPath} (${vsInstallation.installationVersion})`,\n );\n }\n return new MSBuildTools(\n minVersion,\n vsInstallation.installationPath,\n vsInstallation.installationVersion,\n );\n } else {\n throw new CodedError(\n 'NoMSBuild',\n `MSBuild path '${toolsPath} does not exist'`,\n );\n }\n }\n\n static getAllAvailableUAPVersions(): Version[] {\n const results: Version[] = [];\n\n const programFilesFolder =\n process.env['ProgramFiles(x86)'] || process.env.ProgramFiles;\n // No Program Files folder found, so we won't be able to find UAP SDK\n if (!programFilesFolder) {\n return results;\n }\n\n let uapFolderPath = path.join(\n programFilesFolder,\n 'Windows Kits',\n '10',\n 'Platforms',\n 'UAP',\n );\n\n if (!shell.test('-e', uapFolderPath)) {\n // Check other installation folder from reg\n const sdkFolder = getSDK10InstallationFolder();\n if (sdkFolder) {\n uapFolderPath = path.join(sdkFolder, 'Platforms', 'UAP');\n }\n }\n\n // No UAP SDK exists on this machine\n if (!shell.test('-e', uapFolderPath)) {\n return results;\n }\n\n shell\n .ls(uapFolderPath)\n .filter(uapDir => shell.test('-d', path.join(uapFolderPath, uapDir)))\n .map(Version.tryParse)\n .forEach(version => version && results.push(version));\n\n return results;\n }\n\n evaluateMSBuildProperties(\n solutionFile: string,\n projectFile: string,\n propertyNames?: string[],\n extraMsBuildProps?: Record<string, string>,\n ): Record<string, string> {\n const spinner = newSpinner('Running Eval-MsBuildProperties.ps1');\n\n try {\n const msbuildEvalScriptPath = path.resolve(\n __dirname,\n '..',\n '..',\n 'src',\n 'powershell',\n 'Eval-MsBuildProperties.ps1',\n );\n\n let command = `${powershell} -ExecutionPolicy Unrestricted -NoProfile \"${msbuildEvalScriptPath}\" -SolutionFile '${solutionFile}' -ProjectFile '${projectFile}' -MSBuildPath '${this.msbuildPath()}'`;\n\n if (propertyNames && propertyNames.length > 0) {\n command += ` -PropertyNames '${propertyNames.join(',')}'`;\n }\n\n if (extraMsBuildProps) {\n command += \" -ExtraMSBuildProps '\";\n for (const extraProp in extraMsBuildProps) {\n if (!(extraProp in Object.prototype)) {\n command += `,${extraProp}=${extraMsBuildProps[extraProp]}`;\n }\n }\n command += \"'\";\n }\n\n const commandOutput = execSync(command).toString();\n spinner.succeed();\n\n const properties = JSON.parse(commandOutput) as Record<string, string>;\n spinner.succeed();\n return properties;\n } catch (e) {\n spinner.fail(\n 'Running Eval-MsBuildProperties.ps1 failed: ' + (e as Error).message,\n );\n throw e;\n }\n }\n}\n\nfunction getVCToolsByArch(buildArch: BuildArch): string {\n switch (buildArch) {\n case 'x86':\n case 'x64':\n return 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64';\n case 'ARM64':\n return 'Microsoft.VisualStudio.Component.VC.Tools.ARM64';\n }\n}\n\nfunction getSDK10InstallationFolder(): string {\n const folder = '';\n\n const execString =\n 'reg query \"HKLM\\\\SOFTWARE\\\\Microsoft\\\\Microsoft SDKs\\\\Windows\\\\v10.0\" /s /v InstallationFolder /reg:32';\n let output;\n try {\n output = execSync(execString).toString();\n } catch (e) {\n return folder;\n }\n\n const re =\n /\\\\Microsoft SDKs\\\\Windows\\\\v10.0\\s*InstallationFolder\\s+REG_SZ\\s+(.*)/gim;\n const match = re.exec(output);\n if (match) {\n return match[1];\n }\n\n return folder;\n}\n"]}
@@ -52,11 +52,11 @@ function enumerateVsInstalls(opts) {
52
52
  let maxVersion;
53
53
  if (minVersionSemVer) {
54
54
  minVersion = minVersionSemVer.toString();
55
- maxVersion = (minVersionSemVer.major + 1).toFixed(1);
55
+ maxVersion = `${(minVersionSemVer.major + 1)}.0`;
56
56
  }
57
57
  else if (!Number.isNaN(minVersionNum)) {
58
- minVersion = minVersionNum.toFixed(1);
59
- maxVersion = (Math.floor(minVersionNum) + 1).toFixed(1);
58
+ minVersion = Number.isInteger(minVersionNum) ? `${minVersionNum}.0` : minVersionNum.toString();
59
+ maxVersion = `${(Math.floor(minVersionNum) + 1)}.0`;
60
60
  }
61
61
  else {
62
62
  // Unable to parse minVersion and determine maxVersion,
@@ -1 +1 @@
1
- {"version":3,"file":"vsInstalls.js","sourceRoot":"","sources":["../../src/utils/vsInstalls.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,+DAA2D;AAC3D,iDAAuC;AACvC,kEAA0C;AAC1C,gDAAwB;AACxB,oDAA4B;AAY5B;;;;;GAKG;AACH,SAAS,OAAO,CAAC,IAAc,EAAE,OAAiB;IAChD,gEAAgE;IAChE,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAC3B,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,YAAa,EAC7D,gDAAgD,CACjD,CAAC;IAEF,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,WAAW,CAAC,CAAC;KACvD;IAED,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAC/B,MAAM,IAAI,sBAAU,CAClB,WAAW,EACX,6BAA6B,WAAW,EAAE,CAC3C,CAAC;KACH;IAED,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,YAAY,CAAC;IACvD,MAAM,OAAO,GAAG,GAAG,QAAQ,gBAAgB,QAAQ,4BAA4B,WAAW,KAAK,IAAI,CAAC,IAAI,CACtG,GAAG,CACJ,qBAAqB,CAAC;IACvB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,wBAAQ,EAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEtD,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE;QACxB,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,4BAA4B,CAAC;KAC/D;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,mBAA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,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;KACnD;IAED,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACtB;IAED,IAAI,IAAI,CAAC,UAAU,EAAE;QACnB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;KAC1B;IAED,OAAO,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAzDD,kDAyDC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,IAKnC;IACC,IAAI,QAAQ,GAAG,mBAAmB,CAAC,EAAC,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;IAE5D,IAAI,IAAI,CAAC,UAAU,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1C,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,MAAM,CAAC,CAAC;KAC1D;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;KACpB;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAjBD,kDAiBC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CodedError} from '@react-native-windows/telemetry';\nimport {execSync} from 'child_process';\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport semver from 'semver';\n\n/**\n * A subset of the per-instance properties returned by vswhere\n */\ninterface VisualStudioInstallation {\n instanceId: string;\n installationPath: string;\n installationVersion: string;\n prerelease: string;\n}\n\n/**\n * Helper to run vswhere in JSON mode\n *\n * @param args Arguments to pass to vsWhere\n * @param verbose enable verbose logging\n */\nfunction vsWhere(args: string[], verbose?: boolean): any[] {\n // This path is maintained and VS has promised to keep it valid.\n const vsWherePath = path.join(\n process.env['ProgramFiles(x86)'] || process.env.ProgramFiles!,\n '/Microsoft Visual Studio/Installer/vswhere.exe',\n );\n\n if (verbose) {\n console.log('Looking for vswhere at: ' + vsWherePath);\n }\n\n if (!fs.existsSync(vsWherePath)) {\n throw new CodedError(\n 'NoVSWhere',\n `Unable to find vswhere at ${vsWherePath}`,\n );\n }\n\n const system32 = `${process.env.SystemRoot}\\\\System32`;\n const cmdline = `${system32}\\\\cmd.exe /c ${system32}\\\\chcp.com 65001>nul && \"${vsWherePath}\" ${args.join(\n ' ',\n )} -format json -utf8`;\n const json = JSON.parse(execSync(cmdline).toString());\n\n for (const entry of json) {\n entry.prerelease = entry.catalog.productMilestoneIsPreRelease;\n }\n\n return json;\n}\n\n/**\n * Enumerate the installed versions of Visual Studio\n */\nexport function enumerateVsInstalls(opts: {\n requires?: string[];\n minVersion?: string;\n verbose?: boolean;\n latest?: boolean;\n prerelease?: boolean;\n}): VisualStudioInstallation[] {\n const args: string[] = [];\n\n if (opts.minVersion) {\n // VS 2019 ex: minVersion == 16.7 => [16.7,17.0)\n // VS 2022 ex: minVersion == 17.0 => [17.0,18.0)\n\n // Try to parse minVersion as both a Number and SemVer\n const minVersionNum = Number(opts.minVersion);\n const minVersionSemVer = semver.parse(opts.minVersion);\n\n let minVersion: string;\n let maxVersion: string;\n\n if (minVersionSemVer) {\n minVersion = minVersionSemVer.toString();\n maxVersion = (minVersionSemVer.major + 1).toFixed(1);\n } else if (!Number.isNaN(minVersionNum)) {\n minVersion = minVersionNum.toFixed(1);\n maxVersion = (Math.floor(minVersionNum) + 1).toFixed(1);\n } else {\n // Unable to parse minVersion and determine maxVersion,\n // caller will throw error that version couldn't be found.\n return [];\n }\n\n const versionRange =\n `[${minVersion},${maxVersion}` + (opts.prerelease ? ']' : ')');\n\n if (opts.verbose) {\n console.log(\n `Looking for VS installs with version range: ${versionRange}`,\n );\n }\n\n args.push(`-version ${versionRange}`);\n }\n\n if (opts.requires) {\n args.push(`-requires ${opts.requires.join(' ')}`);\n }\n\n if (opts.latest) {\n args.push('-latest');\n }\n\n if (opts.prerelease) {\n args.push('-prerelease');\n }\n\n return vsWhere(args, opts.verbose);\n}\n\n/**\n * Find the latest available VS installation that matches the given constraints\n */\nexport function findLatestVsInstall(opts: {\n requires?: string[];\n minVersion?: string;\n verbose?: boolean;\n prerelease?: boolean;\n}): VisualStudioInstallation | null {\n let installs = enumerateVsInstalls({...opts, latest: true});\n\n if (opts.prerelease && installs.length > 0) {\n installs = installs.filter(x => x.prerelease === 'True');\n }\n\n if (installs.length > 0) {\n return installs[0];\n } else {\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"vsInstalls.js","sourceRoot":"","sources":["../../src/utils/vsInstalls.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,+DAA2D;AAC3D,iDAAuC;AACvC,kEAA0C;AAC1C,gDAAwB;AACxB,oDAA4B;AAY5B;;;;;GAKG;AACH,SAAS,OAAO,CAAC,IAAc,EAAE,OAAiB;IAChD,gEAAgE;IAChE,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAC3B,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,YAAa,EAC7D,gDAAgD,CACjD,CAAC;IAEF,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,WAAW,CAAC,CAAC;KACvD;IAED,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAC/B,MAAM,IAAI,sBAAU,CAClB,WAAW,EACX,6BAA6B,WAAW,EAAE,CAC3C,CAAC;KACH;IAED,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,YAAY,CAAC;IACvD,MAAM,OAAO,GAAG,GAAG,QAAQ,gBAAgB,QAAQ,4BAA4B,WAAW,KAAK,IAAI,CAAC,IAAI,CACtG,GAAG,CACJ,qBAAqB,CAAC;IACvB,MAAM,IAA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C,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAEjE,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,OAAO,CAAC,GAAG,CACT,+CAA+C,YAAY,EAAE,CAC9D,CAAC;SACH;QAED,IAAI,CAAC,IAAI,CAAC,YAAY,YAAY,EAAE,CAAC,CAAC;KACvC;IAED,IAAI,IAAI,CAAC,QAAQ,EAAE;QACjB,IAAI,CAAC,IAAI,CAAC,aAAa,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;KACnD;IAED,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;KACtB;IAED,IAAI,IAAI,CAAC,UAAU,EAAE;QACnB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;KAC1B;IAED,OAAO,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAzDD,kDAyDC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,IAKnC;IACC,IAAI,QAAQ,GAAG,mBAAmB,CAAC,EAAC,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;IAE5D,IAAI,IAAI,CAAC,UAAU,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QAC1C,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,MAAM,CAAC,CAAC;KAC1D;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;KACpB;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAjBD,kDAiBC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CodedError} from '@react-native-windows/telemetry';\nimport {execSync} from 'child_process';\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport semver from 'semver';\n\n/**\n * A subset of the per-instance properties returned by vswhere\n */\ninterface VisualStudioInstallation {\n instanceId: string;\n installationPath: string;\n installationVersion: string;\n prerelease: string;\n}\n\n/**\n * Helper to run vswhere in JSON mode\n *\n * @param args Arguments to pass to vsWhere\n * @param verbose enable verbose logging\n */\nfunction vsWhere(args: string[], verbose?: boolean): any[] {\n // This path is maintained and VS has promised to keep it valid.\n const vsWherePath = path.join(\n process.env['ProgramFiles(x86)'] || process.env.ProgramFiles!,\n '/Microsoft Visual Studio/Installer/vswhere.exe',\n );\n\n if (verbose) {\n console.log('Looking for vswhere at: ' + vsWherePath);\n }\n\n if (!fs.existsSync(vsWherePath)) {\n throw new CodedError(\n 'NoVSWhere',\n `Unable to find vswhere at ${vsWherePath}`,\n );\n }\n\n const system32 = `${process.env.SystemRoot}\\\\System32`;\n const cmdline = `${system32}\\\\cmd.exe /c ${system32}\\\\chcp.com 65001>nul && \"${vsWherePath}\" ${args.join(\n ' ',\n )} -format json -utf8`;\n const json = JSON.parse(execSync(cmdline).toString());\n\n for (const entry of json) {\n entry.prerelease = entry.catalog.productMilestoneIsPreRelease;\n }\n\n return json;\n}\n\n/**\n * Enumerate the installed versions of Visual Studio\n */\nexport function enumerateVsInstalls(opts: {\n requires?: string[];\n minVersion?: string;\n verbose?: boolean;\n latest?: boolean;\n prerelease?: boolean;\n}): VisualStudioInstallation[] {\n const args: string[] = [];\n\n if (opts.minVersion) {\n // VS 2019 ex: minVersion == 16.7 => [16.7,17.0)\n // VS 2022 ex: minVersion == 17.0 => [17.0,18.0)\n\n // Try to parse minVersion as both a Number and SemVer\n const minVersionNum = Number(opts.minVersion);\n const minVersionSemVer = semver.parse(opts.minVersion);\n\n let minVersion: string;\n let maxVersion: string;\n\n if (minVersionSemVer) {\n minVersion = minVersionSemVer.toString();\n maxVersion = `${(minVersionSemVer.major + 1)}.0`;\n } else if (!Number.isNaN(minVersionNum)) {\n minVersion = Number.isInteger(minVersionNum) ? `${minVersionNum}.0` : minVersionNum.toString();\n maxVersion = `${(Math.floor(minVersionNum) + 1)}.0`;\n } else {\n // Unable to parse minVersion and determine maxVersion,\n // caller will throw error that version couldn't be found.\n return [];\n }\n\n const versionRange =\n `[${minVersion},${maxVersion}` + (opts.prerelease ? ']' : ')');\n\n if (opts.verbose) {\n console.log(\n `Looking for VS installs with version range: ${versionRange}`,\n );\n }\n\n args.push(`-version ${versionRange}`);\n }\n\n if (opts.requires) {\n args.push(`-requires ${opts.requires.join(' ')}`);\n }\n\n if (opts.latest) {\n args.push('-latest');\n }\n\n if (opts.prerelease) {\n args.push('-prerelease');\n }\n\n return vsWhere(args, opts.verbose);\n}\n\n/**\n * Find the latest available VS installation that matches the given constraints\n */\nexport function findLatestVsInstall(opts: {\n requires?: string[];\n minVersion?: string;\n verbose?: boolean;\n prerelease?: boolean;\n}): VisualStudioInstallation | null {\n let installs = enumerateVsInstalls({...opts, latest: true});\n\n if (opts.prerelease && installs.length > 0) {\n installs = installs.filter(x => x.prerelease === 'True');\n }\n\n if (installs.length > 0) {\n return installs[0];\n } else {\n return null;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-windows/cli",
3
- "version": "0.0.0-canary.223",
3
+ "version": "0.0.0-canary.225",
4
4
  "license": "MIT",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "repository": {