@react-native-windows/cli 0.0.0-canary.21 → 0.0.0-canary.210
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.
- package/README.md +47 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +87 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +661 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js.map +1 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +33 -0
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js.map +1 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindows.js +206 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindows.js.map +1 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +23 -0
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js.map +1 -0
- package/lib-commonjs/{config → commands/config}/configUtils.d.ts +123 -93
- package/lib-commonjs/commands/config/configUtils.js +381 -0
- package/lib-commonjs/commands/config/configUtils.js.map +1 -0
- package/lib-commonjs/{config → commands/config}/dependencyConfig.d.ts +37 -37
- package/lib-commonjs/commands/config/dependencyConfig.js +228 -0
- package/lib-commonjs/commands/config/dependencyConfig.js.map +1 -0
- package/lib-commonjs/{config → commands/config}/projectConfig.d.ts +27 -24
- package/lib-commonjs/{config → commands/config}/projectConfig.js +180 -120
- package/lib-commonjs/commands/config/projectConfig.js.map +1 -0
- package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -0
- package/lib-commonjs/commands/healthCheck/healthCheckList.js +21 -0
- package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -0
- package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -0
- package/lib-commonjs/commands/healthCheck/healthChecks.js +124 -0
- package/lib-commonjs/commands/healthCheck/healthChecks.js.map +1 -0
- package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -0
- package/lib-commonjs/commands/initWindows/initWindows.js +244 -0
- package/lib-commonjs/commands/initWindows/initWindows.js.map +1 -0
- package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -0
- package/lib-commonjs/commands/initWindows/initWindowsOptions.js +38 -0
- package/lib-commonjs/commands/initWindows/initWindowsOptions.js.map +1 -0
- package/lib-commonjs/{runWindows → commands/runWindows}/runWindows.d.ts +10 -10
- package/lib-commonjs/commands/runWindows/runWindows.js +322 -0
- package/lib-commonjs/commands/runWindows/runWindows.js.map +1 -0
- package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.d.ts +56 -52
- package/lib-commonjs/{runWindows → commands/runWindows}/runWindowsOptions.js +132 -131
- package/lib-commonjs/commands/runWindows/runWindowsOptions.js.map +1 -0
- package/lib-commonjs/e2etest/autolink.test.d.ts +6 -0
- package/lib-commonjs/e2etest/autolink.test.js +367 -0
- package/lib-commonjs/e2etest/autolink.test.js.map +1 -0
- package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -0
- package/lib-commonjs/e2etest/dependencyConfig.test.js +130 -0
- package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -0
- package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -0
- package/lib-commonjs/e2etest/healthChecks.test.js +31 -0
- package/lib-commonjs/e2etest/healthChecks.test.js.map +1 -0
- package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -0
- package/lib-commonjs/e2etest/initWindows.test.js +43 -0
- package/lib-commonjs/e2etest/initWindows.test.js.map +1 -0
- package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -0
- package/lib-commonjs/e2etest/projectConfig.test.js +111 -0
- package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -0
- package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -0
- package/lib-commonjs/e2etest/projectConfig.utils.js +77 -0
- package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -0
- package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -0
- package/lib-commonjs/e2etest/runWindows.test.js +61 -0
- package/lib-commonjs/e2etest/runWindows.test.js.map +1 -0
- package/lib-commonjs/e2etest/typesUpToDate.test.d.ts +6 -0
- package/lib-commonjs/e2etest/typesUpToDate.test.js +21 -0
- package/lib-commonjs/e2etest/typesUpToDate.test.js.map +1 -0
- package/lib-commonjs/generator-common/index.d.ts +39 -23
- package/lib-commonjs/generator-common/index.js +242 -221
- package/lib-commonjs/generator-common/index.js.map +1 -1
- package/lib-commonjs/generator-windows/index.d.ts +10 -10
- package/lib-commonjs/generator-windows/index.js +316 -352
- package/lib-commonjs/generator-windows/index.js.map +1 -1
- package/lib-commonjs/index.d.ts +50 -46
- package/lib-commonjs/index.js +77 -39
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/{runWindows/utils → utils}/build.d.ts +12 -13
- package/lib-commonjs/{runWindows/utils → utils}/build.js +84 -91
- package/lib-commonjs/utils/build.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.d.ts +6 -6
- package/lib-commonjs/{runWindows/utils → utils}/checkRequirements.js +69 -65
- package/lib-commonjs/utils/checkRequirements.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.d.ts +21 -13
- package/lib-commonjs/{runWindows/utils → utils}/commandWithProgress.js +149 -113
- package/lib-commonjs/utils/commandWithProgress.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/deploy.d.ts +12 -12
- package/lib-commonjs/utils/deploy.js +354 -0
- package/lib-commonjs/utils/deploy.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/info.d.ts +6 -6
- package/lib-commonjs/{runWindows/utils → utils}/info.js +28 -25
- package/lib-commonjs/utils/info.js.map +1 -0
- package/lib-commonjs/utils/msbuildtools.d.ts +28 -0
- package/lib-commonjs/utils/msbuildtools.js +274 -0
- package/lib-commonjs/utils/msbuildtools.js.map +1 -0
- package/lib-commonjs/utils/pathHelpers.d.ts +9 -0
- package/lib-commonjs/utils/pathHelpers.js +37 -0
- package/lib-commonjs/utils/pathHelpers.js.map +1 -0
- package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -0
- package/lib-commonjs/utils/telemetryHelpers.js +121 -0
- package/lib-commonjs/utils/telemetryHelpers.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/version.d.ts +19 -19
- package/lib-commonjs/{runWindows/utils → utils}/version.js +109 -109
- package/lib-commonjs/utils/version.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/vsInstalls.d.ts +34 -34
- package/lib-commonjs/utils/vsInstalls.js +100 -0
- package/lib-commonjs/utils/vsInstalls.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/vstools.d.ts +16 -15
- package/lib-commonjs/utils/vstools.js +190 -0
- package/lib-commonjs/utils/vstools.js.map +1 -0
- package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.d.ts +24 -24
- package/lib-commonjs/{runWindows/utils → utils}/winappdeploytool.js +108 -105
- package/lib-commonjs/utils/winappdeploytool.js.map +1 -0
- package/package.json +50 -30
- package/{powershell → src/powershell}/Add-AppDevPackage.ps1 +2 -2
- package/src/powershell/Eval-MsBuildProperties.ps1 +156 -0
- package/{powershell → src/powershell}/WindowsStoreAppUtils.ps1 +10 -0
- package/CHANGELOG.json +0 -317
- package/CHANGELOG.md +0 -159
- package/lib-commonjs/config/configUtils.js +0 -253
- package/lib-commonjs/config/configUtils.js.map +0 -1
- package/lib-commonjs/config/dependencyConfig.js +0 -167
- package/lib-commonjs/config/dependencyConfig.js.map +0 -1
- package/lib-commonjs/config/projectConfig.js.map +0 -1
- package/lib-commonjs/runWindows/runWindows.js +0 -159
- package/lib-commonjs/runWindows/runWindows.js.map +0 -1
- package/lib-commonjs/runWindows/runWindowsOptions.js.map +0 -1
- package/lib-commonjs/runWindows/utils/autolink.d.ts +0 -7
- package/lib-commonjs/runWindows/utils/autolink.js +0 -353
- package/lib-commonjs/runWindows/utils/autolink.js.map +0 -1
- package/lib-commonjs/runWindows/utils/build.js.map +0 -1
- package/lib-commonjs/runWindows/utils/checkRequirements.js.map +0 -1
- package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +0 -1
- package/lib-commonjs/runWindows/utils/deploy.js +0 -247
- package/lib-commonjs/runWindows/utils/deploy.js.map +0 -1
- package/lib-commonjs/runWindows/utils/info.js.map +0 -1
- package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +0 -22
- package/lib-commonjs/runWindows/utils/msbuildtools.js +0 -195
- package/lib-commonjs/runWindows/utils/msbuildtools.js.map +0 -1
- package/lib-commonjs/runWindows/utils/version.js.map +0 -1
- package/lib-commonjs/runWindows/utils/vsInstalls.js +0 -70
- package/lib-commonjs/runWindows/utils/vsInstalls.js.map +0 -1
- package/lib-commonjs/runWindows/utils/vstools.js +0 -150
- package/lib-commonjs/runWindows/utils/vstools.js.map +0 -1
- package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +0 -1
|
@@ -1,93 +1,123 @@
|
|
|
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
|
|
68
|
-
/**
|
|
69
|
-
* Search for the given
|
|
70
|
-
* @param projectContents The XML project contents.
|
|
71
|
-
* @param
|
|
72
|
-
* @return
|
|
73
|
-
*/
|
|
74
|
-
export declare function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
* @param projectContents The XML project contents.
|
|
79
|
-
* @
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
*
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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 tryFindPropertyValue(projectContents: Node, propertyName: string): string | null;
|
|
68
|
+
/**
|
|
69
|
+
* Search for the given property in the project contents and return its value.
|
|
70
|
+
* @param projectContents The XML project contents.
|
|
71
|
+
* @param propertyName The property to look for.
|
|
72
|
+
* @return The value of the tag if it exists.
|
|
73
|
+
*/
|
|
74
|
+
export declare function tryFindPropertyValueAsBoolean(projectContents: Node, propertyName: string): boolean | null;
|
|
75
|
+
export declare function findPropertyValue(projectContents: Node, propertyName: string, filePath: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Search for the given import project in the project contents and return if it exists.
|
|
78
|
+
* @param projectContents The XML project contents.
|
|
79
|
+
* @param projectName The project to look for.
|
|
80
|
+
* @return If the target exists.
|
|
81
|
+
*/
|
|
82
|
+
export declare function importProjectExists(projectContents: Node, projectName: string): boolean;
|
|
83
|
+
export type ConfigurationType = 'application' | 'dynamiclibrary' | 'generic' | 'staticlibrary' | 'unknown';
|
|
84
|
+
/**
|
|
85
|
+
* Gets the configuration type of the project from the project contents.
|
|
86
|
+
* @param projectContents The XML project contents.
|
|
87
|
+
* @return The project configuration type.
|
|
88
|
+
*/
|
|
89
|
+
export declare function getConfigurationType(projectContents: Node): ConfigurationType;
|
|
90
|
+
export type OutputType = 'appcontainerexe' | 'exe' | 'library' | 'module' | 'unknown' | 'winexe' | 'winmdobj';
|
|
91
|
+
/**
|
|
92
|
+
* Gets the output type of the project from the project contents.
|
|
93
|
+
* @param projectContents The XML project contents.
|
|
94
|
+
* @return The project output type.
|
|
95
|
+
*/
|
|
96
|
+
export declare function getOutputType(projectContents: Node): OutputType;
|
|
97
|
+
/**
|
|
98
|
+
* Gets the type of the project from the project contents.
|
|
99
|
+
* @param projectPath The project file path to check.
|
|
100
|
+
* @param projectContents The XML project contents.
|
|
101
|
+
* @return The project type.
|
|
102
|
+
*/
|
|
103
|
+
export declare function getProjectType(projectPath: string, projectContents: Node): ConfigurationType | OutputType;
|
|
104
|
+
/**
|
|
105
|
+
* Gets the name of the project from the project contents.
|
|
106
|
+
* @param projectPath The project file path to check.
|
|
107
|
+
* @param projectContents The XML project contents.
|
|
108
|
+
* @return The project name.
|
|
109
|
+
*/
|
|
110
|
+
export declare function getProjectName(projectPath: string, projectContents: Node): string;
|
|
111
|
+
/**
|
|
112
|
+
* Gets the namespace of the project from the project contents.
|
|
113
|
+
* @param projectContents The XML project contents.
|
|
114
|
+
* @return The project namespace.
|
|
115
|
+
*/
|
|
116
|
+
export declare function getProjectNamespace(projectContents: Node): string | null;
|
|
117
|
+
/**
|
|
118
|
+
* Gets the guid of the project from the project contents.
|
|
119
|
+
* @param projectContents The XML project contents.
|
|
120
|
+
* @return The project guid.
|
|
121
|
+
*/
|
|
122
|
+
export declare function getProjectGuid(projectContents: Node): string | null;
|
|
123
|
+
export declare function getExperimentalFeatures(solutionDir: string): Record<string, string> | undefined;
|
|
@@ -0,0 +1,381 @@
|
|
|
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.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.findDependencyProjectFiles = exports.isRnwDependencyProject = 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
|
+
* Checks if the target file path is a RNW lib project file.
|
|
95
|
+
* @param filePath The absolute file path to check.
|
|
96
|
+
* @return Whether the path is to a RNW lib project file.
|
|
97
|
+
*/
|
|
98
|
+
function isRnwDependencyProject(filePath) {
|
|
99
|
+
const projectContents = readProjectFile(filePath);
|
|
100
|
+
const projectLang = getProjectLanguage(filePath);
|
|
101
|
+
if (projectLang === 'cs') {
|
|
102
|
+
return importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CSharpLib.targets');
|
|
103
|
+
}
|
|
104
|
+
else if (projectLang === 'cpp') {
|
|
105
|
+
return (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppLib.targets') ||
|
|
106
|
+
importProjectExists(projectContents, 'Microsoft.ReactNative.Composition.CppLib.targets'));
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
exports.isRnwDependencyProject = isRnwDependencyProject;
|
|
111
|
+
/**
|
|
112
|
+
* Search for the RNW lib project files under the target folder.
|
|
113
|
+
* @param winFolder The absolute path to target folder.
|
|
114
|
+
* @return Return the array of relative file paths.
|
|
115
|
+
*/
|
|
116
|
+
function findDependencyProjectFiles(winFolder) {
|
|
117
|
+
// First, search for all potential project files
|
|
118
|
+
const allCppProj = findFiles(winFolder, '*.vcxproj');
|
|
119
|
+
const allCsProj = findFiles(winFolder, '*.csproj');
|
|
120
|
+
const allProjects = allCppProj.concat(allCsProj);
|
|
121
|
+
if (allProjects.length === 0) {
|
|
122
|
+
// If there're no project files, return 0
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
const dependencyProjectFiles = [];
|
|
126
|
+
// Try to find any project file that appears to be a dependency project
|
|
127
|
+
for (const projectFile of allProjects) {
|
|
128
|
+
// A project is marked as a RNW dependency iff either:
|
|
129
|
+
// - If the project has the standard native module imports, or
|
|
130
|
+
// - If we only have a single project (and it doesn't have the standard native module imports),
|
|
131
|
+
// pick it and hope for the best. This enables autolinking for modules that were written
|
|
132
|
+
// before the standard native module template existed.
|
|
133
|
+
if (allProjects.length === 1 ||
|
|
134
|
+
isRnwDependencyProject(path_1.default.join(winFolder, projectFile))) {
|
|
135
|
+
dependencyProjectFiles.push(path_1.default.normalize(projectFile));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return dependencyProjectFiles;
|
|
139
|
+
}
|
|
140
|
+
exports.findDependencyProjectFiles = findDependencyProjectFiles;
|
|
141
|
+
function getReactNativeProjectType(value) {
|
|
142
|
+
switch (value) {
|
|
143
|
+
case 'App-WinAppSDK':
|
|
144
|
+
return value;
|
|
145
|
+
default:
|
|
146
|
+
return 'unknown';
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Checks if the target file path is a RNW app project file.
|
|
151
|
+
* @param filePath The absolute file path to check.
|
|
152
|
+
* @return Whether the path is to a RNW app project file.
|
|
153
|
+
*/
|
|
154
|
+
function isRnwAppProject(filePath) {
|
|
155
|
+
const projectContents = readProjectFile(filePath);
|
|
156
|
+
const rnProjectType = getReactNativeProjectType(tryFindPropertyValue(projectContents, 'ReactNativeProjectType'));
|
|
157
|
+
if (rnProjectType !== 'unknown') {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
const projectLang = getProjectLanguage(filePath);
|
|
161
|
+
if (projectLang === 'cs') {
|
|
162
|
+
return importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CSharpApp.targets');
|
|
163
|
+
}
|
|
164
|
+
else if (projectLang === 'cpp') {
|
|
165
|
+
return (importProjectExists(projectContents, 'Microsoft.ReactNative.Uwp.CppApp.targets') ||
|
|
166
|
+
importProjectExists(projectContents, 'Microsoft.ReactNative.Composition.CppApp.targets'));
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Search for the RNW app project files under the target folder.
|
|
172
|
+
* @param winFolder The absolute path to target folder.
|
|
173
|
+
* @return Return the array of relative file paths.
|
|
174
|
+
*/
|
|
175
|
+
function findAppProjectFiles(winFolder) {
|
|
176
|
+
// First, search for all potential project files
|
|
177
|
+
const allCppProj = findFiles(winFolder, '*.vcxproj');
|
|
178
|
+
const allCsProj = findFiles(winFolder, '*.csproj');
|
|
179
|
+
const allProjects = allCppProj.concat(allCsProj);
|
|
180
|
+
if (allProjects.length === 0) {
|
|
181
|
+
// If there're no project files, return 0
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
const appProjectFiles = [];
|
|
185
|
+
// Try to find any project file that appears to be an app project
|
|
186
|
+
for (const projectFile of allProjects) {
|
|
187
|
+
if (isRnwAppProject(path_1.default.join(winFolder, projectFile))) {
|
|
188
|
+
appProjectFiles.push(path_1.default.normalize(projectFile));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return appProjectFiles;
|
|
192
|
+
}
|
|
193
|
+
exports.findAppProjectFiles = findAppProjectFiles;
|
|
194
|
+
/**
|
|
195
|
+
* Returns the programming language of the project file.
|
|
196
|
+
* @param projectPath The project file path to check.
|
|
197
|
+
* @return The language string: cpp, cs, or null if unknown.
|
|
198
|
+
*/
|
|
199
|
+
function getProjectLanguage(projectPath) {
|
|
200
|
+
if (projectPath.endsWith('.vcxproj')) {
|
|
201
|
+
return 'cpp';
|
|
202
|
+
}
|
|
203
|
+
else if (projectPath.endsWith('.csproj')) {
|
|
204
|
+
return 'cs';
|
|
205
|
+
}
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
exports.getProjectLanguage = getProjectLanguage;
|
|
209
|
+
/**
|
|
210
|
+
* Reads in the contents of the target project file.
|
|
211
|
+
* @param projectPath The target project file path.
|
|
212
|
+
* @return The project file contents.
|
|
213
|
+
*/
|
|
214
|
+
function readProjectFile(projectPath) {
|
|
215
|
+
const projectContents = fs_1.default.readFileSync(projectPath, 'utf8').toString();
|
|
216
|
+
return new xmldom_1.DOMParser().parseFromString(projectContents, 'application/xml');
|
|
217
|
+
}
|
|
218
|
+
exports.readProjectFile = readProjectFile;
|
|
219
|
+
/**
|
|
220
|
+
* Search for the given property in the project contents and return its value.
|
|
221
|
+
* @param projectContents The XML project contents.
|
|
222
|
+
* @param propertyName The property to look for.
|
|
223
|
+
* @return The value of the tag if it exists.
|
|
224
|
+
*/
|
|
225
|
+
function tryFindPropertyValue(projectContents, propertyName) {
|
|
226
|
+
const nodes = msbuildSelect(`//msbuild:PropertyGroup/msbuild:${propertyName}`, projectContents);
|
|
227
|
+
if (nodes.length > 0) {
|
|
228
|
+
// Take the last one
|
|
229
|
+
return nodes[nodes.length - 1].textContent;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
const noNamespaceNodes = xpath_1.default.select(`//PropertyGroup/${propertyName}`, projectContents);
|
|
233
|
+
if (noNamespaceNodes.length > 0) {
|
|
234
|
+
return noNamespaceNodes[noNamespaceNodes.length - 1]
|
|
235
|
+
.textContent;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
exports.tryFindPropertyValue = tryFindPropertyValue;
|
|
241
|
+
/**
|
|
242
|
+
* Search for the given property in the project contents and return its value.
|
|
243
|
+
* @param projectContents The XML project contents.
|
|
244
|
+
* @param propertyName The property to look for.
|
|
245
|
+
* @return The value of the tag if it exists.
|
|
246
|
+
*/
|
|
247
|
+
function tryFindPropertyValueAsBoolean(projectContents, propertyName) {
|
|
248
|
+
const rawValue = tryFindPropertyValue(projectContents, propertyName);
|
|
249
|
+
switch (rawValue) {
|
|
250
|
+
case 'true':
|
|
251
|
+
return true;
|
|
252
|
+
case 'false':
|
|
253
|
+
return false;
|
|
254
|
+
default:
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
exports.tryFindPropertyValueAsBoolean = tryFindPropertyValueAsBoolean;
|
|
259
|
+
function findPropertyValue(projectContents, propertyName, filePath) {
|
|
260
|
+
const res = tryFindPropertyValue(projectContents, propertyName);
|
|
261
|
+
if (!res) {
|
|
262
|
+
throw new telemetry_1.CodedError('NoPropertyInProject', `Couldn't find property ${propertyName} from ${filePath}`, { propertyName: propertyName });
|
|
263
|
+
}
|
|
264
|
+
return res;
|
|
265
|
+
}
|
|
266
|
+
exports.findPropertyValue = findPropertyValue;
|
|
267
|
+
/**
|
|
268
|
+
* Search for the given import project in the project contents and return if it exists.
|
|
269
|
+
* @param projectContents The XML project contents.
|
|
270
|
+
* @param projectName The project to look for.
|
|
271
|
+
* @return If the target exists.
|
|
272
|
+
*/
|
|
273
|
+
function importProjectExists(projectContents, projectName) {
|
|
274
|
+
const nodes = msbuildSelect(`//msbuild:Import[contains(@Project,'${projectName}')]`, projectContents);
|
|
275
|
+
return nodes.length > 0;
|
|
276
|
+
}
|
|
277
|
+
exports.importProjectExists = importProjectExists;
|
|
278
|
+
/**
|
|
279
|
+
* Gets the configuration type of the project from the project contents.
|
|
280
|
+
* @param projectContents The XML project contents.
|
|
281
|
+
* @return The project configuration type.
|
|
282
|
+
*/
|
|
283
|
+
function getConfigurationType(projectContents) {
|
|
284
|
+
var _a;
|
|
285
|
+
const configurationType = (_a = tryFindPropertyValue(projectContents, 'ConfigurationType')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
286
|
+
switch (configurationType) {
|
|
287
|
+
case 'application':
|
|
288
|
+
case 'dynamiclibrary':
|
|
289
|
+
case 'generic':
|
|
290
|
+
case 'staticlibrary':
|
|
291
|
+
return configurationType;
|
|
292
|
+
default:
|
|
293
|
+
return 'unknown';
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
exports.getConfigurationType = getConfigurationType;
|
|
297
|
+
/**
|
|
298
|
+
* Gets the output type of the project from the project contents.
|
|
299
|
+
* @param projectContents The XML project contents.
|
|
300
|
+
* @return The project output type.
|
|
301
|
+
*/
|
|
302
|
+
function getOutputType(projectContents) {
|
|
303
|
+
var _a;
|
|
304
|
+
const outputType = (_a = tryFindPropertyValue(projectContents, 'OutputType')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
305
|
+
switch (outputType) {
|
|
306
|
+
case 'appcontainerexe':
|
|
307
|
+
case 'exe':
|
|
308
|
+
case 'library':
|
|
309
|
+
case 'module':
|
|
310
|
+
case 'winexe':
|
|
311
|
+
case 'winmdobj':
|
|
312
|
+
return outputType;
|
|
313
|
+
default:
|
|
314
|
+
return 'unknown';
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
exports.getOutputType = getOutputType;
|
|
318
|
+
/**
|
|
319
|
+
* Gets the type of the project from the project contents.
|
|
320
|
+
* @param projectPath The project file path to check.
|
|
321
|
+
* @param projectContents The XML project contents.
|
|
322
|
+
* @return The project type.
|
|
323
|
+
*/
|
|
324
|
+
function getProjectType(projectPath, projectContents) {
|
|
325
|
+
switch (getProjectLanguage(projectPath)) {
|
|
326
|
+
case 'cpp':
|
|
327
|
+
return getConfigurationType(projectContents);
|
|
328
|
+
case 'cs':
|
|
329
|
+
return getOutputType(projectContents);
|
|
330
|
+
default:
|
|
331
|
+
return 'unknown';
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
exports.getProjectType = getProjectType;
|
|
335
|
+
/**
|
|
336
|
+
* Gets the name of the project from the project contents.
|
|
337
|
+
* @param projectPath The project file path to check.
|
|
338
|
+
* @param projectContents The XML project contents.
|
|
339
|
+
* @return The project name.
|
|
340
|
+
*/
|
|
341
|
+
function getProjectName(projectPath, projectContents) {
|
|
342
|
+
const name = tryFindPropertyValue(projectContents, 'ProjectName') ||
|
|
343
|
+
path_1.default.parse(projectPath).name ||
|
|
344
|
+
'';
|
|
345
|
+
return name;
|
|
346
|
+
}
|
|
347
|
+
exports.getProjectName = getProjectName;
|
|
348
|
+
/**
|
|
349
|
+
* Gets the namespace of the project from the project contents.
|
|
350
|
+
* @param projectContents The XML project contents.
|
|
351
|
+
* @return The project namespace.
|
|
352
|
+
*/
|
|
353
|
+
function getProjectNamespace(projectContents) {
|
|
354
|
+
return tryFindPropertyValue(projectContents, 'RootNamespace');
|
|
355
|
+
}
|
|
356
|
+
exports.getProjectNamespace = getProjectNamespace;
|
|
357
|
+
/**
|
|
358
|
+
* Gets the guid of the project from the project contents.
|
|
359
|
+
* @param projectContents The XML project contents.
|
|
360
|
+
* @return The project guid.
|
|
361
|
+
*/
|
|
362
|
+
function getProjectGuid(projectContents) {
|
|
363
|
+
return tryFindPropertyValue(projectContents, 'ProjectGuid');
|
|
364
|
+
}
|
|
365
|
+
exports.getProjectGuid = getProjectGuid;
|
|
366
|
+
function getExperimentalFeatures(solutionDir) {
|
|
367
|
+
const propsFile = path_1.default.join(solutionDir, 'ExperimentalFeatures.props');
|
|
368
|
+
if (!fs_1.default.existsSync(propsFile)) {
|
|
369
|
+
return undefined;
|
|
370
|
+
}
|
|
371
|
+
const result = {};
|
|
372
|
+
const propsContents = readProjectFile(propsFile);
|
|
373
|
+
const nodes = msbuildSelect(`//msbuild:PropertyGroup/msbuild:*`, propsContents);
|
|
374
|
+
for (const node of nodes) {
|
|
375
|
+
const propertyNode = node;
|
|
376
|
+
result[propertyNode.nodeName] = propertyNode.textContent;
|
|
377
|
+
}
|
|
378
|
+
return result;
|
|
379
|
+
}
|
|
380
|
+
exports.getExperimentalFeatures = getExperimentalFeatures;
|
|
381
|
+
//# sourceMappingURL=configUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configUtils.js","sourceRoot":"","sources":["../../../src/commands/config/configUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,gDAAwB;AAExB,2CAAyC;AACzC,kDAA0B;AAC1B,+DAA2D;AAE3D,MAAM,aAAa,GAAG,eAAK,CAAC,aAAa,CAAC;IACxC,OAAO,EAAE,qDAAqD;CAC/D,CAAC,CAAC;AAEH;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,MAAc,EAAE,eAAuB;IAC/D,MAAM,KAAK,GAAG,cAAI,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,EAAE;QACxD,GAAG,EAAE,MAAM;QACX,MAAM,EAAE;YACN,iBAAiB;YACjB,aAAa;YACb,eAAe;YACf,uBAAuB;YACvB,gBAAgB;SACjB;KACF,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAbD,8BAaC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,MAAc;IAC9C,MAAM,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,C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OAAO,SAAS,CAAC;KAClB;IAED,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,MAAM,aAAa,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,aAAa,CACzB,mCAAmC,EACnC,aAAa,CACd,CAAC;IACF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,MAAM,YAAY,GAAG,IAAY,CAAC;QAClC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC;KAC1D;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AApBD,0DAoBC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport glob from 'glob';\n\nimport {DOMParser} from '@xmldom/xmldom';\nimport xpath from 'xpath';\nimport {CodedError} from '@react-native-windows/telemetry';\n\nconst msbuildSelect = xpath.useNamespaces({\n msbuild: 'http://schemas.microsoft.com/developer/msbuild/2003',\n});\n\n/**\n * Search for files matching the pattern under the target folder.\n * @param folder The absolute path to target folder.\n * @param filenamePattern The pattern to search for.\n * @return Return the array of relative file paths.\n */\nexport function findFiles(folder: string, filenamePattern: string): string[] {\n const files = glob.sync(path.join('**', filenamePattern), {\n cwd: folder,\n ignore: [\n 'node_modules/**',\n '**/Debug/**',\n '**/Release/**',\n '**/Generated Files/**',\n '**/packages/**',\n ],\n });\n\n return files;\n}\n\n/**\n * Search for the windows sub-folder under the target folder.\n * @param folder The absolute path to the target folder.\n * @return The absolute path to the windows folder, if it exists.\n */\nexport function findWindowsFolder(folder: string): string | null {\n const winDir = 'windows';\n const joinedDir = path.join(folder, winDir);\n if (fs.existsSync(joinedDir)) {\n return joinedDir;\n }\n\n return null;\n}\n\n/**\n * Checks if the target file path is a RNW solution file by checking if it contains the string \"ReactNative\".\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW solution file.\n */\nexport function isRnwSolution(filePath: string): boolean {\n return (\n fs\n .readFileSync(filePath)\n .toString()\n .search(/ReactNative/) > 0\n );\n}\n\n/**\n * Search for the RNW solution files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findSolutionFiles(winFolder: string): string[] {\n // First search for all potential solution files\n const allSolutions = findFiles(winFolder, '*.sln');\n\n if (allSolutions.length === 0) {\n // If there're no solution files, return 0\n return [];\n } else if (allSolutions.length === 1) {\n // If there is exactly one solution file, assume it's it\n return [allSolutions[0]];\n }\n\n const solutionFiles = [];\n\n // Try to find any solution file that appears to be a React Native solution\n for (const solutionFile of allSolutions) {\n if (isRnwSolution(path.join(winFolder, solutionFile))) {\n solutionFiles.push(path.normalize(solutionFile));\n }\n }\n\n return solutionFiles;\n}\n\n/**\n * Checks if the target file path is a RNW lib project file.\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW lib project file.\n */\nexport function isRnwDependencyProject(filePath: string): boolean {\n const projectContents = readProjectFile(filePath);\n\n const projectLang = getProjectLanguage(filePath);\n if (projectLang === 'cs') {\n return importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpLib.targets',\n );\n } else if (projectLang === 'cpp') {\n return (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppLib.targets',\n ) ||\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppLib.targets',\n )\n );\n }\n\n return false;\n}\n\n/**\n * Search for the RNW lib project files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findDependencyProjectFiles(winFolder: string): string[] {\n // First, search for all potential project files\n const allCppProj = findFiles(winFolder, '*.vcxproj');\n const allCsProj = findFiles(winFolder, '*.csproj');\n\n const allProjects = allCppProj.concat(allCsProj);\n\n if (allProjects.length === 0) {\n // If there're no project files, return 0\n return [];\n }\n\n const dependencyProjectFiles = [];\n\n // Try to find any project file that appears to be a dependency project\n for (const projectFile of allProjects) {\n // A project is marked as a RNW dependency iff either:\n // - If the project has the standard native module imports, or\n // - If we only have a single project (and it doesn't have the standard native module imports),\n // pick it and hope for the best. This enables autolinking for modules that were written\n // before the standard native module template existed.\n if (\n allProjects.length === 1 ||\n isRnwDependencyProject(path.join(winFolder, projectFile))\n ) {\n dependencyProjectFiles.push(path.normalize(projectFile));\n }\n }\n\n return dependencyProjectFiles;\n}\n\ntype ReactNativeProjectType = 'unknown' | 'App-WinAppSDK';\n\nfunction getReactNativeProjectType(\n value: string | null,\n): ReactNativeProjectType {\n switch (value) {\n case 'App-WinAppSDK':\n return value;\n\n default:\n return 'unknown';\n }\n}\n\n/**\n * Checks if the target file path is a RNW app project file.\n * @param filePath The absolute file path to check.\n * @return Whether the path is to a RNW app project file.\n */\nfunction isRnwAppProject(filePath: string): boolean {\n const projectContents = readProjectFile(filePath);\n\n const rnProjectType = getReactNativeProjectType(\n tryFindPropertyValue(projectContents, 'ReactNativeProjectType'),\n );\n\n if (rnProjectType !== 'unknown') {\n return true;\n }\n\n const projectLang = getProjectLanguage(filePath);\n if (projectLang === 'cs') {\n return importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CSharpApp.targets',\n );\n } else if (projectLang === 'cpp') {\n return (\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Uwp.CppApp.targets',\n ) ||\n importProjectExists(\n projectContents,\n 'Microsoft.ReactNative.Composition.CppApp.targets',\n )\n );\n }\n\n return false;\n}\n\n/**\n * Search for the RNW app project files under the target folder.\n * @param winFolder The absolute path to target folder.\n * @return Return the array of relative file paths.\n */\nexport function findAppProjectFiles(winFolder: string): string[] {\n // First, search for all potential project files\n const allCppProj = findFiles(winFolder, '*.vcxproj');\n const allCsProj = findFiles(winFolder, '*.csproj');\n\n const allProjects = allCppProj.concat(allCsProj);\n\n if (allProjects.length === 0) {\n // If there're no project files, return 0\n return [];\n }\n\n const appProjectFiles = [];\n\n // Try to find any project file that appears to be an app project\n for (const projectFile of allProjects) {\n if (isRnwAppProject(path.join(winFolder, projectFile))) {\n appProjectFiles.push(path.normalize(projectFile));\n }\n }\n\n return appProjectFiles;\n}\n\n/**\n * Returns the programming language of the project file.\n * @param projectPath The project file path to check.\n * @return The language string: cpp, cs, or null if unknown.\n */\nexport function getProjectLanguage(projectPath: string): 'cpp' | 'cs' | null {\n if (projectPath.endsWith('.vcxproj')) {\n return 'cpp';\n } else if (projectPath.endsWith('.csproj')) {\n return 'cs';\n }\n\n return null;\n}\n\n/**\n * Reads in the contents of the target project file.\n * @param projectPath The target project file path.\n * @return The project file contents.\n */\nexport function readProjectFile(projectPath: string) {\n const projectContents = fs.readFileSync(projectPath, 'utf8').toString();\n return new DOMParser().parseFromString(projectContents, 'application/xml');\n}\n\n/**\n * Search for the given property in the project contents and return its value.\n * @param projectContents The XML project contents.\n * @param propertyName The property to look for.\n * @return The value of the tag if it exists.\n */\nexport function tryFindPropertyValue(\n projectContents: Node,\n propertyName: string,\n): string | null {\n const nodes = msbuildSelect(\n `//msbuild:PropertyGroup/msbuild:${propertyName}`,\n projectContents,\n );\n\n if (nodes.length > 0) {\n // Take the last one\n return (nodes[nodes.length - 1] as Node).textContent;\n } else {\n const noNamespaceNodes = xpath.select(\n `//PropertyGroup/${propertyName}`,\n projectContents,\n );\n if (noNamespaceNodes.length > 0) {\n return (noNamespaceNodes[noNamespaceNodes.length - 1] as Node)\n .textContent;\n }\n }\n\n return null;\n}\n\n/**\n * Search for the given property in the project contents and return its value.\n * @param projectContents The XML project contents.\n * @param propertyName The property to look for.\n * @return The value of the tag if it exists.\n */\nexport function tryFindPropertyValueAsBoolean(\n projectContents: Node,\n propertyName: string,\n): boolean | null {\n const rawValue = tryFindPropertyValue(projectContents, propertyName);\n\n switch (rawValue) {\n case 'true':\n return true;\n case 'false':\n return false;\n default:\n return null;\n }\n}\n\nexport function findPropertyValue(\n projectContents: Node,\n propertyName: string,\n filePath: string,\n): string {\n const res = tryFindPropertyValue(projectContents, propertyName);\n if (!res) {\n throw new CodedError(\n 'NoPropertyInProject',\n `Couldn't find property ${propertyName} from ${filePath}`,\n {propertyName: propertyName},\n );\n }\n return res;\n}\n\n/**\n * Search for the given import project in the project contents and return if it exists.\n * @param projectContents The XML project contents.\n * @param projectName The project to look for.\n * @return If the target exists.\n */\nexport function importProjectExists(\n projectContents: Node,\n projectName: string,\n): boolean {\n const nodes = msbuildSelect(\n `//msbuild:Import[contains(@Project,'${projectName}')]`,\n projectContents,\n );\n\n return nodes.length > 0;\n}\n\nexport type ConfigurationType =\n | 'application'\n | 'dynamiclibrary'\n | 'generic'\n | 'staticlibrary'\n | 'unknown';\n\n/**\n * Gets the configuration type of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project configuration type.\n */\nexport function getConfigurationType(projectContents: Node): ConfigurationType {\n const configurationType = tryFindPropertyValue(\n projectContents,\n 'ConfigurationType',\n )?.toLowerCase();\n\n switch (configurationType) {\n case 'application':\n case 'dynamiclibrary':\n case 'generic':\n case 'staticlibrary':\n return configurationType;\n\n default:\n return 'unknown';\n }\n}\n\nexport type OutputType =\n | 'appcontainerexe'\n | 'exe'\n | 'library'\n | 'module'\n | 'unknown'\n | 'winexe'\n | 'winmdobj';\n\n/**\n * Gets the output type of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project output type.\n */\nexport function getOutputType(projectContents: Node): OutputType {\n const outputType = tryFindPropertyValue(\n projectContents,\n 'OutputType',\n )?.toLowerCase();\n\n switch (outputType) {\n case 'appcontainerexe':\n case 'exe':\n case 'library':\n case 'module':\n case 'winexe':\n case 'winmdobj':\n return outputType;\n\n default:\n return 'unknown';\n }\n}\n\n/**\n * Gets the type of the project from the project contents.\n * @param projectPath The project file path to check.\n * @param projectContents The XML project contents.\n * @return The project type.\n */\nexport function getProjectType(\n projectPath: string,\n projectContents: Node,\n): ConfigurationType | OutputType {\n switch (getProjectLanguage(projectPath)) {\n case 'cpp':\n return getConfigurationType(projectContents);\n\n case 'cs':\n return getOutputType(projectContents);\n\n default:\n return 'unknown';\n }\n}\n\n/**\n * Gets the name of the project from the project contents.\n * @param projectPath The project file path to check.\n * @param projectContents The XML project contents.\n * @return The project name.\n */\nexport function getProjectName(\n projectPath: string,\n projectContents: Node,\n): string {\n const name =\n tryFindPropertyValue(projectContents, 'ProjectName') ||\n path.parse(projectPath).name ||\n '';\n\n return name;\n}\n\n/**\n * Gets the namespace of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project namespace.\n */\nexport function getProjectNamespace(projectContents: Node): string | null {\n return tryFindPropertyValue(projectContents, 'RootNamespace');\n}\n\n/**\n * Gets the guid of the project from the project contents.\n * @param projectContents The XML project contents.\n * @return The project guid.\n */\nexport function getProjectGuid(projectContents: Node): string | null {\n return tryFindPropertyValue(projectContents, 'ProjectGuid');\n}\n\nexport function getExperimentalFeatures(\n solutionDir: string,\n): Record<string, string> | undefined {\n const propsFile = path.join(solutionDir, 'ExperimentalFeatures.props');\n\n if (!fs.existsSync(propsFile)) {\n return undefined;\n }\n\n const result: Record<string, any> = {};\n const propsContents = readProjectFile(propsFile);\n const nodes = msbuildSelect(\n `//msbuild:PropertyGroup/msbuild:*`,\n propsContents,\n );\n for (const node of nodes) {\n const propertyNode = node as Node;\n result[propertyNode.nodeName] = propertyNode.textContent;\n }\n return result;\n}\n"]}
|