@craft_eco/craft-mcp 0.1.29 → 0.1.30
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 +10 -55
- package/bin/craft-mcp.mjs +4 -1
- package/dist-server/game-workflow/check.mjs +3 -2
- package/dist-server/game-workflow/context-state.mjs +67 -67
- package/dist-server/game-workflow/draft-archive.mjs +147 -2
- package/dist-server/game-workflow/draft-upload-identity.mjs +11 -0
- package/dist-server/game-workflow/draft-uploads.mjs +105 -60
- package/dist-server/game-workflow/local-context.mjs +62 -62
- package/dist-server/game-workflow/native-context.mjs +289 -289
- package/dist-server/game-workflow/project-bundles.mjs +246 -246
- package/dist-server/game-workflow/project-context.mjs +8 -8
- package/dist-server/game-workflow/projects.mjs +6 -4
- package/dist-server/game-workflow/tasks.mjs +1 -1
- package/dist-server/game-workflow/work-scope.mjs +7 -7
- package/dist-server/integrations/config.mjs +145 -145
- package/dist-server/integrations/connect.mjs +36 -0
- package/dist-server/integrations/connection-handoff.mjs +36 -42
- package/dist-server/integrations/dsh-config.mjs +182 -182
- package/dist-server/integrations/files.mjs +54 -54
- package/dist-server/integrations/fixed-launcher.mjs +31 -0
- package/dist-server/integrations/host-reload.mjs +19 -0
- package/dist-server/integrations/hosts.mjs +55 -55
- package/dist-server/integrations/install.mjs +223 -205
- package/dist-server/integrations/installation-state.mjs +84 -84
- package/dist-server/integrations/launcher-start.mjs +52 -0
- package/dist-server/integrations/npm-diagnostics.mjs +32 -0
- package/dist-server/integrations/runtime-gc.mjs +191 -188
- package/dist-server/integrations/runtime-identity.mjs +22 -0
- package/dist-server/integrations/runtime.mjs +111 -126
- package/dist-server/integrations/updates.mjs +258 -225
- package/dist-server/integrations/version-policy.mjs +32 -32
- package/dist-server/launcher.mjs +1845 -0
- package/dist-server/mcp/control-panel.mjs +8 -23
- package/dist-server/mcp/server.mjs +31 -80
- package/dist-server/mcp/update-session.mjs +107 -92
- package/dist-server/upstream/craft-aigc.mjs +43 -16
- package/dist-server/upstream/draft-source.mjs +29 -0
- package/package.json +3 -2
- package/resources/context-filter-report.json +1 -1
- package/resources/craft-create/SKILL.md +19 -19
- package/resources/craft-update/SKILL.md +9 -11
- package/resources/targets/claude/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/claude/js/context-filter-report.json +1 -1
- package/resources/targets/claude/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/claude/js/js/bundle.json +7 -7
- package/resources/targets/claude/js/recovery.md +5 -1
- package/resources/targets/claude/js/target.json +1 -1
- package/resources/targets/claude/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/claude/js3d/context-filter-report.json +1 -1
- package/resources/targets/claude/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/claude/js3d/js3d/bundle.json +7 -7
- package/resources/targets/claude/js3d/recovery.md +5 -1
- package/resources/targets/claude/js3d/target.json +1 -1
- package/resources/targets/codebuddy/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/codebuddy/js/context-filter-report.json +1 -1
- package/resources/targets/codebuddy/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/codebuddy/js/js/bundle.json +7 -7
- package/resources/targets/codebuddy/js/recovery.md +5 -1
- package/resources/targets/codebuddy/js/target.json +1 -1
- package/resources/targets/codebuddy/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/codebuddy/js3d/context-filter-report.json +1 -1
- package/resources/targets/codebuddy/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/codebuddy/js3d/js3d/bundle.json +7 -7
- package/resources/targets/codebuddy/js3d/recovery.md +5 -1
- package/resources/targets/codebuddy/js3d/target.json +1 -1
- package/resources/targets/codex/js/bootstrap/SKILL.md +2 -4
- package/resources/targets/codex/js/context-filter-report.json +1 -1
- package/resources/targets/codex/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/codex/js/js/bundle.json +7 -7
- package/resources/targets/codex/js/recovery.md +3 -3
- package/resources/targets/codex/js/target.json +1 -1
- package/resources/targets/codex/js3d/bootstrap/SKILL.md +2 -4
- package/resources/targets/codex/js3d/context-filter-report.json +1 -1
- package/resources/targets/codex/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/codex/js3d/js3d/bundle.json +7 -7
- package/resources/targets/codex/js3d/recovery.md +3 -3
- package/resources/targets/codex/js3d/target.json +1 -1
- package/resources/targets/cursor/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/cursor/js/context-filter-report.json +1 -1
- package/resources/targets/cursor/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/cursor/js/js/bundle.json +7 -7
- package/resources/targets/cursor/js/recovery.md +5 -1
- package/resources/targets/cursor/js/target.json +1 -1
- package/resources/targets/cursor/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/cursor/js3d/context-filter-report.json +1 -1
- package/resources/targets/cursor/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/cursor/js3d/js3d/bundle.json +7 -7
- package/resources/targets/cursor/js3d/recovery.md +5 -1
- package/resources/targets/cursor/js3d/target.json +1 -1
- package/resources/targets/dsh/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/dsh/js/context-filter-report.json +1 -1
- package/resources/targets/dsh/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/dsh/js/js/bundle.json +7 -7
- package/resources/targets/dsh/js/recovery.md +5 -1
- package/resources/targets/dsh/js/target.json +1 -1
- package/resources/targets/dsh/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/dsh/js3d/context-filter-report.json +1 -1
- package/resources/targets/dsh/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/dsh/js3d/js3d/bundle.json +7 -7
- package/resources/targets/dsh/js3d/recovery.md +5 -1
- package/resources/targets/dsh/js3d/target.json +1 -1
- package/resources/targets/index.json +32 -32
- package/resources/targets/kimi/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/kimi/js/context-filter-report.json +1 -1
- package/resources/targets/kimi/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/kimi/js/js/bundle.json +7 -7
- package/resources/targets/kimi/js/recovery.md +5 -1
- package/resources/targets/kimi/js/target.json +1 -1
- package/resources/targets/kimi/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/kimi/js3d/context-filter-report.json +1 -1
- package/resources/targets/kimi/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/kimi/js3d/js3d/bundle.json +7 -7
- package/resources/targets/kimi/js3d/recovery.md +5 -1
- package/resources/targets/kimi/js3d/target.json +1 -1
- package/resources/targets/workbuddy/js/bootstrap/SKILL.md +22 -24
- package/resources/targets/workbuddy/js/context-filter-report.json +1 -1
- package/resources/targets/workbuddy/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/workbuddy/js/js/bundle.json +8 -8
- package/resources/targets/workbuddy/js/js/context/AGENTS.md +29 -29
- package/resources/targets/workbuddy/js/recovery.md +19 -19
- package/resources/targets/workbuddy/js/target.json +1 -1
- package/resources/targets/workbuddy/js3d/bootstrap/SKILL.md +22 -24
- package/resources/targets/workbuddy/js3d/context-filter-report.json +1 -1
- package/resources/targets/workbuddy/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/workbuddy/js3d/js3d/bundle.json +8 -8
- package/resources/targets/workbuddy/js3d/js3d/context/AGENTS.md +30 -30
- package/resources/targets/workbuddy/js3d/recovery.md +19 -19
- package/resources/targets/workbuddy/js3d/target.json +1 -1
- package/resources/targets/zcode/js/bootstrap/SKILL.md +3 -1
- package/resources/targets/zcode/js/context-filter-report.json +1 -1
- package/resources/targets/zcode/js/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/zcode/js/js/bundle.json +7 -7
- package/resources/targets/zcode/js/recovery.md +5 -1
- package/resources/targets/zcode/js/target.json +1 -1
- package/resources/targets/zcode/js3d/bootstrap/SKILL.md +3 -1
- package/resources/targets/zcode/js3d/context-filter-report.json +1 -1
- package/resources/targets/zcode/js3d/craft-game-maker/SKILL.md +11 -15
- package/resources/targets/zcode/js3d/js3d/bundle.json +7 -7
- package/resources/targets/zcode/js3d/recovery.md +5 -1
- package/resources/targets/zcode/js3d/target.json +1 -1
- package/vendor/craft-runtime/SOURCE.json +4 -4
- package/vendor/craft-runtime/package.json +1 -1
- package/dist-server/game-workflow/publication-materials.mjs +0 -92
- package/dist-server/game-workflow/publications.mjs +0 -168
- package/dist-server/game-workflow/publish-capture-worker.mjs +0 -57
- package/dist-server/game-workflow/publish-capture.mjs +0 -75
- package/dist-server/mcp/publication-page.html +0 -86
- package/dist-server/mcp/publication-page.mjs +0 -375
- package/dist-server/mcp/publication-preview.mjs +0 -63
- package/dist-server/mcp/publication-tools.mjs +0 -22
- package/dist-server/mcp/publish-panel.mjs +0 -210
- package/dist-server/upstream/publication-transport.mjs +0 -101
|
@@ -0,0 +1,1845 @@
|
|
|
1
|
+
// craft-mcp:launcher:v1
|
|
2
|
+
import { createRequire as launcherRequire } from "node:module"; const require = launcherRequire(import.meta.url);
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
15
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
34
|
+
|
|
35
|
+
// node_modules/graceful-fs/polyfills.js
|
|
36
|
+
var require_polyfills = __commonJS({
|
|
37
|
+
"node_modules/graceful-fs/polyfills.js"(exports, module) {
|
|
38
|
+
var constants = __require("constants");
|
|
39
|
+
var origCwd = process.cwd;
|
|
40
|
+
var cwd = null;
|
|
41
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
42
|
+
process.cwd = function() {
|
|
43
|
+
if (!cwd)
|
|
44
|
+
cwd = origCwd.call(process);
|
|
45
|
+
return cwd;
|
|
46
|
+
};
|
|
47
|
+
try {
|
|
48
|
+
process.cwd();
|
|
49
|
+
} catch (er) {
|
|
50
|
+
}
|
|
51
|
+
if (typeof process.chdir === "function") {
|
|
52
|
+
chdir = process.chdir;
|
|
53
|
+
process.chdir = function(d) {
|
|
54
|
+
cwd = null;
|
|
55
|
+
chdir.call(process, d);
|
|
56
|
+
};
|
|
57
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
58
|
+
}
|
|
59
|
+
var chdir;
|
|
60
|
+
module.exports = patch;
|
|
61
|
+
function patch(fs) {
|
|
62
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
63
|
+
patchLchmod(fs);
|
|
64
|
+
}
|
|
65
|
+
if (!fs.lutimes) {
|
|
66
|
+
patchLutimes(fs);
|
|
67
|
+
}
|
|
68
|
+
fs.chown = chownFix(fs.chown);
|
|
69
|
+
fs.fchown = chownFix(fs.fchown);
|
|
70
|
+
fs.lchown = chownFix(fs.lchown);
|
|
71
|
+
fs.chmod = chmodFix(fs.chmod);
|
|
72
|
+
fs.fchmod = chmodFix(fs.fchmod);
|
|
73
|
+
fs.lchmod = chmodFix(fs.lchmod);
|
|
74
|
+
fs.chownSync = chownFixSync(fs.chownSync);
|
|
75
|
+
fs.fchownSync = chownFixSync(fs.fchownSync);
|
|
76
|
+
fs.lchownSync = chownFixSync(fs.lchownSync);
|
|
77
|
+
fs.chmodSync = chmodFixSync(fs.chmodSync);
|
|
78
|
+
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
|
|
79
|
+
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
|
|
80
|
+
fs.stat = statFix(fs.stat);
|
|
81
|
+
fs.fstat = statFix(fs.fstat);
|
|
82
|
+
fs.lstat = statFix(fs.lstat);
|
|
83
|
+
fs.statSync = statFixSync(fs.statSync);
|
|
84
|
+
fs.fstatSync = statFixSync(fs.fstatSync);
|
|
85
|
+
fs.lstatSync = statFixSync(fs.lstatSync);
|
|
86
|
+
if (fs.chmod && !fs.lchmod) {
|
|
87
|
+
fs.lchmod = function(path6, mode, cb) {
|
|
88
|
+
if (cb) process.nextTick(cb);
|
|
89
|
+
};
|
|
90
|
+
fs.lchmodSync = function() {
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
if (fs.chown && !fs.lchown) {
|
|
94
|
+
fs.lchown = function(path6, uid, gid, cb) {
|
|
95
|
+
if (cb) process.nextTick(cb);
|
|
96
|
+
};
|
|
97
|
+
fs.lchownSync = function() {
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (platform === "win32") {
|
|
101
|
+
fs.rename = typeof fs.rename !== "function" ? fs.rename : (function(fs$rename) {
|
|
102
|
+
function rename2(from, to, cb) {
|
|
103
|
+
var start2 = Date.now();
|
|
104
|
+
var backoff = 0;
|
|
105
|
+
fs$rename(from, to, function CB(er) {
|
|
106
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start2 < 6e4) {
|
|
107
|
+
setTimeout(function() {
|
|
108
|
+
fs.stat(to, function(stater, st) {
|
|
109
|
+
if (stater && stater.code === "ENOENT")
|
|
110
|
+
fs$rename(from, to, CB);
|
|
111
|
+
else
|
|
112
|
+
cb(er);
|
|
113
|
+
});
|
|
114
|
+
}, backoff);
|
|
115
|
+
if (backoff < 100)
|
|
116
|
+
backoff += 10;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (cb) cb(er);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename2, fs$rename);
|
|
123
|
+
return rename2;
|
|
124
|
+
})(fs.rename);
|
|
125
|
+
}
|
|
126
|
+
fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
|
|
127
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
128
|
+
var callback;
|
|
129
|
+
if (callback_ && typeof callback_ === "function") {
|
|
130
|
+
var eagCounter = 0;
|
|
131
|
+
callback = function(er, _, __) {
|
|
132
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
133
|
+
eagCounter++;
|
|
134
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
135
|
+
}
|
|
136
|
+
callback_.apply(this, arguments);
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
140
|
+
}
|
|
141
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
142
|
+
return read;
|
|
143
|
+
})(fs.read);
|
|
144
|
+
fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : /* @__PURE__ */ (function(fs$readSync) {
|
|
145
|
+
return function(fd, buffer, offset, length, position) {
|
|
146
|
+
var eagCounter = 0;
|
|
147
|
+
while (true) {
|
|
148
|
+
try {
|
|
149
|
+
return fs$readSync.call(fs, fd, buffer, offset, length, position);
|
|
150
|
+
} catch (er) {
|
|
151
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
152
|
+
eagCounter++;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
throw er;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
})(fs.readSync);
|
|
160
|
+
function patchLchmod(fs2) {
|
|
161
|
+
fs2.lchmod = function(path6, mode, callback) {
|
|
162
|
+
fs2.open(
|
|
163
|
+
path6,
|
|
164
|
+
constants.O_WRONLY | constants.O_SYMLINK,
|
|
165
|
+
mode,
|
|
166
|
+
function(err, fd) {
|
|
167
|
+
if (err) {
|
|
168
|
+
if (callback) callback(err);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
fs2.fchmod(fd, mode, function(err2) {
|
|
172
|
+
fs2.close(fd, function(err22) {
|
|
173
|
+
if (callback) callback(err2 || err22);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
fs2.lchmodSync = function(path6, mode) {
|
|
180
|
+
var fd = fs2.openSync(path6, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
181
|
+
var threw = true;
|
|
182
|
+
var ret;
|
|
183
|
+
try {
|
|
184
|
+
ret = fs2.fchmodSync(fd, mode);
|
|
185
|
+
threw = false;
|
|
186
|
+
} finally {
|
|
187
|
+
if (threw) {
|
|
188
|
+
try {
|
|
189
|
+
fs2.closeSync(fd);
|
|
190
|
+
} catch (er) {
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
fs2.closeSync(fd);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return ret;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function patchLutimes(fs2) {
|
|
200
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
|
|
201
|
+
fs2.lutimes = function(path6, at, mt, cb) {
|
|
202
|
+
fs2.open(path6, constants.O_SYMLINK, function(er, fd) {
|
|
203
|
+
if (er) {
|
|
204
|
+
if (cb) cb(er);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
fs2.futimes(fd, at, mt, function(er2) {
|
|
208
|
+
fs2.close(fd, function(er22) {
|
|
209
|
+
if (cb) cb(er2 || er22);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
fs2.lutimesSync = function(path6, at, mt) {
|
|
215
|
+
var fd = fs2.openSync(path6, constants.O_SYMLINK);
|
|
216
|
+
var ret;
|
|
217
|
+
var threw = true;
|
|
218
|
+
try {
|
|
219
|
+
ret = fs2.futimesSync(fd, at, mt);
|
|
220
|
+
threw = false;
|
|
221
|
+
} finally {
|
|
222
|
+
if (threw) {
|
|
223
|
+
try {
|
|
224
|
+
fs2.closeSync(fd);
|
|
225
|
+
} catch (er) {
|
|
226
|
+
}
|
|
227
|
+
} else {
|
|
228
|
+
fs2.closeSync(fd);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return ret;
|
|
232
|
+
};
|
|
233
|
+
} else if (fs2.futimes) {
|
|
234
|
+
fs2.lutimes = function(_a, _b, _c, cb) {
|
|
235
|
+
if (cb) process.nextTick(cb);
|
|
236
|
+
};
|
|
237
|
+
fs2.lutimesSync = function() {
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function chmodFix(orig) {
|
|
242
|
+
if (!orig) return orig;
|
|
243
|
+
return function(target, mode, cb) {
|
|
244
|
+
return orig.call(fs, target, mode, function(er) {
|
|
245
|
+
if (chownErOk(er)) er = null;
|
|
246
|
+
if (cb) cb.apply(this, arguments);
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function chmodFixSync(orig) {
|
|
251
|
+
if (!orig) return orig;
|
|
252
|
+
return function(target, mode) {
|
|
253
|
+
try {
|
|
254
|
+
return orig.call(fs, target, mode);
|
|
255
|
+
} catch (er) {
|
|
256
|
+
if (!chownErOk(er)) throw er;
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function chownFix(orig) {
|
|
261
|
+
if (!orig) return orig;
|
|
262
|
+
return function(target, uid, gid, cb) {
|
|
263
|
+
return orig.call(fs, target, uid, gid, function(er) {
|
|
264
|
+
if (chownErOk(er)) er = null;
|
|
265
|
+
if (cb) cb.apply(this, arguments);
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function chownFixSync(orig) {
|
|
270
|
+
if (!orig) return orig;
|
|
271
|
+
return function(target, uid, gid) {
|
|
272
|
+
try {
|
|
273
|
+
return orig.call(fs, target, uid, gid);
|
|
274
|
+
} catch (er) {
|
|
275
|
+
if (!chownErOk(er)) throw er;
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function statFix(orig) {
|
|
280
|
+
if (!orig) return orig;
|
|
281
|
+
return function(target, options, cb) {
|
|
282
|
+
if (typeof options === "function") {
|
|
283
|
+
cb = options;
|
|
284
|
+
options = null;
|
|
285
|
+
}
|
|
286
|
+
function callback(er, stats) {
|
|
287
|
+
if (stats) {
|
|
288
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
289
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
290
|
+
}
|
|
291
|
+
if (cb) cb.apply(this, arguments);
|
|
292
|
+
}
|
|
293
|
+
return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
function statFixSync(orig) {
|
|
297
|
+
if (!orig) return orig;
|
|
298
|
+
return function(target, options) {
|
|
299
|
+
var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
|
|
300
|
+
if (stats) {
|
|
301
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
302
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
303
|
+
}
|
|
304
|
+
return stats;
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function chownErOk(er) {
|
|
308
|
+
if (!er)
|
|
309
|
+
return true;
|
|
310
|
+
if (er.code === "ENOSYS")
|
|
311
|
+
return true;
|
|
312
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
313
|
+
if (nonroot) {
|
|
314
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
// node_modules/graceful-fs/legacy-streams.js
|
|
324
|
+
var require_legacy_streams = __commonJS({
|
|
325
|
+
"node_modules/graceful-fs/legacy-streams.js"(exports, module) {
|
|
326
|
+
var Stream = __require("stream").Stream;
|
|
327
|
+
module.exports = legacy;
|
|
328
|
+
function legacy(fs) {
|
|
329
|
+
return {
|
|
330
|
+
ReadStream,
|
|
331
|
+
WriteStream
|
|
332
|
+
};
|
|
333
|
+
function ReadStream(path6, options) {
|
|
334
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path6, options);
|
|
335
|
+
Stream.call(this);
|
|
336
|
+
var self = this;
|
|
337
|
+
this.path = path6;
|
|
338
|
+
this.fd = null;
|
|
339
|
+
this.readable = true;
|
|
340
|
+
this.paused = false;
|
|
341
|
+
this.flags = "r";
|
|
342
|
+
this.mode = 438;
|
|
343
|
+
this.bufferSize = 64 * 1024;
|
|
344
|
+
options = options || {};
|
|
345
|
+
var keys = Object.keys(options);
|
|
346
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
347
|
+
var key = keys[index];
|
|
348
|
+
this[key] = options[key];
|
|
349
|
+
}
|
|
350
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
351
|
+
if (this.start !== void 0) {
|
|
352
|
+
if ("number" !== typeof this.start) {
|
|
353
|
+
throw TypeError("start must be a Number");
|
|
354
|
+
}
|
|
355
|
+
if (this.end === void 0) {
|
|
356
|
+
this.end = Infinity;
|
|
357
|
+
} else if ("number" !== typeof this.end) {
|
|
358
|
+
throw TypeError("end must be a Number");
|
|
359
|
+
}
|
|
360
|
+
if (this.start > this.end) {
|
|
361
|
+
throw new Error("start must be <= end");
|
|
362
|
+
}
|
|
363
|
+
this.pos = this.start;
|
|
364
|
+
}
|
|
365
|
+
if (this.fd !== null) {
|
|
366
|
+
process.nextTick(function() {
|
|
367
|
+
self._read();
|
|
368
|
+
});
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
fs.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
372
|
+
if (err) {
|
|
373
|
+
self.emit("error", err);
|
|
374
|
+
self.readable = false;
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
self.fd = fd;
|
|
378
|
+
self.emit("open", fd);
|
|
379
|
+
self._read();
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
function WriteStream(path6, options) {
|
|
383
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path6, options);
|
|
384
|
+
Stream.call(this);
|
|
385
|
+
this.path = path6;
|
|
386
|
+
this.fd = null;
|
|
387
|
+
this.writable = true;
|
|
388
|
+
this.flags = "w";
|
|
389
|
+
this.encoding = "binary";
|
|
390
|
+
this.mode = 438;
|
|
391
|
+
this.bytesWritten = 0;
|
|
392
|
+
options = options || {};
|
|
393
|
+
var keys = Object.keys(options);
|
|
394
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
395
|
+
var key = keys[index];
|
|
396
|
+
this[key] = options[key];
|
|
397
|
+
}
|
|
398
|
+
if (this.start !== void 0) {
|
|
399
|
+
if ("number" !== typeof this.start) {
|
|
400
|
+
throw TypeError("start must be a Number");
|
|
401
|
+
}
|
|
402
|
+
if (this.start < 0) {
|
|
403
|
+
throw new Error("start must be >= zero");
|
|
404
|
+
}
|
|
405
|
+
this.pos = this.start;
|
|
406
|
+
}
|
|
407
|
+
this.busy = false;
|
|
408
|
+
this._queue = [];
|
|
409
|
+
if (this.fd === null) {
|
|
410
|
+
this._open = fs.open;
|
|
411
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
412
|
+
this.flush();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
// node_modules/graceful-fs/clone.js
|
|
420
|
+
var require_clone = __commonJS({
|
|
421
|
+
"node_modules/graceful-fs/clone.js"(exports, module) {
|
|
422
|
+
"use strict";
|
|
423
|
+
module.exports = clone;
|
|
424
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
425
|
+
return obj.__proto__;
|
|
426
|
+
};
|
|
427
|
+
function clone(obj) {
|
|
428
|
+
if (obj === null || typeof obj !== "object")
|
|
429
|
+
return obj;
|
|
430
|
+
if (obj instanceof Object)
|
|
431
|
+
var copy = { __proto__: getPrototypeOf(obj) };
|
|
432
|
+
else
|
|
433
|
+
var copy = /* @__PURE__ */ Object.create(null);
|
|
434
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
435
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
436
|
+
});
|
|
437
|
+
return copy;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
// node_modules/graceful-fs/graceful-fs.js
|
|
443
|
+
var require_graceful_fs = __commonJS({
|
|
444
|
+
"node_modules/graceful-fs/graceful-fs.js"(exports, module) {
|
|
445
|
+
var fs = __require("fs");
|
|
446
|
+
var polyfills = require_polyfills();
|
|
447
|
+
var legacy = require_legacy_streams();
|
|
448
|
+
var clone = require_clone();
|
|
449
|
+
var util = __require("util");
|
|
450
|
+
var gracefulQueue;
|
|
451
|
+
var previousSymbol;
|
|
452
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
453
|
+
gracefulQueue = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
|
|
454
|
+
previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
|
|
455
|
+
} else {
|
|
456
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
457
|
+
previousSymbol = "___graceful-fs.previous";
|
|
458
|
+
}
|
|
459
|
+
function noop() {
|
|
460
|
+
}
|
|
461
|
+
function publishQueue(context, queue2) {
|
|
462
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
463
|
+
get: function() {
|
|
464
|
+
return queue2;
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
var debug = noop;
|
|
469
|
+
if (util.debuglog)
|
|
470
|
+
debug = util.debuglog("gfs4");
|
|
471
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
472
|
+
debug = function() {
|
|
473
|
+
var m = util.format.apply(util, arguments);
|
|
474
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
475
|
+
console.error(m);
|
|
476
|
+
};
|
|
477
|
+
if (!fs[gracefulQueue]) {
|
|
478
|
+
queue = global[gracefulQueue] || [];
|
|
479
|
+
publishQueue(fs, queue);
|
|
480
|
+
fs.close = (function(fs$close) {
|
|
481
|
+
function close(fd, cb) {
|
|
482
|
+
return fs$close.call(fs, fd, function(err) {
|
|
483
|
+
if (!err) {
|
|
484
|
+
resetQueue();
|
|
485
|
+
}
|
|
486
|
+
if (typeof cb === "function")
|
|
487
|
+
cb.apply(this, arguments);
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
Object.defineProperty(close, previousSymbol, {
|
|
491
|
+
value: fs$close
|
|
492
|
+
});
|
|
493
|
+
return close;
|
|
494
|
+
})(fs.close);
|
|
495
|
+
fs.closeSync = (function(fs$closeSync) {
|
|
496
|
+
function closeSync(fd) {
|
|
497
|
+
fs$closeSync.apply(fs, arguments);
|
|
498
|
+
resetQueue();
|
|
499
|
+
}
|
|
500
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
501
|
+
value: fs$closeSync
|
|
502
|
+
});
|
|
503
|
+
return closeSync;
|
|
504
|
+
})(fs.closeSync);
|
|
505
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
506
|
+
process.on("exit", function() {
|
|
507
|
+
debug(fs[gracefulQueue]);
|
|
508
|
+
__require("assert").equal(fs[gracefulQueue].length, 0);
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
var queue;
|
|
513
|
+
if (!global[gracefulQueue]) {
|
|
514
|
+
publishQueue(global, fs[gracefulQueue]);
|
|
515
|
+
}
|
|
516
|
+
module.exports = patch(clone(fs));
|
|
517
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
|
518
|
+
module.exports = patch(fs);
|
|
519
|
+
fs.__patched = true;
|
|
520
|
+
}
|
|
521
|
+
function patch(fs2) {
|
|
522
|
+
polyfills(fs2);
|
|
523
|
+
fs2.gracefulify = patch;
|
|
524
|
+
fs2.createReadStream = createReadStream;
|
|
525
|
+
fs2.createWriteStream = createWriteStream;
|
|
526
|
+
var fs$readFile = fs2.readFile;
|
|
527
|
+
fs2.readFile = readFile5;
|
|
528
|
+
function readFile5(path6, options, cb) {
|
|
529
|
+
if (typeof options === "function")
|
|
530
|
+
cb = options, options = null;
|
|
531
|
+
return go$readFile(path6, options, cb);
|
|
532
|
+
function go$readFile(path7, options2, cb2, startTime) {
|
|
533
|
+
return fs$readFile(path7, options2, function(err) {
|
|
534
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
535
|
+
enqueue([go$readFile, [path7, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
536
|
+
else {
|
|
537
|
+
if (typeof cb2 === "function")
|
|
538
|
+
cb2.apply(this, arguments);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
var fs$writeFile = fs2.writeFile;
|
|
544
|
+
fs2.writeFile = writeFile3;
|
|
545
|
+
function writeFile3(path6, data, options, cb) {
|
|
546
|
+
if (typeof options === "function")
|
|
547
|
+
cb = options, options = null;
|
|
548
|
+
return go$writeFile(path6, data, options, cb);
|
|
549
|
+
function go$writeFile(path7, data2, options2, cb2, startTime) {
|
|
550
|
+
return fs$writeFile(path7, data2, options2, function(err) {
|
|
551
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
552
|
+
enqueue([go$writeFile, [path7, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
553
|
+
else {
|
|
554
|
+
if (typeof cb2 === "function")
|
|
555
|
+
cb2.apply(this, arguments);
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
var fs$appendFile = fs2.appendFile;
|
|
561
|
+
if (fs$appendFile)
|
|
562
|
+
fs2.appendFile = appendFile;
|
|
563
|
+
function appendFile(path6, data, options, cb) {
|
|
564
|
+
if (typeof options === "function")
|
|
565
|
+
cb = options, options = null;
|
|
566
|
+
return go$appendFile(path6, data, options, cb);
|
|
567
|
+
function go$appendFile(path7, data2, options2, cb2, startTime) {
|
|
568
|
+
return fs$appendFile(path7, data2, options2, function(err) {
|
|
569
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
570
|
+
enqueue([go$appendFile, [path7, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
571
|
+
else {
|
|
572
|
+
if (typeof cb2 === "function")
|
|
573
|
+
cb2.apply(this, arguments);
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
var fs$copyFile = fs2.copyFile;
|
|
579
|
+
if (fs$copyFile)
|
|
580
|
+
fs2.copyFile = copyFile;
|
|
581
|
+
function copyFile(src, dest, flags, cb) {
|
|
582
|
+
if (typeof flags === "function") {
|
|
583
|
+
cb = flags;
|
|
584
|
+
flags = 0;
|
|
585
|
+
}
|
|
586
|
+
return go$copyFile(src, dest, flags, cb);
|
|
587
|
+
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
588
|
+
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
589
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
590
|
+
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
591
|
+
else {
|
|
592
|
+
if (typeof cb2 === "function")
|
|
593
|
+
cb2.apply(this, arguments);
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
var fs$readdir = fs2.readdir;
|
|
599
|
+
fs2.readdir = readdir2;
|
|
600
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
601
|
+
function readdir2(path6, options, cb) {
|
|
602
|
+
if (typeof options === "function")
|
|
603
|
+
cb = options, options = null;
|
|
604
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path7, options2, cb2, startTime) {
|
|
605
|
+
return fs$readdir(path7, fs$readdirCallback(
|
|
606
|
+
path7,
|
|
607
|
+
options2,
|
|
608
|
+
cb2,
|
|
609
|
+
startTime
|
|
610
|
+
));
|
|
611
|
+
} : function go$readdir2(path7, options2, cb2, startTime) {
|
|
612
|
+
return fs$readdir(path7, options2, fs$readdirCallback(
|
|
613
|
+
path7,
|
|
614
|
+
options2,
|
|
615
|
+
cb2,
|
|
616
|
+
startTime
|
|
617
|
+
));
|
|
618
|
+
};
|
|
619
|
+
return go$readdir(path6, options, cb);
|
|
620
|
+
function fs$readdirCallback(path7, options2, cb2, startTime) {
|
|
621
|
+
return function(err, files) {
|
|
622
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
623
|
+
enqueue([
|
|
624
|
+
go$readdir,
|
|
625
|
+
[path7, options2, cb2],
|
|
626
|
+
err,
|
|
627
|
+
startTime || Date.now(),
|
|
628
|
+
Date.now()
|
|
629
|
+
]);
|
|
630
|
+
else {
|
|
631
|
+
if (files && files.sort)
|
|
632
|
+
files.sort();
|
|
633
|
+
if (typeof cb2 === "function")
|
|
634
|
+
cb2.call(this, err, files);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
640
|
+
var legStreams = legacy(fs2);
|
|
641
|
+
ReadStream = legStreams.ReadStream;
|
|
642
|
+
WriteStream = legStreams.WriteStream;
|
|
643
|
+
}
|
|
644
|
+
var fs$ReadStream = fs2.ReadStream;
|
|
645
|
+
if (fs$ReadStream) {
|
|
646
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
647
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
648
|
+
}
|
|
649
|
+
var fs$WriteStream = fs2.WriteStream;
|
|
650
|
+
if (fs$WriteStream) {
|
|
651
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
652
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
653
|
+
}
|
|
654
|
+
Object.defineProperty(fs2, "ReadStream", {
|
|
655
|
+
get: function() {
|
|
656
|
+
return ReadStream;
|
|
657
|
+
},
|
|
658
|
+
set: function(val) {
|
|
659
|
+
ReadStream = val;
|
|
660
|
+
},
|
|
661
|
+
enumerable: true,
|
|
662
|
+
configurable: true
|
|
663
|
+
});
|
|
664
|
+
Object.defineProperty(fs2, "WriteStream", {
|
|
665
|
+
get: function() {
|
|
666
|
+
return WriteStream;
|
|
667
|
+
},
|
|
668
|
+
set: function(val) {
|
|
669
|
+
WriteStream = val;
|
|
670
|
+
},
|
|
671
|
+
enumerable: true,
|
|
672
|
+
configurable: true
|
|
673
|
+
});
|
|
674
|
+
var FileReadStream = ReadStream;
|
|
675
|
+
Object.defineProperty(fs2, "FileReadStream", {
|
|
676
|
+
get: function() {
|
|
677
|
+
return FileReadStream;
|
|
678
|
+
},
|
|
679
|
+
set: function(val) {
|
|
680
|
+
FileReadStream = val;
|
|
681
|
+
},
|
|
682
|
+
enumerable: true,
|
|
683
|
+
configurable: true
|
|
684
|
+
});
|
|
685
|
+
var FileWriteStream = WriteStream;
|
|
686
|
+
Object.defineProperty(fs2, "FileWriteStream", {
|
|
687
|
+
get: function() {
|
|
688
|
+
return FileWriteStream;
|
|
689
|
+
},
|
|
690
|
+
set: function(val) {
|
|
691
|
+
FileWriteStream = val;
|
|
692
|
+
},
|
|
693
|
+
enumerable: true,
|
|
694
|
+
configurable: true
|
|
695
|
+
});
|
|
696
|
+
function ReadStream(path6, options) {
|
|
697
|
+
if (this instanceof ReadStream)
|
|
698
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
699
|
+
else
|
|
700
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
701
|
+
}
|
|
702
|
+
function ReadStream$open() {
|
|
703
|
+
var that = this;
|
|
704
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
705
|
+
if (err) {
|
|
706
|
+
if (that.autoClose)
|
|
707
|
+
that.destroy();
|
|
708
|
+
that.emit("error", err);
|
|
709
|
+
} else {
|
|
710
|
+
that.fd = fd;
|
|
711
|
+
that.emit("open", fd);
|
|
712
|
+
that.read();
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
function WriteStream(path6, options) {
|
|
717
|
+
if (this instanceof WriteStream)
|
|
718
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
719
|
+
else
|
|
720
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
721
|
+
}
|
|
722
|
+
function WriteStream$open() {
|
|
723
|
+
var that = this;
|
|
724
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
725
|
+
if (err) {
|
|
726
|
+
that.destroy();
|
|
727
|
+
that.emit("error", err);
|
|
728
|
+
} else {
|
|
729
|
+
that.fd = fd;
|
|
730
|
+
that.emit("open", fd);
|
|
731
|
+
}
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
function createReadStream(path6, options) {
|
|
735
|
+
return new fs2.ReadStream(path6, options);
|
|
736
|
+
}
|
|
737
|
+
function createWriteStream(path6, options) {
|
|
738
|
+
return new fs2.WriteStream(path6, options);
|
|
739
|
+
}
|
|
740
|
+
var fs$open = fs2.open;
|
|
741
|
+
fs2.open = open;
|
|
742
|
+
function open(path6, flags, mode, cb) {
|
|
743
|
+
if (typeof mode === "function")
|
|
744
|
+
cb = mode, mode = null;
|
|
745
|
+
return go$open(path6, flags, mode, cb);
|
|
746
|
+
function go$open(path7, flags2, mode2, cb2, startTime) {
|
|
747
|
+
return fs$open(path7, flags2, mode2, function(err, fd) {
|
|
748
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
749
|
+
enqueue([go$open, [path7, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
750
|
+
else {
|
|
751
|
+
if (typeof cb2 === "function")
|
|
752
|
+
cb2.apply(this, arguments);
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
return fs2;
|
|
758
|
+
}
|
|
759
|
+
function enqueue(elem) {
|
|
760
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
761
|
+
fs[gracefulQueue].push(elem);
|
|
762
|
+
retry();
|
|
763
|
+
}
|
|
764
|
+
var retryTimer;
|
|
765
|
+
function resetQueue() {
|
|
766
|
+
var now = Date.now();
|
|
767
|
+
for (var i = 0; i < fs[gracefulQueue].length; ++i) {
|
|
768
|
+
if (fs[gracefulQueue][i].length > 2) {
|
|
769
|
+
fs[gracefulQueue][i][3] = now;
|
|
770
|
+
fs[gracefulQueue][i][4] = now;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
retry();
|
|
774
|
+
}
|
|
775
|
+
function retry() {
|
|
776
|
+
clearTimeout(retryTimer);
|
|
777
|
+
retryTimer = void 0;
|
|
778
|
+
if (fs[gracefulQueue].length === 0)
|
|
779
|
+
return;
|
|
780
|
+
var elem = fs[gracefulQueue].shift();
|
|
781
|
+
var fn = elem[0];
|
|
782
|
+
var args = elem[1];
|
|
783
|
+
var err = elem[2];
|
|
784
|
+
var startTime = elem[3];
|
|
785
|
+
var lastTime = elem[4];
|
|
786
|
+
if (startTime === void 0) {
|
|
787
|
+
debug("RETRY", fn.name, args);
|
|
788
|
+
fn.apply(null, args);
|
|
789
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
790
|
+
debug("TIMEOUT", fn.name, args);
|
|
791
|
+
var cb = args.pop();
|
|
792
|
+
if (typeof cb === "function")
|
|
793
|
+
cb.call(null, err);
|
|
794
|
+
} else {
|
|
795
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
796
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
797
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
798
|
+
if (sinceAttempt >= desiredDelay) {
|
|
799
|
+
debug("RETRY", fn.name, args);
|
|
800
|
+
fn.apply(null, args.concat([startTime]));
|
|
801
|
+
} else {
|
|
802
|
+
fs[gracefulQueue].push(elem);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
if (retryTimer === void 0) {
|
|
806
|
+
retryTimer = setTimeout(retry, 0);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
});
|
|
811
|
+
|
|
812
|
+
// node_modules/retry/lib/retry_operation.js
|
|
813
|
+
var require_retry_operation = __commonJS({
|
|
814
|
+
"node_modules/retry/lib/retry_operation.js"(exports, module) {
|
|
815
|
+
function RetryOperation(timeouts, options) {
|
|
816
|
+
if (typeof options === "boolean") {
|
|
817
|
+
options = { forever: options };
|
|
818
|
+
}
|
|
819
|
+
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
820
|
+
this._timeouts = timeouts;
|
|
821
|
+
this._options = options || {};
|
|
822
|
+
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
823
|
+
this._fn = null;
|
|
824
|
+
this._errors = [];
|
|
825
|
+
this._attempts = 1;
|
|
826
|
+
this._operationTimeout = null;
|
|
827
|
+
this._operationTimeoutCb = null;
|
|
828
|
+
this._timeout = null;
|
|
829
|
+
this._operationStart = null;
|
|
830
|
+
if (this._options.forever) {
|
|
831
|
+
this._cachedTimeouts = this._timeouts.slice(0);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
module.exports = RetryOperation;
|
|
835
|
+
RetryOperation.prototype.reset = function() {
|
|
836
|
+
this._attempts = 1;
|
|
837
|
+
this._timeouts = this._originalTimeouts;
|
|
838
|
+
};
|
|
839
|
+
RetryOperation.prototype.stop = function() {
|
|
840
|
+
if (this._timeout) {
|
|
841
|
+
clearTimeout(this._timeout);
|
|
842
|
+
}
|
|
843
|
+
this._timeouts = [];
|
|
844
|
+
this._cachedTimeouts = null;
|
|
845
|
+
};
|
|
846
|
+
RetryOperation.prototype.retry = function(err) {
|
|
847
|
+
if (this._timeout) {
|
|
848
|
+
clearTimeout(this._timeout);
|
|
849
|
+
}
|
|
850
|
+
if (!err) {
|
|
851
|
+
return false;
|
|
852
|
+
}
|
|
853
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
854
|
+
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
855
|
+
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
856
|
+
return false;
|
|
857
|
+
}
|
|
858
|
+
this._errors.push(err);
|
|
859
|
+
var timeout = this._timeouts.shift();
|
|
860
|
+
if (timeout === void 0) {
|
|
861
|
+
if (this._cachedTimeouts) {
|
|
862
|
+
this._errors.splice(this._errors.length - 1, this._errors.length);
|
|
863
|
+
this._timeouts = this._cachedTimeouts.slice(0);
|
|
864
|
+
timeout = this._timeouts.shift();
|
|
865
|
+
} else {
|
|
866
|
+
return false;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
var self = this;
|
|
870
|
+
var timer = setTimeout(function() {
|
|
871
|
+
self._attempts++;
|
|
872
|
+
if (self._operationTimeoutCb) {
|
|
873
|
+
self._timeout = setTimeout(function() {
|
|
874
|
+
self._operationTimeoutCb(self._attempts);
|
|
875
|
+
}, self._operationTimeout);
|
|
876
|
+
if (self._options.unref) {
|
|
877
|
+
self._timeout.unref();
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
self._fn(self._attempts);
|
|
881
|
+
}, timeout);
|
|
882
|
+
if (this._options.unref) {
|
|
883
|
+
timer.unref();
|
|
884
|
+
}
|
|
885
|
+
return true;
|
|
886
|
+
};
|
|
887
|
+
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
888
|
+
this._fn = fn;
|
|
889
|
+
if (timeoutOps) {
|
|
890
|
+
if (timeoutOps.timeout) {
|
|
891
|
+
this._operationTimeout = timeoutOps.timeout;
|
|
892
|
+
}
|
|
893
|
+
if (timeoutOps.cb) {
|
|
894
|
+
this._operationTimeoutCb = timeoutOps.cb;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
var self = this;
|
|
898
|
+
if (this._operationTimeoutCb) {
|
|
899
|
+
this._timeout = setTimeout(function() {
|
|
900
|
+
self._operationTimeoutCb();
|
|
901
|
+
}, self._operationTimeout);
|
|
902
|
+
}
|
|
903
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
904
|
+
this._fn(this._attempts);
|
|
905
|
+
};
|
|
906
|
+
RetryOperation.prototype.try = function(fn) {
|
|
907
|
+
console.log("Using RetryOperation.try() is deprecated");
|
|
908
|
+
this.attempt(fn);
|
|
909
|
+
};
|
|
910
|
+
RetryOperation.prototype.start = function(fn) {
|
|
911
|
+
console.log("Using RetryOperation.start() is deprecated");
|
|
912
|
+
this.attempt(fn);
|
|
913
|
+
};
|
|
914
|
+
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
915
|
+
RetryOperation.prototype.errors = function() {
|
|
916
|
+
return this._errors;
|
|
917
|
+
};
|
|
918
|
+
RetryOperation.prototype.attempts = function() {
|
|
919
|
+
return this._attempts;
|
|
920
|
+
};
|
|
921
|
+
RetryOperation.prototype.mainError = function() {
|
|
922
|
+
if (this._errors.length === 0) {
|
|
923
|
+
return null;
|
|
924
|
+
}
|
|
925
|
+
var counts = {};
|
|
926
|
+
var mainError = null;
|
|
927
|
+
var mainErrorCount = 0;
|
|
928
|
+
for (var i = 0; i < this._errors.length; i++) {
|
|
929
|
+
var error = this._errors[i];
|
|
930
|
+
var message = error.message;
|
|
931
|
+
var count = (counts[message] || 0) + 1;
|
|
932
|
+
counts[message] = count;
|
|
933
|
+
if (count >= mainErrorCount) {
|
|
934
|
+
mainError = error;
|
|
935
|
+
mainErrorCount = count;
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
return mainError;
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
});
|
|
942
|
+
|
|
943
|
+
// node_modules/retry/lib/retry.js
|
|
944
|
+
var require_retry = __commonJS({
|
|
945
|
+
"node_modules/retry/lib/retry.js"(exports) {
|
|
946
|
+
var RetryOperation = require_retry_operation();
|
|
947
|
+
exports.operation = function(options) {
|
|
948
|
+
var timeouts = exports.timeouts(options);
|
|
949
|
+
return new RetryOperation(timeouts, {
|
|
950
|
+
forever: options && options.forever,
|
|
951
|
+
unref: options && options.unref,
|
|
952
|
+
maxRetryTime: options && options.maxRetryTime
|
|
953
|
+
});
|
|
954
|
+
};
|
|
955
|
+
exports.timeouts = function(options) {
|
|
956
|
+
if (options instanceof Array) {
|
|
957
|
+
return [].concat(options);
|
|
958
|
+
}
|
|
959
|
+
var opts = {
|
|
960
|
+
retries: 10,
|
|
961
|
+
factor: 2,
|
|
962
|
+
minTimeout: 1 * 1e3,
|
|
963
|
+
maxTimeout: Infinity,
|
|
964
|
+
randomize: false
|
|
965
|
+
};
|
|
966
|
+
for (var key in options) {
|
|
967
|
+
opts[key] = options[key];
|
|
968
|
+
}
|
|
969
|
+
if (opts.minTimeout > opts.maxTimeout) {
|
|
970
|
+
throw new Error("minTimeout is greater than maxTimeout");
|
|
971
|
+
}
|
|
972
|
+
var timeouts = [];
|
|
973
|
+
for (var i = 0; i < opts.retries; i++) {
|
|
974
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
975
|
+
}
|
|
976
|
+
if (options && options.forever && !timeouts.length) {
|
|
977
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
978
|
+
}
|
|
979
|
+
timeouts.sort(function(a, b) {
|
|
980
|
+
return a - b;
|
|
981
|
+
});
|
|
982
|
+
return timeouts;
|
|
983
|
+
};
|
|
984
|
+
exports.createTimeout = function(attempt, opts) {
|
|
985
|
+
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
986
|
+
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
|
|
987
|
+
timeout = Math.min(timeout, opts.maxTimeout);
|
|
988
|
+
return timeout;
|
|
989
|
+
};
|
|
990
|
+
exports.wrap = function(obj, options, methods) {
|
|
991
|
+
if (options instanceof Array) {
|
|
992
|
+
methods = options;
|
|
993
|
+
options = null;
|
|
994
|
+
}
|
|
995
|
+
if (!methods) {
|
|
996
|
+
methods = [];
|
|
997
|
+
for (var key in obj) {
|
|
998
|
+
if (typeof obj[key] === "function") {
|
|
999
|
+
methods.push(key);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
for (var i = 0; i < methods.length; i++) {
|
|
1004
|
+
var method = methods[i];
|
|
1005
|
+
var original = obj[method];
|
|
1006
|
+
obj[method] = function retryWrapper(original2) {
|
|
1007
|
+
var op = exports.operation(options);
|
|
1008
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
1009
|
+
var callback = args.pop();
|
|
1010
|
+
args.push(function(err) {
|
|
1011
|
+
if (op.retry(err)) {
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
if (err) {
|
|
1015
|
+
arguments[0] = op.mainError();
|
|
1016
|
+
}
|
|
1017
|
+
callback.apply(this, arguments);
|
|
1018
|
+
});
|
|
1019
|
+
op.attempt(function() {
|
|
1020
|
+
original2.apply(obj, args);
|
|
1021
|
+
});
|
|
1022
|
+
}.bind(obj, original);
|
|
1023
|
+
obj[method].options = options;
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
|
|
1029
|
+
// node_modules/retry/index.js
|
|
1030
|
+
var require_retry2 = __commonJS({
|
|
1031
|
+
"node_modules/retry/index.js"(exports, module) {
|
|
1032
|
+
module.exports = require_retry();
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
// node_modules/signal-exit/signals.js
|
|
1037
|
+
var require_signals = __commonJS({
|
|
1038
|
+
"node_modules/signal-exit/signals.js"(exports, module) {
|
|
1039
|
+
module.exports = [
|
|
1040
|
+
"SIGABRT",
|
|
1041
|
+
"SIGALRM",
|
|
1042
|
+
"SIGHUP",
|
|
1043
|
+
"SIGINT",
|
|
1044
|
+
"SIGTERM"
|
|
1045
|
+
];
|
|
1046
|
+
if (process.platform !== "win32") {
|
|
1047
|
+
module.exports.push(
|
|
1048
|
+
"SIGVTALRM",
|
|
1049
|
+
"SIGXCPU",
|
|
1050
|
+
"SIGXFSZ",
|
|
1051
|
+
"SIGUSR2",
|
|
1052
|
+
"SIGTRAP",
|
|
1053
|
+
"SIGSYS",
|
|
1054
|
+
"SIGQUIT",
|
|
1055
|
+
"SIGIOT"
|
|
1056
|
+
// should detect profiler and enable/disable accordingly.
|
|
1057
|
+
// see #21
|
|
1058
|
+
// 'SIGPROF'
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
1061
|
+
if (process.platform === "linux") {
|
|
1062
|
+
module.exports.push(
|
|
1063
|
+
"SIGIO",
|
|
1064
|
+
"SIGPOLL",
|
|
1065
|
+
"SIGPWR",
|
|
1066
|
+
"SIGSTKFLT",
|
|
1067
|
+
"SIGUNUSED"
|
|
1068
|
+
);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
|
|
1073
|
+
// node_modules/signal-exit/index.js
|
|
1074
|
+
var require_signal_exit = __commonJS({
|
|
1075
|
+
"node_modules/signal-exit/index.js"(exports, module) {
|
|
1076
|
+
var process2 = global.process;
|
|
1077
|
+
var processOk = function(process3) {
|
|
1078
|
+
return process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
|
|
1079
|
+
};
|
|
1080
|
+
if (!processOk(process2)) {
|
|
1081
|
+
module.exports = function() {
|
|
1082
|
+
return function() {
|
|
1083
|
+
};
|
|
1084
|
+
};
|
|
1085
|
+
} else {
|
|
1086
|
+
assert = __require("assert");
|
|
1087
|
+
signals = require_signals();
|
|
1088
|
+
isWin = /^win/i.test(process2.platform);
|
|
1089
|
+
EE = __require("events");
|
|
1090
|
+
if (typeof EE !== "function") {
|
|
1091
|
+
EE = EE.EventEmitter;
|
|
1092
|
+
}
|
|
1093
|
+
if (process2.__signal_exit_emitter__) {
|
|
1094
|
+
emitter = process2.__signal_exit_emitter__;
|
|
1095
|
+
} else {
|
|
1096
|
+
emitter = process2.__signal_exit_emitter__ = new EE();
|
|
1097
|
+
emitter.count = 0;
|
|
1098
|
+
emitter.emitted = {};
|
|
1099
|
+
}
|
|
1100
|
+
if (!emitter.infinite) {
|
|
1101
|
+
emitter.setMaxListeners(Infinity);
|
|
1102
|
+
emitter.infinite = true;
|
|
1103
|
+
}
|
|
1104
|
+
module.exports = function(cb, opts) {
|
|
1105
|
+
if (!processOk(global.process)) {
|
|
1106
|
+
return function() {
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
1110
|
+
if (loaded === false) {
|
|
1111
|
+
load();
|
|
1112
|
+
}
|
|
1113
|
+
var ev = "exit";
|
|
1114
|
+
if (opts && opts.alwaysLast) {
|
|
1115
|
+
ev = "afterexit";
|
|
1116
|
+
}
|
|
1117
|
+
var remove = function() {
|
|
1118
|
+
emitter.removeListener(ev, cb);
|
|
1119
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
|
|
1120
|
+
unload();
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
emitter.on(ev, cb);
|
|
1124
|
+
return remove;
|
|
1125
|
+
};
|
|
1126
|
+
unload = function unload2() {
|
|
1127
|
+
if (!loaded || !processOk(global.process)) {
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
loaded = false;
|
|
1131
|
+
signals.forEach(function(sig) {
|
|
1132
|
+
try {
|
|
1133
|
+
process2.removeListener(sig, sigListeners[sig]);
|
|
1134
|
+
} catch (er) {
|
|
1135
|
+
}
|
|
1136
|
+
});
|
|
1137
|
+
process2.emit = originalProcessEmit;
|
|
1138
|
+
process2.reallyExit = originalProcessReallyExit;
|
|
1139
|
+
emitter.count -= 1;
|
|
1140
|
+
};
|
|
1141
|
+
module.exports.unload = unload;
|
|
1142
|
+
emit = function emit2(event, code, signal) {
|
|
1143
|
+
if (emitter.emitted[event]) {
|
|
1144
|
+
return;
|
|
1145
|
+
}
|
|
1146
|
+
emitter.emitted[event] = true;
|
|
1147
|
+
emitter.emit(event, code, signal);
|
|
1148
|
+
};
|
|
1149
|
+
sigListeners = {};
|
|
1150
|
+
signals.forEach(function(sig) {
|
|
1151
|
+
sigListeners[sig] = function listener() {
|
|
1152
|
+
if (!processOk(global.process)) {
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
var listeners = process2.listeners(sig);
|
|
1156
|
+
if (listeners.length === emitter.count) {
|
|
1157
|
+
unload();
|
|
1158
|
+
emit("exit", null, sig);
|
|
1159
|
+
emit("afterexit", null, sig);
|
|
1160
|
+
if (isWin && sig === "SIGHUP") {
|
|
1161
|
+
sig = "SIGINT";
|
|
1162
|
+
}
|
|
1163
|
+
process2.kill(process2.pid, sig);
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
});
|
|
1167
|
+
module.exports.signals = function() {
|
|
1168
|
+
return signals;
|
|
1169
|
+
};
|
|
1170
|
+
loaded = false;
|
|
1171
|
+
load = function load2() {
|
|
1172
|
+
if (loaded || !processOk(global.process)) {
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
loaded = true;
|
|
1176
|
+
emitter.count += 1;
|
|
1177
|
+
signals = signals.filter(function(sig) {
|
|
1178
|
+
try {
|
|
1179
|
+
process2.on(sig, sigListeners[sig]);
|
|
1180
|
+
return true;
|
|
1181
|
+
} catch (er) {
|
|
1182
|
+
return false;
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
process2.emit = processEmit;
|
|
1186
|
+
process2.reallyExit = processReallyExit;
|
|
1187
|
+
};
|
|
1188
|
+
module.exports.load = load;
|
|
1189
|
+
originalProcessReallyExit = process2.reallyExit;
|
|
1190
|
+
processReallyExit = function processReallyExit2(code) {
|
|
1191
|
+
if (!processOk(global.process)) {
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
process2.exitCode = code || /* istanbul ignore next */
|
|
1195
|
+
0;
|
|
1196
|
+
emit("exit", process2.exitCode, null);
|
|
1197
|
+
emit("afterexit", process2.exitCode, null);
|
|
1198
|
+
originalProcessReallyExit.call(process2, process2.exitCode);
|
|
1199
|
+
};
|
|
1200
|
+
originalProcessEmit = process2.emit;
|
|
1201
|
+
processEmit = function processEmit2(ev, arg) {
|
|
1202
|
+
if (ev === "exit" && processOk(global.process)) {
|
|
1203
|
+
if (arg !== void 0) {
|
|
1204
|
+
process2.exitCode = arg;
|
|
1205
|
+
}
|
|
1206
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
1207
|
+
emit("exit", process2.exitCode, null);
|
|
1208
|
+
emit("afterexit", process2.exitCode, null);
|
|
1209
|
+
return ret;
|
|
1210
|
+
} else {
|
|
1211
|
+
return originalProcessEmit.apply(this, arguments);
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
var assert;
|
|
1216
|
+
var signals;
|
|
1217
|
+
var isWin;
|
|
1218
|
+
var EE;
|
|
1219
|
+
var emitter;
|
|
1220
|
+
var unload;
|
|
1221
|
+
var emit;
|
|
1222
|
+
var sigListeners;
|
|
1223
|
+
var loaded;
|
|
1224
|
+
var load;
|
|
1225
|
+
var originalProcessReallyExit;
|
|
1226
|
+
var processReallyExit;
|
|
1227
|
+
var originalProcessEmit;
|
|
1228
|
+
var processEmit;
|
|
1229
|
+
}
|
|
1230
|
+
});
|
|
1231
|
+
|
|
1232
|
+
// node_modules/proper-lockfile/lib/mtime-precision.js
|
|
1233
|
+
var require_mtime_precision = __commonJS({
|
|
1234
|
+
"node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module) {
|
|
1235
|
+
"use strict";
|
|
1236
|
+
var cacheSymbol = /* @__PURE__ */ Symbol();
|
|
1237
|
+
function probe(file, fs, callback) {
|
|
1238
|
+
const cachedPrecision = fs[cacheSymbol];
|
|
1239
|
+
if (cachedPrecision) {
|
|
1240
|
+
return fs.stat(file, (err, stat) => {
|
|
1241
|
+
if (err) {
|
|
1242
|
+
return callback(err);
|
|
1243
|
+
}
|
|
1244
|
+
callback(null, stat.mtime, cachedPrecision);
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1248
|
+
fs.utimes(file, mtime, mtime, (err) => {
|
|
1249
|
+
if (err) {
|
|
1250
|
+
return callback(err);
|
|
1251
|
+
}
|
|
1252
|
+
fs.stat(file, (err2, stat) => {
|
|
1253
|
+
if (err2) {
|
|
1254
|
+
return callback(err2);
|
|
1255
|
+
}
|
|
1256
|
+
const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1257
|
+
Object.defineProperty(fs, cacheSymbol, { value: precision });
|
|
1258
|
+
callback(null, stat.mtime, precision);
|
|
1259
|
+
});
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
function getMtime(precision) {
|
|
1263
|
+
let now = Date.now();
|
|
1264
|
+
if (precision === "s") {
|
|
1265
|
+
now = Math.ceil(now / 1e3) * 1e3;
|
|
1266
|
+
}
|
|
1267
|
+
return new Date(now);
|
|
1268
|
+
}
|
|
1269
|
+
module.exports.probe = probe;
|
|
1270
|
+
module.exports.getMtime = getMtime;
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
|
|
1274
|
+
// node_modules/proper-lockfile/lib/lockfile.js
|
|
1275
|
+
var require_lockfile = __commonJS({
|
|
1276
|
+
"node_modules/proper-lockfile/lib/lockfile.js"(exports, module) {
|
|
1277
|
+
"use strict";
|
|
1278
|
+
var path6 = __require("path");
|
|
1279
|
+
var fs = require_graceful_fs();
|
|
1280
|
+
var retry = require_retry2();
|
|
1281
|
+
var onExit = require_signal_exit();
|
|
1282
|
+
var mtimePrecision = require_mtime_precision();
|
|
1283
|
+
var locks = {};
|
|
1284
|
+
function getLockFile(file, options) {
|
|
1285
|
+
return options.lockfilePath || `${file}.lock`;
|
|
1286
|
+
}
|
|
1287
|
+
function resolveCanonicalPath(file, options, callback) {
|
|
1288
|
+
if (!options.realpath) {
|
|
1289
|
+
return callback(null, path6.resolve(file));
|
|
1290
|
+
}
|
|
1291
|
+
options.fs.realpath(file, callback);
|
|
1292
|
+
}
|
|
1293
|
+
function acquireLock(file, options, callback) {
|
|
1294
|
+
const lockfilePath = getLockFile(file, options);
|
|
1295
|
+
options.fs.mkdir(lockfilePath, (err) => {
|
|
1296
|
+
if (!err) {
|
|
1297
|
+
return mtimePrecision.probe(lockfilePath, options.fs, (err2, mtime, mtimePrecision2) => {
|
|
1298
|
+
if (err2) {
|
|
1299
|
+
options.fs.rmdir(lockfilePath, () => {
|
|
1300
|
+
});
|
|
1301
|
+
return callback(err2);
|
|
1302
|
+
}
|
|
1303
|
+
callback(null, mtime, mtimePrecision2);
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
if (err.code !== "EEXIST") {
|
|
1307
|
+
return callback(err);
|
|
1308
|
+
}
|
|
1309
|
+
if (options.stale <= 0) {
|
|
1310
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1311
|
+
}
|
|
1312
|
+
options.fs.stat(lockfilePath, (err2, stat) => {
|
|
1313
|
+
if (err2) {
|
|
1314
|
+
if (err2.code === "ENOENT") {
|
|
1315
|
+
return acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1316
|
+
}
|
|
1317
|
+
return callback(err2);
|
|
1318
|
+
}
|
|
1319
|
+
if (!isLockStale(stat, options)) {
|
|
1320
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1321
|
+
}
|
|
1322
|
+
removeLock(file, options, (err3) => {
|
|
1323
|
+
if (err3) {
|
|
1324
|
+
return callback(err3);
|
|
1325
|
+
}
|
|
1326
|
+
acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1327
|
+
});
|
|
1328
|
+
});
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
function isLockStale(stat, options) {
|
|
1332
|
+
return stat.mtime.getTime() < Date.now() - options.stale;
|
|
1333
|
+
}
|
|
1334
|
+
function removeLock(file, options, callback) {
|
|
1335
|
+
options.fs.rmdir(getLockFile(file, options), (err) => {
|
|
1336
|
+
if (err && err.code !== "ENOENT") {
|
|
1337
|
+
return callback(err);
|
|
1338
|
+
}
|
|
1339
|
+
callback();
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
function updateLock(file, options) {
|
|
1343
|
+
const lock2 = locks[file];
|
|
1344
|
+
if (lock2.updateTimeout) {
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
lock2.updateDelay = lock2.updateDelay || options.update;
|
|
1348
|
+
lock2.updateTimeout = setTimeout(() => {
|
|
1349
|
+
lock2.updateTimeout = null;
|
|
1350
|
+
options.fs.stat(lock2.lockfilePath, (err, stat) => {
|
|
1351
|
+
const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
|
|
1352
|
+
if (err) {
|
|
1353
|
+
if (err.code === "ENOENT" || isOverThreshold) {
|
|
1354
|
+
return setLockAsCompromised(file, lock2, Object.assign(err, { code: "ECOMPROMISED" }));
|
|
1355
|
+
}
|
|
1356
|
+
lock2.updateDelay = 1e3;
|
|
1357
|
+
return updateLock(file, options);
|
|
1358
|
+
}
|
|
1359
|
+
const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
|
|
1360
|
+
if (!isMtimeOurs) {
|
|
1361
|
+
return setLockAsCompromised(
|
|
1362
|
+
file,
|
|
1363
|
+
lock2,
|
|
1364
|
+
Object.assign(
|
|
1365
|
+
new Error("Unable to update lock within the stale threshold"),
|
|
1366
|
+
{ code: "ECOMPROMISED" }
|
|
1367
|
+
)
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
|
|
1371
|
+
options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err2) => {
|
|
1372
|
+
const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
|
|
1373
|
+
if (lock2.released) {
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
if (err2) {
|
|
1377
|
+
if (err2.code === "ENOENT" || isOverThreshold2) {
|
|
1378
|
+
return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
|
|
1379
|
+
}
|
|
1380
|
+
lock2.updateDelay = 1e3;
|
|
1381
|
+
return updateLock(file, options);
|
|
1382
|
+
}
|
|
1383
|
+
lock2.mtime = mtime;
|
|
1384
|
+
lock2.lastUpdate = Date.now();
|
|
1385
|
+
lock2.updateDelay = null;
|
|
1386
|
+
updateLock(file, options);
|
|
1387
|
+
});
|
|
1388
|
+
});
|
|
1389
|
+
}, lock2.updateDelay);
|
|
1390
|
+
if (lock2.updateTimeout.unref) {
|
|
1391
|
+
lock2.updateTimeout.unref();
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
function setLockAsCompromised(file, lock2, err) {
|
|
1395
|
+
lock2.released = true;
|
|
1396
|
+
if (lock2.updateTimeout) {
|
|
1397
|
+
clearTimeout(lock2.updateTimeout);
|
|
1398
|
+
}
|
|
1399
|
+
if (locks[file] === lock2) {
|
|
1400
|
+
delete locks[file];
|
|
1401
|
+
}
|
|
1402
|
+
lock2.options.onCompromised(err);
|
|
1403
|
+
}
|
|
1404
|
+
function lock(file, options, callback) {
|
|
1405
|
+
options = {
|
|
1406
|
+
stale: 1e4,
|
|
1407
|
+
update: null,
|
|
1408
|
+
realpath: true,
|
|
1409
|
+
retries: 0,
|
|
1410
|
+
fs,
|
|
1411
|
+
onCompromised: (err) => {
|
|
1412
|
+
throw err;
|
|
1413
|
+
},
|
|
1414
|
+
...options
|
|
1415
|
+
};
|
|
1416
|
+
options.retries = options.retries || 0;
|
|
1417
|
+
options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
|
|
1418
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1419
|
+
options.update = options.update == null ? options.stale / 2 : options.update || 0;
|
|
1420
|
+
options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
|
|
1421
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1422
|
+
if (err) {
|
|
1423
|
+
return callback(err);
|
|
1424
|
+
}
|
|
1425
|
+
const operation = retry.operation(options.retries);
|
|
1426
|
+
operation.attempt(() => {
|
|
1427
|
+
acquireLock(file2, options, (err2, mtime, mtimePrecision2) => {
|
|
1428
|
+
if (operation.retry(err2)) {
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
if (err2) {
|
|
1432
|
+
return callback(operation.mainError());
|
|
1433
|
+
}
|
|
1434
|
+
const lock2 = locks[file2] = {
|
|
1435
|
+
lockfilePath: getLockFile(file2, options),
|
|
1436
|
+
mtime,
|
|
1437
|
+
mtimePrecision: mtimePrecision2,
|
|
1438
|
+
options,
|
|
1439
|
+
lastUpdate: Date.now()
|
|
1440
|
+
};
|
|
1441
|
+
updateLock(file2, options);
|
|
1442
|
+
callback(null, (releasedCallback) => {
|
|
1443
|
+
if (lock2.released) {
|
|
1444
|
+
return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
|
|
1445
|
+
}
|
|
1446
|
+
unlock(file2, { ...options, realpath: false }, releasedCallback);
|
|
1447
|
+
});
|
|
1448
|
+
});
|
|
1449
|
+
});
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
function unlock(file, options, callback) {
|
|
1453
|
+
options = {
|
|
1454
|
+
fs,
|
|
1455
|
+
realpath: true,
|
|
1456
|
+
...options
|
|
1457
|
+
};
|
|
1458
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1459
|
+
if (err) {
|
|
1460
|
+
return callback(err);
|
|
1461
|
+
}
|
|
1462
|
+
const lock2 = locks[file2];
|
|
1463
|
+
if (!lock2) {
|
|
1464
|
+
return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
|
|
1465
|
+
}
|
|
1466
|
+
lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
|
|
1467
|
+
lock2.released = true;
|
|
1468
|
+
delete locks[file2];
|
|
1469
|
+
removeLock(file2, options, callback);
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
function check(file, options, callback) {
|
|
1473
|
+
options = {
|
|
1474
|
+
stale: 1e4,
|
|
1475
|
+
realpath: true,
|
|
1476
|
+
fs,
|
|
1477
|
+
...options
|
|
1478
|
+
};
|
|
1479
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1480
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1481
|
+
if (err) {
|
|
1482
|
+
return callback(err);
|
|
1483
|
+
}
|
|
1484
|
+
options.fs.stat(getLockFile(file2, options), (err2, stat) => {
|
|
1485
|
+
if (err2) {
|
|
1486
|
+
return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
|
|
1487
|
+
}
|
|
1488
|
+
return callback(null, !isLockStale(stat, options));
|
|
1489
|
+
});
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
function getLocks() {
|
|
1493
|
+
return locks;
|
|
1494
|
+
}
|
|
1495
|
+
onExit(() => {
|
|
1496
|
+
for (const file in locks) {
|
|
1497
|
+
const options = locks[file].options;
|
|
1498
|
+
try {
|
|
1499
|
+
options.fs.rmdirSync(getLockFile(file, options));
|
|
1500
|
+
} catch (e) {
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
});
|
|
1504
|
+
module.exports.lock = lock;
|
|
1505
|
+
module.exports.unlock = unlock;
|
|
1506
|
+
module.exports.check = check;
|
|
1507
|
+
module.exports.getLocks = getLocks;
|
|
1508
|
+
}
|
|
1509
|
+
});
|
|
1510
|
+
|
|
1511
|
+
// node_modules/proper-lockfile/lib/adapter.js
|
|
1512
|
+
var require_adapter = __commonJS({
|
|
1513
|
+
"node_modules/proper-lockfile/lib/adapter.js"(exports, module) {
|
|
1514
|
+
"use strict";
|
|
1515
|
+
var fs = require_graceful_fs();
|
|
1516
|
+
function createSyncFs(fs2) {
|
|
1517
|
+
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
1518
|
+
const newFs = { ...fs2 };
|
|
1519
|
+
methods.forEach((method) => {
|
|
1520
|
+
newFs[method] = (...args) => {
|
|
1521
|
+
const callback = args.pop();
|
|
1522
|
+
let ret;
|
|
1523
|
+
try {
|
|
1524
|
+
ret = fs2[`${method}Sync`](...args);
|
|
1525
|
+
} catch (err) {
|
|
1526
|
+
return callback(err);
|
|
1527
|
+
}
|
|
1528
|
+
callback(null, ret);
|
|
1529
|
+
};
|
|
1530
|
+
});
|
|
1531
|
+
return newFs;
|
|
1532
|
+
}
|
|
1533
|
+
function toPromise(method) {
|
|
1534
|
+
return (...args) => new Promise((resolve, reject) => {
|
|
1535
|
+
args.push((err, result) => {
|
|
1536
|
+
if (err) {
|
|
1537
|
+
reject(err);
|
|
1538
|
+
} else {
|
|
1539
|
+
resolve(result);
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
method(...args);
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
function toSync(method) {
|
|
1546
|
+
return (...args) => {
|
|
1547
|
+
let err;
|
|
1548
|
+
let result;
|
|
1549
|
+
args.push((_err, _result) => {
|
|
1550
|
+
err = _err;
|
|
1551
|
+
result = _result;
|
|
1552
|
+
});
|
|
1553
|
+
method(...args);
|
|
1554
|
+
if (err) {
|
|
1555
|
+
throw err;
|
|
1556
|
+
}
|
|
1557
|
+
return result;
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
function toSyncOptions(options) {
|
|
1561
|
+
options = { ...options };
|
|
1562
|
+
options.fs = createSyncFs(options.fs || fs);
|
|
1563
|
+
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
1564
|
+
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
1565
|
+
}
|
|
1566
|
+
return options;
|
|
1567
|
+
}
|
|
1568
|
+
module.exports = {
|
|
1569
|
+
toPromise,
|
|
1570
|
+
toSync,
|
|
1571
|
+
toSyncOptions
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
});
|
|
1575
|
+
|
|
1576
|
+
// node_modules/proper-lockfile/index.js
|
|
1577
|
+
var require_proper_lockfile = __commonJS({
|
|
1578
|
+
"node_modules/proper-lockfile/index.js"(exports, module) {
|
|
1579
|
+
"use strict";
|
|
1580
|
+
var lockfile2 = require_lockfile();
|
|
1581
|
+
var { toPromise, toSync, toSyncOptions } = require_adapter();
|
|
1582
|
+
async function lock(file, options) {
|
|
1583
|
+
const release = await toPromise(lockfile2.lock)(file, options);
|
|
1584
|
+
return toPromise(release);
|
|
1585
|
+
}
|
|
1586
|
+
function lockSync(file, options) {
|
|
1587
|
+
const release = toSync(lockfile2.lock)(file, toSyncOptions(options));
|
|
1588
|
+
return toSync(release);
|
|
1589
|
+
}
|
|
1590
|
+
function unlock(file, options) {
|
|
1591
|
+
return toPromise(lockfile2.unlock)(file, options);
|
|
1592
|
+
}
|
|
1593
|
+
function unlockSync(file, options) {
|
|
1594
|
+
return toSync(lockfile2.unlock)(file, toSyncOptions(options));
|
|
1595
|
+
}
|
|
1596
|
+
function check(file, options) {
|
|
1597
|
+
return toPromise(lockfile2.check)(file, options);
|
|
1598
|
+
}
|
|
1599
|
+
function checkSync(file, options) {
|
|
1600
|
+
return toSync(lockfile2.check)(file, toSyncOptions(options));
|
|
1601
|
+
}
|
|
1602
|
+
module.exports = lock;
|
|
1603
|
+
module.exports.lock = lock;
|
|
1604
|
+
module.exports.unlock = unlock;
|
|
1605
|
+
module.exports.lockSync = lockSync;
|
|
1606
|
+
module.exports.unlockSync = unlockSync;
|
|
1607
|
+
module.exports.check = check;
|
|
1608
|
+
module.exports.checkSync = checkSync;
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
|
|
1612
|
+
// dist-server/integrations/launcher-start.mjs
|
|
1613
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
1614
|
+
import path5 from "node:path";
|
|
1615
|
+
import { pathToFileURL } from "node:url";
|
|
1616
|
+
import { readFile as readFile4, mkdir as mkdir2, writeFile as writeFile2, unlink as unlink2 } from "node:fs/promises";
|
|
1617
|
+
import { unlinkSync } from "node:fs";
|
|
1618
|
+
import { randomUUID } from "node:crypto";
|
|
1619
|
+
|
|
1620
|
+
// dist-server/integrations/installation-state.mjs
|
|
1621
|
+
import path2 from "node:path";
|
|
1622
|
+
|
|
1623
|
+
// dist-server/integrations/files.mjs
|
|
1624
|
+
import path from "node:path";
|
|
1625
|
+
import { lstat, readFile, mkdir, writeFile, rename, unlink } from "node:fs/promises";
|
|
1626
|
+
async function optionalFile(file) {
|
|
1627
|
+
try {
|
|
1628
|
+
return await readFile(file, "utf8");
|
|
1629
|
+
} catch (error) {
|
|
1630
|
+
if (error.code !== "ENOENT") throw error;
|
|
1631
|
+
return null;
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
async function assertPlainPath(file) {
|
|
1635
|
+
let current = path.resolve(file);
|
|
1636
|
+
for (; ; ) {
|
|
1637
|
+
try {
|
|
1638
|
+
const info = await lstat(current);
|
|
1639
|
+
if (info.isSymbolicLink() || (current === path.resolve(file) ? !info.isFile() : !info.isDirectory())) throw new Error("Refusing linked or invalid install path: " + current);
|
|
1640
|
+
} catch (error) {
|
|
1641
|
+
if (error.code !== "ENOENT") throw error;
|
|
1642
|
+
}
|
|
1643
|
+
const parent = path.dirname(current);
|
|
1644
|
+
if (parent === current) break;
|
|
1645
|
+
current = parent;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
// dist-server/integrations/version-policy.mjs
|
|
1650
|
+
var pattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
1651
|
+
function parseVersion(value) {
|
|
1652
|
+
const match = typeof value === "string" && pattern.exec(value);
|
|
1653
|
+
if (!match) throw new Error("Invalid Craft version: " + value);
|
|
1654
|
+
const numbers = match.slice(1, 4).map(Number), prerelease = match[4]?.split(".") ?? [];
|
|
1655
|
+
if (numbers.some((number) => !Number.isSafeInteger(number)) || prerelease.some((part) => /^\d+$/.test(part) && (part.length > 1 && part[0] === "0"))) throw new Error("Invalid Craft version: " + value);
|
|
1656
|
+
return { numbers, prerelease };
|
|
1657
|
+
}
|
|
1658
|
+
function compareVersions(left, right) {
|
|
1659
|
+
const a = parseVersion(left), b = parseVersion(right);
|
|
1660
|
+
for (let i = 0; i < 3; i++) if (a.numbers[i] !== b.numbers[i]) return a.numbers[i] < b.numbers[i] ? -1 : 1;
|
|
1661
|
+
if (!a.prerelease.length || !b.prerelease.length) return a.prerelease.length === b.prerelease.length ? 0 : a.prerelease.length ? -1 : 1;
|
|
1662
|
+
for (let i = 0; i < Math.max(a.prerelease.length, b.prerelease.length); i++) {
|
|
1663
|
+
const x = a.prerelease[i], y = b.prerelease[i];
|
|
1664
|
+
if (x === y) continue;
|
|
1665
|
+
if (x === void 0 || y === void 0) return x === void 0 ? -1 : 1;
|
|
1666
|
+
const xn = /^\d+$/.test(x), yn = /^\d+$/.test(y);
|
|
1667
|
+
if (xn && yn) return BigInt(x) < BigInt(y) ? -1 : 1;
|
|
1668
|
+
if (xn !== yn) return xn ? -1 : 1;
|
|
1669
|
+
return x < y ? -1 : 1;
|
|
1670
|
+
}
|
|
1671
|
+
return 0;
|
|
1672
|
+
}
|
|
1673
|
+
function requireForwardVersion(next, previous) {
|
|
1674
|
+
if (!previous) return;
|
|
1675
|
+
const comparison = compareVersions(next.version, previous.version);
|
|
1676
|
+
if (comparison < 0) throw new Error("Craft downgrade refused: " + previous.version + " -> " + next.version);
|
|
1677
|
+
if (comparison === 0 && previous.build_id && next.build_id && previous.build_id !== next.build_id) throw new Error("Craft same-version build replacement refused; publish a new version");
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
// dist-server/integrations/hosts.mjs
|
|
1681
|
+
var hosts = Object.freeze({
|
|
1682
|
+
codex: { label: "Codex", config: ".codex/config.toml", skills: ".agents/skills", projectSkills: ".agents/skills", format: "toml" },
|
|
1683
|
+
workbuddy: { label: "WorkBuddy", config: ".workbuddy/mcp.json", skills: ".workbuddy/skills", projectSkills: ".workbuddy/skills", format: "json" },
|
|
1684
|
+
codebuddy: { label: "CodeBuddy", config: ".codebuddy/.mcp.json", skills: ".codebuddy/skills", projectSkills: ".codebuddy/skills", format: "json" },
|
|
1685
|
+
cursor: { label: "Cursor", config: ".cursor/mcp.json", skills: ".cursor/skills", projectSkills: ".cursor/skills", format: "json" },
|
|
1686
|
+
claude: { label: "Claude Code", config: ".claude.json", skills: ".claude/skills", projectSkills: ".claude/skills", format: "json" },
|
|
1687
|
+
dsh: { label: "DSH", config: ".dsh/cordis.patch.yml", skills: ".dsh/skills", projectSkills: ".dsh/skills", format: "yaml" },
|
|
1688
|
+
zcode: { label: "ZCode", config: ".zcode/cli/config.json", skills: ".zcode/skills", projectSkills: ".zcode/skills", format: "json" },
|
|
1689
|
+
kimi: { label: "Kimi Code", config: ".kimi-code/mcp.json", skills: ".kimi-code/skills", projectSkills: ".kimi-code/skills", format: "json" }
|
|
1690
|
+
});
|
|
1691
|
+
|
|
1692
|
+
// dist-server/integrations/installation-state.mjs
|
|
1693
|
+
var defaultRegistry = "https://registry.npmjs.org/";
|
|
1694
|
+
var activationMode = "next_mcp_start";
|
|
1695
|
+
function sameRuntimeIdentity(left, right) {
|
|
1696
|
+
const samePath = (a, b) => typeof a === "string" && typeof b === "string" && (process.platform === "win32" ? path2.resolve(a).toLowerCase() === path2.resolve(b).toLowerCase() : path2.resolve(a) === path2.resolve(b));
|
|
1697
|
+
return Boolean(left && right && left.package === right.package && left.version === right.version && left.build_id === right.build_id && samePath(left.package_root, right.package_root) && samePath(left.entry, right.entry));
|
|
1698
|
+
}
|
|
1699
|
+
var managedSkillMarkers = Object.freeze({ "craft-create": "<!-- craft-mcp:bootstrap:v1 -->", "craft-update": "<!-- craft-mcp:update:v1 -->" });
|
|
1700
|
+
function installedSkillEntries(state) {
|
|
1701
|
+
if (state.skills === void 0) return [];
|
|
1702
|
+
if (!state.skills || typeof state.skills !== "object" || Array.isArray(state.skills) || !state.skills["craft-create"]) throw new Error("Invalid installed Skill destinations");
|
|
1703
|
+
return Object.entries(state.skills).map(([name, file]) => {
|
|
1704
|
+
if (!Object.hasOwn(managedSkillMarkers, name) || typeof file !== "string" || !path2.isAbsolute(file) || path2.basename(file) !== "SKILL.md" || path2.basename(path2.dirname(file)) !== name) throw new Error("Invalid installed Skill destination");
|
|
1705
|
+
return { name, file, marker: managedSkillMarkers[name] };
|
|
1706
|
+
});
|
|
1707
|
+
}
|
|
1708
|
+
function registryOrigin(value = defaultRegistry) {
|
|
1709
|
+
const url = new URL(value);
|
|
1710
|
+
if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash) throw new Error("Registry must be a credential-free HTTPS URL");
|
|
1711
|
+
return url.href.replace(/\/?$/, "/");
|
|
1712
|
+
}
|
|
1713
|
+
function validateIdentity(identity) {
|
|
1714
|
+
if (!identity || typeof identity !== "object") throw new Error("Missing Craft runtime identity");
|
|
1715
|
+
parseVersion(identity.version);
|
|
1716
|
+
if (!identity.package || !/^[a-f0-9]{64}$/.test(identity.build_id ?? "") || !path2.isAbsolute(identity.package_root ?? "") || !path2.isAbsolute(identity.entry ?? "")) throw new Error("Invalid Craft runtime identity");
|
|
1717
|
+
if (path2.resolve(identity.entry) !== path2.join(path2.resolve(identity.package_root), "bin", "craft-mcp.mjs")) throw new Error("Craft entry is outside its runtime package");
|
|
1718
|
+
return identity;
|
|
1719
|
+
}
|
|
1720
|
+
async function readInstallationSnapshot(file) {
|
|
1721
|
+
if (!file || !path2.isAbsolute(file)) throw new Error("CRAFT_INSTALLATION_FILE must be absolute");
|
|
1722
|
+
const text = await optionalFile(file);
|
|
1723
|
+
if (text === null) throw new Error("Craft installation state is missing; run install again");
|
|
1724
|
+
const state = JSON.parse(text);
|
|
1725
|
+
if (![1, 2].includes(state.schema) || state.schema === 2 && state.activation_mode !== activationMode || !state.id || !Object.hasOwn(hosts, state.host) || !path2.isAbsolute(state.config ?? "") || !path2.isAbsolute(state.workspace ?? "") || !state.server_id || !["auto", "off"].includes(state.policy?.mode)) throw new Error("Invalid Craft installation state");
|
|
1726
|
+
validateIdentity(state.anchor);
|
|
1727
|
+
validateIdentity(state.target);
|
|
1728
|
+
if (state.source?.package !== state.anchor.package || state.target.package !== state.anchor.package) throw new Error("Craft installation package identity mismatch");
|
|
1729
|
+
installedSkillEntries(state);
|
|
1730
|
+
if (state.skills_runtime !== void 0) {
|
|
1731
|
+
validateIdentity(state.skills_runtime);
|
|
1732
|
+
if (state.skills_runtime.package !== state.source.package) throw new Error("Installed Skill runtime package identity mismatch");
|
|
1733
|
+
requireForwardVersion(state.target, state.skills_runtime);
|
|
1734
|
+
}
|
|
1735
|
+
if (state.schema === 2 && (!sameRuntimeIdentity(state.anchor, state.target) || !sameRuntimeIdentity(state.skills_runtime, state.target))) throw new Error("Configured runtime and installed Skill identities differ");
|
|
1736
|
+
if (state.connection_verification !== void 0) {
|
|
1737
|
+
const receipt = state.connection_verification;
|
|
1738
|
+
if (!receipt || receipt.version !== state.target.version || receipt.build_id !== state.target.build_id || typeof receipt.instance_id !== "string" || !receipt.instance_id || !Number.isFinite(Date.parse(receipt.confirmed_at))) throw new Error("Invalid Craft connection verification receipt");
|
|
1739
|
+
}
|
|
1740
|
+
registryOrigin(state.source.registry);
|
|
1741
|
+
if (!/^[a-zA-Z][a-zA-Z0-9._-]*$/.test(state.source.channel ?? "")) throw new Error("Invalid Craft update channel");
|
|
1742
|
+
return { state, text };
|
|
1743
|
+
}
|
|
1744
|
+
async function readInstallation(file) {
|
|
1745
|
+
return (await readInstallationSnapshot(file)).state;
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
// dist-server/integrations/runtime-identity.mjs
|
|
1749
|
+
import path3 from "node:path";
|
|
1750
|
+
import { readFile as readFile2, readdir, lstat as lstat2 } from "node:fs/promises";
|
|
1751
|
+
import { createHash } from "node:crypto";
|
|
1752
|
+
async function getRuntimeIdentity(packageRoot) {
|
|
1753
|
+
packageRoot = path3.resolve(packageRoot);
|
|
1754
|
+
const pkg = JSON.parse(await readFile2(path3.join(packageRoot, "package.json"), "utf8"));
|
|
1755
|
+
const hash = createHash("sha256");
|
|
1756
|
+
async function visit(relative) {
|
|
1757
|
+
const file = path3.join(packageRoot, relative);
|
|
1758
|
+
let info;
|
|
1759
|
+
try {
|
|
1760
|
+
info = await lstat2(file);
|
|
1761
|
+
} catch (error) {
|
|
1762
|
+
if (error.code === "ENOENT") return;
|
|
1763
|
+
throw error;
|
|
1764
|
+
}
|
|
1765
|
+
if (info.isSymbolicLink()) throw new Error("Craft runtime contains a linked product file: " + relative);
|
|
1766
|
+
if (info.isDirectory()) {
|
|
1767
|
+
for (const entry of (await readdir(file)).sort()) if (entry !== "node_modules") await visit(relative + "/" + entry);
|
|
1768
|
+
} else if (info.isFile()) hash.update(relative + "\0").update(await readFile2(file)).update("\0");
|
|
1769
|
+
else throw new Error("Invalid Craft runtime file: " + relative);
|
|
1770
|
+
}
|
|
1771
|
+
for (const relative of ["package.json", "bin", "dist-server", "resources", "vendor"]) await visit(relative);
|
|
1772
|
+
return { package: pkg.name, version: pkg.version, build_id: hash.digest("hex"), package_root: packageRoot, entry: path3.join(packageRoot, "bin/craft-mcp.mjs") };
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
// dist-server/integrations/fixed-launcher.mjs
|
|
1776
|
+
import path4 from "node:path";
|
|
1777
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
1778
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
1779
|
+
function launcherPath(installationFile) {
|
|
1780
|
+
return installationFile.replace(/\.json$/, "") + ".launcher.mjs";
|
|
1781
|
+
}
|
|
1782
|
+
async function verifyLauncher(state, installationFile, connection) {
|
|
1783
|
+
if (!state.launcher) return { mode: "legacy_versioned_entry" };
|
|
1784
|
+
const expected = launcherPath(installationFile);
|
|
1785
|
+
if (state.launcher.schema !== 1 || state.launcher.entry !== expected || !/^[a-f0-9]{64}$/.test(state.launcher.sha256 ?? "")) throw new Error("Invalid Craft fixed launcher identity");
|
|
1786
|
+
if (state.launcher.kind !== void 0) throw new Error("Unsupported Craft launcher; run the standard installer and reconnect");
|
|
1787
|
+
await assertPlainPath(expected);
|
|
1788
|
+
if (createHash2("sha256").update(await readFile3(expected)).digest("hex") !== state.launcher.sha256) throw new Error("Craft fixed launcher integrity mismatch");
|
|
1789
|
+
if (connection && path4.resolve(connection.args?.[0] ?? "") !== path4.resolve(expected)) throw new Error("Craft host configuration does not use the installed fixed launcher");
|
|
1790
|
+
return { mode: "fixed_entry", entry: expected };
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
// dist-server/integrations/launcher-start.mjs
|
|
1794
|
+
async function start() {
|
|
1795
|
+
const entry = path5.resolve(process.argv[1]);
|
|
1796
|
+
const installationFile = entry.replace(/\.launcher\.mjs$/, ".json");
|
|
1797
|
+
if (launcherPath(installationFile) !== entry) throw new Error("Invalid Craft launcher path");
|
|
1798
|
+
await assertPlainPath(installationFile);
|
|
1799
|
+
const initial = await readInstallation(installationFile);
|
|
1800
|
+
await assertPlainPath(path5.join(initial.runtime_root, ".path-check"));
|
|
1801
|
+
const unlock = await import_proper_lockfile.default.lock(initial.runtime_root, { stale: 12e4, retries: { retries: 240, minTimeout: 250, maxTimeout: 500 } });
|
|
1802
|
+
let identity, state, lease;
|
|
1803
|
+
try {
|
|
1804
|
+
state = await readInstallation(installationFile);
|
|
1805
|
+
if (state.runtime_root !== initial.runtime_root || state.schema !== 2) throw new Error("Craft installation changed or needs migration");
|
|
1806
|
+
await verifyLauncher(state, installationFile, { args: [entry] });
|
|
1807
|
+
if (process.env.CRAFT_INSTALLATION_FILE && path5.resolve(process.env.CRAFT_INSTALLATION_FILE) !== installationFile) throw new Error("Craft launcher installation scope mismatch");
|
|
1808
|
+
for (const [key, expected] of Object.entries({ CRAFT_CLIENT_IDE: state.host, CLIENT_WORKSPACE_ROOT: state.workspace, CRAFT_WEB_URL: state.platform })) {
|
|
1809
|
+
if (process.env[key] && process.env[key] !== expected) throw new Error("Craft launcher scope mismatch: " + key);
|
|
1810
|
+
process.env[key] = expected;
|
|
1811
|
+
}
|
|
1812
|
+
const relative = path5.relative(path5.resolve(state.runtime_root), state.target.package_root);
|
|
1813
|
+
if (!relative || relative === ".." || relative.startsWith(".." + path5.sep) || path5.isAbsolute(relative)) throw new Error("Craft target is outside the managed runtime root");
|
|
1814
|
+
await assertPlainPath(state.target.entry);
|
|
1815
|
+
identity = await getRuntimeIdentity(state.target.package_root);
|
|
1816
|
+
if (!sameRuntimeIdentity(identity, state.target)) throw new Error("Craft target package integrity mismatch");
|
|
1817
|
+
const leaseRoot = path5.join(state.runtime_root, ".connections");
|
|
1818
|
+
await mkdir2(leaseRoot, { recursive: true });
|
|
1819
|
+
lease = path5.join(leaseRoot, "launcher-" + randomUUID() + ".json");
|
|
1820
|
+
await assertPlainPath(lease);
|
|
1821
|
+
await writeFile2(lease, JSON.stringify({ pid: process.pid, package_root: identity.package_root, version: identity.version, build_id: identity.build_id }), { flag: "wx", mode: 384 });
|
|
1822
|
+
process.once("exit", () => {
|
|
1823
|
+
try {
|
|
1824
|
+
unlinkSync(lease);
|
|
1825
|
+
} catch {
|
|
1826
|
+
}
|
|
1827
|
+
});
|
|
1828
|
+
} finally {
|
|
1829
|
+
await unlock();
|
|
1830
|
+
}
|
|
1831
|
+
if (process.env.CRAFT_STANDALONE_PROBE !== "1") process.env.CRAFT_INSTALLATION_FILE = installationFile;
|
|
1832
|
+
process.env.CRAFT_FIXED_LAUNCHER = entry;
|
|
1833
|
+
process.argv = [process.execPath, identity.entry, ...process.argv.slice(2)];
|
|
1834
|
+
try {
|
|
1835
|
+
await import(pathToFileURL(identity.entry).href);
|
|
1836
|
+
} catch (error) {
|
|
1837
|
+
await unlink2(lease).catch(() => {
|
|
1838
|
+
});
|
|
1839
|
+
throw error;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
await start().catch((error) => {
|
|
1843
|
+
process.stderr.write("Craft launcher failed: " + error.message + "\n");
|
|
1844
|
+
process.exitCode = 1;
|
|
1845
|
+
});
|