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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -123,6 +123,12 @@ class InitWindows {
123
123
  (_a = (_l = this.options).template) !== null && _a !== void 0 ? _a : (_l.template = (_d = (_c = (_b = this.rnwConfig) === null || _b === void 0 ? void 0 : _b['init-windows']) === null || _c === void 0 ? void 0 : _c.template) !== null && _d !== void 0 ? _d : this.getDefaultTemplateName());
124
124
  spinner.info(`Using template '${this.options.template}'...`);
125
125
  if (!this.templates.has(this.options.template.replace(/[\\]/g, '/'))) {
126
+ // Check if user is trying to use an old architecture template
127
+ const isOldArchTemplate = this.options.template.startsWith('old');
128
+ if (isOldArchTemplate) {
129
+ (0, oldArchWarning_1.showOldArchitectureWarning)();
130
+ throw new telemetry_1.CodedError('InvalidTemplateName', `The template '${this.options.template}' is no longer available. Please use 'cpp-app' template instead.`);
131
+ }
126
132
  throw new telemetry_1.CodedError('InvalidTemplateName', `Unable to find template '${this.options.template}'.`);
127
133
  }
128
134
  const isOldArchTemplate = this.options.template.startsWith('old');
@@ -1 +1 @@
1
- {"version":3,"file":"initWindows.js","sourceRoot":"","sources":["../../../src/commands/initWindows/initWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,kDAA0B;AAC1B,+BAAsC;AAEtC,2CAAuC;AAEvC,gDAAwB;AAExB,MAAM,IAAI,GAAG,cAAI,CAAC,SAAS,CAAC,WAAQ,CAAC,CAAC;AAGtC,+DAAsE;AAEtE,yEAGyC;AACzC,qEAAuD;AACvD,mEAIsC;AACtC,6DAAyE;AACzE,qEAAuD;AACvD,+DAAsE;AAEtE,6DAAiD;AAoBjD,MAAa,WAAW;IAMtB,YAAqB,MAAc,EAAW,OAAoB;;QAA7C,WAAM,GAAN,MAAM,CAAQ;QAAW,YAAO,GA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yB,CAAC,CAAC;IACtD,IAAI;QACF,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjD,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAElC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,KAAK,CAAC,UAAU,CAAC,6BAA6B,IAAI,CAAC,KAAK,CAC/D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAK,CAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,KAAK,CAC7D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;QACF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AA3BD,kDA2BC;AAED;;GAEG;AACU,QAAA,WAAW,GAAY;IAClC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,qDAAqD;IAClE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,gCAAW;CACrB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport chalk from 'chalk';\nimport {glob as globFunc} from 'glob';\nimport _ from 'lodash';\nimport {performance} from 'perf_hooks';\nimport {Ora} from 'ora';\nimport util from 'util';\n\nconst glob = util.promisify(globFunc);\n\nimport type {Command, Config} from '@react-native-community/cli-types';\nimport {CodedError, Telemetry} from '@react-native-windows/telemetry';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport {copyAndReplaceWithChangedCallback} from '../../generator-common';\nimport * as nameHelpers from '../../utils/nameHelpers';\nimport {showOldArchitectureWarning} from '../../utils/oldArchWarning';\nimport type {InitOptions} from './initWindowsOptions';\nimport {initOptions} from './initWindowsOptions';\n\nexport interface TemplateFileMapping {\n from: string;\n to: string;\n replacements?: Record<string, any>;\n}\n\nexport interface InitWindowsTemplateConfig {\n name: string;\n description: string;\n isDefault?: boolean;\n preInstall?: (config: Config, options: InitOptions) => Promise<void>;\n getFileMappings?: (\n config: Config,\n options: InitOptions,\n ) => Promise<TemplateFileMapping[]>;\n postInstall?: (config: Config, options: InitOptions) => Promise<void>;\n}\n\nexport class InitWindows {\n protected readonly rnwPath: string;\n protected readonly rnwConfig?: Record<string, any>;\n protected readonly templates: Map<string, InitWindowsTemplateConfig> =\n new Map();\n\n constructor(readonly config: Config, readonly options: InitOptions) {\n this.rnwPath = pathHelpers.resolveRnwRoot(this.config.root);\n this.rnwConfig = this.config.project.windows?.rnwConfig;\n }\n\n protected verboseMessage(message: any) {\n verboseMessage(message, !!this.options.logging);\n }\n\n protected async loadTemplates() {\n const templatesRoot = path.join(this.rnwPath, 'templates');\n for (const file of await glob('**/template.config.js', {\n cwd: templatesRoot,\n })) {\n const templateName = path.dirname(file).replace(/[\\\\]/g, '/');\n const templateConfig: InitWindowsTemplateConfig = require(path.join(\n templatesRoot,\n file,\n ));\n this.templates.set(templateName, templateConfig);\n }\n if (this.templates.size === 0) {\n throw new CodedError(\n 'NoTemplatesFound',\n `No templates were found in ${templatesRoot}.`,\n );\n }\n }\n\n protected getDefaultTemplateName(): string {\n for (const [name, config] of this.templates) {\n if (config.isDefault) {\n return name;\n }\n }\n throw new CodedError(\n 'NoDefaultTemplate',\n 'No template specified and no default template found.',\n );\n }\n\n protected getReactNativeProjectName(projectDir: string): string {\n this.verboseMessage('Looking for project name in package.json...');\n const pkgJsonPath = path.join(projectDir, 'package.json');\n if (!fs.existsSync(pkgJsonPath)) {\n throw new CodedError(\n 'NoPackageJson',\n 'Unable to find package.json. This should be run from within an existing react-native project.',\n );\n }\n type PackageJson = {name: string};\n\n let name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n if (!name) {\n const appJsonPath = path.join(projectDir, 'app.json');\n if (fs.existsSync(appJsonPath)) {\n this.verboseMessage('Looking for project name in app.json...');\n name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n }\n }\n\n if (!name) {\n throw new CodedError(\n 'NoProjectName',\n 'Please specify name in package.json or app.json',\n );\n }\n\n return name;\n }\n\n protected printTemplateList() {\n if (this.templates.size === 0) {\n console.log('\\nNo templates found.\\n');\n return;\n }\n\n for (const [key, value] of this.templates.entries()) {\n const defaultLabel = value.isDefault ? chalk.yellow('[Default] ') : '';\n console.log(\n `\\n${key} - ${value.name}\\n ${defaultLabel}${value.description}`,\n );\n }\n console.log(`\\n`);\n }\n\n // eslint-disable-next-line complexity\n public async run(spinner: Ora) {\n await this.loadTemplates();\n\n spinner.info();\n\n if (this.options.list) {\n this.printTemplateList();\n return;\n }\n\n this.options.template ??=\n (this.rnwConfig?.['init-windows']?.template as string | undefined) ??\n this.getDefaultTemplateName();\n\n spinner.info(`Using template '${this.options.template}'...`);\n if (!this.templates.has(this.options.template.replace(/[\\\\]/g, '/'))) {\n throw new CodedError(\n 'InvalidTemplateName',\n `Unable to find template '${this.options.template}'.`,\n );\n }\n\n const isOldArchTemplate = this.options.template.startsWith('old');\n\n if (isOldArchTemplate) {\n showOldArchitectureWarning();\n }\n\n const templateConfig = this.templates.get(this.options.template)!;\n\n // Check if there's a passed-in project name and if it's valid\n if (\n this.options.name &&\n !nameHelpers.isValidProjectName(this.options.name)\n ) {\n throw new CodedError(\n 'InvalidProjectName',\n `The specified name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // If no project name is provided, check previously used name or calculate a name and clean if necessary\n if (!this.options.name) {\n const projectName =\n (this.rnwConfig?.['init-windows']?.name as string | undefined) ??\n this.getReactNativeProjectName(this.config.root);\n this.options.name = nameHelpers.isValidProjectName(projectName)\n ? projectName\n : nameHelpers.cleanName(projectName);\n }\n\n // Final check that the project name is valid\n if (!nameHelpers.isValidProjectName(this.options.name)) {\n throw new CodedError(\n 'InvalidProjectName',\n `The name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // Check if there's a passed-in project namespace and if it's valid\n if (\n this.options.namespace &&\n !nameHelpers.isValidProjectNamespace(this.options.namespace)\n ) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The specified namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n // If no project namespace is provided, check previously used namespace or use the project name and clean if necessary\n if (!this.options.namespace) {\n const namespace =\n (this.rnwConfig?.['init-windows']?.namespace as string | undefined) ??\n this.options.name;\n this.options.namespace = nameHelpers.isValidProjectNamespace(namespace)\n ? namespace\n : nameHelpers.cleanNamespace(namespace);\n }\n\n // Final check that the project namespace is valid\n if (!nameHelpers.isValidProjectNamespace(this.options.namespace)) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n if (templateConfig.preInstall) {\n spinner.info(`Running ${this.options.template} preInstall()...`);\n await templateConfig.preInstall(this.config, this.options);\n }\n\n // Get template files to copy and copy if available\n if (templateConfig.getFileMappings) {\n const fileMappings = await templateConfig.getFileMappings(\n this.config,\n this.options,\n );\n\n for (const fileMapping of fileMappings) {\n const targetDir = path.join(\n this.config.root,\n path.dirname(fileMapping.to),\n );\n\n if (!(await fs.exists(targetDir))) {\n await fs.mkdir(targetDir, {recursive: true});\n }\n\n await copyAndReplaceWithChangedCallback(\n fileMapping.from,\n this.config.root,\n fileMapping.to,\n fileMapping.replacements,\n this.options.overwrite,\n );\n }\n }\n\n if (templateConfig.postInstall) {\n spinner.info(`Running ${this.options.template} postInstall()...`);\n await templateConfig.postInstall(this.config, this.options);\n }\n\n spinner.succeed();\n }\n}\n\n/**\n * Logs the given message if verbose is True.\n * @param message The message to log.\n * @param verbose Whether or not verbose logging is enabled.\n */\nfunction verboseMessage(message: any, verbose?: boolean) {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\nfunction optionSanitizer(key: keyof InitOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'name':\n case 'namespace':\n return value === undefined ? false : true; // Strip PII\n case 'logging':\n case 'template':\n case 'overwrite':\n case 'telemetry':\n case 'list':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `init-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {};\n return extraProps;\n}\n\nfunction sanitizeOptions(\n opts: Record<string, any>,\n sanitizer: (key: keyof InitOptions, value: any) => any,\n): Record<string, any> {\n const sanitized: Record<string, any> = {};\n for (const key in opts) {\n if (Object.prototype.hasOwnProperty.call(opts, key)) {\n sanitized[key] = sanitizer(key as keyof InitOptions, opts[key]);\n }\n }\n return sanitized;\n}\n\n/**\n * The function run when calling `npx @react-native-community/cli init-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function initWindows(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n await startTelemetrySession(\n 'init-windows',\n config,\n options,\n getDefaultOptions(config, initOptions),\n optionSanitizer,\n );\n\n let initWindowsError: Error | undefined;\n\n try {\n await initWindowsInternal(args, config, options);\n } catch (ex) {\n initWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(initWindowsError);\n }\n\n // Now, instead of custom fields, just pass the final options object\n await endTelemetrySession(initWindowsError, getExtraProps, options, opts =>\n sanitizeOptions(opts, optionSanitizer),\n );\n\n setExitProcessWithError(options.logging, initWindowsError);\n}\n\n/**\n * Initializes a new RNW project from a given template.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nexport async function initWindowsInternal(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner('Running init-windows...');\n try {\n const codegen = new InitWindows(config, options);\n await codegen.run(spinner);\n const endTime = performance.now();\n\n console.log(\n `${chalk.green('Success:')} init-windows completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } catch (e) {\n spinner.fail();\n const endTime = performance.now();\n console.log(\n `${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n throw e;\n }\n}\n\n/**\n * Initializes a new RNW project from a given template.\n */\nexport const initCommand: Command = {\n name: 'init-windows',\n description: 'Initializes a new RNW project from a given template',\n func: initWindows,\n options: initOptions,\n};\n"]}
1
+ {"version":3,"file":"initWindows.js","sourceRoot":"","sources":["../../../src/commands/initWindows/initWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,kDAA0B;AAC1B,+BAAsC;AAEtC,2CAAuC;AAEvC,gDAAwB;AAExB,MAAM,IAAI,GAAG,cAAI,CAAC,SAAS,CAAC,WAAQ,CAAC,CAAC;AAGtC,+DAAsE;AAEtE,yEAGyC;AACzC,qEAAuD;AACvD,mEAIsC;AACtC,6DAAyE;AACzE,qEAAuD;AACvD,+DAAsE;AAEtE,6DAAiD;AAoBjD,MAAa,WAAW;IAMtB,YAAqB,MAAc,EAAW,OAAoB;;QAA7C,WAAM,GAAN,MAAM,CAAQ;QAAW,YAAO,GAAP,OAAO,CAAa;QAH/C,cAAS,GAC1B,IAAI,GAAG,EAAE,CAAC;QAGV,IAAI,CAAC,OAAO,GAAG,WA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,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,mBAAmB,CACvC,IAAc,EACd,MAAc,EACd,OAAoB;IAEpB,MAAM,SAAS,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;IACpC,MAAM,OAAO,GAAG,IAAA,gCAAU,EAAC,yBAAyB,CAAC,CAAC;IACtD,IAAI;QACF,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjD,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAElC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,KAAK,CAAC,UAAU,CAAC,6BAA6B,IAAI,CAAC,KAAK,CAC/D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;KACH;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,wBAAW,CAAC,GAAG,EAAE,CAAC;QAClC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAK,CAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,KAAK,CAC7D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;QACF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AA3BD,kDA2BC;AAED;;GAEG;AACU,QAAA,WAAW,GAAY;IAClC,IAAI,EAAE,cAAc;IACpB,WAAW,EAAE,qDAAqD;IAClE,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,gCAAW;CACrB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport chalk from 'chalk';\nimport {glob as globFunc} from 'glob';\nimport _ from 'lodash';\nimport {performance} from 'perf_hooks';\nimport {Ora} from 'ora';\nimport util from 'util';\n\nconst glob = util.promisify(globFunc);\n\nimport type {Command, Config} from '@react-native-community/cli-types';\nimport {CodedError, Telemetry} from '@react-native-windows/telemetry';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport {copyAndReplaceWithChangedCallback} from '../../generator-common';\nimport * as nameHelpers from '../../utils/nameHelpers';\nimport {showOldArchitectureWarning} from '../../utils/oldArchWarning';\nimport type {InitOptions} from './initWindowsOptions';\nimport {initOptions} from './initWindowsOptions';\n\nexport interface TemplateFileMapping {\n from: string;\n to: string;\n replacements?: Record<string, any>;\n}\n\nexport interface InitWindowsTemplateConfig {\n name: string;\n description: string;\n isDefault?: boolean;\n preInstall?: (config: Config, options: InitOptions) => Promise<void>;\n getFileMappings?: (\n config: Config,\n options: InitOptions,\n ) => Promise<TemplateFileMapping[]>;\n postInstall?: (config: Config, options: InitOptions) => Promise<void>;\n}\n\nexport class InitWindows {\n protected readonly rnwPath: string;\n protected readonly rnwConfig?: Record<string, any>;\n protected readonly templates: Map<string, InitWindowsTemplateConfig> =\n new Map();\n\n constructor(readonly config: Config, readonly options: InitOptions) {\n this.rnwPath = pathHelpers.resolveRnwRoot(this.config.root);\n this.rnwConfig = this.config.project.windows?.rnwConfig;\n }\n\n protected verboseMessage(message: any) {\n verboseMessage(message, !!this.options.logging);\n }\n\n protected async loadTemplates() {\n const templatesRoot = path.join(this.rnwPath, 'templates');\n for (const file of await glob('**/template.config.js', {\n cwd: templatesRoot,\n })) {\n const templateName = path.dirname(file).replace(/[\\\\]/g, '/');\n const templateConfig: InitWindowsTemplateConfig = require(path.join(\n templatesRoot,\n file,\n ));\n this.templates.set(templateName, templateConfig);\n }\n if (this.templates.size === 0) {\n throw new CodedError(\n 'NoTemplatesFound',\n `No templates were found in ${templatesRoot}.`,\n );\n }\n }\n\n protected getDefaultTemplateName(): string {\n for (const [name, config] of this.templates) {\n if (config.isDefault) {\n return name;\n }\n }\n throw new CodedError(\n 'NoDefaultTemplate',\n 'No template specified and no default template found.',\n );\n }\n\n protected getReactNativeProjectName(projectDir: string): string {\n this.verboseMessage('Looking for project name in package.json...');\n const pkgJsonPath = path.join(projectDir, 'package.json');\n if (!fs.existsSync(pkgJsonPath)) {\n throw new CodedError(\n 'NoPackageJson',\n 'Unable to find package.json. This should be run from within an existing react-native project.',\n );\n }\n type PackageJson = {name: string};\n\n let name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n if (!name) {\n const appJsonPath = path.join(projectDir, 'app.json');\n if (fs.existsSync(appJsonPath)) {\n this.verboseMessage('Looking for project name in app.json...');\n name = fs.readJsonFileSync<PackageJson>(pkgJsonPath).name;\n }\n }\n\n if (!name) {\n throw new CodedError(\n 'NoProjectName',\n 'Please specify name in package.json or app.json',\n );\n }\n\n return name;\n }\n\n protected printTemplateList() {\n if (this.templates.size === 0) {\n console.log('\\nNo templates found.\\n');\n return;\n }\n\n for (const [key, value] of this.templates.entries()) {\n const defaultLabel = value.isDefault ? chalk.yellow('[Default] ') : '';\n console.log(\n `\\n${key} - ${value.name}\\n ${defaultLabel}${value.description}`,\n );\n }\n console.log(`\\n`);\n }\n\n // eslint-disable-next-line complexity\n public async run(spinner: Ora) {\n await this.loadTemplates();\n\n spinner.info();\n\n if (this.options.list) {\n this.printTemplateList();\n return;\n }\n\n this.options.template ??=\n (this.rnwConfig?.['init-windows']?.template as string | undefined) ??\n this.getDefaultTemplateName();\n\n spinner.info(`Using template '${this.options.template}'...`);\n if (!this.templates.has(this.options.template.replace(/[\\\\]/g, '/'))) {\n // Check if user is trying to use an old architecture template\n const isOldArchTemplate = this.options.template.startsWith('old');\n if (isOldArchTemplate) {\n showOldArchitectureWarning();\n throw new CodedError(\n 'InvalidTemplateName',\n `The template '${this.options.template}' is no longer available. Please use 'cpp-app' template instead.`,\n );\n }\n throw new CodedError(\n 'InvalidTemplateName',\n `Unable to find template '${this.options.template}'.`,\n );\n }\n\n const isOldArchTemplate = this.options.template.startsWith('old');\n\n if (isOldArchTemplate) {\n showOldArchitectureWarning();\n }\n\n const templateConfig = this.templates.get(this.options.template)!;\n\n // Check if there's a passed-in project name and if it's valid\n if (\n this.options.name &&\n !nameHelpers.isValidProjectName(this.options.name)\n ) {\n throw new CodedError(\n 'InvalidProjectName',\n `The specified name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // If no project name is provided, check previously used name or calculate a name and clean if necessary\n if (!this.options.name) {\n const projectName =\n (this.rnwConfig?.['init-windows']?.name as string | undefined) ??\n this.getReactNativeProjectName(this.config.root);\n this.options.name = nameHelpers.isValidProjectName(projectName)\n ? projectName\n : nameHelpers.cleanName(projectName);\n }\n\n // Final check that the project name is valid\n if (!nameHelpers.isValidProjectName(this.options.name)) {\n throw new CodedError(\n 'InvalidProjectName',\n `The name '${this.options.name}' is not a valid identifier`,\n );\n }\n\n // Check if there's a passed-in project namespace and if it's valid\n if (\n this.options.namespace &&\n !nameHelpers.isValidProjectNamespace(this.options.namespace)\n ) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The specified namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n // If no project namespace is provided, check previously used namespace or use the project name and clean if necessary\n if (!this.options.namespace) {\n const namespace =\n (this.rnwConfig?.['init-windows']?.namespace as string | undefined) ??\n this.options.name;\n this.options.namespace = nameHelpers.isValidProjectNamespace(namespace)\n ? namespace\n : nameHelpers.cleanNamespace(namespace);\n }\n\n // Final check that the project namespace is valid\n if (!nameHelpers.isValidProjectNamespace(this.options.namespace)) {\n throw new CodedError(\n 'InvalidProjectNamespace',\n `The namespace '${this.options.namespace}' is not a valid identifier`,\n );\n }\n\n if (templateConfig.preInstall) {\n spinner.info(`Running ${this.options.template} preInstall()...`);\n await templateConfig.preInstall(this.config, this.options);\n }\n\n // Get template files to copy and copy if available\n if (templateConfig.getFileMappings) {\n const fileMappings = await templateConfig.getFileMappings(\n this.config,\n this.options,\n );\n\n for (const fileMapping of fileMappings) {\n const targetDir = path.join(\n this.config.root,\n path.dirname(fileMapping.to),\n );\n\n if (!(await fs.exists(targetDir))) {\n await fs.mkdir(targetDir, {recursive: true});\n }\n\n await copyAndReplaceWithChangedCallback(\n fileMapping.from,\n this.config.root,\n fileMapping.to,\n fileMapping.replacements,\n this.options.overwrite,\n );\n }\n }\n\n if (templateConfig.postInstall) {\n spinner.info(`Running ${this.options.template} postInstall()...`);\n await templateConfig.postInstall(this.config, this.options);\n }\n\n spinner.succeed();\n }\n}\n\n/**\n * Logs the given message if verbose is True.\n * @param message The message to log.\n * @param verbose Whether or not verbose logging is enabled.\n */\nfunction verboseMessage(message: any, verbose?: boolean) {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\nfunction optionSanitizer(key: keyof InitOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'name':\n case 'namespace':\n return value === undefined ? false : true; // Strip PII\n case 'logging':\n case 'template':\n case 'overwrite':\n case 'telemetry':\n case 'list':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `init-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {};\n return extraProps;\n}\n\nfunction sanitizeOptions(\n opts: Record<string, any>,\n sanitizer: (key: keyof InitOptions, value: any) => any,\n): Record<string, any> {\n const sanitized: Record<string, any> = {};\n for (const key in opts) {\n if (Object.prototype.hasOwnProperty.call(opts, key)) {\n sanitized[key] = sanitizer(key as keyof InitOptions, opts[key]);\n }\n }\n return sanitized;\n}\n\n/**\n * The function run when calling `npx @react-native-community/cli init-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function initWindows(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n await startTelemetrySession(\n 'init-windows',\n config,\n options,\n getDefaultOptions(config, initOptions),\n optionSanitizer,\n );\n\n let initWindowsError: Error | undefined;\n\n try {\n await initWindowsInternal(args, config, options);\n } catch (ex) {\n initWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(initWindowsError);\n }\n\n // Now, instead of custom fields, just pass the final options object\n await endTelemetrySession(initWindowsError, getExtraProps, options, opts =>\n sanitizeOptions(opts, optionSanitizer),\n );\n\n setExitProcessWithError(options.logging, initWindowsError);\n}\n\n/**\n * Initializes a new RNW project from a given template.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nexport async function initWindowsInternal(\n args: string[],\n config: Config,\n options: InitOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner('Running init-windows...');\n try {\n const codegen = new InitWindows(config, options);\n await codegen.run(spinner);\n const endTime = performance.now();\n\n console.log(\n `${chalk.green('Success:')} init-windows completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } catch (e) {\n spinner.fail();\n const endTime = performance.now();\n console.log(\n `${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n throw e;\n }\n}\n\n/**\n * Initializes a new RNW project from a given template.\n */\nexport const initCommand: Command = {\n name: 'init-windows',\n description: 'Initializes a new RNW project from a given template',\n func: initWindows,\n options: initOptions,\n};\n"]}
@@ -14,9 +14,7 @@ const chalk_1 = __importDefault(require("chalk"));
14
14
  * Displays a warning message about the Old Architecture template.
15
15
  */
16
16
  function showOldArchitectureWarning() {
17
- console.log(chalk_1.default.yellow(`⚠️ This project is using the React Native (for Windows) Old Architecture. The old architecture will begin to be removed starting with react-native-windows@0.82.0.`));
18
- console.log();
19
- console.log(chalk_1.default.cyan('💡 It is strongly recommended to move to the new architecture as soon as possible to take advantage of improved performance, long-term support, and modern capabilities.'));
17
+ console.log(chalk_1.default.yellow(`⚠️ The old architecture (Paper) is not supported in RNW version v0.82. Please enable your projects using new architecture (Fabric).`));
20
18
  console.log();
21
19
  console.log(chalk_1.default.blue('🔗 Learn more: https://microsoft.github.io/react-native-windows/docs/new-architecture'));
22
20
  console.log();
@@ -1 +1 @@
1
- {"version":3,"file":"oldArchWarning.js","sourceRoot":"","sources":["../../src/utils/oldArchWarning.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kDAA0B;AAE1B;;GAEG;AACH,SAAgB,0BAA0B;IACxC,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,MAAM,CACV,oKAAoK,CACrK,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,0KAA0K,CAC3K,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,uFAAuF,CACxF,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,yIAAyI,CAC1I,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,wHAAwH,CACzH,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC;AA/BD,gEA+BC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport chalk from 'chalk';\n\n/**\n * Displays a warning message about the Old Architecture template.\n */\nexport function showOldArchitectureWarning(): void {\n console.log(\n chalk.yellow(\n `⚠️ This project is using the React Native (for Windows) Old Architecture. The old architecture will begin to be removed starting with react-native-windows@0.82.0.`,\n ),\n );\n console.log();\n console.log(\n chalk.cyan(\n '💡 It is strongly recommended to move to the new architecture as soon as possible to take advantage of improved performance, long-term support, and modern capabilities.',\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '🔗 Learn more: https://microsoft.github.io/react-native-windows/docs/new-architecture',\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '🔗 View the list of properties not yet supported in Fabric: https://microsoft.github.io/react-native-windows/docs/new-arch-missingProps',\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '💬 If you encounter missing properties, please open an issue: https://github.com/microsoft/react-native-windows/issues',\n ),\n );\n console.log();\n}\n"]}
1
+ {"version":3,"file":"oldArchWarning.js","sourceRoot":"","sources":["../../src/utils/oldArchWarning.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kDAA0B;AAE1B;;GAEG;AACH,SAAgB,0BAA0B;IACxC,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,MAAM,CACV,qIAAqI,CACtI,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,uFAAuF,CACxF,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,yIAAyI,CAC1I,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,IAAI,CACR,wHAAwH,CACzH,CACF,CAAC;IACF,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC;AAzBD,gEAyBC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport chalk from 'chalk';\n\n/**\n * Displays a warning message about the Old Architecture template.\n */\nexport function showOldArchitectureWarning(): void {\n console.log(\n chalk.yellow(\n `⚠️ The old architecture (Paper) is not supported in RNW version v0.82. Please enable your projects using new architecture (Fabric).`,\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '🔗 Learn more: https://microsoft.github.io/react-native-windows/docs/new-architecture',\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '🔗 View the list of properties not yet supported in Fabric: https://microsoft.github.io/react-native-windows/docs/new-arch-missingProps',\n ),\n );\n console.log();\n console.log(\n chalk.blue(\n '💬 If you encounter missing properties, please open an issue: https://github.com/microsoft/react-native-windows/issues',\n ),\n );\n console.log();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-windows/cli",
3
- "version": "0.82.0-preview.3",
3
+ "version": "0.82.0",
4
4
  "license": "MIT",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "repository": {
@@ -17,10 +17,10 @@
17
17
  "watch": "rnw-scripts watch"
18
18
  },
19
19
  "dependencies": {
20
- "@react-native-windows/codegen": "0.82.0-preview.2",
21
- "@react-native-windows/fs": "0.82.0-preview.1",
22
- "@react-native-windows/package-utils": "0.82.0-preview.1",
23
- "@react-native-windows/telemetry": "0.82.0-preview.1",
20
+ "@react-native-windows/codegen": "0.82.0",
21
+ "@react-native-windows/fs": "0.82.0",
22
+ "@react-native-windows/package-utils": "0.82.0",
23
+ "@react-native-windows/telemetry": "0.82.0",
24
24
  "@xmldom/xmldom": "^0.7.7",
25
25
  "chalk": "^4.1.0",
26
26
  "cli-spinners": "^2.2.0",
@@ -73,11 +73,11 @@
73
73
  "src/powershell"
74
74
  ],
75
75
  "beachball": {
76
- "defaultNpmTag": "preview",
76
+ "defaultNpmTag": "latest",
77
77
  "disallowedChangeTypes": [
78
78
  "major",
79
79
  "minor",
80
- "patch",
80
+ "prerelease",
81
81
  "premajor",
82
82
  "preminor",
83
83
  "prepatch"