@react-native-windows/cli 0.73.2 → 0.74.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.d.ts +87 -87
- package/lib-commonjs/commands/autolinkWindows/autolinkWindows.js +654 -654
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.d.ts +14 -14
- package/lib-commonjs/commands/autolinkWindows/autolinkWindowsOptions.js +32 -32
- package/lib-commonjs/commands/codegenWindows/codegenWindows.d.ts +27 -27
- package/lib-commonjs/commands/codegenWindows/codegenWindows.js +205 -205
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.d.ts +12 -12
- package/lib-commonjs/commands/codegenWindows/codegenWindowsOptions.js +22 -22
- package/lib-commonjs/commands/config/configUtils.d.ts +123 -123
- package/lib-commonjs/commands/config/configUtils.js +380 -380
- package/lib-commonjs/commands/config/dependencyConfig.d.ts +37 -37
- package/lib-commonjs/commands/config/dependencyConfig.js +227 -227
- package/lib-commonjs/commands/config/projectConfig.d.ts +27 -27
- package/lib-commonjs/commands/config/projectConfig.js +180 -180
- package/lib-commonjs/commands/healthCheck/healthCheckList.d.ts +6 -6
- package/lib-commonjs/commands/healthCheck/healthCheckList.js +20 -20
- package/lib-commonjs/commands/healthCheck/healthCheckList.js.map +1 -1
- package/lib-commonjs/commands/healthCheck/healthChecks.d.ts +7 -7
- package/lib-commonjs/commands/healthCheck/healthChecks.js +123 -123
- package/lib-commonjs/commands/initWindows/initWindows.d.ts +46 -46
- package/lib-commonjs/commands/initWindows/initWindows.js +243 -243
- package/lib-commonjs/commands/initWindows/initWindowsOptions.d.ts +15 -15
- package/lib-commonjs/commands/initWindows/initWindowsOptions.js +37 -37
- package/lib-commonjs/commands/runWindows/runWindows.d.ts +10 -10
- package/lib-commonjs/commands/runWindows/runWindows.js +321 -321
- package/lib-commonjs/commands/runWindows/runWindowsOptions.d.ts +56 -56
- package/lib-commonjs/commands/runWindows/runWindowsOptions.js +132 -132
- package/lib-commonjs/e2etest/autolink.test.d.ts +6 -6
- package/lib-commonjs/e2etest/autolink.test.js +366 -366
- package/lib-commonjs/e2etest/dependencyConfig.test.d.ts +6 -6
- package/lib-commonjs/e2etest/dependencyConfig.test.js +129 -129
- package/lib-commonjs/e2etest/healthChecks.test.d.ts +6 -6
- package/lib-commonjs/e2etest/healthChecks.test.js +30 -30
- package/lib-commonjs/e2etest/initWindows.test.d.ts +6 -6
- package/lib-commonjs/e2etest/initWindows.test.js +42 -42
- package/lib-commonjs/e2etest/projectConfig.test.d.ts +6 -6
- package/lib-commonjs/e2etest/projectConfig.test.js +110 -110
- package/lib-commonjs/e2etest/projectConfig.utils.d.ts +8 -8
- package/lib-commonjs/e2etest/projectConfig.utils.js +76 -76
- package/lib-commonjs/e2etest/runWindows.test.d.ts +6 -6
- package/lib-commonjs/e2etest/runWindows.test.js +60 -60
- 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 -39
- package/lib-commonjs/generator-common/index.js +242 -242
- package/lib-commonjs/generator-windows/index.d.ts +10 -10
- package/lib-commonjs/generator-windows/index.js +316 -316
- package/lib-commonjs/index.d.ts +50 -50
- package/lib-commonjs/index.js +77 -77
- package/lib-commonjs/utils/build.d.ts +12 -12
- package/lib-commonjs/utils/build.js +84 -84
- package/lib-commonjs/utils/checkRequirements.d.ts +6 -6
- package/lib-commonjs/utils/checkRequirements.js +69 -69
- package/lib-commonjs/utils/commandWithProgress.d.ts +21 -21
- package/lib-commonjs/utils/commandWithProgress.js +149 -149
- package/lib-commonjs/utils/deploy.d.ts +12 -12
- package/lib-commonjs/utils/deploy.js +353 -353
- package/lib-commonjs/utils/info.d.ts +6 -6
- package/lib-commonjs/utils/info.js +28 -28
- package/lib-commonjs/utils/msbuildtools.d.ts +28 -28
- package/lib-commonjs/utils/msbuildtools.js +273 -273
- package/lib-commonjs/utils/msbuildtools.js.map +1 -1
- package/lib-commonjs/utils/pathHelpers.d.ts +9 -9
- package/lib-commonjs/utils/pathHelpers.js +36 -36
- package/lib-commonjs/utils/telemetryHelpers.d.ts +29 -29
- package/lib-commonjs/utils/telemetryHelpers.js +120 -120
- package/lib-commonjs/utils/version.d.ts +19 -19
- package/lib-commonjs/utils/version.js +109 -109
- package/lib-commonjs/utils/vsInstalls.d.ts +34 -34
- package/lib-commonjs/utils/vsInstalls.js +99 -99
- package/lib-commonjs/utils/vstools.d.ts +16 -16
- package/lib-commonjs/utils/vstools.js +189 -189
- package/lib-commonjs/utils/winappdeploytool.d.ts +24 -24
- package/lib-commonjs/utils/winappdeploytool.js +108 -108
- package/package.json +16 -16
|
@@ -1,190 +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;
|
|
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
190
|
//# sourceMappingURL=vstools.js.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
* @format
|
|
5
|
-
*/
|
|
6
|
-
declare class DeviceInfo {
|
|
7
|
-
readonly name: string;
|
|
8
|
-
readonly guid: string;
|
|
9
|
-
readonly ip: string;
|
|
10
|
-
private readonly index;
|
|
11
|
-
private readonly type;
|
|
12
|
-
constructor(name: string, guid: string, ip: string, index: number, type: string);
|
|
13
|
-
toString(): string;
|
|
14
|
-
}
|
|
15
|
-
export default class WinAppDeployTool {
|
|
16
|
-
private readonly path;
|
|
17
|
-
constructor();
|
|
18
|
-
get isAvailable(): boolean;
|
|
19
|
-
findDevice(target: string): DeviceInfo;
|
|
20
|
-
enumerateDevices(): DeviceInfo[];
|
|
21
|
-
installAppPackage(pathToAppxPackage: string, targetDevice: DeviceInfo, shouldLaunch: boolean, shouldUpdate: boolean, pin: boolean, verbose?: boolean): Promise<void>;
|
|
22
|
-
uninstallAppPackage(appName: string, targetDevice: DeviceInfo, verbose: boolean): Promise<void>;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
* @format
|
|
5
|
+
*/
|
|
6
|
+
declare class DeviceInfo {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly guid: string;
|
|
9
|
+
readonly ip: string;
|
|
10
|
+
private readonly index;
|
|
11
|
+
private readonly type;
|
|
12
|
+
constructor(name: string, guid: string, ip: string, index: number, type: string);
|
|
13
|
+
toString(): string;
|
|
14
|
+
}
|
|
15
|
+
export default class WinAppDeployTool {
|
|
16
|
+
private readonly path;
|
|
17
|
+
constructor();
|
|
18
|
+
get isAvailable(): boolean;
|
|
19
|
+
findDevice(target: string): DeviceInfo;
|
|
20
|
+
enumerateDevices(): DeviceInfo[];
|
|
21
|
+
installAppPackage(pathToAppxPackage: string, targetDevice: DeviceInfo, shouldLaunch: boolean, shouldUpdate: boolean, pin: boolean, verbose?: boolean): Promise<void>;
|
|
22
|
+
uninstallAppPackage(appName: string, targetDevice: DeviceInfo, verbose: boolean): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -1,109 +1,109 @@
|
|
|
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
|
-
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
12
|
-
const path_1 = __importDefault(require("path"));
|
|
13
|
-
const child_process_1 = require("child_process");
|
|
14
|
-
const commandWithProgress_1 = require("./commandWithProgress");
|
|
15
|
-
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
16
|
-
function sortDevices(l, r) {
|
|
17
|
-
return l.toString().length - r.toString().length;
|
|
18
|
-
}
|
|
19
|
-
class DeviceInfo {
|
|
20
|
-
constructor(name, guid, ip, index, type) {
|
|
21
|
-
this.name = name;
|
|
22
|
-
this.guid = guid;
|
|
23
|
-
this.ip = ip;
|
|
24
|
-
this.index = index;
|
|
25
|
-
this.type = type;
|
|
26
|
-
}
|
|
27
|
-
toString() {
|
|
28
|
-
return `${this.index}. ${this.name} (${this.type})`;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
class WinAppDeployTool {
|
|
32
|
-
constructor() {
|
|
33
|
-
const programFilesPath = process.env['ProgramFiles(x86)'] || process.env.ProgramFiles;
|
|
34
|
-
this.path = path_1.default.join(programFilesPath, 'Windows Kits', '10', 'bin', 'x86', 'WinAppDeployCmd.exe');
|
|
35
|
-
}
|
|
36
|
-
get isAvailable() {
|
|
37
|
-
return fs_1.default.existsSync(this.path);
|
|
38
|
-
}
|
|
39
|
-
findDevice(target) {
|
|
40
|
-
const devices = this.enumerateDevices();
|
|
41
|
-
if (devices.length === 0) {
|
|
42
|
-
throw new telemetry_1.CodedError('NoDevice', 'No devices found');
|
|
43
|
-
}
|
|
44
|
-
if (target === 'emulator') {
|
|
45
|
-
const sortedList = devices.sort(sortDevices);
|
|
46
|
-
for (const sortedItem of sortedList) {
|
|
47
|
-
if (sortedItem.toString().includes(target)) {
|
|
48
|
-
return sortedItem;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (target === 'device') {
|
|
53
|
-
return devices[0];
|
|
54
|
-
}
|
|
55
|
-
const candidateList = devices.filter(device => device.guid === target);
|
|
56
|
-
if (candidateList.length > 0) {
|
|
57
|
-
return candidateList[0];
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
throw new telemetry_1.CodedError('NoDevice', 'No devices found');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
enumerateDevices() {
|
|
64
|
-
// 127.0.0.1 00000015-b21e-0da9-0000-000000000000 Lumia 1520 (RM-940)\r
|
|
65
|
-
// maps to
|
|
66
|
-
// [(line), '127.0.0.1', '00000015-b21e-0da9-0000-000000000000', 'Lumia 1520 (RM-940)']
|
|
67
|
-
// The expansion is: IP address, spaces, GUID, spaces, text name
|
|
68
|
-
const LINE_TEST = /^([\d\.]+?)\s+([\da-fA-F\-]+?)\s+(.+)$/m; // eslint-disable-line no-useless-escape
|
|
69
|
-
const result = (0, child_process_1.execSync)(`"${this.path}" devices`).toString();
|
|
70
|
-
const lines = result.split('\r\n');
|
|
71
|
-
const matchedLines = lines.filter(line => LINE_TEST.test(line));
|
|
72
|
-
const devices = matchedLines.map((line, arrayIndex) => {
|
|
73
|
-
const match = line.match(LINE_TEST);
|
|
74
|
-
if (!match) {
|
|
75
|
-
throw new telemetry_1.CodedError('InvalidDevicesOutput', 'Unexpected format of "devices" output');
|
|
76
|
-
}
|
|
77
|
-
const ip = match[1];
|
|
78
|
-
const guid = match[2];
|
|
79
|
-
const name = match[3];
|
|
80
|
-
const type = 'device';
|
|
81
|
-
const deviceInfo = new DeviceInfo(name, guid, ip, arrayIndex, type);
|
|
82
|
-
return deviceInfo;
|
|
83
|
-
});
|
|
84
|
-
return devices;
|
|
85
|
-
}
|
|
86
|
-
async installAppPackage(pathToAppxPackage, targetDevice, shouldLaunch, shouldUpdate, pin, verbose = false) {
|
|
87
|
-
const text = `Installing app to ${targetDevice.name}`;
|
|
88
|
-
if (shouldLaunch) {
|
|
89
|
-
(0, commandWithProgress_1.newWarn)('Cannot launch app with current version of Windows 10 SDK tools. You will have to launch the app after installation is completed.');
|
|
90
|
-
}
|
|
91
|
-
const args = [
|
|
92
|
-
shouldUpdate ? 'update' : 'install',
|
|
93
|
-
'-file',
|
|
94
|
-
pathToAppxPackage,
|
|
95
|
-
'-ip',
|
|
96
|
-
targetDevice.ip,
|
|
97
|
-
];
|
|
98
|
-
if (pin) {
|
|
99
|
-
args.push('-pin', pin.toString());
|
|
100
|
-
}
|
|
101
|
-
await (0, commandWithProgress_1.commandWithProgress)((0, commandWithProgress_1.newSpinner)(text), text, this.path, args, verbose, 'InstallAppToDeviceFailure');
|
|
102
|
-
}
|
|
103
|
-
async uninstallAppPackage(appName, targetDevice, verbose) {
|
|
104
|
-
const text = `Uninstalling app from ${targetDevice.name}`;
|
|
105
|
-
await (0, commandWithProgress_1.commandWithProgress)((0, commandWithProgress_1.newSpinner)(text), text, this.path, `uninstall -package ${appName} -ip {$targetDevice.ip}`.split(' '), verbose, 'UninstallAppOnDeviceFailure');
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
exports.default = WinAppDeployTool;
|
|
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
|
+
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
12
|
+
const path_1 = __importDefault(require("path"));
|
|
13
|
+
const child_process_1 = require("child_process");
|
|
14
|
+
const commandWithProgress_1 = require("./commandWithProgress");
|
|
15
|
+
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
16
|
+
function sortDevices(l, r) {
|
|
17
|
+
return l.toString().length - r.toString().length;
|
|
18
|
+
}
|
|
19
|
+
class DeviceInfo {
|
|
20
|
+
constructor(name, guid, ip, index, type) {
|
|
21
|
+
this.name = name;
|
|
22
|
+
this.guid = guid;
|
|
23
|
+
this.ip = ip;
|
|
24
|
+
this.index = index;
|
|
25
|
+
this.type = type;
|
|
26
|
+
}
|
|
27
|
+
toString() {
|
|
28
|
+
return `${this.index}. ${this.name} (${this.type})`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
class WinAppDeployTool {
|
|
32
|
+
constructor() {
|
|
33
|
+
const programFilesPath = process.env['ProgramFiles(x86)'] || process.env.ProgramFiles;
|
|
34
|
+
this.path = path_1.default.join(programFilesPath, 'Windows Kits', '10', 'bin', 'x86', 'WinAppDeployCmd.exe');
|
|
35
|
+
}
|
|
36
|
+
get isAvailable() {
|
|
37
|
+
return fs_1.default.existsSync(this.path);
|
|
38
|
+
}
|
|
39
|
+
findDevice(target) {
|
|
40
|
+
const devices = this.enumerateDevices();
|
|
41
|
+
if (devices.length === 0) {
|
|
42
|
+
throw new telemetry_1.CodedError('NoDevice', 'No devices found');
|
|
43
|
+
}
|
|
44
|
+
if (target === 'emulator') {
|
|
45
|
+
const sortedList = devices.sort(sortDevices);
|
|
46
|
+
for (const sortedItem of sortedList) {
|
|
47
|
+
if (sortedItem.toString().includes(target)) {
|
|
48
|
+
return sortedItem;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (target === 'device') {
|
|
53
|
+
return devices[0];
|
|
54
|
+
}
|
|
55
|
+
const candidateList = devices.filter(device => device.guid === target);
|
|
56
|
+
if (candidateList.length > 0) {
|
|
57
|
+
return candidateList[0];
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
throw new telemetry_1.CodedError('NoDevice', 'No devices found');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
enumerateDevices() {
|
|
64
|
+
// 127.0.0.1 00000015-b21e-0da9-0000-000000000000 Lumia 1520 (RM-940)\r
|
|
65
|
+
// maps to
|
|
66
|
+
// [(line), '127.0.0.1', '00000015-b21e-0da9-0000-000000000000', 'Lumia 1520 (RM-940)']
|
|
67
|
+
// The expansion is: IP address, spaces, GUID, spaces, text name
|
|
68
|
+
const LINE_TEST = /^([\d\.]+?)\s+([\da-fA-F\-]+?)\s+(.+)$/m; // eslint-disable-line no-useless-escape
|
|
69
|
+
const result = (0, child_process_1.execSync)(`"${this.path}" devices`).toString();
|
|
70
|
+
const lines = result.split('\r\n');
|
|
71
|
+
const matchedLines = lines.filter(line => LINE_TEST.test(line));
|
|
72
|
+
const devices = matchedLines.map((line, arrayIndex) => {
|
|
73
|
+
const match = line.match(LINE_TEST);
|
|
74
|
+
if (!match) {
|
|
75
|
+
throw new telemetry_1.CodedError('InvalidDevicesOutput', 'Unexpected format of "devices" output');
|
|
76
|
+
}
|
|
77
|
+
const ip = match[1];
|
|
78
|
+
const guid = match[2];
|
|
79
|
+
const name = match[3];
|
|
80
|
+
const type = 'device';
|
|
81
|
+
const deviceInfo = new DeviceInfo(name, guid, ip, arrayIndex, type);
|
|
82
|
+
return deviceInfo;
|
|
83
|
+
});
|
|
84
|
+
return devices;
|
|
85
|
+
}
|
|
86
|
+
async installAppPackage(pathToAppxPackage, targetDevice, shouldLaunch, shouldUpdate, pin, verbose = false) {
|
|
87
|
+
const text = `Installing app to ${targetDevice.name}`;
|
|
88
|
+
if (shouldLaunch) {
|
|
89
|
+
(0, commandWithProgress_1.newWarn)('Cannot launch app with current version of Windows 10 SDK tools. You will have to launch the app after installation is completed.');
|
|
90
|
+
}
|
|
91
|
+
const args = [
|
|
92
|
+
shouldUpdate ? 'update' : 'install',
|
|
93
|
+
'-file',
|
|
94
|
+
pathToAppxPackage,
|
|
95
|
+
'-ip',
|
|
96
|
+
targetDevice.ip,
|
|
97
|
+
];
|
|
98
|
+
if (pin) {
|
|
99
|
+
args.push('-pin', pin.toString());
|
|
100
|
+
}
|
|
101
|
+
await (0, commandWithProgress_1.commandWithProgress)((0, commandWithProgress_1.newSpinner)(text), text, this.path, args, verbose, 'InstallAppToDeviceFailure');
|
|
102
|
+
}
|
|
103
|
+
async uninstallAppPackage(appName, targetDevice, verbose) {
|
|
104
|
+
const text = `Uninstalling app from ${targetDevice.name}`;
|
|
105
|
+
await (0, commandWithProgress_1.commandWithProgress)((0, commandWithProgress_1.newSpinner)(text), text, this.path, `uninstall -package ${appName} -ip {$targetDevice.ip}`.split(' '), verbose, 'UninstallAppOnDeviceFailure');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.default = WinAppDeployTool;
|
|
109
109
|
//# sourceMappingURL=winappdeploytool.js.map
|