react-native-platform-override 0.4.6 → 0.81.0-preview.10
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/bin.js +1 -2
- package/lib-commonjs/Api.d.ts +57 -56
- package/lib-commonjs/Api.js +187 -167
- package/lib-commonjs/Api.js.map +1 -1
- package/lib-commonjs/BatchingQueue.d.ts +15 -15
- package/lib-commonjs/BatchingQueue.js +57 -57
- package/lib-commonjs/BatchingQueue.js.map +1 -1
- package/lib-commonjs/Cli.d.ts +7 -7
- package/lib-commonjs/Cli.js +323 -291
- package/lib-commonjs/Cli.js.map +1 -1
- package/lib-commonjs/CrossProcessLock.d.ts +44 -44
- package/lib-commonjs/CrossProcessLock.js +147 -144
- package/lib-commonjs/CrossProcessLock.js.map +1 -1
- package/lib-commonjs/DiffStrategy.d.ts +24 -24
- package/lib-commonjs/DiffStrategy.js +34 -34
- package/lib-commonjs/DiffStrategy.js.map +1 -1
- package/lib-commonjs/FileRepository.d.ts +63 -62
- package/lib-commonjs/FileRepository.js +21 -21
- package/lib-commonjs/FileRepository.js.map +1 -1
- package/lib-commonjs/FileSearch.d.ts +21 -21
- package/lib-commonjs/FileSearch.js +77 -91
- package/lib-commonjs/FileSearch.js.map +1 -1
- package/lib-commonjs/FileSystemRepository.d.ts +21 -20
- package/lib-commonjs/FileSystemRepository.js +62 -59
- package/lib-commonjs/FileSystemRepository.js.map +1 -1
- package/lib-commonjs/GitReactFileRepository.d.ts +57 -58
- package/lib-commonjs/GitReactFileRepository.js +202 -208
- package/lib-commonjs/GitReactFileRepository.js.map +1 -1
- package/lib-commonjs/Hash.d.ts +34 -33
- package/lib-commonjs/Hash.js +81 -81
- package/lib-commonjs/Hash.js.map +1 -1
- package/lib-commonjs/Manifest.d.ts +80 -80
- package/lib-commonjs/Manifest.js +157 -154
- package/lib-commonjs/Manifest.js.map +1 -1
- package/lib-commonjs/Override.d.ts +182 -182
- package/lib-commonjs/Override.js +248 -245
- package/lib-commonjs/Override.js.map +1 -1
- package/lib-commonjs/OverrideFactory.d.ts +33 -33
- package/lib-commonjs/OverrideFactory.js +85 -70
- package/lib-commonjs/OverrideFactory.js.map +1 -1
- package/lib-commonjs/OverridePrompt.d.ts +30 -30
- package/lib-commonjs/OverridePrompt.js +130 -104
- package/lib-commonjs/OverridePrompt.js.map +1 -1
- package/lib-commonjs/PackageUtils.d.ts +15 -15
- package/lib-commonjs/PackageUtils.js +40 -38
- package/lib-commonjs/PackageUtils.js.map +1 -1
- package/lib-commonjs/PathUtils.d.ts +14 -14
- package/lib-commonjs/PathUtils.js +31 -28
- package/lib-commonjs/PathUtils.js.map +1 -1
- package/lib-commonjs/Serialized.d.ts +158 -158
- package/lib-commonjs/Serialized.js +145 -119
- package/lib-commonjs/Serialized.js.map +1 -1
- package/lib-commonjs/UpgradeStrategy.d.ts +39 -39
- package/lib-commonjs/UpgradeStrategy.js +102 -99
- package/lib-commonjs/UpgradeStrategy.js.map +1 -1
- package/lib-commonjs/ValidationStrategy.d.ts +57 -57
- package/lib-commonjs/ValidationStrategy.js +124 -124
- package/lib-commonjs/ValidationStrategy.js.map +1 -1
- package/lib-commonjs/refFromVersion.d.ts +10 -0
- package/lib-commonjs/refFromVersion.js +99 -0
- package/lib-commonjs/refFromVersion.js.map +1 -0
- package/lib-commonjs/scripts/generateManifest.d.ts +7 -7
- package/lib-commonjs/scripts/generateManifest.js +196 -170
- package/lib-commonjs/scripts/generateManifest.js.map +1 -1
- package/lib-commonjs/scripts/hashFile.d.ts +7 -7
- package/lib-commonjs/scripts/hashFile.js +17 -14
- package/lib-commonjs/scripts/hashFile.js.map +1 -1
- package/lib-commonjs/scripts/testLocks.d.ts +1 -1
- package/lib-commonjs/scripts/testLocks.js +29 -26
- package/lib-commonjs/scripts/testLocks.js.map +1 -1
- package/package.json +53 -43
- package/CHANGELOG.json +0 -524
- package/CHANGELOG.md +0 -230
|
@@ -1,62 +1,63 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
/// <reference types="node" />
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="node" />
|
|
8
|
+
/// <reference types="node" />
|
|
9
|
+
/**
|
|
10
|
+
* A filesystem abstraction that allows listing and reading files
|
|
11
|
+
*/
|
|
12
|
+
export default interface FileRepository {
|
|
13
|
+
/**
|
|
14
|
+
* Return the repository-relative path to files
|
|
15
|
+
* @param globs optional list of globs which files must match
|
|
16
|
+
*/
|
|
17
|
+
listFiles(globs?: string[]): Promise<Array<string>>;
|
|
18
|
+
/**
|
|
19
|
+
* Read the contents of a patch file.
|
|
20
|
+
* @param filename is expected to be relative to the repository root.
|
|
21
|
+
*/
|
|
22
|
+
readFile(filename: string): Promise<Buffer | null>;
|
|
23
|
+
/**
|
|
24
|
+
* Check whether a file exists, and if so whether its a file or directory
|
|
25
|
+
*/
|
|
26
|
+
stat(filename: string): Promise<'file' | 'directory' | 'none'>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Provides access to files
|
|
30
|
+
*/
|
|
31
|
+
export interface WritableFileRepository extends FileRepository {
|
|
32
|
+
/**
|
|
33
|
+
* Sets the contents of a file. Rejects the promise if the file doesn't
|
|
34
|
+
* exist.
|
|
35
|
+
*/
|
|
36
|
+
writeFile(filename: string, content: Buffer | string): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Deletes the file/directory, rejecting the promise if it doesn't exist.
|
|
39
|
+
*/
|
|
40
|
+
deleteFile(filename: string): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Provides access to React Native source files
|
|
44
|
+
*/
|
|
45
|
+
export interface ReactFileRepository extends FileRepository {
|
|
46
|
+
/**
|
|
47
|
+
* Get the React Native version the repo is exploring
|
|
48
|
+
*/
|
|
49
|
+
getVersion(): string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Provides access to React Native source files of arbitrary version
|
|
53
|
+
* {@see ReactFileRepository} for more details
|
|
54
|
+
*/
|
|
55
|
+
export interface VersionedReactFileRepository {
|
|
56
|
+
listFiles(globs: string[] | undefined, version: string): Promise<Array<string>>;
|
|
57
|
+
readFile(filename: string, version: string): Promise<Buffer | null>;
|
|
58
|
+
stat(filename: string, version: string): Promise<'file' | 'directory' | 'none'>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Convert from a VersionedReactFileRepository to ReactFileRepository
|
|
62
|
+
*/
|
|
63
|
+
export declare function bindVersion(repository: VersionedReactFileRepository, version: string): ReactFileRepository;
|
|
@@ -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileRepository.js","sourceRoot":"","sources":["../src/FileRepository.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAkEH;;GAEG;AACH,SAAgB,WAAW,CACzB,UAAwC,EACxC,OAAe;IAEf,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC;QACxD,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC5D,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC;QACpD,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO;KAC1B,CAAC;AACJ,CAAC;AAVD,kCAUC"}
|
|
1
|
+
{"version":3,"file":"FileRepository.js","sourceRoot":"","sources":["../src/FileRepository.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAkEH;;GAEG;AACH,SAAgB,WAAW,CACzB,UAAwC,EACxC,OAAe;IAEf,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC;QACxD,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;QAC5D,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC;QACpD,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO;KAC1B,CAAC;AACJ,CAAC;AAVD,kCAUC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\n/**\n * A filesystem abstraction that allows listing and reading files\n */\nexport default interface FileRepository {\n /**\n * Return the repository-relative path to files\n * @param globs optional list of globs which files must match\n */\n listFiles(globs?: string[]): Promise<Array<string>>;\n\n /**\n * Read the contents of a patch file.\n * @param filename is expected to be relative to the repository root.\n */\n readFile(filename: string): Promise<Buffer | null>;\n\n /**\n * Check whether a file exists, and if so whether its a file or directory\n */\n stat(filename: string): Promise<'file' | 'directory' | 'none'>;\n}\n\n/**\n * Provides access to files\n */\nexport interface WritableFileRepository extends FileRepository {\n /**\n * Sets the contents of a file. Rejects the promise if the file doesn't\n * exist.\n */\n writeFile(filename: string, content: Buffer | string): Promise<void>;\n\n /**\n * Deletes the file/directory, rejecting the promise if it doesn't exist.\n */\n deleteFile(filename: string): Promise<void>;\n}\n\n/**\n * Provides access to React Native source files\n */\nexport interface ReactFileRepository extends FileRepository {\n /**\n * Get the React Native version the repo is exploring\n */\n getVersion(): string;\n}\n\n/**\n * Provides access to React Native source files of arbitrary version\n * {@see ReactFileRepository} for more details\n */\nexport interface VersionedReactFileRepository {\n listFiles(\n globs: string[] | undefined,\n version: string,\n ): Promise<Array<string>>;\n readFile(filename: string, version: string): Promise<Buffer | null>;\n stat(\n filename: string,\n version: string,\n ): Promise<'file' | 'directory' | 'none'>;\n}\n\n/**\n * Convert from a VersionedReactFileRepository to ReactFileRepository\n */\nexport function bindVersion(\n repository: VersionedReactFileRepository,\n version: string,\n): ReactFileRepository {\n return {\n listFiles: globs => repository.listFiles(globs, version),\n readFile: filename => repository.readFile(filename, version),\n stat: filename => repository.stat(filename, version),\n getVersion: () => version,\n };\n}\n"]}
|
|
@@ -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,
|
|
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
|
-
*
|
|
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,92 +1,78 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Microsoft Corporation.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*
|
|
6
|
-
* @format
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
async function exists(filepath) {
|
|
79
|
-
try {
|
|
80
|
-
await fs.promises.access(filepath);
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
catch (ex) {
|
|
84
|
-
if (ex.code === 'ENOENT') {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
throw ex;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
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
|
+
}
|
|
92
78
|
//# sourceMappingURL=FileSearch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSearch.js","sourceRoot":"","sources":["../src/FileSearch.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"FileSearch.js","sourceRoot":"","sources":["../src/FileSearch.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;AAEH,kEAA0C;AAC1C,gDAAwB;AACxB,uEAA0E;AAE1E;;;GAGG;AACI,KAAK,UAAU,YAAY,CAAC,GAAY;IAC7C,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IAC9E,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IAED,MAAM,YAAY,GAAG,cAAI,CAAC,IAAI,CAAC,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAC5E,IAAI,CAAC,CAAC,MAAM,YAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE;QACpC,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;KACH;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAdD,oCAcC;AAED;;;;GAIG;AACI,KAAK,UAAU,gBAAgB;IACpC,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;IACvE,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IAED,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAI,MAAM,YAAE,CAAC,MAAM,CAAC,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC,EAAE;QAC5D,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC;KAClD;IAED,MAAM,aAAa,GAAG,MAAM,IAAA,qCAAqB,EAAC,GAAG,CAAC,EAAE,CACtD,YAAE,CAAC,MAAM,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CACjD,CAAC;IAEF,OAAO,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;AACzE,CAAC;AAhBD,4CAgBC;AAED;;GAEG;AACI,KAAK,UAAU,eAAe;IACnC,MAAM,eAAe,GAAG,MAAM,aAAa,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IACvE,IAAI,CAAC,eAAe,EAAE;QACpB,MAAM,IAAI,KAAK,CACb,sFAAsF,CACvF,CAAC;KACH;IAED,OAAO,eAAe,CAAC;AACzB,CAAC;AATD,0CASC;AAED;;GAEG;AACH,KAAK,UAAU,aAAa,CAC1B,IAAY,EACZ,MAAc;IAEd,MAAM,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC/C,IAAI,MAAM,YAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;QAC7B,OAAO,QAAQ,CAAC;KACjB;IAED,MAAM,gBAAgB,GAAG,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;IACnE,IAAI,gBAAgB,KAAK,UAAU,EAAE;QACnC,OAAO,IAAI,CAAC;KACb;SAAM;QACL,OAAO,aAAa,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;KAChD;AACH,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport {enumerateRepoPackages} from '@react-native-windows/package-utils';\n\n/**\n * Search for a single manifest adjacent to the package above a directory or\n * CWD\n */\nexport async function findManifest(cwd?: string): Promise<string> {\n const packagePath = await findFileAbove(cwd || process.cwd(), 'package.json');\n if (!packagePath) {\n throw new Error('This command must be run within a package');\n }\n\n const manifestPath = path.join(path.dirname(packagePath), 'overrides.json');\n if (!(await fs.exists(manifestPath))) {\n throw new Error(\n 'Expected an \"overrides.json\" file at the root of the current package',\n );\n }\n\n return manifestPath;\n}\n\n/**\n * Enumerate the override manifests reachable from CWD, preferring the local\n * package if run within a package with an override manifest, otherwise\n * searching for packages in a monorepo\n */\nexport async function findAllManifests(): Promise<string[]> {\n const packagePath = await findFileAbove(process.cwd(), 'package.json');\n if (!packagePath) {\n throw new Error('This command must be run within a package');\n }\n\n const packageDir = path.dirname(packagePath);\n if (await fs.exists(path.join(packageDir, 'overrides.json'))) {\n return [path.join(packageDir, 'overrides.json')];\n }\n\n const localPackages = await enumerateRepoPackages(pkg =>\n fs.exists(path.join(pkg.path, 'overrides.json')),\n );\n\n return localPackages.map(pkg => path.join(pkg.path, 'overrides.json'));\n}\n\n/**\n * Search for the package.json for this package (react-native-platform-override)\n */\nexport async function findThisPackage(): Promise<string> {\n const thisPackagePath = await findFileAbove(__dirname, 'package.json');\n if (!thisPackagePath) {\n throw new Error(\n 'Unable to find a package.json about our source code. Did directory structure change?',\n );\n }\n\n return thisPackagePath;\n}\n\n/**\n * Search for the target path segment in all directories above the base\n */\nasync function findFileAbove(\n base: string,\n target: string,\n): Promise<string | null> {\n const searchPath = path.resolve(base);\n const fullPath = path.join(searchPath, target);\n if (await fs.exists(fullPath)) {\n return fullPath;\n }\n\n const searchPathParent = path.resolve(path.join(searchPath, '..'));\n if (searchPathParent === searchPath) {\n return null;\n } else {\n return findFileAbove(searchPathParent, target);\n }\n}\n"]}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
/// <reference types="node" />
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="node" />
|
|
8
|
+
/// <reference types="node" />
|
|
9
|
+
import { WritableFileRepository } from './FileRepository';
|
|
10
|
+
/**
|
|
11
|
+
* Allows reading physical files based on a passed in directory
|
|
12
|
+
*/
|
|
13
|
+
export default class FileSystemRepository implements WritableFileRepository {
|
|
14
|
+
private readonly baseDir;
|
|
15
|
+
constructor(baseDir: string);
|
|
16
|
+
listFiles(globs?: string[]): Promise<string[]>;
|
|
17
|
+
readFile(filename: string): Promise<Buffer | null>;
|
|
18
|
+
stat(filename: string): Promise<'file' | 'directory' | 'none'>;
|
|
19
|
+
writeFile(filename: string, content: Buffer | string): Promise<void>;
|
|
20
|
+
deleteFile(filename: string): Promise<void>;
|
|
21
|
+
}
|
|
@@ -1,60 +1,63 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Microsoft Corporation.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*
|
|
6
|
-
* @format
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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;
|
|
60
63
|
//# sourceMappingURL=FileSystemRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystemRepository.js","sourceRoot":"","sources":["../src/FileSystemRepository.ts"],"names":[],"mappings":";AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"FileSystemRepository.js","sourceRoot":"","sources":["../src/FileSystemRepository.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;AAEH,kEAA0C;AAC1C,oDAA4B;AAC5B,gDAAwB;AAIxB;;GAEG;AACH,MAAqB,oBAAoB;IAGvC,YAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAAkB,CAAC,IAAI,CAAC;QACtC,OAAO,MAAM,IAAA,gBAAM,EAAC,KAAK,EAAE;YACzB,GAAG,EAAE,IAAI,CAAC,OAAO;YACjB,GAAG,EAAE,IAAI;SACV,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAgB;QAC7B,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnD,IAAI;YACF,OAAO,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SACpC;QAAC,WAAM;YACN,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAgB;QACzB,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnD,IAAI;YACF,MAAM,KAAK,GAAG,MAAM,YAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACtC,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC;SACnD;QAAC,OAAO,EAAE,EAAE;YACX,IAAK,EAA4B,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACnD,OAAO,MAAM,CAAC;aACf;iBAAM;gBACL,MAAM,EAAE,CAAC;aACV;SACF;IACH,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAAgB,EAAE,OAAwB;QACxD,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnD,MAAM,YAAE,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;QAC1D,OAAO,YAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAAgB;QAC/B,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnD,MAAM,YAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;CACF;AA/CD,uCA+CC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport fs from '@react-native-windows/fs';\nimport globby from 'globby';\nimport path from 'path';\n\nimport {WritableFileRepository} from './FileRepository';\n\n/**\n * Allows reading physical files based on a passed in directory\n */\nexport default class FileSystemRepository implements WritableFileRepository {\n private readonly baseDir: string;\n\n constructor(baseDir: string) {\n this.baseDir = baseDir;\n }\n\n async listFiles(globs: string[] = ['**']): Promise<string[]> {\n return await globby(globs, {\n cwd: this.baseDir,\n dot: true,\n });\n }\n\n async readFile(filename: string): Promise<Buffer | null> {\n const filePath = path.join(this.baseDir, filename);\n try {\n return await fs.readFile(filePath);\n } catch {\n return null;\n }\n }\n\n async stat(filename: string): Promise<'file' | 'directory' | 'none'> {\n const filePath = path.join(this.baseDir, filename);\n try {\n const stats = await fs.stat(filePath);\n return stats.isDirectory() ? 'directory' : 'file';\n } catch (ex) {\n if ((ex as NodeJS.ErrnoException).code === 'ENOENT') {\n return 'none';\n } else {\n throw ex;\n }\n }\n }\n\n async writeFile(filename: string, content: Buffer | string) {\n const filePath = path.join(this.baseDir, filename);\n await fs.mkdir(path.dirname(filePath), {recursive: true});\n return fs.writeFile(filePath, content);\n }\n\n async deleteFile(filename: string): Promise<void> {\n const filePath = path.join(this.baseDir, filename);\n await fs.unlink(filePath);\n }\n}\n"]}
|