@atlaspack/fs 2.15.16-typescript-b27501580.0 → 2.15.16-typescript-5b4d3ad41.0

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.
@@ -0,0 +1,4 @@
1
+ import type { FileSystem } from '@atlaspack/types-internal';
2
+ export declare class NodeFS implements FileSystem {
3
+ constructor();
4
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NodeFS = void 0;
7
+ // @ts-expect-error TS2420
8
+ class NodeFS {
9
+ constructor() {
10
+ throw new Error("NodeFS isn't available in the browser");
11
+ }
12
+ }
13
+ exports.NodeFS = NodeFS;
@@ -0,0 +1,38 @@
1
+ import type { ReadStream, Stats } from 'fs';
2
+ import type { Writable } from 'stream';
3
+ import type { FilePath, Encoding, FileOptions, FileSystem } from '@atlaspack/types-internal';
4
+ import type { Event, Options as WatcherOptions, AsyncSubscription } from '@parcel/watcher';
5
+ import watcher from '@parcel/watcher';
6
+ export declare class NodeFS implements FileSystem {
7
+ readFile: any;
8
+ copyFile: any;
9
+ stat: any;
10
+ readdir: any;
11
+ symlink: any;
12
+ unlink: any;
13
+ utimes: any;
14
+ ncp: any;
15
+ createReadStream: (path: string, options?: any) => ReadStream;
16
+ cwd: () => string;
17
+ chdir: (directory: string) => void;
18
+ statSync: (path: string) => Stats;
19
+ realpathSync: (path: string, cache?: any) => string;
20
+ existsSync: (path: string) => boolean;
21
+ readdirSync: any;
22
+ findAncestorFile: any;
23
+ findNodeModule: any;
24
+ findFirstFile: any;
25
+ watcher(): typeof watcher;
26
+ createWriteStream(filePath: string, options?: any): Writable;
27
+ writeFile(filePath: FilePath, contents: Buffer | string, options?: FileOptions | null): Promise<void>;
28
+ readFileSync(filePath: FilePath, encoding?: Encoding): any;
29
+ realpath(originalPath: string): Promise<string>;
30
+ exists(filePath: FilePath): Promise<boolean>;
31
+ watch(dir: FilePath, fn: (err: Error | null | undefined, events: Array<Event>) => unknown, opts: WatcherOptions): Promise<AsyncSubscription>;
32
+ getEventsSince(dir: FilePath, snapshot: FilePath, opts: WatcherOptions): Promise<Array<Event>>;
33
+ writeSnapshot(dir: FilePath, snapshot: FilePath, opts: WatcherOptions): Promise<void>;
34
+ static deserialize(): NodeFS;
35
+ serialize(): null;
36
+ mkdirp(filePath: FilePath): Promise<void>;
37
+ rimraf(filePath: FilePath): Promise<void>;
38
+ }
package/lib/NodeFS.js ADDED
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NodeFS = void 0;
7
+ function _gracefulFs() {
8
+ const data = _interopRequireDefault(require("graceful-fs"));
9
+ _gracefulFs = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _fs() {
15
+ const data = _interopRequireDefault(require("fs"));
16
+ _fs = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _ncp() {
22
+ const data = _interopRequireDefault(require("ncp"));
23
+ _ncp = function () {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _path() {
29
+ const data = _interopRequireDefault(require("path"));
30
+ _path = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _os() {
36
+ const data = require("os");
37
+ _os = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
42
+ function _util() {
43
+ const data = require("util");
44
+ _util = function () {
45
+ return data;
46
+ };
47
+ return data;
48
+ }
49
+ function _buildCache() {
50
+ const data = require("@atlaspack/build-cache");
51
+ _buildCache = function () {
52
+ return data;
53
+ };
54
+ return data;
55
+ }
56
+ function _utils() {
57
+ const data = require("@atlaspack/utils");
58
+ _utils = function () {
59
+ return data;
60
+ };
61
+ return data;
62
+ }
63
+ function _featureFlags() {
64
+ const data = require("@atlaspack/feature-flags");
65
+ _featureFlags = function () {
66
+ return data;
67
+ };
68
+ return data;
69
+ }
70
+ function _watcher() {
71
+ const data = _interopRequireDefault(require("@parcel/watcher"));
72
+ _watcher = function () {
73
+ return data;
74
+ };
75
+ return data;
76
+ }
77
+ var _package = _interopRequireDefault(require("../package.json"));
78
+ function searchNative() {
79
+ const data = _interopRequireWildcard(require("@atlaspack/rust"));
80
+ searchNative = function () {
81
+ return data;
82
+ };
83
+ return data;
84
+ }
85
+ var searchJS = _interopRequireWildcard(require("./find"));
86
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
87
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
88
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
89
+ // @ts-expect-error TS7016
90
+
91
+ // @ts-expect-error TS7016
92
+
93
+ // Most of this can go away once we only support Node 10+, which includes
94
+ // require('fs').promises
95
+ const realpath = (0, _util().promisify)(process.platform === 'win32' ? _gracefulFs().default.realpath : _gracefulFs().default.realpath.native);
96
+ const isPnP = process.versions.pnp != null;
97
+ function getWatchmanWatcher() {
98
+ // This is here to trick atlaspack into ignoring this require...
99
+ const packageName = ['@atlaspack', 'watcher-watchman-js'].join('/');
100
+ return require(packageName);
101
+ }
102
+ class NodeFS {
103
+ readFile = (0, _util().promisify)(_gracefulFs().default.readFile);
104
+ copyFile = (0, _util().promisify)(_gracefulFs().default.copyFile);
105
+ stat = (0, _util().promisify)(_gracefulFs().default.stat);
106
+ readdir = (0, _util().promisify)(_gracefulFs().default.readdir);
107
+ symlink = (0, _util().promisify)(_gracefulFs().default.symlink);
108
+ unlink = (0, _util().promisify)(_gracefulFs().default.unlink);
109
+ utimes = (0, _util().promisify)(_gracefulFs().default.utimes);
110
+ ncp = (0, _util().promisify)(_ncp().default);
111
+ createReadStream = _gracefulFs().default.createReadStream;
112
+ cwd = () => process.cwd();
113
+ chdir = directory => process.chdir(directory);
114
+ statSync = path => _gracefulFs().default.statSync(path);
115
+ realpathSync = process.platform === 'win32' ? _gracefulFs().default.realpathSync : _gracefulFs().default.realpathSync.native;
116
+ existsSync = _gracefulFs().default.existsSync;
117
+ readdirSync = _gracefulFs().default.readdirSync;
118
+ findAncestorFile = isPnP ?
119
+ // @ts-expect-error TS7019
120
+ (...args) => searchJS.findAncestorFile(this, ...args) : searchNative().findAncestorFile;
121
+ findNodeModule = isPnP ?
122
+ // @ts-expect-error TS7019
123
+ (...args) => searchJS.findNodeModule(this, ...args) : searchNative().findNodeModule;
124
+ findFirstFile = isPnP ?
125
+ // @ts-expect-error TS7019
126
+ (...args) => searchJS.findFirstFile(this, ...args) : searchNative().findFirstFile;
127
+ watcher() {
128
+ return (0, _featureFlags().getFeatureFlag)('useWatchmanWatcher') ? getWatchmanWatcher() : _watcher().default;
129
+ }
130
+ createWriteStream(filePath, options) {
131
+ // Make createWriteStream atomic
132
+ let tmpFilePath = getTempFilePath(filePath);
133
+ let failed = false;
134
+ const move = async () => {
135
+ if (!failed) {
136
+ try {
137
+ await _gracefulFs().default.promises.rename(tmpFilePath, filePath);
138
+ } catch (e) {
139
+ // This is adapted from fs-write-stream-atomic. Apparently
140
+ // Windows doesn't like renaming when the target already exists.
141
+ if (process.platform === 'win32' && e.syscall && e.syscall === 'rename' && e.code && e.code === 'EPERM') {
142
+ let [hashTmp, hashTarget] = await Promise.all([(0, _utils().hashFile)(this, tmpFilePath), (0, _utils().hashFile)(this, filePath)]);
143
+ await this.unlink(tmpFilePath);
144
+ if (hashTmp != hashTarget) {
145
+ throw e;
146
+ }
147
+ }
148
+ }
149
+ }
150
+ };
151
+ let writeStream = _gracefulFs().default.createWriteStream(tmpFilePath, {
152
+ ...options,
153
+ fs: {
154
+ ..._gracefulFs().default,
155
+ // @ts-expect-error TS7006
156
+ close: (fd, cb) => {
157
+ // @ts-expect-error TS7006
158
+ _gracefulFs().default.close(fd, err => {
159
+ if (err) {
160
+ cb(err);
161
+ } else {
162
+ move().then(() => cb(), err => cb(err));
163
+ }
164
+ });
165
+ }
166
+ }
167
+ });
168
+ writeStream.once('error', () => {
169
+ failed = true;
170
+ try {
171
+ _gracefulFs().default.unlinkSync(tmpFilePath);
172
+ } catch (_err) {
173
+ // ignore
174
+ }
175
+ });
176
+ return writeStream;
177
+ }
178
+ async writeFile(filePath, contents, options) {
179
+ let tmpFilePath = getTempFilePath(filePath);
180
+ await _gracefulFs().default.promises.writeFile(tmpFilePath, contents, options);
181
+ await _gracefulFs().default.promises.rename(tmpFilePath, filePath);
182
+ }
183
+ readFileSync(filePath, encoding) {
184
+ if (encoding != null) {
185
+ return _gracefulFs().default.readFileSync(filePath, encoding);
186
+ }
187
+ return _gracefulFs().default.readFileSync(filePath);
188
+ }
189
+ async realpath(originalPath) {
190
+ try {
191
+ return await realpath(originalPath, 'utf8');
192
+ } catch (e) {
193
+ // do nothing
194
+ }
195
+ return originalPath;
196
+ }
197
+ exists(filePath) {
198
+ return new Promise(resolve => {
199
+ _gracefulFs().default.exists(filePath, resolve);
200
+ });
201
+ }
202
+ watch(dir, fn, opts) {
203
+ return this.watcher().subscribe(dir, fn, opts);
204
+ }
205
+ getEventsSince(dir, snapshot, opts) {
206
+ return this.watcher().getEventsSince(dir, snapshot, opts);
207
+ }
208
+ async writeSnapshot(dir, snapshot, opts) {
209
+ await this.mkdirp(_path().default.dirname(snapshot));
210
+ await this.watcher().writeSnapshot(dir, snapshot, opts);
211
+ }
212
+ static deserialize() {
213
+ return new NodeFS();
214
+ }
215
+ serialize() {
216
+ return null;
217
+ }
218
+ async mkdirp(filePath) {
219
+ await _fs().default.promises.mkdir(filePath, {
220
+ recursive: true
221
+ });
222
+ }
223
+ async rimraf(filePath) {
224
+ if (_gracefulFs().default.promises.rm) {
225
+ await _gracefulFs().default.promises.rm(filePath, {
226
+ recursive: true,
227
+ force: true
228
+ });
229
+ return;
230
+ }
231
+
232
+ // fs.promises.rm is not supported in node 12...
233
+ let stat;
234
+ try {
235
+ stat = await this.stat(filePath);
236
+ } catch (err) {
237
+ return;
238
+ }
239
+ if (stat.isDirectory()) {
240
+ await _fs().default.promises.rmdir(filePath, {
241
+ recursive: true
242
+ });
243
+ } else {
244
+ await _fs().default.promises.unlink(filePath);
245
+ }
246
+ }
247
+ }
248
+ exports.NodeFS = NodeFS;
249
+ (0, _buildCache().registerSerializableClass)(`${_package.default.version}:NodeFS`, NodeFS);
250
+ let writeStreamCalls = 0;
251
+
252
+ // @ts-expect-error TS7034
253
+ let threadId;
254
+ try {
255
+ ({
256
+ threadId
257
+ } = require('worker_threads'));
258
+ } catch {
259
+ //
260
+ }
261
+
262
+ // @ts-expect-error TS7034
263
+ let useOsTmpDir;
264
+ function shouldUseOsTmpDir(filePath) {
265
+ // @ts-expect-error TS7005
266
+ if (useOsTmpDir != null) {
267
+ // @ts-expect-error TS7005
268
+ return useOsTmpDir;
269
+ }
270
+ try {
271
+ const tmpDir = (0, _os().tmpdir)();
272
+ _fs().default.accessSync(tmpDir, _fs().default.constants.R_OK | _fs().default.constants.W_OK);
273
+ const tmpDirStats = _fs().default.statSync(tmpDir);
274
+ const filePathStats = _fs().default.statSync(filePath);
275
+ // Check the tmpdir is on the same partition as the target directory.
276
+ // This is required to ensure renaming is an atomic operation.
277
+ useOsTmpDir = tmpDirStats.dev === filePathStats.dev;
278
+ } catch (e) {
279
+ // We don't have read/write access to the OS tmp directory
280
+ useOsTmpDir = false;
281
+ }
282
+ return useOsTmpDir;
283
+ }
284
+
285
+ // Generate a temporary file path used for atomic writing of files.
286
+ function getTempFilePath(filePath) {
287
+ writeStreamCalls = writeStreamCalls % Number.MAX_SAFE_INTEGER;
288
+ let tmpFilePath = filePath;
289
+
290
+ // If possible, write the tmp file to the OS tmp directory
291
+ // This reduces the amount of FS events the watcher needs to process during the build
292
+ if (shouldUseOsTmpDir(filePath)) {
293
+ tmpFilePath = _path().default.join((0, _os().tmpdir)(), _path().default.basename(filePath));
294
+ }
295
+ return tmpFilePath + '.' + process.pid + (
296
+ // @ts-expect-error TS7005
297
+ threadId != null ? '.' + threadId : '') + '.' + (writeStreamCalls++).toString(36);
298
+ }
@@ -0,0 +1,18 @@
1
+ import { NodeFS } from './NodeFS';
2
+ import type { FilePath } from '@atlaspack/types-internal';
3
+ import type { Event, Options as WatcherOptions } from '@parcel/watcher';
4
+ export interface NodeVCSAwareFSOptions {
5
+ gitRepoPath: null | FilePath;
6
+ excludePatterns: Array<string>;
7
+ logEventDiff: null | ((watcherEvents: Event[], vcsEvents: Event[]) => void);
8
+ }
9
+ export type SerializedNodeVCSAwareFS = NodeVCSAwareFSOptions;
10
+ export declare class NodeVCSAwareFS extends NodeFS {
11
+ #private;
12
+ constructor(options: NodeVCSAwareFSOptions);
13
+ static deserialize(data: SerializedNodeVCSAwareFS): NodeVCSAwareFS;
14
+ serialize(): SerializedNodeVCSAwareFS;
15
+ setGitRepoPath(gitRepoPath: null | FilePath): void;
16
+ getEventsSince(dir: FilePath, snapshot: FilePath, opts: WatcherOptions): Promise<Array<Event>>;
17
+ writeSnapshot(dir: FilePath, snapshot: FilePath, opts: WatcherOptions): Promise<void>;
18
+ }
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NodeVCSAwareFS = void 0;
7
+ function _path() {
8
+ const data = _interopRequireDefault(require("path"));
9
+ _path = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ var _NodeFS = require("./NodeFS");
15
+ function _rust() {
16
+ const data = require("@atlaspack/rust");
17
+ _rust = function () {
18
+ return data;
19
+ };
20
+ return data;
21
+ }
22
+ function _buildCache() {
23
+ const data = require("@atlaspack/build-cache");
24
+ _buildCache = function () {
25
+ return data;
26
+ };
27
+ return data;
28
+ }
29
+ function _logger() {
30
+ const data = _interopRequireWildcard(require("@atlaspack/logger"));
31
+ _logger = function () {
32
+ return data;
33
+ };
34
+ return data;
35
+ }
36
+ function _featureFlags() {
37
+ const data = require("@atlaspack/feature-flags");
38
+ _featureFlags = function () {
39
+ return data;
40
+ };
41
+ return data;
42
+ }
43
+ var _package = _interopRequireDefault(require("../package.json"));
44
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
45
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
46
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
47
+ class NodeVCSAwareFS extends _NodeFS.NodeFS {
48
+ /**
49
+ * These files are excluded from 'dirty file' tracking even if they are
50
+ * modified.
51
+ */
52
+ #excludePatterns;
53
+ /**
54
+ * Logging function for the diff between watcher events and vcs events.
55
+ */
56
+ #logEventDiff;
57
+ /**
58
+ * The path of the git repository containing the project root. Null if the
59
+ * project is not a git repository.
60
+ */
61
+ #gitRepoPath;
62
+ constructor(options) {
63
+ super();
64
+ this.#excludePatterns = options.excludePatterns;
65
+ this.#logEventDiff = options.logEventDiff;
66
+ this.#gitRepoPath = options.gitRepoPath;
67
+ }
68
+ static deserialize(data) {
69
+ const fs = new NodeVCSAwareFS({
70
+ excludePatterns: data.excludePatterns,
71
+ logEventDiff: null,
72
+ gitRepoPath: data.gitRepoPath
73
+ });
74
+ return fs;
75
+ }
76
+
77
+ // @ts-expect-error TS2416
78
+ serialize() {
79
+ return {
80
+ excludePatterns: this.#excludePatterns,
81
+ logEventDiff: null,
82
+ gitRepoPath: this.#gitRepoPath
83
+ };
84
+ }
85
+ setGitRepoPath(gitRepoPath) {
86
+ this.#gitRepoPath = gitRepoPath;
87
+ }
88
+ async getEventsSince(dir, snapshot, opts) {
89
+ const gitRepoPath = this.#gitRepoPath;
90
+ if (gitRepoPath == null) {
91
+ return this.watcher().getEventsSince(dir, snapshot, opts);
92
+ }
93
+ const {
94
+ nativeSnapshotPath,
95
+ vcsState
96
+ } = await (0, _logger().instrumentAsync)('NodeVCSAwareFS.readSnapshot', async () => {
97
+ // Note: can't use toString() directly, or it won't resolve the promise
98
+ const snapshotFile = await this.readFile(snapshot);
99
+ const snapshotFileContent = snapshotFile.toString();
100
+ return JSON.parse(snapshotFileContent);
101
+ });
102
+ let watcherEventsSince = [];
103
+ const vcsEventsSince = vcsState != null ?
104
+ // @ts-expect-error TS2571
105
+ (await (0, _logger().instrumentAsync)('NodeVCSAwareFS::rust.getEventsSince', () =>
106
+ // @ts-expect-error TS2739
107
+ (0, _rust().getEventsSince)(gitRepoPath, vcsState, null))
108
+
109
+ // @ts-expect-error TS7006
110
+ ).map(e => ({
111
+ path: e.path,
112
+ type: e.changeType
113
+ })) : null;
114
+ if ((0, _featureFlags().getFeatureFlagValue)('vcsMode') !== 'NEW' && vcsEventsSince != null) {
115
+ var _this$logEventDiff;
116
+ watcherEventsSince = await (0, _logger().instrumentAsync)('NodeVCSAwareFS::watchman.getEventsSince', () => this.watcher().getEventsSince(dir, nativeSnapshotPath, opts));
117
+ (_this$logEventDiff = this.#logEventDiff) === null || _this$logEventDiff === void 0 || _this$logEventDiff.call(this, watcherEventsSince, vcsEventsSince);
118
+ }
119
+
120
+ // @ts-expect-error TS2345
121
+ if (['NEW_AND_CHECK', 'NEW'].includes((0, _featureFlags().getFeatureFlagValue)('vcsMode'))) {
122
+ if (vcsEventsSince == null) {
123
+ _logger().default.error({
124
+ origin: '@atlaspack/fs',
125
+ message: 'Missing VCS state. There was an error when writing the snapshot. Please clear your cache.',
126
+ meta: {
127
+ trackableEvent: 'vcs_state_snapshot_read_failed'
128
+ }
129
+ });
130
+ return [];
131
+ }
132
+ return vcsEventsSince;
133
+ }
134
+ return watcherEventsSince;
135
+ }
136
+ async writeSnapshot(dir, snapshot, opts) {
137
+ const gitRepoPath = this.#gitRepoPath;
138
+ if (gitRepoPath == null) {
139
+ await this.watcher().writeSnapshot(dir, snapshot, opts);
140
+ return;
141
+ }
142
+ const snapshotDirectory = _path().default.dirname(snapshot);
143
+ await this.mkdirp(snapshotDirectory);
144
+ const filename = _path().default.basename(snapshot, '.txt');
145
+ const nativeSnapshotPath = _path().default.join(snapshotDirectory, `${filename}.native-snapshot.txt`);
146
+ if ((0, _featureFlags().getFeatureFlagValue)('vcsMode') !== 'NEW') {
147
+ await (0, _logger().instrumentAsync)('NodeVCSAwareFS::watchman.writeSnapshot', async () => {
148
+ await this.watcher().writeSnapshot(dir, nativeSnapshotPath, opts);
149
+ });
150
+ }
151
+ let vcsState = null;
152
+ try {
153
+ var _vcsState, _vcsState2;
154
+ vcsState = await (0, _logger().instrumentAsync)('NodeVCSAwareFS::getVcsStateSnapshot',
155
+ // @ts-expect-error TS2322
156
+ () => (0, _rust().getVcsStateSnapshot)(gitRepoPath, this.#excludePatterns));
157
+ _logger().default.verbose({
158
+ origin: '@atlaspack/fs',
159
+ message: 'Expose VCS timing metrics',
160
+ meta: {
161
+ trackableEvent: 'vcs_timing_metrics',
162
+ // @ts-expect-error TS2339
163
+ dirtyFilesExecutionTime: (_vcsState = vcsState) === null || _vcsState === void 0 ? void 0 : _vcsState.dirtyFilesExecutionTime,
164
+ // @ts-expect-error TS2339
165
+ yarnStatesExecutionTime: (_vcsState2 = vcsState) === null || _vcsState2 === void 0 ? void 0 : _vcsState2.yarnStatesExecutionTime
166
+ }
167
+ });
168
+ } catch (err) {
169
+ _logger().default.error({
170
+ origin: '@atlaspack/fs',
171
+ message: `Failed to get VCS state snapshot: ${err.message}`,
172
+ meta: {
173
+ trackableEvent: 'vcs_state_snapshot_failed',
174
+ error: err
175
+ }
176
+ });
177
+ }
178
+ const snapshotContents = {
179
+ vcsState,
180
+ nativeSnapshotPath
181
+ };
182
+ await this.writeFile(snapshot, JSON.stringify(snapshotContents));
183
+ }
184
+ }
185
+ exports.NodeVCSAwareFS = NodeVCSAwareFS;
186
+ (0, _buildCache().registerSerializableClass)(`${_package.default.version}:NodeVCSAwareFS`, NodeVCSAwareFS);
@@ -0,0 +1,50 @@
1
+ import type { Readable, Writable } from 'stream';
2
+ import type { FilePath, Encoding, FileOptions, FileSystem, ReaddirOptions, FileStats } from '@atlaspack/types-internal';
3
+ import type { Event, Options as WatcherOptions, AsyncSubscription } from '@parcel/watcher';
4
+ import WorkerFarm from '@atlaspack/workers';
5
+ export declare class OverlayFS implements FileSystem {
6
+ deleted: Set<FilePath>;
7
+ writable: FileSystem;
8
+ readable: FileSystem;
9
+ _cwd: FilePath;
10
+ constructor(workerFarmOrFS: WorkerFarm | FileSystem, readable: FileSystem);
11
+ static deserialize(opts: any): OverlayFS;
12
+ serialize(): {
13
+ $$raw: boolean;
14
+ readable: FileSystem;
15
+ writable: FileSystem;
16
+ deleted: Set<FilePath>;
17
+ };
18
+ _deletedThrows(filePath: FilePath): FilePath;
19
+ _checkExists(filePath: FilePath): FilePath;
20
+ _isSymlink(filePath: FilePath): boolean;
21
+ _copyPathForWrite(filePath: FilePath): Promise<FilePath>;
22
+ _normalizePath(filePath: FilePath): FilePath;
23
+ readFile(filePath: FilePath, encoding?: Encoding): Promise<any>;
24
+ writeFile(filePath: FilePath, contents: string | Buffer, options?: FileOptions | null): Promise<void>;
25
+ copyFile(source: FilePath, destination: FilePath): Promise<void>;
26
+ stat(filePath: FilePath): Promise<FileStats>;
27
+ symlink(target: FilePath, filePath: FilePath): Promise<void>;
28
+ unlink(filePath: FilePath): Promise<void>;
29
+ mkdirp(dir: FilePath): Promise<void>;
30
+ rimraf(filePath: FilePath): Promise<void>;
31
+ ncp(source: FilePath, destination: FilePath): Promise<void>;
32
+ createReadStream(filePath: FilePath, opts?: FileOptions | null): Readable;
33
+ createWriteStream(path: FilePath, opts?: FileOptions | null): Writable;
34
+ cwd(): FilePath;
35
+ chdir(path: FilePath): void;
36
+ realpath(filePath: FilePath): Promise<FilePath>;
37
+ readFileSync(filePath: FilePath, encoding?: Encoding): any;
38
+ statSync(filePath: FilePath): FileStats;
39
+ realpathSync(filePath: FilePath): FilePath;
40
+ exists(filePath: FilePath): Promise<boolean>;
41
+ existsSync(filePath: FilePath): boolean;
42
+ readdir(path: FilePath, opts?: ReaddirOptions): Promise<any>;
43
+ readdirSync(dir: FilePath, opts?: ReaddirOptions): any;
44
+ watch(dir: FilePath, fn: (err: Error | null | undefined, events: Array<Event>) => unknown, opts: WatcherOptions): Promise<AsyncSubscription>;
45
+ getEventsSince(dir: FilePath, snapshot: FilePath, opts: WatcherOptions): Promise<Array<Event>>;
46
+ writeSnapshot(dir: FilePath, snapshot: FilePath, opts: WatcherOptions): Promise<void>;
47
+ findAncestorFile(fileNames: Array<string>, fromDir: FilePath, root: FilePath): FilePath | null | undefined;
48
+ findNodeModule(moduleName: string, fromDir: FilePath): FilePath | null | undefined;
49
+ findFirstFile(filePaths: Array<FilePath>): FilePath | null | undefined;
50
+ }