@decohere/core 0.0.1-dev.118 → 0.0.1-dev.120
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/commonjs/src/caching/cache-manager.js +3 -3
- package/commonjs/src/caching/index.js +1 -1
- package/commonjs/src/caching/map-cache.js +39 -0
- package/commonjs/src/io/io.js +0 -3
- package/es6/src/caching/cache-manager.js +3 -3
- package/es6/src/caching/index.js +1 -1
- package/es6/src/caching/map-cache.js +35 -0
- package/es6/src/caching/memoize.decorator.js +1 -1
- package/es6/src/io/io.js +0 -3
- package/package.json +6 -40
- package/types/src/caching/index.d.ts +1 -1
- package/types/src/caching/map-cache.d.ts +23 -0
- package/types/src/caching/memoize.decorator.d.ts +1 -1
- package/types/src/io/io.d.ts +0 -3
- package/commonjs/src/caching/node-cache-memoize.adapter.js +0 -49
- package/commonjs/src/cli/action.js +0 -65
- package/commonjs/src/cli/command.js +0 -127
- package/commonjs/src/cli/index.js +0 -61
- package/commonjs/src/cli/module.type.js +0 -18
- package/commonjs/src/cli/options.js +0 -115
- package/commonjs/src/diagnostics/index.js +0 -22
- package/commonjs/src/diagnostics/trace.js +0 -86
- package/commonjs/src/interop/docker/docker.js +0 -54
- package/commonjs/src/interop/errors/interop.error.js +0 -12
- package/commonjs/src/interop/git/git.js +0 -134
- package/commonjs/src/interop/git/git.types.js +0 -4
- package/commonjs/src/interop/index.js +0 -97
- package/commonjs/src/interop/node/index.js +0 -18
- package/commonjs/src/interop/node/node.js +0 -45
- package/commonjs/src/interop/npm/npm.js +0 -231
- package/commonjs/src/interop/npm/npm.types.js +0 -16
- package/commonjs/src/interop/pnpm/pnpm.js +0 -34
- package/commonjs/src/interop/pnpm/pnpm.types.js +0 -4
- package/commonjs/src/interop/shell/shell.argv.js +0 -45
- package/commonjs/src/interop/shell/shell.js +0 -105
- package/commonjs/src/interop/shell/shell.types.js +0 -4
- package/commonjs/src/interop/types/detect-package-manager.js +0 -71
- package/commonjs/src/interop/types/package-manager.js +0 -4
- package/commonjs/src/interop/yarn/yarn.js +0 -34
- package/commonjs/src/interop/yarn/yarn.types.js +0 -4
- package/commonjs/src/io/find-directories.js +0 -21
- package/commonjs/src/io/find-file.js +0 -45
- package/commonjs/src/io/watch.js +0 -261
- package/commonjs/src/semver/index.js +0 -18
- package/commonjs/src/semver/semver.js +0 -92
- package/commonjs/src/testing/flush-promises.js +0 -16
- package/commonjs/src/testing/glob-with-memfs.js +0 -22
- package/commonjs/src/testing/index.js +0 -22
- package/commonjs/src/testing/memfs.js +0 -52
- package/commonjs/src/testing/mock-logger.js +0 -36
- package/commonjs/src/testing/spy-on-constructor.js +0 -27
- package/es6/src/caching/node-cache-memoize.adapter.js +0 -37
- package/es6/src/cli/action.js +0 -47
- package/es6/src/cli/command.js +0 -106
- package/es6/src/cli/index.js +0 -4
- package/es6/src/cli/module.type.js +0 -11
- package/es6/src/cli/options.js +0 -76
- package/es6/src/diagnostics/index.js +0 -1
- package/es6/src/diagnostics/trace.js +0 -68
- package/es6/src/interop/docker/docker.js +0 -44
- package/es6/src/interop/errors/interop.error.js +0 -2
- package/es6/src/interop/git/git.js +0 -124
- package/es6/src/interop/git/git.types.js +0 -1
- package/es6/src/interop/index.js +0 -21
- package/es6/src/interop/node/index.js +0 -1
- package/es6/src/interop/node/node.js +0 -35
- package/es6/src/interop/npm/npm.js +0 -180
- package/es6/src/interop/npm/npm.types.js +0 -6
- package/es6/src/interop/pnpm/pnpm.js +0 -24
- package/es6/src/interop/pnpm/pnpm.types.js +0 -1
- package/es6/src/interop/shell/shell.argv.js +0 -35
- package/es6/src/interop/shell/shell.js +0 -95
- package/es6/src/interop/shell/shell.types.js +0 -1
- package/es6/src/interop/types/detect-package-manager.js +0 -50
- package/es6/src/interop/types/package-manager.js +0 -1
- package/es6/src/interop/yarn/yarn.js +0 -24
- package/es6/src/interop/yarn/yarn.types.js +0 -1
- package/es6/src/io/find-directories.js +0 -11
- package/es6/src/io/find-file.js +0 -27
- package/es6/src/io/watch.js +0 -238
- package/es6/src/semver/index.js +0 -1
- package/es6/src/semver/semver.js +0 -71
- package/es6/src/testing/flush-promises.js +0 -6
- package/es6/src/testing/glob-with-memfs.js +0 -20
- package/es6/src/testing/index.js +0 -5
- package/es6/src/testing/memfs.js +0 -25
- package/es6/src/testing/mock-logger.js +0 -26
- package/es6/src/testing/spy-on-constructor.js +0 -31
- package/types/src/caching/node-cache-memoize.adapter.d.ts +0 -22
- package/types/src/cli/action.d.ts +0 -36
- package/types/src/cli/command.d.ts +0 -34
- package/types/src/cli/index.d.ts +0 -7
- package/types/src/cli/module.type.d.ts +0 -36
- package/types/src/cli/options.d.ts +0 -28
- package/types/src/diagnostics/index.d.ts +0 -1
- package/types/src/diagnostics/trace.d.ts +0 -10
- package/types/src/interop/docker/docker.d.ts +0 -19
- package/types/src/interop/errors/interop.error.d.ts +0 -2
- package/types/src/interop/git/git.d.ts +0 -16
- package/types/src/interop/git/git.types.d.ts +0 -14
- package/types/src/interop/index.d.ts +0 -14
- package/types/src/interop/node/index.d.ts +0 -1
- package/types/src/interop/node/node.d.ts +0 -5
- package/types/src/interop/npm/npm.d.ts +0 -29
- package/types/src/interop/npm/npm.types.d.ts +0 -24
- package/types/src/interop/pnpm/pnpm.d.ts +0 -9
- package/types/src/interop/pnpm/pnpm.types.d.ts +0 -3
- package/types/src/interop/shell/shell.argv.d.ts +0 -5
- package/types/src/interop/shell/shell.d.ts +0 -6
- package/types/src/interop/shell/shell.types.d.ts +0 -9
- package/types/src/interop/types/detect-package-manager.d.ts +0 -4
- package/types/src/interop/types/package-manager.d.ts +0 -10
- package/types/src/interop/yarn/yarn.d.ts +0 -9
- package/types/src/interop/yarn/yarn.types.d.ts +0 -3
- package/types/src/io/find-directories.d.ts +0 -2
- package/types/src/io/find-file.d.ts +0 -9
- package/types/src/io/watch.d.ts +0 -16
- package/types/src/semver/index.d.ts +0 -1
- package/types/src/semver/semver.d.ts +0 -18
- package/types/src/testing/flush-promises.d.ts +0 -1
- package/types/src/testing/glob-with-memfs.d.ts +0 -3
- package/types/src/testing/index.d.ts +0 -5
- package/types/src/testing/memfs.d.ts +0 -5
- package/types/src/testing/mock-logger.d.ts +0 -13
- package/types/src/testing/spy-on-constructor.d.ts +0 -21
package/commonjs/src/io/watch.js
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get WatchEvents () {
|
|
13
|
-
return WatchEvents;
|
|
14
|
-
},
|
|
15
|
-
get watch () {
|
|
16
|
-
return watch;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const _nodefs = require("node:fs");
|
|
20
|
-
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
21
|
-
const _picomatch = /*#__PURE__*/ _interop_require_default(require("picomatch"));
|
|
22
|
-
const _file = require("./types/file.js");
|
|
23
|
-
function _interop_require_default(obj) {
|
|
24
|
-
return obj && obj.__esModule ? obj : {
|
|
25
|
-
default: obj
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
const WatchEvents = {
|
|
29
|
-
add: "add",
|
|
30
|
-
change: "change",
|
|
31
|
-
addDir: "addDir",
|
|
32
|
-
unlink: "unlink",
|
|
33
|
-
unlinkDir: "unlinkDir"
|
|
34
|
-
};
|
|
35
|
-
function watch(directory, options = {
|
|
36
|
-
cwd: "."
|
|
37
|
-
}) {
|
|
38
|
-
const { include, ignore, ignoreInitial = false } = options;
|
|
39
|
-
const changeCoalesceMs = 25;
|
|
40
|
-
const handlers = {
|
|
41
|
-
ready: new Set(),
|
|
42
|
-
add: new Set(),
|
|
43
|
-
change: new Set(),
|
|
44
|
-
addDir: new Set(),
|
|
45
|
-
unlink: new Set(),
|
|
46
|
-
unlinkDir: new Set()
|
|
47
|
-
};
|
|
48
|
-
let resolveReady;
|
|
49
|
-
const ready = new Promise((resolve)=>{
|
|
50
|
-
resolveReady = resolve;
|
|
51
|
-
});
|
|
52
|
-
const snapshot = buildSnapshot(directory);
|
|
53
|
-
const isFiltered = (relativePath)=>{
|
|
54
|
-
const posixRelativePath = toPosixPath(relativePath);
|
|
55
|
-
const posixFullPath = toPosixPath(_nodepath.default.resolve(directory, relativePath));
|
|
56
|
-
const matchesEitherPath = (patterns)=>_picomatch.default.isMatch(posixRelativePath, patterns) || _picomatch.default.isMatch(posixFullPath, patterns);
|
|
57
|
-
if (include && include.length > 0) {
|
|
58
|
-
return !matchesEitherPath(include);
|
|
59
|
-
}
|
|
60
|
-
if (ignore && ignore.length > 0) {
|
|
61
|
-
return matchesEitherPath(ignore);
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
64
|
-
};
|
|
65
|
-
const emit = (event, relativePath)=>{
|
|
66
|
-
if (isFiltered(relativePath)) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const fullPath = _nodepath.default.resolve(directory, relativePath);
|
|
70
|
-
for (const handler of handlers[event]){
|
|
71
|
-
handler(new _file.FileEx({
|
|
72
|
-
fullPath,
|
|
73
|
-
relativePath
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const pendingChangeTimers = new Map();
|
|
78
|
-
const emitChange = (relativePath)=>{
|
|
79
|
-
const existing = pendingChangeTimers.get(relativePath);
|
|
80
|
-
if (existing != null) {
|
|
81
|
-
clearTimeout(existing);
|
|
82
|
-
}
|
|
83
|
-
const timer = setTimeout(()=>{
|
|
84
|
-
pendingChangeTimers.delete(relativePath);
|
|
85
|
-
emit("change", relativePath);
|
|
86
|
-
}, changeCoalesceMs);
|
|
87
|
-
pendingChangeTimers.set(relativePath, timer);
|
|
88
|
-
};
|
|
89
|
-
const emitReady = ()=>{
|
|
90
|
-
for (const handler of handlers.ready){
|
|
91
|
-
handler();
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
queueMicrotask(()=>{
|
|
95
|
-
if (!ignoreInitial) {
|
|
96
|
-
for (const [relativePath, entry] of snapshot){
|
|
97
|
-
emit(entry.isDirectory ? "addDir" : "add", relativePath);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
emitReady();
|
|
101
|
-
resolveReady?.();
|
|
102
|
-
resolveReady = undefined;
|
|
103
|
-
});
|
|
104
|
-
// One non-recursive watcher per directory. Node's recursive mode on Linux tracks files
|
|
105
|
-
// individually and goes silent for a file once an editor replaces it with an atomic save
|
|
106
|
-
// (write temp file, rename over the original); directory watchers keep seeing it (#505).
|
|
107
|
-
const directoryWatchers = new Map();
|
|
108
|
-
const watchDirectory = (relativeDir)=>{
|
|
109
|
-
if (directoryWatchers.has(relativeDir)) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
try {
|
|
113
|
-
const watcher = (0, _nodefs.watch)(_nodepath.default.resolve(directory, relativeDir), (_eventType, fileName)=>{
|
|
114
|
-
if (fileName != null) {
|
|
115
|
-
onFsEvent(_nodepath.default.posix.join(relativeDir, toPosixPath(fileName.toString())));
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
watcher.on("error", ()=>unwatchDirectory(relativeDir));
|
|
119
|
-
directoryWatchers.set(relativeDir, watcher);
|
|
120
|
-
} catch {
|
|
121
|
-
// The directory vanished before we could watch it; its unlink event covers it.
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
const unwatchDirectory = (relativeDir)=>{
|
|
125
|
-
for (const [watchedDir, watcher] of directoryWatchers){
|
|
126
|
-
if (watchedDir === relativeDir || watchedDir.startsWith(`${relativeDir}/`)) {
|
|
127
|
-
watcher.close();
|
|
128
|
-
directoryWatchers.delete(watchedDir);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
/** A directory appeared: watch it, and report what was created in it before we were watching. */ const addDirectory = (relativeDir)=>{
|
|
133
|
-
watchDirectory(relativeDir);
|
|
134
|
-
const found = new Map();
|
|
135
|
-
try {
|
|
136
|
-
collectSnapshotEntries(directory, _nodepath.default.resolve(directory, relativeDir), found);
|
|
137
|
-
} catch {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
for (const [relativePath, entry] of found){
|
|
141
|
-
if (snapshot.has(relativePath)) continue;
|
|
142
|
-
snapshot.set(relativePath, entry);
|
|
143
|
-
if (entry.isDirectory) watchDirectory(relativePath);
|
|
144
|
-
emit(entry.isDirectory ? "addDir" : "add", relativePath);
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
/** A directory went away: stop watching it and forget everything that was under it. */ const removeDirectoryContents = (relativeDir)=>{
|
|
148
|
-
unwatchDirectory(relativeDir);
|
|
149
|
-
// oxlint-disable-next-line unicorn/no-useless-spread -- iterate a copy: the loop deletes from the snapshot
|
|
150
|
-
for (const [relativePath, entry] of [
|
|
151
|
-
...snapshot
|
|
152
|
-
]){
|
|
153
|
-
if (relativePath.startsWith(`${relativeDir}/`)) {
|
|
154
|
-
snapshot.delete(relativePath);
|
|
155
|
-
emit(entry.isDirectory ? "unlinkDir" : "unlink", relativePath);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
const onFsEvent = (eventPath)=>{
|
|
160
|
-
const relativePath = eventPath === "." ? "" : eventPath;
|
|
161
|
-
if (relativePath.length === 0) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const fullPath = _nodepath.default.resolve(directory, relativePath);
|
|
165
|
-
const previous = snapshot.get(relativePath);
|
|
166
|
-
try {
|
|
167
|
-
const stat = (0, _nodefs.statSync)(fullPath);
|
|
168
|
-
const current = toSnapshotEntry(stat);
|
|
169
|
-
snapshot.set(relativePath, current);
|
|
170
|
-
if (previous == null) {
|
|
171
|
-
emit(current.isDirectory ? "addDir" : "add", relativePath);
|
|
172
|
-
if (current.isDirectory) addDirectory(relativePath);
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
if (previous.isDirectory !== current.isDirectory) {
|
|
176
|
-
if (previous.isDirectory) removeDirectoryContents(relativePath);
|
|
177
|
-
emit(previous.isDirectory ? "unlinkDir" : "unlink", relativePath);
|
|
178
|
-
emit(current.isDirectory ? "addDir" : "add", relativePath);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (!current.isDirectory && previous.fingerprint !== current.fingerprint) {
|
|
182
|
-
emitChange(relativePath);
|
|
183
|
-
}
|
|
184
|
-
} catch {
|
|
185
|
-
if (previous == null) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
snapshot.delete(relativePath);
|
|
189
|
-
const pending = pendingChangeTimers.get(relativePath);
|
|
190
|
-
if (pending != null) {
|
|
191
|
-
clearTimeout(pending);
|
|
192
|
-
pendingChangeTimers.delete(relativePath);
|
|
193
|
-
}
|
|
194
|
-
emit(previous.isDirectory ? "unlinkDir" : "unlink", relativePath);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
watchDirectory("");
|
|
198
|
-
for (const [relativePath, entry] of snapshot){
|
|
199
|
-
if (entry.isDirectory) watchDirectory(relativePath);
|
|
200
|
-
}
|
|
201
|
-
const watchApi = {
|
|
202
|
-
ready,
|
|
203
|
-
on (event, handler) {
|
|
204
|
-
if (event === "ready") {
|
|
205
|
-
handlers.ready.add(handler);
|
|
206
|
-
return watchApi;
|
|
207
|
-
}
|
|
208
|
-
handlers[event].add(handler);
|
|
209
|
-
return watchApi;
|
|
210
|
-
},
|
|
211
|
-
close: ()=>{
|
|
212
|
-
for (const pending of pendingChangeTimers.values()){
|
|
213
|
-
clearTimeout(pending);
|
|
214
|
-
}
|
|
215
|
-
pendingChangeTimers.clear();
|
|
216
|
-
for (const watcher of directoryWatchers.values()){
|
|
217
|
-
watcher.close();
|
|
218
|
-
}
|
|
219
|
-
directoryWatchers.clear();
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
return watchApi;
|
|
223
|
-
}
|
|
224
|
-
function buildSnapshot(directoryPath) {
|
|
225
|
-
const snapshot = new Map();
|
|
226
|
-
collectSnapshotEntries(directoryPath, directoryPath, snapshot);
|
|
227
|
-
return snapshot;
|
|
228
|
-
}
|
|
229
|
-
/** Never source, and huge: watching every folder inside them could exhaust OS watch limits. */ const UNWATCHED_DIRECTORIES = new Set([
|
|
230
|
-
"node_modules",
|
|
231
|
-
".git"
|
|
232
|
-
]);
|
|
233
|
-
function collectSnapshotEntries(rootDirectoryPath, currentDirectoryPath, snapshot) {
|
|
234
|
-
for (const entry of (0, _nodefs.readdirSync)(currentDirectoryPath, {
|
|
235
|
-
encoding: "utf8"
|
|
236
|
-
})){
|
|
237
|
-
const name = typeof entry === "string" ? entry : String(entry);
|
|
238
|
-
const fullPath = _nodepath.default.join(currentDirectoryPath, name);
|
|
239
|
-
if (UNWATCHED_DIRECTORIES.has(name)) {
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
const relativePath = toPosixPath(_nodepath.default.relative(rootDirectoryPath, fullPath));
|
|
243
|
-
const stat = (0, _nodefs.statSync)(fullPath);
|
|
244
|
-
const snapshotEntry = toSnapshotEntry(stat);
|
|
245
|
-
snapshot.set(relativePath, snapshotEntry);
|
|
246
|
-
if (!snapshotEntry.isDirectory) {
|
|
247
|
-
continue;
|
|
248
|
-
}
|
|
249
|
-
collectSnapshotEntries(rootDirectoryPath, fullPath, snapshot);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
function toSnapshotEntry(stat) {
|
|
253
|
-
const isDirectory = stat.isDirectory();
|
|
254
|
-
return {
|
|
255
|
-
isDirectory,
|
|
256
|
-
fingerprint: isDirectory ? `dir:${stat.mtimeMs}` : `file:${stat.mtimeMs}:${stat.size}`
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
function toPosixPath(filePath) {
|
|
260
|
-
return filePath.split(_nodepath.default.sep).join(_nodepath.default.posix.sep);
|
|
261
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./semver.js"), exports);
|
|
6
|
-
function _export_star(from, to) {
|
|
7
|
-
Object.keys(from).forEach(function(k) {
|
|
8
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
-
Object.defineProperty(to, k, {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function() {
|
|
12
|
-
return from[k];
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return from;
|
|
18
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get Semver () {
|
|
13
|
-
return Semver;
|
|
14
|
-
},
|
|
15
|
-
get SemverError () {
|
|
16
|
-
return SemverError;
|
|
17
|
-
},
|
|
18
|
-
get VersionTypes () {
|
|
19
|
-
return VersionTypes;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const VersionTypes = {
|
|
23
|
-
major: "major",
|
|
24
|
-
minor: "minor",
|
|
25
|
-
patch: "patch",
|
|
26
|
-
prerelease: "prerelease"
|
|
27
|
-
};
|
|
28
|
-
class SemverError extends Error {
|
|
29
|
-
constructor(message){
|
|
30
|
-
super(message);
|
|
31
|
-
this.name = SemverError.name;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
const SEMVER_REGEX = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
|
|
35
|
-
class Semver {
|
|
36
|
-
version;
|
|
37
|
-
constructor(version){
|
|
38
|
-
this.ensureValid(version);
|
|
39
|
-
this.version = version;
|
|
40
|
-
}
|
|
41
|
-
increment(versionType, preid = "pre") {
|
|
42
|
-
const { major, minor, patch, prerelease } = this.parse(this.version);
|
|
43
|
-
if (versionType === "major") {
|
|
44
|
-
this.version = `${major + 1}.0.0`;
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
if (versionType === "minor") {
|
|
48
|
-
this.version = `${major}.${minor + 1}.0`;
|
|
49
|
-
return this;
|
|
50
|
-
}
|
|
51
|
-
if (versionType === "patch") {
|
|
52
|
-
this.version = `${major}.${minor}.${patch + 1}`;
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
if (prerelease == null) {
|
|
56
|
-
this.version = `${major}.${minor}.${patch + 1}-${preid}.0`;
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
const [identifier, ...rest] = prerelease.split(".");
|
|
60
|
-
const maybeCounter = rest.at(-1);
|
|
61
|
-
const counter = maybeCounter != null ? Number.parseInt(maybeCounter, 10) : Number.NaN;
|
|
62
|
-
if (identifier === preid && Number.isFinite(counter)) {
|
|
63
|
-
const nextCounter = counter + 1;
|
|
64
|
-
const prefix = rest.length > 1 ? `${rest.slice(0, -1).join(".")}.` : "";
|
|
65
|
-
this.version = `${major}.${minor}.${patch}-${preid}.${prefix}${nextCounter}`;
|
|
66
|
-
return this;
|
|
67
|
-
}
|
|
68
|
-
this.version = `${major}.${minor}.${patch}-${preid}.0`;
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
toString() {
|
|
72
|
-
return this.version;
|
|
73
|
-
}
|
|
74
|
-
ensureValid(version) {
|
|
75
|
-
if (SEMVER_REGEX.test(version)) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
throw new SemverError(`Invalid semantic version: ${version}`);
|
|
79
|
-
}
|
|
80
|
-
parse(version) {
|
|
81
|
-
const match = version.match(SEMVER_REGEX);
|
|
82
|
-
if (match == null) {
|
|
83
|
-
throw new SemverError(`Invalid semantic version: ${version}`);
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
major: Number.parseInt(match[1], 10),
|
|
87
|
-
minor: Number.parseInt(match[2], 10),
|
|
88
|
-
patch: Number.parseInt(match[3], 10),
|
|
89
|
-
prerelease: match[4]
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "flushPromises", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return flushPromises;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
var scheduler = typeof setImmediate === "function" ? setImmediate : setTimeout;
|
|
12
|
-
function flushPromises() {
|
|
13
|
-
return new Promise((resolve)=>{
|
|
14
|
-
scheduler(resolve);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "withMemfsFsForGlob", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return withMemfsFsForGlob;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _memfs = require("memfs");
|
|
12
|
-
function withMemfsFsForGlob(actual) {
|
|
13
|
-
// Preserve all module exports, overriding only `glob` to force `{ fs: memfs }`.
|
|
14
|
-
const glob = (pattern, options)=>actual.glob(pattern, {
|
|
15
|
-
...options,
|
|
16
|
-
fs: _memfs.fs
|
|
17
|
-
});
|
|
18
|
-
return {
|
|
19
|
-
...actual,
|
|
20
|
-
glob
|
|
21
|
-
};
|
|
22
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./flush-promises.js"), exports);
|
|
6
|
-
_export_star(require("./glob-with-memfs.js"), exports);
|
|
7
|
-
_export_star(require("./memfs.js"), exports);
|
|
8
|
-
_export_star(require("./mock-logger.js"), exports);
|
|
9
|
-
_export_star(require("./spy-on-constructor.js"), exports);
|
|
10
|
-
function _export_star(from, to) {
|
|
11
|
-
Object.keys(from).forEach(function(k) {
|
|
12
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
13
|
-
Object.defineProperty(to, k, {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function() {
|
|
16
|
-
return from[k];
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
return from;
|
|
22
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get createTestFile () {
|
|
13
|
-
return createTestFile;
|
|
14
|
-
},
|
|
15
|
-
get fileExists () {
|
|
16
|
-
return fileExists;
|
|
17
|
-
},
|
|
18
|
-
get readFile () {
|
|
19
|
-
return readFile;
|
|
20
|
-
},
|
|
21
|
-
get resetMemfs () {
|
|
22
|
-
return resetMemfs;
|
|
23
|
-
},
|
|
24
|
-
get seedMemfs () {
|
|
25
|
-
return seedMemfs;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
const _memfs = require("memfs");
|
|
29
|
-
function resetMemfs() {
|
|
30
|
-
_memfs.vol.reset();
|
|
31
|
-
}
|
|
32
|
-
function seedMemfs(files) {
|
|
33
|
-
_memfs.vol.fromJSON(files);
|
|
34
|
-
}
|
|
35
|
-
function createTestFile(filePath, content) {
|
|
36
|
-
_memfs.fs.mkdirSync(filePath.substring(0, filePath.lastIndexOf("/")), {
|
|
37
|
-
recursive: true
|
|
38
|
-
});
|
|
39
|
-
_memfs.fs.writeFileSync(filePath, content);
|
|
40
|
-
}
|
|
41
|
-
async function readFile(filePath) {
|
|
42
|
-
const response = await _memfs.fs.promises.readFile(filePath, "utf8");
|
|
43
|
-
return response;
|
|
44
|
-
}
|
|
45
|
-
function fileExists(filePath) {
|
|
46
|
-
try {
|
|
47
|
-
_memfs.vol.statSync(filePath);
|
|
48
|
-
return true;
|
|
49
|
-
} catch {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "createMockLogger", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return createMockLogger;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _vitest = require("vitest");
|
|
12
|
-
const DefaultLogLevels = {
|
|
13
|
-
fatal: 60,
|
|
14
|
-
error: 50,
|
|
15
|
-
warn: 40,
|
|
16
|
-
info: 30,
|
|
17
|
-
debug: 20,
|
|
18
|
-
trace: 10
|
|
19
|
-
};
|
|
20
|
-
function createMockLogger() {
|
|
21
|
-
return {
|
|
22
|
-
error: _vitest.vi.fn(),
|
|
23
|
-
info: _vitest.vi.fn(),
|
|
24
|
-
warn: _vitest.vi.fn(),
|
|
25
|
-
debug: _vitest.vi.fn(),
|
|
26
|
-
trace: _vitest.vi.fn(),
|
|
27
|
-
fatal: _vitest.vi.fn(),
|
|
28
|
-
isLevelEnabled: _vitest.vi.fn().mockReturnValue(true),
|
|
29
|
-
get currentLevel () {
|
|
30
|
-
return "info";
|
|
31
|
-
},
|
|
32
|
-
get logLevels () {
|
|
33
|
-
return DefaultLogLevels;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "spyOnConstructor", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return spyOnConstructor;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _vitest = require("vitest");
|
|
12
|
-
function spyOnConstructor(Target) {
|
|
13
|
-
const spy = _vitest.vi.fn();
|
|
14
|
-
const ProxiedTarget = new Proxy(Target, {
|
|
15
|
-
construct (Ctor, args) {
|
|
16
|
-
spy(...args);
|
|
17
|
-
return Reflect.construct(Ctor, args);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
for (const key of Reflect.getMetadataKeys(Target)){
|
|
21
|
-
Reflect.defineMetadata(key, Reflect.getMetadata(key, Target), ProxiedTarget);
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
spy,
|
|
25
|
-
Proxy: ProxiedTarget
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import NodeCache from "@cacheable/node-cache";
|
|
2
|
-
/**
|
|
3
|
-
* NodeCache adapter configured for memoization (useClones: false)
|
|
4
|
-
* This allows storing object references instead of clones for true memoization
|
|
5
|
-
*/ export class NodeCacheAdapter {
|
|
6
|
-
static create(options = {
|
|
7
|
-
enableMemoization: false
|
|
8
|
-
}) {
|
|
9
|
-
const nodeCache = new NodeCache({
|
|
10
|
-
useClones: !options.enableMemoization
|
|
11
|
-
});
|
|
12
|
-
return new NodeCacheAdapter(nodeCache);
|
|
13
|
-
}
|
|
14
|
-
supportsMemoization = true;
|
|
15
|
-
cache;
|
|
16
|
-
constructor(inst = new NodeCache()){
|
|
17
|
-
this.cache = inst;
|
|
18
|
-
}
|
|
19
|
-
get isMemoize() {
|
|
20
|
-
return !this.cache.options.useClones;
|
|
21
|
-
}
|
|
22
|
-
get(key) {
|
|
23
|
-
return this.cache.get(key);
|
|
24
|
-
}
|
|
25
|
-
set(key, value) {
|
|
26
|
-
this.cache.set(key, value);
|
|
27
|
-
}
|
|
28
|
-
has(key) {
|
|
29
|
-
return this.cache.has(key);
|
|
30
|
-
}
|
|
31
|
-
del(key) {
|
|
32
|
-
this.cache.del(key);
|
|
33
|
-
}
|
|
34
|
-
flushAll() {
|
|
35
|
-
this.cache.flushAll();
|
|
36
|
-
}
|
|
37
|
-
}
|
package/es6/src/cli/action.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export const ActionMap = Symbol("ActionMap");
|
|
2
|
-
export class ActionResponse {
|
|
3
|
-
static Success(name, data) {
|
|
4
|
-
return new ActionResponse({
|
|
5
|
-
name,
|
|
6
|
-
data,
|
|
7
|
-
succeeded: true
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
static Skipped(name) {
|
|
11
|
-
return new ActionResponse({
|
|
12
|
-
name,
|
|
13
|
-
skipped: true
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
static Blocking(name) {
|
|
17
|
-
return new ActionResponse({
|
|
18
|
-
name,
|
|
19
|
-
succeeded: true,
|
|
20
|
-
blocking: true
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
static Error(name, messageOrData, data) {
|
|
24
|
-
if (Array.isArray(messageOrData)) {
|
|
25
|
-
const message = messageOrData.filter((r)=>!r.succeeded).map((r)=>r.error ?? "Unknown error").join("\n");
|
|
26
|
-
return new ActionResponse({
|
|
27
|
-
name,
|
|
28
|
-
message,
|
|
29
|
-
data: messageOrData
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return new ActionResponse({
|
|
33
|
-
name,
|
|
34
|
-
message: messageOrData,
|
|
35
|
-
data
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
constructor(data){
|
|
39
|
-
Object.assign(this, data);
|
|
40
|
-
}
|
|
41
|
-
name;
|
|
42
|
-
succeeded = false;
|
|
43
|
-
skipped = false;
|
|
44
|
-
blocking = false;
|
|
45
|
-
message;
|
|
46
|
-
data;
|
|
47
|
-
}
|