@atlaspack/fs 2.12.1-dev.3466 → 2.12.1-dev.3502
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/lib/browser.js +2 -1
- package/lib/browser.js.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/package.json +9 -11
- package/src/MemoryFS.js +1 -0
- package/src/NodeVCSAwareFS.js +79 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/fs",
|
|
3
|
-
"version": "2.12.1-dev.
|
|
3
|
+
"version": "2.12.1-dev.3502+c2daeab5a",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"publishConfig": {
|
|
@@ -48,26 +48,24 @@
|
|
|
48
48
|
"check-ts": "tsc --noEmit index.d.ts"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@atlaspack/
|
|
52
|
-
"@atlaspack/
|
|
53
|
-
"@atlaspack/
|
|
54
|
-
"@atlaspack/
|
|
55
|
-
"@atlaspack/
|
|
51
|
+
"@atlaspack/build-cache": "2.12.1-dev.3502+c2daeab5a",
|
|
52
|
+
"@atlaspack/feature-flags": "2.12.1-dev.3502+c2daeab5a",
|
|
53
|
+
"@atlaspack/rust": "2.12.1-dev.3502+c2daeab5a",
|
|
54
|
+
"@atlaspack/types-internal": "2.12.1-dev.3502+c2daeab5a",
|
|
55
|
+
"@atlaspack/utils": "2.12.1-dev.3502+c2daeab5a",
|
|
56
|
+
"@atlaspack/workers": "2.12.1-dev.3502+c2daeab5a",
|
|
56
57
|
"@parcel/watcher": "^2.0.7"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@atlaspack/watcher-watchman-js": "2.12.1-dev.
|
|
60
|
+
"@atlaspack/watcher-watchman-js": "2.12.1-dev.3502+c2daeab5a",
|
|
60
61
|
"graceful-fs": "^4.2.4",
|
|
61
62
|
"ncp": "^2.0.0",
|
|
62
63
|
"nullthrows": "^1.1.1",
|
|
63
64
|
"utility-types": "^3.10.0"
|
|
64
65
|
},
|
|
65
|
-
"peerDependencies": {
|
|
66
|
-
"@atlaspack/build-cache": "^2.12.0"
|
|
67
|
-
},
|
|
68
66
|
"browser": {
|
|
69
67
|
"@atlaspack/fs": "./lib/browser.js",
|
|
70
68
|
"./src/NodeFS.js": "./src/NodeFS.browser.js"
|
|
71
69
|
},
|
|
72
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "c2daeab5a12461903159dec34df5671eaaa9b749"
|
|
73
71
|
}
|
package/src/MemoryFS.js
CHANGED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// @flow strict-local
|
|
2
|
+
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import {NodeFS} from './NodeFS';
|
|
5
|
+
import {getVcsStateSnapshot, getEventsSince} from '@atlaspack/rust';
|
|
6
|
+
import type {FilePath} from '@atlaspack/types-internal';
|
|
7
|
+
import type {Event, Options as WatcherOptions} from '@parcel/watcher';
|
|
8
|
+
import {registerSerializableClass} from '@atlaspack/build-cache';
|
|
9
|
+
|
|
10
|
+
// $FlowFixMe
|
|
11
|
+
import packageJSON from '../package.json';
|
|
12
|
+
|
|
13
|
+
export interface NodeVCSAwareFSOptions {
|
|
14
|
+
gitRepoPath: FilePath;
|
|
15
|
+
excludePatterns: Array<string>;
|
|
16
|
+
logEventDiff: (watcherEvents: Event[], vcsEvents: string[]) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class NodeVCSAwareFS extends NodeFS {
|
|
20
|
+
#options: NodeVCSAwareFSOptions;
|
|
21
|
+
|
|
22
|
+
constructor(options: NodeVCSAwareFSOptions) {
|
|
23
|
+
super();
|
|
24
|
+
this.#options = options;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async getEventsSince(
|
|
28
|
+
dir: FilePath,
|
|
29
|
+
snapshot: FilePath,
|
|
30
|
+
opts: WatcherOptions,
|
|
31
|
+
): Promise<Array<Event>> {
|
|
32
|
+
const snapshotFile = await this.readFile(snapshot).toString();
|
|
33
|
+
const {nativeSnapshotPath, vcsState} = JSON.parse(snapshotFile);
|
|
34
|
+
|
|
35
|
+
const watcherEventsSince = await this.watcher().getEventsSince(
|
|
36
|
+
dir,
|
|
37
|
+
nativeSnapshotPath,
|
|
38
|
+
opts,
|
|
39
|
+
);
|
|
40
|
+
const vcsEventsSince = getEventsSince(
|
|
41
|
+
this.#options.gitRepoPath,
|
|
42
|
+
vcsState.gitHash,
|
|
43
|
+
);
|
|
44
|
+
this.#options.logEventDiff(watcherEventsSince, vcsEventsSince);
|
|
45
|
+
|
|
46
|
+
return watcherEventsSince;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async writeSnapshot(
|
|
50
|
+
dir: FilePath,
|
|
51
|
+
snapshot: FilePath,
|
|
52
|
+
opts: WatcherOptions,
|
|
53
|
+
): Promise<void> {
|
|
54
|
+
const snapshotDirectory = path.dirname(snapshot);
|
|
55
|
+
const filename = path.basename(snapshot, '.txt');
|
|
56
|
+
const nativeSnapshotPath = path.join(
|
|
57
|
+
snapshotDirectory,
|
|
58
|
+
`${filename}.native-snapshot.txt`,
|
|
59
|
+
);
|
|
60
|
+
await this.watcher().writeSnapshot(dir, nativeSnapshotPath, opts);
|
|
61
|
+
|
|
62
|
+
// TODO: we need the git repo path, pass the exclude patterns
|
|
63
|
+
const vcsState = await getVcsStateSnapshot(
|
|
64
|
+
this.#options.gitRepoPath,
|
|
65
|
+
this.#options.excludePatterns,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const snapshotContents = {
|
|
69
|
+
vcsState,
|
|
70
|
+
nativeSnapshotPath,
|
|
71
|
+
};
|
|
72
|
+
await this.writeFile(snapshot, JSON.stringify(snapshotContents));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
registerSerializableClass(
|
|
77
|
+
`${packageJSON.version}:NodeVCSAwareFS`,
|
|
78
|
+
NodeVCSAwareFS,
|
|
79
|
+
);
|