@react-native-windows/cli 0.75.2 → 0.75.4
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.
|
@@ -64,7 +64,7 @@ function optionSanitizer(key, value) {
|
|
|
64
64
|
case 'buildLogDirectory':
|
|
65
65
|
return value === undefined ? false : true; // Strip PII
|
|
66
66
|
case 'msbuildprops':
|
|
67
|
-
return value ===
|
|
67
|
+
return typeof value === 'string' ? value.split(',').length : 0; // Convert to count
|
|
68
68
|
case 'release':
|
|
69
69
|
case 'arch':
|
|
70
70
|
case 'singleproc':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWindows.js","sourceRoot":"","sources":["../../../src/commands/runWindows/runWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AAExB,+DAAsE;AAGtE,yDAA2C;AAC3C,kDAA0B;AAC1B,2DAA6C;AAC7C,yEAKyC;AACzC,mEAIsC;AACtC,qEAAuD;AACvD,uDAAyC;AACzC,4EAAoD;AACpD,2DAAyE;AACzE,wEAA2E;AAG3E;;;;;GAKG;AACH,sCAAsC;AACtC,SAAS,eAAe,CAAC,GAA4B,EAAE,KAAU;IAC/D,kCAAkC;IAClC,2EAA2E;IAC3E,8DAA8D;IAC9D,QAAQ,GAAG,EAAE;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,mBAAmB;YACtB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;QACzD,KAAK,cAAc;YACjB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,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AAC,CAAC;SACT;KACF;SAAM;QACL,IAAA,6BAAO,EAAC,wBAAwB,CAAC,CAAC;KACnC;AACH,CAAC;AAED,SAAS,oBAAoB,CAAC,OAA0B;IACtD,OAAO,CACL,OAAO,CAAC,QAAQ,KAAK,IAAI;QACzB,OAAO,CAAC,MAAM,KAAK,IAAI;QACvB,OAAO,CAAC,OAAO,KAAK,IAAI,CACzB,CAAC;AACJ,CAAC;AAED;;;;;;;;EAQE;AAEF;;GAEG;AACU,QAAA,iBAAiB,GAAY;IACxC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,kFAAkF;IACpF,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,qCAAiB;CAC3B,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\n\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport {Command, Config} from '@react-native-community/cli-types';\n\nimport * as build from '../../utils/build';\nimport chalk from 'chalk';\nimport * as deploy from '../../utils/deploy';\nimport {\n newError,\n newInfo,\n newWarn,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport * as info from '../../utils/info';\nimport MSBuildTools from '../../utils/msbuildtools';\nimport {runWindowsOptions, RunWindowsOptions} from './runWindowsOptions';\nimport {autolinkWindowsInternal} from '../autolinkWindows/autolinkWindows';\nimport {AutoLinkOptions} from '../autolinkWindows/autolinkWindowsOptions';\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\n// eslint-disable-next-line complexity\nfunction optionSanitizer(key: keyof RunWindowsOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'root':\n case 'target':\n case 'sln':\n case 'proj':\n case 'buildLogDirectory':\n return value === undefined ? false : true; // Strip PII\n case 'msbuildprops':\n return value === undefined ? 0 : value.split(',').length; // Convert to count\n case 'release':\n case 'arch':\n case 'singleproc':\n case 'emulator':\n case 'device':\n case 'remoteDebugging':\n case 'logging':\n case 'packager':\n case 'bundle':\n case 'launch':\n case 'autolink':\n case 'build':\n case 'deploy':\n case 'deployFromLayout':\n case 'info':\n case 'directDebugging':\n case 'telemetry':\n return value === undefined ? false : value; // Return value\n }\n}\n\n/**\n * Get the extra props to add to the `run-windows` telemetry event.\n * @returns The extra props.\n */\nasync function getExtraProps(): Promise<Record<string, any>> {\n const extraProps: Record<string, any> = {\n phase: runWindowsPhase,\n hasRunRnwDependencies,\n msBuildProps: evaluateMSBuildPropsCallback\n ? evaluateMSBuildPropsCallback()\n : {},\n };\n return extraProps;\n}\n\n/**\n * Labels used by telemetry to represent current operation\n */\ntype RunWindowsPhase =\n | 'None'\n | 'Info'\n | 'FindSolution'\n | 'FindBuildTools'\n | 'Autolink'\n | 'RestorePackagesConfig'\n | 'Build'\n | 'Deploy';\n\nlet runWindowsPhase: RunWindowsPhase = 'None';\n\nlet hasRunRnwDependencies: boolean = false;\n\nlet evaluateMSBuildPropsCallback:\n | (() => Record<string, string> | null)\n | undefined;\n\n/**\n * The function run when calling `react-native run-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindows(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n await startTelemetrySession(\n 'run-windows',\n config,\n options,\n getDefaultOptions(config, runWindowsOptions),\n optionSanitizer,\n );\n\n // https://github.com/yarnpkg/yarn/issues/8334 - Yarn on Windows breaks apps that read from the environment variables\n // Yarn will run node via CreateProcess and pass npm_config_* variables in lowercase without unifying their value\n // with their possibly existing uppercase counterparts. This breaks programs that read from the environment block\n // and write to a case-insensitive dictionary since they expect to encounter each variable only once.\n // The values of the lowercase variables are the one npm actually wants to use, plus they are seeded from the\n // uppercase variable values one if there are no overrides.\n delete process.env.NPM_CONFIG_CACHE;\n delete process.env.NPM_CONFIG_PREFIX;\n\n if (process.env.LocalAppData) {\n hasRunRnwDependencies = fs.existsSync(\n path.join(process.env.LocalAppData, 'rnw-dependencies.txt'),\n ); // CODESYNC \\vnext\\scripts\\rnw-dependencies.ps1\n }\n\n let runWindowsError: Error | undefined;\n if (options.info) {\n runWindowsPhase = 'Info';\n try {\n const output = await info.getEnvironmentInfo();\n console.log(output.trimEnd());\n console.log(' Installed UWP SDKs:');\n const sdks = MSBuildTools.getAllAvailableUAPVersions();\n sdks.forEach(version => console.log(' ' + version));\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n newError(\n 'Unable to print environment info.\\n' + runWindowsError.toString(),\n );\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n return;\n }\n\n try {\n await runWindowsInternal(args, config, options);\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n if (!hasRunRnwDependencies) {\n const rnwDependenciesPath = path.join(\n pathHelpers.resolveRnwRoot([process.cwd(), __dirname]),\n 'scripts/rnw-dependencies.ps1',\n );\n\n newError(\n `It is possible your installation is missing required software dependencies. Dependencies can be automatically installed by running ${rnwDependenciesPath} from an elevated PowerShell prompt.\\nFor more information, go to http://aka.ms/rnw-deps`,\n );\n }\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n}\n\n/**\n * Performs build deploy and launch of RNW apps.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindowsInternal(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n const verbose = options.logging === true;\n\n if (verbose) {\n newInfo('Verbose: ON');\n }\n\n // Get the solution file\n let slnFile: string | null;\n runWindowsPhase = 'FindSolution';\n try {\n slnFile = build.getAppSolutionFile(options, config);\n } catch (e) {\n newError(`Couldn't get app solution information. ${(e as Error).message}`);\n throw e;\n }\n\n let buildTools: MSBuildTools;\n runWindowsPhase = 'FindBuildTools';\n try {\n buildTools = MSBuildTools.findAvailableVersion(options.arch, verbose);\n } catch (error) {\n newWarn('No public VS release found');\n // Try prerelease\n try {\n newInfo('Trying pre-release VS');\n buildTools = MSBuildTools.findAvailableVersion(\n options.arch,\n verbose,\n true, // preRelease\n );\n } catch (e) {\n newError((e as Error).message);\n throw error;\n }\n }\n\n // Set up the callback to capture MSBuild properties after the command completes\n evaluateMSBuildPropsCallback = () => {\n const projectFile = build.getAppProjectFile(options, config);\n if (projectFile) {\n if (verbose) {\n newInfo('Gathering MSBuild data for telemetry.');\n }\n\n const msBuildPropertiesJsonPath = path.resolve(\n path.dirname(projectFile),\n 'Generated Files',\n 'msbuildproperties.g.json',\n );\n\n if (fs.existsSync(msBuildPropertiesJsonPath)) {\n if (verbose) {\n newInfo('Loading properties from msbuildproperties.g.json');\n }\n return fs.readJsonFileSync(msBuildPropertiesJsonPath);\n }\n\n if (verbose) {\n newInfo('Unable to find msbuildproperties.g.json');\n }\n }\n\n return {};\n };\n\n // Restore packages.config files for dependencies that don't support PackageReference.\n runWindowsPhase = 'RestorePackagesConfig';\n const buildType = deploy.getBuildConfiguration(options);\n try {\n await buildTools.restorePackageConfigs(slnFile, options.arch, buildType);\n } catch (e) {\n newError(\n `Couldn't restore found packages.config instances. ${\n (e as Error).message\n }`,\n );\n throw e;\n }\n\n if (options.autolink) {\n runWindowsPhase = 'Autolink';\n try {\n const autolinkArgs: string[] = [];\n const autolinkConfig = config;\n const autolinkOptions: AutoLinkOptions = {\n logging: options.logging,\n check: false,\n proj: options.proj,\n sln: options.sln,\n telemetry: options.telemetry,\n };\n await autolinkWindowsInternal(\n autolinkArgs,\n autolinkConfig,\n autolinkOptions,\n );\n } catch (e) {\n newError(`Autolinking failed. ${(e as Error).message}`);\n throw e;\n }\n } else {\n newInfo('Autolink step is skipped');\n }\n\n if (options.build) {\n runWindowsPhase = 'Build';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx react-native-windows-init\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n // Get build/deploy options\n const msBuildProps = build.parseMsBuildProps(options);\n\n // Disable the autolink check since we just ran it\n msBuildProps.RunAutolinkCheck = 'false';\n\n try {\n await build.buildSolution(\n buildTools,\n slnFile!,\n buildType,\n options.arch,\n msBuildProps,\n verbose,\n 'build',\n options.buildLogDirectory,\n options.singleproc,\n );\n } catch (e) {\n newError(\n `Build failed with message ${\n (e as Error).message\n }. Check your build configuration.`,\n );\n if ((e as any).logfile) {\n console.log('See', chalk.bold((e as any).logfile));\n }\n throw e;\n }\n } else {\n newInfo('Build step is skipped');\n }\n\n if (shouldLaunchPackager(options)) {\n await deploy.startServerInNewWindow(options, verbose);\n }\n\n if (options.deploy) {\n runWindowsPhase = 'Deploy';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx react-native-windows-init\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n try {\n if (options.device || options.emulator || options.target) {\n await deploy.deployToDevice(options, verbose, config);\n } else {\n await deploy.deployToDesktop(options, verbose, config, buildTools);\n }\n } catch (e) {\n newError(`Failed to deploy${e ? `: ${(e as Error).message}` : ''}`);\n throw e;\n }\n } else {\n newInfo('Deploy step is skipped');\n }\n}\n\nfunction shouldLaunchPackager(options: RunWindowsOptions): boolean {\n return (\n options.packager === true &&\n options.launch === true &&\n options.release !== true\n );\n}\n\n/*\n// Example of running the Windows Command\nrunWindows({\n root: 'C:\\\\github\\\\hack\\\\myapp',\n debug: true,\n arch: 'x86',\n nugetPath: 'C:\\\\github\\\\react\\\\react-native-windows\\\\local-cli\\\\runWindows\\\\.nuget\\\\nuget.exe'\n});\n*/\n\n/**\n * Starts the app on a connected Windows emulator or mobile device.\n */\nexport const runWindowsCommand: Command = {\n name: 'run-windows',\n description:\n 'Builds your app and starts it on a connected Windows desktop, emulator or device',\n func: runWindows,\n options: runWindowsOptions,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"runWindows.js","sourceRoot":"","sources":["../../../src/commands/runWindows/runWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AAExB,+DAAsE;AAGtE,yDAA2C;AAC3C,kDAA0B;AAC1B,2DAA6C;AAC7C,yEAKyC;AACzC,mEAIsC;AACtC,qEAAuD;AACvD,uDAAyC;AACzC,4EAAoD;AACpD,2DAAyE;AACzE,wEAA2E;AAG3E;;;;;GAKG;AACH,sCAAsC;AACtC,SAAS,eAAe,CAAC,GAA4B,EAAE,KAAU;IAC/D,kCAAkC;IAClC,2EAA2E;IAC3E,8DAA8D;IAC9D,QAAQ,GAAG,EAAE;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,KAAK,CAAC;QACX,KAAK,MAAM,CAAC;QACZ,KAAK,mBAAmB;YACtB,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;QACzD,KAAK,cAAc;YACjB,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB;QACrF,KAAK,SAAS,CAAC;QACf,KAAK,MAAM,CAAC;QACZ,KAAK,YAAY,CAAC;QAClB,KAAK,UAAU,CAAC;QAChB,KAAK,QAAQ,CAAC;QACd,KAAK,iBAAiB,CAAC;QACvB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QACh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ACvB,OAAO,CAAC,OAAO,KAAK,IAAI,CACzB,CAAC;AACJ,CAAC;AAED;;;;;;;;EAQE;AAEF;;GAEG;AACU,QAAA,iBAAiB,GAAY;IACxC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,kFAAkF;IACpF,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,qCAAiB;CAC3B,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\n\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\nimport {Command, Config} from '@react-native-community/cli-types';\n\nimport * as build from '../../utils/build';\nimport chalk from 'chalk';\nimport * as deploy from '../../utils/deploy';\nimport {\n newError,\n newInfo,\n newWarn,\n setExitProcessWithError,\n} from '../../utils/commandWithProgress';\nimport {\n getDefaultOptions,\n startTelemetrySession,\n endTelemetrySession,\n} from '../../utils/telemetryHelpers';\nimport * as pathHelpers from '../../utils/pathHelpers';\nimport * as info from '../../utils/info';\nimport MSBuildTools from '../../utils/msbuildtools';\nimport {runWindowsOptions, RunWindowsOptions} from './runWindowsOptions';\nimport {autolinkWindowsInternal} from '../autolinkWindows/autolinkWindows';\nimport {AutoLinkOptions} from '../autolinkWindows/autolinkWindowsOptions';\n\n/**\n * Sanitizes the given option for telemetry.\n * @param key The key of the option.\n * @param value The unsanitized value of the option.\n * @returns The sanitized value of the option.\n */\n// eslint-disable-next-line complexity\nfunction optionSanitizer(key: keyof RunWindowsOptions, value: any): any {\n // Do not add a default case here.\n // Strings risking PII should just return true if present, false otherwise.\n // All others should return the value (or false if undefined).\n switch (key) {\n case 'root':\n case 'target':\n case 'sln':\n case 'proj':\n case 'buildLogDirectory':\n return value === undefined ? false : true; // Strip PII\n case 'msbuildprops':\n return 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 `react-native run-windows`.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindows(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n await startTelemetrySession(\n 'run-windows',\n config,\n options,\n getDefaultOptions(config, runWindowsOptions),\n optionSanitizer,\n );\n\n // https://github.com/yarnpkg/yarn/issues/8334 - Yarn on Windows breaks apps that read from the environment variables\n // Yarn will run node via CreateProcess and pass npm_config_* variables in lowercase without unifying their value\n // with their possibly existing uppercase counterparts. This breaks programs that read from the environment block\n // and write to a case-insensitive dictionary since they expect to encounter each variable only once.\n // The values of the lowercase variables are the one npm actually wants to use, plus they are seeded from the\n // uppercase variable values one if there are no overrides.\n delete process.env.NPM_CONFIG_CACHE;\n delete process.env.NPM_CONFIG_PREFIX;\n\n if (process.env.LocalAppData) {\n hasRunRnwDependencies = fs.existsSync(\n path.join(process.env.LocalAppData, 'rnw-dependencies.txt'),\n ); // CODESYNC \\vnext\\scripts\\rnw-dependencies.ps1\n }\n\n let runWindowsError: Error | undefined;\n if (options.info) {\n runWindowsPhase = 'Info';\n try {\n const output = await info.getEnvironmentInfo();\n console.log(output.trimEnd());\n console.log(' Installed UWP SDKs:');\n const sdks = MSBuildTools.getAllAvailableUAPVersions();\n sdks.forEach(version => console.log(' ' + version));\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n newError(\n 'Unable to print environment info.\\n' + runWindowsError.toString(),\n );\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n return;\n }\n\n try {\n await runWindowsInternal(args, config, options);\n } catch (ex) {\n runWindowsError =\n ex instanceof Error ? (ex as Error) : new Error(String(ex));\n Telemetry.trackException(runWindowsError);\n\n if (!hasRunRnwDependencies) {\n const rnwDependenciesPath = path.join(\n pathHelpers.resolveRnwRoot([process.cwd(), __dirname]),\n 'scripts/rnw-dependencies.ps1',\n );\n\n newError(\n `It is possible your installation is missing required software dependencies. Dependencies can be automatically installed by running ${rnwDependenciesPath} from an elevated PowerShell prompt.\\nFor more information, go to http://aka.ms/rnw-deps`,\n );\n }\n }\n await endTelemetrySession(runWindowsError, getExtraProps);\n setExitProcessWithError(options.logging, runWindowsError);\n}\n\n/**\n * Performs build deploy and launch of RNW apps.\n * @param args Unprocessed args passed from react-native CLI.\n * @param config Config passed from react-native CLI.\n * @param options Options passed from react-native CLI.\n */\nasync function runWindowsInternal(\n args: string[],\n config: Config,\n options: RunWindowsOptions,\n) {\n const verbose = options.logging === true;\n\n if (verbose) {\n newInfo('Verbose: ON');\n }\n\n // Get the solution file\n let slnFile: string | null;\n runWindowsPhase = 'FindSolution';\n try {\n slnFile = build.getAppSolutionFile(options, config);\n } catch (e) {\n newError(`Couldn't get app solution information. ${(e as Error).message}`);\n throw e;\n }\n\n let buildTools: MSBuildTools;\n runWindowsPhase = 'FindBuildTools';\n try {\n buildTools = MSBuildTools.findAvailableVersion(options.arch, verbose);\n } catch (error) {\n newWarn('No public VS release found');\n // Try prerelease\n try {\n newInfo('Trying pre-release VS');\n buildTools = MSBuildTools.findAvailableVersion(\n options.arch,\n verbose,\n true, // preRelease\n );\n } catch (e) {\n newError((e as Error).message);\n throw error;\n }\n }\n\n // Set up the callback to capture MSBuild properties after the command completes\n evaluateMSBuildPropsCallback = () => {\n const projectFile = build.getAppProjectFile(options, config);\n if (projectFile) {\n if (verbose) {\n newInfo('Gathering MSBuild data for telemetry.');\n }\n\n const msBuildPropertiesJsonPath = path.resolve(\n path.dirname(projectFile),\n 'Generated Files',\n 'msbuildproperties.g.json',\n );\n\n if (fs.existsSync(msBuildPropertiesJsonPath)) {\n if (verbose) {\n newInfo('Loading properties from msbuildproperties.g.json');\n }\n return fs.readJsonFileSync(msBuildPropertiesJsonPath);\n }\n\n if (verbose) {\n newInfo('Unable to find msbuildproperties.g.json');\n }\n }\n\n return {};\n };\n\n // Restore packages.config files for dependencies that don't support PackageReference.\n runWindowsPhase = 'RestorePackagesConfig';\n const buildType = deploy.getBuildConfiguration(options);\n try {\n await buildTools.restorePackageConfigs(slnFile, options.arch, buildType);\n } catch (e) {\n newError(\n `Couldn't restore found packages.config instances. ${\n (e as Error).message\n }`,\n );\n throw e;\n }\n\n if (options.autolink) {\n runWindowsPhase = 'Autolink';\n try {\n const autolinkArgs: string[] = [];\n const autolinkConfig = config;\n const autolinkOptions: AutoLinkOptions = {\n logging: options.logging,\n check: false,\n proj: options.proj,\n sln: options.sln,\n telemetry: options.telemetry,\n };\n await autolinkWindowsInternal(\n autolinkArgs,\n autolinkConfig,\n autolinkOptions,\n );\n } catch (e) {\n newError(`Autolinking failed. ${(e as Error).message}`);\n throw e;\n }\n } else {\n newInfo('Autolink step is skipped');\n }\n\n if (options.build) {\n runWindowsPhase = 'Build';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx react-native-windows-init\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n // Get build/deploy options\n const msBuildProps = build.parseMsBuildProps(options);\n\n // Disable the autolink check since we just ran it\n msBuildProps.RunAutolinkCheck = 'false';\n\n try {\n await build.buildSolution(\n buildTools,\n slnFile!,\n buildType,\n options.arch,\n msBuildProps,\n verbose,\n 'build',\n options.buildLogDirectory,\n options.singleproc,\n );\n } catch (e) {\n newError(\n `Build failed with message ${\n (e as Error).message\n }. Check your build configuration.`,\n );\n if ((e as any).logfile) {\n console.log('See', chalk.bold((e as any).logfile));\n }\n throw e;\n }\n } else {\n newInfo('Build step is skipped');\n }\n\n if (shouldLaunchPackager(options)) {\n await deploy.startServerInNewWindow(options, verbose);\n }\n\n if (options.deploy) {\n runWindowsPhase = 'Deploy';\n if (!slnFile) {\n newError(\n 'Visual Studio Solution file not found. Maybe run \"npx react-native-windows-init\" first?',\n );\n throw new CodedError('NoSolution', 'Cannot find solution file');\n }\n\n try {\n if (options.device || options.emulator || options.target) {\n await deploy.deployToDevice(options, verbose, config);\n } else {\n await deploy.deployToDesktop(options, verbose, config, buildTools);\n }\n } catch (e) {\n newError(`Failed to deploy${e ? `: ${(e as Error).message}` : ''}`);\n throw e;\n }\n } else {\n newInfo('Deploy step is skipped');\n }\n}\n\nfunction shouldLaunchPackager(options: RunWindowsOptions): boolean {\n return (\n options.packager === true &&\n options.launch === true &&\n options.release !== true\n );\n}\n\n/*\n// Example of running the Windows Command\nrunWindows({\n root: 'C:\\\\github\\\\hack\\\\myapp',\n debug: true,\n arch: 'x86',\n nugetPath: 'C:\\\\github\\\\react\\\\react-native-windows\\\\local-cli\\\\runWindows\\\\.nuget\\\\nuget.exe'\n});\n*/\n\n/**\n * Starts the app on a connected Windows emulator or mobile device.\n */\nexport const runWindowsCommand: Command = {\n name: 'run-windows',\n description:\n 'Builds your app and starts it on a connected Windows desktop, emulator or device',\n func: runWindows,\n options: runWindowsOptions,\n};\n"]}
|
|
@@ -72,11 +72,16 @@ function getAppProjectFile(options, config) {
|
|
|
72
72
|
exports.getAppProjectFile = getAppProjectFile;
|
|
73
73
|
function parseMsBuildProps(options) {
|
|
74
74
|
const result = {};
|
|
75
|
-
if (options.msbuildprops) {
|
|
75
|
+
if (typeof options.msbuildprops === 'string') {
|
|
76
76
|
const props = options.msbuildprops.split(',');
|
|
77
77
|
for (const prop of props) {
|
|
78
78
|
const propAssignment = prop.split('=');
|
|
79
|
-
|
|
79
|
+
if (propAssignment.length === 2 && propAssignment[0].trim().length > 0) {
|
|
80
|
+
result[propAssignment[0].trim()] = propAssignment[1].trim();
|
|
81
|
+
}
|
|
82
|
+
else if (options.logging === true) {
|
|
83
|
+
(0, commandWithProgress_1.newWarn)(`Unable to parse msbuildprop: '${prop}'`);
|
|
84
|
+
}
|
|
80
85
|
}
|
|
81
86
|
}
|
|
82
87
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/utils/build.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gDAAwB;AAExB,kEAA0C;AAC1C,wDAAgC;AAChC,+
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/utils/build.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gDAAwB;AAExB,kEAA0C;AAC1C,wDAAgC;AAChC,+DAAwD;AAOxD,+DAA2D;AAEpD,KAAK,UAAU,aAAa,CACjC,UAAwB,EACxB,OAAe,EACf,SAAsB,EACtB,SAAoB,EACpB,YAAoC,EACpC,OAAgB,EAChB,MAA0B,EAC1B,iBAA0B,EAC1B,UAAoB;IAEpB,MAAM,UAAU,GAAG,IAAI,iBAAO,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAChD,MAAM,WAAW,GAAG,sBAAY,CAAC,0BAA0B,EAAE,CAAC;IAC9D,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,E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gBACtE,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aAC7D;iBAAM,IAAI,OAAO,CAAC,OAAO,KAAK,IAAI,EAAE;gBACnC,IAAA,6BAAO,EAAC,iCAAiC,IAAI,GAAG,CAAC,CAAC;aACnD;SACF;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAhBD,8CAgBC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\n\nimport MSBuildTools from './msbuildtools';\nimport Version from './version';\nimport {newError, newWarn} from './commandWithProgress';\nimport {\n RunWindowsOptions,\n BuildConfig,\n BuildArch,\n} from '../commands/runWindows/runWindowsOptions';\nimport {Config} from '@react-native-community/cli-types';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nexport async function buildSolution(\n buildTools: MSBuildTools,\n slnFile: string,\n buildType: BuildConfig,\n buildArch: BuildArch,\n msBuildProps: Record<string, string>,\n verbose: boolean,\n target: 'build' | 'deploy',\n buildLogDirectory?: string,\n singleproc?: boolean,\n) {\n const minVersion = new Version(10, 0, 22621, 0);\n const allVersions = MSBuildTools.getAllAvailableUAPVersions();\n if (!allVersions.some(v => v.gte(minVersion))) {\n throw new CodedError(\n 'MinSDKVersionNotMet',\n 'Must have a minimum Windows SDK version 10.0.22621.0 installed',\n );\n }\n\n await buildTools.buildProject(\n slnFile,\n buildType,\n buildArch,\n msBuildProps,\n verbose,\n target,\n buildLogDirectory,\n singleproc,\n );\n}\n\nconst configErrorString = 'Error: ';\n\nexport function getAppSolutionFile(options: RunWindowsOptions, config: Config) {\n // Use the solution file if specified\n if (options.sln) {\n return path.join(options.root, options.sln);\n }\n\n // Check the answer from react-native config\n const windowsAppConfig = config.project.windows;\n if (!windowsAppConfig) {\n throw new CodedError(\n 'NoWindowsConfig',\n \"Couldn't determine Windows app config\",\n );\n }\n const configSolutionFile = windowsAppConfig.solutionFile;\n\n if (configSolutionFile.startsWith(configErrorString)) {\n newError(\n configSolutionFile.substr(configErrorString.length) +\n ' Optionally, use --sln {slnFile}.',\n );\n return null;\n } else {\n return path.join(\n windowsAppConfig.folder,\n windowsAppConfig.sourceDir,\n configSolutionFile,\n );\n }\n}\n\nexport function getAppProjectFile(options: RunWindowsOptions, config: Config) {\n // Use the project file if specified\n if (options.proj) {\n return path.join(options.root, options.proj);\n }\n\n // Check the answer from react-native config\n const windowsAppConfig = config.project.windows;\n const configProject = windowsAppConfig.project;\n\n if (\n typeof configProject === 'string' &&\n configProject.startsWith(configErrorString)\n ) {\n newError(\n configProject.substr(configErrorString.length) +\n ' Optionally, use --proj {projFile}.',\n );\n return null;\n } else {\n const configProjectFile = configProject.projectFile;\n if (configProjectFile.startsWith(configErrorString)) {\n newError(\n configProjectFile.substr(configErrorString.length) +\n ' Optionally, use --proj {projFile}.',\n );\n return null;\n }\n return path.join(\n windowsAppConfig.folder,\n windowsAppConfig.sourceDir,\n configProjectFile,\n );\n }\n}\n\nexport function parseMsBuildProps(\n options: RunWindowsOptions,\n): Record<string, string> {\n const result: Record<string, string> = {};\n if (typeof options.msbuildprops === 'string') {\n const props = options.msbuildprops.split(',');\n for (const prop of props) {\n const propAssignment = prop.split('=');\n if (propAssignment.length === 2 && propAssignment[0].trim().length > 0) {\n result[propAssignment[0].trim()] = propAssignment[1].trim();\n } else if (options.logging === true) {\n newWarn(`Unable to parse msbuildprop: '${prop}'`);\n }\n }\n }\n return result;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-windows/cli",
|
|
3
|
-
"version": "0.75.
|
|
3
|
+
"version": "0.75.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"watch": "rnw-scripts watch"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@react-native-windows/codegen": "0.75.
|
|
20
|
+
"@react-native-windows/codegen": "0.75.2",
|
|
21
21
|
"@react-native-windows/fs": "0.75.0",
|
|
22
22
|
"@react-native-windows/package-utils": "0.75.0",
|
|
23
23
|
"@react-native-windows/telemetry": "0.75.1",
|