@react-native-windows/cli 0.72.1 → 0.72.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.
@@ -55,7 +55,18 @@ class CodeGenWindows {
55
55
  cppStringType = pkgJson.codegenConfig.windows.cppStringType;
56
56
  break;
57
57
  default:
58
- throw new telemetry_1.CodedError('InvalidCodegenConfig', `Value of ${chalk_1.default.bold('codegenConfig.windows.cppStringType')} package.json should be either 'std::string' or 'std::wstring'`);
58
+ throw new telemetry_1.CodedError('InvalidCodegenConfig', `Value of ${chalk_1.default.bold('codegenConfig.windows.cppStringType')} in package.json should be either 'std::string' or 'std::wstring'`);
59
+ }
60
+ }
61
+ let separateDataTypes = false;
62
+ if (pkgJson.codegenConfig.windows.separateDataTypes !== undefined) {
63
+ switch (pkgJson.codegenConfig.windows.separateDataTypes) {
64
+ case true:
65
+ case false:
66
+ separateDataTypes = pkgJson.codegenConfig.windows.separateDataTypes;
67
+ break;
68
+ default:
69
+ throw new telemetry_1.CodedError('InvalidCodegenConfig', `Value of ${chalk_1.default.bold('codegenConfig.windows.separateDataTypes')} in package.json should be either true or false`);
59
70
  }
60
71
  }
61
72
  if (!pkgJson.codegenConfig.name) {
@@ -76,6 +87,7 @@ class CodeGenWindows {
76
87
  `${jsRootPathRelative}${jsRootPathRelative ? '/' : ''}**/*Native*.[jt]s`,
77
88
  ],
78
89
  cppStringType,
90
+ separateDataTypes,
79
91
  libraryName: projectName,
80
92
  methodOnly: false,
81
93
  modulesCxx: generators.indexOf('modulesCxx') !== -1,
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gDAAwB;AACxB,kDAA0B;AAC1B,2CAAuC;AAEvC,gFAGgD;AAOhD,+DAAsE;AACtE,0EAI6C;AAE7C,2DAIuC;AAGvC,MAAa,cAAc;IAGlB,gBAAgB;QACrB,OAAO,IAAI,CA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G,CACT,GAAG,eAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAK,CAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,KAAK,CAC7D,OAAO,GAAG,SAAS,CACpB,KAAK,CACP,CAAC;QACF,MAAM,CAAC,CAAC;KACT;AACH,CAAC;AA1DD,wDA0DC;AAQY,QAAA,cAAc,GAAoB;IAC7C;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,qDAAqD;KACnE;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uGAAuG;KAC1G;CACF,CAAC;AAEF;;GAEG;AACU,QAAA,cAAc,GAAY;IACrC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,+BAA+B;IAC5C,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,sBAAc;CACxB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\nimport chalk from 'chalk';\nimport {performance} from 'perf_hooks';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from './runWindows/utils/commandWithProgress';\n\nimport {\n Command,\n CommandOption,\n Config,\n} from '@react-native-community/cli-types';\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from './runWindows/utils/telemetryHelpers';\n\nimport {\n CodeGenOptions as RnwCodeGenOptions,\n CppStringTypes,\n runCodeGen,\n} from '@react-native-windows/codegen';\nimport {Ora} from 'ora';\n\nexport class CodeGenWindows {\n private changesNecessary: boolean;\n\n public areChangesNeeded() {\n return this.changesNecessary;\n }\n\n constructor(readonly root: string, readonly options: CodeGenOptions) {\n this.changesNecessary = false;\n }\n\n public async run(spinner: Ora) {\n const verbose = this.options.logging;\n\n verboseMessage('', verbose);\n\n verboseMessage('Loading codegenConfig from package.json');\n const pkgJson = require(path.join(this.root, 'package.json'));\n\n if (!pkgJson.codegenConfig) {\n spinner.info(\n `No ${chalk.bold(\n 'codegenConfig',\n )} specified in package.json - ${chalk.yellow(\n 'Skipping codegen-windows',\n )}`,\n );\n return;\n }\n\n const codegenConfigType = pkgJson.codegenConfig.type;\n if (codegenConfigType !== 'modules' && codegenConfigType !== 'all') {\n spinner.info(\n `${chalk.bold(\n 'codegenConfig.type',\n )} in package.json is not ${chalk.bold('modules')} or ${chalk.bold(\n 'all',\n )} - ${chalk.yellow('Skipping codegen-windows')}`,\n );\n return;\n }\n\n if (!pkgJson.codegenConfig.windows) {\n spinner.info(\n `No ${chalk.bold(\n 'codegenConfig.windows',\n )} specified in package.json - ${chalk.yellow(\n 'Skipping codegen-windows',\n )}`,\n );\n return;\n }\n\n if (!pkgJson.codegenConfig.windows.namespace) {\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Missing ${chalk.bold(\n 'codegenConfig.windows.namespace',\n )} value in package.json`,\n );\n }\n\n let cppStringType: CppStringTypes = 'std::string';\n if (pkgJson.codegenConfig.windows.cppStringType) {\n switch (pkgJson.codegenConfig.windows.cppStringType) {\n case 'std::string':\n case 'std::wstring':\n cppStringType = pkgJson.codegenConfig.windows.cppStringType;\n break;\n default:\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Value of ${chalk.bold(\n 'codegenConfig.windows.cppStringType',\n )} package.json should be either 'std::string' or 'std::wstring'`,\n );\n }\n }\n\n if (!pkgJson.codegenConfig.name) {\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Missing ${chalk.bold('codegenConfig.name')} value in package.json`,\n );\n }\n\n const projectName = pkgJson.codegenConfig.name.replace(/[^a-zA-Z]/g, '');\n const projectNamespace = pkgJson.codegenConfig.windows.namespace;\n const jsRootDir = pkgJson.codegenConfig.jsSrcsDir\n ? path.join(this.root, pkgJson.codegenConfig.jsSrcsDir)\n : this.root;\n const codegenOutputDir =\n pkgJson.codegenConfig.windows.outputDirectory ?? 'codegen';\n\n const generators = pkgJson.codegenConfig.windows.generators ?? [\n 'modulesWindows',\n ];\n\n const jsRootPathRelative = path.relative(process.cwd(), jsRootDir);\n const options: RnwCodeGenOptions = {\n files: [\n `${jsRootPathRelative}${\n jsRootPathRelative ? '/' : ''\n }**/*Native*.[jt]s`,\n ],\n cppStringType,\n libraryName: projectName,\n methodOnly: false,\n modulesCxx: generators.indexOf('modulesCxx') !== -1,\n modulesTypeScriptTypes:\n generators.indexOf('modulesTypeScriptTypes') !== -1,\n modulesWindows: generators.indexOf('modulesWindows') !== -1,\n namespace: projectNamespace,\n outputDirectory: path.join(this.root, codegenOutputDir),\n test: !!this.options.check,\n };\n\n verboseMessage(\n `Run codegen with options: \\n${JSON.stringify(options, null, 2)}`,\n verbose,\n );\n\n this.changesNecessary = runCodeGen(options);\n\n spinner.succeed();\n }\n}\n\n/**\n * Logs the given message if verbose is True.\n * @param message The message to log.\n * @param verbose Whether or not verbose logging is enabled.\n */\nfunction verboseMessage(message: any, verbose?: boolean) {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sanitizes the given option for telemetery.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\nfunction optionSanitizer(key: keyof CodeGenOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'logging':\n case 'check':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `codegen-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {};\n return extraProps;\n}\n\n/**\n * The function run when calling `react-native codegen-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function codegenWindows(\n args: string[],\n config: Config,\n options: CodeGenOptions,\n) {\n await startTelemetrySession(\n 'codegen-windows',\n config,\n options,\n getDefaultOptions(config, codegenOptions),\n optionSanitizer,\n );\n\n let codegenWindowsError: Error | undefined;\n try {\n await codegenWindowsInternal(args, config, options);\n } catch (ex) {\n codegenWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(codegenWindowsError);\n }\n\n await endTelemetrySession(codegenWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, codegenWindowsError);\n}\n\n/**\n * Performs codegen for RNW native modules and apps.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nexport async function codegenWindowsInternal(\n args: string[],\n config: Config,\n options: CodeGenOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner(\n options.check\n ? 'Checking codegen-windows files...'\n : 'Running codegen-windows...',\n );\n try {\n const codegen = new CodeGenWindows(config.root, options);\n await codegen.run(spinner);\n const endTime = performance.now();\n\n if (!codegen.areChangesNeeded()) {\n console.log(\n `${chalk.green(\n 'Success:',\n )} No codegen-windows changes necessary. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } else if (options.check) {\n const codegenCommand = 'npx react-native codegen-windows';\n console.log(\n `${chalk.yellow(\n 'Warning:',\n )} Codegen-windows changes were necessary but ${chalk.bold(\n '--check',\n )} specified. Run '${chalk.bold(\n `${codegenCommand}`,\n )}' to apply the changes. (${Math.round(endTime - startTime)}ms)`,\n );\n throw new CodedError(\n 'NeedCodegen',\n `Codegen-windows changes were necessary but --check was specified. Run '${codegenCommand}' to apply the changes`,\n );\n } else {\n console.log(\n `${chalk.green(\n 'Success:',\n )} Codegen-windows changes completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n }\n } catch (e) {\n spinner.fail();\n const endTime = performance.now();\n console.log(\n `${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n throw e;\n }\n}\n\nexport interface CodeGenOptions {\n logging?: boolean;\n check?: boolean;\n telemetry?: boolean;\n}\n\nexport const codegenOptions: CommandOption[] = [\n {\n name: '--logging',\n description: 'Verbose output logging',\n },\n {\n name: '--check',\n description: 'Only check whether any codegen files need to change',\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\n/**\n * Performs codegen for RNW native modules.\n */\nexport const codegenCommand: Command = {\n name: 'codegen-windows',\n description: 'Runs Windows specific codegen',\n func: codegenWindows,\n options: codegenOptions,\n};\n"]}
1
+ {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gDAAwB;AACxB,kDAA0B;AAC1B,2CAAuC;AAEvC,gFAGgD;AAOhD,+DAAsE;AACtE,0EAI6C;AAE7C,2DAIuC;AAGvC,MAAa,cAAc;IAGlB,gBAAgB;QACrB,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED,YAAqB,IAAY,EAAW,OAAuB;QAA9C,SAAI,GAAJ,IAAI,CAAQ;QAAW,YAAO,GAAP,OAAO,CAAgB;QACjE,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;IAChC,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,OAAY;;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAErC,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAE5B,cAAc,CAAC,yCAAyC,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;QAE9D,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;YAC1B,OAAO,CAAC,IAAI,CACV,MAAM,eAAK,CAAC,IAAI,CACd,eAAe,CAChB,gCAAgC,eAAK,CAAC,MAAM,CAC3C,0BAA0B,CAC3B,EAAE,CACJ,CAAC;YACF,OAAO;SACR;QAED,MAAM,i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E,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,qDAAqD;KACnE;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uGAAuG;KAC1G;CACF,CAAC;AAEF;;GAEG;AACU,QAAA,cAAc,GAAY;IACrC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,+BAA+B;IAC5C,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,sBAAc;CACxB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\nimport chalk from 'chalk';\nimport {performance} from 'perf_hooks';\n\nimport {\n newSpinner,\n setExitProcessWithError,\n} from './runWindows/utils/commandWithProgress';\n\nimport {\n Command,\n CommandOption,\n Config,\n} from '@react-native-community/cli-types';\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from './runWindows/utils/telemetryHelpers';\n\nimport {\n CodeGenOptions as RnwCodeGenOptions,\n CppStringTypes,\n runCodeGen,\n} from '@react-native-windows/codegen';\nimport {Ora} from 'ora';\n\nexport class CodeGenWindows {\n private changesNecessary: boolean;\n\n public areChangesNeeded() {\n return this.changesNecessary;\n }\n\n constructor(readonly root: string, readonly options: CodeGenOptions) {\n this.changesNecessary = false;\n }\n\n public async run(spinner: Ora) {\n const verbose = this.options.logging;\n\n verboseMessage('', verbose);\n\n verboseMessage('Loading codegenConfig from package.json');\n const pkgJson = require(path.join(this.root, 'package.json'));\n\n if (!pkgJson.codegenConfig) {\n spinner.info(\n `No ${chalk.bold(\n 'codegenConfig',\n )} specified in package.json - ${chalk.yellow(\n 'Skipping codegen-windows',\n )}`,\n );\n return;\n }\n\n const codegenConfigType = pkgJson.codegenConfig.type;\n if (codegenConfigType !== 'modules' && codegenConfigType !== 'all') {\n spinner.info(\n `${chalk.bold(\n 'codegenConfig.type',\n )} in package.json is not ${chalk.bold('modules')} or ${chalk.bold(\n 'all',\n )} - ${chalk.yellow('Skipping codegen-windows')}`,\n );\n return;\n }\n\n if (!pkgJson.codegenConfig.windows) {\n spinner.info(\n `No ${chalk.bold(\n 'codegenConfig.windows',\n )} specified in package.json - ${chalk.yellow(\n 'Skipping codegen-windows',\n )}`,\n );\n return;\n }\n\n if (!pkgJson.codegenConfig.windows.namespace) {\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Missing ${chalk.bold(\n 'codegenConfig.windows.namespace',\n )} value in package.json`,\n );\n }\n\n let cppStringType: CppStringTypes = 'std::string';\n if (pkgJson.codegenConfig.windows.cppStringType) {\n switch (pkgJson.codegenConfig.windows.cppStringType) {\n case 'std::string':\n case 'std::wstring':\n cppStringType = pkgJson.codegenConfig.windows.cppStringType;\n break;\n default:\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Value of ${chalk.bold(\n 'codegenConfig.windows.cppStringType',\n )} in package.json should be either 'std::string' or 'std::wstring'`,\n );\n }\n }\n\n let separateDataTypes = false;\n if (pkgJson.codegenConfig.windows.separateDataTypes !== undefined) {\n switch (pkgJson.codegenConfig.windows.separateDataTypes) {\n case true:\n case false:\n separateDataTypes = pkgJson.codegenConfig.windows.separateDataTypes;\n break;\n default:\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Value of ${chalk.bold(\n 'codegenConfig.windows.separateDataTypes',\n )} in package.json should be either true or false`,\n );\n }\n }\n\n if (!pkgJson.codegenConfig.name) {\n throw new CodedError(\n 'InvalidCodegenConfig',\n `Missing ${chalk.bold('codegenConfig.name')} value in package.json`,\n );\n }\n\n const projectName = pkgJson.codegenConfig.name.replace(/[^a-zA-Z]/g, '');\n const projectNamespace = pkgJson.codegenConfig.windows.namespace;\n const jsRootDir = pkgJson.codegenConfig.jsSrcsDir\n ? path.join(this.root, pkgJson.codegenConfig.jsSrcsDir)\n : this.root;\n const codegenOutputDir =\n pkgJson.codegenConfig.windows.outputDirectory ?? 'codegen';\n\n const generators = pkgJson.codegenConfig.windows.generators ?? [\n 'modulesWindows',\n ];\n\n const jsRootPathRelative = path.relative(process.cwd(), jsRootDir);\n const options: RnwCodeGenOptions = {\n files: [\n `${jsRootPathRelative}${\n jsRootPathRelative ? '/' : ''\n }**/*Native*.[jt]s`,\n ],\n cppStringType,\n separateDataTypes,\n libraryName: projectName,\n methodOnly: false,\n modulesCxx: generators.indexOf('modulesCxx') !== -1,\n modulesTypeScriptTypes:\n generators.indexOf('modulesTypeScriptTypes') !== -1,\n modulesWindows: generators.indexOf('modulesWindows') !== -1,\n namespace: projectNamespace,\n outputDirectory: path.join(this.root, codegenOutputDir),\n test: !!this.options.check,\n };\n\n verboseMessage(\n `Run codegen with options: \\n${JSON.stringify(options, null, 2)}`,\n verbose,\n );\n\n this.changesNecessary = runCodeGen(options);\n\n spinner.succeed();\n }\n}\n\n/**\n * Logs the given message if verbose is True.\n * @param message The message to log.\n * @param verbose Whether or not verbose logging is enabled.\n */\nfunction verboseMessage(message: any, verbose?: boolean) {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sanitizes the given option for telemetery.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\nfunction optionSanitizer(key: keyof CodeGenOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'logging':\n case 'check':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `codegen-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {};\n return extraProps;\n}\n\n/**\n * The function run when calling `react-native codegen-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function codegenWindows(\n args: string[],\n config: Config,\n options: CodeGenOptions,\n) {\n await startTelemetrySession(\n 'codegen-windows',\n config,\n options,\n getDefaultOptions(config, codegenOptions),\n optionSanitizer,\n );\n\n let codegenWindowsError: Error | undefined;\n try {\n await codegenWindowsInternal(args, config, options);\n } catch (ex) {\n codegenWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(codegenWindowsError);\n }\n\n await endTelemetrySession(codegenWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, codegenWindowsError);\n}\n\n/**\n * Performs codegen for RNW native modules and apps.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nexport async function codegenWindowsInternal(\n args: string[],\n config: Config,\n options: CodeGenOptions,\n) {\n const startTime = performance.now();\n const spinner = newSpinner(\n options.check\n ? 'Checking codegen-windows files...'\n : 'Running codegen-windows...',\n );\n try {\n const codegen = new CodeGenWindows(config.root, options);\n await codegen.run(spinner);\n const endTime = performance.now();\n\n if (!codegen.areChangesNeeded()) {\n console.log(\n `${chalk.green(\n 'Success:',\n )} No codegen-windows changes necessary. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n } else if (options.check) {\n const codegenCommand = 'npx react-native codegen-windows';\n console.log(\n `${chalk.yellow(\n 'Warning:',\n )} Codegen-windows changes were necessary but ${chalk.bold(\n '--check',\n )} specified. Run '${chalk.bold(\n `${codegenCommand}`,\n )}' to apply the changes. (${Math.round(endTime - startTime)}ms)`,\n );\n throw new CodedError(\n 'NeedCodegen',\n `Codegen-windows changes were necessary but --check was specified. Run '${codegenCommand}' to apply the changes`,\n );\n } else {\n console.log(\n `${chalk.green(\n 'Success:',\n )} Codegen-windows changes completed. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n }\n } catch (e) {\n spinner.fail();\n const endTime = performance.now();\n console.log(\n `${chalk.red('Error:')} ${(e as any).toString()}. (${Math.round(\n endTime - startTime,\n )}ms)`,\n );\n throw e;\n }\n}\n\nexport interface CodeGenOptions {\n logging?: boolean;\n check?: boolean;\n telemetry?: boolean;\n}\n\nexport const codegenOptions: CommandOption[] = [\n {\n name: '--logging',\n description: 'Verbose output logging',\n },\n {\n name: '--check',\n description: 'Only check whether any codegen files need to change',\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\n/**\n * Performs codegen for RNW native modules.\n */\nexport const codegenCommand: Command = {\n name: 'codegen-windows',\n description: 'Runs Windows specific codegen',\n func: codegenWindows,\n options: codegenOptions,\n};\n"]}
@@ -4,12 +4,9 @@
4
4
  * Licensed under the MIT License.
5
5
  * @format
6
6
  */
7
- var __importDefault = (this && this.__importDefault) || function (mod) {
8
- return (mod && mod.__esModule) ? mod : { "default": mod };
9
- };
10
7
  Object.defineProperty(exports, "__esModule", { value: true });
11
8
  exports.runWindowsOptions = void 0;
12
- const os_1 = __importDefault(require("os"));
9
+ const telemetry_1 = require("@react-native-windows/telemetry");
13
10
  exports.runWindowsOptions = [
14
11
  {
15
12
  name: '--release',
@@ -23,11 +20,7 @@ exports.runWindowsOptions = [
23
20
  {
24
21
  name: '--arch [string]',
25
22
  description: 'The build architecture (ARM64, x86, x64)',
26
- default: os_1.default.arch() === 'ia32'
27
- ? 'x86'
28
- : os_1.default.arch() === 'arm64'
29
- ? 'ARM64'
30
- : os_1.default.arch(),
23
+ default: parseBuildArch((0, telemetry_1.deviceArchitecture)()),
31
24
  parse: parseBuildArch,
32
25
  },
33
26
  {
@@ -1 +1 @@
1
- {"version":3,"file":"runWindowsOptions.js","sourceRoot":"","sources":["../../src/runWindows/runWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,4CAAoB;AAsDP,QAAA,iBAAiB,GAAoB;IAChD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,2BAA2B;KACzC;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,sFAAsF;QACxF,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,MAA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Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport os from 'os';\nimport {CommandOption} from '@react-native-community/cli-types';\n\nexport type BuildArch = 'x86' | 'x64' | 'ARM64';\nexport type BuildConfig = 'Debug' | 'DebugBundle' | 'Release' | 'ReleaseBundle';\n\n/**\n * * Options are the following:\n * release: Boolean - Specifies release build\n * root: String - The root of the application\n * arch: String - The build architecture (ARM64, x86, x64)\n * singleproc: Boolean - opt out of multi-proc builds\n * emulator: Boolean - Deploy to the emulator\n * device: Boolean - Deploy to a device\n * target: String - Device GUID to deploy to\n * remote-debugging: Boolean - Run using remote JS proxy\n * logging: Boolean - Enables logging\n * no-packager: Boolean - Do not launch packager while building\n * bundle: Boolean - Enable Bundle configuration.\n * no-launch: Boolean - Do not launch the app after deployment\n * no-build: Boolean - Do not build the solution\n * no-deploy: Boolean - Do not deploy the app\n * deploy-from-layout: Force deploy from layout, even in release builds\n * sln: String - Solution file to build\n * msbuildprops: String - Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2\n * direct-debugging: Number - Enable direct debugging on specified port\n * no-telemetry: Boolean - Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI\n */\nexport interface RunWindowsOptions {\n release?: boolean;\n root: string;\n arch: BuildArch;\n singleproc?: boolean;\n emulator?: boolean;\n device?: boolean;\n target?: string;\n remoteDebugging?: string;\n logging?: boolean;\n packager?: boolean;\n bundle?: boolean;\n launch?: boolean;\n autolink?: boolean;\n build?: boolean;\n deploy?: boolean;\n deployFromLayout?: boolean;\n sln?: string;\n proj?: string;\n msbuildprops?: string;\n buildLogDirectory?: string;\n info?: boolean;\n directDebugging?: number;\n telemetry?: boolean;\n}\n\nexport const runWindowsOptions: CommandOption[] = [\n {\n name: '--release',\n description: 'Specifies a release build',\n },\n {\n name: '--root [string]',\n description:\n 'Override the root directory for the windows build which contains the windows folder.',\n default: config => config.root,\n },\n {\n name: '--arch [string]',\n description: 'The build architecture (ARM64, x86, x64)',\n default:\n os.arch() === 'ia32'\n ? 'x86'\n : os.arch() === 'arm64'\n ? 'ARM64'\n : os.arch(),\n parse: parseBuildArch,\n },\n {\n name: '--singleproc',\n description: 'Disables multi-proc build',\n },\n {\n name: '--emulator',\n description: 'Deploys the app to an emulator',\n },\n {\n name: '--device',\n description: 'Deploys the app to a connected device',\n },\n {\n name: '--target [string]',\n description: 'Deploys the app to the specified GUID for a device.',\n },\n {\n name: '--remote-debugging',\n description: 'Deploys the app in remote debugging mode.',\n },\n {\n name: '--logging',\n description: 'Enables logging',\n },\n {\n name: '--no-packager',\n description: 'Do not launch packager while building',\n },\n {\n name: '--bundle',\n description:\n 'Enable Bundle configuration and it would be ReleaseBundle/DebugBundle other than Release/Debug',\n },\n {\n name: '--no-launch',\n description: 'Do not launch the app after deployment',\n },\n {\n name: '--no-autolink',\n description: 'Do not run autolinking',\n },\n {\n name: '--no-build',\n description: 'Do not build the solution',\n },\n {\n name: '--no-deploy',\n description: 'Do not deploy the app',\n },\n {\n name: '--deploy-from-layout',\n description: 'Force deploy from layout',\n },\n {\n name: '--sln [string]',\n description:\n \"Override the app solution file determined by 'react-native config', e.g. windows\\\\myApp.sln\",\n default: undefined,\n },\n {\n name: '--proj [string]',\n description:\n \"Override the app project file determined by 'react-native config', e.g. windows\\\\myApp\\\\myApp.vcxproj\",\n default: undefined,\n },\n {\n name: '--msbuildprops [string]',\n description:\n 'Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2',\n },\n {\n name: '--buildLogDirectory [string]',\n description: 'Optional directory where msbuild log files should be stored',\n },\n {\n name: '--info',\n description: 'Dump environment information',\n },\n {\n name: '--direct-debugging [number]',\n description: 'Enable direct debugging on specified port',\n parse: parseDirectDebuggingPort,\n },\n {\n name: '--no-telemetry',\n description:\n 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',\n },\n];\n\nfunction parseBuildArch(arg: string): BuildArch {\n const supportedArches: BuildArch[] = ['x86', 'x64', 'ARM64'];\n for (const supported of supportedArches) {\n if (arg.toLowerCase() === supported.toLowerCase()) {\n return supported;\n }\n }\n\n errorOut(`Unrecognized --arch '${arg}'. Expected one of ${supportedArches}`);\n}\n\nfunction parseDirectDebuggingPort(arg: string): number {\n const num = parseInt(arg, 10);\n\n if (!Number.isInteger(num)) {\n errorOut(`Expected argument '--direct-debugging' to be a number`);\n }\n if (num < 1024 || num >= 65535) {\n errorOut('Direct debugging port it out of range');\n }\n\n return num;\n}\n\nfunction errorOut(arg: string): never {\n console.error(arg);\n process.exit(1);\n}\n"]}
1
+ {"version":3,"file":"runWindowsOptions.js","sourceRoot":"","sources":["../../src/runWindows/runWindowsOptions.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,+DAAmE;AAqDtD,QAAA,iBAAiB,GAAoB;IAChD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,2BAA2B;KACzC;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,sFAAsF;QACxF,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI;KAC/B;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,0CAA0C;QACvD,OAAO,EAAE,cAAc,CAAC,IAAA,8BAAkB,GAAE,CAAC;QAC7C,KAAK,EAAE,cAAc;KACtB;IACD;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,2BAA2B;KACzC;IACD;QACE,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,gCAAgC;KAC9C;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,uCAAuC;KACrD;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,qDAAqD;KACnE;IACD;QACE,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,2CAA2C;KACzD;IACD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,iBAAiB;KAC/B;IACD;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,uCAAuC;KACrD;IACD;QACE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AC,GAAW;IAC3C,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAE9B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;QAC1B,QAAQ,CAAC,uDAAuD,CAAC,CAAC;KACnE;IACD,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,IAAI,KAAK,EAAE;QAC9B,QAAQ,CAAC,uCAAuC,CAAC,CAAC;KACnD;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,QAAQ,CAAC,GAAW;IAC3B,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CommandOption} from '@react-native-community/cli-types';\nimport {deviceArchitecture} from '@react-native-windows/telemetry';\n\nexport type BuildArch = 'x86' | 'x64' | 'ARM64';\nexport type BuildConfig = 'Debug' | 'DebugBundle' | 'Release' | 'ReleaseBundle';\n\n/**\n * * Options are the following:\n * release: Boolean - Specifies release build\n * root: String - The root of the application\n * arch: String - The build architecture (ARM64, x86, x64)\n * singleproc: Boolean - opt out of multi-proc builds\n * emulator: Boolean - Deploy to the emulator\n * device: Boolean - Deploy to a device\n * target: String - Device GUID to deploy to\n * remote-debugging: Boolean - Run using remote JS proxy\n * logging: Boolean - Enables logging\n * no-packager: Boolean - Do not launch packager while building\n * bundle: Boolean - Enable Bundle configuration.\n * no-launch: Boolean - Do not launch the app after deployment\n * no-build: Boolean - Do not build the solution\n * no-deploy: Boolean - Do not deploy the app\n * deploy-from-layout: Force deploy from layout, even in release builds\n * sln: String - Solution file to build\n * msbuildprops: String - Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2\n * direct-debugging: Number - Enable direct debugging on specified port\n * no-telemetry: Boolean - Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI\n */\nexport interface RunWindowsOptions {\n release?: boolean;\n root: string;\n arch: BuildArch;\n singleproc?: boolean;\n emulator?: boolean;\n device?: boolean;\n target?: string;\n remoteDebugging?: string;\n logging?: boolean;\n packager?: boolean;\n bundle?: boolean;\n launch?: boolean;\n autolink?: boolean;\n build?: boolean;\n deploy?: boolean;\n deployFromLayout?: boolean;\n sln?: string;\n proj?: string;\n msbuildprops?: string;\n buildLogDirectory?: string;\n info?: boolean;\n directDebugging?: number;\n telemetry?: boolean;\n}\n\nexport const runWindowsOptions: CommandOption[] = [\n {\n name: '--release',\n description: 'Specifies a release build',\n },\n {\n name: '--root [string]',\n description:\n 'Override the root directory for the windows build which contains the windows folder.',\n default: config => config.root,\n },\n {\n name: '--arch [string]',\n description: 'The build architecture (ARM64, x86, x64)',\n default: parseBuildArch(deviceArchitecture()),\n parse: parseBuildArch,\n },\n {\n name: '--singleproc',\n description: 'Disables multi-proc build',\n },\n {\n name: '--emulator',\n description: 'Deploys the app to an emulator',\n },\n {\n name: '--device',\n description: 'Deploys the app to a connected device',\n },\n {\n name: '--target [string]',\n description: 'Deploys the app to the specified GUID for a device.',\n },\n {\n name: '--remote-debugging',\n description: 'Deploys the app in remote debugging mode.',\n },\n {\n name: '--logging',\n description: 'Enables logging',\n },\n {\n name: '--no-packager',\n description: 'Do not launch packager while building',\n },\n {\n name: '--bundle',\n description:\n 'Enable Bundle configuration and it would be ReleaseBundle/DebugBundle other than Release/Debug',\n },\n {\n name: '--no-launch',\n description: 'Do not launch the app after deployment',\n },\n {\n name: '--no-autolink',\n description: 'Do not run autolinking',\n },\n {\n name: '--no-build',\n description: 'Do not build the solution',\n },\n {\n name: '--no-deploy',\n description: 'Do not deploy the app',\n },\n {\n name: '--deploy-from-layout',\n description: 'Force deploy from layout',\n },\n {\n name: '--sln [string]',\n description:\n \"Override the app solution file determined by 'react-native config', e.g. windows\\\\myApp.sln\",\n default: undefined,\n },\n {\n name: '--proj [string]',\n description:\n \"Override the app project file determined by 'react-native config', e.g. windows\\\\myApp\\\\myApp.vcxproj\",\n default: undefined,\n },\n {\n name: '--msbuildprops [string]',\n description:\n 'Comma separated props to pass to msbuild, eg: prop1=value1,prop2=value2',\n },\n {\n name: '--buildLogDirectory [string]',\n description: 'Optional directory where msbuild log files should be stored',\n },\n {\n name: '--info',\n description: 'Dump environment information',\n },\n {\n name: '--direct-debugging [number]',\n description: 'Enable direct debugging on specified port',\n parse: parseDirectDebuggingPort,\n },\n {\n name: '--no-telemetry',\n description:\n 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',\n },\n];\n\nfunction parseBuildArch(arg: string): BuildArch {\n const supportedArches: BuildArch[] = ['x86', 'x64', 'ARM64'];\n for (const supported of supportedArches) {\n if (arg.toLowerCase() === supported.toLowerCase()) {\n return supported;\n }\n }\n\n errorOut(`Unrecognized --arch '${arg}'. Expected one of ${supportedArches}`);\n}\n\nfunction parseDirectDebuggingPort(arg: string): number {\n const num = parseInt(arg, 10);\n\n if (!Number.isInteger(num)) {\n errorOut(`Expected argument '--direct-debugging' to be a number`);\n }\n if (num < 1024 || num >= 65535) {\n errorOut('Direct debugging port it out of range');\n }\n\n return num;\n}\n\nfunction errorOut(arg: string): never {\n console.error(arg);\n process.exit(1);\n}\n"]}
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.endTelemetrySession = exports.startTelemetrySession = exports.getDefaultOptions = void 0;
9
9
  const lodash_1 = require("lodash");
10
10
  const telemetry_1 = require("@react-native-windows/telemetry");
11
+ const commandWithProgress_1 = require("./commandWithProgress");
11
12
  /**
12
13
  * Calculates a the default values of a given react-native CLI command's options.
13
14
  * @param config Config passed from react-native CLI.
@@ -63,12 +64,19 @@ exports.getDefaultOptions = getDefaultOptions;
63
64
  * @param optionSanitizer Function to sanitize the option values for telemetry.
64
65
  */
65
66
  async function startTelemetrySession(commandName, config, options, defaultOptions, optionSanitizer) {
67
+ const verbose = options.logging === true;
66
68
  if (!options.telemetry) {
67
- if (options.logging) {
68
- console.log('Telemetry is disabled');
69
+ if (verbose) {
70
+ (0, commandWithProgress_1.newInfo)('Telemetry is disabled');
69
71
  }
70
72
  return;
71
73
  }
74
+ if (verbose) {
75
+ (0, commandWithProgress_1.newInfo)(`Running ${(0, telemetry_1.nodeArchitecture)()} node on a ${(0, telemetry_1.deviceArchitecture)()} machine`);
76
+ }
77
+ if ((0, telemetry_1.deviceArchitecture)() !== (0, telemetry_1.nodeArchitecture)()) {
78
+ (0, commandWithProgress_1.newWarn)('This version of node was built for a different architecture than this machine and may cause unintended behavior');
79
+ }
72
80
  await telemetry_1.Telemetry.setup();
73
81
  const sanitizedOptions = (0, telemetry_1.commanderOptionsToOptions)(options, optionSanitizer);
74
82
  const sanitizedDefaultOptions = (0, telemetry_1.commanderOptionsToOptions)(defaultOptions, optionSanitizer);
@@ -1 +1 @@
1
- {"version":3,"file":"telemetryHelpers.js","sourceRoot":"","sources":["../../../src/runWindows/utils/telemetryHelpers.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,mCAAiC;AAQjC,+DAWyC;AAEzC;;;;;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,CA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ChB,CAAC;IACF,MAAM,aAAa,GAAG,IAAA,yBAAa,EAAC,gBAAgB,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE,MAAM,SAAS,GAAqB;QAClC,WAAW;QACX,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,gBAAgB;QACzB,cAAc,EAAE,uBAAuB;KACxC,CAAC;IAEF,qBAAS,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAElC,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAmB,EAAC,MAAM,CAAC,CAAC;IACtD,IAAI,WAAW,EAAE;QACf,qBAAS,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;KACvC;IAED,MAAM,WAAW,GAAG,IAAA,oCAAwB,EAAC,MAAM,CAAC,CAAC;IACrD,IAAI,WAAW,EAAE;QACf,MAAM,qBAAS,CAAC,4BAA4B,CAAC,WAAW,CAAC,CAAC;KAC3D;AACH,CAAC;AAzCD,sDAyCC;AAED;;;;GAIG;AACI,KAAK,UAAU,mBAAmB,CACvC,KAAa,EACb,aAAkD;IAElD,IAAI,CAAC,qBAAS,CAAC,SAAS,EAAE,EAAE;QAC1B,sCAAsC;QACtC,OAAO;KACR;IAED,MAAM,OAAO,GAAmB;QAC9B,UAAU,EAAE,SAAS;KACtB,CAAC;IAEF,IAAI,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 {\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} from '@react-native-windows/telemetry';\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 if (!options.telemetry) {\n if (options.logging) {\n console.log('Telemetry is disabled');\n }\n return;\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/runWindows/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;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AAO,GAAmB;QAC9B,UAAU,EAAE,SAAS;KACtB,CAAC;IAEF,IAAI,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 {\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-windows/cli",
3
- "version": "0.72.1",
3
+ "version": "0.72.3",
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.72.1",
20
+ "@react-native-windows/codegen": "0.72.2",
21
21
  "@react-native-windows/fs": "0.72.0",
22
22
  "@react-native-windows/package-utils": "0.72.0",
23
- "@react-native-windows/telemetry": "0.72.0",
23
+ "@react-native-windows/telemetry": "0.72.1",
24
24
  "@xmldom/xmldom": "^0.7.7",
25
25
  "chalk": "^4.1.0",
26
26
  "cli-spinners": "^2.2.0",