@react-native-windows/cli 0.78.3 → 0.79.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82,7 +82,10 @@ class CodeGenWindows {
82
82
  const generators = (_b = pkgJson.codegenConfig.windows.generators) !== null && _b !== void 0 ? _b : [
83
83
  'modulesWindows',
84
84
  ];
85
- const jsRootPathRelative = path_1.default.relative(process.cwd(), jsRootDir);
85
+ const jsRootPathRelative = path_1.default
86
+ .relative(process.cwd(), jsRootDir)
87
+ .split(path_1.default.sep)
88
+ .join('/');
86
89
  const options = {
87
90
  files: [
88
91
  `${jsRootPathRelative}${jsRootPathRelative ? '/' : ''}**/*Native*.[jt]s`,
@@ -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;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C,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 componentsWindows: generators.indexOf('componentsWindows') !== -1,\n internalComponents: generators.indexOf('internalComponents') !== -1,\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 `npx @react-native-community/cli 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-community/cli 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"]}
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,MA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BAAW,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\n .relative(process.cwd(), jsRootDir)\n .split(path.sep)\n .join('/');\n const options: RnwCodeGenOptions = {\n files: [\n `${jsRootPathRelative}${\n jsRootPathRelative ? '/' : ''\n }**/*Native*.[jt]s`,\n ],\n componentsWindows: generators.indexOf('componentsWindows') !== -1,\n internalComponents: generators.indexOf('internalComponents') !== -1,\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 `npx @react-native-community/cli 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-community/cli 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"]}
@@ -404,7 +404,10 @@ function getExperimentalFeatures(solutionDir) {
404
404
  exports.getExperimentalFeatures = getExperimentalFeatures;
405
405
  function getRnwConfig(root, projectFile) {
406
406
  var _a, _b;
407
- const pkgJson = require(path_1.default.join(root, 'package.json'));
407
+ const pkgPath = path_1.default.join(root, 'package.json');
408
+ const pkgJson = fs_1.default.existsSync(pkgPath)
409
+ ? require(path_1.default.join(root, 'package.json'))
410
+ : {};
408
411
  const config = (_a = pkgJson['react-native-windows']) !== null && _a !== void 0 ? _a : {};
409
412
  // if init-windows is missing (most existing projects), try to auto-calculate it
410
413
  (_b = config['init-windows']) !== null && _b !== void 0 ? _b : (config['init-windows'] = {});
@@ -1 +1 @@
1
- {"version":3,"file":"configUtils.js","sourceRoot":"","sources":["../../../src/commands/config/configUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,gDAAwB;AAExB,2CAAyC;AACzC,kDAA0B;AAC1B,+DAA2D;AAE3D,MAAM,aAAa,GAAG,eAAK,CAAC,aAAa,CAAC;IACxC,OAAO,EAAE,qDAAqD;CAC/D,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,MAAc,EAAE,eAAuB;IAC/D,MAAM,KAAK,GAAG,cAAI,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,EAAE;QACxD,GAAG,EAAE,MAAM;QACX,MAAM,EAAE;YACN,iBAAiB;YACjB,aAAa;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QAAQ,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC;KAC1D;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AApBD,0DAoBC;AAED,SAAgB,YAAY,CAC1B,IAAY,EACZ,WAAmB;;IAEnB,MAAM,OAAO,GAAG,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;IAEzD,MAAM,MAAM,GAAwB,MAAA,OAAO,CAAC,sBAAsB,CAAC,mCAAI,EAAE,CAAC;IAE1E,gFAAgF;IAChF,MAAA,MAAM,CAAC,cAAc,qCAArB,MAAM,CAAC,cAAc,IAAM,EAAE,EAAC;IAC9B,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE;QACpC,MAAM,IAAI,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;QAC7C,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE;YAC5D,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,GAAG,GAChC,IAAI,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAC5C,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;SAC3C;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AApBD,oCAoBC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport glob from 'glob';\n\nimport {DOMParser} from '@xmldom/xmldom';\nimport xpath from 'xpath';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nconst msbuildSelect = xpath.useNamespaces({\n msbuild: 'http://schemas.microsoft.com/developer/msbuild/2003',\n});\n\n/**\n * Search for files matching the pattern under the target folder.\n * @param folder The absolute path to target folder.\n * @param filenamePattern The pattern to search for.\n * @return Return the array of relative file paths.\n */\nexport function findFiles(folder: string, filenamePattern: string): string[] {\n const files = glob.sync(path.join('**', filenamePattern), {\n cwd: folder,\n ignore: [\n 'node_modules/**',\n '**/Debug/**',\n '**/Release/**',\n '**/Generated Files/**',\n '**/packages/**',\n ],\n });\n\n return files;\n}\n\n/**\n * Search for the windows sub-folder under the target folder.\n * @param folder The absolute path to the target folder.\n * @return The absolute path to the windows folder, if it exists.\n */\nexport function findWindowsFolder(folder: string): string | null {\n const winDir = 'windows';\n const joinedDir = path.join(folder, winDir);\n if (fs.existsSync(joinedDir)) {\n return joinedDir;\n }\n\n return null;\n}\n\n/**\n * Checks if the target file path is a RNW solution file by checking if it contains the string \"ReactNative\".\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW solution file.\n */\nexport function isRnwSolution(filePath: string): boolean {\n return (\n fs\n .readFileSync(filePath)\n .toString()\n .search(/ReactNative/) > 0\n );\n}\n\n/**\n * Search for the RNW solution files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findSolutionFiles(winFolder: string): string[] {\n // First search for all potential solution files\n const allSolutions = findFiles(winFolder, '*.sln');\n\n if (allSolutions.length === 0) {\n // If there're no solution files, return 0\n return [];\n } else if (allSolutions.length === 1) {\n // If there is exactly one solution file, assume it's it\n return [allSolutions[0]];\n }\n\n const solutionFiles = [];\n\n // Try to find any solution file that appears to be a React Native solution\n for (const solutionFile of allSolutions) {\n if (isRnwSolution(path.join(winFolder, solutionFile))) {\n solutionFiles.push(path.normalize(solutionFile));\n }\n }\n\n return solutionFiles;\n}\n\nexport interface RawTemplateInfo {\n projectLang: 'cpp' | 'cs' | null;\n projectType: 'app' | 'lib' | null;\n projectArch: 'old' | 'new' | 'mixed' | null;\n}\n\n/**\n * Determines the RawTemplateInfo of the target project file.\n * @param filePath The absolute file path to check.\n * @return The RawTemplateInfo for the specific project.\n */\nexport function getRawTemplateInfo(filePath: string): RawTemplateInfo {\n const result: RawTemplateInfo = {\n projectLang: null,\n projectType: null,\n projectArch: null,\n };\n\n if (!fs.existsSync(filePath)) {\n return result;\n }\n\n result.projectLang = getProjectLanguage(filePath);\n\n const projectContents = readProjectFile(filePath);\n\n if (result.projectLang === 'cs') {\n if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'old';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'old';\n }\n } else if (result.projectLang === 'cpp') {\n if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'old';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'old';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'new';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'new';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'mixed';\n }\n }\n\n return result;\n}\n\n/**\n * Checks if the target file path is a RNW lib project file.\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW lib project file.\n */\nexport function isRnwDependencyProject(filePath: string): boolean {\n const rawTemplateInfo = getRawTemplateInfo(filePath);\n return rawTemplateInfo.projectType === 'lib';\n}\n\n/**\n * Search for the RNW lib project files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findDependencyProjectFiles(winFolder: string): string[] {\n // First, search for all potential project files\n const allCppProj = findFiles(winFolder, '*.vcxproj');\n const allCsProj = findFiles(winFolder, '*.csproj');\n\n const allProjects = allCppProj.concat(allCsProj);\n\n if (allProjects.length === 0) {\n // If there're no project files, return 0\n return [];\n }\n\n const dependencyProjectFiles = [];\n\n // Try to find any project file that appears to be a dependency project\n for (const projectFile of allProjects) {\n // A project is marked as a RNW dependency iff either:\n // - If the project has the standard native module imports, or\n // - If we only have a single project (and it doesn't have the standard native module imports),\n // pick it and hope for the best. This enables autolinking for modules that were written\n // before the standard native module template existed.\n if (\n allProjects.length === 1 ||\n isRnwDependencyProject(path.join(winFolder, projectFile))\n ) {\n dependencyProjectFiles.push(path.normalize(projectFile));\n }\n }\n\n return dependencyProjectFiles;\n}\n\n/**\n * Checks if the target file path is a RNW app project file.\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW app project file.\n */\nexport function isRnwAppProject(filePath: string): boolean {\n const rawTemplateInfo = getRawTemplateInfo(filePath);\n return rawTemplateInfo.projectType === 'app';\n}\n\n/**\n * Search for the RNW app project files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findAppProjectFiles(winFolder: string): string[] {\n // First, search for all potential project files\n const allCppProj = findFiles(winFolder, '*.vcxproj');\n const allCsProj = findFiles(winFolder, '*.csproj');\n\n const allProjects = allCppProj.concat(allCsProj);\n\n if (allProjects.length === 0) {\n // If there're no project files, return 0\n return [];\n }\n\n const appProjectFiles = [];\n\n // Try to find any project file that appears to be an app project\n for (const projectFile of allProjects) {\n if (isRnwAppProject(path.join(winFolder, projectFile))) {\n appProjectFiles.push(path.normalize(projectFile));\n }\n }\n\n return appProjectFiles;\n}\n\n/**\n * Returns the programming language of the project file.\n * @param projectPath The project file path to check.\n * @return The language string: cpp, cs, or null if unknown.\n */\nexport function getProjectLanguage(projectPath: string): 'cpp' | 'cs' | null {\n if (projectPath.endsWith('.vcxproj')) {\n return 'cpp';\n } else if (projectPath.endsWith('.csproj')) {\n return 'cs';\n }\n\n return null;\n}\n\n/**\n * Reads in the contents of the target project file.\n * @param projectPath The target project file path.\n * @return The project file contents.\n */\nexport function readProjectFile(projectPath: string) {\n const projectContents = fs.readFileSync(projectPath, 'utf8').toString();\n return new DOMParser().parseFromString(projectContents, 'application/xml');\n}\n\n/**\n * Search for the given property in the project contents and return its value.\n * @param projectContents The XML project contents.\n * @param propertyName The property to look for.\n * @return The value of the tag if it exists.\n */\nexport function tryFindPropertyValue(\n projectContents: Node,\n propertyName: string,\n): string | null {\n const nodes = msbuildSelect(\n `//msbuild:PropertyGroup/msbuild:${propertyName}`,\n projectContents,\n );\n\n if (nodes.length > 0) {\n // Take the last one\n return (nodes[nodes.length - 1] as Node).textContent;\n } else {\n const noNamespaceNodes = xpath.select(\n `//PropertyGroup/${propertyName}`,\n projectContents,\n );\n if (noNamespaceNodes.length > 0) {\n return (noNamespaceNodes[noNamespaceNodes.length - 1] as Node)\n .textContent;\n }\n }\n\n return null;\n}\n\n/**\n * Search for the given property in the project contents and return its value.\n * @param projectContents The XML project contents.\n * @param propertyName The property to look for.\n * @return The value of the tag if it exists.\n */\nexport function tryFindPropertyValueAsBoolean(\n projectContents: Node,\n propertyName: string,\n): boolean | null {\n const rawValue = tryFindPropertyValue(projectContents, propertyName);\n\n switch (rawValue) {\n case 'true':\n return true;\n case 'false':\n return false;\n default:\n return null;\n }\n}\n\nexport function findPropertyValue(\n projectContents: Node,\n propertyName: string,\n filePath: string,\n): string {\n const res = tryFindPropertyValue(projectContents, propertyName);\n if (!res) {\n throw new CodedError(\n 'NoPropertyInProject',\n `Couldn't find property ${propertyName} from ${filePath}`,\n {propertyName: propertyName},\n );\n }\n return res;\n}\n\n/**\n * Search for the given import project in the project contents and return if it exists.\n * @param projectContents The XML project contents.\n * @param projectName The project to look for.\n * @return If the target exists.\n */\nexport function importProjectExists(\n projectContents: Node,\n projectName: string,\n): boolean {\n const nodes = msbuildSelect(\n `//msbuild:Import[contains(@Project,'${projectName}')]`,\n projectContents,\n );\n\n return nodes.length > 0;\n}\n\nexport type ConfigurationType =\n | 'application'\n | 'dynamiclibrary'\n | 'generic'\n | 'staticlibrary'\n | 'unknown';\n\n/**\n * Gets the configuration type of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project configuration type.\n */\nexport function getConfigurationType(projectContents: Node): ConfigurationType {\n const configurationType = tryFindPropertyValue(\n projectContents,\n 'ConfigurationType',\n )?.toLowerCase();\n\n switch (configurationType) {\n case 'application':\n case 'dynamiclibrary':\n case 'generic':\n case 'staticlibrary':\n return configurationType;\n\n default:\n return 'unknown';\n }\n}\n\nexport type OutputType =\n | 'appcontainerexe'\n | 'exe'\n | 'library'\n | 'module'\n | 'unknown'\n | 'winexe'\n | 'winmdobj';\n\n/**\n * Gets the output type of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project output type.\n */\nexport function getOutputType(projectContents: Node): OutputType {\n const outputType = tryFindPropertyValue(\n projectContents,\n 'OutputType',\n )?.toLowerCase();\n\n switch (outputType) {\n case 'appcontainerexe':\n case 'exe':\n case 'library':\n case 'module':\n case 'winexe':\n case 'winmdobj':\n return outputType;\n\n default:\n return 'unknown';\n }\n}\n\n/**\n * Gets the type of the project from the project contents.\n * @param projectPath The project file path to check.\n * @param projectContents The XML project contents.\n * @return The project type.\n */\nexport function getProjectType(\n projectPath: string,\n projectContents: Node,\n): ConfigurationType | OutputType {\n switch (getProjectLanguage(projectPath)) {\n case 'cpp':\n return getConfigurationType(projectContents);\n\n case 'cs':\n return getOutputType(projectContents);\n\n default:\n return 'unknown';\n }\n}\n\n/**\n * Gets the name of the project from the project contents.\n * @param projectPath The project file path to check.\n * @param projectContents The XML project contents.\n * @return The project name.\n */\nexport function getProjectName(\n projectPath: string,\n projectContents: Node,\n): string {\n const name =\n tryFindPropertyValue(projectContents, 'ProjectName') ||\n path.parse(projectPath).name ||\n '';\n\n return name;\n}\n\n/**\n * Gets the namespace of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project namespace.\n */\nexport function getProjectNamespace(projectContents: Node): string | null {\n return tryFindPropertyValue(projectContents, 'RootNamespace');\n}\n\n/**\n * Gets the guid of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project guid.\n */\nexport function getProjectGuid(projectContents: Node): string | null {\n return tryFindPropertyValue(projectContents, 'ProjectGuid');\n}\n\nexport function getExperimentalFeatures(\n solutionDir: string,\n): Record<string, string> | undefined {\n const propsFile = path.join(solutionDir, 'ExperimentalFeatures.props');\n\n if (!fs.existsSync(propsFile)) {\n return undefined;\n }\n\n const result: Record<string, any> = {};\n const propsContents = readProjectFile(propsFile);\n const nodes = msbuildSelect(\n `//msbuild:PropertyGroup/msbuild:*`,\n propsContents,\n );\n for (const node of nodes) {\n const propertyNode = node as Node;\n result[propertyNode.nodeName] = propertyNode.textContent;\n }\n return result;\n}\n\nexport function getRnwConfig(\n root: string,\n projectFile: string,\n): Record<string, any> | undefined {\n const pkgJson = require(path.join(root, 'package.json'));\n\n const config: Record<string, any> = pkgJson['react-native-windows'] ?? {};\n\n // if init-windows is missing (most existing projects), try to auto-calculate it\n config['init-windows'] ??= {};\n if (!config['init-windows'].template) {\n const info = getRawTemplateInfo(projectFile);\n if (info.projectArch && info.projectLang && info.projectType) {\n config['init-windows'].template = `${\n info.projectArch === 'old' ? 'old/uwp-' : ''\n }${info.projectLang}-${info.projectType}`;\n }\n }\n\n return config;\n}\n"]}
1
+ {"version":3,"file":"configUtils.js","sourceRoot":"","sources":["../../../src/commands/config/configUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,gDAAwB;AAExB,2CAAyC;AACzC,kDAA0B;AAC1B,+DAA2D;AAE3D,MAAM,aAAa,GAAG,eAAK,CAAC,aAAa,CAAC;IACxC,OAAO,EAAE,qDAAqD;CAC/D,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,MAAc,EAAE,eAAuB;IAC/D,MAAM,KAAK,GAAG,cAAI,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,IA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AM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,YAAY,GAAG,IAAY,CAAC;QAClC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC;KAC1D;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AApBD,0DAoBC;AAED,SAAgB,YAAY,CAC1B,IAAY,EACZ,WAAmB;;IAEnB,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,YAAE,CAAC,UAAU,CAAC,OAAO,CAAC;QACpC,CAAC,CAAC,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAC1C,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,MAAM,GAAwB,MAAA,OAAO,CAAC,sBAAsB,CAAC,mCAAI,EAAE,CAAC;IAE1E,gFAAgF;IAChF,MAAA,MAAM,CAAC,cAAc,qCAArB,MAAM,CAAC,cAAc,IAAM,EAAE,EAAC;IAC9B,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE;QACpC,MAAM,IAAI,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;QAC7C,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE;YAC5D,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,GAAG,GAChC,IAAI,CAAC,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAC5C,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;SAC3C;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAvBD,oCAuBC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport glob from 'glob';\n\nimport {DOMParser} from '@xmldom/xmldom';\nimport xpath from 'xpath';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nconst msbuildSelect = xpath.useNamespaces({\n msbuild: 'http://schemas.microsoft.com/developer/msbuild/2003',\n});\n\n/**\n * Search for files matching the pattern under the target folder.\n * @param folder The absolute path to target folder.\n * @param filenamePattern The pattern to search for.\n * @return Return the array of relative file paths.\n */\nexport function findFiles(folder: string, filenamePattern: string): string[] {\n const files = glob.sync(path.join('**', filenamePattern), {\n cwd: folder,\n ignore: [\n 'node_modules/**',\n '**/Debug/**',\n '**/Release/**',\n '**/Generated Files/**',\n '**/packages/**',\n ],\n });\n\n return files;\n}\n\n/**\n * Search for the windows sub-folder under the target folder.\n * @param folder The absolute path to the target folder.\n * @return The absolute path to the windows folder, if it exists.\n */\nexport function findWindowsFolder(folder: string): string | null {\n const winDir = 'windows';\n const joinedDir = path.join(folder, winDir);\n if (fs.existsSync(joinedDir)) {\n return joinedDir;\n }\n\n return null;\n}\n\n/**\n * Checks if the target file path is a RNW solution file by checking if it contains the string \"ReactNative\".\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW solution file.\n */\nexport function isRnwSolution(filePath: string): boolean {\n return (\n fs\n .readFileSync(filePath)\n .toString()\n .search(/ReactNative/) > 0\n );\n}\n\n/**\n * Search for the RNW solution files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findSolutionFiles(winFolder: string): string[] {\n // First search for all potential solution files\n const allSolutions = findFiles(winFolder, '*.sln');\n\n if (allSolutions.length === 0) {\n // If there're no solution files, return 0\n return [];\n } else if (allSolutions.length === 1) {\n // If there is exactly one solution file, assume it's it\n return [allSolutions[0]];\n }\n\n const solutionFiles = [];\n\n // Try to find any solution file that appears to be a React Native solution\n for (const solutionFile of allSolutions) {\n if (isRnwSolution(path.join(winFolder, solutionFile))) {\n solutionFiles.push(path.normalize(solutionFile));\n }\n }\n\n return solutionFiles;\n}\n\nexport interface RawTemplateInfo {\n projectLang: 'cpp' | 'cs' | null;\n projectType: 'app' | 'lib' | null;\n projectArch: 'old' | 'new' | 'mixed' | null;\n}\n\n/**\n * Determines the RawTemplateInfo of the target project file.\n * @param filePath The absolute file path to check.\n * @return The RawTemplateInfo for the specific project.\n */\nexport function getRawTemplateInfo(filePath: string): RawTemplateInfo {\n const result: RawTemplateInfo = {\n projectLang: null,\n projectType: null,\n projectArch: null,\n };\n\n if (!fs.existsSync(filePath)) {\n return result;\n }\n\n result.projectLang = getProjectLanguage(filePath);\n\n const projectContents = readProjectFile(filePath);\n\n if (result.projectLang === 'cs') {\n if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'old';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'old';\n }\n } else if (result.projectLang === 'cpp') {\n if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'old';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'old';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppApp.targets',\n )\n ) {\n result.projectType = 'app';\n result.projectArch = 'new';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'new';\n } else if (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.CppLib.targets',\n )\n ) {\n result.projectType = 'lib';\n result.projectArch = 'mixed';\n }\n }\n\n return result;\n}\n\n/**\n * Checks if the target file path is a RNW lib project file.\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW lib project file.\n */\nexport function isRnwDependencyProject(filePath: string): boolean {\n const rawTemplateInfo = getRawTemplateInfo(filePath);\n return rawTemplateInfo.projectType === 'lib';\n}\n\n/**\n * Search for the RNW lib project files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findDependencyProjectFiles(winFolder: string): string[] {\n // First, search for all potential project files\n const allCppProj = findFiles(winFolder, '*.vcxproj');\n const allCsProj = findFiles(winFolder, '*.csproj');\n\n const allProjects = allCppProj.concat(allCsProj);\n\n if (allProjects.length === 0) {\n // If there're no project files, return 0\n return [];\n }\n\n const dependencyProjectFiles = [];\n\n // Try to find any project file that appears to be a dependency project\n for (const projectFile of allProjects) {\n // A project is marked as a RNW dependency iff either:\n // - If the project has the standard native module imports, or\n // - If we only have a single project (and it doesn't have the standard native module imports),\n // pick it and hope for the best. This enables autolinking for modules that were written\n // before the standard native module template existed.\n if (\n allProjects.length === 1 ||\n isRnwDependencyProject(path.join(winFolder, projectFile))\n ) {\n dependencyProjectFiles.push(path.normalize(projectFile));\n }\n }\n\n return dependencyProjectFiles;\n}\n\n/**\n * Checks if the target file path is a RNW app project file.\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW app project file.\n */\nexport function isRnwAppProject(filePath: string): boolean {\n const rawTemplateInfo = getRawTemplateInfo(filePath);\n return rawTemplateInfo.projectType === 'app';\n}\n\n/**\n * Search for the RNW app project files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findAppProjectFiles(winFolder: string): string[] {\n // First, search for all potential project files\n const allCppProj = findFiles(winFolder, '*.vcxproj');\n const allCsProj = findFiles(winFolder, '*.csproj');\n\n const allProjects = allCppProj.concat(allCsProj);\n\n if (allProjects.length === 0) {\n // If there're no project files, return 0\n return [];\n }\n\n const appProjectFiles = [];\n\n // Try to find any project file that appears to be an app project\n for (const projectFile of allProjects) {\n if (isRnwAppProject(path.join(winFolder, projectFile))) {\n appProjectFiles.push(path.normalize(projectFile));\n }\n }\n\n return appProjectFiles;\n}\n\n/**\n * Returns the programming language of the project file.\n * @param projectPath The project file path to check.\n * @return The language string: cpp, cs, or null if unknown.\n */\nexport function getProjectLanguage(projectPath: string): 'cpp' | 'cs' | null {\n if (projectPath.endsWith('.vcxproj')) {\n return 'cpp';\n } else if (projectPath.endsWith('.csproj')) {\n return 'cs';\n }\n\n return null;\n}\n\n/**\n * Reads in the contents of the target project file.\n * @param projectPath The target project file path.\n * @return The project file contents.\n */\nexport function readProjectFile(projectPath: string) {\n const projectContents = fs.readFileSync(projectPath, 'utf8').toString();\n return new DOMParser().parseFromString(projectContents, 'application/xml');\n}\n\n/**\n * Search for the given property in the project contents and return its value.\n * @param projectContents The XML project contents.\n * @param propertyName The property to look for.\n * @return The value of the tag if it exists.\n */\nexport function tryFindPropertyValue(\n projectContents: Node,\n propertyName: string,\n): string | null {\n const nodes = msbuildSelect(\n `//msbuild:PropertyGroup/msbuild:${propertyName}`,\n projectContents,\n );\n\n if (nodes.length > 0) {\n // Take the last one\n return (nodes[nodes.length - 1] as Node).textContent;\n } else {\n const noNamespaceNodes = xpath.select(\n `//PropertyGroup/${propertyName}`,\n projectContents,\n );\n if (noNamespaceNodes.length > 0) {\n return (noNamespaceNodes[noNamespaceNodes.length - 1] as Node)\n .textContent;\n }\n }\n\n return null;\n}\n\n/**\n * Search for the given property in the project contents and return its value.\n * @param projectContents The XML project contents.\n * @param propertyName The property to look for.\n * @return The value of the tag if it exists.\n */\nexport function tryFindPropertyValueAsBoolean(\n projectContents: Node,\n propertyName: string,\n): boolean | null {\n const rawValue = tryFindPropertyValue(projectContents, propertyName);\n\n switch (rawValue) {\n case 'true':\n return true;\n case 'false':\n return false;\n default:\n return null;\n }\n}\n\nexport function findPropertyValue(\n projectContents: Node,\n propertyName: string,\n filePath: string,\n): string {\n const res = tryFindPropertyValue(projectContents, propertyName);\n if (!res) {\n throw new CodedError(\n 'NoPropertyInProject',\n `Couldn't find property ${propertyName} from ${filePath}`,\n {propertyName: propertyName},\n );\n }\n return res;\n}\n\n/**\n * Search for the given import project in the project contents and return if it exists.\n * @param projectContents The XML project contents.\n * @param projectName The project to look for.\n * @return If the target exists.\n */\nexport function importProjectExists(\n projectContents: Node,\n projectName: string,\n): boolean {\n const nodes = msbuildSelect(\n `//msbuild:Import[contains(@Project,'${projectName}')]`,\n projectContents,\n );\n\n return nodes.length > 0;\n}\n\nexport type ConfigurationType =\n | 'application'\n | 'dynamiclibrary'\n | 'generic'\n | 'staticlibrary'\n | 'unknown';\n\n/**\n * Gets the configuration type of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project configuration type.\n */\nexport function getConfigurationType(projectContents: Node): ConfigurationType {\n const configurationType = tryFindPropertyValue(\n projectContents,\n 'ConfigurationType',\n )?.toLowerCase();\n\n switch (configurationType) {\n case 'application':\n case 'dynamiclibrary':\n case 'generic':\n case 'staticlibrary':\n return configurationType;\n\n default:\n return 'unknown';\n }\n}\n\nexport type OutputType =\n | 'appcontainerexe'\n | 'exe'\n | 'library'\n | 'module'\n | 'unknown'\n | 'winexe'\n | 'winmdobj';\n\n/**\n * Gets the output type of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project output type.\n */\nexport function getOutputType(projectContents: Node): OutputType {\n const outputType = tryFindPropertyValue(\n projectContents,\n 'OutputType',\n )?.toLowerCase();\n\n switch (outputType) {\n case 'appcontainerexe':\n case 'exe':\n case 'library':\n case 'module':\n case 'winexe':\n case 'winmdobj':\n return outputType;\n\n default:\n return 'unknown';\n }\n}\n\n/**\n * Gets the type of the project from the project contents.\n * @param projectPath The project file path to check.\n * @param projectContents The XML project contents.\n * @return The project type.\n */\nexport function getProjectType(\n projectPath: string,\n projectContents: Node,\n): ConfigurationType | OutputType {\n switch (getProjectLanguage(projectPath)) {\n case 'cpp':\n return getConfigurationType(projectContents);\n\n case 'cs':\n return getOutputType(projectContents);\n\n default:\n return 'unknown';\n }\n}\n\n/**\n * Gets the name of the project from the project contents.\n * @param projectPath The project file path to check.\n * @param projectContents The XML project contents.\n * @return The project name.\n */\nexport function getProjectName(\n projectPath: string,\n projectContents: Node,\n): string {\n const name =\n tryFindPropertyValue(projectContents, 'ProjectName') ||\n path.parse(projectPath).name ||\n '';\n\n return name;\n}\n\n/**\n * Gets the namespace of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project namespace.\n */\nexport function getProjectNamespace(projectContents: Node): string | null {\n return tryFindPropertyValue(projectContents, 'RootNamespace');\n}\n\n/**\n * Gets the guid of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project guid.\n */\nexport function getProjectGuid(projectContents: Node): string | null {\n return tryFindPropertyValue(projectContents, 'ProjectGuid');\n}\n\nexport function getExperimentalFeatures(\n solutionDir: string,\n): Record<string, string> | undefined {\n const propsFile = path.join(solutionDir, 'ExperimentalFeatures.props');\n\n if (!fs.existsSync(propsFile)) {\n return undefined;\n }\n\n const result: Record<string, any> = {};\n const propsContents = readProjectFile(propsFile);\n const nodes = msbuildSelect(\n `//msbuild:PropertyGroup/msbuild:*`,\n propsContents,\n );\n for (const node of nodes) {\n const propertyNode = node as Node;\n result[propertyNode.nodeName] = propertyNode.textContent;\n }\n return result;\n}\n\nexport function getRnwConfig(\n root: string,\n projectFile: string,\n): Record<string, any> | undefined {\n const pkgPath = path.join(root, 'package.json');\n const pkgJson = fs.existsSync(pkgPath)\n ? require(path.join(root, 'package.json'))\n : {};\n\n const config: Record<string, any> = pkgJson['react-native-windows'] ?? {};\n\n // if init-windows is missing (most existing projects), try to auto-calculate it\n config['init-windows'] ??= {};\n if (!config['init-windows'].template) {\n const info = getRawTemplateInfo(projectFile);\n if (info.projectArch && info.projectLang && info.projectType) {\n config['init-windows'].template = `${\n info.projectArch === 'old' ? 'old/uwp-' : ''\n }${info.projectLang}-${info.projectType}`;\n }\n }\n\n return config;\n}\n"]}
@@ -85,7 +85,8 @@ test.each(projects)('projectConfig - %s (Ignore react-native.config.js)', async
85
85
  });
86
86
  }
87
87
  });
88
- test('useWinUI3=true in react-native.config.js, UseWinUI3=false in ExperimentalFeatures.props', async () => {
88
+ // Skipping this test as the feature is broken and needs to be removed, see https://github.com/microsoft/react-native-windows/issues/14601
89
+ test.skip('useWinUI3=true in react-native.config.js, UseWinUI3=false in ExperimentalFeatures.props', async () => {
89
90
  const folder = path_1.default.resolve('src/e2etest/projects/WithWinUI3');
90
91
  // Create project with UseWinUI3 == false in ExperimentalFeatures.props
91
92
  await (0, projectConfig_utils_1.ensureCppAppProject)(folder, 'WithWinUI3', false, false, false);
@@ -1 +1 @@
1
- {"version":3,"file":"projectConfig.test.js","sourceRoot":"","sources":["../../src/e2etest/projectConfig.test.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AAExB,oEAG0C;AAE1C,iFAA4E;AAC5E,+DAO+B;AAI/B,SAAS,OAAO,CACd,IAAY,EACZ,KAAyC;IAEzC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,QAAQ,GAAoB;IAChC,mDAAmD;IACnD,OAAO,CAAC,UAAU,CAAC;IACnB,+BAA+B;IAC/B,OAAO,CAAC,wBAAwB,EAAE,KAAK,EAAE,MAAc,EAAE,EAAE;QACzD,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAChD,MAAM,IAAA,8BAAQ,EAAC,UAAU,CAAC,CAAC;IAC7B,CAAC,CAAC;IACF,wCAAwC;IACxC,OAAO,CAAC,cAAc,EAAE,KAAK,EAAE,MAAc,EAAE,EAAE;QAC/C,MAAM,IAAA,yCAAmB,EAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACpD,CAAC,CAAC;IACF,uCAAuC;IACvC,OAAO,CAAC,iBAAiB,EAAE,KAAK,EAAE,MAAc,EAAE,EAAE;QAClD,MAAM,IAAA,4CAAsB,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC1D,CAAC,CAAC;IACF,OAAO,CAAC,YAA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Y,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAErE,MAAM,GAAG,GAAG,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC,CAAC;IAEjE,MAAM,MAAM,GAAG,IAAA,oCAAoB,EAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAE,CAAC;IAClE,+CAA+C;IAC/C,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;IAExB,MAAM,6BAA6B,GAAG,cAAI,CAAC,IAAI,CAC7C,MAAM,EACN,oCAAoC,CACrC,CAAC;IAEF,6BAA6B;IAC7B,MAAM,4BAA4B,GAAG,CACnC,MAAM,YAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CACjD,CAAC,QAAQ,EAAE,CAAC;IACb,MAAM,CAAC,4BAA4B,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;IAE1E,iCAAiC;IACjC,MAAM,EAAE,GAAG,IAAI,iCAAe,CAC5B,EAAC,OAAO,EAAE,MAAM,EAAC,EACjB,EAAE,EACF;QACE,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,KAAK;KACf,CACF,CAAC;IAEF,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,iBAAiB,EAAE,CAAC;IACzC,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;IAEzB,2BAA2B;IAC3B,MAAM,yBAAyB,GAAG,CAChC,MAAM,YAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CACjD,CAAC,QAAQ,EAAE,CAAC;IAEb,MAAM,CAAC,yBAAyB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;AACzE,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\n\nimport {\n projectConfigWindows,\n WindowsProjectConfig,\n} from '../commands/config/projectConfig';\n\nimport {AutoLinkWindows} from '../commands/autolinkWindows/autolinkWindows';\nimport {\n ensureCppAppProject,\n ensureCSharpAppProject,\n ensureWinUI3Project,\n ensureHermesProject,\n ensureExperimentalNuGetProject,\n tryMkdir,\n} from './projectConfig.utils';\n\ntype TargetProject = [string, ((folder: string) => Promise<void>)?];\n\nfunction project(\n name: string,\n setup?: (folder: string) => Promise<void>,\n): TargetProject {\n return [name, setup];\n}\n\nconst projects: TargetProject[] = [\n // Nothing but a react-native.config.js, with nulls\n project('BlankApp'),\n // Nothing but a windows folder\n project('MissingProjectFilesApp', async (folder: string) => {\n const windowsDir = path.join(folder, 'windows');\n await tryMkdir(windowsDir);\n }),\n // New C++ project based on the template\n project('SimpleCppApp', async (folder: string) => {\n await ensureCppAppProject(folder, 'SimpleCppApp');\n }),\n // New C# project based on the template\n project('SimpleCSharpApp', async (folder: string) => {\n await ensureCSharpAppProject(folder, 'SimpleCSharpApp');\n }),\n project('WithWinUI3', async (folder: string) => {\n await ensureWinUI3Project(folder);\n }),\n project('WithHermes', async (folder: string) => {\n await ensureHermesProject(folder);\n }),\n project('WithExperimentalNuget', async (folder: string) => {\n await ensureExperimentalNuGetProject(folder);\n }),\n project('WithIndirectDependency'),\n];\n\n// Tests that given userConfig is null, the result will always be null\ntest.each(projects)(\n 'projectConfig - %s (userConfig is null)',\n async (name, setup) => {\n const folder = path.resolve('src/e2etest/projects/', name);\n\n if (setup !== undefined) {\n await setup(folder);\n }\n\n const userConfig = null;\n\n expect(projectConfigWindows(folder, userConfig)).toBeNull();\n },\n);\n\n// Tests the result given a windows project config in react-native.config.js\ntest.each(projects)(\n 'projectConfig - %s (Use react-native.config.js)',\n async (name, setup) => {\n const folder = path.resolve('src/e2etest/projects/', name);\n const rnc = require(path.join(folder, 'react-native.config.js'));\n\n if (setup !== undefined) {\n await setup(folder);\n }\n\n const userConfig: Partial<WindowsProjectConfig> = rnc.project.windows;\n\n if (name === 'BlankApp') {\n expect(projectConfigWindows(folder, userConfig)).toMatchSnapshot();\n } else {\n expect(projectConfigWindows(folder, userConfig)).toMatchSnapshot({\n folder: expect.stringContaining(name),\n });\n }\n },\n);\n\n// Tests the result of ignoring the windows project config in react-native.config.js\ntest.each(projects)(\n 'projectConfig - %s (Ignore react-native.config.js)',\n async (name, setup) => {\n const folder = path.resolve('src/e2etest/projects/', name);\n\n if (setup !== undefined) {\n await setup(folder);\n }\n\n const userConfig: Partial<WindowsProjectConfig> = {};\n\n if (name === 'BlankApp') {\n expect(projectConfigWindows(folder, userConfig)).toMatchSnapshot();\n } else {\n expect(projectConfigWindows(folder, userConfig)).toMatchSnapshot({\n folder: expect.stringContaining(name),\n });\n }\n },\n);\n\ntest('useWinUI3=true in react-native.config.js, UseWinUI3=false in ExperimentalFeatures.props', async () => {\n const folder = path.resolve('src/e2etest/projects/WithWinUI3');\n\n // Create project with UseWinUI3 == false in ExperimentalFeatures.props\n await ensureCppAppProject(folder, 'WithWinUI3', false, false, false);\n\n const rnc = require(path.join(folder, 'react-native.config.js'));\n\n const config = projectConfigWindows(folder, rnc.project.windows)!;\n // Set useWinUI3=true in react-native.config.js\n config.useWinUI3 = true;\n\n const experimentalFeaturesPropsFile = path.join(\n folder,\n 'windows/ExperimentalFeatures.props',\n );\n\n // Verify starting props file\n const startingExperimentalFeatures = (\n await fs.readFile(experimentalFeaturesPropsFile)\n ).toString();\n expect(startingExperimentalFeatures.replace(/\\r/g, '')).toMatchSnapshot();\n\n // Run Autolink to sync the files\n const al = new AutoLinkWindows(\n {windows: config},\n {},\n {\n check: false,\n logging: false,\n },\n );\n\n const exd = await al.ensureXAMLDialect();\n expect(exd).toBeTruthy();\n\n // Verify ending props file\n const finalExperimentalFeatures = (\n await fs.readFile(experimentalFeaturesPropsFile)\n ).toString();\n\n expect(finalExperimentalFeatures.replace(/\\r/g, '')).toMatchSnapshot();\n});\n"]}
1
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AAG,IAAI,CAAC;IAExB,MAAM,6BAA6B,GAAG,cAAI,CAAC,IAAI,CAC7C,MAAM,EACN,oCAAoC,CACrC,CAAC;IAEF,6BAA6B;IAC7B,MAAM,4BAA4B,GAAG,CACnC,MAAM,YAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CACjD,CAAC,QAAQ,EAAE,CAAC;IACb,MAAM,CAAC,4BAA4B,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;IAE1E,iCAAiC;IACjC,MAAM,EAAE,GAAG,IAAI,iCAAe,CAC5B,EAAC,OAAO,EAAE,MAAM,EAAC,EACjB,EAAE,EACF;QACE,KAAK,EAAE,KAAK;QACZ,OAAO,EAAE,KAAK;KACf,CACF,CAAC;IAEF,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,iBAAiB,EAAE,CAAC;IACzC,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC;IAEzB,2BAA2B;IAC3B,MAAM,yBAAyB,GAAG,CAChC,MAAM,YAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CACjD,CAAC,QAAQ,EAAE,CAAC;IAEb,MAAM,CAAC,yBAAyB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;AACzE,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\n\nimport {\n projectConfigWindows,\n WindowsProjectConfig,\n} from '../commands/config/projectConfig';\n\nimport {AutoLinkWindows} from '../commands/autolinkWindows/autolinkWindows';\nimport {\n ensureCppAppProject,\n ensureCSharpAppProject,\n ensureWinUI3Project,\n ensureHermesProject,\n ensureExperimentalNuGetProject,\n tryMkdir,\n} from './projectConfig.utils';\n\ntype TargetProject = [string, ((folder: string) => Promise<void>)?];\n\nfunction project(\n name: string,\n setup?: (folder: string) => Promise<void>,\n): TargetProject {\n return [name, setup];\n}\n\nconst projects: TargetProject[] = [\n // Nothing but a react-native.config.js, with nulls\n project('BlankApp'),\n // Nothing but a windows folder\n project('MissingProjectFilesApp', async (folder: string) => {\n const windowsDir = path.join(folder, 'windows');\n await tryMkdir(windowsDir);\n }),\n // New C++ project based on the template\n project('SimpleCppApp', async (folder: string) => {\n await ensureCppAppProject(folder, 'SimpleCppApp');\n }),\n // New C# project based on the template\n project('SimpleCSharpApp', async (folder: string) => {\n await ensureCSharpAppProject(folder, 'SimpleCSharpApp');\n }),\n project('WithWinUI3', async (folder: string) => {\n await ensureWinUI3Project(folder);\n }),\n project('WithHermes', async (folder: string) => {\n await ensureHermesProject(folder);\n }),\n project('WithExperimentalNuget', async (folder: string) => {\n await ensureExperimentalNuGetProject(folder);\n }),\n project('WithIndirectDependency'),\n];\n\n// Tests that given userConfig is null, the result will always be null\ntest.each(projects)(\n 'projectConfig - %s (userConfig is null)',\n async (name, setup) => {\n const folder = path.resolve('src/e2etest/projects/', name);\n\n if (setup !== undefined) {\n await setup(folder);\n }\n\n const userConfig = null;\n\n expect(projectConfigWindows(folder, userConfig)).toBeNull();\n },\n);\n\n// Tests the result given a windows project config in react-native.config.js\ntest.each(projects)(\n 'projectConfig - %s (Use react-native.config.js)',\n async (name, setup) => {\n const folder = path.resolve('src/e2etest/projects/', name);\n const rnc = require(path.join(folder, 'react-native.config.js'));\n\n if (setup !== undefined) {\n await setup(folder);\n }\n\n const userConfig: Partial<WindowsProjectConfig> = rnc.project.windows;\n\n if (name === 'BlankApp') {\n expect(projectConfigWindows(folder, userConfig)).toMatchSnapshot();\n } else {\n expect(projectConfigWindows(folder, userConfig)).toMatchSnapshot({\n folder: expect.stringContaining(name),\n });\n }\n },\n);\n\n// Tests the result of ignoring the windows project config in react-native.config.js\ntest.each(projects)(\n 'projectConfig - %s (Ignore react-native.config.js)',\n async (name, setup) => {\n const folder = path.resolve('src/e2etest/projects/', name);\n\n if (setup !== undefined) {\n await setup(folder);\n }\n\n const userConfig: Partial<WindowsProjectConfig> = {};\n\n if (name === 'BlankApp') {\n expect(projectConfigWindows(folder, userConfig)).toMatchSnapshot();\n } else {\n expect(projectConfigWindows(folder, userConfig)).toMatchSnapshot({\n folder: expect.stringContaining(name),\n });\n }\n },\n);\n\n// Skipping this test as the feature is broken and needs to be removed, see https://github.com/microsoft/react-native-windows/issues/14601\ntest.skip('useWinUI3=true in react-native.config.js, UseWinUI3=false in ExperimentalFeatures.props', async () => {\n const folder = path.resolve('src/e2etest/projects/WithWinUI3');\n\n // Create project with UseWinUI3 == false in ExperimentalFeatures.props\n await ensureCppAppProject(folder, 'WithWinUI3', false, false, false);\n\n const rnc = require(path.join(folder, 'react-native.config.js'));\n\n const config = projectConfigWindows(folder, rnc.project.windows)!;\n // Set useWinUI3=true in react-native.config.js\n config.useWinUI3 = true;\n\n const experimentalFeaturesPropsFile = path.join(\n folder,\n 'windows/ExperimentalFeatures.props',\n );\n\n // Verify starting props file\n const startingExperimentalFeatures = (\n await fs.readFile(experimentalFeaturesPropsFile)\n ).toString();\n expect(startingExperimentalFeatures.replace(/\\r/g, '')).toMatchSnapshot();\n\n // Run Autolink to sync the files\n const al = new AutoLinkWindows(\n {windows: config},\n {},\n {\n check: false,\n logging: false,\n },\n );\n\n const exd = await al.ensureXAMLDialect();\n expect(exd).toBeTruthy();\n\n // Verify ending props file\n const finalExperimentalFeatures = (\n await fs.readFile(experimentalFeaturesPropsFile)\n ).toString();\n\n expect(finalExperimentalFeatures.replace(/\\r/g, '')).toMatchSnapshot();\n});\n"]}
@@ -36,7 +36,6 @@ const fs_1 = __importDefault(require("@react-native-windows/fs"));
36
36
  const path_1 = __importDefault(require("path"));
37
37
  const child_process_1 = __importDefault(require("child_process"));
38
38
  const chalk_1 = __importDefault(require("chalk"));
39
- const os_2 = __importDefault(require("os"));
40
39
  const shelljs_1 = __importDefault(require("shelljs"));
41
40
  const version_1 = __importDefault(require("./version"));
42
41
  const checkRequirements = __importStar(require("./checkRequirements"));
@@ -83,11 +82,11 @@ class MSBuildTools {
83
82
  (0, commandWithProgress_1.newInfo)(`Build configuration: ${buildType}`);
84
83
  (0, commandWithProgress_1.newInfo)(`Build platform: ${buildArch}`);
85
84
  const verbosityOption = verbose ? 'normal' : 'minimal';
86
- const logPrefix = path_1.default.join(buildLogDirectory || os_2.default.tmpdir(), `msbuild_${process.pid}_${target}`);
85
+ const defaultLogDirectory = path_1.default.dirname(slnFile);
86
+ const logPrefix = path_1.default.join(buildLogDirectory || defaultLogDirectory, `msbuild_${process.pid}_${target}`);
87
87
  const errorLog = logPrefix + '.err';
88
88
  const warnLog = logPrefix + '.wrn';
89
- const localBinLog = target === 'build' ? '' : ':deploy.binlog';
90
- const binlog = buildLogDirectory ? `:${logPrefix}.binlog` : localBinLog;
89
+ const binlog = `:${logPrefix}.binlog`;
91
90
  const args = [
92
91
  `/clp:NoSummary;NoItemAndPropertyList;Verbosity=${verbosityOption}`,
93
92
  '/nologo',
@@ -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,CAAC;IAEJ;;OAEG;IACH,WAAW;QACT,OAAO,cAAI,CAAC,IAAI,CAAC,IA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EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,KAAK,EAAE;QACT,OAAO,KAAK,CAAC,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 !== true && 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 =\n process.env.MinimumVisualStudioVersion ||\n process.env.VisualStudioVersion ||\n '17.11.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 {\n MinimumVisualStudioVersionFromEnv:\n process.env.MinimumVisualStudioVersion,\n },\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"]}
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,sDAA4B;AAC5B,wDAAgC;AAChC,uEAA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IAC3G,IAAI,MAAM,CAAC;IACX,IAAI;QACF,MAAM,GAAG,IAAA,wBAAQ,EAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;KAC1C;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,MAAM,CAAC;KACf;IAED,MAAM,EAAE,GACN,0EAA0E,CAAC;IAC7E,MAAM,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,IAAI,KAAK,EAAE;QACT,OAAO,KAAK,CAAC,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 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 defaultLogDirectory = path.dirname(slnFile);\n const logPrefix = path.join(\n buildLogDirectory || defaultLogDirectory,\n `msbuild_${process.pid}_${target}`,\n );\n\n const errorLog = logPrefix + '.err';\n const warnLog = logPrefix + '.wrn';\n\n const binlog = `:${logPrefix}.binlog`;\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 !== true && 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 =\n process.env.MinimumVisualStudioVersion ||\n process.env.VisualStudioVersion ||\n '17.11.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 {\n MinimumVisualStudioVersionFromEnv:\n process.env.MinimumVisualStudioVersion,\n },\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-windows/cli",
3
- "version": "0.78.3",
3
+ "version": "0.79.0-preview.1",
4
4
  "license": "MIT",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "repository": {
@@ -17,10 +17,10 @@
17
17
  "watch": "rnw-scripts watch"
18
18
  },
19
19
  "dependencies": {
20
- "@react-native-windows/codegen": "0.78.2",
21
- "@react-native-windows/fs": "0.78.0",
22
- "@react-native-windows/package-utils": "0.78.0",
23
- "@react-native-windows/telemetry": "0.78.0",
20
+ "@react-native-windows/codegen": "0.79.0-preview.1",
21
+ "@react-native-windows/fs": "0.79.0-preview.1",
22
+ "@react-native-windows/package-utils": "0.79.0-preview.1",
23
+ "@react-native-windows/telemetry": "0.79.0-preview.1",
24
24
  "@xmldom/xmldom": "^0.7.7",
25
25
  "chalk": "^4.1.0",
26
26
  "cli-spinners": "^2.2.0",
@@ -39,11 +39,11 @@
39
39
  "xpath": "^0.0.27"
40
40
  },
41
41
  "devDependencies": {
42
- "@react-native-community/cli-doctor": "^15.0.0",
43
- "@react-native-community/cli-types": "^15.0.0",
44
- "@rnw-scripts/eslint-config": "1.2.32",
42
+ "@react-native-community/cli-doctor": "15.0.0-alpha.2",
43
+ "@react-native-community/cli-types": "15.0.0-alpha.2",
44
+ "@rnw-scripts/eslint-config": "1.2.36",
45
45
  "@rnw-scripts/jest-unittest-config": "1.5.11",
46
- "@rnw-scripts/just-task": "2.3.49",
46
+ "@rnw-scripts/just-task": "2.3.53",
47
47
  "@rnw-scripts/ts-config": "2.0.5",
48
48
  "@types/chalk": "^2.2.0",
49
49
  "@types/jest": "^29.2.2",
@@ -72,11 +72,11 @@
72
72
  "src/powershell"
73
73
  ],
74
74
  "beachball": {
75
- "defaultNpmTag": "latest",
75
+ "defaultNpmTag": "preview",
76
76
  "disallowedChangeTypes": [
77
77
  "major",
78
78
  "minor",
79
- "prerelease",
79
+ "patch",
80
80
  "premajor",
81
81
  "preminor",
82
82
  "prepatch"