react-native-platform-override 1.9.21 → 1.9.23
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/Api.d.ts +57 -57
- package/lib-commonjs/Api.js +187 -187
- package/lib-commonjs/BatchingQueue.d.ts +15 -15
- package/lib-commonjs/BatchingQueue.js +57 -57
- package/lib-commonjs/Cli.d.ts +7 -7
- package/lib-commonjs/Cli.js +323 -323
- package/lib-commonjs/CrossProcessLock.d.ts +44 -44
- package/lib-commonjs/CrossProcessLock.js +147 -147
- package/lib-commonjs/DiffStrategy.d.ts +24 -24
- package/lib-commonjs/DiffStrategy.js +34 -34
- package/lib-commonjs/FileRepository.d.ts +62 -62
- package/lib-commonjs/FileRepository.js +21 -21
- package/lib-commonjs/FileSearch.d.ts +21 -21
- package/lib-commonjs/FileSearch.js +77 -77
- package/lib-commonjs/FileSystemRepository.d.ts +20 -20
- package/lib-commonjs/FileSystemRepository.js +62 -62
- package/lib-commonjs/GitReactFileRepository.d.ts +56 -56
- package/lib-commonjs/GitReactFileRepository.js +202 -202
- package/lib-commonjs/Hash.d.ts +33 -33
- package/lib-commonjs/Hash.js +81 -81
- package/lib-commonjs/Manifest.d.ts +80 -80
- package/lib-commonjs/Manifest.js +157 -157
- package/lib-commonjs/Override.d.ts +182 -182
- package/lib-commonjs/Override.js +248 -248
- package/lib-commonjs/OverrideFactory.d.ts +33 -33
- package/lib-commonjs/OverrideFactory.js +85 -85
- package/lib-commonjs/OverridePrompt.d.ts +30 -30
- package/lib-commonjs/OverridePrompt.js +130 -130
- package/lib-commonjs/PackageUtils.d.ts +15 -15
- package/lib-commonjs/PackageUtils.js +40 -40
- package/lib-commonjs/PathUtils.d.ts +14 -14
- package/lib-commonjs/PathUtils.js +31 -31
- package/lib-commonjs/Serialized.d.ts +158 -158
- package/lib-commonjs/Serialized.js +145 -145
- package/lib-commonjs/UpgradeStrategy.d.ts +39 -39
- package/lib-commonjs/UpgradeStrategy.js +102 -102
- package/lib-commonjs/ValidationStrategy.d.ts +57 -57
- package/lib-commonjs/ValidationStrategy.js +124 -124
- package/lib-commonjs/refFromVersion.d.ts +10 -10
- package/lib-commonjs/refFromVersion.js +98 -98
- package/lib-commonjs/refFromVersion.js.map +1 -1
- package/lib-commonjs/scripts/generateManifest.d.ts +7 -7
- package/lib-commonjs/scripts/generateManifest.js +196 -196
- package/lib-commonjs/scripts/hashFile.d.ts +7 -7
- package/lib-commonjs/scripts/hashFile.js +17 -17
- package/lib-commonjs/scripts/testLocks.d.ts +1 -1
- package/lib-commonjs/scripts/testLocks.js +29 -29
- package/package.json +10 -10
package/lib-commonjs/Api.d.ts
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
import OverrideFactory from './OverrideFactory';
|
|
8
|
-
import Override from './Override';
|
|
9
|
-
import { UpgradeResult } from './UpgradeStrategy';
|
|
10
|
-
import { ValidationError } from './ValidationStrategy';
|
|
11
|
-
export * from './OverrideFactory';
|
|
12
|
-
export * from './Override';
|
|
13
|
-
export * from './refFromVersion';
|
|
14
|
-
export { UpgradeResult, ValidationError };
|
|
15
|
-
/**
|
|
16
|
-
* Check that the given manifest correctly describe overrides and that all
|
|
17
|
-
* overrides are up to date
|
|
18
|
-
*/
|
|
19
|
-
export declare function validateManifest(manifestPath: string, opts?: {
|
|
20
|
-
reactNativeVersion?: string;
|
|
21
|
-
}): Promise<ValidationError[]>;
|
|
22
|
-
/**
|
|
23
|
-
* Return whether the override exists in the manifest
|
|
24
|
-
*/
|
|
25
|
-
export declare function hasOverride(overrideName: string, manifestPath: string): Promise<boolean>;
|
|
26
|
-
/**
|
|
27
|
-
* Removes an override from the manifest if it exists.
|
|
28
|
-
* @returns whether the override was removed
|
|
29
|
-
*/
|
|
30
|
-
export declare function removeOverride(overrideName: string, manifestPath: string): Promise<boolean>;
|
|
31
|
-
/**
|
|
32
|
-
* Returns a factory to create overrides which may be added to the manifest
|
|
33
|
-
*/
|
|
34
|
-
export declare function getOverrideFactory(manifestPath: string, opts?: {
|
|
35
|
-
reactNativeVersion?: string;
|
|
36
|
-
}): Promise<OverrideFactory>;
|
|
37
|
-
/**
|
|
38
|
-
* Adds an override to the manifest
|
|
39
|
-
*/
|
|
40
|
-
export declare function addOverride(override: Override, manifestPath: string): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* Outputs a patch-style diff of an override compared to its original source
|
|
43
|
-
*/
|
|
44
|
-
export declare function diffOverride(overrideName: string, manifestPath: string): Promise<string>;
|
|
45
|
-
/**
|
|
46
|
-
* Receives notifications on progress during override upgrades
|
|
47
|
-
*/
|
|
48
|
-
export type UpgradeProgressListener = (currentOverride: number, totalOverrides: number) => void;
|
|
49
|
-
/**
|
|
50
|
-
* Attempts to automatically merge changes from the current version into
|
|
51
|
-
* out-of-date overrides.
|
|
52
|
-
*/
|
|
53
|
-
export declare function upgradeOverrides(manifestPath: string, opts: {
|
|
54
|
-
allowConflicts: boolean;
|
|
55
|
-
reactNativeVersion?: string;
|
|
56
|
-
progressListener?: UpgradeProgressListener;
|
|
57
|
-
}): Promise<UpgradeResult[]>;
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
import OverrideFactory from './OverrideFactory';
|
|
8
|
+
import Override from './Override';
|
|
9
|
+
import { UpgradeResult } from './UpgradeStrategy';
|
|
10
|
+
import { ValidationError } from './ValidationStrategy';
|
|
11
|
+
export * from './OverrideFactory';
|
|
12
|
+
export * from './Override';
|
|
13
|
+
export * from './refFromVersion';
|
|
14
|
+
export { UpgradeResult, ValidationError };
|
|
15
|
+
/**
|
|
16
|
+
* Check that the given manifest correctly describe overrides and that all
|
|
17
|
+
* overrides are up to date
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateManifest(manifestPath: string, opts?: {
|
|
20
|
+
reactNativeVersion?: string;
|
|
21
|
+
}): Promise<ValidationError[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Return whether the override exists in the manifest
|
|
24
|
+
*/
|
|
25
|
+
export declare function hasOverride(overrideName: string, manifestPath: string): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Removes an override from the manifest if it exists.
|
|
28
|
+
* @returns whether the override was removed
|
|
29
|
+
*/
|
|
30
|
+
export declare function removeOverride(overrideName: string, manifestPath: string): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a factory to create overrides which may be added to the manifest
|
|
33
|
+
*/
|
|
34
|
+
export declare function getOverrideFactory(manifestPath: string, opts?: {
|
|
35
|
+
reactNativeVersion?: string;
|
|
36
|
+
}): Promise<OverrideFactory>;
|
|
37
|
+
/**
|
|
38
|
+
* Adds an override to the manifest
|
|
39
|
+
*/
|
|
40
|
+
export declare function addOverride(override: Override, manifestPath: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Outputs a patch-style diff of an override compared to its original source
|
|
43
|
+
*/
|
|
44
|
+
export declare function diffOverride(overrideName: string, manifestPath: string): Promise<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Receives notifications on progress during override upgrades
|
|
47
|
+
*/
|
|
48
|
+
export type UpgradeProgressListener = (currentOverride: number, totalOverrides: number) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Attempts to automatically merge changes from the current version into
|
|
51
|
+
* out-of-date overrides.
|
|
52
|
+
*/
|
|
53
|
+
export declare function upgradeOverrides(manifestPath: string, opts: {
|
|
54
|
+
allowConflicts: boolean;
|
|
55
|
+
reactNativeVersion?: string;
|
|
56
|
+
progressListener?: UpgradeProgressListener;
|
|
57
|
+
}): Promise<UpgradeResult[]>;
|
package/lib-commonjs/Api.js
CHANGED
|
@@ -1,188 +1,188 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Microsoft Corporation.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*
|
|
6
|
-
* @format
|
|
7
|
-
*/
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
-
}) : function(o, v) {
|
|
22
|
-
o["default"] = v;
|
|
23
|
-
});
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.upgradeOverrides = exports.diffOverride = exports.addOverride = exports.getOverrideFactory = exports.removeOverride = exports.hasOverride = exports.validateManifest = void 0;
|
|
39
|
-
// Typings for "async" confuse this rule
|
|
40
|
-
/* eslint-disable @typescript-eslint/no-misused-promises */
|
|
41
|
-
const Serialized = __importStar(require("./Serialized"));
|
|
42
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
43
|
-
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
44
|
-
const path_1 = __importDefault(require("path"));
|
|
45
|
-
const OverrideFactory_1 = require("./OverrideFactory");
|
|
46
|
-
const FileRepository_1 = require("./FileRepository");
|
|
47
|
-
const async_1 = require("async");
|
|
48
|
-
const FileSystemRepository_1 = __importDefault(require("./FileSystemRepository"));
|
|
49
|
-
const GitReactFileRepository_1 = __importDefault(require("./GitReactFileRepository"));
|
|
50
|
-
const Manifest_1 = __importDefault(require("./Manifest"));
|
|
51
|
-
const PackageUtils_1 = require("./PackageUtils");
|
|
52
|
-
// Re-export types used in the public API so external packages don't have to
|
|
53
|
-
// reach into our guts to import them.
|
|
54
|
-
__exportStar(require("./OverrideFactory"), exports);
|
|
55
|
-
__exportStar(require("./Override"), exports);
|
|
56
|
-
__exportStar(require("./refFromVersion"), exports);
|
|
57
|
-
const MAX_CONCURRENT_TASKS = 30;
|
|
58
|
-
/**
|
|
59
|
-
* Check that the given manifest correctly describe overrides and that all
|
|
60
|
-
* overrides are up to date
|
|
61
|
-
*/
|
|
62
|
-
async function validateManifest(manifestPath, opts) {
|
|
63
|
-
const { manifest, overrideRepo, reactRepo } = await createManifestContext(manifestPath, opts);
|
|
64
|
-
return await manifest.validate(overrideRepo, reactRepo);
|
|
65
|
-
}
|
|
66
|
-
exports.validateManifest = validateManifest;
|
|
67
|
-
/**
|
|
68
|
-
* Return whether the override exists in the manifest
|
|
69
|
-
*/
|
|
70
|
-
async function hasOverride(overrideName, manifestPath) {
|
|
71
|
-
const { manifest } = await createManifestContext(manifestPath);
|
|
72
|
-
return manifest.hasOverride(overrideName);
|
|
73
|
-
}
|
|
74
|
-
exports.hasOverride = hasOverride;
|
|
75
|
-
/**
|
|
76
|
-
* Removes an override from the manifest if it exists.
|
|
77
|
-
* @returns whether the override was removed
|
|
78
|
-
*/
|
|
79
|
-
async function removeOverride(overrideName, manifestPath) {
|
|
80
|
-
const { manifest } = await createManifestContext(manifestPath);
|
|
81
|
-
const removed = manifest.removeOverride(overrideName);
|
|
82
|
-
if (removed) {
|
|
83
|
-
await Serialized.writeManifestToFile(manifest.serialize(), manifestPath);
|
|
84
|
-
}
|
|
85
|
-
return removed;
|
|
86
|
-
}
|
|
87
|
-
exports.removeOverride = removeOverride;
|
|
88
|
-
/**
|
|
89
|
-
* Returns a factory to create overrides which may be added to the manifest
|
|
90
|
-
*/
|
|
91
|
-
async function getOverrideFactory(manifestPath, opts) {
|
|
92
|
-
return (await createManifestContext(manifestPath, opts)).overrideFactory;
|
|
93
|
-
}
|
|
94
|
-
exports.getOverrideFactory = getOverrideFactory;
|
|
95
|
-
/**
|
|
96
|
-
* Adds an override to the manifest
|
|
97
|
-
*/
|
|
98
|
-
async function addOverride(override, manifestPath) {
|
|
99
|
-
const { manifest } = await createManifestContext(manifestPath);
|
|
100
|
-
manifest.addOverride(override);
|
|
101
|
-
await Serialized.writeManifestToFile(manifest.serialize(), manifestPath);
|
|
102
|
-
}
|
|
103
|
-
exports.addOverride = addOverride;
|
|
104
|
-
/**
|
|
105
|
-
* Outputs a patch-style diff of an override compared to its original source
|
|
106
|
-
*/
|
|
107
|
-
async function diffOverride(overrideName, manifestPath) {
|
|
108
|
-
const ctx = await createManifestContext(manifestPath);
|
|
109
|
-
const override = ctx.manifest.findOverride(overrideName);
|
|
110
|
-
if (!override) {
|
|
111
|
-
throw new Error(`Could not find override with name "${overrideName}"`);
|
|
112
|
-
}
|
|
113
|
-
return override.diffStrategy().diff(ctx.gitReactRepo, ctx.overrideRepo);
|
|
114
|
-
}
|
|
115
|
-
exports.diffOverride = diffOverride;
|
|
116
|
-
/**
|
|
117
|
-
* Attempts to automatically merge changes from the current version into
|
|
118
|
-
* out-of-date overrides.
|
|
119
|
-
*/
|
|
120
|
-
async function upgradeOverrides(manifestPath, opts) {
|
|
121
|
-
const ctx = await createManifestContext(manifestPath, opts);
|
|
122
|
-
const validationErrors = await ctx.manifest.validate(ctx.overrideRepo, ctx.reactRepo);
|
|
123
|
-
const outOfDateOverrides = validationErrors
|
|
124
|
-
.filter(err => err.type === 'outOfDate')
|
|
125
|
-
.map(err => ctx.manifest.findOverride(err.overrideName));
|
|
126
|
-
// Perform upgrades concurrently so we can take advantage of
|
|
127
|
-
// GitReactFileRepository optimizations when multiple requests are queued at
|
|
128
|
-
// once.
|
|
129
|
-
let i = 0;
|
|
130
|
-
const upgradeResults = await (0, async_1.mapLimit)(outOfDateOverrides, MAX_CONCURRENT_TASKS, async (override) => {
|
|
131
|
-
const upgradeResult = await override
|
|
132
|
-
.upgradeStrategy()
|
|
133
|
-
.upgrade(ctx.gitReactRepo, ctx.overrideRepo, ctx.reactNativeVersion, opts.allowConflicts);
|
|
134
|
-
if (opts.progressListener) {
|
|
135
|
-
opts.progressListener(++i, outOfDateOverrides.length);
|
|
136
|
-
}
|
|
137
|
-
return upgradeResult;
|
|
138
|
-
});
|
|
139
|
-
// Regenerate overrides that are already up to date to update the baseVersion
|
|
140
|
-
// to current. This helps to minimize the numbers of versions we have to
|
|
141
|
-
// check out for future upgrades.
|
|
142
|
-
const upToDateOverrides = [
|
|
143
|
-
...lodash_1.default.difference(ctx.manifest.listOverrides(), validationErrors.map(err => ctx.manifest.findOverride(err.overrideName))).map(ovr => ovr.name()),
|
|
144
|
-
...upgradeResults
|
|
145
|
-
.filter(res => res.filesWritten)
|
|
146
|
-
.map(res => res.overrideName),
|
|
147
|
-
];
|
|
148
|
-
await (0, async_1.eachLimit)(upToDateOverrides, MAX_CONCURRENT_TASKS, async (name) => {
|
|
149
|
-
await ctx.manifest.markUpToDate(name, ctx.overrideFactory);
|
|
150
|
-
});
|
|
151
|
-
ctx.manifest.setBaseVersion(ctx.reactNativeVersion);
|
|
152
|
-
await Serialized.writeManifestToFile(ctx.manifest.serialize(), manifestPath);
|
|
153
|
-
return upgradeResults.sort((a, b) => a.overrideName.localeCompare(b.overrideName, 'en'));
|
|
154
|
-
}
|
|
155
|
-
exports.upgradeOverrides = upgradeOverrides;
|
|
156
|
-
/**
|
|
157
|
-
* Throw if a file doesn't exist, printing an error message on the way
|
|
158
|
-
*/
|
|
159
|
-
async function checkFileExists(friendlyName, filePath) {
|
|
160
|
-
try {
|
|
161
|
-
await fs_1.default.access(filePath);
|
|
162
|
-
}
|
|
163
|
-
catch (ex) {
|
|
164
|
-
throw new Error(`Could not find ${friendlyName} at path '${filePath}'`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Sets up state for a manifest describing overrides at a specified RN version
|
|
169
|
-
*/
|
|
170
|
-
async function createManifestContext(manifestPath, opts) {
|
|
171
|
-
await checkFileExists('manifest', manifestPath);
|
|
172
|
-
const reactNativeVersion = (opts === null || opts === void 0 ? void 0 : opts.reactNativeVersion) || (await (0, PackageUtils_1.getInstalledRNVersion)());
|
|
173
|
-
const overrideDir = path_1.default.dirname(manifestPath);
|
|
174
|
-
const overrideRepo = new FileSystemRepository_1.default(overrideDir);
|
|
175
|
-
const gitReactRepo = await GitReactFileRepository_1.default.createAndInit();
|
|
176
|
-
const reactRepo = (0, FileRepository_1.bindVersion)(gitReactRepo, reactNativeVersion);
|
|
177
|
-
const overrideFactory = new OverrideFactory_1.OverrideFactoryImpl(reactRepo, overrideRepo);
|
|
178
|
-
const manifest = Manifest_1.default.fromSerialized(await Serialized.readManifestFromFile(manifestPath));
|
|
179
|
-
return {
|
|
180
|
-
overrideRepo,
|
|
181
|
-
reactRepo,
|
|
182
|
-
gitReactRepo,
|
|
183
|
-
overrideFactory,
|
|
184
|
-
manifest,
|
|
185
|
-
reactNativeVersion,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*
|
|
6
|
+
* @format
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
32
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.upgradeOverrides = exports.diffOverride = exports.addOverride = exports.getOverrideFactory = exports.removeOverride = exports.hasOverride = exports.validateManifest = void 0;
|
|
39
|
+
// Typings for "async" confuse this rule
|
|
40
|
+
/* eslint-disable @typescript-eslint/no-misused-promises */
|
|
41
|
+
const Serialized = __importStar(require("./Serialized"));
|
|
42
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
43
|
+
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
44
|
+
const path_1 = __importDefault(require("path"));
|
|
45
|
+
const OverrideFactory_1 = require("./OverrideFactory");
|
|
46
|
+
const FileRepository_1 = require("./FileRepository");
|
|
47
|
+
const async_1 = require("async");
|
|
48
|
+
const FileSystemRepository_1 = __importDefault(require("./FileSystemRepository"));
|
|
49
|
+
const GitReactFileRepository_1 = __importDefault(require("./GitReactFileRepository"));
|
|
50
|
+
const Manifest_1 = __importDefault(require("./Manifest"));
|
|
51
|
+
const PackageUtils_1 = require("./PackageUtils");
|
|
52
|
+
// Re-export types used in the public API so external packages don't have to
|
|
53
|
+
// reach into our guts to import them.
|
|
54
|
+
__exportStar(require("./OverrideFactory"), exports);
|
|
55
|
+
__exportStar(require("./Override"), exports);
|
|
56
|
+
__exportStar(require("./refFromVersion"), exports);
|
|
57
|
+
const MAX_CONCURRENT_TASKS = 30;
|
|
58
|
+
/**
|
|
59
|
+
* Check that the given manifest correctly describe overrides and that all
|
|
60
|
+
* overrides are up to date
|
|
61
|
+
*/
|
|
62
|
+
async function validateManifest(manifestPath, opts) {
|
|
63
|
+
const { manifest, overrideRepo, reactRepo } = await createManifestContext(manifestPath, opts);
|
|
64
|
+
return await manifest.validate(overrideRepo, reactRepo);
|
|
65
|
+
}
|
|
66
|
+
exports.validateManifest = validateManifest;
|
|
67
|
+
/**
|
|
68
|
+
* Return whether the override exists in the manifest
|
|
69
|
+
*/
|
|
70
|
+
async function hasOverride(overrideName, manifestPath) {
|
|
71
|
+
const { manifest } = await createManifestContext(manifestPath);
|
|
72
|
+
return manifest.hasOverride(overrideName);
|
|
73
|
+
}
|
|
74
|
+
exports.hasOverride = hasOverride;
|
|
75
|
+
/**
|
|
76
|
+
* Removes an override from the manifest if it exists.
|
|
77
|
+
* @returns whether the override was removed
|
|
78
|
+
*/
|
|
79
|
+
async function removeOverride(overrideName, manifestPath) {
|
|
80
|
+
const { manifest } = await createManifestContext(manifestPath);
|
|
81
|
+
const removed = manifest.removeOverride(overrideName);
|
|
82
|
+
if (removed) {
|
|
83
|
+
await Serialized.writeManifestToFile(manifest.serialize(), manifestPath);
|
|
84
|
+
}
|
|
85
|
+
return removed;
|
|
86
|
+
}
|
|
87
|
+
exports.removeOverride = removeOverride;
|
|
88
|
+
/**
|
|
89
|
+
* Returns a factory to create overrides which may be added to the manifest
|
|
90
|
+
*/
|
|
91
|
+
async function getOverrideFactory(manifestPath, opts) {
|
|
92
|
+
return (await createManifestContext(manifestPath, opts)).overrideFactory;
|
|
93
|
+
}
|
|
94
|
+
exports.getOverrideFactory = getOverrideFactory;
|
|
95
|
+
/**
|
|
96
|
+
* Adds an override to the manifest
|
|
97
|
+
*/
|
|
98
|
+
async function addOverride(override, manifestPath) {
|
|
99
|
+
const { manifest } = await createManifestContext(manifestPath);
|
|
100
|
+
manifest.addOverride(override);
|
|
101
|
+
await Serialized.writeManifestToFile(manifest.serialize(), manifestPath);
|
|
102
|
+
}
|
|
103
|
+
exports.addOverride = addOverride;
|
|
104
|
+
/**
|
|
105
|
+
* Outputs a patch-style diff of an override compared to its original source
|
|
106
|
+
*/
|
|
107
|
+
async function diffOverride(overrideName, manifestPath) {
|
|
108
|
+
const ctx = await createManifestContext(manifestPath);
|
|
109
|
+
const override = ctx.manifest.findOverride(overrideName);
|
|
110
|
+
if (!override) {
|
|
111
|
+
throw new Error(`Could not find override with name "${overrideName}"`);
|
|
112
|
+
}
|
|
113
|
+
return override.diffStrategy().diff(ctx.gitReactRepo, ctx.overrideRepo);
|
|
114
|
+
}
|
|
115
|
+
exports.diffOverride = diffOverride;
|
|
116
|
+
/**
|
|
117
|
+
* Attempts to automatically merge changes from the current version into
|
|
118
|
+
* out-of-date overrides.
|
|
119
|
+
*/
|
|
120
|
+
async function upgradeOverrides(manifestPath, opts) {
|
|
121
|
+
const ctx = await createManifestContext(manifestPath, opts);
|
|
122
|
+
const validationErrors = await ctx.manifest.validate(ctx.overrideRepo, ctx.reactRepo);
|
|
123
|
+
const outOfDateOverrides = validationErrors
|
|
124
|
+
.filter(err => err.type === 'outOfDate')
|
|
125
|
+
.map(err => ctx.manifest.findOverride(err.overrideName));
|
|
126
|
+
// Perform upgrades concurrently so we can take advantage of
|
|
127
|
+
// GitReactFileRepository optimizations when multiple requests are queued at
|
|
128
|
+
// once.
|
|
129
|
+
let i = 0;
|
|
130
|
+
const upgradeResults = await (0, async_1.mapLimit)(outOfDateOverrides, MAX_CONCURRENT_TASKS, async (override) => {
|
|
131
|
+
const upgradeResult = await override
|
|
132
|
+
.upgradeStrategy()
|
|
133
|
+
.upgrade(ctx.gitReactRepo, ctx.overrideRepo, ctx.reactNativeVersion, opts.allowConflicts);
|
|
134
|
+
if (opts.progressListener) {
|
|
135
|
+
opts.progressListener(++i, outOfDateOverrides.length);
|
|
136
|
+
}
|
|
137
|
+
return upgradeResult;
|
|
138
|
+
});
|
|
139
|
+
// Regenerate overrides that are already up to date to update the baseVersion
|
|
140
|
+
// to current. This helps to minimize the numbers of versions we have to
|
|
141
|
+
// check out for future upgrades.
|
|
142
|
+
const upToDateOverrides = [
|
|
143
|
+
...lodash_1.default.difference(ctx.manifest.listOverrides(), validationErrors.map(err => ctx.manifest.findOverride(err.overrideName))).map(ovr => ovr.name()),
|
|
144
|
+
...upgradeResults
|
|
145
|
+
.filter(res => res.filesWritten)
|
|
146
|
+
.map(res => res.overrideName),
|
|
147
|
+
];
|
|
148
|
+
await (0, async_1.eachLimit)(upToDateOverrides, MAX_CONCURRENT_TASKS, async (name) => {
|
|
149
|
+
await ctx.manifest.markUpToDate(name, ctx.overrideFactory);
|
|
150
|
+
});
|
|
151
|
+
ctx.manifest.setBaseVersion(ctx.reactNativeVersion);
|
|
152
|
+
await Serialized.writeManifestToFile(ctx.manifest.serialize(), manifestPath);
|
|
153
|
+
return upgradeResults.sort((a, b) => a.overrideName.localeCompare(b.overrideName, 'en'));
|
|
154
|
+
}
|
|
155
|
+
exports.upgradeOverrides = upgradeOverrides;
|
|
156
|
+
/**
|
|
157
|
+
* Throw if a file doesn't exist, printing an error message on the way
|
|
158
|
+
*/
|
|
159
|
+
async function checkFileExists(friendlyName, filePath) {
|
|
160
|
+
try {
|
|
161
|
+
await fs_1.default.access(filePath);
|
|
162
|
+
}
|
|
163
|
+
catch (ex) {
|
|
164
|
+
throw new Error(`Could not find ${friendlyName} at path '${filePath}'`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Sets up state for a manifest describing overrides at a specified RN version
|
|
169
|
+
*/
|
|
170
|
+
async function createManifestContext(manifestPath, opts) {
|
|
171
|
+
await checkFileExists('manifest', manifestPath);
|
|
172
|
+
const reactNativeVersion = (opts === null || opts === void 0 ? void 0 : opts.reactNativeVersion) || (await (0, PackageUtils_1.getInstalledRNVersion)());
|
|
173
|
+
const overrideDir = path_1.default.dirname(manifestPath);
|
|
174
|
+
const overrideRepo = new FileSystemRepository_1.default(overrideDir);
|
|
175
|
+
const gitReactRepo = await GitReactFileRepository_1.default.createAndInit();
|
|
176
|
+
const reactRepo = (0, FileRepository_1.bindVersion)(gitReactRepo, reactNativeVersion);
|
|
177
|
+
const overrideFactory = new OverrideFactory_1.OverrideFactoryImpl(reactRepo, overrideRepo);
|
|
178
|
+
const manifest = Manifest_1.default.fromSerialized(await Serialized.readManifestFromFile(manifestPath));
|
|
179
|
+
return {
|
|
180
|
+
overrideRepo,
|
|
181
|
+
reactRepo,
|
|
182
|
+
gitReactRepo,
|
|
183
|
+
overrideFactory,
|
|
184
|
+
manifest,
|
|
185
|
+
reactNativeVersion,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
188
|
//# sourceMappingURL=Api.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Executes actions, attempting to group by a given key
|
|
9
|
-
*/
|
|
10
|
-
export default class BatchingQueue<TKey> {
|
|
11
|
-
private readonly keyedQueues;
|
|
12
|
-
private currentKey?;
|
|
13
|
-
enqueue<T>(key: TKey, action: () => Promise<T>): Promise<T>;
|
|
14
|
-
private pumpQueue;
|
|
15
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Executes actions, attempting to group by a given key
|
|
9
|
+
*/
|
|
10
|
+
export default class BatchingQueue<TKey> {
|
|
11
|
+
private readonly keyedQueues;
|
|
12
|
+
private currentKey?;
|
|
13
|
+
enqueue<T>(key: TKey, action: () => Promise<T>): Promise<T>;
|
|
14
|
+
private pumpQueue;
|
|
15
|
+
}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Microsoft Corporation.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*
|
|
6
|
-
* @format
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
/**
|
|
10
|
-
* Executes actions, attempting to group by a given key
|
|
11
|
-
*/
|
|
12
|
-
class BatchingQueue {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.keyedQueues = new Map();
|
|
15
|
-
}
|
|
16
|
-
enqueue(key, action) {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
if (!this.keyedQueues.has(key)) {
|
|
19
|
-
this.keyedQueues.set(key, []);
|
|
20
|
-
}
|
|
21
|
-
this.keyedQueues.get(key).push(async () => {
|
|
22
|
-
try {
|
|
23
|
-
resolve(await action());
|
|
24
|
-
}
|
|
25
|
-
catch (ex) {
|
|
26
|
-
reject(ex);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
if (!this.currentKey) {
|
|
30
|
-
this.currentKey = key;
|
|
31
|
-
void this.pumpQueue();
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
async pumpQueue() {
|
|
36
|
-
const currentQueue = this.keyedQueues.get(this.currentKey);
|
|
37
|
-
while (currentQueue.length > 0) {
|
|
38
|
-
await currentQueue.shift()();
|
|
39
|
-
}
|
|
40
|
-
this.keyedQueues.delete(this.currentKey);
|
|
41
|
-
this.currentKey = undefined;
|
|
42
|
-
// If we have more batches, pick the next greedily based on size
|
|
43
|
-
if (this.keyedQueues.size > 0) {
|
|
44
|
-
let nextKey;
|
|
45
|
-
let maxLength = 0;
|
|
46
|
-
this.keyedQueues.forEach((queue, key) => {
|
|
47
|
-
if (queue.length > maxLength) {
|
|
48
|
-
maxLength = queue.length;
|
|
49
|
-
nextKey = key;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
this.currentKey = nextKey;
|
|
53
|
-
return this.pumpQueue();
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
exports.default = BatchingQueue;
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*
|
|
6
|
+
* @format
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
/**
|
|
10
|
+
* Executes actions, attempting to group by a given key
|
|
11
|
+
*/
|
|
12
|
+
class BatchingQueue {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.keyedQueues = new Map();
|
|
15
|
+
}
|
|
16
|
+
enqueue(key, action) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
if (!this.keyedQueues.has(key)) {
|
|
19
|
+
this.keyedQueues.set(key, []);
|
|
20
|
+
}
|
|
21
|
+
this.keyedQueues.get(key).push(async () => {
|
|
22
|
+
try {
|
|
23
|
+
resolve(await action());
|
|
24
|
+
}
|
|
25
|
+
catch (ex) {
|
|
26
|
+
reject(ex);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
if (!this.currentKey) {
|
|
30
|
+
this.currentKey = key;
|
|
31
|
+
void this.pumpQueue();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async pumpQueue() {
|
|
36
|
+
const currentQueue = this.keyedQueues.get(this.currentKey);
|
|
37
|
+
while (currentQueue.length > 0) {
|
|
38
|
+
await currentQueue.shift()();
|
|
39
|
+
}
|
|
40
|
+
this.keyedQueues.delete(this.currentKey);
|
|
41
|
+
this.currentKey = undefined;
|
|
42
|
+
// If we have more batches, pick the next greedily based on size
|
|
43
|
+
if (this.keyedQueues.size > 0) {
|
|
44
|
+
let nextKey;
|
|
45
|
+
let maxLength = 0;
|
|
46
|
+
this.keyedQueues.forEach((queue, key) => {
|
|
47
|
+
if (queue.length > maxLength) {
|
|
48
|
+
maxLength = queue.length;
|
|
49
|
+
nextKey = key;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
this.currentKey = nextKey;
|
|
53
|
+
return this.pumpQueue();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.default = BatchingQueue;
|
|
58
58
|
//# sourceMappingURL=BatchingQueue.js.map
|
package/lib-commonjs/Cli.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
export {};
|