@react-native-windows/cli 0.0.0-canary.21 → 0.0.0-canary.211
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,110 +1,110 @@
|
|
|
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
|
-
const VERSION_EXPRESSION = /^\d{1,8}(\.\d{1,8}){0,3}$/;
|
|
9
|
-
class Version {
|
|
10
|
-
constructor(major, minor = 0, build = 0, qfe = 0) {
|
|
11
|
-
this.major = major;
|
|
12
|
-
this.minor = minor;
|
|
13
|
-
this.build = build;
|
|
14
|
-
this.qfe = qfe;
|
|
15
|
-
}
|
|
16
|
-
eq(other) {
|
|
17
|
-
if (other.constructor !== Version) {
|
|
18
|
-
throw new TypeError('other must be a Version instance');
|
|
19
|
-
}
|
|
20
|
-
return (this.major === other.major &&
|
|
21
|
-
this.minor === other.minor &&
|
|
22
|
-
this.build === other.build &&
|
|
23
|
-
this.qfe === other.qfe);
|
|
24
|
-
}
|
|
25
|
-
gt(other) {
|
|
26
|
-
if (other.constructor !== Version) {
|
|
27
|
-
throw new TypeError('other must be a Version instance');
|
|
28
|
-
}
|
|
29
|
-
if (this.major > other.major) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
if (this.major < other.major) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
if (this.minor > other.minor) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
if (this.minor < other.minor) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
if (this.build > other.build) {
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
if (this.build < other.build) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
if (this.qfe > other.qfe) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
if (this.qfe < other.qfe) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
gte(other) {
|
|
56
|
-
if (other.constructor !== Version) {
|
|
57
|
-
throw new TypeError('other must be a Version instance');
|
|
58
|
-
}
|
|
59
|
-
if (this.major > other.major) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
if (this.major < other.major) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
if (this.minor > other.minor) {
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
if (this.minor < other.minor) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
if (this.build > other.build) {
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
if (this.build < other.build) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
if (this.qfe > other.qfe) {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
if (this.qfe < other.qfe) {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
toString() {
|
|
86
|
-
return `${this.major}.${this.minor}.${this.build}.${this.qfe}`;
|
|
87
|
-
}
|
|
88
|
-
static compare(x, y) {
|
|
89
|
-
if (x.constructor !== Version || y.constructor !== Version) {
|
|
90
|
-
throw new TypeError('Only can compare Version objects');
|
|
91
|
-
}
|
|
92
|
-
return x.gt(y) ? 1 : x.eq(y) ? 0 : -1;
|
|
93
|
-
}
|
|
94
|
-
static fromString(str) {
|
|
95
|
-
const version = Version.tryParse(str);
|
|
96
|
-
if (!version) {
|
|
97
|
-
throw new TypeError('Cannot construct a version from "' + str + '".');
|
|
98
|
-
}
|
|
99
|
-
return version;
|
|
100
|
-
}
|
|
101
|
-
static tryParse(str) {
|
|
102
|
-
if (VERSION_EXPRESSION.test(str)) {
|
|
103
|
-
const versionArray = str.split('.').map(x => parseInt(x, 10));
|
|
104
|
-
return new Version(versionArray[0], versionArray[1], versionArray[2], versionArray[3]);
|
|
105
|
-
}
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.default = Version;
|
|
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
|
+
const VERSION_EXPRESSION = /^\d{1,8}(\.\d{1,8}){0,3}$/;
|
|
9
|
+
class Version {
|
|
10
|
+
constructor(major, minor = 0, build = 0, qfe = 0) {
|
|
11
|
+
this.major = major;
|
|
12
|
+
this.minor = minor;
|
|
13
|
+
this.build = build;
|
|
14
|
+
this.qfe = qfe;
|
|
15
|
+
}
|
|
16
|
+
eq(other) {
|
|
17
|
+
if (other.constructor !== Version) {
|
|
18
|
+
throw new TypeError('other must be a Version instance');
|
|
19
|
+
}
|
|
20
|
+
return (this.major === other.major &&
|
|
21
|
+
this.minor === other.minor &&
|
|
22
|
+
this.build === other.build &&
|
|
23
|
+
this.qfe === other.qfe);
|
|
24
|
+
}
|
|
25
|
+
gt(other) {
|
|
26
|
+
if (other.constructor !== Version) {
|
|
27
|
+
throw new TypeError('other must be a Version instance');
|
|
28
|
+
}
|
|
29
|
+
if (this.major > other.major) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (this.major < other.major) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (this.minor > other.minor) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
if (this.minor < other.minor) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
if (this.build > other.build) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (this.build < other.build) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
if (this.qfe > other.qfe) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (this.qfe < other.qfe) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
gte(other) {
|
|
56
|
+
if (other.constructor !== Version) {
|
|
57
|
+
throw new TypeError('other must be a Version instance');
|
|
58
|
+
}
|
|
59
|
+
if (this.major > other.major) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (this.major < other.major) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
if (this.minor > other.minor) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if (this.minor < other.minor) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (this.build > other.build) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (this.build < other.build) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (this.qfe > other.qfe) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (this.qfe < other.qfe) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
toString() {
|
|
86
|
+
return `${this.major}.${this.minor}.${this.build}.${this.qfe}`;
|
|
87
|
+
}
|
|
88
|
+
static compare(x, y) {
|
|
89
|
+
if (x.constructor !== Version || y.constructor !== Version) {
|
|
90
|
+
throw new TypeError('Only can compare Version objects');
|
|
91
|
+
}
|
|
92
|
+
return x.gt(y) ? 1 : x.eq(y) ? 0 : -1;
|
|
93
|
+
}
|
|
94
|
+
static fromString(str) {
|
|
95
|
+
const version = Version.tryParse(str);
|
|
96
|
+
if (!version) {
|
|
97
|
+
throw new TypeError('Cannot construct a version from "' + str + '".');
|
|
98
|
+
}
|
|
99
|
+
return version;
|
|
100
|
+
}
|
|
101
|
+
static tryParse(str) {
|
|
102
|
+
if (VERSION_EXPRESSION.test(str)) {
|
|
103
|
+
const versionArray = str.split('.').map(x => parseInt(x, 10));
|
|
104
|
+
return new Version(versionArray[0], versionArray[1], versionArray[2], versionArray[3]);
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.default = Version;
|
|
110
110
|
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/utils/version.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAEH,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAEvD,MAAqB,OAAO;IAC1B,YACmB,KAAa,EACb,QAAgB,CAAC,EACjB,QAAgB,CAAC,EACjB,MAAc,CAAC;QAHf,UAAK,GAAL,KAAK,CAAQ;QACb,UAAK,GAAL,KAAK,CAAY;QACjB,UAAK,GAAL,KAAK,CAAY;QACjB,QAAG,GAAH,GAAG,CAAY;IAC/B,CAAC;IAEJ,EAAE,CAAC,KAAc;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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,GAAW;QAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,IAAI,SAAS,CAAC,mCAAmC,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;SACvE;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,GAAW;QACzB,IAAI,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YAChC,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YAC9D,OAAO,IAAI,OAAO,CAChB,YAAY,CAAC,CAAC,CAAC,EACf,YAAY,CAAC,CAAC,CAAC,EACf,YAAY,CAAC,CAAC,CAAC,EACf,YAAY,CAAC,CAAC,CAAC,CAChB,CAAC;SACH;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAvHD,0BAuHC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nconst VERSION_EXPRESSION = /^\\d{1,8}(\\.\\d{1,8}){0,3}$/;\n\nexport default class Version {\n constructor(\n private readonly major: number,\n private readonly minor: number = 0,\n private readonly build: number = 0,\n private readonly qfe: number = 0,\n ) {}\n\n eq(other: Version): boolean {\n if (other.constructor !== Version) {\n throw new TypeError('other must be a Version instance');\n }\n\n return (\n this.major === other.major &&\n this.minor === other.minor &&\n this.build === other.build &&\n this.qfe === other.qfe\n );\n }\n\n gt(other: Version): boolean {\n if (other.constructor !== Version) {\n throw new TypeError('other must be a Version instance');\n }\n\n if (this.major > other.major) {\n return true;\n }\n if (this.major < other.major) {\n return false;\n }\n if (this.minor > other.minor) {\n return true;\n }\n if (this.minor < other.minor) {\n return false;\n }\n if (this.build > other.build) {\n return true;\n }\n if (this.build < other.build) {\n return false;\n }\n if (this.qfe > other.qfe) {\n return true;\n }\n if (this.qfe < other.qfe) {\n return false;\n }\n\n return false;\n }\n\n gte(other: Version): boolean {\n if (other.constructor !== Version) {\n throw new TypeError('other must be a Version instance');\n }\n\n if (this.major > other.major) {\n return true;\n }\n if (this.major < other.major) {\n return false;\n }\n if (this.minor > other.minor) {\n return true;\n }\n if (this.minor < other.minor) {\n return false;\n }\n if (this.build > other.build) {\n return true;\n }\n if (this.build < other.build) {\n return false;\n }\n if (this.qfe > other.qfe) {\n return true;\n }\n if (this.qfe < other.qfe) {\n return false;\n }\n\n return true;\n }\n\n toString(): string {\n return `${this.major}.${this.minor}.${this.build}.${this.qfe}`;\n }\n\n static compare(x: Version, y: Version): number {\n if (x.constructor !== Version || y.constructor !== Version) {\n throw new TypeError('Only can compare Version objects');\n }\n\n return x.gt(y) ? 1 : x.eq(y) ? 0 : -1;\n }\n\n static fromString(str: string): Version {\n const version = Version.tryParse(str);\n if (!version) {\n throw new TypeError('Cannot construct a version from \"' + str + '\".');\n }\n return version;\n }\n\n static tryParse(str: string): Version | null {\n if (VERSION_EXPRESSION.test(str)) {\n const versionArray = str.split('.').map(x => parseInt(x, 10));\n return new Version(\n versionArray[0],\n versionArray[1],\n versionArray[2],\n versionArray[3],\n );\n }\n return null;\n }\n}\n"]}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
* @format
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* A subset of the per-instance properties returned by vswhere
|
|
8
|
-
*/
|
|
9
|
-
interface VisualStudioInstallation {
|
|
10
|
-
instanceId: string;
|
|
11
|
-
installationPath: string;
|
|
12
|
-
installationVersion: string;
|
|
13
|
-
prerelease: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Enumerate the installed versions of Visual Studio
|
|
17
|
-
*/
|
|
18
|
-
export declare function enumerateVsInstalls(opts: {
|
|
19
|
-
requires?: string[];
|
|
20
|
-
|
|
21
|
-
verbose?: boolean;
|
|
22
|
-
latest?: boolean;
|
|
23
|
-
prerelease?: boolean;
|
|
24
|
-
}): VisualStudioInstallation[];
|
|
25
|
-
/**
|
|
26
|
-
* Find the latest available VS installation that matches the given constraints
|
|
27
|
-
*/
|
|
28
|
-
export declare function findLatestVsInstall(opts: {
|
|
29
|
-
requires?: string[];
|
|
30
|
-
|
|
31
|
-
verbose?: boolean;
|
|
32
|
-
prerelease?: boolean;
|
|
33
|
-
}): VisualStudioInstallation | null;
|
|
34
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A subset of the per-instance properties returned by vswhere
|
|
8
|
+
*/
|
|
9
|
+
interface VisualStudioInstallation {
|
|
10
|
+
instanceId: string;
|
|
11
|
+
installationPath: string;
|
|
12
|
+
installationVersion: string;
|
|
13
|
+
prerelease: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Enumerate the installed versions of Visual Studio
|
|
17
|
+
*/
|
|
18
|
+
export declare function enumerateVsInstalls(opts: {
|
|
19
|
+
requires?: string[];
|
|
20
|
+
minVersion?: string;
|
|
21
|
+
verbose?: boolean;
|
|
22
|
+
latest?: boolean;
|
|
23
|
+
prerelease?: boolean;
|
|
24
|
+
}): VisualStudioInstallation[];
|
|
25
|
+
/**
|
|
26
|
+
* Find the latest available VS installation that matches the given constraints
|
|
27
|
+
*/
|
|
28
|
+
export declare function findLatestVsInstall(opts: {
|
|
29
|
+
requires?: string[];
|
|
30
|
+
minVersion?: string;
|
|
31
|
+
verbose?: boolean;
|
|
32
|
+
prerelease?: boolean;
|
|
33
|
+
}): VisualStudioInstallation | null;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
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.findLatestVsInstall = exports.enumerateVsInstalls = void 0;
|
|
12
|
+
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
14
|
+
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const semver_1 = __importDefault(require("semver"));
|
|
17
|
+
/**
|
|
18
|
+
* Helper to run vswhere in JSON mode
|
|
19
|
+
*
|
|
20
|
+
* @param args Arguments to pass to vsWhere
|
|
21
|
+
* @param verbose enable verbose logging
|
|
22
|
+
*/
|
|
23
|
+
function vsWhere(args, verbose) {
|
|
24
|
+
// This path is maintained and VS has promised to keep it valid.
|
|
25
|
+
const vsWherePath = path_1.default.join(process.env['ProgramFiles(x86)'] || process.env.ProgramFiles, '/Microsoft Visual Studio/Installer/vswhere.exe');
|
|
26
|
+
if (verbose) {
|
|
27
|
+
console.log('Looking for vswhere at: ' + vsWherePath);
|
|
28
|
+
}
|
|
29
|
+
if (!fs_1.default.existsSync(vsWherePath)) {
|
|
30
|
+
throw new telemetry_1.CodedError('NoVSWhere', `Unable to find vswhere at ${vsWherePath}`);
|
|
31
|
+
}
|
|
32
|
+
const system32 = `${process.env.SystemRoot}\\System32`;
|
|
33
|
+
const cmdline = `${system32}\\cmd.exe /c ${system32}\\chcp.com 65001>nul && "${vsWherePath}" ${args.join(' ')} -format json -utf8`;
|
|
34
|
+
const json = JSON.parse((0, child_process_1.execSync)(cmdline).toString());
|
|
35
|
+
for (const entry of json) {
|
|
36
|
+
entry.prerelease = entry.catalog.productMilestoneIsPreRelease;
|
|
37
|
+
}
|
|
38
|
+
return json;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Enumerate the installed versions of Visual Studio
|
|
42
|
+
*/
|
|
43
|
+
function enumerateVsInstalls(opts) {
|
|
44
|
+
const args = [];
|
|
45
|
+
if (opts.minVersion) {
|
|
46
|
+
// VS 2019 ex: minVersion == 16.7 => [16.7,17.0)
|
|
47
|
+
// VS 2022 ex: minVersion == 17.0 => [17.0,18.0)
|
|
48
|
+
// Try to parse minVersion as both a Number and SemVer
|
|
49
|
+
const minVersionNum = Number(opts.minVersion);
|
|
50
|
+
const minVersionSemVer = semver_1.default.parse(opts.minVersion);
|
|
51
|
+
let minVersion;
|
|
52
|
+
let maxVersion;
|
|
53
|
+
if (minVersionSemVer) {
|
|
54
|
+
minVersion = minVersionSemVer.toString();
|
|
55
|
+
maxVersion = (minVersionSemVer.major + 1).toFixed(1);
|
|
56
|
+
}
|
|
57
|
+
else if (!Number.isNaN(minVersionNum)) {
|
|
58
|
+
minVersion = minVersionNum.toFixed(1);
|
|
59
|
+
maxVersion = (Math.floor(minVersionNum) + 1).toFixed(1);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// Unable to parse minVersion and determine maxVersion,
|
|
63
|
+
// caller will throw error that version couldn't be found.
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
const versionRange = `[${minVersion},${maxVersion}` + (opts.prerelease ? ']' : ')');
|
|
67
|
+
if (opts.verbose) {
|
|
68
|
+
console.log(`Looking for VS installs with version range: ${versionRange}`);
|
|
69
|
+
}
|
|
70
|
+
args.push(`-version ${versionRange}`);
|
|
71
|
+
}
|
|
72
|
+
if (opts.requires) {
|
|
73
|
+
args.push(`-requires ${opts.requires.join(' ')}`);
|
|
74
|
+
}
|
|
75
|
+
if (opts.latest) {
|
|
76
|
+
args.push('-latest');
|
|
77
|
+
}
|
|
78
|
+
if (opts.prerelease) {
|
|
79
|
+
args.push('-prerelease');
|
|
80
|
+
}
|
|
81
|
+
return vsWhere(args, opts.verbose);
|
|
82
|
+
}
|
|
83
|
+
exports.enumerateVsInstalls = enumerateVsInstalls;
|
|
84
|
+
/**
|
|
85
|
+
* Find the latest available VS installation that matches the given constraints
|
|
86
|
+
*/
|
|
87
|
+
function findLatestVsInstall(opts) {
|
|
88
|
+
let installs = enumerateVsInstalls({ ...opts, latest: true });
|
|
89
|
+
if (opts.prerelease && installs.length > 0) {
|
|
90
|
+
installs = installs.filter(x => x.prerelease === 'True');
|
|
91
|
+
}
|
|
92
|
+
if (installs.length > 0) {
|
|
93
|
+
return installs[0];
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.findLatestVsInstall = findLatestVsInstall;
|
|
100
|
+
//# sourceMappingURL=vsInstalls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vsInstalls.js","sourceRoot":"","sources":["../../src/utils/vsInstalls.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,+DAA2D;AAC3D,iDAAuC;AACvC,kEAA0C;AAC1C,gDAAwB;AACxB,oDAA4B;AAY5B;;;;;GAKG;AACH,SAAS,OAAO,CAAC,IAAc,EAAE,OAAiB;IAChD,gEAAgE;IAChE,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAC3B,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,YAAa,EAC7D,gDAAgD,CACjD,CAAC;IAEF,IAAI,OAAO,EAAE;QACX,OAAO,CAAC,GAAG,CAAC,0BAA0B,GA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AAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,MAAM,CAAC,CAAC;KAC1D;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;KACpB;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAjBD,kDAiBC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {CodedError} from '@react-native-windows/telemetry';\nimport {execSync} from 'child_process';\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport semver from 'semver';\n\n/**\n * A subset of the per-instance properties returned by vswhere\n */\ninterface VisualStudioInstallation {\n instanceId: string;\n installationPath: string;\n installationVersion: string;\n prerelease: string;\n}\n\n/**\n * Helper to run vswhere in JSON mode\n *\n * @param args Arguments to pass to vsWhere\n * @param verbose enable verbose logging\n */\nfunction vsWhere(args: string[], verbose?: boolean): any[] {\n // This path is maintained and VS has promised to keep it valid.\n const vsWherePath = path.join(\n process.env['ProgramFiles(x86)'] || process.env.ProgramFiles!,\n '/Microsoft Visual Studio/Installer/vswhere.exe',\n );\n\n if (verbose) {\n console.log('Looking for vswhere at: ' + vsWherePath);\n }\n\n if (!fs.existsSync(vsWherePath)) {\n throw new CodedError(\n 'NoVSWhere',\n `Unable to find vswhere at ${vsWherePath}`,\n );\n }\n\n const system32 = `${process.env.SystemRoot}\\\\System32`;\n const cmdline = `${system32}\\\\cmd.exe /c ${system32}\\\\chcp.com 65001>nul && \"${vsWherePath}\" ${args.join(\n ' ',\n )} -format json -utf8`;\n const json = JSON.parse(execSync(cmdline).toString());\n\n for (const entry of json) {\n entry.prerelease = entry.catalog.productMilestoneIsPreRelease;\n }\n\n return json;\n}\n\n/**\n * Enumerate the installed versions of Visual Studio\n */\nexport function enumerateVsInstalls(opts: {\n requires?: string[];\n minVersion?: string;\n verbose?: boolean;\n latest?: boolean;\n prerelease?: boolean;\n}): VisualStudioInstallation[] {\n const args: string[] = [];\n\n if (opts.minVersion) {\n // VS 2019 ex: minVersion == 16.7 => [16.7,17.0)\n // VS 2022 ex: minVersion == 17.0 => [17.0,18.0)\n\n // Try to parse minVersion as both a Number and SemVer\n const minVersionNum = Number(opts.minVersion);\n const minVersionSemVer = semver.parse(opts.minVersion);\n\n let minVersion: string;\n let maxVersion: string;\n\n if (minVersionSemVer) {\n minVersion = minVersionSemVer.toString();\n maxVersion = (minVersionSemVer.major + 1).toFixed(1);\n } else if (!Number.isNaN(minVersionNum)) {\n minVersion = minVersionNum.toFixed(1);\n maxVersion = (Math.floor(minVersionNum) + 1).toFixed(1);\n } else {\n // Unable to parse minVersion and determine maxVersion,\n // caller will throw error that version couldn't be found.\n return [];\n }\n\n const versionRange =\n `[${minVersion},${maxVersion}` + (opts.prerelease ? ']' : ')');\n\n if (opts.verbose) {\n console.log(\n `Looking for VS installs with version range: ${versionRange}`,\n );\n }\n\n args.push(`-version ${versionRange}`);\n }\n\n if (opts.requires) {\n args.push(`-requires ${opts.requires.join(' ')}`);\n }\n\n if (opts.latest) {\n args.push('-latest');\n }\n\n if (opts.prerelease) {\n args.push('-prerelease');\n }\n\n return vsWhere(args, opts.verbose);\n}\n\n/**\n * Find the latest available VS installation that matches the given constraints\n */\nexport function findLatestVsInstall(opts: {\n requires?: string[];\n minVersion?: string;\n verbose?: boolean;\n prerelease?: boolean;\n}): VisualStudioInstallation | null {\n let installs = enumerateVsInstalls({...opts, latest: true});\n\n if (opts.prerelease && installs.length > 0) {\n installs = installs.filter(x => x.prerelease === 'True');\n }\n\n if (installs.length > 0) {\n return installs[0];\n } else {\n return null;\n }\n}\n"]}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
* @format
|
|
5
|
-
*/
|
|
6
|
-
import { Project } from '
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
import { Project } from '../commands/config/projectConfig';
|
|
7
|
+
export declare const dotNetCoreProjectTypeGuid = "{9A19103F-16F7-4668-BE54-9A1E7A4F7556}";
|
|
8
|
+
/**
|
|
9
|
+
* Adds the necessary info from a VS project into a VS solution file so that it will build.
|
|
10
|
+
* @param slnFile The Absolute path to the target VS solution file.
|
|
11
|
+
* @param project The object representing the project info.
|
|
12
|
+
* @param verbose If true, enable verbose logging.
|
|
13
|
+
* @param checkMode It true, don't make any changes.
|
|
14
|
+
* @return Whether any changes were necessary.
|
|
15
|
+
*/
|
|
16
|
+
export declare function addProjectToSolution(slnFile: string, project: Project, verbose?: boolean, checkMode?: boolean): boolean;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
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.addProjectToSolution = exports.dotNetCoreProjectTypeGuid = void 0;
|
|
12
|
+
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
15
|
+
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
16
|
+
const projectTypeGuidsByLanguage = {
|
|
17
|
+
cpp: '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}',
|
|
18
|
+
cs: '{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}',
|
|
19
|
+
};
|
|
20
|
+
exports.dotNetCoreProjectTypeGuid = '{9A19103F-16F7-4668-BE54-9A1E7A4F7556}';
|
|
21
|
+
/**
|
|
22
|
+
* Checks is the given block of lines exists within an array of lines.
|
|
23
|
+
* @param lines The array of lines to search.
|
|
24
|
+
* @param block The block of lines to search for.
|
|
25
|
+
* @return The starting index the block within lines, if it exists.
|
|
26
|
+
*/
|
|
27
|
+
function linesContainsBlock(lines, block) {
|
|
28
|
+
if (block.length > 0) {
|
|
29
|
+
const startIndex = lines.findIndex(s => block[0] instanceof RegExp ? s.match(block[0]) : s === block[0]);
|
|
30
|
+
if (startIndex >= 0) {
|
|
31
|
+
for (let i = 1; i < block.length; i++) {
|
|
32
|
+
if (block[i] instanceof RegExp
|
|
33
|
+
? !lines[startIndex + i].match(block[i])
|
|
34
|
+
: lines[startIndex + i] !== block[i]) {
|
|
35
|
+
return -1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return startIndex;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Insert the given block of lines into an array of lines.
|
|
45
|
+
* @param lines The array of lines to insert into.
|
|
46
|
+
* @param block The block of lines to insert.
|
|
47
|
+
* @param index The index to perform the insert.
|
|
48
|
+
*/
|
|
49
|
+
function insertBlockIntoLines(lines, block, index) {
|
|
50
|
+
for (let i = 0; i < block.length; i++) {
|
|
51
|
+
lines.splice(index + i, 0, block[i]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Overwrite the lines at the given index with the block.
|
|
56
|
+
* @param lines The destination array of lines to.
|
|
57
|
+
* @param block The source block of lines.
|
|
58
|
+
* @param index The index to perform the overwrite.
|
|
59
|
+
*/
|
|
60
|
+
function overwriteLinesWithBlock(lines, block, index) {
|
|
61
|
+
for (let i = 0; i < block.length; i++) {
|
|
62
|
+
lines[index + i] = block[i];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Search through an array of lines for a block of lines starting with startLine and ending with endLine.
|
|
67
|
+
* @param lines The array of lines to search.
|
|
68
|
+
* @param startLine The first line of the block.
|
|
69
|
+
* @param endLine The last line of the block.
|
|
70
|
+
* @param includeStartEnd Include the start and end lines in the result.
|
|
71
|
+
* @return The found block of lines, if found.
|
|
72
|
+
*/
|
|
73
|
+
function getBlockContentsFromLines(lines, startLine, endLine, includeStartEnd = true) {
|
|
74
|
+
const startIndex = lines.indexOf(startLine);
|
|
75
|
+
const endIndex = lines.indexOf(endLine, startIndex);
|
|
76
|
+
if (startIndex >= 0 && startIndex < endIndex) {
|
|
77
|
+
if (includeStartEnd) {
|
|
78
|
+
return lines.slice(startIndex, endIndex + 1);
|
|
79
|
+
}
|
|
80
|
+
else if (startIndex + 1 < endIndex) {
|
|
81
|
+
return lines.slice(startIndex + 1, endIndex);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Adds the necessary info from a VS project into a VS solution file so that it will build.
|
|
88
|
+
* @param slnFile The Absolute path to the target VS solution file.
|
|
89
|
+
* @param project The object representing the project info.
|
|
90
|
+
* @param verbose If true, enable verbose logging.
|
|
91
|
+
* @param checkMode It true, don't make any changes.
|
|
92
|
+
* @return Whether any changes were necessary.
|
|
93
|
+
*/
|
|
94
|
+
function addProjectToSolution(slnFile, project, verbose = false, checkMode = false) {
|
|
95
|
+
if (project.projectLang === null) {
|
|
96
|
+
throw new telemetry_1.CodedError('AddProjectToSolution', 'Unable to add project to solution, projectLang is null');
|
|
97
|
+
}
|
|
98
|
+
if (project.projectGuid === null) {
|
|
99
|
+
throw new telemetry_1.CodedError('AddProjectToSolution', 'Unable to add project to solution, projectGuid is null');
|
|
100
|
+
}
|
|
101
|
+
if (verbose) {
|
|
102
|
+
console.log(`Processing ${chalk_1.default.bold(path_1.default.basename(project.projectFile))}...`);
|
|
103
|
+
}
|
|
104
|
+
const originalSlnContents = fs_1.default.readFileSync(slnFile).toString();
|
|
105
|
+
const isCRLF = originalSlnContents.includes('\r\n');
|
|
106
|
+
const slnLines = originalSlnContents.split(isCRLF ? '\r\n' : '\n');
|
|
107
|
+
let contentsChanged = false;
|
|
108
|
+
// Check for the project entry block
|
|
109
|
+
const slnDir = path_1.default.dirname(slnFile);
|
|
110
|
+
const relProjectFile = path_1.default.relative(slnDir, project.projectFile);
|
|
111
|
+
const projectTypeGuid = 'projectTypeGuid' in project
|
|
112
|
+
? project.projectTypeGuid
|
|
113
|
+
: projectTypeGuidsByLanguage[project.projectLang];
|
|
114
|
+
const projectGuid = project.projectGuid.toUpperCase();
|
|
115
|
+
const projectEntryBlock = [
|
|
116
|
+
`Project("${projectTypeGuid}") = "${project.projectName}", "${relProjectFile}", "${projectGuid}"`,
|
|
117
|
+
'EndProject',
|
|
118
|
+
];
|
|
119
|
+
const projectEntryBlockRegex = [
|
|
120
|
+
new RegExp(`Project\\("${projectTypeGuid}"\\) = "${project.projectName}", "(.*)", "${projectGuid}"`),
|
|
121
|
+
'EndProject',
|
|
122
|
+
];
|
|
123
|
+
const blockIndex = linesContainsBlock(slnLines, projectEntryBlockRegex);
|
|
124
|
+
if (blockIndex < 0) {
|
|
125
|
+
// Regex didn't match, insert
|
|
126
|
+
if (verbose) {
|
|
127
|
+
console.log(chalk_1.default.yellow('Missing project entry block, inserting.'));
|
|
128
|
+
}
|
|
129
|
+
const globalIndex = slnLines.indexOf('Global');
|
|
130
|
+
insertBlockIntoLines(slnLines, projectEntryBlock, globalIndex);
|
|
131
|
+
contentsChanged = true;
|
|
132
|
+
}
|
|
133
|
+
else if (linesContainsBlock(slnLines, projectEntryBlock) < 0) {
|
|
134
|
+
// Regex matched but project path has changed, so correct it
|
|
135
|
+
if (verbose) {
|
|
136
|
+
console.log(chalk_1.default.yellow('Existing project entry block found, overwriting.'));
|
|
137
|
+
}
|
|
138
|
+
overwriteLinesWithBlock(slnLines, projectEntryBlock, blockIndex);
|
|
139
|
+
contentsChanged = true;
|
|
140
|
+
}
|
|
141
|
+
// Check for the project configuration platforms
|
|
142
|
+
const slnConfigs = getBlockContentsFromLines(slnLines, '\tGlobalSection(SolutionConfigurationPlatforms) = preSolution', '\tEndGlobalSection', false).map(line => line.match(/\s+([\w\s|]+)\s=/)[1]);
|
|
143
|
+
const projectConfigLines = [];
|
|
144
|
+
slnConfigs.forEach(slnConfig => {
|
|
145
|
+
if (!slnConfig.endsWith('|Any CPU')) {
|
|
146
|
+
projectConfigLines.push(`\t\t${projectGuid}.${slnConfig}.ActiveCfg = ${project.projectLang === 'cpp'
|
|
147
|
+
? slnConfig.replace('x86', 'Win32')
|
|
148
|
+
: slnConfig}`);
|
|
149
|
+
projectConfigLines.push(`\t\t${projectGuid}.${slnConfig}.Build.0 = ${project.projectLang === 'cpp'
|
|
150
|
+
? slnConfig.replace('x86', 'Win32')
|
|
151
|
+
: slnConfig}`);
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
const projectConfigStartIndex = slnLines.indexOf('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution');
|
|
155
|
+
projectConfigLines.forEach(projectConfigLine => {
|
|
156
|
+
if (!slnLines.includes(projectConfigLine)) {
|
|
157
|
+
if (verbose) {
|
|
158
|
+
const configLine = projectConfigLine.substr(projectConfigLine.indexOf('= ') + 2);
|
|
159
|
+
console.log(chalk_1.default.yellow(`Missing ${configLine} config block.`));
|
|
160
|
+
}
|
|
161
|
+
const projectConfigEndIndex = slnLines.indexOf('\tEndGlobalSection', projectConfigStartIndex);
|
|
162
|
+
slnLines.splice(projectConfigEndIndex, 0, projectConfigLine);
|
|
163
|
+
contentsChanged = true;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
// Write out new solution file if there were changes
|
|
167
|
+
if (contentsChanged) {
|
|
168
|
+
if (verbose) {
|
|
169
|
+
console.log(chalk_1.default.yellow(`${chalk_1.default.bold(path_1.default.basename(slnFile))} needs to be updated.`));
|
|
170
|
+
}
|
|
171
|
+
if (!checkMode) {
|
|
172
|
+
if (verbose) {
|
|
173
|
+
console.log(`Writing changes to ${chalk_1.default.bold(path_1.default.basename(slnFile))}...`);
|
|
174
|
+
}
|
|
175
|
+
const slnContents = slnLines.join(isCRLF ? '\r\n' : '\n');
|
|
176
|
+
fs_1.default.writeFileSync(slnFile, slnContents, {
|
|
177
|
+
encoding: 'utf8',
|
|
178
|
+
flag: 'w',
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
if (verbose) {
|
|
184
|
+
console.log(`No changes to ${chalk_1.default.bold(path_1.default.basename(slnFile))}.`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return contentsChanged;
|
|
188
|
+
}
|
|
189
|
+
exports.addProjectToSolution = addProjectToSolution;
|
|
190
|
+
//# sourceMappingURL=vstools.js.map
|