@react-native-windows/cli 0.68.0 → 0.69.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +0 -2
  2. package/lib-commonjs/config/configUtils.js +19 -0
  3. package/lib-commonjs/config/configUtils.js.map +1 -1
  4. package/lib-commonjs/config/dependencyConfig.js +6 -2
  5. package/lib-commonjs/config/dependencyConfig.js.map +1 -1
  6. package/lib-commonjs/config/projectConfig.js +5 -1
  7. package/lib-commonjs/config/projectConfig.js.map +1 -1
  8. package/lib-commonjs/e2etest/autolink.test.js +14 -63
  9. package/lib-commonjs/e2etest/autolink.test.js.map +1 -1
  10. package/lib-commonjs/e2etest/dependencyConfig.test.js +16 -48
  11. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -1
  12. package/lib-commonjs/e2etest/projectConfig.test.js +21 -33
  13. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -1
  14. package/lib-commonjs/e2etest/projectConfig.utils.d.ts +4 -0
  15. package/lib-commonjs/e2etest/projectConfig.utils.js +45 -10
  16. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -1
  17. package/lib-commonjs/generator-common/index.js +6 -6
  18. package/lib-commonjs/generator-common/index.js.map +1 -1
  19. package/lib-commonjs/generator-windows/index.js +56 -12
  20. package/lib-commonjs/generator-windows/index.js.map +1 -1
  21. package/lib-commonjs/index.js +5 -1
  22. package/lib-commonjs/index.js.map +1 -1
  23. package/lib-commonjs/runWindows/runWindows.js +6 -2
  24. package/lib-commonjs/runWindows/runWindows.js.map +1 -1
  25. package/lib-commonjs/runWindows/runWindowsOptions.js +1 -1
  26. package/lib-commonjs/runWindows/runWindowsOptions.js.map +1 -1
  27. package/lib-commonjs/runWindows/utils/autolink.js +25 -21
  28. package/lib-commonjs/runWindows/utils/autolink.js.map +1 -1
  29. package/lib-commonjs/runWindows/utils/build.js +1 -1
  30. package/lib-commonjs/runWindows/utils/build.js.map +1 -1
  31. package/lib-commonjs/runWindows/utils/checkRequirements.js +1 -1
  32. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +1 -1
  33. package/lib-commonjs/runWindows/utils/commandWithProgress.js +7 -6
  34. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +1 -1
  35. package/lib-commonjs/runWindows/utils/deploy.js +12 -8
  36. package/lib-commonjs/runWindows/utils/deploy.js.map +1 -1
  37. package/lib-commonjs/runWindows/utils/msbuildtools.js +26 -11
  38. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +1 -1
  39. package/lib-commonjs/runWindows/utils/version.js +1 -1
  40. package/lib-commonjs/runWindows/utils/version.js.map +1 -1
  41. package/lib-commonjs/runWindows/utils/vsInstalls.js +1 -1
  42. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +1 -1
  43. package/lib-commonjs/runWindows/utils/vstools.js +3 -3
  44. package/lib-commonjs/runWindows/utils/vstools.js.map +1 -1
  45. package/lib-commonjs/runWindows/utils/winappdeploytool.js +2 -2
  46. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +1 -1
  47. package/package.json +12 -10
@@ -21,7 +21,7 @@ function walk(current) {
21
21
  }
22
22
  const files = fs_1.default
23
23
  .readdirSync(current)
24
- .map((child) => walk(path_1.default.join(current, child)));
24
+ .map(child => walk(path_1.default.join(current, child)));
25
25
  const result = [];
26
26
  return result.concat.apply([current], files);
27
27
  }
@@ -51,12 +51,12 @@ function resolveContents(srcPath, replacements) {
51
51
  }
52
52
  if (replacements.useMustache) {
53
53
  content = mustache_1.default.render(content, replacements);
54
- (replacements.regExpPatternsToRemove || []).forEach((regexPattern) => {
54
+ (replacements.regExpPatternsToRemove || []).forEach(regexPattern => {
55
55
  content = content.replace(new RegExp(regexPattern, 'g'), '');
56
56
  });
57
57
  }
58
58
  else {
59
- Object.keys(replacements).forEach((regex) => {
59
+ Object.keys(replacements).forEach(regex => {
60
60
  content = content.replace(new RegExp(regex, 'g'), replacements[regex]);
61
61
  });
62
62
  }
@@ -109,7 +109,7 @@ async function copyAndReplace(srcPath, destPath, replacements, contentChangedCal
109
109
  shouldOverwrite = await contentChangedCallback(destPath, contentChanged);
110
110
  }
111
111
  if (shouldOverwrite === 'overwrite') {
112
- copyBinaryFile(srcPath, destPath, (err) => {
112
+ copyBinaryFile(srcPath, destPath, err => {
113
113
  if (err) {
114
114
  throw err;
115
115
  }
@@ -157,13 +157,13 @@ function copyBinaryFile(srcPath, destPath, cb) {
157
157
  let cbCalled = false;
158
158
  const srcPermissions = fs_1.default.statSync(srcPath).mode;
159
159
  const readStream = fs_1.default.createReadStream(srcPath);
160
- readStream.on('error', (err) => {
160
+ readStream.on('error', err => {
161
161
  done(err);
162
162
  });
163
163
  const writeStream = fs_1.default.createWriteStream(destPath, {
164
164
  mode: srcPermissions,
165
165
  });
166
- writeStream.on('error', (err) => {
166
+ writeStream.on('error', err => {
167
167
  done(err);
168
168
  });
169
169
  writeStream.on('close', () => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator-common/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kEAA0C;AAC1C,kDAA0B;AAC1B,sDAA8B;AAC9B,gDAAwB;AACxB,wDAAgC;AAChC,+DAA2D;AAW3D,SAAS,IAAI,CAAC,OAAe;IAC3B,IAAI,CAAC,YAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;QACxC,OAAO,CAAC,OAAO,CAAC,CAAC;KAClB;IAED,MAAM,KAAK,GAAG,YAAE;SACb,WAAW,CAAC,OAAO,CAAC;SACpB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACnD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE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C,MAAM,CAC1D,eAAe,CAChB,EAAE,CACJ,CAAC;QACF,OAAO,WAAW,CAAC;KACpB;IACD,IAAI,cAAc,KAAK,WAAW,EAAE;QAClC,OAAO,MAAM,CAAC;KACf;IACD,MAAM,IAAI,sBAAU,CAClB,aAAa,EACb,+BAA+B,gBAAgB,KAAK,cAAc,EAAE,CACrE,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,iCAAiC,CAC9C,mBAA2B,EAC3B,gBAAwB,EACxB,cAA4C;IAE5C,IAAI,cAAc,KAAK,KAAK,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,GAAG,eAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;QACxD,OAAO,WAAW,CAAC;KACpB;IACD,IAAI,cAAc,KAAK,SAAS,EAAE;QAChC,OAAO,CAAC,GAAG,CACT,GAAG,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG;YAChC,6DAA6D,gBAAgB,0BAA0B;YACvG,0FAA0F;YAC1F,qCAAqC,mBAAmB,EAAE,CAC7D,CAAC;QAEF,MAAM,EAAC,aAAa,EAAC,GAAG,MAAM,IAAA,iBAAO,EAAC;YACpC;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,0BAA0B,gBAAgB,GAAG;gBACtD,OAAO,EAAE,KAAK;aACf;SACF,CAAC,CAAC;QAEH,OAAO,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC;KAC7C;IACD,IAAI,cAAc,KAAK,WAAW,EAAE;QAClC,OAAO,MAAM,CAAC;KACf;IACD,MAAM,IAAI,sBAAU,CAClB,aAAa,EACb,+BAA+B,gBAAgB,KAAK,cAAc,EAAE,CACrE,CAAC;AACJ,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 chalk from 'chalk';\nimport prompts from 'prompts';\nimport path from 'path';\nimport mustache from 'mustache';\nimport {CodedError} from '@react-native-windows/telemetry';\n\n/**\n * Text to replace, + config options\n */\nexport type Replacements = {\n useMustache?: boolean;\n regExpPatternsToRemove?: RegExp[];\n [key: string]: any;\n};\n\nfunction walk(current: string): string[] {\n if (!fs.lstatSync(current).isDirectory()) {\n return [current];\n }\n\n const files = fs\n .readdirSync(current)\n .map((child) => walk(path.join(current, child)));\n const result: string[] = [];\n return result.concat.apply([current], files);\n}\n\n/**\n * Get a source file and replace parts of its contents.\n * @param srcPath Path to the source file.\n * @param replacements e.g. {'TextToBeReplaced': 'Replacement'}\n * @return The contents of the file with the replacements applied.\n */\nexport function resolveContents(\n srcPath: string,\n replacements: Replacements,\n): string {\n let content = fs.readFileSync(srcPath, 'utf8');\n\n if (content.includes('\\r\\n')) {\n // CRLF file, make sure multiline replacements are also CRLF\n for (const key of Object.keys(replacements)) {\n if (typeof replacements[key] === 'string') {\n replacements[key] = replacements[key].replace(/(?<!\\r)\\n/g, '\\r\\n');\n }\n }\n } else {\n // LF file, make sure multiline replacements are also LF\n for (const key of Object.keys(replacements)) {\n if (typeof replacements[key] === 'string') {\n replacements[key] = replacements[key].replace(/\\r\\n/g, '\\n');\n }\n }\n }\n\n if (replacements.useMustache) {\n content = mustache.render(content, replacements);\n (replacements.regExpPatternsToRemove || []).forEach((regexPattern) => {\n content = content.replace(new RegExp(regexPattern, 'g'), '');\n });\n } else {\n Object.keys(replacements).forEach((regex) => {\n content = content.replace(new RegExp(regex, 'g'), replacements[regex]);\n });\n }\n return content;\n}\n\n// Binary files, don't process these (avoid decoding as utf8)\nconst binaryExtensions = ['.png', '.jar', '.keystore'];\n\ntype ContentChangedCallbackOption = 'identical' | 'changed' | 'new' | null;\n\ntype ContentChangedCallback = (\n path: string,\n option: ContentChangedCallbackOption,\n) => Promise<'keep' | 'overwrite'>;\n\n/**\n * Copy a file to given destination, replacing parts of its contents.\n * @param srcPath Path to a file to be copied.\n * @param destPath Destination path.\n * @param replacements: e.g. {'TextToBeReplaced': 'Replacement'}\n * @param contentChangedCallback\n * Used when upgrading projects. Based on if file contents would change\n * when being replaced, allows the caller to specify whether the file\n * should be replaced or not.\n * If null, files will be overwritten.\n * Function(path, 'identical' | 'changed' | 'new') => 'keep' | 'overwrite'\n */\nexport async function copyAndReplace(\n srcPath: string,\n destPath: string,\n replacements: Replacements,\n contentChangedCallback: ContentChangedCallback | null,\n) {\n if (fs.lstatSync(srcPath).isDirectory()) {\n if (!fs.existsSync(destPath)) {\n fs.mkdirSync(destPath);\n }\n // Not recursive\n return;\n }\n\n const extension = path.extname(srcPath);\n if (binaryExtensions.includes(extension)) {\n // Binary file\n let shouldOverwrite = 'overwrite';\n if (contentChangedCallback) {\n const newContentBuffer = fs.readFileSync(srcPath);\n let contentChanged: ContentChangedCallbackOption = 'identical';\n try {\n const origContentBuffer = fs.readFileSync(destPath);\n if (Buffer.compare(origContentBuffer, newContentBuffer) !== 0) {\n contentChanged = 'changed';\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n contentChanged = 'new';\n } else {\n throw err;\n }\n }\n shouldOverwrite = await contentChangedCallback(destPath, contentChanged);\n }\n if (shouldOverwrite === 'overwrite') {\n copyBinaryFile(srcPath, destPath, (err) => {\n if (err) {\n throw err;\n }\n });\n }\n } else {\n // Text file\n const srcPermissions = fs.statSync(srcPath).mode;\n const content = resolveContents(srcPath, replacements);\n\n let shouldOverwrite = 'overwrite';\n if (contentChangedCallback) {\n // Check if contents changed and ask to overwrite\n let contentChanged: ContentChangedCallbackOption = 'identical';\n try {\n const origContent = fs.readFileSync(destPath, 'utf8');\n if (content !== origContent) {\n // logger.info('Content changed: ' + destPath);\n contentChanged = 'changed';\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n contentChanged = 'new';\n } else {\n throw err;\n }\n }\n shouldOverwrite = await contentChangedCallback(destPath, contentChanged);\n }\n if (shouldOverwrite === 'overwrite') {\n fs.writeFileSync(destPath, content, {\n encoding: 'utf8',\n mode: srcPermissions,\n });\n }\n }\n}\n\n/**\n * Same as 'cp' on Unix. Don't do any replacements.\n */\nfunction copyBinaryFile(\n srcPath: string,\n destPath: string,\n cb: (err?: Error) => void,\n) {\n let cbCalled = false;\n const srcPermissions = fs.statSync(srcPath).mode;\n const readStream = fs.createReadStream(srcPath);\n readStream.on('error', (err) => {\n done(err);\n });\n const writeStream = fs.createWriteStream(destPath, {\n mode: srcPermissions,\n });\n writeStream.on('error', (err) => {\n done(err);\n });\n writeStream.on('close', () => {\n done();\n });\n readStream.pipe(writeStream);\n function done(err?: Error) {\n if (!cbCalled) {\n cb(err);\n cbCalled = true;\n }\n }\n}\n\nexport function createDir(destPath: string) {\n if (!fs.existsSync(destPath)) {\n fs.mkdirSync(destPath);\n }\n}\n\nexport async function copyAndReplaceWithChangedCallback(\n srcPath: string,\n destRoot: string,\n relativeDestPath: string,\n replacements?: Record<string, string>,\n alwaysOverwrite?: boolean,\n) {\n if (!replacements) {\n replacements = {};\n }\n const contentChangedCallback: ContentChangedCallback = alwaysOverwrite\n ? (_, contentChanged) =>\n alwaysOverwriteContentChangedCallback(\n srcPath,\n relativeDestPath,\n contentChanged,\n )\n : (_, contentChanged) =>\n upgradeFileContentChangedCallback(\n srcPath,\n relativeDestPath,\n contentChanged,\n );\n\n await copyAndReplace(\n srcPath,\n path.join(destRoot, relativeDestPath),\n replacements,\n contentChangedCallback,\n );\n}\n\nexport async function copyAndReplaceAll(\n srcPath: string,\n destPath: string,\n relativeDestDir: string,\n replacements: Replacements,\n alwaysOverwrite: boolean,\n) {\n for (const absoluteSrcFilePath of walk(srcPath)) {\n const filename = path.relative(srcPath, absoluteSrcFilePath);\n const relativeDestPath = path.join(relativeDestDir, filename);\n await copyAndReplaceWithChangedCallback(\n absoluteSrcFilePath,\n destPath,\n relativeDestPath,\n replacements,\n alwaysOverwrite,\n );\n }\n}\n\nasync function alwaysOverwriteContentChangedCallback(\n absoluteSrcFilePath: string,\n relativeDestPath: string,\n contentChanged: ContentChangedCallbackOption,\n): Promise<'keep' | 'overwrite'> {\n if (contentChanged === 'new') {\n console.log(`${chalk.bold('new')} ${relativeDestPath}`);\n return 'overwrite';\n }\n if (contentChanged === 'changed') {\n console.log(\n `${chalk.bold('changed')} ${relativeDestPath} ${chalk.yellow(\n '[overwriting]',\n )}`,\n );\n return 'overwrite';\n }\n if (contentChanged === 'identical') {\n return 'keep';\n }\n throw new CodedError(\n 'Autolinking',\n `Unknown file changed state: ${relativeDestPath}, ${contentChanged}`,\n );\n}\n\nasync function upgradeFileContentChangedCallback(\n absoluteSrcFilePath: string,\n relativeDestPath: string,\n contentChanged: ContentChangedCallbackOption,\n): Promise<'keep' | 'overwrite'> {\n if (contentChanged === 'new') {\n console.log(`${chalk.bold('new')} ${relativeDestPath}`);\n return 'overwrite';\n }\n if (contentChanged === 'changed') {\n console.log(\n `${chalk.bold(relativeDestPath)} ` +\n `has changed in the new version.\\nDo you want to keep your ${relativeDestPath} or replace it with the ` +\n 'latest version?\\nMake sure you have any changes you made to this file saved somewhere.\\n' +\n `You can see the new version here: ${absoluteSrcFilePath}`,\n );\n\n const {shouldReplace} = await prompts([\n {\n name: 'shouldReplace',\n type: 'confirm',\n message: `Do you want to replace ${relativeDestPath}?`,\n initial: false,\n },\n ]);\n\n return shouldReplace ? 'overwrite' : 'keep';\n }\n if (contentChanged === 'identical') {\n return 'keep';\n }\n throw new CodedError(\n 'Autolinking',\n `Unknown file changed state: ${relativeDestPath}, ${contentChanged}`,\n );\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator-common/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kEAA0C;AAC1C,kDAA0B;AAC1B,sDAA8B;AAC9B,gDAAwB;AACxB,wDAAgC;AAChC,+DAA2D;AAW3D,SAAS,IAAI,CAAC,OAAe;IAC3B,IAAI,CAAC,YAAE,CAAC,SAAS,CAA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AAO,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC;KAC7C;IACD,IAAI,cAAc,KAAK,WAAW,EAAE;QAClC,OAAO,MAAM,CAAC;KACf;IACD,MAAM,IAAI,sBAAU,CAClB,aAAa,EACb,+BAA+B,gBAAgB,KAAK,cAAc,EAAE,CACrE,CAAC;AACJ,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 chalk from 'chalk';\nimport prompts from 'prompts';\nimport path from 'path';\nimport mustache from 'mustache';\nimport {CodedError} from '@react-native-windows/telemetry';\n\n/**\n * Text to replace, + config options\n */\nexport type Replacements = {\n useMustache?: boolean;\n regExpPatternsToRemove?: RegExp[];\n [key: string]: any;\n};\n\nfunction walk(current: string): string[] {\n if (!fs.lstatSync(current).isDirectory()) {\n return [current];\n }\n\n const files = fs\n .readdirSync(current)\n .map(child => walk(path.join(current, child)));\n const result: string[] = [];\n return result.concat.apply([current], files);\n}\n\n/**\n * Get a source file and replace parts of its contents.\n * @param srcPath Path to the source file.\n * @param replacements e.g. {'TextToBeReplaced': 'Replacement'}\n * @return The contents of the file with the replacements applied.\n */\nexport function resolveContents(\n srcPath: string,\n replacements: Replacements,\n): string {\n let content = fs.readFileSync(srcPath, 'utf8');\n\n if (content.includes('\\r\\n')) {\n // CRLF file, make sure multiline replacements are also CRLF\n for (const key of Object.keys(replacements)) {\n if (typeof replacements[key] === 'string') {\n replacements[key] = replacements[key].replace(/(?<!\\r)\\n/g, '\\r\\n');\n }\n }\n } else {\n // LF file, make sure multiline replacements are also LF\n for (const key of Object.keys(replacements)) {\n if (typeof replacements[key] === 'string') {\n replacements[key] = replacements[key].replace(/\\r\\n/g, '\\n');\n }\n }\n }\n\n if (replacements.useMustache) {\n content = mustache.render(content, replacements);\n (replacements.regExpPatternsToRemove || []).forEach(regexPattern => {\n content = content.replace(new RegExp(regexPattern, 'g'), '');\n });\n } else {\n Object.keys(replacements).forEach(regex => {\n content = content.replace(new RegExp(regex, 'g'), replacements[regex]);\n });\n }\n return content;\n}\n\n// Binary files, don't process these (avoid decoding as utf8)\nconst binaryExtensions = ['.png', '.jar', '.keystore'];\n\ntype ContentChangedCallbackOption = 'identical' | 'changed' | 'new' | null;\n\ntype ContentChangedCallback = (\n path: string,\n option: ContentChangedCallbackOption,\n) => Promise<'keep' | 'overwrite'>;\n\n/**\n * Copy a file to given destination, replacing parts of its contents.\n * @param srcPath Path to a file to be copied.\n * @param destPath Destination path.\n * @param replacements: e.g. {'TextToBeReplaced': 'Replacement'}\n * @param contentChangedCallback\n * Used when upgrading projects. Based on if file contents would change\n * when being replaced, allows the caller to specify whether the file\n * should be replaced or not.\n * If null, files will be overwritten.\n * Function(path, 'identical' | 'changed' | 'new') => 'keep' | 'overwrite'\n */\nexport async function copyAndReplace(\n srcPath: string,\n destPath: string,\n replacements: Replacements,\n contentChangedCallback: ContentChangedCallback | null,\n) {\n if (fs.lstatSync(srcPath).isDirectory()) {\n if (!fs.existsSync(destPath)) {\n fs.mkdirSync(destPath);\n }\n // Not recursive\n return;\n }\n\n const extension = path.extname(srcPath);\n if (binaryExtensions.includes(extension)) {\n // Binary file\n let shouldOverwrite = 'overwrite';\n if (contentChangedCallback) {\n const newContentBuffer = fs.readFileSync(srcPath);\n let contentChanged: ContentChangedCallbackOption = 'identical';\n try {\n const origContentBuffer = fs.readFileSync(destPath);\n if (Buffer.compare(origContentBuffer, newContentBuffer) !== 0) {\n contentChanged = 'changed';\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n contentChanged = 'new';\n } else {\n throw err;\n }\n }\n shouldOverwrite = await contentChangedCallback(destPath, contentChanged);\n }\n if (shouldOverwrite === 'overwrite') {\n copyBinaryFile(srcPath, destPath, err => {\n if (err) {\n throw err;\n }\n });\n }\n } else {\n // Text file\n const srcPermissions = fs.statSync(srcPath).mode;\n const content = resolveContents(srcPath, replacements);\n\n let shouldOverwrite = 'overwrite';\n if (contentChangedCallback) {\n // Check if contents changed and ask to overwrite\n let contentChanged: ContentChangedCallbackOption = 'identical';\n try {\n const origContent = fs.readFileSync(destPath, 'utf8');\n if (content !== origContent) {\n // logger.info('Content changed: ' + destPath);\n contentChanged = 'changed';\n }\n } catch (err) {\n if ((err as NodeJS.ErrnoException).code === 'ENOENT') {\n contentChanged = 'new';\n } else {\n throw err;\n }\n }\n shouldOverwrite = await contentChangedCallback(destPath, contentChanged);\n }\n if (shouldOverwrite === 'overwrite') {\n fs.writeFileSync(destPath, content, {\n encoding: 'utf8',\n mode: srcPermissions,\n });\n }\n }\n}\n\n/**\n * Same as 'cp' on Unix. Don't do any replacements.\n */\nfunction copyBinaryFile(\n srcPath: string,\n destPath: string,\n cb: (err?: Error) => void,\n) {\n let cbCalled = false;\n const srcPermissions = fs.statSync(srcPath).mode;\n const readStream = fs.createReadStream(srcPath);\n readStream.on('error', err => {\n done(err);\n });\n const writeStream = fs.createWriteStream(destPath, {\n mode: srcPermissions,\n });\n writeStream.on('error', err => {\n done(err);\n });\n writeStream.on('close', () => {\n done();\n });\n readStream.pipe(writeStream);\n function done(err?: Error) {\n if (!cbCalled) {\n cb(err);\n cbCalled = true;\n }\n }\n}\n\nexport function createDir(destPath: string) {\n if (!fs.existsSync(destPath)) {\n fs.mkdirSync(destPath);\n }\n}\n\nexport async function copyAndReplaceWithChangedCallback(\n srcPath: string,\n destRoot: string,\n relativeDestPath: string,\n replacements?: Record<string, string>,\n alwaysOverwrite?: boolean,\n) {\n if (!replacements) {\n replacements = {};\n }\n const contentChangedCallback: ContentChangedCallback = alwaysOverwrite\n ? (_, contentChanged) =>\n alwaysOverwriteContentChangedCallback(\n srcPath,\n relativeDestPath,\n contentChanged,\n )\n : (_, contentChanged) =>\n upgradeFileContentChangedCallback(\n srcPath,\n relativeDestPath,\n contentChanged,\n );\n\n await copyAndReplace(\n srcPath,\n path.join(destRoot, relativeDestPath),\n replacements,\n contentChangedCallback,\n );\n}\n\nexport async function copyAndReplaceAll(\n srcPath: string,\n destPath: string,\n relativeDestDir: string,\n replacements: Replacements,\n alwaysOverwrite: boolean,\n) {\n for (const absoluteSrcFilePath of walk(srcPath)) {\n const filename = path.relative(srcPath, absoluteSrcFilePath);\n const relativeDestPath = path.join(relativeDestDir, filename);\n await copyAndReplaceWithChangedCallback(\n absoluteSrcFilePath,\n destPath,\n relativeDestPath,\n replacements,\n alwaysOverwrite,\n );\n }\n}\n\nasync function alwaysOverwriteContentChangedCallback(\n absoluteSrcFilePath: string,\n relativeDestPath: string,\n contentChanged: ContentChangedCallbackOption,\n): Promise<'keep' | 'overwrite'> {\n if (contentChanged === 'new') {\n console.log(`${chalk.bold('new')} ${relativeDestPath}`);\n return 'overwrite';\n }\n if (contentChanged === 'changed') {\n console.log(\n `${chalk.bold('changed')} ${relativeDestPath} ${chalk.yellow(\n '[overwriting]',\n )}`,\n );\n return 'overwrite';\n }\n if (contentChanged === 'identical') {\n return 'keep';\n }\n throw new CodedError(\n 'Autolinking',\n `Unknown file changed state: ${relativeDestPath}, ${contentChanged}`,\n );\n}\n\nasync function upgradeFileContentChangedCallback(\n absoluteSrcFilePath: string,\n relativeDestPath: string,\n contentChanged: ContentChangedCallbackOption,\n): Promise<'keep' | 'overwrite'> {\n if (contentChanged === 'new') {\n console.log(`${chalk.bold('new')} ${relativeDestPath}`);\n return 'overwrite';\n }\n if (contentChanged === 'changed') {\n console.log(\n `${chalk.bold(relativeDestPath)} ` +\n `has changed in the new version.\\nDo you want to keep your ${relativeDestPath} or replace it with the ` +\n 'latest version?\\nMake sure you have any changes you made to this file saved somewhere.\\n' +\n `You can see the new version here: ${absoluteSrcFilePath}`,\n );\n\n const {shouldReplace} = await prompts([\n {\n name: 'shouldReplace',\n type: 'confirm',\n message: `Do you want to replace ${relativeDestPath}?`,\n initial: false,\n },\n ]);\n\n return shouldReplace ? 'overwrite' : 'keep';\n }\n if (contentChanged === 'identical') {\n return 'keep';\n }\n throw new CodedError(\n 'Autolinking',\n `Unknown file changed state: ${relativeDestPath}, ${contentChanged}`,\n );\n}\n"]}
@@ -18,6 +18,7 @@ const fs_1 = __importDefault(require("@react-native-windows/fs"));
18
18
  const semver_1 = __importDefault(require("semver"));
19
19
  const lodash_1 = __importDefault(require("lodash"));
20
20
  const find_up_1 = __importDefault(require("find-up"));
21
+ const configUtils_1 = require("../config/configUtils");
21
22
  const generator_common_1 = require("../generator-common");
22
23
  const telemetry_1 = require("@react-native-windows/telemetry");
23
24
  const package_utils_1 = require("@react-native-windows/package-utils");
@@ -45,6 +46,7 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
45
46
  throw new telemetry_1.CodedError('CopyProjectTemplateNoProjectName', 'Need a project name');
46
47
  }
47
48
  const projectType = options.projectType;
49
+ const language = options.language;
48
50
  // React-native init only allows alphanumerics in project names, but other
49
51
  // new project tools (like create-react-native-module) are less strict.
50
52
  if (projectType === 'lib') {
@@ -54,24 +56,42 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
54
56
  if (projectType === 'lib') {
55
57
  namespace = namespace.split(/[.:]+/).map(pascalCase).join('.');
56
58
  }
59
+ // Checking if we're overwriting an existing project and re-uses their projectGUID
60
+ const existingProjectPath = path_1.default.join(destPath, windowsDir, newProjectName, newProjectName + (language === 'cs' ? '.csproj' : '.vcxproj'));
61
+ let existingProjectGuid;
62
+ if (fs_1.default.existsSync(existingProjectPath)) {
63
+ console.log('Found existing project, extracting ProjectGuid.');
64
+ existingProjectGuid = (0, configUtils_1.findPropertyValue)((0, configUtils_1.readProjectFile)(existingProjectPath), 'ProjectGuid', existingProjectPath).replace(/[{}]/g, '');
65
+ }
57
66
  (0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir));
58
67
  (0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName));
59
68
  if (projectType === 'app') {
60
69
  (0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName, bundleDir));
61
70
  (0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName, 'BundleBuilder'));
62
71
  }
63
- const language = options.language;
64
72
  const namespaceCpp = toCppNamespace(namespace);
65
73
  if (options.experimentalNuGetDependency) {
66
74
  console.log('Using experimental NuGet dependency.');
67
75
  }
76
+ let realProjectType = projectType;
68
77
  if (options.useWinUI3) {
69
78
  console.log('Using experimental WinUI3 dependency.');
79
+ if (projectType === 'lib') {
80
+ throw new telemetry_1.CodedError('IncompatibleOptions', 'WinUI 3 project template only supports apps at the moment', {
81
+ detail: 'useWinUI3 and lib',
82
+ });
83
+ }
84
+ else if (language !== 'cs') {
85
+ throw new telemetry_1.CodedError('IncompatibleOptions', 'WinUI 3 project template only support C# at the moment', {
86
+ detail: 'useWinUI3 and cpp',
87
+ });
88
+ }
89
+ realProjectType += '-WinAppSDK';
70
90
  }
71
91
  const projDir = 'proj';
72
- const srcPath = path_1.default.join(srcRootPath, `${language}-${projectType}`);
92
+ const srcPath = path_1.default.join(srcRootPath, `${language}-${realProjectType}`);
73
93
  const sharedPath = path_1.default.join(srcRootPath, `shared-${projectType}`);
74
- const projectGuid = uuid_1.default.v4();
94
+ const projectGuid = existingProjectGuid || uuid_1.default.v4();
75
95
  const rnwVersion = require(resolveRnwPath('package.json')).version;
76
96
  const nugetVersion = options.nuGetTestVersion || rnwVersion;
77
97
  const packageGuid = uuid_1.default.v4();
@@ -82,12 +102,9 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
82
102
  const appJson = await fs_1.default.readJsonFile(appJsonPath);
83
103
  mainComponentName = appJson.name;
84
104
  }
85
- const csNugetPackages = [
86
- {
87
- id: 'Microsoft.NETCore.UniversalWindowsPlatform',
88
- version: '6.2.9',
89
- },
90
- ];
105
+ const csNugetPackages = options.useWinUI3
106
+ ? getWinAppSDKPackages(nugetVersion)
107
+ : getUwpCsPackages();
91
108
  const cppNugetPackages = [
92
109
  {
93
110
  id: 'Microsoft.Windows.CppWinRT',
@@ -241,9 +258,16 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
241
258
  if (fs_1.default.existsSync(path_1.default.join(sharedPath, 'assets'))) {
242
259
  await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(sharedPath, 'assets'), destPath, path_1.default.join(windowsDir, newProjectName, 'Assets'), templateVars, options.overwrite);
243
260
  }
244
- // shared src
245
- if (fs_1.default.existsSync(path_1.default.join(sharedPath, 'src'))) {
246
- await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(sharedPath, 'src'), destPath, path_1.default.join(windowsDir, newProjectName), templateVars, options.overwrite);
261
+ if (!options.useWinUI3) {
262
+ // shared src
263
+ if (fs_1.default.existsSync(path_1.default.join(sharedPath, 'src'))) {
264
+ await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(sharedPath, 'src'), destPath, path_1.default.join(windowsDir, newProjectName), templateVars, options.overwrite);
265
+ }
266
+ }
267
+ else {
268
+ if (fs_1.default.existsSync(path_1.default.join(srcPath, 'MyApp'))) {
269
+ await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(srcPath, 'MyApp'), destPath, path_1.default.join(windowsDir, newProjectName), templateVars, options.overwrite);
270
+ }
247
271
  }
248
272
  // src
249
273
  if (fs_1.default.existsSync(path_1.default.join(srcPath, 'src'))) {
@@ -255,6 +279,14 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
255
279
  }
256
280
  }
257
281
  exports.copyProjectTemplateAndReplace = copyProjectTemplateAndReplace;
282
+ function getUwpCsPackages() {
283
+ return [
284
+ {
285
+ id: 'Microsoft.NETCore.UniversalWindowsPlatform',
286
+ version: '6.2.9',
287
+ },
288
+ ];
289
+ }
258
290
  function toCppNamespace(namespace) {
259
291
  return namespace.replace(/\./g, '::');
260
292
  }
@@ -305,4 +337,16 @@ async function installScriptsAndDependencies(options) {
305
337
  }
306
338
  }
307
339
  exports.installScriptsAndDependencies = installScriptsAndDependencies;
340
+ function getWinAppSDKPackages(nugetVersion) {
341
+ const winAppSDKPackages = [];
342
+ winAppSDKPackages.push({
343
+ id: 'Microsoft.ReactNative.WindowsAppSDK',
344
+ version: nugetVersion,
345
+ });
346
+ winAppSDKPackages.push({
347
+ id: 'Microsoft.WindowsAppSDK',
348
+ version: '1.0.0',
349
+ });
350
+ return winAppSDKPackages;
351
+ }
308
352
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator-windows/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kDAA0B;AAC1B,gDAAwB;AACxB,wDAAgC;AAChC,gDAAwB;AACxB,kEAAyC;AACzC,kEAA0C;AAC1C,oDAA4B;AAC5B,oDAAuB;AACvB,sDAA6B;AAE7B,0DAI6B;AAE7B,+DAGyC;AACzC,uEAG6C;AAE7C,MAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,MAAM,SAAS,GAAG,QAAQ,CAAC;AAU3B,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,SAAS,GAAG,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,cAAc,CAAC,OAAe;IACrC,OAAO,OAAO,CAAC,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC,EAAE;QACjE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;KACvB,CAAC,CAAC;AACL,CAAC;AAED,sCAAsC;AACtC,sCAAsC;AAC/B,KAAK,UAAU,6BAA6B,CACjD,WAAmB,EACnB,QAAgB,EAChB,cAAsB,EACtB,SAAiB,EACjB,OAAwB;IAExB,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,sBAAU,CAClB,iCAAiC,EACjC,0BAA0B,CAC3B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c,CAAC,UAAU,CAAC;YAC9B,eAAe,EAAE;gBACf,cAAc,EAAE,IAAI,kBAAkB,CAAC,IAAI,CAAC,OAAO,EAAE;aACtD;SACF,CAAC,CAAC;KACJ;IAED,MAAM,gBAAgB,GAAG,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAE1E,IACE,CAAC,gBAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC;SAC3D,MAAA,cAAc,CAAC,IAAI,CAAC,YAAY,0CAAG,cAAc,CAAC,CAAA,EAClD;QACA,OAAO,CAAC,GAAG,CACT,eAAK,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAChE,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,OAAO,gBAAgB,EAAE,CAAC,CAAC,CAAC;QAEpD,qEAAqE;QACrE,MAAM,cAAc,CAAC,UAAU,CAAC;YAC9B,YAAY,EAAE,EAAC,cAAc,EAAE,gBAAgB,EAAC;SACjD,CAAC,CAAC;QAEH,qDAAqD;QACrD,MAAM,MAAM,GAAG,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;QACpE,uBAAY,CAAC,QAAQ,CACnB,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EACzB,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAC,KAAK,EAAE,SAAS,EAAC,CAAC,CAAC,CAAC,EAAE,CAC1C,CAAC;KACH;AACH,CAAC;AAhED,sEAgEC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport chalk from 'chalk';\nimport path from 'path';\nimport username from 'username';\nimport uuid from 'uuid';\nimport childProcess from 'child_process';\nimport fs from '@react-native-windows/fs';\nimport semver from 'semver';\nimport _ from 'lodash';\nimport findUp from 'find-up';\n\nimport {\n createDir,\n copyAndReplaceAll,\n copyAndReplaceWithChangedCallback,\n} from '../generator-common';\nimport {GenerateOptions} from '..';\nimport {\n CodedError,\n getVersionOfNpmPackage,\n} from '@react-native-windows/telemetry';\nimport {\n findPackage,\n WritableNpmPackage,\n} from '@react-native-windows/package-utils';\n\nconst windowsDir = 'windows';\nconst bundleDir = 'Bundle';\n\n/**\n * This represents the data to insert nuget packages\n */\ninterface NugetPackage {\n id: string;\n version: string;\n}\n\nfunction pascalCase(str: string) {\n const camelCase = _.camelCase(str);\n return camelCase[0].toUpperCase() + camelCase.substr(1);\n}\n\nfunction resolveRnwPath(subpath: string): string {\n return require.resolve(path.join('react-native-windows', subpath), {\n paths: [process.cwd()],\n });\n}\n\n// Existing high cyclomatic complexity\n// eslint-disable-next-line complexity\nexport async function copyProjectTemplateAndReplace(\n srcRootPath: string,\n destPath: string,\n newProjectName: string,\n namespace: string,\n options: GenerateOptions,\n) {\n if (!srcRootPath) {\n throw new CodedError(\n 'CopyProjectTemplateNoSourcePath',\n 'Need a path to copy from',\n );\n }\n\n if (!destPath) {\n throw new CodedError(\n 'CopyProjectTemplateNoDestPath',\n 'Need a path to copy to',\n );\n }\n\n if (!newProjectName) {\n throw new CodedError(\n 'CopyProjectTemplateNoProjectName',\n 'Need a project name',\n );\n }\n\n const projectType = options.projectType;\n\n // React-native init only allows alphanumerics in project names, but other\n // new project tools (like create-react-native-module) are less strict.\n if (projectType === 'lib') {\n newProjectName = pascalCase(newProjectName);\n }\n\n // Similar to the above, but we want to retain namespace separators\n if (projectType === 'lib') {\n namespace = namespace.split(/[.:]+/).map(pascalCase).join('.');\n }\n\n createDir(path.join(destPath, windowsDir));\n createDir(path.join(destPath, windowsDir, newProjectName));\n\n if (projectType === 'app') {\n createDir(path.join(destPath, windowsDir, newProjectName, bundleDir));\n createDir(path.join(destPath, windowsDir, newProjectName, 'BundleBuilder'));\n }\n\n const language = options.language;\n const namespaceCpp = toCppNamespace(namespace);\n if (options.experimentalNuGetDependency) {\n console.log('Using experimental NuGet dependency.');\n }\n if (options.useWinUI3) {\n console.log('Using experimental WinUI3 dependency.');\n }\n const projDir = 'proj';\n const srcPath = path.join(srcRootPath, `${language}-${projectType}`);\n const sharedPath = path.join(srcRootPath, `shared-${projectType}`);\n const projectGuid = uuid.v4();\n const rnwVersion = require(resolveRnwPath('package.json')).version;\n const nugetVersion = options.nuGetTestVersion || rnwVersion;\n const packageGuid = uuid.v4();\n const currentUser = username.sync()!; // Gets the current username depending on the platform.\n\n let mainComponentName = newProjectName;\n const appJsonPath = await findUp('app.json', {cwd: destPath});\n if (appJsonPath) {\n const appJson = await fs.readJsonFile<{name: string}>(appJsonPath);\n mainComponentName = appJson.name;\n }\n\n const csNugetPackages: NugetPackage[] = [\n {\n id: 'Microsoft.NETCore.UniversalWindowsPlatform',\n version: '6.2.9',\n },\n ];\n\n const cppNugetPackages: NugetPackage[] = [\n {\n id: 'Microsoft.Windows.CppWinRT',\n version: '2.0.211028.7',\n },\n ];\n\n const templateVars: Record<string, any> = {\n useMustache: true,\n regExpPatternsToRemove: [],\n\n name: newProjectName,\n namespace: namespace,\n namespaceCpp: namespaceCpp,\n languageIsCpp: language === 'cpp',\n\n rnwVersion: await getVersionOfNpmPackage('react-native-windows'),\n\n mainComponentName: mainComponentName,\n\n // Visual Studio is very picky about the casing of the guids for projects, project references and the solution\n // https://www.bing.com/search?q=visual+studio+project+guid+casing&cvid=311a5ad7f9fc41089507b24600d23ee7&FORM=ANAB01&PC=U531\n // we therefore have to precariously use the right casing in the right place or risk building in VS breaking.\n projectGuidLower: `{${projectGuid.toLowerCase()}}`,\n projectGuidUpper: `{${projectGuid.toUpperCase()}}`,\n\n // packaging and signing variables:\n packageGuid: packageGuid,\n currentUser: currentUser,\n\n useExperimentalNuget: options.experimentalNuGetDependency,\n nuGetTestFeed: options.nuGetTestFeed,\n nuGetADOFeed: nugetVersion.startsWith('0.0.0-'),\n\n // cpp template variables\n useWinUI3: options.useWinUI3,\n useHermes: options.useHermes,\n cppNugetPackages: cppNugetPackages,\n\n // cs template variables\n csNugetPackages: csNugetPackages,\n\n // autolinking template variables\n autolinkPropertiesForProps: '',\n autolinkProjectReferencesForTargets: '',\n autolinkCsUsingNamespaces: '',\n autolinkCsReactPackageProviders: '',\n autolinkCppIncludes: '',\n autolinkCppPackageProviders:\n '\\n UNREFERENCED_PARAMETER(packageProviders);', // CODESYNC: vnext\\local-cli\\runWindows\\utils\\autolink.js\n };\n\n const commonMappings =\n projectType === 'app'\n ? [\n // app common mappings\n {\n from: path.join(\n srcRootPath,\n options.useDevMode\n ? 'metro.devMode.config.js'\n : 'metro.config.js',\n ),\n to: 'metro.config.js',\n },\n {\n from: path.join(srcRootPath, '_gitignore'),\n to: path.join(windowsDir, '.gitignore'),\n },\n {\n from: path.join(srcRootPath, 'b_gitignore'),\n to: path.join(windowsDir, newProjectName, '.gitignore'),\n },\n {\n from: path.join(srcRootPath, 'index.windows.bundle'),\n to: path.join(\n windowsDir,\n newProjectName,\n bundleDir,\n 'index.windows.bundle',\n ),\n },\n {\n from: path.join(srcPath, projDir, 'MyApp.sln'),\n to: path.join(windowsDir, newProjectName + '.sln'),\n },\n ]\n : [\n // lib common mappings\n {\n from: path.join(srcRootPath, '_gitignore'),\n to: path.join(windowsDir, '.gitignore'),\n },\n {\n from: path.join(srcPath, projDir, 'MyLib.sln'),\n to: path.join(windowsDir, newProjectName + '.sln'),\n },\n ];\n\n for (const mapping of commonMappings) {\n await copyAndReplaceWithChangedCallback(\n mapping.from,\n destPath,\n mapping.to,\n templateVars,\n options.overwrite,\n );\n }\n\n if (language === 'cs') {\n const csMappings =\n projectType === 'app'\n ? [\n // cs app mappings\n {\n from: path.join(srcPath, projDir, 'MyApp.csproj'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.csproj',\n ),\n },\n ]\n : [\n // cs lib mappings\n {\n from: path.join(srcPath, projDir, 'MyLib.csproj'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.csproj',\n ),\n },\n ];\n\n for (const mapping of csMappings) {\n await copyAndReplaceWithChangedCallback(\n mapping.from,\n destPath,\n mapping.to,\n templateVars,\n options.overwrite,\n );\n }\n } else {\n const cppMappings =\n projectType === 'app'\n ? [\n // cpp app mappings\n {\n from: path.join(srcPath, projDir, 'MyApp.vcxproj'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.vcxproj',\n ),\n },\n {\n from: path.join(srcPath, projDir, 'MyApp.vcxproj.filters'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.vcxproj.filters',\n ),\n },\n ]\n : [\n // cpp lib mappings\n {\n from: path.join(srcPath, projDir, 'MyLib.vcxproj'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.vcxproj',\n ),\n },\n {\n from: path.join(srcPath, projDir, 'MyLib.vcxproj.filters'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.vcxproj.filters',\n ),\n },\n {\n from: path.join(srcPath, projDir, 'MyLib.def'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.def',\n ),\n },\n ];\n\n for (const mapping of cppMappings) {\n await copyAndReplaceWithChangedCallback(\n mapping.from,\n destPath,\n mapping.to,\n templateVars,\n options.overwrite,\n );\n }\n }\n\n // shared proj\n if (fs.existsSync(path.join(sharedPath, projDir))) {\n const sharedProjMappings = [];\n\n sharedProjMappings.push({\n from: path.join(sharedPath, projDir, 'NuGet.Config'),\n to: path.join(windowsDir, 'NuGet.Config'),\n });\n\n if (\n fs.existsSync(\n path.join(sharedPath, projDir, 'ExperimentalFeatures.props'),\n )\n ) {\n sharedProjMappings.push({\n from: path.join(sharedPath, projDir, 'ExperimentalFeatures.props'),\n to: path.join(windowsDir, 'ExperimentalFeatures.props'),\n });\n }\n\n for (const mapping of sharedProjMappings) {\n await copyAndReplaceWithChangedCallback(\n mapping.from,\n destPath,\n mapping.to,\n templateVars,\n options.overwrite,\n );\n }\n }\n\n // shared assets\n if (fs.existsSync(path.join(sharedPath, 'assets'))) {\n await copyAndReplaceAll(\n path.join(sharedPath, 'assets'),\n destPath,\n path.join(windowsDir, newProjectName, 'Assets'),\n templateVars,\n options.overwrite,\n );\n }\n\n // shared src\n if (fs.existsSync(path.join(sharedPath, 'src'))) {\n await copyAndReplaceAll(\n path.join(sharedPath, 'src'),\n destPath,\n path.join(windowsDir, newProjectName),\n templateVars,\n options.overwrite,\n );\n }\n\n // src\n if (fs.existsSync(path.join(srcPath, 'src'))) {\n await copyAndReplaceAll(\n path.join(srcPath, 'src'),\n destPath,\n path.join(windowsDir, newProjectName),\n templateVars,\n options.overwrite,\n );\n }\n\n if (projectType === 'app') {\n console.log(chalk.white.bold('To run your app on UWP:'));\n console.log(chalk.white(' npx react-native run-windows'));\n }\n}\n\nfunction toCppNamespace(namespace: string) {\n return namespace.replace(/\\./g, '::');\n}\n\nexport async function installScriptsAndDependencies(options: {\n verbose: boolean;\n}) {\n const projectPackage = await WritableNpmPackage.fromPath(process.cwd());\n if (!projectPackage) {\n throw new Error(\n `The current directory '${process.cwd()}' is not the root of an npm package`,\n );\n }\n\n await projectPackage.mergeProps({\n scripts: {windows: 'react-native run-windows'},\n });\n\n const rnwPackage = await findPackage('react-native-windows');\n if (!rnwPackage) {\n throw new Error('Could not locate the package for react-native-windows');\n }\n\n const rnPackage = await findPackage('react-native');\n if (!rnPackage) {\n throw new Error('Could not locate the package for react-native');\n }\n\n // We add an exclusionList from metro config. This will be hoisted, but add\n // an explict dep because we require it directly.\n const cliPackage = await findPackage('@react-native-community/cli', {\n searchPath: rnPackage.path,\n });\n const metroConfigPackage = await findPackage('metro-config', {\n searchPath: cliPackage?.path || rnPackage.path,\n });\n\n if (metroConfigPackage) {\n await projectPackage.mergeProps({\n devDependencies: {\n 'metro-config': `^${metroConfigPackage.json.version}`,\n },\n });\n }\n\n const rnPeerDependency = rnwPackage.json.peerDependencies['react-native'];\n\n if (\n !semver.satisfies(rnPackage.json.version, rnPeerDependency) &&\n projectPackage.json.dependencies?.['react-native']\n ) {\n console.log(\n chalk.green('Installing a compatible version of react-native:'),\n );\n console.log(chalk.white(` ${rnPeerDependency}`));\n\n // Patch package.json to have proper react-native version and install\n await projectPackage.mergeProps({\n dependencies: {'react-native': rnPeerDependency},\n });\n\n // Install dependencies using correct package manager\n const isYarn = fs.existsSync(path.join(process.cwd(), 'yarn.lock'));\n childProcess.execSync(\n isYarn ? 'yarn' : 'npm i',\n options.verbose ? {stdio: 'inherit'} : {},\n );\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator-windows/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kDAA0B;AAC1B,gDAAwB;AACxB,wDAAgC;AAChC,gDAAwB;AACxB,kEAAyC;AACzC,kEAA0C;AAC1C,oDAA4B;AAC5B,oDAAuB;AACvB,sDAA6B;AAC7B,uDAAyE;AAEzE,0DAI6B;AAE7B,+DAGyC;AACzC,uEAG6C;AAE7C,MAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,MAAM,SAAS,GAAG,QAAQ,CAAC;AAU3B,SAAS,UAAU,CAAC,GAAW;IAC7B,MAAM,SAAS,GAAG,gBAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,cAAc,CAAC,OAAe;IACrC,OAAO,OAAO,CAAC,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,sBAAsB,EAAE,OAAO,CAAC,EAAE;QACjE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;KACvB,CAAC,CAAC;AACL,CAAC;AAED,sCAAsC;AACtC,sCAAsC;AAC/B,KAAK,UAAU,6BAA6B,CACjD,WAAmB,EACnB,QAAgB,EAChB,cAAsB,EACtB,SAAiB,EACjB,OAAwB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CAAC;KACH;AACH,CAAC;AAhED,sEAgEC;AACD,SAAS,oBAAoB,CAAC,YAAoB;IAChD,MAAM,iBAAiB,GAAmB,EAAE,CAAC;IAC7C,iBAAiB,CAAC,IAAI,CAAC;QACrB,EAAE,EAAE,qCAAqC;QACzC,OAAO,EAAE,YAAY;KACtB,CAAC,CAAC;IAEH,iBAAiB,CAAC,IAAI,CAAC;QACrB,EAAE,EAAE,yBAAyB;QAC7B,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IAEH,OAAO,iBAAiB,CAAC;AAC3B,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport chalk from 'chalk';\nimport path from 'path';\nimport username from 'username';\nimport uuid from 'uuid';\nimport childProcess from 'child_process';\nimport fs from '@react-native-windows/fs';\nimport semver from 'semver';\nimport _ from 'lodash';\nimport findUp from 'find-up';\nimport {readProjectFile, findPropertyValue} from '../config/configUtils';\n\nimport {\n createDir,\n copyAndReplaceAll,\n copyAndReplaceWithChangedCallback,\n} from '../generator-common';\nimport {GenerateOptions} from '..';\nimport {\n CodedError,\n getVersionOfNpmPackage,\n} from '@react-native-windows/telemetry';\nimport {\n findPackage,\n WritableNpmPackage,\n} from '@react-native-windows/package-utils';\n\nconst windowsDir = 'windows';\nconst bundleDir = 'Bundle';\n\n/**\n * This represents the data to insert nuget packages\n */\ninterface NugetPackage {\n id: string;\n version: string;\n}\n\nfunction pascalCase(str: string) {\n const camelCase = _.camelCase(str);\n return camelCase[0].toUpperCase() + camelCase.substr(1);\n}\n\nfunction resolveRnwPath(subpath: string): string {\n return require.resolve(path.join('react-native-windows', subpath), {\n paths: [process.cwd()],\n });\n}\n\n// Existing high cyclomatic complexity\n// eslint-disable-next-line complexity\nexport async function copyProjectTemplateAndReplace(\n srcRootPath: string,\n destPath: string,\n newProjectName: string,\n namespace: string,\n options: GenerateOptions,\n) {\n if (!srcRootPath) {\n throw new CodedError(\n 'CopyProjectTemplateNoSourcePath',\n 'Need a path to copy from',\n );\n }\n\n if (!destPath) {\n throw new CodedError(\n 'CopyProjectTemplateNoDestPath',\n 'Need a path to copy to',\n );\n }\n\n if (!newProjectName) {\n throw new CodedError(\n 'CopyProjectTemplateNoProjectName',\n 'Need a project name',\n );\n }\n\n const projectType = options.projectType;\n const language = options.language;\n\n // React-native init only allows alphanumerics in project names, but other\n // new project tools (like create-react-native-module) are less strict.\n if (projectType === 'lib') {\n newProjectName = pascalCase(newProjectName);\n }\n\n // Similar to the above, but we want to retain namespace separators\n if (projectType === 'lib') {\n namespace = namespace.split(/[.:]+/).map(pascalCase).join('.');\n }\n\n // Checking if we're overwriting an existing project and re-uses their projectGUID\n const existingProjectPath = path.join(\n destPath,\n windowsDir,\n newProjectName,\n newProjectName + (language === 'cs' ? '.csproj' : '.vcxproj'),\n );\n let existingProjectGuid: string | undefined;\n if (fs.existsSync(existingProjectPath)) {\n console.log('Found existing project, extracting ProjectGuid.');\n existingProjectGuid = findPropertyValue(\n readProjectFile(existingProjectPath),\n 'ProjectGuid',\n existingProjectPath,\n ).replace(/[{}]/g, '');\n }\n\n createDir(path.join(destPath, windowsDir));\n createDir(path.join(destPath, windowsDir, newProjectName));\n\n if (projectType === 'app') {\n createDir(path.join(destPath, windowsDir, newProjectName, bundleDir));\n createDir(path.join(destPath, windowsDir, newProjectName, 'BundleBuilder'));\n }\n\n const namespaceCpp = toCppNamespace(namespace);\n if (options.experimentalNuGetDependency) {\n console.log('Using experimental NuGet dependency.');\n }\n\n let realProjectType = projectType;\n\n if (options.useWinUI3) {\n console.log('Using experimental WinUI3 dependency.');\n if (projectType === 'lib') {\n throw new CodedError(\n 'IncompatibleOptions',\n 'WinUI 3 project template only supports apps at the moment',\n {\n detail: 'useWinUI3 and lib',\n },\n );\n } else if (language !== 'cs') {\n throw new CodedError(\n 'IncompatibleOptions',\n 'WinUI 3 project template only support C# at the moment',\n {\n detail: 'useWinUI3 and cpp',\n },\n );\n }\n\n realProjectType += '-WinAppSDK';\n }\n\n const projDir = 'proj';\n const srcPath = path.join(srcRootPath, `${language}-${realProjectType}`);\n const sharedPath = path.join(srcRootPath, `shared-${projectType}`);\n const projectGuid = existingProjectGuid || uuid.v4();\n const rnwVersion = require(resolveRnwPath('package.json')).version;\n const nugetVersion = options.nuGetTestVersion || rnwVersion;\n const packageGuid = uuid.v4();\n const currentUser = username.sync()!; // Gets the current username depending on the platform.\n\n let mainComponentName = newProjectName;\n const appJsonPath = await findUp('app.json', {cwd: destPath});\n if (appJsonPath) {\n const appJson = await fs.readJsonFile<{name: string}>(appJsonPath);\n mainComponentName = appJson.name;\n }\n\n const csNugetPackages: NugetPackage[] = options.useWinUI3\n ? getWinAppSDKPackages(nugetVersion)\n : getUwpCsPackages();\n\n const cppNugetPackages: NugetPackage[] = [\n {\n id: 'Microsoft.Windows.CppWinRT',\n version: '2.0.211028.7',\n },\n ];\n\n const templateVars: Record<string, any> = {\n useMustache: true,\n regExpPatternsToRemove: [],\n\n name: newProjectName,\n namespace: namespace,\n namespaceCpp: namespaceCpp,\n languageIsCpp: language === 'cpp',\n\n rnwVersion: await getVersionOfNpmPackage('react-native-windows'),\n\n mainComponentName: mainComponentName,\n\n // Visual Studio is very picky about the casing of the guids for projects, project references and the solution\n // https://www.bing.com/search?q=visual+studio+project+guid+casing&cvid=311a5ad7f9fc41089507b24600d23ee7&FORM=ANAB01&PC=U531\n // we therefore have to precariously use the right casing in the right place or risk building in VS breaking.\n projectGuidLower: `{${projectGuid.toLowerCase()}}`,\n projectGuidUpper: `{${projectGuid.toUpperCase()}}`,\n\n // packaging and signing variables:\n packageGuid: packageGuid,\n currentUser: currentUser,\n\n useExperimentalNuget: options.experimentalNuGetDependency,\n nuGetTestFeed: options.nuGetTestFeed,\n nuGetADOFeed: nugetVersion.startsWith('0.0.0-'),\n\n // cpp template variables\n useWinUI3: options.useWinUI3,\n useHermes: options.useHermes,\n cppNugetPackages: cppNugetPackages,\n\n // cs template variables\n csNugetPackages: csNugetPackages,\n\n // autolinking template variables\n autolinkPropertiesForProps: '',\n autolinkProjectReferencesForTargets: '',\n autolinkCsUsingNamespaces: '',\n autolinkCsReactPackageProviders: '',\n autolinkCppIncludes: '',\n autolinkCppPackageProviders:\n '\\n UNREFERENCED_PARAMETER(packageProviders);', // CODESYNC: vnext\\local-cli\\runWindows\\utils\\autolink.js\n };\n\n const commonMappings =\n projectType === 'app'\n ? [\n // app common mappings\n {\n from: path.join(\n srcRootPath,\n options.useDevMode\n ? 'metro.devMode.config.js'\n : 'metro.config.js',\n ),\n to: 'metro.config.js',\n },\n {\n from: path.join(srcRootPath, '_gitignore'),\n to: path.join(windowsDir, '.gitignore'),\n },\n {\n from: path.join(srcRootPath, 'b_gitignore'),\n to: path.join(windowsDir, newProjectName, '.gitignore'),\n },\n {\n from: path.join(srcRootPath, 'index.windows.bundle'),\n to: path.join(\n windowsDir,\n newProjectName,\n bundleDir,\n 'index.windows.bundle',\n ),\n },\n {\n from: path.join(srcPath, projDir, 'MyApp.sln'),\n to: path.join(windowsDir, newProjectName + '.sln'),\n },\n ]\n : [\n // lib common mappings\n {\n from: path.join(srcRootPath, '_gitignore'),\n to: path.join(windowsDir, '.gitignore'),\n },\n {\n from: path.join(srcPath, projDir, 'MyLib.sln'),\n to: path.join(windowsDir, newProjectName + '.sln'),\n },\n ];\n\n for (const mapping of commonMappings) {\n await copyAndReplaceWithChangedCallback(\n mapping.from,\n destPath,\n mapping.to,\n templateVars,\n options.overwrite,\n );\n }\n\n if (language === 'cs') {\n const csMappings =\n projectType === 'app'\n ? [\n // cs app mappings\n {\n from: path.join(srcPath, projDir, 'MyApp.csproj'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.csproj',\n ),\n },\n ]\n : [\n // cs lib mappings\n {\n from: path.join(srcPath, projDir, 'MyLib.csproj'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.csproj',\n ),\n },\n ];\n\n for (const mapping of csMappings) {\n await copyAndReplaceWithChangedCallback(\n mapping.from,\n destPath,\n mapping.to,\n templateVars,\n options.overwrite,\n );\n }\n } else {\n const cppMappings =\n projectType === 'app'\n ? [\n // cpp app mappings\n {\n from: path.join(srcPath, projDir, 'MyApp.vcxproj'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.vcxproj',\n ),\n },\n {\n from: path.join(srcPath, projDir, 'MyApp.vcxproj.filters'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.vcxproj.filters',\n ),\n },\n ]\n : [\n // cpp lib mappings\n {\n from: path.join(srcPath, projDir, 'MyLib.vcxproj'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.vcxproj',\n ),\n },\n {\n from: path.join(srcPath, projDir, 'MyLib.vcxproj.filters'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.vcxproj.filters',\n ),\n },\n {\n from: path.join(srcPath, projDir, 'MyLib.def'),\n to: path.join(\n windowsDir,\n newProjectName,\n newProjectName + '.def',\n ),\n },\n ];\n\n for (const mapping of cppMappings) {\n await copyAndReplaceWithChangedCallback(\n mapping.from,\n destPath,\n mapping.to,\n templateVars,\n options.overwrite,\n );\n }\n }\n\n // shared proj\n if (fs.existsSync(path.join(sharedPath, projDir))) {\n const sharedProjMappings = [];\n\n sharedProjMappings.push({\n from: path.join(sharedPath, projDir, 'NuGet.Config'),\n to: path.join(windowsDir, 'NuGet.Config'),\n });\n\n if (\n fs.existsSync(\n path.join(sharedPath, projDir, 'ExperimentalFeatures.props'),\n )\n ) {\n sharedProjMappings.push({\n from: path.join(sharedPath, projDir, 'ExperimentalFeatures.props'),\n to: path.join(windowsDir, 'ExperimentalFeatures.props'),\n });\n }\n\n for (const mapping of sharedProjMappings) {\n await copyAndReplaceWithChangedCallback(\n mapping.from,\n destPath,\n mapping.to,\n templateVars,\n options.overwrite,\n );\n }\n }\n\n // shared assets\n if (fs.existsSync(path.join(sharedPath, 'assets'))) {\n await copyAndReplaceAll(\n path.join(sharedPath, 'assets'),\n destPath,\n path.join(windowsDir, newProjectName, 'Assets'),\n templateVars,\n options.overwrite,\n );\n }\n\n if (!options.useWinUI3) {\n // shared src\n if (fs.existsSync(path.join(sharedPath, 'src'))) {\n await copyAndReplaceAll(\n path.join(sharedPath, 'src'),\n destPath,\n path.join(windowsDir, newProjectName),\n templateVars,\n options.overwrite,\n );\n }\n } else {\n if (fs.existsSync(path.join(srcPath, 'MyApp'))) {\n await copyAndReplaceAll(\n path.join(srcPath, 'MyApp'),\n destPath,\n path.join(windowsDir, newProjectName),\n templateVars,\n options.overwrite,\n );\n }\n }\n\n // src\n if (fs.existsSync(path.join(srcPath, 'src'))) {\n await copyAndReplaceAll(\n path.join(srcPath, 'src'),\n destPath,\n path.join(windowsDir, newProjectName),\n templateVars,\n options.overwrite,\n );\n }\n\n if (projectType === 'app') {\n console.log(chalk.white.bold('To run your app on UWP:'));\n console.log(chalk.white(' npx react-native run-windows'));\n }\n}\n\nfunction getUwpCsPackages(): NugetPackage[] {\n return [\n {\n id: 'Microsoft.NETCore.UniversalWindowsPlatform',\n version: '6.2.9',\n },\n ];\n}\n\nfunction toCppNamespace(namespace: string) {\n return namespace.replace(/\\./g, '::');\n}\n\nexport async function installScriptsAndDependencies(options: {\n verbose: boolean;\n}) {\n const projectPackage = await WritableNpmPackage.fromPath(process.cwd());\n if (!projectPackage) {\n throw new Error(\n `The current directory '${process.cwd()}' is not the root of an npm package`,\n );\n }\n\n await projectPackage.mergeProps({\n scripts: {windows: 'react-native run-windows'},\n });\n\n const rnwPackage = await findPackage('react-native-windows');\n if (!rnwPackage) {\n throw new Error('Could not locate the package for react-native-windows');\n }\n\n const rnPackage = await findPackage('react-native');\n if (!rnPackage) {\n throw new Error('Could not locate the package for react-native');\n }\n\n // We add an exclusionList from metro config. This will be hoisted, but add\n // an explict dep because we require it directly.\n const cliPackage = await findPackage('@react-native-community/cli', {\n searchPath: rnPackage.path,\n });\n const metroConfigPackage = await findPackage('metro-config', {\n searchPath: cliPackage?.path || rnPackage.path,\n });\n\n if (metroConfigPackage) {\n await projectPackage.mergeProps({\n devDependencies: {\n 'metro-config': `^${metroConfigPackage.json.version}`,\n },\n });\n }\n\n const rnPeerDependency = rnwPackage.json.peerDependencies['react-native'];\n\n if (\n !semver.satisfies(rnPackage.json.version, rnPeerDependency) &&\n projectPackage.json.dependencies?.['react-native']\n ) {\n console.log(\n chalk.green('Installing a compatible version of react-native:'),\n );\n console.log(chalk.white(` ${rnPeerDependency}`));\n\n // Patch package.json to have proper react-native version and install\n await projectPackage.mergeProps({\n dependencies: {'react-native': rnPeerDependency},\n });\n\n // Install dependencies using correct package manager\n const isYarn = fs.existsSync(path.join(process.cwd(), 'yarn.lock'));\n childProcess.execSync(\n isYarn ? 'yarn' : 'npm i',\n options.verbose ? {stdio: 'inherit'} : {},\n );\n }\n}\nfunction getWinAppSDKPackages(nugetVersion: string): NugetPackage[] {\n const winAppSDKPackages: NugetPackage[] = [];\n winAppSDKPackages.push({\n id: 'Microsoft.ReactNative.WindowsAppSDK',\n version: nugetVersion,\n });\n\n winAppSDKPackages.push({\n id: 'Microsoft.WindowsAppSDK',\n version: '1.0.0',\n });\n\n return winAppSDKPackages;\n}\n"]}
@@ -6,7 +6,11 @@
6
6
  */
7
7
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
8
  if (k2 === undefined) k2 = k;
9
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
10
14
  }) : (function(o, m, k, k2) {
11
15
  if (k2 === undefined) k2 = k;
12
16
  o[k2] = m[k];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AAExB,2DAG6B;AAE7B,0DAA4D;AAC5D,wDAA0D;AAC1D,gEAAkE;AAClE,0DAA4D;AAiC5D;;;;;;;GAOG;AACI,KAAK,UAAU,eAAe,CACnC,UAAkB,EAClB,IAAY,EACZ,EAAU,EACV,OAAwB;IAExB,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC9B,YAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;KAC1B;IAED,MAAM,IAAA,iDAA6B,EAAC,OAAO,CAAC,CAAC;IAE7C,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAC7B,OAAO,CAAC,OAAO,CAAC,mCAAmC,EAAE;QACnD,KAAK,EAAE,CAAC,UAAU,CAAC;KACpB,CAAC,CACH,CAAC;IACF,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvD,MAAM,IAAA,iDAA6B,EACjC,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,EAAE,EACF,OAAO,CACR,CAAC;AACJ,CAAC;AAzBD,0CAyBC;AAED,iEAAiE;AACjE,MAAM,qBAAqB,GAOf,IAAI,CAAC;AACjB,qBAAqB,CAAC;AAET,QAAA,QAAQ,GAAG,CAAC,0BAAe,EAAE,8BAAiB,CAAC,CAAC;AAChD,QAAA,gBAAgB,GAAG,0CAAuB,CAAC;AAC3C,QAAA,aAAa,GAAG,oCAAoB,CAAC;AAClD,iDAA+B","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 {\n copyProjectTemplateAndReplace,\n installScriptsAndDependencies,\n} from './generator-windows';\n\nimport {autoLinkCommand} from './runWindows/utils/autolink';\nimport {runWindowsCommand} from './runWindows/runWindows';\nimport {dependencyConfigWindows} from './config/dependencyConfig';\nimport {projectConfigWindows} from './config/projectConfig';\n\n/**\n * Project generation options\n *\n * _\n * | |\n * __| | __ _ _ __ __ _ ___ _ __\n * / _` |/ _` | '_ \\ / _` |/ _ \\ '__|\n * | (_| | (_| | | | | (_| | __/ |\n * \\__,_|\\__,_|_| |_|\\__, |\\___|_|\n * __/ |\n * |___/\n *\n *\n * Properties on this interface must remain stable, as new versions of\n * react-native-windows-init may be used with local-cli dating back to 0.61.\n * All existing arguments must work correctly when changing this interface.\n */\nexport interface GenerateOptions {\n overwrite: boolean;\n language: 'cpp' | 'cs';\n projectType: 'app' | 'lib';\n experimentalNuGetDependency: boolean;\n nuGetTestVersion?: string;\n nuGetTestFeed?: string;\n useWinUI3: boolean;\n useHermes: boolean;\n useDevMode: boolean;\n verbose: boolean;\n telemetry: boolean;\n}\n\n/**\n * Simple utility for running the Windows generator.\n *\n * @param projectDir root project directory (i.e. contains index.js)\n * @param name name of the root JS module for this app\n * @param ns namespace for the project\n * @param options command line options container\n */\nexport async function generateWindows(\n projectDir: string,\n name: string,\n ns: string,\n options: GenerateOptions,\n) {\n if (!fs.existsSync(projectDir)) {\n fs.mkdirSync(projectDir);\n }\n\n await installScriptsAndDependencies(options);\n\n const rnwPackage = path.dirname(\n require.resolve('react-native-windows/package.json', {\n paths: [projectDir],\n }),\n );\n const templateRoot = path.join(rnwPackage, 'template');\n await copyProjectTemplateAndReplace(\n templateRoot,\n projectDir,\n name,\n ns,\n options,\n );\n}\n\n// Assert the interface here doesn't change for the reasons above\nconst assertStableInterface: typeof generateWindows extends (\n projectDir: string,\n name: string,\n ns: string,\n options: GenerateOptions,\n) => Promise<void>\n ? true\n : never = true;\nassertStableInterface;\n\nexport const commands = [autoLinkCommand, runWindowsCommand];\nexport const dependencyConfig = dependencyConfigWindows;\nexport const projectConfig = projectConfigWindows;\nexport * from './healthChecks';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AAExB,2DAG6B;AAE7B,0DAA4D;AAC5D,wDAA0D;AAC1D,gEAAkE;AAClE,0DAA4D;AAiC5D;;;;;;;GAOG;AACI,KAAK,UAAU,eAAe,CACnC,UAAkB,EAClB,IAAY,EACZ,EAAU,EACV,OAAwB;IAExB,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAC9B,YAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;KAC1B;IAED,MAAM,IAAA,iDAA6B,EAAC,OAAO,CAAC,CAAC;IAE7C,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAC7B,OAAO,CAAC,OAAO,CAAC,mCAAmC,EAAE;QACnD,KAAK,EAAE,CAAC,UAAU,CAAC;KACpB,CAAC,CACH,CAAC;IACF,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvD,MAAM,IAAA,iDAA6B,EACjC,YAAY,EACZ,UAAU,EACV,IAAI,EACJ,EAAE,EACF,OAAO,CACR,CAAC;AACJ,CAAC;AAzBD,0CAyBC;AAED,iEAAiE;AACjE,MAAM,qBAAqB,GAOf,IAAI,CAAC;AACjB,qBAAqB,CAAC;AAET,QAAA,QAAQ,GAAG,CAAC,0BAAe,EAAE,8BAAiB,CAAC,CAAC;AAChD,QAAA,gBAAgB,GAAG,0CAAuB,CAAC;AAC3C,QAAA,aAAa,GAAG,oCAAoB,CAAC;AAClD,iDAA+B","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 {\n copyProjectTemplateAndReplace,\n installScriptsAndDependencies,\n} from './generator-windows';\n\nimport {autoLinkCommand} from './runWindows/utils/autolink';\nimport {runWindowsCommand} from './runWindows/runWindows';\nimport {dependencyConfigWindows} from './config/dependencyConfig';\nimport {projectConfigWindows} from './config/projectConfig';\n\n/**\n * Project generation options\n *\n * _\n * | |\n * __| | __ _ _ __ __ _ ___ _ __\n * / _` |/ _` | '_ \\ / _` |/ _ \\ '__|\n * | (_| | (_| | | | | (_| | __/ |\n * \\__,_|\\__,_|_| |_|\\__, |\\___|_|\n * __/ |\n * |___/\n *\n *\n * Properties on this interface must remain stable, as new versions of\n * react-native-windows-init may be used with local-cli dating back to 0.61.\n * All existing arguments must work correctly when changing this interface.\n */\nexport interface GenerateOptions {\n overwrite: boolean;\n language: 'cpp' | 'cs';\n projectType: 'app' | 'lib';\n experimentalNuGetDependency: boolean;\n nuGetTestVersion?: string;\n nuGetTestFeed?: string;\n useWinUI3: boolean;\n useHermes: boolean;\n useDevMode: boolean;\n verbose: boolean;\n telemetry: boolean;\n}\n\n/**\n * Simple utility for running the Windows generator.\n *\n * @param projectDir root project directory (i.e. contains index.js)\n * @param name name of the root JS module for this app\n * @param ns namespace for the project\n * @param options command line options container\n */\nexport async function generateWindows(\n projectDir: string,\n name: string,\n ns: string,\n options: GenerateOptions,\n) {\n if (!fs.existsSync(projectDir)) {\n fs.mkdirSync(projectDir);\n }\n\n await installScriptsAndDependencies(options);\n\n const rnwPackage = path.dirname(\n require.resolve('react-native-windows/package.json', {\n paths: [projectDir],\n }),\n );\n const templateRoot = path.join(rnwPackage, 'template');\n await copyProjectTemplateAndReplace(\n templateRoot,\n projectDir,\n name,\n ns,\n options,\n );\n}\n\n// Assert the interface here doesn't change for the reasons above\nconst assertStableInterface: typeof generateWindows extends (\n projectDir: string,\n name: string,\n ns: string,\n options: GenerateOptions,\n) => Promise<void>\n ? true\n : never = true;\nassertStableInterface;\n\nexport const commands = [autoLinkCommand, runWindowsCommand];\nexport const dependencyConfig = dependencyConfigWindows;\nexport const projectConfig = projectConfigWindows;\nexport * from './healthChecks';\n"]}
@@ -6,7 +6,11 @@
6
6
  */
7
7
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
8
  if (k2 === undefined) k2 = k;
9
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
10
14
  }) : (function(o, m, k, k2) {
11
15
  if (k2 === undefined) k2 = k;
12
16
  o[k2] = m[k];
@@ -124,7 +128,7 @@ async function runWindows(args, config, options) {
124
128
  console.log(output.trimEnd());
125
129
  console.log(' Installed UWP SDKs:');
126
130
  const sdks = msbuildtools_1.default.getAllAvailableUAPVersions();
127
- sdks.forEach((version) => console.log(' ' + version));
131
+ sdks.forEach(version => console.log(' ' + version));
128
132
  }
129
133
  catch (ex) {
130
134
  runWindowsError =
@@ -1 +1 @@
1
- {"version":3,"file":"runWindows.js","sourceRoot":"","sources":["../../src/runWindows/runWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,+DAAsE;AAEtE,qDAAuC;AACvC,kDAA0B;AAC1B,uDAAyC;AACzC,qEAKqC;AACrC,+DAIkC;AAClC,mDAAqC;AACrC,wEAAgD;AAGhD,2DAAyE;AAEzE,+CAA0E;AAE1E;;;;;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,C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pE;SACF;QAAC,OAAO,CAAC,EAAE;YACV,IAAA,8BAAQ,EAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,KAAM,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACpE,MAAM,CAAC,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';\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\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 info from './utils/info';\nimport MSBuildTools from './utils/msbuildtools';\n\nimport {Command, Config} from '@react-native-community/cli-types';\nimport {runWindowsOptions, RunWindowsOptions} from './runWindowsOptions';\n\nimport {autolinkWindowsInternal, AutoLinkOptions} from './utils/autolink';\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 */\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 rnwPkgJsonPath = require.resolve(\n 'react-native-windows/package.json',\n {\n paths: [process.cwd(), __dirname],\n },\n );\n const rnwDependenciesPath = path.join(\n path.dirname(rnwPkgJsonPath),\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/runWindows/runWindows.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,+DAAsE;AAEtE,qDAAuC;AACvC,kDAA0B;AAC1B,uDAAyC;AACzC,qEAKqC;AACrC,+DAIkC;AAClC,mDAAqC;AACrC,wEAAgD;AAGhD,2DAAyE;AAEzE,+CAA0E;AAE1E;;;;;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,mBAAmB;QAC/E,KAAK,SAAS,CAAC;QACf,KAAK,MAAM,CAAC;QACZ,KAAK,YAAY,CAAC;QAClB,K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C;YACpE,MAAM,CAAC,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';\nimport {Telemetry, CodedError} from '@react-native-windows/telemetry';\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 info from './utils/info';\nimport MSBuildTools from './utils/msbuildtools';\n\nimport {Command, Config} from '@react-native-community/cli-types';\nimport {runWindowsOptions, RunWindowsOptions} from './runWindowsOptions';\n\nimport {autolinkWindowsInternal, AutoLinkOptions} from './utils/autolink';\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 */\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 rnwPkgJsonPath = require.resolve(\n 'react-native-windows/package.json',\n {\n paths: [process.cwd(), __dirname],\n },\n );\n const rnwDependenciesPath = path.join(\n path.dirname(rnwPkgJsonPath),\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"]}
@@ -18,7 +18,7 @@ exports.runWindowsOptions = [
18
18
  {
19
19
  name: '--root [string]',
20
20
  description: 'Override the root directory for the windows build which contains the windows folder.',
21
- default: (config) => config.root,
21
+ default: config => config.root,
22
22
  },
23
23
  {
24
24
  name: '--arch [string]',
@@ -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,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI;KACjC;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,0CAA0C;QACvD,OAAO,EAAE,YAAE,CAAC,IAAI,EAAE;QAClB,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,EA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AAC;AAED,SAAS,wBAAwB,CAAC,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 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: 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;;;;;;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,MAAM,CAAC,IAAI;KAC/B;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,0CAA0C;QACvD,OAAO,EAAE,YAAE,CAAC,IAAI,EAAE;QAClB,KAAK,EAAE,cAAc;K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,wBAAwB;KAChC;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,uGAAuG;KAC1G;CACF,CAAC;AAEF,SAAS,cAAc,CAAC,GAAW;IACjC,MAAM,eAAe,GAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7D,KAAK,MAAM,SAAS,IAAI,eAAe,EAAE;QACvC,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,EAAE;YACjD,OAAO,SAAS,CAAC;SAClB;KACF;IAED,QAAQ,CAAC,wBAAwB,GAAG,sBAAsB,eAAe,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,SAAS,wBAAwB,CAAC,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 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: 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"]}