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.
Files changed (73) hide show
  1. package/bin.js +1 -2
  2. package/lib-commonjs/Api.d.ts +57 -56
  3. package/lib-commonjs/Api.js +187 -167
  4. package/lib-commonjs/Api.js.map +1 -1
  5. package/lib-commonjs/BatchingQueue.d.ts +15 -15
  6. package/lib-commonjs/BatchingQueue.js +57 -57
  7. package/lib-commonjs/BatchingQueue.js.map +1 -1
  8. package/lib-commonjs/Cli.d.ts +7 -7
  9. package/lib-commonjs/Cli.js +323 -291
  10. package/lib-commonjs/Cli.js.map +1 -1
  11. package/lib-commonjs/CrossProcessLock.d.ts +44 -44
  12. package/lib-commonjs/CrossProcessLock.js +147 -144
  13. package/lib-commonjs/CrossProcessLock.js.map +1 -1
  14. package/lib-commonjs/DiffStrategy.d.ts +24 -24
  15. package/lib-commonjs/DiffStrategy.js +34 -34
  16. package/lib-commonjs/DiffStrategy.js.map +1 -1
  17. package/lib-commonjs/FileRepository.d.ts +63 -62
  18. package/lib-commonjs/FileRepository.js +21 -21
  19. package/lib-commonjs/FileRepository.js.map +1 -1
  20. package/lib-commonjs/FileSearch.d.ts +21 -21
  21. package/lib-commonjs/FileSearch.js +77 -91
  22. package/lib-commonjs/FileSearch.js.map +1 -1
  23. package/lib-commonjs/FileSystemRepository.d.ts +21 -20
  24. package/lib-commonjs/FileSystemRepository.js +62 -59
  25. package/lib-commonjs/FileSystemRepository.js.map +1 -1
  26. package/lib-commonjs/GitReactFileRepository.d.ts +57 -58
  27. package/lib-commonjs/GitReactFileRepository.js +202 -208
  28. package/lib-commonjs/GitReactFileRepository.js.map +1 -1
  29. package/lib-commonjs/Hash.d.ts +34 -33
  30. package/lib-commonjs/Hash.js +81 -81
  31. package/lib-commonjs/Hash.js.map +1 -1
  32. package/lib-commonjs/Manifest.d.ts +80 -80
  33. package/lib-commonjs/Manifest.js +157 -154
  34. package/lib-commonjs/Manifest.js.map +1 -1
  35. package/lib-commonjs/Override.d.ts +182 -182
  36. package/lib-commonjs/Override.js +248 -245
  37. package/lib-commonjs/Override.js.map +1 -1
  38. package/lib-commonjs/OverrideFactory.d.ts +33 -33
  39. package/lib-commonjs/OverrideFactory.js +85 -70
  40. package/lib-commonjs/OverrideFactory.js.map +1 -1
  41. package/lib-commonjs/OverridePrompt.d.ts +30 -30
  42. package/lib-commonjs/OverridePrompt.js +130 -104
  43. package/lib-commonjs/OverridePrompt.js.map +1 -1
  44. package/lib-commonjs/PackageUtils.d.ts +15 -15
  45. package/lib-commonjs/PackageUtils.js +40 -38
  46. package/lib-commonjs/PackageUtils.js.map +1 -1
  47. package/lib-commonjs/PathUtils.d.ts +14 -14
  48. package/lib-commonjs/PathUtils.js +31 -28
  49. package/lib-commonjs/PathUtils.js.map +1 -1
  50. package/lib-commonjs/Serialized.d.ts +158 -158
  51. package/lib-commonjs/Serialized.js +145 -119
  52. package/lib-commonjs/Serialized.js.map +1 -1
  53. package/lib-commonjs/UpgradeStrategy.d.ts +39 -39
  54. package/lib-commonjs/UpgradeStrategy.js +102 -99
  55. package/lib-commonjs/UpgradeStrategy.js.map +1 -1
  56. package/lib-commonjs/ValidationStrategy.d.ts +57 -57
  57. package/lib-commonjs/ValidationStrategy.js +124 -124
  58. package/lib-commonjs/ValidationStrategy.js.map +1 -1
  59. package/lib-commonjs/refFromVersion.d.ts +10 -0
  60. package/lib-commonjs/refFromVersion.js +99 -0
  61. package/lib-commonjs/refFromVersion.js.map +1 -0
  62. package/lib-commonjs/scripts/generateManifest.d.ts +7 -7
  63. package/lib-commonjs/scripts/generateManifest.js +196 -170
  64. package/lib-commonjs/scripts/generateManifest.js.map +1 -1
  65. package/lib-commonjs/scripts/hashFile.d.ts +7 -7
  66. package/lib-commonjs/scripts/hashFile.js +17 -14
  67. package/lib-commonjs/scripts/hashFile.js.map +1 -1
  68. package/lib-commonjs/scripts/testLocks.d.ts +1 -1
  69. package/lib-commonjs/scripts/testLocks.js +29 -26
  70. package/lib-commonjs/scripts/testLocks.js.map +1 -1
  71. package/package.json +53 -43
  72. package/CHANGELOG.json +0 -524
  73. 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
- * A filesystem abstraction that allows listing and reading files
10
- */
11
- export default interface FileRepository {
12
- /**
13
- * Return the repository-relative path to files
14
- * @param globs optional list of globs which files must match
15
- */
16
- listFiles(globs?: string[]): Promise<Array<string>>;
17
- /**
18
- * Read the contents of a patch file.
19
- * @param filename is expected to be relative to the repository root.
20
- */
21
- readFile(filename: string): Promise<Buffer | null>;
22
- /**
23
- * Check whether a file exists, and if so whether its a file or directory
24
- */
25
- stat(filename: string): Promise<'file' | 'directory' | 'none'>;
26
- }
27
- /**
28
- * Provides access to files
29
- */
30
- export interface WritableFileRepository extends FileRepository {
31
- /**
32
- * Sets the contents of a file. Rejects the promise if the file doesn't
33
- * exist.
34
- */
35
- writeFile(filename: string, content: Buffer | string): Promise<void>;
36
- /**
37
- * Deletes the file/directory, rejecting the promise if it doesn't exist.
38
- */
39
- deleteFile(filename: string): Promise<void>;
40
- }
41
- /**
42
- * Provides access to React Native source files
43
- */
44
- export interface ReactFileRepository extends FileRepository {
45
- /**
46
- * Get the React Native version the repo is exploring
47
- */
48
- getVersion(): string;
49
- }
50
- /**
51
- * Provides access to React Native source files of arbitrary version
52
- * {@see ReactFileRepository} for more details
53
- */
54
- export interface VersionedReactFileRepository {
55
- listFiles(globs: string[] | undefined, version: string): Promise<Array<string>>;
56
- readFile(filename: string, version: string): Promise<Buffer | null>;
57
- stat(filename: string, version: string): Promise<'file' | 'directory' | 'none'>;
58
- }
59
- /**
60
- * Convert from a VersionedReactFileRepository to ReactFileRepository
61
- */
62
- export declare function bindVersion(repository: VersionedReactFileRepository, version: string): ReactFileRepository;
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, prefering 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
- * Seatch 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,92 +1,78 @@
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.findThisPackage = exports.findAllManifests = exports.findManifest = void 0;
10
- const fs = require("fs");
11
- const path = require("path");
12
- const package_utils_1 = require("@react-native-windows/package-utils");
13
- /**
14
- * Search for a single manifest adjacent to the package above a directory or
15
- * CWD
16
- */
17
- async function findManifest(cwd) {
18
- const packagePath = await findFileAbove(cwd || process.cwd(), 'package.json');
19
- if (!packagePath) {
20
- throw new Error('This command must be run within a package');
21
- }
22
- const manifestPath = path.join(path.dirname(packagePath), 'overrides.json');
23
- if (!(await exists(manifestPath))) {
24
- throw new Error('Expected an "overrides.json" file at the root of the current package');
25
- }
26
- return manifestPath;
27
- }
28
- exports.findManifest = findManifest;
29
- /**
30
- * Enumerate the override manifests reachable from CWD, prefering the local
31
- * package if run within a package with an override manifest, otherwise
32
- * searching for packages in a monorepo
33
- */
34
- async function findAllManifests() {
35
- const packagePath = await findFileAbove(process.cwd(), 'package.json');
36
- if (!packagePath) {
37
- throw new Error('This command must be run within a package');
38
- }
39
- const packageDir = path.dirname(packagePath);
40
- if (await exists(path.join(packageDir, 'overrides.json'))) {
41
- return [path.join(packageDir, 'overrides.json')];
42
- }
43
- const localPackages = await package_utils_1.enumerateRepoPackages(pkg => exists(path.join(pkg.path, 'overrides.json')));
44
- return localPackages.map(pkg => path.join(pkg.path, 'overrides.json'));
45
- }
46
- exports.findAllManifests = findAllManifests;
47
- /**
48
- * Seatch for the package.json for this package (react-native-platform-override)
49
- */
50
- async function findThisPackage() {
51
- const thisPackagePath = await findFileAbove(__dirname, 'package.json');
52
- if (!thisPackagePath) {
53
- throw new Error('Unable to find a package.json about our source code. Did directory structure change?');
54
- }
55
- return thisPackagePath;
56
- }
57
- exports.findThisPackage = findThisPackage;
58
- /**
59
- * Search for the target path segment in all directories above the base
60
- */
61
- async function findFileAbove(base, target) {
62
- const searchPath = path.resolve(base);
63
- const fullPath = path.join(searchPath, target);
64
- if (await exists(fullPath)) {
65
- return fullPath;
66
- }
67
- const searchPathParent = path.resolve(path.join(searchPath, '..'));
68
- if (searchPathParent === searchPath) {
69
- return null;
70
- }
71
- else {
72
- return findFileAbove(searchPathParent, target);
73
- }
74
- }
75
- /**
76
- * Asyncrhonusly tests if a file exists
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;;;AAEH,yBAAyB;AACzB,6BAA6B;AAC7B,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,IAAI,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AS,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
- import { WritableFileRepository } from './FileRepository';
9
- /**
10
- * Allows reading phsyical 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
+ /// <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
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const fs = require("fs");
10
- const globby = require("globby");
11
- const path = require("path");
12
- /**
13
- * Allows reading phsyical files based on a passed in directory
14
- */
15
- class FileSystemRepository {
16
- constructor(baseDir) {
17
- this.baseDir = baseDir;
18
- }
19
- async listFiles(globs = ['**']) {
20
- return await globby(globs, {
21
- cwd: this.baseDir,
22
- dot: true,
23
- });
24
- }
25
- async readFile(filename) {
26
- const filePath = path.join(this.baseDir, filename);
27
- try {
28
- return await fs.promises.readFile(filePath);
29
- }
30
- catch (_a) {
31
- return null;
32
- }
33
- }
34
- async stat(filename) {
35
- const filePath = path.join(this.baseDir, filename);
36
- try {
37
- const stats = await fs.promises.stat(filePath);
38
- return stats.isDirectory() ? 'directory' : 'file';
39
- }
40
- catch (ex) {
41
- if (ex.code === 'ENOENT') {
42
- return 'none';
43
- }
44
- else {
45
- throw ex;
46
- }
47
- }
48
- }
49
- async writeFile(filename, content) {
50
- const filePath = path.join(this.baseDir, filename);
51
- await fs.promises.mkdir(path.dirname(filePath), { recursive: true });
52
- return fs.promises.writeFile(filePath, content);
53
- }
54
- async deleteFile(filename) {
55
- const filePath = path.join(this.baseDir, filename);
56
- await fs.promises.unlink(filePath);
57
- }
58
- }
59
- 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;
60
63
  //# sourceMappingURL=FileSystemRepository.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileSystemRepository.js","sourceRoot":"","sources":["../src/File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,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"]}