fork-ts-checker-webpack-plugin 9.1.1 → 10.0.0-alpha.1
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/README.md +23 -13
- package/lib/files-change.js +5 -6
- package/lib/formatter/basic-formatter.js +3 -4
- package/lib/formatter/code-frame-formatter.d.ts +3 -2
- package/lib/formatter/code-frame-formatter.js +14 -5
- package/lib/formatter/formatter-config.js +3 -3
- package/lib/formatter/formatter-options.d.ts +1 -1
- package/lib/formatter/stats-formatter.js +4 -5
- package/lib/formatter/webpack-formatter.js +6 -11
- package/lib/hooks/intercept-done-to-get-dev-server-tap.js +1 -2
- package/lib/hooks/report-issues.d.ts +8 -0
- package/lib/hooks/report-issues.js +22 -0
- package/lib/hooks/tap-after-compile-to-add-dependencies.js +4 -14
- package/lib/hooks/tap-after-compile-to-get-issues.js +7 -29
- package/lib/hooks/tap-after-environment-to-patch-watching.js +1 -2
- package/lib/hooks/tap-done-to-async-get-issues.js +13 -34
- package/lib/hooks/tap-error-to-log-message.js +6 -9
- package/lib/hooks/tap-start-to-run-workers.js +13 -24
- package/lib/hooks/tap-stop-to-terminate-workers.js +1 -2
- package/lib/infrastructure-logger.js +1 -2
- package/lib/issue/issue-config.js +1 -2
- package/lib/issue/issue-location.js +2 -3
- package/lib/issue/issue-match.js +3 -4
- package/lib/issue/issue-position.js +1 -2
- package/lib/issue/issue-predicate.js +2 -3
- package/lib/issue/issue-severity.js +2 -3
- package/lib/issue/issue-webpack-error.js +21 -18
- package/lib/issue/issue.js +2 -3
- package/lib/plugin-config.js +1 -2
- package/lib/plugin-hooks.d.ts +4 -4
- package/lib/plugin-hooks.js +1 -2
- package/lib/plugin-options.json +4 -8
- package/lib/plugin-pools.js +17 -7
- package/lib/plugin-state.d.ts +0 -1
- package/lib/plugin-state.js +1 -2
- package/lib/plugin.d.ts +2 -2
- package/lib/plugin.js +39 -24
- package/lib/rpc/expose-rpc.js +6 -16
- package/lib/rpc/rpc-error.js +2 -0
- package/lib/rpc/rpc-worker.d.ts +1 -2
- package/lib/rpc/rpc-worker.js +26 -17
- package/lib/rpc/wrap-rpc.d.ts +0 -1
- package/lib/rpc/wrap-rpc.js +4 -14
- package/lib/typescript/type-script-package.d.ts +4 -0
- package/lib/typescript/type-script-package.js +88 -0
- package/lib/typescript/type-script-support.js +26 -27
- package/lib/typescript/type-script-worker-config.d.ts +2 -3
- package/lib/typescript/type-script-worker-config.js +24 -4
- package/lib/typescript/type-script-worker-options.d.ts +4 -3
- package/lib/typescript/type-script-worker-options.js +4 -0
- package/lib/typescript/worker/get-dependencies-worker.js +15 -4
- package/lib/typescript/worker/get-issues-worker.d.ts +1 -1
- package/lib/typescript/worker/get-issues-worker.js +52 -64
- package/lib/typescript/worker/lib/api.d.ts +13 -0
- package/lib/typescript/worker/lib/api.js +62 -0
- package/lib/typescript/worker/lib/config.d.ts +13 -9
- package/lib/typescript/worker/lib/config.js +93 -65
- package/lib/typescript/worker/lib/dependencies.d.ts +6 -1
- package/lib/typescript/worker/lib/dependencies.js +187 -53
- package/lib/typescript/worker/lib/diagnostics.d.ts +5 -4
- package/lib/typescript/worker/lib/diagnostics.js +67 -51
- package/lib/typescript/worker/lib/in-memory-file-system.d.ts +14 -0
- package/lib/typescript/worker/lib/in-memory-file-system.js +140 -0
- package/lib/typescript/worker/lib/performance.d.ts +1 -2
- package/lib/typescript/worker/lib/performance.js +13 -21
- package/lib/typescript/worker/lib/program/program.d.ts +6 -2
- package/lib/typescript/worker/lib/program/program.js +136 -26
- package/lib/typescript/worker/lib/program/solution-builder.d.ts +3 -1
- package/lib/typescript/worker/lib/program/solution-builder.js +43 -27
- package/lib/typescript/worker/lib/typescript.d.ts +4 -2
- package/lib/typescript/worker/lib/typescript.js +69 -3
- package/lib/utils/async/abort-error.d.ts +0 -1
- package/lib/utils/async/abort-error.js +1 -1
- package/lib/utils/async/controlled-promise.js +1 -2
- package/lib/utils/async/is-pending.js +1 -2
- package/lib/utils/async/pool.d.ts +0 -1
- package/lib/utils/async/pool.js +13 -25
- package/lib/utils/async/wait.js +1 -2
- package/lib/utils/deep-merge.d.ts +5 -0
- package/lib/utils/deep-merge.js +56 -0
- package/lib/utils/path/format-file-path.d.ts +3 -0
- package/lib/utils/path/format-file-path.js +15 -0
- package/lib/utils/path/forward-slash.js +1 -2
- package/lib/utils/path/is-inside-another-path.js +1 -2
- package/lib/utils/path/relative-to-context.js +1 -2
- package/lib/watch/inclusive-node-watch-file-system.d.ts +3 -0
- package/lib/watch/inclusive-node-watch-file-system.js +121 -113
- package/lib/watch/watch-file-system.d.ts +0 -1
- package/package.json +43 -53
- package/lib/formatter/types/babel__code-frame.d.ts +0 -21
- package/lib/formatter/types/babel__code-frame.js +0 -7
- package/lib/typescript/worker/lib/artifacts.d.ts +0 -4
- package/lib/typescript/worker/lib/artifacts.js +0 -94
- package/lib/typescript/worker/lib/emit.d.ts +0 -2
- package/lib/typescript/worker/lib/emit.js +0 -13
- package/lib/typescript/worker/lib/file-system/file-system.d.ts +0 -18
- package/lib/typescript/worker/lib/file-system/file-system.js +0 -2
- package/lib/typescript/worker/lib/file-system/mem-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/mem-file-system.js +0 -78
- package/lib/typescript/worker/lib/file-system/passive-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/passive-file-system.js +0 -65
- package/lib/typescript/worker/lib/file-system/real-file-system.d.ts +0 -5
- package/lib/typescript/worker/lib/file-system/real-file-system.js +0 -191
- package/lib/typescript/worker/lib/host/compiler-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/compiler-host.js +0 -10
- package/lib/typescript/worker/lib/host/watch-compiler-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/watch-compiler-host.js +0 -20
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.d.ts +0 -2
- package/lib/typescript/worker/lib/host/watch-solution-builder-host.js +0 -47
- package/lib/typescript/worker/lib/program/watch-program.d.ts +0 -3
- package/lib/typescript/worker/lib/program/watch-program.js +0 -51
- package/lib/typescript/worker/lib/system.d.ts +0 -19
- package/lib/typescript/worker/lib/system.js +0 -232
- package/lib/typescript/worker/lib/tracing.d.ts +0 -4
- package/lib/typescript/worker/lib/tracing.js +0 -29
- package/lib/typescript/worker/lib/tsbuildinfo.d.ts +0 -4
- package/lib/typescript/worker/lib/tsbuildinfo.js +0 -96
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fork-ts-checker-webpack-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0-alpha.1",
|
|
4
4
|
"description": "Runs typescript type checker and linter on separate process.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -31,14 +31,16 @@
|
|
|
31
31
|
"main": "lib/index.js",
|
|
32
32
|
"types": "lib/index.d.ts",
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "
|
|
35
|
-
"lint": "
|
|
34
|
+
"build": "node -e \"require('fs').rmSync('lib',{recursive:true,force:true})\" && tsc --version && tsc",
|
|
35
|
+
"lint": "tsc -p . --noEmit && tsc -p test --noEmit && oxlint src test",
|
|
36
36
|
"test": "npm run build && npm run test:unit && npm run test:e2e",
|
|
37
|
-
"test:unit": "
|
|
38
|
-
"test:e2e": "npm pack &&
|
|
39
|
-
"
|
|
37
|
+
"test:unit": "jest --config=test/unit/jest.config.js",
|
|
38
|
+
"test:e2e": "npm pack && jest --config=test/e2e/jest.config.js --ci -i -b",
|
|
39
|
+
"precommit": "lint-staged && npm run build && npm run test:unit",
|
|
40
|
+
"commit": "git-cz",
|
|
40
41
|
"semantic-release": "semantic-release",
|
|
41
|
-
"prepare": "husky
|
|
42
|
+
"prepare": "husky",
|
|
43
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\""
|
|
42
44
|
},
|
|
43
45
|
"commitlint": {
|
|
44
46
|
"extends": [
|
|
@@ -46,7 +48,10 @@
|
|
|
46
48
|
]
|
|
47
49
|
},
|
|
48
50
|
"lint-staged": {
|
|
49
|
-
"*.ts":
|
|
51
|
+
"*.ts": [
|
|
52
|
+
"oxlint --fix",
|
|
53
|
+
"prettier --write"
|
|
54
|
+
]
|
|
50
55
|
},
|
|
51
56
|
"config": {
|
|
52
57
|
"commitizen": {
|
|
@@ -54,66 +59,51 @@
|
|
|
54
59
|
}
|
|
55
60
|
},
|
|
56
61
|
"dependencies": {
|
|
57
|
-
"@babel/code-frame": "^
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"node-abort-controller": "^3.0.1",
|
|
66
|
-
"schema-utils": "^3.1.1",
|
|
67
|
-
"semver": "^7.3.5",
|
|
68
|
-
"tapable": "^2.2.1"
|
|
62
|
+
"@babel/code-frame": "^8.0.6",
|
|
63
|
+
"chokidar": "^6.0.0",
|
|
64
|
+
"cosmiconfig": "^10.0.1",
|
|
65
|
+
"minimatch": "^11.0.9",
|
|
66
|
+
"picocolors": "^1.1.1",
|
|
67
|
+
"schema-utils": "^4.8.3",
|
|
68
|
+
"semver": "^7.8.6",
|
|
69
|
+
"tapable": "^2.3.4"
|
|
69
70
|
},
|
|
70
71
|
"peerDependencies": {
|
|
71
|
-
"typescript": "
|
|
72
|
+
"typescript": ">=7.1.0-beta",
|
|
72
73
|
"webpack": "^5.11.0"
|
|
73
74
|
},
|
|
74
75
|
"devDependencies": {
|
|
75
|
-
"@commitlint/config-conventional": "^
|
|
76
|
+
"@commitlint/config-conventional": "^21.2.4",
|
|
76
77
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
77
78
|
"@semantic-release/exec": "^7.1.0",
|
|
78
79
|
"@semantic-release/github": "^12.0.11",
|
|
79
80
|
"@semantic-release/npm": "^13.2.0",
|
|
80
81
|
"@semantic-release/release-notes-generator": "^14.1.1",
|
|
81
|
-
"@
|
|
82
|
-
"@
|
|
83
|
-
"@types/
|
|
84
|
-
"@types/
|
|
85
|
-
"@types/
|
|
86
|
-
"@types/
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"@yarnpkg/cli-dist": "4.7.0",
|
|
93
|
-
"commitlint": "^16.1.0",
|
|
94
|
-
"cross-env": "^7.0.3",
|
|
95
|
-
"eslint": "^8.8.0",
|
|
96
|
-
"eslint-plugin-import": "^2.25.4",
|
|
97
|
-
"eslint-plugin-node": "^11.1.0",
|
|
98
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
99
|
-
"git-cz": "^4.8.0",
|
|
100
|
-
"husky": "^7.0.4",
|
|
101
|
-
"jest": "^27.4.7",
|
|
102
|
-
"jest-circus": "^27.4.6",
|
|
103
|
-
"jest-environment-node": "^27.4.6",
|
|
82
|
+
"@swc/core": "^1.16.22",
|
|
83
|
+
"@swc/jest": "^0.2.39",
|
|
84
|
+
"@types/jest": "^30.0.0",
|
|
85
|
+
"@types/json-schema": "^7.0.15",
|
|
86
|
+
"@types/node": "^22.20.5",
|
|
87
|
+
"@types/semver": "^7.8.0",
|
|
88
|
+
"commitlint": "^21.2.4",
|
|
89
|
+
"git-cz": "^4.9.0",
|
|
90
|
+
"husky": "^9.1.7",
|
|
91
|
+
"jest": "^30.5.2",
|
|
92
|
+
"jest-environment-node": "^30.5.2",
|
|
104
93
|
"json-schema": "^0.4.0",
|
|
105
94
|
"karton": "^0.4.1",
|
|
106
|
-
"lint-staged": "^
|
|
107
|
-
"
|
|
108
|
-
"
|
|
95
|
+
"lint-staged": "^17.6.0",
|
|
96
|
+
"oxlint": "^1.93.0",
|
|
97
|
+
"prettier": "^3.10.1",
|
|
109
98
|
"semantic-release": "^25.0.9",
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
|
|
99
|
+
"typescript": "7.1.0-beta",
|
|
100
|
+
"webpack": "^5.112.2"
|
|
101
|
+
},
|
|
102
|
+
"overrides": {
|
|
103
|
+
"typescript": "$typescript"
|
|
114
104
|
},
|
|
115
105
|
"engines": {
|
|
116
|
-
"node": ">=
|
|
106
|
+
"node": "^22.22.0 || >=24.11.0"
|
|
117
107
|
},
|
|
118
108
|
"packageManager": "npm@11.21.2"
|
|
119
109
|
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface BabelCodeFrameOptions {
|
|
2
|
-
/** Syntax highlight the code as JavaScript for terminals. default: false */
|
|
3
|
-
highlightCode?: boolean;
|
|
4
|
-
/** The number of lines to show above the error. default: 2 */
|
|
5
|
-
linesAbove?: number;
|
|
6
|
-
/** The number of lines to show below the error. default: 3 */
|
|
7
|
-
linesBelow?: number;
|
|
8
|
-
/**
|
|
9
|
-
* Forcibly syntax highlight the code as JavaScript (for non-terminals);
|
|
10
|
-
* overrides highlightCode.
|
|
11
|
-
* default: false
|
|
12
|
-
*/
|
|
13
|
-
forceColor?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Pass in a string to be displayed inline (if possible) next to the
|
|
16
|
-
* highlighted location in the code. If it can't be positioned inline,
|
|
17
|
-
* it will be placed above the code frame.
|
|
18
|
-
* default: nothing
|
|
19
|
-
*/
|
|
20
|
-
message?: string;
|
|
21
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Base on the type definitions for @babel/code-frame 7.0
|
|
3
|
-
// Project: https://github.com/babel/babel/tree/main/packages/babel-code-frame, https://babeljs.io
|
|
4
|
-
// Definitions by: Mohsen Azimi <https://github.com/mohsen1>
|
|
5
|
-
// Forbes Lindesay <https://github.com/ForbesLindesay>
|
|
6
|
-
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.registerArtifacts = exports.invalidateArtifacts = exports.getArtifacts = void 0;
|
|
27
|
-
const path = __importStar(require("path"));
|
|
28
|
-
const config_1 = require("./config");
|
|
29
|
-
const system_1 = require("./system");
|
|
30
|
-
const tsbuildinfo_1 = require("./tsbuildinfo");
|
|
31
|
-
const typescript_1 = require("./typescript");
|
|
32
|
-
const worker_config_1 = require("./worker-config");
|
|
33
|
-
let artifacts;
|
|
34
|
-
function getArtifacts(force = false) {
|
|
35
|
-
if (!artifacts || force) {
|
|
36
|
-
const parsedConfig = (0, config_1.getParsedConfig)();
|
|
37
|
-
artifacts = getArtifactsWorker(parsedConfig, worker_config_1.config.context);
|
|
38
|
-
}
|
|
39
|
-
return artifacts;
|
|
40
|
-
}
|
|
41
|
-
exports.getArtifacts = getArtifacts;
|
|
42
|
-
function invalidateArtifacts() {
|
|
43
|
-
artifacts = undefined;
|
|
44
|
-
}
|
|
45
|
-
exports.invalidateArtifacts = invalidateArtifacts;
|
|
46
|
-
function registerArtifacts() {
|
|
47
|
-
system_1.system.setArtifacts(getArtifacts());
|
|
48
|
-
}
|
|
49
|
-
exports.registerArtifacts = registerArtifacts;
|
|
50
|
-
function getArtifactsWorker(parsedConfig, configFileContext, processedConfigFiles = []) {
|
|
51
|
-
const files = new Set();
|
|
52
|
-
const dirs = new Set();
|
|
53
|
-
if (parsedConfig.fileNames.length > 0) {
|
|
54
|
-
if (parsedConfig.options.outFile) {
|
|
55
|
-
files.add(path.resolve(configFileContext, parsedConfig.options.outFile));
|
|
56
|
-
}
|
|
57
|
-
const tsBuildInfoPath = (0, tsbuildinfo_1.getTsBuildInfoEmitPath)(parsedConfig.options);
|
|
58
|
-
if (tsBuildInfoPath) {
|
|
59
|
-
files.add(path.resolve(configFileContext, tsBuildInfoPath));
|
|
60
|
-
}
|
|
61
|
-
if (parsedConfig.options.outDir) {
|
|
62
|
-
dirs.add(path.resolve(configFileContext, parsedConfig.options.outDir));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
for (const projectReference of parsedConfig.projectReferences || []) {
|
|
66
|
-
const configFile = typescript_1.typescript.resolveProjectReferencePath(projectReference);
|
|
67
|
-
if (processedConfigFiles.includes(configFile)) {
|
|
68
|
-
// handle circular dependencies
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
const parsedConfig = (0, config_1.parseConfig)(configFile, path.dirname(configFile));
|
|
72
|
-
const childArtifacts = getArtifactsWorker(parsedConfig, configFileContext, [
|
|
73
|
-
...processedConfigFiles,
|
|
74
|
-
configFile,
|
|
75
|
-
]);
|
|
76
|
-
childArtifacts.files.forEach((file) => {
|
|
77
|
-
files.add(file);
|
|
78
|
-
});
|
|
79
|
-
childArtifacts.dirs.forEach((dir) => {
|
|
80
|
-
dirs.add(dir);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
const extensions = [
|
|
84
|
-
typescript_1.typescript.Extension.Dts,
|
|
85
|
-
typescript_1.typescript.Extension.Js,
|
|
86
|
-
typescript_1.typescript.Extension.TsBuildInfo,
|
|
87
|
-
];
|
|
88
|
-
return {
|
|
89
|
-
files: Array.from(files).map((file) => path.normalize(file)),
|
|
90
|
-
dirs: Array.from(dirs).map((dir) => path.normalize(dir)),
|
|
91
|
-
excluded: [],
|
|
92
|
-
extensions,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emitDtsIfNeeded = void 0;
|
|
4
|
-
const config_1 = require("./config");
|
|
5
|
-
const worker_config_1 = require("./worker-config");
|
|
6
|
-
function emitDtsIfNeeded(program) {
|
|
7
|
-
const parsedConfig = (0, config_1.getParsedConfig)();
|
|
8
|
-
if (worker_config_1.config.mode === 'write-dts' && parsedConfig.options.declaration) {
|
|
9
|
-
// emit .d.ts files only
|
|
10
|
-
program.emit(undefined, undefined, undefined, true);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.emitDtsIfNeeded = emitDtsIfNeeded;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { Dirent, Stats } from 'fs';
|
|
3
|
-
/**
|
|
4
|
-
* Interface to abstract file system implementation details.
|
|
5
|
-
*/
|
|
6
|
-
export interface FileSystem {
|
|
7
|
-
exists(path: string): boolean;
|
|
8
|
-
readFile(path: string, encoding?: string): string | undefined;
|
|
9
|
-
readDir(path: string): Dirent[];
|
|
10
|
-
readStats(path: string): Stats | undefined;
|
|
11
|
-
realPath(path: string): string;
|
|
12
|
-
normalizePath(path: string): string;
|
|
13
|
-
writeFile(path: string, data: string): void;
|
|
14
|
-
deleteFile(path: string): void;
|
|
15
|
-
createDir(path: string): void;
|
|
16
|
-
updateTimes(path: string, atime: Date, mtime: Date): void;
|
|
17
|
-
clearCache(): void;
|
|
18
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.memFileSystem = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const memfs_1 = require("memfs");
|
|
6
|
-
const real_file_system_1 = require("./real-file-system");
|
|
7
|
-
/**
|
|
8
|
-
* It's an implementation of FileSystem interface which reads and writes to the in-memory file system.
|
|
9
|
-
*/
|
|
10
|
-
exports.memFileSystem = Object.assign(Object.assign({}, real_file_system_1.realFileSystem), { exists(path) {
|
|
11
|
-
return exists(real_file_system_1.realFileSystem.realPath(path));
|
|
12
|
-
},
|
|
13
|
-
readFile(path, encoding) {
|
|
14
|
-
return readFile(real_file_system_1.realFileSystem.realPath(path), encoding);
|
|
15
|
-
},
|
|
16
|
-
readDir(path) {
|
|
17
|
-
return readDir(real_file_system_1.realFileSystem.realPath(path));
|
|
18
|
-
},
|
|
19
|
-
readStats(path) {
|
|
20
|
-
return readStats(real_file_system_1.realFileSystem.realPath(path));
|
|
21
|
-
},
|
|
22
|
-
writeFile(path, data) {
|
|
23
|
-
writeFile(real_file_system_1.realFileSystem.realPath(path), data);
|
|
24
|
-
},
|
|
25
|
-
deleteFile(path) {
|
|
26
|
-
deleteFile(real_file_system_1.realFileSystem.realPath(path));
|
|
27
|
-
},
|
|
28
|
-
createDir(path) {
|
|
29
|
-
createDir(real_file_system_1.realFileSystem.realPath(path));
|
|
30
|
-
},
|
|
31
|
-
updateTimes(path, atime, mtime) {
|
|
32
|
-
updateTimes(real_file_system_1.realFileSystem.realPath(path), atime, mtime);
|
|
33
|
-
},
|
|
34
|
-
clearCache() {
|
|
35
|
-
real_file_system_1.realFileSystem.clearCache();
|
|
36
|
-
} });
|
|
37
|
-
function exists(path) {
|
|
38
|
-
return memfs_1.fs.existsSync(real_file_system_1.realFileSystem.normalizePath(path));
|
|
39
|
-
}
|
|
40
|
-
function readStats(path) {
|
|
41
|
-
return exists(path) ? memfs_1.fs.statSync(real_file_system_1.realFileSystem.normalizePath(path)) : undefined;
|
|
42
|
-
}
|
|
43
|
-
function readFile(path, encoding) {
|
|
44
|
-
const stats = readStats(path);
|
|
45
|
-
if (stats && stats.isFile()) {
|
|
46
|
-
return memfs_1.fs
|
|
47
|
-
.readFileSync(real_file_system_1.realFileSystem.normalizePath(path), { encoding: encoding })
|
|
48
|
-
.toString();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function readDir(path) {
|
|
52
|
-
const stats = readStats(path);
|
|
53
|
-
if (stats && stats.isDirectory()) {
|
|
54
|
-
return memfs_1.fs.readdirSync(real_file_system_1.realFileSystem.normalizePath(path), {
|
|
55
|
-
withFileTypes: true,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
function createDir(path) {
|
|
61
|
-
memfs_1.fs.mkdirSync(real_file_system_1.realFileSystem.normalizePath(path), { recursive: true });
|
|
62
|
-
}
|
|
63
|
-
function writeFile(path, data) {
|
|
64
|
-
if (!exists((0, path_1.dirname)(path))) {
|
|
65
|
-
createDir((0, path_1.dirname)(path));
|
|
66
|
-
}
|
|
67
|
-
memfs_1.fs.writeFileSync(real_file_system_1.realFileSystem.normalizePath(path), data);
|
|
68
|
-
}
|
|
69
|
-
function deleteFile(path) {
|
|
70
|
-
if (exists(path)) {
|
|
71
|
-
memfs_1.fs.unlinkSync(real_file_system_1.realFileSystem.normalizePath(path));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function updateTimes(path, atime, mtime) {
|
|
75
|
-
if (exists(path)) {
|
|
76
|
-
memfs_1.fs.utimesSync(real_file_system_1.realFileSystem.normalizePath(path), atime, mtime);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.passiveFileSystem = void 0;
|
|
4
|
-
const mem_file_system_1 = require("./mem-file-system");
|
|
5
|
-
const real_file_system_1 = require("./real-file-system");
|
|
6
|
-
/**
|
|
7
|
-
* It's an implementation of FileSystem interface which reads from the real file system, but write to the in-memory file system.
|
|
8
|
-
*/
|
|
9
|
-
exports.passiveFileSystem = Object.assign(Object.assign({}, mem_file_system_1.memFileSystem), { exists(path) {
|
|
10
|
-
return exists(real_file_system_1.realFileSystem.realPath(path));
|
|
11
|
-
},
|
|
12
|
-
readFile(path, encoding) {
|
|
13
|
-
return readFile(real_file_system_1.realFileSystem.realPath(path), encoding);
|
|
14
|
-
},
|
|
15
|
-
readDir(path) {
|
|
16
|
-
return readDir(real_file_system_1.realFileSystem.realPath(path));
|
|
17
|
-
},
|
|
18
|
-
readStats(path) {
|
|
19
|
-
return readStats(real_file_system_1.realFileSystem.realPath(path));
|
|
20
|
-
},
|
|
21
|
-
realPath(path) {
|
|
22
|
-
return real_file_system_1.realFileSystem.realPath(path);
|
|
23
|
-
},
|
|
24
|
-
clearCache() {
|
|
25
|
-
real_file_system_1.realFileSystem.clearCache();
|
|
26
|
-
} });
|
|
27
|
-
function exists(path) {
|
|
28
|
-
return real_file_system_1.realFileSystem.exists(path) || mem_file_system_1.memFileSystem.exists(path);
|
|
29
|
-
}
|
|
30
|
-
function readFile(path, encoding) {
|
|
31
|
-
const fsStats = real_file_system_1.realFileSystem.readStats(path);
|
|
32
|
-
const memStats = mem_file_system_1.memFileSystem.readStats(path);
|
|
33
|
-
if (fsStats && memStats) {
|
|
34
|
-
return fsStats.mtimeMs > memStats.mtimeMs
|
|
35
|
-
? real_file_system_1.realFileSystem.readFile(path, encoding)
|
|
36
|
-
: mem_file_system_1.memFileSystem.readFile(path, encoding);
|
|
37
|
-
}
|
|
38
|
-
else if (fsStats) {
|
|
39
|
-
return real_file_system_1.realFileSystem.readFile(path, encoding);
|
|
40
|
-
}
|
|
41
|
-
else if (memStats) {
|
|
42
|
-
return mem_file_system_1.memFileSystem.readFile(path, encoding);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function readDir(path) {
|
|
46
|
-
const fsDirents = real_file_system_1.realFileSystem.readDir(path);
|
|
47
|
-
const memDirents = mem_file_system_1.memFileSystem.readDir(path);
|
|
48
|
-
// merge list of dirents from fs and mem
|
|
49
|
-
return fsDirents
|
|
50
|
-
.filter((fsDirent) => !memDirents.some((memDirent) => memDirent.name === fsDirent.name))
|
|
51
|
-
.concat(memDirents);
|
|
52
|
-
}
|
|
53
|
-
function readStats(path) {
|
|
54
|
-
const fsStats = real_file_system_1.realFileSystem.readStats(path);
|
|
55
|
-
const memStats = mem_file_system_1.memFileSystem.readStats(path);
|
|
56
|
-
if (fsStats && memStats) {
|
|
57
|
-
return fsStats.mtimeMs > memStats.mtimeMs ? fsStats : memStats;
|
|
58
|
-
}
|
|
59
|
-
else if (fsStats) {
|
|
60
|
-
return fsStats;
|
|
61
|
-
}
|
|
62
|
-
else if (memStats) {
|
|
63
|
-
return memStats;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.realFileSystem = void 0;
|
|
27
|
-
const path_1 = require("path");
|
|
28
|
-
const fs = __importStar(require("fs-extra"));
|
|
29
|
-
const existsCache = new Map();
|
|
30
|
-
const readStatsCache = new Map();
|
|
31
|
-
const readFileCache = new Map();
|
|
32
|
-
const readDirCache = new Map();
|
|
33
|
-
const realPathCache = new Map();
|
|
34
|
-
/**
|
|
35
|
-
* It's an implementation of the FileSystem interface which reads and writes directly to the real file system.
|
|
36
|
-
*/
|
|
37
|
-
exports.realFileSystem = {
|
|
38
|
-
exists(path) {
|
|
39
|
-
return exists(getRealPath(path));
|
|
40
|
-
},
|
|
41
|
-
readFile(path, encoding) {
|
|
42
|
-
return readFile(getRealPath(path), encoding);
|
|
43
|
-
},
|
|
44
|
-
readDir(path) {
|
|
45
|
-
return readDir(getRealPath(path));
|
|
46
|
-
},
|
|
47
|
-
readStats(path) {
|
|
48
|
-
return readStats(getRealPath(path));
|
|
49
|
-
},
|
|
50
|
-
realPath(path) {
|
|
51
|
-
return getRealPath(path);
|
|
52
|
-
},
|
|
53
|
-
normalizePath(path) {
|
|
54
|
-
return (0, path_1.normalize)(path);
|
|
55
|
-
},
|
|
56
|
-
writeFile(path, data) {
|
|
57
|
-
writeFile(getRealPath(path), data);
|
|
58
|
-
},
|
|
59
|
-
deleteFile(path) {
|
|
60
|
-
deleteFile(getRealPath(path));
|
|
61
|
-
},
|
|
62
|
-
createDir(path) {
|
|
63
|
-
createDir(getRealPath(path));
|
|
64
|
-
},
|
|
65
|
-
updateTimes(path, atime, mtime) {
|
|
66
|
-
updateTimes(getRealPath(path), atime, mtime);
|
|
67
|
-
},
|
|
68
|
-
clearCache() {
|
|
69
|
-
existsCache.clear();
|
|
70
|
-
readStatsCache.clear();
|
|
71
|
-
readFileCache.clear();
|
|
72
|
-
readDirCache.clear();
|
|
73
|
-
realPathCache.clear();
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
// read methods
|
|
77
|
-
function exists(path) {
|
|
78
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
79
|
-
if (!existsCache.has(normalizedPath)) {
|
|
80
|
-
existsCache.set(normalizedPath, fs.existsSync(normalizedPath));
|
|
81
|
-
}
|
|
82
|
-
return !!existsCache.get(normalizedPath);
|
|
83
|
-
}
|
|
84
|
-
function readStats(path) {
|
|
85
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
86
|
-
if (!readStatsCache.has(normalizedPath)) {
|
|
87
|
-
if (exists(normalizedPath)) {
|
|
88
|
-
readStatsCache.set(normalizedPath, fs.statSync(normalizedPath));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return readStatsCache.get(normalizedPath);
|
|
92
|
-
}
|
|
93
|
-
function readFile(path, encoding) {
|
|
94
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
95
|
-
if (!readFileCache.has(normalizedPath)) {
|
|
96
|
-
const stats = readStats(normalizedPath);
|
|
97
|
-
if (stats && stats.isFile()) {
|
|
98
|
-
readFileCache.set(normalizedPath, fs.readFileSync(normalizedPath, { encoding: encoding }).toString());
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
readFileCache.set(normalizedPath, undefined);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return readFileCache.get(normalizedPath);
|
|
105
|
-
}
|
|
106
|
-
function readDir(path) {
|
|
107
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
108
|
-
if (!readDirCache.has(normalizedPath)) {
|
|
109
|
-
const stats = readStats(normalizedPath);
|
|
110
|
-
if (stats && stats.isDirectory()) {
|
|
111
|
-
readDirCache.set(normalizedPath, fs.readdirSync(normalizedPath, { withFileTypes: true }));
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
readDirCache.set(normalizedPath, []);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return readDirCache.get(normalizedPath) || [];
|
|
118
|
-
}
|
|
119
|
-
function getRealPath(path) {
|
|
120
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
121
|
-
if (!realPathCache.has(normalizedPath)) {
|
|
122
|
-
let base = normalizedPath;
|
|
123
|
-
let nested = '';
|
|
124
|
-
while (base !== (0, path_1.dirname)(base)) {
|
|
125
|
-
if (exists(base)) {
|
|
126
|
-
realPathCache.set(normalizedPath, (0, path_1.normalize)((0, path_1.join)(fs.realpathSync(base), nested)));
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
nested = (0, path_1.join)((0, path_1.basename)(base), nested);
|
|
130
|
-
base = (0, path_1.dirname)(base);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return realPathCache.get(normalizedPath) || normalizedPath;
|
|
134
|
-
}
|
|
135
|
-
function createDir(path) {
|
|
136
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
137
|
-
fs.mkdirSync(normalizedPath, { recursive: true });
|
|
138
|
-
// update cache
|
|
139
|
-
existsCache.set(normalizedPath, true);
|
|
140
|
-
if (readDirCache.has((0, path_1.dirname)(normalizedPath))) {
|
|
141
|
-
readDirCache.delete((0, path_1.dirname)(normalizedPath));
|
|
142
|
-
}
|
|
143
|
-
if (readStatsCache.has(normalizedPath)) {
|
|
144
|
-
readStatsCache.delete(normalizedPath);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function writeFile(path, data) {
|
|
148
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
149
|
-
if (!exists((0, path_1.dirname)(normalizedPath))) {
|
|
150
|
-
createDir((0, path_1.dirname)(normalizedPath));
|
|
151
|
-
}
|
|
152
|
-
fs.writeFileSync(normalizedPath, data);
|
|
153
|
-
// update cache
|
|
154
|
-
existsCache.set(normalizedPath, true);
|
|
155
|
-
if (readDirCache.has((0, path_1.dirname)(normalizedPath))) {
|
|
156
|
-
readDirCache.delete((0, path_1.dirname)(normalizedPath));
|
|
157
|
-
}
|
|
158
|
-
if (readStatsCache.has(normalizedPath)) {
|
|
159
|
-
readStatsCache.delete(normalizedPath);
|
|
160
|
-
}
|
|
161
|
-
if (readFileCache.has(normalizedPath)) {
|
|
162
|
-
readFileCache.delete(normalizedPath);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function deleteFile(path) {
|
|
166
|
-
if (exists(path)) {
|
|
167
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
168
|
-
fs.unlinkSync(normalizedPath);
|
|
169
|
-
// update cache
|
|
170
|
-
existsCache.set(normalizedPath, false);
|
|
171
|
-
if (readDirCache.has((0, path_1.dirname)(normalizedPath))) {
|
|
172
|
-
readDirCache.delete((0, path_1.dirname)(normalizedPath));
|
|
173
|
-
}
|
|
174
|
-
if (readStatsCache.has(normalizedPath)) {
|
|
175
|
-
readStatsCache.delete(normalizedPath);
|
|
176
|
-
}
|
|
177
|
-
if (readFileCache.has(normalizedPath)) {
|
|
178
|
-
readFileCache.delete(normalizedPath);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
function updateTimes(path, atime, mtime) {
|
|
183
|
-
if (exists(path)) {
|
|
184
|
-
const normalizedPath = (0, path_1.normalize)(path);
|
|
185
|
-
fs.utimesSync((0, path_1.normalize)(path), atime, mtime);
|
|
186
|
-
// update cache
|
|
187
|
-
if (readStatsCache.has(normalizedPath)) {
|
|
188
|
-
readStatsCache.delete(normalizedPath);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|