@react-native-windows/cli 0.80.0-preview.2 → 0.80.0-preview.3

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.
@@ -45,6 +45,8 @@ const pathHelpers = __importStar(require("../../utils/pathHelpers"));
45
45
  const telemetryHelpers_1 = require("../../utils/telemetryHelpers");
46
46
  const generator_common_1 = require("../../generator-common");
47
47
  const nameHelpers = __importStar(require("../../utils/nameHelpers"));
48
+ const oldArchWarning_1 = require("../../utils/oldArchWarning");
49
+ const architecturePrompt_1 = require("../../utils/architecturePrompt");
48
50
  const initWindowsOptions_1 = require("./initWindowsOptions");
49
51
  class InitWindows {
50
52
  constructor(config, options) {
@@ -119,13 +121,24 @@ class InitWindows {
119
121
  this.printTemplateList();
120
122
  return;
121
123
  }
124
+ const userDidNotPassTemplate = !process.argv.some(arg => arg.startsWith('--template'));
122
125
  (_a = (_l = this.options).template) !== null && _a !== void 0 ? _a : (_l.template = (_d = (_c = (_b = this.rnwConfig) === null || _b === void 0 ? void 0 : _b['init-windows']) === null || _c === void 0 ? void 0 : _c.template) !== null && _d !== void 0 ? _d : this.getDefaultTemplateName());
123
126
  spinner.info(`Using template '${this.options.template}'...`);
124
127
  if (!this.templates.has(this.options.template.replace(/[\\]/g, '/'))) {
125
128
  throw new telemetry_1.CodedError('InvalidTemplateName', `Unable to find template '${this.options.template}'.`);
126
129
  }
127
- if (this.options.template.startsWith('old')) {
128
- spinner.warn(`The legacy '${this.options.template}' template targets the React Native Old Architecture, which will eventually be deprecated. See https://microsoft.github.io/react-native-windows/docs/new-architecture for details on switching to the New Architecture.`);
130
+ const isOldArchTemplate = this.options.template.startsWith('old');
131
+ const promptFlag = this.options.prompt;
132
+ if (isOldArchTemplate) {
133
+ (0, oldArchWarning_1.showOldArchitectureWarning)();
134
+ if (userDidNotPassTemplate && promptFlag) {
135
+ const promptResult = await (0, architecturePrompt_1.promptForArchitectureChoice)();
136
+ if (!promptResult.shouldContinueWithOldArch &&
137
+ !promptResult.userCancelled) {
138
+ spinner.info('Switching to New Architecture template (cpp-app)...');
139
+ this.options.template = 'cpp-app';
140
+ }
141
+ }
129
142
  }
130
143
  const templateConfig = this.templates.get(this.options.template);
131
144
  // Check if there's a passed-in project name and if it's valid
@@ -212,6 +225,7 @@ function optionSanitizer(key, value) {
212
225
  case 'overwrite':
213
226
  case 'telemetry':
214
227
  case 'list':
228
+ case 'prompt':
215
229
  return value === undefined ? false : value; // Return value
216
230
  }
217
231
  }
@@ -223,6 +237,15 @@ async function getExtraProps() {
223
237
  const extraProps = {};
224
238
  return extraProps;
225
239
  }
240
+ function sanitizeOptions(opts, sanitizer) {
241
+ const sanitized = {};
242
+ for (const key in opts) {
243
+ if (Object.prototype.hasOwnProperty.call(opts, key)) {
244
+ sanitized[key] = sanitizer(key, opts[key]);
245
+ }
246
+ }
247
+ return sanitized;
248
+ }
226
249
  /**
227
250
  * The function run when calling `npx @react-native-community/cli init-windows`.
228
251
  * @param args Unprocessed args passed from react-native CLI.
@@ -240,7 +263,8 @@ async function initWindows(args, config, options) {
240
263
  ex instanceof Error ? ex : new Error(String(ex));
241
264
  telemetry_1.Telemetry.trackException(initWindowsError);
242
265
  }
243
- await (0, telemetryHelpers_1.endTelemetrySession)(initWindowsError, getExtraProps);
266
+ // Now, instead of custom fields, just pass the final options object
267
+ await (0, telemetryHelpers_1.endTelemetrySession)(initWindowsError, getExtraProps, options, opts => sanitizeOptions(opts, optionSanitizer));
244
268
  (0, commandWithProgress_1.setExitProcessWithError)(options.logging, initWindowsError);
245
269
  }
246
270
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"initWindows.js","sourceRoot":"","sources":["../../../src/commands/initWindows/initWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,kDAA0B;AAC1B,+BAAsC;AAEtC,2CAAuC;AAEvC,gDAAwB;AAExB,MAAM,IAAI,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AAW,CAAC,GAAG,EAAE,CAAC;QAElC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,KAAK,CAAC,UAAU,CAAC,6BAA6B,IAAI,CAAC,KAAK,CAC/D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAK,CAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,KAAK,CAC7D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;QACF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AA3BD,kDA2BC;AAED;;GAEG;AACU,QAAA,WAAW,GAAY;IAClC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,qDAAqD;IAClE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,gCAAW;CACrB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport chalk from 'chalk';\nimport {glob as globFunc} from 'glob';\nimport _ from 'lodash';\nimport {performance} from 'perf_hooks';\nimport {Ora} from 'ora';\nimport util from 'util';\n\nconst glob = util.promisify(globFunc);\n\nimport type {Command, Config} from '@react-native-community/cli-types';\nimport {CodedError, Telemetry} from '@react-native-windows/telemetry';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport {copyAndReplaceWithChangedCallback} from '../../generator-common';\nimport * as nameHelpers from '../../utils/nameHelpers';\nimport type {InitOptions} from './initWindowsOptions';\nimport {initOptions} from './initWindowsOptions';\n\nexport interface TemplateFileMapping {\n from: string;\n to: string;\n replacements?: Record<string, any>;\n}\n\nexport interface InitWindowsTemplateConfig {\n name: string;\n description: string;\n isDefault?: boolean;\n preInstall?: (config: Config, options: InitOptions) => Promise<void>;\n getFileMappings?: (\n config: Config,\n options: InitOptions,\n ) => Promise<TemplateFileMapping[]>;\n postInstall?: (config: Config, options: InitOptions) => Promise<void>;\n}\n\nexport class InitWindows {\n protected readonly rnwPath: string;\n protected readonly rnwConfig?: Record<string, any>;\n protected readonly templates: Map<string, InitWindowsTemplateConfig> =\n new Map();\n\n constructor(readonly config: Config, readonly options: InitOptions) {\n this.rnwPath = pathHelpers.resolveRnwRoot(this.config.root);\n this.rnwConfig = this.config.project.windows?.rnwConfig;\n }\n\n protected verboseMessage(message: any) {\n verboseMessage(message, !!this.options.logging);\n }\n\n protected async loadTemplates() {\n const templatesRoot = path.join(this.rnwPath, 'templates');\n for (const file of await glob('**/template.config.js', {\n cwd: templatesRoot,\n })) {\n const templateName = path.dirname(file).replace(/[\\\\]/g, '/');\n const templateConfig: InitWindowsTemplateConfig = require(path.join(\n templatesRoot,\n file,\n ));\n this.templates.set(templateName, templateConfig);\n }\n if (this.templates.size === 0) {\n throw new CodedError(\n 'NoTemplatesFound',\n `No templates were found in ${templatesRoot}.`,\n );\n }\n }\n\n protected getDefaultTemplateName(): string {\n for (const [name, config] of this.templates) {\n if (config.isDefault) {\n return name;\n }\n }\n throw new CodedError(\n 'NoDefaultTemplate',\n 'No template specified and no default template found.',\n );\n }\n\n protected getReactNativeProjectName(projectDir: string): string {\n this.verboseMessage('Looking for project name in package.json...');\n const pkgJsonPath = path.join(projectDir, 'package.json');\n if (!fs.existsSync(pkgJsonPath)) {\n throw new CodedError(\n 'NoPackageJson',\n 'Unable to find package.json. This should be run from within an existing react-native project.',\n );\n }\n type PackageJson = {name: string};\n\n let name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n if (!name) {\n const appJsonPath = path.join(projectDir, 'app.json');\n if (fs.existsSync(appJsonPath)) {\n this.verboseMessage('Looking for project name in app.json...');\n name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n }\n }\n\n if (!name) {\n throw new CodedError(\n 'NoProjectName',\n 'Please specify name in package.json or app.json',\n );\n }\n\n return name;\n }\n\n protected printTemplateList() {\n if (this.templates.size === 0) {\n console.log('\\nNo templates found.\\n');\n return;\n }\n\n for (const [key, value] of this.templates.entries()) {\n const defaultLabel = value.isDefault ? chalk.yellow('[Default] ') : '';\n console.log(\n `\\n${key} - ${value.name}\\n ${defaultLabel}${value.description}`,\n );\n }\n console.log(`\\n`);\n }\n\n // eslint-disable-next-line complexity\n public async run(spinner: Ora) {\n await this.loadTemplates();\n\n spinner.info();\n\n if (this.options.list) {\n this.printTemplateList();\n return;\n }\n\n this.options.template ??=\n (this.rnwConfig?.['init-windows']?.template as string | undefined) ??\n this.getDefaultTemplateName();\n\n spinner.info(`Using template '${this.options.template}'...`);\n if (!this.templates.has(this.options.template.replace(/[\\\\]/g, '/'))) {\n throw new CodedError(\n 'InvalidTemplateName',\n `Unable to find template '${this.options.template}'.`,\n );\n }\n\n if (this.options.template.startsWith('old')) {\n spinner.warn(\n `The legacy '${this.options.template}' template targets the React Native Old Architecture, which will eventually be deprecated. See https://microsoft.github.io/react-native-windows/docs/new-architecture for details on switching to the New Architecture.`,\n );\n }\n\n const templateConfig = this.templates.get(this.options.template)!;\n\n // Check if there's a passed-in project name and if it's valid\n if (\n this.options.name &&\n !nameHelpers.isValidProjectName(this.options.name)\n ) {\n throw new CodedError(\n 'InvalidProjectName',\n `The specified name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // If no project name is provided, check previously used name or calculate a name and clean if necessary\n if (!this.options.name) {\n const projectName =\n (this.rnwConfig?.['init-windows']?.name as string | undefined) ??\n this.getReactNativeProjectName(this.config.root);\n this.options.name = nameHelpers.isValidProjectName(projectName)\n ? projectName\n : nameHelpers.cleanName(projectName);\n }\n\n // Final check that the project name is valid\n if (!nameHelpers.isValidProjectName(this.options.name)) {\n throw new CodedError(\n 'InvalidProjectName',\n `The name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // Check if there's a passed-in project namespace and if it's valid\n if (\n this.options.namespace &&\n !nameHelpers.isValidProjectNamespace(this.options.namespace)\n ) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The specified namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n // If no project namespace is provided, check previously used namespace or use the project name and clean if necessary\n if (!this.options.namespace) {\n const namespace =\n (this.rnwConfig?.['init-windows']?.namespace as string | undefined) ??\n this.options.name;\n this.options.namespace = nameHelpers.isValidProjectNamespace(namespace)\n ? namespace\n : nameHelpers.cleanNamespace(namespace);\n }\n\n // Final check that the project namespace is valid\n if (!nameHelpers.isValidProjectNamespace(this.options.namespace)) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n if (templateConfig.preInstall) {\n spinner.info(`Running ${this.options.template} preInstall()...`);\n await templateConfig.preInstall(this.config, this.options);\n }\n\n // Get template files to copy and copy if available\n if (templateConfig.getFileMappings) {\n const fileMappings = await templateConfig.getFileMappings(\n this.config,\n this.options,\n );\n\n for (const fileMapping of fileMappings) {\n const targetDir = path.join(\n this.config.root,\n path.dirname(fileMapping.to),\n );\n\n if (!(await fs.exists(targetDir))) {\n await fs.mkdir(targetDir, {recursive: true});\n }\n\n await copyAndReplaceWithChangedCallback(\n fileMapping.from,\n this.config.root,\n fileMapping.to,\n fileMapping.replacements,\n this.options.overwrite,\n );\n }\n }\n\n if (templateConfig.postInstall) {\n spinner.info(`Running ${this.options.template} postInstall()...`);\n await templateConfig.postInstall(this.config, this.options);\n }\n\n spinner.succeed();\n }\n}\n\n/**\n * Logs the given message if verbose is True.\n * @param message The message to log.\n * @param verbose Whether or not verbose logging is enabled.\n */\nfunction verboseMessage(message: any, verbose?: boolean) {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\nfunction optionSanitizer(key: keyof InitOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'name':\n case 'namespace':\n return value === undefined ? false : true; // Strip PII\n case 'logging':\n case 'template':\n case 'overwrite':\n case 'telemetry':\n case 'list':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `init-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {};\n return extraProps;\n}\n\n/**\n * The function run when calling `npx @react-native-community/cli init-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function initWindows(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n await startTelemetrySession(\n 'init-windows',\n config,\n options,\n getDefaultOptions(config, initOptions),\n optionSanitizer,\n );\n\n let initWindowsError: Error | undefined;\n try {\n await initWindowsInternal(args, config, options);\n } catch (ex) {\n initWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(initWindowsError);\n }\n\n await endTelemetrySession(initWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, initWindowsError);\n}\n\n/**\n * Initializes a new RNW project from a given template.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nexport async function initWindowsInternal(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner('Running init-windows...');\n try {\n const codegen = new InitWindows(config, options);\n await codegen.run(spinner);\n const endTime = performance.now();\n\n console.log(\n `${chalk.green('Success:')} init-windows completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } catch (e) {\n spinner.fail();\n const endTime = performance.now();\n console.log(\n `${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n throw e;\n }\n}\n\n/**\n * Initializes a new RNW project from a given template.\n */\nexport const initCommand: Command = {\n name: 'init-windows',\n description: 'Initializes a new RNW project from a given template',\n func: initWindows,\n options: initOptions,\n};\n"]}
1
+ {"version":3,"file":"initWindows.js","sourceRoot":"","sources":["../../../src/commands/initWindows/initWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,kDAA0B;AAC1B,+BAAsC;AAEtC,2CAAuC;AAEvC,gDAAwB;AAExB,MAAM,IAAI,GAAG,cAAI,CAAC,SAAS,CAAC,WAAQ,CAAC,CAAC;AAGtC,+DAAsE;AAEtE,yEAGyC;AACzC,qEAAuD;AACvD,mEAIsC;AACtC,6DAAyE;AACzE,qEAAuD;AACvD,+DAAsE;AACtE,uEAA2E;AAE3E,6DAAiD;AAoBjD,MAAa,WAAW;IAMtB,YAAqB,MAAc,EAAW,OAAoB;;QAA7C,WAAM,GAAN,MAAM,CAAQ;QAAW,YAAO,GAAP,OAAO,CAAa;QAH/C,cAAS,GAC1B,IAAI,GAAG,EAAE,CAAC;QAGV,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,GAAG,MAAA,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,0CAAE,SAAS,CAAC;IAC1D,CAAC;IAES,cAAc,CAAC,OAAY;QACnC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAES,KAAK,CAAC,aAAa;QAC3B,MAAM,aAAa,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC3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U,EAAC,yBAAyB,CAAC,CAAC;IACtD,IAAI;QACF,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjD,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAElC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,KAAK,CAAC,UAAU,CAAC,6BAA6B,IAAI,CAAC,KAAK,CAC/D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAK,CAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,KAAK,CAC7D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;QACF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AA3BD,kDA2BC;AAED;;GAEG;AACU,QAAA,WAAW,GAAY;IAClC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,qDAAqD;IAClE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,gCAAW;CACrB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport chalk from 'chalk';\nimport {glob as globFunc} from 'glob';\nimport _ from 'lodash';\nimport {performance} from 'perf_hooks';\nimport {Ora} from 'ora';\nimport util from 'util';\n\nconst glob = util.promisify(globFunc);\n\nimport type {Command, Config} from '@react-native-community/cli-types';\nimport {CodedError, Telemetry} from '@react-native-windows/telemetry';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport {copyAndReplaceWithChangedCallback} from '../../generator-common';\nimport * as nameHelpers from '../../utils/nameHelpers';\nimport {showOldArchitectureWarning} from '../../utils/oldArchWarning';\nimport {promptForArchitectureChoice} from '../../utils/architecturePrompt';\nimport type {InitOptions} from './initWindowsOptions';\nimport {initOptions} from './initWindowsOptions';\n\nexport interface TemplateFileMapping {\n from: string;\n to: string;\n replacements?: Record<string, any>;\n}\n\nexport interface InitWindowsTemplateConfig {\n name: string;\n description: string;\n isDefault?: boolean;\n preInstall?: (config: Config, options: InitOptions) => Promise<void>;\n getFileMappings?: (\n config: Config,\n options: InitOptions,\n ) => Promise<TemplateFileMapping[]>;\n postInstall?: (config: Config, options: InitOptions) => Promise<void>;\n}\n\nexport class InitWindows {\n protected readonly rnwPath: string;\n protected readonly rnwConfig?: Record<string, any>;\n protected readonly templates: Map<string, InitWindowsTemplateConfig> =\n new Map();\n\n constructor(readonly config: Config, readonly options: InitOptions) {\n this.rnwPath = pathHelpers.resolveRnwRoot(this.config.root);\n this.rnwConfig = this.config.project.windows?.rnwConfig;\n }\n\n protected verboseMessage(message: any) {\n verboseMessage(message, !!this.options.logging);\n }\n\n protected async loadTemplates() {\n const templatesRoot = path.join(this.rnwPath, 'templates');\n for (const file of await glob('**/template.config.js', {\n cwd: templatesRoot,\n })) {\n const templateName = path.dirname(file).replace(/[\\\\]/g, '/');\n const templateConfig: InitWindowsTemplateConfig = require(path.join(\n templatesRoot,\n file,\n ));\n this.templates.set(templateName, templateConfig);\n }\n if (this.templates.size === 0) {\n throw new CodedError(\n 'NoTemplatesFound',\n `No templates were found in ${templatesRoot}.`,\n );\n }\n }\n\n protected getDefaultTemplateName(): string {\n for (const [name, config] of this.templates) {\n if (config.isDefault) {\n return name;\n }\n }\n throw new CodedError(\n 'NoDefaultTemplate',\n 'No template specified and no default template found.',\n );\n }\n\n protected getReactNativeProjectName(projectDir: string): string {\n this.verboseMessage('Looking for project name in package.json...');\n const pkgJsonPath = path.join(projectDir, 'package.json');\n if (!fs.existsSync(pkgJsonPath)) {\n throw new CodedError(\n 'NoPackageJson',\n 'Unable to find package.json. This should be run from within an existing react-native project.',\n );\n }\n type PackageJson = {name: string};\n\n let name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n if (!name) {\n const appJsonPath = path.join(projectDir, 'app.json');\n if (fs.existsSync(appJsonPath)) {\n this.verboseMessage('Looking for project name in app.json...');\n name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n }\n }\n\n if (!name) {\n throw new CodedError(\n 'NoProjectName',\n 'Please specify name in package.json or app.json',\n );\n }\n\n return name;\n }\n\n protected printTemplateList() {\n if (this.templates.size === 0) {\n console.log('\\nNo templates found.\\n');\n return;\n }\n\n for (const [key, value] of this.templates.entries()) {\n const defaultLabel = value.isDefault ? chalk.yellow('[Default] ') : '';\n console.log(\n `\\n${key} - ${value.name}\\n ${defaultLabel}${value.description}`,\n );\n }\n console.log(`\\n`);\n }\n\n // eslint-disable-next-line complexity\n public async run(spinner: Ora) {\n await this.loadTemplates();\n\n spinner.info();\n\n if (this.options.list) {\n this.printTemplateList();\n return;\n }\n\n const userDidNotPassTemplate = !process.argv.some(arg =>\n arg.startsWith('--template'),\n );\n this.options.template ??=\n (this.rnwConfig?.['init-windows']?.template as string | undefined) ??\n this.getDefaultTemplateName();\n\n spinner.info(`Using template '${this.options.template}'...`);\n if (!this.templates.has(this.options.template.replace(/[\\\\]/g, '/'))) {\n throw new CodedError(\n 'InvalidTemplateName',\n `Unable to find template '${this.options.template}'.`,\n );\n }\n\n const isOldArchTemplate = this.options.template.startsWith('old');\n const promptFlag = this.options.prompt;\n\n if (isOldArchTemplate) {\n showOldArchitectureWarning();\n\n if (userDidNotPassTemplate && promptFlag) {\n const promptResult = await promptForArchitectureChoice();\n\n if (\n !promptResult.shouldContinueWithOldArch &&\n !promptResult.userCancelled\n ) {\n spinner.info('Switching to New Architecture template (cpp-app)...');\n this.options.template = 'cpp-app';\n }\n }\n }\n\n const templateConfig = this.templates.get(this.options.template)!;\n\n // Check if there's a passed-in project name and if it's valid\n if (\n this.options.name &&\n !nameHelpers.isValidProjectName(this.options.name)\n ) {\n throw new CodedError(\n 'InvalidProjectName',\n `The specified name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // If no project name is provided, check previously used name or calculate a name and clean if necessary\n if (!this.options.name) {\n const projectName =\n (this.rnwConfig?.['init-windows']?.name as string | undefined) ??\n this.getReactNativeProjectName(this.config.root);\n this.options.name = nameHelpers.isValidProjectName(projectName)\n ? projectName\n : nameHelpers.cleanName(projectName);\n }\n\n // Final check that the project name is valid\n if (!nameHelpers.isValidProjectName(this.options.name)) {\n throw new CodedError(\n 'InvalidProjectName',\n `The name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // Check if there's a passed-in project namespace and if it's valid\n if (\n this.options.namespace &&\n !nameHelpers.isValidProjectNamespace(this.options.namespace)\n ) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The specified namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n // If no project namespace is provided, check previously used namespace or use the project name and clean if necessary\n if (!this.options.namespace) {\n const namespace =\n (this.rnwConfig?.['init-windows']?.namespace as string | undefined) ??\n this.options.name;\n this.options.namespace = nameHelpers.isValidProjectNamespace(namespace)\n ? namespace\n : nameHelpers.cleanNamespace(namespace);\n }\n\n // Final check that the project namespace is valid\n if (!nameHelpers.isValidProjectNamespace(this.options.namespace)) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n if (templateConfig.preInstall) {\n spinner.info(`Running ${this.options.template} preInstall()...`);\n await templateConfig.preInstall(this.config, this.options);\n }\n\n // Get template files to copy and copy if available\n if (templateConfig.getFileMappings) {\n const fileMappings = await templateConfig.getFileMappings(\n this.config,\n this.options,\n );\n\n for (const fileMapping of fileMappings) {\n const targetDir = path.join(\n this.config.root,\n path.dirname(fileMapping.to),\n );\n\n if (!(await fs.exists(targetDir))) {\n await fs.mkdir(targetDir, {recursive: true});\n }\n\n await copyAndReplaceWithChangedCallback(\n fileMapping.from,\n this.config.root,\n fileMapping.to,\n fileMapping.replacements,\n this.options.overwrite,\n );\n }\n }\n\n if (templateConfig.postInstall) {\n spinner.info(`Running ${this.options.template} postInstall()...`);\n await templateConfig.postInstall(this.config, this.options);\n }\n\n spinner.succeed();\n }\n}\n\n/**\n * Logs the given message if verbose is True.\n * @param message The message to log.\n * @param verbose Whether or not verbose logging is enabled.\n */\nfunction verboseMessage(message: any, verbose?: boolean) {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\nfunction optionSanitizer(key: keyof InitOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'name':\n case 'namespace':\n return value === undefined ? false : true; // Strip PII\n case 'logging':\n case 'template':\n case 'overwrite':\n case 'telemetry':\n case 'list':\n case 'prompt':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `init-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {};\n return extraProps;\n}\n\nfunction sanitizeOptions(\n opts: Record<string, any>,\n sanitizer: (key: keyof InitOptions, value: any) => any,\n): Record<string, any> {\n const sanitized: Record<string, any> = {};\n for (const key in opts) {\n if (Object.prototype.hasOwnProperty.call(opts, key)) {\n sanitized[key] = sanitizer(key as keyof InitOptions, opts[key]);\n }\n }\n return sanitized;\n}\n\n/**\n * The function run when calling `npx @react-native-community/cli init-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function initWindows(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n await startTelemetrySession(\n 'init-windows',\n config,\n options,\n getDefaultOptions(config, initOptions),\n optionSanitizer,\n );\n\n let initWindowsError: Error | undefined;\n\n try {\n await initWindowsInternal(args, config, options);\n } catch (ex) {\n initWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(initWindowsError);\n }\n\n // Now, instead of custom fields, just pass the final options object\n await endTelemetrySession(initWindowsError, getExtraProps, options, opts =>\n sanitizeOptions(opts, optionSanitizer),\n );\n\n setExitProcessWithError(options.logging, initWindowsError);\n}\n\n/**\n * Initializes a new RNW project from a given template.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nexport async function initWindowsInternal(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner('Running init-windows...');\n try {\n const codegen = new InitWindows(config, options);\n await codegen.run(spinner);\n const endTime = performance.now();\n\n console.log(\n `${chalk.green('Success:')} init-windows completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } catch (e) {\n spinner.fail();\n const endTime = performance.now();\n console.log(\n `${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n throw e;\n }\n}\n\n/**\n * Initializes a new RNW project from a given template.\n */\nexport const initCommand: Command = {\n name: 'init-windows',\n description: 'Initializes a new RNW project from a given template',\n func: initWindows,\n options: initOptions,\n};\n"]}
@@ -12,5 +12,6 @@ export interface InitOptions {
12
12
  overwrite?: boolean;
13
13
  telemetry?: boolean;
14
14
  list?: boolean;
15
+ prompt?: boolean;
15
16
  }
16
17
  export declare const initOptions: CommandOption[];
@@ -38,5 +38,9 @@ exports.initOptions = [
38
38
  name: '--list',
39
39
  description: 'Shows a list with all available templates with their descriptions.',
40
40
  },
41
+ {
42
+ name: '--no-prompt',
43
+ description: 'Skip any interactive prompts and use default choices.',
44
+ },
41
45
  ];
42
46
  //# sourceMappingURL=initWindowsOptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"initWindowsOptions.js","sourceRoot":"","sources":["../../../src/commands/initWindows/initWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAcU,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,iBAAiB;KAC3B;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;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,oEAAoE;KACvE;CACF,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport type {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 list?: 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: 'old/uwp-cpp-app',\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 name: '--list',\n description:\n 'Shows a list with all available templates with their descriptions.',\n },\n];\n"]}
1
+ {"version":3,"file":"initWindowsOptions.js","sourceRoot":"","sources":["../../../src/commands/initWindows/initWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAeU,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,iBAAiB;KAC3B;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;IACD;QACE,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,oEAAoE;KACvE;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,uDAAuD;KACrE;CACF,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport type {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 list?: boolean;\n prompt?: 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: 'old/uwp-cpp-app',\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 name: '--list',\n description:\n 'Shows a list with all available templates with their descriptions.',\n },\n {\n name: '--no-prompt',\n description: 'Skip any interactive prompts and use default choices.',\n },\n];\n"]}
@@ -46,6 +46,7 @@ const info = __importStar(require("../../utils/info"));
46
46
  const msbuildtools_1 = __importDefault(require("../../utils/msbuildtools"));
47
47
  const runWindowsOptions_1 = require("./runWindowsOptions");
48
48
  const autolinkWindows_1 = require("../autolinkWindows/autolinkWindows");
49
+ const oldArchWarning_1 = require("../../utils/oldArchWarning");
49
50
  /**
50
51
  * Sanitizes the given option for telemetry.
51
52
  * @param key The key of the option.
@@ -170,7 +171,7 @@ async function runWindowsInternal(args, config, options) {
170
171
  }
171
172
  // Warn about old architecture projects
172
173
  if (((_b = (_a = config.project.windows) === null || _a === void 0 ? void 0 : _a.rnwConfig) === null || _b === void 0 ? void 0 : _b.projectArch) === 'old') {
173
- (0, commandWithProgress_1.newWarn)('This project is using the React Native (for Windows) Old Architecture, which will eventually be deprecated. See https://microsoft.github.io/react-native-windows/docs/new-architecture for details on switching to the New Architecture.');
174
+ (0, oldArchWarning_1.showOldArchitectureWarning)();
174
175
  }
175
176
  // Get the solution file
176
177
  let slnFile;
@@ -1 +1 @@
1
- {"version":3,"file":"runWindows.js","sourceRoot":"","sources":["../../../src/commands/runWindows/runWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+BAA+B;AAE/B,kEAA0C;AAC1C,gDAAwB;AAExB,+DAAsE;AAGtE,yDAA2C;AAC3C,kDAA0B;AAC1B,2DAA6C;AAC7C,yEAKyC;AACzC,mEAIsC;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* @format\n */\n\n/* eslint-disable complexity */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\n\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport type {Command, Config} from '@react-native-community/cli-types';\n\nimport * as build from '../../utils/build';\nimport chalk from 'chalk';\nimport * as deploy from '../../utils/deploy';\nimport {\n newError,\n newInfo,\n newWarn,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport * as info from '../../utils/info';\nimport MSBuildTools from '../../utils/msbuildtools';\nimport type {RunWindowsOptions} from './runWindowsOptions';\nimport {runWindowsOptions} from './runWindowsOptions';\nimport {autolinkWindowsInternal} from '../autolinkWindows/autolinkWindows';\nimport type {AutoLinkOptions} from '../autolinkWindows/autolinkWindowsOptions';\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\nfunction optionSanitizer(key: keyof RunWindowsOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'root':\n case 'target':\n case 'sln':\n case 'proj':\n case 'buildLogDirectory':\n return value === undefined ? false : true; // Strip PII\n case 'msbuildprops':\n return typeof value === 'string' ? value.split(',').length : 0; // Convert to count\n case 'release':\n case 'arch':\n case 'singleproc':\n case 'emulator':\n case 'device':\n case 'remoteDebugging':\n case 'logging':\n case 'packager':\n case 'bundle':\n case 'launch':\n case 'autolink':\n case 'build':\n case 'deploy':\n case 'deployFromLayout':\n case 'info':\n case 'directDebugging':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `run-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {\n phase: runWindowsPhase,\n hasRunRnwDependencies,\n msBuildProps: evaluateMSBuildPropsCallback\n ? evaluateMSBuildPropsCallback()\n : {},\n };\n return extraProps;\n}\n\n/**\n * Labels used by telemetry to represent current operation\n */\ntype RunWindowsPhase =\n | 'None'\n | 'Info'\n | 'FindSolution'\n | 'FindBuildTools'\n | 'Autolink'\n | 'RestorePackagesConfig'\n | 'Build'\n | 'Deploy';\n\nlet runWindowsPhase: RunWindowsPhase = 'None';\n\nlet hasRunRnwDependencies: boolean = false;\n\nlet evaluateMSBuildPropsCallback:\n | (() => Record<string, string> | null)\n | undefined;\n\n/**\n * The function run when calling `npx @react-native-community/cli run-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindows(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n await startTelemetrySession(\n 'run-windows',\n config,\n options,\n getDefaultOptions(config, runWindowsOptions),\n optionSanitizer,\n );\n\n // https://github.com/yarnpkg/yarn/issues/8334 - Yarn on Windows breaks apps that read from the environment variables\n // Yarn will run node via CreateProcess and pass npm_config_* variables in lowercase without unifying their value\n // with their possibly existing uppercase counterparts. This breaks programs that read from the environment block\n // and write to a case-insensitive dictionary since they expect to encounter each variable only once.\n // The values of the lowercase variables are the one npm actually wants to use, plus they are seeded from the\n // uppercase variable values one if there are no overrides.\n delete process.env.NPM_CONFIG_CACHE;\n delete process.env.NPM_CONFIG_PREFIX;\n\n if (process.env.LocalAppData) {\n hasRunRnwDependencies = fs.existsSync(\n path.join(process.env.LocalAppData, 'rnw-dependencies.txt'),\n ); // CODESYNC \\vnext\\scripts\\rnw-dependencies.ps1\n }\n\n let runWindowsError: Error | undefined;\n if (options.info) {\n runWindowsPhase = 'Info';\n try {\n const output = await info.getEnvironmentInfo();\n console.log(output.trimEnd());\n console.log(' Installed UWP SDKs:');\n const sdks = MSBuildTools.getAllAvailableUAPVersions();\n sdks.forEach(version => console.log(' ' + version));\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n newError(\n 'Unable to print environment info.\\n' + runWindowsError.toString(),\n );\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n return;\n }\n\n try {\n await runWindowsInternal(args, config, options);\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n if (!hasRunRnwDependencies) {\n const rnwDependenciesPath = path.join(\n pathHelpers.resolveRnwRoot([process.cwd(), __dirname]),\n 'scripts/rnw-dependencies.ps1',\n );\n\n newError(\n `It is possible your installation is missing required software dependencies. Dependencies can be automatically installed by running ${rnwDependenciesPath} from an elevated PowerShell prompt.\\nFor more information, go to http://aka.ms/rnw-deps`,\n );\n }\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n}\n\n/**\n * Performs build deploy and launch of RNW apps.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindowsInternal(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n const verbose = options.logging === true;\n\n if (verbose) {\n newInfo('Verbose: ON');\n }\n\n // Warn about old architecture projects\n if (config.project.windows?.rnwConfig?.projectArch === 'old') {\n newWarn(\n 'This project is using the React Native (for Windows) Old Architecture, which will eventually be deprecated. See https://microsoft.github.io/react-native-windows/docs/new-architecture for details on switching to the New Architecture.',\n );\n }\n\n // Get the solution file\n let slnFile: string | null;\n runWindowsPhase = 'FindSolution';\n try {\n slnFile = build.getAppSolutionFile(options, config);\n } catch (e) {\n newError(`Couldn't get app solution information. ${(e as Error).message}`);\n throw e;\n }\n\n let buildTools: MSBuildTools;\n runWindowsPhase = 'FindBuildTools';\n try {\n buildTools = MSBuildTools.findAvailableVersion(options.arch, verbose);\n } catch (error) {\n newWarn('No public VS release found');\n // Try prerelease\n try {\n newInfo('Trying pre-release VS');\n buildTools = MSBuildTools.findAvailableVersion(\n options.arch,\n verbose,\n true, // preRelease\n );\n } catch (e) {\n newError((e as Error).message);\n throw error;\n }\n }\n\n // Set up the callback to capture MSBuild properties after the command completes\n evaluateMSBuildPropsCallback = () => {\n const projectFile = build.getAppProjectFile(options, config);\n if (projectFile) {\n if (verbose) {\n newInfo('Gathering MSBuild data for telemetry.');\n }\n\n const msBuildPropertiesJsonPath = path.resolve(\n path.dirname(projectFile),\n 'Generated Files',\n 'msbuildproperties.g.json',\n );\n\n if (fs.existsSync(msBuildPropertiesJsonPath)) {\n if (verbose) {\n newInfo('Loading properties from msbuildproperties.g.json');\n }\n return fs.readJsonFileSync(msBuildPropertiesJsonPath);\n }\n\n if (verbose) {\n newInfo('Unable to find msbuildproperties.g.json');\n }\n }\n\n return {};\n };\n\n // Restore packages.config files for dependencies that don't support PackageReference.\n runWindowsPhase = 'RestorePackagesConfig';\n const buildType = deploy.getBuildConfiguration(options);\n try {\n await buildTools.restorePackageConfigs(slnFile, options.arch, buildType);\n } catch (e) {\n newError(\n `Couldn't restore found packages.config instances. ${\n (e as Error).message\n }`,\n );\n throw e;\n }\n\n if (options.autolink) {\n runWindowsPhase = 'Autolink';\n try {\n const autolinkArgs: string[] = [];\n const autolinkConfig = config;\n const autolinkOptions: AutoLinkOptions = {\n logging: options.logging,\n check: false,\n proj: options.proj,\n sln: options.sln,\n telemetry: options.telemetry,\n };\n await autolinkWindowsInternal(\n autolinkArgs,\n autolinkConfig,\n autolinkOptions,\n );\n } catch (e) {\n newError(`Autolinking failed. ${(e as Error).message}`);\n throw e;\n }\n } else {\n newInfo('Autolink step is skipped');\n }\n\n if (options.build) {\n runWindowsPhase = 'Build';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx @react-native-community/cli init-windows\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n // Get build/deploy options\n const msBuildProps = build.parseMsBuildProps(options);\n\n // Disable the autolink check since we just ran it\n msBuildProps.RunAutolinkCheck = 'false';\n\n try {\n await build.buildSolution(\n buildTools,\n slnFile!,\n buildType,\n options.arch,\n msBuildProps,\n verbose,\n 'build',\n options.buildLogDirectory,\n options.singleproc,\n );\n } catch (e) {\n newError(\n `Build failed with message ${\n (e as Error).message\n }. Check your build configuration.`,\n );\n if ((e as any).logfile) {\n console.log('See', chalk.bold((e as any).logfile));\n }\n throw e;\n }\n } else {\n newInfo('Build step is skipped');\n }\n\n if (shouldLaunchPackager(options)) {\n await deploy.startServerInNewWindow(options, verbose);\n }\n\n if (options.deploy) {\n runWindowsPhase = 'Deploy';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx @react-native-community/cli init-windows\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n try {\n if (options.device || options.emulator || options.target) {\n await deploy.deployToDevice(options, verbose, config);\n } else {\n await deploy.deployToDesktop(options, verbose, config, buildTools);\n }\n } catch (e) {\n newError(`Failed to deploy${e ? `: ${(e as Error).message}` : ''}`);\n throw e;\n }\n } else {\n newInfo('Deploy step is skipped');\n }\n}\n\nfunction shouldLaunchPackager(options: RunWindowsOptions): boolean {\n return (\n options.packager === true &&\n options.launch === true &&\n options.release !== true\n );\n}\n\n/*\n// Example of running the Windows Command\nrunWindows({\n root: 'C:\\\\github\\\\hack\\\\myapp',\n debug: true,\n arch: 'x86',\n nugetPath: 'C:\\\\github\\\\react\\\\react-native-windows\\\\local-cli\\\\runWindows\\\\.nuget\\\\nuget.exe'\n});\n*/\n\n/**\n * Starts the app on a connected Windows emulator or mobile device.\n */\nexport const runWindowsCommand: Command = {\n name: 'run-windows',\n description:\n 'Builds your RNW app and starts it on a connected Windows desktop, emulator or device',\n func: runWindows,\n options: runWindowsOptions,\n};\n"]}
1
+ {"version":3,"file":"runWindows.js","sourceRoot":"","sources":["../../../src/commands/runWindows/runWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG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B,GAAY;IACxC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,sFAAsF;IACxF,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,qCAAiB;CAC3B,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\n/* eslint-disable complexity */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\n\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport type {Command, Config} from '@react-native-community/cli-types';\n\nimport * as build from '../../utils/build';\nimport chalk from 'chalk';\nimport * as deploy from '../../utils/deploy';\nimport {\n newError,\n newInfo,\n newWarn,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport * as info from '../../utils/info';\nimport MSBuildTools from '../../utils/msbuildtools';\nimport type {RunWindowsOptions} from './runWindowsOptions';\nimport {runWindowsOptions} from './runWindowsOptions';\nimport {autolinkWindowsInternal} from '../autolinkWindows/autolinkWindows';\nimport type {AutoLinkOptions} from '../autolinkWindows/autolinkWindowsOptions';\nimport {showOldArchitectureWarning} from '../../utils/oldArchWarning';\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\nfunction optionSanitizer(key: keyof RunWindowsOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'root':\n case 'target':\n case 'sln':\n case 'proj':\n case 'buildLogDirectory':\n return value === undefined ? false : true; // Strip PII\n case 'msbuildprops':\n return typeof value === 'string' ? value.split(',').length : 0; // Convert to count\n case 'release':\n case 'arch':\n case 'singleproc':\n case 'emulator':\n case 'device':\n case 'remoteDebugging':\n case 'logging':\n case 'packager':\n case 'bundle':\n case 'launch':\n case 'autolink':\n case 'build':\n case 'deploy':\n case 'deployFromLayout':\n case 'info':\n case 'directDebugging':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `run-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {\n phase: runWindowsPhase,\n hasRunRnwDependencies,\n msBuildProps: evaluateMSBuildPropsCallback\n ? evaluateMSBuildPropsCallback()\n : {},\n };\n return extraProps;\n}\n\n/**\n * Labels used by telemetry to represent current operation\n */\ntype RunWindowsPhase =\n | 'None'\n | 'Info'\n | 'FindSolution'\n | 'FindBuildTools'\n | 'Autolink'\n | 'RestorePackagesConfig'\n | 'Build'\n | 'Deploy';\n\nlet runWindowsPhase: RunWindowsPhase = 'None';\n\nlet hasRunRnwDependencies: boolean = false;\n\nlet evaluateMSBuildPropsCallback:\n | (() => Record<string, string> | null)\n | undefined;\n\n/**\n * The function run when calling `npx @react-native-community/cli run-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindows(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n await startTelemetrySession(\n 'run-windows',\n config,\n options,\n getDefaultOptions(config, runWindowsOptions),\n optionSanitizer,\n );\n\n // https://github.com/yarnpkg/yarn/issues/8334 - Yarn on Windows breaks apps that read from the environment variables\n // Yarn will run node via CreateProcess and pass npm_config_* variables in lowercase without unifying their value\n // with their possibly existing uppercase counterparts. This breaks programs that read from the environment block\n // and write to a case-insensitive dictionary since they expect to encounter each variable only once.\n // The values of the lowercase variables are the one npm actually wants to use, plus they are seeded from the\n // uppercase variable values one if there are no overrides.\n delete process.env.NPM_CONFIG_CACHE;\n delete process.env.NPM_CONFIG_PREFIX;\n\n if (process.env.LocalAppData) {\n hasRunRnwDependencies = fs.existsSync(\n path.join(process.env.LocalAppData, 'rnw-dependencies.txt'),\n ); // CODESYNC \\vnext\\scripts\\rnw-dependencies.ps1\n }\n\n let runWindowsError: Error | undefined;\n if (options.info) {\n runWindowsPhase = 'Info';\n try {\n const output = await info.getEnvironmentInfo();\n console.log(output.trimEnd());\n console.log(' Installed UWP SDKs:');\n const sdks = MSBuildTools.getAllAvailableUAPVersions();\n sdks.forEach(version => console.log(' ' + version));\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n newError(\n 'Unable to print environment info.\\n' + runWindowsError.toString(),\n );\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n return;\n }\n\n try {\n await runWindowsInternal(args, config, options);\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n if (!hasRunRnwDependencies) {\n const rnwDependenciesPath = path.join(\n pathHelpers.resolveRnwRoot([process.cwd(), __dirname]),\n 'scripts/rnw-dependencies.ps1',\n );\n\n newError(\n `It is possible your installation is missing required software dependencies. Dependencies can be automatically installed by running ${rnwDependenciesPath} from an elevated PowerShell prompt.\\nFor more information, go to http://aka.ms/rnw-deps`,\n );\n }\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n}\n\n/**\n * Performs build deploy and launch of RNW apps.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindowsInternal(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n const verbose = options.logging === true;\n\n if (verbose) {\n newInfo('Verbose: ON');\n }\n\n // Warn about old architecture projects\n if (config.project.windows?.rnwConfig?.projectArch === 'old') {\n showOldArchitectureWarning();\n }\n\n // Get the solution file\n let slnFile: string | null;\n runWindowsPhase = 'FindSolution';\n try {\n slnFile = build.getAppSolutionFile(options, config);\n } catch (e) {\n newError(`Couldn't get app solution information. ${(e as Error).message}`);\n throw e;\n }\n\n let buildTools: MSBuildTools;\n runWindowsPhase = 'FindBuildTools';\n try {\n buildTools = MSBuildTools.findAvailableVersion(options.arch, verbose);\n } catch (error) {\n newWarn('No public VS release found');\n // Try prerelease\n try {\n newInfo('Trying pre-release VS');\n buildTools = MSBuildTools.findAvailableVersion(\n options.arch,\n verbose,\n true, // preRelease\n );\n } catch (e) {\n newError((e as Error).message);\n throw error;\n }\n }\n\n // Set up the callback to capture MSBuild properties after the command completes\n evaluateMSBuildPropsCallback = () => {\n const projectFile = build.getAppProjectFile(options, config);\n if (projectFile) {\n if (verbose) {\n newInfo('Gathering MSBuild data for telemetry.');\n }\n\n const msBuildPropertiesJsonPath = path.resolve(\n path.dirname(projectFile),\n 'Generated Files',\n 'msbuildproperties.g.json',\n );\n\n if (fs.existsSync(msBuildPropertiesJsonPath)) {\n if (verbose) {\n newInfo('Loading properties from msbuildproperties.g.json');\n }\n return fs.readJsonFileSync(msBuildPropertiesJsonPath);\n }\n\n if (verbose) {\n newInfo('Unable to find msbuildproperties.g.json');\n }\n }\n\n return {};\n };\n\n // Restore packages.config files for dependencies that don't support PackageReference.\n runWindowsPhase = 'RestorePackagesConfig';\n const buildType = deploy.getBuildConfiguration(options);\n try {\n await buildTools.restorePackageConfigs(slnFile, options.arch, buildType);\n } catch (e) {\n newError(\n `Couldn't restore found packages.config instances. ${\n (e as Error).message\n }`,\n );\n throw e;\n }\n\n if (options.autolink) {\n runWindowsPhase = 'Autolink';\n try {\n const autolinkArgs: string[] = [];\n const autolinkConfig = config;\n const autolinkOptions: AutoLinkOptions = {\n logging: options.logging,\n check: false,\n proj: options.proj,\n sln: options.sln,\n telemetry: options.telemetry,\n };\n await autolinkWindowsInternal(\n autolinkArgs,\n autolinkConfig,\n autolinkOptions,\n );\n } catch (e) {\n newError(`Autolinking failed. ${(e as Error).message}`);\n throw e;\n }\n } else {\n newInfo('Autolink step is skipped');\n }\n\n if (options.build) {\n runWindowsPhase = 'Build';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx @react-native-community/cli init-windows\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n // Get build/deploy options\n const msBuildProps = build.parseMsBuildProps(options);\n\n // Disable the autolink check since we just ran it\n msBuildProps.RunAutolinkCheck = 'false';\n\n try {\n await build.buildSolution(\n buildTools,\n slnFile!,\n buildType,\n options.arch,\n msBuildProps,\n verbose,\n 'build',\n options.buildLogDirectory,\n options.singleproc,\n );\n } catch (e) {\n newError(\n `Build failed with message ${\n (e as Error).message\n }. Check your build configuration.`,\n );\n if ((e as any).logfile) {\n console.log('See', chalk.bold((e as any).logfile));\n }\n throw e;\n }\n } else {\n newInfo('Build step is skipped');\n }\n\n if (shouldLaunchPackager(options)) {\n await deploy.startServerInNewWindow(options, verbose);\n }\n\n if (options.deploy) {\n runWindowsPhase = 'Deploy';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx @react-native-community/cli init-windows\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n try {\n if (options.device || options.emulator || options.target) {\n await deploy.deployToDevice(options, verbose, config);\n } else {\n await deploy.deployToDesktop(options, verbose, config, buildTools);\n }\n } catch (e) {\n newError(`Failed to deploy${e ? `: ${(e as Error).message}` : ''}`);\n throw e;\n }\n } else {\n newInfo('Deploy step is skipped');\n }\n}\n\nfunction shouldLaunchPackager(options: RunWindowsOptions): boolean {\n return (\n options.packager === true &&\n options.launch === true &&\n options.release !== true\n );\n}\n\n/*\n// Example of running the Windows Command\nrunWindows({\n root: 'C:\\\\github\\\\hack\\\\myapp',\n debug: true,\n arch: 'x86',\n nugetPath: 'C:\\\\github\\\\react\\\\react-native-windows\\\\local-cli\\\\runWindows\\\\.nuget\\\\nuget.exe'\n});\n*/\n\n/**\n * Starts the app on a connected Windows emulator or mobile device.\n */\nexport const runWindowsCommand: Command = {\n name: 'run-windows',\n description:\n 'Builds your RNW app and starts it on a connected Windows desktop, emulator or device',\n func: runWindows,\n options: runWindowsOptions,\n};\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ export {};
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ const architecturePrompt_1 = require("../utils/architecturePrompt");
12
+ // Mock prompts module
13
+ jest.mock('prompts', () => {
14
+ return jest.fn();
15
+ });
16
+ const prompts_1 = __importDefault(require("prompts"));
17
+ const mockPrompts = prompts_1.default;
18
+ describe('architecturePrompt', () => {
19
+ beforeEach(() => {
20
+ jest.clearAllMocks();
21
+ });
22
+ test('returns true when user chooses Y', async () => {
23
+ mockPrompts.mockResolvedValue({ choice: 'y' });
24
+ const result = await (0, architecturePrompt_1.promptForArchitectureChoice)();
25
+ expect(result.shouldContinueWithOldArch).toBe(true);
26
+ expect(result.userCancelled).toBe(false);
27
+ });
28
+ test('returns true when user chooses Y (uppercase)', async () => {
29
+ mockPrompts.mockResolvedValue({ choice: 'Y' });
30
+ const result = await (0, architecturePrompt_1.promptForArchitectureChoice)();
31
+ expect(result.shouldContinueWithOldArch).toBe(true);
32
+ expect(result.userCancelled).toBe(false);
33
+ });
34
+ test('returns false when user chooses N', async () => {
35
+ mockPrompts.mockResolvedValue({ choice: 'n' });
36
+ const result = await (0, architecturePrompt_1.promptForArchitectureChoice)();
37
+ expect(result.shouldContinueWithOldArch).toBe(false);
38
+ expect(result.userCancelled).toBe(false);
39
+ });
40
+ test('returns false when user chooses N (uppercase)', async () => {
41
+ mockPrompts.mockResolvedValue({ choice: 'N' });
42
+ const result = await (0, architecturePrompt_1.promptForArchitectureChoice)();
43
+ expect(result.shouldContinueWithOldArch).toBe(false);
44
+ expect(result.userCancelled).toBe(false);
45
+ });
46
+ test('returns true with userCancelled when user cancels with no input', async () => {
47
+ mockPrompts.mockResolvedValue({});
48
+ const result = await (0, architecturePrompt_1.promptForArchitectureChoice)();
49
+ expect(result.shouldContinueWithOldArch).toBe(true);
50
+ expect(result.userCancelled).toBe(true);
51
+ });
52
+ test('returns true with userCancelled when prompts throws cancellation error', async () => {
53
+ mockPrompts.mockRejectedValue(new Error('User cancelled'));
54
+ const result = await (0, architecturePrompt_1.promptForArchitectureChoice)();
55
+ expect(result.shouldContinueWithOldArch).toBe(true);
56
+ expect(result.userCancelled).toBe(true);
57
+ });
58
+ test('returns true and not cancelled on other errors', async () => {
59
+ mockPrompts.mockRejectedValue(new Error('Some other error'));
60
+ const result = await (0, architecturePrompt_1.promptForArchitectureChoice)();
61
+ expect(result.shouldContinueWithOldArch).toBe(true);
62
+ expect(result.userCancelled).toBe(false);
63
+ });
64
+ });
65
+ //# sourceMappingURL=architecturePrompt.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"architecturePrompt.test.js","sourceRoot":"","sources":["../../src/e2etest/architecturePrompt.test.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;AAEH,oEAAwE;AAExE,sBAAsB;AACtB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IACxB,OAAO,IAAI,CAAC,EAAE,EAAE,CAAC;AACnB,CAAC,CAAC,CAAC;AAEH,sDAA8B;AAC9B,MAAM,WAAW,GAAG,iBAA8C,CAAC;AAEnE,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QAClD,WAAW,CAAC,iBAAiB,CAAC,EAAC,MAAM,EAAE,GAAG,EAAC,CAAC,CAAC;QAE7C,MAAM,MAA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Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {promptForArchitectureChoice} from '../utils/architecturePrompt';\n\n// Mock prompts module\njest.mock('prompts', () => {\n return jest.fn();\n});\n\nimport prompts from 'prompts';\nconst mockPrompts = prompts as jest.MockedFunction<typeof prompts>;\n\ndescribe('architecturePrompt', () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n test('returns true when user chooses Y', async () => {\n mockPrompts.mockResolvedValue({choice: 'y'});\n\n const result = await promptForArchitectureChoice();\n\n expect(result.shouldContinueWithOldArch).toBe(true);\n expect(result.userCancelled).toBe(false);\n });\n\n test('returns true when user chooses Y (uppercase)', async () => {\n mockPrompts.mockResolvedValue({choice: 'Y'});\n\n const result = await promptForArchitectureChoice();\n\n expect(result.shouldContinueWithOldArch).toBe(true);\n expect(result.userCancelled).toBe(false);\n });\n\n test('returns false when user chooses N', async () => {\n mockPrompts.mockResolvedValue({choice: 'n'});\n\n const result = await promptForArchitectureChoice();\n\n expect(result.shouldContinueWithOldArch).toBe(false);\n expect(result.userCancelled).toBe(false);\n });\n\n test('returns false when user chooses N (uppercase)', async () => {\n mockPrompts.mockResolvedValue({choice: 'N'});\n\n const result = await promptForArchitectureChoice();\n\n expect(result.shouldContinueWithOldArch).toBe(false);\n expect(result.userCancelled).toBe(false);\n });\n\n test('returns true with userCancelled when user cancels with no input', async () => {\n mockPrompts.mockResolvedValue({});\n\n const result = await promptForArchitectureChoice();\n\n expect(result.shouldContinueWithOldArch).toBe(true);\n expect(result.userCancelled).toBe(true);\n });\n\n test('returns true with userCancelled when prompts throws cancellation error', async () => {\n mockPrompts.mockRejectedValue(new Error('User cancelled'));\n\n const result = await promptForArchitectureChoice();\n\n expect(result.shouldContinueWithOldArch).toBe(true);\n expect(result.userCancelled).toBe(true);\n });\n\n test('returns true and not cancelled on other errors', async () => {\n mockPrompts.mockRejectedValue(new Error('Some other error'));\n\n const result = await promptForArchitectureChoice();\n\n expect(result.shouldContinueWithOldArch).toBe(true);\n expect(result.userCancelled).toBe(false);\n });\n});\n"]}
@@ -41,6 +41,7 @@ function validateOptionName(name, optionName) {
41
41
  case 'overwrite':
42
42
  case 'telemetry':
43
43
  case 'list':
44
+ case 'prompt':
44
45
  return true;
45
46
  }
46
47
  throw new Error(`Unable to find ${optionName} to match '${name}' in InitOptions.`);
@@ -1 +1 @@
1
- {"version":3,"file":"initWindows.test.js","sourceRoot":"","sources":["../../src/e2etest/initWindows.test.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+DAA0E;AAE1E,mFAGoD;AAEpD,kEAAoD;AAEpD,SAAS,kBAAkB,CACzB,IAAY,EACZ,UAA6B;IAE7B,yEAAyE;IACzE,QAAQ,UAAU,EAAE;QAClB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,MAAM,CAAC;QACZ,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW,CAAC;QACjB,KAAK,MAAM;YACT,OAAO,IAAI,CAAC;KACf;IACD,MAAM,IAAI,KAAK,CACb,kBAAkB,UAAU,cAAc,IAAI,mBAAmB,CAClE,CAAC;AACJ,CAAC;AAED,IAAI,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC1C,KAAK,MAAM,aAAa,IAAI,gCAAW,EAAE;QACvC,iBAAiB;QACjB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC1C,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QAE3D,oBAAoB;QACpB,IACE,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAA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AAI,CAAC,IAAI,CAAC,CAAC;IAC1E,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,CACtE,KAAK,CACN,CAAC;IACF,MAAM,CACJ,WAAW,CAAC,uBAAuB,CAAC,4BAA4B,CAAC,CAClE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACd,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7E,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CACxE,KAAK,CACN,CAAC;IACF,MAAM,CACJ,WAAW,CAAC,uBAAuB,CAAC,+BAA+B,CAAC,CACrE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChB,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {commanderNameToOptionName} from '@react-native-windows/telemetry';\n\nimport {\n initOptions,\n InitOptions,\n} from '../commands/initWindows/initWindowsOptions';\n\nimport * as nameHelpers from '../utils/nameHelpers';\n\nfunction validateOptionName(\n name: string,\n optionName: keyof InitOptions,\n): boolean {\n // Do not add a default case here. Every item must explicitly return true\n switch (optionName) {\n case 'logging':\n case 'template':\n case 'name':\n case 'namespace':\n case 'overwrite':\n case 'telemetry':\n case 'list':\n return true;\n }\n throw new Error(\n `Unable to find ${optionName} to match '${name}' in InitOptions.`,\n );\n}\n\ntest('initOptions - validate options', () => {\n for (const commandOption of initOptions) {\n // Validate names\n expect(commandOption.name).not.toBeNull();\n expect(commandOption.name.startsWith('--')).toBe(true);\n expect(commandOption.name).toBe(commandOption.name.trim());\n\n // Validate defaults\n if (\n !commandOption.name.endsWith(' [string]') &&\n !commandOption.name.endsWith(' [number]')\n ) {\n // Commander ignores defaults for flags, so leave undefined to prevent confusion\n expect(commandOption.default).toBeUndefined();\n }\n\n // Validate description\n expect(commandOption.description).not.toBeNull();\n expect(commandOption.description!).toBe(commandOption.description!.trim());\n\n // Validate all command options are present in InitOptions\n const optionName = commanderNameToOptionName(commandOption.name);\n expect(\n validateOptionName(commandOption.name, optionName as keyof InitOptions),\n ).toBe(true);\n }\n});\n\ntest('nameHelpers - cleanName', () => {\n expect(nameHelpers.cleanName('@scope/package')).toBe('Package');\n expect(nameHelpers.cleanName('@scope/package-name')).toBe('PackageName');\n expect(nameHelpers.cleanName('package')).toBe('Package');\n expect(nameHelpers.cleanName('package-name')).toBe('PackageName');\n});\n\ntest('nameHelpers - isValidProjectName', () => {\n expect(nameHelpers.isValidProjectName('package')).toBe(true);\n expect(nameHelpers.isValidProjectName('package-name')).toBe(false);\n expect(nameHelpers.isValidProjectName('Package')).toBe(true);\n expect(nameHelpers.isValidProjectName('Package-name')).toBe(false);\n expect(nameHelpers.isValidProjectName('Package-Name')).toBe(false);\n expect(nameHelpers.isValidProjectName('@scope/package')).toBe(false);\n expect(nameHelpers.isValidProjectName('@scope/package-name')).toBe(false);\n});\n\ntest('nameHelpers - cleanNamespace', () => {\n expect(nameHelpers.cleanNamespace('@scope/package')).toBe('Package');\n expect(nameHelpers.cleanNamespace('@scope/package-name')).toBe('PackageName');\n expect(nameHelpers.cleanNamespace('package')).toBe('Package');\n expect(nameHelpers.cleanNamespace('package-name')).toBe('PackageName');\n expect(nameHelpers.cleanNamespace('com.company.app')).toBe('Com.Company.App');\n expect(nameHelpers.cleanNamespace('com.company.app-name')).toBe(\n 'Com.Company.AppName',\n );\n expect(nameHelpers.cleanNamespace('com.company.app-name.other')).toBe(\n 'Com.Company.AppName.Other',\n );\n expect(nameHelpers.cleanNamespace('com::company::app')).toBe(\n 'Com.Company.App',\n );\n expect(nameHelpers.cleanNamespace('com::company::app-name')).toBe(\n 'Com.Company.AppName',\n );\n expect(nameHelpers.cleanNamespace('com::company::app-name::other')).toBe(\n 'Com.Company.AppName.Other',\n );\n});\n\ntest('nameHelpers - isValidProjectNamespace', () => {\n expect(nameHelpers.isValidProjectNamespace('package')).toBe(true);\n expect(nameHelpers.isValidProjectNamespace('package-name')).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('Package')).toBe(true);\n expect(nameHelpers.isValidProjectNamespace('Package-name')).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('Package-Name')).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('@scope/package')).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('@scope/package-name')).toBe(\n false,\n );\n expect(nameHelpers.isValidProjectNamespace('com.company.app')).toBe(true);\n expect(nameHelpers.isValidProjectNamespace('com.company.app-name')).toBe(\n false,\n );\n expect(\n nameHelpers.isValidProjectNamespace('com.company.app-name.other'),\n ).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('com::company::app')).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('com::company::app-name')).toBe(\n false,\n );\n expect(\n nameHelpers.isValidProjectNamespace('com::company::app-name::other'),\n ).toBe(false);\n});\n"]}
1
+ {"version":3,"file":"initWindows.test.js","sourceRoot":"","sources":["../../src/e2etest/initWindows.test.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+DAA0E;AAE1E,mFAGoD;AAEpD,kEAAoD;AAEpD,SAAS,kBAAkB,CACzB,IAAY,EACZ,UAA6B;IAE7B,yEAAyE;IACzE,QAAQ,UAAU,EAAE;QAClB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,MAAM,CAAC;QACZ,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW,CAAC;QACjB,KAAK,WAAW,CAAC;QACjB,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC;KACf;IACD,MAAM,IAAI,KAAK,CACb,kBAAkB,UAAU,cAAc,IAAI,mBAAmB,CAClE,CAAC;AACJ,CAAC;AAED,IAAI,CAAC,gCAAgC,EAA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AAW,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxE,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxE,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1E,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CACrE,KAAK,CACN,CAAC;IACF,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1E,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,CACtE,KAAK,CACN,CAAC;IACF,MAAM,CACJ,WAAW,CAAC,uBAAuB,CAAC,4BAA4B,CAAC,CAClE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACd,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7E,MAAM,CAAC,WAAW,CAAC,uBAAuB,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CACxE,KAAK,CACN,CAAC;IACF,MAAM,CACJ,WAAW,CAAC,uBAAuB,CAAC,+BAA+B,CAAC,CACrE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAChB,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {commanderNameToOptionName} from '@react-native-windows/telemetry';\n\nimport {\n initOptions,\n InitOptions,\n} from '../commands/initWindows/initWindowsOptions';\n\nimport * as nameHelpers from '../utils/nameHelpers';\n\nfunction validateOptionName(\n name: string,\n optionName: keyof InitOptions,\n): boolean {\n // Do not add a default case here. Every item must explicitly return true\n switch (optionName) {\n case 'logging':\n case 'template':\n case 'name':\n case 'namespace':\n case 'overwrite':\n case 'telemetry':\n case 'list':\n case 'prompt':\n return true;\n }\n throw new Error(\n `Unable to find ${optionName} to match '${name}' in InitOptions.`,\n );\n}\n\ntest('initOptions - validate options', () => {\n for (const commandOption of initOptions) {\n // Validate names\n expect(commandOption.name).not.toBeNull();\n expect(commandOption.name.startsWith('--')).toBe(true);\n expect(commandOption.name).toBe(commandOption.name.trim());\n\n // Validate defaults\n if (\n !commandOption.name.endsWith(' [string]') &&\n !commandOption.name.endsWith(' [number]')\n ) {\n // Commander ignores defaults for flags, so leave undefined to prevent confusion\n expect(commandOption.default).toBeUndefined();\n }\n\n // Validate description\n expect(commandOption.description).not.toBeNull();\n expect(commandOption.description!).toBe(commandOption.description!.trim());\n\n // Validate all command options are present in InitOptions\n const optionName = commanderNameToOptionName(commandOption.name);\n\n expect(\n validateOptionName(commandOption.name, optionName as keyof InitOptions),\n ).toBe(true);\n }\n});\n\ntest('nameHelpers - cleanName', () => {\n expect(nameHelpers.cleanName('@scope/package')).toBe('Package');\n expect(nameHelpers.cleanName('@scope/package-name')).toBe('PackageName');\n expect(nameHelpers.cleanName('package')).toBe('Package');\n expect(nameHelpers.cleanName('package-name')).toBe('PackageName');\n});\n\ntest('nameHelpers - isValidProjectName', () => {\n expect(nameHelpers.isValidProjectName('package')).toBe(true);\n expect(nameHelpers.isValidProjectName('package-name')).toBe(false);\n expect(nameHelpers.isValidProjectName('Package')).toBe(true);\n expect(nameHelpers.isValidProjectName('Package-name')).toBe(false);\n expect(nameHelpers.isValidProjectName('Package-Name')).toBe(false);\n expect(nameHelpers.isValidProjectName('@scope/package')).toBe(false);\n expect(nameHelpers.isValidProjectName('@scope/package-name')).toBe(false);\n});\n\ntest('nameHelpers - cleanNamespace', () => {\n expect(nameHelpers.cleanNamespace('@scope/package')).toBe('Package');\n expect(nameHelpers.cleanNamespace('@scope/package-name')).toBe('PackageName');\n expect(nameHelpers.cleanNamespace('package')).toBe('Package');\n expect(nameHelpers.cleanNamespace('package-name')).toBe('PackageName');\n expect(nameHelpers.cleanNamespace('com.company.app')).toBe('Com.Company.App');\n expect(nameHelpers.cleanNamespace('com.company.app-name')).toBe(\n 'Com.Company.AppName',\n );\n expect(nameHelpers.cleanNamespace('com.company.app-name.other')).toBe(\n 'Com.Company.AppName.Other',\n );\n expect(nameHelpers.cleanNamespace('com::company::app')).toBe(\n 'Com.Company.App',\n );\n expect(nameHelpers.cleanNamespace('com::company::app-name')).toBe(\n 'Com.Company.AppName',\n );\n expect(nameHelpers.cleanNamespace('com::company::app-name::other')).toBe(\n 'Com.Company.AppName.Other',\n );\n});\n\ntest('nameHelpers - isValidProjectNamespace', () => {\n expect(nameHelpers.isValidProjectNamespace('package')).toBe(true);\n expect(nameHelpers.isValidProjectNamespace('package-name')).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('Package')).toBe(true);\n expect(nameHelpers.isValidProjectNamespace('Package-name')).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('Package-Name')).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('@scope/package')).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('@scope/package-name')).toBe(\n false,\n );\n expect(nameHelpers.isValidProjectNamespace('com.company.app')).toBe(true);\n expect(nameHelpers.isValidProjectNamespace('com.company.app-name')).toBe(\n false,\n );\n expect(\n nameHelpers.isValidProjectNamespace('com.company.app-name.other'),\n ).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('com::company::app')).toBe(false);\n expect(nameHelpers.isValidProjectNamespace('com::company::app-name')).toBe(\n false,\n );\n expect(\n nameHelpers.isValidProjectNamespace('com::company::app-name::other'),\n ).toBe(false);\n});\n"]}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ export interface ArchitecturePromptResult {
7
+ shouldContinueWithOldArch: boolean;
8
+ userCancelled: boolean;
9
+ }
10
+ export declare function promptForArchitectureChoice(): Promise<ArchitecturePromptResult>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.promptForArchitectureChoice = void 0;
12
+ const prompts_1 = __importDefault(require("prompts"));
13
+ const chalk_1 = __importDefault(require("chalk"));
14
+ async function promptForArchitectureChoice() {
15
+ try {
16
+ const response = await (0, prompts_1.default)({
17
+ type: 'text',
18
+ name: 'choice',
19
+ message: 'Would you like to continue using the Old Architecture? (Y/N)',
20
+ validate: (value) => {
21
+ const normalized = value.trim().toLowerCase();
22
+ if (normalized === 'y' || normalized === 'n') {
23
+ return true;
24
+ }
25
+ return "Invalid input. Please enter 'Y' for Yes or 'N' for No.";
26
+ },
27
+ }, {
28
+ onCancel: () => {
29
+ throw new Error('User cancelled');
30
+ },
31
+ });
32
+ if (!response.choice) {
33
+ return { shouldContinueWithOldArch: true, userCancelled: true };
34
+ }
35
+ const normalizedChoice = response.choice.trim().toLowerCase();
36
+ if (normalizedChoice === 'y') {
37
+ console.log(chalk_1.default.yellow('Proceeding with Old Architecture. You can migrate later using our migration guide: https://microsoft.github.io/react-native-windows/docs/new-architecture'));
38
+ return { shouldContinueWithOldArch: true, userCancelled: false };
39
+ }
40
+ else {
41
+ console.log(chalk_1.default.green('Great choice! Setting up the project with New Architecture support.'));
42
+ return { shouldContinueWithOldArch: false, userCancelled: false };
43
+ }
44
+ }
45
+ catch (error) {
46
+ if (error.message === 'User cancelled') {
47
+ return { shouldContinueWithOldArch: true, userCancelled: true };
48
+ }
49
+ console.log(chalk_1.default.yellow('Proceeding with Old Architecture. You can migrate later using our migration guide: https://microsoft.github.io/react-native-windows/docs/new-architecture'));
50
+ return { shouldContinueWithOldArch: true, userCancelled: false };
51
+ }
52
+ }
53
+ exports.promptForArchitectureChoice = promptForArchitectureChoice;
54
+ //# sourceMappingURL=architecturePrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"architecturePrompt.js","sourceRoot":"","sources":["../../src/utils/architecturePrompt.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,sDAA8B;AAC9B,kDAA0B;AAMnB,KAAK,UAAU,2BAA2B;IAC/C,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,IAAA,iBAAO,EAC5B;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,8DAA8D;YACvE,QAAQ,EAAE,CAAC,KAAa,EAAE,EAAE;gBAC1B,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;gBAC9C,IAAI,UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,GAAG,EAAE;oBAC5C,OAAO,IAAI,CAAC;iBACb;gBACD,OAAO,wDAAwD,CAAC;YAClE,CAAC;SACF,EACD;YACE,QAAQ,EAAE,GAAG,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACpC,CAAC;SACF,CACF,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;YACpB,OAAO,EAAC,yBAAyB,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAC,CAAC;SAC/D;QAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC9D,IAAI,gBAAgB,KAAK,GAAG,EAAE;YAC5B,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,MAAM,CACV,2JAA2J,CAC5J,CACF,CAAC;YACF,OAAO,EAAC,yBAAyB,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAC,CAAC;SAChE;aAAM;YACL,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,KAAK,CACT,qEAAqE,CACtE,CACF,CAAC;YACF,OAAO,EAAC,yBAAyB,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAC,CAAC;SACjE;KACF;IAAC,OAAO,KAAK,EAAE;QACd,IAAK,KAAe,CAAC,OAAO,KAAK,gBAAgB,EAAE;YACjD,OAAO,EAAC,yBAAyB,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAC,CAAC;SAC/D;QACD,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,MAAM,CACV,2JAA2J,CAC5J,CACF,CAAC;QACF,OAAO,EAAC,yBAAyB,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAC,CAAC;KAChE;AACH,CAAC;AArDD,kEAqDC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport prompts from 'prompts';\nimport chalk from 'chalk';\nexport interface ArchitecturePromptResult {\n shouldContinueWithOldArch: boolean;\n userCancelled: boolean;\n}\n\nexport async function promptForArchitectureChoice(): Promise<ArchitecturePromptResult> {\n try {\n const response = await prompts(\n {\n type: 'text',\n name: 'choice',\n message: 'Would you like to continue using the Old Architecture? (Y/N)',\n validate: (value: string) => {\n const normalized = value.trim().toLowerCase();\n if (normalized === 'y' || normalized === 'n') {\n return true;\n }\n return \"Invalid input. Please enter 'Y' for Yes or 'N' for No.\";\n },\n },\n {\n onCancel: () => {\n throw new Error('User cancelled');\n },\n },\n );\n\n if (!response.choice) {\n return {shouldContinueWithOldArch: true, userCancelled: true};\n }\n\n const normalizedChoice = response.choice.trim().toLowerCase();\n if (normalizedChoice === 'y') {\n console.log(\n chalk.yellow(\n 'Proceeding with Old Architecture. You can migrate later using our migration guide: https://microsoft.github.io/react-native-windows/docs/new-architecture',\n ),\n );\n return {shouldContinueWithOldArch: true, userCancelled: false};\n } else {\n console.log(\n chalk.green(\n 'Great choice! Setting up the project with New Architecture support.',\n ),\n );\n return {shouldContinueWithOldArch: false, userCancelled: false};\n }\n } catch (error) {\n if ((error as Error).message === 'User cancelled') {\n return {shouldContinueWithOldArch: true, userCancelled: true};\n }\n console.log(\n chalk.yellow(\n 'Proceeding with Old Architecture. You can migrate later using our migration guide: https://microsoft.github.io/react-native-windows/docs/new-architecture',\n ),\n );\n return {shouldContinueWithOldArch: true, userCancelled: false};\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ /**
7
+ * Displays a warning message about the Old Architecture template.
8
+ */
9
+ export declare function showOldArchitectureWarning(): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.showOldArchitectureWarning = void 0;
12
+ const chalk_1 = __importDefault(require("chalk"));
13
+ /**
14
+ * Displays a warning message about the Old Architecture template.
15
+ */
16
+ function showOldArchitectureWarning() {
17
+ console.log(chalk_1.default.yellow(`⚠️ This project is using the React Native (for Windows) Old Architecture. The old architecture will begin to be removed starting with react-native-windows@0.82.0.`));
18
+ console.log();
19
+ console.log(chalk_1.default.cyan('💡 It is strongly recommended to move to the new architecture as soon as possible to take advantage of improved performance, long-term support, and modern capabilities.'));
20
+ console.log();
21
+ console.log(chalk_1.default.blue('🔗 Learn more: https://microsoft.github.io/react-native-windows/docs/new-architecture'));
22
+ console.log();
23
+ }
24
+ exports.showOldArchitectureWarning = showOldArchitectureWarning;
25
+ //# sourceMappingURL=oldArchWarning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oldArchWarning.js","sourceRoot":"","sources":["../../src/utils/oldArchWarning.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kDAA0B;AAE1B;;GAEG;AACH,SAAgB,0BAA0B;IACxC,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,MAAM,CACV,oKAAoK,CACrK,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,0KAA0K,CAC3K,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,uFAAuF,CACxF,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC;AAnBD,gEAmBC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport chalk from 'chalk';\n\n/**\n * Displays a warning message about the Old Architecture template.\n */\nexport function showOldArchitectureWarning(): void {\n console.log(\n chalk.yellow(\n `⚠️ This project is using the React Native (for Windows) Old Architecture. The old architecture will begin to be removed starting with react-native-windows@0.82.0.`,\n ),\n );\n console.log();\n console.log(\n chalk.cyan(\n '💡 It is strongly recommended to move to the new architecture as soon as possible to take advantage of improved performance, long-term support, and modern capabilities.',\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '🔗 Learn more: https://microsoft.github.io/react-native-windows/docs/new-architecture',\n ),\n );\n console.log();\n}\n"]}
@@ -26,4 +26,4 @@ export declare function startTelemetrySession(commandName: string, config: Confi
26
26
  * @param error The error (if any) thrown during the command.
27
27
  * @param getExtraProps Function to get any extra command-specific telemetry properties.
28
28
  */
29
- export declare function endTelemetrySession(error?: Error, getExtraProps?: () => Promise<Record<string, any>>): Promise<void>;
29
+ export declare function endTelemetrySession(error?: Error, getExtraProps?: () => Promise<Record<string, any>>, finalOptions?: Record<string, any>, optionSanitizer?: (opts: Record<string, any>) => Record<string, any>): Promise<void>;
@@ -103,7 +103,7 @@ exports.startTelemetrySession = startTelemetrySession;
103
103
  * @param error The error (if any) thrown during the command.
104
104
  * @param getExtraProps Function to get any extra command-specific telemetry properties.
105
105
  */
106
- async function endTelemetrySession(error, getExtraProps) {
106
+ async function endTelemetrySession(error, getExtraProps, finalOptions, optionSanitizer) {
107
107
  if (!telemetry_1.Telemetry.isEnabled()) {
108
108
  // Bail early so don't waste time here
109
109
  return;
@@ -115,7 +115,13 @@ async function endTelemetrySession(error, getExtraProps) {
115
115
  endInfo.resultCode =
116
116
  error instanceof telemetry_1.CodedError ? error.type : 'Unknown';
117
117
  }
118
- telemetry_1.Telemetry.endCommand(endInfo, getExtraProps ? await getExtraProps() : undefined);
118
+ // Get extra properties
119
+ const extraProps = getExtraProps ? await getExtraProps() : undefined;
120
+ // Sanitize and attach finalOptions if provided
121
+ if (finalOptions && optionSanitizer) {
122
+ endInfo.finalOptions = optionSanitizer(finalOptions);
123
+ }
124
+ telemetry_1.Telemetry.endCommand(endInfo, extraProps);
119
125
  }
120
126
  exports.endTelemetrySession = endTelemetrySession;
121
127
  //# sourceMappingURL=telemetryHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"telemetryHelpers.js","sourceRoot":"","sources":["../../src/utils/telemetryHelpers.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mCAAiC;AAQjC,+DAayC;AAEzC,+DAAuD;AAEvD;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,MAAc,EACd,cAA+B;IAE/B,MAAM,MAAM,GAAyB;QACnC,OAAO,EAAE,KAAK;KACf,CAAC;IACF,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE;QACnC,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACpC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;YAChC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;QAChB,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,IAAI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,KAAK,EAAE;QACT,OAAO,CAAC,UAAU;YAChB,KAAK,YAAY,sBAAU,CAAC,CAAC,CAAE,KAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;KACxE;IAED,qBAAS,CAAC,UAAU,CAClB,OAAO,EACP,aAAa,CAAC,CAAC,CAAC,MAAM,aAAa,EAAE,CAAC,CAAC,CAAC,SAAS,CAClD,CAAC;AACJ,CAAC;AAtBD,kDAsBC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {camelCase} from 'lodash';\n\nimport type {\n Config,\n CommandOption,\n OptionValue,\n} from '@react-native-community/cli-types';\n\nimport {\n Telemetry,\n CodedError,\n CommandStartInfo,\n CommandEndInfo,\n CommanderOptionsType,\n commanderOptionsToOptions,\n optionsToArgs,\n OptionSanitizer,\n configToProjectInfo,\n getProjectFileFromConfig,\n deviceArchitecture,\n nodeArchitecture,\n} from '@react-native-windows/telemetry';\n\nimport {newInfo, newWarn} from './commandWithProgress';\n\n/**\n * Calculates a the default values of a given react-native CLI command's options.\n * @param config Config passed from react-native CLI.\n * @param commandOptions The options definition for the command.\n * @returns The default options for the command.\n */\nexport function getDefaultOptions(\n config: Config,\n commandOptions: CommandOption[],\n): CommanderOptionsType {\n const result: CommanderOptionsType = {\n logging: false,\n };\n for (const option of commandOptions) {\n let key = option.name.startsWith('--')\n ? option.name.slice('--'.length)\n : option.name;\n key = key.trim();\n\n let value = option.default;\n if (value !== undefined && (value as (ctx: Config) => OptionValue).name) {\n value = (value as (ctx: Config) => OptionValue)(config);\n }\n\n if (key.endsWith(' [string]')) {\n // Option is a string\n key = key.slice(0, -' [string]'.length);\n // Option is a number\n } else if (key.endsWith(' [number]')) {\n key = key.slice(0, -' [number]'.length);\n } else {\n // Option is a boolean\n // Note: Commander ignores the default property for booleans\n if (key.startsWith('no-')) {\n key = key.slice('no-'.length);\n // Commander always defaults to true for flags that start with --no\n value = true;\n } else {\n // Commander always defaults to undefined for flags\n value = undefined;\n }\n }\n\n key = camelCase(key);\n result[key] = value;\n }\n return result;\n}\n\n/**\n * Sets up and starts the telemetry gathering for the CLI command.\n * @param commandName The name of the CLI command.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n * @param defaultOptions Default options for the command.\n * @param optionSanitizer Function to sanitize the option values for telemetry.\n */\nexport async function startTelemetrySession(\n commandName: string,\n config: Config,\n options: CommanderOptionsType,\n defaultOptions: CommanderOptionsType,\n optionSanitizer: OptionSanitizer,\n) {\n const verbose = options.logging === true;\n\n if (!options.telemetry) {\n if (verbose) {\n newInfo('Telemetry is disabled');\n }\n return;\n }\n\n if (verbose) {\n newInfo(\n `Running ${nodeArchitecture()} node on a ${deviceArchitecture()} machine`,\n );\n }\n\n if (deviceArchitecture() !== nodeArchitecture()) {\n newWarn(\n 'This version of node was built for a different architecture than this machine and may cause unintended behavior',\n );\n }\n\n await Telemetry.setup();\n\n const sanitizedOptions = commanderOptionsToOptions(options, optionSanitizer);\n const sanitizedDefaultOptions = commanderOptionsToOptions(\n defaultOptions,\n optionSanitizer,\n );\n const sanitizedArgs = optionsToArgs(sanitizedOptions, process.argv);\n\n const startInfo: CommandStartInfo = {\n commandName,\n args: sanitizedArgs,\n options: sanitizedOptions,\n defaultOptions: sanitizedDefaultOptions,\n };\n\n Telemetry.startCommand(startInfo);\n\n const projectInfo = await configToProjectInfo(config);\n if (projectInfo) {\n Telemetry.setProjectInfo(projectInfo);\n }\n\n const projectFile = getProjectFileFromConfig(config);\n if (projectFile) {\n await Telemetry.populateNuGetPackageVersions(projectFile);\n }\n}\n\n/**\n * Ends the gathering of telemetry for the CLI command.\n * @param error The error (if any) thrown during the command.\n * @param getExtraProps Function to get any extra command-specific telemetry properties.\n */\nexport async function endTelemetrySession(\n error?: Error,\n getExtraProps?: () => Promise<Record<string, any>>,\n) {\n if (!Telemetry.isEnabled()) {\n // Bail early so don't waste time here\n return;\n }\n\n const endInfo: CommandEndInfo = {\n resultCode: 'Success',\n };\n\n if (error) {\n endInfo.resultCode =\n error instanceof CodedError ? (error as CodedError).type : 'Unknown';\n }\n\n Telemetry.endCommand(\n endInfo,\n getExtraProps ? await getExtraProps() : undefined,\n );\n}\n"]}
1
+ {"version":3,"file":"telemetryHelpers.js","sourceRoot":"","sources":["../../src/utils/telemetryHelpers.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mCAAiC;AAQjC,+DAayC;AAEzC,+DAAuD;AAEvD;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,MAAc,EACd,cAA+B;IAE/B,MAAM,MAAM,GAAyB;QACnC,OAAO,EAAE,KAAK;KACf,CAAC;IACF,KAAK,MAAM,MAAM,IAAI,cAAc,EAAE;QACnC,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACpC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;YAChC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;QAChB,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAEjB,IAAI,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC;QAC3B,IAAI,KAAK,KAAK,SAAS,IAAK,KAAsC,CAAC,IAAI,EAAE;YACvE,KAAK,GAAI,KAAsC,CAAC,MAAM,CAAC,CAAC;SACzD;QAED,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;YAC7B,qBAAqB;YACrB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACxC,qBAAqB;SACtB;aAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;YACpC,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SACzC;aAAM;YACL,sBAAsB;YACtB,4DAA4D;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ensed under the MIT License.\n * @format\n */\n\nimport {camelCase} from 'lodash';\n\nimport type {\n Config,\n CommandOption,\n OptionValue,\n} from '@react-native-community/cli-types';\n\nimport {\n Telemetry,\n CodedError,\n CommandStartInfo,\n CommandEndInfo,\n CommanderOptionsType,\n commanderOptionsToOptions,\n optionsToArgs,\n OptionSanitizer,\n configToProjectInfo,\n getProjectFileFromConfig,\n deviceArchitecture,\n nodeArchitecture,\n} from '@react-native-windows/telemetry';\n\nimport {newInfo, newWarn} from './commandWithProgress';\n\n/**\n * Calculates a the default values of a given react-native CLI command's options.\n * @param config Config passed from react-native CLI.\n * @param commandOptions The options definition for the command.\n * @returns The default options for the command.\n */\nexport function getDefaultOptions(\n config: Config,\n commandOptions: CommandOption[],\n): CommanderOptionsType {\n const result: CommanderOptionsType = {\n logging: false,\n };\n for (const option of commandOptions) {\n let key = option.name.startsWith('--')\n ? option.name.slice('--'.length)\n : option.name;\n key = key.trim();\n\n let value = option.default;\n if (value !== undefined && (value as (ctx: Config) => OptionValue).name) {\n value = (value as (ctx: Config) => OptionValue)(config);\n }\n\n if (key.endsWith(' [string]')) {\n // Option is a string\n key = key.slice(0, -' [string]'.length);\n // Option is a number\n } else if (key.endsWith(' [number]')) {\n key = key.slice(0, -' [number]'.length);\n } else {\n // Option is a boolean\n // Note: Commander ignores the default property for booleans\n if (key.startsWith('no-')) {\n key = key.slice('no-'.length);\n // Commander always defaults to true for flags that start with --no\n value = true;\n } else {\n // Commander always defaults to undefined for flags\n value = undefined;\n }\n }\n\n key = camelCase(key);\n result[key] = value;\n }\n return result;\n}\n\n/**\n * Sets up and starts the telemetry gathering for the CLI command.\n * @param commandName The name of the CLI command.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n * @param defaultOptions Default options for the command.\n * @param optionSanitizer Function to sanitize the option values for telemetry.\n */\nexport async function startTelemetrySession(\n commandName: string,\n config: Config,\n options: CommanderOptionsType,\n defaultOptions: CommanderOptionsType,\n optionSanitizer: OptionSanitizer,\n) {\n const verbose = options.logging === true;\n\n if (!options.telemetry) {\n if (verbose) {\n newInfo('Telemetry is disabled');\n }\n return;\n }\n\n if (verbose) {\n newInfo(\n `Running ${nodeArchitecture()} node on a ${deviceArchitecture()} machine`,\n );\n }\n\n if (deviceArchitecture() !== nodeArchitecture()) {\n newWarn(\n 'This version of node was built for a different architecture than this machine and may cause unintended behavior',\n );\n }\n\n await Telemetry.setup();\n\n const sanitizedOptions = commanderOptionsToOptions(options, optionSanitizer);\n const sanitizedDefaultOptions = commanderOptionsToOptions(\n defaultOptions,\n optionSanitizer,\n );\n const sanitizedArgs = optionsToArgs(sanitizedOptions, process.argv);\n\n const startInfo: CommandStartInfo = {\n commandName,\n args: sanitizedArgs,\n options: sanitizedOptions,\n defaultOptions: sanitizedDefaultOptions,\n };\n\n Telemetry.startCommand(startInfo);\n\n const projectInfo = await configToProjectInfo(config);\n if (projectInfo) {\n Telemetry.setProjectInfo(projectInfo);\n }\n\n const projectFile = getProjectFileFromConfig(config);\n if (projectFile) {\n await Telemetry.populateNuGetPackageVersions(projectFile);\n }\n}\n\n/**\n * Ends the gathering of telemetry for the CLI command.\n * @param error The error (if any) thrown during the command.\n * @param getExtraProps Function to get any extra command-specific telemetry properties.\n */\nexport async function endTelemetrySession(\n error?: Error,\n getExtraProps?: () => Promise<Record<string, any>>,\n finalOptions?: Record<string, any>,\n optionSanitizer?: (opts: Record<string, any>) => Record<string, any>,\n) {\n if (!Telemetry.isEnabled()) {\n // Bail early so don't waste time here\n return;\n }\n\n const endInfo: CommandEndInfo = {\n resultCode: 'Success',\n };\n\n if (error) {\n endInfo.resultCode =\n error instanceof CodedError ? (error as CodedError).type : 'Unknown';\n }\n\n // Get extra properties\n const extraProps = getExtraProps ? await getExtraProps() : undefined;\n\n // Sanitize and attach finalOptions if provided\n if (finalOptions && optionSanitizer) {\n endInfo.finalOptions = optionSanitizer(finalOptions);\n }\n\n Telemetry.endCommand(endInfo, extraProps);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-windows/cli",
3
- "version": "0.80.0-preview.2",
3
+ "version": "0.80.0-preview.3",
4
4
  "license": "MIT",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "repository": {
@@ -20,7 +20,7 @@
20
20
  "@react-native-windows/codegen": "0.80.0-preview.1",
21
21
  "@react-native-windows/fs": "0.80.0-preview.1",
22
22
  "@react-native-windows/package-utils": "0.80.0-preview.1",
23
- "@react-native-windows/telemetry": "0.80.0-preview.1",
23
+ "@react-native-windows/telemetry": "0.80.0-preview.2",
24
24
  "@xmldom/xmldom": "^0.7.7",
25
25
  "chalk": "^4.1.0",
26
26
  "cli-spinners": "^2.2.0",