@mutmutco/cli 3.102.0 → 3.104.0
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/dist/main.cjs +1979 -122
- package/package.json +4 -2
package/dist/main.cjs
CHANGED
|
@@ -5,6 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
try {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw mod = 0, e;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
8
15
|
var __export = (target, all) => {
|
|
9
16
|
for (var name in all)
|
|
10
17
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +34,1583 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
34
|
));
|
|
28
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
36
|
|
|
37
|
+
// node_modules/graceful-fs/polyfills.js
|
|
38
|
+
var require_polyfills = __commonJS({
|
|
39
|
+
"node_modules/graceful-fs/polyfills.js"(exports2, module2) {
|
|
40
|
+
var constants = require("constants");
|
|
41
|
+
var origCwd = process.cwd;
|
|
42
|
+
var cwd = null;
|
|
43
|
+
var platform2 = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
44
|
+
process.cwd = function() {
|
|
45
|
+
if (!cwd)
|
|
46
|
+
cwd = origCwd.call(process);
|
|
47
|
+
return cwd;
|
|
48
|
+
};
|
|
49
|
+
try {
|
|
50
|
+
process.cwd();
|
|
51
|
+
} catch (er) {
|
|
52
|
+
}
|
|
53
|
+
if (typeof process.chdir === "function") {
|
|
54
|
+
chdir = process.chdir;
|
|
55
|
+
process.chdir = function(d) {
|
|
56
|
+
cwd = null;
|
|
57
|
+
chdir.call(process, d);
|
|
58
|
+
};
|
|
59
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
60
|
+
}
|
|
61
|
+
var chdir;
|
|
62
|
+
module2.exports = patch;
|
|
63
|
+
function patch(fs2) {
|
|
64
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
65
|
+
patchLchmod(fs2);
|
|
66
|
+
}
|
|
67
|
+
if (!fs2.lutimes) {
|
|
68
|
+
patchLutimes(fs2);
|
|
69
|
+
}
|
|
70
|
+
fs2.chown = chownFix(fs2.chown);
|
|
71
|
+
fs2.fchown = chownFix(fs2.fchown);
|
|
72
|
+
fs2.lchown = chownFix(fs2.lchown);
|
|
73
|
+
fs2.chmod = chmodFix(fs2.chmod);
|
|
74
|
+
fs2.fchmod = chmodFix(fs2.fchmod);
|
|
75
|
+
fs2.lchmod = chmodFix(fs2.lchmod);
|
|
76
|
+
fs2.chownSync = chownFixSync(fs2.chownSync);
|
|
77
|
+
fs2.fchownSync = chownFixSync(fs2.fchownSync);
|
|
78
|
+
fs2.lchownSync = chownFixSync(fs2.lchownSync);
|
|
79
|
+
fs2.chmodSync = chmodFixSync(fs2.chmodSync);
|
|
80
|
+
fs2.fchmodSync = chmodFixSync(fs2.fchmodSync);
|
|
81
|
+
fs2.lchmodSync = chmodFixSync(fs2.lchmodSync);
|
|
82
|
+
fs2.stat = statFix(fs2.stat);
|
|
83
|
+
fs2.fstat = statFix(fs2.fstat);
|
|
84
|
+
fs2.lstat = statFix(fs2.lstat);
|
|
85
|
+
fs2.statSync = statFixSync(fs2.statSync);
|
|
86
|
+
fs2.fstatSync = statFixSync(fs2.fstatSync);
|
|
87
|
+
fs2.lstatSync = statFixSync(fs2.lstatSync);
|
|
88
|
+
if (fs2.chmod && !fs2.lchmod) {
|
|
89
|
+
fs2.lchmod = function(path2, mode, cb) {
|
|
90
|
+
if (cb) process.nextTick(cb);
|
|
91
|
+
};
|
|
92
|
+
fs2.lchmodSync = function() {
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (fs2.chown && !fs2.lchown) {
|
|
96
|
+
fs2.lchown = function(path2, uid, gid, cb) {
|
|
97
|
+
if (cb) process.nextTick(cb);
|
|
98
|
+
};
|
|
99
|
+
fs2.lchownSync = function() {
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (platform2 === "win32") {
|
|
103
|
+
fs2.rename = typeof fs2.rename !== "function" ? fs2.rename : (function(fs$rename) {
|
|
104
|
+
function rename2(from, to, cb) {
|
|
105
|
+
var start = Date.now();
|
|
106
|
+
var backoff = 0;
|
|
107
|
+
fs$rename(from, to, function CB(er) {
|
|
108
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
109
|
+
setTimeout(function() {
|
|
110
|
+
fs2.stat(to, function(stater, st) {
|
|
111
|
+
if (stater && stater.code === "ENOENT")
|
|
112
|
+
fs$rename(from, to, CB);
|
|
113
|
+
else
|
|
114
|
+
cb(er);
|
|
115
|
+
});
|
|
116
|
+
}, backoff);
|
|
117
|
+
if (backoff < 100)
|
|
118
|
+
backoff += 10;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (cb) cb(er);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename2, fs$rename);
|
|
125
|
+
return rename2;
|
|
126
|
+
})(fs2.rename);
|
|
127
|
+
}
|
|
128
|
+
fs2.read = typeof fs2.read !== "function" ? fs2.read : (function(fs$read) {
|
|
129
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
130
|
+
var callback;
|
|
131
|
+
if (callback_ && typeof callback_ === "function") {
|
|
132
|
+
var eagCounter = 0;
|
|
133
|
+
callback = function(er, _, __) {
|
|
134
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
135
|
+
eagCounter++;
|
|
136
|
+
return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
|
|
137
|
+
}
|
|
138
|
+
callback_.apply(this, arguments);
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
|
|
142
|
+
}
|
|
143
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
144
|
+
return read;
|
|
145
|
+
})(fs2.read);
|
|
146
|
+
fs2.readSync = typeof fs2.readSync !== "function" ? fs2.readSync : /* @__PURE__ */ (function(fs$readSync) {
|
|
147
|
+
return function(fd, buffer, offset, length, position) {
|
|
148
|
+
var eagCounter = 0;
|
|
149
|
+
while (true) {
|
|
150
|
+
try {
|
|
151
|
+
return fs$readSync.call(fs2, fd, buffer, offset, length, position);
|
|
152
|
+
} catch (er) {
|
|
153
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
154
|
+
eagCounter++;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
throw er;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
})(fs2.readSync);
|
|
162
|
+
function patchLchmod(fs3) {
|
|
163
|
+
fs3.lchmod = function(path2, mode, callback) {
|
|
164
|
+
fs3.open(
|
|
165
|
+
path2,
|
|
166
|
+
constants.O_WRONLY | constants.O_SYMLINK,
|
|
167
|
+
mode,
|
|
168
|
+
function(err, fd) {
|
|
169
|
+
if (err) {
|
|
170
|
+
if (callback) callback(err);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
fs3.fchmod(fd, mode, function(err2) {
|
|
174
|
+
fs3.close(fd, function(err22) {
|
|
175
|
+
if (callback) callback(err2 || err22);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
fs3.lchmodSync = function(path2, mode) {
|
|
182
|
+
var fd = fs3.openSync(path2, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
183
|
+
var threw = true;
|
|
184
|
+
var ret;
|
|
185
|
+
try {
|
|
186
|
+
ret = fs3.fchmodSync(fd, mode);
|
|
187
|
+
threw = false;
|
|
188
|
+
} finally {
|
|
189
|
+
if (threw) {
|
|
190
|
+
try {
|
|
191
|
+
fs3.closeSync(fd);
|
|
192
|
+
} catch (er) {
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
fs3.closeSync(fd);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return ret;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
function patchLutimes(fs3) {
|
|
202
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs3.futimes) {
|
|
203
|
+
fs3.lutimes = function(path2, at, mt, cb) {
|
|
204
|
+
fs3.open(path2, constants.O_SYMLINK, function(er, fd) {
|
|
205
|
+
if (er) {
|
|
206
|
+
if (cb) cb(er);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
fs3.futimes(fd, at, mt, function(er2) {
|
|
210
|
+
fs3.close(fd, function(er22) {
|
|
211
|
+
if (cb) cb(er2 || er22);
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
fs3.lutimesSync = function(path2, at, mt) {
|
|
217
|
+
var fd = fs3.openSync(path2, constants.O_SYMLINK);
|
|
218
|
+
var ret;
|
|
219
|
+
var threw = true;
|
|
220
|
+
try {
|
|
221
|
+
ret = fs3.futimesSync(fd, at, mt);
|
|
222
|
+
threw = false;
|
|
223
|
+
} finally {
|
|
224
|
+
if (threw) {
|
|
225
|
+
try {
|
|
226
|
+
fs3.closeSync(fd);
|
|
227
|
+
} catch (er) {
|
|
228
|
+
}
|
|
229
|
+
} else {
|
|
230
|
+
fs3.closeSync(fd);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return ret;
|
|
234
|
+
};
|
|
235
|
+
} else if (fs3.futimes) {
|
|
236
|
+
fs3.lutimes = function(_a, _b, _c, cb) {
|
|
237
|
+
if (cb) process.nextTick(cb);
|
|
238
|
+
};
|
|
239
|
+
fs3.lutimesSync = function() {
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function chmodFix(orig) {
|
|
244
|
+
if (!orig) return orig;
|
|
245
|
+
return function(target, mode, cb) {
|
|
246
|
+
return orig.call(fs2, target, mode, function(er) {
|
|
247
|
+
if (chownErOk(er)) er = null;
|
|
248
|
+
if (cb) cb.apply(this, arguments);
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function chmodFixSync(orig) {
|
|
253
|
+
if (!orig) return orig;
|
|
254
|
+
return function(target, mode) {
|
|
255
|
+
try {
|
|
256
|
+
return orig.call(fs2, target, mode);
|
|
257
|
+
} catch (er) {
|
|
258
|
+
if (!chownErOk(er)) throw er;
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function chownFix(orig) {
|
|
263
|
+
if (!orig) return orig;
|
|
264
|
+
return function(target, uid, gid, cb) {
|
|
265
|
+
return orig.call(fs2, target, uid, gid, function(er) {
|
|
266
|
+
if (chownErOk(er)) er = null;
|
|
267
|
+
if (cb) cb.apply(this, arguments);
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function chownFixSync(orig) {
|
|
272
|
+
if (!orig) return orig;
|
|
273
|
+
return function(target, uid, gid) {
|
|
274
|
+
try {
|
|
275
|
+
return orig.call(fs2, target, uid, gid);
|
|
276
|
+
} catch (er) {
|
|
277
|
+
if (!chownErOk(er)) throw er;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function statFix(orig) {
|
|
282
|
+
if (!orig) return orig;
|
|
283
|
+
return function(target, options, cb) {
|
|
284
|
+
if (typeof options === "function") {
|
|
285
|
+
cb = options;
|
|
286
|
+
options = null;
|
|
287
|
+
}
|
|
288
|
+
function callback(er, stats) {
|
|
289
|
+
if (stats) {
|
|
290
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
291
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
292
|
+
}
|
|
293
|
+
if (cb) cb.apply(this, arguments);
|
|
294
|
+
}
|
|
295
|
+
return options ? orig.call(fs2, target, options, callback) : orig.call(fs2, target, callback);
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function statFixSync(orig) {
|
|
299
|
+
if (!orig) return orig;
|
|
300
|
+
return function(target, options) {
|
|
301
|
+
var stats = options ? orig.call(fs2, target, options) : orig.call(fs2, target);
|
|
302
|
+
if (stats) {
|
|
303
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
304
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
305
|
+
}
|
|
306
|
+
return stats;
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function chownErOk(er) {
|
|
310
|
+
if (!er)
|
|
311
|
+
return true;
|
|
312
|
+
if (er.code === "ENOSYS")
|
|
313
|
+
return true;
|
|
314
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
315
|
+
if (nonroot) {
|
|
316
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
// node_modules/graceful-fs/legacy-streams.js
|
|
326
|
+
var require_legacy_streams = __commonJS({
|
|
327
|
+
"node_modules/graceful-fs/legacy-streams.js"(exports2, module2) {
|
|
328
|
+
var Stream = require("stream").Stream;
|
|
329
|
+
module2.exports = legacy;
|
|
330
|
+
function legacy(fs2) {
|
|
331
|
+
return {
|
|
332
|
+
ReadStream,
|
|
333
|
+
WriteStream
|
|
334
|
+
};
|
|
335
|
+
function ReadStream(path2, options) {
|
|
336
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path2, options);
|
|
337
|
+
Stream.call(this);
|
|
338
|
+
var self = this;
|
|
339
|
+
this.path = path2;
|
|
340
|
+
this.fd = null;
|
|
341
|
+
this.readable = true;
|
|
342
|
+
this.paused = false;
|
|
343
|
+
this.flags = "r";
|
|
344
|
+
this.mode = 438;
|
|
345
|
+
this.bufferSize = 64 * 1024;
|
|
346
|
+
options = options || {};
|
|
347
|
+
var keys = Object.keys(options);
|
|
348
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
349
|
+
var key = keys[index];
|
|
350
|
+
this[key] = options[key];
|
|
351
|
+
}
|
|
352
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
353
|
+
if (this.start !== void 0) {
|
|
354
|
+
if ("number" !== typeof this.start) {
|
|
355
|
+
throw TypeError("start must be a Number");
|
|
356
|
+
}
|
|
357
|
+
if (this.end === void 0) {
|
|
358
|
+
this.end = Infinity;
|
|
359
|
+
} else if ("number" !== typeof this.end) {
|
|
360
|
+
throw TypeError("end must be a Number");
|
|
361
|
+
}
|
|
362
|
+
if (this.start > this.end) {
|
|
363
|
+
throw new Error("start must be <= end");
|
|
364
|
+
}
|
|
365
|
+
this.pos = this.start;
|
|
366
|
+
}
|
|
367
|
+
if (this.fd !== null) {
|
|
368
|
+
process.nextTick(function() {
|
|
369
|
+
self._read();
|
|
370
|
+
});
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
fs2.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
374
|
+
if (err) {
|
|
375
|
+
self.emit("error", err);
|
|
376
|
+
self.readable = false;
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
self.fd = fd;
|
|
380
|
+
self.emit("open", fd);
|
|
381
|
+
self._read();
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
function WriteStream(path2, options) {
|
|
385
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path2, options);
|
|
386
|
+
Stream.call(this);
|
|
387
|
+
this.path = path2;
|
|
388
|
+
this.fd = null;
|
|
389
|
+
this.writable = true;
|
|
390
|
+
this.flags = "w";
|
|
391
|
+
this.encoding = "binary";
|
|
392
|
+
this.mode = 438;
|
|
393
|
+
this.bytesWritten = 0;
|
|
394
|
+
options = options || {};
|
|
395
|
+
var keys = Object.keys(options);
|
|
396
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
397
|
+
var key = keys[index];
|
|
398
|
+
this[key] = options[key];
|
|
399
|
+
}
|
|
400
|
+
if (this.start !== void 0) {
|
|
401
|
+
if ("number" !== typeof this.start) {
|
|
402
|
+
throw TypeError("start must be a Number");
|
|
403
|
+
}
|
|
404
|
+
if (this.start < 0) {
|
|
405
|
+
throw new Error("start must be >= zero");
|
|
406
|
+
}
|
|
407
|
+
this.pos = this.start;
|
|
408
|
+
}
|
|
409
|
+
this.busy = false;
|
|
410
|
+
this._queue = [];
|
|
411
|
+
if (this.fd === null) {
|
|
412
|
+
this._open = fs2.open;
|
|
413
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
414
|
+
this.flush();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// node_modules/graceful-fs/clone.js
|
|
422
|
+
var require_clone = __commonJS({
|
|
423
|
+
"node_modules/graceful-fs/clone.js"(exports2, module2) {
|
|
424
|
+
"use strict";
|
|
425
|
+
module2.exports = clone;
|
|
426
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
427
|
+
return obj.__proto__;
|
|
428
|
+
};
|
|
429
|
+
function clone(obj) {
|
|
430
|
+
if (obj === null || typeof obj !== "object")
|
|
431
|
+
return obj;
|
|
432
|
+
if (obj instanceof Object)
|
|
433
|
+
var copy = { __proto__: getPrototypeOf(obj) };
|
|
434
|
+
else
|
|
435
|
+
var copy = /* @__PURE__ */ Object.create(null);
|
|
436
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
437
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
438
|
+
});
|
|
439
|
+
return copy;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
// node_modules/graceful-fs/graceful-fs.js
|
|
445
|
+
var require_graceful_fs = __commonJS({
|
|
446
|
+
"node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
|
|
447
|
+
var fs2 = require("fs");
|
|
448
|
+
var polyfills = require_polyfills();
|
|
449
|
+
var legacy = require_legacy_streams();
|
|
450
|
+
var clone = require_clone();
|
|
451
|
+
var util = require("util");
|
|
452
|
+
var gracefulQueue;
|
|
453
|
+
var previousSymbol;
|
|
454
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
455
|
+
gracefulQueue = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
|
|
456
|
+
previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
|
|
457
|
+
} else {
|
|
458
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
459
|
+
previousSymbol = "___graceful-fs.previous";
|
|
460
|
+
}
|
|
461
|
+
function noop() {
|
|
462
|
+
}
|
|
463
|
+
function publishQueue(context, queue2) {
|
|
464
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
465
|
+
get: function() {
|
|
466
|
+
return queue2;
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
var debug = noop;
|
|
471
|
+
if (util.debuglog)
|
|
472
|
+
debug = util.debuglog("gfs4");
|
|
473
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
474
|
+
debug = function() {
|
|
475
|
+
var m = util.format.apply(util, arguments);
|
|
476
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
477
|
+
console.error(m);
|
|
478
|
+
};
|
|
479
|
+
if (!fs2[gracefulQueue]) {
|
|
480
|
+
queue = global[gracefulQueue] || [];
|
|
481
|
+
publishQueue(fs2, queue);
|
|
482
|
+
fs2.close = (function(fs$close) {
|
|
483
|
+
function close(fd, cb) {
|
|
484
|
+
return fs$close.call(fs2, fd, function(err) {
|
|
485
|
+
if (!err) {
|
|
486
|
+
resetQueue();
|
|
487
|
+
}
|
|
488
|
+
if (typeof cb === "function")
|
|
489
|
+
cb.apply(this, arguments);
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
Object.defineProperty(close, previousSymbol, {
|
|
493
|
+
value: fs$close
|
|
494
|
+
});
|
|
495
|
+
return close;
|
|
496
|
+
})(fs2.close);
|
|
497
|
+
fs2.closeSync = (function(fs$closeSync) {
|
|
498
|
+
function closeSync2(fd) {
|
|
499
|
+
fs$closeSync.apply(fs2, arguments);
|
|
500
|
+
resetQueue();
|
|
501
|
+
}
|
|
502
|
+
Object.defineProperty(closeSync2, previousSymbol, {
|
|
503
|
+
value: fs$closeSync
|
|
504
|
+
});
|
|
505
|
+
return closeSync2;
|
|
506
|
+
})(fs2.closeSync);
|
|
507
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
508
|
+
process.on("exit", function() {
|
|
509
|
+
debug(fs2[gracefulQueue]);
|
|
510
|
+
require("assert").equal(fs2[gracefulQueue].length, 0);
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
var queue;
|
|
515
|
+
if (!global[gracefulQueue]) {
|
|
516
|
+
publishQueue(global, fs2[gracefulQueue]);
|
|
517
|
+
}
|
|
518
|
+
module2.exports = patch(clone(fs2));
|
|
519
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs2.__patched) {
|
|
520
|
+
module2.exports = patch(fs2);
|
|
521
|
+
fs2.__patched = true;
|
|
522
|
+
}
|
|
523
|
+
function patch(fs3) {
|
|
524
|
+
polyfills(fs3);
|
|
525
|
+
fs3.gracefulify = patch;
|
|
526
|
+
fs3.createReadStream = createReadStream;
|
|
527
|
+
fs3.createWriteStream = createWriteStream;
|
|
528
|
+
var fs$readFile = fs3.readFile;
|
|
529
|
+
fs3.readFile = readFile9;
|
|
530
|
+
function readFile9(path2, options, cb) {
|
|
531
|
+
if (typeof options === "function")
|
|
532
|
+
cb = options, options = null;
|
|
533
|
+
return go$readFile(path2, options, cb);
|
|
534
|
+
function go$readFile(path3, options2, cb2, startTime) {
|
|
535
|
+
return fs$readFile(path3, options2, function(err) {
|
|
536
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
537
|
+
enqueue([go$readFile, [path3, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
538
|
+
else {
|
|
539
|
+
if (typeof cb2 === "function")
|
|
540
|
+
cb2.apply(this, arguments);
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
var fs$writeFile = fs3.writeFile;
|
|
546
|
+
fs3.writeFile = writeFile4;
|
|
547
|
+
function writeFile4(path2, data, options, cb) {
|
|
548
|
+
if (typeof options === "function")
|
|
549
|
+
cb = options, options = null;
|
|
550
|
+
return go$writeFile(path2, data, options, cb);
|
|
551
|
+
function go$writeFile(path3, data2, options2, cb2, startTime) {
|
|
552
|
+
return fs$writeFile(path3, data2, options2, function(err) {
|
|
553
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
554
|
+
enqueue([go$writeFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
555
|
+
else {
|
|
556
|
+
if (typeof cb2 === "function")
|
|
557
|
+
cb2.apply(this, arguments);
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
var fs$appendFile = fs3.appendFile;
|
|
563
|
+
if (fs$appendFile)
|
|
564
|
+
fs3.appendFile = appendFile;
|
|
565
|
+
function appendFile(path2, data, options, cb) {
|
|
566
|
+
if (typeof options === "function")
|
|
567
|
+
cb = options, options = null;
|
|
568
|
+
return go$appendFile(path2, data, options, cb);
|
|
569
|
+
function go$appendFile(path3, data2, options2, cb2, startTime) {
|
|
570
|
+
return fs$appendFile(path3, data2, options2, function(err) {
|
|
571
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
572
|
+
enqueue([go$appendFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
573
|
+
else {
|
|
574
|
+
if (typeof cb2 === "function")
|
|
575
|
+
cb2.apply(this, arguments);
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
var fs$copyFile = fs3.copyFile;
|
|
581
|
+
if (fs$copyFile)
|
|
582
|
+
fs3.copyFile = copyFile;
|
|
583
|
+
function copyFile(src, dest, flags, cb) {
|
|
584
|
+
if (typeof flags === "function") {
|
|
585
|
+
cb = flags;
|
|
586
|
+
flags = 0;
|
|
587
|
+
}
|
|
588
|
+
return go$copyFile(src, dest, flags, cb);
|
|
589
|
+
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
590
|
+
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
591
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
592
|
+
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
593
|
+
else {
|
|
594
|
+
if (typeof cb2 === "function")
|
|
595
|
+
cb2.apply(this, arguments);
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
var fs$readdir = fs3.readdir;
|
|
601
|
+
fs3.readdir = readdir2;
|
|
602
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
603
|
+
function readdir2(path2, options, cb) {
|
|
604
|
+
if (typeof options === "function")
|
|
605
|
+
cb = options, options = null;
|
|
606
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path3, options2, cb2, startTime) {
|
|
607
|
+
return fs$readdir(path3, fs$readdirCallback(
|
|
608
|
+
path3,
|
|
609
|
+
options2,
|
|
610
|
+
cb2,
|
|
611
|
+
startTime
|
|
612
|
+
));
|
|
613
|
+
} : function go$readdir2(path3, options2, cb2, startTime) {
|
|
614
|
+
return fs$readdir(path3, options2, fs$readdirCallback(
|
|
615
|
+
path3,
|
|
616
|
+
options2,
|
|
617
|
+
cb2,
|
|
618
|
+
startTime
|
|
619
|
+
));
|
|
620
|
+
};
|
|
621
|
+
return go$readdir(path2, options, cb);
|
|
622
|
+
function fs$readdirCallback(path3, options2, cb2, startTime) {
|
|
623
|
+
return function(err, files) {
|
|
624
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
625
|
+
enqueue([
|
|
626
|
+
go$readdir,
|
|
627
|
+
[path3, options2, cb2],
|
|
628
|
+
err,
|
|
629
|
+
startTime || Date.now(),
|
|
630
|
+
Date.now()
|
|
631
|
+
]);
|
|
632
|
+
else {
|
|
633
|
+
if (files && files.sort)
|
|
634
|
+
files.sort();
|
|
635
|
+
if (typeof cb2 === "function")
|
|
636
|
+
cb2.call(this, err, files);
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
642
|
+
var legStreams = legacy(fs3);
|
|
643
|
+
ReadStream = legStreams.ReadStream;
|
|
644
|
+
WriteStream = legStreams.WriteStream;
|
|
645
|
+
}
|
|
646
|
+
var fs$ReadStream = fs3.ReadStream;
|
|
647
|
+
if (fs$ReadStream) {
|
|
648
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
649
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
650
|
+
}
|
|
651
|
+
var fs$WriteStream = fs3.WriteStream;
|
|
652
|
+
if (fs$WriteStream) {
|
|
653
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
654
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
655
|
+
}
|
|
656
|
+
Object.defineProperty(fs3, "ReadStream", {
|
|
657
|
+
get: function() {
|
|
658
|
+
return ReadStream;
|
|
659
|
+
},
|
|
660
|
+
set: function(val) {
|
|
661
|
+
ReadStream = val;
|
|
662
|
+
},
|
|
663
|
+
enumerable: true,
|
|
664
|
+
configurable: true
|
|
665
|
+
});
|
|
666
|
+
Object.defineProperty(fs3, "WriteStream", {
|
|
667
|
+
get: function() {
|
|
668
|
+
return WriteStream;
|
|
669
|
+
},
|
|
670
|
+
set: function(val) {
|
|
671
|
+
WriteStream = val;
|
|
672
|
+
},
|
|
673
|
+
enumerable: true,
|
|
674
|
+
configurable: true
|
|
675
|
+
});
|
|
676
|
+
var FileReadStream = ReadStream;
|
|
677
|
+
Object.defineProperty(fs3, "FileReadStream", {
|
|
678
|
+
get: function() {
|
|
679
|
+
return FileReadStream;
|
|
680
|
+
},
|
|
681
|
+
set: function(val) {
|
|
682
|
+
FileReadStream = val;
|
|
683
|
+
},
|
|
684
|
+
enumerable: true,
|
|
685
|
+
configurable: true
|
|
686
|
+
});
|
|
687
|
+
var FileWriteStream = WriteStream;
|
|
688
|
+
Object.defineProperty(fs3, "FileWriteStream", {
|
|
689
|
+
get: function() {
|
|
690
|
+
return FileWriteStream;
|
|
691
|
+
},
|
|
692
|
+
set: function(val) {
|
|
693
|
+
FileWriteStream = val;
|
|
694
|
+
},
|
|
695
|
+
enumerable: true,
|
|
696
|
+
configurable: true
|
|
697
|
+
});
|
|
698
|
+
function ReadStream(path2, options) {
|
|
699
|
+
if (this instanceof ReadStream)
|
|
700
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
701
|
+
else
|
|
702
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
703
|
+
}
|
|
704
|
+
function ReadStream$open() {
|
|
705
|
+
var that = this;
|
|
706
|
+
open2(that.path, that.flags, that.mode, function(err, fd) {
|
|
707
|
+
if (err) {
|
|
708
|
+
if (that.autoClose)
|
|
709
|
+
that.destroy();
|
|
710
|
+
that.emit("error", err);
|
|
711
|
+
} else {
|
|
712
|
+
that.fd = fd;
|
|
713
|
+
that.emit("open", fd);
|
|
714
|
+
that.read();
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
function WriteStream(path2, options) {
|
|
719
|
+
if (this instanceof WriteStream)
|
|
720
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
721
|
+
else
|
|
722
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
723
|
+
}
|
|
724
|
+
function WriteStream$open() {
|
|
725
|
+
var that = this;
|
|
726
|
+
open2(that.path, that.flags, that.mode, function(err, fd) {
|
|
727
|
+
if (err) {
|
|
728
|
+
that.destroy();
|
|
729
|
+
that.emit("error", err);
|
|
730
|
+
} else {
|
|
731
|
+
that.fd = fd;
|
|
732
|
+
that.emit("open", fd);
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
function createReadStream(path2, options) {
|
|
737
|
+
return new fs3.ReadStream(path2, options);
|
|
738
|
+
}
|
|
739
|
+
function createWriteStream(path2, options) {
|
|
740
|
+
return new fs3.WriteStream(path2, options);
|
|
741
|
+
}
|
|
742
|
+
var fs$open = fs3.open;
|
|
743
|
+
fs3.open = open2;
|
|
744
|
+
function open2(path2, flags, mode, cb) {
|
|
745
|
+
if (typeof mode === "function")
|
|
746
|
+
cb = mode, mode = null;
|
|
747
|
+
return go$open(path2, flags, mode, cb);
|
|
748
|
+
function go$open(path3, flags2, mode2, cb2, startTime) {
|
|
749
|
+
return fs$open(path3, flags2, mode2, function(err, fd) {
|
|
750
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
751
|
+
enqueue([go$open, [path3, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
752
|
+
else {
|
|
753
|
+
if (typeof cb2 === "function")
|
|
754
|
+
cb2.apply(this, arguments);
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
return fs3;
|
|
760
|
+
}
|
|
761
|
+
function enqueue(elem) {
|
|
762
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
763
|
+
fs2[gracefulQueue].push(elem);
|
|
764
|
+
retry();
|
|
765
|
+
}
|
|
766
|
+
var retryTimer;
|
|
767
|
+
function resetQueue() {
|
|
768
|
+
var now = Date.now();
|
|
769
|
+
for (var i = 0; i < fs2[gracefulQueue].length; ++i) {
|
|
770
|
+
if (fs2[gracefulQueue][i].length > 2) {
|
|
771
|
+
fs2[gracefulQueue][i][3] = now;
|
|
772
|
+
fs2[gracefulQueue][i][4] = now;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
retry();
|
|
776
|
+
}
|
|
777
|
+
function retry() {
|
|
778
|
+
clearTimeout(retryTimer);
|
|
779
|
+
retryTimer = void 0;
|
|
780
|
+
if (fs2[gracefulQueue].length === 0)
|
|
781
|
+
return;
|
|
782
|
+
var elem = fs2[gracefulQueue].shift();
|
|
783
|
+
var fn = elem[0];
|
|
784
|
+
var args = elem[1];
|
|
785
|
+
var err = elem[2];
|
|
786
|
+
var startTime = elem[3];
|
|
787
|
+
var lastTime = elem[4];
|
|
788
|
+
if (startTime === void 0) {
|
|
789
|
+
debug("RETRY", fn.name, args);
|
|
790
|
+
fn.apply(null, args);
|
|
791
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
792
|
+
debug("TIMEOUT", fn.name, args);
|
|
793
|
+
var cb = args.pop();
|
|
794
|
+
if (typeof cb === "function")
|
|
795
|
+
cb.call(null, err);
|
|
796
|
+
} else {
|
|
797
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
798
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
799
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
800
|
+
if (sinceAttempt >= desiredDelay) {
|
|
801
|
+
debug("RETRY", fn.name, args);
|
|
802
|
+
fn.apply(null, args.concat([startTime]));
|
|
803
|
+
} else {
|
|
804
|
+
fs2[gracefulQueue].push(elem);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
if (retryTimer === void 0) {
|
|
808
|
+
retryTimer = setTimeout(retry, 0);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
|
|
814
|
+
// node_modules/retry/lib/retry_operation.js
|
|
815
|
+
var require_retry_operation = __commonJS({
|
|
816
|
+
"node_modules/retry/lib/retry_operation.js"(exports2, module2) {
|
|
817
|
+
function RetryOperation(timeouts, options) {
|
|
818
|
+
if (typeof options === "boolean") {
|
|
819
|
+
options = { forever: options };
|
|
820
|
+
}
|
|
821
|
+
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
822
|
+
this._timeouts = timeouts;
|
|
823
|
+
this._options = options || {};
|
|
824
|
+
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
825
|
+
this._fn = null;
|
|
826
|
+
this._errors = [];
|
|
827
|
+
this._attempts = 1;
|
|
828
|
+
this._operationTimeout = null;
|
|
829
|
+
this._operationTimeoutCb = null;
|
|
830
|
+
this._timeout = null;
|
|
831
|
+
this._operationStart = null;
|
|
832
|
+
if (this._options.forever) {
|
|
833
|
+
this._cachedTimeouts = this._timeouts.slice(0);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
module2.exports = RetryOperation;
|
|
837
|
+
RetryOperation.prototype.reset = function() {
|
|
838
|
+
this._attempts = 1;
|
|
839
|
+
this._timeouts = this._originalTimeouts;
|
|
840
|
+
};
|
|
841
|
+
RetryOperation.prototype.stop = function() {
|
|
842
|
+
if (this._timeout) {
|
|
843
|
+
clearTimeout(this._timeout);
|
|
844
|
+
}
|
|
845
|
+
this._timeouts = [];
|
|
846
|
+
this._cachedTimeouts = null;
|
|
847
|
+
};
|
|
848
|
+
RetryOperation.prototype.retry = function(err) {
|
|
849
|
+
if (this._timeout) {
|
|
850
|
+
clearTimeout(this._timeout);
|
|
851
|
+
}
|
|
852
|
+
if (!err) {
|
|
853
|
+
return false;
|
|
854
|
+
}
|
|
855
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
856
|
+
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
857
|
+
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
858
|
+
return false;
|
|
859
|
+
}
|
|
860
|
+
this._errors.push(err);
|
|
861
|
+
var timeout = this._timeouts.shift();
|
|
862
|
+
if (timeout === void 0) {
|
|
863
|
+
if (this._cachedTimeouts) {
|
|
864
|
+
this._errors.splice(this._errors.length - 1, this._errors.length);
|
|
865
|
+
this._timeouts = this._cachedTimeouts.slice(0);
|
|
866
|
+
timeout = this._timeouts.shift();
|
|
867
|
+
} else {
|
|
868
|
+
return false;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
var self = this;
|
|
872
|
+
var timer = setTimeout(function() {
|
|
873
|
+
self._attempts++;
|
|
874
|
+
if (self._operationTimeoutCb) {
|
|
875
|
+
self._timeout = setTimeout(function() {
|
|
876
|
+
self._operationTimeoutCb(self._attempts);
|
|
877
|
+
}, self._operationTimeout);
|
|
878
|
+
if (self._options.unref) {
|
|
879
|
+
self._timeout.unref();
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
self._fn(self._attempts);
|
|
883
|
+
}, timeout);
|
|
884
|
+
if (this._options.unref) {
|
|
885
|
+
timer.unref();
|
|
886
|
+
}
|
|
887
|
+
return true;
|
|
888
|
+
};
|
|
889
|
+
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
890
|
+
this._fn = fn;
|
|
891
|
+
if (timeoutOps) {
|
|
892
|
+
if (timeoutOps.timeout) {
|
|
893
|
+
this._operationTimeout = timeoutOps.timeout;
|
|
894
|
+
}
|
|
895
|
+
if (timeoutOps.cb) {
|
|
896
|
+
this._operationTimeoutCb = timeoutOps.cb;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
var self = this;
|
|
900
|
+
if (this._operationTimeoutCb) {
|
|
901
|
+
this._timeout = setTimeout(function() {
|
|
902
|
+
self._operationTimeoutCb();
|
|
903
|
+
}, self._operationTimeout);
|
|
904
|
+
}
|
|
905
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
906
|
+
this._fn(this._attempts);
|
|
907
|
+
};
|
|
908
|
+
RetryOperation.prototype.try = function(fn) {
|
|
909
|
+
console.log("Using RetryOperation.try() is deprecated");
|
|
910
|
+
this.attempt(fn);
|
|
911
|
+
};
|
|
912
|
+
RetryOperation.prototype.start = function(fn) {
|
|
913
|
+
console.log("Using RetryOperation.start() is deprecated");
|
|
914
|
+
this.attempt(fn);
|
|
915
|
+
};
|
|
916
|
+
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
917
|
+
RetryOperation.prototype.errors = function() {
|
|
918
|
+
return this._errors;
|
|
919
|
+
};
|
|
920
|
+
RetryOperation.prototype.attempts = function() {
|
|
921
|
+
return this._attempts;
|
|
922
|
+
};
|
|
923
|
+
RetryOperation.prototype.mainError = function() {
|
|
924
|
+
if (this._errors.length === 0) {
|
|
925
|
+
return null;
|
|
926
|
+
}
|
|
927
|
+
var counts = {};
|
|
928
|
+
var mainError = null;
|
|
929
|
+
var mainErrorCount = 0;
|
|
930
|
+
for (var i = 0; i < this._errors.length; i++) {
|
|
931
|
+
var error = this._errors[i];
|
|
932
|
+
var message = error.message;
|
|
933
|
+
var count = (counts[message] || 0) + 1;
|
|
934
|
+
counts[message] = count;
|
|
935
|
+
if (count >= mainErrorCount) {
|
|
936
|
+
mainError = error;
|
|
937
|
+
mainErrorCount = count;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return mainError;
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
// node_modules/retry/lib/retry.js
|
|
946
|
+
var require_retry = __commonJS({
|
|
947
|
+
"node_modules/retry/lib/retry.js"(exports2) {
|
|
948
|
+
var RetryOperation = require_retry_operation();
|
|
949
|
+
exports2.operation = function(options) {
|
|
950
|
+
var timeouts = exports2.timeouts(options);
|
|
951
|
+
return new RetryOperation(timeouts, {
|
|
952
|
+
forever: options && options.forever,
|
|
953
|
+
unref: options && options.unref,
|
|
954
|
+
maxRetryTime: options && options.maxRetryTime
|
|
955
|
+
});
|
|
956
|
+
};
|
|
957
|
+
exports2.timeouts = function(options) {
|
|
958
|
+
if (options instanceof Array) {
|
|
959
|
+
return [].concat(options);
|
|
960
|
+
}
|
|
961
|
+
var opts = {
|
|
962
|
+
retries: 10,
|
|
963
|
+
factor: 2,
|
|
964
|
+
minTimeout: 1 * 1e3,
|
|
965
|
+
maxTimeout: Infinity,
|
|
966
|
+
randomize: false
|
|
967
|
+
};
|
|
968
|
+
for (var key in options) {
|
|
969
|
+
opts[key] = options[key];
|
|
970
|
+
}
|
|
971
|
+
if (opts.minTimeout > opts.maxTimeout) {
|
|
972
|
+
throw new Error("minTimeout is greater than maxTimeout");
|
|
973
|
+
}
|
|
974
|
+
var timeouts = [];
|
|
975
|
+
for (var i = 0; i < opts.retries; i++) {
|
|
976
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
977
|
+
}
|
|
978
|
+
if (options && options.forever && !timeouts.length) {
|
|
979
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
980
|
+
}
|
|
981
|
+
timeouts.sort(function(a, b) {
|
|
982
|
+
return a - b;
|
|
983
|
+
});
|
|
984
|
+
return timeouts;
|
|
985
|
+
};
|
|
986
|
+
exports2.createTimeout = function(attempt, opts) {
|
|
987
|
+
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
988
|
+
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
|
|
989
|
+
timeout = Math.min(timeout, opts.maxTimeout);
|
|
990
|
+
return timeout;
|
|
991
|
+
};
|
|
992
|
+
exports2.wrap = function(obj, options, methods) {
|
|
993
|
+
if (options instanceof Array) {
|
|
994
|
+
methods = options;
|
|
995
|
+
options = null;
|
|
996
|
+
}
|
|
997
|
+
if (!methods) {
|
|
998
|
+
methods = [];
|
|
999
|
+
for (var key in obj) {
|
|
1000
|
+
if (typeof obj[key] === "function") {
|
|
1001
|
+
methods.push(key);
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
for (var i = 0; i < methods.length; i++) {
|
|
1006
|
+
var method = methods[i];
|
|
1007
|
+
var original = obj[method];
|
|
1008
|
+
obj[method] = function retryWrapper(original2) {
|
|
1009
|
+
var op = exports2.operation(options);
|
|
1010
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
1011
|
+
var callback = args.pop();
|
|
1012
|
+
args.push(function(err) {
|
|
1013
|
+
if (op.retry(err)) {
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
if (err) {
|
|
1017
|
+
arguments[0] = op.mainError();
|
|
1018
|
+
}
|
|
1019
|
+
callback.apply(this, arguments);
|
|
1020
|
+
});
|
|
1021
|
+
op.attempt(function() {
|
|
1022
|
+
original2.apply(obj, args);
|
|
1023
|
+
});
|
|
1024
|
+
}.bind(obj, original);
|
|
1025
|
+
obj[method].options = options;
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
|
|
1031
|
+
// node_modules/retry/index.js
|
|
1032
|
+
var require_retry2 = __commonJS({
|
|
1033
|
+
"node_modules/retry/index.js"(exports2, module2) {
|
|
1034
|
+
module2.exports = require_retry();
|
|
1035
|
+
}
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
// node_modules/signal-exit/signals.js
|
|
1039
|
+
var require_signals = __commonJS({
|
|
1040
|
+
"node_modules/signal-exit/signals.js"(exports2, module2) {
|
|
1041
|
+
module2.exports = [
|
|
1042
|
+
"SIGABRT",
|
|
1043
|
+
"SIGALRM",
|
|
1044
|
+
"SIGHUP",
|
|
1045
|
+
"SIGINT",
|
|
1046
|
+
"SIGTERM"
|
|
1047
|
+
];
|
|
1048
|
+
if (process.platform !== "win32") {
|
|
1049
|
+
module2.exports.push(
|
|
1050
|
+
"SIGVTALRM",
|
|
1051
|
+
"SIGXCPU",
|
|
1052
|
+
"SIGXFSZ",
|
|
1053
|
+
"SIGUSR2",
|
|
1054
|
+
"SIGTRAP",
|
|
1055
|
+
"SIGSYS",
|
|
1056
|
+
"SIGQUIT",
|
|
1057
|
+
"SIGIOT"
|
|
1058
|
+
// should detect profiler and enable/disable accordingly.
|
|
1059
|
+
// see #21
|
|
1060
|
+
// 'SIGPROF'
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
1063
|
+
if (process.platform === "linux") {
|
|
1064
|
+
module2.exports.push(
|
|
1065
|
+
"SIGIO",
|
|
1066
|
+
"SIGPOLL",
|
|
1067
|
+
"SIGPWR",
|
|
1068
|
+
"SIGSTKFLT",
|
|
1069
|
+
"SIGUNUSED"
|
|
1070
|
+
);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
|
|
1075
|
+
// node_modules/signal-exit/index.js
|
|
1076
|
+
var require_signal_exit = __commonJS({
|
|
1077
|
+
"node_modules/signal-exit/index.js"(exports2, module2) {
|
|
1078
|
+
var process3 = global.process;
|
|
1079
|
+
var processOk = function(process4) {
|
|
1080
|
+
return process4 && typeof process4 === "object" && typeof process4.removeListener === "function" && typeof process4.emit === "function" && typeof process4.reallyExit === "function" && typeof process4.listeners === "function" && typeof process4.kill === "function" && typeof process4.pid === "number" && typeof process4.on === "function";
|
|
1081
|
+
};
|
|
1082
|
+
if (!processOk(process3)) {
|
|
1083
|
+
module2.exports = function() {
|
|
1084
|
+
return function() {
|
|
1085
|
+
};
|
|
1086
|
+
};
|
|
1087
|
+
} else {
|
|
1088
|
+
assert = require("assert");
|
|
1089
|
+
signals = require_signals();
|
|
1090
|
+
isWin3 = /^win/i.test(process3.platform);
|
|
1091
|
+
EE = require("events");
|
|
1092
|
+
if (typeof EE !== "function") {
|
|
1093
|
+
EE = EE.EventEmitter;
|
|
1094
|
+
}
|
|
1095
|
+
if (process3.__signal_exit_emitter__) {
|
|
1096
|
+
emitter = process3.__signal_exit_emitter__;
|
|
1097
|
+
} else {
|
|
1098
|
+
emitter = process3.__signal_exit_emitter__ = new EE();
|
|
1099
|
+
emitter.count = 0;
|
|
1100
|
+
emitter.emitted = {};
|
|
1101
|
+
}
|
|
1102
|
+
if (!emitter.infinite) {
|
|
1103
|
+
emitter.setMaxListeners(Infinity);
|
|
1104
|
+
emitter.infinite = true;
|
|
1105
|
+
}
|
|
1106
|
+
module2.exports = function(cb, opts) {
|
|
1107
|
+
if (!processOk(global.process)) {
|
|
1108
|
+
return function() {
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
1112
|
+
if (loaded === false) {
|
|
1113
|
+
load();
|
|
1114
|
+
}
|
|
1115
|
+
var ev = "exit";
|
|
1116
|
+
if (opts && opts.alwaysLast) {
|
|
1117
|
+
ev = "afterexit";
|
|
1118
|
+
}
|
|
1119
|
+
var remove2 = function() {
|
|
1120
|
+
emitter.removeListener(ev, cb);
|
|
1121
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
|
|
1122
|
+
unload();
|
|
1123
|
+
}
|
|
1124
|
+
};
|
|
1125
|
+
emitter.on(ev, cb);
|
|
1126
|
+
return remove2;
|
|
1127
|
+
};
|
|
1128
|
+
unload = function unload2() {
|
|
1129
|
+
if (!loaded || !processOk(global.process)) {
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
loaded = false;
|
|
1133
|
+
signals.forEach(function(sig) {
|
|
1134
|
+
try {
|
|
1135
|
+
process3.removeListener(sig, sigListeners[sig]);
|
|
1136
|
+
} catch (er) {
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1139
|
+
process3.emit = originalProcessEmit;
|
|
1140
|
+
process3.reallyExit = originalProcessReallyExit;
|
|
1141
|
+
emitter.count -= 1;
|
|
1142
|
+
};
|
|
1143
|
+
module2.exports.unload = unload;
|
|
1144
|
+
emit = function emit2(event, code, signal) {
|
|
1145
|
+
if (emitter.emitted[event]) {
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
emitter.emitted[event] = true;
|
|
1149
|
+
emitter.emit(event, code, signal);
|
|
1150
|
+
};
|
|
1151
|
+
sigListeners = {};
|
|
1152
|
+
signals.forEach(function(sig) {
|
|
1153
|
+
sigListeners[sig] = function listener() {
|
|
1154
|
+
if (!processOk(global.process)) {
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
var listeners = process3.listeners(sig);
|
|
1158
|
+
if (listeners.length === emitter.count) {
|
|
1159
|
+
unload();
|
|
1160
|
+
emit("exit", null, sig);
|
|
1161
|
+
emit("afterexit", null, sig);
|
|
1162
|
+
if (isWin3 && sig === "SIGHUP") {
|
|
1163
|
+
sig = "SIGINT";
|
|
1164
|
+
}
|
|
1165
|
+
process3.kill(process3.pid, sig);
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
});
|
|
1169
|
+
module2.exports.signals = function() {
|
|
1170
|
+
return signals;
|
|
1171
|
+
};
|
|
1172
|
+
loaded = false;
|
|
1173
|
+
load = function load2() {
|
|
1174
|
+
if (loaded || !processOk(global.process)) {
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
loaded = true;
|
|
1178
|
+
emitter.count += 1;
|
|
1179
|
+
signals = signals.filter(function(sig) {
|
|
1180
|
+
try {
|
|
1181
|
+
process3.on(sig, sigListeners[sig]);
|
|
1182
|
+
return true;
|
|
1183
|
+
} catch (er) {
|
|
1184
|
+
return false;
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
process3.emit = processEmit;
|
|
1188
|
+
process3.reallyExit = processReallyExit;
|
|
1189
|
+
};
|
|
1190
|
+
module2.exports.load = load;
|
|
1191
|
+
originalProcessReallyExit = process3.reallyExit;
|
|
1192
|
+
processReallyExit = function processReallyExit2(code) {
|
|
1193
|
+
if (!processOk(global.process)) {
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
process3.exitCode = code || /* istanbul ignore next */
|
|
1197
|
+
0;
|
|
1198
|
+
emit("exit", process3.exitCode, null);
|
|
1199
|
+
emit("afterexit", process3.exitCode, null);
|
|
1200
|
+
originalProcessReallyExit.call(process3, process3.exitCode);
|
|
1201
|
+
};
|
|
1202
|
+
originalProcessEmit = process3.emit;
|
|
1203
|
+
processEmit = function processEmit2(ev, arg) {
|
|
1204
|
+
if (ev === "exit" && processOk(global.process)) {
|
|
1205
|
+
if (arg !== void 0) {
|
|
1206
|
+
process3.exitCode = arg;
|
|
1207
|
+
}
|
|
1208
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
1209
|
+
emit("exit", process3.exitCode, null);
|
|
1210
|
+
emit("afterexit", process3.exitCode, null);
|
|
1211
|
+
return ret;
|
|
1212
|
+
} else {
|
|
1213
|
+
return originalProcessEmit.apply(this, arguments);
|
|
1214
|
+
}
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
var assert;
|
|
1218
|
+
var signals;
|
|
1219
|
+
var isWin3;
|
|
1220
|
+
var EE;
|
|
1221
|
+
var emitter;
|
|
1222
|
+
var unload;
|
|
1223
|
+
var emit;
|
|
1224
|
+
var sigListeners;
|
|
1225
|
+
var loaded;
|
|
1226
|
+
var load;
|
|
1227
|
+
var originalProcessReallyExit;
|
|
1228
|
+
var processReallyExit;
|
|
1229
|
+
var originalProcessEmit;
|
|
1230
|
+
var processEmit;
|
|
1231
|
+
}
|
|
1232
|
+
});
|
|
1233
|
+
|
|
1234
|
+
// node_modules/proper-lockfile/lib/mtime-precision.js
|
|
1235
|
+
var require_mtime_precision = __commonJS({
|
|
1236
|
+
"node_modules/proper-lockfile/lib/mtime-precision.js"(exports2, module2) {
|
|
1237
|
+
"use strict";
|
|
1238
|
+
var cacheSymbol = /* @__PURE__ */ Symbol();
|
|
1239
|
+
function probe(file, fs2, callback) {
|
|
1240
|
+
const cachedPrecision = fs2[cacheSymbol];
|
|
1241
|
+
if (cachedPrecision) {
|
|
1242
|
+
return fs2.stat(file, (err, stat3) => {
|
|
1243
|
+
if (err) {
|
|
1244
|
+
return callback(err);
|
|
1245
|
+
}
|
|
1246
|
+
callback(null, stat3.mtime, cachedPrecision);
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1250
|
+
fs2.utimes(file, mtime, mtime, (err) => {
|
|
1251
|
+
if (err) {
|
|
1252
|
+
return callback(err);
|
|
1253
|
+
}
|
|
1254
|
+
fs2.stat(file, (err2, stat3) => {
|
|
1255
|
+
if (err2) {
|
|
1256
|
+
return callback(err2);
|
|
1257
|
+
}
|
|
1258
|
+
const precision = stat3.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1259
|
+
Object.defineProperty(fs2, cacheSymbol, { value: precision });
|
|
1260
|
+
callback(null, stat3.mtime, precision);
|
|
1261
|
+
});
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
function getMtime(precision) {
|
|
1265
|
+
let now = Date.now();
|
|
1266
|
+
if (precision === "s") {
|
|
1267
|
+
now = Math.ceil(now / 1e3) * 1e3;
|
|
1268
|
+
}
|
|
1269
|
+
return new Date(now);
|
|
1270
|
+
}
|
|
1271
|
+
module2.exports.probe = probe;
|
|
1272
|
+
module2.exports.getMtime = getMtime;
|
|
1273
|
+
}
|
|
1274
|
+
});
|
|
1275
|
+
|
|
1276
|
+
// node_modules/proper-lockfile/lib/lockfile.js
|
|
1277
|
+
var require_lockfile = __commonJS({
|
|
1278
|
+
"node_modules/proper-lockfile/lib/lockfile.js"(exports2, module2) {
|
|
1279
|
+
"use strict";
|
|
1280
|
+
var path2 = require("path");
|
|
1281
|
+
var fs2 = require_graceful_fs();
|
|
1282
|
+
var retry = require_retry2();
|
|
1283
|
+
var onExit = require_signal_exit();
|
|
1284
|
+
var mtimePrecision = require_mtime_precision();
|
|
1285
|
+
var locks = {};
|
|
1286
|
+
function getLockFile(file, options) {
|
|
1287
|
+
return options.lockfilePath || `${file}.lock`;
|
|
1288
|
+
}
|
|
1289
|
+
function resolveCanonicalPath(file, options, callback) {
|
|
1290
|
+
if (!options.realpath) {
|
|
1291
|
+
return callback(null, path2.resolve(file));
|
|
1292
|
+
}
|
|
1293
|
+
options.fs.realpath(file, callback);
|
|
1294
|
+
}
|
|
1295
|
+
function acquireLock2(file, options, callback) {
|
|
1296
|
+
const lockfilePath = getLockFile(file, options);
|
|
1297
|
+
options.fs.mkdir(lockfilePath, (err) => {
|
|
1298
|
+
if (!err) {
|
|
1299
|
+
return mtimePrecision.probe(lockfilePath, options.fs, (err2, mtime, mtimePrecision2) => {
|
|
1300
|
+
if (err2) {
|
|
1301
|
+
options.fs.rmdir(lockfilePath, () => {
|
|
1302
|
+
});
|
|
1303
|
+
return callback(err2);
|
|
1304
|
+
}
|
|
1305
|
+
callback(null, mtime, mtimePrecision2);
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
if (err.code !== "EEXIST") {
|
|
1309
|
+
return callback(err);
|
|
1310
|
+
}
|
|
1311
|
+
if (options.stale <= 0) {
|
|
1312
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1313
|
+
}
|
|
1314
|
+
options.fs.stat(lockfilePath, (err2, stat3) => {
|
|
1315
|
+
if (err2) {
|
|
1316
|
+
if (err2.code === "ENOENT") {
|
|
1317
|
+
return acquireLock2(file, { ...options, stale: 0 }, callback);
|
|
1318
|
+
}
|
|
1319
|
+
return callback(err2);
|
|
1320
|
+
}
|
|
1321
|
+
if (!isLockStale(stat3, options)) {
|
|
1322
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1323
|
+
}
|
|
1324
|
+
removeLock(file, options, (err3) => {
|
|
1325
|
+
if (err3) {
|
|
1326
|
+
return callback(err3);
|
|
1327
|
+
}
|
|
1328
|
+
acquireLock2(file, { ...options, stale: 0 }, callback);
|
|
1329
|
+
});
|
|
1330
|
+
});
|
|
1331
|
+
});
|
|
1332
|
+
}
|
|
1333
|
+
function isLockStale(stat3, options) {
|
|
1334
|
+
return stat3.mtime.getTime() < Date.now() - options.stale;
|
|
1335
|
+
}
|
|
1336
|
+
function removeLock(file, options, callback) {
|
|
1337
|
+
options.fs.rmdir(getLockFile(file, options), (err) => {
|
|
1338
|
+
if (err && err.code !== "ENOENT") {
|
|
1339
|
+
return callback(err);
|
|
1340
|
+
}
|
|
1341
|
+
callback();
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
function updateLock(file, options) {
|
|
1345
|
+
const lock2 = locks[file];
|
|
1346
|
+
if (lock2.updateTimeout) {
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
lock2.updateDelay = lock2.updateDelay || options.update;
|
|
1350
|
+
lock2.updateTimeout = setTimeout(() => {
|
|
1351
|
+
lock2.updateTimeout = null;
|
|
1352
|
+
options.fs.stat(lock2.lockfilePath, (err, stat3) => {
|
|
1353
|
+
const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
|
|
1354
|
+
if (err) {
|
|
1355
|
+
if (err.code === "ENOENT" || isOverThreshold) {
|
|
1356
|
+
return setLockAsCompromised(file, lock2, Object.assign(err, { code: "ECOMPROMISED" }));
|
|
1357
|
+
}
|
|
1358
|
+
lock2.updateDelay = 1e3;
|
|
1359
|
+
return updateLock(file, options);
|
|
1360
|
+
}
|
|
1361
|
+
const isMtimeOurs = lock2.mtime.getTime() === stat3.mtime.getTime();
|
|
1362
|
+
if (!isMtimeOurs) {
|
|
1363
|
+
return setLockAsCompromised(
|
|
1364
|
+
file,
|
|
1365
|
+
lock2,
|
|
1366
|
+
Object.assign(
|
|
1367
|
+
new Error("Unable to update lock within the stale threshold"),
|
|
1368
|
+
{ code: "ECOMPROMISED" }
|
|
1369
|
+
)
|
|
1370
|
+
);
|
|
1371
|
+
}
|
|
1372
|
+
const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
|
|
1373
|
+
options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err2) => {
|
|
1374
|
+
const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
|
|
1375
|
+
if (lock2.released) {
|
|
1376
|
+
return;
|
|
1377
|
+
}
|
|
1378
|
+
if (err2) {
|
|
1379
|
+
if (err2.code === "ENOENT" || isOverThreshold2) {
|
|
1380
|
+
return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
|
|
1381
|
+
}
|
|
1382
|
+
lock2.updateDelay = 1e3;
|
|
1383
|
+
return updateLock(file, options);
|
|
1384
|
+
}
|
|
1385
|
+
lock2.mtime = mtime;
|
|
1386
|
+
lock2.lastUpdate = Date.now();
|
|
1387
|
+
lock2.updateDelay = null;
|
|
1388
|
+
updateLock(file, options);
|
|
1389
|
+
});
|
|
1390
|
+
});
|
|
1391
|
+
}, lock2.updateDelay);
|
|
1392
|
+
if (lock2.updateTimeout.unref) {
|
|
1393
|
+
lock2.updateTimeout.unref();
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
function setLockAsCompromised(file, lock2, err) {
|
|
1397
|
+
lock2.released = true;
|
|
1398
|
+
if (lock2.updateTimeout) {
|
|
1399
|
+
clearTimeout(lock2.updateTimeout);
|
|
1400
|
+
}
|
|
1401
|
+
if (locks[file] === lock2) {
|
|
1402
|
+
delete locks[file];
|
|
1403
|
+
}
|
|
1404
|
+
lock2.options.onCompromised(err);
|
|
1405
|
+
}
|
|
1406
|
+
function lock(file, options, callback) {
|
|
1407
|
+
options = {
|
|
1408
|
+
stale: 1e4,
|
|
1409
|
+
update: null,
|
|
1410
|
+
realpath: true,
|
|
1411
|
+
retries: 0,
|
|
1412
|
+
fs: fs2,
|
|
1413
|
+
onCompromised: (err) => {
|
|
1414
|
+
throw err;
|
|
1415
|
+
},
|
|
1416
|
+
...options
|
|
1417
|
+
};
|
|
1418
|
+
options.retries = options.retries || 0;
|
|
1419
|
+
options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
|
|
1420
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1421
|
+
options.update = options.update == null ? options.stale / 2 : options.update || 0;
|
|
1422
|
+
options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
|
|
1423
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1424
|
+
if (err) {
|
|
1425
|
+
return callback(err);
|
|
1426
|
+
}
|
|
1427
|
+
const operation = retry.operation(options.retries);
|
|
1428
|
+
operation.attempt(() => {
|
|
1429
|
+
acquireLock2(file2, options, (err2, mtime, mtimePrecision2) => {
|
|
1430
|
+
if (operation.retry(err2)) {
|
|
1431
|
+
return;
|
|
1432
|
+
}
|
|
1433
|
+
if (err2) {
|
|
1434
|
+
return callback(operation.mainError());
|
|
1435
|
+
}
|
|
1436
|
+
const lock2 = locks[file2] = {
|
|
1437
|
+
lockfilePath: getLockFile(file2, options),
|
|
1438
|
+
mtime,
|
|
1439
|
+
mtimePrecision: mtimePrecision2,
|
|
1440
|
+
options,
|
|
1441
|
+
lastUpdate: Date.now()
|
|
1442
|
+
};
|
|
1443
|
+
updateLock(file2, options);
|
|
1444
|
+
callback(null, (releasedCallback) => {
|
|
1445
|
+
if (lock2.released) {
|
|
1446
|
+
return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
|
|
1447
|
+
}
|
|
1448
|
+
unlock(file2, { ...options, realpath: false }, releasedCallback);
|
|
1449
|
+
});
|
|
1450
|
+
});
|
|
1451
|
+
});
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
function unlock(file, options, callback) {
|
|
1455
|
+
options = {
|
|
1456
|
+
fs: fs2,
|
|
1457
|
+
realpath: true,
|
|
1458
|
+
...options
|
|
1459
|
+
};
|
|
1460
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1461
|
+
if (err) {
|
|
1462
|
+
return callback(err);
|
|
1463
|
+
}
|
|
1464
|
+
const lock2 = locks[file2];
|
|
1465
|
+
if (!lock2) {
|
|
1466
|
+
return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
|
|
1467
|
+
}
|
|
1468
|
+
lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
|
|
1469
|
+
lock2.released = true;
|
|
1470
|
+
delete locks[file2];
|
|
1471
|
+
removeLock(file2, options, callback);
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
function check(file, options, callback) {
|
|
1475
|
+
options = {
|
|
1476
|
+
stale: 1e4,
|
|
1477
|
+
realpath: true,
|
|
1478
|
+
fs: fs2,
|
|
1479
|
+
...options
|
|
1480
|
+
};
|
|
1481
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1482
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
1483
|
+
if (err) {
|
|
1484
|
+
return callback(err);
|
|
1485
|
+
}
|
|
1486
|
+
options.fs.stat(getLockFile(file2, options), (err2, stat3) => {
|
|
1487
|
+
if (err2) {
|
|
1488
|
+
return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
|
|
1489
|
+
}
|
|
1490
|
+
return callback(null, !isLockStale(stat3, options));
|
|
1491
|
+
});
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
function getLocks() {
|
|
1495
|
+
return locks;
|
|
1496
|
+
}
|
|
1497
|
+
onExit(() => {
|
|
1498
|
+
for (const file in locks) {
|
|
1499
|
+
const options = locks[file].options;
|
|
1500
|
+
try {
|
|
1501
|
+
options.fs.rmdirSync(getLockFile(file, options));
|
|
1502
|
+
} catch (e) {
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
});
|
|
1506
|
+
module2.exports.lock = lock;
|
|
1507
|
+
module2.exports.unlock = unlock;
|
|
1508
|
+
module2.exports.check = check;
|
|
1509
|
+
module2.exports.getLocks = getLocks;
|
|
1510
|
+
}
|
|
1511
|
+
});
|
|
1512
|
+
|
|
1513
|
+
// node_modules/proper-lockfile/lib/adapter.js
|
|
1514
|
+
var require_adapter = __commonJS({
|
|
1515
|
+
"node_modules/proper-lockfile/lib/adapter.js"(exports2, module2) {
|
|
1516
|
+
"use strict";
|
|
1517
|
+
var fs2 = require_graceful_fs();
|
|
1518
|
+
function createSyncFs(fs3) {
|
|
1519
|
+
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
1520
|
+
const newFs = { ...fs3 };
|
|
1521
|
+
methods.forEach((method) => {
|
|
1522
|
+
newFs[method] = (...args) => {
|
|
1523
|
+
const callback = args.pop();
|
|
1524
|
+
let ret;
|
|
1525
|
+
try {
|
|
1526
|
+
ret = fs3[`${method}Sync`](...args);
|
|
1527
|
+
} catch (err) {
|
|
1528
|
+
return callback(err);
|
|
1529
|
+
}
|
|
1530
|
+
callback(null, ret);
|
|
1531
|
+
};
|
|
1532
|
+
});
|
|
1533
|
+
return newFs;
|
|
1534
|
+
}
|
|
1535
|
+
function toPromise(method) {
|
|
1536
|
+
return (...args) => new Promise((resolve5, reject) => {
|
|
1537
|
+
args.push((err, result) => {
|
|
1538
|
+
if (err) {
|
|
1539
|
+
reject(err);
|
|
1540
|
+
} else {
|
|
1541
|
+
resolve5(result);
|
|
1542
|
+
}
|
|
1543
|
+
});
|
|
1544
|
+
method(...args);
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
function toSync(method) {
|
|
1548
|
+
return (...args) => {
|
|
1549
|
+
let err;
|
|
1550
|
+
let result;
|
|
1551
|
+
args.push((_err, _result) => {
|
|
1552
|
+
err = _err;
|
|
1553
|
+
result = _result;
|
|
1554
|
+
});
|
|
1555
|
+
method(...args);
|
|
1556
|
+
if (err) {
|
|
1557
|
+
throw err;
|
|
1558
|
+
}
|
|
1559
|
+
return result;
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1562
|
+
function toSyncOptions(options) {
|
|
1563
|
+
options = { ...options };
|
|
1564
|
+
options.fs = createSyncFs(options.fs || fs2);
|
|
1565
|
+
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
1566
|
+
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
1567
|
+
}
|
|
1568
|
+
return options;
|
|
1569
|
+
}
|
|
1570
|
+
module2.exports = {
|
|
1571
|
+
toPromise,
|
|
1572
|
+
toSync,
|
|
1573
|
+
toSyncOptions
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
});
|
|
1577
|
+
|
|
1578
|
+
// node_modules/proper-lockfile/index.js
|
|
1579
|
+
var require_proper_lockfile = __commonJS({
|
|
1580
|
+
"node_modules/proper-lockfile/index.js"(exports2, module2) {
|
|
1581
|
+
"use strict";
|
|
1582
|
+
var lockfile2 = require_lockfile();
|
|
1583
|
+
var { toPromise, toSync, toSyncOptions } = require_adapter();
|
|
1584
|
+
async function lock(file, options) {
|
|
1585
|
+
const release = await toPromise(lockfile2.lock)(file, options);
|
|
1586
|
+
return toPromise(release);
|
|
1587
|
+
}
|
|
1588
|
+
function lockSync(file, options) {
|
|
1589
|
+
const release = toSync(lockfile2.lock)(file, toSyncOptions(options));
|
|
1590
|
+
return toSync(release);
|
|
1591
|
+
}
|
|
1592
|
+
function unlock(file, options) {
|
|
1593
|
+
return toPromise(lockfile2.unlock)(file, options);
|
|
1594
|
+
}
|
|
1595
|
+
function unlockSync(file, options) {
|
|
1596
|
+
return toSync(lockfile2.unlock)(file, toSyncOptions(options));
|
|
1597
|
+
}
|
|
1598
|
+
function check(file, options) {
|
|
1599
|
+
return toPromise(lockfile2.check)(file, options);
|
|
1600
|
+
}
|
|
1601
|
+
function checkSync(file, options) {
|
|
1602
|
+
return toSync(lockfile2.check)(file, toSyncOptions(options));
|
|
1603
|
+
}
|
|
1604
|
+
module2.exports = lock;
|
|
1605
|
+
module2.exports.lock = lock;
|
|
1606
|
+
module2.exports.unlock = unlock;
|
|
1607
|
+
module2.exports.lockSync = lockSync;
|
|
1608
|
+
module2.exports.unlockSync = unlockSync;
|
|
1609
|
+
module2.exports.check = check;
|
|
1610
|
+
module2.exports.checkSync = checkSync;
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
|
|
30
1614
|
// src/index.ts
|
|
31
1615
|
var index_exports = {};
|
|
32
1616
|
__export(index_exports, {
|
|
@@ -3416,7 +5000,7 @@ var program = new Command();
|
|
|
3416
5000
|
|
|
3417
5001
|
// src/index.ts
|
|
3418
5002
|
var import_promises11 = require("node:fs/promises");
|
|
3419
|
-
var
|
|
5003
|
+
var import_node_fs41 = require("node:fs");
|
|
3420
5004
|
var import_node_child_process19 = require("node:child_process");
|
|
3421
5005
|
|
|
3422
5006
|
// src/cli-shared.ts
|
|
@@ -7006,7 +8590,7 @@ function commandLadderHint() {
|
|
|
7006
8590
|
}
|
|
7007
8591
|
|
|
7008
8592
|
// src/index.ts
|
|
7009
|
-
var
|
|
8593
|
+
var import_node_path39 = require("node:path");
|
|
7010
8594
|
|
|
7011
8595
|
// src/merge-ci-policy.ts
|
|
7012
8596
|
function resolveMergeCiPolicy(input) {
|
|
@@ -8741,6 +10325,7 @@ var import_node_fs15 = require("node:fs");
|
|
|
8741
10325
|
var import_node_child_process6 = require("node:child_process");
|
|
8742
10326
|
var import_node_path14 = require("node:path");
|
|
8743
10327
|
var import_node_os4 = require("node:os");
|
|
10328
|
+
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
8744
10329
|
|
|
8745
10330
|
// src/version-lag.ts
|
|
8746
10331
|
var VERSION_LABEL = "installed plugin/adapter cache freshness";
|
|
@@ -9270,17 +10855,26 @@ function findMmiPiSourceClone(home = (0, import_node_os4.homedir)()) {
|
|
|
9270
10855
|
}
|
|
9271
10856
|
return best;
|
|
9272
10857
|
}
|
|
10858
|
+
function acquirePiSettingsLock(settingsPath2) {
|
|
10859
|
+
const maxAttempts = 10;
|
|
10860
|
+
const delayMs = 20;
|
|
10861
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
10862
|
+
try {
|
|
10863
|
+
return import_proper_lockfile.default.lockSync(settingsPath2, { realpath: false });
|
|
10864
|
+
} catch (error) {
|
|
10865
|
+
const code = typeof error === "object" && error !== null && "code" in error ? String(error.code) : void 0;
|
|
10866
|
+
if (code !== "ELOCKED" || attempt === maxAttempts) return void 0;
|
|
10867
|
+
const start = Date.now();
|
|
10868
|
+
while (Date.now() - start < delayMs) {
|
|
10869
|
+
}
|
|
10870
|
+
}
|
|
10871
|
+
}
|
|
10872
|
+
return void 0;
|
|
10873
|
+
}
|
|
9273
10874
|
function healJervCodePackageRegistration(opts = {}) {
|
|
9274
10875
|
const env = opts.env ?? process.env;
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
available: true,
|
|
9278
|
-
ok: true,
|
|
9279
|
-
changed: false,
|
|
9280
|
-
version: null,
|
|
9281
|
-
detail: "skipped \u2014 live JervCode/Pi seat (PI_SESSION_ID set); the package set is read at launch, so this registration is deferred to an out-of-session doctor run"
|
|
9282
|
-
};
|
|
9283
|
-
}
|
|
10876
|
+
const inSeat = !!env.PI_SESSION_ID?.trim();
|
|
10877
|
+
const nextLaunch = inSeat ? " \u2014 takes effect on the next seat launch" : "";
|
|
9284
10878
|
const home = opts.home ?? (0, import_node_os4.homedir)();
|
|
9285
10879
|
const agentDir = surfaceConfigRoot("jervcode", env, home);
|
|
9286
10880
|
if (!(0, import_node_fs15.existsSync)(agentDir)) {
|
|
@@ -9292,45 +10886,59 @@ function healJervCodePackageRegistration(opts = {}) {
|
|
|
9292
10886
|
}
|
|
9293
10887
|
const packagePath = `${clone.path.replace(/\\/g, "/").replace(/\/+$/, "")}/${JERVCODE_WRAPPER_DIR}`;
|
|
9294
10888
|
const settingsPath2 = (0, import_node_path14.join)(agentDir, "settings.json");
|
|
9295
|
-
const
|
|
9296
|
-
if (
|
|
10889
|
+
const release = (0, import_node_fs15.existsSync)(settingsPath2) ? acquirePiSettingsLock(settingsPath2) : void 0;
|
|
10890
|
+
if ((0, import_node_fs15.existsSync)(settingsPath2) && !release) {
|
|
9297
10891
|
return {
|
|
9298
10892
|
available: true,
|
|
9299
10893
|
ok: false,
|
|
9300
10894
|
changed: false,
|
|
9301
10895
|
version: clone.version,
|
|
9302
|
-
detail: `package NOT registered \u2014 ${settingsPath2} is
|
|
10896
|
+
detail: `package NOT registered \u2014 Pi's settings lock (${settingsPath2}.lock) is held by another process; nothing written, retry on the next doctor run`
|
|
9303
10897
|
};
|
|
9304
10898
|
}
|
|
9305
|
-
const current = settings ?? {};
|
|
9306
|
-
const entries = Array.isArray(current.packages) ? current.packages : [];
|
|
9307
|
-
const merged = mergeMmiPiPackageEntries(entries, packagePath);
|
|
9308
|
-
if (!merged.changed) {
|
|
9309
|
-
return { available: true, ok: true, changed: false, version: clone.version, detail: `holds ${clone.version}` };
|
|
9310
|
-
}
|
|
9311
|
-
current.packages = merged.next;
|
|
9312
10899
|
try {
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
10900
|
+
const settings = readPiSettings(settingsPath2);
|
|
10901
|
+
if (settings === null) {
|
|
10902
|
+
return {
|
|
10903
|
+
available: true,
|
|
10904
|
+
ok: false,
|
|
10905
|
+
changed: false,
|
|
10906
|
+
version: clone.version,
|
|
10907
|
+
detail: `package NOT registered \u2014 ${settingsPath2} is not a strict JSON object, so mmi left it alone; add ${packagePath} to its packages array by hand`
|
|
10908
|
+
};
|
|
10909
|
+
}
|
|
10910
|
+
const current = settings ?? {};
|
|
10911
|
+
const entries = Array.isArray(current.packages) ? current.packages : [];
|
|
10912
|
+
const merged = mergeMmiPiPackageEntries(entries, packagePath);
|
|
10913
|
+
if (!merged.changed) {
|
|
10914
|
+
return { available: true, ok: true, changed: false, version: clone.version, detail: `holds ${clone.version}` };
|
|
10915
|
+
}
|
|
10916
|
+
current.packages = merged.next;
|
|
9317
10917
|
try {
|
|
9318
|
-
(0, import_node_fs15.
|
|
9319
|
-
|
|
9320
|
-
(0, import_node_fs15.
|
|
9321
|
-
|
|
10918
|
+
(0, import_node_fs15.mkdirSync)((0, import_node_path14.dirname)(settingsPath2), { recursive: true });
|
|
10919
|
+
const tmp = `${settingsPath2}.tmp-${process.pid}`;
|
|
10920
|
+
(0, import_node_fs15.writeFileSync)(tmp, `${JSON.stringify(current, null, 2)}
|
|
10921
|
+
`, "utf8");
|
|
10922
|
+
try {
|
|
10923
|
+
(0, import_node_fs15.renameSync)(tmp, settingsPath2);
|
|
10924
|
+
} catch (renameError) {
|
|
10925
|
+
(0, import_node_fs15.rmSync)(tmp, { force: true });
|
|
10926
|
+
throw renameError;
|
|
10927
|
+
}
|
|
10928
|
+
} catch (error) {
|
|
10929
|
+
return { available: true, ok: false, changed: false, version: clone.version, detail: `package NOT registered \u2014 ${error.message}` };
|
|
9322
10930
|
}
|
|
9323
|
-
|
|
9324
|
-
return {
|
|
10931
|
+
const beside = `package registered in settings.json (${merged.next.length - 1} other package(s) untouched)`;
|
|
10932
|
+
return {
|
|
10933
|
+
available: true,
|
|
10934
|
+
ok: true,
|
|
10935
|
+
changed: true,
|
|
10936
|
+
version: clone.version,
|
|
10937
|
+
detail: `${clone.version}: ${merged.superseded > 0 ? `${beside}, superseding ${merged.superseded} earlier mmi version(s)` : beside}${nextLaunch}`
|
|
10938
|
+
};
|
|
10939
|
+
} finally {
|
|
10940
|
+
release?.();
|
|
9325
10941
|
}
|
|
9326
|
-
const beside = `package registered in settings.json (${merged.next.length - 1} other package(s) untouched)`;
|
|
9327
|
-
return {
|
|
9328
|
-
available: true,
|
|
9329
|
-
ok: true,
|
|
9330
|
-
changed: true,
|
|
9331
|
-
version: clone.version,
|
|
9332
|
-
detail: `${clone.version}: ${merged.superseded > 0 ? `${beside}, superseding ${merged.superseded} earlier mmi version(s)` : beside}`
|
|
9333
|
-
};
|
|
9334
10942
|
}
|
|
9335
10943
|
function snapshotPluginGuardInput(surface = detectSurface(process.env), isOrgRepo = false) {
|
|
9336
10944
|
const root = surfaceConfigRoot(surface);
|
|
@@ -9354,6 +10962,9 @@ function snapshotPluginGuardInput(surface = detectSurface(process.env), isOrgRep
|
|
|
9354
10962
|
) : (0, import_node_fs15.existsSync)((0, import_node_path14.join)(root, "plugins", "cache", "mutmutco", "mmi"))
|
|
9355
10963
|
};
|
|
9356
10964
|
}
|
|
10965
|
+
async function runHostBinLogged(bin, args, opts) {
|
|
10966
|
+
return runHostBin(bin, args, opts);
|
|
10967
|
+
}
|
|
9357
10968
|
async function runPluginCli(bin, args, log) {
|
|
9358
10969
|
try {
|
|
9359
10970
|
await runHostBin(bin, args, { timeout: CLAUDE_PLUGIN_TIMEOUT_MS, step: `${bin} ${args.join(" ")}` });
|
|
@@ -13592,7 +15203,7 @@ async function executeWaveLand(plan, deps, opts = { preserveWorktree: true }) {
|
|
|
13592
15203
|
}
|
|
13593
15204
|
|
|
13594
15205
|
// src/index.ts
|
|
13595
|
-
var
|
|
15206
|
+
var import_node_os16 = require("node:os");
|
|
13596
15207
|
|
|
13597
15208
|
// src/board.ts
|
|
13598
15209
|
var import_node_child_process9 = require("node:child_process");
|
|
@@ -16180,6 +17791,12 @@ mutation($projectId: ID!, $itemId: ID!) {
|
|
|
16180
17791
|
deletedItemId
|
|
16181
17792
|
}
|
|
16182
17793
|
}`;
|
|
17794
|
+
var ARCHIVE_PROJECT_ITEM_MUTATION = `
|
|
17795
|
+
mutation($projectId: ID!, $itemId: ID!) {
|
|
17796
|
+
archiveProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {
|
|
17797
|
+
item { id }
|
|
17798
|
+
}
|
|
17799
|
+
}`;
|
|
16183
17800
|
async function updateItemSingleSelect(client, projectId, itemId, fieldId, optionId) {
|
|
16184
17801
|
await client.graphql(UPDATE_ITEM_FIELD_MUTATION, { projectId, itemId, fieldId, optionId });
|
|
16185
17802
|
}
|
|
@@ -16518,6 +18135,31 @@ async function removeRepoBoardItems(options, deps = {}) {
|
|
|
16518
18135
|
}
|
|
16519
18136
|
return { repo, board, dryRun: Boolean(options.dryRun), removed, failures };
|
|
16520
18137
|
}
|
|
18138
|
+
async function archiveClosedDoneBoardItems(options, deps = {}) {
|
|
18139
|
+
const cfg = resolveBoardConfig(options.config);
|
|
18140
|
+
const client = deps.client ?? defaultGitHubClient();
|
|
18141
|
+
const collected = await collectBoardItems(cfg, { repo: options.repo, activeOnly: false }, deps);
|
|
18142
|
+
const candidates = collected.items.filter((item) => item.status === "Done" && item.state === "CLOSED");
|
|
18143
|
+
const result = {
|
|
18144
|
+
board: { owner: cfg.projectOwner, number: cfg.projectNumber, id: collected.projectId },
|
|
18145
|
+
dryRun: !options.apply,
|
|
18146
|
+
scanned: collected.items.length,
|
|
18147
|
+
candidates: candidates.map(({ ref, url }) => ({ ref, url })),
|
|
18148
|
+
archived: [],
|
|
18149
|
+
failures: []
|
|
18150
|
+
};
|
|
18151
|
+
if (!options.apply) return result;
|
|
18152
|
+
for (const item of candidates) {
|
|
18153
|
+
try {
|
|
18154
|
+
await client.graphql(ARCHIVE_PROJECT_ITEM_MUTATION, { projectId: collected.projectId, itemId: item.itemId });
|
|
18155
|
+
result.archived.push({ ref: item.ref, url: item.url });
|
|
18156
|
+
} catch (e) {
|
|
18157
|
+
result.failures.push({ ref: item.ref, error: ghError(e) });
|
|
18158
|
+
break;
|
|
18159
|
+
}
|
|
18160
|
+
}
|
|
18161
|
+
return result;
|
|
18162
|
+
}
|
|
16521
18163
|
async function showBoardItem(options, deps = {}) {
|
|
16522
18164
|
const cfg = resolveBoardConfig(options.config);
|
|
16523
18165
|
const client = deps.client ?? defaultGitHubClient();
|
|
@@ -17907,6 +19549,7 @@ function consolidateCommandNamespaces(program3) {
|
|
|
17907
19549
|
move(program3, plugin, "guard");
|
|
17908
19550
|
move(program3, plugin, "plugin-heal", "heal");
|
|
17909
19551
|
move(program3, plugin, "plugin-prune", "prune");
|
|
19552
|
+
move(program3, plugin, "plugin-release-catchup", "release-catchup");
|
|
17910
19553
|
move(program3, plugin, "session-start");
|
|
17911
19554
|
const train = child(program3, "train");
|
|
17912
19555
|
const fullTrack2 = child(program3, "full-track");
|
|
@@ -17946,6 +19589,9 @@ function selectPrunablePluginVersions(names, currentVersion, installedVersion) {
|
|
|
17946
19589
|
function pluginCacheRootForConfig(configRoot) {
|
|
17947
19590
|
return `${configRoot}/plugins/cache/mutmutco/mmi`;
|
|
17948
19591
|
}
|
|
19592
|
+
function pluginCacheRoot(home) {
|
|
19593
|
+
return pluginCacheRootForConfig(`${home}/.claude`);
|
|
19594
|
+
}
|
|
17949
19595
|
function runningPluginVersion(env, cliVersion) {
|
|
17950
19596
|
const root = env.CLAUDE_PLUGIN_ROOT?.trim();
|
|
17951
19597
|
const leaf = root ? root.replace(/[\\/]+$/, "").split(/[\\/]/).pop() : void 0;
|
|
@@ -18167,12 +19813,29 @@ function renderPluginCachePlan(plan, applied) {
|
|
|
18167
19813
|
function isMmiPiPackage(entry) {
|
|
18168
19814
|
return /[\\/]mutmutco[\\/]mmi[\\/][^\\/]+[\\/]\.pi-plugin\/?$/.test(entry);
|
|
18169
19815
|
}
|
|
19816
|
+
function newestExistingPiPlugin(home) {
|
|
19817
|
+
const cacheRoot = pluginCacheRoot(home);
|
|
19818
|
+
let names;
|
|
19819
|
+
try {
|
|
19820
|
+
names = (0, import_node_fs22.readdirSync)(cacheRoot);
|
|
19821
|
+
} catch {
|
|
19822
|
+
return void 0;
|
|
19823
|
+
}
|
|
19824
|
+
for (const version of names.filter(isVersionDirName).sort((a, b) => compareVersions(b, a))) {
|
|
19825
|
+
const candidate = (0, import_node_path20.join)(cacheRoot, version, ".pi-plugin");
|
|
19826
|
+
if ((0, import_node_fs22.existsSync)(candidate)) return candidate;
|
|
19827
|
+
}
|
|
19828
|
+
return void 0;
|
|
19829
|
+
}
|
|
18170
19830
|
function expectedPiPluginPath(home, env, installedVersion) {
|
|
18171
19831
|
const root = env.CLAUDE_PLUGIN_ROOT?.trim();
|
|
18172
19832
|
if (root && /[\\/]mutmutco[\\/]mmi[\\/]/.test(root)) return (0, import_node_path20.join)(root, ".pi-plugin");
|
|
18173
19833
|
const version = installedVersion ?? runningPluginVersion(env);
|
|
18174
|
-
if (
|
|
18175
|
-
|
|
19834
|
+
if (version) {
|
|
19835
|
+
const pinned = (0, import_node_path20.join)(home, ".claude", "plugins", "cache", "mutmutco", "mmi", version, ".pi-plugin");
|
|
19836
|
+
if ((0, import_node_fs22.existsSync)(pinned)) return pinned;
|
|
19837
|
+
}
|
|
19838
|
+
return newestExistingPiPlugin(home);
|
|
18176
19839
|
}
|
|
18177
19840
|
function settingsPath(home) {
|
|
18178
19841
|
return (0, import_node_path20.join)(home, ".pi", "agent", "settings.json");
|
|
@@ -18180,7 +19843,7 @@ function settingsPath(home) {
|
|
|
18180
19843
|
function readPiPluginState(home, env, installedVersion) {
|
|
18181
19844
|
if (!(0, import_node_fs22.existsSync)((0, import_node_path20.join)(home, ".pi", "agent"))) return void 0;
|
|
18182
19845
|
const expectedPath = expectedPiPluginPath(home, env, installedVersion);
|
|
18183
|
-
if (!expectedPath
|
|
19846
|
+
if (!expectedPath) return void 0;
|
|
18184
19847
|
const file = settingsPath(home);
|
|
18185
19848
|
if (!(0, import_node_fs22.existsSync)(file)) return { expectedPath, settingsReadable: true };
|
|
18186
19849
|
try {
|
|
@@ -26313,6 +27976,21 @@ function registerBoardCommands(program3) {
|
|
|
26313
27976
|
return failGraceful(`board unclaim failed: ${e.message}`);
|
|
26314
27977
|
}
|
|
26315
27978
|
});
|
|
27979
|
+
board.command("archive-done").description("archive closed Done project cards; previews the exact refs by default, --apply writes").option("--json", "machine-readable output with every candidate/result ref").option("--repo <owner/repo>", "current repo (defaults to git origin)").option("--apply", "archive the previewed closed Done project cards").action(async (o) => {
|
|
27980
|
+
try {
|
|
27981
|
+
const result = await archiveClosedDoneBoardItems({
|
|
27982
|
+
config: await loadConfigForRepo(o.repo),
|
|
27983
|
+
repo: o.repo,
|
|
27984
|
+
apply: o.apply
|
|
27985
|
+
});
|
|
27986
|
+
if (result.archived.length) invalidateStatuslineBoardCache();
|
|
27987
|
+
if (o.json) return console.log(JSON.stringify(result));
|
|
27988
|
+
console.log(o.apply ? `board archive-done: archived ${result.archived.length}/${result.candidates.length}, failed ${result.failures.length}` : `board archive-done: would archive ${result.candidates.length} closed Done cards (scanned ${result.scanned}; pass --apply to write)`);
|
|
27989
|
+
if (result.failures.length) process.exitCode = 1;
|
|
27990
|
+
} catch (e) {
|
|
27991
|
+
return failGraceful(`board archive-done failed: ${e.message}`);
|
|
27992
|
+
}
|
|
27993
|
+
});
|
|
26316
27994
|
board.command("doctor").description("detect board invariant drift (transfer ghosts, closed-not-Done, assignee/status mismatch, stray priority:* labels, possibly-abandoned claims)").option("--json", "machine-readable output").option("--repo <owner/repo>", "current repo (defaults to git origin)").option("--fix", "apply automatic fixes to detected drift").option("--concurrency <n>", "parallel transfer-ghost checks (default 4)", "4").action(async (o) => {
|
|
26317
27995
|
try {
|
|
26318
27996
|
const result = await boardDoctor({
|
|
@@ -29847,6 +31525,125 @@ function registerSessionReport(program3) {
|
|
|
29847
31525
|
});
|
|
29848
31526
|
}
|
|
29849
31527
|
|
|
31528
|
+
// src/plugin-release-catchup.ts
|
|
31529
|
+
var import_node_fs39 = require("node:fs");
|
|
31530
|
+
var import_node_path37 = require("node:path");
|
|
31531
|
+
var import_node_os14 = require("node:os");
|
|
31532
|
+
var RELEASE_CATCHUP_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
31533
|
+
var RELEASE_CATCHUP_DISABLE_ENV = "MMI_NO_RELEASE_CATCHUP";
|
|
31534
|
+
function releaseCatchupStatePath(env = process.env) {
|
|
31535
|
+
if (env.MMI_RELEASE_CATCHUP_STATE) return env.MMI_RELEASE_CATCHUP_STATE;
|
|
31536
|
+
if (process.platform === "win32") {
|
|
31537
|
+
const base2 = env.LOCALAPPDATA || (0, import_node_path37.join)((0, import_node_os14.homedir)(), "AppData", "Local");
|
|
31538
|
+
return (0, import_node_path37.join)(base2, "MMI Future", "mmi-cli", "release-catchup.json");
|
|
31539
|
+
}
|
|
31540
|
+
const base = env.XDG_STATE_HOME || (0, import_node_path37.join)((0, import_node_os14.homedir)(), ".local", "state");
|
|
31541
|
+
return (0, import_node_path37.join)(base, "mmi-cli", "release-catchup.json");
|
|
31542
|
+
}
|
|
31543
|
+
function releaseCatchupDue(state, now, force = false) {
|
|
31544
|
+
if (force) return true;
|
|
31545
|
+
if (!state || typeof state.checkedAt !== "number") return true;
|
|
31546
|
+
return now - state.checkedAt >= RELEASE_CATCHUP_TTL_MS;
|
|
31547
|
+
}
|
|
31548
|
+
function newestCachedPluginVersion(home) {
|
|
31549
|
+
let names;
|
|
31550
|
+
try {
|
|
31551
|
+
names = (0, import_node_fs39.readdirSync)(pluginCacheRoot(home));
|
|
31552
|
+
} catch {
|
|
31553
|
+
return void 0;
|
|
31554
|
+
}
|
|
31555
|
+
return names.filter(isVersionDirName).sort((a, b) => compareVersions(b, a))[0];
|
|
31556
|
+
}
|
|
31557
|
+
function marketplaceClonePath(home) {
|
|
31558
|
+
try {
|
|
31559
|
+
const parsed = JSON.parse((0, import_node_fs39.readFileSync)((0, import_node_path37.join)(home, ".claude", "plugins", "known_marketplaces.json"), "utf8"));
|
|
31560
|
+
if (parsed.mutmutco?.installLocation) return parsed.mutmutco.installLocation;
|
|
31561
|
+
} catch {
|
|
31562
|
+
}
|
|
31563
|
+
return (0, import_node_path37.join)(home, ".claude", "plugins", "marketplaces", "mutmutco");
|
|
31564
|
+
}
|
|
31565
|
+
function readCatalogVersion(home) {
|
|
31566
|
+
try {
|
|
31567
|
+
const parsed = JSON.parse((0, import_node_fs39.readFileSync)((0, import_node_path37.join)(marketplaceClonePath(home), ".claude-plugin", "marketplace.json"), "utf8"));
|
|
31568
|
+
return parsed.plugins?.find((p) => p.name === "mmi")?.version;
|
|
31569
|
+
} catch {
|
|
31570
|
+
return void 0;
|
|
31571
|
+
}
|
|
31572
|
+
}
|
|
31573
|
+
function readMmiInstallRecord(home) {
|
|
31574
|
+
try {
|
|
31575
|
+
const parsed = JSON.parse((0, import_node_fs39.readFileSync)((0, import_node_path37.join)(home, ".claude", "plugins", "installed_plugins.json"), "utf8"));
|
|
31576
|
+
const record = parsed.plugins?.["mmi@mutmutco"]?.[0];
|
|
31577
|
+
return record?.version ? { version: record.version, gitCommitSha: record.gitCommitSha } : void 0;
|
|
31578
|
+
} catch {
|
|
31579
|
+
return void 0;
|
|
31580
|
+
}
|
|
31581
|
+
}
|
|
31582
|
+
async function runReleaseCatchup(home, env, deps, opts = {}) {
|
|
31583
|
+
if (env[RELEASE_CATCHUP_DISABLE_ENV]) return { ok: true, skipped: true, detail: `disabled via ${RELEASE_CATCHUP_DISABLE_ENV}` };
|
|
31584
|
+
if (!(0, import_node_fs39.existsSync)(pluginCacheRoot(home))) return { ok: true, skipped: true, detail: "no mmi plugin cache on this machine \u2014 nothing to catch up" };
|
|
31585
|
+
const statePath = releaseCatchupStatePath(env);
|
|
31586
|
+
const state = deps.readState(statePath);
|
|
31587
|
+
if (!releaseCatchupDue(state, deps.now(), opts.force)) {
|
|
31588
|
+
return { ok: true, skipped: true, detail: `checked within the last 24h${state?.latest ? ` (released ${state.latest})` : ""}` };
|
|
31589
|
+
}
|
|
31590
|
+
const latest = await deps.fetchReleased();
|
|
31591
|
+
if (!latest) return { ok: true, skipped: true, detail: "released version unreadable \u2014 will retry next session start" };
|
|
31592
|
+
const newest = newestCachedPluginVersion(home);
|
|
31593
|
+
if (newest && compareVersions(latest, newest) <= 0) {
|
|
31594
|
+
deps.writeState(statePath, { checkedAt: deps.now(), latest });
|
|
31595
|
+
return { ok: true, skipped: true, detail: `already current (cache ${newest}, released ${latest})` };
|
|
31596
|
+
}
|
|
31597
|
+
if (!await deps.runClaude(["plugin", "marketplace", "update", "mutmutco"], "claude plugin marketplace update mutmutco")) {
|
|
31598
|
+
return { ok: false, detail: `released ${latest} (cache ${newest ?? "none"}) but the marketplace refresh failed \u2014 nothing changed` };
|
|
31599
|
+
}
|
|
31600
|
+
const catalog = readCatalogVersion(home);
|
|
31601
|
+
if (catalog !== latest) {
|
|
31602
|
+
return { ok: true, skipped: true, detail: `released ${latest} but the refreshed catalog offers ${catalog ?? "nothing"} \u2014 will retry next session start` };
|
|
31603
|
+
}
|
|
31604
|
+
const prior = readMmiInstallRecord(home);
|
|
31605
|
+
if (prior && !await deps.runClaude(["plugin", "uninstall", "mmi@mutmutco"], "claude plugin uninstall mmi@mutmutco")) {
|
|
31606
|
+
return { ok: false, detail: `released ${latest} but the install record could not be cleared \u2014 nothing changed (record still ${prior.version})` };
|
|
31607
|
+
}
|
|
31608
|
+
const installed = await deps.runClaude(["plugin", "install", "mmi@mutmutco"], "claude plugin install mmi@mutmutco");
|
|
31609
|
+
const payload = (0, import_node_path37.join)(pluginCacheRoot(home), latest, ".pi-plugin");
|
|
31610
|
+
if (!installed || !(0, import_node_fs39.existsSync)(payload)) {
|
|
31611
|
+
const why = installed ? `install of ${latest} did not produce a verifiable .pi-plugin payload` : `install of ${latest} failed`;
|
|
31612
|
+
if (!prior) return { ok: false, detail: `${why}; no prior record to restore` };
|
|
31613
|
+
const rollback = await restorePriorRecord(home, prior, deps);
|
|
31614
|
+
return {
|
|
31615
|
+
ok: false,
|
|
31616
|
+
detail: rollback ? `${why}; prior record ${prior.version} restored and verified` : `${why}; ROLLBACK UNVERIFIED \u2014 prior record ${prior.version} could not be restored; run \`mmi-cli plugin heal\``
|
|
31617
|
+
};
|
|
31618
|
+
}
|
|
31619
|
+
const heal = deps.healRegistration();
|
|
31620
|
+
deps.writeState(statePath, { checkedAt: deps.now(), latest });
|
|
31621
|
+
return heal.ok ? { ok: true, detail: `caught up to ${latest}: ${heal.detail} \u2014 new skills load on the next seat launch` } : { ok: true, detail: `caught up to ${latest} (Pi registration: ${heal.detail})` };
|
|
31622
|
+
}
|
|
31623
|
+
async function restorePriorRecord(home, prior, deps) {
|
|
31624
|
+
const clone = marketplaceClonePath(home);
|
|
31625
|
+
try {
|
|
31626
|
+
if (prior.gitCommitSha) {
|
|
31627
|
+
if (!await deps.runGit(["-C", clone, "checkout", prior.gitCommitSha], `git -C ${clone} checkout ${prior.gitCommitSha}`)) return false;
|
|
31628
|
+
}
|
|
31629
|
+
if (!await deps.runClaude(["plugin", "install", "mmi@mutmutco"], "claude plugin install mmi@mutmutco (rollback)")) return false;
|
|
31630
|
+
const restored = readMmiInstallRecord(home);
|
|
31631
|
+
return restored?.version === prior.version;
|
|
31632
|
+
} finally {
|
|
31633
|
+
if (prior.gitCommitSha) await deps.runGit(["-C", clone, "checkout", "main"], `git -C ${clone} checkout main`);
|
|
31634
|
+
}
|
|
31635
|
+
}
|
|
31636
|
+
function shouldSpawnReleaseCatchup(home, env, readState2, now = Date.now()) {
|
|
31637
|
+
if (env[RELEASE_CATCHUP_DISABLE_ENV]) return false;
|
|
31638
|
+
if (!(0, import_node_fs39.existsSync)(pluginCacheRoot(home))) return false;
|
|
31639
|
+
return releaseCatchupDue(readState2(releaseCatchupStatePath(env)), now);
|
|
31640
|
+
}
|
|
31641
|
+
function defaultRegistrationHeal(home, env) {
|
|
31642
|
+
const healEnv = { ...env };
|
|
31643
|
+
delete healEnv.CLAUDE_PLUGIN_ROOT;
|
|
31644
|
+
return () => healPiPluginRegistration(home, healEnv);
|
|
31645
|
+
}
|
|
31646
|
+
|
|
29850
31647
|
// src/doctor-render.ts
|
|
29851
31648
|
var RESTART_LINE = "\u21BB Restart Claude to finish.";
|
|
29852
31649
|
var VERBOSE_INDENT = " ";
|
|
@@ -31884,17 +33681,17 @@ function parseOriginRepo(remoteUrl) {
|
|
|
31884
33681
|
}
|
|
31885
33682
|
function ghHostsConfigPath(env, platform2) {
|
|
31886
33683
|
const sep3 = platform2 === "win32" ? "\\" : "/";
|
|
31887
|
-
const
|
|
33684
|
+
const join35 = (...parts) => parts.join(sep3);
|
|
31888
33685
|
const explicit = env.GH_CONFIG_DIR?.trim();
|
|
31889
|
-
if (explicit) return
|
|
33686
|
+
if (explicit) return join35(explicit, "hosts.yml");
|
|
31890
33687
|
if (platform2 === "win32") {
|
|
31891
33688
|
const appData = (env.AppData ?? env.APPDATA)?.trim();
|
|
31892
|
-
return appData ?
|
|
33689
|
+
return appData ? join35(appData, "GitHub CLI", "hosts.yml") : void 0;
|
|
31893
33690
|
}
|
|
31894
33691
|
const xdg = env.XDG_CONFIG_HOME?.trim();
|
|
31895
|
-
if (xdg) return
|
|
33692
|
+
if (xdg) return join35(xdg, "gh", "hosts.yml");
|
|
31896
33693
|
const home = env.HOME?.trim();
|
|
31897
|
-
return home ?
|
|
33694
|
+
return home ? join35(home, ".config", "gh", "hosts.yml") : void 0;
|
|
31898
33695
|
}
|
|
31899
33696
|
function parseGhHostsAccounts(yaml, host = "github.com") {
|
|
31900
33697
|
let hostIndent = null;
|
|
@@ -31944,9 +33741,9 @@ function ghAccountCaveat(announcedLogin, accounts) {
|
|
|
31944
33741
|
}
|
|
31945
33742
|
|
|
31946
33743
|
// src/doctor-io.ts
|
|
31947
|
-
var
|
|
31948
|
-
var
|
|
31949
|
-
var
|
|
33744
|
+
var import_node_fs40 = require("node:fs");
|
|
33745
|
+
var import_node_os15 = require("node:os");
|
|
33746
|
+
var import_node_path38 = require("node:path");
|
|
31950
33747
|
var import_node_child_process18 = require("node:child_process");
|
|
31951
33748
|
var import_node_util8 = require("node:util");
|
|
31952
33749
|
var execFileP6 = (0, import_node_util8.promisify)(import_node_child_process18.execFile);
|
|
@@ -31954,7 +33751,7 @@ var MMI_PLUGIN_ID2 = "mmi@mutmutco";
|
|
|
31954
33751
|
function installedClaudePluginVersion() {
|
|
31955
33752
|
try {
|
|
31956
33753
|
const file = JSON.parse(
|
|
31957
|
-
(0,
|
|
33754
|
+
(0, import_node_fs40.readFileSync)((0, import_node_path38.join)((0, import_node_os15.homedir)(), ".claude", "plugins", "installed_plugins.json"), "utf8")
|
|
31958
33755
|
);
|
|
31959
33756
|
const versions = (file.plugins?.[MMI_PLUGIN_ID2] ?? []).map((r) => r.version).filter((v) => Boolean(v));
|
|
31960
33757
|
if (versions.length === 0) return void 0;
|
|
@@ -31965,7 +33762,7 @@ function installedClaudePluginVersion() {
|
|
|
31965
33762
|
}
|
|
31966
33763
|
function manifestVersion(path2) {
|
|
31967
33764
|
try {
|
|
31968
|
-
const manifest = JSON.parse((0,
|
|
33765
|
+
const manifest = JSON.parse((0, import_node_fs40.readFileSync)(path2, "utf8"));
|
|
31969
33766
|
return typeof manifest.version === "string" && manifest.version.trim() ? manifest.version.trim() : void 0;
|
|
31970
33767
|
} catch {
|
|
31971
33768
|
return void 0;
|
|
@@ -31975,22 +33772,22 @@ function installedSurfacePluginVersion(surface) {
|
|
|
31975
33772
|
const token = surfaceToken(surface);
|
|
31976
33773
|
if (token === "kilo") {
|
|
31977
33774
|
try {
|
|
31978
|
-
const stamp = (0,
|
|
33775
|
+
const stamp = (0, import_node_fs40.readFileSync)((0, import_node_path38.join)((0, import_node_os15.homedir)(), ".kilo", ".mmi-kilo-version"), "utf8").trim();
|
|
31979
33776
|
return stamp || void 0;
|
|
31980
33777
|
} catch {
|
|
31981
33778
|
return void 0;
|
|
31982
33779
|
}
|
|
31983
33780
|
}
|
|
31984
33781
|
if (token === "cursor") {
|
|
31985
|
-
return manifestVersion((0,
|
|
33782
|
+
return manifestVersion((0, import_node_path38.join)(cursorLocalPluginRoot(), ".cursor-plugin", "plugin.json"));
|
|
31986
33783
|
}
|
|
31987
33784
|
if (token === "jervcode") {
|
|
31988
33785
|
const entry = mmiPiWrapperEntry();
|
|
31989
33786
|
if (!entry) return void 0;
|
|
31990
|
-
return manifestVersion((0,
|
|
33787
|
+
return manifestVersion((0, import_node_path38.join)(decodeURIComponent(entry.replace(/^file:\/\/\/?/, "")), "package.json"));
|
|
31991
33788
|
}
|
|
31992
33789
|
if (token === "kimi") {
|
|
31993
|
-
return manifestVersion((0,
|
|
33790
|
+
return manifestVersion((0, import_node_path38.join)(surfaceConfigRoot(surface), "plugins", "managed", "mmi", ".kimi-plugin", "plugin.json"));
|
|
31994
33791
|
}
|
|
31995
33792
|
if (token === "claude") return installedClaudePluginVersion();
|
|
31996
33793
|
if (token !== "codex") return void 0;
|
|
@@ -32028,13 +33825,13 @@ function worktreeRootSync() {
|
|
|
32028
33825
|
}
|
|
32029
33826
|
var gitignorePath = () => {
|
|
32030
33827
|
const root = worktreeRootSync();
|
|
32031
|
-
return root === null ? null : (0,
|
|
33828
|
+
return root === null ? null : (0, import_node_path38.join)(root, ".gitignore");
|
|
32032
33829
|
};
|
|
32033
33830
|
function readGitignore() {
|
|
32034
33831
|
const path2 = gitignorePath();
|
|
32035
33832
|
if (path2 === null) return null;
|
|
32036
33833
|
try {
|
|
32037
|
-
return (0,
|
|
33834
|
+
return (0, import_node_fs40.readFileSync)(path2, "utf8");
|
|
32038
33835
|
} catch {
|
|
32039
33836
|
return null;
|
|
32040
33837
|
}
|
|
@@ -32043,7 +33840,7 @@ function writeGitignore(content) {
|
|
|
32043
33840
|
const path2 = gitignorePath();
|
|
32044
33841
|
if (path2 === null) return false;
|
|
32045
33842
|
try {
|
|
32046
|
-
(0,
|
|
33843
|
+
(0, import_node_fs40.writeFileSync)(path2, content, "utf8");
|
|
32047
33844
|
return true;
|
|
32048
33845
|
} catch {
|
|
32049
33846
|
return false;
|
|
@@ -32067,7 +33864,7 @@ async function repoRoot() {
|
|
|
32067
33864
|
}
|
|
32068
33865
|
function hasRepoLocalWorktrees() {
|
|
32069
33866
|
const root = worktreeRootSync();
|
|
32070
|
-
return root !== null && (0,
|
|
33867
|
+
return root !== null && (0, import_node_fs40.existsSync)((0, import_node_path38.join)(root, ".worktrees"));
|
|
32071
33868
|
}
|
|
32072
33869
|
|
|
32073
33870
|
// src/index.ts
|
|
@@ -32086,8 +33883,8 @@ ${r.stderr ?? ""}`).catch(() => "");
|
|
|
32086
33883
|
function ghMultiAccountCaveat(announcedLogin) {
|
|
32087
33884
|
try {
|
|
32088
33885
|
const hostsPath = ghHostsConfigPath(process.env, process.platform);
|
|
32089
|
-
if (!hostsPath || !(0,
|
|
32090
|
-
return ghAccountCaveat(announcedLogin, parseGhHostsAccounts((0,
|
|
33886
|
+
if (!hostsPath || !(0, import_node_fs41.existsSync)(hostsPath)) return void 0;
|
|
33887
|
+
return ghAccountCaveat(announcedLogin, parseGhHostsAccounts((0, import_node_fs41.readFileSync)(hostsPath, "utf8")));
|
|
32091
33888
|
} catch {
|
|
32092
33889
|
return void 0;
|
|
32093
33890
|
}
|
|
@@ -32095,12 +33892,12 @@ function ghMultiAccountCaveat(announcedLogin) {
|
|
|
32095
33892
|
var ENV_HEAL_LOCK_STALE_MS = 10 * 6e4;
|
|
32096
33893
|
var ENV_HEAL_LOCK_MAX_WAIT_MS = 2 * 6e4;
|
|
32097
33894
|
function envHealLockPath(home) {
|
|
32098
|
-
return (0,
|
|
33895
|
+
return (0, import_node_path39.join)(home, ".claude", "plugins", ".mmi-env-heal.lock");
|
|
32099
33896
|
}
|
|
32100
33897
|
async function withEnvHealLock(what, run) {
|
|
32101
33898
|
try {
|
|
32102
33899
|
return await withFileLock(
|
|
32103
|
-
envHealLockPath((0,
|
|
33900
|
+
envHealLockPath((0, import_node_os16.homedir)()),
|
|
32104
33901
|
{ staleMs: ENV_HEAL_LOCK_STALE_MS, maxWaitMs: ENV_HEAL_LOCK_MAX_WAIT_MS, label: "mmi env-heal lock" },
|
|
32105
33902
|
run
|
|
32106
33903
|
);
|
|
@@ -32197,7 +33994,7 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32197
33994
|
const configRoot = surfaceConfigRoot(surface);
|
|
32198
33995
|
const running = surface === "codex" ? installedActivePluginVersion(surface) : runningPluginVersion(process.env, resolveClientVersion());
|
|
32199
33996
|
const plan = buildPluginCachePlan(
|
|
32200
|
-
(0,
|
|
33997
|
+
(0, import_node_os16.homedir)(),
|
|
32201
33998
|
running,
|
|
32202
33999
|
pluginCacheFsDeps(configRoot, () => 0),
|
|
32203
34000
|
{ configRoot, includeStaging: surface !== "codex" }
|
|
@@ -32221,14 +34018,14 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32221
34018
|
const running = surface === "codex" ? installedActivePluginVersion(surface) : runningPluginVersion(process.env, resolveClientVersion());
|
|
32222
34019
|
const installed = installedActivePluginVersion(surface);
|
|
32223
34020
|
const plan = buildPluginCachePlan(
|
|
32224
|
-
(0,
|
|
34021
|
+
(0, import_node_os16.homedir)(),
|
|
32225
34022
|
running,
|
|
32226
34023
|
pluginCacheFsDeps(configRoot, () => 0),
|
|
32227
34024
|
{ configRoot, includeStaging: surface !== "codex", installedVersion: installed }
|
|
32228
34025
|
);
|
|
32229
34026
|
const result = applyPluginCachePlan(
|
|
32230
34027
|
plan,
|
|
32231
|
-
(p) => (0,
|
|
34028
|
+
(p) => (0, import_node_fs41.rmSync)(p, { recursive: true }),
|
|
32232
34029
|
stagingApplyFsGuard(configRoot)
|
|
32233
34030
|
);
|
|
32234
34031
|
return {
|
|
@@ -32247,8 +34044,22 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32247
34044
|
};
|
|
32248
34045
|
},
|
|
32249
34046
|
// #4201: mmi `.pi-plugin` registration in ~/.pi/agent/settings.json — mirror of jerv-cli's own heal.
|
|
32250
|
-
|
|
32251
|
-
|
|
34047
|
+
// #4305: BOTH the state read and the heal strip CLAUDE_PLUGIN_ROOT — inside a Claude session it names
|
|
34048
|
+
// the RUNNING clone, and since #4302 the registration legitimately LEADS the running clone (a catch-up
|
|
34049
|
+
// re-points it at the newest release; the restart-pending truth is the JervCode plugin guard row's).
|
|
34050
|
+
// Unstripped, the state row calls the post-catch-up registration "stale", the intent line names the old
|
|
34051
|
+
// clone while the heal writes the new one, and the heal itself reverts the catch-up. The expected path
|
|
34052
|
+
// for registration purposes is always the newest existing clone, never the running one.
|
|
34053
|
+
piPluginState: () => {
|
|
34054
|
+
const env = { ...process.env };
|
|
34055
|
+
delete env.CLAUDE_PLUGIN_ROOT;
|
|
34056
|
+
return readPiPluginState((0, import_node_os16.homedir)(), env);
|
|
34057
|
+
},
|
|
34058
|
+
healPiPlugin: () => {
|
|
34059
|
+
const env = { ...process.env };
|
|
34060
|
+
delete env.CLAUDE_PLUGIN_ROOT;
|
|
34061
|
+
return healPiPluginRegistration((0, import_node_os16.homedir)(), env);
|
|
34062
|
+
},
|
|
32252
34063
|
// #3470: what the SessionStart hook LAST emitted, measured at emission by the session-start verb below.
|
|
32253
34064
|
// A local record read ? cheap enough for every lane, including the banner.
|
|
32254
34065
|
sessionPayload: () => readSessionPayload(process.cwd()),
|
|
@@ -32257,17 +34068,17 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32257
34068
|
marketplaceRows: () => {
|
|
32258
34069
|
try {
|
|
32259
34070
|
if (detectSurface(process.env) === "codex") return [];
|
|
32260
|
-
const home = (0,
|
|
34071
|
+
const home = (0, import_node_os16.homedir)();
|
|
32261
34072
|
const rows = marketplaceRows(
|
|
32262
34073
|
MMI_MARKETPLACE_NAME,
|
|
32263
|
-
readFileSyncSafe((0,
|
|
32264
|
-
readFileSyncSafe((0,
|
|
34074
|
+
readFileSyncSafe((0, import_node_path39.join)(home, ...KNOWN_MARKETPLACES_RELATIVE), import_node_fs41.readFileSync),
|
|
34075
|
+
readFileSyncSafe((0, import_node_path39.join)(home, ".claude", "settings.json"), import_node_fs41.readFileSync),
|
|
32265
34076
|
// #3974: this CLI heals these rows, so report mode names the doctor run rather than the hand
|
|
32266
34077
|
// edit. Unconditional ? it is a fact about mmi-cli, not about the lane this run is on.
|
|
32267
34078
|
true
|
|
32268
34079
|
);
|
|
32269
34080
|
const pending = readMarketplacePinPending(
|
|
32270
|
-
(0,
|
|
34081
|
+
(0, import_node_path39.join)(home, ".claude", "plugins", ".mmi-marketplace-pin-pending.json"),
|
|
32271
34082
|
MMI_MARKETPLACE_NAME
|
|
32272
34083
|
);
|
|
32273
34084
|
if (!pending) return rows;
|
|
@@ -32291,11 +34102,11 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32291
34102
|
healMarketplacePins: () => {
|
|
32292
34103
|
try {
|
|
32293
34104
|
if (detectSurface(process.env) === "codex") return void 0;
|
|
32294
|
-
const home = (0,
|
|
34105
|
+
const home = (0, import_node_os16.homedir)();
|
|
32295
34106
|
const names = [MMI_MARKETPLACE_NAME];
|
|
32296
|
-
const result = applyOrgMarketplacePins((0,
|
|
34107
|
+
const result = applyOrgMarketplacePins((0, import_node_path39.join)(home, ...KNOWN_MARKETPLACES_RELATIVE), names);
|
|
32297
34108
|
if (result?.wrote) {
|
|
32298
|
-
writeMarketplacePinPending((0,
|
|
34109
|
+
writeMarketplacePinPending((0, import_node_path39.join)(home, ".claude", "plugins", ".mmi-marketplace-pin-pending.json"), names);
|
|
32299
34110
|
}
|
|
32300
34111
|
return result;
|
|
32301
34112
|
} catch {
|
|
@@ -32311,7 +34122,7 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32311
34122
|
// adopted the generated routing index (MMG-Unlive: `docs/Archive/**` only, no index, no gate.yml) would
|
|
32312
34123
|
// get a permanent ? demanding an artifact it never asked for.
|
|
32313
34124
|
docsIndexState: (root) => {
|
|
32314
|
-
if (!(0,
|
|
34125
|
+
if (!(0, import_node_fs41.existsSync)((0, import_node_path39.join)(root, DOCS_INDEX_PATH))) return void 0;
|
|
32315
34126
|
const real = createDocsIndexDeps(root);
|
|
32316
34127
|
let docs2;
|
|
32317
34128
|
const listDocs = () => docs2 ??= real.listDocs();
|
|
@@ -32320,7 +34131,7 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32320
34131
|
},
|
|
32321
34132
|
// #4168: working-tree heal — write if drifted, then re-check. Commit remains the operator's step.
|
|
32322
34133
|
healDocsIndex: (root) => {
|
|
32323
|
-
if (!(0,
|
|
34134
|
+
if (!(0, import_node_fs41.existsSync)((0, import_node_path39.join)(root, DOCS_INDEX_PATH))) return { drift: false, docCount: 0 };
|
|
32324
34135
|
const real = createDocsIndexDeps(root);
|
|
32325
34136
|
let docs2;
|
|
32326
34137
|
const listDocs = () => docs2 ??= real.listDocs();
|
|
@@ -32655,19 +34466,19 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
32655
34466
|
});
|
|
32656
34467
|
var rules = program2.command("rules").description("org-managed .gitignore delivery");
|
|
32657
34468
|
rules.command("gitignore").option("--write", "upsert the managed block into .gitignore (default: check only, non-zero exit on drift)").option("--json", "machine-readable output").description("verify (or --write) this repo's org-managed .gitignore block matches the SSOT").action((opts) => {
|
|
32658
|
-
const path2 = (0,
|
|
32659
|
-
const current = (0,
|
|
34469
|
+
const path2 = (0, import_node_path39.join)(process.cwd(), ".gitignore");
|
|
34470
|
+
const current = (0, import_node_fs41.existsSync)(path2) ? (0, import_node_fs41.readFileSync)(path2, "utf8") : null;
|
|
32660
34471
|
const plan = planManagedGitignore(current);
|
|
32661
34472
|
const drift = [...plan.added.map((l) => `+${l}`), ...plan.removed.map((l) => `-${l}`)].join(", ") || "block normalize";
|
|
32662
34473
|
if (opts.json) {
|
|
32663
|
-
if (opts.write && plan.changed) (0,
|
|
34474
|
+
if (opts.write && plan.changed) (0, import_node_fs41.writeFileSync)(path2, plan.content, "utf8");
|
|
32664
34475
|
console.log(JSON.stringify(plan, null, 2));
|
|
32665
34476
|
if (!opts.write && plan.changed) process.exitCode = 1;
|
|
32666
34477
|
return;
|
|
32667
34478
|
}
|
|
32668
34479
|
if (opts.write) {
|
|
32669
34480
|
if (plan.changed) {
|
|
32670
|
-
(0,
|
|
34481
|
+
(0, import_node_fs41.writeFileSync)(path2, plan.content, "utf8");
|
|
32671
34482
|
console.log(`mmi-cli org rules gitignore: updated .gitignore (${drift})`);
|
|
32672
34483
|
} else {
|
|
32673
34484
|
console.log("mmi-cli org rules gitignore: up to date");
|
|
@@ -32825,8 +34636,8 @@ gcCmd.option("--dry-run", "show what would be deleted (default)").option("--appl
|
|
|
32825
34636
|
if (!Number.isFinite(limit) || limit < 1) return fail("worktree gc: --limit must be a positive integer");
|
|
32826
34637
|
let root;
|
|
32827
34638
|
if (o.root !== void 0) {
|
|
32828
|
-
root = (0,
|
|
32829
|
-
if (!(0,
|
|
34639
|
+
root = (0, import_node_path39.resolve)(o.root);
|
|
34640
|
+
if (!(0, import_node_fs41.existsSync)(root) || !(0, import_node_fs41.statSync)(root).isDirectory()) return fail(`worktree gc: --root ${o.root} is not a directory`);
|
|
32830
34641
|
const gcRepoRoot = (await execFileP2("git", ["rev-parse", "--show-toplevel"], { timeout: GIT_TIMEOUT_MS }).catch(() => ({ stdout: "" }))).stdout.trim() || process.cwd();
|
|
32831
34642
|
if (isPathUnderDirectory(gcRepoRoot, root)) {
|
|
32832
34643
|
return fail(`worktree gc: --root ${root} contains this checkout ? name a worktrees root, not the repo or an ancestor of it`);
|
|
@@ -32906,7 +34717,7 @@ async function currentWorktreeRemovalContext(command, force) {
|
|
|
32906
34717
|
};
|
|
32907
34718
|
}
|
|
32908
34719
|
async function unprovenWorktreeReason(wtPath, repoRoot2) {
|
|
32909
|
-
if (!(0,
|
|
34720
|
+
if (!(0, import_node_fs41.existsSync)(wtPath)) return `${wtPath} does not exist on disk`;
|
|
32910
34721
|
const porcelain = (await execFileP2("git", ["-C", repoRoot2, "worktree", "list", "--porcelain"], { timeout: GIT_TIMEOUT_MS }).catch(() => ({ stdout: "" }))).stdout;
|
|
32911
34722
|
const registered = parseWorktreePorcelainEntries(porcelain);
|
|
32912
34723
|
if (!registered.length) {
|
|
@@ -32928,26 +34739,26 @@ function makeProvisionDeps(worktreeRoot, quiet, log) {
|
|
|
32928
34739
|
function acquireWorktreeSetupLock(worktreeRoot) {
|
|
32929
34740
|
const lockPath = repoRuntimeStatePath(worktreeRoot, "worktree-setup.lock");
|
|
32930
34741
|
const take = () => {
|
|
32931
|
-
const fd = (0,
|
|
34742
|
+
const fd = (0, import_node_fs41.openSync)(lockPath, "wx");
|
|
32932
34743
|
try {
|
|
32933
|
-
(0,
|
|
34744
|
+
(0, import_node_fs41.writeSync)(fd, String(Date.now()));
|
|
32934
34745
|
} finally {
|
|
32935
|
-
(0,
|
|
34746
|
+
(0, import_node_fs41.closeSync)(fd);
|
|
32936
34747
|
}
|
|
32937
34748
|
return () => {
|
|
32938
34749
|
try {
|
|
32939
|
-
(0,
|
|
34750
|
+
(0, import_node_fs41.rmSync)(lockPath, { force: true });
|
|
32940
34751
|
} catch {
|
|
32941
34752
|
}
|
|
32942
34753
|
};
|
|
32943
34754
|
};
|
|
32944
34755
|
try {
|
|
32945
|
-
(0,
|
|
34756
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path39.dirname)(lockPath), { recursive: true });
|
|
32946
34757
|
return take();
|
|
32947
34758
|
} catch {
|
|
32948
34759
|
try {
|
|
32949
|
-
if (Date.now() - (0,
|
|
32950
|
-
(0,
|
|
34760
|
+
if (Date.now() - (0, import_node_fs41.statSync)(lockPath).mtimeMs > WORKTREE_SETUP_LOCK_TTL_MS) {
|
|
34761
|
+
(0, import_node_fs41.rmSync)(lockPath, { force: true });
|
|
32951
34762
|
return take();
|
|
32952
34763
|
}
|
|
32953
34764
|
} catch {
|
|
@@ -33795,7 +35606,7 @@ project.command("set [owner/repo]").description("upsert project META (idempotent
|
|
|
33795
35606
|
if (dupe) return fail(`org project set: KEY "${dupe}" was passed to both --var and --set; --set is an alias of --var, so pass each KEY once`);
|
|
33796
35607
|
if (o.secretsFile) {
|
|
33797
35608
|
try {
|
|
33798
|
-
vars.push(`secrets=${(0,
|
|
35609
|
+
vars.push(`secrets=${(0, import_node_fs41.readFileSync)(o.secretsFile, "utf8")}`);
|
|
33799
35610
|
} catch (e) {
|
|
33800
35611
|
return fail(`org project set: cannot read --secrets-file ${o.secretsFile}: ${e.message}`);
|
|
33801
35612
|
}
|
|
@@ -34549,11 +36360,11 @@ pr.command("view <number>").description("read a PR as structured JSON (merged st
|
|
|
34549
36360
|
}
|
|
34550
36361
|
});
|
|
34551
36362
|
async function listCiWorkflowPaths(cwd = process.cwd()) {
|
|
34552
|
-
const wfDir = (0,
|
|
34553
|
-
if (!(0,
|
|
34554
|
-
return (0,
|
|
36363
|
+
const wfDir = (0, import_node_path39.join)(cwd, ".github", "workflows");
|
|
36364
|
+
if (!(0, import_node_fs41.existsSync)(wfDir)) return [];
|
|
36365
|
+
return (0, import_node_fs41.readdirSync)(wfDir).filter((name) => /\.(ya?ml)$/i.test(name)).filter((name) => {
|
|
34555
36366
|
try {
|
|
34556
|
-
return workflowReportsPrChecks((0,
|
|
36367
|
+
return workflowReportsPrChecks((0, import_node_fs41.readFileSync)((0, import_node_path39.join)(wfDir, name), "utf8"));
|
|
34557
36368
|
} catch {
|
|
34558
36369
|
return true;
|
|
34559
36370
|
}
|
|
@@ -34585,16 +36396,16 @@ function ciAuditDeps() {
|
|
|
34585
36396
|
// gate re-seed step is skipped gracefully rather than failing mid-run.
|
|
34586
36397
|
readSeedFile: (path2) => {
|
|
34587
36398
|
if (!root) return null;
|
|
34588
|
-
const fullPath = (0,
|
|
34589
|
-
return (0,
|
|
36399
|
+
const fullPath = (0, import_node_path39.join)(root, path2);
|
|
36400
|
+
return (0, import_node_fs41.existsSync)(fullPath) ? (0, import_node_fs41.readFileSync)(fullPath, "utf8") : null;
|
|
34590
36401
|
}
|
|
34591
36402
|
};
|
|
34592
36403
|
}
|
|
34593
36404
|
function hubRoot() {
|
|
34594
|
-
const fromPkg = (0,
|
|
36405
|
+
const fromPkg = (0, import_node_path39.join)(__dirname, "..", "..");
|
|
34595
36406
|
const marker = "skills/bootstrap/seeds/manifest.json";
|
|
34596
|
-
if ((0,
|
|
34597
|
-
if ((0,
|
|
36407
|
+
if ((0, import_node_fs41.existsSync)((0, import_node_path39.join)(fromPkg, marker))) return fromPkg;
|
|
36408
|
+
if ((0, import_node_fs41.existsSync)((0, import_node_path39.join)(process.cwd(), marker))) return process.cwd();
|
|
34598
36409
|
return null;
|
|
34599
36410
|
}
|
|
34600
36411
|
pr.command("ci-policy").description("report merge CI policy: wait-for-checks vs no-ci (for grind/build agents)").option("--json", "machine-readable output").option("--repo <owner/repo>", "target repo (defaults to the current checkout)").action(async (o) => {
|
|
@@ -34906,7 +36717,7 @@ jsonParity(pr.command("merge <number>").description("merge a PR (squash by defau
|
|
|
34906
36717
|
localCleanup = await cleanupPrMergeLocalBranch(headRef, {
|
|
34907
36718
|
beforeWorktrees,
|
|
34908
36719
|
startingPath,
|
|
34909
|
-
pathExists: (p) => (0,
|
|
36720
|
+
pathExists: (p) => (0, import_node_fs41.existsSync)(p),
|
|
34910
36721
|
execGit: async (args) => (await execFileP2("git", args, { timeout: GIT_TIMEOUT_MS })).stdout,
|
|
34911
36722
|
teardownWorktreeStage,
|
|
34912
36723
|
deferredStore,
|
|
@@ -35402,12 +37213,12 @@ access.command("audit").description("audit collaborator roles + train-branch pus
|
|
|
35402
37213
|
targets = resolution.targets;
|
|
35403
37214
|
}
|
|
35404
37215
|
const derivedMatrix = registryProjects ? accessMatrixFromProjects(registryProjects) : {};
|
|
35405
|
-
const fileMatrix = (0,
|
|
37216
|
+
const fileMatrix = (0, import_node_fs41.existsSync)("access-matrix.json") ? loadAccessMatrix((0, import_node_fs41.readFileSync)("access-matrix.json", "utf8")) : {};
|
|
35406
37217
|
const matrix = mergeAccessMatrix(fileMatrix, derivedMatrix);
|
|
35407
37218
|
const derivedContracts = registryProjects ? dataAccessContractsFromProjects(registryProjects) : { consumers: {} };
|
|
35408
|
-
const fileContracts = (0,
|
|
37219
|
+
const fileContracts = (0, import_node_fs41.existsSync)("data-access-contracts.json") ? loadDataAccessContracts((0, import_node_fs41.readFileSync)("data-access-contracts.json", "utf8")) : { consumers: {} };
|
|
35409
37220
|
const dataAccess = mergeDataAccessContracts(fileContracts, derivedContracts);
|
|
35410
|
-
const sanctioned = (0,
|
|
37221
|
+
const sanctioned = (0, import_node_fs41.existsSync)("access-matrix.json") ? loadSanctionedAdmins((0, import_node_fs41.readFileSync)("access-matrix.json", "utf8")) : {};
|
|
35411
37222
|
const report = await auditOrgAccess(targets, deps, matrix, dataAccess, sanctioned);
|
|
35412
37223
|
console.log(o.json ? JSON.stringify(report, null, 2) : renderAccessReport(report));
|
|
35413
37224
|
if (!report.ok) process.exitCode = 1;
|
|
@@ -35439,16 +37250,16 @@ function directoryBytes(path2) {
|
|
|
35439
37250
|
let total = 0;
|
|
35440
37251
|
let entries;
|
|
35441
37252
|
try {
|
|
35442
|
-
entries = (0,
|
|
37253
|
+
entries = (0, import_node_fs41.readdirSync)(path2, { withFileTypes: true });
|
|
35443
37254
|
} catch {
|
|
35444
37255
|
return 0;
|
|
35445
37256
|
}
|
|
35446
37257
|
for (const entry of entries) {
|
|
35447
|
-
const child2 = (0,
|
|
37258
|
+
const child2 = (0, import_node_path39.join)(path2, entry.name);
|
|
35448
37259
|
if (entry.isDirectory()) total += directoryBytes(child2);
|
|
35449
37260
|
else {
|
|
35450
37261
|
try {
|
|
35451
|
-
total += (0,
|
|
37262
|
+
total += (0, import_node_fs41.statSync)(child2).size;
|
|
35452
37263
|
} catch {
|
|
35453
37264
|
}
|
|
35454
37265
|
}
|
|
@@ -35456,25 +37267,25 @@ function directoryBytes(path2) {
|
|
|
35456
37267
|
return total;
|
|
35457
37268
|
}
|
|
35458
37269
|
function listDirEntries(dir) {
|
|
35459
|
-
return (0,
|
|
37270
|
+
return (0, import_node_fs41.readdirSync)(dir, { withFileTypes: true }).map((d) => ({ name: d.name, isDirectory: d.isDirectory() }));
|
|
35460
37271
|
}
|
|
35461
37272
|
function readInstalledPluginRefs(configRoot) {
|
|
35462
37273
|
const p = installedPluginsPathForConfig(configRoot);
|
|
35463
|
-
if (!(0,
|
|
37274
|
+
if (!(0, import_node_fs41.existsSync)(p)) return [];
|
|
35464
37275
|
try {
|
|
35465
|
-
return installedPluginPaths((0,
|
|
37276
|
+
return installedPluginPaths((0, import_node_fs41.readFileSync)(p, "utf8"));
|
|
35466
37277
|
} catch {
|
|
35467
37278
|
return null;
|
|
35468
37279
|
}
|
|
35469
37280
|
}
|
|
35470
37281
|
function pluginCacheFsDeps(configRoot, dirBytes) {
|
|
35471
37282
|
return {
|
|
35472
|
-
exists: (p) => (0,
|
|
35473
|
-
listVersionDirs: (root) => (0,
|
|
37283
|
+
exists: (p) => (0, import_node_fs41.existsSync)(p),
|
|
37284
|
+
listVersionDirs: (root) => (0, import_node_fs41.readdirSync)(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name),
|
|
35474
37285
|
dirBytes,
|
|
35475
|
-
listStagingDirs: (root) => (0,
|
|
37286
|
+
listStagingDirs: (root) => (0, import_node_fs41.readdirSync)(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => {
|
|
35476
37287
|
try {
|
|
35477
|
-
return { name: d.name, mtimeMs: newestMtimeMs((0,
|
|
37288
|
+
return { name: d.name, mtimeMs: newestMtimeMs((0, import_node_path39.join)(root, d.name), listDirEntries, (p) => (0, import_node_fs41.statSync)(p).mtimeMs) };
|
|
35478
37289
|
} catch {
|
|
35479
37290
|
return { name: d.name, mtimeMs: Date.now() };
|
|
35480
37291
|
}
|
|
@@ -35488,10 +37299,10 @@ function stagingApplyFsGuard(configRoot) {
|
|
|
35488
37299
|
return {
|
|
35489
37300
|
referencedPaths: () => readInstalledPluginRefs(configRoot),
|
|
35490
37301
|
mtimeMs: (name) => {
|
|
35491
|
-
const p = (0,
|
|
35492
|
-
if (!(0,
|
|
37302
|
+
const p = (0, import_node_path39.join)(stagingRoot, name);
|
|
37303
|
+
if (!(0, import_node_fs41.existsSync)(p)) return null;
|
|
35493
37304
|
try {
|
|
35494
|
-
return newestMtimeMs(p, listDirEntries, (q) => (0,
|
|
37305
|
+
return newestMtimeMs(p, listDirEntries, (q) => (0, import_node_fs41.statSync)(q).mtimeMs);
|
|
35495
37306
|
} catch {
|
|
35496
37307
|
return null;
|
|
35497
37308
|
}
|
|
@@ -35511,18 +37322,61 @@ program2.command("plugin-prune").description(`prune stale cached MMI plugin vers
|
|
|
35511
37322
|
return;
|
|
35512
37323
|
}
|
|
35513
37324
|
const plan = buildPluginCachePlan(
|
|
35514
|
-
(0,
|
|
37325
|
+
(0, import_node_os16.homedir)(),
|
|
35515
37326
|
running,
|
|
35516
37327
|
pluginCacheFsDeps(configRoot, directoryBytes),
|
|
35517
37328
|
{ withBytes: true, configRoot, includeStaging: surface !== "codex" }
|
|
35518
37329
|
);
|
|
35519
37330
|
const anythingToDelete = plan.prune.length > 0 || plan.staging.length > 0;
|
|
35520
|
-
const result = o.apply && anythingToDelete ? applyPluginCachePlan(plan, (p) => (0,
|
|
37331
|
+
const result = o.apply && anythingToDelete ? applyPluginCachePlan(plan, (p) => (0, import_node_fs41.rmSync)(p, { recursive: true, force: true }), stagingApplyFsGuard(configRoot)) : void 0;
|
|
35521
37332
|
const warnings = plan.prune.length > 0 ? [CONCURRENT_SESSION_WARNING] : [];
|
|
35522
37333
|
if (o.json) console.log(JSON.stringify({ ...plan, warnings, applied: result ?? null }));
|
|
35523
37334
|
else console.log(renderPluginCachePlan(plan, result));
|
|
35524
37335
|
if (result?.failed.length || result?.failedStaging.length) process.exitCode = 1;
|
|
35525
37336
|
});
|
|
37337
|
+
function readReleaseCatchupState(path2) {
|
|
37338
|
+
try {
|
|
37339
|
+
const parsed = JSON.parse((0, import_node_fs41.readFileSync)(path2, "utf8"));
|
|
37340
|
+
return typeof parsed?.checkedAt === "number" ? parsed : void 0;
|
|
37341
|
+
} catch {
|
|
37342
|
+
return void 0;
|
|
37343
|
+
}
|
|
37344
|
+
}
|
|
37345
|
+
function writeReleaseCatchupState(path2, state) {
|
|
37346
|
+
try {
|
|
37347
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path39.dirname)(path2), { recursive: true });
|
|
37348
|
+
(0, import_node_fs41.writeFileSync)(path2, `${JSON.stringify(state)}
|
|
37349
|
+
`);
|
|
37350
|
+
} catch {
|
|
37351
|
+
}
|
|
37352
|
+
}
|
|
37353
|
+
program2.command("plugin-release-catchup").description("install a newer released MMI plugin clone non-destructively and re-point the Pi registration (#4297); TTL-gated no-op when current").option("--force", "skip the 24h TTL (acceptance proof / manual run)").option("--quiet", "print only failures (the detached session-start lane)").option("--json", "machine-readable output").action(async (o) => {
|
|
37354
|
+
const outcome = await withEnvHealLock(
|
|
37355
|
+
"plugin release catch-up",
|
|
37356
|
+
() => runReleaseCatchup((0, import_node_os16.homedir)(), process.env, {
|
|
37357
|
+
fetchReleased: fetchNpmReleasedVersion,
|
|
37358
|
+
runClaude: (args, step) => runPluginCli("claude", args, (msg) => {
|
|
37359
|
+
if (!o.quiet && !o.json) console.log(msg);
|
|
37360
|
+
void step;
|
|
37361
|
+
}),
|
|
37362
|
+
runGit: async (args, step) => {
|
|
37363
|
+
try {
|
|
37364
|
+
await runHostBinLogged("git", args, { timeout: 6e4, step });
|
|
37365
|
+
return true;
|
|
37366
|
+
} catch {
|
|
37367
|
+
return false;
|
|
37368
|
+
}
|
|
37369
|
+
},
|
|
37370
|
+
readState: readReleaseCatchupState,
|
|
37371
|
+
writeState: writeReleaseCatchupState,
|
|
37372
|
+
healRegistration: defaultRegistrationHeal((0, import_node_os16.homedir)(), process.env),
|
|
37373
|
+
now: () => Date.now()
|
|
37374
|
+
}, { force: o.force })
|
|
37375
|
+
);
|
|
37376
|
+
if (o.json) console.log(JSON.stringify(outcome));
|
|
37377
|
+
else if (!o.quiet || !outcome.ok) console.log(`${outcome.ok ? "\u2713" : "\u2717"} plugin release catch-up \u2014 ${outcome.detail}`);
|
|
37378
|
+
if (!outcome.ok && !outcome.skipped) process.exitCode = 1;
|
|
37379
|
+
});
|
|
35526
37380
|
program2.command("session-start").description("run the SessionStart verbs (whoami, board slice, doctor) in one process").action(async () => {
|
|
35527
37381
|
if (isInsideRepoSubdir(process.cwd())) {
|
|
35528
37382
|
console.error("[mmi-hook] plugin session-start: cwd is a repository SUBDIRECTORY ? skipping the SessionStart hook (spine/docs/plan/saga delivery); run it from the repo root.");
|
|
@@ -35583,6 +37437,9 @@ program2.command("session-start").description("run the SessionStart verbs (whoam
|
|
|
35583
37437
|
spawnDetachedSelf(["worktree", "setup", "--quiet"], { spawn: import_node_child_process19.spawn, execPath: process.execPath, scriptPath: process.argv[1] });
|
|
35584
37438
|
bannerIo.log(worktreeBanner);
|
|
35585
37439
|
}
|
|
37440
|
+
if (shouldSpawnReleaseCatchup((0, import_node_os16.homedir)(), process.env, readReleaseCatchupState)) {
|
|
37441
|
+
spawnDetachedSelf(["plugin", "release-catchup", "--quiet"], { spawn: import_node_child_process19.spawn, execPath: process.execPath, scriptPath: process.argv[1] });
|
|
37442
|
+
}
|
|
35586
37443
|
if (isLinkedWorktree(process.cwd())) {
|
|
35587
37444
|
const primaryRoot = await primaryCheckoutRoot(process.cwd());
|
|
35588
37445
|
if (primaryRoot) touchWorktreeOwner(primaryRoot, process.cwd());
|