@react-native-windows/cli 0.73.2 → 0.74.0-preview.2
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,354 +1,354 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Microsoft Corporation.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
-
if (mod && mod.__esModule) return mod;
|
|
25
|
-
var result = {};
|
|
26
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
-
__setModuleDefault(result, mod);
|
|
28
|
-
return result;
|
|
29
|
-
};
|
|
30
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
-
};
|
|
33
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.startServerInNewWindow = exports.deployToDesktop = exports.deployToDevice = exports.getBuildConfiguration = void 0;
|
|
35
|
-
const child_process_1 = require("child_process");
|
|
36
|
-
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
37
|
-
const http_1 = __importDefault(require("http"));
|
|
38
|
-
const path_1 = __importDefault(require("path"));
|
|
39
|
-
const glob_1 = __importDefault(require("glob"));
|
|
40
|
-
const xml_parser_1 = __importDefault(require("xml-parser"));
|
|
41
|
-
const winappdeploytool_1 = __importDefault(require("./winappdeploytool"));
|
|
42
|
-
const commandWithProgress_1 = require("./commandWithProgress");
|
|
43
|
-
const build = __importStar(require("./build"));
|
|
44
|
-
const configUtils = __importStar(require("../commands/config/configUtils"));
|
|
45
|
-
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
46
|
-
const version_1 = __importDefault(require("./version"));
|
|
47
|
-
function pushd(pathArg) {
|
|
48
|
-
const cwd = process.cwd();
|
|
49
|
-
process.chdir(pathArg);
|
|
50
|
-
return () => process.chdir(cwd);
|
|
51
|
-
}
|
|
52
|
-
function getBuildConfiguration(options) {
|
|
53
|
-
return options.release
|
|
54
|
-
? options.bundle
|
|
55
|
-
? 'ReleaseBundle'
|
|
56
|
-
: 'Release'
|
|
57
|
-
: options.bundle
|
|
58
|
-
? 'DebugBundle'
|
|
59
|
-
: 'Debug';
|
|
60
|
-
}
|
|
61
|
-
exports.getBuildConfiguration = getBuildConfiguration;
|
|
62
|
-
function shouldDeployByPackage(options, config) {
|
|
63
|
-
if (options.deployFromLayout) {
|
|
64
|
-
// Force deploy by layout
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
let hasAppxSigningEnabled = null;
|
|
68
|
-
let hasPackageCertificateKeyFile = null;
|
|
69
|
-
// TODO: These two properties should really be determined by
|
|
70
|
-
// getting the actual values msbuild used during the build,
|
|
71
|
-
// but for now we'll try to get them manually
|
|
72
|
-
// Check passed in msbuild property overrides
|
|
73
|
-
if (options.msbuildprops) {
|
|
74
|
-
const msbuildprops = build.parseMsBuildProps(options);
|
|
75
|
-
if ('AppxSigningEnabled' in msbuildprops) {
|
|
76
|
-
hasAppxSigningEnabled =
|
|
77
|
-
msbuildprops.AppxSigningEnabled.toLowerCase() === 'true';
|
|
78
|
-
}
|
|
79
|
-
if ('PackageCertificateKeyFile' in msbuildprops) {
|
|
80
|
-
hasPackageCertificateKeyFile = true;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
// If at least one override wasn't set, we need to parse the project file
|
|
84
|
-
if (hasAppxSigningEnabled === null || hasPackageCertificateKeyFile === null) {
|
|
85
|
-
const projectFile = build.getAppProjectFile(options, config);
|
|
86
|
-
if (projectFile) {
|
|
87
|
-
const projectContents = configUtils.readProjectFile(projectFile);
|
|
88
|
-
// Find AppxSigningEnabled
|
|
89
|
-
if (hasAppxSigningEnabled === null) {
|
|
90
|
-
const appxSigningEnabled = configUtils.tryFindPropertyValue(projectContents, 'AppxSigningEnabled');
|
|
91
|
-
if (appxSigningEnabled !== null) {
|
|
92
|
-
hasAppxSigningEnabled = appxSigningEnabled.toLowerCase() === 'true';
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// Find PackageCertificateKeyFile
|
|
96
|
-
if (hasPackageCertificateKeyFile === null) {
|
|
97
|
-
const packageCertificateKeyFile = configUtils.tryFindPropertyValue(projectContents, 'PackageCertificateKeyFile');
|
|
98
|
-
if (packageCertificateKeyFile !== null) {
|
|
99
|
-
hasPackageCertificateKeyFile = true;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return (hasAppxSigningEnabled === true && hasPackageCertificateKeyFile === true);
|
|
105
|
-
}
|
|
106
|
-
function shouldLaunchApp(options) {
|
|
107
|
-
return options.launch === true;
|
|
108
|
-
}
|
|
109
|
-
function getAppPackage(options, projectName) {
|
|
110
|
-
const configuration = getBuildConfiguration(options);
|
|
111
|
-
const packageFolder = options.arch === 'x86'
|
|
112
|
-
? `{*_x86_${configuration}_*,*_Win32_${configuration}_*}`
|
|
113
|
-
: `*_${options.arch}_${configuration}_*`;
|
|
114
|
-
const appPackageGlob = `${options.root}/windows/{*/AppPackages,AppPackages/*}/${packageFolder}`;
|
|
115
|
-
const appPackageCandidates = glob_1.default.sync(appPackageGlob);
|
|
116
|
-
let appPackage;
|
|
117
|
-
if (appPackageCandidates.length === 1 || !projectName) {
|
|
118
|
-
appPackage = appPackageCandidates[0];
|
|
119
|
-
}
|
|
120
|
-
else if (appPackageCandidates.length > 1) {
|
|
121
|
-
const filteredAppPackageCandidates = appPackageCandidates.filter(x => x.includes(projectName));
|
|
122
|
-
if (filteredAppPackageCandidates.length >= 1) {
|
|
123
|
-
appPackage = filteredAppPackageCandidates[0];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (!appPackage && options.release) {
|
|
127
|
-
// in the latest vs, Release is removed
|
|
128
|
-
(0, commandWithProgress_1.newWarn)('No package found in *_Release_* folder, removing the _Release_ prefix and checking again');
|
|
129
|
-
const rootGlob = `${options.root}/windows/{*/AppPackages,AppPackages/*}`;
|
|
130
|
-
const newGlob = `${rootGlob}/*_${options.arch === 'x86' ? '{Win32,x86}' : options.arch}_Test`;
|
|
131
|
-
const result = glob_1.default.sync(newGlob);
|
|
132
|
-
if (result.length > 1 && projectName) {
|
|
133
|
-
const newFilteredGlobs = result.filter(x => x.includes(projectName));
|
|
134
|
-
if (newFilteredGlobs.length >= 1) {
|
|
135
|
-
(0, commandWithProgress_1.newWarn)(`More than one app package found: ${result}`);
|
|
136
|
-
}
|
|
137
|
-
appPackage = newFilteredGlobs[0];
|
|
138
|
-
}
|
|
139
|
-
else if (result.length === 1) {
|
|
140
|
-
// we're good
|
|
141
|
-
appPackage = result[0];
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
if (!appPackage) {
|
|
145
|
-
throw new telemetry_1.CodedError('NoAppPackage', `Unable to find app package using search path: "${appPackageGlob}"`);
|
|
146
|
-
}
|
|
147
|
-
return appPackage;
|
|
148
|
-
}
|
|
149
|
-
function getWindowsStoreAppUtils(options) {
|
|
150
|
-
const popd = pushd(options.root);
|
|
151
|
-
const windowsStoreAppUtilsPath = path_1.default.resolve(__dirname, '..', '..', 'src', 'powershell', 'WindowsStoreAppUtils.ps1');
|
|
152
|
-
(0, child_process_1.execSync)(`${commandWithProgress_1.powershell} -NoProfile Unblock-File '${windowsStoreAppUtilsPath}'`);
|
|
153
|
-
popd();
|
|
154
|
-
return windowsStoreAppUtilsPath;
|
|
155
|
-
}
|
|
156
|
-
function getAppxManifestPath(options, projectName) {
|
|
157
|
-
const configuration = getBuildConfiguration(options);
|
|
158
|
-
// C++ x86 manifest would go under windows/Debug whereas x64 goes under windows/x64/Debug
|
|
159
|
-
// If we've built both, this causes us to end up with two matches, so we have to carefully select the right folder
|
|
160
|
-
let archFolder;
|
|
161
|
-
if (options.arch !== 'x86') {
|
|
162
|
-
archFolder = `${options.arch}/${configuration}`;
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
archFolder = `${configuration}`;
|
|
166
|
-
}
|
|
167
|
-
const appxManifestGlob = `windows/{*/bin/${options.arch}/${configuration},${archFolder}/*,target/${options.arch}/${configuration}}/AppxManifest.xml`;
|
|
168
|
-
const globs = glob_1.default.sync(path_1.default.join(options.root, appxManifestGlob));
|
|
169
|
-
let appxPath;
|
|
170
|
-
if (globs.length === 1 || !projectName) {
|
|
171
|
-
appxPath = globs[0];
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
const filteredGlobs = globs.filter(x => x.includes(projectName));
|
|
175
|
-
appxPath = filteredGlobs[0];
|
|
176
|
-
if (filteredGlobs.length > 1) {
|
|
177
|
-
(0, commandWithProgress_1.newWarn)(`More than one appxmanifest for ${projectName}: ${filteredGlobs.join(',')}`);
|
|
178
|
-
(0, commandWithProgress_1.newWarn)(`Choosing ${appxPath}`);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (!appxPath) {
|
|
182
|
-
throw new telemetry_1.CodedError('NoAppxManifest', `Unable to find AppxManifest from "${options.root}", using search path: "${appxManifestGlob}" `);
|
|
183
|
-
}
|
|
184
|
-
return appxPath;
|
|
185
|
-
}
|
|
186
|
-
function getAppxRecipePath(options, projectName) {
|
|
187
|
-
const appxManifestPath = path_1.default.dirname(getAppxManifestPath(options, projectName));
|
|
188
|
-
const appxRecipeGlob = `*.build.appxrecipe`;
|
|
189
|
-
const globs = glob_1.default.sync(path_1.default.join(appxManifestPath, appxRecipeGlob));
|
|
190
|
-
let appxRecipePath;
|
|
191
|
-
if (globs.length === 1 || !projectName) {
|
|
192
|
-
appxRecipePath = globs[0];
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
const filteredGlobs = globs.filter(x => x.includes(projectName));
|
|
196
|
-
appxRecipePath = filteredGlobs[0];
|
|
197
|
-
if (filteredGlobs.length > 1) {
|
|
198
|
-
(0, commandWithProgress_1.newWarn)(`More than one appxrecipe for ${projectName}: ${filteredGlobs.join(',')}`);
|
|
199
|
-
(0, commandWithProgress_1.newWarn)(`Choosing ${appxRecipePath}`);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (!appxRecipePath) {
|
|
203
|
-
throw new telemetry_1.CodedError('DeployRecipeFailure', `Unable to find AppxRecipe from "${appxManifestPath}", using search path: "${appxRecipeGlob}" `);
|
|
204
|
-
}
|
|
205
|
-
return appxRecipePath;
|
|
206
|
-
}
|
|
207
|
-
function parseAppxManifest(appxManifestPath) {
|
|
208
|
-
return (0, xml_parser_1.default)(fs_1.default.readFileSync(appxManifestPath, 'utf8'));
|
|
209
|
-
}
|
|
210
|
-
function getAppxManifest(options, projectName) {
|
|
211
|
-
return parseAppxManifest(getAppxManifestPath(options, projectName));
|
|
212
|
-
}
|
|
213
|
-
function handleResponseError(e) {
|
|
214
|
-
if (e.message.indexOf('Error code -2146233088')) {
|
|
215
|
-
throw new telemetry_1.CodedError('NoDevice', `No Windows Mobile device was detected: ${e.message}`);
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
throw new telemetry_1.CodedError('AppDidNotDeploy', `Unexpected error deploying app: ${e.message}`);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
// Errors: 0x80073d10 - bad architecture
|
|
222
|
-
async function deployToDevice(options, verbose, config) {
|
|
223
|
-
const windowsConfig = config.project.windows;
|
|
224
|
-
const projectName = windowsConfig && windowsConfig.project && windowsConfig.project.projectName
|
|
225
|
-
? windowsConfig.project.projectName
|
|
226
|
-
: path_1.default.parse(options.proj).name;
|
|
227
|
-
const appPackageFolder = getAppPackage(options);
|
|
228
|
-
const deployTarget = options.target
|
|
229
|
-
? options.target
|
|
230
|
-
: options.emulator
|
|
231
|
-
? 'emulator'
|
|
232
|
-
: 'device';
|
|
233
|
-
const deployTool = new winappdeploytool_1.default();
|
|
234
|
-
const appxManifest = getAppxManifest(options, projectName);
|
|
235
|
-
const shouldLaunch = shouldLaunchApp(options);
|
|
236
|
-
const identity = appxManifest.root.children.filter(x => {
|
|
237
|
-
return x.name === 'mp:PhoneIdentity';
|
|
238
|
-
})[0];
|
|
239
|
-
const appName = identity.attributes.PhoneProductId;
|
|
240
|
-
const device = deployTool.findDevice(deployTarget);
|
|
241
|
-
try {
|
|
242
|
-
await deployTool.uninstallAppPackage(appName, device, verbose);
|
|
243
|
-
}
|
|
244
|
-
catch (e) {
|
|
245
|
-
(0, commandWithProgress_1.newWarn)('Failed to uninstall app from ' + device.name);
|
|
246
|
-
}
|
|
247
|
-
const appxFile = glob_1.default.sync(path_1.default.join(appPackageFolder, '*.appx'))[0];
|
|
248
|
-
try {
|
|
249
|
-
await deployTool.installAppPackage(appxFile, device, shouldLaunch, false, verbose);
|
|
250
|
-
}
|
|
251
|
-
catch (e) {
|
|
252
|
-
if (e.message.includes('Error code 2148734208 for command')) {
|
|
253
|
-
await deployTool.installAppPackage(appxFile, device, shouldLaunch, true, verbose);
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
handleResponseError(e);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
exports.deployToDevice = deployToDevice;
|
|
261
|
-
async function deployToDesktop(options, verbose, config, buildTools) {
|
|
262
|
-
const windowsConfig = config.project.windows;
|
|
263
|
-
const slnFile = windowsConfig && windowsConfig.solutionFile && windowsConfig.sourceDir
|
|
264
|
-
? path_1.default.join(windowsConfig.sourceDir, windowsConfig.solutionFile)
|
|
265
|
-
: options.sln;
|
|
266
|
-
const projectName = windowsConfig && windowsConfig.project && windowsConfig.project.projectName
|
|
267
|
-
? windowsConfig.project.projectName
|
|
268
|
-
: path_1.default.parse(options.proj).name;
|
|
269
|
-
const windowsStoreAppUtils = getWindowsStoreAppUtils(options);
|
|
270
|
-
const appxManifestPath = getAppxManifestPath(options, projectName);
|
|
271
|
-
const appxManifest = parseAppxManifest(appxManifestPath);
|
|
272
|
-
const identity = appxManifest.root.children.filter(x => {
|
|
273
|
-
return x.name === 'Identity';
|
|
274
|
-
})[0];
|
|
275
|
-
const appName = identity.attributes.Name;
|
|
276
|
-
const vsVersion = version_1.default.fromString(buildTools.installationVersion);
|
|
277
|
-
const args = [];
|
|
278
|
-
if (options.remoteDebugging) {
|
|
279
|
-
args.push('--remote-debugging');
|
|
280
|
-
}
|
|
281
|
-
if (options.directDebugging) {
|
|
282
|
-
args.push('--direct-debugging', options.directDebugging.toString());
|
|
283
|
-
}
|
|
284
|
-
await (0, commandWithProgress_1.runPowerShellScriptFunction)('Enabling Developer Mode', windowsStoreAppUtils, 'EnableDevMode', verbose, 'EnableDevModeFailure');
|
|
285
|
-
const appPackageFolder = getAppPackage(options, projectName);
|
|
286
|
-
if (shouldDeployByPackage(options, config)) {
|
|
287
|
-
// Deploy by package
|
|
288
|
-
await (0, commandWithProgress_1.runPowerShellScriptFunction)('Removing old version of the app', windowsStoreAppUtils, `Uninstall-App ${appName}`, verbose, 'RemoveOldAppVersionFailure');
|
|
289
|
-
const script = glob_1.default.sync(path_1.default.join(appPackageFolder, 'Add-AppDevPackage.ps1'))[0];
|
|
290
|
-
await (0, commandWithProgress_1.runPowerShellScriptFunction)('Installing new version of the app', windowsStoreAppUtils, `Install-App "${script}" -Force`, verbose, 'InstallAppFailure');
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
// Deploy from layout
|
|
294
|
-
// If we have DeployAppRecipe.exe, use it (start in 16.8.4, earlier 16.8 versions have bugs)
|
|
295
|
-
const appxRecipe = getAppxRecipePath(options, projectName);
|
|
296
|
-
const ideFolder = `${buildTools.installationPath}\\Common7\\IDE`;
|
|
297
|
-
const deployAppxRecipeExePath = `${ideFolder}\\DeployAppRecipe.exe`;
|
|
298
|
-
if (vsVersion.gte(version_1.default.fromString('16.8.30906.45')) &&
|
|
299
|
-
fs_1.default.existsSync(deployAppxRecipeExePath)) {
|
|
300
|
-
await (0, commandWithProgress_1.commandWithProgress)((0, commandWithProgress_1.newSpinner)('Deploying'), `Deploying ${appxRecipe}`, deployAppxRecipeExePath, [appxRecipe], verbose, 'DeployRecipeFailure');
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
// Install the app package's dependencies before attempting to deploy.
|
|
304
|
-
await (0, commandWithProgress_1.runPowerShellScriptFunction)('Installing dependent framework packages', windowsStoreAppUtils, `Install-AppDependencies ${appxManifestPath} ${appPackageFolder} ${options.arch}`, verbose, 'InstallAppDependenciesFailure');
|
|
305
|
-
await build.buildSolution(buildTools, slnFile,
|
|
306
|
-
/* options.release ? 'Release' : */ 'Debug', options.arch, { DeployLayout: 'true' }, verbose, 'deploy', options.buildLogDirectory);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
const appFamilyName = (0, child_process_1.execSync)(`${commandWithProgress_1.powershell} -NoProfile -c $(Get-AppxPackage -Name ${appName}).PackageFamilyName`)
|
|
310
|
-
.toString()
|
|
311
|
-
.trim();
|
|
312
|
-
if (!appFamilyName) {
|
|
313
|
-
throw new telemetry_1.CodedError('AppDidNotDeploy', 'Fail to check the installed app, maybe developer mode is off on Windows');
|
|
314
|
-
}
|
|
315
|
-
const loopbackText = 'Verifying loopbackExempt';
|
|
316
|
-
const loopbackSpinner = (0, commandWithProgress_1.newSpinner)(loopbackText);
|
|
317
|
-
await (0, commandWithProgress_1.commandWithProgress)(loopbackSpinner, loopbackText, 'CheckNetIsolation', `LoopbackExempt -a -n=${appFamilyName}`.split(' '), verbose, 'CheckNetIsolationFailure');
|
|
318
|
-
if (shouldLaunchApp(options)) {
|
|
319
|
-
await (0, commandWithProgress_1.runPowerShellScriptFunction)('Starting the app', windowsStoreAppUtils, `Start-Locally ${appName} ${args}`, verbose, 'AppStartupFailure');
|
|
320
|
-
}
|
|
321
|
-
else {
|
|
322
|
-
(0, commandWithProgress_1.newInfo)('Skip the step to start the app');
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
exports.deployToDesktop = deployToDesktop;
|
|
326
|
-
function startServerInNewWindow(options, verbose) {
|
|
327
|
-
return new Promise(resolve => {
|
|
328
|
-
http_1.default
|
|
329
|
-
.get('http://localhost:8081/status', res => {
|
|
330
|
-
if (res.statusCode === 200) {
|
|
331
|
-
(0, commandWithProgress_1.newSuccess)('React-Native Server already started');
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
(0, commandWithProgress_1.newError)('React-Native Server not responding');
|
|
335
|
-
}
|
|
336
|
-
resolve();
|
|
337
|
-
})
|
|
338
|
-
.on('error', () => {
|
|
339
|
-
launchServer(options, verbose);
|
|
340
|
-
resolve();
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
exports.startServerInNewWindow = startServerInNewWindow;
|
|
345
|
-
function launchServer(options, verbose) {
|
|
346
|
-
(0, commandWithProgress_1.newSuccess)('Starting the React-Native Server');
|
|
347
|
-
const opts = {
|
|
348
|
-
cwd: options.root,
|
|
349
|
-
detached: true,
|
|
350
|
-
stdio: verbose ? 'inherit' : 'ignore',
|
|
351
|
-
};
|
|
352
|
-
(0, child_process_1.spawn)('cmd.exe', ['/C', 'start npx react-native start'], opts);
|
|
353
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
+
if (mod && mod.__esModule) return mod;
|
|
25
|
+
var result = {};
|
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
+
__setModuleDefault(result, mod);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.startServerInNewWindow = exports.deployToDesktop = exports.deployToDevice = exports.getBuildConfiguration = void 0;
|
|
35
|
+
const child_process_1 = require("child_process");
|
|
36
|
+
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
37
|
+
const http_1 = __importDefault(require("http"));
|
|
38
|
+
const path_1 = __importDefault(require("path"));
|
|
39
|
+
const glob_1 = __importDefault(require("glob"));
|
|
40
|
+
const xml_parser_1 = __importDefault(require("xml-parser"));
|
|
41
|
+
const winappdeploytool_1 = __importDefault(require("./winappdeploytool"));
|
|
42
|
+
const commandWithProgress_1 = require("./commandWithProgress");
|
|
43
|
+
const build = __importStar(require("./build"));
|
|
44
|
+
const configUtils = __importStar(require("../commands/config/configUtils"));
|
|
45
|
+
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
46
|
+
const version_1 = __importDefault(require("./version"));
|
|
47
|
+
function pushd(pathArg) {
|
|
48
|
+
const cwd = process.cwd();
|
|
49
|
+
process.chdir(pathArg);
|
|
50
|
+
return () => process.chdir(cwd);
|
|
51
|
+
}
|
|
52
|
+
function getBuildConfiguration(options) {
|
|
53
|
+
return options.release
|
|
54
|
+
? options.bundle
|
|
55
|
+
? 'ReleaseBundle'
|
|
56
|
+
: 'Release'
|
|
57
|
+
: options.bundle
|
|
58
|
+
? 'DebugBundle'
|
|
59
|
+
: 'Debug';
|
|
60
|
+
}
|
|
61
|
+
exports.getBuildConfiguration = getBuildConfiguration;
|
|
62
|
+
function shouldDeployByPackage(options, config) {
|
|
63
|
+
if (options.deployFromLayout) {
|
|
64
|
+
// Force deploy by layout
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
let hasAppxSigningEnabled = null;
|
|
68
|
+
let hasPackageCertificateKeyFile = null;
|
|
69
|
+
// TODO: These two properties should really be determined by
|
|
70
|
+
// getting the actual values msbuild used during the build,
|
|
71
|
+
// but for now we'll try to get them manually
|
|
72
|
+
// Check passed in msbuild property overrides
|
|
73
|
+
if (options.msbuildprops) {
|
|
74
|
+
const msbuildprops = build.parseMsBuildProps(options);
|
|
75
|
+
if ('AppxSigningEnabled' in msbuildprops) {
|
|
76
|
+
hasAppxSigningEnabled =
|
|
77
|
+
msbuildprops.AppxSigningEnabled.toLowerCase() === 'true';
|
|
78
|
+
}
|
|
79
|
+
if ('PackageCertificateKeyFile' in msbuildprops) {
|
|
80
|
+
hasPackageCertificateKeyFile = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// If at least one override wasn't set, we need to parse the project file
|
|
84
|
+
if (hasAppxSigningEnabled === null || hasPackageCertificateKeyFile === null) {
|
|
85
|
+
const projectFile = build.getAppProjectFile(options, config);
|
|
86
|
+
if (projectFile) {
|
|
87
|
+
const projectContents = configUtils.readProjectFile(projectFile);
|
|
88
|
+
// Find AppxSigningEnabled
|
|
89
|
+
if (hasAppxSigningEnabled === null) {
|
|
90
|
+
const appxSigningEnabled = configUtils.tryFindPropertyValue(projectContents, 'AppxSigningEnabled');
|
|
91
|
+
if (appxSigningEnabled !== null) {
|
|
92
|
+
hasAppxSigningEnabled = appxSigningEnabled.toLowerCase() === 'true';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Find PackageCertificateKeyFile
|
|
96
|
+
if (hasPackageCertificateKeyFile === null) {
|
|
97
|
+
const packageCertificateKeyFile = configUtils.tryFindPropertyValue(projectContents, 'PackageCertificateKeyFile');
|
|
98
|
+
if (packageCertificateKeyFile !== null) {
|
|
99
|
+
hasPackageCertificateKeyFile = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return (hasAppxSigningEnabled === true && hasPackageCertificateKeyFile === true);
|
|
105
|
+
}
|
|
106
|
+
function shouldLaunchApp(options) {
|
|
107
|
+
return options.launch === true;
|
|
108
|
+
}
|
|
109
|
+
function getAppPackage(options, projectName) {
|
|
110
|
+
const configuration = getBuildConfiguration(options);
|
|
111
|
+
const packageFolder = options.arch === 'x86'
|
|
112
|
+
? `{*_x86_${configuration}_*,*_Win32_${configuration}_*}`
|
|
113
|
+
: `*_${options.arch}_${configuration}_*`;
|
|
114
|
+
const appPackageGlob = `${options.root}/windows/{*/AppPackages,AppPackages/*}/${packageFolder}`;
|
|
115
|
+
const appPackageCandidates = glob_1.default.sync(appPackageGlob);
|
|
116
|
+
let appPackage;
|
|
117
|
+
if (appPackageCandidates.length === 1 || !projectName) {
|
|
118
|
+
appPackage = appPackageCandidates[0];
|
|
119
|
+
}
|
|
120
|
+
else if (appPackageCandidates.length > 1) {
|
|
121
|
+
const filteredAppPackageCandidates = appPackageCandidates.filter(x => x.includes(projectName));
|
|
122
|
+
if (filteredAppPackageCandidates.length >= 1) {
|
|
123
|
+
appPackage = filteredAppPackageCandidates[0];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (!appPackage && options.release) {
|
|
127
|
+
// in the latest vs, Release is removed
|
|
128
|
+
(0, commandWithProgress_1.newWarn)('No package found in *_Release_* folder, removing the _Release_ prefix and checking again');
|
|
129
|
+
const rootGlob = `${options.root}/windows/{*/AppPackages,AppPackages/*}`;
|
|
130
|
+
const newGlob = `${rootGlob}/*_${options.arch === 'x86' ? '{Win32,x86}' : options.arch}_Test`;
|
|
131
|
+
const result = glob_1.default.sync(newGlob);
|
|
132
|
+
if (result.length > 1 && projectName) {
|
|
133
|
+
const newFilteredGlobs = result.filter(x => x.includes(projectName));
|
|
134
|
+
if (newFilteredGlobs.length >= 1) {
|
|
135
|
+
(0, commandWithProgress_1.newWarn)(`More than one app package found: ${result}`);
|
|
136
|
+
}
|
|
137
|
+
appPackage = newFilteredGlobs[0];
|
|
138
|
+
}
|
|
139
|
+
else if (result.length === 1) {
|
|
140
|
+
// we're good
|
|
141
|
+
appPackage = result[0];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (!appPackage) {
|
|
145
|
+
throw new telemetry_1.CodedError('NoAppPackage', `Unable to find app package using search path: "${appPackageGlob}"`);
|
|
146
|
+
}
|
|
147
|
+
return appPackage;
|
|
148
|
+
}
|
|
149
|
+
function getWindowsStoreAppUtils(options) {
|
|
150
|
+
const popd = pushd(options.root);
|
|
151
|
+
const windowsStoreAppUtilsPath = path_1.default.resolve(__dirname, '..', '..', 'src', 'powershell', 'WindowsStoreAppUtils.ps1');
|
|
152
|
+
(0, child_process_1.execSync)(`${commandWithProgress_1.powershell} -NoProfile Unblock-File '${windowsStoreAppUtilsPath}'`);
|
|
153
|
+
popd();
|
|
154
|
+
return windowsStoreAppUtilsPath;
|
|
155
|
+
}
|
|
156
|
+
function getAppxManifestPath(options, projectName) {
|
|
157
|
+
const configuration = getBuildConfiguration(options);
|
|
158
|
+
// C++ x86 manifest would go under windows/Debug whereas x64 goes under windows/x64/Debug
|
|
159
|
+
// If we've built both, this causes us to end up with two matches, so we have to carefully select the right folder
|
|
160
|
+
let archFolder;
|
|
161
|
+
if (options.arch !== 'x86') {
|
|
162
|
+
archFolder = `${options.arch}/${configuration}`;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
archFolder = `${configuration}`;
|
|
166
|
+
}
|
|
167
|
+
const appxManifestGlob = `windows/{*/bin/${options.arch}/${configuration},${archFolder}/*,target/${options.arch}/${configuration}}/AppxManifest.xml`;
|
|
168
|
+
const globs = glob_1.default.sync(path_1.default.join(options.root, appxManifestGlob));
|
|
169
|
+
let appxPath;
|
|
170
|
+
if (globs.length === 1 || !projectName) {
|
|
171
|
+
appxPath = globs[0];
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const filteredGlobs = globs.filter(x => x.includes(projectName));
|
|
175
|
+
appxPath = filteredGlobs[0];
|
|
176
|
+
if (filteredGlobs.length > 1) {
|
|
177
|
+
(0, commandWithProgress_1.newWarn)(`More than one appxmanifest for ${projectName}: ${filteredGlobs.join(',')}`);
|
|
178
|
+
(0, commandWithProgress_1.newWarn)(`Choosing ${appxPath}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (!appxPath) {
|
|
182
|
+
throw new telemetry_1.CodedError('NoAppxManifest', `Unable to find AppxManifest from "${options.root}", using search path: "${appxManifestGlob}" `);
|
|
183
|
+
}
|
|
184
|
+
return appxPath;
|
|
185
|
+
}
|
|
186
|
+
function getAppxRecipePath(options, projectName) {
|
|
187
|
+
const appxManifestPath = path_1.default.dirname(getAppxManifestPath(options, projectName));
|
|
188
|
+
const appxRecipeGlob = `*.build.appxrecipe`;
|
|
189
|
+
const globs = glob_1.default.sync(path_1.default.join(appxManifestPath, appxRecipeGlob));
|
|
190
|
+
let appxRecipePath;
|
|
191
|
+
if (globs.length === 1 || !projectName) {
|
|
192
|
+
appxRecipePath = globs[0];
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
const filteredGlobs = globs.filter(x => x.includes(projectName));
|
|
196
|
+
appxRecipePath = filteredGlobs[0];
|
|
197
|
+
if (filteredGlobs.length > 1) {
|
|
198
|
+
(0, commandWithProgress_1.newWarn)(`More than one appxrecipe for ${projectName}: ${filteredGlobs.join(',')}`);
|
|
199
|
+
(0, commandWithProgress_1.newWarn)(`Choosing ${appxRecipePath}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (!appxRecipePath) {
|
|
203
|
+
throw new telemetry_1.CodedError('DeployRecipeFailure', `Unable to find AppxRecipe from "${appxManifestPath}", using search path: "${appxRecipeGlob}" `);
|
|
204
|
+
}
|
|
205
|
+
return appxRecipePath;
|
|
206
|
+
}
|
|
207
|
+
function parseAppxManifest(appxManifestPath) {
|
|
208
|
+
return (0, xml_parser_1.default)(fs_1.default.readFileSync(appxManifestPath, 'utf8'));
|
|
209
|
+
}
|
|
210
|
+
function getAppxManifest(options, projectName) {
|
|
211
|
+
return parseAppxManifest(getAppxManifestPath(options, projectName));
|
|
212
|
+
}
|
|
213
|
+
function handleResponseError(e) {
|
|
214
|
+
if (e.message.indexOf('Error code -2146233088')) {
|
|
215
|
+
throw new telemetry_1.CodedError('NoDevice', `No Windows Mobile device was detected: ${e.message}`);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
throw new telemetry_1.CodedError('AppDidNotDeploy', `Unexpected error deploying app: ${e.message}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
// Errors: 0x80073d10 - bad architecture
|
|
222
|
+
async function deployToDevice(options, verbose, config) {
|
|
223
|
+
const windowsConfig = config.project.windows;
|
|
224
|
+
const projectName = windowsConfig && windowsConfig.project && windowsConfig.project.projectName
|
|
225
|
+
? windowsConfig.project.projectName
|
|
226
|
+
: path_1.default.parse(options.proj).name;
|
|
227
|
+
const appPackageFolder = getAppPackage(options);
|
|
228
|
+
const deployTarget = options.target
|
|
229
|
+
? options.target
|
|
230
|
+
: options.emulator
|
|
231
|
+
? 'emulator'
|
|
232
|
+
: 'device';
|
|
233
|
+
const deployTool = new winappdeploytool_1.default();
|
|
234
|
+
const appxManifest = getAppxManifest(options, projectName);
|
|
235
|
+
const shouldLaunch = shouldLaunchApp(options);
|
|
236
|
+
const identity = appxManifest.root.children.filter(x => {
|
|
237
|
+
return x.name === 'mp:PhoneIdentity';
|
|
238
|
+
})[0];
|
|
239
|
+
const appName = identity.attributes.PhoneProductId;
|
|
240
|
+
const device = deployTool.findDevice(deployTarget);
|
|
241
|
+
try {
|
|
242
|
+
await deployTool.uninstallAppPackage(appName, device, verbose);
|
|
243
|
+
}
|
|
244
|
+
catch (e) {
|
|
245
|
+
(0, commandWithProgress_1.newWarn)('Failed to uninstall app from ' + device.name);
|
|
246
|
+
}
|
|
247
|
+
const appxFile = glob_1.default.sync(path_1.default.join(appPackageFolder, '*.appx'))[0];
|
|
248
|
+
try {
|
|
249
|
+
await deployTool.installAppPackage(appxFile, device, shouldLaunch, false, verbose);
|
|
250
|
+
}
|
|
251
|
+
catch (e) {
|
|
252
|
+
if (e.message.includes('Error code 2148734208 for command')) {
|
|
253
|
+
await deployTool.installAppPackage(appxFile, device, shouldLaunch, true, verbose);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
handleResponseError(e);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
exports.deployToDevice = deployToDevice;
|
|
261
|
+
async function deployToDesktop(options, verbose, config, buildTools) {
|
|
262
|
+
const windowsConfig = config.project.windows;
|
|
263
|
+
const slnFile = windowsConfig && windowsConfig.solutionFile && windowsConfig.sourceDir
|
|
264
|
+
? path_1.default.join(windowsConfig.sourceDir, windowsConfig.solutionFile)
|
|
265
|
+
: options.sln;
|
|
266
|
+
const projectName = windowsConfig && windowsConfig.project && windowsConfig.project.projectName
|
|
267
|
+
? windowsConfig.project.projectName
|
|
268
|
+
: path_1.default.parse(options.proj).name;
|
|
269
|
+
const windowsStoreAppUtils = getWindowsStoreAppUtils(options);
|
|
270
|
+
const appxManifestPath = getAppxManifestPath(options, projectName);
|
|
271
|
+
const appxManifest = parseAppxManifest(appxManifestPath);
|
|
272
|
+
const identity = appxManifest.root.children.filter(x => {
|
|
273
|
+
return x.name === 'Identity';
|
|
274
|
+
})[0];
|
|
275
|
+
const appName = identity.attributes.Name;
|
|
276
|
+
const vsVersion = version_1.default.fromString(buildTools.installationVersion);
|
|
277
|
+
const args = [];
|
|
278
|
+
if (options.remoteDebugging) {
|
|
279
|
+
args.push('--remote-debugging');
|
|
280
|
+
}
|
|
281
|
+
if (options.directDebugging) {
|
|
282
|
+
args.push('--direct-debugging', options.directDebugging.toString());
|
|
283
|
+
}
|
|
284
|
+
await (0, commandWithProgress_1.runPowerShellScriptFunction)('Enabling Developer Mode', windowsStoreAppUtils, 'EnableDevMode', verbose, 'EnableDevModeFailure');
|
|
285
|
+
const appPackageFolder = getAppPackage(options, projectName);
|
|
286
|
+
if (shouldDeployByPackage(options, config)) {
|
|
287
|
+
// Deploy by package
|
|
288
|
+
await (0, commandWithProgress_1.runPowerShellScriptFunction)('Removing old version of the app', windowsStoreAppUtils, `Uninstall-App ${appName}`, verbose, 'RemoveOldAppVersionFailure');
|
|
289
|
+
const script = glob_1.default.sync(path_1.default.join(appPackageFolder, 'Add-AppDevPackage.ps1'))[0];
|
|
290
|
+
await (0, commandWithProgress_1.runPowerShellScriptFunction)('Installing new version of the app', windowsStoreAppUtils, `Install-App "${script}" -Force`, verbose, 'InstallAppFailure');
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
// Deploy from layout
|
|
294
|
+
// If we have DeployAppRecipe.exe, use it (start in 16.8.4, earlier 16.8 versions have bugs)
|
|
295
|
+
const appxRecipe = getAppxRecipePath(options, projectName);
|
|
296
|
+
const ideFolder = `${buildTools.installationPath}\\Common7\\IDE`;
|
|
297
|
+
const deployAppxRecipeExePath = `${ideFolder}\\DeployAppRecipe.exe`;
|
|
298
|
+
if (vsVersion.gte(version_1.default.fromString('16.8.30906.45')) &&
|
|
299
|
+
fs_1.default.existsSync(deployAppxRecipeExePath)) {
|
|
300
|
+
await (0, commandWithProgress_1.commandWithProgress)((0, commandWithProgress_1.newSpinner)('Deploying'), `Deploying ${appxRecipe}`, deployAppxRecipeExePath, [appxRecipe], verbose, 'DeployRecipeFailure');
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
// Install the app package's dependencies before attempting to deploy.
|
|
304
|
+
await (0, commandWithProgress_1.runPowerShellScriptFunction)('Installing dependent framework packages', windowsStoreAppUtils, `Install-AppDependencies ${appxManifestPath} ${appPackageFolder} ${options.arch}`, verbose, 'InstallAppDependenciesFailure');
|
|
305
|
+
await build.buildSolution(buildTools, slnFile,
|
|
306
|
+
/* options.release ? 'Release' : */ 'Debug', options.arch, { DeployLayout: 'true' }, verbose, 'deploy', options.buildLogDirectory);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const appFamilyName = (0, child_process_1.execSync)(`${commandWithProgress_1.powershell} -NoProfile -c $(Get-AppxPackage -Name ${appName}).PackageFamilyName`)
|
|
310
|
+
.toString()
|
|
311
|
+
.trim();
|
|
312
|
+
if (!appFamilyName) {
|
|
313
|
+
throw new telemetry_1.CodedError('AppDidNotDeploy', 'Fail to check the installed app, maybe developer mode is off on Windows');
|
|
314
|
+
}
|
|
315
|
+
const loopbackText = 'Verifying loopbackExempt';
|
|
316
|
+
const loopbackSpinner = (0, commandWithProgress_1.newSpinner)(loopbackText);
|
|
317
|
+
await (0, commandWithProgress_1.commandWithProgress)(loopbackSpinner, loopbackText, 'CheckNetIsolation', `LoopbackExempt -a -n=${appFamilyName}`.split(' '), verbose, 'CheckNetIsolationFailure');
|
|
318
|
+
if (shouldLaunchApp(options)) {
|
|
319
|
+
await (0, commandWithProgress_1.runPowerShellScriptFunction)('Starting the app', windowsStoreAppUtils, `Start-Locally ${appName} ${args}`, verbose, 'AppStartupFailure');
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
(0, commandWithProgress_1.newInfo)('Skip the step to start the app');
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
exports.deployToDesktop = deployToDesktop;
|
|
326
|
+
function startServerInNewWindow(options, verbose) {
|
|
327
|
+
return new Promise(resolve => {
|
|
328
|
+
http_1.default
|
|
329
|
+
.get('http://localhost:8081/status', res => {
|
|
330
|
+
if (res.statusCode === 200) {
|
|
331
|
+
(0, commandWithProgress_1.newSuccess)('React-Native Server already started');
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
(0, commandWithProgress_1.newError)('React-Native Server not responding');
|
|
335
|
+
}
|
|
336
|
+
resolve();
|
|
337
|
+
})
|
|
338
|
+
.on('error', () => {
|
|
339
|
+
launchServer(options, verbose);
|
|
340
|
+
resolve();
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
exports.startServerInNewWindow = startServerInNewWindow;
|
|
345
|
+
function launchServer(options, verbose) {
|
|
346
|
+
(0, commandWithProgress_1.newSuccess)('Starting the React-Native Server');
|
|
347
|
+
const opts = {
|
|
348
|
+
cwd: options.root,
|
|
349
|
+
detached: true,
|
|
350
|
+
stdio: verbose ? 'inherit' : 'ignore',
|
|
351
|
+
};
|
|
352
|
+
(0, child_process_1.spawn)('cmd.exe', ['/C', 'start npx react-native start'], opts);
|
|
353
|
+
}
|
|
354
354
|
//# sourceMappingURL=deploy.js.map
|