@react-native-windows/cli 0.66.2 → 0.68.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/README.md +1 -1
- package/lib-commonjs/config/configUtils.js +1 -1
- package/lib-commonjs/config/configUtils.js.map +1 -1
- package/lib-commonjs/config/dependencyConfig.js +6 -4
- package/lib-commonjs/config/dependencyConfig.js.map +1 -1
- package/lib-commonjs/config/projectConfig.js +2 -2
- package/lib-commonjs/config/projectConfig.js.map +1 -1
- package/lib-commonjs/e2etest/autolink.test.d.ts +5 -0
- package/lib-commonjs/e2etest/autolink.test.js +109 -12
- package/lib-commonjs/e2etest/autolink.test.js.map +1 -1
- package/lib-commonjs/e2etest/dependencyConfig.test.js +17 -17
- package/lib-commonjs/e2etest/dependencyConfig.test.js.map +1 -1
- package/lib-commonjs/e2etest/projectConfig.test.js +18 -20
- package/lib-commonjs/e2etest/projectConfig.test.js.map +1 -1
- package/lib-commonjs/e2etest/projectConfig.utils.js +6 -13
- package/lib-commonjs/e2etest/projectConfig.utils.js.map +1 -1
- package/lib-commonjs/e2etest/runWindows.test.js +52 -13
- package/lib-commonjs/e2etest/runWindows.test.js.map +1 -1
- package/lib-commonjs/generator-common/index.js +8 -8
- package/lib-commonjs/generator-common/index.js.map +1 -1
- package/lib-commonjs/generator-windows/index.js +34 -77
- package/lib-commonjs/generator-windows/index.js.map +1 -1
- package/lib-commonjs/healthChecks.js +22 -4
- package/lib-commonjs/healthChecks.js.map +1 -1
- package/lib-commonjs/index.js +10 -61
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/runWindows/runWindows.d.ts +0 -1
- package/lib-commonjs/runWindows/runWindows.js +124 -145
- package/lib-commonjs/runWindows/runWindows.js.map +1 -1
- package/lib-commonjs/runWindows/runWindowsOptions.d.ts +8 -8
- package/lib-commonjs/runWindows/runWindowsOptions.js +7 -12
- package/lib-commonjs/runWindows/runWindowsOptions.js.map +1 -1
- package/lib-commonjs/runWindows/utils/autolink.d.ts +16 -5
- package/lib-commonjs/runWindows/utils/autolink.js +118 -57
- package/lib-commonjs/runWindows/utils/autolink.js.map +1 -1
- package/lib-commonjs/runWindows/utils/build.js +4 -4
- package/lib-commonjs/runWindows/utils/build.js.map +1 -1
- package/lib-commonjs/runWindows/utils/checkRequirements.js +2 -2
- package/lib-commonjs/runWindows/utils/checkRequirements.js.map +1 -1
- package/lib-commonjs/runWindows/utils/commandWithProgress.d.ts +8 -1
- package/lib-commonjs/runWindows/utils/commandWithProgress.js +30 -8
- package/lib-commonjs/runWindows/utils/commandWithProgress.js.map +1 -1
- package/lib-commonjs/runWindows/utils/deploy.d.ts +1 -1
- package/lib-commonjs/runWindows/utils/deploy.js +88 -37
- package/lib-commonjs/runWindows/utils/deploy.js.map +1 -1
- package/lib-commonjs/runWindows/utils/msbuildtools.d.ts +1 -0
- package/lib-commonjs/runWindows/utils/msbuildtools.js +30 -23
- package/lib-commonjs/runWindows/utils/msbuildtools.js.map +1 -1
- package/lib-commonjs/runWindows/utils/telemetryHelpers.d.ts +29 -0
- package/lib-commonjs/runWindows/utils/telemetryHelpers.js +109 -0
- package/lib-commonjs/runWindows/utils/telemetryHelpers.js.map +1 -0
- package/lib-commonjs/runWindows/utils/version.js +1 -1
- package/lib-commonjs/runWindows/utils/version.js.map +1 -1
- package/lib-commonjs/runWindows/utils/vsInstalls.js +3 -3
- package/lib-commonjs/runWindows/utils/vsInstalls.js.map +1 -1
- package/lib-commonjs/runWindows/utils/vstools.js +4 -4
- package/lib-commonjs/runWindows/utils/vstools.js.map +1 -1
- package/lib-commonjs/runWindows/utils/winappdeploytool.js +7 -7
- package/lib-commonjs/runWindows/utils/winappdeploytool.js.map +1 -1
- package/package.json +17 -13
- package/CHANGELOG.json +0 -1585
- package/CHANGELOG.md +0 -713
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
* @format
|
|
5
5
|
*/
|
|
6
|
-
import { Command, Dependency, ProjectConfig } from '@react-native-community/cli-types';
|
|
6
|
+
import { Command, CommandOption, Config, Dependency, ProjectConfig } from '@react-native-community/cli-types';
|
|
7
7
|
import { WindowsProjectConfig } from '../../config/projectConfig';
|
|
8
8
|
import { Ora } from 'ora';
|
|
9
9
|
export declare class AutolinkWindows {
|
|
@@ -73,11 +73,22 @@ export declare class AutolinkWindows {
|
|
|
73
73
|
/** @return The CLI command to invoke autolink-windows independently */
|
|
74
74
|
getAutolinkWindowsCommand(): string;
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Performs auto-linking for RNW native modules and apps.
|
|
78
|
+
* @param args Unprocessed args passed from react-native CLI.
|
|
79
|
+
* @param config Config passed from react-native CLI.
|
|
80
|
+
* @param options Options passed from react-native CLI.
|
|
81
|
+
*/
|
|
82
|
+
export declare function autolinkWindowsInternal(args: string[], config: Config, options: AutoLinkOptions): Promise<void>;
|
|
83
|
+
export interface AutoLinkOptions {
|
|
84
|
+
logging?: boolean;
|
|
85
|
+
check?: boolean;
|
|
79
86
|
sln?: string;
|
|
80
87
|
proj?: string;
|
|
88
|
+
telemetry?: boolean;
|
|
81
89
|
}
|
|
90
|
+
export declare const autolinkOptions: CommandOption[];
|
|
91
|
+
/**
|
|
92
|
+
* Performs auto-linking for RNW native modules and apps.
|
|
93
|
+
*/
|
|
82
94
|
export declare const autoLinkCommand: Command;
|
|
83
|
-
export {};
|
|
@@ -19,7 +19,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
19
19
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
20
|
if (mod && mod.__esModule) return mod;
|
|
21
21
|
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
23
|
__setModuleDefault(result, mod);
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
@@ -27,12 +27,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.autoLinkCommand = exports.AutolinkWindows = void 0;
|
|
30
|
+
exports.autoLinkCommand = exports.autolinkOptions = exports.autolinkWindowsInternal = exports.AutolinkWindows = void 0;
|
|
31
31
|
// Types in this file are inaccurate compared to usage in terms of falsiness.
|
|
32
32
|
// We should try to rewrite some of this to do automated schema validation to
|
|
33
33
|
// guarantee correct types
|
|
34
34
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
35
|
-
const fs_1 = __importDefault(require("fs"));
|
|
35
|
+
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
36
36
|
const path_1 = __importDefault(require("path"));
|
|
37
37
|
const chalk_1 = __importDefault(require("chalk"));
|
|
38
38
|
const perf_hooks_1 = require("perf_hooks");
|
|
@@ -41,6 +41,7 @@ const vstools = __importStar(require("./vstools"));
|
|
|
41
41
|
const generatorCommon = __importStar(require("../../generator-common"));
|
|
42
42
|
const configUtils = __importStar(require("../../config/configUtils"));
|
|
43
43
|
const telemetry_1 = require("@react-native-windows/telemetry");
|
|
44
|
+
const telemetryHelpers_1 = require("./telemetryHelpers");
|
|
44
45
|
const xmldom_1 = require("@xmldom/xmldom");
|
|
45
46
|
const formatter = require('xml-formatter');
|
|
46
47
|
class AutolinkWindows {
|
|
@@ -149,7 +150,7 @@ class AutolinkWindows {
|
|
|
149
150
|
'solutionFile',
|
|
150
151
|
'project',
|
|
151
152
|
];
|
|
152
|
-
alwaysRequired.forEach(item => {
|
|
153
|
+
alwaysRequired.forEach((item) => {
|
|
153
154
|
if (!(item in this.windowsAppConfig) ||
|
|
154
155
|
this.windowsAppConfig[item] === null) {
|
|
155
156
|
throw new telemetry_1.CodedError('IncompleteConfig', `${item} is required but not specified by react-native config`, { item: item });
|
|
@@ -174,7 +175,7 @@ class AutolinkWindows {
|
|
|
174
175
|
'projectLang',
|
|
175
176
|
'projectGuid',
|
|
176
177
|
];
|
|
177
|
-
projectRequired.forEach(item => {
|
|
178
|
+
projectRequired.forEach((item) => {
|
|
178
179
|
if (!(item in windowsAppProjectConfig) ||
|
|
179
180
|
windowsAppProjectConfig[item] === null) {
|
|
180
181
|
throw new telemetry_1.CodedError('IncompleteConfig', `project.${item} is required but not specified by react-native config`, { item: item });
|
|
@@ -203,14 +204,14 @@ class AutolinkWindows {
|
|
|
203
204
|
let cppPackageProviders = '';
|
|
204
205
|
const windowsDependencies = this.getWindowsDependencies();
|
|
205
206
|
for (const dependencyName of Object.keys(windowsDependencies)) {
|
|
206
|
-
windowsDependencies[dependencyName].projects.forEach(project => {
|
|
207
|
+
windowsDependencies[dependencyName].projects.forEach((project) => {
|
|
207
208
|
if (project.directDependency) {
|
|
208
209
|
cppIncludes += `\n\n// Includes from ${dependencyName}`;
|
|
209
|
-
project.cppHeaders.forEach(header => {
|
|
210
|
+
project.cppHeaders.forEach((header) => {
|
|
210
211
|
cppIncludes += `\n#include <${header}>`;
|
|
211
212
|
});
|
|
212
213
|
cppPackageProviders += `\n // IReactPackageProviders from ${dependencyName}`;
|
|
213
|
-
project.cppPackageProviders.forEach(packageProvider => {
|
|
214
|
+
project.cppPackageProviders.forEach((packageProvider) => {
|
|
214
215
|
cppPackageProviders += `\n packageProviders.Append(winrt::${packageProvider}());`;
|
|
215
216
|
});
|
|
216
217
|
}
|
|
@@ -224,7 +225,7 @@ class AutolinkWindows {
|
|
|
224
225
|
return { cppPackageProviders, cppIncludes };
|
|
225
226
|
}
|
|
226
227
|
generateCSAutolinking(templateRoot, projectLang, projectDir) {
|
|
227
|
-
const { csUsingNamespaces, csReactPackageProviders
|
|
228
|
+
const { csUsingNamespaces, csReactPackageProviders } = this.getCsReplacements();
|
|
228
229
|
const csFileName = 'AutolinkedNativeModules.g.cs';
|
|
229
230
|
const srcCsFile = path_1.default.join(templateRoot, `${projectLang}-app`, 'src', csFileName);
|
|
230
231
|
const destCsFile = path_1.default.join(projectDir, csFileName);
|
|
@@ -241,14 +242,14 @@ class AutolinkWindows {
|
|
|
241
242
|
let csReactPackageProviders = '';
|
|
242
243
|
const windowsDependencies = this.getWindowsDependencies();
|
|
243
244
|
for (const dependencyName of Object.keys(windowsDependencies)) {
|
|
244
|
-
windowsDependencies[dependencyName].projects.forEach(project => {
|
|
245
|
+
windowsDependencies[dependencyName].projects.forEach((project) => {
|
|
245
246
|
if (project.directDependency) {
|
|
246
247
|
csUsingNamespaces += `\n\n// Namespaces from ${dependencyName}`;
|
|
247
|
-
project.csNamespaces.forEach(namespace => {
|
|
248
|
+
project.csNamespaces.forEach((namespace) => {
|
|
248
249
|
csUsingNamespaces += `\nusing ${namespace};`;
|
|
249
250
|
});
|
|
250
251
|
csReactPackageProviders += `\n // IReactPackageProviders from ${dependencyName}`;
|
|
251
|
-
project.csPackageProviders.forEach(packageProvider => {
|
|
252
|
+
project.csPackageProviders.forEach((packageProvider) => {
|
|
252
253
|
csReactPackageProviders += `\n packageProviders.Add(new ${packageProvider}());`;
|
|
253
254
|
});
|
|
254
255
|
}
|
|
@@ -259,8 +260,7 @@ class AutolinkWindows {
|
|
|
259
260
|
getWindowsDependencies() {
|
|
260
261
|
if (Object.keys(this.windowsDependencies).length === 0) {
|
|
261
262
|
for (const dependencyName of Object.keys(this.dependenciesConfig)) {
|
|
262
|
-
const windowsDependency = this
|
|
263
|
-
.dependenciesConfig[dependencyName].platforms.windows;
|
|
263
|
+
const windowsDependency = this.dependenciesConfig[dependencyName].platforms.windows;
|
|
264
264
|
if (windowsDependency) {
|
|
265
265
|
verboseMessage(`${chalk_1.default.bold(dependencyName)} has Windows implementation, config:`, this.options.logging);
|
|
266
266
|
verboseMessage(windowsDependency, this.options.logging);
|
|
@@ -276,12 +276,12 @@ class AutolinkWindows {
|
|
|
276
276
|
// the dependency is probably a react native module, but we didn't find a module project
|
|
277
277
|
throw new telemetry_1.CodedError('Autolinking', `Found a Windows solution for ${dependencyName} but no React Native for Windows native module projects`);
|
|
278
278
|
}
|
|
279
|
-
windowsDependency.projects.forEach(project => {
|
|
279
|
+
windowsDependency.projects.forEach((project) => {
|
|
280
280
|
const itemsToCheck = [
|
|
281
281
|
'projectFile',
|
|
282
282
|
'directDependency',
|
|
283
283
|
];
|
|
284
|
-
itemsToCheck.forEach(item => {
|
|
284
|
+
itemsToCheck.forEach((item) => {
|
|
285
285
|
dependencyIsValid = !!(dependencyIsValid &&
|
|
286
286
|
item in project &&
|
|
287
287
|
project[item] !== '' &&
|
|
@@ -311,14 +311,14 @@ class AutolinkWindows {
|
|
|
311
311
|
const fileName = chalk_1.default.bold(path_1.default.basename(filePath));
|
|
312
312
|
verboseMessage(`Reading ${fileName}...`, this.options.logging);
|
|
313
313
|
const actualContents = fs_1.default.existsSync(filePath)
|
|
314
|
-
? (await fs_1.default.
|
|
314
|
+
? (await fs_1.default.readFile(filePath)).toString()
|
|
315
315
|
: '';
|
|
316
316
|
const contentsChanged = expectedContents !== actualContents;
|
|
317
317
|
if (contentsChanged) {
|
|
318
318
|
verboseMessage(chalk_1.default.yellow(`${fileName} needs to be updated.`), this.options.logging);
|
|
319
319
|
if (!this.options.check) {
|
|
320
320
|
verboseMessage(`Writing ${fileName}...`, this.options.logging);
|
|
321
|
-
await fs_1.default.
|
|
321
|
+
await fs_1.default.writeFile(filePath, expectedContents, {
|
|
322
322
|
encoding: 'utf8',
|
|
323
323
|
flag: 'w',
|
|
324
324
|
});
|
|
@@ -333,7 +333,7 @@ class AutolinkWindows {
|
|
|
333
333
|
let projectReferencesForTargets = '';
|
|
334
334
|
const windowsDependencies = this.getWindowsDependencies();
|
|
335
335
|
for (const dependencyName of Object.keys(windowsDependencies)) {
|
|
336
|
-
windowsDependencies[dependencyName].projects.forEach(project => {
|
|
336
|
+
windowsDependencies[dependencyName].projects.forEach((project) => {
|
|
337
337
|
if (project.directDependency) {
|
|
338
338
|
const dependencyProjectFile = path_1.default.join(windowsDependencies[dependencyName].folder, windowsDependencies[dependencyName].sourceDir, project.projectFile);
|
|
339
339
|
const relDependencyProjectFile = path_1.default.relative(projectDir, dependencyProjectFile);
|
|
@@ -370,7 +370,7 @@ class AutolinkWindows {
|
|
|
370
370
|
const csModuleNames = [];
|
|
371
371
|
const windowsDependencies = this.getWindowsDependencies();
|
|
372
372
|
for (const dependencyName of Object.keys(windowsDependencies)) {
|
|
373
|
-
windowsDependencies[dependencyName].projects.forEach(project => {
|
|
373
|
+
windowsDependencies[dependencyName].projects.forEach((project) => {
|
|
374
374
|
if (project.directDependency && project.projectLang === 'cs') {
|
|
375
375
|
csModuleNames.push(project.projectName);
|
|
376
376
|
}
|
|
@@ -383,7 +383,7 @@ class AutolinkWindows {
|
|
|
383
383
|
const windowsDependencies = this.getWindowsDependencies();
|
|
384
384
|
for (const dependencyName of Object.keys(windowsDependencies)) {
|
|
385
385
|
// Process dependency projects
|
|
386
|
-
windowsDependencies[dependencyName].projects.forEach(project => {
|
|
386
|
+
windowsDependencies[dependencyName].projects.forEach((project) => {
|
|
387
387
|
const dependencyProjectFile = path_1.default.join(windowsDependencies[dependencyName].folder, windowsDependencies[dependencyName].sourceDir, project.projectFile);
|
|
388
388
|
projectsForSolution.push({
|
|
389
389
|
projectFile: dependencyProjectFile,
|
|
@@ -412,7 +412,7 @@ class AutolinkWindows {
|
|
|
412
412
|
}
|
|
413
413
|
verboseMessage(`Calculating ${chalk_1.default.bold(path_1.default.basename(solutionFile))} changes...`, this.options.logging);
|
|
414
414
|
let changesNecessary = false;
|
|
415
|
-
projectsForSolution.forEach(project => {
|
|
415
|
+
projectsForSolution.forEach((project) => {
|
|
416
416
|
const contentsChanged = vstools.addProjectToSolution(solutionFile, project, this.options.logging, this.options.check);
|
|
417
417
|
changesNecessary = changesNecessary || contentsChanged;
|
|
418
418
|
});
|
|
@@ -437,10 +437,14 @@ class AutolinkWindows {
|
|
|
437
437
|
if (experimentalFeatures) {
|
|
438
438
|
const useWinUI3FromExperimentalFeatures = ((_a = configUtils
|
|
439
439
|
.tryFindPropertyValue(experimentalFeatures.content, 'UseWinUI3')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'true';
|
|
440
|
-
//
|
|
440
|
+
// Check if WinUI2xVersion is specified in experimental features
|
|
441
|
+
const targetWinUI2xVersion = configUtils.tryFindPropertyValue(experimentalFeatures.content, 'WinUI2xVersion');
|
|
442
|
+
// Check if WinUI3Version is specified in experimental features
|
|
443
|
+
const targetWinUI3xVersion = configUtils.tryFindPropertyValue(experimentalFeatures.content, 'WinUI3Version');
|
|
444
|
+
// Use the UseWinUI3 value in react-native.config.js, or if not present, the value from ExperimentalFeatures.props
|
|
441
445
|
changesNeeded = await this.updatePackagesConfigXAMLDialect(useWinUI3FromConfig !== undefined
|
|
442
446
|
? useWinUI3FromConfig
|
|
443
|
-
: useWinUI3FromExperimentalFeatures);
|
|
447
|
+
: useWinUI3FromExperimentalFeatures, targetWinUI2xVersion, targetWinUI3xVersion);
|
|
444
448
|
if (useWinUI3FromConfig !== undefined) {
|
|
445
449
|
// Make sure ExperimentalFeatures.props matches the value that comes from react-native.config.js
|
|
446
450
|
const node = experimentalFeatures.content.getElementsByTagName('UseWinUI3');
|
|
@@ -466,7 +470,7 @@ class AutolinkWindows {
|
|
|
466
470
|
}
|
|
467
471
|
return undefined;
|
|
468
472
|
}
|
|
469
|
-
async updatePackagesConfigXAMLDialect(useWinUI3) {
|
|
473
|
+
async updatePackagesConfigXAMLDialect(useWinUI3, targetWinUI2xVersion, targetWinUI3xVersion) {
|
|
470
474
|
let changed = false;
|
|
471
475
|
const packagesConfig = this.getPackagesConfigXml();
|
|
472
476
|
if (packagesConfig) {
|
|
@@ -474,8 +478,10 @@ class AutolinkWindows {
|
|
|
474
478
|
const project = this.getWindowsConfig();
|
|
475
479
|
const winUIPropsPath = path_1.default.join(resolveRnwRoot(project), 'PropertySheets/WinUI.props');
|
|
476
480
|
const winuiPropsContents = configUtils.readProjectFile(winUIPropsPath);
|
|
477
|
-
|
|
478
|
-
const
|
|
481
|
+
// Use the given WinUI2xVersion, otherwise fallback to WinUI.props
|
|
482
|
+
const winui2xVersion = targetWinUI2xVersion !== null && targetWinUI2xVersion !== void 0 ? targetWinUI2xVersion : configUtils.tryFindPropertyValue(winuiPropsContents, 'WinUI2xVersion');
|
|
483
|
+
// Use the given WinUI3Version, otherwise fallback to WinUI.props
|
|
484
|
+
const winui3Version = targetWinUI3xVersion !== null && targetWinUI3xVersion !== void 0 ? targetWinUI3xVersion : configUtils.tryFindPropertyValue(winuiPropsContents, 'WinUI3Version');
|
|
479
485
|
const dialects = [
|
|
480
486
|
{ id: 'Microsoft.WinUI', version: winui3Version },
|
|
481
487
|
{ id: 'Microsoft.UI.Xaml', version: winui2xVersion },
|
|
@@ -500,8 +506,8 @@ class AutolinkWindows {
|
|
|
500
506
|
const packageElement = packageElements.item(i);
|
|
501
507
|
const idAttr = packageElement.getAttributeNode('id');
|
|
502
508
|
const id = idAttr.value;
|
|
503
|
-
const keepPkg = keepPkgs.find(pkg => pkg.id === id);
|
|
504
|
-
if (removePkgs.find(pkg => pkg.id === id)) {
|
|
509
|
+
const keepPkg = keepPkgs.find((pkg) => pkg.id === id);
|
|
510
|
+
if (removePkgs.find((pkg) => pkg.id === id)) {
|
|
505
511
|
nodesToRemove.push(packageElement);
|
|
506
512
|
changed = true;
|
|
507
513
|
}
|
|
@@ -509,11 +515,11 @@ class AutolinkWindows {
|
|
|
509
515
|
changed =
|
|
510
516
|
changed || keepPkg.version !== packageElement.getAttribute('version');
|
|
511
517
|
packageElement.setAttribute('version', keepPkg.version);
|
|
512
|
-
keepPkgs = keepPkgs.filter(pkg => pkg.id !== keepPkg.id);
|
|
518
|
+
keepPkgs = keepPkgs.filter((pkg) => pkg.id !== keepPkg.id);
|
|
513
519
|
}
|
|
514
520
|
}
|
|
515
|
-
nodesToRemove.forEach(pkg => packagesConfig.content.documentElement.removeChild(pkg));
|
|
516
|
-
keepPkgs.forEach(keepPkg => {
|
|
521
|
+
nodesToRemove.forEach((pkg) => packagesConfig.content.documentElement.removeChild(pkg));
|
|
522
|
+
keepPkgs.forEach((keepPkg) => {
|
|
517
523
|
const newPkg = packagesConfig.content.createElement('package');
|
|
518
524
|
Object.entries(keepPkg).forEach(([attr, value]) => {
|
|
519
525
|
newPkg.setAttribute(attr, value);
|
|
@@ -561,15 +567,63 @@ function verboseMessage(message, verbose) {
|
|
|
561
567
|
console.log(message);
|
|
562
568
|
}
|
|
563
569
|
}
|
|
570
|
+
/**
|
|
571
|
+
* Sanitizes the given option for telemetery.
|
|
572
|
+
* @param key The key of the option.
|
|
573
|
+
* @param value The unsanitized value of the option.
|
|
574
|
+
* @returns The sanitized value of the option.
|
|
575
|
+
*/
|
|
576
|
+
function optionSanitizer(key, value) {
|
|
577
|
+
// Do not add a default case here.
|
|
578
|
+
// Strings risking PII should just return true if present, false otherwise.
|
|
579
|
+
// All others should return the value (or false if undefined).
|
|
580
|
+
switch (key) {
|
|
581
|
+
case 'sln':
|
|
582
|
+
case 'proj':
|
|
583
|
+
return value === undefined ? false : true; // Strip PII
|
|
584
|
+
case 'logging':
|
|
585
|
+
case 'check':
|
|
586
|
+
case 'telemetry':
|
|
587
|
+
return value === undefined ? false : value; // Return value
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Get the extra props to add to the `autolink-windows` telemetry event.
|
|
592
|
+
* @returns The extra props.
|
|
593
|
+
*/
|
|
594
|
+
async function getExtraProps() {
|
|
595
|
+
const extraProps = {};
|
|
596
|
+
return extraProps;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* The function run when calling `react-native autolink-windows`.
|
|
600
|
+
* @param args Unprocessed args passed from react-native CLI.
|
|
601
|
+
* @param config Config passed from react-native CLI.
|
|
602
|
+
* @param options Options passed from react-native CLI.
|
|
603
|
+
*/
|
|
604
|
+
async function autolinkWindows(args, config, options) {
|
|
605
|
+
await (0, telemetryHelpers_1.startTelemetrySession)('autolink-windows', config, options, (0, telemetryHelpers_1.getDefaultOptions)(config, exports.autolinkOptions), optionSanitizer);
|
|
606
|
+
let autolinkWindowsError;
|
|
607
|
+
try {
|
|
608
|
+
await autolinkWindowsInternal(args, config, options);
|
|
609
|
+
}
|
|
610
|
+
catch (ex) {
|
|
611
|
+
autolinkWindowsError =
|
|
612
|
+
ex instanceof Error ? ex : new Error(String(ex));
|
|
613
|
+
telemetry_1.Telemetry.trackException(autolinkWindowsError);
|
|
614
|
+
}
|
|
615
|
+
await (0, telemetryHelpers_1.endTelemetrySession)(autolinkWindowsError, getExtraProps);
|
|
616
|
+
(0, commandWithProgress_1.setExitProcessWithError)(options.logging, autolinkWindowsError);
|
|
617
|
+
}
|
|
564
618
|
/**
|
|
565
619
|
* Performs auto-linking for RNW native modules and apps.
|
|
566
620
|
* @param args Unprocessed args passed from react-native CLI.
|
|
567
621
|
* @param config Config passed from react-native CLI.
|
|
568
622
|
* @param options Options passed from react-native CLI.
|
|
569
623
|
*/
|
|
570
|
-
async function
|
|
624
|
+
async function autolinkWindowsInternal(args, config, options) {
|
|
571
625
|
const startTime = perf_hooks_1.performance.now();
|
|
572
|
-
const spinner = commandWithProgress_1.newSpinner(options.check ? 'Checking auto-linked files...' : 'Auto-linking...');
|
|
626
|
+
const spinner = (0, commandWithProgress_1.newSpinner)(options.check ? 'Checking auto-linked files...' : 'Auto-linking...');
|
|
573
627
|
try {
|
|
574
628
|
const autolink = new AutolinkWindows(config.project, config.dependencies, options);
|
|
575
629
|
await autolink.run(spinner);
|
|
@@ -593,31 +647,38 @@ async function updateAutoLink(args, config, options) {
|
|
|
593
647
|
throw e;
|
|
594
648
|
}
|
|
595
649
|
}
|
|
650
|
+
exports.autolinkWindowsInternal = autolinkWindowsInternal;
|
|
651
|
+
exports.autolinkOptions = [
|
|
652
|
+
{
|
|
653
|
+
name: '--logging',
|
|
654
|
+
description: 'Verbose output logging',
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
name: '--check',
|
|
658
|
+
description: 'Only check whether any autolinked files need to change',
|
|
659
|
+
},
|
|
660
|
+
{
|
|
661
|
+
name: '--sln [string]',
|
|
662
|
+
description: "Override the app solution file determined by 'react-native config', e.g. windows\\myApp.sln",
|
|
663
|
+
default: undefined,
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
name: '--proj [string]',
|
|
667
|
+
description: "Override the app project file determined by 'react-native config', e.g. windows\\myApp\\myApp.vcxproj",
|
|
668
|
+
default: undefined,
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
name: '--no-telemetry',
|
|
672
|
+
description: 'Disables sending telemetry that allows analysis of usage and failures of the react-native-windows CLI',
|
|
673
|
+
},
|
|
674
|
+
];
|
|
675
|
+
/**
|
|
676
|
+
* Performs auto-linking for RNW native modules and apps.
|
|
677
|
+
*/
|
|
596
678
|
exports.autoLinkCommand = {
|
|
597
679
|
name: 'autolink-windows',
|
|
598
680
|
description: 'performs autolinking',
|
|
599
|
-
func:
|
|
600
|
-
options:
|
|
601
|
-
{
|
|
602
|
-
name: '--logging',
|
|
603
|
-
description: 'Verbose output logging',
|
|
604
|
-
default: false,
|
|
605
|
-
},
|
|
606
|
-
{
|
|
607
|
-
name: '--check',
|
|
608
|
-
description: 'Only check whether any autolinked files need to change',
|
|
609
|
-
default: false,
|
|
610
|
-
},
|
|
611
|
-
{
|
|
612
|
-
name: '--sln [string]',
|
|
613
|
-
description: "Override the app solution file determined by 'react-native config', e.g. windows\\myApp.sln",
|
|
614
|
-
default: undefined,
|
|
615
|
-
},
|
|
616
|
-
{
|
|
617
|
-
name: '--proj [string]',
|
|
618
|
-
description: "Override the app project file determined by 'react-native config', e.g. windows\\myApp\\myApp.vcxproj",
|
|
619
|
-
default: undefined,
|
|
620
|
-
},
|
|
621
|
-
],
|
|
681
|
+
func: autolinkWindows,
|
|
682
|
+
options: exports.autolinkOptions,
|
|
622
683
|
};
|
|
623
684
|
//# sourceMappingURL=autolink.js.map
|