@react-native-windows/cli 0.0.0-canary.19 → 0.0.0-canary.191

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 (138) hide show
  1. package/README.md +47 -0
  2. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +87 -0
  3. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +661 -0
  4. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js.map +1 -0
  5. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -0
  6. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +33 -0
  7. package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js.map +1 -0
  8. package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -0
  9. package/lib-commonjs/commands/codegenWindows/codegenWindows.js +206 -0
  10. package/lib-commonjs/commands/codegenWindows/codegenWindows.js.map +1 -0
  11. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -0
  12. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +23 -0
  13. package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js.map +1 -0
  14. package/lib-commonjs/{config → commands/config}/configUtils.d.ts +25 -2
  15. package/lib-commonjs/{config → commands/config}/configUtils.js +142 -32
  16. package/lib-commonjs/commands/config/configUtils.js.map +1 -0
  17. package/lib-commonjs/commands/config/dependencyConfig.js +228 -0
  18. package/lib-commonjs/commands/config/dependencyConfig.js.map +1 -0
  19. package/lib-commonjs/{config → commands/config}/projectConfig.d.ts +4 -1
  20. package/lib-commonjs/{config → commands/config}/projectConfig.js +72 -12
  21. package/lib-commonjs/commands/config/projectConfig.js.map +1 -0
  22. package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -0
  23. package/lib-commonjs/commands/healthCheck/healthCheckList.js +21 -0
  24. package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -0
  25. package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -0
  26. package/lib-commonjs/commands/healthCheck/healthChecks.js +124 -0
  27. package/lib-commonjs/commands/healthCheck/healthChecks.js.map +1 -0
  28. package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -0
  29. package/lib-commonjs/commands/initWindows/initWindows.js +244 -0
  30. package/lib-commonjs/commands/initWindows/initWindows.js.map +1 -0
  31. package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -0
  32. package/lib-commonjs/commands/initWindows/initWindowsOptions.js +38 -0
  33. package/lib-commonjs/commands/initWindows/initWindowsOptions.js.map +1 -0
  34. package/lib-commonjs/commands/runWindows/runWindows.js +322 -0
  35. package/lib-commonjs/commands/runWindows/runWindows.js.map +1 -0
  36. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.d.ts +15 -11
  37. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.js +12 -11
  38. package/lib-commonjs/commands/runWindows/runWindowsOptions.js.map +1 -0
  39. package/lib-commonjs/e2etest/autolink.test.d.ts +6 -0
  40. package/lib-commonjs/e2etest/autolink.test.js +367 -0
  41. package/lib-commonjs/e2etest/autolink.test.js.map +1 -0
  42. package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -0
  43. package/lib-commonjs/e2etest/dependencyConfig.test.js +130 -0
  44. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -0
  45. package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -0
  46. package/lib-commonjs/e2etest/healthChecks.test.js +31 -0
  47. package/lib-commonjs/e2etest/healthChecks.test.js.map +1 -0
  48. package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -0
  49. package/lib-commonjs/e2etest/initWindows.test.js +43 -0
  50. package/lib-commonjs/e2etest/initWindows.test.js.map +1 -0
  51. package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -0
  52. package/lib-commonjs/e2etest/projectConfig.test.js +111 -0
  53. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -0
  54. package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -0
  55. package/lib-commonjs/e2etest/projectConfig.utils.js +77 -0
  56. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -0
  57. package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -0
  58. package/lib-commonjs/e2etest/runWindows.test.js +61 -0
  59. package/lib-commonjs/e2etest/runWindows.test.js.map +1 -0
  60. package/lib-commonjs/generator-common/index.d.ts +17 -1
  61. package/lib-commonjs/generator-common/index.js +61 -40
  62. package/lib-commonjs/generator-common/index.js.map +1 -1
  63. package/lib-commonjs/generator-windows/index.d.ts +2 -2
  64. package/lib-commonjs/generator-windows/index.js +159 -204
  65. package/lib-commonjs/generator-windows/index.js.map +1 -1
  66. package/lib-commonjs/index.d.ts +6 -2
  67. package/lib-commonjs/index.js +51 -13
  68. package/lib-commonjs/index.js.map +1 -1
  69. package/lib-commonjs/{runWindows/utils → utils}/build.d.ts +2 -3
  70. package/lib-commonjs/{runWindows/utils → utils}/build.js +24 -31
  71. package/lib-commonjs/utils/build.js.map +1 -0
  72. package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.js +11 -7
  73. package/lib-commonjs/utils/checkRequirements.js.map +1 -0
  74. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.d.ts +11 -3
  75. package/lib-commonjs/utils/commandWithProgress.js +150 -0
  76. package/lib-commonjs/utils/commandWithProgress.js.map +1 -0
  77. package/lib-commonjs/{runWindows/utils → utils}/deploy.d.ts +2 -2
  78. package/lib-commonjs/utils/deploy.js +354 -0
  79. package/lib-commonjs/utils/deploy.js.map +1 -0
  80. package/lib-commonjs/{runWindows/utils → utils}/info.js +5 -2
  81. package/lib-commonjs/utils/info.js.map +1 -0
  82. package/lib-commonjs/utils/msbuildtools.d.ts +28 -0
  83. package/lib-commonjs/utils/msbuildtools.js +274 -0
  84. package/lib-commonjs/utils/msbuildtools.js.map +1 -0
  85. package/lib-commonjs/utils/pathHelpers.d.ts +9 -0
  86. package/lib-commonjs/utils/pathHelpers.js +37 -0
  87. package/lib-commonjs/utils/pathHelpers.js.map +1 -0
  88. package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -0
  89. package/lib-commonjs/utils/telemetryHelpers.js +121 -0
  90. package/lib-commonjs/utils/telemetryHelpers.js.map +1 -0
  91. package/lib-commonjs/{runWindows/utils → utils}/version.d.ts +4 -4
  92. package/lib-commonjs/utils/version.js.map +1 -0
  93. package/lib-commonjs/{runWindows/utils → utils}/vsInstalls.d.ts +2 -2
  94. package/lib-commonjs/utils/vsInstalls.js +100 -0
  95. package/lib-commonjs/utils/vsInstalls.js.map +1 -0
  96. package/lib-commonjs/{runWindows/utils → utils}/vstools.d.ts +2 -1
  97. package/lib-commonjs/utils/vstools.js +190 -0
  98. package/lib-commonjs/utils/vstools.js.map +1 -0
  99. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.d.ts +3 -3
  100. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.js +17 -14
  101. package/lib-commonjs/utils/winappdeploytool.js.map +1 -0
  102. package/package.json +47 -29
  103. package/{powershell → src/powershell}/Add-AppDevPackage.ps1 +2 -2
  104. package/src/powershell/Eval-MsBuildProperties.ps1 +156 -0
  105. package/{powershell → src/powershell}/WindowsStoreAppUtils.ps1 +10 -0
  106. package/CHANGELOG.json +0 -287
  107. package/CHANGELOG.md +0 -143
  108. package/lib-commonjs/config/configUtils.js.map +0 -1
  109. package/lib-commonjs/config/dependencyConfig.js +0 -167
  110. package/lib-commonjs/config/dependencyConfig.js.map +0 -1
  111. package/lib-commonjs/config/projectConfig.js.map +0 -1
  112. package/lib-commonjs/runWindows/runWindows.js +0 -159
  113. package/lib-commonjs/runWindows/runWindows.js.map +0 -1
  114. package/lib-commonjs/runWindows/runWindowsOptions.js.map +0 -1
  115. package/lib-commonjs/runWindows/utils/autolink.d.ts +0 -7
  116. package/lib-commonjs/runWindows/utils/autolink.js +0 -353
  117. package/lib-commonjs/runWindows/utils/autolink.js.map +0 -1
  118. package/lib-commonjs/runWindows/utils/build.js.map +0 -1
  119. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +0 -1
  120. package/lib-commonjs/runWindows/utils/commandWithProgress.js +0 -114
  121. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +0 -1
  122. package/lib-commonjs/runWindows/utils/deploy.js +0 -247
  123. package/lib-commonjs/runWindows/utils/deploy.js.map +0 -1
  124. package/lib-commonjs/runWindows/utils/info.js.map +0 -1
  125. package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +0 -22
  126. package/lib-commonjs/runWindows/utils/msbuildtools.js +0 -195
  127. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +0 -1
  128. package/lib-commonjs/runWindows/utils/version.js.map +0 -1
  129. package/lib-commonjs/runWindows/utils/vsInstalls.js +0 -70
  130. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +0 -1
  131. package/lib-commonjs/runWindows/utils/vstools.js +0 -150
  132. package/lib-commonjs/runWindows/utils/vstools.js.map +0 -1
  133. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +0 -1
  134. /package/lib-commonjs/{config → commands/config}/dependencyConfig.d.ts +0 -0
  135. /package/lib-commonjs/{runWindows → commands/runWindows}/runWindows.d.ts +0 -0
  136. /package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.d.ts +0 -0
  137. /package/lib-commonjs/{runWindows/utils → utils}/info.d.ts +0 -0
  138. /package/lib-commonjs/{runWindows/utils → utils}/version.js +0 -0
@@ -4,33 +4,71 @@
4
4
  * Licensed under the MIT License.
5
5
  * @format
6
6
  */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = 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);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || function (mod) {
24
+ if (mod && mod.__esModule) return mod;
25
+ var result = {};
26
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
+ __setModuleDefault(result, mod);
28
+ return result;
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
7
33
  Object.defineProperty(exports, "__esModule", { value: true });
8
34
  exports.projectConfigWindows = void 0;
9
- const path = require("path");
10
- const configUtils = require("./configUtils.js");
35
+ // Types in this file are inaccurate compared to usage in terms of falsiness.
36
+ // We should try to rewrite some of this to do automated schema validation to
37
+ // guarantee correct types
38
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition */
39
+ const os_1 = require("os");
40
+ const path_1 = __importDefault(require("path"));
41
+ const configUtils = __importStar(require("./configUtils"));
11
42
  /**
12
43
  * Gets the config of any RNW apps under the target folder.
13
44
  * @param folder The absolute path to the target folder.
14
45
  * @param userConfig A manually specified override config.
15
46
  * @return The config if any RNW apps exist.
16
47
  */
48
+ // Disabled due to existing high cyclomatic complexity
49
+ // eslint-disable-next-line complexity
17
50
  function projectConfigWindows(folder, userConfig = {}) {
51
+ var _a;
52
+ if ((0, os_1.platform)() !== 'win32') {
53
+ return null;
54
+ }
18
55
  if (userConfig === null) {
19
56
  return null;
20
57
  }
21
58
  const usingManualOverride = 'sourceDir' in userConfig;
22
59
  const sourceDir = usingManualOverride
23
- ? path.join(folder, userConfig.sourceDir)
60
+ ? path_1.default.join(folder, userConfig.sourceDir)
24
61
  : configUtils.findWindowsFolder(folder);
25
62
  if (sourceDir === null) {
26
63
  // Nothing to look for here, bail
27
64
  return null;
28
65
  }
29
- var result = {
66
+ const result = {
30
67
  folder: folder,
31
- sourceDir: sourceDir.substr(folder.length + 1),
68
+ sourceDir: path_1.default.relative(folder, sourceDir),
32
69
  };
33
- var validProject = false;
70
+ let validSolution = false;
71
+ let validProject = false;
34
72
  if (usingManualOverride) {
35
73
  // Manual override, try to use it for solutionFile
36
74
  if (!('solutionFile' in userConfig)) {
@@ -42,7 +80,8 @@ function projectConfigWindows(folder, userConfig = {}) {
42
80
  'Error: Solution file is null in react-native.config.';
43
81
  }
44
82
  else {
45
- result.solutionFile = userConfig.solutionFile;
83
+ result.solutionFile = path_1.default.normalize(userConfig.solutionFile);
84
+ validSolution = true;
46
85
  }
47
86
  // Manual override, try to use it for project
48
87
  if (!('project' in userConfig)) {
@@ -68,11 +107,14 @@ function projectConfigWindows(folder, userConfig = {}) {
68
107
  }
69
108
  else {
70
109
  result.project = {
71
- projectFile: userConfig.project.projectFile,
110
+ projectFile: path_1.default.normalize(userConfig.project.projectFile),
72
111
  };
73
112
  validProject = true;
74
113
  }
75
114
  }
115
+ if ('useWinUI3' in userConfig) {
116
+ result.useWinUI3 = userConfig.useWinUI3;
117
+ }
76
118
  }
77
119
  else {
78
120
  // No manually provided solutionFile, try to find it
@@ -86,7 +128,8 @@ function projectConfigWindows(folder, userConfig = {}) {
86
128
  'Error: Too many app solution files found, please specify in react-native.config.';
87
129
  }
88
130
  else {
89
- result.solutionFile = foundSolutions[0];
131
+ result.solutionFile = path_1.default.normalize(foundSolutions[0]);
132
+ validSolution = true;
90
133
  }
91
134
  // No manually provided project, try to find it
92
135
  const foundProjects = configUtils.findAppProjectFiles(sourceDir);
@@ -102,18 +145,35 @@ function projectConfigWindows(folder, userConfig = {}) {
102
145
  }
103
146
  else {
104
147
  result.project = {
105
- projectFile: foundProjects[0],
148
+ projectFile: path_1.default.normalize(foundProjects[0]),
106
149
  };
107
150
  validProject = true;
108
151
  }
109
152
  }
153
+ if (validSolution) {
154
+ result.solutionFile = path_1.default.relative(sourceDir, path_1.default.join(sourceDir, result.solutionFile));
155
+ // Populating experimental features from ExperimentalFeatures.props
156
+ const experimentalFeatures = configUtils.getExperimentalFeatures(path_1.default.dirname(path_1.default.join(sourceDir, result.solutionFile)));
157
+ if (experimentalFeatures) {
158
+ result.experimentalFeatures = experimentalFeatures;
159
+ }
160
+ }
110
161
  if (validProject) {
111
- const projectFile = path.join(sourceDir, result.project.projectFile);
162
+ const projectFile = path_1.default.join(sourceDir, result.project.projectFile);
112
163
  const projectContents = configUtils.readProjectFile(projectFile);
164
+ result.project.projectFile = path_1.default.relative(sourceDir, projectFile);
113
165
  // Add missing (auto) items
114
- result.project.projectName = configUtils.getProjectName(projectContents);
166
+ result.project.projectName = configUtils.getProjectName(projectFile, projectContents);
115
167
  result.project.projectLang = configUtils.getProjectLanguage(projectFile);
116
168
  result.project.projectGuid = configUtils.getProjectGuid(projectContents);
169
+ // Since we moved the UseExperimentalNuget property from the project to the
170
+ // ExperimentalFeatures.props file, we should should double-check the project file
171
+ // in case it was made with an older template
172
+ const useExperimentalNuget = configUtils.tryFindPropertyValue(projectContents, 'UseExperimentalNuget');
173
+ if (useExperimentalNuget) {
174
+ result.experimentalFeatures = (_a = result.experimentalFeatures) !== null && _a !== void 0 ? _a : {};
175
+ result.experimentalFeatures.UseExperimentalNuget = useExperimentalNuget;
176
+ }
117
177
  }
118
178
  return result;
119
179
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projectConfig.js","sourceRoot":"","sources":["../../../src/commands/config/projectConfig.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6EAA6E;AAC7E,6EAA6E;AAC7E,0BAA0B;AAC1B,gEAAgE;AAEhE,2BAA4B;AAC5B,gDAAwB;AAExB,2DAA6C;AAiE7C;;;;;GAKG;AACH,sDAAsD;AACtD,sCAAsC;AACtC,SAAgB,o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,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;QAEzE,2EAA2E;QAC3E,kFAAkF;QAClF,6CAA6C;QAC7C,MAAM,oBAAoB,GAAG,WAAW,CAAC,oBAAoB,CAC3D,eAAe,EACf,sBAAsB,CACvB,CAAC;QACF,IAAI,oBAAoB,EAAE;YACxB,MAAM,CAAC,oBAAoB,GAAG,MAAA,MAAM,CAAC,oBAAoB,mCAAI,EAAE,CAAC;YAChE,MAAM,CAAC,oBAAoB,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;SACzE;KACF;IAED,OAAO,MAA8B,CAAC;AACxC,CAAC;AAxJD,oDAwJC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\n// Types in this file are inaccurate compared to usage in terms of falsiness.\n// We should try to rewrite some of this to do automated schema validation to\n// guarantee correct types\n/* eslint-disable @typescript-eslint/no-unnecessary-condition */\n\nimport {platform} from 'os';\nimport path from 'path';\n\nimport * as configUtils from './configUtils';\n\n/*\n\nreact-native config will generate the following JSON for app projects that have a\nwindows implementation, as a target for auto-linking. This is done heuristically,\nso if the result isn't quite correct, app developers can provide a manual override\nfile: react-native.config.js.\n\nSchema for app projects:\n\nTags:\nauto - Item is always calculated by config. An override file should NEVER provide it.\nreq - Item is required. If an override file exists, it MUST provide it. If no override file exists, config will try to calculate it.\nopt - Item is optional. If an override file exists, it MAY provide it. If no override file exists, config may try to calculate it.\n\n{\n folder: string, // (auto) Absolute path to the app root folder, determined by react-native config, ex: 'c:\\path\\to\\my-app'\n sourceDir: string, // (req) Relative path to the Windows implementation under folder, ex: 'windows'\n solutionFile: string, // (req) Relative path to the app's VS solution file under sourceDir, ex: 'MyApp.sln'\n useWinUI3: boolean // (opt) If true, use WinUI 3. If false, use Windows XAML and WinUI 2.x. If missing, the value from rnwRoot\\PropertySheets\\ExperimentalFeatures.props will be used.\n project: { // (req)\n projectFile: string, // (req) Relative path to the VS project file under sourceDir, ex: 'MyApp\\MyApp.vcxproj' for 'c:\\path\\to\\my-app\\windows\\MyApp\\MyApp.vcxproj'\n projectName: string, // (auto) Name of the project, determined from projectFile, ex: 'MyApp'\n projectLang: string, // (auto) Language of the project, cpp or cs, determined from projectFile\n projectGuid: string, // (auto) Project identifier, determined from projectFile\n },\n experimentalFeatures: Record<String, string> // (auto) Properties extracted from ExperimentalFeatures.props\n}\n\nExample react-native.config.js for a 'MyApp':\n\nmodule.exports = {\n project: {\n windows: {\n sourceDir: 'windows',\n solutionFile: 'MyApp.sln',\n project: {\n projectFile: 'MyApp\\\\MyApp.vcxproj',\n },\n },\n },\n};\n\n*/\n\nexport interface Project {\n projectFile: string;\n projectName: string;\n projectLang: 'cpp' | 'cs' | null;\n projectGuid: string | null;\n projectTypeGuid?: string;\n}\n\nexport interface WindowsProjectConfig {\n folder: string;\n sourceDir: string;\n solutionFile: string;\n project: Project;\n useWinUI3?: boolean;\n experimentalFeatures?: Record<string, string>;\n}\n\ntype DeepPartial<T> = {[P in keyof T]?: DeepPartial<T[P]>};\n\n/**\n * Gets the config of any RNW apps under the target folder.\n * @param folder The absolute path to the target folder.\n * @param userConfig A manually specified override config.\n * @return The config if any RNW apps exist.\n */\n// Disabled due to existing high cyclomatic complexity\n// eslint-disable-next-line complexity\nexport function projectConfigWindows(\n folder: string,\n userConfig: Partial<WindowsProjectConfig> | null = {},\n): WindowsProjectConfig | null {\n if (platform() !== 'win32') {\n return null;\n }\n\n if (userConfig === null) {\n return null;\n }\n\n const usingManualOverride = 'sourceDir' in userConfig;\n\n const sourceDir = usingManualOverride\n ? path.join(folder, userConfig.sourceDir!)\n : configUtils.findWindowsFolder(folder);\n\n if (sourceDir === null) {\n // Nothing to look for here, bail\n return null;\n }\n\n const result: DeepPartial<WindowsProjectConfig> = {\n folder: folder,\n sourceDir: path.relative(folder, sourceDir),\n };\n\n let validSolution = false;\n let validProject = false;\n\n if (usingManualOverride) {\n // Manual override, try to use it for solutionFile\n if (!('solutionFile' in userConfig)) {\n result.solutionFile =\n 'Error: Solution file is required but not specified in react-native.config.';\n } else if (userConfig.solutionFile === null) {\n result.solutionFile =\n 'Error: Solution file is null in react-native.config.';\n } else {\n result.solutionFile = path.normalize(userConfig.solutionFile!);\n validSolution = true;\n }\n\n // Manual override, try to use it for project\n if (!('project' in userConfig)) {\n result.project = {\n projectFile:\n 'Error: Project is required but not specified in react-native.config.',\n };\n } else if (!userConfig.project) {\n result.project = {\n projectFile: 'Error: Project is null in react-native.config.',\n };\n } else {\n if (!('projectFile' in userConfig.project)) {\n result.project = {\n projectFile:\n 'Error: Project file is required for project in react-native.config.',\n };\n } else if (userConfig.project.projectFile === null) {\n result.project = {\n projectFile: 'Error: Project file is null in react-native.config.',\n };\n } else {\n result.project = {\n projectFile: path.normalize(userConfig.project.projectFile),\n };\n validProject = true;\n }\n }\n\n if ('useWinUI3' in userConfig) {\n result.useWinUI3 = userConfig.useWinUI3;\n }\n } else {\n // No manually provided solutionFile, try to find it\n const foundSolutions = configUtils.findSolutionFiles(sourceDir);\n if (foundSolutions.length === 0) {\n result.solutionFile =\n 'Error: No app solution file found, please specify in react-native.config.';\n } else if (foundSolutions.length > 1) {\n result.solutionFile =\n 'Error: Too many app solution files found, please specify in react-native.config.';\n } else {\n result.solutionFile = path.normalize(foundSolutions[0]);\n validSolution = true;\n }\n\n // No manually provided project, try to find it\n const foundProjects = configUtils.findAppProjectFiles(sourceDir);\n if (foundProjects.length === 0) {\n result.project = {\n projectFile:\n 'Error: No app project file found, please specify in react-native.config.',\n };\n } else if (foundProjects.length > 1) {\n result.project = {\n projectFile:\n 'Error: Too many app project files found, please specify in react-native.config.',\n };\n } else {\n result.project = {\n projectFile: path.normalize(foundProjects[0]),\n };\n validProject = true;\n }\n }\n\n if (validSolution) {\n result.solutionFile = path.relative(\n sourceDir,\n path.join(sourceDir, result.solutionFile),\n );\n\n // Populating experimental features from ExperimentalFeatures.props\n const experimentalFeatures = configUtils.getExperimentalFeatures(\n path.dirname(path.join(sourceDir, result.solutionFile)),\n );\n if (experimentalFeatures) {\n result.experimentalFeatures = experimentalFeatures;\n }\n }\n\n if (validProject) {\n const projectFile = path.join(sourceDir, result.project.projectFile!);\n const projectContents = configUtils.readProjectFile(projectFile);\n\n result.project.projectFile = path.relative(sourceDir, projectFile);\n\n // Add missing (auto) items\n result.project.projectName = configUtils.getProjectName(\n projectFile,\n projectContents,\n );\n result.project.projectLang = configUtils.getProjectLanguage(projectFile);\n result.project.projectGuid = configUtils.getProjectGuid(projectContents);\n\n // Since we moved the UseExperimentalNuget property from the project to the\n // ExperimentalFeatures.props file, we should should double-check the project file\n // in case it was made with an older template\n const useExperimentalNuget = configUtils.tryFindPropertyValue(\n projectContents,\n 'UseExperimentalNuget',\n );\n if (useExperimentalNuget) {\n result.experimentalFeatures = result.experimentalFeatures ?? {};\n result.experimentalFeatures.UseExperimentalNuget = useExperimentalNuget;\n }\n }\n\n return result as WindowsProjectConfig;\n}\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ export declare const HealthCheckList: (string | boolean)[][];
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.HealthCheckList = void 0;
9
+ // Store list of health checks here to avoid having to launch PowerShell on every react-native config call
10
+ exports.HealthCheckList = [
11
+ [false, 'FreeSpace', 'Free space on current drive > 15 GB'],
12
+ [false, 'InstalledMemory', 'Installed memory >= 16 GB'],
13
+ [true, 'WindowsVersion', 'Windows version >= 10.0.17763.0'],
14
+ [true, 'DeveloperMode', 'Developer mode is on'],
15
+ [true, 'LongPath', 'Long path support is enabled'],
16
+ [true, 'VSUWP', 'Visual Studio 2022 (>= 17.3) & req. components'],
17
+ [true, 'Node', 'Node.js (LTS, >= 18.0)'],
18
+ [true, 'Yarn', 'Yarn'],
19
+ [true, 'DotNetCore', '.NET SDK (LTS, = 6.0)'],
20
+ ];
21
+ //# sourceMappingURL=healthCheckList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"healthCheckList.js","sourceRoot":"","sources":["../../../src/commands/healthCheck/healthCheckList.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,0GAA0G;AAC7F,QAAA,eAAe,GAAG;IAC7B,CAAC,KAAK,EAAE,WAAW,EAAE,qCAAqC,CAAC;IAC3D,CAAC,KAAK,EAAE,iBAAiB,EAAE,2BAA2B,CAAC;IACvD,CAAC,IAAI,EAAE,gBAAgB,EAAE,iCAAiC,CAAC;IAC3D,CAAC,IAAI,EAAE,eAAe,EAAE,sBAAsB,CAAC;IAC/C,CAAC,IAAI,EAAE,UAAU,EAAE,8BAA8B,CAAC;IAClD,CAAC,IAAI,EAAE,OAAO,EAAE,gDAAgD,CAAC;IACjE,CAAC,IAAI,EAAE,MAAM,EAAE,wBAAwB,CAAC;IACxC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC;IACtB,CAAC,IAAI,EAAE,YAAY,EAAE,uBAAuB,CAAC;CAC9C,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\n// Store list of health checks here to avoid having to launch PowerShell on every react-native config call\nexport const HealthCheckList = [\n [false, 'FreeSpace', 'Free space on current drive > 15 GB'],\n [false, 'InstalledMemory', 'Installed memory >= 16 GB'],\n [true, 'WindowsVersion', 'Windows version >= 10.0.17763.0'],\n [true, 'DeveloperMode', 'Developer mode is on'],\n [true, 'LongPath', 'Long path support is enabled'],\n [true, 'VSUWP', 'Visual Studio 2022 (>= 17.3) & req. components'],\n [true, 'Node', 'Node.js (LTS, >= 18.0)'],\n [true, 'Yarn', 'Yarn'],\n [true, 'DotNetCore', '.NET SDK (LTS, = 6.0)'],\n];\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import type { HealthCheckCategory } from '@react-native-community/cli-doctor/build/types';
7
+ export declare function getHealthChecks(): HealthCheckCategory[] | undefined;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = 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);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || function (mod) {
24
+ if (mod && mod.__esModule) return mod;
25
+ var result = {};
26
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
+ __setModuleDefault(result, mod);
28
+ return result;
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.getHealthChecks = void 0;
35
+ const path_1 = __importDefault(require("path"));
36
+ const pathHelpers = __importStar(require("../../utils/pathHelpers"));
37
+ const rnDir = pathHelpers.resolveRnRoot(process.cwd());
38
+ const cliDir = pathHelpers.resolveRnCliRoot(rnDir);
39
+ const execaPath = require.resolve('execa', { paths: [cliDir] });
40
+ const execa = require(execaPath);
41
+ const commandWithProgress_1 = require("../../utils/commandWithProgress");
42
+ const healthCheckList_1 = require("./healthCheckList");
43
+ function getHealthChecks() {
44
+ // #8471: There are known cases where the dependencies script will error out.
45
+ // Fail gracefully if that happens in the meantime.
46
+ try {
47
+ return getHealthChecksUnsafe();
48
+ }
49
+ catch (_a) {
50
+ return [
51
+ {
52
+ label: 'Windows',
53
+ healthchecks: [
54
+ {
55
+ label: 'Failed to enumerate health checks',
56
+ description: 'Failed to enumerate health checks',
57
+ getDiagnostics: async () => ({ needsToBeFixed: true }),
58
+ runAutomaticFix: async ({ loader }) => {
59
+ loader.fail();
60
+ },
61
+ },
62
+ ],
63
+ },
64
+ ];
65
+ }
66
+ }
67
+ exports.getHealthChecks = getHealthChecks;
68
+ function getHealthChecksUnsafe() {
69
+ // All our health checks are windows only...
70
+ if (process.platform !== 'win32') {
71
+ return undefined;
72
+ }
73
+ const rnwDepScriptPath = path_1.default.join(pathHelpers.resolveRnwRoot(process.cwd()), 'Scripts/rnw-dependencies.ps1');
74
+ return [
75
+ {
76
+ label: 'Windows',
77
+ healthchecks: healthCheckList_1.HealthCheckList.map((dep) => {
78
+ const [optional, id, name] = dep;
79
+ return {
80
+ label: name,
81
+ description: name,
82
+ // The schema check of react-native doctor requires this to be a string, although it should be a boolean
83
+ // Enable this once we pick up a new version of the CLI that includes https://github.com/react-native-community/cli/pull/1367
84
+ isRequired: optional,
85
+ getDiagnostics: async () => {
86
+ let needsToBeFixed = true;
87
+ try {
88
+ await execa(`"${commandWithProgress_1.powershell}" -ExecutionPolicy Unrestricted -NoProfile "${rnwDepScriptPath}" -NoPrompt -Check ${id}`);
89
+ needsToBeFixed = false;
90
+ }
91
+ catch (_a) { }
92
+ return {
93
+ needsToBeFixed,
94
+ };
95
+ },
96
+ runAutomaticFix: async ({ loader, logManualInstallation }) => {
97
+ const command = `${commandWithProgress_1.powershell} -ExecutionPolicy Unrestricted -NoProfile "${rnwDepScriptPath}" -Check ${id}`;
98
+ try {
99
+ const { exitCode } = await execa(command, { stdio: 'inherit' });
100
+ if (exitCode) {
101
+ logManualInstallation({
102
+ command,
103
+ healthcheck: `react-native-windows dependency "${id}"`,
104
+ });
105
+ loader.fail();
106
+ }
107
+ else {
108
+ loader.succeed();
109
+ }
110
+ }
111
+ catch (_a) {
112
+ logManualInstallation({
113
+ command,
114
+ healthcheck: `react-native-windows dependency "${id}"`,
115
+ });
116
+ loader.fail();
117
+ }
118
+ },
119
+ };
120
+ }),
121
+ },
122
+ ];
123
+ }
124
+ //# sourceMappingURL=healthChecks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"healthChecks.js","sourceRoot":"","sources":["../../../src/commands/healthCheck/healthChecks.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAwB;AAExB,qEAAuD;AAEvD,MAAM,KAAK,GAAG,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AACvD,MAAM,MAAM,GAAG,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;AAEnD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,EAAC,KAAK,EAAE,CAAC,MAAM,CAAC,EAAC,CAAC,CAAC;AAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAMjC,yEAA2D;AAC3D,uDAAkD;AAElD,SAAgB,eAAe;IAC7B,6EAA6E;IAC7E,mDAAmD;IACnD,IAAI;QACF,OAAO,qBAAqB,EAAE,CAAC;KAChC;IAAC,WAAM;QACN,OAAO;YACL;gBACE,KAAK,EAAE,SAAS;gBAChB,YAAY,EAAE;oBACZ;wBACE,KAAK,EAAE,mCAAmC;wBAC1C,WAAW,EAAE,mCAAmC;wBAChD,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC;wBACpD,eAAe,EAA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EAAE,SAAS,EAAC,CAAC,CAAC;4BAC5D,IAAI,QAAQ,EAAE;gCACZ,qBAAqB,CAAC;oCACpB,OAAO;oCACP,WAAW,EAAE,oCAAoC,EAAE,GAAG;iCACvD,CAAC,CAAC;gCACH,MAAM,CAAC,IAAI,EAAE,CAAC;6BACf;iCAAM;gCACL,MAAM,CAAC,OAAO,EAAE,CAAC;6BAClB;yBACF;wBAAC,WAAM;4BACN,qBAAqB,CAAC;gCACpB,OAAO;gCACP,WAAW,EAAE,oCAAoC,EAAE,GAAG;6BACvD,CAAC,CAAC;4BACH,MAAM,CAAC,IAAI,EAAE,CAAC;yBACf;oBACH,CAAC;iBACsB,CAAC;YAC5B,CAAC,CAAC;SACH;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\n\nimport * as pathHelpers from '../../utils/pathHelpers';\n\nconst rnDir = pathHelpers.resolveRnRoot(process.cwd());\nconst cliDir = pathHelpers.resolveRnCliRoot(rnDir);\n\nconst execaPath = require.resolve('execa', {paths: [cliDir]});\nconst execa = require(execaPath);\n\nimport type {\n HealthCheckCategory,\n HealthCheckInterface,\n} from '@react-native-community/cli-doctor/build/types';\nimport {powershell} from '../../utils/commandWithProgress';\nimport {HealthCheckList} from './healthCheckList';\n\nexport function getHealthChecks(): HealthCheckCategory[] | undefined {\n // #8471: There are known cases where the dependencies script will error out.\n // Fail gracefully if that happens in the meantime.\n try {\n return getHealthChecksUnsafe();\n } catch {\n return [\n {\n label: 'Windows',\n healthchecks: [\n {\n label: 'Failed to enumerate health checks',\n description: 'Failed to enumerate health checks',\n getDiagnostics: async () => ({needsToBeFixed: true}),\n runAutomaticFix: async ({loader}) => {\n loader.fail();\n },\n },\n ],\n },\n ];\n }\n}\n\nfunction getHealthChecksUnsafe(): HealthCheckCategory[] | undefined {\n // All our health checks are windows only...\n if (process.platform !== 'win32') {\n return undefined;\n }\n\n const rnwDepScriptPath = path.join(\n pathHelpers.resolveRnwRoot(process.cwd()),\n 'Scripts/rnw-dependencies.ps1',\n );\n\n return [\n {\n label: 'Windows',\n healthchecks: HealthCheckList.map((dep: [boolean, string, string]) => {\n const [optional, id, name] = dep;\n return {\n label: name,\n description: name,\n // The schema check of react-native doctor requires this to be a string, although it should be a boolean\n // Enable this once we pick up a new version of the CLI that includes https://github.com/react-native-community/cli/pull/1367\n isRequired: optional,\n getDiagnostics: async () => {\n let needsToBeFixed = true;\n try {\n await execa(\n `\"${powershell}\" -ExecutionPolicy Unrestricted -NoProfile \"${rnwDepScriptPath}\" -NoPrompt -Check ${id}`,\n );\n needsToBeFixed = false;\n } catch {}\n return {\n needsToBeFixed,\n };\n },\n runAutomaticFix: async ({loader, logManualInstallation}) => {\n const command = `${powershell} -ExecutionPolicy Unrestricted -NoProfile \"${rnwDepScriptPath}\" -Check ${id}`;\n try {\n const {exitCode} = await execa(command, {stdio: 'inherit'});\n if (exitCode) {\n logManualInstallation({\n command,\n healthcheck: `react-native-windows dependency \"${id}\"`,\n });\n loader.fail();\n } else {\n loader.succeed();\n }\n } catch {\n logManualInstallation({\n command,\n healthcheck: `react-native-windows dependency \"${id}\"`,\n });\n loader.fail();\n }\n },\n } as HealthCheckInterface;\n }),\n },\n ];\n}\n"]}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ import { Ora } from 'ora';
7
+ import { Command, Config } from '@react-native-community/cli-types';
8
+ import { InitOptions } from './initWindowsOptions';
9
+ export interface TemplateFileMapping {
10
+ from: string;
11
+ to: string;
12
+ replacements?: Record<string, any>;
13
+ }
14
+ export interface InitWindowsTemplateConfig {
15
+ name: string;
16
+ description: string;
17
+ isDefault?: boolean;
18
+ preInstall?: (config: Config, options: InitOptions) => Promise<void>;
19
+ getFileMappings?: (config: Config, options: InitOptions) => Promise<TemplateFileMapping[]>;
20
+ postInstall?: (config: Config, options: InitOptions) => Promise<void>;
21
+ }
22
+ export declare class InitWindows {
23
+ readonly config: Config;
24
+ readonly options: InitOptions;
25
+ protected readonly rnwPath: string;
26
+ protected readonly templates: Map<string, InitWindowsTemplateConfig>;
27
+ constructor(config: Config, options: InitOptions);
28
+ protected verboseMessage(message: any): void;
29
+ protected loadTemplates(): Promise<void>;
30
+ protected getDefaultTemplateName(): string;
31
+ protected pascalCase(str: string): string;
32
+ protected isValidProjectName(name: string): boolean;
33
+ protected getReactNativeProjectName(projectDir: string): string;
34
+ run(spinner: Ora): Promise<void>;
35
+ }
36
+ /**
37
+ * Initializes a new RNW project from a given template.
38
+ * @param args Unprocessed args passed from react-native CLI.
39
+ * @param config Config passed from react-native CLI.
40
+ * @param options Options passed from react-native CLI.
41
+ */
42
+ export declare function initWindowsInternal(args: string[], config: Config, options: InitOptions): Promise<void>;
43
+ /**
44
+ * Initializes a new RNW project from a given template.
45
+ */
46
+ export declare const initCommand: Command;
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = 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);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || function (mod) {
24
+ if (mod && mod.__esModule) return mod;
25
+ var result = {};
26
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
+ __setModuleDefault(result, mod);
28
+ return result;
29
+ };
30
+ var __importDefault = (this && this.__importDefault) || function (mod) {
31
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32
+ };
33
+ Object.defineProperty(exports, "__esModule", { value: true });
34
+ exports.initCommand = exports.initWindowsInternal = exports.InitWindows = void 0;
35
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
36
+ const path_1 = __importDefault(require("path"));
37
+ const chalk_1 = __importDefault(require("chalk"));
38
+ const glob_1 = require("glob");
39
+ const lodash_1 = __importDefault(require("lodash"));
40
+ const perf_hooks_1 = require("perf_hooks");
41
+ const util_1 = __importDefault(require("util"));
42
+ const glob = util_1.default.promisify(glob_1.glob);
43
+ const telemetry_1 = require("@react-native-windows/telemetry");
44
+ const commandWithProgress_1 = require("../../utils/commandWithProgress");
45
+ const pathHelpers = __importStar(require("../../utils/pathHelpers"));
46
+ const telemetryHelpers_1 = require("../../utils/telemetryHelpers");
47
+ const generator_common_1 = require("../../generator-common");
48
+ const initWindowsOptions_1 = require("./initWindowsOptions");
49
+ class InitWindows {
50
+ constructor(config, options) {
51
+ this.config = config;
52
+ this.options = options;
53
+ this.templates = new Map();
54
+ this.rnwPath = pathHelpers.resolveRnwRoot(this.config.root);
55
+ }
56
+ verboseMessage(message) {
57
+ verboseMessage(message, !!this.options.logging);
58
+ }
59
+ async loadTemplates() {
60
+ const templatesRoot = path_1.default.join(this.rnwPath, 'templates');
61
+ for (const file of await glob('**/template.config.js', {
62
+ cwd: templatesRoot,
63
+ })) {
64
+ const templateName = path_1.default.dirname(file).replace('\\', '/');
65
+ const templateConfig = require(path_1.default.join(templatesRoot, file));
66
+ this.templates.set(templateName, templateConfig);
67
+ }
68
+ if (this.templates.size === 0) {
69
+ throw new telemetry_1.CodedError('NoTemplatesFound', `No templates were found in ${templatesRoot}.`);
70
+ }
71
+ }
72
+ getDefaultTemplateName() {
73
+ for (const [name, config] of this.templates) {
74
+ if (config.isDefault) {
75
+ return name;
76
+ }
77
+ }
78
+ throw new telemetry_1.CodedError('NoDefaultTemplate', 'No template specified and no default template found.');
79
+ }
80
+ pascalCase(str) {
81
+ const camelCase = lodash_1.default.camelCase(str);
82
+ return camelCase[0].toUpperCase() + camelCase.substr(1);
83
+ }
84
+ isValidProjectName(name) {
85
+ if (name.match(/^[a-z][a-z0-9]*$/gi)) {
86
+ return true;
87
+ }
88
+ return false;
89
+ }
90
+ getReactNativeProjectName(projectDir) {
91
+ this.verboseMessage('Looking for project name in package.json...');
92
+ const pkgJsonPath = path_1.default.join(projectDir, 'package.json');
93
+ if (!fs_1.default.existsSync(pkgJsonPath)) {
94
+ throw new telemetry_1.CodedError('NoPackageJson', 'Unable to find package.json. This should be run from within an existing react-native project.');
95
+ }
96
+ let name = fs_1.default.readJsonFileSync(pkgJsonPath).name;
97
+ if (!name) {
98
+ const appJsonPath = path_1.default.join(projectDir, 'app.json');
99
+ if (fs_1.default.existsSync(appJsonPath)) {
100
+ this.verboseMessage('Looking for project name in app.json...');
101
+ name = fs_1.default.readJsonFileSync(pkgJsonPath).name;
102
+ }
103
+ }
104
+ if (!name) {
105
+ throw new telemetry_1.CodedError('NoProjectName', 'Please specify name in package.json or app.json');
106
+ }
107
+ return name;
108
+ }
109
+ async run(spinner) {
110
+ var _a, _b;
111
+ var _c, _d;
112
+ await this.loadTemplates();
113
+ spinner.info();
114
+ (_a = (_c = this.options).template) !== null && _a !== void 0 ? _a : (_c.template = this.getDefaultTemplateName());
115
+ spinner.info(`Using template '${this.options.template}'...`);
116
+ if (!this.templates.has(this.options.template.replace('\\', '/'))) {
117
+ throw new telemetry_1.CodedError('InvalidTemplateName', `Unable to find template '${this.options.template}'.`);
118
+ }
119
+ const templateConfig = this.templates.get(this.options.template);
120
+ if (this.options.name && !this.isValidProjectName(this.options.name)) {
121
+ throw new telemetry_1.CodedError('InvalidProjectName', `The specified name is not a valid identifier`);
122
+ }
123
+ if (!this.options.name) {
124
+ const projectName = this.getReactNativeProjectName(this.config.root);
125
+ this.options.name = this.isValidProjectName(projectName)
126
+ ? projectName
127
+ : this.pascalCase(projectName);
128
+ }
129
+ (_b = (_d = this.options).namespace) !== null && _b !== void 0 ? _b : (_d.namespace = this.options.name);
130
+ if (templateConfig.preInstall) {
131
+ spinner.info(`Running ${this.options.template} preInstall()...`);
132
+ await templateConfig.preInstall(this.config, this.options);
133
+ }
134
+ // Get template files to copy and copy if available
135
+ if (templateConfig.getFileMappings) {
136
+ const fileMappings = await templateConfig.getFileMappings(this.config, this.options);
137
+ for (const fileMapping of fileMappings) {
138
+ const targetDir = path_1.default.join(this.config.root, path_1.default.dirname(fileMapping.to));
139
+ if (!(await fs_1.default.exists(targetDir))) {
140
+ await fs_1.default.mkdir(targetDir, { recursive: true });
141
+ }
142
+ await (0, generator_common_1.copyAndReplaceWithChangedCallback)(fileMapping.from, this.config.root, fileMapping.to, fileMapping.replacements, this.options.overwrite);
143
+ }
144
+ }
145
+ if (templateConfig.postInstall) {
146
+ spinner.info(`Running ${this.options.template} postInstall()...`);
147
+ await templateConfig.postInstall(this.config, this.options);
148
+ }
149
+ spinner.succeed();
150
+ }
151
+ }
152
+ exports.InitWindows = InitWindows;
153
+ /**
154
+ * Logs the given message if verbose is True.
155
+ * @param message The message to log.
156
+ * @param verbose Whether or not verbose logging is enabled.
157
+ */
158
+ function verboseMessage(message, verbose) {
159
+ if (verbose) {
160
+ console.log(message);
161
+ }
162
+ }
163
+ /**
164
+ * Sanitizes the given option for telemetry.
165
+ * @param key The key of the option.
166
+ * @param value The unsanitized value of the option.
167
+ * @returns The sanitized value of the option.
168
+ */
169
+ function optionSanitizer(key, value) {
170
+ // Do not add a default case here.
171
+ // Strings risking PII should just return true if present, false otherwise.
172
+ // All others should return the value (or false if undefined).
173
+ switch (key) {
174
+ case 'name':
175
+ case 'namespace':
176
+ return value === undefined ? false : true; // Strip PII
177
+ case 'logging':
178
+ case 'template':
179
+ case 'overwrite':
180
+ case 'telemetry':
181
+ return value === undefined ? false : value; // Return value
182
+ }
183
+ }
184
+ /**
185
+ * Get the extra props to add to the `init-windows` telemetry event.
186
+ * @returns The extra props.
187
+ */
188
+ async function getExtraProps() {
189
+ const extraProps = {};
190
+ return extraProps;
191
+ }
192
+ /**
193
+ * The function run when calling `react-native init-windows`.
194
+ * @param args Unprocessed args passed from react-native CLI.
195
+ * @param config Config passed from react-native CLI.
196
+ * @param options Options passed from react-native CLI.
197
+ */
198
+ async function initWindows(args, config, options) {
199
+ await (0, telemetryHelpers_1.startTelemetrySession)('init-windows', config, options, (0, telemetryHelpers_1.getDefaultOptions)(config, initWindowsOptions_1.initOptions), optionSanitizer);
200
+ let initWindowsError;
201
+ try {
202
+ await initWindowsInternal(args, config, options);
203
+ }
204
+ catch (ex) {
205
+ initWindowsError =
206
+ ex instanceof Error ? ex : new Error(String(ex));
207
+ telemetry_1.Telemetry.trackException(initWindowsError);
208
+ }
209
+ await (0, telemetryHelpers_1.endTelemetrySession)(initWindowsError, getExtraProps);
210
+ (0, commandWithProgress_1.setExitProcessWithError)(options.logging, initWindowsError);
211
+ }
212
+ /**
213
+ * Initializes a new RNW project from a given template.
214
+ * @param args Unprocessed args passed from react-native CLI.
215
+ * @param config Config passed from react-native CLI.
216
+ * @param options Options passed from react-native CLI.
217
+ */
218
+ async function initWindowsInternal(args, config, options) {
219
+ const startTime = perf_hooks_1.performance.now();
220
+ const spinner = (0, commandWithProgress_1.newSpinner)('Running init-windows...');
221
+ try {
222
+ const codegen = new InitWindows(config, options);
223
+ await codegen.run(spinner);
224
+ const endTime = perf_hooks_1.performance.now();
225
+ console.log(`${chalk_1.default.green('Success:')} init-windows completed. (${Math.round(endTime - startTime)}ms)`);
226
+ }
227
+ catch (e) {
228
+ spinner.fail();
229
+ const endTime = perf_hooks_1.performance.now();
230
+ console.log(`${chalk_1.default.red('Error:')} ${e.toString()}. (${Math.round(endTime - startTime)}ms)`);
231
+ throw e;
232
+ }
233
+ }
234
+ exports.initWindowsInternal = initWindowsInternal;
235
+ /**
236
+ * Initializes a new RNW project from a given template.
237
+ */
238
+ exports.initCommand = {
239
+ name: 'init-windows',
240
+ description: 'Initializes a new RNW project from a given template.',
241
+ func: initWindows,
242
+ options: initWindowsOptions_1.initOptions,
243
+ };
244
+ //# sourceMappingURL=initWindows.js.map