@mutmutco/cli 3.103.0 → 3.105.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 +1967 -123
- 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(" ")}` });
|
|
@@ -10782,6 +12393,9 @@ async function preflight(deps, ctx, stage, meta) {
|
|
|
10782
12393
|
}
|
|
10783
12394
|
await deps.runSelf(["secrets", "preflight", "--stage", stage, "--repo", ctx.repo]);
|
|
10784
12395
|
enforceGateBudget(deps, ctx.repo);
|
|
12396
|
+
if (model === "hub-serverless") {
|
|
12397
|
+
await deps.run("node", ["scripts/release-distribution.mjs", "verify-deps"]);
|
|
12398
|
+
}
|
|
10785
12399
|
return model;
|
|
10786
12400
|
}
|
|
10787
12401
|
async function preflightMergeToMain(deps, deployModel, remoteRef, blockingPrefix, realignMessage) {
|
|
@@ -13592,7 +15206,7 @@ async function executeWaveLand(plan, deps, opts = { preserveWorktree: true }) {
|
|
|
13592
15206
|
}
|
|
13593
15207
|
|
|
13594
15208
|
// src/index.ts
|
|
13595
|
-
var
|
|
15209
|
+
var import_node_os16 = require("node:os");
|
|
13596
15210
|
|
|
13597
15211
|
// src/board.ts
|
|
13598
15212
|
var import_node_child_process9 = require("node:child_process");
|
|
@@ -16180,6 +17794,12 @@ mutation($projectId: ID!, $itemId: ID!) {
|
|
|
16180
17794
|
deletedItemId
|
|
16181
17795
|
}
|
|
16182
17796
|
}`;
|
|
17797
|
+
var ARCHIVE_PROJECT_ITEM_MUTATION = `
|
|
17798
|
+
mutation($projectId: ID!, $itemId: ID!) {
|
|
17799
|
+
archiveProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {
|
|
17800
|
+
item { id }
|
|
17801
|
+
}
|
|
17802
|
+
}`;
|
|
16183
17803
|
async function updateItemSingleSelect(client, projectId, itemId, fieldId, optionId) {
|
|
16184
17804
|
await client.graphql(UPDATE_ITEM_FIELD_MUTATION, { projectId, itemId, fieldId, optionId });
|
|
16185
17805
|
}
|
|
@@ -16518,6 +18138,31 @@ async function removeRepoBoardItems(options, deps = {}) {
|
|
|
16518
18138
|
}
|
|
16519
18139
|
return { repo, board, dryRun: Boolean(options.dryRun), removed, failures };
|
|
16520
18140
|
}
|
|
18141
|
+
async function archiveClosedDoneBoardItems(options, deps = {}) {
|
|
18142
|
+
const cfg = resolveBoardConfig(options.config);
|
|
18143
|
+
const client = deps.client ?? defaultGitHubClient();
|
|
18144
|
+
const collected = await collectBoardItems(cfg, { repo: options.repo, activeOnly: false }, deps);
|
|
18145
|
+
const candidates = collected.items.filter((item) => item.status === "Done" && item.state === "CLOSED");
|
|
18146
|
+
const result = {
|
|
18147
|
+
board: { owner: cfg.projectOwner, number: cfg.projectNumber, id: collected.projectId },
|
|
18148
|
+
dryRun: !options.apply,
|
|
18149
|
+
scanned: collected.items.length,
|
|
18150
|
+
candidates: candidates.map(({ ref, url }) => ({ ref, url })),
|
|
18151
|
+
archived: [],
|
|
18152
|
+
failures: []
|
|
18153
|
+
};
|
|
18154
|
+
if (!options.apply) return result;
|
|
18155
|
+
for (const item of candidates) {
|
|
18156
|
+
try {
|
|
18157
|
+
await client.graphql(ARCHIVE_PROJECT_ITEM_MUTATION, { projectId: collected.projectId, itemId: item.itemId });
|
|
18158
|
+
result.archived.push({ ref: item.ref, url: item.url });
|
|
18159
|
+
} catch (e) {
|
|
18160
|
+
result.failures.push({ ref: item.ref, error: ghError(e) });
|
|
18161
|
+
break;
|
|
18162
|
+
}
|
|
18163
|
+
}
|
|
18164
|
+
return result;
|
|
18165
|
+
}
|
|
16521
18166
|
async function showBoardItem(options, deps = {}) {
|
|
16522
18167
|
const cfg = resolveBoardConfig(options.config);
|
|
16523
18168
|
const client = deps.client ?? defaultGitHubClient();
|
|
@@ -17907,6 +19552,7 @@ function consolidateCommandNamespaces(program3) {
|
|
|
17907
19552
|
move(program3, plugin, "guard");
|
|
17908
19553
|
move(program3, plugin, "plugin-heal", "heal");
|
|
17909
19554
|
move(program3, plugin, "plugin-prune", "prune");
|
|
19555
|
+
move(program3, plugin, "plugin-release-catchup", "release-catchup");
|
|
17910
19556
|
move(program3, plugin, "session-start");
|
|
17911
19557
|
const train = child(program3, "train");
|
|
17912
19558
|
const fullTrack2 = child(program3, "full-track");
|
|
@@ -18178,10 +19824,11 @@ function newestExistingPiPlugin(home) {
|
|
|
18178
19824
|
} catch {
|
|
18179
19825
|
return void 0;
|
|
18180
19826
|
}
|
|
18181
|
-
const
|
|
18182
|
-
|
|
18183
|
-
|
|
18184
|
-
|
|
19827
|
+
for (const version of names.filter(isVersionDirName).sort((a, b) => compareVersions(b, a))) {
|
|
19828
|
+
const candidate = (0, import_node_path20.join)(cacheRoot, version, ".pi-plugin");
|
|
19829
|
+
if ((0, import_node_fs22.existsSync)(candidate)) return candidate;
|
|
19830
|
+
}
|
|
19831
|
+
return void 0;
|
|
18185
19832
|
}
|
|
18186
19833
|
function expectedPiPluginPath(home, env, installedVersion) {
|
|
18187
19834
|
const root = env.CLAUDE_PLUGIN_ROOT?.trim();
|
|
@@ -18792,6 +20439,9 @@ async function runHotfixStart(deps, options) {
|
|
|
18792
20439
|
};
|
|
18793
20440
|
}
|
|
18794
20441
|
const { sha, label } = await resolveHotfixSource(deps, ctx, options.from);
|
|
20442
|
+
if (deployModel === "hub-serverless") {
|
|
20443
|
+
await deps.run("node", ["scripts/release-distribution.mjs", "verify-deps"]);
|
|
20444
|
+
}
|
|
18795
20445
|
const remoteBranch = clean3(await deps.run("git", ["ls-remote", "origin", `refs/heads/${branch}`]));
|
|
18796
20446
|
if (remoteBranch) {
|
|
18797
20447
|
await deps.run("git", ["checkout", branch]);
|
|
@@ -26332,6 +27982,21 @@ function registerBoardCommands(program3) {
|
|
|
26332
27982
|
return failGraceful(`board unclaim failed: ${e.message}`);
|
|
26333
27983
|
}
|
|
26334
27984
|
});
|
|
27985
|
+
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) => {
|
|
27986
|
+
try {
|
|
27987
|
+
const result = await archiveClosedDoneBoardItems({
|
|
27988
|
+
config: await loadConfigForRepo(o.repo),
|
|
27989
|
+
repo: o.repo,
|
|
27990
|
+
apply: o.apply
|
|
27991
|
+
});
|
|
27992
|
+
if (result.archived.length) invalidateStatuslineBoardCache();
|
|
27993
|
+
if (o.json) return console.log(JSON.stringify(result));
|
|
27994
|
+
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)`);
|
|
27995
|
+
if (result.failures.length) process.exitCode = 1;
|
|
27996
|
+
} catch (e) {
|
|
27997
|
+
return failGraceful(`board archive-done failed: ${e.message}`);
|
|
27998
|
+
}
|
|
27999
|
+
});
|
|
26335
28000
|
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) => {
|
|
26336
28001
|
try {
|
|
26337
28002
|
const result = await boardDoctor({
|
|
@@ -29866,6 +31531,125 @@ function registerSessionReport(program3) {
|
|
|
29866
31531
|
});
|
|
29867
31532
|
}
|
|
29868
31533
|
|
|
31534
|
+
// src/plugin-release-catchup.ts
|
|
31535
|
+
var import_node_fs39 = require("node:fs");
|
|
31536
|
+
var import_node_path37 = require("node:path");
|
|
31537
|
+
var import_node_os14 = require("node:os");
|
|
31538
|
+
var RELEASE_CATCHUP_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
31539
|
+
var RELEASE_CATCHUP_DISABLE_ENV = "MMI_NO_RELEASE_CATCHUP";
|
|
31540
|
+
function releaseCatchupStatePath(env = process.env) {
|
|
31541
|
+
if (env.MMI_RELEASE_CATCHUP_STATE) return env.MMI_RELEASE_CATCHUP_STATE;
|
|
31542
|
+
if (process.platform === "win32") {
|
|
31543
|
+
const base2 = env.LOCALAPPDATA || (0, import_node_path37.join)((0, import_node_os14.homedir)(), "AppData", "Local");
|
|
31544
|
+
return (0, import_node_path37.join)(base2, "MMI Future", "mmi-cli", "release-catchup.json");
|
|
31545
|
+
}
|
|
31546
|
+
const base = env.XDG_STATE_HOME || (0, import_node_path37.join)((0, import_node_os14.homedir)(), ".local", "state");
|
|
31547
|
+
return (0, import_node_path37.join)(base, "mmi-cli", "release-catchup.json");
|
|
31548
|
+
}
|
|
31549
|
+
function releaseCatchupDue(state, now, force = false) {
|
|
31550
|
+
if (force) return true;
|
|
31551
|
+
if (!state || typeof state.checkedAt !== "number") return true;
|
|
31552
|
+
return now - state.checkedAt >= RELEASE_CATCHUP_TTL_MS;
|
|
31553
|
+
}
|
|
31554
|
+
function newestCachedPluginVersion(home) {
|
|
31555
|
+
let names;
|
|
31556
|
+
try {
|
|
31557
|
+
names = (0, import_node_fs39.readdirSync)(pluginCacheRoot(home));
|
|
31558
|
+
} catch {
|
|
31559
|
+
return void 0;
|
|
31560
|
+
}
|
|
31561
|
+
return names.filter(isVersionDirName).sort((a, b) => compareVersions(b, a))[0];
|
|
31562
|
+
}
|
|
31563
|
+
function marketplaceClonePath(home) {
|
|
31564
|
+
try {
|
|
31565
|
+
const parsed = JSON.parse((0, import_node_fs39.readFileSync)((0, import_node_path37.join)(home, ".claude", "plugins", "known_marketplaces.json"), "utf8"));
|
|
31566
|
+
if (parsed.mutmutco?.installLocation) return parsed.mutmutco.installLocation;
|
|
31567
|
+
} catch {
|
|
31568
|
+
}
|
|
31569
|
+
return (0, import_node_path37.join)(home, ".claude", "plugins", "marketplaces", "mutmutco");
|
|
31570
|
+
}
|
|
31571
|
+
function readCatalogVersion(home) {
|
|
31572
|
+
try {
|
|
31573
|
+
const parsed = JSON.parse((0, import_node_fs39.readFileSync)((0, import_node_path37.join)(marketplaceClonePath(home), ".claude-plugin", "marketplace.json"), "utf8"));
|
|
31574
|
+
return parsed.plugins?.find((p) => p.name === "mmi")?.version;
|
|
31575
|
+
} catch {
|
|
31576
|
+
return void 0;
|
|
31577
|
+
}
|
|
31578
|
+
}
|
|
31579
|
+
function readMmiInstallRecord(home) {
|
|
31580
|
+
try {
|
|
31581
|
+
const parsed = JSON.parse((0, import_node_fs39.readFileSync)((0, import_node_path37.join)(home, ".claude", "plugins", "installed_plugins.json"), "utf8"));
|
|
31582
|
+
const record = parsed.plugins?.["mmi@mutmutco"]?.[0];
|
|
31583
|
+
return record?.version ? { version: record.version, gitCommitSha: record.gitCommitSha } : void 0;
|
|
31584
|
+
} catch {
|
|
31585
|
+
return void 0;
|
|
31586
|
+
}
|
|
31587
|
+
}
|
|
31588
|
+
async function runReleaseCatchup(home, env, deps, opts = {}) {
|
|
31589
|
+
if (env[RELEASE_CATCHUP_DISABLE_ENV]) return { ok: true, skipped: true, detail: `disabled via ${RELEASE_CATCHUP_DISABLE_ENV}` };
|
|
31590
|
+
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" };
|
|
31591
|
+
const statePath = releaseCatchupStatePath(env);
|
|
31592
|
+
const state = deps.readState(statePath);
|
|
31593
|
+
if (!releaseCatchupDue(state, deps.now(), opts.force)) {
|
|
31594
|
+
return { ok: true, skipped: true, detail: `checked within the last 24h${state?.latest ? ` (released ${state.latest})` : ""}` };
|
|
31595
|
+
}
|
|
31596
|
+
const latest = await deps.fetchReleased();
|
|
31597
|
+
if (!latest) return { ok: true, skipped: true, detail: "released version unreadable \u2014 will retry next session start" };
|
|
31598
|
+
const newest = newestCachedPluginVersion(home);
|
|
31599
|
+
if (newest && compareVersions(latest, newest) <= 0) {
|
|
31600
|
+
deps.writeState(statePath, { checkedAt: deps.now(), latest });
|
|
31601
|
+
return { ok: true, skipped: true, detail: `already current (cache ${newest}, released ${latest})` };
|
|
31602
|
+
}
|
|
31603
|
+
if (!await deps.runClaude(["plugin", "marketplace", "update", "mutmutco"], "claude plugin marketplace update mutmutco")) {
|
|
31604
|
+
return { ok: false, detail: `released ${latest} (cache ${newest ?? "none"}) but the marketplace refresh failed \u2014 nothing changed` };
|
|
31605
|
+
}
|
|
31606
|
+
const catalog = readCatalogVersion(home);
|
|
31607
|
+
if (catalog !== latest) {
|
|
31608
|
+
return { ok: true, skipped: true, detail: `released ${latest} but the refreshed catalog offers ${catalog ?? "nothing"} \u2014 will retry next session start` };
|
|
31609
|
+
}
|
|
31610
|
+
const prior = readMmiInstallRecord(home);
|
|
31611
|
+
if (prior && !await deps.runClaude(["plugin", "uninstall", "mmi@mutmutco"], "claude plugin uninstall mmi@mutmutco")) {
|
|
31612
|
+
return { ok: false, detail: `released ${latest} but the install record could not be cleared \u2014 nothing changed (record still ${prior.version})` };
|
|
31613
|
+
}
|
|
31614
|
+
const installed = await deps.runClaude(["plugin", "install", "mmi@mutmutco"], "claude plugin install mmi@mutmutco");
|
|
31615
|
+
const payload = (0, import_node_path37.join)(pluginCacheRoot(home), latest, ".pi-plugin");
|
|
31616
|
+
if (!installed || !(0, import_node_fs39.existsSync)(payload)) {
|
|
31617
|
+
const why = installed ? `install of ${latest} did not produce a verifiable .pi-plugin payload` : `install of ${latest} failed`;
|
|
31618
|
+
if (!prior) return { ok: false, detail: `${why}; no prior record to restore` };
|
|
31619
|
+
const rollback = await restorePriorRecord(home, prior, deps);
|
|
31620
|
+
return {
|
|
31621
|
+
ok: false,
|
|
31622
|
+
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\``
|
|
31623
|
+
};
|
|
31624
|
+
}
|
|
31625
|
+
const heal = deps.healRegistration();
|
|
31626
|
+
deps.writeState(statePath, { checkedAt: deps.now(), latest });
|
|
31627
|
+
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})` };
|
|
31628
|
+
}
|
|
31629
|
+
async function restorePriorRecord(home, prior, deps) {
|
|
31630
|
+
const clone = marketplaceClonePath(home);
|
|
31631
|
+
try {
|
|
31632
|
+
if (prior.gitCommitSha) {
|
|
31633
|
+
if (!await deps.runGit(["-C", clone, "checkout", prior.gitCommitSha], `git -C ${clone} checkout ${prior.gitCommitSha}`)) return false;
|
|
31634
|
+
}
|
|
31635
|
+
if (!await deps.runClaude(["plugin", "install", "mmi@mutmutco"], "claude plugin install mmi@mutmutco (rollback)")) return false;
|
|
31636
|
+
const restored = readMmiInstallRecord(home);
|
|
31637
|
+
return restored?.version === prior.version;
|
|
31638
|
+
} finally {
|
|
31639
|
+
if (prior.gitCommitSha) await deps.runGit(["-C", clone, "checkout", "main"], `git -C ${clone} checkout main`);
|
|
31640
|
+
}
|
|
31641
|
+
}
|
|
31642
|
+
function shouldSpawnReleaseCatchup(home, env, readState2, now = Date.now()) {
|
|
31643
|
+
if (env[RELEASE_CATCHUP_DISABLE_ENV]) return false;
|
|
31644
|
+
if (!(0, import_node_fs39.existsSync)(pluginCacheRoot(home))) return false;
|
|
31645
|
+
return releaseCatchupDue(readState2(releaseCatchupStatePath(env)), now);
|
|
31646
|
+
}
|
|
31647
|
+
function defaultRegistrationHeal(home, env) {
|
|
31648
|
+
const healEnv = { ...env };
|
|
31649
|
+
delete healEnv.CLAUDE_PLUGIN_ROOT;
|
|
31650
|
+
return () => healPiPluginRegistration(home, healEnv);
|
|
31651
|
+
}
|
|
31652
|
+
|
|
29869
31653
|
// src/doctor-render.ts
|
|
29870
31654
|
var RESTART_LINE = "\u21BB Restart Claude to finish.";
|
|
29871
31655
|
var VERBOSE_INDENT = " ";
|
|
@@ -31903,17 +33687,17 @@ function parseOriginRepo(remoteUrl) {
|
|
|
31903
33687
|
}
|
|
31904
33688
|
function ghHostsConfigPath(env, platform2) {
|
|
31905
33689
|
const sep3 = platform2 === "win32" ? "\\" : "/";
|
|
31906
|
-
const
|
|
33690
|
+
const join35 = (...parts) => parts.join(sep3);
|
|
31907
33691
|
const explicit = env.GH_CONFIG_DIR?.trim();
|
|
31908
|
-
if (explicit) return
|
|
33692
|
+
if (explicit) return join35(explicit, "hosts.yml");
|
|
31909
33693
|
if (platform2 === "win32") {
|
|
31910
33694
|
const appData = (env.AppData ?? env.APPDATA)?.trim();
|
|
31911
|
-
return appData ?
|
|
33695
|
+
return appData ? join35(appData, "GitHub CLI", "hosts.yml") : void 0;
|
|
31912
33696
|
}
|
|
31913
33697
|
const xdg = env.XDG_CONFIG_HOME?.trim();
|
|
31914
|
-
if (xdg) return
|
|
33698
|
+
if (xdg) return join35(xdg, "gh", "hosts.yml");
|
|
31915
33699
|
const home = env.HOME?.trim();
|
|
31916
|
-
return home ?
|
|
33700
|
+
return home ? join35(home, ".config", "gh", "hosts.yml") : void 0;
|
|
31917
33701
|
}
|
|
31918
33702
|
function parseGhHostsAccounts(yaml, host = "github.com") {
|
|
31919
33703
|
let hostIndent = null;
|
|
@@ -31963,9 +33747,9 @@ function ghAccountCaveat(announcedLogin, accounts) {
|
|
|
31963
33747
|
}
|
|
31964
33748
|
|
|
31965
33749
|
// src/doctor-io.ts
|
|
31966
|
-
var
|
|
31967
|
-
var
|
|
31968
|
-
var
|
|
33750
|
+
var import_node_fs40 = require("node:fs");
|
|
33751
|
+
var import_node_os15 = require("node:os");
|
|
33752
|
+
var import_node_path38 = require("node:path");
|
|
31969
33753
|
var import_node_child_process18 = require("node:child_process");
|
|
31970
33754
|
var import_node_util8 = require("node:util");
|
|
31971
33755
|
var execFileP6 = (0, import_node_util8.promisify)(import_node_child_process18.execFile);
|
|
@@ -31973,7 +33757,7 @@ var MMI_PLUGIN_ID2 = "mmi@mutmutco";
|
|
|
31973
33757
|
function installedClaudePluginVersion() {
|
|
31974
33758
|
try {
|
|
31975
33759
|
const file = JSON.parse(
|
|
31976
|
-
(0,
|
|
33760
|
+
(0, import_node_fs40.readFileSync)((0, import_node_path38.join)((0, import_node_os15.homedir)(), ".claude", "plugins", "installed_plugins.json"), "utf8")
|
|
31977
33761
|
);
|
|
31978
33762
|
const versions = (file.plugins?.[MMI_PLUGIN_ID2] ?? []).map((r) => r.version).filter((v) => Boolean(v));
|
|
31979
33763
|
if (versions.length === 0) return void 0;
|
|
@@ -31984,7 +33768,7 @@ function installedClaudePluginVersion() {
|
|
|
31984
33768
|
}
|
|
31985
33769
|
function manifestVersion(path2) {
|
|
31986
33770
|
try {
|
|
31987
|
-
const manifest = JSON.parse((0,
|
|
33771
|
+
const manifest = JSON.parse((0, import_node_fs40.readFileSync)(path2, "utf8"));
|
|
31988
33772
|
return typeof manifest.version === "string" && manifest.version.trim() ? manifest.version.trim() : void 0;
|
|
31989
33773
|
} catch {
|
|
31990
33774
|
return void 0;
|
|
@@ -31994,22 +33778,22 @@ function installedSurfacePluginVersion(surface) {
|
|
|
31994
33778
|
const token = surfaceToken(surface);
|
|
31995
33779
|
if (token === "kilo") {
|
|
31996
33780
|
try {
|
|
31997
|
-
const stamp = (0,
|
|
33781
|
+
const stamp = (0, import_node_fs40.readFileSync)((0, import_node_path38.join)((0, import_node_os15.homedir)(), ".kilo", ".mmi-kilo-version"), "utf8").trim();
|
|
31998
33782
|
return stamp || void 0;
|
|
31999
33783
|
} catch {
|
|
32000
33784
|
return void 0;
|
|
32001
33785
|
}
|
|
32002
33786
|
}
|
|
32003
33787
|
if (token === "cursor") {
|
|
32004
|
-
return manifestVersion((0,
|
|
33788
|
+
return manifestVersion((0, import_node_path38.join)(cursorLocalPluginRoot(), ".cursor-plugin", "plugin.json"));
|
|
32005
33789
|
}
|
|
32006
33790
|
if (token === "jervcode") {
|
|
32007
33791
|
const entry = mmiPiWrapperEntry();
|
|
32008
33792
|
if (!entry) return void 0;
|
|
32009
|
-
return manifestVersion((0,
|
|
33793
|
+
return manifestVersion((0, import_node_path38.join)(decodeURIComponent(entry.replace(/^file:\/\/\/?/, "")), "package.json"));
|
|
32010
33794
|
}
|
|
32011
33795
|
if (token === "kimi") {
|
|
32012
|
-
return manifestVersion((0,
|
|
33796
|
+
return manifestVersion((0, import_node_path38.join)(surfaceConfigRoot(surface), "plugins", "managed", "mmi", ".kimi-plugin", "plugin.json"));
|
|
32013
33797
|
}
|
|
32014
33798
|
if (token === "claude") return installedClaudePluginVersion();
|
|
32015
33799
|
if (token !== "codex") return void 0;
|
|
@@ -32047,13 +33831,13 @@ function worktreeRootSync() {
|
|
|
32047
33831
|
}
|
|
32048
33832
|
var gitignorePath = () => {
|
|
32049
33833
|
const root = worktreeRootSync();
|
|
32050
|
-
return root === null ? null : (0,
|
|
33834
|
+
return root === null ? null : (0, import_node_path38.join)(root, ".gitignore");
|
|
32051
33835
|
};
|
|
32052
33836
|
function readGitignore() {
|
|
32053
33837
|
const path2 = gitignorePath();
|
|
32054
33838
|
if (path2 === null) return null;
|
|
32055
33839
|
try {
|
|
32056
|
-
return (0,
|
|
33840
|
+
return (0, import_node_fs40.readFileSync)(path2, "utf8");
|
|
32057
33841
|
} catch {
|
|
32058
33842
|
return null;
|
|
32059
33843
|
}
|
|
@@ -32062,7 +33846,7 @@ function writeGitignore(content) {
|
|
|
32062
33846
|
const path2 = gitignorePath();
|
|
32063
33847
|
if (path2 === null) return false;
|
|
32064
33848
|
try {
|
|
32065
|
-
(0,
|
|
33849
|
+
(0, import_node_fs40.writeFileSync)(path2, content, "utf8");
|
|
32066
33850
|
return true;
|
|
32067
33851
|
} catch {
|
|
32068
33852
|
return false;
|
|
@@ -32086,7 +33870,7 @@ async function repoRoot() {
|
|
|
32086
33870
|
}
|
|
32087
33871
|
function hasRepoLocalWorktrees() {
|
|
32088
33872
|
const root = worktreeRootSync();
|
|
32089
|
-
return root !== null && (0,
|
|
33873
|
+
return root !== null && (0, import_node_fs40.existsSync)((0, import_node_path38.join)(root, ".worktrees"));
|
|
32090
33874
|
}
|
|
32091
33875
|
|
|
32092
33876
|
// src/index.ts
|
|
@@ -32105,8 +33889,8 @@ ${r.stderr ?? ""}`).catch(() => "");
|
|
|
32105
33889
|
function ghMultiAccountCaveat(announcedLogin) {
|
|
32106
33890
|
try {
|
|
32107
33891
|
const hostsPath = ghHostsConfigPath(process.env, process.platform);
|
|
32108
|
-
if (!hostsPath || !(0,
|
|
32109
|
-
return ghAccountCaveat(announcedLogin, parseGhHostsAccounts((0,
|
|
33892
|
+
if (!hostsPath || !(0, import_node_fs41.existsSync)(hostsPath)) return void 0;
|
|
33893
|
+
return ghAccountCaveat(announcedLogin, parseGhHostsAccounts((0, import_node_fs41.readFileSync)(hostsPath, "utf8")));
|
|
32110
33894
|
} catch {
|
|
32111
33895
|
return void 0;
|
|
32112
33896
|
}
|
|
@@ -32114,12 +33898,12 @@ function ghMultiAccountCaveat(announcedLogin) {
|
|
|
32114
33898
|
var ENV_HEAL_LOCK_STALE_MS = 10 * 6e4;
|
|
32115
33899
|
var ENV_HEAL_LOCK_MAX_WAIT_MS = 2 * 6e4;
|
|
32116
33900
|
function envHealLockPath(home) {
|
|
32117
|
-
return (0,
|
|
33901
|
+
return (0, import_node_path39.join)(home, ".claude", "plugins", ".mmi-env-heal.lock");
|
|
32118
33902
|
}
|
|
32119
33903
|
async function withEnvHealLock(what, run) {
|
|
32120
33904
|
try {
|
|
32121
33905
|
return await withFileLock(
|
|
32122
|
-
envHealLockPath((0,
|
|
33906
|
+
envHealLockPath((0, import_node_os16.homedir)()),
|
|
32123
33907
|
{ staleMs: ENV_HEAL_LOCK_STALE_MS, maxWaitMs: ENV_HEAL_LOCK_MAX_WAIT_MS, label: "mmi env-heal lock" },
|
|
32124
33908
|
run
|
|
32125
33909
|
);
|
|
@@ -32216,7 +34000,7 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32216
34000
|
const configRoot = surfaceConfigRoot(surface);
|
|
32217
34001
|
const running = surface === "codex" ? installedActivePluginVersion(surface) : runningPluginVersion(process.env, resolveClientVersion());
|
|
32218
34002
|
const plan = buildPluginCachePlan(
|
|
32219
|
-
(0,
|
|
34003
|
+
(0, import_node_os16.homedir)(),
|
|
32220
34004
|
running,
|
|
32221
34005
|
pluginCacheFsDeps(configRoot, () => 0),
|
|
32222
34006
|
{ configRoot, includeStaging: surface !== "codex" }
|
|
@@ -32240,14 +34024,14 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32240
34024
|
const running = surface === "codex" ? installedActivePluginVersion(surface) : runningPluginVersion(process.env, resolveClientVersion());
|
|
32241
34025
|
const installed = installedActivePluginVersion(surface);
|
|
32242
34026
|
const plan = buildPluginCachePlan(
|
|
32243
|
-
(0,
|
|
34027
|
+
(0, import_node_os16.homedir)(),
|
|
32244
34028
|
running,
|
|
32245
34029
|
pluginCacheFsDeps(configRoot, () => 0),
|
|
32246
34030
|
{ configRoot, includeStaging: surface !== "codex", installedVersion: installed }
|
|
32247
34031
|
);
|
|
32248
34032
|
const result = applyPluginCachePlan(
|
|
32249
34033
|
plan,
|
|
32250
|
-
(p) => (0,
|
|
34034
|
+
(p) => (0, import_node_fs41.rmSync)(p, { recursive: true }),
|
|
32251
34035
|
stagingApplyFsGuard(configRoot)
|
|
32252
34036
|
);
|
|
32253
34037
|
return {
|
|
@@ -32266,8 +34050,22 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32266
34050
|
};
|
|
32267
34051
|
},
|
|
32268
34052
|
// #4201: mmi `.pi-plugin` registration in ~/.pi/agent/settings.json — mirror of jerv-cli's own heal.
|
|
32269
|
-
|
|
32270
|
-
|
|
34053
|
+
// #4305: BOTH the state read and the heal strip CLAUDE_PLUGIN_ROOT — inside a Claude session it names
|
|
34054
|
+
// the RUNNING clone, and since #4302 the registration legitimately LEADS the running clone (a catch-up
|
|
34055
|
+
// re-points it at the newest release; the restart-pending truth is the JervCode plugin guard row's).
|
|
34056
|
+
// Unstripped, the state row calls the post-catch-up registration "stale", the intent line names the old
|
|
34057
|
+
// clone while the heal writes the new one, and the heal itself reverts the catch-up. The expected path
|
|
34058
|
+
// for registration purposes is always the newest existing clone, never the running one.
|
|
34059
|
+
piPluginState: () => {
|
|
34060
|
+
const env = { ...process.env };
|
|
34061
|
+
delete env.CLAUDE_PLUGIN_ROOT;
|
|
34062
|
+
return readPiPluginState((0, import_node_os16.homedir)(), env);
|
|
34063
|
+
},
|
|
34064
|
+
healPiPlugin: () => {
|
|
34065
|
+
const env = { ...process.env };
|
|
34066
|
+
delete env.CLAUDE_PLUGIN_ROOT;
|
|
34067
|
+
return healPiPluginRegistration((0, import_node_os16.homedir)(), env);
|
|
34068
|
+
},
|
|
32271
34069
|
// #3470: what the SessionStart hook LAST emitted, measured at emission by the session-start verb below.
|
|
32272
34070
|
// A local record read ? cheap enough for every lane, including the banner.
|
|
32273
34071
|
sessionPayload: () => readSessionPayload(process.cwd()),
|
|
@@ -32276,17 +34074,17 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32276
34074
|
marketplaceRows: () => {
|
|
32277
34075
|
try {
|
|
32278
34076
|
if (detectSurface(process.env) === "codex") return [];
|
|
32279
|
-
const home = (0,
|
|
34077
|
+
const home = (0, import_node_os16.homedir)();
|
|
32280
34078
|
const rows = marketplaceRows(
|
|
32281
34079
|
MMI_MARKETPLACE_NAME,
|
|
32282
|
-
readFileSyncSafe((0,
|
|
32283
|
-
readFileSyncSafe((0,
|
|
34080
|
+
readFileSyncSafe((0, import_node_path39.join)(home, ...KNOWN_MARKETPLACES_RELATIVE), import_node_fs41.readFileSync),
|
|
34081
|
+
readFileSyncSafe((0, import_node_path39.join)(home, ".claude", "settings.json"), import_node_fs41.readFileSync),
|
|
32284
34082
|
// #3974: this CLI heals these rows, so report mode names the doctor run rather than the hand
|
|
32285
34083
|
// edit. Unconditional ? it is a fact about mmi-cli, not about the lane this run is on.
|
|
32286
34084
|
true
|
|
32287
34085
|
);
|
|
32288
34086
|
const pending = readMarketplacePinPending(
|
|
32289
|
-
(0,
|
|
34087
|
+
(0, import_node_path39.join)(home, ".claude", "plugins", ".mmi-marketplace-pin-pending.json"),
|
|
32290
34088
|
MMI_MARKETPLACE_NAME
|
|
32291
34089
|
);
|
|
32292
34090
|
if (!pending) return rows;
|
|
@@ -32310,11 +34108,11 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32310
34108
|
healMarketplacePins: () => {
|
|
32311
34109
|
try {
|
|
32312
34110
|
if (detectSurface(process.env) === "codex") return void 0;
|
|
32313
|
-
const home = (0,
|
|
34111
|
+
const home = (0, import_node_os16.homedir)();
|
|
32314
34112
|
const names = [MMI_MARKETPLACE_NAME];
|
|
32315
|
-
const result = applyOrgMarketplacePins((0,
|
|
34113
|
+
const result = applyOrgMarketplacePins((0, import_node_path39.join)(home, ...KNOWN_MARKETPLACES_RELATIVE), names);
|
|
32316
34114
|
if (result?.wrote) {
|
|
32317
|
-
writeMarketplacePinPending((0,
|
|
34115
|
+
writeMarketplacePinPending((0, import_node_path39.join)(home, ".claude", "plugins", ".mmi-marketplace-pin-pending.json"), names);
|
|
32318
34116
|
}
|
|
32319
34117
|
return result;
|
|
32320
34118
|
} catch {
|
|
@@ -32330,7 +34128,7 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32330
34128
|
// adopted the generated routing index (MMG-Unlive: `docs/Archive/**` only, no index, no gate.yml) would
|
|
32331
34129
|
// get a permanent ? demanding an artifact it never asked for.
|
|
32332
34130
|
docsIndexState: (root) => {
|
|
32333
|
-
if (!(0,
|
|
34131
|
+
if (!(0, import_node_fs41.existsSync)((0, import_node_path39.join)(root, DOCS_INDEX_PATH))) return void 0;
|
|
32334
34132
|
const real = createDocsIndexDeps(root);
|
|
32335
34133
|
let docs2;
|
|
32336
34134
|
const listDocs = () => docs2 ??= real.listDocs();
|
|
@@ -32339,7 +34137,7 @@ function mmiDoctorDeps(opts = {}) {
|
|
|
32339
34137
|
},
|
|
32340
34138
|
// #4168: working-tree heal — write if drifted, then re-check. Commit remains the operator's step.
|
|
32341
34139
|
healDocsIndex: (root) => {
|
|
32342
|
-
if (!(0,
|
|
34140
|
+
if (!(0, import_node_fs41.existsSync)((0, import_node_path39.join)(root, DOCS_INDEX_PATH))) return { drift: false, docCount: 0 };
|
|
32343
34141
|
const real = createDocsIndexDeps(root);
|
|
32344
34142
|
let docs2;
|
|
32345
34143
|
const listDocs = () => docs2 ??= real.listDocs();
|
|
@@ -32674,19 +34472,19 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
32674
34472
|
});
|
|
32675
34473
|
var rules = program2.command("rules").description("org-managed .gitignore delivery");
|
|
32676
34474
|
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) => {
|
|
32677
|
-
const path2 = (0,
|
|
32678
|
-
const current = (0,
|
|
34475
|
+
const path2 = (0, import_node_path39.join)(process.cwd(), ".gitignore");
|
|
34476
|
+
const current = (0, import_node_fs41.existsSync)(path2) ? (0, import_node_fs41.readFileSync)(path2, "utf8") : null;
|
|
32679
34477
|
const plan = planManagedGitignore(current);
|
|
32680
34478
|
const drift = [...plan.added.map((l) => `+${l}`), ...plan.removed.map((l) => `-${l}`)].join(", ") || "block normalize";
|
|
32681
34479
|
if (opts.json) {
|
|
32682
|
-
if (opts.write && plan.changed) (0,
|
|
34480
|
+
if (opts.write && plan.changed) (0, import_node_fs41.writeFileSync)(path2, plan.content, "utf8");
|
|
32683
34481
|
console.log(JSON.stringify(plan, null, 2));
|
|
32684
34482
|
if (!opts.write && plan.changed) process.exitCode = 1;
|
|
32685
34483
|
return;
|
|
32686
34484
|
}
|
|
32687
34485
|
if (opts.write) {
|
|
32688
34486
|
if (plan.changed) {
|
|
32689
|
-
(0,
|
|
34487
|
+
(0, import_node_fs41.writeFileSync)(path2, plan.content, "utf8");
|
|
32690
34488
|
console.log(`mmi-cli org rules gitignore: updated .gitignore (${drift})`);
|
|
32691
34489
|
} else {
|
|
32692
34490
|
console.log("mmi-cli org rules gitignore: up to date");
|
|
@@ -32844,8 +34642,8 @@ gcCmd.option("--dry-run", "show what would be deleted (default)").option("--appl
|
|
|
32844
34642
|
if (!Number.isFinite(limit) || limit < 1) return fail("worktree gc: --limit must be a positive integer");
|
|
32845
34643
|
let root;
|
|
32846
34644
|
if (o.root !== void 0) {
|
|
32847
|
-
root = (0,
|
|
32848
|
-
if (!(0,
|
|
34645
|
+
root = (0, import_node_path39.resolve)(o.root);
|
|
34646
|
+
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`);
|
|
32849
34647
|
const gcRepoRoot = (await execFileP2("git", ["rev-parse", "--show-toplevel"], { timeout: GIT_TIMEOUT_MS }).catch(() => ({ stdout: "" }))).stdout.trim() || process.cwd();
|
|
32850
34648
|
if (isPathUnderDirectory(gcRepoRoot, root)) {
|
|
32851
34649
|
return fail(`worktree gc: --root ${root} contains this checkout ? name a worktrees root, not the repo or an ancestor of it`);
|
|
@@ -32925,7 +34723,7 @@ async function currentWorktreeRemovalContext(command, force) {
|
|
|
32925
34723
|
};
|
|
32926
34724
|
}
|
|
32927
34725
|
async function unprovenWorktreeReason(wtPath, repoRoot2) {
|
|
32928
|
-
if (!(0,
|
|
34726
|
+
if (!(0, import_node_fs41.existsSync)(wtPath)) return `${wtPath} does not exist on disk`;
|
|
32929
34727
|
const porcelain = (await execFileP2("git", ["-C", repoRoot2, "worktree", "list", "--porcelain"], { timeout: GIT_TIMEOUT_MS }).catch(() => ({ stdout: "" }))).stdout;
|
|
32930
34728
|
const registered = parseWorktreePorcelainEntries(porcelain);
|
|
32931
34729
|
if (!registered.length) {
|
|
@@ -32947,26 +34745,26 @@ function makeProvisionDeps(worktreeRoot, quiet, log) {
|
|
|
32947
34745
|
function acquireWorktreeSetupLock(worktreeRoot) {
|
|
32948
34746
|
const lockPath = repoRuntimeStatePath(worktreeRoot, "worktree-setup.lock");
|
|
32949
34747
|
const take = () => {
|
|
32950
|
-
const fd = (0,
|
|
34748
|
+
const fd = (0, import_node_fs41.openSync)(lockPath, "wx");
|
|
32951
34749
|
try {
|
|
32952
|
-
(0,
|
|
34750
|
+
(0, import_node_fs41.writeSync)(fd, String(Date.now()));
|
|
32953
34751
|
} finally {
|
|
32954
|
-
(0,
|
|
34752
|
+
(0, import_node_fs41.closeSync)(fd);
|
|
32955
34753
|
}
|
|
32956
34754
|
return () => {
|
|
32957
34755
|
try {
|
|
32958
|
-
(0,
|
|
34756
|
+
(0, import_node_fs41.rmSync)(lockPath, { force: true });
|
|
32959
34757
|
} catch {
|
|
32960
34758
|
}
|
|
32961
34759
|
};
|
|
32962
34760
|
};
|
|
32963
34761
|
try {
|
|
32964
|
-
(0,
|
|
34762
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path39.dirname)(lockPath), { recursive: true });
|
|
32965
34763
|
return take();
|
|
32966
34764
|
} catch {
|
|
32967
34765
|
try {
|
|
32968
|
-
if (Date.now() - (0,
|
|
32969
|
-
(0,
|
|
34766
|
+
if (Date.now() - (0, import_node_fs41.statSync)(lockPath).mtimeMs > WORKTREE_SETUP_LOCK_TTL_MS) {
|
|
34767
|
+
(0, import_node_fs41.rmSync)(lockPath, { force: true });
|
|
32970
34768
|
return take();
|
|
32971
34769
|
}
|
|
32972
34770
|
} catch {
|
|
@@ -33814,7 +35612,7 @@ project.command("set [owner/repo]").description("upsert project META (idempotent
|
|
|
33814
35612
|
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`);
|
|
33815
35613
|
if (o.secretsFile) {
|
|
33816
35614
|
try {
|
|
33817
|
-
vars.push(`secrets=${(0,
|
|
35615
|
+
vars.push(`secrets=${(0, import_node_fs41.readFileSync)(o.secretsFile, "utf8")}`);
|
|
33818
35616
|
} catch (e) {
|
|
33819
35617
|
return fail(`org project set: cannot read --secrets-file ${o.secretsFile}: ${e.message}`);
|
|
33820
35618
|
}
|
|
@@ -34568,11 +36366,11 @@ pr.command("view <number>").description("read a PR as structured JSON (merged st
|
|
|
34568
36366
|
}
|
|
34569
36367
|
});
|
|
34570
36368
|
async function listCiWorkflowPaths(cwd = process.cwd()) {
|
|
34571
|
-
const wfDir = (0,
|
|
34572
|
-
if (!(0,
|
|
34573
|
-
return (0,
|
|
36369
|
+
const wfDir = (0, import_node_path39.join)(cwd, ".github", "workflows");
|
|
36370
|
+
if (!(0, import_node_fs41.existsSync)(wfDir)) return [];
|
|
36371
|
+
return (0, import_node_fs41.readdirSync)(wfDir).filter((name) => /\.(ya?ml)$/i.test(name)).filter((name) => {
|
|
34574
36372
|
try {
|
|
34575
|
-
return workflowReportsPrChecks((0,
|
|
36373
|
+
return workflowReportsPrChecks((0, import_node_fs41.readFileSync)((0, import_node_path39.join)(wfDir, name), "utf8"));
|
|
34576
36374
|
} catch {
|
|
34577
36375
|
return true;
|
|
34578
36376
|
}
|
|
@@ -34604,16 +36402,16 @@ function ciAuditDeps() {
|
|
|
34604
36402
|
// gate re-seed step is skipped gracefully rather than failing mid-run.
|
|
34605
36403
|
readSeedFile: (path2) => {
|
|
34606
36404
|
if (!root) return null;
|
|
34607
|
-
const fullPath = (0,
|
|
34608
|
-
return (0,
|
|
36405
|
+
const fullPath = (0, import_node_path39.join)(root, path2);
|
|
36406
|
+
return (0, import_node_fs41.existsSync)(fullPath) ? (0, import_node_fs41.readFileSync)(fullPath, "utf8") : null;
|
|
34609
36407
|
}
|
|
34610
36408
|
};
|
|
34611
36409
|
}
|
|
34612
36410
|
function hubRoot() {
|
|
34613
|
-
const fromPkg = (0,
|
|
36411
|
+
const fromPkg = (0, import_node_path39.join)(__dirname, "..", "..");
|
|
34614
36412
|
const marker = "skills/bootstrap/seeds/manifest.json";
|
|
34615
|
-
if ((0,
|
|
34616
|
-
if ((0,
|
|
36413
|
+
if ((0, import_node_fs41.existsSync)((0, import_node_path39.join)(fromPkg, marker))) return fromPkg;
|
|
36414
|
+
if ((0, import_node_fs41.existsSync)((0, import_node_path39.join)(process.cwd(), marker))) return process.cwd();
|
|
34617
36415
|
return null;
|
|
34618
36416
|
}
|
|
34619
36417
|
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) => {
|
|
@@ -34925,7 +36723,7 @@ jsonParity(pr.command("merge <number>").description("merge a PR (squash by defau
|
|
|
34925
36723
|
localCleanup = await cleanupPrMergeLocalBranch(headRef, {
|
|
34926
36724
|
beforeWorktrees,
|
|
34927
36725
|
startingPath,
|
|
34928
|
-
pathExists: (p) => (0,
|
|
36726
|
+
pathExists: (p) => (0, import_node_fs41.existsSync)(p),
|
|
34929
36727
|
execGit: async (args) => (await execFileP2("git", args, { timeout: GIT_TIMEOUT_MS })).stdout,
|
|
34930
36728
|
teardownWorktreeStage,
|
|
34931
36729
|
deferredStore,
|
|
@@ -35421,12 +37219,12 @@ access.command("audit").description("audit collaborator roles + train-branch pus
|
|
|
35421
37219
|
targets = resolution.targets;
|
|
35422
37220
|
}
|
|
35423
37221
|
const derivedMatrix = registryProjects ? accessMatrixFromProjects(registryProjects) : {};
|
|
35424
|
-
const fileMatrix = (0,
|
|
37222
|
+
const fileMatrix = (0, import_node_fs41.existsSync)("access-matrix.json") ? loadAccessMatrix((0, import_node_fs41.readFileSync)("access-matrix.json", "utf8")) : {};
|
|
35425
37223
|
const matrix = mergeAccessMatrix(fileMatrix, derivedMatrix);
|
|
35426
37224
|
const derivedContracts = registryProjects ? dataAccessContractsFromProjects(registryProjects) : { consumers: {} };
|
|
35427
|
-
const fileContracts = (0,
|
|
37225
|
+
const fileContracts = (0, import_node_fs41.existsSync)("data-access-contracts.json") ? loadDataAccessContracts((0, import_node_fs41.readFileSync)("data-access-contracts.json", "utf8")) : { consumers: {} };
|
|
35428
37226
|
const dataAccess = mergeDataAccessContracts(fileContracts, derivedContracts);
|
|
35429
|
-
const sanctioned = (0,
|
|
37227
|
+
const sanctioned = (0, import_node_fs41.existsSync)("access-matrix.json") ? loadSanctionedAdmins((0, import_node_fs41.readFileSync)("access-matrix.json", "utf8")) : {};
|
|
35430
37228
|
const report = await auditOrgAccess(targets, deps, matrix, dataAccess, sanctioned);
|
|
35431
37229
|
console.log(o.json ? JSON.stringify(report, null, 2) : renderAccessReport(report));
|
|
35432
37230
|
if (!report.ok) process.exitCode = 1;
|
|
@@ -35458,16 +37256,16 @@ function directoryBytes(path2) {
|
|
|
35458
37256
|
let total = 0;
|
|
35459
37257
|
let entries;
|
|
35460
37258
|
try {
|
|
35461
|
-
entries = (0,
|
|
37259
|
+
entries = (0, import_node_fs41.readdirSync)(path2, { withFileTypes: true });
|
|
35462
37260
|
} catch {
|
|
35463
37261
|
return 0;
|
|
35464
37262
|
}
|
|
35465
37263
|
for (const entry of entries) {
|
|
35466
|
-
const child2 = (0,
|
|
37264
|
+
const child2 = (0, import_node_path39.join)(path2, entry.name);
|
|
35467
37265
|
if (entry.isDirectory()) total += directoryBytes(child2);
|
|
35468
37266
|
else {
|
|
35469
37267
|
try {
|
|
35470
|
-
total += (0,
|
|
37268
|
+
total += (0, import_node_fs41.statSync)(child2).size;
|
|
35471
37269
|
} catch {
|
|
35472
37270
|
}
|
|
35473
37271
|
}
|
|
@@ -35475,25 +37273,25 @@ function directoryBytes(path2) {
|
|
|
35475
37273
|
return total;
|
|
35476
37274
|
}
|
|
35477
37275
|
function listDirEntries(dir) {
|
|
35478
|
-
return (0,
|
|
37276
|
+
return (0, import_node_fs41.readdirSync)(dir, { withFileTypes: true }).map((d) => ({ name: d.name, isDirectory: d.isDirectory() }));
|
|
35479
37277
|
}
|
|
35480
37278
|
function readInstalledPluginRefs(configRoot) {
|
|
35481
37279
|
const p = installedPluginsPathForConfig(configRoot);
|
|
35482
|
-
if (!(0,
|
|
37280
|
+
if (!(0, import_node_fs41.existsSync)(p)) return [];
|
|
35483
37281
|
try {
|
|
35484
|
-
return installedPluginPaths((0,
|
|
37282
|
+
return installedPluginPaths((0, import_node_fs41.readFileSync)(p, "utf8"));
|
|
35485
37283
|
} catch {
|
|
35486
37284
|
return null;
|
|
35487
37285
|
}
|
|
35488
37286
|
}
|
|
35489
37287
|
function pluginCacheFsDeps(configRoot, dirBytes) {
|
|
35490
37288
|
return {
|
|
35491
|
-
exists: (p) => (0,
|
|
35492
|
-
listVersionDirs: (root) => (0,
|
|
37289
|
+
exists: (p) => (0, import_node_fs41.existsSync)(p),
|
|
37290
|
+
listVersionDirs: (root) => (0, import_node_fs41.readdirSync)(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name),
|
|
35493
37291
|
dirBytes,
|
|
35494
|
-
listStagingDirs: (root) => (0,
|
|
37292
|
+
listStagingDirs: (root) => (0, import_node_fs41.readdirSync)(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => {
|
|
35495
37293
|
try {
|
|
35496
|
-
return { name: d.name, mtimeMs: newestMtimeMs((0,
|
|
37294
|
+
return { name: d.name, mtimeMs: newestMtimeMs((0, import_node_path39.join)(root, d.name), listDirEntries, (p) => (0, import_node_fs41.statSync)(p).mtimeMs) };
|
|
35497
37295
|
} catch {
|
|
35498
37296
|
return { name: d.name, mtimeMs: Date.now() };
|
|
35499
37297
|
}
|
|
@@ -35507,10 +37305,10 @@ function stagingApplyFsGuard(configRoot) {
|
|
|
35507
37305
|
return {
|
|
35508
37306
|
referencedPaths: () => readInstalledPluginRefs(configRoot),
|
|
35509
37307
|
mtimeMs: (name) => {
|
|
35510
|
-
const p = (0,
|
|
35511
|
-
if (!(0,
|
|
37308
|
+
const p = (0, import_node_path39.join)(stagingRoot, name);
|
|
37309
|
+
if (!(0, import_node_fs41.existsSync)(p)) return null;
|
|
35512
37310
|
try {
|
|
35513
|
-
return newestMtimeMs(p, listDirEntries, (q) => (0,
|
|
37311
|
+
return newestMtimeMs(p, listDirEntries, (q) => (0, import_node_fs41.statSync)(q).mtimeMs);
|
|
35514
37312
|
} catch {
|
|
35515
37313
|
return null;
|
|
35516
37314
|
}
|
|
@@ -35530,18 +37328,61 @@ program2.command("plugin-prune").description(`prune stale cached MMI plugin vers
|
|
|
35530
37328
|
return;
|
|
35531
37329
|
}
|
|
35532
37330
|
const plan = buildPluginCachePlan(
|
|
35533
|
-
(0,
|
|
37331
|
+
(0, import_node_os16.homedir)(),
|
|
35534
37332
|
running,
|
|
35535
37333
|
pluginCacheFsDeps(configRoot, directoryBytes),
|
|
35536
37334
|
{ withBytes: true, configRoot, includeStaging: surface !== "codex" }
|
|
35537
37335
|
);
|
|
35538
37336
|
const anythingToDelete = plan.prune.length > 0 || plan.staging.length > 0;
|
|
35539
|
-
const result = o.apply && anythingToDelete ? applyPluginCachePlan(plan, (p) => (0,
|
|
37337
|
+
const result = o.apply && anythingToDelete ? applyPluginCachePlan(plan, (p) => (0, import_node_fs41.rmSync)(p, { recursive: true, force: true }), stagingApplyFsGuard(configRoot)) : void 0;
|
|
35540
37338
|
const warnings = plan.prune.length > 0 ? [CONCURRENT_SESSION_WARNING] : [];
|
|
35541
37339
|
if (o.json) console.log(JSON.stringify({ ...plan, warnings, applied: result ?? null }));
|
|
35542
37340
|
else console.log(renderPluginCachePlan(plan, result));
|
|
35543
37341
|
if (result?.failed.length || result?.failedStaging.length) process.exitCode = 1;
|
|
35544
37342
|
});
|
|
37343
|
+
function readReleaseCatchupState(path2) {
|
|
37344
|
+
try {
|
|
37345
|
+
const parsed = JSON.parse((0, import_node_fs41.readFileSync)(path2, "utf8"));
|
|
37346
|
+
return typeof parsed?.checkedAt === "number" ? parsed : void 0;
|
|
37347
|
+
} catch {
|
|
37348
|
+
return void 0;
|
|
37349
|
+
}
|
|
37350
|
+
}
|
|
37351
|
+
function writeReleaseCatchupState(path2, state) {
|
|
37352
|
+
try {
|
|
37353
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path39.dirname)(path2), { recursive: true });
|
|
37354
|
+
(0, import_node_fs41.writeFileSync)(path2, `${JSON.stringify(state)}
|
|
37355
|
+
`);
|
|
37356
|
+
} catch {
|
|
37357
|
+
}
|
|
37358
|
+
}
|
|
37359
|
+
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) => {
|
|
37360
|
+
const outcome = await withEnvHealLock(
|
|
37361
|
+
"plugin release catch-up",
|
|
37362
|
+
() => runReleaseCatchup((0, import_node_os16.homedir)(), process.env, {
|
|
37363
|
+
fetchReleased: fetchNpmReleasedVersion,
|
|
37364
|
+
runClaude: (args, step) => runPluginCli("claude", args, (msg) => {
|
|
37365
|
+
if (!o.quiet && !o.json) console.log(msg);
|
|
37366
|
+
void step;
|
|
37367
|
+
}),
|
|
37368
|
+
runGit: async (args, step) => {
|
|
37369
|
+
try {
|
|
37370
|
+
await runHostBinLogged("git", args, { timeout: 6e4, step });
|
|
37371
|
+
return true;
|
|
37372
|
+
} catch {
|
|
37373
|
+
return false;
|
|
37374
|
+
}
|
|
37375
|
+
},
|
|
37376
|
+
readState: readReleaseCatchupState,
|
|
37377
|
+
writeState: writeReleaseCatchupState,
|
|
37378
|
+
healRegistration: defaultRegistrationHeal((0, import_node_os16.homedir)(), process.env),
|
|
37379
|
+
now: () => Date.now()
|
|
37380
|
+
}, { force: o.force })
|
|
37381
|
+
);
|
|
37382
|
+
if (o.json) console.log(JSON.stringify(outcome));
|
|
37383
|
+
else if (!o.quiet || !outcome.ok) console.log(`${outcome.ok ? "\u2713" : "\u2717"} plugin release catch-up \u2014 ${outcome.detail}`);
|
|
37384
|
+
if (!outcome.ok && !outcome.skipped) process.exitCode = 1;
|
|
37385
|
+
});
|
|
35545
37386
|
program2.command("session-start").description("run the SessionStart verbs (whoami, board slice, doctor) in one process").action(async () => {
|
|
35546
37387
|
if (isInsideRepoSubdir(process.cwd())) {
|
|
35547
37388
|
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.");
|
|
@@ -35602,6 +37443,9 @@ program2.command("session-start").description("run the SessionStart verbs (whoam
|
|
|
35602
37443
|
spawnDetachedSelf(["worktree", "setup", "--quiet"], { spawn: import_node_child_process19.spawn, execPath: process.execPath, scriptPath: process.argv[1] });
|
|
35603
37444
|
bannerIo.log(worktreeBanner);
|
|
35604
37445
|
}
|
|
37446
|
+
if (shouldSpawnReleaseCatchup((0, import_node_os16.homedir)(), process.env, readReleaseCatchupState)) {
|
|
37447
|
+
spawnDetachedSelf(["plugin", "release-catchup", "--quiet"], { spawn: import_node_child_process19.spawn, execPath: process.execPath, scriptPath: process.argv[1] });
|
|
37448
|
+
}
|
|
35605
37449
|
if (isLinkedWorktree(process.cwd())) {
|
|
35606
37450
|
const primaryRoot = await primaryCheckoutRoot(process.cwd());
|
|
35607
37451
|
if (primaryRoot) touchWorktreeOwner(primaryRoot, process.cwd());
|