@atlaspack/fs 2.14.5-dev.73 → 2.14.5-dev.93
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/CHANGELOG.md +31 -0
- package/lib/MemoryFS.js +829 -0
- package/lib/NodeFS.browser.js +13 -0
- package/lib/NodeFS.js +281 -0
- package/lib/NodeVCSAwareFS.js +176 -0
- package/lib/OverlayFS.js +366 -0
- package/lib/find.js +77 -0
- package/lib/index.js +92 -2411
- package/package.json +10 -10
- package/test/OverlayFS.test.js +2 -1
- package/lib/browser.js +0 -1271
- package/lib/browser.js.map +0 -1
- package/lib/index.js.map +0 -1
package/lib/browser.js
DELETED
|
@@ -1,1271 +0,0 @@
|
|
|
1
|
-
var $jF595$path = require("path");
|
|
2
|
-
var $jF595$stream = require("stream");
|
|
3
|
-
var $jF595$util = require("util");
|
|
4
|
-
var $jF595$buffer = require("buffer");
|
|
5
|
-
var $jF595$atlaspackbuildcache = require("@atlaspack/build-cache");
|
|
6
|
-
var $jF595$atlaspackutils = require("@atlaspack/utils");
|
|
7
|
-
var $jF595$atlaspackworkers = require("@atlaspack/workers");
|
|
8
|
-
var $jF595$events = require("events");
|
|
9
|
-
var $jF595$atlaspackrust = require("@atlaspack/rust");
|
|
10
|
-
var $jF595$atlaspacklogger = require("@atlaspack/logger");
|
|
11
|
-
var $jF595$atlaspackfeatureflags = require("@atlaspack/feature-flags");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function $parcel$interopDefault(a) {
|
|
15
|
-
return a && a.__esModule ? a.default : a;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function $parcel$exportWildcard(dest, source) {
|
|
19
|
-
Object.keys(source).forEach(function(key) {
|
|
20
|
-
if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
Object.defineProperty(dest, key, {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return source[key];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
return dest;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function $parcel$export(e, n, v, s) {
|
|
36
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
$parcel$export(module.exports, "ncp", () => $81d23888a9e9b3a9$export$d3a8044e3fef7335);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var $3efdc9f199571449$exports = {};
|
|
44
|
-
|
|
45
|
-
$parcel$export($3efdc9f199571449$exports, "NodeFS", () => $3efdc9f199571449$export$c4e0ef2ab73c21e7);
|
|
46
|
-
// $FlowFixMe[prop-missing] handled by the throwing constructor
|
|
47
|
-
class $3efdc9f199571449$export$c4e0ef2ab73c21e7 {
|
|
48
|
-
constructor(){
|
|
49
|
-
throw new Error("NodeFS isn't available in the browser");
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var $ce546cd73efa5b9e$exports = {};
|
|
55
|
-
|
|
56
|
-
$parcel$export($ce546cd73efa5b9e$exports, "MemoryFS", () => $ce546cd73efa5b9e$export$3048eb7ec07c2c4e);
|
|
57
|
-
$parcel$export($ce546cd73efa5b9e$exports, "FSError", () => $ce546cd73efa5b9e$export$d414276624ebf134);
|
|
58
|
-
$parcel$export($ce546cd73efa5b9e$exports, "makeShared", () => $ce546cd73efa5b9e$export$df9eb3e75aa27a22);
|
|
59
|
-
$parcel$export($ce546cd73efa5b9e$exports, "File", () => $ce546cd73efa5b9e$export$b6afa8811b7e644e);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var $a29f1902b85e3e69$exports = {};
|
|
65
|
-
$a29f1902b85e3e69$exports = JSON.parse("{\"name\":\"@atlaspack/fs\",\"version\":\"2.14.5-dev.73+84eec3484\",\"description\":\"Blazing fast, zero configuration web application bundler\",\"license\":\"(MIT OR Apache-2.0)\",\"publishConfig\":{\"access\":\"public\"},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/atlassian-labs/atlaspack.git\"},\"main\":\"lib/index.js\",\"source\":\"src/index.js\",\"types\":\"index.d.ts\",\"engines\":{\"node\":\">= 16.0.0\"},\"targets\":{\"types\":false,\"main\":{\"includeNodeModules\":{\"@atlaspack/build-cache\":false,\"@atlaspack/diagnostic\":false,\"@atlaspack/feature-flags\":false,\"@atlaspack/logger\":false,\"@atlaspack/rust\":false,\"@atlaspack/types-internal\":false,\"@atlaspack/utils\":false,\"@atlaspack/watcher-watchman-js\":false,\"@parcel/watcher\":false,\"@atlaspack/workers\":false}},\"browser\":{\"includeNodeModules\":{\"@atlaspack/build-cache\":false,\"@atlaspack/diagnostic\":false,\"@atlaspack/feature-flags\":false,\"@atlaspack/logger\":false,\"@atlaspack/rust\":false,\"@atlaspack/types-internal\":false,\"@atlaspack/utils\":false,\"@atlaspack/watcher-watchman-js\":false,\"@parcel/watcher\":false,\"@atlaspack/workers\":false}}},\"scripts\":{\"build-ts\":\"mkdir -p lib && flow-to-ts src/types.js > lib/types.d.ts\",\"check-ts\":\"tsc --noEmit index.d.ts\"},\"dependencies\":{\"@atlaspack/build-cache\":\"2.13.3-dev.141+84eec3484\",\"@atlaspack/feature-flags\":\"2.14.1-dev.141+84eec3484\",\"@atlaspack/logger\":\"2.14.5-dev.73+84eec3484\",\"@atlaspack/rust\":\"3.2.1-dev.73+84eec3484\",\"@atlaspack/types-internal\":\"2.14.1-dev.141+84eec3484\",\"@atlaspack/utils\":\"2.14.5-dev.73+84eec3484\",\"@atlaspack/workers\":\"2.14.5-dev.73+84eec3484\",\"@parcel/watcher\":\"^2.0.7\"},\"devDependencies\":{\"@atlaspack/watcher-watchman-js\":\"2.14.5-dev.73+84eec3484\",\"graceful-fs\":\"^4.2.4\",\"ncp\":\"^2.0.0\",\"nullthrows\":\"^1.1.1\",\"utility-types\":\"^3.10.0\"},\"browser\":{\"@atlaspack/fs\":\"./lib/browser.js\",\"./src/NodeFS.js\":\"./src/NodeFS.browser.js\"},\"type\":\"commonjs\",\"gitHead\":\"84eec348413c647de4872f902c4bc8ff54c347f3\"}");
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var $500746ffcc30dcc7$exports = {};
|
|
70
|
-
'use strict';
|
|
71
|
-
function $500746ffcc30dcc7$var$nullthrows(x, message) {
|
|
72
|
-
if (x != null) return x;
|
|
73
|
-
var error = new Error(message !== undefined ? message : 'Got unexpected ' + x);
|
|
74
|
-
error.framesToPop = 1; // Skip nullthrows's own stack frame.
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
$500746ffcc30dcc7$exports = $500746ffcc30dcc7$var$nullthrows;
|
|
78
|
-
$500746ffcc30dcc7$exports.default = $500746ffcc30dcc7$var$nullthrows;
|
|
79
|
-
Object.defineProperty($500746ffcc30dcc7$exports, '__esModule', {
|
|
80
|
-
value: true
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
function $7f6bcebe3ce84296$export$4c6d088a7d7f9947(fs, moduleName, dir) {
|
|
87
|
-
let { root: root } = (0, ($parcel$interopDefault($jF595$path))).parse(dir);
|
|
88
|
-
while(dir !== root){
|
|
89
|
-
// Skip node_modules directories
|
|
90
|
-
if ((0, ($parcel$interopDefault($jF595$path))).basename(dir) === 'node_modules') dir = (0, ($parcel$interopDefault($jF595$path))).dirname(dir);
|
|
91
|
-
try {
|
|
92
|
-
let moduleDir = (0, ($parcel$interopDefault($jF595$path))).join(dir, 'node_modules', moduleName);
|
|
93
|
-
let stats = fs.statSync(moduleDir);
|
|
94
|
-
if (stats.isDirectory()) return moduleDir;
|
|
95
|
-
} catch (err) {
|
|
96
|
-
// ignore
|
|
97
|
-
}
|
|
98
|
-
// Move up a directory
|
|
99
|
-
dir = (0, ($parcel$interopDefault($jF595$path))).dirname(dir);
|
|
100
|
-
}
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
function $7f6bcebe3ce84296$export$d51a93c758976388(fs, fileNames, dir, root) {
|
|
104
|
-
let { root: pathRoot } = (0, ($parcel$interopDefault($jF595$path))).parse(dir);
|
|
105
|
-
// eslint-disable-next-line no-constant-condition
|
|
106
|
-
while(true){
|
|
107
|
-
if ((0, ($parcel$interopDefault($jF595$path))).basename(dir) === 'node_modules') return null;
|
|
108
|
-
for (const fileName of fileNames){
|
|
109
|
-
let filePath = (0, ($parcel$interopDefault($jF595$path))).join(dir, fileName);
|
|
110
|
-
try {
|
|
111
|
-
if (fs.statSync(filePath).isFile()) return filePath;
|
|
112
|
-
} catch (err) {
|
|
113
|
-
// ignore
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (dir === root || dir === pathRoot) break;
|
|
117
|
-
dir = (0, ($parcel$interopDefault($jF595$path))).dirname(dir);
|
|
118
|
-
}
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
function $7f6bcebe3ce84296$export$64df6e3182fd5b2d(fs, filePaths) {
|
|
122
|
-
for (let filePath of filePaths)try {
|
|
123
|
-
if (fs.statSync(filePath).isFile()) return filePath;
|
|
124
|
-
} catch (err) {
|
|
125
|
-
// ignore
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
var $ce546cd73efa5b9e$require$Buffer = $jF595$buffer.Buffer;
|
|
132
|
-
const $ce546cd73efa5b9e$var$instances = new Map();
|
|
133
|
-
let $ce546cd73efa5b9e$var$id = 0;
|
|
134
|
-
class $ce546cd73efa5b9e$export$3048eb7ec07c2c4e {
|
|
135
|
-
_numWorkerInstances = 0;
|
|
136
|
-
_workerRegisterResolves = [];
|
|
137
|
-
_emitter = new (0, ($parcel$interopDefault($jF595$events)))();
|
|
138
|
-
constructor(workerFarm){
|
|
139
|
-
this.farm = workerFarm;
|
|
140
|
-
this._cwd = (0, ($parcel$interopDefault($jF595$path))).resolve((0, ($parcel$interopDefault($jF595$path))).sep);
|
|
141
|
-
this.dirs = new Map([
|
|
142
|
-
[
|
|
143
|
-
this._cwd,
|
|
144
|
-
new $ce546cd73efa5b9e$var$Directory()
|
|
145
|
-
]
|
|
146
|
-
]);
|
|
147
|
-
this.files = new Map();
|
|
148
|
-
this.symlinks = new Map();
|
|
149
|
-
this.watchers = new Map();
|
|
150
|
-
this.events = [];
|
|
151
|
-
this.id = $ce546cd73efa5b9e$var$id++;
|
|
152
|
-
this._workerHandles = [];
|
|
153
|
-
this._eventQueue = [];
|
|
154
|
-
$ce546cd73efa5b9e$var$instances.set(this.id, this);
|
|
155
|
-
this._emitter.on('allWorkersRegistered', ()=>{
|
|
156
|
-
for (let resolve of this._workerRegisterResolves)resolve();
|
|
157
|
-
this._workerRegisterResolves = [];
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
static deserialize(opts) {
|
|
161
|
-
let existing = $ce546cd73efa5b9e$var$instances.get(opts.id);
|
|
162
|
-
if (existing != null) {
|
|
163
|
-
// Correct the count of worker instances since serialization assumes a new instance is created
|
|
164
|
-
(0, ($parcel$interopDefault($jF595$atlaspackworkers))).getWorkerApi().runHandle(opts.handle, [
|
|
165
|
-
'decrementWorkerInstance',
|
|
166
|
-
[]
|
|
167
|
-
]);
|
|
168
|
-
return existing;
|
|
169
|
-
}
|
|
170
|
-
let fs = new $ce546cd73efa5b9e$var$WorkerFS(opts.id, (0, (/*@__PURE__*/$parcel$interopDefault($500746ffcc30dcc7$exports)))(opts.handle));
|
|
171
|
-
fs.dirs = opts.dirs;
|
|
172
|
-
fs.files = opts.files;
|
|
173
|
-
fs.symlinks = opts.symlinks;
|
|
174
|
-
return fs;
|
|
175
|
-
}
|
|
176
|
-
serialize() {
|
|
177
|
-
if (!this.handle) this.handle = this.farm.createReverseHandle((fn, args)=>{
|
|
178
|
-
// $FlowFixMe
|
|
179
|
-
return this[fn](...args);
|
|
180
|
-
});
|
|
181
|
-
// If a worker instance already exists, it will decrement this number
|
|
182
|
-
this._numWorkerInstances++;
|
|
183
|
-
return {
|
|
184
|
-
$$raw: false,
|
|
185
|
-
id: this.id,
|
|
186
|
-
handle: this.handle,
|
|
187
|
-
dirs: this.dirs,
|
|
188
|
-
files: this.files,
|
|
189
|
-
symlinks: this.symlinks
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
decrementWorkerInstance() {
|
|
193
|
-
this._numWorkerInstances--;
|
|
194
|
-
if (this._numWorkerInstances === this._workerHandles.length) this._emitter.emit('allWorkersRegistered');
|
|
195
|
-
}
|
|
196
|
-
cwd() {
|
|
197
|
-
return this._cwd;
|
|
198
|
-
}
|
|
199
|
-
chdir(dir) {
|
|
200
|
-
this._cwd = dir;
|
|
201
|
-
}
|
|
202
|
-
_normalizePath(filePath, realpath = true) {
|
|
203
|
-
filePath = (0, ($parcel$interopDefault($jF595$path))).normalize(filePath);
|
|
204
|
-
if (!filePath.startsWith(this.cwd())) filePath = (0, ($parcel$interopDefault($jF595$path))).resolve(this.cwd(), filePath);
|
|
205
|
-
// get realpath by following symlinks
|
|
206
|
-
if (realpath) {
|
|
207
|
-
let { root: root, dir: dir, base: base } = (0, ($parcel$interopDefault($jF595$path))).parse(filePath);
|
|
208
|
-
let parts = dir.slice(root.length).split((0, ($parcel$interopDefault($jF595$path))).sep).concat(base);
|
|
209
|
-
let res = root;
|
|
210
|
-
for (let part of parts){
|
|
211
|
-
res = (0, ($parcel$interopDefault($jF595$path))).join(res, part);
|
|
212
|
-
let symlink = this.symlinks.get(res);
|
|
213
|
-
if (symlink) res = symlink;
|
|
214
|
-
}
|
|
215
|
-
return res;
|
|
216
|
-
}
|
|
217
|
-
return filePath;
|
|
218
|
-
}
|
|
219
|
-
async writeFile(filePath, contents, options) {
|
|
220
|
-
filePath = this._normalizePath(filePath);
|
|
221
|
-
if (this.dirs.has(filePath)) throw new $ce546cd73efa5b9e$export$d414276624ebf134('EISDIR', filePath, 'is a directory');
|
|
222
|
-
let dir = (0, ($parcel$interopDefault($jF595$path))).dirname(filePath);
|
|
223
|
-
if (!this.dirs.has(dir)) throw new $ce546cd73efa5b9e$export$d414276624ebf134('ENOENT', dir, 'does not exist');
|
|
224
|
-
let buffer = $ce546cd73efa5b9e$export$df9eb3e75aa27a22(contents);
|
|
225
|
-
let file = this.files.get(filePath);
|
|
226
|
-
let mode = options && options.mode || 438;
|
|
227
|
-
if (file) {
|
|
228
|
-
file.write(buffer, mode);
|
|
229
|
-
this.files.set(filePath, file);
|
|
230
|
-
} else this.files.set(filePath, new $ce546cd73efa5b9e$export$b6afa8811b7e644e(buffer, mode));
|
|
231
|
-
await this._sendWorkerEvent({
|
|
232
|
-
type: 'writeFile',
|
|
233
|
-
path: filePath,
|
|
234
|
-
entry: this.files.get(filePath)
|
|
235
|
-
});
|
|
236
|
-
this._triggerEvent({
|
|
237
|
-
type: file ? 'update' : 'create',
|
|
238
|
-
path: filePath
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
// eslint-disable-next-line require-await
|
|
242
|
-
async readFile(filePath, encoding) {
|
|
243
|
-
return this.readFileSync(filePath, encoding);
|
|
244
|
-
}
|
|
245
|
-
readFileSync(filePath, encoding) {
|
|
246
|
-
filePath = this._normalizePath(filePath);
|
|
247
|
-
let file = this.files.get(filePath);
|
|
248
|
-
if (file == null) throw new $ce546cd73efa5b9e$export$d414276624ebf134('ENOENT', filePath, 'does not exist');
|
|
249
|
-
let buffer = file.read();
|
|
250
|
-
if (encoding) return buffer.toString(encoding);
|
|
251
|
-
return buffer;
|
|
252
|
-
}
|
|
253
|
-
async copyFile(source, destination) {
|
|
254
|
-
let contents = await this.readFile(source);
|
|
255
|
-
await this.writeFile(destination, contents);
|
|
256
|
-
}
|
|
257
|
-
statSync(filePath) {
|
|
258
|
-
filePath = this._normalizePath(filePath);
|
|
259
|
-
let dir = this.dirs.get(filePath);
|
|
260
|
-
if (dir) return dir.stat();
|
|
261
|
-
let file = this.files.get(filePath);
|
|
262
|
-
if (file == null) throw new $ce546cd73efa5b9e$export$d414276624ebf134('ENOENT', filePath, 'does not exist');
|
|
263
|
-
return file.stat();
|
|
264
|
-
}
|
|
265
|
-
// eslint-disable-next-line require-await
|
|
266
|
-
async stat(filePath) {
|
|
267
|
-
return this.statSync(filePath);
|
|
268
|
-
}
|
|
269
|
-
readdirSync(dir, opts) {
|
|
270
|
-
dir = this._normalizePath(dir);
|
|
271
|
-
if (!this.dirs.has(dir)) throw new $ce546cd73efa5b9e$export$d414276624ebf134('ENOENT', dir, 'does not exist');
|
|
272
|
-
if (!dir.endsWith((0, ($parcel$interopDefault($jF595$path))).sep)) dir += (0, ($parcel$interopDefault($jF595$path))).sep;
|
|
273
|
-
let res = [];
|
|
274
|
-
for (let [filePath, entry] of this.dirs){
|
|
275
|
-
if (filePath === dir) continue;
|
|
276
|
-
if (filePath.startsWith(dir) && filePath.indexOf((0, ($parcel$interopDefault($jF595$path))).sep, dir.length) === -1) {
|
|
277
|
-
let name = filePath.slice(dir.length);
|
|
278
|
-
if (opts?.withFileTypes) res.push(new $ce546cd73efa5b9e$var$Dirent(name, entry));
|
|
279
|
-
else res.push(name);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
for (let [filePath, entry] of this.files)if (filePath.startsWith(dir) && filePath.indexOf((0, ($parcel$interopDefault($jF595$path))).sep, dir.length) === -1) {
|
|
283
|
-
let name = filePath.slice(dir.length);
|
|
284
|
-
if (opts?.withFileTypes) res.push(new $ce546cd73efa5b9e$var$Dirent(name, entry));
|
|
285
|
-
else res.push(name);
|
|
286
|
-
}
|
|
287
|
-
for (let [from] of this.symlinks)if (from.startsWith(dir) && from.indexOf((0, ($parcel$interopDefault($jF595$path))).sep, dir.length) === -1) {
|
|
288
|
-
let name = from.slice(dir.length);
|
|
289
|
-
if (opts?.withFileTypes) res.push(new $ce546cd73efa5b9e$var$Dirent(name, {
|
|
290
|
-
mode: $ce546cd73efa5b9e$var$S_IFLNK
|
|
291
|
-
}));
|
|
292
|
-
else res.push(name);
|
|
293
|
-
}
|
|
294
|
-
return res;
|
|
295
|
-
}
|
|
296
|
-
// eslint-disable-next-line require-await
|
|
297
|
-
async readdir(dir, opts) {
|
|
298
|
-
return this.readdirSync(dir, opts);
|
|
299
|
-
}
|
|
300
|
-
async unlink(filePath) {
|
|
301
|
-
filePath = this._normalizePath(filePath);
|
|
302
|
-
if (!this.files.has(filePath) && !this.dirs.has(filePath)) throw new $ce546cd73efa5b9e$export$d414276624ebf134('ENOENT', filePath, 'does not exist');
|
|
303
|
-
this.files.delete(filePath);
|
|
304
|
-
this.dirs.delete(filePath);
|
|
305
|
-
this.watchers.delete(filePath);
|
|
306
|
-
await this._sendWorkerEvent({
|
|
307
|
-
type: 'unlink',
|
|
308
|
-
path: filePath
|
|
309
|
-
});
|
|
310
|
-
this._triggerEvent({
|
|
311
|
-
type: 'delete',
|
|
312
|
-
path: filePath
|
|
313
|
-
});
|
|
314
|
-
return Promise.resolve();
|
|
315
|
-
}
|
|
316
|
-
async mkdirp(dir) {
|
|
317
|
-
dir = this._normalizePath(dir);
|
|
318
|
-
if (this.dirs.has(dir)) return Promise.resolve();
|
|
319
|
-
if (this.files.has(dir)) throw new $ce546cd73efa5b9e$export$d414276624ebf134('ENOENT', dir, 'is not a directory');
|
|
320
|
-
let root = (0, ($parcel$interopDefault($jF595$path))).parse(dir).root;
|
|
321
|
-
while(dir !== root){
|
|
322
|
-
if (this.dirs.has(dir)) break;
|
|
323
|
-
this.dirs.set(dir, new $ce546cd73efa5b9e$var$Directory());
|
|
324
|
-
await this._sendWorkerEvent({
|
|
325
|
-
type: 'mkdir',
|
|
326
|
-
path: dir
|
|
327
|
-
});
|
|
328
|
-
this._triggerEvent({
|
|
329
|
-
type: 'create',
|
|
330
|
-
path: dir
|
|
331
|
-
});
|
|
332
|
-
dir = (0, ($parcel$interopDefault($jF595$path))).dirname(dir);
|
|
333
|
-
}
|
|
334
|
-
return Promise.resolve();
|
|
335
|
-
}
|
|
336
|
-
async rimraf(filePath) {
|
|
337
|
-
filePath = this._normalizePath(filePath);
|
|
338
|
-
if (this.dirs.has(filePath)) {
|
|
339
|
-
let dir = filePath + (0, ($parcel$interopDefault($jF595$path))).sep;
|
|
340
|
-
for (let filePath of this.files.keys())if (filePath.startsWith(dir)) {
|
|
341
|
-
this.files.delete(filePath);
|
|
342
|
-
await this._sendWorkerEvent({
|
|
343
|
-
type: 'unlink',
|
|
344
|
-
path: filePath
|
|
345
|
-
});
|
|
346
|
-
this._triggerEvent({
|
|
347
|
-
type: 'delete',
|
|
348
|
-
path: filePath
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
for (let dirPath of this.dirs.keys())if (dirPath.startsWith(dir)) {
|
|
352
|
-
this.dirs.delete(dirPath);
|
|
353
|
-
this.watchers.delete(dirPath);
|
|
354
|
-
await this._sendWorkerEvent({
|
|
355
|
-
type: 'unlink',
|
|
356
|
-
path: filePath
|
|
357
|
-
});
|
|
358
|
-
this._triggerEvent({
|
|
359
|
-
type: 'delete',
|
|
360
|
-
path: dirPath
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
for (let filePath of this.symlinks.keys())if (filePath.startsWith(dir)) {
|
|
364
|
-
this.symlinks.delete(filePath);
|
|
365
|
-
await this._sendWorkerEvent({
|
|
366
|
-
type: 'unlink',
|
|
367
|
-
path: filePath
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
this.dirs.delete(filePath);
|
|
371
|
-
await this._sendWorkerEvent({
|
|
372
|
-
type: 'unlink',
|
|
373
|
-
path: filePath
|
|
374
|
-
});
|
|
375
|
-
this._triggerEvent({
|
|
376
|
-
type: 'delete',
|
|
377
|
-
path: filePath
|
|
378
|
-
});
|
|
379
|
-
} else if (this.files.has(filePath)) {
|
|
380
|
-
this.files.delete(filePath);
|
|
381
|
-
await this._sendWorkerEvent({
|
|
382
|
-
type: 'unlink',
|
|
383
|
-
path: filePath
|
|
384
|
-
});
|
|
385
|
-
this._triggerEvent({
|
|
386
|
-
type: 'delete',
|
|
387
|
-
path: filePath
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
return Promise.resolve();
|
|
391
|
-
}
|
|
392
|
-
async ncp(source, destination) {
|
|
393
|
-
source = this._normalizePath(source);
|
|
394
|
-
if (this.dirs.has(source)) {
|
|
395
|
-
if (!this.dirs.has(destination)) {
|
|
396
|
-
this.dirs.set(destination, new $ce546cd73efa5b9e$var$Directory());
|
|
397
|
-
await this._sendWorkerEvent({
|
|
398
|
-
type: 'mkdir',
|
|
399
|
-
path: destination
|
|
400
|
-
});
|
|
401
|
-
this._triggerEvent({
|
|
402
|
-
type: 'create',
|
|
403
|
-
path: destination
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
let dir = source + (0, ($parcel$interopDefault($jF595$path))).sep;
|
|
407
|
-
for (let dirPath of this.dirs.keys())if (dirPath.startsWith(dir)) {
|
|
408
|
-
let destName = (0, ($parcel$interopDefault($jF595$path))).join(destination, dirPath.slice(dir.length));
|
|
409
|
-
if (!this.dirs.has(destName)) {
|
|
410
|
-
this.dirs.set(destName, new $ce546cd73efa5b9e$var$Directory());
|
|
411
|
-
await this._sendWorkerEvent({
|
|
412
|
-
type: 'mkdir',
|
|
413
|
-
path: destination
|
|
414
|
-
});
|
|
415
|
-
this._triggerEvent({
|
|
416
|
-
type: 'create',
|
|
417
|
-
path: destName
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
for (let [filePath, file] of this.files)if (filePath.startsWith(dir)) {
|
|
422
|
-
let destName = (0, ($parcel$interopDefault($jF595$path))).join(destination, filePath.slice(dir.length));
|
|
423
|
-
let exists = this.files.has(destName);
|
|
424
|
-
this.files.set(destName, file);
|
|
425
|
-
await this._sendWorkerEvent({
|
|
426
|
-
type: 'writeFile',
|
|
427
|
-
path: destName,
|
|
428
|
-
entry: file
|
|
429
|
-
});
|
|
430
|
-
this._triggerEvent({
|
|
431
|
-
type: exists ? 'update' : 'create',
|
|
432
|
-
path: destName
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
} else await this.copyFile(source, destination);
|
|
436
|
-
}
|
|
437
|
-
createReadStream(filePath) {
|
|
438
|
-
return new $ce546cd73efa5b9e$var$ReadStream(this, filePath);
|
|
439
|
-
}
|
|
440
|
-
createWriteStream(filePath, options) {
|
|
441
|
-
this.mkdirp((0, ($parcel$interopDefault($jF595$path))).dirname(filePath));
|
|
442
|
-
return new $ce546cd73efa5b9e$var$WriteStream(this, filePath, options);
|
|
443
|
-
}
|
|
444
|
-
realpathSync(filePath) {
|
|
445
|
-
return this._normalizePath(filePath);
|
|
446
|
-
}
|
|
447
|
-
// eslint-disable-next-line require-await
|
|
448
|
-
async realpath(filePath) {
|
|
449
|
-
return this.realpathSync(filePath);
|
|
450
|
-
}
|
|
451
|
-
async symlink(target, path) {
|
|
452
|
-
target = this._normalizePath(target);
|
|
453
|
-
path = this._normalizePath(path);
|
|
454
|
-
this.symlinks.set(path, target);
|
|
455
|
-
await this._sendWorkerEvent({
|
|
456
|
-
type: 'symlink',
|
|
457
|
-
path: path,
|
|
458
|
-
target: target
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
existsSync(filePath) {
|
|
462
|
-
filePath = this._normalizePath(filePath);
|
|
463
|
-
return this.files.has(filePath) || this.dirs.has(filePath);
|
|
464
|
-
}
|
|
465
|
-
// eslint-disable-next-line require-await
|
|
466
|
-
async exists(filePath) {
|
|
467
|
-
return this.existsSync(filePath);
|
|
468
|
-
}
|
|
469
|
-
_triggerEvent(event) {
|
|
470
|
-
this.events.push(event);
|
|
471
|
-
if (this.watchers.size === 0) return;
|
|
472
|
-
// Batch events
|
|
473
|
-
this._eventQueue.push(event);
|
|
474
|
-
clearTimeout(this._watcherTimer);
|
|
475
|
-
this._watcherTimer = setTimeout(()=>{
|
|
476
|
-
let events = this._eventQueue;
|
|
477
|
-
this._eventQueue = [];
|
|
478
|
-
for (let [dir, watchers] of this.watchers){
|
|
479
|
-
if (!dir.endsWith((0, ($parcel$interopDefault($jF595$path))).sep)) dir += (0, ($parcel$interopDefault($jF595$path))).sep;
|
|
480
|
-
const relevantEvents = events.filter((event)=>event.path.startsWith(dir));
|
|
481
|
-
if (relevantEvents.length > 0) for (let watcher of watchers)watcher.trigger(relevantEvents);
|
|
482
|
-
}
|
|
483
|
-
}, 50);
|
|
484
|
-
}
|
|
485
|
-
_registerWorker(handle) {
|
|
486
|
-
this._workerHandles.push(handle);
|
|
487
|
-
if (this._numWorkerInstances === this._workerHandles.length) this._emitter.emit('allWorkersRegistered');
|
|
488
|
-
}
|
|
489
|
-
async _sendWorkerEvent(event) {
|
|
490
|
-
// Wait for worker instances to register their handles
|
|
491
|
-
while(this._workerHandles.length < this._numWorkerInstances)await new Promise((resolve)=>this._workerRegisterResolves.push(resolve));
|
|
492
|
-
await Promise.all(this._workerHandles.map((workerHandle)=>this.farm.workerApi.runHandle(workerHandle, [
|
|
493
|
-
event
|
|
494
|
-
])));
|
|
495
|
-
}
|
|
496
|
-
watch(dir, fn, opts) {
|
|
497
|
-
dir = this._normalizePath(dir);
|
|
498
|
-
let watcher = new $ce546cd73efa5b9e$var$Watcher(fn, opts);
|
|
499
|
-
let watchers = this.watchers.get(dir);
|
|
500
|
-
if (!watchers) {
|
|
501
|
-
watchers = new Set();
|
|
502
|
-
this.watchers.set(dir, watchers);
|
|
503
|
-
}
|
|
504
|
-
watchers.add(watcher);
|
|
505
|
-
return Promise.resolve({
|
|
506
|
-
unsubscribe: ()=>{
|
|
507
|
-
watchers = (0, (/*@__PURE__*/$parcel$interopDefault($500746ffcc30dcc7$exports)))(watchers);
|
|
508
|
-
watchers.delete(watcher);
|
|
509
|
-
if (watchers.size === 0) this.watchers.delete(dir);
|
|
510
|
-
return Promise.resolve();
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
}
|
|
514
|
-
async getEventsSince(dir, snapshot, opts) {
|
|
515
|
-
let contents = await this.readFile(snapshot, 'utf8');
|
|
516
|
-
let len = Number(contents);
|
|
517
|
-
let events = this.events.slice(len);
|
|
518
|
-
let ignore = opts.ignore;
|
|
519
|
-
if (ignore) events = events.filter((event)=>!ignore.some((i)=>event.path.startsWith(i + (0, ($parcel$interopDefault($jF595$path))).sep)));
|
|
520
|
-
return events;
|
|
521
|
-
}
|
|
522
|
-
async writeSnapshot(dir, snapshot) {
|
|
523
|
-
await this.mkdirp((0, ($parcel$interopDefault($jF595$path))).dirname(snapshot));
|
|
524
|
-
await this.writeFile(snapshot, '' + this.events.length);
|
|
525
|
-
}
|
|
526
|
-
findAncestorFile(fileNames, fromDir, root) {
|
|
527
|
-
return (0, $7f6bcebe3ce84296$export$d51a93c758976388)(this, fileNames, fromDir, root);
|
|
528
|
-
}
|
|
529
|
-
findNodeModule(moduleName, fromDir) {
|
|
530
|
-
return (0, $7f6bcebe3ce84296$export$4c6d088a7d7f9947)(this, moduleName, fromDir);
|
|
531
|
-
}
|
|
532
|
-
findFirstFile(filePaths) {
|
|
533
|
-
return (0, $7f6bcebe3ce84296$export$64df6e3182fd5b2d)(this, filePaths);
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
class $ce546cd73efa5b9e$var$Watcher {
|
|
537
|
-
constructor(fn, options){
|
|
538
|
-
this.fn = fn;
|
|
539
|
-
this.options = options;
|
|
540
|
-
}
|
|
541
|
-
trigger(events) {
|
|
542
|
-
let ignore = this.options.ignore;
|
|
543
|
-
if (ignore) events = events.filter((event)=>!ignore.some((i)=>event.path.startsWith(i + (0, ($parcel$interopDefault($jF595$path))).sep)));
|
|
544
|
-
if (events.length > 0) this.fn(null, events);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
class $ce546cd73efa5b9e$export$d414276624ebf134 extends Error {
|
|
548
|
-
constructor(code, path, message){
|
|
549
|
-
super(`${code}: ${path} ${message}`);
|
|
550
|
-
this.name = 'FSError';
|
|
551
|
-
this.code = code;
|
|
552
|
-
this.path = path;
|
|
553
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
class $ce546cd73efa5b9e$var$ReadStream extends (0, $jF595$stream.Readable) {
|
|
557
|
-
constructor(fs, filePath){
|
|
558
|
-
super();
|
|
559
|
-
this.fs = fs;
|
|
560
|
-
this.filePath = filePath;
|
|
561
|
-
this.reading = false;
|
|
562
|
-
this.bytesRead = 0;
|
|
563
|
-
}
|
|
564
|
-
_read() {
|
|
565
|
-
if (this.reading) return;
|
|
566
|
-
this.reading = true;
|
|
567
|
-
this.fs.readFile(this.filePath).then((res)=>{
|
|
568
|
-
this.bytesRead += res.byteLength;
|
|
569
|
-
this.push(res);
|
|
570
|
-
this.push(null);
|
|
571
|
-
}, (err)=>{
|
|
572
|
-
this.emit('error', err);
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
class $ce546cd73efa5b9e$var$WriteStream extends (0, $jF595$stream.Writable) {
|
|
577
|
-
constructor(fs, filePath, options){
|
|
578
|
-
super({
|
|
579
|
-
emitClose: true,
|
|
580
|
-
autoDestroy: true
|
|
581
|
-
});
|
|
582
|
-
this.fs = fs;
|
|
583
|
-
this.filePath = filePath;
|
|
584
|
-
this.options = options;
|
|
585
|
-
this.buffer = $ce546cd73efa5b9e$require$Buffer.alloc(0);
|
|
586
|
-
}
|
|
587
|
-
_write(chunk, encoding, callback) {
|
|
588
|
-
let c = typeof chunk === 'string' ? $ce546cd73efa5b9e$require$Buffer.from(chunk, encoding) : chunk;
|
|
589
|
-
this.buffer = $ce546cd73efa5b9e$require$Buffer.concat([
|
|
590
|
-
this.buffer,
|
|
591
|
-
c
|
|
592
|
-
]);
|
|
593
|
-
callback();
|
|
594
|
-
}
|
|
595
|
-
_final(callback) {
|
|
596
|
-
this.fs.writeFile(this.filePath, this.buffer, this.options).then(callback).catch(callback);
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
const $ce546cd73efa5b9e$var$S_IFREG = 32768;
|
|
600
|
-
const $ce546cd73efa5b9e$var$S_IFDIR = 16384;
|
|
601
|
-
const $ce546cd73efa5b9e$var$S_IFLNK = 40960;
|
|
602
|
-
const $ce546cd73efa5b9e$var$S_IFMT = 61440;
|
|
603
|
-
class $ce546cd73efa5b9e$var$Entry {
|
|
604
|
-
constructor(mode){
|
|
605
|
-
this.mode = mode;
|
|
606
|
-
let now = Date.now();
|
|
607
|
-
this.atime = now;
|
|
608
|
-
this.mtime = now;
|
|
609
|
-
this.ctime = now;
|
|
610
|
-
this.birthtime = now;
|
|
611
|
-
}
|
|
612
|
-
access() {
|
|
613
|
-
let now = Date.now();
|
|
614
|
-
this.atime = now;
|
|
615
|
-
this.ctime = now;
|
|
616
|
-
}
|
|
617
|
-
modify(mode) {
|
|
618
|
-
let now = Date.now();
|
|
619
|
-
this.mtime = now;
|
|
620
|
-
this.ctime = now;
|
|
621
|
-
this.mode = mode;
|
|
622
|
-
}
|
|
623
|
-
getSize() {
|
|
624
|
-
return 0;
|
|
625
|
-
}
|
|
626
|
-
stat() {
|
|
627
|
-
return new $ce546cd73efa5b9e$var$Stat(this);
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
class $ce546cd73efa5b9e$var$Stat {
|
|
631
|
-
dev = 0;
|
|
632
|
-
ino = 0;
|
|
633
|
-
nlink = 0;
|
|
634
|
-
uid = 0;
|
|
635
|
-
gid = 0;
|
|
636
|
-
rdev = 0;
|
|
637
|
-
blksize = 0;
|
|
638
|
-
blocks = 0;
|
|
639
|
-
constructor(entry){
|
|
640
|
-
this.mode = entry.mode;
|
|
641
|
-
this.size = entry.getSize();
|
|
642
|
-
this.atimeMs = entry.atime;
|
|
643
|
-
this.mtimeMs = entry.mtime;
|
|
644
|
-
this.ctimeMs = entry.ctime;
|
|
645
|
-
this.birthtimeMs = entry.birthtime;
|
|
646
|
-
this.atime = new Date(entry.atime);
|
|
647
|
-
this.mtime = new Date(entry.mtime);
|
|
648
|
-
this.ctime = new Date(entry.ctime);
|
|
649
|
-
this.birthtime = new Date(entry.birthtime);
|
|
650
|
-
}
|
|
651
|
-
isFile() {
|
|
652
|
-
return Boolean(this.mode & $ce546cd73efa5b9e$var$S_IFREG);
|
|
653
|
-
}
|
|
654
|
-
isDirectory() {
|
|
655
|
-
return Boolean(this.mode & $ce546cd73efa5b9e$var$S_IFDIR);
|
|
656
|
-
}
|
|
657
|
-
isBlockDevice() {
|
|
658
|
-
return false;
|
|
659
|
-
}
|
|
660
|
-
isCharacterDevice() {
|
|
661
|
-
return false;
|
|
662
|
-
}
|
|
663
|
-
isSymbolicLink() {
|
|
664
|
-
return false;
|
|
665
|
-
}
|
|
666
|
-
isFIFO() {
|
|
667
|
-
return false;
|
|
668
|
-
}
|
|
669
|
-
isSocket() {
|
|
670
|
-
return false;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
class $ce546cd73efa5b9e$var$Dirent {
|
|
674
|
-
#mode;
|
|
675
|
-
constructor(name, entry){
|
|
676
|
-
this.name = name;
|
|
677
|
-
this.#mode = entry.mode;
|
|
678
|
-
}
|
|
679
|
-
isFile() {
|
|
680
|
-
return (this.#mode & $ce546cd73efa5b9e$var$S_IFMT) === $ce546cd73efa5b9e$var$S_IFREG;
|
|
681
|
-
}
|
|
682
|
-
isDirectory() {
|
|
683
|
-
return (this.#mode & $ce546cd73efa5b9e$var$S_IFMT) === $ce546cd73efa5b9e$var$S_IFDIR;
|
|
684
|
-
}
|
|
685
|
-
isBlockDevice() {
|
|
686
|
-
return false;
|
|
687
|
-
}
|
|
688
|
-
isCharacterDevice() {
|
|
689
|
-
return false;
|
|
690
|
-
}
|
|
691
|
-
isSymbolicLink() {
|
|
692
|
-
return (this.#mode & $ce546cd73efa5b9e$var$S_IFMT) === $ce546cd73efa5b9e$var$S_IFLNK;
|
|
693
|
-
}
|
|
694
|
-
isFIFO() {
|
|
695
|
-
return false;
|
|
696
|
-
}
|
|
697
|
-
isSocket() {
|
|
698
|
-
return false;
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
class $ce546cd73efa5b9e$export$b6afa8811b7e644e extends $ce546cd73efa5b9e$var$Entry {
|
|
702
|
-
constructor(buffer, mode){
|
|
703
|
-
super($ce546cd73efa5b9e$var$S_IFREG | mode);
|
|
704
|
-
this.buffer = buffer;
|
|
705
|
-
}
|
|
706
|
-
read() {
|
|
707
|
-
super.access();
|
|
708
|
-
return $ce546cd73efa5b9e$require$Buffer.from(this.buffer);
|
|
709
|
-
}
|
|
710
|
-
write(buffer, mode) {
|
|
711
|
-
super.modify($ce546cd73efa5b9e$var$S_IFREG | mode);
|
|
712
|
-
this.buffer = buffer;
|
|
713
|
-
}
|
|
714
|
-
getSize() {
|
|
715
|
-
return this.buffer.byteLength;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
class $ce546cd73efa5b9e$var$Directory extends $ce546cd73efa5b9e$var$Entry {
|
|
719
|
-
constructor(){
|
|
720
|
-
super($ce546cd73efa5b9e$var$S_IFDIR);
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
function $ce546cd73efa5b9e$export$df9eb3e75aa27a22(contents) {
|
|
724
|
-
if (typeof contents !== 'string' && contents.buffer instanceof (0, $jF595$atlaspackutils.SharedBuffer)) return contents;
|
|
725
|
-
let contentsBuffer = contents;
|
|
726
|
-
// For the polyfilled buffer module, it's faster to always convert once so that the subsequent
|
|
727
|
-
// operations are fast (.byteLength and using .set instead of .write)
|
|
728
|
-
contentsBuffer = contentsBuffer instanceof $ce546cd73efa5b9e$require$Buffer ? contentsBuffer : $ce546cd73efa5b9e$require$Buffer.from(contentsBuffer);
|
|
729
|
-
let length = $ce546cd73efa5b9e$require$Buffer.byteLength(contentsBuffer);
|
|
730
|
-
let shared = new (0, $jF595$atlaspackutils.SharedBuffer)(length);
|
|
731
|
-
let buffer = $ce546cd73efa5b9e$require$Buffer.from(shared);
|
|
732
|
-
if (length > 0) {
|
|
733
|
-
if (typeof contentsBuffer === 'string') buffer.write(contentsBuffer);
|
|
734
|
-
else buffer.set(contentsBuffer);
|
|
735
|
-
}
|
|
736
|
-
return buffer;
|
|
737
|
-
}
|
|
738
|
-
class $ce546cd73efa5b9e$var$WorkerFS extends $ce546cd73efa5b9e$export$3048eb7ec07c2c4e {
|
|
739
|
-
constructor(id, handle){
|
|
740
|
-
// TODO Make this not a subclass
|
|
741
|
-
// $FlowFixMe
|
|
742
|
-
super();
|
|
743
|
-
this.id = id;
|
|
744
|
-
this.handleFn = (methodName, args)=>(0, ($parcel$interopDefault($jF595$atlaspackworkers))).getWorkerApi().runHandle(handle, [
|
|
745
|
-
methodName,
|
|
746
|
-
args
|
|
747
|
-
]);
|
|
748
|
-
this.handleFn('_registerWorker', [
|
|
749
|
-
(0, ($parcel$interopDefault($jF595$atlaspackworkers))).getWorkerApi().createReverseHandle((event)=>{
|
|
750
|
-
switch(event.type){
|
|
751
|
-
case 'writeFile':
|
|
752
|
-
this.files.set(event.path, event.entry);
|
|
753
|
-
break;
|
|
754
|
-
case 'unlink':
|
|
755
|
-
this.files.delete(event.path);
|
|
756
|
-
this.dirs.delete(event.path);
|
|
757
|
-
this.symlinks.delete(event.path);
|
|
758
|
-
break;
|
|
759
|
-
case 'mkdir':
|
|
760
|
-
this.dirs.set(event.path, new $ce546cd73efa5b9e$var$Directory());
|
|
761
|
-
break;
|
|
762
|
-
case 'symlink':
|
|
763
|
-
this.symlinks.set(event.path, event.target);
|
|
764
|
-
break;
|
|
765
|
-
}
|
|
766
|
-
})
|
|
767
|
-
]);
|
|
768
|
-
}
|
|
769
|
-
static deserialize(opts) {
|
|
770
|
-
return (0, (/*@__PURE__*/$parcel$interopDefault($500746ffcc30dcc7$exports)))($ce546cd73efa5b9e$var$instances.get(opts.id));
|
|
771
|
-
}
|
|
772
|
-
serialize() {
|
|
773
|
-
// $FlowFixMe
|
|
774
|
-
return {
|
|
775
|
-
id: this.id
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
writeFile(filePath, contents, options) {
|
|
779
|
-
super.writeFile(filePath, contents, options);
|
|
780
|
-
let buffer = $ce546cd73efa5b9e$export$df9eb3e75aa27a22(contents);
|
|
781
|
-
return this.handleFn('writeFile', [
|
|
782
|
-
filePath,
|
|
783
|
-
buffer,
|
|
784
|
-
options
|
|
785
|
-
]);
|
|
786
|
-
}
|
|
787
|
-
unlink(filePath) {
|
|
788
|
-
super.unlink(filePath);
|
|
789
|
-
return this.handleFn('unlink', [
|
|
790
|
-
filePath
|
|
791
|
-
]);
|
|
792
|
-
}
|
|
793
|
-
mkdirp(dir) {
|
|
794
|
-
super.mkdirp(dir);
|
|
795
|
-
return this.handleFn('mkdirp', [
|
|
796
|
-
dir
|
|
797
|
-
]);
|
|
798
|
-
}
|
|
799
|
-
rimraf(filePath) {
|
|
800
|
-
super.rimraf(filePath);
|
|
801
|
-
return this.handleFn('rimraf', [
|
|
802
|
-
filePath
|
|
803
|
-
]);
|
|
804
|
-
}
|
|
805
|
-
ncp(source, destination) {
|
|
806
|
-
super.ncp(source, destination);
|
|
807
|
-
return this.handleFn('ncp', [
|
|
808
|
-
source,
|
|
809
|
-
destination
|
|
810
|
-
]);
|
|
811
|
-
}
|
|
812
|
-
symlink(target, path) {
|
|
813
|
-
super.symlink(target, path);
|
|
814
|
-
return this.handleFn('symlink', [
|
|
815
|
-
target,
|
|
816
|
-
path
|
|
817
|
-
]);
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
(0, $jF595$atlaspackbuildcache.registerSerializableClass)(`${(0, (/*@__PURE__*/$parcel$interopDefault($a29f1902b85e3e69$exports))).version}:MemoryFS`, $ce546cd73efa5b9e$export$3048eb7ec07c2c4e);
|
|
821
|
-
(0, $jF595$atlaspackbuildcache.registerSerializableClass)(`${(0, (/*@__PURE__*/$parcel$interopDefault($a29f1902b85e3e69$exports))).version}:WorkerFS`, $ce546cd73efa5b9e$var$WorkerFS);
|
|
822
|
-
(0, $jF595$atlaspackbuildcache.registerSerializableClass)(`${(0, (/*@__PURE__*/$parcel$interopDefault($a29f1902b85e3e69$exports))).version}:Stat`, $ce546cd73efa5b9e$var$Stat);
|
|
823
|
-
(0, $jF595$atlaspackbuildcache.registerSerializableClass)(`${(0, (/*@__PURE__*/$parcel$interopDefault($a29f1902b85e3e69$exports))).version}:File`, $ce546cd73efa5b9e$export$b6afa8811b7e644e);
|
|
824
|
-
(0, $jF595$atlaspackbuildcache.registerSerializableClass)(`${(0, (/*@__PURE__*/$parcel$interopDefault($a29f1902b85e3e69$exports))).version}:Directory`, $ce546cd73efa5b9e$var$Directory);
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
var $e75797f2a6f0115f$exports = {};
|
|
828
|
-
|
|
829
|
-
$parcel$export($e75797f2a6f0115f$exports, "OverlayFS", () => $e75797f2a6f0115f$export$5963299e2424ca1c);
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
class $e75797f2a6f0115f$export$5963299e2424ca1c {
|
|
838
|
-
deleted = new Set();
|
|
839
|
-
constructor(workerFarmOrFS, readable){
|
|
840
|
-
if (workerFarmOrFS instanceof (0, ($parcel$interopDefault($jF595$atlaspackworkers)))) this.writable = new (0, $ce546cd73efa5b9e$export$3048eb7ec07c2c4e)(workerFarmOrFS);
|
|
841
|
-
else this.writable = workerFarmOrFS;
|
|
842
|
-
this.readable = readable;
|
|
843
|
-
this._cwd = readable.cwd();
|
|
844
|
-
}
|
|
845
|
-
static deserialize(opts) {
|
|
846
|
-
let fs = new $e75797f2a6f0115f$export$5963299e2424ca1c(opts.writable, opts.readable);
|
|
847
|
-
if (opts.deleted != null) fs.deleted = opts.deleted;
|
|
848
|
-
return fs;
|
|
849
|
-
}
|
|
850
|
-
serialize() {
|
|
851
|
-
return {
|
|
852
|
-
$$raw: false,
|
|
853
|
-
writable: this.writable,
|
|
854
|
-
readable: this.readable,
|
|
855
|
-
deleted: this.deleted
|
|
856
|
-
};
|
|
857
|
-
}
|
|
858
|
-
_deletedThrows(filePath) {
|
|
859
|
-
filePath = this._normalizePath(filePath);
|
|
860
|
-
if (this.deleted.has(filePath)) throw new $e75797f2a6f0115f$var$FSError('ENOENT', filePath, 'does not exist');
|
|
861
|
-
return filePath;
|
|
862
|
-
}
|
|
863
|
-
_checkExists(filePath) {
|
|
864
|
-
filePath = this._deletedThrows(filePath);
|
|
865
|
-
if (!this.existsSync(filePath)) throw new $e75797f2a6f0115f$var$FSError('ENOENT', filePath, 'does not exist');
|
|
866
|
-
return filePath;
|
|
867
|
-
}
|
|
868
|
-
_isSymlink(filePath) {
|
|
869
|
-
filePath = this._normalizePath(filePath);
|
|
870
|
-
// Check the parts of the path to see if any are symlinks.
|
|
871
|
-
let { root: root, dir: dir, base: base } = (0, ($parcel$interopDefault($jF595$path))).parse(filePath);
|
|
872
|
-
let segments = dir.slice(root.length).split((0, ($parcel$interopDefault($jF595$path))).sep).concat(base);
|
|
873
|
-
while(segments.length){
|
|
874
|
-
filePath = (0, ($parcel$interopDefault($jF595$path))).join(root, ...segments);
|
|
875
|
-
let name = segments.pop();
|
|
876
|
-
if (this.deleted.has(filePath)) return false;
|
|
877
|
-
else if (this.writable instanceof (0, $ce546cd73efa5b9e$export$3048eb7ec07c2c4e) && this.writable.symlinks.has(filePath)) return true;
|
|
878
|
-
else {
|
|
879
|
-
// HACK: Atlaspack fs does not provide `lstatSync`,
|
|
880
|
-
// so we use `readdirSync` to check if the path is a symlink.
|
|
881
|
-
let parent = (0, ($parcel$interopDefault($jF595$path))).resolve(filePath, '..');
|
|
882
|
-
if (parent === filePath) return false;
|
|
883
|
-
try {
|
|
884
|
-
for (let dirent of this.readdirSync(parent, {
|
|
885
|
-
withFileTypes: true
|
|
886
|
-
})){
|
|
887
|
-
if (typeof dirent === 'string') break; // {withFileTypes: true} not supported
|
|
888
|
-
else if (dirent.name === name) {
|
|
889
|
-
if (dirent.isSymbolicLink()) return true;
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
} catch (e) {
|
|
893
|
-
if (e.code === 'ENOENT') return false;
|
|
894
|
-
throw e;
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
return false;
|
|
899
|
-
}
|
|
900
|
-
async _copyPathForWrite(filePath) {
|
|
901
|
-
filePath = await this._normalizePath(filePath);
|
|
902
|
-
let dirPath = (0, ($parcel$interopDefault($jF595$path))).dirname(filePath);
|
|
903
|
-
if (this.existsSync(dirPath) && !this.writable.existsSync(dirPath)) await this.writable.mkdirp(dirPath);
|
|
904
|
-
return filePath;
|
|
905
|
-
}
|
|
906
|
-
_normalizePath(filePath) {
|
|
907
|
-
return (0, ($parcel$interopDefault($jF595$path))).resolve(this.cwd(), filePath);
|
|
908
|
-
}
|
|
909
|
-
// eslint-disable-next-line require-await
|
|
910
|
-
async readFile(filePath, encoding) {
|
|
911
|
-
return this.readFileSync(filePath, encoding);
|
|
912
|
-
}
|
|
913
|
-
async writeFile(filePath, contents, options) {
|
|
914
|
-
filePath = await this._copyPathForWrite(filePath);
|
|
915
|
-
await this.writable.writeFile(filePath, contents, options);
|
|
916
|
-
this.deleted.delete(filePath);
|
|
917
|
-
}
|
|
918
|
-
async copyFile(source, destination) {
|
|
919
|
-
source = this._normalizePath(source);
|
|
920
|
-
destination = await this._copyPathForWrite(destination);
|
|
921
|
-
if (await this.writable.exists(source)) await this.writable.writeFile(destination, await this.writable.readFile(source));
|
|
922
|
-
else await this.writable.writeFile(destination, await this.readable.readFile(source));
|
|
923
|
-
this.deleted.delete(destination);
|
|
924
|
-
}
|
|
925
|
-
// eslint-disable-next-line require-await
|
|
926
|
-
async stat(filePath) {
|
|
927
|
-
return this.statSync(filePath);
|
|
928
|
-
}
|
|
929
|
-
async symlink(target, filePath) {
|
|
930
|
-
target = this._normalizePath(target);
|
|
931
|
-
filePath = this._normalizePath(filePath);
|
|
932
|
-
await this.writable.symlink(target, filePath);
|
|
933
|
-
this.deleted.delete(filePath);
|
|
934
|
-
}
|
|
935
|
-
async unlink(filePath) {
|
|
936
|
-
filePath = this._normalizePath(filePath);
|
|
937
|
-
let toDelete = [
|
|
938
|
-
filePath
|
|
939
|
-
];
|
|
940
|
-
if (this.writable instanceof (0, $ce546cd73efa5b9e$export$3048eb7ec07c2c4e) && this._isSymlink(filePath)) this.writable.symlinks.delete(filePath);
|
|
941
|
-
else if (this.statSync(filePath).isDirectory()) {
|
|
942
|
-
let stack = [
|
|
943
|
-
filePath
|
|
944
|
-
];
|
|
945
|
-
// Recursively add every descendant path to deleted.
|
|
946
|
-
while(stack.length){
|
|
947
|
-
let root = (0, (/*@__PURE__*/$parcel$interopDefault($500746ffcc30dcc7$exports)))(stack.pop());
|
|
948
|
-
for (let ent of this.readdirSync(root, {
|
|
949
|
-
withFileTypes: true
|
|
950
|
-
}))if (typeof ent === 'string') {
|
|
951
|
-
let childPath = (0, ($parcel$interopDefault($jF595$path))).join(root, ent);
|
|
952
|
-
toDelete.push(childPath);
|
|
953
|
-
if (this.statSync(childPath).isDirectory()) stack.push(childPath);
|
|
954
|
-
} else {
|
|
955
|
-
let childPath = (0, ($parcel$interopDefault($jF595$path))).join(root, ent.name);
|
|
956
|
-
toDelete.push(childPath);
|
|
957
|
-
if (ent.isDirectory()) stack.push(childPath);
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
try {
|
|
962
|
-
await this.writable.unlink(filePath);
|
|
963
|
-
} catch (e) {
|
|
964
|
-
if (e.code === 'ENOENT' && !this.readable.existsSync(filePath)) throw e;
|
|
965
|
-
}
|
|
966
|
-
for (let pathToDelete of toDelete)this.deleted.add(pathToDelete);
|
|
967
|
-
}
|
|
968
|
-
async mkdirp(dir) {
|
|
969
|
-
dir = this._normalizePath(dir);
|
|
970
|
-
await this.writable.mkdirp(dir);
|
|
971
|
-
if (this.deleted != null) {
|
|
972
|
-
let root = (0, ($parcel$interopDefault($jF595$path))).parse(dir).root;
|
|
973
|
-
while(dir !== root){
|
|
974
|
-
this.deleted.delete(dir);
|
|
975
|
-
dir = (0, ($parcel$interopDefault($jF595$path))).dirname(dir);
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
async rimraf(filePath) {
|
|
980
|
-
try {
|
|
981
|
-
await this.unlink(filePath);
|
|
982
|
-
} catch (e) {
|
|
983
|
-
// noop
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
// eslint-disable-next-line require-await
|
|
987
|
-
async ncp(source, destination) {
|
|
988
|
-
// TODO: Implement this correctly.
|
|
989
|
-
return this.writable.ncp(source, destination);
|
|
990
|
-
}
|
|
991
|
-
createReadStream(filePath, opts) {
|
|
992
|
-
filePath = this._deletedThrows(filePath);
|
|
993
|
-
if (this.writable.existsSync(filePath)) return this.writable.createReadStream(filePath, opts);
|
|
994
|
-
return this.readable.createReadStream(filePath, opts);
|
|
995
|
-
}
|
|
996
|
-
createWriteStream(path, opts) {
|
|
997
|
-
path = this._normalizePath(path);
|
|
998
|
-
this.deleted.delete(path);
|
|
999
|
-
return this.writable.createWriteStream(path, opts);
|
|
1000
|
-
}
|
|
1001
|
-
cwd() {
|
|
1002
|
-
return this._cwd;
|
|
1003
|
-
}
|
|
1004
|
-
chdir(path) {
|
|
1005
|
-
this._cwd = this._checkExists(path);
|
|
1006
|
-
}
|
|
1007
|
-
// eslint-disable-next-line require-await
|
|
1008
|
-
async realpath(filePath) {
|
|
1009
|
-
return this.realpathSync(filePath);
|
|
1010
|
-
}
|
|
1011
|
-
readFileSync(filePath, encoding) {
|
|
1012
|
-
filePath = this.realpathSync(filePath);
|
|
1013
|
-
try {
|
|
1014
|
-
// $FlowFixMe[incompatible-call]
|
|
1015
|
-
return this.writable.readFileSync(filePath, encoding);
|
|
1016
|
-
} catch (err) {
|
|
1017
|
-
// $FlowFixMe[incompatible-call]
|
|
1018
|
-
return this.readable.readFileSync(filePath, encoding);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
statSync(filePath) {
|
|
1022
|
-
filePath = this._normalizePath(filePath);
|
|
1023
|
-
try {
|
|
1024
|
-
return this.writable.statSync(filePath);
|
|
1025
|
-
} catch (e) {
|
|
1026
|
-
if (e.code === 'ENOENT' && this.existsSync(filePath)) return this.readable.statSync(filePath);
|
|
1027
|
-
throw e;
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
realpathSync(filePath) {
|
|
1031
|
-
filePath = this._deletedThrows(filePath);
|
|
1032
|
-
filePath = this._deletedThrows(this.writable.realpathSync(filePath));
|
|
1033
|
-
if (!this.writable.existsSync(filePath)) return this.readable.realpathSync(filePath);
|
|
1034
|
-
return filePath;
|
|
1035
|
-
}
|
|
1036
|
-
// eslint-disable-next-line require-await
|
|
1037
|
-
async exists(filePath) {
|
|
1038
|
-
return this.existsSync(filePath);
|
|
1039
|
-
}
|
|
1040
|
-
existsSync(filePath) {
|
|
1041
|
-
filePath = this._normalizePath(filePath);
|
|
1042
|
-
if (this.deleted.has(filePath)) return false;
|
|
1043
|
-
try {
|
|
1044
|
-
filePath = this.realpathSync(filePath);
|
|
1045
|
-
} catch (err) {
|
|
1046
|
-
if (err.code !== 'ENOENT') throw err;
|
|
1047
|
-
}
|
|
1048
|
-
if (this.deleted.has(filePath)) return false;
|
|
1049
|
-
return this.writable.existsSync(filePath) || this.readable.existsSync(filePath);
|
|
1050
|
-
}
|
|
1051
|
-
// eslint-disable-next-line require-await
|
|
1052
|
-
async readdir(path, opts) {
|
|
1053
|
-
return this.readdirSync(path, opts);
|
|
1054
|
-
}
|
|
1055
|
-
readdirSync(dir, opts) {
|
|
1056
|
-
dir = this.realpathSync(dir);
|
|
1057
|
-
// Read from both filesystems and merge the results
|
|
1058
|
-
let entries = new Map();
|
|
1059
|
-
try {
|
|
1060
|
-
for (let entry of this.writable.readdirSync(dir, opts)){
|
|
1061
|
-
let filePath = (0, ($parcel$interopDefault($jF595$path))).join(dir, entry.name ?? entry);
|
|
1062
|
-
if (this.deleted.has(filePath)) continue;
|
|
1063
|
-
entries.set(filePath, entry);
|
|
1064
|
-
}
|
|
1065
|
-
} catch {
|
|
1066
|
-
// noop
|
|
1067
|
-
}
|
|
1068
|
-
try {
|
|
1069
|
-
for (let entry of this.readable.readdirSync(dir, opts)){
|
|
1070
|
-
let filePath = (0, ($parcel$interopDefault($jF595$path))).join(dir, entry.name ?? entry);
|
|
1071
|
-
if (this.deleted.has(filePath)) continue;
|
|
1072
|
-
if (entries.has(filePath)) continue;
|
|
1073
|
-
entries.set(filePath, entry);
|
|
1074
|
-
}
|
|
1075
|
-
} catch {
|
|
1076
|
-
// noop
|
|
1077
|
-
}
|
|
1078
|
-
return Array.from(entries.values());
|
|
1079
|
-
}
|
|
1080
|
-
async watch(dir, fn, opts) {
|
|
1081
|
-
let writableSubscription = await this.writable.watch(dir, fn, opts);
|
|
1082
|
-
let readableSubscription = await this.readable.watch(dir, fn, opts);
|
|
1083
|
-
return {
|
|
1084
|
-
unsubscribe: async ()=>{
|
|
1085
|
-
await writableSubscription.unsubscribe();
|
|
1086
|
-
await readableSubscription.unsubscribe();
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
}
|
|
1090
|
-
async getEventsSince(dir, snapshot, opts) {
|
|
1091
|
-
let writableEvents = await this.writable.getEventsSince(dir, snapshot, opts);
|
|
1092
|
-
let readableEvents = await this.readable.getEventsSince(dir, snapshot, opts);
|
|
1093
|
-
return [
|
|
1094
|
-
...writableEvents,
|
|
1095
|
-
...readableEvents
|
|
1096
|
-
];
|
|
1097
|
-
}
|
|
1098
|
-
async writeSnapshot(dir, snapshot, opts) {
|
|
1099
|
-
await this.writable.writeSnapshot(dir, snapshot, opts);
|
|
1100
|
-
}
|
|
1101
|
-
findAncestorFile(fileNames, fromDir, root) {
|
|
1102
|
-
return (0, $7f6bcebe3ce84296$export$d51a93c758976388)(this, fileNames, fromDir, root);
|
|
1103
|
-
}
|
|
1104
|
-
findNodeModule(moduleName, fromDir) {
|
|
1105
|
-
return (0, $7f6bcebe3ce84296$export$4c6d088a7d7f9947)(this, moduleName, fromDir);
|
|
1106
|
-
}
|
|
1107
|
-
findFirstFile(filePaths) {
|
|
1108
|
-
return (0, $7f6bcebe3ce84296$export$64df6e3182fd5b2d)(this, filePaths);
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
class $e75797f2a6f0115f$var$FSError extends Error {
|
|
1112
|
-
constructor(code, path, message){
|
|
1113
|
-
super(`${code}: ${path} ${message}`);
|
|
1114
|
-
this.name = 'FSError';
|
|
1115
|
-
this.code = code;
|
|
1116
|
-
this.path = path;
|
|
1117
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
(0, $jF595$atlaspackbuildcache.registerSerializableClass)(`${(0, (/*@__PURE__*/$parcel$interopDefault($a29f1902b85e3e69$exports))).version}:OverlayFS`, $e75797f2a6f0115f$export$5963299e2424ca1c);
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
var $80660f432e25e217$exports = {};
|
|
1124
|
-
|
|
1125
|
-
$parcel$export($80660f432e25e217$exports, "NodeVCSAwareFS", () => $80660f432e25e217$export$80de92554c03942a);
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
class $80660f432e25e217$export$80de92554c03942a extends (0, $3efdc9f199571449$export$c4e0ef2ab73c21e7) {
|
|
1134
|
-
/**
|
|
1135
|
-
* These files are excluded from 'dirty file' tracking even if they are
|
|
1136
|
-
* modified.
|
|
1137
|
-
*/ #excludePatterns;
|
|
1138
|
-
/**
|
|
1139
|
-
* Logging function for the diff between watcher events and vcs events.
|
|
1140
|
-
*/ #logEventDiff;
|
|
1141
|
-
/**
|
|
1142
|
-
* The path of the git repository containing the project root. Null if the
|
|
1143
|
-
* project is not a git repository.
|
|
1144
|
-
*/ #gitRepoPath;
|
|
1145
|
-
constructor(options){
|
|
1146
|
-
super();
|
|
1147
|
-
this.#excludePatterns = options.excludePatterns;
|
|
1148
|
-
this.#logEventDiff = options.logEventDiff;
|
|
1149
|
-
this.#gitRepoPath = options.gitRepoPath;
|
|
1150
|
-
}
|
|
1151
|
-
// $FlowFixMe[incompatible-extend] the serialization API is not happy with inheritance
|
|
1152
|
-
static deserialize(data) {
|
|
1153
|
-
const fs = new $80660f432e25e217$export$80de92554c03942a({
|
|
1154
|
-
excludePatterns: data.excludePatterns,
|
|
1155
|
-
logEventDiff: null,
|
|
1156
|
-
gitRepoPath: data.gitRepoPath
|
|
1157
|
-
});
|
|
1158
|
-
return fs;
|
|
1159
|
-
}
|
|
1160
|
-
// $FlowFixMe[incompatible-extend] the serialization API is not happy with inheritance
|
|
1161
|
-
serialize() {
|
|
1162
|
-
return {
|
|
1163
|
-
excludePatterns: this.#excludePatterns,
|
|
1164
|
-
logEventDiff: null,
|
|
1165
|
-
gitRepoPath: this.#gitRepoPath
|
|
1166
|
-
};
|
|
1167
|
-
}
|
|
1168
|
-
setGitRepoPath(gitRepoPath) {
|
|
1169
|
-
this.#gitRepoPath = gitRepoPath;
|
|
1170
|
-
}
|
|
1171
|
-
async getEventsSince(dir, snapshot, opts) {
|
|
1172
|
-
const gitRepoPath = this.#gitRepoPath;
|
|
1173
|
-
if (gitRepoPath == null) return this.watcher().getEventsSince(dir, snapshot, opts);
|
|
1174
|
-
const { nativeSnapshotPath: nativeSnapshotPath, vcsState: vcsState } = await (0, $jF595$atlaspacklogger.instrumentAsync)('NodeVCSAwareFS.readSnapshot', async ()=>{
|
|
1175
|
-
// Note: can't use toString() directly, or it won't resolve the promise
|
|
1176
|
-
const snapshotFile = await this.readFile(snapshot);
|
|
1177
|
-
const snapshotFileContent = snapshotFile.toString();
|
|
1178
|
-
return JSON.parse(snapshotFileContent);
|
|
1179
|
-
});
|
|
1180
|
-
let watcherEventsSince = [];
|
|
1181
|
-
const vcsEventsSince = vcsState != null ? (await (0, $jF595$atlaspacklogger.instrumentAsync)('NodeVCSAwareFS::rust.getEventsSince', ()=>(0, $jF595$atlaspackrust.getEventsSince)(gitRepoPath, vcsState, null))).map((e)=>({
|
|
1182
|
-
path: e.path,
|
|
1183
|
-
type: e.changeType
|
|
1184
|
-
})) : null;
|
|
1185
|
-
if ((0, $jF595$atlaspackfeatureflags.getFeatureFlagValue)('vcsMode') !== 'NEW' && vcsEventsSince != null) {
|
|
1186
|
-
watcherEventsSince = await (0, $jF595$atlaspacklogger.instrumentAsync)('NodeVCSAwareFS::watchman.getEventsSince', ()=>this.watcher().getEventsSince(dir, nativeSnapshotPath, opts));
|
|
1187
|
-
this.#logEventDiff?.(watcherEventsSince, vcsEventsSince);
|
|
1188
|
-
}
|
|
1189
|
-
if ([
|
|
1190
|
-
'NEW_AND_CHECK',
|
|
1191
|
-
'NEW'
|
|
1192
|
-
].includes((0, $jF595$atlaspackfeatureflags.getFeatureFlagValue)('vcsMode'))) {
|
|
1193
|
-
if (vcsEventsSince == null) {
|
|
1194
|
-
(0, ($parcel$interopDefault($jF595$atlaspacklogger))).error({
|
|
1195
|
-
origin: '@atlaspack/fs',
|
|
1196
|
-
message: 'Missing VCS state. There was an error when writing the snapshot. Please clear your cache.',
|
|
1197
|
-
meta: {
|
|
1198
|
-
trackableEvent: 'vcs_state_snapshot_read_failed'
|
|
1199
|
-
}
|
|
1200
|
-
});
|
|
1201
|
-
return [];
|
|
1202
|
-
}
|
|
1203
|
-
return vcsEventsSince;
|
|
1204
|
-
}
|
|
1205
|
-
return watcherEventsSince;
|
|
1206
|
-
}
|
|
1207
|
-
async writeSnapshot(dir, snapshot, opts) {
|
|
1208
|
-
const gitRepoPath = this.#gitRepoPath;
|
|
1209
|
-
if (gitRepoPath == null) {
|
|
1210
|
-
await this.watcher().writeSnapshot(dir, snapshot, opts);
|
|
1211
|
-
return;
|
|
1212
|
-
}
|
|
1213
|
-
const snapshotDirectory = (0, ($parcel$interopDefault($jF595$path))).dirname(snapshot);
|
|
1214
|
-
await this.mkdirp(snapshotDirectory);
|
|
1215
|
-
const filename = (0, ($parcel$interopDefault($jF595$path))).basename(snapshot, '.txt');
|
|
1216
|
-
const nativeSnapshotPath = (0, ($parcel$interopDefault($jF595$path))).join(snapshotDirectory, `${filename}.native-snapshot.txt`);
|
|
1217
|
-
if ((0, $jF595$atlaspackfeatureflags.getFeatureFlagValue)('vcsMode') !== 'NEW') await (0, $jF595$atlaspacklogger.instrumentAsync)('NodeVCSAwareFS::watchman.writeSnapshot', async ()=>{
|
|
1218
|
-
await this.watcher().writeSnapshot(dir, nativeSnapshotPath, opts);
|
|
1219
|
-
});
|
|
1220
|
-
let vcsState = null;
|
|
1221
|
-
try {
|
|
1222
|
-
vcsState = await (0, $jF595$atlaspacklogger.instrumentAsync)('NodeVCSAwareFS::getVcsStateSnapshot', ()=>(0, $jF595$atlaspackrust.getVcsStateSnapshot)(gitRepoPath, this.#excludePatterns));
|
|
1223
|
-
(0, ($parcel$interopDefault($jF595$atlaspacklogger))).verbose({
|
|
1224
|
-
origin: '@atlaspack/fs',
|
|
1225
|
-
message: 'Expose VCS timing metrics',
|
|
1226
|
-
meta: {
|
|
1227
|
-
trackableEvent: 'vcs_timing_metrics',
|
|
1228
|
-
dirtyFilesExecutionTime: vcsState?.dirtyFilesExecutionTime,
|
|
1229
|
-
yarnStatesExecutionTime: vcsState?.yarnStatesExecutionTime
|
|
1230
|
-
}
|
|
1231
|
-
});
|
|
1232
|
-
} catch (err) {
|
|
1233
|
-
(0, ($parcel$interopDefault($jF595$atlaspacklogger))).error({
|
|
1234
|
-
origin: '@atlaspack/fs',
|
|
1235
|
-
message: `Failed to get VCS state snapshot: ${err.message}`,
|
|
1236
|
-
meta: {
|
|
1237
|
-
trackableEvent: 'vcs_state_snapshot_failed',
|
|
1238
|
-
error: err
|
|
1239
|
-
}
|
|
1240
|
-
});
|
|
1241
|
-
}
|
|
1242
|
-
const snapshotContents = {
|
|
1243
|
-
vcsState: vcsState,
|
|
1244
|
-
nativeSnapshotPath: nativeSnapshotPath
|
|
1245
|
-
};
|
|
1246
|
-
await this.writeFile(snapshot, JSON.stringify(snapshotContents));
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
(0, $jF595$atlaspackbuildcache.registerSerializableClass)(`${(0, (/*@__PURE__*/$parcel$interopDefault($a29f1902b85e3e69$exports))).version}:NodeVCSAwareFS`, $80660f432e25e217$export$80de92554c03942a);
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
const $81d23888a9e9b3a9$var$pipeline = (0, $jF595$util.promisify)((0, ($parcel$interopDefault($jF595$stream))).pipeline);
|
|
1253
|
-
async function $81d23888a9e9b3a9$export$d3a8044e3fef7335(sourceFS, source, destinationFS, destination, filter) {
|
|
1254
|
-
await destinationFS.mkdirp(destination);
|
|
1255
|
-
let files = await sourceFS.readdir(source);
|
|
1256
|
-
for (let file of files){
|
|
1257
|
-
if (filter && !filter(file)) continue;
|
|
1258
|
-
let sourcePath = (0, ($parcel$interopDefault($jF595$path))).join(source, file);
|
|
1259
|
-
let destPath = (0, ($parcel$interopDefault($jF595$path))).join(destination, file);
|
|
1260
|
-
let stats = await sourceFS.stat(sourcePath);
|
|
1261
|
-
if (stats.isFile()) await $81d23888a9e9b3a9$var$pipeline(sourceFS.createReadStream(sourcePath), destinationFS.createWriteStream(destPath));
|
|
1262
|
-
else if (stats.isDirectory()) await $81d23888a9e9b3a9$export$d3a8044e3fef7335(sourceFS, sourcePath, destinationFS, destPath, filter);
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
$parcel$exportWildcard(module.exports, $3efdc9f199571449$exports);
|
|
1266
|
-
$parcel$exportWildcard(module.exports, $ce546cd73efa5b9e$exports);
|
|
1267
|
-
$parcel$exportWildcard(module.exports, $e75797f2a6f0115f$exports);
|
|
1268
|
-
$parcel$exportWildcard(module.exports, $80660f432e25e217$exports);
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
//# sourceMappingURL=browser.js.map
|