@react-native-windows/cli 0.66.2 → 0.68.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 (62) hide show
  1. package/README.md +1 -1
  2. package/lib-commonjs/config/configUtils.js +1 -1
  3. package/lib-commonjs/config/configUtils.js.map +1 -1
  4. package/lib-commonjs/config/dependencyConfig.js +6 -4
  5. package/lib-commonjs/config/dependencyConfig.js.map +1 -1
  6. package/lib-commonjs/config/projectConfig.js +2 -2
  7. package/lib-commonjs/config/projectConfig.js.map +1 -1
  8. package/lib-commonjs/e2etest/autolink.test.d.ts +5 -0
  9. package/lib-commonjs/e2etest/autolink.test.js +109 -12
  10. package/lib-commonjs/e2etest/autolink.test.js.map +1 -1
  11. package/lib-commonjs/e2etest/dependencyConfig.test.js +17 -17
  12. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -1
  13. package/lib-commonjs/e2etest/projectConfig.test.js +18 -20
  14. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -1
  15. package/lib-commonjs/e2etest/projectConfig.utils.js +6 -13
  16. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -1
  17. package/lib-commonjs/e2etest/runWindows.test.js +52 -13
  18. package/lib-commonjs/e2etest/runWindows.test.js.map +1 -1
  19. package/lib-commonjs/generator-common/index.js +8 -8
  20. package/lib-commonjs/generator-common/index.js.map +1 -1
  21. package/lib-commonjs/generator-windows/index.js +34 -77
  22. package/lib-commonjs/generator-windows/index.js.map +1 -1
  23. package/lib-commonjs/healthChecks.js +22 -4
  24. package/lib-commonjs/healthChecks.js.map +1 -1
  25. package/lib-commonjs/index.js +10 -61
  26. package/lib-commonjs/index.js.map +1 -1
  27. package/lib-commonjs/runWindows/runWindows.d.ts +0 -1
  28. package/lib-commonjs/runWindows/runWindows.js +124 -145
  29. package/lib-commonjs/runWindows/runWindows.js.map +1 -1
  30. package/lib-commonjs/runWindows/runWindowsOptions.d.ts +8 -8
  31. package/lib-commonjs/runWindows/runWindowsOptions.js +7 -12
  32. package/lib-commonjs/runWindows/runWindowsOptions.js.map +1 -1
  33. package/lib-commonjs/runWindows/utils/autolink.d.ts +16 -5
  34. package/lib-commonjs/runWindows/utils/autolink.js +118 -57
  35. package/lib-commonjs/runWindows/utils/autolink.js.map +1 -1
  36. package/lib-commonjs/runWindows/utils/build.js +4 -4
  37. package/lib-commonjs/runWindows/utils/build.js.map +1 -1
  38. package/lib-commonjs/runWindows/utils/checkRequirements.js +2 -2
  39. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +1 -1
  40. package/lib-commonjs/runWindows/utils/commandWithProgress.d.ts +8 -1
  41. package/lib-commonjs/runWindows/utils/commandWithProgress.js +30 -8
  42. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +1 -1
  43. package/lib-commonjs/runWindows/utils/deploy.d.ts +1 -1
  44. package/lib-commonjs/runWindows/utils/deploy.js +88 -37
  45. package/lib-commonjs/runWindows/utils/deploy.js.map +1 -1
  46. package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +1 -0
  47. package/lib-commonjs/runWindows/utils/msbuildtools.js +30 -23
  48. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +1 -1
  49. package/lib-commonjs/runWindows/utils/telemetryHelpers.d.ts +29 -0
  50. package/lib-commonjs/runWindows/utils/telemetryHelpers.js +109 -0
  51. package/lib-commonjs/runWindows/utils/telemetryHelpers.js.map +1 -0
  52. package/lib-commonjs/runWindows/utils/version.js +1 -1
  53. package/lib-commonjs/runWindows/utils/version.js.map +1 -1
  54. package/lib-commonjs/runWindows/utils/vsInstalls.js +3 -3
  55. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +1 -1
  56. package/lib-commonjs/runWindows/utils/vstools.js +4 -4
  57. package/lib-commonjs/runWindows/utils/vstools.js.map +1 -1
  58. package/lib-commonjs/runWindows/utils/winappdeploytool.js +7 -7
  59. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +1 -1
  60. package/package.json +17 -13
  61. package/CHANGELOG.json +0 -1585
  62. package/CHANGELOG.md +0 -713
@@ -5,18 +5,57 @@
5
5
  * @format
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- const runWindows_1 = require("../runWindows/runWindows");
9
- test('getAnonymizedProjectName - Project Exists', async () => {
10
- const fooName = await runWindows_1.getAnonymizedProjectName(`${__dirname}/projects/FooPackage`);
11
- const barName = await runWindows_1.getAnonymizedProjectName(`${__dirname}/projects/BarPackage`);
12
- expect(typeof fooName).toBe('string');
13
- expect(typeof barName).toBe('string');
14
- expect(fooName.length).toBeGreaterThan(0);
15
- expect(barName.length).toBeGreaterThan(0);
16
- expect(fooName).not.toBe(barName);
17
- });
18
- test('getAnonymizedProjectName - Project Doesnt Exist', async () => {
19
- const emptyPackageName = await runWindows_1.getAnonymizedProjectName(`${__dirname}/projects/BlankApp`);
20
- expect(emptyPackageName).toBeNull();
8
+ const telemetry_1 = require("@react-native-windows/telemetry");
9
+ const runWindowsOptions_1 = require("../runWindows/runWindowsOptions");
10
+ // eslint-disable-next-line complexity
11
+ function validateOptionName(name, optionName) {
12
+ // Do not add a default case here. Every item must explicitly return true
13
+ switch (optionName) {
14
+ case 'release':
15
+ case 'root':
16
+ case 'arch':
17
+ case 'singleproc':
18
+ case 'emulator':
19
+ case 'device':
20
+ case 'target':
21
+ case 'remoteDebugging':
22
+ case 'logging':
23
+ case 'packager':
24
+ case 'bundle':
25
+ case 'launch':
26
+ case 'autolink':
27
+ case 'build':
28
+ case 'deploy':
29
+ case 'deployFromLayout':
30
+ case 'sln':
31
+ case 'proj':
32
+ case 'msbuildprops':
33
+ case 'buildLogDirectory':
34
+ case 'info':
35
+ case 'directDebugging':
36
+ case 'telemetry':
37
+ return true;
38
+ }
39
+ throw new Error(`Unable to find ${optionName} to match '${name}' in RunWindowsOptions.`);
40
+ }
41
+ test('runWindowsOptions - validate options', () => {
42
+ for (const commandOption of runWindowsOptions_1.runWindowsOptions) {
43
+ // Validate names
44
+ expect(commandOption.name).not.toBeNull();
45
+ expect(commandOption.name.startsWith('--')).toBe(true);
46
+ expect(commandOption.name).toBe(commandOption.name.trim());
47
+ // Validate defaults
48
+ if (!commandOption.name.endsWith(' [string]') &&
49
+ !commandOption.name.endsWith(' [number]')) {
50
+ // Commander ignores defaults for flags, so leave undefined to prevent confusion
51
+ expect(commandOption.default).toBeUndefined();
52
+ }
53
+ // Validate description
54
+ expect(commandOption.description).not.toBeNull();
55
+ expect(commandOption.description).toBe(commandOption.description.trim());
56
+ // Validate all command options are present in RunWindowsOptions
57
+ const optionName = (0, telemetry_1.commanderNameToOptionName)(commandOption.name);
58
+ expect(validateOptionName(commandOption.name, optionName)).toBe(true);
59
+ }
21
60
  });
22
61
  //# sourceMappingURL=runWindows.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runWindows.test.js","sourceRoot":"","sources":["../../src/e2etest/runWindows.test.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAEH,yDAAkE;AAElE,IAAI,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;IAC3D,MAAM,OAAO,GAAG,MAAM,qCAAwB,CAC5C,GAAG,SAAS,sBAAsB,CACnC,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,qCAAwB,CAC5C,GAAG,SAAS,sBAAsB,CACnC,CAAC;IAEF,MAAM,CAAC,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtC,MAAM,CAAC,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEtC,MAAM,CAAC,OAAQ,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,CAAC,OAAQ,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAE3C,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;IACjE,MAAM,gBAAgB,GAAG,MAAM,qCAAwB,CACrD,GAAG,SAAS,oBAAoB,CACjC,CAAC;IACF,MAAM,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAC;AACtC,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {getAnonymizedProjectName} from '../runWindows/runWindows';\n\ntest('getAnonymizedProjectName - Project Exists', async () => {\n const fooName = await getAnonymizedProjectName(\n `${__dirname}/projects/FooPackage`,\n );\n const barName = await getAnonymizedProjectName(\n `${__dirname}/projects/BarPackage`,\n );\n\n expect(typeof fooName).toBe('string');\n expect(typeof barName).toBe('string');\n\n expect(fooName!.length).toBeGreaterThan(0);\n expect(barName!.length).toBeGreaterThan(0);\n\n expect(fooName).not.toBe(barName);\n});\n\ntest('getAnonymizedProjectName - Project Doesnt Exist', async () => {\n const emptyPackageName = await getAnonymizedProjectName(\n `${__dirname}/projects/BlankApp`,\n );\n expect(emptyPackageName).toBeNull();\n});\n"]}
1
+ {"version":3,"file":"runWindows.test.js","sourceRoot":"","sources":["../../src/e2etest/runWindows.test.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAEH,+DAA0E;AAE1E,uEAGyC;AAEzC,sCAAsC;AACtC,SAAS,kBAAkB,CACzB,IAAY,EACZ,UAAmC;IAEnC,yEAAyE;IACzE,QAAQ,UAAU,EAAE;QAClB,KAAK,SAAS,CAAC;QACf,KAAK,MAAM,CAAC;QACZ,KAAK,MAAM,CAAC;QACZ,KAAK,YAAY,CAAC;QAClB,KAAK,UAAU,CAAC;QAChB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,iBAAiB,CAAC;QACvB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU,CAAC;QAChB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC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AChE,MAAM,UAAU,GAAG,IAAA,qCAAyB,EAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACjE,MAAM,CACJ,kBAAkB,CAChB,aAAa,CAAC,IAAI,EAClB,UAAqC,CACtC,CACF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACd;AACH,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {commanderNameToOptionName} from '@react-native-windows/telemetry';\n\nimport {\n runWindowsOptions,\n RunWindowsOptions,\n} from '../runWindows/runWindowsOptions';\n\n// eslint-disable-next-line complexity\nfunction validateOptionName(\n name: string,\n optionName: keyof RunWindowsOptions,\n): boolean {\n // Do not add a default case here. Every item must explicitly return true\n switch (optionName) {\n case 'release':\n case 'root':\n case 'arch':\n case 'singleproc':\n case 'emulator':\n case 'device':\n case 'target':\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 'sln':\n case 'proj':\n case 'msbuildprops':\n case 'buildLogDirectory':\n case 'info':\n case 'directDebugging':\n case 'telemetry':\n return true;\n }\n throw new Error(\n `Unable to find ${optionName} to match '${name}' in RunWindowsOptions.`,\n );\n}\n\ntest('runWindowsOptions - validate options', () => {\n for (const commandOption of runWindowsOptions) {\n // Validate names\n expect(commandOption.name).not.toBeNull();\n expect(commandOption.name.startsWith('--')).toBe(true);\n expect(commandOption.name).toBe(commandOption.name.trim());\n\n // Validate defaults\n if (\n !commandOption.name.endsWith(' [string]') &&\n !commandOption.name.endsWith(' [number]')\n ) {\n // Commander ignores defaults for flags, so leave undefined to prevent confusion\n expect(commandOption.default).toBeUndefined();\n }\n\n // Validate description\n expect(commandOption.description).not.toBeNull();\n expect(commandOption.description!).toBe(commandOption.description!.trim());\n\n // Validate all command options are present in RunWindowsOptions\n const optionName = commanderNameToOptionName(commandOption.name);\n expect(\n validateOptionName(\n commandOption.name,\n optionName as keyof RunWindowsOptions,\n ),\n ).toBe(true);\n }\n});\n"]}
@@ -9,7 +9,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.copyAndReplaceAll = exports.copyAndReplaceWithChangedCallback = exports.createDir = exports.copyAndReplace = exports.resolveContents = void 0;
12
- const fs_1 = __importDefault(require("fs"));
12
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
13
13
  const chalk_1 = __importDefault(require("chalk"));
14
14
  const prompts_1 = __importDefault(require("prompts"));
15
15
  const path_1 = __importDefault(require("path"));
@@ -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', () => {
@@ -225,7 +225,7 @@ async function upgradeFileContentChangedCallback(absoluteSrcFilePath, relativeDe
225
225
  `has changed in the new version.\nDo you want to keep your ${relativeDestPath} or replace it with the ` +
226
226
  'latest version?\nMake sure you have any changes you made to this file saved somewhere.\n' +
227
227
  `You can see the new version here: ${absoluteSrcFilePath}`);
228
- const { shouldReplace } = await prompts_1.default([
228
+ const { shouldReplace } = await (0, prompts_1.default)([
229
229
  {
230
230
  name: 'shouldReplace',
231
231
  type: 'confirm',
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generator-common/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,4CAAoB;AACpB,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,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAA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,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,iBAAO,CAAC;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 '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.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.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,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;QACxC,OAAO,CAAC,OAAO,CAAC,CAAC;KAClB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AAC,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"]}
@@ -14,8 +14,7 @@ const path_1 = __importDefault(require("path"));
14
14
  const username_1 = __importDefault(require("username"));
15
15
  const uuid_1 = __importDefault(require("uuid"));
16
16
  const child_process_1 = __importDefault(require("child_process"));
17
- const fs_1 = __importDefault(require("fs"));
18
- const os_1 = __importDefault(require("os"));
17
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
19
18
  const semver_1 = __importDefault(require("semver"));
20
19
  const lodash_1 = __importDefault(require("lodash"));
21
20
  const find_up_1 = __importDefault(require("find-up"));
@@ -25,30 +24,6 @@ const telemetry_1 = require("@react-native-windows/telemetry");
25
24
  const package_utils_1 = require("@react-native-windows/package-utils");
26
25
  const windowsDir = 'windows';
27
26
  const bundleDir = 'Bundle';
28
- async function generateCertificate(srcPath, destPath, newProjectName, currentUser) {
29
- console.log('Generating self-signed certificate...');
30
- if (os_1.default.platform() === 'win32') {
31
- try {
32
- const thumbprint = child_process_1.default
33
- .execSync(`powershell -NoProfile -Command "Write-Output (New-SelfSignedCertificate -KeyUsage DigitalSignature -KeyExportPolicy Exportable -Subject 'CN=${currentUser}' -TextExtension @('2.5.29.37={text}1.3.6.1.5.5.7.3.3', '2.5.29.19={text}Subject Type:End Entity') -CertStoreLocation 'Cert:\\CurrentUser\\My').Thumbprint"`)
34
- .toString()
35
- .trim();
36
- if (!fs_1.default.existsSync(path_1.default.join(windowsDir, newProjectName))) {
37
- fs_1.default.mkdirSync(path_1.default.join(windowsDir, newProjectName));
38
- }
39
- child_process_1.default.execSync(`powershell -NoProfile -Command "$pwd = (ConvertTo-SecureString -String password -Force -AsPlainText); Export-PfxCertificate -Cert 'cert:\\CurrentUser\\My\\${thumbprint}' -FilePath ${path_1.default.join(windowsDir, newProjectName, newProjectName)}_TemporaryKey.pfx -Password $pwd"`);
40
- console.log(chalk_1.default.green('Self-signed certificate generated successfully.'));
41
- return thumbprint;
42
- }
43
- catch (err) {
44
- console.log(chalk_1.default.yellow('Unable to generate the self-signed certificate:'));
45
- console.log(chalk_1.default.red(err));
46
- }
47
- }
48
- console.log(chalk_1.default.yellow('Using Default Certificate. Use Visual Studio to renew it.'));
49
- await generator_common_1.copyAndReplaceWithChangedCallback(path_1.default.join(srcPath, 'keys', 'MyApp_TemporaryKey.pfx'), destPath, path_1.default.join(windowsDir, newProjectName, newProjectName + '_TemporaryKey.pfx'));
50
- return null;
51
- }
52
27
  function pascalCase(str) {
53
28
  const camelCase = lodash_1.default.camelCase(str);
54
29
  return camelCase[0].toUpperCase() + camelCase.substr(1);
@@ -78,16 +53,13 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
78
53
  }
79
54
  // Similar to the above, but we want to retain namespace separators
80
55
  if (projectType === 'lib') {
81
- namespace = namespace
82
- .split(/[.:]+/)
83
- .map(pascalCase)
84
- .join('.');
56
+ namespace = namespace.split(/[.:]+/).map(pascalCase).join('.');
85
57
  }
86
- generator_common_1.createDir(path_1.default.join(destPath, windowsDir));
87
- generator_common_1.createDir(path_1.default.join(destPath, windowsDir, newProjectName));
58
+ (0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir));
59
+ (0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName));
88
60
  if (projectType === 'app') {
89
- generator_common_1.createDir(path_1.default.join(destPath, windowsDir, newProjectName, bundleDir));
90
- generator_common_1.createDir(path_1.default.join(destPath, windowsDir, newProjectName, 'BundleBuilder'));
61
+ (0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName, bundleDir));
62
+ (0, generator_common_1.createDir)(path_1.default.join(destPath, windowsDir, newProjectName, 'BundleBuilder'));
91
63
  }
92
64
  const language = options.language;
93
65
  const namespaceCpp = toCppNamespace(namespace);
@@ -106,23 +78,21 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
106
78
  const packageGuid = uuid_1.default.v4();
107
79
  const currentUser = username_1.default.sync(); // Gets the current username depending on the platform.
108
80
  let mainComponentName = newProjectName;
109
- const appJsonPath = await find_up_1.default('app.json', { cwd: destPath });
81
+ const appJsonPath = await (0, find_up_1.default)('app.json', { cwd: destPath });
110
82
  if (appJsonPath) {
111
- mainComponentName = JSON.parse(fs_1.default.readFileSync(appJsonPath, 'utf8')).name;
83
+ const appJson = await fs_1.default.readJsonFile(appJsonPath);
84
+ mainComponentName = appJson.name;
112
85
  }
113
- const certificateThumbprint = projectType === 'app'
114
- ? await generateCertificate(srcPath, destPath, newProjectName, currentUser)
115
- : null;
116
86
  const xamlNamespace = options.useWinUI3
117
87
  ? 'Microsoft.UI.Xaml'
118
88
  : 'Windows.UI.Xaml';
119
89
  const xamlNamespaceCpp = toCppNamespace(xamlNamespace);
120
90
  const winuiPropsPath = resolveRnwPath('PropertySheets/WinUI.props');
121
- const winuiProps = configUtils_1.readProjectFile(winuiPropsPath);
122
- const winui3Version = configUtils_1.findPropertyValue(winuiProps, 'WinUI3Version', winuiPropsPath);
123
- const winui2xVersion = configUtils_1.findPropertyValue(winuiProps, 'WinUI2xVersion', winuiPropsPath);
91
+ const winuiProps = (0, configUtils_1.readProjectFile)(winuiPropsPath);
92
+ const winui3Version = (0, configUtils_1.findPropertyValue)(winuiProps, 'WinUI3Version', winuiPropsPath);
93
+ const winui2xVersion = (0, configUtils_1.findPropertyValue)(winuiProps, 'WinUI2xVersion', winuiPropsPath);
124
94
  const jsEnginePropsPath = resolveRnwPath('PropertySheets/JSengine.props');
125
- const hermesVersion = configUtils_1.findPropertyValue(configUtils_1.readProjectFile(jsEnginePropsPath), 'HermesVersion', jsEnginePropsPath);
95
+ const hermesVersion = (0, configUtils_1.findPropertyValue)((0, configUtils_1.readProjectFile)(jsEnginePropsPath), 'HermesVersion', jsEnginePropsPath);
126
96
  const csNugetPackages = [
127
97
  {
128
98
  id: 'Microsoft.NETCore.UniversalWindowsPlatform',
@@ -136,16 +106,11 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
136
106
  const cppNugetPackages = [
137
107
  {
138
108
  id: 'Microsoft.Windows.CppWinRT',
139
- version: '2.0.210312.4',
140
- propsTopOfFile: true,
141
- hasProps: true,
142
- hasTargets: true,
109
+ version: '2.0.211028.7',
143
110
  },
144
111
  {
145
112
  id: 'ReactNative.Hermes.Windows',
146
113
  version: hermesVersion,
147
- hasProps: false,
148
- hasTargets: true,
149
114
  },
150
115
  ];
151
116
  if (options.experimentalNuGetDependency) {
@@ -156,14 +121,10 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
156
121
  cppNugetPackages.push({
157
122
  id: 'Microsoft.ReactNative',
158
123
  version: nugetVersion,
159
- hasProps: false,
160
- hasTargets: true,
161
124
  });
162
125
  cppNugetPackages.push({
163
126
  id: 'Microsoft.ReactNative.Cxx',
164
127
  version: nugetVersion,
165
- hasProps: false,
166
- hasTargets: true,
167
128
  });
168
129
  }
169
130
  const packagesConfigCppNugetPackages = [
@@ -171,8 +132,6 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
171
132
  {
172
133
  id: options.useWinUI3 ? 'Microsoft.WinUI' : 'Microsoft.UI.Xaml',
173
134
  version: options.useWinUI3 ? winui3Version : winui2xVersion,
174
- hasProps: false,
175
- hasTargets: false,
176
135
  },
177
136
  ];
178
137
  const templateVars = {
@@ -182,6 +141,7 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
182
141
  namespace: namespace,
183
142
  namespaceCpp: namespaceCpp,
184
143
  languageIsCpp: language === 'cpp',
144
+ rnwVersion: await (0, telemetry_1.getVersionOfNpmPackage)('react-native-windows'),
185
145
  mainComponentName: mainComponentName,
186
146
  // Visual Studio is very picky about the casing of the guids for projects, project references and the solution
187
147
  // https://www.bing.com/search?q=visual+studio+project+guid+casing&cvid=311a5ad7f9fc41089507b24600d23ee7&FORM=ANAB01&PC=U531
@@ -191,9 +151,9 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
191
151
  // packaging and signing variables:
192
152
  packageGuid: packageGuid,
193
153
  currentUser: currentUser,
194
- certificateThumbprint: certificateThumbprint,
195
154
  useExperimentalNuget: options.experimentalNuGetDependency,
196
155
  nuGetTestFeed: options.nuGetTestFeed,
156
+ nuGetADOFeed: nugetVersion.startsWith('0.0.0-'),
197
157
  // cpp template variables
198
158
  useWinUI3: options.useWinUI3,
199
159
  useHermes: options.useHermes,
@@ -209,7 +169,7 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
209
169
  autolinkCsUsingNamespaces: '',
210
170
  autolinkCsReactPackageProviders: '',
211
171
  autolinkCppIncludes: '',
212
- autolinkCppPackageProviders: '\n UNREFERENCED_PARAMETER(packageProviders);',
172
+ autolinkCppPackageProviders: '\n UNREFERENCED_PARAMETER(packageProviders);', // CODESYNC: vnext\local-cli\runWindows\utils\autolink.js
213
173
  };
214
174
  const commonMappings = projectType === 'app'
215
175
  ? [
@@ -249,7 +209,7 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
249
209
  },
250
210
  ];
251
211
  for (const mapping of commonMappings) {
252
- await generator_common_1.copyAndReplaceWithChangedCallback(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
212
+ await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
253
213
  }
254
214
  if (language === 'cs') {
255
215
  const csMappings = projectType === 'app'
@@ -267,8 +227,12 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
267
227
  to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.csproj'),
268
228
  },
269
229
  ];
230
+ csMappings.push({
231
+ from: path_1.default.join(srcPath, projDir, 'Directory.Build.props'),
232
+ to: path_1.default.join(windowsDir, 'Directory.Build.props'),
233
+ });
270
234
  for (const mapping of csMappings) {
271
- await generator_common_1.copyAndReplaceWithChangedCallback(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
235
+ await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
272
236
  }
273
237
  }
274
238
  else {
@@ -283,10 +247,6 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
283
247
  from: path_1.default.join(srcPath, projDir, 'MyApp.vcxproj.filters'),
284
248
  to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.vcxproj.filters'),
285
249
  },
286
- {
287
- from: path_1.default.join(srcPath, projDir, 'packages.config'),
288
- to: path_1.default.join(windowsDir, newProjectName, 'packages.config'),
289
- },
290
250
  ]
291
251
  : [
292
252
  // cpp lib mappings
@@ -302,13 +262,9 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
302
262
  from: path_1.default.join(srcPath, projDir, 'MyLib.def'),
303
263
  to: path_1.default.join(windowsDir, newProjectName, newProjectName + '.def'),
304
264
  },
305
- {
306
- from: path_1.default.join(srcPath, projDir, 'packages.config'),
307
- to: path_1.default.join(windowsDir, newProjectName, 'packages.config'),
308
- },
309
265
  ];
310
266
  for (const mapping of cppMappings) {
311
- await generator_common_1.copyAndReplaceWithChangedCallback(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
267
+ await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
312
268
  }
313
269
  }
314
270
  // shared proj
@@ -325,20 +281,20 @@ async function copyProjectTemplateAndReplace(srcRootPath, destPath, newProjectNa
325
281
  });
326
282
  }
327
283
  for (const mapping of sharedProjMappings) {
328
- await generator_common_1.copyAndReplaceWithChangedCallback(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
284
+ await (0, generator_common_1.copyAndReplaceWithChangedCallback)(mapping.from, destPath, mapping.to, templateVars, options.overwrite);
329
285
  }
330
286
  }
331
287
  // shared assets
332
288
  if (fs_1.default.existsSync(path_1.default.join(sharedPath, 'assets'))) {
333
- await generator_common_1.copyAndReplaceAll(path_1.default.join(sharedPath, 'assets'), destPath, path_1.default.join(windowsDir, newProjectName, 'Assets'), templateVars, options.overwrite);
289
+ await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(sharedPath, 'assets'), destPath, path_1.default.join(windowsDir, newProjectName, 'Assets'), templateVars, options.overwrite);
334
290
  }
335
291
  // shared src
336
292
  if (fs_1.default.existsSync(path_1.default.join(sharedPath, 'src'))) {
337
- await generator_common_1.copyAndReplaceAll(path_1.default.join(sharedPath, 'src'), destPath, path_1.default.join(windowsDir, newProjectName), templateVars, options.overwrite);
293
+ await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(sharedPath, 'src'), destPath, path_1.default.join(windowsDir, newProjectName), templateVars, options.overwrite);
338
294
  }
339
295
  // src
340
296
  if (fs_1.default.existsSync(path_1.default.join(srcPath, 'src'))) {
341
- await generator_common_1.copyAndReplaceAll(path_1.default.join(srcPath, 'src'), destPath, path_1.default.join(windowsDir, newProjectName), templateVars, options.overwrite);
297
+ await (0, generator_common_1.copyAndReplaceAll)(path_1.default.join(srcPath, 'src'), destPath, path_1.default.join(windowsDir, newProjectName), templateVars, options.overwrite);
342
298
  }
343
299
  if (projectType === 'app') {
344
300
  console.log(chalk_1.default.white.bold('To run your app on UWP:'));
@@ -358,20 +314,20 @@ async function installScriptsAndDependencies(options) {
358
314
  await projectPackage.mergeProps({
359
315
  scripts: { windows: 'react-native run-windows' },
360
316
  });
361
- const rnwPackage = await package_utils_1.findPackage('react-native-windows');
317
+ const rnwPackage = await (0, package_utils_1.findPackage)('react-native-windows');
362
318
  if (!rnwPackage) {
363
319
  throw new Error('Could not locate the package for react-native-windows');
364
320
  }
365
- const rnPackage = await package_utils_1.findPackage('react-native');
321
+ const rnPackage = await (0, package_utils_1.findPackage)('react-native');
366
322
  if (!rnPackage) {
367
323
  throw new Error('Could not locate the package for react-native');
368
324
  }
369
325
  // We add an exclusionList from metro config. This will be hoisted, but add
370
326
  // an explict dep because we require it directly.
371
- const cliPackage = await package_utils_1.findPackage('@react-native-community/cli', {
327
+ const cliPackage = await (0, package_utils_1.findPackage)('@react-native-community/cli', {
372
328
  searchPath: rnPackage.path,
373
329
  });
374
- const metroConfigPackage = await package_utils_1.findPackage('metro-config', {
330
+ const metroConfigPackage = await (0, package_utils_1.findPackage)('metro-config', {
375
331
  searchPath: (cliPackage === null || cliPackage === void 0 ? void 0 : cliPackage.path) || rnPackage.path,
376
332
  });
377
333
  if (metroConfigPackage) {
@@ -382,7 +338,8 @@ async function installScriptsAndDependencies(options) {
382
338
  });
383
339
  }
384
340
  const rnPeerDependency = rnwPackage.json.peerDependencies['react-native'];
385
- if (!semver_1.default.satisfies(rnPackage.json.version, rnPeerDependency) && ((_a = projectPackage.json.dependencies) === null || _a === void 0 ? void 0 : _a['react-native'])) {
341
+ if (!semver_1.default.satisfies(rnPackage.json.version, rnPeerDependency) &&
342
+ ((_a = projectPackage.json.dependencies) === null || _a === void 0 ? void 0 : _a['react-native'])) {
386
343
  console.log(chalk_1.default.green('Installing a compatible version of react-native:'));
387
344
  console.log(chalk_1.default.white(` ${rnPeerDependency}`));
388
345
  // Patch package.json to have proper react-native version and install