@react-native-windows/cli 0.0.0-canary.26 → 0.0.0-canary.261

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 (145) hide show
  1. package/README.md +117 -0
  2. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +88 -0
  3. package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +705 -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 +211 -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 +141 -93
  15. package/lib-commonjs/commands/config/configUtils.js +423 -0
  16. package/lib-commonjs/commands/config/configUtils.js.map +1 -0
  17. package/lib-commonjs/{config → commands/config}/dependencyConfig.d.ts +38 -37
  18. package/lib-commonjs/commands/config/dependencyConfig.js +230 -0
  19. package/lib-commonjs/commands/config/dependencyConfig.js.map +1 -0
  20. package/lib-commonjs/{config → commands/config}/projectConfig.d.ts +28 -24
  21. package/lib-commonjs/commands/config/projectConfig.js +191 -0
  22. package/lib-commonjs/commands/config/projectConfig.js.map +1 -0
  23. package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -0
  24. package/lib-commonjs/commands/healthCheck/healthCheckList.js +21 -0
  25. package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -0
  26. package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -0
  27. package/lib-commonjs/commands/healthCheck/healthChecks.js +124 -0
  28. package/lib-commonjs/commands/healthCheck/healthChecks.js.map +1 -0
  29. package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -0
  30. package/lib-commonjs/commands/initWindows/initWindows.js +275 -0
  31. package/lib-commonjs/commands/initWindows/initWindows.js.map +1 -0
  32. package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +16 -0
  33. package/lib-commonjs/commands/initWindows/initWindowsOptions.js +42 -0
  34. package/lib-commonjs/commands/initWindows/initWindowsOptions.js.map +1 -0
  35. package/lib-commonjs/{runWindows → commands/runWindows}/runWindows.d.ts +10 -10
  36. package/lib-commonjs/commands/runWindows/runWindows.js +322 -0
  37. package/lib-commonjs/commands/runWindows/runWindows.js.map +1 -0
  38. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.d.ts +56 -52
  39. package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.js +132 -131
  40. package/lib-commonjs/commands/runWindows/runWindowsOptions.js.map +1 -0
  41. package/lib-commonjs/e2etest/autolink.test.d.ts +6 -0
  42. package/lib-commonjs/e2etest/autolink.test.js +367 -0
  43. package/lib-commonjs/e2etest/autolink.test.js.map +1 -0
  44. package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -0
  45. package/lib-commonjs/e2etest/dependencyConfig.test.js +130 -0
  46. package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -0
  47. package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -0
  48. package/lib-commonjs/e2etest/healthChecks.test.js +31 -0
  49. package/lib-commonjs/e2etest/healthChecks.test.js.map +1 -0
  50. package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -0
  51. package/lib-commonjs/e2etest/initWindows.test.js +110 -0
  52. package/lib-commonjs/e2etest/initWindows.test.js.map +1 -0
  53. package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -0
  54. package/lib-commonjs/e2etest/projectConfig.test.js +112 -0
  55. package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -0
  56. package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -0
  57. package/lib-commonjs/e2etest/projectConfig.utils.js +77 -0
  58. package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -0
  59. package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -0
  60. package/lib-commonjs/e2etest/runWindows.test.js +61 -0
  61. package/lib-commonjs/e2etest/runWindows.test.js.map +1 -0
  62. package/lib-commonjs/e2etest/typesUpToDate.test.d.ts +6 -0
  63. package/lib-commonjs/e2etest/typesUpToDate.test.js +21 -0
  64. package/lib-commonjs/e2etest/typesUpToDate.test.js.map +1 -0
  65. package/lib-commonjs/generator-common/index.d.ts +39 -23
  66. package/lib-commonjs/generator-common/index.js +242 -221
  67. package/lib-commonjs/generator-common/index.js.map +1 -1
  68. package/lib-commonjs/generator-windows/index.d.ts +10 -10
  69. package/lib-commonjs/generator-windows/index.js +341 -364
  70. package/lib-commonjs/generator-windows/index.js.map +1 -1
  71. package/lib-commonjs/index.d.ts +50 -47
  72. package/lib-commonjs/index.js +77 -39
  73. package/lib-commonjs/index.js.map +1 -1
  74. package/lib-commonjs/{runWindows/utils → utils}/build.d.ts +12 -13
  75. package/lib-commonjs/{runWindows/utils → utils}/build.js +89 -91
  76. package/lib-commonjs/utils/build.js.map +1 -0
  77. package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.d.ts +6 -6
  78. package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.js +69 -65
  79. package/lib-commonjs/utils/checkRequirements.js.map +1 -0
  80. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.d.ts +21 -13
  81. package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.js +149 -113
  82. package/lib-commonjs/utils/commandWithProgress.js.map +1 -0
  83. package/lib-commonjs/{runWindows/utils → utils}/deploy.d.ts +12 -12
  84. package/lib-commonjs/utils/deploy.js +354 -0
  85. package/lib-commonjs/utils/deploy.js.map +1 -0
  86. package/lib-commonjs/{runWindows/utils → utils}/info.d.ts +6 -6
  87. package/lib-commonjs/{runWindows/utils → utils}/info.js +28 -25
  88. package/lib-commonjs/utils/info.js.map +1 -0
  89. package/lib-commonjs/utils/msbuildtools.d.ts +28 -0
  90. package/lib-commonjs/utils/msbuildtools.js +281 -0
  91. package/lib-commonjs/utils/msbuildtools.js.map +1 -0
  92. package/lib-commonjs/utils/nameHelpers.d.ts +9 -0
  93. package/lib-commonjs/utils/nameHelpers.js +46 -0
  94. package/lib-commonjs/utils/nameHelpers.js.map +1 -0
  95. package/lib-commonjs/utils/pathHelpers.d.ts +9 -0
  96. package/lib-commonjs/utils/pathHelpers.js +37 -0
  97. package/lib-commonjs/utils/pathHelpers.js.map +1 -0
  98. package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -0
  99. package/lib-commonjs/utils/telemetryHelpers.js +121 -0
  100. package/lib-commonjs/utils/telemetryHelpers.js.map +1 -0
  101. package/lib-commonjs/{runWindows/utils → utils}/version.d.ts +19 -19
  102. package/lib-commonjs/{runWindows/utils → utils}/version.js +109 -109
  103. package/lib-commonjs/utils/version.js.map +1 -0
  104. package/lib-commonjs/{runWindows/utils → utils}/vsInstalls.d.ts +34 -34
  105. package/lib-commonjs/utils/vsInstalls.js +102 -0
  106. package/lib-commonjs/utils/vsInstalls.js.map +1 -0
  107. package/lib-commonjs/{runWindows/utils → utils}/vstools.d.ts +16 -15
  108. package/lib-commonjs/utils/vstools.js +190 -0
  109. package/lib-commonjs/utils/vstools.js.map +1 -0
  110. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.d.ts +24 -24
  111. package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.js +108 -105
  112. package/lib-commonjs/utils/winappdeploytool.js.map +1 -0
  113. package/package.json +49 -31
  114. package/{powershell → src/powershell}/Add-AppDevPackage.ps1 +2 -2
  115. package/src/powershell/Eval-MsBuildProperties.ps1 +156 -0
  116. package/{powershell → src/powershell}/WindowsStoreAppUtils.ps1 +10 -0
  117. package/CHANGELOG.json +0 -413
  118. package/CHANGELOG.md +0 -200
  119. package/lib-commonjs/config/configUtils.js +0 -253
  120. package/lib-commonjs/config/configUtils.js.map +0 -1
  121. package/lib-commonjs/config/dependencyConfig.js +0 -167
  122. package/lib-commonjs/config/dependencyConfig.js.map +0 -1
  123. package/lib-commonjs/config/projectConfig.js +0 -121
  124. package/lib-commonjs/config/projectConfig.js.map +0 -1
  125. package/lib-commonjs/runWindows/runWindows.js +0 -159
  126. package/lib-commonjs/runWindows/runWindows.js.map +0 -1
  127. package/lib-commonjs/runWindows/runWindowsOptions.js.map +0 -1
  128. package/lib-commonjs/runWindows/utils/autolink.d.ts +0 -7
  129. package/lib-commonjs/runWindows/utils/autolink.js +0 -353
  130. package/lib-commonjs/runWindows/utils/autolink.js.map +0 -1
  131. package/lib-commonjs/runWindows/utils/build.js.map +0 -1
  132. package/lib-commonjs/runWindows/utils/checkRequirements.js.map +0 -1
  133. package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +0 -1
  134. package/lib-commonjs/runWindows/utils/deploy.js +0 -247
  135. package/lib-commonjs/runWindows/utils/deploy.js.map +0 -1
  136. package/lib-commonjs/runWindows/utils/info.js.map +0 -1
  137. package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +0 -22
  138. package/lib-commonjs/runWindows/utils/msbuildtools.js +0 -195
  139. package/lib-commonjs/runWindows/utils/msbuildtools.js.map +0 -1
  140. package/lib-commonjs/runWindows/utils/version.js.map +0 -1
  141. package/lib-commonjs/runWindows/utils/vsInstalls.js +0 -70
  142. package/lib-commonjs/runWindows/utils/vsInstalls.js.map +0 -1
  143. package/lib-commonjs/runWindows/utils/vstools.js +0 -150
  144. package/lib-commonjs/runWindows/utils/vstools.js.map +0 -1
  145. package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +0 -1
@@ -1,93 +1,141 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- * @format
5
- */
6
- /**
7
- * Search for files matching the pattern under the target folder.
8
- * @param folder The absolute path to target folder.
9
- * @param filenamePattern The pattern to search for.
10
- * @return Return the array of relative file paths.
11
- */
12
- export declare function findFiles(folder: string, filenamePattern: string): string[];
13
- /**
14
- * Search for the windows sub-folder under the target folder.
15
- * @param folder The absolute path to the target folder.
16
- * @return The absolute path to the windows folder, if it exists.
17
- */
18
- export declare function findWindowsFolder(folder: string): string | null;
19
- /**
20
- * Checks if the target file path is a RNW solution file by checking if it contains the string "ReactNative".
21
- * @param filePath The absolute file path to check.
22
- * @return Whether the path is to a RNW solution file.
23
- */
24
- export declare function isRnwSolution(filePath: string): boolean;
25
- /**
26
- * Search for the RNW solution files under the target folder.
27
- * @param winFolder The absolute path to target folder.
28
- * @return Return the array of relative file paths.
29
- */
30
- export declare function findSolutionFiles(winFolder: string): string[];
31
- /**
32
- * Checks if the target file path is a RNW lib project file.
33
- * @param filePath The absolute file path to check.
34
- * @return Whether the path is to a RNW lib project file.
35
- */
36
- export declare function isRnwDependencyProject(filePath: string): boolean;
37
- /**
38
- * Search for the RNW lib project files under the target folder.
39
- * @param winFolder The absolute path to target folder.
40
- * @return Return the array of relative file paths.
41
- */
42
- export declare function findDependencyProjectFiles(winFolder: string): string[];
43
- /**
44
- * Search for the RNW app project files under the target folder.
45
- * @param winFolder The absolute path to target folder.
46
- * @return Return the array of relative file paths.
47
- */
48
- export declare function findAppProjectFiles(winFolder: string): string[];
49
- /**
50
- * Returns the programming language of the project file.
51
- * @param projectPath The project file path to check.
52
- * @return The language string: cpp, cs, or null if unknown.
53
- */
54
- export declare function getProjectLanguage(projectPath: string): 'cpp' | 'cs' | null;
55
- /**
56
- * Reads in the contents of the target project file.
57
- * @param projectPath The target project file path.
58
- * @return The project file contents.
59
- */
60
- export declare function readProjectFile(projectPath: string): Document;
61
- /**
62
- * Search for the given property in the project contents and return its value.
63
- * @param projectContents The XML project contents.
64
- * @param propertyName The property to look for.
65
- * @return The value of the tag if it exists.
66
- */
67
- export declare function findPropertyValue(projectContents: Node, propertyName: string): string | null;
68
- /**
69
- * Search for the given import project in the project contents and return if it exists.
70
- * @param projectContents The XML project contents.
71
- * @param projectName The project to look for.
72
- * @return If the target exists.
73
- */
74
- export declare function importProjectExists(projectContents: Node, projectName: string): boolean;
75
- /**
76
- * Gets the name of the project from the project contents.
77
- * @param projectPath The project file path to check.
78
- * @param projectContents The XML project contents.
79
- * @return The project name.
80
- */
81
- export declare function getProjectName(projectContents: Node): string;
82
- /**
83
- * Gets the namespace of the project from the project contents.
84
- * @param projectContents The XML project contents.
85
- * @return The project namespace.
86
- */
87
- export declare function getProjectNamespace(projectContents: Node): string | null;
88
- /**
89
- * Gets the guid of the project from the project contents.
90
- * @param projectContents The XML project contents.
91
- * @return The project guid.
92
- */
93
- export declare function getProjectGuid(projectContents: Node): string | null;
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ /**
7
+ * Search for files matching the pattern under the target folder.
8
+ * @param folder The absolute path to target folder.
9
+ * @param filenamePattern The pattern to search for.
10
+ * @return Return the array of relative file paths.
11
+ */
12
+ export declare function findFiles(folder: string, filenamePattern: string): string[];
13
+ /**
14
+ * Search for the windows sub-folder under the target folder.
15
+ * @param folder The absolute path to the target folder.
16
+ * @return The absolute path to the windows folder, if it exists.
17
+ */
18
+ export declare function findWindowsFolder(folder: string): string | null;
19
+ /**
20
+ * Checks if the target file path is a RNW solution file by checking if it contains the string "ReactNative".
21
+ * @param filePath The absolute file path to check.
22
+ * @return Whether the path is to a RNW solution file.
23
+ */
24
+ export declare function isRnwSolution(filePath: string): boolean;
25
+ /**
26
+ * Search for the RNW solution files under the target folder.
27
+ * @param winFolder The absolute path to target folder.
28
+ * @return Return the array of relative file paths.
29
+ */
30
+ export declare function findSolutionFiles(winFolder: string): string[];
31
+ export interface RawTemplateInfo {
32
+ projectLang: 'cpp' | 'cs' | null;
33
+ projectType: 'app' | 'lib' | null;
34
+ projectArch: 'old' | 'new' | 'mixed' | null;
35
+ }
36
+ /**
37
+ * Determines the RawTemplateInfo of the target project file.
38
+ * @param filePath The absolute file path to check.
39
+ * @return The RawTemplateInfo for the specific project.
40
+ */
41
+ export declare function getRawTemplateInfo(filePath: string): RawTemplateInfo;
42
+ /**
43
+ * Checks if the target file path is a RNW lib project file.
44
+ * @param filePath The absolute file path to check.
45
+ * @return Whether the path is to a RNW lib project file.
46
+ */
47
+ export declare function isRnwDependencyProject(filePath: string): boolean;
48
+ /**
49
+ * Search for the RNW lib project files under the target folder.
50
+ * @param winFolder The absolute path to target folder.
51
+ * @return Return the array of relative file paths.
52
+ */
53
+ export declare function findDependencyProjectFiles(winFolder: string): string[];
54
+ /**
55
+ * Checks if the target file path is a RNW app project file.
56
+ * @param filePath The absolute file path to check.
57
+ * @return Whether the path is to a RNW app project file.
58
+ */
59
+ export declare function isRnwAppProject(filePath: string): boolean;
60
+ /**
61
+ * Search for the RNW app project files under the target folder.
62
+ * @param winFolder The absolute path to target folder.
63
+ * @return Return the array of relative file paths.
64
+ */
65
+ export declare function findAppProjectFiles(winFolder: string): string[];
66
+ /**
67
+ * Returns the programming language of the project file.
68
+ * @param projectPath The project file path to check.
69
+ * @return The language string: cpp, cs, or null if unknown.
70
+ */
71
+ export declare function getProjectLanguage(projectPath: string): 'cpp' | 'cs' | null;
72
+ /**
73
+ * Reads in the contents of the target project file.
74
+ * @param projectPath The target project file path.
75
+ * @return The project file contents.
76
+ */
77
+ export declare function readProjectFile(projectPath: string): Document;
78
+ /**
79
+ * Search for the given property in the project contents and return its value.
80
+ * @param projectContents The XML project contents.
81
+ * @param propertyName The property to look for.
82
+ * @return The value of the tag if it exists.
83
+ */
84
+ export declare function tryFindPropertyValue(projectContents: Node, propertyName: string): string | null;
85
+ /**
86
+ * Search for the given property in the project contents and return its value.
87
+ * @param projectContents The XML project contents.
88
+ * @param propertyName The property to look for.
89
+ * @return The value of the tag if it exists.
90
+ */
91
+ export declare function tryFindPropertyValueAsBoolean(projectContents: Node, propertyName: string): boolean | null;
92
+ export declare function findPropertyValue(projectContents: Node, propertyName: string, filePath: string): string;
93
+ /**
94
+ * Search for the given import project in the project contents and return if it exists.
95
+ * @param projectContents The XML project contents.
96
+ * @param projectName The project to look for.
97
+ * @return If the target exists.
98
+ */
99
+ export declare function importProjectExists(projectContents: Node, projectName: string): boolean;
100
+ export type ConfigurationType = 'application' | 'dynamiclibrary' | 'generic' | 'staticlibrary' | 'unknown';
101
+ /**
102
+ * Gets the configuration type of the project from the project contents.
103
+ * @param projectContents The XML project contents.
104
+ * @return The project configuration type.
105
+ */
106
+ export declare function getConfigurationType(projectContents: Node): ConfigurationType;
107
+ export type OutputType = 'appcontainerexe' | 'exe' | 'library' | 'module' | 'unknown' | 'winexe' | 'winmdobj';
108
+ /**
109
+ * Gets the output type of the project from the project contents.
110
+ * @param projectContents The XML project contents.
111
+ * @return The project output type.
112
+ */
113
+ export declare function getOutputType(projectContents: Node): OutputType;
114
+ /**
115
+ * Gets the type of the project from the project contents.
116
+ * @param projectPath The project file path to check.
117
+ * @param projectContents The XML project contents.
118
+ * @return The project type.
119
+ */
120
+ export declare function getProjectType(projectPath: string, projectContents: Node): ConfigurationType | OutputType;
121
+ /**
122
+ * Gets the name of the project from the project contents.
123
+ * @param projectPath The project file path to check.
124
+ * @param projectContents The XML project contents.
125
+ * @return The project name.
126
+ */
127
+ export declare function getProjectName(projectPath: string, projectContents: Node): string;
128
+ /**
129
+ * Gets the namespace of the project from the project contents.
130
+ * @param projectContents The XML project contents.
131
+ * @return The project namespace.
132
+ */
133
+ export declare function getProjectNamespace(projectContents: Node): string | null;
134
+ /**
135
+ * Gets the guid of the project from the project contents.
136
+ * @param projectContents The XML project contents.
137
+ * @return The project guid.
138
+ */
139
+ export declare function getProjectGuid(projectContents: Node): string | null;
140
+ export declare function getExperimentalFeatures(solutionDir: string): Record<string, string> | undefined;
141
+ export declare function getRnwConfig(root: string, projectFile: string): Record<string, any> | undefined;
@@ -0,0 +1,423 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.getRnwConfig = exports.getExperimentalFeatures = exports.getProjectGuid = exports.getProjectNamespace = exports.getProjectName = exports.getProjectType = exports.getOutputType = exports.getConfigurationType = exports.importProjectExists = exports.findPropertyValue = exports.tryFindPropertyValueAsBoolean = exports.tryFindPropertyValue = exports.readProjectFile = exports.getProjectLanguage = exports.findAppProjectFiles = exports.isRnwAppProject = exports.findDependencyProjectFiles = exports.isRnwDependencyProject = exports.getRawTemplateInfo = exports.findSolutionFiles = exports.isRnwSolution = exports.findWindowsFolder = exports.findFiles = void 0;
12
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
13
+ const path_1 = __importDefault(require("path"));
14
+ const glob_1 = __importDefault(require("glob"));
15
+ const xmldom_1 = require("@xmldom/xmldom");
16
+ const xpath_1 = __importDefault(require("xpath"));
17
+ const telemetry_1 = require("@react-native-windows/telemetry");
18
+ const msbuildSelect = xpath_1.default.useNamespaces({
19
+ msbuild: 'http://schemas.microsoft.com/developer/msbuild/2003',
20
+ });
21
+ /**
22
+ * Search for files matching the pattern under the target folder.
23
+ * @param folder The absolute path to target folder.
24
+ * @param filenamePattern The pattern to search for.
25
+ * @return Return the array of relative file paths.
26
+ */
27
+ function findFiles(folder, filenamePattern) {
28
+ const files = glob_1.default.sync(path_1.default.join('**', filenamePattern), {
29
+ cwd: folder,
30
+ ignore: [
31
+ 'node_modules/**',
32
+ '**/Debug/**',
33
+ '**/Release/**',
34
+ '**/Generated Files/**',
35
+ '**/packages/**',
36
+ ],
37
+ });
38
+ return files;
39
+ }
40
+ exports.findFiles = findFiles;
41
+ /**
42
+ * Search for the windows sub-folder under the target folder.
43
+ * @param folder The absolute path to the target folder.
44
+ * @return The absolute path to the windows folder, if it exists.
45
+ */
46
+ function findWindowsFolder(folder) {
47
+ const winDir = 'windows';
48
+ const joinedDir = path_1.default.join(folder, winDir);
49
+ if (fs_1.default.existsSync(joinedDir)) {
50
+ return joinedDir;
51
+ }
52
+ return null;
53
+ }
54
+ exports.findWindowsFolder = findWindowsFolder;
55
+ /**
56
+ * Checks if the target file path is a RNW solution file by checking if it contains the string "ReactNative".
57
+ * @param filePath The absolute file path to check.
58
+ * @return Whether the path is to a RNW solution file.
59
+ */
60
+ function isRnwSolution(filePath) {
61
+ return (fs_1.default
62
+ .readFileSync(filePath)
63
+ .toString()
64
+ .search(/ReactNative/) > 0);
65
+ }
66
+ exports.isRnwSolution = isRnwSolution;
67
+ /**
68
+ * Search for the RNW solution files under the target folder.
69
+ * @param winFolder The absolute path to target folder.
70
+ * @return Return the array of relative file paths.
71
+ */
72
+ function findSolutionFiles(winFolder) {
73
+ // First search for all potential solution files
74
+ const allSolutions = findFiles(winFolder, '*.sln');
75
+ if (allSolutions.length === 0) {
76
+ // If there're no solution files, return 0
77
+ return [];
78
+ }
79
+ else if (allSolutions.length === 1) {
80
+ // If there is exactly one solution file, assume it's it
81
+ return [allSolutions[0]];
82
+ }
83
+ const solutionFiles = [];
84
+ // Try to find any solution file that appears to be a React Native solution
85
+ for (const solutionFile of allSolutions) {
86
+ if (isRnwSolution(path_1.default.join(winFolder, solutionFile))) {
87
+ solutionFiles.push(path_1.default.normalize(solutionFile));
88
+ }
89
+ }
90
+ return solutionFiles;
91
+ }
92
+ exports.findSolutionFiles = findSolutionFiles;
93
+ /**
94
+ * Determines the RawTemplateInfo of the target project file.
95
+ * @param filePath The absolute file path to check.
96
+ * @return The RawTemplateInfo for the specific project.
97
+ */
98
+ function getRawTemplateInfo(filePath) {
99
+ const result = {
100
+ projectLang: null,
101
+ projectType: null,
102
+ projectArch: null,
103
+ };
104
+ if (!fs_1.default.existsSync(filePath)) {
105
+ return result;
106
+ }
107
+ result.projectLang = getProjectLanguage(filePath);
108
+ const projectContents = readProjectFile(filePath);
109
+ if (result.projectLang === 'cs') {
110
+ if (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CSharpApp.targets')) {
111
+ result.projectType = 'app';
112
+ result.projectArch = 'old';
113
+ }
114
+ else if (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CSharpLib.targets')) {
115
+ result.projectType = 'lib';
116
+ result.projectArch = 'old';
117
+ }
118
+ }
119
+ else if (result.projectLang === 'cpp') {
120
+ if (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppApp.targets')) {
121
+ result.projectType = 'app';
122
+ result.projectArch = 'old';
123
+ }
124
+ else if (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppLib.targets')) {
125
+ result.projectType = 'lib';
126
+ result.projectArch = 'old';
127
+ }
128
+ else if (importProjectExists(projectContents, 'Microsoft.ReactNative.Composition.CppApp.targets')) {
129
+ result.projectType = 'app';
130
+ result.projectArch = 'new';
131
+ }
132
+ else if (importProjectExists(projectContents, 'Microsoft.ReactNative.Composition.CppLib.targets')) {
133
+ result.projectType = 'lib';
134
+ result.projectArch = 'new';
135
+ }
136
+ else if (importProjectExists(projectContents, 'Microsoft.ReactNative.CppLib.targets')) {
137
+ result.projectType = 'lib';
138
+ result.projectArch = 'mixed';
139
+ }
140
+ }
141
+ return result;
142
+ }
143
+ exports.getRawTemplateInfo = getRawTemplateInfo;
144
+ /**
145
+ * Checks if the target file path is a RNW lib project file.
146
+ * @param filePath The absolute file path to check.
147
+ * @return Whether the path is to a RNW lib project file.
148
+ */
149
+ function isRnwDependencyProject(filePath) {
150
+ const rawTemplateInfo = getRawTemplateInfo(filePath);
151
+ return rawTemplateInfo.projectType === 'lib';
152
+ }
153
+ exports.isRnwDependencyProject = isRnwDependencyProject;
154
+ /**
155
+ * Search for the RNW lib project files under the target folder.
156
+ * @param winFolder The absolute path to target folder.
157
+ * @return Return the array of relative file paths.
158
+ */
159
+ function findDependencyProjectFiles(winFolder) {
160
+ // First, search for all potential project files
161
+ const allCppProj = findFiles(winFolder, '*.vcxproj');
162
+ const allCsProj = findFiles(winFolder, '*.csproj');
163
+ const allProjects = allCppProj.concat(allCsProj);
164
+ if (allProjects.length === 0) {
165
+ // If there're no project files, return 0
166
+ return [];
167
+ }
168
+ const dependencyProjectFiles = [];
169
+ // Try to find any project file that appears to be a dependency project
170
+ for (const projectFile of allProjects) {
171
+ // A project is marked as a RNW dependency iff either:
172
+ // - If the project has the standard native module imports, or
173
+ // - If we only have a single project (and it doesn't have the standard native module imports),
174
+ // pick it and hope for the best. This enables autolinking for modules that were written
175
+ // before the standard native module template existed.
176
+ if (allProjects.length === 1 ||
177
+ isRnwDependencyProject(path_1.default.join(winFolder, projectFile))) {
178
+ dependencyProjectFiles.push(path_1.default.normalize(projectFile));
179
+ }
180
+ }
181
+ return dependencyProjectFiles;
182
+ }
183
+ exports.findDependencyProjectFiles = findDependencyProjectFiles;
184
+ /**
185
+ * Checks if the target file path is a RNW app project file.
186
+ * @param filePath The absolute file path to check.
187
+ * @return Whether the path is to a RNW app project file.
188
+ */
189
+ function isRnwAppProject(filePath) {
190
+ const rawTemplateInfo = getRawTemplateInfo(filePath);
191
+ return rawTemplateInfo.projectType === 'app';
192
+ }
193
+ exports.isRnwAppProject = isRnwAppProject;
194
+ /**
195
+ * Search for the RNW app project files under the target folder.
196
+ * @param winFolder The absolute path to target folder.
197
+ * @return Return the array of relative file paths.
198
+ */
199
+ function findAppProjectFiles(winFolder) {
200
+ // First, search for all potential project files
201
+ const allCppProj = findFiles(winFolder, '*.vcxproj');
202
+ const allCsProj = findFiles(winFolder, '*.csproj');
203
+ const allProjects = allCppProj.concat(allCsProj);
204
+ if (allProjects.length === 0) {
205
+ // If there're no project files, return 0
206
+ return [];
207
+ }
208
+ const appProjectFiles = [];
209
+ // Try to find any project file that appears to be an app project
210
+ for (const projectFile of allProjects) {
211
+ if (isRnwAppProject(path_1.default.join(winFolder, projectFile))) {
212
+ appProjectFiles.push(path_1.default.normalize(projectFile));
213
+ }
214
+ }
215
+ return appProjectFiles;
216
+ }
217
+ exports.findAppProjectFiles = findAppProjectFiles;
218
+ /**
219
+ * Returns the programming language of the project file.
220
+ * @param projectPath The project file path to check.
221
+ * @return The language string: cpp, cs, or null if unknown.
222
+ */
223
+ function getProjectLanguage(projectPath) {
224
+ if (projectPath.endsWith('.vcxproj')) {
225
+ return 'cpp';
226
+ }
227
+ else if (projectPath.endsWith('.csproj')) {
228
+ return 'cs';
229
+ }
230
+ return null;
231
+ }
232
+ exports.getProjectLanguage = getProjectLanguage;
233
+ /**
234
+ * Reads in the contents of the target project file.
235
+ * @param projectPath The target project file path.
236
+ * @return The project file contents.
237
+ */
238
+ function readProjectFile(projectPath) {
239
+ const projectContents = fs_1.default.readFileSync(projectPath, 'utf8').toString();
240
+ return new xmldom_1.DOMParser().parseFromString(projectContents, 'application/xml');
241
+ }
242
+ exports.readProjectFile = readProjectFile;
243
+ /**
244
+ * Search for the given property in the project contents and return its value.
245
+ * @param projectContents The XML project contents.
246
+ * @param propertyName The property to look for.
247
+ * @return The value of the tag if it exists.
248
+ */
249
+ function tryFindPropertyValue(projectContents, propertyName) {
250
+ const nodes = msbuildSelect(`//msbuild:PropertyGroup/msbuild:${propertyName}`, projectContents);
251
+ if (nodes.length > 0) {
252
+ // Take the last one
253
+ return nodes[nodes.length - 1].textContent;
254
+ }
255
+ else {
256
+ const noNamespaceNodes = xpath_1.default.select(`//PropertyGroup/${propertyName}`, projectContents);
257
+ if (noNamespaceNodes.length > 0) {
258
+ return noNamespaceNodes[noNamespaceNodes.length - 1]
259
+ .textContent;
260
+ }
261
+ }
262
+ return null;
263
+ }
264
+ exports.tryFindPropertyValue = tryFindPropertyValue;
265
+ /**
266
+ * Search for the given property in the project contents and return its value.
267
+ * @param projectContents The XML project contents.
268
+ * @param propertyName The property to look for.
269
+ * @return The value of the tag if it exists.
270
+ */
271
+ function tryFindPropertyValueAsBoolean(projectContents, propertyName) {
272
+ const rawValue = tryFindPropertyValue(projectContents, propertyName);
273
+ switch (rawValue) {
274
+ case 'true':
275
+ return true;
276
+ case 'false':
277
+ return false;
278
+ default:
279
+ return null;
280
+ }
281
+ }
282
+ exports.tryFindPropertyValueAsBoolean = tryFindPropertyValueAsBoolean;
283
+ function findPropertyValue(projectContents, propertyName, filePath) {
284
+ const res = tryFindPropertyValue(projectContents, propertyName);
285
+ if (!res) {
286
+ throw new telemetry_1.CodedError('NoPropertyInProject', `Couldn't find property ${propertyName} from ${filePath}`, { propertyName: propertyName });
287
+ }
288
+ return res;
289
+ }
290
+ exports.findPropertyValue = findPropertyValue;
291
+ /**
292
+ * Search for the given import project in the project contents and return if it exists.
293
+ * @param projectContents The XML project contents.
294
+ * @param projectName The project to look for.
295
+ * @return If the target exists.
296
+ */
297
+ function importProjectExists(projectContents, projectName) {
298
+ const nodes = msbuildSelect(`//msbuild:Import[contains(@Project,'${projectName}')]`, projectContents);
299
+ return nodes.length > 0;
300
+ }
301
+ exports.importProjectExists = importProjectExists;
302
+ /**
303
+ * Gets the configuration type of the project from the project contents.
304
+ * @param projectContents The XML project contents.
305
+ * @return The project configuration type.
306
+ */
307
+ function getConfigurationType(projectContents) {
308
+ var _a;
309
+ const configurationType = (_a = tryFindPropertyValue(projectContents, 'ConfigurationType')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
310
+ switch (configurationType) {
311
+ case 'application':
312
+ case 'dynamiclibrary':
313
+ case 'generic':
314
+ case 'staticlibrary':
315
+ return configurationType;
316
+ default:
317
+ return 'unknown';
318
+ }
319
+ }
320
+ exports.getConfigurationType = getConfigurationType;
321
+ /**
322
+ * Gets the output type of the project from the project contents.
323
+ * @param projectContents The XML project contents.
324
+ * @return The project output type.
325
+ */
326
+ function getOutputType(projectContents) {
327
+ var _a;
328
+ const outputType = (_a = tryFindPropertyValue(projectContents, 'OutputType')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
329
+ switch (outputType) {
330
+ case 'appcontainerexe':
331
+ case 'exe':
332
+ case 'library':
333
+ case 'module':
334
+ case 'winexe':
335
+ case 'winmdobj':
336
+ return outputType;
337
+ default:
338
+ return 'unknown';
339
+ }
340
+ }
341
+ exports.getOutputType = getOutputType;
342
+ /**
343
+ * Gets the type of the project from the project contents.
344
+ * @param projectPath The project file path to check.
345
+ * @param projectContents The XML project contents.
346
+ * @return The project type.
347
+ */
348
+ function getProjectType(projectPath, projectContents) {
349
+ switch (getProjectLanguage(projectPath)) {
350
+ case 'cpp':
351
+ return getConfigurationType(projectContents);
352
+ case 'cs':
353
+ return getOutputType(projectContents);
354
+ default:
355
+ return 'unknown';
356
+ }
357
+ }
358
+ exports.getProjectType = getProjectType;
359
+ /**
360
+ * Gets the name of the project from the project contents.
361
+ * @param projectPath The project file path to check.
362
+ * @param projectContents The XML project contents.
363
+ * @return The project name.
364
+ */
365
+ function getProjectName(projectPath, projectContents) {
366
+ const name = tryFindPropertyValue(projectContents, 'ProjectName') ||
367
+ path_1.default.parse(projectPath).name ||
368
+ '';
369
+ return name;
370
+ }
371
+ exports.getProjectName = getProjectName;
372
+ /**
373
+ * Gets the namespace of the project from the project contents.
374
+ * @param projectContents The XML project contents.
375
+ * @return The project namespace.
376
+ */
377
+ function getProjectNamespace(projectContents) {
378
+ return tryFindPropertyValue(projectContents, 'RootNamespace');
379
+ }
380
+ exports.getProjectNamespace = getProjectNamespace;
381
+ /**
382
+ * Gets the guid of the project from the project contents.
383
+ * @param projectContents The XML project contents.
384
+ * @return The project guid.
385
+ */
386
+ function getProjectGuid(projectContents) {
387
+ return tryFindPropertyValue(projectContents, 'ProjectGuid');
388
+ }
389
+ exports.getProjectGuid = getProjectGuid;
390
+ function getExperimentalFeatures(solutionDir) {
391
+ const propsFile = path_1.default.join(solutionDir, 'ExperimentalFeatures.props');
392
+ if (!fs_1.default.existsSync(propsFile)) {
393
+ return undefined;
394
+ }
395
+ const result = {};
396
+ const propsContents = readProjectFile(propsFile);
397
+ const nodes = msbuildSelect(`//msbuild:PropertyGroup/msbuild:*`, propsContents);
398
+ for (const node of nodes) {
399
+ const propertyNode = node;
400
+ result[propertyNode.nodeName] = propertyNode.textContent;
401
+ }
402
+ return result;
403
+ }
404
+ exports.getExperimentalFeatures = getExperimentalFeatures;
405
+ function getRnwConfig(root, projectFile) {
406
+ var _a, _b;
407
+ const pkgPath = path_1.default.join(root, 'package.json');
408
+ const pkgJson = fs_1.default.existsSync(pkgPath)
409
+ ? require(path_1.default.join(root, 'package.json'))
410
+ : {};
411
+ const config = (_a = pkgJson['react-native-windows']) !== null && _a !== void 0 ? _a : {};
412
+ // if init-windows is missing (most existing projects), try to auto-calculate it
413
+ (_b = config['init-windows']) !== null && _b !== void 0 ? _b : (config['init-windows'] = {});
414
+ if (!config['init-windows'].template) {
415
+ const info = getRawTemplateInfo(projectFile);
416
+ if (info.projectArch && info.projectLang && info.projectType) {
417
+ config['init-windows'].template = `${info.projectArch === 'old' ? 'old/uwp-' : ''}${info.projectLang}-${info.projectType}`;
418
+ }
419
+ }
420
+ return config;
421
+ }
422
+ exports.getRnwConfig = getRnwConfig;
423
+ //# sourceMappingURL=configUtils.js.map