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.
Files changed (48) hide show
  1. package/lib-commonjs/Api.d.ts +57 -57
  2. package/lib-commonjs/Api.js +187 -187
  3. package/lib-commonjs/BatchingQueue.d.ts +15 -15
  4. package/lib-commonjs/BatchingQueue.js +57 -57
  5. package/lib-commonjs/Cli.d.ts +7 -7
  6. package/lib-commonjs/Cli.js +323 -323
  7. package/lib-commonjs/CrossProcessLock.d.ts +44 -44
  8. package/lib-commonjs/CrossProcessLock.js +147 -147
  9. package/lib-commonjs/DiffStrategy.d.ts +24 -24
  10. package/lib-commonjs/DiffStrategy.js +34 -34
  11. package/lib-commonjs/FileRepository.d.ts +62 -62
  12. package/lib-commonjs/FileRepository.js +21 -21
  13. package/lib-commonjs/FileSearch.d.ts +21 -21
  14. package/lib-commonjs/FileSearch.js +77 -77
  15. package/lib-commonjs/FileSystemRepository.d.ts +20 -20
  16. package/lib-commonjs/FileSystemRepository.js +62 -62
  17. package/lib-commonjs/GitReactFileRepository.d.ts +56 -56
  18. package/lib-commonjs/GitReactFileRepository.js +202 -202
  19. package/lib-commonjs/Hash.d.ts +33 -33
  20. package/lib-commonjs/Hash.js +81 -81
  21. package/lib-commonjs/Manifest.d.ts +80 -80
  22. package/lib-commonjs/Manifest.js +157 -157
  23. package/lib-commonjs/Override.d.ts +182 -182
  24. package/lib-commonjs/Override.js +248 -248
  25. package/lib-commonjs/OverrideFactory.d.ts +33 -33
  26. package/lib-commonjs/OverrideFactory.js +85 -85
  27. package/lib-commonjs/OverridePrompt.d.ts +30 -30
  28. package/lib-commonjs/OverridePrompt.js +130 -130
  29. package/lib-commonjs/PackageUtils.d.ts +15 -15
  30. package/lib-commonjs/PackageUtils.js +40 -40
  31. package/lib-commonjs/PathUtils.d.ts +14 -14
  32. package/lib-commonjs/PathUtils.js +31 -31
  33. package/lib-commonjs/Serialized.d.ts +158 -158
  34. package/lib-commonjs/Serialized.js +145 -145
  35. package/lib-commonjs/UpgradeStrategy.d.ts +39 -39
  36. package/lib-commonjs/UpgradeStrategy.js +102 -102
  37. package/lib-commonjs/ValidationStrategy.d.ts +57 -57
  38. package/lib-commonjs/ValidationStrategy.js +124 -124
  39. package/lib-commonjs/refFromVersion.d.ts +10 -10
  40. package/lib-commonjs/refFromVersion.js +98 -98
  41. package/lib-commonjs/refFromVersion.js.map +1 -1
  42. package/lib-commonjs/scripts/generateManifest.d.ts +7 -7
  43. package/lib-commonjs/scripts/generateManifest.js +196 -196
  44. package/lib-commonjs/scripts/hashFile.d.ts +7 -7
  45. package/lib-commonjs/scripts/hashFile.js +17 -17
  46. package/lib-commonjs/scripts/testLocks.d.ts +1 -1
  47. package/lib-commonjs/scripts/testLocks.js +29 -29
  48. package/package.json +10 -10
@@ -1,22 +1,22 @@
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
- exports.bindVersion = void 0;
10
- /**
11
- * Convert from a VersionedReactFileRepository to ReactFileRepository
12
- */
13
- function bindVersion(repository, version) {
14
- return {
15
- listFiles: globs => repository.listFiles(globs, version),
16
- readFile: filename => repository.readFile(filename, version),
17
- stat: filename => repository.stat(filename, version),
18
- getVersion: () => version,
19
- };
20
- }
21
- exports.bindVersion = bindVersion;
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
+ exports.bindVersion = void 0;
10
+ /**
11
+ * Convert from a VersionedReactFileRepository to ReactFileRepository
12
+ */
13
+ function bindVersion(repository, version) {
14
+ return {
15
+ listFiles: globs => repository.listFiles(globs, version),
16
+ readFile: filename => repository.readFile(filename, version),
17
+ stat: filename => repository.stat(filename, version),
18
+ getVersion: () => version,
19
+ };
20
+ }
21
+ exports.bindVersion = bindVersion;
22
22
  //# sourceMappingURL=FileRepository.js.map
@@ -1,21 +1,21 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * @format
6
- */
7
- /**
8
- * Search for a single manifest adjacent to the package above a directory or
9
- * CWD
10
- */
11
- export declare function findManifest(cwd?: string): Promise<string>;
12
- /**
13
- * Enumerate the override manifests reachable from CWD, preferring the local
14
- * package if run within a package with an override manifest, otherwise
15
- * searching for packages in a monorepo
16
- */
17
- export declare function findAllManifests(): Promise<string[]>;
18
- /**
19
- * Search for the package.json for this package (react-native-platform-override)
20
- */
21
- export declare function findThisPackage(): Promise<string>;
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * @format
6
+ */
7
+ /**
8
+ * Search for a single manifest adjacent to the package above a directory or
9
+ * CWD
10
+ */
11
+ export declare function findManifest(cwd?: string): Promise<string>;
12
+ /**
13
+ * Enumerate the override manifests reachable from CWD, preferring the local
14
+ * package if run within a package with an override manifest, otherwise
15
+ * searching for packages in a monorepo
16
+ */
17
+ export declare function findAllManifests(): Promise<string[]>;
18
+ /**
19
+ * Search for the package.json for this package (react-native-platform-override)
20
+ */
21
+ export declare function findThisPackage(): Promise<string>;
@@ -1,78 +1,78 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Microsoft Corporation.
4
- * Licensed under the MIT License.
5
- *
6
- * @format
7
- */
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.findThisPackage = exports.findAllManifests = exports.findManifest = void 0;
13
- const fs_1 = __importDefault(require("@react-native-windows/fs"));
14
- const path_1 = __importDefault(require("path"));
15
- const package_utils_1 = require("@react-native-windows/package-utils");
16
- /**
17
- * Search for a single manifest adjacent to the package above a directory or
18
- * CWD
19
- */
20
- async function findManifest(cwd) {
21
- const packagePath = await findFileAbove(cwd || process.cwd(), 'package.json');
22
- if (!packagePath) {
23
- throw new Error('This command must be run within a package');
24
- }
25
- const manifestPath = path_1.default.join(path_1.default.dirname(packagePath), 'overrides.json');
26
- if (!(await fs_1.default.exists(manifestPath))) {
27
- throw new Error('Expected an "overrides.json" file at the root of the current package');
28
- }
29
- return manifestPath;
30
- }
31
- exports.findManifest = findManifest;
32
- /**
33
- * Enumerate the override manifests reachable from CWD, preferring the local
34
- * package if run within a package with an override manifest, otherwise
35
- * searching for packages in a monorepo
36
- */
37
- async function findAllManifests() {
38
- const packagePath = await findFileAbove(process.cwd(), 'package.json');
39
- if (!packagePath) {
40
- throw new Error('This command must be run within a package');
41
- }
42
- const packageDir = path_1.default.dirname(packagePath);
43
- if (await fs_1.default.exists(path_1.default.join(packageDir, 'overrides.json'))) {
44
- return [path_1.default.join(packageDir, 'overrides.json')];
45
- }
46
- const localPackages = await (0, package_utils_1.enumerateRepoPackages)(pkg => fs_1.default.exists(path_1.default.join(pkg.path, 'overrides.json')));
47
- return localPackages.map(pkg => path_1.default.join(pkg.path, 'overrides.json'));
48
- }
49
- exports.findAllManifests = findAllManifests;
50
- /**
51
- * Search for the package.json for this package (react-native-platform-override)
52
- */
53
- async function findThisPackage() {
54
- const thisPackagePath = await findFileAbove(__dirname, 'package.json');
55
- if (!thisPackagePath) {
56
- throw new Error('Unable to find a package.json about our source code. Did directory structure change?');
57
- }
58
- return thisPackagePath;
59
- }
60
- exports.findThisPackage = findThisPackage;
61
- /**
62
- * Search for the target path segment in all directories above the base
63
- */
64
- async function findFileAbove(base, target) {
65
- const searchPath = path_1.default.resolve(base);
66
- const fullPath = path_1.default.join(searchPath, target);
67
- if (await fs_1.default.exists(fullPath)) {
68
- return fullPath;
69
- }
70
- const searchPathParent = path_1.default.resolve(path_1.default.join(searchPath, '..'));
71
- if (searchPathParent === searchPath) {
72
- return null;
73
- }
74
- else {
75
- return findFileAbove(searchPathParent, target);
76
- }
77
- }
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ *
6
+ * @format
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.findThisPackage = exports.findAllManifests = exports.findManifest = void 0;
13
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
14
+ const path_1 = __importDefault(require("path"));
15
+ const package_utils_1 = require("@react-native-windows/package-utils");
16
+ /**
17
+ * Search for a single manifest adjacent to the package above a directory or
18
+ * CWD
19
+ */
20
+ async function findManifest(cwd) {
21
+ const packagePath = await findFileAbove(cwd || process.cwd(), 'package.json');
22
+ if (!packagePath) {
23
+ throw new Error('This command must be run within a package');
24
+ }
25
+ const manifestPath = path_1.default.join(path_1.default.dirname(packagePath), 'overrides.json');
26
+ if (!(await fs_1.default.exists(manifestPath))) {
27
+ throw new Error('Expected an "overrides.json" file at the root of the current package');
28
+ }
29
+ return manifestPath;
30
+ }
31
+ exports.findManifest = findManifest;
32
+ /**
33
+ * Enumerate the override manifests reachable from CWD, preferring the local
34
+ * package if run within a package with an override manifest, otherwise
35
+ * searching for packages in a monorepo
36
+ */
37
+ async function findAllManifests() {
38
+ const packagePath = await findFileAbove(process.cwd(), 'package.json');
39
+ if (!packagePath) {
40
+ throw new Error('This command must be run within a package');
41
+ }
42
+ const packageDir = path_1.default.dirname(packagePath);
43
+ if (await fs_1.default.exists(path_1.default.join(packageDir, 'overrides.json'))) {
44
+ return [path_1.default.join(packageDir, 'overrides.json')];
45
+ }
46
+ const localPackages = await (0, package_utils_1.enumerateRepoPackages)(pkg => fs_1.default.exists(path_1.default.join(pkg.path, 'overrides.json')));
47
+ return localPackages.map(pkg => path_1.default.join(pkg.path, 'overrides.json'));
48
+ }
49
+ exports.findAllManifests = findAllManifests;
50
+ /**
51
+ * Search for the package.json for this package (react-native-platform-override)
52
+ */
53
+ async function findThisPackage() {
54
+ const thisPackagePath = await findFileAbove(__dirname, 'package.json');
55
+ if (!thisPackagePath) {
56
+ throw new Error('Unable to find a package.json about our source code. Did directory structure change?');
57
+ }
58
+ return thisPackagePath;
59
+ }
60
+ exports.findThisPackage = findThisPackage;
61
+ /**
62
+ * Search for the target path segment in all directories above the base
63
+ */
64
+ async function findFileAbove(base, target) {
65
+ const searchPath = path_1.default.resolve(base);
66
+ const fullPath = path_1.default.join(searchPath, target);
67
+ if (await fs_1.default.exists(fullPath)) {
68
+ return fullPath;
69
+ }
70
+ const searchPathParent = path_1.default.resolve(path_1.default.join(searchPath, '..'));
71
+ if (searchPathParent === searchPath) {
72
+ return null;
73
+ }
74
+ else {
75
+ return findFileAbove(searchPathParent, target);
76
+ }
77
+ }
78
78
  //# sourceMappingURL=FileSearch.js.map
@@ -1,20 +1,20 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * @format
6
- */
7
- /// <reference types="node" />
8
- import { WritableFileRepository } from './FileRepository';
9
- /**
10
- * Allows reading physical files based on a passed in directory
11
- */
12
- export default class FileSystemRepository implements WritableFileRepository {
13
- private readonly baseDir;
14
- constructor(baseDir: string);
15
- listFiles(globs?: string[]): Promise<string[]>;
16
- readFile(filename: string): Promise<Buffer | null>;
17
- stat(filename: string): Promise<'file' | 'directory' | 'none'>;
18
- writeFile(filename: string, content: Buffer | string): Promise<void>;
19
- deleteFile(filename: string): Promise<void>;
20
- }
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * @format
6
+ */
7
+ /// <reference types="node" />
8
+ import { WritableFileRepository } from './FileRepository';
9
+ /**
10
+ * Allows reading physical files based on a passed in directory
11
+ */
12
+ export default class FileSystemRepository implements WritableFileRepository {
13
+ private readonly baseDir;
14
+ constructor(baseDir: string);
15
+ listFiles(globs?: string[]): Promise<string[]>;
16
+ readFile(filename: string): Promise<Buffer | null>;
17
+ stat(filename: string): Promise<'file' | 'directory' | 'none'>;
18
+ writeFile(filename: string, content: Buffer | string): Promise<void>;
19
+ deleteFile(filename: string): Promise<void>;
20
+ }
@@ -1,63 +1,63 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Microsoft Corporation.
4
- * Licensed under the MIT License.
5
- *
6
- * @format
7
- */
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const fs_1 = __importDefault(require("@react-native-windows/fs"));
13
- const globby_1 = __importDefault(require("globby"));
14
- const path_1 = __importDefault(require("path"));
15
- /**
16
- * Allows reading physical files based on a passed in directory
17
- */
18
- class FileSystemRepository {
19
- constructor(baseDir) {
20
- this.baseDir = baseDir;
21
- }
22
- async listFiles(globs = ['**']) {
23
- return await (0, globby_1.default)(globs, {
24
- cwd: this.baseDir,
25
- dot: true,
26
- });
27
- }
28
- async readFile(filename) {
29
- const filePath = path_1.default.join(this.baseDir, filename);
30
- try {
31
- return await fs_1.default.readFile(filePath);
32
- }
33
- catch (_a) {
34
- return null;
35
- }
36
- }
37
- async stat(filename) {
38
- const filePath = path_1.default.join(this.baseDir, filename);
39
- try {
40
- const stats = await fs_1.default.stat(filePath);
41
- return stats.isDirectory() ? 'directory' : 'file';
42
- }
43
- catch (ex) {
44
- if (ex.code === 'ENOENT') {
45
- return 'none';
46
- }
47
- else {
48
- throw ex;
49
- }
50
- }
51
- }
52
- async writeFile(filename, content) {
53
- const filePath = path_1.default.join(this.baseDir, filename);
54
- await fs_1.default.mkdir(path_1.default.dirname(filePath), { recursive: true });
55
- return fs_1.default.writeFile(filePath, content);
56
- }
57
- async deleteFile(filename) {
58
- const filePath = path_1.default.join(this.baseDir, filename);
59
- await fs_1.default.unlink(filePath);
60
- }
61
- }
62
- exports.default = FileSystemRepository;
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ *
6
+ * @format
7
+ */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const fs_1 = __importDefault(require("@react-native-windows/fs"));
13
+ const globby_1 = __importDefault(require("globby"));
14
+ const path_1 = __importDefault(require("path"));
15
+ /**
16
+ * Allows reading physical files based on a passed in directory
17
+ */
18
+ class FileSystemRepository {
19
+ constructor(baseDir) {
20
+ this.baseDir = baseDir;
21
+ }
22
+ async listFiles(globs = ['**']) {
23
+ return await (0, globby_1.default)(globs, {
24
+ cwd: this.baseDir,
25
+ dot: true,
26
+ });
27
+ }
28
+ async readFile(filename) {
29
+ const filePath = path_1.default.join(this.baseDir, filename);
30
+ try {
31
+ return await fs_1.default.readFile(filePath);
32
+ }
33
+ catch (_a) {
34
+ return null;
35
+ }
36
+ }
37
+ async stat(filename) {
38
+ const filePath = path_1.default.join(this.baseDir, filename);
39
+ try {
40
+ const stats = await fs_1.default.stat(filePath);
41
+ return stats.isDirectory() ? 'directory' : 'file';
42
+ }
43
+ catch (ex) {
44
+ if (ex.code === 'ENOENT') {
45
+ return 'none';
46
+ }
47
+ else {
48
+ throw ex;
49
+ }
50
+ }
51
+ }
52
+ async writeFile(filename, content) {
53
+ const filePath = path_1.default.join(this.baseDir, filename);
54
+ await fs_1.default.mkdir(path_1.default.dirname(filePath), { recursive: true });
55
+ return fs_1.default.writeFile(filePath, content);
56
+ }
57
+ async deleteFile(filename) {
58
+ const filePath = path_1.default.join(this.baseDir, filename);
59
+ await fs_1.default.unlink(filePath);
60
+ }
61
+ }
62
+ exports.default = FileSystemRepository;
63
63
  //# sourceMappingURL=FileSystemRepository.js.map
@@ -1,56 +1,56 @@
1
- /**
2
- * Copyright (c) Microsoft Corporation.
3
- * Licensed under the MIT License.
4
- *
5
- * @format
6
- */
7
- /// <reference types="node" />
8
- import { VersionedReactFileRepository } from './FileRepository';
9
- /**
10
- * Retrieves React Native files using the React Native Github repo. Switching
11
- * between getting file contents of different versions may be slow.
12
- */
13
- export default class GitReactFileRepository implements VersionedReactFileRepository {
14
- private readonly fileRepo;
15
- private readonly gitClient;
16
- private checkedOutVersion?;
17
- private static githubToken?;
18
- private readonly batchingQueue;
19
- private constructor();
20
- /**
21
- * Asynchronously initialize the scratch repository, creating a new Git repo is needed
22
- * @param gitDirectory optional repo directory
23
- */
24
- static createAndInit(gitDirectory?: string): Promise<GitReactFileRepository>;
25
- /**
26
- * Set a GitHub API token for all instances of GitReactFileRepository to use
27
- * when making requests.
28
- * @param token a GitHub PAT
29
- */
30
- static setGithubToken(token: string): void;
31
- listFiles(globs: string[] | undefined, reactNativeVersion: string): Promise<string[]>;
32
- readFile(filename: string, reactNativeVersion: string): Promise<Buffer | null>;
33
- stat(filename: string, reactNativeVersion: string): Promise<'file' | 'directory' | 'none'>;
34
- /**
35
- * Generate a Git-style patch to transform the given file into the given
36
- * content.
37
- */
38
- generatePatch(filename: string, reactNativeVersion: string, newContent: Buffer): Promise<string>;
39
- /**
40
- * Apply a patch to the given file, returning the merged result, which may
41
- * include conflict markers. The underlying file is not mutated.
42
- *
43
- * Git is unable to generate a representation with conflict markers in the
44
- * event of binary merge conflicts. In this case a null Buffer is returned.
45
- */
46
- getPatchedFile(filename: string, reactNativeVersion: string, patchContent: string): Promise<{
47
- patchedFile: Buffer | null;
48
- hasConflicts: boolean;
49
- }>;
50
- private usingVersion;
51
- private checkoutVersion;
52
- private tryCheckoutLocal;
53
- private fetchAndCheckout;
54
- private static defaultGitDirectory;
55
- private ensureFile;
56
- }
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * @format
6
+ */
7
+ /// <reference types="node" />
8
+ import { VersionedReactFileRepository } from './FileRepository';
9
+ /**
10
+ * Retrieves React Native files using the React Native Github repo. Switching
11
+ * between getting file contents of different versions may be slow.
12
+ */
13
+ export default class GitReactFileRepository implements VersionedReactFileRepository {
14
+ private readonly fileRepo;
15
+ private readonly gitClient;
16
+ private checkedOutVersion?;
17
+ private static githubToken?;
18
+ private readonly batchingQueue;
19
+ private constructor();
20
+ /**
21
+ * Asynchronously initialize the scratch repository, creating a new Git repo is needed
22
+ * @param gitDirectory optional repo directory
23
+ */
24
+ static createAndInit(gitDirectory?: string): Promise<GitReactFileRepository>;
25
+ /**
26
+ * Set a GitHub API token for all instances of GitReactFileRepository to use
27
+ * when making requests.
28
+ * @param token a GitHub PAT
29
+ */
30
+ static setGithubToken(token: string): void;
31
+ listFiles(globs: string[] | undefined, reactNativeVersion: string): Promise<string[]>;
32
+ readFile(filename: string, reactNativeVersion: string): Promise<Buffer | null>;
33
+ stat(filename: string, reactNativeVersion: string): Promise<'file' | 'directory' | 'none'>;
34
+ /**
35
+ * Generate a Git-style patch to transform the given file into the given
36
+ * content.
37
+ */
38
+ generatePatch(filename: string, reactNativeVersion: string, newContent: Buffer): Promise<string>;
39
+ /**
40
+ * Apply a patch to the given file, returning the merged result, which may
41
+ * include conflict markers. The underlying file is not mutated.
42
+ *
43
+ * Git is unable to generate a representation with conflict markers in the
44
+ * event of binary merge conflicts. In this case a null Buffer is returned.
45
+ */
46
+ getPatchedFile(filename: string, reactNativeVersion: string, patchContent: string): Promise<{
47
+ patchedFile: Buffer | null;
48
+ hasConflicts: boolean;
49
+ }>;
50
+ private usingVersion;
51
+ private checkoutVersion;
52
+ private tryCheckoutLocal;
53
+ private fetchAndCheckout;
54
+ private static defaultGitDirectory;
55
+ private ensureFile;
56
+ }