canopycms-cdk 0.8.0 → 0.8.2
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/lambda/asset-transform/dist/node_modules/.package-lock.json +6 -6
- package/lambda/asset-transform/dist/node_modules/semver/classes/range.js +2 -2
- package/lambda/asset-transform/dist/node_modules/semver/internal/constants.js +30 -0
- package/lambda/asset-transform/dist/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
- package/lambda/asset-transform/dist/node_modules/semver/package.json +1 -1
- package/lambda/asset-transform/dist/node_modules/tslib/README.md +3 -8
- package/lambda/asset-transform/dist/node_modules/tslib/package.json +1 -1
- package/lambda/asset-transform/dist/node_modules/tslib/tslib.d.ts +4 -2
- package/lambda/asset-transform/dist/node_modules/tslib/tslib.es6.js +10 -1
- package/lambda/asset-transform/dist/node_modules/tslib/tslib.es6.mjs +10 -1
- package/lambda/asset-transform/dist/node_modules/tslib/tslib.js +10 -1
- package/package.json +4 -4
- package/worker/dist/index.js +1549 -639
- package/worker/dist/index.js.sha256 +1 -1
package/worker/dist/index.js
CHANGED
|
@@ -67,54 +67,54 @@ var require_polyfills = __commonJS({
|
|
|
67
67
|
}
|
|
68
68
|
var chdir;
|
|
69
69
|
module.exports = patch;
|
|
70
|
-
function patch(
|
|
70
|
+
function patch(fs34) {
|
|
71
71
|
if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
72
|
-
patchLchmod(
|
|
73
|
-
}
|
|
74
|
-
if (!
|
|
75
|
-
patchLutimes(
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
|
|
72
|
+
patchLchmod(fs34);
|
|
73
|
+
}
|
|
74
|
+
if (!fs34.lutimes) {
|
|
75
|
+
patchLutimes(fs34);
|
|
76
|
+
}
|
|
77
|
+
fs34.chown = chownFix(fs34.chown);
|
|
78
|
+
fs34.fchown = chownFix(fs34.fchown);
|
|
79
|
+
fs34.lchown = chownFix(fs34.lchown);
|
|
80
|
+
fs34.chmod = chmodFix(fs34.chmod);
|
|
81
|
+
fs34.fchmod = chmodFix(fs34.fchmod);
|
|
82
|
+
fs34.lchmod = chmodFix(fs34.lchmod);
|
|
83
|
+
fs34.chownSync = chownFixSync(fs34.chownSync);
|
|
84
|
+
fs34.fchownSync = chownFixSync(fs34.fchownSync);
|
|
85
|
+
fs34.lchownSync = chownFixSync(fs34.lchownSync);
|
|
86
|
+
fs34.chmodSync = chmodFixSync(fs34.chmodSync);
|
|
87
|
+
fs34.fchmodSync = chmodFixSync(fs34.fchmodSync);
|
|
88
|
+
fs34.lchmodSync = chmodFixSync(fs34.lchmodSync);
|
|
89
|
+
fs34.stat = statFix(fs34.stat);
|
|
90
|
+
fs34.fstat = statFix(fs34.fstat);
|
|
91
|
+
fs34.lstat = statFix(fs34.lstat);
|
|
92
|
+
fs34.statSync = statFixSync(fs34.statSync);
|
|
93
|
+
fs34.fstatSync = statFixSync(fs34.fstatSync);
|
|
94
|
+
fs34.lstatSync = statFixSync(fs34.lstatSync);
|
|
95
|
+
if (fs34.chmod && !fs34.lchmod) {
|
|
96
|
+
fs34.lchmod = function(path37, mode, cb) {
|
|
97
97
|
if (cb) process.nextTick(cb);
|
|
98
98
|
};
|
|
99
|
-
|
|
99
|
+
fs34.lchmodSync = function() {
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
if (
|
|
103
|
-
|
|
102
|
+
if (fs34.chown && !fs34.lchown) {
|
|
103
|
+
fs34.lchown = function(path37, uid, gid, cb) {
|
|
104
104
|
if (cb) process.nextTick(cb);
|
|
105
105
|
};
|
|
106
|
-
|
|
106
|
+
fs34.lchownSync = function() {
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
if (platform2 === "win32") {
|
|
110
|
-
|
|
110
|
+
fs34.rename = typeof fs34.rename !== "function" ? fs34.rename : (function(fs$rename) {
|
|
111
111
|
function rename(from, to, cb) {
|
|
112
112
|
var start = Date.now();
|
|
113
113
|
var backoff = 0;
|
|
114
114
|
fs$rename(from, to, function CB(er) {
|
|
115
115
|
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
116
116
|
setTimeout(function() {
|
|
117
|
-
|
|
117
|
+
fs34.stat(to, function(stater, st) {
|
|
118
118
|
if (stater && stater.code === "ENOENT")
|
|
119
119
|
fs$rename(from, to, CB);
|
|
120
120
|
else
|
|
@@ -130,9 +130,9 @@ var require_polyfills = __commonJS({
|
|
|
130
130
|
}
|
|
131
131
|
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
|
|
132
132
|
return rename;
|
|
133
|
-
})(
|
|
133
|
+
})(fs34.rename);
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
fs34.read = typeof fs34.read !== "function" ? fs34.read : (function(fs$read) {
|
|
136
136
|
function read(fd, buffer, offset, length, position, callback_) {
|
|
137
137
|
var callback;
|
|
138
138
|
if (callback_ && typeof callback_ === "function") {
|
|
@@ -140,22 +140,22 @@ var require_polyfills = __commonJS({
|
|
|
140
140
|
callback = function(er, _3, __) {
|
|
141
141
|
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
142
142
|
eagCounter++;
|
|
143
|
-
return fs$read.call(
|
|
143
|
+
return fs$read.call(fs34, fd, buffer, offset, length, position, callback);
|
|
144
144
|
}
|
|
145
145
|
callback_.apply(this, arguments);
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
-
return fs$read.call(
|
|
148
|
+
return fs$read.call(fs34, fd, buffer, offset, length, position, callback);
|
|
149
149
|
}
|
|
150
150
|
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
151
151
|
return read;
|
|
152
|
-
})(
|
|
153
|
-
|
|
152
|
+
})(fs34.read);
|
|
153
|
+
fs34.readSync = typeof fs34.readSync !== "function" ? fs34.readSync : /* @__PURE__ */ (function(fs$readSync) {
|
|
154
154
|
return function(fd, buffer, offset, length, position) {
|
|
155
155
|
var eagCounter = 0;
|
|
156
156
|
while (true) {
|
|
157
157
|
try {
|
|
158
|
-
return fs$readSync.call(
|
|
158
|
+
return fs$readSync.call(fs34, fd, buffer, offset, length, position);
|
|
159
159
|
} catch (er) {
|
|
160
160
|
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
161
161
|
eagCounter++;
|
|
@@ -165,11 +165,11 @@ var require_polyfills = __commonJS({
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
|
-
})(
|
|
169
|
-
function patchLchmod(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
})(fs34.readSync);
|
|
169
|
+
function patchLchmod(fs35) {
|
|
170
|
+
fs35.lchmod = function(path37, mode, callback) {
|
|
171
|
+
fs35.open(
|
|
172
|
+
path37,
|
|
173
173
|
constants2.O_WRONLY | constants2.O_SYMLINK,
|
|
174
174
|
mode,
|
|
175
175
|
function(err, fd) {
|
|
@@ -177,80 +177,80 @@ var require_polyfills = __commonJS({
|
|
|
177
177
|
if (callback) callback(err);
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
fs35.fchmod(fd, mode, function(err2) {
|
|
181
|
+
fs35.close(fd, function(err22) {
|
|
182
182
|
if (callback) callback(err2 || err22);
|
|
183
183
|
});
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
);
|
|
187
187
|
};
|
|
188
|
-
|
|
189
|
-
var fd =
|
|
188
|
+
fs35.lchmodSync = function(path37, mode) {
|
|
189
|
+
var fd = fs35.openSync(path37, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
|
|
190
190
|
var threw = true;
|
|
191
191
|
var ret;
|
|
192
192
|
try {
|
|
193
|
-
ret =
|
|
193
|
+
ret = fs35.fchmodSync(fd, mode);
|
|
194
194
|
threw = false;
|
|
195
195
|
} finally {
|
|
196
196
|
if (threw) {
|
|
197
197
|
try {
|
|
198
|
-
|
|
198
|
+
fs35.closeSync(fd);
|
|
199
199
|
} catch (er) {
|
|
200
200
|
}
|
|
201
201
|
} else {
|
|
202
|
-
|
|
202
|
+
fs35.closeSync(fd);
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
return ret;
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
|
-
function patchLutimes(
|
|
209
|
-
if (constants2.hasOwnProperty("O_SYMLINK") &&
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
function patchLutimes(fs35) {
|
|
209
|
+
if (constants2.hasOwnProperty("O_SYMLINK") && fs35.futimes) {
|
|
210
|
+
fs35.lutimes = function(path37, at, mt, cb) {
|
|
211
|
+
fs35.open(path37, constants2.O_SYMLINK, function(er, fd) {
|
|
212
212
|
if (er) {
|
|
213
213
|
if (cb) cb(er);
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
fs35.futimes(fd, at, mt, function(er2) {
|
|
217
|
+
fs35.close(fd, function(er22) {
|
|
218
218
|
if (cb) cb(er2 || er22);
|
|
219
219
|
});
|
|
220
220
|
});
|
|
221
221
|
});
|
|
222
222
|
};
|
|
223
|
-
|
|
224
|
-
var fd =
|
|
223
|
+
fs35.lutimesSync = function(path37, at, mt) {
|
|
224
|
+
var fd = fs35.openSync(path37, constants2.O_SYMLINK);
|
|
225
225
|
var ret;
|
|
226
226
|
var threw = true;
|
|
227
227
|
try {
|
|
228
|
-
ret =
|
|
228
|
+
ret = fs35.futimesSync(fd, at, mt);
|
|
229
229
|
threw = false;
|
|
230
230
|
} finally {
|
|
231
231
|
if (threw) {
|
|
232
232
|
try {
|
|
233
|
-
|
|
233
|
+
fs35.closeSync(fd);
|
|
234
234
|
} catch (er) {
|
|
235
235
|
}
|
|
236
236
|
} else {
|
|
237
|
-
|
|
237
|
+
fs35.closeSync(fd);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
return ret;
|
|
241
241
|
};
|
|
242
|
-
} else if (
|
|
243
|
-
|
|
242
|
+
} else if (fs35.futimes) {
|
|
243
|
+
fs35.lutimes = function(_a4, _b, _c9, cb) {
|
|
244
244
|
if (cb) process.nextTick(cb);
|
|
245
245
|
};
|
|
246
|
-
|
|
246
|
+
fs35.lutimesSync = function() {
|
|
247
247
|
};
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
function chmodFix(orig) {
|
|
251
251
|
if (!orig) return orig;
|
|
252
252
|
return function(target, mode, cb) {
|
|
253
|
-
return orig.call(
|
|
253
|
+
return orig.call(fs34, target, mode, function(er) {
|
|
254
254
|
if (chownErOk(er)) er = null;
|
|
255
255
|
if (cb) cb.apply(this, arguments);
|
|
256
256
|
});
|
|
@@ -260,7 +260,7 @@ var require_polyfills = __commonJS({
|
|
|
260
260
|
if (!orig) return orig;
|
|
261
261
|
return function(target, mode) {
|
|
262
262
|
try {
|
|
263
|
-
return orig.call(
|
|
263
|
+
return orig.call(fs34, target, mode);
|
|
264
264
|
} catch (er) {
|
|
265
265
|
if (!chownErOk(er)) throw er;
|
|
266
266
|
}
|
|
@@ -269,7 +269,7 @@ var require_polyfills = __commonJS({
|
|
|
269
269
|
function chownFix(orig) {
|
|
270
270
|
if (!orig) return orig;
|
|
271
271
|
return function(target, uid, gid, cb) {
|
|
272
|
-
return orig.call(
|
|
272
|
+
return orig.call(fs34, target, uid, gid, function(er) {
|
|
273
273
|
if (chownErOk(er)) er = null;
|
|
274
274
|
if (cb) cb.apply(this, arguments);
|
|
275
275
|
});
|
|
@@ -279,7 +279,7 @@ var require_polyfills = __commonJS({
|
|
|
279
279
|
if (!orig) return orig;
|
|
280
280
|
return function(target, uid, gid) {
|
|
281
281
|
try {
|
|
282
|
-
return orig.call(
|
|
282
|
+
return orig.call(fs34, target, uid, gid);
|
|
283
283
|
} catch (er) {
|
|
284
284
|
if (!chownErOk(er)) throw er;
|
|
285
285
|
}
|
|
@@ -299,13 +299,13 @@ var require_polyfills = __commonJS({
|
|
|
299
299
|
}
|
|
300
300
|
if (cb) cb.apply(this, arguments);
|
|
301
301
|
}
|
|
302
|
-
return options ? orig.call(
|
|
302
|
+
return options ? orig.call(fs34, target, options, callback) : orig.call(fs34, target, callback);
|
|
303
303
|
};
|
|
304
304
|
}
|
|
305
305
|
function statFixSync(orig) {
|
|
306
306
|
if (!orig) return orig;
|
|
307
307
|
return function(target, options) {
|
|
308
|
-
var stats = options ? orig.call(
|
|
308
|
+
var stats = options ? orig.call(fs34, target, options) : orig.call(fs34, target);
|
|
309
309
|
if (stats) {
|
|
310
310
|
if (stats.uid < 0) stats.uid += 4294967296;
|
|
311
311
|
if (stats.gid < 0) stats.gid += 4294967296;
|
|
@@ -334,16 +334,16 @@ var require_legacy_streams = __commonJS({
|
|
|
334
334
|
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js"(exports, module) {
|
|
335
335
|
var Stream = __require("stream").Stream;
|
|
336
336
|
module.exports = legacy;
|
|
337
|
-
function legacy(
|
|
337
|
+
function legacy(fs34) {
|
|
338
338
|
return {
|
|
339
339
|
ReadStream: ReadStream2,
|
|
340
340
|
WriteStream
|
|
341
341
|
};
|
|
342
|
-
function ReadStream2(
|
|
343
|
-
if (!(this instanceof ReadStream2)) return new ReadStream2(
|
|
342
|
+
function ReadStream2(path37, options) {
|
|
343
|
+
if (!(this instanceof ReadStream2)) return new ReadStream2(path37, options);
|
|
344
344
|
Stream.call(this);
|
|
345
345
|
var self2 = this;
|
|
346
|
-
this.path =
|
|
346
|
+
this.path = path37;
|
|
347
347
|
this.fd = null;
|
|
348
348
|
this.readable = true;
|
|
349
349
|
this.paused = false;
|
|
@@ -377,7 +377,7 @@ var require_legacy_streams = __commonJS({
|
|
|
377
377
|
});
|
|
378
378
|
return;
|
|
379
379
|
}
|
|
380
|
-
|
|
380
|
+
fs34.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
381
381
|
if (err) {
|
|
382
382
|
self2.emit("error", err);
|
|
383
383
|
self2.readable = false;
|
|
@@ -388,10 +388,10 @@ var require_legacy_streams = __commonJS({
|
|
|
388
388
|
self2._read();
|
|
389
389
|
});
|
|
390
390
|
}
|
|
391
|
-
function WriteStream(
|
|
392
|
-
if (!(this instanceof WriteStream)) return new WriteStream(
|
|
391
|
+
function WriteStream(path37, options) {
|
|
392
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path37, options);
|
|
393
393
|
Stream.call(this);
|
|
394
|
-
this.path =
|
|
394
|
+
this.path = path37;
|
|
395
395
|
this.fd = null;
|
|
396
396
|
this.writable = true;
|
|
397
397
|
this.flags = "w";
|
|
@@ -416,7 +416,7 @@ var require_legacy_streams = __commonJS({
|
|
|
416
416
|
this.busy = false;
|
|
417
417
|
this._queue = [];
|
|
418
418
|
if (this.fd === null) {
|
|
419
|
-
this._open =
|
|
419
|
+
this._open = fs34.open;
|
|
420
420
|
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
421
421
|
this.flush();
|
|
422
422
|
}
|
|
@@ -451,7 +451,7 @@ var require_clone = __commonJS({
|
|
|
451
451
|
// ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
|
|
452
452
|
var require_graceful_fs = __commonJS({
|
|
453
453
|
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports, module) {
|
|
454
|
-
var
|
|
454
|
+
var fs34 = __require("fs");
|
|
455
455
|
var polyfills = require_polyfills();
|
|
456
456
|
var legacy = require_legacy_streams();
|
|
457
457
|
var clone = require_clone();
|
|
@@ -483,12 +483,12 @@ var require_graceful_fs = __commonJS({
|
|
|
483
483
|
m7 = "GFS4: " + m7.split(/\n/).join("\nGFS4: ");
|
|
484
484
|
console.error(m7);
|
|
485
485
|
};
|
|
486
|
-
if (!
|
|
486
|
+
if (!fs34[gracefulQueue]) {
|
|
487
487
|
queue = global[gracefulQueue] || [];
|
|
488
|
-
publishQueue(
|
|
489
|
-
|
|
488
|
+
publishQueue(fs34, queue);
|
|
489
|
+
fs34.close = (function(fs$close) {
|
|
490
490
|
function close(fd, cb) {
|
|
491
|
-
return fs$close.call(
|
|
491
|
+
return fs$close.call(fs34, fd, function(err) {
|
|
492
492
|
if (!err) {
|
|
493
493
|
resetQueue();
|
|
494
494
|
}
|
|
@@ -500,48 +500,48 @@ var require_graceful_fs = __commonJS({
|
|
|
500
500
|
value: fs$close
|
|
501
501
|
});
|
|
502
502
|
return close;
|
|
503
|
-
})(
|
|
504
|
-
|
|
503
|
+
})(fs34.close);
|
|
504
|
+
fs34.closeSync = (function(fs$closeSync) {
|
|
505
505
|
function closeSync(fd) {
|
|
506
|
-
fs$closeSync.apply(
|
|
506
|
+
fs$closeSync.apply(fs34, arguments);
|
|
507
507
|
resetQueue();
|
|
508
508
|
}
|
|
509
509
|
Object.defineProperty(closeSync, previousSymbol, {
|
|
510
510
|
value: fs$closeSync
|
|
511
511
|
});
|
|
512
512
|
return closeSync;
|
|
513
|
-
})(
|
|
513
|
+
})(fs34.closeSync);
|
|
514
514
|
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
515
515
|
process.on("exit", function() {
|
|
516
|
-
debug2(
|
|
517
|
-
__require("assert").equal(
|
|
516
|
+
debug2(fs34[gracefulQueue]);
|
|
517
|
+
__require("assert").equal(fs34[gracefulQueue].length, 0);
|
|
518
518
|
});
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
521
|
var queue;
|
|
522
522
|
if (!global[gracefulQueue]) {
|
|
523
|
-
publishQueue(global,
|
|
524
|
-
}
|
|
525
|
-
module.exports = patch(clone(
|
|
526
|
-
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !
|
|
527
|
-
module.exports = patch(
|
|
528
|
-
|
|
529
|
-
}
|
|
530
|
-
function patch(
|
|
531
|
-
polyfills(
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
var fs$readFile =
|
|
536
|
-
|
|
537
|
-
function readFile3(
|
|
523
|
+
publishQueue(global, fs34[gracefulQueue]);
|
|
524
|
+
}
|
|
525
|
+
module.exports = patch(clone(fs34));
|
|
526
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs34.__patched) {
|
|
527
|
+
module.exports = patch(fs34);
|
|
528
|
+
fs34.__patched = true;
|
|
529
|
+
}
|
|
530
|
+
function patch(fs35) {
|
|
531
|
+
polyfills(fs35);
|
|
532
|
+
fs35.gracefulify = patch;
|
|
533
|
+
fs35.createReadStream = createReadStream;
|
|
534
|
+
fs35.createWriteStream = createWriteStream;
|
|
535
|
+
var fs$readFile = fs35.readFile;
|
|
536
|
+
fs35.readFile = readFile3;
|
|
537
|
+
function readFile3(path37, options, cb) {
|
|
538
538
|
if (typeof options === "function")
|
|
539
539
|
cb = options, options = null;
|
|
540
|
-
return go$readFile(
|
|
541
|
-
function go$readFile(
|
|
542
|
-
return fs$readFile(
|
|
540
|
+
return go$readFile(path37, options, cb);
|
|
541
|
+
function go$readFile(path38, options2, cb2, startTime) {
|
|
542
|
+
return fs$readFile(path38, options2, function(err) {
|
|
543
543
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
544
|
-
enqueue([go$readFile, [
|
|
544
|
+
enqueue([go$readFile, [path38, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
545
545
|
else {
|
|
546
546
|
if (typeof cb2 === "function")
|
|
547
547
|
cb2.apply(this, arguments);
|
|
@@ -549,16 +549,16 @@ var require_graceful_fs = __commonJS({
|
|
|
549
549
|
});
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
-
var fs$writeFile =
|
|
553
|
-
|
|
554
|
-
function writeFile(
|
|
552
|
+
var fs$writeFile = fs35.writeFile;
|
|
553
|
+
fs35.writeFile = writeFile;
|
|
554
|
+
function writeFile(path37, data3, options, cb) {
|
|
555
555
|
if (typeof options === "function")
|
|
556
556
|
cb = options, options = null;
|
|
557
|
-
return go$writeFile(
|
|
558
|
-
function go$writeFile(
|
|
559
|
-
return fs$writeFile(
|
|
557
|
+
return go$writeFile(path37, data3, options, cb);
|
|
558
|
+
function go$writeFile(path38, data4, options2, cb2, startTime) {
|
|
559
|
+
return fs$writeFile(path38, data4, options2, function(err) {
|
|
560
560
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
561
|
-
enqueue([go$writeFile, [
|
|
561
|
+
enqueue([go$writeFile, [path38, data4, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
562
562
|
else {
|
|
563
563
|
if (typeof cb2 === "function")
|
|
564
564
|
cb2.apply(this, arguments);
|
|
@@ -566,17 +566,17 @@ var require_graceful_fs = __commonJS({
|
|
|
566
566
|
});
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
|
-
var fs$appendFile =
|
|
569
|
+
var fs$appendFile = fs35.appendFile;
|
|
570
570
|
if (fs$appendFile)
|
|
571
|
-
|
|
572
|
-
function appendFile(
|
|
571
|
+
fs35.appendFile = appendFile;
|
|
572
|
+
function appendFile(path37, data3, options, cb) {
|
|
573
573
|
if (typeof options === "function")
|
|
574
574
|
cb = options, options = null;
|
|
575
|
-
return go$appendFile(
|
|
576
|
-
function go$appendFile(
|
|
577
|
-
return fs$appendFile(
|
|
575
|
+
return go$appendFile(path37, data3, options, cb);
|
|
576
|
+
function go$appendFile(path38, data4, options2, cb2, startTime) {
|
|
577
|
+
return fs$appendFile(path38, data4, options2, function(err) {
|
|
578
578
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
579
|
-
enqueue([go$appendFile, [
|
|
579
|
+
enqueue([go$appendFile, [path38, data4, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
580
580
|
else {
|
|
581
581
|
if (typeof cb2 === "function")
|
|
582
582
|
cb2.apply(this, arguments);
|
|
@@ -584,9 +584,9 @@ var require_graceful_fs = __commonJS({
|
|
|
584
584
|
});
|
|
585
585
|
}
|
|
586
586
|
}
|
|
587
|
-
var fs$copyFile =
|
|
587
|
+
var fs$copyFile = fs35.copyFile;
|
|
588
588
|
if (fs$copyFile)
|
|
589
|
-
|
|
589
|
+
fs35.copyFile = copyFile;
|
|
590
590
|
function copyFile(src, dest, flags, cb) {
|
|
591
591
|
if (typeof flags === "function") {
|
|
592
592
|
cb = flags;
|
|
@@ -604,34 +604,34 @@ var require_graceful_fs = __commonJS({
|
|
|
604
604
|
});
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
|
-
var fs$readdir =
|
|
608
|
-
|
|
607
|
+
var fs$readdir = fs35.readdir;
|
|
608
|
+
fs35.readdir = readdir;
|
|
609
609
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
610
|
-
function readdir(
|
|
610
|
+
function readdir(path37, options, cb) {
|
|
611
611
|
if (typeof options === "function")
|
|
612
612
|
cb = options, options = null;
|
|
613
|
-
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(
|
|
614
|
-
return fs$readdir(
|
|
615
|
-
|
|
613
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path38, options2, cb2, startTime) {
|
|
614
|
+
return fs$readdir(path38, fs$readdirCallback(
|
|
615
|
+
path38,
|
|
616
616
|
options2,
|
|
617
617
|
cb2,
|
|
618
618
|
startTime
|
|
619
619
|
));
|
|
620
|
-
} : function go$readdir2(
|
|
621
|
-
return fs$readdir(
|
|
622
|
-
|
|
620
|
+
} : function go$readdir2(path38, options2, cb2, startTime) {
|
|
621
|
+
return fs$readdir(path38, options2, fs$readdirCallback(
|
|
622
|
+
path38,
|
|
623
623
|
options2,
|
|
624
624
|
cb2,
|
|
625
625
|
startTime
|
|
626
626
|
));
|
|
627
627
|
};
|
|
628
|
-
return go$readdir(
|
|
629
|
-
function fs$readdirCallback(
|
|
628
|
+
return go$readdir(path37, options, cb);
|
|
629
|
+
function fs$readdirCallback(path38, options2, cb2, startTime) {
|
|
630
630
|
return function(err, files) {
|
|
631
631
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
632
632
|
enqueue([
|
|
633
633
|
go$readdir,
|
|
634
|
-
[
|
|
634
|
+
[path38, options2, cb2],
|
|
635
635
|
err,
|
|
636
636
|
startTime || Date.now(),
|
|
637
637
|
Date.now()
|
|
@@ -646,21 +646,21 @@ var require_graceful_fs = __commonJS({
|
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
if (process.version.substr(0, 4) === "v0.8") {
|
|
649
|
-
var legStreams = legacy(
|
|
649
|
+
var legStreams = legacy(fs35);
|
|
650
650
|
ReadStream2 = legStreams.ReadStream;
|
|
651
651
|
WriteStream = legStreams.WriteStream;
|
|
652
652
|
}
|
|
653
|
-
var fs$ReadStream =
|
|
653
|
+
var fs$ReadStream = fs35.ReadStream;
|
|
654
654
|
if (fs$ReadStream) {
|
|
655
655
|
ReadStream2.prototype = Object.create(fs$ReadStream.prototype);
|
|
656
656
|
ReadStream2.prototype.open = ReadStream$open;
|
|
657
657
|
}
|
|
658
|
-
var fs$WriteStream =
|
|
658
|
+
var fs$WriteStream = fs35.WriteStream;
|
|
659
659
|
if (fs$WriteStream) {
|
|
660
660
|
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
661
661
|
WriteStream.prototype.open = WriteStream$open;
|
|
662
662
|
}
|
|
663
|
-
Object.defineProperty(
|
|
663
|
+
Object.defineProperty(fs35, "ReadStream", {
|
|
664
664
|
get: function() {
|
|
665
665
|
return ReadStream2;
|
|
666
666
|
},
|
|
@@ -670,7 +670,7 @@ var require_graceful_fs = __commonJS({
|
|
|
670
670
|
enumerable: true,
|
|
671
671
|
configurable: true
|
|
672
672
|
});
|
|
673
|
-
Object.defineProperty(
|
|
673
|
+
Object.defineProperty(fs35, "WriteStream", {
|
|
674
674
|
get: function() {
|
|
675
675
|
return WriteStream;
|
|
676
676
|
},
|
|
@@ -681,7 +681,7 @@ var require_graceful_fs = __commonJS({
|
|
|
681
681
|
configurable: true
|
|
682
682
|
});
|
|
683
683
|
var FileReadStream = ReadStream2;
|
|
684
|
-
Object.defineProperty(
|
|
684
|
+
Object.defineProperty(fs35, "FileReadStream", {
|
|
685
685
|
get: function() {
|
|
686
686
|
return FileReadStream;
|
|
687
687
|
},
|
|
@@ -692,7 +692,7 @@ var require_graceful_fs = __commonJS({
|
|
|
692
692
|
configurable: true
|
|
693
693
|
});
|
|
694
694
|
var FileWriteStream = WriteStream;
|
|
695
|
-
Object.defineProperty(
|
|
695
|
+
Object.defineProperty(fs35, "FileWriteStream", {
|
|
696
696
|
get: function() {
|
|
697
697
|
return FileWriteStream;
|
|
698
698
|
},
|
|
@@ -702,7 +702,7 @@ var require_graceful_fs = __commonJS({
|
|
|
702
702
|
enumerable: true,
|
|
703
703
|
configurable: true
|
|
704
704
|
});
|
|
705
|
-
function ReadStream2(
|
|
705
|
+
function ReadStream2(path37, options) {
|
|
706
706
|
if (this instanceof ReadStream2)
|
|
707
707
|
return fs$ReadStream.apply(this, arguments), this;
|
|
708
708
|
else
|
|
@@ -722,7 +722,7 @@ var require_graceful_fs = __commonJS({
|
|
|
722
722
|
}
|
|
723
723
|
});
|
|
724
724
|
}
|
|
725
|
-
function WriteStream(
|
|
725
|
+
function WriteStream(path37, options) {
|
|
726
726
|
if (this instanceof WriteStream)
|
|
727
727
|
return fs$WriteStream.apply(this, arguments), this;
|
|
728
728
|
else
|
|
@@ -740,22 +740,22 @@ var require_graceful_fs = __commonJS({
|
|
|
740
740
|
}
|
|
741
741
|
});
|
|
742
742
|
}
|
|
743
|
-
function createReadStream(
|
|
744
|
-
return new
|
|
743
|
+
function createReadStream(path37, options) {
|
|
744
|
+
return new fs35.ReadStream(path37, options);
|
|
745
745
|
}
|
|
746
|
-
function createWriteStream(
|
|
747
|
-
return new
|
|
746
|
+
function createWriteStream(path37, options) {
|
|
747
|
+
return new fs35.WriteStream(path37, options);
|
|
748
748
|
}
|
|
749
|
-
var fs$open =
|
|
750
|
-
|
|
751
|
-
function open(
|
|
749
|
+
var fs$open = fs35.open;
|
|
750
|
+
fs35.open = open;
|
|
751
|
+
function open(path37, flags, mode, cb) {
|
|
752
752
|
if (typeof mode === "function")
|
|
753
753
|
cb = mode, mode = null;
|
|
754
|
-
return go$open(
|
|
755
|
-
function go$open(
|
|
756
|
-
return fs$open(
|
|
754
|
+
return go$open(path37, flags, mode, cb);
|
|
755
|
+
function go$open(path38, flags2, mode2, cb2, startTime) {
|
|
756
|
+
return fs$open(path38, flags2, mode2, function(err, fd) {
|
|
757
757
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
758
|
-
enqueue([go$open, [
|
|
758
|
+
enqueue([go$open, [path38, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
759
759
|
else {
|
|
760
760
|
if (typeof cb2 === "function")
|
|
761
761
|
cb2.apply(this, arguments);
|
|
@@ -763,20 +763,20 @@ var require_graceful_fs = __commonJS({
|
|
|
763
763
|
});
|
|
764
764
|
}
|
|
765
765
|
}
|
|
766
|
-
return
|
|
766
|
+
return fs35;
|
|
767
767
|
}
|
|
768
768
|
function enqueue(elem) {
|
|
769
769
|
debug2("ENQUEUE", elem[0].name, elem[1]);
|
|
770
|
-
|
|
770
|
+
fs34[gracefulQueue].push(elem);
|
|
771
771
|
retry2();
|
|
772
772
|
}
|
|
773
773
|
var retryTimer;
|
|
774
774
|
function resetQueue() {
|
|
775
775
|
var now = Date.now();
|
|
776
|
-
for (var i10 = 0; i10 <
|
|
777
|
-
if (
|
|
778
|
-
|
|
779
|
-
|
|
776
|
+
for (var i10 = 0; i10 < fs34[gracefulQueue].length; ++i10) {
|
|
777
|
+
if (fs34[gracefulQueue][i10].length > 2) {
|
|
778
|
+
fs34[gracefulQueue][i10][3] = now;
|
|
779
|
+
fs34[gracefulQueue][i10][4] = now;
|
|
780
780
|
}
|
|
781
781
|
}
|
|
782
782
|
retry2();
|
|
@@ -784,9 +784,9 @@ var require_graceful_fs = __commonJS({
|
|
|
784
784
|
function retry2() {
|
|
785
785
|
clearTimeout(retryTimer);
|
|
786
786
|
retryTimer = void 0;
|
|
787
|
-
if (
|
|
787
|
+
if (fs34[gracefulQueue].length === 0)
|
|
788
788
|
return;
|
|
789
|
-
var elem =
|
|
789
|
+
var elem = fs34[gracefulQueue].shift();
|
|
790
790
|
var fn = elem[0];
|
|
791
791
|
var args = elem[1];
|
|
792
792
|
var err = elem[2];
|
|
@@ -808,7 +808,7 @@ var require_graceful_fs = __commonJS({
|
|
|
808
808
|
debug2("RETRY", fn.name, args);
|
|
809
809
|
fn.apply(null, args.concat([startTime]));
|
|
810
810
|
} else {
|
|
811
|
-
|
|
811
|
+
fs34[gracefulQueue].push(elem);
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
814
|
if (retryTimer === void 0) {
|
|
@@ -1243,10 +1243,10 @@ var require_mtime_precision = __commonJS({
|
|
|
1243
1243
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module) {
|
|
1244
1244
|
"use strict";
|
|
1245
1245
|
var cacheSymbol = Symbol();
|
|
1246
|
-
function probe(file,
|
|
1247
|
-
const cachedPrecision =
|
|
1246
|
+
function probe(file, fs34, callback) {
|
|
1247
|
+
const cachedPrecision = fs34[cacheSymbol];
|
|
1248
1248
|
if (cachedPrecision) {
|
|
1249
|
-
return
|
|
1249
|
+
return fs34.stat(file, (err, stat) => {
|
|
1250
1250
|
if (err) {
|
|
1251
1251
|
return callback(err);
|
|
1252
1252
|
}
|
|
@@ -1254,16 +1254,16 @@ var require_mtime_precision = __commonJS({
|
|
|
1254
1254
|
});
|
|
1255
1255
|
}
|
|
1256
1256
|
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1257
|
-
|
|
1257
|
+
fs34.utimes(file, mtime, mtime, (err) => {
|
|
1258
1258
|
if (err) {
|
|
1259
1259
|
return callback(err);
|
|
1260
1260
|
}
|
|
1261
|
-
|
|
1261
|
+
fs34.stat(file, (err2, stat) => {
|
|
1262
1262
|
if (err2) {
|
|
1263
1263
|
return callback(err2);
|
|
1264
1264
|
}
|
|
1265
1265
|
const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1266
|
-
Object.defineProperty(
|
|
1266
|
+
Object.defineProperty(fs34, cacheSymbol, { value: precision });
|
|
1267
1267
|
callback(null, stat.mtime, precision);
|
|
1268
1268
|
});
|
|
1269
1269
|
});
|
|
@@ -1284,8 +1284,8 @@ var require_mtime_precision = __commonJS({
|
|
|
1284
1284
|
var require_lockfile = __commonJS({
|
|
1285
1285
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/lockfile.js"(exports, module) {
|
|
1286
1286
|
"use strict";
|
|
1287
|
-
var
|
|
1288
|
-
var
|
|
1287
|
+
var path37 = __require("path");
|
|
1288
|
+
var fs34 = require_graceful_fs();
|
|
1289
1289
|
var retry2 = require_retry2();
|
|
1290
1290
|
var onExit = require_signal_exit();
|
|
1291
1291
|
var mtimePrecision = require_mtime_precision();
|
|
@@ -1295,7 +1295,7 @@ var require_lockfile = __commonJS({
|
|
|
1295
1295
|
}
|
|
1296
1296
|
function resolveCanonicalPath(file, options, callback) {
|
|
1297
1297
|
if (!options.realpath) {
|
|
1298
|
-
return callback(null,
|
|
1298
|
+
return callback(null, path37.resolve(file));
|
|
1299
1299
|
}
|
|
1300
1300
|
options.fs.realpath(file, callback);
|
|
1301
1301
|
}
|
|
@@ -1416,7 +1416,7 @@ var require_lockfile = __commonJS({
|
|
|
1416
1416
|
update: null,
|
|
1417
1417
|
realpath: true,
|
|
1418
1418
|
retries: 0,
|
|
1419
|
-
fs:
|
|
1419
|
+
fs: fs34,
|
|
1420
1420
|
onCompromised: (err) => {
|
|
1421
1421
|
throw err;
|
|
1422
1422
|
},
|
|
@@ -1460,7 +1460,7 @@ var require_lockfile = __commonJS({
|
|
|
1460
1460
|
}
|
|
1461
1461
|
function unlock(file, options, callback) {
|
|
1462
1462
|
options = {
|
|
1463
|
-
fs:
|
|
1463
|
+
fs: fs34,
|
|
1464
1464
|
realpath: true,
|
|
1465
1465
|
...options
|
|
1466
1466
|
};
|
|
@@ -1482,7 +1482,7 @@ var require_lockfile = __commonJS({
|
|
|
1482
1482
|
options = {
|
|
1483
1483
|
stale: 1e4,
|
|
1484
1484
|
realpath: true,
|
|
1485
|
-
fs:
|
|
1485
|
+
fs: fs34,
|
|
1486
1486
|
...options
|
|
1487
1487
|
};
|
|
1488
1488
|
options.stale = Math.max(options.stale || 0, 2e3);
|
|
@@ -1521,16 +1521,16 @@ var require_lockfile = __commonJS({
|
|
|
1521
1521
|
var require_adapter = __commonJS({
|
|
1522
1522
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/adapter.js"(exports, module) {
|
|
1523
1523
|
"use strict";
|
|
1524
|
-
var
|
|
1525
|
-
function createSyncFs(
|
|
1524
|
+
var fs34 = require_graceful_fs();
|
|
1525
|
+
function createSyncFs(fs35) {
|
|
1526
1526
|
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
1527
|
-
const newFs = { ...
|
|
1527
|
+
const newFs = { ...fs35 };
|
|
1528
1528
|
methods.forEach((method) => {
|
|
1529
1529
|
newFs[method] = (...args) => {
|
|
1530
1530
|
const callback = args.pop();
|
|
1531
1531
|
let ret;
|
|
1532
1532
|
try {
|
|
1533
|
-
ret =
|
|
1533
|
+
ret = fs35[`${method}Sync`](...args);
|
|
1534
1534
|
} catch (err) {
|
|
1535
1535
|
return callback(err);
|
|
1536
1536
|
}
|
|
@@ -1568,7 +1568,7 @@ var require_adapter = __commonJS({
|
|
|
1568
1568
|
}
|
|
1569
1569
|
function toSyncOptions(options) {
|
|
1570
1570
|
options = { ...options };
|
|
1571
|
-
options.fs = createSyncFs(options.fs ||
|
|
1571
|
+
options.fs = createSyncFs(options.fs || fs34);
|
|
1572
1572
|
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
1573
1573
|
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
1574
1574
|
}
|
|
@@ -2530,10 +2530,10 @@ var require_src2 = __commonJS({
|
|
|
2530
2530
|
var fs_1 = __require("fs");
|
|
2531
2531
|
var debug_1 = __importDefault2(require_src());
|
|
2532
2532
|
var log6 = debug_1.default("@kwsites/file-exists");
|
|
2533
|
-
function check(
|
|
2534
|
-
log6(`checking %s`,
|
|
2533
|
+
function check(path37, isFile, isDirectory) {
|
|
2534
|
+
log6(`checking %s`, path37);
|
|
2535
2535
|
try {
|
|
2536
|
-
const stat = fs_1.statSync(
|
|
2536
|
+
const stat = fs_1.statSync(path37);
|
|
2537
2537
|
if (stat.isFile() && isFile) {
|
|
2538
2538
|
log6(`[OK] path represents a file`);
|
|
2539
2539
|
return true;
|
|
@@ -2553,8 +2553,8 @@ var require_src2 = __commonJS({
|
|
|
2553
2553
|
throw e9;
|
|
2554
2554
|
}
|
|
2555
2555
|
}
|
|
2556
|
-
function exists3(
|
|
2557
|
-
return check(
|
|
2556
|
+
function exists3(path37, type = exports.READABLE) {
|
|
2557
|
+
return check(path37, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
2558
2558
|
}
|
|
2559
2559
|
exports.exists = exists3;
|
|
2560
2560
|
exports.FILE = 1;
|
|
@@ -2617,6 +2617,24 @@ var require_dist2 = __commonJS({
|
|
|
2617
2617
|
}
|
|
2618
2618
|
});
|
|
2619
2619
|
|
|
2620
|
+
// ../canopycms/src/utils/logger.ts
|
|
2621
|
+
function setCanopyLogger(logger4) {
|
|
2622
|
+
active = logger4;
|
|
2623
|
+
}
|
|
2624
|
+
function canopyLogWarn(...args) {
|
|
2625
|
+
active.warn(...args);
|
|
2626
|
+
}
|
|
2627
|
+
function canopyLogError(...args) {
|
|
2628
|
+
active.error(...args);
|
|
2629
|
+
}
|
|
2630
|
+
var active;
|
|
2631
|
+
var init_logger = __esm({
|
|
2632
|
+
"../canopycms/src/utils/logger.ts"() {
|
|
2633
|
+
"use strict";
|
|
2634
|
+
active = console;
|
|
2635
|
+
}
|
|
2636
|
+
});
|
|
2637
|
+
|
|
2620
2638
|
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
|
|
2621
2639
|
var util, objectUtil, ZodParsedType, getParsedType;
|
|
2622
2640
|
var init_util2 = __esm({
|
|
@@ -3029,8 +3047,8 @@ var init_parseUtil = __esm({
|
|
|
3029
3047
|
init_errors();
|
|
3030
3048
|
init_en();
|
|
3031
3049
|
makeIssue = (params) => {
|
|
3032
|
-
const { data: data3, path:
|
|
3033
|
-
const fullPath = [...
|
|
3050
|
+
const { data: data3, path: path37, errorMaps, issueData } = params;
|
|
3051
|
+
const fullPath = [...path37, ...issueData.path || []];
|
|
3034
3052
|
const fullIssue = {
|
|
3035
3053
|
...issueData,
|
|
3036
3054
|
path: fullPath
|
|
@@ -3338,11 +3356,11 @@ var init_types = __esm({
|
|
|
3338
3356
|
init_parseUtil();
|
|
3339
3357
|
init_util2();
|
|
3340
3358
|
ParseInputLazyPath = class {
|
|
3341
|
-
constructor(parent, value,
|
|
3359
|
+
constructor(parent, value, path37, key) {
|
|
3342
3360
|
this._cachedPath = [];
|
|
3343
3361
|
this.parent = parent;
|
|
3344
3362
|
this.data = value;
|
|
3345
|
-
this._path =
|
|
3363
|
+
this._path = path37;
|
|
3346
3364
|
this._key = key;
|
|
3347
3365
|
}
|
|
3348
3366
|
get path() {
|
|
@@ -6723,24 +6741,6 @@ var init_zod = __esm({
|
|
|
6723
6741
|
}
|
|
6724
6742
|
});
|
|
6725
6743
|
|
|
6726
|
-
// ../canopycms/src/utils/logger.ts
|
|
6727
|
-
function setCanopyLogger(logger4) {
|
|
6728
|
-
active = logger4;
|
|
6729
|
-
}
|
|
6730
|
-
function canopyLogWarn(...args) {
|
|
6731
|
-
active.warn(...args);
|
|
6732
|
-
}
|
|
6733
|
-
function canopyLogError(...args) {
|
|
6734
|
-
active.error(...args);
|
|
6735
|
-
}
|
|
6736
|
-
var active;
|
|
6737
|
-
var init_logger = __esm({
|
|
6738
|
-
"../canopycms/src/utils/logger.ts"() {
|
|
6739
|
-
"use strict";
|
|
6740
|
-
active = console;
|
|
6741
|
-
}
|
|
6742
|
-
});
|
|
6743
|
-
|
|
6744
6744
|
// ../../node_modules/.pnpm/short-uuid@6.0.3/node_modules/short-uuid/dist/constants.js
|
|
6745
6745
|
var require_constants = __commonJS({
|
|
6746
6746
|
"../../node_modules/.pnpm/short-uuid@6.0.3/node_modules/short-uuid/dist/constants.js"(exports) {
|
|
@@ -7023,8 +7023,8 @@ var init_branch_name = __esm({
|
|
|
7023
7023
|
});
|
|
7024
7024
|
|
|
7025
7025
|
// ../canopycms/src/paths/normalize.ts
|
|
7026
|
-
function normalizeFilesystemPath(
|
|
7027
|
-
return
|
|
7026
|
+
function normalizeFilesystemPath(path37) {
|
|
7027
|
+
return path37.split(/[\\/]+/).filter(Boolean).join("/");
|
|
7028
7028
|
}
|
|
7029
7029
|
var init_normalize = __esm({
|
|
7030
7030
|
"../canopycms/src/paths/normalize.ts"() {
|
|
@@ -8328,15 +8328,15 @@ var require_dist_node9 = __commonJS({
|
|
|
8328
8328
|
octokit.log.debug("request", options);
|
|
8329
8329
|
const start = Date.now();
|
|
8330
8330
|
const requestOptions = octokit.request.endpoint.parse(options);
|
|
8331
|
-
const
|
|
8331
|
+
const path37 = requestOptions.url.replace(options.baseUrl, "");
|
|
8332
8332
|
return request(options).then((response) => {
|
|
8333
8333
|
octokit.log.info(
|
|
8334
|
-
`${requestOptions.method} ${
|
|
8334
|
+
`${requestOptions.method} ${path37} - ${response.status} in ${Date.now() - start}ms`
|
|
8335
8335
|
);
|
|
8336
8336
|
return response;
|
|
8337
8337
|
}).catch((error3) => {
|
|
8338
8338
|
octokit.log.info(
|
|
8339
|
-
`${requestOptions.method} ${
|
|
8339
|
+
`${requestOptions.method} ${path37} - ${error3.status} in ${Date.now() - start}ms`
|
|
8340
8340
|
);
|
|
8341
8341
|
throw error3;
|
|
8342
8342
|
});
|
|
@@ -12430,7 +12430,7 @@ var require_dist_node13 = __commonJS({
|
|
|
12430
12430
|
];
|
|
12431
12431
|
function routeMatcher(paths) {
|
|
12432
12432
|
const regexes = paths.map(
|
|
12433
|
-
(
|
|
12433
|
+
(path37) => path37.split("/").map((c11) => c11.startsWith("{") ? "(?:.+?)" : c11).join("/")
|
|
12434
12434
|
);
|
|
12435
12435
|
const regex2 = `^(?:${regexes.map((r10) => `(?:${r10})`).join("|")})[^/]*$`;
|
|
12436
12436
|
return new RegExp(regex2, "i");
|
|
@@ -13531,9 +13531,9 @@ var init_createPaginator = __esm({
|
|
|
13531
13531
|
command5 = withCommand(command5) ?? command5;
|
|
13532
13532
|
return await client.send(command5, ...args);
|
|
13533
13533
|
};
|
|
13534
|
-
get = (fromObject,
|
|
13534
|
+
get = (fromObject, path37) => {
|
|
13535
13535
|
let cursor3 = fromObject;
|
|
13536
|
-
const pathComponents =
|
|
13536
|
+
const pathComponents = path37.split(".");
|
|
13537
13537
|
for (const step of pathComponents) {
|
|
13538
13538
|
if (!cursor3 || typeof cursor3 !== "object") {
|
|
13539
13539
|
return void 0;
|
|
@@ -14551,12 +14551,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
14551
14551
|
const password = request.password ?? "";
|
|
14552
14552
|
auth = `${username}:${password}`;
|
|
14553
14553
|
}
|
|
14554
|
-
let
|
|
14554
|
+
let path37 = request.path;
|
|
14555
14555
|
if (queryString) {
|
|
14556
|
-
|
|
14556
|
+
path37 += `?${queryString}`;
|
|
14557
14557
|
}
|
|
14558
14558
|
if (request.fragment) {
|
|
14559
|
-
|
|
14559
|
+
path37 += `#${request.fragment}`;
|
|
14560
14560
|
}
|
|
14561
14561
|
let hostname = request.hostname ?? "";
|
|
14562
14562
|
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
@@ -14568,7 +14568,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
14568
14568
|
headers: request.headers,
|
|
14569
14569
|
host: hostname,
|
|
14570
14570
|
method: request.method,
|
|
14571
|
-
path:
|
|
14571
|
+
path: path37,
|
|
14572
14572
|
port: request.port,
|
|
14573
14573
|
agent,
|
|
14574
14574
|
auth
|
|
@@ -14851,16 +14851,16 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
14851
14851
|
reject(err);
|
|
14852
14852
|
};
|
|
14853
14853
|
const queryString = querystringBuilder.buildQueryString(query || {});
|
|
14854
|
-
let
|
|
14854
|
+
let path37 = request.path;
|
|
14855
14855
|
if (queryString) {
|
|
14856
|
-
|
|
14856
|
+
path37 += `?${queryString}`;
|
|
14857
14857
|
}
|
|
14858
14858
|
if (request.fragment) {
|
|
14859
|
-
|
|
14859
|
+
path37 += `#${request.fragment}`;
|
|
14860
14860
|
}
|
|
14861
14861
|
const req = session.request({
|
|
14862
14862
|
...request.headers,
|
|
14863
|
-
[http2.constants.HTTP2_HEADER_PATH]:
|
|
14863
|
+
[http2.constants.HTTP2_HEADER_PATH]: path37,
|
|
14864
14864
|
[http2.constants.HTTP2_HEADER_METHOD]: method
|
|
14865
14865
|
});
|
|
14866
14866
|
session.ref();
|
|
@@ -15047,13 +15047,13 @@ var require_dist_cjs14 = __commonJS({
|
|
|
15047
15047
|
const abortError = buildAbortError(abortSignal);
|
|
15048
15048
|
return Promise.reject(abortError);
|
|
15049
15049
|
}
|
|
15050
|
-
let
|
|
15050
|
+
let path37 = request.path;
|
|
15051
15051
|
const queryString = querystringBuilder.buildQueryString(request.query || {});
|
|
15052
15052
|
if (queryString) {
|
|
15053
|
-
|
|
15053
|
+
path37 += `?${queryString}`;
|
|
15054
15054
|
}
|
|
15055
15055
|
if (request.fragment) {
|
|
15056
|
-
|
|
15056
|
+
path37 += `#${request.fragment}`;
|
|
15057
15057
|
}
|
|
15058
15058
|
let auth = "";
|
|
15059
15059
|
if (request.username != null || request.password != null) {
|
|
@@ -15062,7 +15062,7 @@ var require_dist_cjs14 = __commonJS({
|
|
|
15062
15062
|
auth = `${username}:${password}@`;
|
|
15063
15063
|
}
|
|
15064
15064
|
const { port, method } = request;
|
|
15065
|
-
const url = `${request.protocol}//${auth}${request.hostname}${port ? `:${port}` : ""}${
|
|
15065
|
+
const url = `${request.protocol}//${auth}${request.hostname}${port ? `:${port}` : ""}${path37}`;
|
|
15066
15066
|
const body = method === "GET" || method === "HEAD" ? void 0 : request.body;
|
|
15067
15067
|
const requestOptions = {
|
|
15068
15068
|
body,
|
|
@@ -17294,13 +17294,13 @@ function __disposeResources(env2) {
|
|
|
17294
17294
|
}
|
|
17295
17295
|
return next();
|
|
17296
17296
|
}
|
|
17297
|
-
function __rewriteRelativeImportExtension(
|
|
17298
|
-
if (typeof
|
|
17299
|
-
return
|
|
17297
|
+
function __rewriteRelativeImportExtension(path37, preserveJsx) {
|
|
17298
|
+
if (typeof path37 === "string" && /^\.\.?\//.test(path37)) {
|
|
17299
|
+
return path37.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m7, tsx, d9, ext, cm) {
|
|
17300
17300
|
return tsx ? preserveJsx ? ".jsx" : ".js" : d9 && (!ext || !cm) ? m7 : d9 + ext + "." + cm.toLowerCase() + "js";
|
|
17301
17301
|
});
|
|
17302
17302
|
}
|
|
17303
|
-
return
|
|
17303
|
+
return path37;
|
|
17304
17304
|
}
|
|
17305
17305
|
var extendStatics, __assign, __createBinding, __setModuleDefault, ownKeys, _SuppressedError, tslib_es6_default;
|
|
17306
17306
|
var init_tslib_es6 = __esm({
|
|
@@ -17406,11 +17406,11 @@ var require_randomUUID = __commonJS({
|
|
|
17406
17406
|
var require_dist_cjs19 = __commonJS({
|
|
17407
17407
|
"../../node_modules/.pnpm/@smithy+uuid@1.1.2/node_modules/@smithy/uuid/dist-cjs/index.js"(exports) {
|
|
17408
17408
|
"use strict";
|
|
17409
|
-
var
|
|
17409
|
+
var randomUUID5 = require_randomUUID();
|
|
17410
17410
|
var decimalToHex2 = Array.from({ length: 256 }, (_3, i10) => i10.toString(16).padStart(2, "0"));
|
|
17411
17411
|
var v43 = () => {
|
|
17412
|
-
if (
|
|
17413
|
-
return
|
|
17412
|
+
if (randomUUID5.randomUUID) {
|
|
17413
|
+
return randomUUID5.randomUUID();
|
|
17414
17414
|
}
|
|
17415
17415
|
const rnds = new Uint8Array(16);
|
|
17416
17416
|
crypto.getRandomValues(rnds);
|
|
@@ -18198,11 +18198,11 @@ var init_HttpBindingProtocol = __esm({
|
|
|
18198
18198
|
const opTraits = translateTraits(operationSchema.traits);
|
|
18199
18199
|
if (opTraits.http) {
|
|
18200
18200
|
request.method = opTraits.http[0];
|
|
18201
|
-
const [
|
|
18201
|
+
const [path37, search] = opTraits.http[1].split("?");
|
|
18202
18202
|
if (request.path == "/") {
|
|
18203
|
-
request.path =
|
|
18203
|
+
request.path = path37;
|
|
18204
18204
|
} else {
|
|
18205
|
-
request.path +=
|
|
18205
|
+
request.path += path37;
|
|
18206
18206
|
}
|
|
18207
18207
|
const traitSearchParams = new URLSearchParams(search ?? "");
|
|
18208
18208
|
Object.assign(query, Object.fromEntries(traitSearchParams));
|
|
@@ -18605,8 +18605,8 @@ var init_requestBuilder = __esm({
|
|
|
18605
18605
|
return this;
|
|
18606
18606
|
}
|
|
18607
18607
|
p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
|
|
18608
|
-
this.resolvePathStack.push((
|
|
18609
|
-
this.path = resolvedPath(
|
|
18608
|
+
this.resolvePathStack.push((path37) => {
|
|
18609
|
+
this.path = resolvedPath(path37, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
|
|
18610
18610
|
});
|
|
18611
18611
|
return this;
|
|
18612
18612
|
}
|
|
@@ -19256,18 +19256,18 @@ var require_dist_cjs20 = __commonJS({
|
|
|
19256
19256
|
}
|
|
19257
19257
|
};
|
|
19258
19258
|
var booleanEquals2 = (value1, value2) => value1 === value2;
|
|
19259
|
-
var getAttrPathList2 = (
|
|
19260
|
-
const parts =
|
|
19259
|
+
var getAttrPathList2 = (path37) => {
|
|
19260
|
+
const parts = path37.split(".");
|
|
19261
19261
|
const pathList = [];
|
|
19262
19262
|
for (const part of parts) {
|
|
19263
19263
|
const squareBracketIndex = part.indexOf("[");
|
|
19264
19264
|
if (squareBracketIndex !== -1) {
|
|
19265
19265
|
if (part.indexOf("]") !== part.length - 1) {
|
|
19266
|
-
throw new EndpointError2(`Path: '${
|
|
19266
|
+
throw new EndpointError2(`Path: '${path37}' does not end with ']'`);
|
|
19267
19267
|
}
|
|
19268
19268
|
const arrayIndex = part.slice(squareBracketIndex + 1, -1);
|
|
19269
19269
|
if (Number.isNaN(parseInt(arrayIndex))) {
|
|
19270
|
-
throw new EndpointError2(`Invalid array index: '${arrayIndex}' in path: '${
|
|
19270
|
+
throw new EndpointError2(`Invalid array index: '${arrayIndex}' in path: '${path37}'`);
|
|
19271
19271
|
}
|
|
19272
19272
|
if (squareBracketIndex !== 0) {
|
|
19273
19273
|
pathList.push(part.slice(0, squareBracketIndex));
|
|
@@ -19279,9 +19279,9 @@ var require_dist_cjs20 = __commonJS({
|
|
|
19279
19279
|
}
|
|
19280
19280
|
return pathList;
|
|
19281
19281
|
};
|
|
19282
|
-
var getAttr2 = (value,
|
|
19282
|
+
var getAttr2 = (value, path37) => getAttrPathList2(path37).reduce((acc, index) => {
|
|
19283
19283
|
if (typeof acc !== "object") {
|
|
19284
|
-
throw new EndpointError2(`Index '${index}' in '${
|
|
19284
|
+
throw new EndpointError2(`Index '${index}' in '${path37}' not found in '${JSON.stringify(value)}'`);
|
|
19285
19285
|
} else if (Array.isArray(acc)) {
|
|
19286
19286
|
return acc[parseInt(index)];
|
|
19287
19287
|
}
|
|
@@ -19300,8 +19300,8 @@ var require_dist_cjs20 = __commonJS({
|
|
|
19300
19300
|
return value;
|
|
19301
19301
|
}
|
|
19302
19302
|
if (typeof value === "object" && "hostname" in value) {
|
|
19303
|
-
const { hostname: hostname2, port, protocol: protocol2 = "", path:
|
|
19304
|
-
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${
|
|
19303
|
+
const { hostname: hostname2, port, protocol: protocol2 = "", path: path37 = "", query = {} } = value;
|
|
19304
|
+
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path37}`);
|
|
19305
19305
|
url.search = Object.entries(query).map(([k10, v5]) => `${k10}=${v5}`).join("&");
|
|
19306
19306
|
return url;
|
|
19307
19307
|
}
|
|
@@ -20746,10 +20746,10 @@ ${longDate}
|
|
|
20746
20746
|
${credentialScope}
|
|
20747
20747
|
${utilHexEncoding.toHex(hashedRequest)}`;
|
|
20748
20748
|
}
|
|
20749
|
-
getCanonicalPath({ path:
|
|
20749
|
+
getCanonicalPath({ path: path37 }) {
|
|
20750
20750
|
if (this.uriEscapePath) {
|
|
20751
20751
|
const normalizedPathSegments = [];
|
|
20752
|
-
for (const pathSegment of
|
|
20752
|
+
for (const pathSegment of path37.split("/")) {
|
|
20753
20753
|
if (pathSegment?.length === 0)
|
|
20754
20754
|
continue;
|
|
20755
20755
|
if (pathSegment === ".")
|
|
@@ -20760,11 +20760,11 @@ ${utilHexEncoding.toHex(hashedRequest)}`;
|
|
|
20760
20760
|
normalizedPathSegments.push(pathSegment);
|
|
20761
20761
|
}
|
|
20762
20762
|
}
|
|
20763
|
-
const normalizedPath = `${
|
|
20763
|
+
const normalizedPath = `${path37?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path37?.endsWith("/") ? "/" : ""}`;
|
|
20764
20764
|
const doubleEncoded = utilUriEscape.escapeUri(normalizedPath);
|
|
20765
20765
|
return doubleEncoded.replace(/%2F/g, "/");
|
|
20766
20766
|
}
|
|
20767
|
-
return
|
|
20767
|
+
return path37;
|
|
20768
20768
|
}
|
|
20769
20769
|
validateResolvedCredentials(credentials) {
|
|
20770
20770
|
if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
|
|
@@ -22068,11 +22068,11 @@ var init_SmithyRpcV2CborProtocol = __esm({
|
|
|
22068
22068
|
}
|
|
22069
22069
|
}
|
|
22070
22070
|
const { service, operation: operation3 } = (0, import_util_middleware5.getSmithyContext)(context);
|
|
22071
|
-
const
|
|
22071
|
+
const path37 = `/service/${service}/operation/${operation3}`;
|
|
22072
22072
|
if (request.path.endsWith("/")) {
|
|
22073
|
-
request.path +=
|
|
22073
|
+
request.path += path37.slice(1);
|
|
22074
22074
|
} else {
|
|
22075
|
-
request.path +=
|
|
22075
|
+
request.path += path37;
|
|
22076
22076
|
}
|
|
22077
22077
|
return request;
|
|
22078
22078
|
}
|
|
@@ -27717,14 +27717,14 @@ var require_readFile = __commonJS({
|
|
|
27717
27717
|
var promises_1 = __require("node:fs/promises");
|
|
27718
27718
|
exports.filePromises = {};
|
|
27719
27719
|
exports.fileIntercept = {};
|
|
27720
|
-
var readFile3 = (
|
|
27721
|
-
if (exports.fileIntercept[
|
|
27722
|
-
return exports.fileIntercept[
|
|
27720
|
+
var readFile3 = (path37, options) => {
|
|
27721
|
+
if (exports.fileIntercept[path37] !== void 0) {
|
|
27722
|
+
return exports.fileIntercept[path37];
|
|
27723
27723
|
}
|
|
27724
|
-
if (!exports.filePromises[
|
|
27725
|
-
exports.filePromises[
|
|
27724
|
+
if (!exports.filePromises[path37] || options?.ignoreCache) {
|
|
27725
|
+
exports.filePromises[path37] = (0, promises_1.readFile)(path37, "utf8");
|
|
27726
27726
|
}
|
|
27727
|
-
return exports.filePromises[
|
|
27727
|
+
return exports.filePromises[path37];
|
|
27728
27728
|
};
|
|
27729
27729
|
exports.readFile = readFile3;
|
|
27730
27730
|
}
|
|
@@ -27737,7 +27737,7 @@ var require_dist_cjs33 = __commonJS({
|
|
|
27737
27737
|
var getHomeDir2 = require_getHomeDir();
|
|
27738
27738
|
var getSSOTokenFilepath2 = require_getSSOTokenFilepath();
|
|
27739
27739
|
var getSSOTokenFromFile2 = require_getSSOTokenFromFile();
|
|
27740
|
-
var
|
|
27740
|
+
var path37 = __require("path");
|
|
27741
27741
|
var types = require_dist_cjs();
|
|
27742
27742
|
var readFile3 = require_readFile();
|
|
27743
27743
|
var ENV_PROFILE2 = "AWS_PROFILE";
|
|
@@ -27759,9 +27759,9 @@ var require_dist_cjs33 = __commonJS({
|
|
|
27759
27759
|
...data3.default && { default: data3.default }
|
|
27760
27760
|
});
|
|
27761
27761
|
var ENV_CONFIG_PATH2 = "AWS_CONFIG_FILE";
|
|
27762
|
-
var getConfigFilepath2 = () => process.env[ENV_CONFIG_PATH2] ||
|
|
27762
|
+
var getConfigFilepath2 = () => process.env[ENV_CONFIG_PATH2] || path37.join(getHomeDir2.getHomeDir(), ".aws", "config");
|
|
27763
27763
|
var ENV_CREDENTIALS_PATH2 = "AWS_SHARED_CREDENTIALS_FILE";
|
|
27764
|
-
var getCredentialsFilepath2 = () => process.env[ENV_CREDENTIALS_PATH2] ||
|
|
27764
|
+
var getCredentialsFilepath2 = () => process.env[ENV_CREDENTIALS_PATH2] || path37.join(getHomeDir2.getHomeDir(), ".aws", "credentials");
|
|
27765
27765
|
var prefixKeyRegex2 = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
|
|
27766
27766
|
var profileNameBlockList2 = ["__proto__", "profile __proto__"];
|
|
27767
27767
|
var parseIni2 = (iniData) => {
|
|
@@ -27816,11 +27816,11 @@ var require_dist_cjs33 = __commonJS({
|
|
|
27816
27816
|
const relativeHomeDirPrefix = "~/";
|
|
27817
27817
|
let resolvedFilepath = filepath;
|
|
27818
27818
|
if (filepath.startsWith(relativeHomeDirPrefix)) {
|
|
27819
|
-
resolvedFilepath =
|
|
27819
|
+
resolvedFilepath = path37.join(homeDir, filepath.slice(2));
|
|
27820
27820
|
}
|
|
27821
27821
|
let resolvedConfigFilepath = configFilepath;
|
|
27822
27822
|
if (configFilepath.startsWith(relativeHomeDirPrefix)) {
|
|
27823
|
-
resolvedConfigFilepath =
|
|
27823
|
+
resolvedConfigFilepath = path37.join(homeDir, configFilepath.slice(2));
|
|
27824
27824
|
}
|
|
27825
27825
|
const parsedFiles = await Promise.all([
|
|
27826
27826
|
readFile3.readFile(resolvedConfigFilepath, {
|
|
@@ -27859,8 +27859,8 @@ var require_dist_cjs33 = __commonJS({
|
|
|
27859
27859
|
getFileRecord() {
|
|
27860
27860
|
return readFile3.fileIntercept;
|
|
27861
27861
|
},
|
|
27862
|
-
interceptFile(
|
|
27863
|
-
readFile3.fileIntercept[
|
|
27862
|
+
interceptFile(path38, contents) {
|
|
27863
|
+
readFile3.fileIntercept[path38] = Promise.resolve(contents);
|
|
27864
27864
|
},
|
|
27865
27865
|
getTokenRecord() {
|
|
27866
27866
|
return getSSOTokenFromFile2.tokenIntercept;
|
|
@@ -28185,8 +28185,8 @@ var require_dist_cjs36 = __commonJS({
|
|
|
28185
28185
|
return endpoint.url.href;
|
|
28186
28186
|
}
|
|
28187
28187
|
if ("hostname" in endpoint) {
|
|
28188
|
-
const { protocol, hostname, port, path:
|
|
28189
|
-
return `${protocol}//${hostname}${port ? ":" + port : ""}${
|
|
28188
|
+
const { protocol, hostname, port, path: path37 } = endpoint;
|
|
28189
|
+
return `${protocol}//${hostname}${port ? ":" + port : ""}${path37}`;
|
|
28190
28190
|
}
|
|
28191
28191
|
}
|
|
28192
28192
|
return endpoint;
|
|
@@ -38220,14 +38220,14 @@ var init_readFile = __esm({
|
|
|
38220
38220
|
"../../node_modules/.pnpm/@smithy+core@3.29.7/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/readFile.js"() {
|
|
38221
38221
|
filePromises = {};
|
|
38222
38222
|
fileIntercept = {};
|
|
38223
|
-
readFile2 = (
|
|
38224
|
-
if (fileIntercept[
|
|
38225
|
-
return fileIntercept[
|
|
38223
|
+
readFile2 = (path37, options) => {
|
|
38224
|
+
if (fileIntercept[path37] !== void 0) {
|
|
38225
|
+
return fileIntercept[path37];
|
|
38226
38226
|
}
|
|
38227
|
-
if (!filePromises[
|
|
38228
|
-
filePromises[
|
|
38227
|
+
if (!filePromises[path37] || options?.ignoreCache) {
|
|
38228
|
+
filePromises[path37] = fsReadFile(path37, "utf8");
|
|
38229
38229
|
}
|
|
38230
|
-
return filePromises[
|
|
38230
|
+
return filePromises[path37];
|
|
38231
38231
|
};
|
|
38232
38232
|
}
|
|
38233
38233
|
});
|
|
@@ -38339,8 +38339,8 @@ var init_externalDataInterceptor = __esm({
|
|
|
38339
38339
|
getFileRecord() {
|
|
38340
38340
|
return fileIntercept;
|
|
38341
38341
|
},
|
|
38342
|
-
interceptFile(
|
|
38343
|
-
fileIntercept[
|
|
38342
|
+
interceptFile(path37, contents) {
|
|
38343
|
+
fileIntercept[path37] = Promise.resolve(contents);
|
|
38344
38344
|
},
|
|
38345
38345
|
getTokenRecord() {
|
|
38346
38346
|
return tokenIntercept;
|
|
@@ -41274,8 +41274,8 @@ var init_createConfigValueProvider = __esm({
|
|
|
41274
41274
|
return endpoint.url.href;
|
|
41275
41275
|
}
|
|
41276
41276
|
if ("hostname" in endpoint) {
|
|
41277
|
-
const { protocol, hostname, port, path:
|
|
41278
|
-
return `${protocol}//${hostname}${port ? ":" + port : ""}${
|
|
41277
|
+
const { protocol, hostname, port, path: path37 } = endpoint;
|
|
41278
|
+
return `${protocol}//${hostname}${port ? ":" + port : ""}${path37}`;
|
|
41279
41279
|
}
|
|
41280
41280
|
}
|
|
41281
41281
|
return endpoint;
|
|
@@ -41650,18 +41650,18 @@ var getAttrPathList;
|
|
|
41650
41650
|
var init_getAttrPathList = __esm({
|
|
41651
41651
|
"../../node_modules/.pnpm/@smithy+core@3.29.7/node_modules/@smithy/core/dist-es/submodules/endpoints/util-endpoints/lib/getAttrPathList.js"() {
|
|
41652
41652
|
init_types4();
|
|
41653
|
-
getAttrPathList = (
|
|
41654
|
-
const parts =
|
|
41653
|
+
getAttrPathList = (path37) => {
|
|
41654
|
+
const parts = path37.split(".");
|
|
41655
41655
|
const pathList = [];
|
|
41656
41656
|
for (const part of parts) {
|
|
41657
41657
|
const squareBracketIndex = part.indexOf("[");
|
|
41658
41658
|
if (squareBracketIndex !== -1) {
|
|
41659
41659
|
if (part.indexOf("]") !== part.length - 1) {
|
|
41660
|
-
throw new EndpointError(`Path: '${
|
|
41660
|
+
throw new EndpointError(`Path: '${path37}' does not end with ']'`);
|
|
41661
41661
|
}
|
|
41662
41662
|
const arrayIndex = part.slice(squareBracketIndex + 1, -1);
|
|
41663
41663
|
if (Number.isNaN(parseInt(arrayIndex))) {
|
|
41664
|
-
throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${
|
|
41664
|
+
throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${path37}'`);
|
|
41665
41665
|
}
|
|
41666
41666
|
if (squareBracketIndex !== 0) {
|
|
41667
41667
|
pathList.push(part.slice(0, squareBracketIndex));
|
|
@@ -41682,9 +41682,9 @@ var init_getAttr = __esm({
|
|
|
41682
41682
|
"../../node_modules/.pnpm/@smithy+core@3.29.7/node_modules/@smithy/core/dist-es/submodules/endpoints/util-endpoints/lib/getAttr.js"() {
|
|
41683
41683
|
init_types4();
|
|
41684
41684
|
init_getAttrPathList();
|
|
41685
|
-
getAttr = (value,
|
|
41685
|
+
getAttr = (value, path37) => getAttrPathList(path37).reduce((acc, index) => {
|
|
41686
41686
|
if (typeof acc !== "object") {
|
|
41687
|
-
throw new EndpointError(`Index '${index}' in '${
|
|
41687
|
+
throw new EndpointError(`Index '${index}' in '${path37}' not found in '${JSON.stringify(value)}'`);
|
|
41688
41688
|
} else if (Array.isArray(acc)) {
|
|
41689
41689
|
const i10 = parseInt(index);
|
|
41690
41690
|
return acc[i10 < 0 ? acc.length + i10 : i10];
|
|
@@ -41745,8 +41745,8 @@ var init_parseURL = __esm({
|
|
|
41745
41745
|
return value;
|
|
41746
41746
|
}
|
|
41747
41747
|
if (typeof value === "object" && "hostname" in value) {
|
|
41748
|
-
const { hostname: hostname2, port, protocol: protocol2 = "", path:
|
|
41749
|
-
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${
|
|
41748
|
+
const { hostname: hostname2, port, protocol: protocol2 = "", path: path37 = "", query = {} } = value;
|
|
41749
|
+
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path37}`);
|
|
41750
41750
|
url.search = Object.entries(query).map(([k10, v5]) => `${k10}=${v5}`).join("&");
|
|
41751
41751
|
return url;
|
|
41752
41752
|
}
|
|
@@ -44983,11 +44983,11 @@ var init_HttpBindingProtocol2 = __esm({
|
|
|
44983
44983
|
const opTraits = translateTraits2(operationSchema.traits);
|
|
44984
44984
|
if (opTraits.http) {
|
|
44985
44985
|
request.method = opTraits.http[0];
|
|
44986
|
-
const [
|
|
44986
|
+
const [path37, search] = opTraits.http[1].split("?");
|
|
44987
44987
|
if (request.path == "/") {
|
|
44988
|
-
request.path =
|
|
44988
|
+
request.path = path37;
|
|
44989
44989
|
} else {
|
|
44990
|
-
request.path +=
|
|
44990
|
+
request.path += path37;
|
|
44991
44991
|
}
|
|
44992
44992
|
const traitSearchParams = new URLSearchParams(search ?? "");
|
|
44993
44993
|
for (const [key, value] of traitSearchParams) {
|
|
@@ -45388,8 +45388,8 @@ var init_requestBuilder3 = __esm({
|
|
|
45388
45388
|
return this;
|
|
45389
45389
|
}
|
|
45390
45390
|
p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
|
|
45391
|
-
this.resolvePathStack.push((
|
|
45392
|
-
this.path = resolvedPath2(
|
|
45391
|
+
this.resolvePathStack.push((path37) => {
|
|
45392
|
+
this.path = resolvedPath2(path37, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
|
|
45393
45393
|
});
|
|
45394
45394
|
return this;
|
|
45395
45395
|
}
|
|
@@ -46028,9 +46028,9 @@ var init_createPaginator2 = __esm({
|
|
|
46028
46028
|
command5 = withCommand(command5) ?? command5;
|
|
46029
46029
|
return await client.send(command5, ...args);
|
|
46030
46030
|
};
|
|
46031
|
-
get2 = (fromObject,
|
|
46031
|
+
get2 = (fromObject, path37) => {
|
|
46032
46032
|
let cursor3 = fromObject;
|
|
46033
|
-
const pathComponents =
|
|
46033
|
+
const pathComponents = path37.split(".");
|
|
46034
46034
|
for (const step of pathComponents) {
|
|
46035
46035
|
if (!cursor3 || typeof cursor3 !== "object") {
|
|
46036
46036
|
return void 0;
|
|
@@ -49601,10 +49601,10 @@ ${longDate}
|
|
|
49601
49601
|
${credentialScope}
|
|
49602
49602
|
${toHex2(hashedRequest)}`;
|
|
49603
49603
|
}
|
|
49604
|
-
getCanonicalPath({ path:
|
|
49604
|
+
getCanonicalPath({ path: path37 }) {
|
|
49605
49605
|
if (this.uriEscapePath) {
|
|
49606
49606
|
const normalizedPathSegments = [];
|
|
49607
|
-
for (const pathSegment of
|
|
49607
|
+
for (const pathSegment of path37.split("/")) {
|
|
49608
49608
|
if (pathSegment?.length === 0)
|
|
49609
49609
|
continue;
|
|
49610
49610
|
if (pathSegment === ".")
|
|
@@ -49615,11 +49615,11 @@ ${toHex2(hashedRequest)}`;
|
|
|
49615
49615
|
normalizedPathSegments.push(pathSegment);
|
|
49616
49616
|
}
|
|
49617
49617
|
}
|
|
49618
|
-
const normalizedPath = `${
|
|
49618
|
+
const normalizedPath = `${path37?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path37?.endsWith("/") ? "/" : ""}`;
|
|
49619
49619
|
const doubleEncoded = escapeUri2(normalizedPath);
|
|
49620
49620
|
return doubleEncoded.replace(/%2F/g, "/");
|
|
49621
49621
|
}
|
|
49622
|
-
return
|
|
49622
|
+
return path37;
|
|
49623
49623
|
}
|
|
49624
49624
|
validateResolvedCredentials(credentials) {
|
|
49625
49625
|
if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
|
|
@@ -51188,11 +51188,11 @@ var init_SmithyRpcV2CborProtocol2 = __esm({
|
|
|
51188
51188
|
}
|
|
51189
51189
|
}
|
|
51190
51190
|
const { service, operation: operation3 } = getSmithyContext11(context);
|
|
51191
|
-
const
|
|
51191
|
+
const path37 = `/service/${service}/operation/${operation3}`;
|
|
51192
51192
|
if (request.path.endsWith("/")) {
|
|
51193
|
-
request.path +=
|
|
51193
|
+
request.path += path37.slice(1);
|
|
51194
51194
|
} else {
|
|
51195
|
-
request.path +=
|
|
51195
|
+
request.path += path37;
|
|
51196
51196
|
}
|
|
51197
51197
|
return request;
|
|
51198
51198
|
}
|
|
@@ -54596,12 +54596,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
54596
54596
|
const password = request.password ?? "";
|
|
54597
54597
|
auth = `${username}:${password}`;
|
|
54598
54598
|
}
|
|
54599
|
-
let
|
|
54599
|
+
let path37 = request.path;
|
|
54600
54600
|
if (queryString) {
|
|
54601
|
-
|
|
54601
|
+
path37 += `?${queryString}`;
|
|
54602
54602
|
}
|
|
54603
54603
|
if (request.fragment) {
|
|
54604
|
-
|
|
54604
|
+
path37 += `#${request.fragment}`;
|
|
54605
54605
|
}
|
|
54606
54606
|
let hostname = request.hostname ?? "";
|
|
54607
54607
|
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
@@ -54613,7 +54613,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
54613
54613
|
headers: request.headers,
|
|
54614
54614
|
host: hostname,
|
|
54615
54615
|
method: request.method,
|
|
54616
|
-
path:
|
|
54616
|
+
path: path37,
|
|
54617
54617
|
port: request.port,
|
|
54618
54618
|
agent,
|
|
54619
54619
|
auth
|
|
@@ -55016,16 +55016,16 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
55016
55016
|
reject(err);
|
|
55017
55017
|
};
|
|
55018
55018
|
const queryString = query ? buildQueryString2(query) : "";
|
|
55019
|
-
let
|
|
55019
|
+
let path37 = request.path;
|
|
55020
55020
|
if (queryString) {
|
|
55021
|
-
|
|
55021
|
+
path37 += `?${queryString}`;
|
|
55022
55022
|
}
|
|
55023
55023
|
if (request.fragment) {
|
|
55024
|
-
|
|
55024
|
+
path37 += `#${request.fragment}`;
|
|
55025
55025
|
}
|
|
55026
55026
|
const clientHttp2Stream = session.request({
|
|
55027
55027
|
...request.headers,
|
|
55028
|
-
[constants2.HTTP2_HEADER_PATH]:
|
|
55028
|
+
[constants2.HTTP2_HEADER_PATH]: path37,
|
|
55029
55029
|
[constants2.HTTP2_HEADER_METHOD]: method
|
|
55030
55030
|
});
|
|
55031
55031
|
if (effectiveRequestTimeout) {
|
|
@@ -55107,7 +55107,7 @@ var require_dist_cjs60 = __commonJS({
|
|
|
55107
55107
|
var { setCredentialFeature: setCredentialFeature3 } = (init_client4(), __toCommonJS(client_exports3));
|
|
55108
55108
|
var { CredentialsProviderError: CredentialsProviderError2 } = (init_config3(), __toCommonJS(config_exports));
|
|
55109
55109
|
var { NodeHttpHandler } = require_dist_cjs59();
|
|
55110
|
-
var
|
|
55110
|
+
var fs34 = __require("node:fs/promises");
|
|
55111
55111
|
var { HttpRequest: HttpRequest11 } = (init_protocols3(), __toCommonJS(protocols_exports3));
|
|
55112
55112
|
var { sdkStreamMixin: sdkStreamMixin4, parseRfc3339DateTime: parseRfc3339DateTime3 } = (init_serde2(), __toCommonJS(serde_exports2));
|
|
55113
55113
|
var ECS_CONTAINER_HOST = "169.254.170.2";
|
|
@@ -55231,7 +55231,7 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
|
|
|
55231
55231
|
const provider = retryWrapper(async () => {
|
|
55232
55232
|
const request = createGetRequest(url);
|
|
55233
55233
|
if (tokenFile) {
|
|
55234
|
-
request.headers.Authorization = validateToken((await
|
|
55234
|
+
request.headers.Authorization = validateToken((await fs34.readFile(tokenFile)).toString());
|
|
55235
55235
|
} else if (token) {
|
|
55236
55236
|
request.headers.Authorization = validateToken(token);
|
|
55237
55237
|
}
|
|
@@ -69368,7 +69368,7 @@ var require_truncate = __commonJS({
|
|
|
69368
69368
|
var require_lrucache = __commonJS({
|
|
69369
69369
|
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/lrucache.js"(exports, module) {
|
|
69370
69370
|
"use strict";
|
|
69371
|
-
var
|
|
69371
|
+
var LRUCache2 = class {
|
|
69372
69372
|
constructor() {
|
|
69373
69373
|
this.max = 1e3;
|
|
69374
69374
|
this.map = /* @__PURE__ */ new Map();
|
|
@@ -69398,7 +69398,7 @@ var require_lrucache = __commonJS({
|
|
|
69398
69398
|
return this;
|
|
69399
69399
|
}
|
|
69400
69400
|
};
|
|
69401
|
-
module.exports =
|
|
69401
|
+
module.exports = LRUCache2;
|
|
69402
69402
|
}
|
|
69403
69403
|
});
|
|
69404
69404
|
|
|
@@ -71474,16 +71474,16 @@ var require_commonjs = __commonJS({
|
|
|
71474
71474
|
"use strict";
|
|
71475
71475
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71476
71476
|
exports.LRUCache = void 0;
|
|
71477
|
-
var
|
|
71477
|
+
var perf2 = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
|
|
71478
71478
|
var warned3 = /* @__PURE__ */ new Set();
|
|
71479
|
-
var
|
|
71480
|
-
var
|
|
71481
|
-
typeof
|
|
71482
|
-
};
|
|
71483
|
-
var
|
|
71484
|
-
var
|
|
71485
|
-
if (typeof
|
|
71486
|
-
|
|
71479
|
+
var PROCESS2 = typeof process === "object" && !!process ? process : {};
|
|
71480
|
+
var emitWarning2 = (msg, type, code, fn) => {
|
|
71481
|
+
typeof PROCESS2.emitWarning === "function" ? PROCESS2.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
71482
|
+
};
|
|
71483
|
+
var AC2 = globalThis.AbortController;
|
|
71484
|
+
var AS2 = globalThis.AbortSignal;
|
|
71485
|
+
if (typeof AC2 === "undefined") {
|
|
71486
|
+
AS2 = class AbortSignal {
|
|
71487
71487
|
onabort;
|
|
71488
71488
|
_onabort = [];
|
|
71489
71489
|
reason;
|
|
@@ -71492,11 +71492,11 @@ var require_commonjs = __commonJS({
|
|
|
71492
71492
|
this._onabort.push(fn);
|
|
71493
71493
|
}
|
|
71494
71494
|
};
|
|
71495
|
-
|
|
71495
|
+
AC2 = class AbortController {
|
|
71496
71496
|
constructor() {
|
|
71497
71497
|
warnACPolyfill();
|
|
71498
71498
|
}
|
|
71499
|
-
signal = new
|
|
71499
|
+
signal = new AS2();
|
|
71500
71500
|
abort(reason) {
|
|
71501
71501
|
if (this.signal.aborted)
|
|
71502
71502
|
return;
|
|
@@ -71508,16 +71508,16 @@ var require_commonjs = __commonJS({
|
|
|
71508
71508
|
this.signal.onabort?.(reason);
|
|
71509
71509
|
}
|
|
71510
71510
|
};
|
|
71511
|
-
let printACPolyfillWarning =
|
|
71511
|
+
let printACPolyfillWarning = PROCESS2.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
|
|
71512
71512
|
const warnACPolyfill = () => {
|
|
71513
71513
|
if (!printACPolyfillWarning)
|
|
71514
71514
|
return;
|
|
71515
71515
|
printACPolyfillWarning = false;
|
|
71516
|
-
|
|
71516
|
+
emitWarning2("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill);
|
|
71517
71517
|
};
|
|
71518
71518
|
}
|
|
71519
71519
|
var shouldWarn = (code) => !warned3.has(code);
|
|
71520
|
-
var
|
|
71520
|
+
var TYPE2 = Symbol("type");
|
|
71521
71521
|
var isPosInt = (n7) => n7 && n7 === Math.floor(n7) && n7 > 0 && isFinite(n7);
|
|
71522
71522
|
var getUintArray = (max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null;
|
|
71523
71523
|
var ZeroArray = class extends Array {
|
|
@@ -71554,7 +71554,7 @@ var require_commonjs = __commonJS({
|
|
|
71554
71554
|
return this.heap[--this.length];
|
|
71555
71555
|
}
|
|
71556
71556
|
};
|
|
71557
|
-
var
|
|
71557
|
+
var LRUCache2 = class _LRUCache {
|
|
71558
71558
|
// options that cannot be changed without disaster
|
|
71559
71559
|
#max;
|
|
71560
71560
|
#maxSize;
|
|
@@ -71812,7 +71812,7 @@ var require_commonjs = __commonJS({
|
|
|
71812
71812
|
if (shouldWarn(code)) {
|
|
71813
71813
|
warned3.add(code);
|
|
71814
71814
|
const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
|
|
71815
|
-
|
|
71815
|
+
emitWarning2(msg, "UnboundedCacheWarning", code, _LRUCache);
|
|
71816
71816
|
}
|
|
71817
71817
|
}
|
|
71818
71818
|
}
|
|
@@ -71828,7 +71828,7 @@ var require_commonjs = __commonJS({
|
|
|
71828
71828
|
const starts = new ZeroArray(this.#max);
|
|
71829
71829
|
this.#ttls = ttls;
|
|
71830
71830
|
this.#starts = starts;
|
|
71831
|
-
this.#setItemTTL = (index, ttl, start =
|
|
71831
|
+
this.#setItemTTL = (index, ttl, start = perf2.now()) => {
|
|
71832
71832
|
starts[index] = ttl !== 0 ? start : 0;
|
|
71833
71833
|
ttls[index] = ttl;
|
|
71834
71834
|
if (ttl !== 0 && this.ttlAutopurge) {
|
|
@@ -71843,7 +71843,7 @@ var require_commonjs = __commonJS({
|
|
|
71843
71843
|
}
|
|
71844
71844
|
};
|
|
71845
71845
|
this.#updateItemAge = (index) => {
|
|
71846
|
-
starts[index] = ttls[index] !== 0 ?
|
|
71846
|
+
starts[index] = ttls[index] !== 0 ? perf2.now() : 0;
|
|
71847
71847
|
};
|
|
71848
71848
|
this.#statusTTL = (status, index) => {
|
|
71849
71849
|
if (ttls[index]) {
|
|
@@ -71860,7 +71860,7 @@ var require_commonjs = __commonJS({
|
|
|
71860
71860
|
};
|
|
71861
71861
|
let cachedNow = 0;
|
|
71862
71862
|
const getNow = () => {
|
|
71863
|
-
const n7 =
|
|
71863
|
+
const n7 = perf2.now();
|
|
71864
71864
|
if (this.ttlResolution > 0) {
|
|
71865
71865
|
cachedNow = n7;
|
|
71866
71866
|
const t6 = setTimeout(() => cachedNow = 0, this.ttlResolution);
|
|
@@ -72163,7 +72163,7 @@ var require_commonjs = __commonJS({
|
|
|
72163
72163
|
const ttl = this.#ttls[i10];
|
|
72164
72164
|
const start = this.#starts[i10];
|
|
72165
72165
|
if (ttl && start) {
|
|
72166
|
-
const remain = ttl - (
|
|
72166
|
+
const remain = ttl - (perf2.now() - start);
|
|
72167
72167
|
entry.ttl = remain;
|
|
72168
72168
|
entry.start = Date.now();
|
|
72169
72169
|
}
|
|
@@ -72197,7 +72197,7 @@ var require_commonjs = __commonJS({
|
|
|
72197
72197
|
const entry = { value };
|
|
72198
72198
|
if (this.#ttls && this.#starts) {
|
|
72199
72199
|
entry.ttl = this.#ttls[i10];
|
|
72200
|
-
const age =
|
|
72200
|
+
const age = perf2.now() - this.#starts[i10];
|
|
72201
72201
|
entry.start = Math.floor(Date.now() - age);
|
|
72202
72202
|
}
|
|
72203
72203
|
if (this.#sizes) {
|
|
@@ -72221,7 +72221,7 @@ var require_commonjs = __commonJS({
|
|
|
72221
72221
|
for (const [key, entry] of arr) {
|
|
72222
72222
|
if (entry.start) {
|
|
72223
72223
|
const age = Date.now() - entry.start;
|
|
72224
|
-
entry.start =
|
|
72224
|
+
entry.start = perf2.now() - age;
|
|
72225
72225
|
}
|
|
72226
72226
|
this.set(key, entry.value, entry);
|
|
72227
72227
|
}
|
|
@@ -72461,7 +72461,7 @@ var require_commonjs = __commonJS({
|
|
|
72461
72461
|
if (this.#isBackgroundFetch(v5)) {
|
|
72462
72462
|
return v5;
|
|
72463
72463
|
}
|
|
72464
|
-
const ac = new
|
|
72464
|
+
const ac = new AC2();
|
|
72465
72465
|
const { signal } = options;
|
|
72466
72466
|
signal?.addEventListener("abort", () => ac.abort(signal.reason), {
|
|
72467
72467
|
signal: ac.signal
|
|
@@ -72567,7 +72567,7 @@ var require_commonjs = __commonJS({
|
|
|
72567
72567
|
if (!this.#hasFetchMethod)
|
|
72568
72568
|
return false;
|
|
72569
72569
|
const b10 = p8;
|
|
72570
|
-
return !!b10 && b10 instanceof Promise && b10.hasOwnProperty("__staleWhileFetching") && b10.__abortController instanceof
|
|
72570
|
+
return !!b10 && b10 instanceof Promise && b10.hasOwnProperty("__staleWhileFetching") && b10.__abortController instanceof AC2;
|
|
72571
72571
|
}
|
|
72572
72572
|
async fetch(k10, fetchOptions = {}) {
|
|
72573
72573
|
const {
|
|
@@ -72841,7 +72841,7 @@ var require_commonjs = __commonJS({
|
|
|
72841
72841
|
}
|
|
72842
72842
|
}
|
|
72843
72843
|
};
|
|
72844
|
-
exports.LRUCache =
|
|
72844
|
+
exports.LRUCache = LRUCache2;
|
|
72845
72845
|
}
|
|
72846
72846
|
});
|
|
72847
72847
|
|
|
@@ -72915,9 +72915,9 @@ var require_dist_node20 = __commonJS({
|
|
|
72915
72915
|
}
|
|
72916
72916
|
}
|
|
72917
72917
|
}
|
|
72918
|
-
var
|
|
72918
|
+
var import_lru_cache2 = require_commonjs();
|
|
72919
72919
|
function getCache() {
|
|
72920
|
-
return new
|
|
72920
|
+
return new import_lru_cache2.LRUCache({
|
|
72921
72921
|
// cache max. 15000 tokens, that will use less than 10mb memory
|
|
72922
72922
|
max: 15e3,
|
|
72923
72923
|
// Cache for 1 minute less than GitHub expiry
|
|
@@ -73313,9 +73313,9 @@ var require_dist_node20 = __commonJS({
|
|
|
73313
73313
|
// ../canopycms/src/worker/cms-worker.ts
|
|
73314
73314
|
var import_proper_lockfile3 = __toESM(require_proper_lockfile(), 1);
|
|
73315
73315
|
import { createHash as createHash2 } from "node:crypto";
|
|
73316
|
-
import
|
|
73316
|
+
import fs32 from "node:fs/promises";
|
|
73317
73317
|
import os from "node:os";
|
|
73318
|
-
import
|
|
73318
|
+
import path34 from "node:path";
|
|
73319
73319
|
|
|
73320
73320
|
// ../canopycms/src/utils/debug.ts
|
|
73321
73321
|
var envFlag = (name2) => typeof process !== "undefined" && process.env[name2] === "true";
|
|
@@ -73552,7 +73552,7 @@ async function failTask(taskDir, taskId, error3, logger4 = nullLogger) {
|
|
|
73552
73552
|
});
|
|
73553
73553
|
logger4.debug("Failed task", { id: taskId, error: error3 });
|
|
73554
73554
|
}
|
|
73555
|
-
async function retryTask(taskDir, taskId, error3, logger4 = nullLogger) {
|
|
73555
|
+
async function retryTask(taskDir, taskId, error3, logger4 = nullLogger, options = {}) {
|
|
73556
73556
|
const processingPath = path2.join(taskDir, "processing", `${taskId}.json`);
|
|
73557
73557
|
const pendingDir = path2.join(taskDir, "pending");
|
|
73558
73558
|
const pendingPath = path2.join(pendingDir, `${taskId}.json`);
|
|
@@ -73572,7 +73572,7 @@ async function retryTask(taskDir, taskId, error3, logger4 = nullLogger) {
|
|
|
73572
73572
|
throw err;
|
|
73573
73573
|
}
|
|
73574
73574
|
const retryCount = (task.retryCount ?? 0) + 1;
|
|
73575
|
-
const backoffMs = Math.min(5e3 * Math.pow(2, retryCount - 1), 6e4);
|
|
73575
|
+
const backoffMs = options.delayMs ?? Math.min(5e3 * Math.pow(2, retryCount - 1), 6e4);
|
|
73576
73576
|
task.status = "pending";
|
|
73577
73577
|
task.retryCount = retryCount;
|
|
73578
73578
|
task.retryAfter = new Date(Date.now() + backoffMs).toISOString();
|
|
@@ -74500,8 +74500,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
74500
74500
|
function forEachLineWithContent(input, callback) {
|
|
74501
74501
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
74502
74502
|
}
|
|
74503
|
-
function folderExists(
|
|
74504
|
-
return (0, import_file_exists.exists)(
|
|
74503
|
+
function folderExists(path37) {
|
|
74504
|
+
return (0, import_file_exists.exists)(path37, import_file_exists.FOLDER);
|
|
74505
74505
|
}
|
|
74506
74506
|
function append(target, item) {
|
|
74507
74507
|
if (Array.isArray(target)) {
|
|
@@ -74903,8 +74903,8 @@ function checkIsRepoRootTask() {
|
|
|
74903
74903
|
commands: commands9,
|
|
74904
74904
|
format: "utf-8",
|
|
74905
74905
|
onError,
|
|
74906
|
-
parser(
|
|
74907
|
-
return /^\.(git)?$/.test(
|
|
74906
|
+
parser(path37) {
|
|
74907
|
+
return /^\.(git)?$/.test(path37.trim());
|
|
74908
74908
|
}
|
|
74909
74909
|
};
|
|
74910
74910
|
}
|
|
@@ -75338,11 +75338,11 @@ function parseGrep(grep) {
|
|
|
75338
75338
|
const paths = /* @__PURE__ */ new Set();
|
|
75339
75339
|
const results = {};
|
|
75340
75340
|
forEachLineWithContent(grep, (input) => {
|
|
75341
|
-
const [
|
|
75342
|
-
paths.add(
|
|
75343
|
-
(results[
|
|
75341
|
+
const [path37, line, preview] = input.split(NULL);
|
|
75342
|
+
paths.add(path37);
|
|
75343
|
+
(results[path37] = results[path37] || []).push({
|
|
75344
75344
|
line: asNumber(line),
|
|
75345
|
-
path:
|
|
75345
|
+
path: path37,
|
|
75346
75346
|
preview
|
|
75347
75347
|
});
|
|
75348
75348
|
});
|
|
@@ -76106,14 +76106,14 @@ var init_hash_object = __esm2({
|
|
|
76106
76106
|
init_task();
|
|
76107
76107
|
}
|
|
76108
76108
|
});
|
|
76109
|
-
function parseInit(bare,
|
|
76109
|
+
function parseInit(bare, path37, text) {
|
|
76110
76110
|
const response = String(text).trim();
|
|
76111
76111
|
let result;
|
|
76112
76112
|
if (result = initResponseRegex.exec(response)) {
|
|
76113
|
-
return new InitSummary(bare,
|
|
76113
|
+
return new InitSummary(bare, path37, false, result[1]);
|
|
76114
76114
|
}
|
|
76115
76115
|
if (result = reInitResponseRegex.exec(response)) {
|
|
76116
|
-
return new InitSummary(bare,
|
|
76116
|
+
return new InitSummary(bare, path37, true, result[1]);
|
|
76117
76117
|
}
|
|
76118
76118
|
let gitDir = "";
|
|
76119
76119
|
const tokens = response.split(" ");
|
|
@@ -76124,7 +76124,7 @@ function parseInit(bare, path36, text) {
|
|
|
76124
76124
|
break;
|
|
76125
76125
|
}
|
|
76126
76126
|
}
|
|
76127
|
-
return new InitSummary(bare,
|
|
76127
|
+
return new InitSummary(bare, path37, /^re/i.test(response), gitDir);
|
|
76128
76128
|
}
|
|
76129
76129
|
var InitSummary;
|
|
76130
76130
|
var initResponseRegex;
|
|
@@ -76133,9 +76133,9 @@ var init_InitSummary = __esm2({
|
|
|
76133
76133
|
"src/lib/responses/InitSummary.ts"() {
|
|
76134
76134
|
"use strict";
|
|
76135
76135
|
InitSummary = class {
|
|
76136
|
-
constructor(bare,
|
|
76136
|
+
constructor(bare, path37, existing, gitDir) {
|
|
76137
76137
|
this.bare = bare;
|
|
76138
|
-
this.path =
|
|
76138
|
+
this.path = path37;
|
|
76139
76139
|
this.existing = existing;
|
|
76140
76140
|
this.gitDir = gitDir;
|
|
76141
76141
|
}
|
|
@@ -76147,7 +76147,7 @@ var init_InitSummary = __esm2({
|
|
|
76147
76147
|
function hasBareCommand(command5) {
|
|
76148
76148
|
return command5.includes(bareCommand);
|
|
76149
76149
|
}
|
|
76150
|
-
function initTask(bare = false,
|
|
76150
|
+
function initTask(bare = false, path37, customArgs) {
|
|
76151
76151
|
const commands9 = ["init", ...customArgs];
|
|
76152
76152
|
if (bare && !hasBareCommand(commands9)) {
|
|
76153
76153
|
commands9.splice(1, 0, bareCommand);
|
|
@@ -76156,7 +76156,7 @@ function initTask(bare = false, path36, customArgs) {
|
|
|
76156
76156
|
commands: commands9,
|
|
76157
76157
|
format: "utf-8",
|
|
76158
76158
|
parser(text) {
|
|
76159
|
-
return parseInit(commands9.includes("--bare"),
|
|
76159
|
+
return parseInit(commands9.includes("--bare"), path37, text);
|
|
76160
76160
|
}
|
|
76161
76161
|
};
|
|
76162
76162
|
}
|
|
@@ -76971,12 +76971,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
76971
76971
|
"use strict";
|
|
76972
76972
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
76973
76973
|
FileStatusSummary = class {
|
|
76974
|
-
constructor(
|
|
76975
|
-
this.path =
|
|
76974
|
+
constructor(path37, index, working_dir) {
|
|
76975
|
+
this.path = path37;
|
|
76976
76976
|
this.index = index;
|
|
76977
76977
|
this.working_dir = working_dir;
|
|
76978
76978
|
if (index === "R" || working_dir === "R") {
|
|
76979
|
-
const detail = fromPathRegex.exec(
|
|
76979
|
+
const detail = fromPathRegex.exec(path37) || [null, path37, path37];
|
|
76980
76980
|
this.from = detail[2] || "";
|
|
76981
76981
|
this.path = detail[1] || "";
|
|
76982
76982
|
}
|
|
@@ -77007,14 +77007,14 @@ function splitLine(result, lineStr) {
|
|
|
77007
77007
|
default:
|
|
77008
77008
|
return;
|
|
77009
77009
|
}
|
|
77010
|
-
function data3(index, workingDir,
|
|
77010
|
+
function data3(index, workingDir, path37) {
|
|
77011
77011
|
const raw = `${index}${workingDir}`;
|
|
77012
77012
|
const handler = parsers6.get(raw);
|
|
77013
77013
|
if (handler) {
|
|
77014
|
-
handler(result,
|
|
77014
|
+
handler(result, path37);
|
|
77015
77015
|
}
|
|
77016
77016
|
if (raw !== "##" && raw !== "!!") {
|
|
77017
|
-
result.files.push(new FileStatusSummary(
|
|
77017
|
+
result.files.push(new FileStatusSummary(path37, index, workingDir));
|
|
77018
77018
|
}
|
|
77019
77019
|
}
|
|
77020
77020
|
}
|
|
@@ -77365,9 +77365,9 @@ var init_simple_git_api = __esm2({
|
|
|
77365
77365
|
next
|
|
77366
77366
|
);
|
|
77367
77367
|
}
|
|
77368
|
-
hashObject(
|
|
77368
|
+
hashObject(path37, write) {
|
|
77369
77369
|
return this._runTask(
|
|
77370
|
-
hashObjectTask(
|
|
77370
|
+
hashObjectTask(path37, write === true),
|
|
77371
77371
|
trailingFunctionArgument(arguments)
|
|
77372
77372
|
);
|
|
77373
77373
|
}
|
|
@@ -77721,8 +77721,8 @@ var init_branch = __esm2({
|
|
|
77721
77721
|
}
|
|
77722
77722
|
});
|
|
77723
77723
|
function toPath(input) {
|
|
77724
|
-
const
|
|
77725
|
-
return
|
|
77724
|
+
const path37 = input.trim().replace(/^["']|["']$/g, "");
|
|
77725
|
+
return path37 && normalize(path37);
|
|
77726
77726
|
}
|
|
77727
77727
|
var parseCheckIgnore;
|
|
77728
77728
|
var init_CheckIgnore = __esm2({
|
|
@@ -78007,8 +78007,8 @@ __export2(sub_module_exports, {
|
|
|
78007
78007
|
subModuleTask: () => subModuleTask,
|
|
78008
78008
|
updateSubModuleTask: () => updateSubModuleTask
|
|
78009
78009
|
});
|
|
78010
|
-
function addSubModuleTask(repo,
|
|
78011
|
-
return subModuleTask(["add", repo,
|
|
78010
|
+
function addSubModuleTask(repo, path37) {
|
|
78011
|
+
return subModuleTask(["add", repo, path37]);
|
|
78012
78012
|
}
|
|
78013
78013
|
function initSubModuleTask(customArgs) {
|
|
78014
78014
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -78322,8 +78322,8 @@ var require_git = __commonJS2({
|
|
|
78322
78322
|
}
|
|
78323
78323
|
return this._runTask(straightThroughStringTask2(command5, this._trimmed), next);
|
|
78324
78324
|
};
|
|
78325
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
78326
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
78325
|
+
Git2.prototype.submoduleAdd = function(repo, path37, then) {
|
|
78326
|
+
return this._runTask(addSubModuleTask2(repo, path37), trailingFunctionArgument2(arguments));
|
|
78327
78327
|
};
|
|
78328
78328
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
78329
78329
|
return this._runTask(
|
|
@@ -78904,6 +78904,7 @@ init_error();
|
|
|
78904
78904
|
import fs3 from "node:fs/promises";
|
|
78905
78905
|
import path4 from "node:path";
|
|
78906
78906
|
import { randomUUID } from "node:crypto";
|
|
78907
|
+
init_logger();
|
|
78907
78908
|
var log = createDebugLogger({ prefix: "ResourceGeneration" });
|
|
78908
78909
|
var META_DIR = ".canopy-meta";
|
|
78909
78910
|
function resourceGenerationPath(root5, resource) {
|
|
@@ -78915,9 +78916,10 @@ async function bumpResourceGeneration(root5, resource, options) {
|
|
|
78915
78916
|
await atomicWriteFile(resourceGenerationPath(root5, resource), token);
|
|
78916
78917
|
return token;
|
|
78917
78918
|
} catch (err) {
|
|
78918
|
-
|
|
78919
|
-
|
|
78920
|
-
|
|
78919
|
+
canopyLogWarn(
|
|
78920
|
+
`CanopyCMS: failed to bump ${resource} generation for ${root5}:`,
|
|
78921
|
+
getErrorMessage(err)
|
|
78922
|
+
);
|
|
78921
78923
|
if (options?.mustSucceed) throw err;
|
|
78922
78924
|
return null;
|
|
78923
78925
|
}
|
|
@@ -78938,6 +78940,50 @@ function isGenerationCurrent(snapshotToken, read) {
|
|
|
78938
78940
|
return read.ok && read.token === snapshotToken;
|
|
78939
78941
|
}
|
|
78940
78942
|
|
|
78943
|
+
// ../../node_modules/.pnpm/lru-cache@10.4.3/node_modules/lru-cache/dist/esm/index.js
|
|
78944
|
+
var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
|
|
78945
|
+
var PROCESS = typeof process === "object" && !!process ? process : {};
|
|
78946
|
+
var emitWarning = (msg, type, code, fn) => {
|
|
78947
|
+
typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
78948
|
+
};
|
|
78949
|
+
var AC = globalThis.AbortController;
|
|
78950
|
+
var AS = globalThis.AbortSignal;
|
|
78951
|
+
if (typeof AC === "undefined") {
|
|
78952
|
+
AS = class AbortSignal {
|
|
78953
|
+
onabort;
|
|
78954
|
+
_onabort = [];
|
|
78955
|
+
reason;
|
|
78956
|
+
aborted = false;
|
|
78957
|
+
addEventListener(_3, fn) {
|
|
78958
|
+
this._onabort.push(fn);
|
|
78959
|
+
}
|
|
78960
|
+
};
|
|
78961
|
+
AC = class AbortController {
|
|
78962
|
+
constructor() {
|
|
78963
|
+
warnACPolyfill();
|
|
78964
|
+
}
|
|
78965
|
+
signal = new AS();
|
|
78966
|
+
abort(reason) {
|
|
78967
|
+
if (this.signal.aborted)
|
|
78968
|
+
return;
|
|
78969
|
+
this.signal.reason = reason;
|
|
78970
|
+
this.signal.aborted = true;
|
|
78971
|
+
for (const fn of this.signal._onabort) {
|
|
78972
|
+
fn(reason);
|
|
78973
|
+
}
|
|
78974
|
+
this.signal.onabort?.(reason);
|
|
78975
|
+
}
|
|
78976
|
+
};
|
|
78977
|
+
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
|
|
78978
|
+
const warnACPolyfill = () => {
|
|
78979
|
+
if (!printACPolyfillWarning)
|
|
78980
|
+
return;
|
|
78981
|
+
printACPolyfillWarning = false;
|
|
78982
|
+
emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill);
|
|
78983
|
+
};
|
|
78984
|
+
}
|
|
78985
|
+
var TYPE = Symbol("type");
|
|
78986
|
+
|
|
78941
78987
|
// ../canopycms/src/id.ts
|
|
78942
78988
|
var import_short_uuid = __toESM(require_dist3(), 1);
|
|
78943
78989
|
init_validation();
|
|
@@ -79060,6 +79106,7 @@ async function readHeadBranch(gitDir, git = simpleGit()) {
|
|
|
79060
79106
|
}
|
|
79061
79107
|
|
|
79062
79108
|
// ../canopycms/src/branch-schema-cache.ts
|
|
79109
|
+
var SNAPSHOT_MEMO_MAX_BYTES = 64 * 1024 * 1024;
|
|
79063
79110
|
var SCHEMA_CACHE_FILE = "schema-cache.json";
|
|
79064
79111
|
var SCHEMA_GENERATION_RESOURCE = "schema";
|
|
79065
79112
|
|
|
@@ -79694,7 +79741,7 @@ function reviewTime(at) {
|
|
|
79694
79741
|
const time3 = typeof at === "string" ? new Date(at) : void 0;
|
|
79695
79742
|
return time3 && !Number.isNaN(time3.getTime()) ? `${time3.toISOString().slice(0, 16).replace("T", " ")} UTC` : void 0;
|
|
79696
79743
|
}
|
|
79697
|
-
function buildReviewBlock(review) {
|
|
79744
|
+
function buildReviewBlock(review, keptOverGitHub = []) {
|
|
79698
79745
|
const verdict = review?.state === "approved" ? "Approved" : review?.state === "changes-requested" ? "Changes requested" : void 0;
|
|
79699
79746
|
let status = "Not yet reviewed in CanopyCMS.";
|
|
79700
79747
|
if (review && verdict) {
|
|
@@ -79702,10 +79749,26 @@ function buildReviewBlock(review) {
|
|
|
79702
79749
|
const when = reviewTime(review.at);
|
|
79703
79750
|
status = `${verdict} in CanopyCMS by ${name2 ? codeSpan(name2) : "a reviewer"}${when ? ` on ${when}` : ""}.`;
|
|
79704
79751
|
}
|
|
79752
|
+
const kept = keptOverGitHubNote(keptOverGitHub);
|
|
79705
79753
|
return `${PR_REVIEW_START}
|
|
79706
79754
|
${status}
|
|
79707
79755
|
${REVIEW_NOT_A_GITHUB_REVIEW}
|
|
79708
|
-
${PR_REVIEW_END}`;
|
|
79756
|
+
${kept}${PR_REVIEW_END}`;
|
|
79757
|
+
}
|
|
79758
|
+
var MAX_LISTED_KEPT_PATHS = 20;
|
|
79759
|
+
var MAX_KEPT_PATH_LENGTH = 120;
|
|
79760
|
+
function keptOverGitHubNote(paths) {
|
|
79761
|
+
if (paths.length === 0) return "";
|
|
79762
|
+
const listed = paths.slice(0, MAX_LISTED_KEPT_PATHS).flatMap((p8) => {
|
|
79763
|
+
const clean = cleanPath(p8);
|
|
79764
|
+
return clean ? [`- ${codeSpan(truncate(clean, MAX_KEPT_PATH_LENGTH))}`] : [];
|
|
79765
|
+
}).join("\n");
|
|
79766
|
+
const more = paths.length - MAX_LISTED_KEPT_PATHS;
|
|
79767
|
+
return `
|
|
79768
|
+
A commit on GitHub changed these files too. The editor's version was kept, and that change is no longer in them:
|
|
79769
|
+
${listed}
|
|
79770
|
+
${more > 0 ? `...and ${more} more
|
|
79771
|
+
` : ""}`;
|
|
79709
79772
|
}
|
|
79710
79773
|
var MAX_LISTED_THREADS = 50;
|
|
79711
79774
|
var MAX_EXCERPT_LENGTH = 80;
|
|
@@ -81592,6 +81655,11 @@ var MirrorSession = class {
|
|
|
81592
81655
|
}
|
|
81593
81656
|
return usable;
|
|
81594
81657
|
}
|
|
81658
|
+
/** Whether `tip`'s history holds `commit`. One the mirror doesn't hold, GitHub's heads don't. */
|
|
81659
|
+
async historyHolds(tip, commit) {
|
|
81660
|
+
if ((await this.objectTypes([commit])).get(commit) !== "commit") return false;
|
|
81661
|
+
return this.allReachable([commit], [tip]);
|
|
81662
|
+
}
|
|
81595
81663
|
/**
|
|
81596
81664
|
* Whether every one of `commits` is reachable from one of `tips`, in ONE walk: rev-list fed the
|
|
81597
81665
|
* commits and a `^<tip>` per tip lists what the tips do not reach, so empty output means all
|
|
@@ -81757,6 +81825,10 @@ var MirrorSession = class {
|
|
|
81757
81825
|
);
|
|
81758
81826
|
}
|
|
81759
81827
|
}
|
|
81828
|
+
const pinned = options.pin !== void 0 && await this.run(["rev-list", "--max-count=1", "--end-of-options", options.pin, `^${sha}`], {
|
|
81829
|
+
repo: options.repo
|
|
81830
|
+
}) === "";
|
|
81831
|
+
const lease = options.lease ?? (pinned ? options.pin : void 0);
|
|
81760
81832
|
options.onPushing?.();
|
|
81761
81833
|
const status = await this.githubBound(
|
|
81762
81834
|
credential,
|
|
@@ -81764,7 +81836,7 @@ var MirrorSession = class {
|
|
|
81764
81836
|
"push",
|
|
81765
81837
|
"--porcelain",
|
|
81766
81838
|
"--progress",
|
|
81767
|
-
...
|
|
81839
|
+
...lease ? [`--force-with-lease=refs/heads/${branch}:${lease}`] : [],
|
|
81768
81840
|
"--end-of-options",
|
|
81769
81841
|
credential.url,
|
|
81770
81842
|
`${sha}:refs/heads/${branch}`
|
|
@@ -82438,6 +82510,7 @@ var LocalGitHubGateway = class {
|
|
|
82438
82510
|
async pushOnce(request, bundle, reach, signal) {
|
|
82439
82511
|
assertObjectId(request.sha, "a commit ID");
|
|
82440
82512
|
if (request.lease !== void 0) assertObjectId(request.lease, "a commit ID");
|
|
82513
|
+
if (request.seen !== void 0) assertObjectId(request.seen, "a commit ID");
|
|
82441
82514
|
if (request.prerequisites.length > MAX_PUSH_PREREQUISITES) {
|
|
82442
82515
|
throw new Error(`A push names at most ${MAX_PUSH_PREREQUISITES} prerequisites`);
|
|
82443
82516
|
}
|
|
@@ -82447,6 +82520,7 @@ var LocalGitHubGateway = class {
|
|
|
82447
82520
|
const credential = () => resolved ??= this.credential(reach);
|
|
82448
82521
|
const session = (received) => this.afterGitHubFetch(
|
|
82449
82522
|
async () => {
|
|
82523
|
+
if (request.seen !== void 0) this.githubFetch = null;
|
|
82450
82524
|
const snapshot = await this.joinGitHubFetchForPush(credential, request.branch, signal);
|
|
82451
82525
|
await credential();
|
|
82452
82526
|
return snapshot;
|
|
@@ -82499,8 +82573,16 @@ var LocalGitHubGateway = class {
|
|
|
82499
82573
|
} else {
|
|
82500
82574
|
repo = await mirror.quarantine(received, request, heads, signal);
|
|
82501
82575
|
}
|
|
82502
|
-
const
|
|
82576
|
+
const tip = heads.get(branch);
|
|
82577
|
+
if (request.seen !== void 0 && tip !== void 0 && !await mirror.historyHolds(tip, request.seen)) {
|
|
82578
|
+
throw new GitHubPushError(
|
|
82579
|
+
"seen-commit-gone",
|
|
82580
|
+
`GitHub's ${branch} no longer contains ${request.seen}, the last commit seen there`
|
|
82581
|
+
);
|
|
82582
|
+
}
|
|
82583
|
+
const attempt = (lease, pin) => mirror.pushToGitHub(credential, branch, sha, {
|
|
82503
82584
|
lease,
|
|
82585
|
+
pin,
|
|
82504
82586
|
signal,
|
|
82505
82587
|
repo,
|
|
82506
82588
|
policy: this.policy,
|
|
@@ -82508,7 +82590,8 @@ var LocalGitHubGateway = class {
|
|
|
82508
82590
|
onPushing: () => this.invalidateGitHubFetch()
|
|
82509
82591
|
});
|
|
82510
82592
|
try {
|
|
82511
|
-
|
|
82593
|
+
const pin = request.seen === void 0 || request.lease !== void 0 ? void 0 : tip;
|
|
82594
|
+
return { kind: "pushed", ...await attempt(request.lease, pin), pastStaleLease: false };
|
|
82512
82595
|
} catch (err) {
|
|
82513
82596
|
if (err instanceof RefusedPushError || err instanceof GitHubTransientError) throw err;
|
|
82514
82597
|
const message2 = getErrorMessage(err);
|
|
@@ -82586,7 +82669,9 @@ var LocalGitHubGateway = class {
|
|
|
82586
82669
|
merged_at: data3.merged_at,
|
|
82587
82670
|
state: data3.state,
|
|
82588
82671
|
node_id: data3.node_id,
|
|
82589
|
-
body: ours ? data3.body ?? "" : null
|
|
82672
|
+
body: ours ? data3.body ?? "" : null,
|
|
82673
|
+
mergeable_state: data3.mergeable_state,
|
|
82674
|
+
baseRef: data3.base.ref
|
|
82590
82675
|
};
|
|
82591
82676
|
});
|
|
82592
82677
|
}
|
|
@@ -82774,11 +82859,12 @@ async function unreachableFrom(ctx, gitDir, ids, tips) {
|
|
|
82774
82859
|
return unreachable;
|
|
82775
82860
|
}
|
|
82776
82861
|
async function pushToGitHub(ctx, request, readSha, signal) {
|
|
82777
|
-
const { prerequisiteBranches, ...rest } = request;
|
|
82862
|
+
const { prerequisiteBranches, readSeen, ...rest } = request;
|
|
82778
82863
|
for (let restarts = 0; ; restarts++) {
|
|
82779
82864
|
const sha = await readSha();
|
|
82865
|
+
const seen = await readSeen?.();
|
|
82780
82866
|
const prerequisites = await trackingTips(ctx.remoteGitPath, prerequisiteBranches);
|
|
82781
|
-
const ask = { ...rest, sha, prerequisites };
|
|
82867
|
+
const ask = { ...rest, sha, ...seen ? { seen } : {}, prerequisites };
|
|
82782
82868
|
const first2 = await ctx.github().push(ask, void 0, signal);
|
|
82783
82869
|
if (first2.kind === "pushed") return { sha, outcome: outcomeOf(first2) };
|
|
82784
82870
|
const bundle = await startBundle(ctx, request.branch, sha, first2.usable, signal);
|
|
@@ -83077,7 +83163,7 @@ init_error();
|
|
|
83077
83163
|
init_worker_status();
|
|
83078
83164
|
|
|
83079
83165
|
// ../canopycms/src/version.ts
|
|
83080
|
-
var CANOPYCMS_VERSION = "0.8.
|
|
83166
|
+
var CANOPYCMS_VERSION = "0.8.2";
|
|
83081
83167
|
|
|
83082
83168
|
// ../canopycms/src/worker/schema-gate.ts
|
|
83083
83169
|
import fs14 from "node:fs/promises";
|
|
@@ -83403,9 +83489,20 @@ var branchMetadataShape = {
|
|
|
83403
83489
|
mergedAt: external_exports.string().optional(),
|
|
83404
83490
|
rebaseFailure: external_exports.object({ message: external_exports.string(), firstAt: external_exports.string(), lastAt: external_exports.string() }).optional(),
|
|
83405
83491
|
historyRewrittenFrom: external_exports.string().optional(),
|
|
83492
|
+
lastGitHubTip: external_exports.string().optional(),
|
|
83493
|
+
keptOverGitHub: external_exports.array(external_exports.string()).optional(),
|
|
83494
|
+
rewrittenOnGitHub: external_exports.string().optional(),
|
|
83495
|
+
submitUnfinished: external_exports.boolean().optional(),
|
|
83496
|
+
submitNotQueued: external_exports.boolean().optional(),
|
|
83497
|
+
unpublishedAtMerge: external_exports.boolean().optional(),
|
|
83406
83498
|
syncFailureReason: external_exports.string().optional(),
|
|
83407
83499
|
editors: external_exports.array(external_exports.string()).optional(),
|
|
83408
83500
|
uncommittedEditors: external_exports.array(external_exports.string()).optional(),
|
|
83501
|
+
// Dropped when malformed: it only decorates the branch card, so it never fails a read.
|
|
83502
|
+
pullRequestHold: external_exports.discriminatedUnion("kind", [
|
|
83503
|
+
external_exports.object({ kind: external_exports.literal("conflicts") }),
|
|
83504
|
+
external_exports.object({ kind: external_exports.literal("retargeted"), base: external_exports.string() })
|
|
83505
|
+
]).optional().catch(void 0),
|
|
83409
83506
|
// Dropped when malformed: it only decorates the PR body, so it never fails a read.
|
|
83410
83507
|
review: external_exports.object({
|
|
83411
83508
|
state: external_exports.enum(["approved", "changes-requested"]),
|
|
@@ -84045,14 +84142,18 @@ function mergeBranchMetadata(existing, version, incoming, now = (/* @__PURE__ */
|
|
|
84045
84142
|
}
|
|
84046
84143
|
};
|
|
84047
84144
|
}
|
|
84048
|
-
|
|
84145
|
+
var awaitsSubmitRetry = ({ submitUnfinished, status }) => submitUnfinished === true && (status === "submitted" || status === "approved");
|
|
84146
|
+
var owesSubmit = (branch) => awaitsSubmitRetry(branch) || branch.syncStatus === "pending-sync" && (branch.status === "submitted" || branch.status === "approved");
|
|
84147
|
+
function buildMergedBranchUpdate(branch, now = /* @__PURE__ */ new Date()) {
|
|
84049
84148
|
return {
|
|
84050
84149
|
status: "archived",
|
|
84051
84150
|
pullRequestState: "merged",
|
|
84052
84151
|
mergedAt: now.toISOString(),
|
|
84053
84152
|
// The merge settled every conflict the record named.
|
|
84054
84153
|
conflictStatus: "clean",
|
|
84055
|
-
conflictFiles: []
|
|
84154
|
+
conflictFiles: [],
|
|
84155
|
+
submitUnfinished: void 0,
|
|
84156
|
+
...owesSubmit(branch) ? { unpublishedAtMerge: true } : {}
|
|
84056
84157
|
};
|
|
84057
84158
|
}
|
|
84058
84159
|
var getBranchMetadataFileManager = (branchRoot, baseRoot, options) => {
|
|
@@ -84161,7 +84262,7 @@ async function readStatusObject(taskDir) {
|
|
|
84161
84262
|
}
|
|
84162
84263
|
|
|
84163
84264
|
// ../canopycms/src/worker/task-runner.ts
|
|
84164
|
-
import
|
|
84265
|
+
import fs22 from "node:fs/promises";
|
|
84165
84266
|
init_branch_name();
|
|
84166
84267
|
init_error();
|
|
84167
84268
|
|
|
@@ -84184,6 +84285,7 @@ var pushRequest = external_exports.object({
|
|
|
84184
84285
|
branch: name,
|
|
84185
84286
|
sha: objectId,
|
|
84186
84287
|
lease: objectId.optional(),
|
|
84288
|
+
seen: objectId.optional(),
|
|
84187
84289
|
prerequisites: external_exports.array(objectId).max(3),
|
|
84188
84290
|
/** Whether the request body is a bundle; without one it is empty. */
|
|
84189
84291
|
bundle: external_exports.boolean()
|
|
@@ -84241,7 +84343,9 @@ var answers = {
|
|
|
84241
84343
|
merged_at: external_exports.string().max(64).nullable(),
|
|
84242
84344
|
state: external_exports.enum(["open", "closed"]),
|
|
84243
84345
|
node_id: external_exports.string().max(256),
|
|
84244
|
-
body: pullRequestText.body.nullable()
|
|
84346
|
+
body: pullRequestText.body.nullable(),
|
|
84347
|
+
mergeable_state: external_exports.string().max(64).optional(),
|
|
84348
|
+
baseRef: external_exports.string().max(256).optional()
|
|
84245
84349
|
}).strict(),
|
|
84246
84350
|
createOrUpdatePullRequest: pullRequestRef.extend({ created: external_exports.boolean() }).strict(),
|
|
84247
84351
|
convertPullRequestToDraft: empty,
|
|
@@ -84344,7 +84448,7 @@ var errorEnvelope = external_exports.discriminatedUnion("kind", [
|
|
|
84344
84448
|
}).strict(),
|
|
84345
84449
|
external_exports.object({
|
|
84346
84450
|
kind: external_exports.literal("push"),
|
|
84347
|
-
pushKind: external_exports.enum(["rejected", "rejected-after-stale-lease"]),
|
|
84451
|
+
pushKind: external_exports.enum(["rejected", "rejected-after-stale-lease", "seen-commit-gone"]),
|
|
84348
84452
|
message
|
|
84349
84453
|
}).strict(),
|
|
84350
84454
|
external_exports.object({
|
|
@@ -84557,13 +84661,19 @@ async function readPublishedSha(ctx, branchRef) {
|
|
|
84557
84661
|
return null;
|
|
84558
84662
|
}
|
|
84559
84663
|
}
|
|
84560
|
-
async function markHistoryRewritten(ctx, branchPath, branchRef, expectedSha) {
|
|
84664
|
+
async function markHistoryRewritten(ctx, branchPath, branchRef, expectedSha, rewrittenTip) {
|
|
84561
84665
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
84562
84666
|
let marked = false;
|
|
84563
84667
|
await meta.update((current) => {
|
|
84564
84668
|
marked = current?.branch.name === branchRef;
|
|
84565
|
-
if (!marked
|
|
84566
|
-
|
|
84669
|
+
if (!marked) return null;
|
|
84670
|
+
const marker = current?.branch.historyRewrittenFrom;
|
|
84671
|
+
return {
|
|
84672
|
+
branch: {
|
|
84673
|
+
historyRewrittenFrom: typeof marker === "string" ? marker : expectedSha,
|
|
84674
|
+
lastGitHubTip: rewrittenTip
|
|
84675
|
+
}
|
|
84676
|
+
};
|
|
84567
84677
|
});
|
|
84568
84678
|
return marked;
|
|
84569
84679
|
}
|
|
@@ -84656,6 +84766,15 @@ async function hasPendingHistoryRewrite(ctx, branchName) {
|
|
|
84656
84766
|
return false;
|
|
84657
84767
|
}
|
|
84658
84768
|
}
|
|
84769
|
+
async function recordSeenOnGitHub(ctx, branchName, sha) {
|
|
84770
|
+
const branchPath = path21.join(ctx.contentBranchesPath, sanitizeBranchName(branchName));
|
|
84771
|
+
const metaFile = await BranchMetadataFileManager.loadOnly(branchPath);
|
|
84772
|
+
if (metaFile?.branch.name !== branchName) return;
|
|
84773
|
+
await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).update(
|
|
84774
|
+
(current) => current?.branch.name === branchName ? { branch: { lastGitHubTip: sha } } : null,
|
|
84775
|
+
{ keepUpdatedAt: true }
|
|
84776
|
+
);
|
|
84777
|
+
}
|
|
84659
84778
|
|
|
84660
84779
|
// ../canopycms/src/worker/task-runner.ts
|
|
84661
84780
|
init_worker_status();
|
|
@@ -84885,18 +85004,23 @@ var SYNC_PR_COMMENTS_ACTION = "sync-pr-comments";
|
|
|
84885
85004
|
async function renderPrCommentsBody(options) {
|
|
84886
85005
|
const original = options.body;
|
|
84887
85006
|
let next = original;
|
|
84888
|
-
|
|
84889
|
-
|
|
84890
|
-
|
|
84891
|
-
|
|
84892
|
-
|
|
84893
|
-
|
|
84894
|
-
|
|
84895
|
-
|
|
85007
|
+
if (!options.reviewBlockOnly) {
|
|
85008
|
+
try {
|
|
85009
|
+
const threads = await new CommentStore(options.branchRoot).listThreadsStrict();
|
|
85010
|
+
next = mergeCommentsBlock(next, buildCommentsBlock(threads, options.branch, options.editorUrl)) ?? next;
|
|
85011
|
+
} catch (err) {
|
|
85012
|
+
if (!(err instanceof SyntaxError || err instanceof CommentsFileMalformedError)) throw err;
|
|
85013
|
+
options.warn(
|
|
85014
|
+
`Could not read the editor comments of ${options.branch}; the PR keeps its summary: ${getErrorMessage(err)}`
|
|
85015
|
+
);
|
|
85016
|
+
}
|
|
84896
85017
|
}
|
|
84897
85018
|
try {
|
|
84898
85019
|
const file = await readBranchMetadataFile(options.branchRoot);
|
|
84899
|
-
if (file)
|
|
85020
|
+
if (file) {
|
|
85021
|
+
const block = buildReviewBlock(file.branch.review, file.branch.keptOverGitHub);
|
|
85022
|
+
next = mergeReviewBlock(next, block) ?? next;
|
|
85023
|
+
}
|
|
84900
85024
|
} catch (err) {
|
|
84901
85025
|
if (!(err instanceof BranchMetadataCorruptError)) throw err;
|
|
84902
85026
|
options.warn(
|
|
@@ -84918,7 +85042,10 @@ async function refreshCommentsBlock(options) {
|
|
|
84918
85042
|
}
|
|
84919
85043
|
try {
|
|
84920
85044
|
const file = await readBranchMetadataFile(options.branchRoot);
|
|
84921
|
-
if (file)
|
|
85045
|
+
if (file) {
|
|
85046
|
+
const block = buildReviewBlock(file.branch.review, file.branch.keptOverGitHub);
|
|
85047
|
+
section = mergeReviewBlock(section, block) ?? section;
|
|
85048
|
+
}
|
|
84922
85049
|
} catch (err) {
|
|
84923
85050
|
options.warn(
|
|
84924
85051
|
`Could not re-read the review state of ${options.branch}; the PR gets it from submit time: ${getErrorMessage(err)}`
|
|
@@ -84927,6 +85054,454 @@ async function refreshCommentsBlock(options) {
|
|
|
84927
85054
|
return section;
|
|
84928
85055
|
}
|
|
84929
85056
|
|
|
85057
|
+
// ../canopycms/src/worker/github-commits.ts
|
|
85058
|
+
init_error();
|
|
85059
|
+
|
|
85060
|
+
// ../canopycms/src/worker/branch-merge.ts
|
|
85061
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
85062
|
+
import fs21 from "node:fs/promises";
|
|
85063
|
+
import path23 from "node:path";
|
|
85064
|
+
init_normalize();
|
|
85065
|
+
init_types2();
|
|
85066
|
+
init_error();
|
|
85067
|
+
var OBJECT_ID2 = /^[0-9a-f]{40}([0-9a-f]{24})?$/;
|
|
85068
|
+
var SETTLED_BY_KEEPING_HEAD = /* @__PURE__ */ new Set([
|
|
85069
|
+
"CONFLICT (contents)",
|
|
85070
|
+
"CONFLICT (binary)",
|
|
85071
|
+
"CONFLICT (modify/delete)"
|
|
85072
|
+
]);
|
|
85073
|
+
function parseMergeTree(output, head, other) {
|
|
85074
|
+
const fields = output.split("\0");
|
|
85075
|
+
const tree = fields[0];
|
|
85076
|
+
if (!OBJECT_ID2.test(tree)) throw new Error(`git merge-tree printed no tree for ${head}, ${other}`);
|
|
85077
|
+
const stages = [];
|
|
85078
|
+
let i10 = 1;
|
|
85079
|
+
for (; i10 < fields.length && fields[i10] !== ""; i10++) {
|
|
85080
|
+
const match2 = /^(\d+) ([0-9a-f]+) (\d)\t([\s\S]*)$/.exec(fields[i10]);
|
|
85081
|
+
if (!match2) throw new Error(`Unreadable git merge-tree entry: ${JSON.stringify(fields[i10])}`);
|
|
85082
|
+
const [, mode, oid, stage, path37] = match2;
|
|
85083
|
+
stages.push({ mode, oid, stage, path: path37 });
|
|
85084
|
+
}
|
|
85085
|
+
const unsettled = /* @__PURE__ */ new Set();
|
|
85086
|
+
for (i10++; i10 < fields.length && fields[i10] !== ""; ) {
|
|
85087
|
+
const kind = fields[i10 + parseInt(fields[i10], 10) + 1];
|
|
85088
|
+
if (kind?.startsWith("CONFLICT") && !SETTLED_BY_KEEPING_HEAD.has(kind)) unsettled.add(kind);
|
|
85089
|
+
i10 += parseInt(fields[i10], 10) + 3;
|
|
85090
|
+
}
|
|
85091
|
+
if (stages.some(({ path: path37 }) => path37.includes("\uFFFD"))) unsettled.add("an unreadable file name");
|
|
85092
|
+
return { tree, stages, unsettled: [...unsettled] };
|
|
85093
|
+
}
|
|
85094
|
+
async function buildMergeCommit(git, clonePath, args) {
|
|
85095
|
+
const { head, other, message: message2, timeoutMs } = args;
|
|
85096
|
+
const output = await git.raw([
|
|
85097
|
+
"merge-tree",
|
|
85098
|
+
"--write-tree",
|
|
85099
|
+
"-z",
|
|
85100
|
+
"--end-of-options",
|
|
85101
|
+
head,
|
|
85102
|
+
other
|
|
85103
|
+
]);
|
|
85104
|
+
const { tree: mergedTree, stages, unsettled } = parseMergeTree(output, head, other);
|
|
85105
|
+
const conflicted = [...new Set(stages.map(({ path: path37 }) => path37))];
|
|
85106
|
+
if (unsettled.length > 0) return { kind: "unsettled", conflicts: unsettled, paths: conflicted };
|
|
85107
|
+
const tree = stages.length === 0 ? mergedTree : await keepHeadStages(clonePath, { mergedTree, stages, conflicted, timeoutMs });
|
|
85108
|
+
const sha = (await git.raw(["commit-tree", "-p", head, "-p", other, "-m", message2, "--end-of-options", tree])).trim();
|
|
85109
|
+
return { kind: "built", sha, conflicted };
|
|
85110
|
+
}
|
|
85111
|
+
async function isCleanMergeOf(git, merged, from, other) {
|
|
85112
|
+
const output = await git.raw([
|
|
85113
|
+
"merge-tree",
|
|
85114
|
+
"--write-tree",
|
|
85115
|
+
"-z",
|
|
85116
|
+
"--end-of-options",
|
|
85117
|
+
from,
|
|
85118
|
+
other
|
|
85119
|
+
]);
|
|
85120
|
+
const { tree, stages } = parseMergeTree(output, from, other);
|
|
85121
|
+
if (stages.length > 0) return false;
|
|
85122
|
+
return (await git.revparse(["--verify", "--end-of-options", `${merged}^{tree}`])).trim() === tree;
|
|
85123
|
+
}
|
|
85124
|
+
async function keepHeadStages(clonePath, args) {
|
|
85125
|
+
const { mergedTree, stages, conflicted, timeoutMs } = args;
|
|
85126
|
+
const shared = sharedRepoProcessOptions(clonePath, "worktree");
|
|
85127
|
+
const indexFile = path23.join(clonePath, ".git", `canopy-merge-index-${randomUUID4()}`);
|
|
85128
|
+
const options = {
|
|
85129
|
+
...shared,
|
|
85130
|
+
env: { ...shared.env, GIT_INDEX_FILE: indexFile },
|
|
85131
|
+
inactivityTimeoutMs: timeoutMs
|
|
85132
|
+
};
|
|
85133
|
+
const kept = new Map(stages.filter((s7) => s7.stage === "2").map((s7) => [s7.path, s7]));
|
|
85134
|
+
const zeros = "0".repeat(mergedTree.length);
|
|
85135
|
+
const entries = conflicted.map((file) => {
|
|
85136
|
+
const entry = kept.get(file);
|
|
85137
|
+
return `${entry?.mode ?? "0"} ${entry?.oid ?? zeros} ${file}\0`;
|
|
85138
|
+
});
|
|
85139
|
+
try {
|
|
85140
|
+
await runGit(["read-tree", "--end-of-options", mergedTree], options);
|
|
85141
|
+
await runGit(["update-index", "-z", "--index-info"], { ...options, stdin: entries.join("") });
|
|
85142
|
+
return (await runGit(["write-tree"], options)).trim();
|
|
85143
|
+
} finally {
|
|
85144
|
+
await fs21.rm(indexFile, { force: true }).catch(() => {
|
|
85145
|
+
});
|
|
85146
|
+
}
|
|
85147
|
+
}
|
|
85148
|
+
async function publishPlainToLocalRemote(ctx, clonePath, branchRef, sha) {
|
|
85149
|
+
const pushGit = sharedRepoGit(clonePath, "worktree", { timeout: { block: ctx.taskTimeoutMs } });
|
|
85150
|
+
try {
|
|
85151
|
+
await pushGit.raw([
|
|
85152
|
+
"push",
|
|
85153
|
+
// Otherwise remote.git's own hooks run, as the worker.
|
|
85154
|
+
`--receive-pack=${pinnedReceivePack()}`,
|
|
85155
|
+
"--end-of-options",
|
|
85156
|
+
ctx.remoteGitPath,
|
|
85157
|
+
`${sha}:refs/heads/${branchRef}`
|
|
85158
|
+
]);
|
|
85159
|
+
return true;
|
|
85160
|
+
} catch (err) {
|
|
85161
|
+
if (isNonFastForwardRejection(redactCredentials(getErrorMessage(err)))) return false;
|
|
85162
|
+
throw err;
|
|
85163
|
+
}
|
|
85164
|
+
}
|
|
85165
|
+
async function commitsApart(git, a9, b10) {
|
|
85166
|
+
const counts = (await git.raw(["rev-list", "--left-right", "--count", "--end-of-options", `${a9}...${b10}`])).trim();
|
|
85167
|
+
const [left, right] = counts.split(/\s+/).map((n7) => parseInt(n7, 10));
|
|
85168
|
+
if (!Number.isInteger(left) || !Number.isInteger(right)) {
|
|
85169
|
+
throw new Error(`Unreadable rev-list output for ${a9}...${b10}: ${JSON.stringify(counts)}`);
|
|
85170
|
+
}
|
|
85171
|
+
return { onlyA: left, onlyB: right };
|
|
85172
|
+
}
|
|
85173
|
+
function conflictFilesToContentIds(conflictedFiles, contentRoot) {
|
|
85174
|
+
const normalizedContentRoot = normalizeFilesystemPath(contentRoot);
|
|
85175
|
+
const conflictIds = [...new Set(conflictedFiles)].map((f9) => {
|
|
85176
|
+
const fileId = extractIdFromFilename(path23.basename(f9));
|
|
85177
|
+
if (fileId) return fileId;
|
|
85178
|
+
const parentDir = path23.basename(path23.dirname(f9));
|
|
85179
|
+
const dirId = extractIdFromFilename(parentDir);
|
|
85180
|
+
if (dirId) return dirId;
|
|
85181
|
+
const parentPath = normalizeFilesystemPath(path23.dirname(f9));
|
|
85182
|
+
if (path23.basename(f9) === ".collection.json" && parentPath === normalizedContentRoot) {
|
|
85183
|
+
return ROOT_COLLECTION_ID;
|
|
85184
|
+
}
|
|
85185
|
+
return null;
|
|
85186
|
+
}).filter((id) => id !== null);
|
|
85187
|
+
return [...new Set(conflictIds)];
|
|
85188
|
+
}
|
|
85189
|
+
function recordConflicts(recorded, found) {
|
|
85190
|
+
const conflictFiles = [.../* @__PURE__ */ new Set([...recorded ?? [], ...found])];
|
|
85191
|
+
return {
|
|
85192
|
+
conflictStatus: conflictFiles.length > 0 ? "conflicts-detected" : "clean",
|
|
85193
|
+
conflictFiles
|
|
85194
|
+
};
|
|
85195
|
+
}
|
|
85196
|
+
|
|
85197
|
+
// ../canopycms/src/worker/github-commits.ts
|
|
85198
|
+
var COMMIT_ID = /^[0-9a-f]{40}([0-9a-f]{24})?$/;
|
|
85199
|
+
var MAX_LISTED_PATH_LENGTH = 200;
|
|
85200
|
+
var REWRITTEN_PUSH_REFUSAL = "This branch was changed on GitHub in a way CanopyCMS can't combine with the work here, so nothing was pushed. Nothing is lost.";
|
|
85201
|
+
var SEEN_COMMIT_GONE_PUSH_REFUSAL = "A commit this branch had on GitHub is no longer there, so nothing was pushed. Nothing is lost.";
|
|
85202
|
+
function rewriteCleared(branch) {
|
|
85203
|
+
const reason = branch.syncFailureReason;
|
|
85204
|
+
if (!reason?.includes(REWRITTEN_PUSH_REFUSAL) && !reason?.includes(SEEN_COMMIT_GONE_PUSH_REFUSAL)) {
|
|
85205
|
+
return { rewrittenOnGitHub: void 0 };
|
|
85206
|
+
}
|
|
85207
|
+
return awaitsSubmitRetry(branch) ? { rewrittenOnGitHub: void 0, syncFailureReason: void 0 } : { rewrittenOnGitHub: void 0, syncStatus: "synced", syncFailureReason: void 0 };
|
|
85208
|
+
}
|
|
85209
|
+
function isPublished({ branch }) {
|
|
85210
|
+
return branch.pushedToGitHubAt !== void 0 || branch.pullRequestNumber !== void 0;
|
|
85211
|
+
}
|
|
85212
|
+
async function bringInGitHubCommits(ctx, args) {
|
|
85213
|
+
const { git, branchRef, metaFile, dirty, gatewayPolicy } = args;
|
|
85214
|
+
const { branch } = metaFile;
|
|
85215
|
+
if (branch.name !== branchRef || !isPublished(metaFile)) return { kind: "in-step" };
|
|
85216
|
+
const gitHubTip = args.gitHub?.tips.get(branchRef);
|
|
85217
|
+
if (args.gitHub !== void 0 && gitHubTip === void 0 && branch.rewrittenOnGitHub) {
|
|
85218
|
+
await clearRewritten(ctx, args);
|
|
85219
|
+
}
|
|
85220
|
+
const published = await readPublishedSha(ctx, branchRef);
|
|
85221
|
+
const tip = gitHubTip ?? published;
|
|
85222
|
+
if (tip === null) return { kind: "in-step" };
|
|
85223
|
+
let head = (await git.revparse(["HEAD"])).trim();
|
|
85224
|
+
if (tip === head && (published === null || published === head)) {
|
|
85225
|
+
await recordGitHubTip(ctx, args, tip);
|
|
85226
|
+
return { kind: "in-step" };
|
|
85227
|
+
}
|
|
85228
|
+
if (ctx.ensureStatusReport().baseHold) return { kind: "wait" };
|
|
85229
|
+
if (published !== null && published !== head) {
|
|
85230
|
+
await fetchFromRemoteGit(git, ctx.remoteGitPath, `refs/heads/${branchRef}`);
|
|
85231
|
+
}
|
|
85232
|
+
if (tip !== head && tip !== published) {
|
|
85233
|
+
await fetchFromRemoteGit(git, ctx.remoteGitPath, `${GITHUB_TRACKING_REF_PREFIX}${branchRef}`);
|
|
85234
|
+
}
|
|
85235
|
+
let rewriteResolved = false;
|
|
85236
|
+
if (args.gitHub !== void 0 && gitHubTip !== void 0) {
|
|
85237
|
+
if (!await holdsCommit(git, tip)) return { kind: "wait" };
|
|
85238
|
+
const lastSeen = await rewrittenFrom(args, tip, head, published);
|
|
85239
|
+
if (lastSeen !== null) {
|
|
85240
|
+
return await pushedSinceFetch(args, args.gitHub.fetchedAt) ? { kind: "wait" } : blockAsRewritten(ctx, args, lastSeen);
|
|
85241
|
+
}
|
|
85242
|
+
if (branch.rewrittenOnGitHub !== void 0) {
|
|
85243
|
+
await clearRewritten(ctx, args);
|
|
85244
|
+
rewriteResolved = true;
|
|
85245
|
+
}
|
|
85246
|
+
}
|
|
85247
|
+
if (published !== null && published !== head) {
|
|
85248
|
+
if ((await commitsApart(git, head, published)).onlyA === 0) {
|
|
85249
|
+
const stopped = await fastForward(ctx, args, head, published);
|
|
85250
|
+
if (stopped) return stopped;
|
|
85251
|
+
head = published;
|
|
85252
|
+
}
|
|
85253
|
+
}
|
|
85254
|
+
if (tip !== head) {
|
|
85255
|
+
const { onlyA, onlyB } = await commitsApart(git, head, tip);
|
|
85256
|
+
if (onlyB > 0 && onlyA === 0) {
|
|
85257
|
+
if (gitHubTip !== void 0 && published !== null && published !== tip) {
|
|
85258
|
+
return { kind: "wait" };
|
|
85259
|
+
}
|
|
85260
|
+
const stopped = await fastForward(ctx, args, head, tip);
|
|
85261
|
+
if (stopped) return stopped;
|
|
85262
|
+
head = tip;
|
|
85263
|
+
} else if (onlyB > 0) {
|
|
85264
|
+
if (branch.historyRewrittenFrom === tip) {
|
|
85265
|
+
if (rewriteResolved) await enqueueGitHubPush(ctx, branchRef, gatewayPolicy);
|
|
85266
|
+
return { kind: "in-step" };
|
|
85267
|
+
}
|
|
85268
|
+
if (dirty) return { kind: "wait" };
|
|
85269
|
+
if (gatewayPolicy && !publishesBranch(gatewayPolicy, branchRef)) return { kind: "in-step" };
|
|
85270
|
+
return mergeIntoBranch(ctx, args, {
|
|
85271
|
+
head,
|
|
85272
|
+
other: tip,
|
|
85273
|
+
message: `Merge commits from GitHub into ${branchRef}`,
|
|
85274
|
+
fromGitHub: true
|
|
85275
|
+
});
|
|
85276
|
+
}
|
|
85277
|
+
}
|
|
85278
|
+
await recordGitHubTip(ctx, args, tip);
|
|
85279
|
+
if (gitHubTip !== void 0 && published !== null && published !== tip && (!gatewayPolicy || publishesBranch(gatewayPolicy, branchRef)) && await contains(git, published, tip)) {
|
|
85280
|
+
if (branch.syncStatus === "sync-failed" && !rewriteResolved) return { kind: "unpushed" };
|
|
85281
|
+
await enqueueGitHubPush(ctx, branchRef, gatewayPolicy);
|
|
85282
|
+
return { kind: "wait" };
|
|
85283
|
+
}
|
|
85284
|
+
return { kind: "in-step" };
|
|
85285
|
+
}
|
|
85286
|
+
async function pushedSinceFetch({ branchPath }, fetchedAt) {
|
|
85287
|
+
const pushedAt = (await BranchMetadataFileManager.loadOnly(branchPath))?.branch.pushedToGitHubAt;
|
|
85288
|
+
return pushedAt !== void 0 && Date.parse(pushedAt) >= fetchedAt;
|
|
85289
|
+
}
|
|
85290
|
+
async function rewrittenFrom({ git, metaFile }, tip, head, published) {
|
|
85291
|
+
const { lastGitHubTip, historyRewrittenFrom } = metaFile.branch;
|
|
85292
|
+
const unrecorded = lastGitHubTip === void 0 && published !== null && published !== head && await contains(git, published, head) && !await contains(git, published, tip) ? published : void 0;
|
|
85293
|
+
const known = [historyRewrittenFrom, lastGitHubTip ?? unrecorded].filter(
|
|
85294
|
+
(sha) => sha !== void 0 && COMMIT_ID.test(sha)
|
|
85295
|
+
);
|
|
85296
|
+
if (known.length === 0) return null;
|
|
85297
|
+
if (await contains(git, tip, head) && (published === null || await contains(git, tip, published))) {
|
|
85298
|
+
return null;
|
|
85299
|
+
}
|
|
85300
|
+
for (const sha of known) if (await contains(git, tip, sha)) return null;
|
|
85301
|
+
const walked = await git.raw(["rev-list", "--count", "--end-of-options", tip]);
|
|
85302
|
+
if (walked.trim() === "") throw new Error(`No answer reading the history of ${tip}`);
|
|
85303
|
+
return known[0];
|
|
85304
|
+
}
|
|
85305
|
+
async function blockAsRewritten(ctx, { branchPath, branchRef, metaFile }, lastSeen) {
|
|
85306
|
+
if (metaFile.branch.rewrittenOnGitHub !== lastSeen) {
|
|
85307
|
+
await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).saveIf(
|
|
85308
|
+
{ branch: { rewrittenOnGitHub: lastSeen } },
|
|
85309
|
+
(current) => current?.branch.name === branchRef
|
|
85310
|
+
);
|
|
85311
|
+
}
|
|
85312
|
+
return {
|
|
85313
|
+
kind: "blocked",
|
|
85314
|
+
reason: `GitHub's ${branchRef} no longer contains ${lastSeen}, the last commit this deployment saw there: it was force-pushed or rewritten. Nothing was merged or pushed, so the rewrite stands, and this branch's changes cannot reach GitHub. To continue, a developer merges that commit back into the branch on GitHub.`
|
|
85315
|
+
};
|
|
85316
|
+
}
|
|
85317
|
+
async function clearRewritten(ctx, { branchPath, branchRef }) {
|
|
85318
|
+
await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).update(
|
|
85319
|
+
(current) => current?.branch.name === branchRef ? { branch: rewriteCleared(current.branch) } : null
|
|
85320
|
+
);
|
|
85321
|
+
}
|
|
85322
|
+
function listPaths(paths) {
|
|
85323
|
+
return paths.slice(0, MAX_REPORTED_PATHS).map((file) => escapeForLog(file).slice(0, MAX_LISTED_PATH_LENGTH)).join(", ");
|
|
85324
|
+
}
|
|
85325
|
+
async function refuseIncoming({ git, branchPath }, from, to) {
|
|
85326
|
+
await assertNoIncomingSubmodules(git, branchPath, from, to);
|
|
85327
|
+
const fields = (await git.raw([
|
|
85328
|
+
"diff-tree",
|
|
85329
|
+
"-r",
|
|
85330
|
+
"-z",
|
|
85331
|
+
"--name-status",
|
|
85332
|
+
"--no-renames",
|
|
85333
|
+
"--end-of-options",
|
|
85334
|
+
from,
|
|
85335
|
+
to
|
|
85336
|
+
])).split("\0");
|
|
85337
|
+
const deleted = [];
|
|
85338
|
+
const changed = [];
|
|
85339
|
+
for (let i10 = 0; i10 + 1 < fields.length; i10 += 2) {
|
|
85340
|
+
const file = fields[i10 + 1];
|
|
85341
|
+
if (!isCanopyInternalPath(file)) continue;
|
|
85342
|
+
if (fields[i10] !== "D") changed.push(file);
|
|
85343
|
+
else if (file !== RETIRED_SCHEMA_CACHE_PATH) deleted.push(file);
|
|
85344
|
+
}
|
|
85345
|
+
if (changed.length > 0) {
|
|
85346
|
+
return {
|
|
85347
|
+
kind: "blocked",
|
|
85348
|
+
reason: `Commits coming into this branch change canopycms's own state, which must not be committed (${listPaths(changed)}). Nothing was brought in. To fix, ${TRACKED_CANOPY_STATE_FIX}.`
|
|
85349
|
+
};
|
|
85350
|
+
}
|
|
85351
|
+
if (deleted.length > 0) {
|
|
85352
|
+
return {
|
|
85353
|
+
kind: "blocked",
|
|
85354
|
+
reason: `Commits coming into this branch stop tracking canopycms state this clone still tracks (${listPaths(deleted)}). Nothing was brought in; the clone needs manual repair.`
|
|
85355
|
+
};
|
|
85356
|
+
}
|
|
85357
|
+
return null;
|
|
85358
|
+
}
|
|
85359
|
+
async function fastForward(ctx, args, from, to) {
|
|
85360
|
+
const { git, branchPath, branchDir, lockLost } = args;
|
|
85361
|
+
const refused = await refuseIncoming(args, from, to);
|
|
85362
|
+
if (refused) return refused;
|
|
85363
|
+
if (lockLost()) return { kind: "wait" };
|
|
85364
|
+
if (await changesWhatWasReviewed(ctx, args, from, to)) await returnToReview(ctx, args);
|
|
85365
|
+
try {
|
|
85366
|
+
await moveClone(git, branchPath, to);
|
|
85367
|
+
} catch (err) {
|
|
85368
|
+
if (!/would be overwritten/.test(getErrorMessage(err))) throw err;
|
|
85369
|
+
workerLog(` ${branchDir}: local changes overlap commits from GitHub, which wait for a submit`);
|
|
85370
|
+
return { kind: "wait" };
|
|
85371
|
+
}
|
|
85372
|
+
workerLog(` ${branchDir}: brought in commits from GitHub (now at ${to.slice(0, 7)})`);
|
|
85373
|
+
return null;
|
|
85374
|
+
}
|
|
85375
|
+
async function moveClone(git, branchPath, to) {
|
|
85376
|
+
await invalidateBranchContentCaches(branchPath);
|
|
85377
|
+
await git.raw(["merge", "--ff-only", "--end-of-options", to]);
|
|
85378
|
+
await invalidateBranchContentCaches(branchPath);
|
|
85379
|
+
}
|
|
85380
|
+
async function mergeIntoBranch(ctx, args, merge2) {
|
|
85381
|
+
const { git, branchPath, branchDir, branchRef, gatewayPolicy, lockLost } = args;
|
|
85382
|
+
const { head, other, message: message2, fromGitHub, stopOnConflict } = merge2;
|
|
85383
|
+
const built = await buildMergeCommit(git, branchPath, {
|
|
85384
|
+
head,
|
|
85385
|
+
other,
|
|
85386
|
+
message: message2,
|
|
85387
|
+
timeoutMs: ctx.taskTimeoutMs
|
|
85388
|
+
});
|
|
85389
|
+
if (stopOnConflict && (built.kind === "unsettled" || built.conflicted.length > 0)) {
|
|
85390
|
+
workerLog(` ${branchDir}: conflicts with ${other.slice(0, 7)}, so it stays as it is`);
|
|
85391
|
+
return { kind: "wait" };
|
|
85392
|
+
}
|
|
85393
|
+
if (built.kind === "unsettled") {
|
|
85394
|
+
return {
|
|
85395
|
+
kind: "blocked",
|
|
85396
|
+
reason: `Git cannot merge ${other} into ${branchRef} by rule: ${built.conflicts.join(", ")}${built.paths.length > 0 ? ` (${listPaths(built.paths)})` : ""}. Nothing was changed. To continue, a developer merges them by hand.`
|
|
85397
|
+
};
|
|
85398
|
+
}
|
|
85399
|
+
const { sha, conflicted } = built;
|
|
85400
|
+
const refused = await refuseIncoming(args, head, sha);
|
|
85401
|
+
if (refused) return refused;
|
|
85402
|
+
if (lockLost()) return { kind: "wait" };
|
|
85403
|
+
if (fromGitHub && await changesWhatWasReviewed(ctx, args, head, sha)) {
|
|
85404
|
+
await returnToReview(ctx, args);
|
|
85405
|
+
}
|
|
85406
|
+
const published = await readPublishedSha(ctx, branchRef);
|
|
85407
|
+
const unpublishable = `This deployment's repository holds commits for ${branchRef} that neither this clone nor GitHub has, so a merge of the two cannot be published. Nothing was changed. Compare the copies with a developer before submitting again.`;
|
|
85408
|
+
if (published !== null && !await contains(git, sha, published)) {
|
|
85409
|
+
return { kind: "blocked", reason: unpublishable };
|
|
85410
|
+
}
|
|
85411
|
+
if (conflicted.length > 0) await recordKeptVersions(ctx, args, conflicted, fromGitHub);
|
|
85412
|
+
if (fromGitHub) await recordSeenOnGitHub(ctx, branchRef, other);
|
|
85413
|
+
if (published !== null) {
|
|
85414
|
+
if (!await publishPlainToLocalRemote(ctx, branchPath, branchRef, sha)) {
|
|
85415
|
+
return { kind: "blocked", reason: unpublishable };
|
|
85416
|
+
}
|
|
85417
|
+
await enqueueGitHubPush(ctx, branchRef, gatewayPolicy);
|
|
85418
|
+
}
|
|
85419
|
+
if (conflicted.length > 0 && fromGitHub) {
|
|
85420
|
+
await enqueueReviewBlockSync(ctx, branchRef, args.metaFile);
|
|
85421
|
+
}
|
|
85422
|
+
await moveClone(git, branchPath, sha);
|
|
85423
|
+
if (fromGitHub) await recordGitHubTip(ctx, args, other);
|
|
85424
|
+
workerLog(
|
|
85425
|
+
conflicted.length > 0 ? ` ${branchDir}: merged ${other.slice(0, 7)} (kept this branch's version of ${conflicted.length} file(s))` : ` ${branchDir}: merged ${other.slice(0, 7)}`
|
|
85426
|
+
);
|
|
85427
|
+
return { kind: "merged" };
|
|
85428
|
+
}
|
|
85429
|
+
async function holdsCommit(git, sha) {
|
|
85430
|
+
let found;
|
|
85431
|
+
try {
|
|
85432
|
+
found = await git.raw(["rev-parse", "--verify", "--end-of-options", `${sha}^{commit}`]);
|
|
85433
|
+
} catch (err) {
|
|
85434
|
+
if (/Needed a single revision/.test(getErrorMessage(err))) return false;
|
|
85435
|
+
throw err;
|
|
85436
|
+
}
|
|
85437
|
+
if (found.trim() === "") throw new Error(`No answer looking for ${sha}`);
|
|
85438
|
+
return true;
|
|
85439
|
+
}
|
|
85440
|
+
async function contains(git, commit, ancestor) {
|
|
85441
|
+
if (!await holdsCommit(git, commit) || !await holdsCommit(git, ancestor)) return false;
|
|
85442
|
+
return (await commitsApart(git, ancestor, commit)).onlyA === 0;
|
|
85443
|
+
}
|
|
85444
|
+
async function changesWhatWasReviewed(ctx, { git, branchPath }, from, to) {
|
|
85445
|
+
const fresh = (await BranchMetadataFileManager.loadOnly(branchPath))?.branch;
|
|
85446
|
+
if (fresh?.status !== "approved") return false;
|
|
85447
|
+
await fetchFromRemoteGit(git, ctx.remoteGitPath, fresh.baseBranch ?? ctx.baseBranch);
|
|
85448
|
+
const base = (await git.revparse(["FETCH_HEAD"])).trim();
|
|
85449
|
+
const forkPoint = (await git.raw(["merge-base", "--end-of-options", to, base])).trim();
|
|
85450
|
+
return forkPoint === "" || !await isCleanMergeOf(git, to, from, forkPoint);
|
|
85451
|
+
}
|
|
85452
|
+
async function returnToReview(ctx, { branchPath, branchDir, branchRef, metaFile }) {
|
|
85453
|
+
const saved = await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).saveIf(
|
|
85454
|
+
{ branch: { status: "submitted", review: void 0 } },
|
|
85455
|
+
(current) => current?.branch.name === branchRef && current.branch.status === "approved"
|
|
85456
|
+
);
|
|
85457
|
+
if (saved === null) return;
|
|
85458
|
+
workerLog(` ${branchDir}: back in review, as commits from GitHub changed what was approved`);
|
|
85459
|
+
await enqueueReviewBlockSync(ctx, branchRef, metaFile);
|
|
85460
|
+
}
|
|
85461
|
+
async function recordKeptVersions(ctx, { branchPath, branchRef }, conflicted, fromGitHub) {
|
|
85462
|
+
const ids = conflictFilesToContentIds(conflicted, ctx.contentRoot);
|
|
85463
|
+
await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).update(
|
|
85464
|
+
(existing) => existing?.branch.name === branchRef ? {
|
|
85465
|
+
branch: {
|
|
85466
|
+
...recordConflicts(existing.branch.conflictFiles, ids),
|
|
85467
|
+
...fromGitHub ? {
|
|
85468
|
+
keptOverGitHub: [
|
|
85469
|
+
.../* @__PURE__ */ new Set([...existing.branch.keptOverGitHub ?? [], ...conflicted])
|
|
85470
|
+
]
|
|
85471
|
+
} : {}
|
|
85472
|
+
}
|
|
85473
|
+
} : null
|
|
85474
|
+
);
|
|
85475
|
+
}
|
|
85476
|
+
async function enqueueReviewBlockSync(ctx, branchRef, { branch }) {
|
|
85477
|
+
if (branch.pullRequestNumber === void 0) return;
|
|
85478
|
+
try {
|
|
85479
|
+
await enqueueTask(ctx.taskDir, {
|
|
85480
|
+
action: SYNC_PR_COMMENTS_ACTION,
|
|
85481
|
+
payload: {
|
|
85482
|
+
branch: branchRef,
|
|
85483
|
+
pullRequestNumber: branch.pullRequestNumber,
|
|
85484
|
+
reviewBlockOnly: true
|
|
85485
|
+
}
|
|
85486
|
+
});
|
|
85487
|
+
} catch (err) {
|
|
85488
|
+
workerLogWarn(` Failed to queue a PR body update for ${branchRef}: ${getErrorMessage(err)}`);
|
|
85489
|
+
}
|
|
85490
|
+
}
|
|
85491
|
+
async function recordGitHubTip(ctx, { branchPath, branchRef, metaFile, gitHub }, tip) {
|
|
85492
|
+
const { lastGitHubTip, rewrittenOnGitHub } = metaFile.branch;
|
|
85493
|
+
if (gitHub?.tips.get(branchRef) !== tip) return;
|
|
85494
|
+
if (lastGitHubTip === tip && rewrittenOnGitHub === void 0) return;
|
|
85495
|
+
await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).update(
|
|
85496
|
+
(current) => {
|
|
85497
|
+
if (current?.branch.name !== branchRef) return null;
|
|
85498
|
+
const seen = current.branch.lastGitHubTip === lastGitHubTip ? { lastGitHubTip: tip } : {};
|
|
85499
|
+
return { branch: { ...seen, ...rewriteCleared(current.branch) } };
|
|
85500
|
+
},
|
|
85501
|
+
{ keepUpdatedAt: true }
|
|
85502
|
+
);
|
|
85503
|
+
}
|
|
85504
|
+
|
|
84930
85505
|
// ../canopycms/src/worker/task-runner.ts
|
|
84931
85506
|
var PermanentTaskError = class extends Error {
|
|
84932
85507
|
};
|
|
@@ -84934,6 +85509,9 @@ var TaskAbortedForShutdownError = class extends Error {
|
|
|
84934
85509
|
};
|
|
84935
85510
|
var NothingToSubmitTaskError = class extends PermanentTaskError {
|
|
84936
85511
|
};
|
|
85512
|
+
var SUBMIT_ACTION = "push-and-create-or-update-pr";
|
|
85513
|
+
var GitHubMovedTaskError = class extends PermanentTaskError {
|
|
85514
|
+
};
|
|
84937
85515
|
function isPermanentTaskFailure(err) {
|
|
84938
85516
|
if (err instanceof PermanentTaskError || err instanceof GatewayRefusalError || err instanceof GatewayRequestRefusedError) {
|
|
84939
85517
|
return true;
|
|
@@ -85019,7 +85597,13 @@ async function processTaskQueue(ctx) {
|
|
|
85019
85597
|
const permanent = isPermanentTaskFailure(err);
|
|
85020
85598
|
const retryCount = task.retryCount ?? 0;
|
|
85021
85599
|
const maxRetries = task.maxRetries ?? ctx.maxRetries;
|
|
85022
|
-
|
|
85600
|
+
const waitsForSync = err instanceof GitHubMovedTaskError;
|
|
85601
|
+
if (waitsForSync && retryCount < maxRetries) {
|
|
85602
|
+
await retryTask(ctx.taskDir, task.id, persistedMessage, ctx.log, {
|
|
85603
|
+
delayMs: ctx.gitSyncIntervalMs
|
|
85604
|
+
});
|
|
85605
|
+
workerLog(` Will retry after the next sync (attempt ${retryCount + 1}/${maxRetries})`);
|
|
85606
|
+
} else if (!permanent && retryCount < maxRetries) {
|
|
85023
85607
|
await retryTask(ctx.taskDir, task.id, persistedMessage, ctx.log);
|
|
85024
85608
|
workerLog(` Will retry (attempt ${retryCount + 1}/${maxRetries})`);
|
|
85025
85609
|
} else {
|
|
@@ -85028,7 +85612,7 @@ async function processTaskQueue(ctx) {
|
|
|
85028
85612
|
unlock: err instanceof NothingToSubmitTaskError
|
|
85029
85613
|
});
|
|
85030
85614
|
workerLogError(
|
|
85031
|
-
permanent ? " Permanently failed (non-retryable error)" : ` Permanently failed after ${maxRetries} retries`
|
|
85615
|
+
permanent && !waitsForSync ? " Permanently failed (non-retryable error)" : ` Permanently failed after ${maxRetries} retries`
|
|
85032
85616
|
);
|
|
85033
85617
|
}
|
|
85034
85618
|
}
|
|
@@ -85103,6 +85687,10 @@ async function executeTask(ctx, task, signal) {
|
|
|
85103
85687
|
}
|
|
85104
85688
|
case "push-and-create-or-update-pr": {
|
|
85105
85689
|
const branch = requireString(payload3, "branch");
|
|
85690
|
+
if (await isSupersededSubmit(ctx, task, branch)) {
|
|
85691
|
+
workerLog(`Not retrying the submit of ${branch}: the branch has moved on from it`);
|
|
85692
|
+
return { superseded: true };
|
|
85693
|
+
}
|
|
85106
85694
|
const base = optionalString(payload3, "baseBranch", ctx.baseBranch);
|
|
85107
85695
|
if (sanitizeBranchName(branch) === ctx.sanitizedBaseBranch) {
|
|
85108
85696
|
throw new PermanentTaskError(
|
|
@@ -85228,6 +85816,7 @@ async function executeTask(ctx, task, signal) {
|
|
|
85228
85816
|
branch: editorBranchOf(payload3, branch),
|
|
85229
85817
|
editorUrl,
|
|
85230
85818
|
body: pr.body,
|
|
85819
|
+
reviewBlockOnly: payload3.reviewBlockOnly === true,
|
|
85231
85820
|
warn: workerLogWarn
|
|
85232
85821
|
});
|
|
85233
85822
|
if (body === void 0) return { updated: false, skipped: "unchanged" };
|
|
@@ -85239,6 +85828,21 @@ async function executeTask(ctx, task, signal) {
|
|
|
85239
85828
|
throw new PermanentTaskError(`Unknown task action: ${action}`);
|
|
85240
85829
|
}
|
|
85241
85830
|
}
|
|
85831
|
+
async function isSupersededSubmit(ctx, task, branch) {
|
|
85832
|
+
const { submittedAt, requeuedFrom } = task.payload;
|
|
85833
|
+
if (typeof submittedAt !== "string") return false;
|
|
85834
|
+
const live = await BranchMetadataFileManager.loadOnly(ctx.branchWorkspacePath(branch));
|
|
85835
|
+
if (live === null) return false;
|
|
85836
|
+
const { status, submittedAt: recorded } = live.branch;
|
|
85837
|
+
if (status === "archived") return true;
|
|
85838
|
+
const firstRun = !task.retryCount && requeuedFrom === void 0;
|
|
85839
|
+
if (firstRun && (recorded === void 0 || recorded < submittedAt)) return false;
|
|
85840
|
+
return status !== "submitted" && status !== "approved" || recorded !== submittedAt;
|
|
85841
|
+
}
|
|
85842
|
+
function isOlderSubmit(task, recorded) {
|
|
85843
|
+
const { submittedAt } = task.payload;
|
|
85844
|
+
return task.action === SUBMIT_ACTION && typeof submittedAt === "string" && recorded !== submittedAt;
|
|
85845
|
+
}
|
|
85242
85846
|
function editorBranchOf(payload3, branch) {
|
|
85243
85847
|
return optionalString(payload3, "editorBranch", branch);
|
|
85244
85848
|
}
|
|
@@ -85254,32 +85858,55 @@ async function updateBranchMetadata(ctx, task, result) {
|
|
|
85254
85858
|
if (!branch) return;
|
|
85255
85859
|
const branchPath = ctx.branchWorkspacePath(branch);
|
|
85256
85860
|
try {
|
|
85257
|
-
await
|
|
85861
|
+
await fs22.stat(branchPath);
|
|
85258
85862
|
} catch {
|
|
85259
85863
|
return;
|
|
85260
85864
|
}
|
|
85261
85865
|
try {
|
|
85262
85866
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
85263
|
-
|
|
85264
|
-
|
|
85265
|
-
|
|
85266
|
-
|
|
85267
|
-
|
|
85268
|
-
|
|
85269
|
-
|
|
85270
|
-
|
|
85271
|
-
|
|
85272
|
-
|
|
85273
|
-
|
|
85274
|
-
|
|
85275
|
-
|
|
85276
|
-
|
|
85277
|
-
|
|
85867
|
+
if (result.superseded === true) {
|
|
85868
|
+
await meta.update(
|
|
85869
|
+
(existing) => existing?.branch.name === branch && (existing.branch.status === "editing" ? existing.branch.syncStatus === "pending-sync" || existing.branch.submitUnfinished === true : existing.branch.status === "archived" && (existing.branch.syncStatus === "pending-sync" || existing.branch.syncStatus === "sync-failed")) ? {
|
|
85870
|
+
branch: {
|
|
85871
|
+
syncStatus: "synced",
|
|
85872
|
+
syncFailureReason: void 0,
|
|
85873
|
+
submitUnfinished: void 0
|
|
85874
|
+
}
|
|
85875
|
+
} : null,
|
|
85876
|
+
{ keepUpdatedAt: true }
|
|
85877
|
+
);
|
|
85878
|
+
return;
|
|
85879
|
+
}
|
|
85880
|
+
let found = false;
|
|
85881
|
+
await meta.update(
|
|
85882
|
+
(existing) => {
|
|
85883
|
+
if (existing?.branch.name !== branch) return null;
|
|
85884
|
+
found = true;
|
|
85885
|
+
const updates = isOlderSubmit(task, existing.branch.submittedAt) || task.action !== SUBMIT_ACTION && awaitsSubmitRetry(existing.branch) ? {} : {
|
|
85886
|
+
syncStatus: "synced",
|
|
85887
|
+
// save()'s merge only overwrites keys present in this update, so a prior
|
|
85888
|
+
// syncFailureReason would survive this successful sync forever unless
|
|
85889
|
+
// cleared explicitly (same pattern as rebaseFailure elsewhere).
|
|
85890
|
+
syncFailureReason: void 0,
|
|
85891
|
+
submitUnfinished: void 0
|
|
85892
|
+
};
|
|
85893
|
+
const archived = existing.branch.status === "archived";
|
|
85894
|
+
if (archived && result.prNumber) {
|
|
85895
|
+
workerLogWarn(`Not recording pull request #${result.prNumber} on merged ${branch}`);
|
|
85278
85896
|
}
|
|
85279
|
-
|
|
85280
|
-
|
|
85281
|
-
|
|
85282
|
-
|
|
85897
|
+
if (result.prUrl && !archived) updates.pullRequestUrl = result.prUrl;
|
|
85898
|
+
if (result.prNumber && !archived) {
|
|
85899
|
+
updates.pullRequestNumber = result.prNumber;
|
|
85900
|
+
const terminal = existing.branch.pullRequestState === "merged" || existing.branch.pullRequestState === "closed";
|
|
85901
|
+
if (!terminal) {
|
|
85902
|
+
updates.pullRequestState = "open";
|
|
85903
|
+
}
|
|
85904
|
+
}
|
|
85905
|
+
return Object.keys(updates).length > 0 ? { branch: updates } : null;
|
|
85906
|
+
},
|
|
85907
|
+
{ keepUpdatedAt: true }
|
|
85908
|
+
);
|
|
85909
|
+
if (!found) noMetadataToRecord(branch, `${task.action} outcome`);
|
|
85283
85910
|
} catch (err) {
|
|
85284
85911
|
workerLogError(
|
|
85285
85912
|
`Failed to update metadata for ${branch}:`,
|
|
@@ -85292,7 +85919,7 @@ async function updateBranchMetadataOnFailure(ctx, task, error3, options) {
|
|
|
85292
85919
|
if (!branch) return;
|
|
85293
85920
|
const branchPath = ctx.branchWorkspacePath(branch);
|
|
85294
85921
|
try {
|
|
85295
|
-
await
|
|
85922
|
+
await fs22.stat(branchPath);
|
|
85296
85923
|
} catch {
|
|
85297
85924
|
return;
|
|
85298
85925
|
}
|
|
@@ -85311,11 +85938,30 @@ async function updateBranchMetadataOnFailure(ctx, task, error3, options) {
|
|
|
85311
85938
|
(existing) => existing?.branch.name === branch && existing.branch.status === "submitted" && existing.branch.pullRequestNumber === void 0 && existing.branch.submittedAt === submittedAt
|
|
85312
85939
|
) !== null;
|
|
85313
85940
|
if (!unlocked) {
|
|
85314
|
-
|
|
85315
|
-
|
|
85316
|
-
|
|
85941
|
+
let found = false;
|
|
85942
|
+
let revoked = false;
|
|
85943
|
+
const saved = await meta.update(
|
|
85944
|
+
(existing) => {
|
|
85945
|
+
if (existing?.branch.name !== branch) return null;
|
|
85946
|
+
found = true;
|
|
85947
|
+
if (isOlderSubmit(task, existing.branch.submittedAt)) return null;
|
|
85948
|
+
if (options.unlock || task.action !== SUBMIT_ACTION) return { branch: failed };
|
|
85949
|
+
if (existing.branch.status === "archived") {
|
|
85950
|
+
return { branch: { ...failed, unpublishedAtMerge: true } };
|
|
85951
|
+
}
|
|
85952
|
+
revoked = existing.branch.status === "approved";
|
|
85953
|
+
return {
|
|
85954
|
+
branch: {
|
|
85955
|
+
...failed,
|
|
85956
|
+
submitUnfinished: true,
|
|
85957
|
+
...revoked ? { status: "submitted", review: void 0 } : {}
|
|
85958
|
+
}
|
|
85959
|
+
};
|
|
85960
|
+
},
|
|
85961
|
+
{ keepUpdatedAt: true }
|
|
85317
85962
|
);
|
|
85318
|
-
if (
|
|
85963
|
+
if (!found) noMetadataToRecord(branch, `${task.action} failure`);
|
|
85964
|
+
if (revoked && saved !== null) await enqueueReviewBlockSync(ctx, branch, saved);
|
|
85319
85965
|
}
|
|
85320
85966
|
} catch (err) {
|
|
85321
85967
|
workerLogError(
|
|
@@ -85345,8 +85991,17 @@ async function pushBranchToGitHub(ctx, branch, signal) {
|
|
|
85345
85991
|
);
|
|
85346
85992
|
}
|
|
85347
85993
|
const branchPath = ctx.branchWorkspacePath(branch);
|
|
85348
|
-
const
|
|
85994
|
+
const readMetadata = () => BranchMetadataFileManager.loadOnly(branchPath).catch((err) => {
|
|
85995
|
+
throw err instanceof BranchMetadataCorruptError ? new Error(err.parseCause) : err;
|
|
85996
|
+
});
|
|
85997
|
+
const metaFile = await readMetadata();
|
|
85349
85998
|
const marker = metaFile?.branch.historyRewrittenFrom;
|
|
85999
|
+
if (metaFile?.branch.rewrittenOnGitHub !== void 0) {
|
|
86000
|
+
workerLogWarn(
|
|
86001
|
+
`Not pushing ${branch}: GitHub's branch no longer contains ${metaFile.branch.rewrittenOnGitHub}`
|
|
86002
|
+
);
|
|
86003
|
+
throw new PermanentTaskError(REWRITTEN_PUSH_REFUSAL);
|
|
86004
|
+
}
|
|
85350
86005
|
const readSha = async () => {
|
|
85351
86006
|
const sha = await readPublishedSha(ctx, branch);
|
|
85352
86007
|
if (sha === null) {
|
|
@@ -85354,6 +86009,10 @@ async function pushBranchToGitHub(ctx, branch, signal) {
|
|
|
85354
86009
|
}
|
|
85355
86010
|
return sha;
|
|
85356
86011
|
};
|
|
86012
|
+
const readSeen = async () => {
|
|
86013
|
+
const seen = (await readMetadata())?.branch.lastGitHubTip;
|
|
86014
|
+
return marker === void 0 && seen !== void 0 && COMMIT_ID.test(seen) ? seen : void 0;
|
|
86015
|
+
};
|
|
85357
86016
|
let outgoingSha;
|
|
85358
86017
|
let outcome;
|
|
85359
86018
|
try {
|
|
@@ -85363,6 +86022,7 @@ async function pushBranchToGitHub(ctx, branch, signal) {
|
|
|
85363
86022
|
{
|
|
85364
86023
|
branch,
|
|
85365
86024
|
lease: marker,
|
|
86025
|
+
readSeen,
|
|
85366
86026
|
prerequisiteBranches: [branch, ctx.baseBranch]
|
|
85367
86027
|
},
|
|
85368
86028
|
readSha,
|
|
@@ -85371,17 +86031,21 @@ async function pushBranchToGitHub(ctx, branch, signal) {
|
|
|
85371
86031
|
} catch (err) {
|
|
85372
86032
|
if (err instanceof RefusedPushError) throw new PermanentTaskError(err.message);
|
|
85373
86033
|
if (!(err instanceof GitHubPushError)) throw err;
|
|
86034
|
+
if (err.kind === "seen-commit-gone") {
|
|
86035
|
+
workerLogWarn(`Not pushing ${branch}: ${err.message}`);
|
|
86036
|
+
throw new GitHubMovedTaskError(SEEN_COMMIT_GONE_PUSH_REFUSAL);
|
|
86037
|
+
}
|
|
85374
86038
|
throwIfWorkflowRefusal(branch, err.message);
|
|
85375
86039
|
if (err.kind === "rejected-after-stale-lease") {
|
|
85376
86040
|
if (isNonFastForwardRejection(err.message)) {
|
|
85377
|
-
throw new
|
|
86041
|
+
throw new GitHubMovedTaskError(
|
|
85378
86042
|
`Push rejected for branch "${branch}": GitHub's tip is neither the commit this deployment last published nor an ancestor of what it is pushing, so the branch has genuinely diverged and nothing was overwritten. Something else moved it on GitHub -- a direct push, or another CanopyCMS deployment sharing this repository.`
|
|
85379
86043
|
);
|
|
85380
86044
|
}
|
|
85381
86045
|
throw new Error(err.message);
|
|
85382
86046
|
}
|
|
85383
86047
|
if (isNonFastForwardRejection(err.message)) {
|
|
85384
|
-
throw new
|
|
86048
|
+
throw new GitHubMovedTaskError(
|
|
85385
86049
|
`Push rejected for branch "${branch}": GitHub's tip is not what this deployment last published, so the branch has diverged and needs reconciling. Something else moved it on GitHub -- a direct push, or another CanopyCMS deployment sharing this repository.`
|
|
85386
86050
|
);
|
|
85387
86051
|
}
|
|
@@ -85389,14 +86053,14 @@ async function pushBranchToGitHub(ctx, branch, signal) {
|
|
|
85389
86053
|
}
|
|
85390
86054
|
if (outcome.pastStaleLease) {
|
|
85391
86055
|
await clearHistoryRewrittenMarker(ctx, branchPath, branch);
|
|
85392
|
-
await recordPushedToGitHub(ctx, branchPath, branch);
|
|
86056
|
+
await recordPushedToGitHub(ctx, branchPath, branch, outgoingSha);
|
|
85393
86057
|
logPushOutcome(ctx, branch, outcome, "GitHub had already moved past the rewritten commit");
|
|
85394
86058
|
return;
|
|
85395
86059
|
}
|
|
85396
86060
|
if (marker && outgoingSha !== marker) {
|
|
85397
86061
|
await clearHistoryRewrittenMarker(ctx, branchPath, branch);
|
|
85398
86062
|
}
|
|
85399
|
-
await recordPushedToGitHub(ctx, branchPath, branch);
|
|
86063
|
+
await recordPushedToGitHub(ctx, branchPath, branch, outgoingSha);
|
|
85400
86064
|
logPushOutcome(ctx, branch, outcome);
|
|
85401
86065
|
}
|
|
85402
86066
|
function logPushOutcome(ctx, branch, outcome, note) {
|
|
@@ -85407,17 +86071,17 @@ function logPushOutcome(ctx, branch, outcome, note) {
|
|
|
85407
86071
|
ctx.log.debug(`${branch} already up to date on GitHub${suffix}`);
|
|
85408
86072
|
}
|
|
85409
86073
|
}
|
|
85410
|
-
async function recordPushedToGitHub(ctx, branchPath, branch) {
|
|
86074
|
+
async function recordPushedToGitHub(ctx, branchPath, branch, sha) {
|
|
85411
86075
|
if (isSettingsBranch(branch)) return;
|
|
85412
86076
|
try {
|
|
85413
|
-
await
|
|
86077
|
+
await fs22.stat(branchPath);
|
|
85414
86078
|
} catch {
|
|
85415
86079
|
return;
|
|
85416
86080
|
}
|
|
85417
86081
|
try {
|
|
85418
|
-
const saved = await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).
|
|
85419
|
-
{ branch: { pushedToGitHubAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
85420
|
-
|
|
86082
|
+
const saved = await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).update(
|
|
86083
|
+
(existing) => existing?.branch.name === branch ? { branch: { pushedToGitHubAt: (/* @__PURE__ */ new Date()).toISOString(), lastGitHubTip: sha } } : null,
|
|
86084
|
+
{ keepUpdatedAt: true }
|
|
85421
86085
|
);
|
|
85422
86086
|
if (saved === null) noMetadataToRecord(branch, "GitHub push");
|
|
85423
86087
|
} catch (err) {
|
|
@@ -85426,19 +86090,17 @@ async function recordPushedToGitHub(ctx, branchPath, branch) {
|
|
|
85426
86090
|
}
|
|
85427
86091
|
|
|
85428
86092
|
// ../canopycms/src/worker/rebase.ts
|
|
85429
|
-
import
|
|
85430
|
-
import
|
|
86093
|
+
import fs24 from "node:fs/promises";
|
|
86094
|
+
import path26 from "node:path";
|
|
85431
86095
|
init_branch_name();
|
|
85432
|
-
init_normalize();
|
|
85433
|
-
init_types2();
|
|
85434
86096
|
|
|
85435
86097
|
// ../canopycms/src/utils/content-write-lock.ts
|
|
85436
86098
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
85437
|
-
import
|
|
86099
|
+
import path24 from "node:path";
|
|
85438
86100
|
var META_DIR2 = ".canopy-meta";
|
|
85439
86101
|
var CONTENT_WRITE_LOCK_NAME = "content-write.lock";
|
|
85440
86102
|
function lockTargetDir(branchRoot) {
|
|
85441
|
-
return
|
|
86103
|
+
return path24.join(path24.resolve(branchRoot), META_DIR2);
|
|
85442
86104
|
}
|
|
85443
86105
|
var CONTENT_WRITE_LOCK_STALE_MS = 3e4;
|
|
85444
86106
|
function tryAcquireContentWriteLock(branchRoot, onCompromised) {
|
|
@@ -85453,8 +86115,8 @@ function tryAcquireContentWriteLock(branchRoot, onCompromised) {
|
|
|
85453
86115
|
var heldRoots = new AsyncLocalStorage();
|
|
85454
86116
|
|
|
85455
86117
|
// ../canopycms/src/worker/provisioned-workspace.ts
|
|
85456
|
-
import
|
|
85457
|
-
import
|
|
86118
|
+
import fs23 from "node:fs/promises";
|
|
86119
|
+
import path25 from "node:path";
|
|
85458
86120
|
init_error();
|
|
85459
86121
|
async function holdProvisionedWorkspace(contentBranchesPath, dirName) {
|
|
85460
86122
|
let release2;
|
|
@@ -85474,13 +86136,13 @@ async function holdProvisionedWorkspace(contentBranchesPath, dirName) {
|
|
|
85474
86136
|
if (isNodeError(err) && err.code === "ELOCKED") return { kind: "locked" };
|
|
85475
86137
|
throw err;
|
|
85476
86138
|
}
|
|
85477
|
-
const root5 =
|
|
86139
|
+
const root5 = path25.join(contentBranchesPath, dirName);
|
|
85478
86140
|
const [gitIsDir, hasMetadata] = await Promise.all([
|
|
85479
|
-
|
|
86141
|
+
fs23.stat(path25.join(root5, ".git")).then(
|
|
85480
86142
|
(stat) => stat.isDirectory(),
|
|
85481
86143
|
() => false
|
|
85482
86144
|
),
|
|
85483
|
-
|
|
86145
|
+
fs23.stat(path25.join(root5, BRANCH_META_DIR, BRANCH_META_FILE)).then(
|
|
85484
86146
|
() => true,
|
|
85485
86147
|
() => false
|
|
85486
86148
|
)
|
|
@@ -85501,7 +86163,7 @@ async function releaseProvisionedWorkspace(release2, dirName) {
|
|
|
85501
86163
|
init_error();
|
|
85502
86164
|
async function pollMergeState(ctx, branchDir, branchPath, metaFile) {
|
|
85503
86165
|
const prNumber2 = metaFile?.branch.pullRequestNumber;
|
|
85504
|
-
if (!prNumber2) return;
|
|
86166
|
+
if (!prNumber2) return null;
|
|
85505
86167
|
const sameBranch2 = (current) => current?.branch.name === metaFile?.branch.name;
|
|
85506
86168
|
const controller = new AbortController();
|
|
85507
86169
|
const timer = setTimeout(() => controller.abort(), ctx.taskTimeoutMs);
|
|
@@ -85509,23 +86171,27 @@ async function pollMergeState(ctx, branchDir, branchPath, metaFile) {
|
|
|
85509
86171
|
const data3 = await ctx.github().getPullRequest(prNumber2, controller.signal);
|
|
85510
86172
|
if (data3.merged) {
|
|
85511
86173
|
const meta2 = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
85512
|
-
const saved2 = await meta2.
|
|
85513
|
-
{
|
|
85514
|
-
branch: buildMergedBranchUpdate(
|
|
85515
|
-
|
|
85516
|
-
|
|
86174
|
+
const saved2 = await meta2.update(
|
|
86175
|
+
(current) => current !== null && sameBranch2(current) ? {
|
|
86176
|
+
branch: buildMergedBranchUpdate(
|
|
86177
|
+
current.branch,
|
|
86178
|
+
data3.merged_at ? new Date(data3.merged_at) : void 0
|
|
86179
|
+
)
|
|
86180
|
+
} : null
|
|
85517
86181
|
);
|
|
85518
86182
|
if (saved2) workerLog(` PR #${prNumber2} for ${branchDir} is merged -> archived`);
|
|
85519
|
-
return;
|
|
86183
|
+
return null;
|
|
85520
86184
|
}
|
|
85521
86185
|
const newState = data3.state === "closed" ? "closed" : "open";
|
|
85522
86186
|
const currentMeta = await BranchMetadataFileManager.loadOnly(branchPath);
|
|
85523
|
-
if (currentMeta?.branch.pullRequestState === newState) return;
|
|
86187
|
+
if (currentMeta?.branch.pullRequestState === newState) return data3;
|
|
85524
86188
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
85525
86189
|
const saved = await meta.saveIf({ branch: { pullRequestState: newState } }, sameBranch2);
|
|
85526
86190
|
if (saved) workerLog(` PR #${prNumber2} for ${branchDir}: pullRequestState -> ${newState}`);
|
|
86191
|
+
return data3;
|
|
85527
86192
|
} catch (err) {
|
|
85528
86193
|
workerLogWarn(` Failed to poll PR #${prNumber2} for ${branchDir}: ${getErrorMessage(err)}`);
|
|
86194
|
+
return null;
|
|
85529
86195
|
} finally {
|
|
85530
86196
|
clearTimeout(timer);
|
|
85531
86197
|
}
|
|
@@ -85556,6 +86222,13 @@ async function recordRebaseFailure(ctx, branchPath, branchDir, message2, branchR
|
|
|
85556
86222
|
}
|
|
85557
86223
|
}
|
|
85558
86224
|
var MAX_REBASE_ROUNDS = 50;
|
|
86225
|
+
async function abortRebase(git, branchPath) {
|
|
86226
|
+
try {
|
|
86227
|
+
await git.rebase(["--abort"]);
|
|
86228
|
+
} finally {
|
|
86229
|
+
await invalidateBranchContentCaches(branchPath);
|
|
86230
|
+
}
|
|
86231
|
+
}
|
|
85559
86232
|
async function runRebaseRounds(ctx, branchGit, branchDir, fetchedBaseTip, isLockCompromised) {
|
|
85560
86233
|
const conflictedFiles = [];
|
|
85561
86234
|
let nextAction = "start";
|
|
@@ -85616,34 +86289,12 @@ async function runRebaseRounds(ctx, branchGit, branchDir, fetchedBaseTip, isLock
|
|
|
85616
86289
|
}
|
|
85617
86290
|
return { completed, conflictedFiles, failureReason };
|
|
85618
86291
|
}
|
|
85619
|
-
function conflictFilesToContentIds(conflictedFiles, contentRoot) {
|
|
85620
|
-
const normalizedContentRoot = normalizeFilesystemPath(contentRoot);
|
|
85621
|
-
const conflictIds = [...new Set(conflictedFiles)].map((f9) => {
|
|
85622
|
-
const fileId = extractIdFromFilename(path25.basename(f9));
|
|
85623
|
-
if (fileId) return fileId;
|
|
85624
|
-
const parentDir = path25.basename(path25.dirname(f9));
|
|
85625
|
-
const dirId = extractIdFromFilename(parentDir);
|
|
85626
|
-
if (dirId) return dirId;
|
|
85627
|
-
const parentPath = normalizeFilesystemPath(path25.dirname(f9));
|
|
85628
|
-
if (path25.basename(f9) === ".collection.json" && parentPath === normalizedContentRoot) {
|
|
85629
|
-
return ROOT_COLLECTION_ID;
|
|
85630
|
-
}
|
|
85631
|
-
return null;
|
|
85632
|
-
}).filter((id) => id !== null);
|
|
85633
|
-
return [...new Set(conflictIds)];
|
|
85634
|
-
}
|
|
85635
|
-
function recordConflicts(recorded, found) {
|
|
85636
|
-
const conflictFiles = [.../* @__PURE__ */ new Set([...recorded ?? [], ...found])];
|
|
85637
|
-
return {
|
|
85638
|
-
conflictStatus: conflictFiles.length > 0 ? "conflicts-detected" : "clean",
|
|
85639
|
-
conflictFiles
|
|
85640
|
-
};
|
|
85641
|
-
}
|
|
85642
86292
|
async function carryForwardRewrittenHistory(ctx, args) {
|
|
85643
86293
|
const { branchPath, branchDir, branchRef, publishedSha, preRebaseHead, gatewayPolicy } = args;
|
|
86294
|
+
const { rebasedHead } = args;
|
|
85644
86295
|
if (publishedSha !== null) {
|
|
85645
86296
|
if (publishedSha === preRebaseHead) {
|
|
85646
|
-
if (!await markHistoryRewritten(ctx, branchPath, branchRef, publishedSha)) {
|
|
86297
|
+
if (!await markHistoryRewritten(ctx, branchPath, branchRef, publishedSha, rebasedHead)) {
|
|
85647
86298
|
workerLogWarn(
|
|
85648
86299
|
` ${branchDir}: rebased, but its branch.json is gone or names another branch than ${branchRef}, so the rewrite is not published`
|
|
85649
86300
|
);
|
|
@@ -85659,14 +86310,14 @@ async function carryForwardRewrittenHistory(ctx, args) {
|
|
|
85659
86310
|
}
|
|
85660
86311
|
}
|
|
85661
86312
|
}
|
|
85662
|
-
async function runRebaseCycle(ctx, gatewayPolicy) {
|
|
86313
|
+
async function runRebaseCycle(ctx, gatewayPolicy, gitHub) {
|
|
85663
86314
|
const rebased = [];
|
|
85664
86315
|
const skippedDirty = [];
|
|
85665
86316
|
const skippedLocked = [];
|
|
85666
86317
|
const failed = [];
|
|
85667
86318
|
let branchDirs;
|
|
85668
86319
|
try {
|
|
85669
|
-
branchDirs = await
|
|
86320
|
+
branchDirs = await fs24.readdir(ctx.contentBranchesPath);
|
|
85670
86321
|
} catch {
|
|
85671
86322
|
return { rebased, skippedDirty, skippedLocked, failed };
|
|
85672
86323
|
}
|
|
@@ -85678,10 +86329,10 @@ async function runRebaseCycle(ctx, gatewayPolicy) {
|
|
|
85678
86329
|
if (branchDir.startsWith(".") || branchDir === "branches.json") {
|
|
85679
86330
|
continue;
|
|
85680
86331
|
}
|
|
85681
|
-
const branchPath =
|
|
85682
|
-
const gitDir =
|
|
86332
|
+
const branchPath = path26.join(ctx.contentBranchesPath, branchDir);
|
|
86333
|
+
const gitDir = path26.join(branchPath, ".git");
|
|
85683
86334
|
try {
|
|
85684
|
-
const stat = await
|
|
86335
|
+
const stat = await fs24.stat(gitDir);
|
|
85685
86336
|
if (!stat.isDirectory()) {
|
|
85686
86337
|
workerLog(` Skipping ${branchDir}: .git is not a directory`);
|
|
85687
86338
|
continue;
|
|
@@ -85698,7 +86349,7 @@ async function runRebaseCycle(ctx, gatewayPolicy) {
|
|
|
85698
86349
|
workerLogWarn(` Skipping ${branchDir}: settings branch, never a content workspace`);
|
|
85699
86350
|
continue;
|
|
85700
86351
|
}
|
|
85701
|
-
const outcome = await holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy);
|
|
86352
|
+
const outcome = await holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy, gitHub);
|
|
85702
86353
|
if (outcome.kind === "rebased") rebased.push(branchDir);
|
|
85703
86354
|
else if (outcome.kind === "skippedDirty") skippedDirty.push(branchDir);
|
|
85704
86355
|
else if (outcome.kind === "skippedLocked") skippedLocked.push(branchDir);
|
|
@@ -85711,7 +86362,7 @@ async function runRebaseCycle(ctx, gatewayPolicy) {
|
|
|
85711
86362
|
}
|
|
85712
86363
|
async function readCloneRef(branchPath) {
|
|
85713
86364
|
try {
|
|
85714
|
-
const head = (await
|
|
86365
|
+
const head = (await fs24.readFile(path26.join(branchPath, ".git", "HEAD"), "utf-8")).trim();
|
|
85715
86366
|
return head.startsWith("ref: refs/heads/") ? head.slice("ref: refs/heads/".length) : null;
|
|
85716
86367
|
} catch {
|
|
85717
86368
|
return null;
|
|
@@ -85743,7 +86394,7 @@ async function restoreRenamedBranch(ctx, branchDir, branchPath, metaFile, namesp
|
|
|
85743
86394
|
return metaFile;
|
|
85744
86395
|
}
|
|
85745
86396
|
}
|
|
85746
|
-
async function holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy) {
|
|
86397
|
+
async function holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy, gitHub) {
|
|
85747
86398
|
let hold;
|
|
85748
86399
|
try {
|
|
85749
86400
|
hold = await holdProvisionedWorkspace(ctx.contentBranchesPath, branchDir);
|
|
@@ -85758,12 +86409,200 @@ async function holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy)
|
|
|
85758
86409
|
}
|
|
85759
86410
|
if (hold.kind === "not-provisioned") return { kind: "none" };
|
|
85760
86411
|
try {
|
|
85761
|
-
return await rebaseOneBranch(
|
|
86412
|
+
return await rebaseOneBranch(
|
|
86413
|
+
ctx,
|
|
86414
|
+
branchDir,
|
|
86415
|
+
branchPath,
|
|
86416
|
+
hold.isCompromised,
|
|
86417
|
+
gatewayPolicy,
|
|
86418
|
+
gitHub
|
|
86419
|
+
);
|
|
85762
86420
|
} finally {
|
|
85763
86421
|
await releaseProvisionedWorkspace(hold.release, branchDir);
|
|
85764
86422
|
}
|
|
85765
86423
|
}
|
|
85766
|
-
async function
|
|
86424
|
+
async function clearRebaseFailure(ctx, branchPath, branchRef) {
|
|
86425
|
+
await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).update(
|
|
86426
|
+
(current) => current?.branch.name === branchRef ? { branch: { rebaseFailure: void 0, ...rewriteCleared(current.branch) } } : null
|
|
86427
|
+
);
|
|
86428
|
+
}
|
|
86429
|
+
async function recordBlocked(ctx, branchDir, branchPath, branchRef, reason) {
|
|
86430
|
+
const error3 = redactCredentials(reason);
|
|
86431
|
+
workerLogWarn(` ${branchDir}: ${error3}`);
|
|
86432
|
+
await recordRebaseFailure(ctx, branchPath, branchDir, error3, branchRef);
|
|
86433
|
+
return { kind: "failed", error: error3 };
|
|
86434
|
+
}
|
|
86435
|
+
async function lacksPublishedCommits(ctx, git, branchRef) {
|
|
86436
|
+
const published = await readPublishedSha(ctx, branchRef);
|
|
86437
|
+
if (published === null) return false;
|
|
86438
|
+
await fetchFromRemoteGit(git, ctx.remoteGitPath, `refs/heads/${branchRef}`);
|
|
86439
|
+
return (await commitsApart(git, "HEAD", published)).onlyB > 0;
|
|
86440
|
+
}
|
|
86441
|
+
async function bringInCommitsForBranchInReview(ctx, branchDir, branchPath, metaFile, isProvisioningLockCompromised, gatewayPolicy, gitHub) {
|
|
86442
|
+
try {
|
|
86443
|
+
const branchRef = await readCloneRef(branchPath);
|
|
86444
|
+
if (branchRef === null) return { kind: "none" };
|
|
86445
|
+
const gitHubTip = gitHub?.tips.get(branchRef);
|
|
86446
|
+
if (gitHubTip === void 0) {
|
|
86447
|
+
if (gitHub === void 0) return { kind: "none" };
|
|
86448
|
+
const { rebaseFailure, rewrittenOnGitHub } = metaFile.branch;
|
|
86449
|
+
if (rebaseFailure !== void 0 || rewrittenOnGitHub !== void 0) {
|
|
86450
|
+
await clearRebaseFailure(ctx, branchPath, branchRef);
|
|
86451
|
+
}
|
|
86452
|
+
return { kind: "none" };
|
|
86453
|
+
}
|
|
86454
|
+
await assertSharedRepoConfig(branchPath, "worktree");
|
|
86455
|
+
const branchGit = sharedRepoGit(branchPath, "worktree");
|
|
86456
|
+
const head = (await branchGit.revparse(["HEAD"])).trim();
|
|
86457
|
+
if (head === gitHubTip && metaFile.branch.lastGitHubTip === gitHubTip && metaFile.branch.rebaseFailure === void 0 && metaFile.branch.rewrittenOnGitHub === void 0 && await readPublishedSha(ctx, branchRef) === gitHubTip) {
|
|
86458
|
+
return { kind: "none" };
|
|
86459
|
+
}
|
|
86460
|
+
return await withContentLockInReview(
|
|
86461
|
+
branchDir,
|
|
86462
|
+
branchPath,
|
|
86463
|
+
isProvisioningLockCompromised,
|
|
86464
|
+
async (lockLost) => {
|
|
86465
|
+
const status = await branchGit.status([...SHARED_REPO_STATUS_ARGS]);
|
|
86466
|
+
const commitArgs = {
|
|
86467
|
+
git: branchGit,
|
|
86468
|
+
branchPath,
|
|
86469
|
+
branchDir,
|
|
86470
|
+
branchRef,
|
|
86471
|
+
metaFile,
|
|
86472
|
+
gitHub,
|
|
86473
|
+
dirty: status.files.some((f9) => !isCanopyInternalPath(f9.path)),
|
|
86474
|
+
gatewayPolicy,
|
|
86475
|
+
lockLost
|
|
86476
|
+
};
|
|
86477
|
+
const outcome = await bringInGitHubCommits(ctx, commitArgs);
|
|
86478
|
+
if (outcome.kind === "blocked") {
|
|
86479
|
+
await returnToReview(ctx, commitArgs);
|
|
86480
|
+
return recordBlocked(ctx, branchDir, branchPath, branchRef, outcome.reason);
|
|
86481
|
+
}
|
|
86482
|
+
if (outcome.kind === "in-step" && metaFile.branch.rebaseFailure !== void 0) {
|
|
86483
|
+
await clearRebaseFailure(ctx, branchPath, branchRef);
|
|
86484
|
+
}
|
|
86485
|
+
return { kind: "none" };
|
|
86486
|
+
}
|
|
86487
|
+
);
|
|
86488
|
+
} catch (err) {
|
|
86489
|
+
const message2 = redactCredentials(getErrorMessage(err));
|
|
86490
|
+
workerLogWarn(` ${branchDir}: could not bring in commits from GitHub: ${message2}`);
|
|
86491
|
+
await recordRebaseFailure(ctx, branchPath, branchDir, message2);
|
|
86492
|
+
return { kind: "failed", error: message2 };
|
|
86493
|
+
}
|
|
86494
|
+
}
|
|
86495
|
+
function pullRequestHoldOf(pullRequest, recordedBase) {
|
|
86496
|
+
const { state: state3, mergeable_state: mergeState, baseRef } = pullRequest;
|
|
86497
|
+
if (state3 !== "open") return void 0;
|
|
86498
|
+
if (mergeState === void 0 || mergeState === "unknown") return null;
|
|
86499
|
+
if (mergeState !== "behind" && mergeState !== "dirty") return void 0;
|
|
86500
|
+
if (baseRef !== void 0 && baseRef !== recordedBase)
|
|
86501
|
+
return { kind: "retargeted", base: baseRef };
|
|
86502
|
+
return mergeState === "dirty" ? { kind: "conflicts" } : void 0;
|
|
86503
|
+
}
|
|
86504
|
+
async function recordPullRequestHold(ctx, branchDir, branchPath, metaFile, pullRequest) {
|
|
86505
|
+
const { name: name2, baseBranch, pullRequestHold, submittedAt } = metaFile.branch;
|
|
86506
|
+
const hold = pullRequestHoldOf(pullRequest, baseBranch ?? ctx.baseBranch);
|
|
86507
|
+
if (hold === null || JSON.stringify(hold) === JSON.stringify(pullRequestHold)) return;
|
|
86508
|
+
try {
|
|
86509
|
+
await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).update(
|
|
86510
|
+
// A newer submit's pull request isn't the one measured.
|
|
86511
|
+
(current) => current?.branch.name === name2 && current.branch.submittedAt === submittedAt ? { branch: { pullRequestHold: hold } } : null,
|
|
86512
|
+
{ keepUpdatedAt: true }
|
|
86513
|
+
);
|
|
86514
|
+
} catch (err) {
|
|
86515
|
+
workerLogWarn(` ${branchDir}: could not record the PR's state: ${getErrorMessage(err)}`);
|
|
86516
|
+
}
|
|
86517
|
+
}
|
|
86518
|
+
async function updateBranchInReviewFromBase(ctx, branchDir, branchPath, pullRequest, isProvisioningLockCompromised, gatewayPolicy, gitHub) {
|
|
86519
|
+
try {
|
|
86520
|
+
const branchRef = await readCloneRef(branchPath);
|
|
86521
|
+
const gitHubTip = branchRef === null ? void 0 : gitHub?.tips.get(branchRef);
|
|
86522
|
+
if (branchRef === null || gitHubTip === void 0) return { kind: "none" };
|
|
86523
|
+
if (ctx.ensureStatusReport().baseHold) return { kind: "none" };
|
|
86524
|
+
if (gatewayPolicy && !publishesBranch(gatewayPolicy, branchRef)) return { kind: "none" };
|
|
86525
|
+
await assertSharedRepoConfig(branchPath, "worktree");
|
|
86526
|
+
const branchGit = sharedRepoGit(branchPath, "worktree");
|
|
86527
|
+
return await withContentLockInReview(
|
|
86528
|
+
branchDir,
|
|
86529
|
+
branchPath,
|
|
86530
|
+
isProvisioningLockCompromised,
|
|
86531
|
+
async (lockLost) => {
|
|
86532
|
+
const metaFile = await BranchMetadataFileManager.loadOnly(branchPath);
|
|
86533
|
+
const { status: state3, name: name2, baseBranch, syncStatus } = metaFile?.branch ?? {};
|
|
86534
|
+
if (metaFile === null || name2 !== branchRef) return { kind: "none" };
|
|
86535
|
+
if (state3 !== "submitted" && state3 !== "approved") return { kind: "none" };
|
|
86536
|
+
if (syncStatus === "sync-failed") return { kind: "none" };
|
|
86537
|
+
const base = baseBranch ?? ctx.baseBranch;
|
|
86538
|
+
if (pullRequest.baseRef !== base) return { kind: "none" };
|
|
86539
|
+
const head = (await branchGit.revparse(["HEAD"])).trim();
|
|
86540
|
+
if (head !== gitHubTip || await readPublishedSha(ctx, branchRef) !== head) {
|
|
86541
|
+
return { kind: "none" };
|
|
86542
|
+
}
|
|
86543
|
+
const status = await branchGit.status([...SHARED_REPO_STATUS_ARGS]);
|
|
86544
|
+
if (status.files.some((f9) => !isCanopyInternalPath(f9.path))) return { kind: "none" };
|
|
86545
|
+
await fetchFromRemoteGit(branchGit, ctx.remoteGitPath, base);
|
|
86546
|
+
const baseTip = (await branchGit.revparse(["FETCH_HEAD"])).trim();
|
|
86547
|
+
if ((await commitsApart(branchGit, head, baseTip)).onlyB === 0) return { kind: "none" };
|
|
86548
|
+
const commitArgs = {
|
|
86549
|
+
git: branchGit,
|
|
86550
|
+
branchPath,
|
|
86551
|
+
branchDir,
|
|
86552
|
+
branchRef,
|
|
86553
|
+
metaFile,
|
|
86554
|
+
gitHub,
|
|
86555
|
+
dirty: false,
|
|
86556
|
+
gatewayPolicy,
|
|
86557
|
+
lockLost
|
|
86558
|
+
};
|
|
86559
|
+
const outcome = await mergeIntoBranch(ctx, commitArgs, {
|
|
86560
|
+
head,
|
|
86561
|
+
other: baseTip,
|
|
86562
|
+
message: `Merge ${base} into ${branchRef}`,
|
|
86563
|
+
fromGitHub: false,
|
|
86564
|
+
stopOnConflict: true
|
|
86565
|
+
});
|
|
86566
|
+
if (outcome.kind === "blocked") {
|
|
86567
|
+
const error3 = redactCredentials(outcome.reason);
|
|
86568
|
+
workerLogWarn(` ${branchDir}: ${error3}`);
|
|
86569
|
+
return { kind: "failed", error: error3 };
|
|
86570
|
+
}
|
|
86571
|
+
return outcome.kind === "merged" ? { kind: "rebased" } : { kind: "none" };
|
|
86572
|
+
}
|
|
86573
|
+
);
|
|
86574
|
+
} catch (err) {
|
|
86575
|
+
const message2 = redactCredentials(getErrorMessage(err));
|
|
86576
|
+
workerLogWarn(` ${branchDir}: could not update it from the base: ${message2}`);
|
|
86577
|
+
return { kind: "failed", error: message2 };
|
|
86578
|
+
}
|
|
86579
|
+
}
|
|
86580
|
+
async function withContentLockInReview(branchDir, branchPath, isProvisioningLockCompromised, work) {
|
|
86581
|
+
let contentLockCompromised = false;
|
|
86582
|
+
let releaseContentLock;
|
|
86583
|
+
try {
|
|
86584
|
+
releaseContentLock = await tryAcquireContentWriteLock(branchPath, (lockErr) => {
|
|
86585
|
+
contentLockCompromised = true;
|
|
86586
|
+
workerLogWarn(` Content-write lock lost for ${branchDir}: ${getErrorMessage(lockErr)}`);
|
|
86587
|
+
});
|
|
86588
|
+
} catch (lockErr) {
|
|
86589
|
+
if (isNodeError(lockErr) && lockErr.code === "ELOCKED") {
|
|
86590
|
+
workerLog(` Skipping ${branchDir}: content write in progress (retrying next cycle)`);
|
|
86591
|
+
return { kind: "skippedLocked" };
|
|
86592
|
+
}
|
|
86593
|
+
throw lockErr;
|
|
86594
|
+
}
|
|
86595
|
+
try {
|
|
86596
|
+
return await work(() => contentLockCompromised || isProvisioningLockCompromised());
|
|
86597
|
+
} finally {
|
|
86598
|
+
await releaseContentLock().catch((releaseErr) => {
|
|
86599
|
+
workerLogWarn(
|
|
86600
|
+
` Failed to release content-write lock for ${branchDir}: ${getErrorMessage(releaseErr)}`
|
|
86601
|
+
);
|
|
86602
|
+
});
|
|
86603
|
+
}
|
|
86604
|
+
}
|
|
86605
|
+
async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCompromised, gatewayPolicy, gitHub) {
|
|
85767
86606
|
let didRebase = false;
|
|
85768
86607
|
try {
|
|
85769
86608
|
const metaFile = await restoreRenamedBranch(
|
|
@@ -85774,10 +86613,33 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85774
86613
|
gatewayPolicy?.namespace
|
|
85775
86614
|
);
|
|
85776
86615
|
const branchStatus2 = metaFile?.branch.status;
|
|
85777
|
-
if (branchStatus2 === "submitted" || branchStatus2 === "approved") {
|
|
86616
|
+
if (metaFile !== null && (branchStatus2 === "submitted" || branchStatus2 === "approved")) {
|
|
85778
86617
|
workerLog(` Skipping ${branchDir} (${branchStatus2})`);
|
|
85779
|
-
|
|
85780
|
-
|
|
86618
|
+
const outcome = await bringInCommitsForBranchInReview(
|
|
86619
|
+
ctx,
|
|
86620
|
+
branchDir,
|
|
86621
|
+
branchPath,
|
|
86622
|
+
metaFile,
|
|
86623
|
+
isProvisioningLockCompromised,
|
|
86624
|
+
gatewayPolicy,
|
|
86625
|
+
gitHub
|
|
86626
|
+
);
|
|
86627
|
+
const pullRequest = await pollMergeState(ctx, branchDir, branchPath, metaFile);
|
|
86628
|
+
if (pullRequest !== null) {
|
|
86629
|
+
await recordPullRequestHold(ctx, branchDir, branchPath, metaFile, pullRequest);
|
|
86630
|
+
}
|
|
86631
|
+
if (outcome.kind === "none" && pullRequest?.state === "open" && pullRequest.mergeable_state === "behind") {
|
|
86632
|
+
return updateBranchInReviewFromBase(
|
|
86633
|
+
ctx,
|
|
86634
|
+
branchDir,
|
|
86635
|
+
branchPath,
|
|
86636
|
+
pullRequest,
|
|
86637
|
+
isProvisioningLockCompromised,
|
|
86638
|
+
gatewayPolicy,
|
|
86639
|
+
gitHub
|
|
86640
|
+
);
|
|
86641
|
+
}
|
|
86642
|
+
return outcome;
|
|
85781
86643
|
}
|
|
85782
86644
|
if (branchStatus2 === "archived") {
|
|
85783
86645
|
workerLog(` Skipping ${branchDir} (${branchStatus2})`);
|
|
@@ -85815,7 +86677,7 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85815
86677
|
` ${branchDir}: found an interrupted rebase (this worker's own abandoned work) -- aborting it to recover the branch`
|
|
85816
86678
|
);
|
|
85817
86679
|
try {
|
|
85818
|
-
await branchGit
|
|
86680
|
+
await abortRebase(branchGit, branchPath);
|
|
85819
86681
|
} catch (abortErr) {
|
|
85820
86682
|
const reason = redactCredentials(
|
|
85821
86683
|
`could not abort interrupted rebase: ${getErrorMessage(abortErr)}`
|
|
@@ -85831,6 +86693,30 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85831
86693
|
dirtyCheck = await branchGit.status([...SHARED_REPO_STATUS_ARGS]);
|
|
85832
86694
|
}
|
|
85833
86695
|
const editorDirt = dirtyCheck.files.filter((f9) => !isCanopyInternalPath(f9.path));
|
|
86696
|
+
const branchRef = (await branchGit.revparse(["--abbrev-ref", "HEAD"])).trim();
|
|
86697
|
+
const canPublish = branchRef.length > 0 && branchRef !== "HEAD";
|
|
86698
|
+
const commitArgs = canPublish && metaFile !== null ? {
|
|
86699
|
+
git: branchGit,
|
|
86700
|
+
branchPath,
|
|
86701
|
+
branchDir,
|
|
86702
|
+
branchRef,
|
|
86703
|
+
metaFile,
|
|
86704
|
+
gitHub,
|
|
86705
|
+
dirty: editorDirt.length > 0,
|
|
86706
|
+
gatewayPolicy,
|
|
86707
|
+
lockLost: lockCompromised
|
|
86708
|
+
} : null;
|
|
86709
|
+
let unpushed = false;
|
|
86710
|
+
if (commitArgs !== null) {
|
|
86711
|
+
const outcome = await bringInGitHubCommits(ctx, commitArgs);
|
|
86712
|
+
if (outcome.kind === "blocked") {
|
|
86713
|
+
return recordBlocked(ctx, branchDir, branchPath, branchRef, outcome.reason);
|
|
86714
|
+
}
|
|
86715
|
+
if (outcome.kind === "unpushed") unpushed = true;
|
|
86716
|
+
else if (outcome.kind !== "in-step") {
|
|
86717
|
+
return editorDirt.length > 0 ? { kind: "skippedDirty" } : { kind: "none" };
|
|
86718
|
+
}
|
|
86719
|
+
}
|
|
85834
86720
|
if (editorDirt.length > 0) {
|
|
85835
86721
|
workerLog(` Skipping ${branchDir}: has uncommitted changes`);
|
|
85836
86722
|
return { kind: "skippedDirty" };
|
|
@@ -85845,8 +86731,6 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85845
86731
|
await recordRebaseFailure(ctx, branchPath, branchDir, reason);
|
|
85846
86732
|
return { kind: "failed", error: reason };
|
|
85847
86733
|
}
|
|
85848
|
-
const branchRef = (await branchGit.revparse(["--abbrev-ref", "HEAD"])).trim();
|
|
85849
|
-
const canPublish = branchRef.length > 0 && branchRef !== "HEAD";
|
|
85850
86734
|
if (canPublish && metaFile?.branch.historyRewrittenFrom) {
|
|
85851
86735
|
await reconcilePendingRewrite(ctx, {
|
|
85852
86736
|
branchPath,
|
|
@@ -85869,6 +86753,9 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85869
86753
|
if (currentMeta?.branch.rebaseFailure === void 0) {
|
|
85870
86754
|
return { kind: "none" };
|
|
85871
86755
|
}
|
|
86756
|
+
if (canPublish && await lacksPublishedCommits(ctx, branchGit, branchRef)) {
|
|
86757
|
+
return { kind: "none" };
|
|
86758
|
+
}
|
|
85872
86759
|
const storedName = currentMeta.branch.name;
|
|
85873
86760
|
await meta.saveIf(
|
|
85874
86761
|
{ branch: { rebaseFailure: void 0 } },
|
|
@@ -85876,6 +86763,23 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85876
86763
|
);
|
|
85877
86764
|
return { kind: "none" };
|
|
85878
86765
|
}
|
|
86766
|
+
const aboveBase = `${fetchedBaseTip}..HEAD`;
|
|
86767
|
+
const countAboveBase = async (args) => (await branchGit.raw(["rev-list", "--count", ...args])).trim();
|
|
86768
|
+
const cannotReplay = await countAboveBase(["--merges", "--end-of-options", aboveBase]) !== "0" || await countAboveBase(["--end-of-options", aboveBase, "--", CANOPY_META_DIR]) !== "0";
|
|
86769
|
+
if (commitArgs !== null && (cannotReplay || unpushed)) {
|
|
86770
|
+
const outcome = await mergeIntoBranch(ctx, commitArgs, {
|
|
86771
|
+
head: (await branchGit.revparse(["HEAD"])).trim(),
|
|
86772
|
+
other: fetchedBaseTip,
|
|
86773
|
+
message: `Merge ${ctx.baseBranch} into ${branchRef}`,
|
|
86774
|
+
fromGitHub: false
|
|
86775
|
+
});
|
|
86776
|
+
if (outcome.kind === "blocked") {
|
|
86777
|
+
return recordBlocked(ctx, branchDir, branchPath, branchRef, outcome.reason);
|
|
86778
|
+
}
|
|
86779
|
+
if (outcome.kind !== "merged") return { kind: "none" };
|
|
86780
|
+
await clearRebaseFailure(ctx, branchPath, branchRef);
|
|
86781
|
+
return { kind: "rebased" };
|
|
86782
|
+
}
|
|
85879
86783
|
workerLog(`Rebasing ${branchDir} (${behindCount} commits behind)...`);
|
|
85880
86784
|
const preRebaseHead = (await branchGit.revparse(["HEAD"])).trim();
|
|
85881
86785
|
const publishedSha = canPublish ? await readPublishedSha(ctx, branchRef) : null;
|
|
@@ -85892,7 +86796,7 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85892
86796
|
workerLogWarn(
|
|
85893
86797
|
` Skipping ${branchDir}: a lock it held was compromised mid-rebase (retrying next cycle)`
|
|
85894
86798
|
);
|
|
85895
|
-
await branchGit
|
|
86799
|
+
await abortRebase(branchGit, branchPath).catch(() => {
|
|
85896
86800
|
});
|
|
85897
86801
|
return { kind: "skippedLocked" };
|
|
85898
86802
|
}
|
|
@@ -85905,7 +86809,7 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85905
86809
|
workerLogWarn(
|
|
85906
86810
|
failureReason !== void 0 ? ` Rebase of ${branchDir} aborted due to unexpected error: ${failureReason}` : ` Rebase of ${branchDir} did not complete within ${MAX_REBASE_ROUNDS} rounds, aborting`
|
|
85907
86811
|
);
|
|
85908
|
-
await branchGit
|
|
86812
|
+
await abortRebase(branchGit, branchPath).catch(() => {
|
|
85909
86813
|
});
|
|
85910
86814
|
const rebaseFailureMessage = failureReason ?? `did not complete within ${MAX_REBASE_ROUNDS} rounds`;
|
|
85911
86815
|
const redactedRebaseFailureMessage = redactCredentials(rebaseFailureMessage);
|
|
@@ -85935,6 +86839,7 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85935
86839
|
branchRef,
|
|
85936
86840
|
publishedSha,
|
|
85937
86841
|
preRebaseHead,
|
|
86842
|
+
rebasedHead: (await branchGit.revparse(["HEAD"])).trim(),
|
|
85938
86843
|
gatewayPolicy
|
|
85939
86844
|
});
|
|
85940
86845
|
return { kind: "rebased" };
|
|
@@ -85944,7 +86849,7 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85944
86849
|
workerLogWarn(
|
|
85945
86850
|
` ${branchDir}: rebase still in progress on exit -- aborting so the clone is not left wedged`
|
|
85946
86851
|
);
|
|
85947
|
-
await branchGit
|
|
86852
|
+
await abortRebase(branchGit, branchPath);
|
|
85948
86853
|
}
|
|
85949
86854
|
} catch (abortErr) {
|
|
85950
86855
|
workerLogWarn(
|
|
@@ -85967,16 +86872,16 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85967
86872
|
}
|
|
85968
86873
|
|
|
85969
86874
|
// ../canopycms/src/worker/git-sync.ts
|
|
85970
|
-
import
|
|
85971
|
-
import
|
|
86875
|
+
import fs29 from "node:fs/promises";
|
|
86876
|
+
import path31 from "node:path";
|
|
85972
86877
|
|
|
85973
86878
|
// ../canopycms/src/branch-health.ts
|
|
85974
86879
|
var ORPHAN_YOUTH_THRESHOLD_MS = 15 * 6e4;
|
|
85975
86880
|
|
|
85976
86881
|
// ../canopycms/src/branch-provisioning.ts
|
|
85977
86882
|
import { createHash, randomBytes as randomBytes2 } from "node:crypto";
|
|
85978
|
-
import
|
|
85979
|
-
import
|
|
86883
|
+
import fs25 from "node:fs/promises";
|
|
86884
|
+
import path27 from "node:path";
|
|
85980
86885
|
init_branch_name();
|
|
85981
86886
|
init_error();
|
|
85982
86887
|
init_logger();
|
|
@@ -86009,7 +86914,7 @@ var DELETING_PREFIX = ".deleting-";
|
|
|
86009
86914
|
var NO_GIT = { hasGitDir: false, configLock: false, hasIndex: false };
|
|
86010
86915
|
async function listDir(dirPath) {
|
|
86011
86916
|
try {
|
|
86012
|
-
return await
|
|
86917
|
+
return await fs25.readdir(dirPath);
|
|
86013
86918
|
} catch (err) {
|
|
86014
86919
|
if (isNodeError(err) && (err.code === "ENOENT" || err.code === "ENOTDIR")) return null;
|
|
86015
86920
|
throw err;
|
|
@@ -86031,19 +86936,19 @@ function gitConfigRemoteUrls(text) {
|
|
|
86031
86936
|
}
|
|
86032
86937
|
function sameRemote(url, expected) {
|
|
86033
86938
|
if (isNetworkRemoteUrl(url) || isNetworkRemoteUrl(expected)) return url === expected;
|
|
86034
|
-
const local = (value) =>
|
|
86939
|
+
const local = (value) => path27.resolve(value.replace(/^file:\/\//i, ""));
|
|
86035
86940
|
return local(url) === local(expected);
|
|
86036
86941
|
}
|
|
86037
86942
|
async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
86038
86943
|
let stat;
|
|
86039
86944
|
try {
|
|
86040
|
-
stat = await
|
|
86945
|
+
stat = await fs25.lstat(dirPath);
|
|
86041
86946
|
} catch (err) {
|
|
86042
86947
|
if (isNotFoundError2(err)) return { kind: "vacant" };
|
|
86043
86948
|
throw err;
|
|
86044
86949
|
}
|
|
86045
86950
|
if (!stat.isDirectory()) return { kind: "residue", signature: NO_GIT };
|
|
86046
|
-
const metaEntries = await listDir(
|
|
86951
|
+
const metaEntries = await listDir(path27.join(dirPath, BRANCH_META_DIR)) ?? [];
|
|
86047
86952
|
if (metaEntries.includes(BRANCH_META_FILE)) {
|
|
86048
86953
|
try {
|
|
86049
86954
|
return await readBranchMetadataFile(dirPath) ? { kind: "live" } : { kind: "protected" };
|
|
@@ -86055,10 +86960,10 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
|
86055
86960
|
if (metaEntries.some((name2) => name2.startsWith(`${BRANCH_META_FILE}.corrupt-`))) {
|
|
86056
86961
|
return { kind: "protected" };
|
|
86057
86962
|
}
|
|
86058
|
-
const gitPath =
|
|
86963
|
+
const gitPath = path27.join(dirPath, ".git");
|
|
86059
86964
|
let gitStat;
|
|
86060
86965
|
try {
|
|
86061
|
-
gitStat = await
|
|
86966
|
+
gitStat = await fs25.lstat(gitPath);
|
|
86062
86967
|
} catch (err) {
|
|
86063
86968
|
if (isNotFoundError2(err)) return { kind: "residue", signature: NO_GIT };
|
|
86064
86969
|
throw err;
|
|
@@ -86072,7 +86977,7 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
|
86072
86977
|
};
|
|
86073
86978
|
let config;
|
|
86074
86979
|
try {
|
|
86075
|
-
config = await
|
|
86980
|
+
config = await fs25.readFile(path27.join(gitPath, "config"), "utf8");
|
|
86076
86981
|
} catch {
|
|
86077
86982
|
return { kind: "residue", signature };
|
|
86078
86983
|
}
|
|
@@ -86081,7 +86986,7 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
|
86081
86986
|
async function quietAgeMs(dirPath, now = Date.now()) {
|
|
86082
86987
|
const mtimes = await Promise.all(
|
|
86083
86988
|
["", ".git", BRANCH_META_DIR].map(
|
|
86084
|
-
(sub) =>
|
|
86989
|
+
(sub) => fs25.lstat(path27.join(dirPath, sub)).then(
|
|
86085
86990
|
(stat) => stat.mtimeMs,
|
|
86086
86991
|
() => 0
|
|
86087
86992
|
)
|
|
@@ -86090,25 +86995,25 @@ async function quietAgeMs(dirPath, now = Date.now()) {
|
|
|
86090
86995
|
return now - Math.max(...mtimes);
|
|
86091
86996
|
}
|
|
86092
86997
|
async function quarantineResidueAt(baseRoot, dirName, options) {
|
|
86093
|
-
const finalPath =
|
|
86998
|
+
const finalPath = path27.join(baseRoot, dirName);
|
|
86094
86999
|
let inode;
|
|
86095
87000
|
try {
|
|
86096
|
-
inode = (await
|
|
87001
|
+
inode = (await fs25.lstat(finalPath)).ino;
|
|
86097
87002
|
} catch (err) {
|
|
86098
87003
|
if (isNotFoundError2(err)) return { kind: "vacant" };
|
|
86099
87004
|
throw err;
|
|
86100
87005
|
}
|
|
86101
87006
|
const candidateName = stampedName(REPAIR_PREFIX, dirName, /* @__PURE__ */ new Date());
|
|
86102
|
-
const candidate =
|
|
87007
|
+
const candidate = path27.join(baseRoot, candidateName);
|
|
86103
87008
|
try {
|
|
86104
|
-
await
|
|
87009
|
+
await fs25.rename(finalPath, candidate);
|
|
86105
87010
|
} catch (err) {
|
|
86106
87011
|
if (isNotFoundError2(err)) return { kind: "vacant" };
|
|
86107
87012
|
throw err;
|
|
86108
87013
|
}
|
|
86109
87014
|
const moveBack = async (why) => {
|
|
86110
87015
|
try {
|
|
86111
|
-
await
|
|
87016
|
+
await fs25.rename(candidate, finalPath);
|
|
86112
87017
|
} catch (err) {
|
|
86113
87018
|
canopyLogError(
|
|
86114
87019
|
`[canopy] Could not move '${dirName}' back from ${candidateName} after ${why}: ${getErrorMessage(err)}. The worker's sweep restores or trashes it.`
|
|
@@ -86123,7 +87028,7 @@ async function quarantineResidueAt(baseRoot, dirName, options) {
|
|
|
86123
87028
|
);
|
|
86124
87029
|
if (reason === void 0 && state3.kind === "residue") {
|
|
86125
87030
|
const trashName = stampedName(TRASH_PREFIX, dirName, /* @__PURE__ */ new Date());
|
|
86126
|
-
await
|
|
87031
|
+
await fs25.rename(candidate, path27.join(baseRoot, trashName));
|
|
86127
87032
|
const { hasGitDir, configLock, hasIndex } = state3.signature;
|
|
86128
87033
|
canopyLogWarn(
|
|
86129
87034
|
`[canopy] Quarantined unfinished branch directory '${dirName}' as ${trashName} (git=${hasGitDir} config.lock=${configLock} index=${hasIndex} quiet=${Math.round(quiet / 1e3)}s)`
|
|
@@ -86135,7 +87040,7 @@ async function quarantineResidueAt(baseRoot, dirName, options) {
|
|
|
86135
87040
|
}
|
|
86136
87041
|
async function judgeQuarantineCandidate(candidate, inode, options) {
|
|
86137
87042
|
const state3 = await classifyFinalDir(candidate, options.expectedRemoteUrl);
|
|
86138
|
-
const moved = await
|
|
87043
|
+
const moved = await fs25.lstat(candidate).catch(() => null);
|
|
86139
87044
|
const quiet = await quietAgeMs(candidate, options.now);
|
|
86140
87045
|
let reason;
|
|
86141
87046
|
if (!moved || moved.ino !== inode) reason = "replaced";
|
|
@@ -86152,7 +87057,7 @@ async function sweepByAge(root5, rules, now) {
|
|
|
86152
87057
|
const stamp = rule ? parseDirStamp(name2) : null;
|
|
86153
87058
|
if (!rule || !stamp || now - stamp.getTime() < rule.maxAgeMs) continue;
|
|
86154
87059
|
try {
|
|
86155
|
-
await
|
|
87060
|
+
await fs25.rm(path27.join(root5, name2), {
|
|
86156
87061
|
recursive: true,
|
|
86157
87062
|
force: true,
|
|
86158
87063
|
maxRetries: 3,
|
|
@@ -86166,7 +87071,7 @@ async function sweepByAge(root5, rules, now) {
|
|
|
86166
87071
|
return actions;
|
|
86167
87072
|
}
|
|
86168
87073
|
async function recoverRepairDir(baseRoot, name2) {
|
|
86169
|
-
const repairPath =
|
|
87074
|
+
const repairPath = path27.join(baseRoot, name2);
|
|
86170
87075
|
const meta = await readBranchMetadataFile(repairPath).catch(() => null);
|
|
86171
87076
|
const dirName = meta ? sanitizeBranchName(meta.branch.name) : void 0;
|
|
86172
87077
|
if (dirName && name2.startsWith(`${REPAIR_PREFIX}${shortDirName(dirName)}-`)) {
|
|
@@ -86180,9 +87085,9 @@ async function recoverRepairDir(baseRoot, name2) {
|
|
|
86180
87085
|
throw err;
|
|
86181
87086
|
}
|
|
86182
87087
|
try {
|
|
86183
|
-
const finalPath =
|
|
86184
|
-
if (await
|
|
86185
|
-
await
|
|
87088
|
+
const finalPath = path27.join(baseRoot, dirName);
|
|
87089
|
+
if (await fs25.lstat(finalPath).catch(() => null) === null) {
|
|
87090
|
+
await fs25.rename(repairPath, finalPath);
|
|
86186
87091
|
return { name: name2, action: "restored", detail: dirName };
|
|
86187
87092
|
}
|
|
86188
87093
|
} finally {
|
|
@@ -86191,7 +87096,7 @@ async function recoverRepairDir(baseRoot, name2) {
|
|
|
86191
87096
|
}
|
|
86192
87097
|
}
|
|
86193
87098
|
const trashName = `${TRASH_PREFIX}${name2.slice(REPAIR_PREFIX.length)}`;
|
|
86194
|
-
await
|
|
87099
|
+
await fs25.rename(repairPath, path27.join(baseRoot, trashName));
|
|
86195
87100
|
return { name: name2, action: "trashed", detail: trashName };
|
|
86196
87101
|
}
|
|
86197
87102
|
async function sweepProvisioningLeftovers(baseRoot, workspaceRoot, now = Date.now()) {
|
|
@@ -86242,12 +87147,12 @@ async function maintainRemoteGit(gitDir) {
|
|
|
86242
87147
|
}
|
|
86243
87148
|
|
|
86244
87149
|
// ../canopycms/src/worker/sparse-cone.ts
|
|
86245
|
-
import
|
|
86246
|
-
import
|
|
87150
|
+
import fs27 from "node:fs/promises";
|
|
87151
|
+
import path29 from "node:path";
|
|
86247
87152
|
|
|
86248
87153
|
// ../canopycms/src/branch-sparse.ts
|
|
86249
|
-
import
|
|
86250
|
-
import
|
|
87154
|
+
import fs26 from "node:fs/promises";
|
|
87155
|
+
import path28 from "node:path";
|
|
86251
87156
|
init_error();
|
|
86252
87157
|
function sameCone(a9, b10) {
|
|
86253
87158
|
if (a9 === null || b10 === null) return a9 === b10;
|
|
@@ -86256,12 +87161,12 @@ function sameCone(a9, b10) {
|
|
|
86256
87161
|
}
|
|
86257
87162
|
var SPARSE_CONE_RECORD = ".sparse-cone.json";
|
|
86258
87163
|
function isConeDir(dir) {
|
|
86259
|
-
return typeof dir === "string" && dir.length > 0 && !
|
|
87164
|
+
return typeof dir === "string" && dir.length > 0 && !path28.isAbsolute(dir) && !dir.split("/").some((segment) => segment === "" || segment === "." || segment === "..");
|
|
86260
87165
|
}
|
|
86261
87166
|
async function readRecordedSparseCone(contentBranchesRoot) {
|
|
86262
87167
|
let raw;
|
|
86263
87168
|
try {
|
|
86264
|
-
raw = await
|
|
87169
|
+
raw = await fs26.readFile(path28.join(contentBranchesRoot, SPARSE_CONE_RECORD), "utf8");
|
|
86265
87170
|
} catch (err) {
|
|
86266
87171
|
if (isNodeError(err) && err.code === "ENOENT") return void 0;
|
|
86267
87172
|
throw err;
|
|
@@ -86294,15 +87199,15 @@ async function reapplySparseCones(ctx) {
|
|
|
86294
87199
|
if (!recorded) return report;
|
|
86295
87200
|
let entries;
|
|
86296
87201
|
try {
|
|
86297
|
-
entries = await
|
|
87202
|
+
entries = await fs27.readdir(ctx.contentBranchesPath, { withFileTypes: true });
|
|
86298
87203
|
} catch (err) {
|
|
86299
87204
|
if (isNodeError(err) && err.code === "ENOENT") return report;
|
|
86300
87205
|
throw err;
|
|
86301
87206
|
}
|
|
86302
87207
|
const dirNames = entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).sort();
|
|
86303
87208
|
for (const dirName of dirNames) {
|
|
86304
|
-
const branchPath =
|
|
86305
|
-
const isClone = await
|
|
87209
|
+
const branchPath = path29.join(ctx.contentBranchesPath, dirName);
|
|
87210
|
+
const isClone = await fs27.stat(path29.join(branchPath, ".git")).then(
|
|
86306
87211
|
(stat) => stat.isDirectory(),
|
|
86307
87212
|
() => false
|
|
86308
87213
|
);
|
|
@@ -86334,7 +87239,7 @@ async function reapplySparseCones(ctx) {
|
|
|
86334
87239
|
return report;
|
|
86335
87240
|
}
|
|
86336
87241
|
async function reapplyOne(contentBranchesPath, dirName, git, target) {
|
|
86337
|
-
const branchPath =
|
|
87242
|
+
const branchPath = path29.join(contentBranchesPath, dirName);
|
|
86338
87243
|
const hold = await holdProvisionedWorkspace(contentBranchesPath, dirName);
|
|
86339
87244
|
if (hold.kind !== "held") return "skipped";
|
|
86340
87245
|
try {
|
|
@@ -86374,11 +87279,11 @@ async function reapplyOne(contentBranchesPath, dirName, git, target) {
|
|
|
86374
87279
|
|
|
86375
87280
|
// ../canopycms/src/worker/stale-mirror.ts
|
|
86376
87281
|
init_branch_name();
|
|
86377
|
-
import
|
|
86378
|
-
import
|
|
87282
|
+
import fs28 from "node:fs/promises";
|
|
87283
|
+
import path30 from "node:path";
|
|
86379
87284
|
init_error();
|
|
86380
87285
|
async function readEditorWork(ctx) {
|
|
86381
|
-
const workspaces = new Set(await
|
|
87286
|
+
const workspaces = new Set(await fs28.readdir(ctx.contentBranchesPath).catch(() => []));
|
|
86382
87287
|
const queuedPushes = /* @__PURE__ */ new Set();
|
|
86383
87288
|
for (const status of ["pending", "processing"]) {
|
|
86384
87289
|
for (const task of await listTasks(ctx.taskDir, status, Number.POSITIVE_INFINITY)) {
|
|
@@ -86413,7 +87318,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
|
|
|
86413
87318
|
throw err;
|
|
86414
87319
|
}
|
|
86415
87320
|
try {
|
|
86416
|
-
if ((await
|
|
87321
|
+
if ((await fs28.readdir(ctx.contentBranchesPath)).includes(dirName)) {
|
|
86417
87322
|
return { kind: "kept", state: "workspace" };
|
|
86418
87323
|
}
|
|
86419
87324
|
const ref = `refs/heads/${name2}`;
|
|
@@ -86423,7 +87328,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
|
|
|
86423
87328
|
);
|
|
86424
87329
|
} catch (err) {
|
|
86425
87330
|
const message2 = getErrorMessage(err);
|
|
86426
|
-
if (lockHeld(message2) ===
|
|
87331
|
+
if (lockHeld(message2) === path30.join(ctx.remoteGitPath, "packed-refs.lock")) {
|
|
86427
87332
|
return { kind: "packed-refs-locked" };
|
|
86428
87333
|
}
|
|
86429
87334
|
if (/cannot lock ref|Unable to create '[^']*\.lock': File exists/.test(message2)) {
|
|
@@ -86438,7 +87343,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
|
|
|
86438
87343
|
}
|
|
86439
87344
|
function lockHeld(message2) {
|
|
86440
87345
|
const match2 = /Unable to create '([^']*)': File exists/.exec(message2);
|
|
86441
|
-
return match2 ?
|
|
87346
|
+
return match2 ? path30.normalize(match2[1]) : null;
|
|
86442
87347
|
}
|
|
86443
87348
|
async function sharesHistory(git, head, baseTip) {
|
|
86444
87349
|
try {
|
|
@@ -86607,11 +87512,12 @@ async function reconcileTrackedBranches(ctx, git, githubTips) {
|
|
|
86607
87512
|
}
|
|
86608
87513
|
}
|
|
86609
87514
|
try {
|
|
87515
|
+
if (name2 !== ctx.baseBranch) await recordSeenOnGitHub(ctx, name2, trackedSha);
|
|
86610
87516
|
await git.raw(["update-ref", "--no-deref", localRef, trackedSha, localSha]);
|
|
86611
87517
|
fastForwarded.push(name2);
|
|
86612
87518
|
} catch (err) {
|
|
86613
87519
|
workerLogWarn(
|
|
86614
|
-
` Tracked-branch reconcile: failed to fast-forward ${escapeForLog(name2)} (concurrent update?): ${escapeForLog(getErrorMessage(err))}`
|
|
87520
|
+
` Tracked-branch reconcile: failed to fast-forward ${escapeForLog(name2)} (concurrent update, or its branch.json?): ${escapeForLog(getErrorMessage(err))}`
|
|
86615
87521
|
);
|
|
86616
87522
|
}
|
|
86617
87523
|
} else if (localBehindCount === 0 && localAheadCount > 0) {
|
|
@@ -86704,7 +87610,7 @@ function divergedWarning({ name: name2, local, github, state: state3, error: err
|
|
|
86704
87610
|
// The reason is part of what was said, so a head first kept as `busy` is reported again with
|
|
86705
87611
|
// the reason that keeps it.
|
|
86706
87612
|
said: `${local} ${github} ${state3}`,
|
|
86707
|
-
line: ` Tracked-branch reconcile: ${escapeForLog(name2)} diverged from GitHub and was left untouched, because ${EDITOR_STATE_WORDS[state3]}${error3 === void 0 ? "" : ` (${escapeForLog(error3)})`} (here ${local}, GitHub ${github}).
|
|
87613
|
+
line: ` Tracked-branch reconcile: ${escapeForLog(name2)} diverged from GitHub and was left untouched, because ${EDITOR_STATE_WORDS[state3]}${error3 === void 0 ? "" : ` (${escapeForLog(error3)})`} (here ${local}, GitHub ${github}). The next rebase cycle merges commits added on GitHub; otherwise publishing it fails until the two are reconciled. System health lists it.`
|
|
86708
87614
|
};
|
|
86709
87615
|
}
|
|
86710
87616
|
function warnOnce2(warned3, lines) {
|
|
@@ -86744,6 +87650,7 @@ async function syncGit(ctx) {
|
|
|
86744
87650
|
workerLogWarn(`remote.git maintenance failed: ${getErrorMessage(err)}`);
|
|
86745
87651
|
}
|
|
86746
87652
|
if (stoppedForDrain(ctx, "the GitHub fetch")) return;
|
|
87653
|
+
const fetchedAt = Date.now();
|
|
86747
87654
|
const { refs: githubTips, needsOperator } = await fetchGitHubIntoRemoteGit(
|
|
86748
87655
|
ctx,
|
|
86749
87656
|
ctx.shutdownSignal()
|
|
@@ -86779,7 +87686,10 @@ async function syncGit(ctx) {
|
|
|
86779
87686
|
(writeErr) => workerLogError("Failed to write worker status:", getErrorMessage(writeErr))
|
|
86780
87687
|
);
|
|
86781
87688
|
}
|
|
86782
|
-
const rebaseSummary = await runRebaseCycle(ctx, branchPolicy
|
|
87689
|
+
const rebaseSummary = await runRebaseCycle(ctx, branchPolicy, {
|
|
87690
|
+
tips: githubTips,
|
|
87691
|
+
fetchedAt
|
|
87692
|
+
});
|
|
86783
87693
|
if (stoppedForDrain(ctx, "the cleanup sweeps")) return;
|
|
86784
87694
|
await cleanupOldTasks(ctx.taskDir, void 0, ctx.log);
|
|
86785
87695
|
if (health && branchPolicy) {
|
|
@@ -86841,7 +87751,7 @@ var reportedForeignDirs = /* @__PURE__ */ new Set();
|
|
|
86841
87751
|
async function repairBranchDirResidue(ctx, now = Date.now()) {
|
|
86842
87752
|
let entries;
|
|
86843
87753
|
try {
|
|
86844
|
-
entries = await
|
|
87754
|
+
entries = await fs29.readdir(ctx.contentBranchesPath, { withFileTypes: true });
|
|
86845
87755
|
} catch (err) {
|
|
86846
87756
|
if (isNodeError(err) && err.code === "ENOENT") return;
|
|
86847
87757
|
throw err;
|
|
@@ -86856,7 +87766,7 @@ async function repairBranchDirResidue(ctx, now = Date.now()) {
|
|
|
86856
87766
|
}
|
|
86857
87767
|
const leftovers = await sweepProvisioningLeftovers(
|
|
86858
87768
|
ctx.contentBranchesPath,
|
|
86859
|
-
|
|
87769
|
+
path31.dirname(ctx.contentBranchesPath),
|
|
86860
87770
|
now
|
|
86861
87771
|
);
|
|
86862
87772
|
for (const { name: name2, action, detail } of leftovers) {
|
|
@@ -86867,8 +87777,8 @@ async function repairBranchDirResidue(ctx, now = Date.now()) {
|
|
|
86867
87777
|
}
|
|
86868
87778
|
}
|
|
86869
87779
|
async function repairOneBranchDir(ctx, dirName, now) {
|
|
86870
|
-
const dirPath =
|
|
86871
|
-
const hasMeta = await
|
|
87780
|
+
const dirPath = path31.join(ctx.contentBranchesPath, dirName);
|
|
87781
|
+
const hasMeta = await fs29.access(path31.join(dirPath, BRANCH_META_DIR, BRANCH_META_FILE)).then(
|
|
86872
87782
|
() => true,
|
|
86873
87783
|
() => false
|
|
86874
87784
|
);
|
|
@@ -86904,7 +87814,7 @@ async function repairOneBranchDir(ctx, dirName, now) {
|
|
|
86904
87814
|
async function cleanupTrashedBranchDirs(ctx) {
|
|
86905
87815
|
let entries;
|
|
86906
87816
|
try {
|
|
86907
|
-
entries = await
|
|
87817
|
+
entries = await fs29.readdir(ctx.contentBranchesPath);
|
|
86908
87818
|
} catch (err) {
|
|
86909
87819
|
if (isNodeError(err) && err.code === "ENOENT") return 0;
|
|
86910
87820
|
throw err;
|
|
@@ -86924,7 +87834,7 @@ async function cleanupTrashedBranchDirs(ctx) {
|
|
|
86924
87834
|
}
|
|
86925
87835
|
if (now - stampDate.getTime() < TRASH_RETENTION_MS) continue;
|
|
86926
87836
|
try {
|
|
86927
|
-
await
|
|
87837
|
+
await fs29.rm(path31.join(ctx.contentBranchesPath, name2), {
|
|
86928
87838
|
recursive: true,
|
|
86929
87839
|
force: true,
|
|
86930
87840
|
maxRetries: 3,
|
|
@@ -86942,7 +87852,7 @@ async function cleanupTrashedBranchDirs(ctx) {
|
|
|
86942
87852
|
}
|
|
86943
87853
|
var warnedTrackedCanopyState = /* @__PURE__ */ new Set();
|
|
86944
87854
|
async function refreshBaseBranchWorkspace(ctx) {
|
|
86945
|
-
const basePath37 =
|
|
87855
|
+
const basePath37 = path31.join(ctx.contentBranchesPath, ctx.sanitizedBaseBranch);
|
|
86946
87856
|
let trackedCanopyMeta;
|
|
86947
87857
|
let releaseProvisioning;
|
|
86948
87858
|
let releaseContentLock;
|
|
@@ -87100,10 +88010,10 @@ async function refreshBaseBranchWorkspace(ctx) {
|
|
|
87100
88010
|
// ../canopycms/src/worker/github-gateway-http.ts
|
|
87101
88011
|
init_error();
|
|
87102
88012
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
87103
|
-
import
|
|
88013
|
+
import fs30 from "node:fs/promises";
|
|
87104
88014
|
import http from "node:http";
|
|
87105
88015
|
import net from "node:net";
|
|
87106
|
-
import
|
|
88016
|
+
import path32 from "node:path";
|
|
87107
88017
|
import { PassThrough } from "node:stream";
|
|
87108
88018
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
87109
88019
|
var MAX_POLL_WAIT_MS = 25e3;
|
|
@@ -87126,11 +88036,11 @@ async function serveGitHubGateway(gateway, listen, options = {}) {
|
|
|
87126
88036
|
if ("fd" in listen) {
|
|
87127
88037
|
await listenOn(server, { fd: listen.fd });
|
|
87128
88038
|
} else {
|
|
87129
|
-
await assertPrivateDirectory(
|
|
88039
|
+
await assertPrivateDirectory(path32.dirname(listen.path));
|
|
87130
88040
|
await removeStaleSocket(listen.path);
|
|
87131
88041
|
await listenOn(server, { path: listen.path });
|
|
87132
88042
|
try {
|
|
87133
|
-
await
|
|
88043
|
+
await fs30.chmod(listen.path, 384);
|
|
87134
88044
|
} catch (err) {
|
|
87135
88045
|
await closeServer(server, handler);
|
|
87136
88046
|
throw err;
|
|
@@ -87171,7 +88081,7 @@ function listenOn(server, options) {
|
|
|
87171
88081
|
});
|
|
87172
88082
|
}
|
|
87173
88083
|
async function assertPrivateDirectory(dir) {
|
|
87174
|
-
const stat = await
|
|
88084
|
+
const stat = await fs30.lstat(dir);
|
|
87175
88085
|
const uid = process.getuid?.();
|
|
87176
88086
|
if (!stat.isDirectory() || uid !== void 0 && (stat.uid !== uid || (stat.mode & 63) !== 0)) {
|
|
87177
88087
|
throw new Error(
|
|
@@ -87182,7 +88092,7 @@ async function assertPrivateDirectory(dir) {
|
|
|
87182
88092
|
async function removeStaleSocket(socketPath) {
|
|
87183
88093
|
let stat;
|
|
87184
88094
|
try {
|
|
87185
|
-
stat = await
|
|
88095
|
+
stat = await fs30.lstat(socketPath);
|
|
87186
88096
|
} catch (err) {
|
|
87187
88097
|
if (isNodeError(err) && err.code === "ENOENT") return;
|
|
87188
88098
|
throw err;
|
|
@@ -87198,7 +88108,7 @@ async function removeStaleSocket(socketPath) {
|
|
|
87198
88108
|
`Refusing to serve the GitHub gateway at ${socketPath}: a gateway already serves there`
|
|
87199
88109
|
);
|
|
87200
88110
|
}
|
|
87201
|
-
await
|
|
88111
|
+
await fs30.unlink(socketPath);
|
|
87202
88112
|
}
|
|
87203
88113
|
function isServed(socketPath) {
|
|
87204
88114
|
return new Promise((resolve) => {
|
|
@@ -87258,11 +88168,8 @@ var GatewayRequestHandler = class {
|
|
|
87258
88168
|
return {};
|
|
87259
88169
|
},
|
|
87260
88170
|
getPullRequest: async ({ number }, signal) => {
|
|
87261
|
-
const { merged, merged_at, state: state3, node_id, body } = await gateway.getPullRequest(
|
|
87262
|
-
|
|
87263
|
-
signal
|
|
87264
|
-
);
|
|
87265
|
-
return { merged, merged_at, state: state3, node_id, body };
|
|
88171
|
+
const { merged, merged_at, state: state3, node_id, body, mergeable_state, baseRef } = await gateway.getPullRequest(number, signal);
|
|
88172
|
+
return { merged, merged_at, state: state3, node_id, body, mergeable_state, baseRef };
|
|
87266
88173
|
},
|
|
87267
88174
|
createOrUpdatePullRequest: async (input, signal) => {
|
|
87268
88175
|
const { number, url, created } = await gateway.createOrUpdatePullRequest(input, signal);
|
|
@@ -87737,6 +88644,7 @@ var GitHubGatewayClient = class {
|
|
|
87737
88644
|
branch: request.branch,
|
|
87738
88645
|
sha: request.sha,
|
|
87739
88646
|
...request.lease === void 0 ? {} : { lease: request.lease },
|
|
88647
|
+
...request.seen === void 0 ? {} : { seen: request.seen },
|
|
87740
88648
|
prerequisites: [...request.prerequisites],
|
|
87741
88649
|
bundle: bundle !== void 0
|
|
87742
88650
|
});
|
|
@@ -87932,9 +88840,9 @@ init_branch_namespace();
|
|
|
87932
88840
|
|
|
87933
88841
|
// ../canopycms/src/worker/self-checks.ts
|
|
87934
88842
|
init_error();
|
|
87935
|
-
import
|
|
88843
|
+
import fs31 from "node:fs/promises";
|
|
87936
88844
|
import net2 from "node:net";
|
|
87937
|
-
import
|
|
88845
|
+
import path33 from "node:path";
|
|
87938
88846
|
var IMDS_HOST = "169.254.169.254";
|
|
87939
88847
|
var IMDS_CONNECT_TIMEOUT_MS = 1e3;
|
|
87940
88848
|
var NO_ROUTE_CODES = /* @__PURE__ */ new Set(["ENETUNREACH", "EAFNOSUPPORT"]);
|
|
@@ -87989,10 +88897,10 @@ async function imdsUnreachable(environment = {}) {
|
|
|
87989
88897
|
};
|
|
87990
88898
|
}
|
|
87991
88899
|
async function onlyLoopback(environment = {}) {
|
|
87992
|
-
const file =
|
|
88900
|
+
const file = path33.join(rootOf(environment), "proc", "self", "net", "dev");
|
|
87993
88901
|
let text;
|
|
87994
88902
|
try {
|
|
87995
|
-
text = await
|
|
88903
|
+
text = await fs31.readFile(file, "utf8");
|
|
87996
88904
|
} catch (err) {
|
|
87997
88905
|
return {
|
|
87998
88906
|
check: "network-namespace",
|
|
@@ -88009,21 +88917,21 @@ async function onlyLoopback(environment = {}) {
|
|
|
88009
88917
|
};
|
|
88010
88918
|
}
|
|
88011
88919
|
async function procShowsOnlyOwnProcesses(environment = {}) {
|
|
88012
|
-
const proc =
|
|
88920
|
+
const proc = path33.join(rootOf(environment), "proc");
|
|
88013
88921
|
const uid = environment.uid ?? process.getuid?.();
|
|
88014
88922
|
if (uid === void 0) {
|
|
88015
88923
|
return { check: "proc", ok: false, detail: "this platform has no process uid to compare" };
|
|
88016
88924
|
}
|
|
88017
88925
|
let entries;
|
|
88018
88926
|
try {
|
|
88019
|
-
entries = await
|
|
88927
|
+
entries = await fs31.readdir(proc);
|
|
88020
88928
|
} catch (err) {
|
|
88021
88929
|
return { check: "proc", ok: false, detail: `cannot list ${proc}: ${getErrorMessage(err)}` };
|
|
88022
88930
|
}
|
|
88023
88931
|
const others = [];
|
|
88024
88932
|
for (const entry of entries.filter((name2) => /^\d+$/.test(name2))) {
|
|
88025
88933
|
try {
|
|
88026
|
-
const stat = await
|
|
88934
|
+
const stat = await fs31.stat(path33.join(proc, entry));
|
|
88027
88935
|
if (stat.uid !== uid) others.push(`${entry} (uid ${stat.uid})`);
|
|
88028
88936
|
} catch (err) {
|
|
88029
88937
|
if (!(isNodeError(err) && err.code === "ENOENT")) {
|
|
@@ -88039,9 +88947,9 @@ async function procShowsOnlyOwnProcesses(environment = {}) {
|
|
|
88039
88947
|
};
|
|
88040
88948
|
}
|
|
88041
88949
|
async function homeIsEmpty(environment = {}) {
|
|
88042
|
-
const home =
|
|
88950
|
+
const home = path33.join(rootOf(environment), "home");
|
|
88043
88951
|
try {
|
|
88044
|
-
const entries = await
|
|
88952
|
+
const entries = await fs31.readdir(home);
|
|
88045
88953
|
return {
|
|
88046
88954
|
check: "home",
|
|
88047
88955
|
ok: entries.length === 0,
|
|
@@ -88064,9 +88972,9 @@ function noSecretsInEnv(environment = {}) {
|
|
|
88064
88972
|
};
|
|
88065
88973
|
}
|
|
88066
88974
|
async function efsUnreadable(environment = {}) {
|
|
88067
|
-
const efs =
|
|
88975
|
+
const efs = path33.join(rootOf(environment), "mnt", "efs");
|
|
88068
88976
|
try {
|
|
88069
|
-
await
|
|
88977
|
+
await fs31.readdir(efs);
|
|
88070
88978
|
} catch (err) {
|
|
88071
88979
|
const code = isNodeError(err) ? err.code : void 0;
|
|
88072
88980
|
const denied = code === "EACCES" || code === "EPERM";
|
|
@@ -88083,9 +88991,9 @@ async function efsUnreadable(environment = {}) {
|
|
|
88083
88991
|
};
|
|
88084
88992
|
}
|
|
88085
88993
|
async function corePatternNotPiped(environment = {}) {
|
|
88086
|
-
const file =
|
|
88994
|
+
const file = path33.join(rootOf(environment), "proc", "sys", "kernel", "core_pattern");
|
|
88087
88995
|
try {
|
|
88088
|
-
const pattern = (await
|
|
88996
|
+
const pattern = (await fs31.readFile(file, "utf8")).trim();
|
|
88089
88997
|
const ok = !pattern.startsWith("|");
|
|
88090
88998
|
return {
|
|
88091
88999
|
check: "core-pattern",
|
|
@@ -88101,10 +89009,10 @@ async function corePatternNotPiped(environment = {}) {
|
|
|
88101
89009
|
}
|
|
88102
89010
|
}
|
|
88103
89011
|
async function coreLimitZero(environment = {}) {
|
|
88104
|
-
const file =
|
|
89012
|
+
const file = path33.join(rootOf(environment), "proc", "self", "limits");
|
|
88105
89013
|
let text;
|
|
88106
89014
|
try {
|
|
88107
|
-
text = await
|
|
89015
|
+
text = await fs31.readFile(file, "utf8");
|
|
88108
89016
|
} catch (err) {
|
|
88109
89017
|
return {
|
|
88110
89018
|
check: "core-limit",
|
|
@@ -88126,11 +89034,11 @@ async function socketAccessIsOthers(environment = {}) {
|
|
|
88126
89034
|
const uid = environment.uid ?? process.getuid?.();
|
|
88127
89035
|
if (uid === void 0) return fail("this platform has no process uid to compare");
|
|
88128
89036
|
const fd = environment.listenFd ?? 3;
|
|
88129
|
-
const proc =
|
|
89037
|
+
const proc = path33.join(rootOf(environment), "proc", "self");
|
|
88130
89038
|
let socketPath;
|
|
88131
89039
|
try {
|
|
88132
|
-
const inode = (await
|
|
88133
|
-
const table = await
|
|
89040
|
+
const inode = (await fs31.stat(path33.join(proc, "fd", String(fd)))).ino;
|
|
89041
|
+
const table = await fs31.readFile(path33.join(proc, "net", "unix"), "utf8");
|
|
88134
89042
|
for (const line of table.split("\n").slice(1)) {
|
|
88135
89043
|
const fields = line.trim().split(/\s+/);
|
|
88136
89044
|
if (fields[6] === String(inode) && fields.length > 7) socketPath = fields.slice(7).join(" ");
|
|
@@ -88138,12 +89046,12 @@ async function socketAccessIsOthers(environment = {}) {
|
|
|
88138
89046
|
} catch (err) {
|
|
88139
89047
|
return fail(`cannot find the socket on descriptor ${fd}: ${getErrorMessage(err)}`);
|
|
88140
89048
|
}
|
|
88141
|
-
if (socketPath === void 0 || !
|
|
89049
|
+
if (socketPath === void 0 || !path33.isAbsolute(socketPath)) {
|
|
88142
89050
|
return fail(`the socket on descriptor ${fd} is not bound to a path`);
|
|
88143
89051
|
}
|
|
88144
89052
|
let node;
|
|
88145
89053
|
try {
|
|
88146
|
-
node = await
|
|
89054
|
+
node = await fs31.lstat(socketPath);
|
|
88147
89055
|
} catch (err) {
|
|
88148
89056
|
return fail(`cannot read ${socketPath}: ${getErrorMessage(err)}`);
|
|
88149
89057
|
}
|
|
@@ -88190,8 +89098,8 @@ function tcpConnect(host, port, timeoutMs) {
|
|
|
88190
89098
|
|
|
88191
89099
|
// ../canopycms/src/worker/cms-worker.ts
|
|
88192
89100
|
function defaultStateDirectory(workspacePath) {
|
|
88193
|
-
const key = createHash2("sha256").update(
|
|
88194
|
-
return
|
|
89101
|
+
const key = createHash2("sha256").update(path34.resolve(workspacePath)).digest("hex").slice(0, 16);
|
|
89102
|
+
return path34.join(os.tmpdir(), `canopycms-worker-${key}`);
|
|
88195
89103
|
}
|
|
88196
89104
|
var MAX_REFS_LISTED = 20;
|
|
88197
89105
|
var RemoteGitKeptError = class extends Error {
|
|
@@ -88242,7 +89150,7 @@ function lockWorkerTaskDir(taskDir, lockStaleMs, options) {
|
|
|
88242
89150
|
const waitMs = options.waitMs ?? 0;
|
|
88243
89151
|
const intervalMs = Math.max(250, Math.min(5e3, Math.floor(lockStaleMs / 4)));
|
|
88244
89152
|
return import_proper_lockfile3.default.lock(taskDir, {
|
|
88245
|
-
lockfilePath:
|
|
89153
|
+
lockfilePath: path34.join(taskDir, ".worker-lock"),
|
|
88246
89154
|
stale: lockStaleMs,
|
|
88247
89155
|
onCompromised: options.onCompromised,
|
|
88248
89156
|
...waitMs > 0 ? {
|
|
@@ -88268,10 +89176,10 @@ async function readCarriedFields(taskDir) {
|
|
|
88268
89176
|
};
|
|
88269
89177
|
}
|
|
88270
89178
|
async function recordWorkerStartupFailure(options) {
|
|
88271
|
-
const taskDir =
|
|
89179
|
+
const taskDir = path34.join(options.workspacePath, ".tasks");
|
|
88272
89180
|
let release2;
|
|
88273
89181
|
try {
|
|
88274
|
-
await
|
|
89182
|
+
await fs32.mkdir(taskDir, { recursive: true });
|
|
88275
89183
|
release2 = await lockWorkerTaskDir(taskDir, 2 * (options.lockStaleMs ?? DEFAULT_LOCK_STALE_MS), {
|
|
88276
89184
|
onCompromised: (err) => workerLogError("Worker lock lost while recording a startup failure:", getErrorMessage(err))
|
|
88277
89185
|
});
|
|
@@ -88326,17 +89234,18 @@ var CmsWorker = class {
|
|
|
88326
89234
|
this.selfStopped = new Promise((resolve) => {
|
|
88327
89235
|
this.settleSelfStopped = resolve;
|
|
88328
89236
|
});
|
|
88329
|
-
this.taskDir =
|
|
88330
|
-
this.remoteGitPath =
|
|
88331
|
-
this.stateDirectory =
|
|
89237
|
+
this.taskDir = path34.join(config.workspacePath, ".tasks");
|
|
89238
|
+
this.remoteGitPath = path34.join(path34.resolve(config.workspacePath), "remote.git");
|
|
89239
|
+
this.stateDirectory = path34.resolve(
|
|
88332
89240
|
config.stateDirectory ?? defaultStateDirectory(config.workspacePath)
|
|
88333
89241
|
);
|
|
88334
|
-
this.contentBranchesPath =
|
|
89242
|
+
this.contentBranchesPath = path34.join(config.workspacePath, "content-branches");
|
|
88335
89243
|
if (config.baseBranch !== void 0) this.setBaseBranch(config.baseBranch);
|
|
88336
89244
|
this.maxTasksPerCycle = config.maxTasksPerCycle ?? 10;
|
|
88337
89245
|
this.taskTimeoutMs = config.taskTimeoutMs ?? DEFAULT_TASK_TIMEOUT;
|
|
89246
|
+
this.gitSyncIntervalMs = config.gitSyncInterval ?? 5 * 6e4;
|
|
88338
89247
|
this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES2;
|
|
88339
|
-
this.lockFilePath =
|
|
89248
|
+
this.lockFilePath = path34.join(config.workspacePath, ".tasks", ".worker-lock");
|
|
88340
89249
|
this.lockStaleMs = config.lockStaleMs ?? DEFAULT_LOCK_STALE_MS;
|
|
88341
89250
|
this.drainDeadlineMs = config.drainDeadlineMs ?? DEFAULT_DRAIN_DEADLINE_MS;
|
|
88342
89251
|
this.contentRoot = config.contentRoot ?? "content";
|
|
@@ -88409,6 +89318,7 @@ var CmsWorker = class {
|
|
|
88409
89318
|
contentRoot: this.contentRoot,
|
|
88410
89319
|
schemaHoldMaxMs: this.schemaHoldMaxMs,
|
|
88411
89320
|
taskTimeoutMs: this.taskTimeoutMs,
|
|
89321
|
+
gitSyncIntervalMs: this.gitSyncIntervalMs,
|
|
88412
89322
|
maxTasksPerCycle: this.maxTasksPerCycle,
|
|
88413
89323
|
maxRetries: this.maxRetries,
|
|
88414
89324
|
log: this.log,
|
|
@@ -88515,7 +89425,7 @@ var CmsWorker = class {
|
|
|
88515
89425
|
}
|
|
88516
89426
|
if (this.stopping) return;
|
|
88517
89427
|
const taskInterval = this.config.taskPollInterval ?? 5e3;
|
|
88518
|
-
const gitInterval = this.
|
|
89428
|
+
const gitInterval = this.gitSyncIntervalMs;
|
|
88519
89429
|
this.scheduleLoop("task queue", () => this.processTaskQueue(), taskInterval);
|
|
88520
89430
|
this.scheduleLoop("git sync", () => this.syncGit(), gitInterval);
|
|
88521
89431
|
if (this.config.refreshAuthCache) {
|
|
@@ -88628,7 +89538,7 @@ var CmsWorker = class {
|
|
|
88628
89538
|
* is negligible at the default TTL; a badly wrong clock misjudges liveness.
|
|
88629
89539
|
*/
|
|
88630
89540
|
async acquireLock() {
|
|
88631
|
-
await
|
|
89541
|
+
await fs32.mkdir(this.taskDir, { recursive: true });
|
|
88632
89542
|
try {
|
|
88633
89543
|
this.releaseLockFn = await lockWorkerTaskDir(this.taskDir, this.lockStaleMs, {
|
|
88634
89544
|
onCompromised: (err) => {
|
|
@@ -88762,7 +89672,7 @@ var CmsWorker = class {
|
|
|
88762
89672
|
);
|
|
88763
89673
|
let remoteGitExists;
|
|
88764
89674
|
try {
|
|
88765
|
-
remoteGitExists = await
|
|
89675
|
+
remoteGitExists = await fs32.stat(this.remoteGitPath).then(
|
|
88766
89676
|
() => true,
|
|
88767
89677
|
(err) => {
|
|
88768
89678
|
if (isNodeError(err) && err.code === "ENOENT") return false;
|
|
@@ -88840,7 +89750,7 @@ var CmsWorker = class {
|
|
|
88840
89750
|
);
|
|
88841
89751
|
if (current === this.baseBranch) return;
|
|
88842
89752
|
await sharedRepoGit(gitDir, "bare").raw(["symbolic-ref", "HEAD", ref]);
|
|
88843
|
-
workerLog(`${
|
|
89753
|
+
workerLog(`${path34.basename(gitDir)} HEAD now names the base branch '${this.baseBranch}'`);
|
|
88844
89754
|
}
|
|
88845
89755
|
/**
|
|
88846
89756
|
* Whether the bare repo at `gitDir` has a local `refs/heads/<baseBranch>`.
|
|
@@ -88940,7 +89850,7 @@ var CmsWorker = class {
|
|
|
88940
89850
|
async ensureRemoteGit() {
|
|
88941
89851
|
let exists3;
|
|
88942
89852
|
try {
|
|
88943
|
-
await
|
|
89853
|
+
await fs32.stat(this.remoteGitPath);
|
|
88944
89854
|
exists3 = true;
|
|
88945
89855
|
} catch {
|
|
88946
89856
|
exists3 = false;
|
|
@@ -88960,7 +89870,7 @@ var CmsWorker = class {
|
|
|
88960
89870
|
}
|
|
88961
89871
|
workerLog("Initializing remote.git from GitHub...");
|
|
88962
89872
|
const stagingPath = await this.seedRemoteGitStaging();
|
|
88963
|
-
await
|
|
89873
|
+
await fs32.rename(stagingPath, this.remoteGitPath);
|
|
88964
89874
|
workerLog("remote.git initialized");
|
|
88965
89875
|
}
|
|
88966
89876
|
/**
|
|
@@ -89016,7 +89926,7 @@ var CmsWorker = class {
|
|
|
89016
89926
|
if (err instanceof RemoteGitKeptError) throw err;
|
|
89017
89927
|
throw notReplaced(redactCredentials(getErrorMessage(err)));
|
|
89018
89928
|
});
|
|
89019
|
-
const discardStaging = () =>
|
|
89929
|
+
const discardStaging = () => fs32.rm(stagingPath, { recursive: true, force: true });
|
|
89020
89930
|
let current;
|
|
89021
89931
|
try {
|
|
89022
89932
|
current = await listRemoteGitRefs(this.remoteGitPath);
|
|
@@ -89034,21 +89944,21 @@ var CmsWorker = class {
|
|
|
89034
89944
|
}
|
|
89035
89945
|
const replaced = `${this.remoteGitPath}.replaced-${Date.now()}`;
|
|
89036
89946
|
try {
|
|
89037
|
-
await
|
|
89947
|
+
await fs32.rename(this.remoteGitPath, replaced);
|
|
89038
89948
|
} catch (err) {
|
|
89039
89949
|
await discardStaging();
|
|
89040
89950
|
throw err;
|
|
89041
89951
|
}
|
|
89042
89952
|
try {
|
|
89043
|
-
await
|
|
89953
|
+
await fs32.rename(stagingPath, this.remoteGitPath);
|
|
89044
89954
|
} catch (err) {
|
|
89045
|
-
await
|
|
89955
|
+
await fs32.rename(replaced, this.remoteGitPath);
|
|
89046
89956
|
await discardStaging();
|
|
89047
89957
|
throw err;
|
|
89048
89958
|
}
|
|
89049
89959
|
const after = await listRemoteGitRefs(replaced).catch(() => null);
|
|
89050
89960
|
if (after !== null && sameRefs(refs, after)) {
|
|
89051
|
-
await
|
|
89961
|
+
await fs32.rm(replaced, { recursive: true, force: true, maxRetries: 3 }).catch((err) => {
|
|
89052
89962
|
workerLogWarn(
|
|
89053
89963
|
`Could not remove the replaced remote.git at ${replaced}: ${getErrorMessage(err)}`
|
|
89054
89964
|
);
|
|
@@ -89068,7 +89978,7 @@ var CmsWorker = class {
|
|
|
89068
89978
|
*/
|
|
89069
89979
|
async seedRemoteGitStaging(check) {
|
|
89070
89980
|
const stagingPath = `${this.remoteGitPath}.cloning`;
|
|
89071
|
-
await
|
|
89981
|
+
await fs32.rm(stagingPath, { recursive: true, force: true });
|
|
89072
89982
|
try {
|
|
89073
89983
|
const githubBranches = await seedFromGitHub(
|
|
89074
89984
|
this.transferContext(),
|
|
@@ -89084,7 +89994,7 @@ var CmsWorker = class {
|
|
|
89084
89994
|
if (!(err instanceof RemoteGitKeptError)) {
|
|
89085
89995
|
workerLogError(`remote.git seeding failed: ${redactCredentials(getErrorMessage(err))}`);
|
|
89086
89996
|
}
|
|
89087
|
-
await
|
|
89997
|
+
await fs32.rm(stagingPath, { recursive: true, force: true });
|
|
89088
89998
|
if (err instanceof RemoteGitKeptError) throw err;
|
|
89089
89999
|
if (err instanceof SharedRepoRefusalError) {
|
|
89090
90000
|
throw new SharedRepoRefusalError(
|
|
@@ -89193,7 +90103,7 @@ var CmsWorker = class {
|
|
|
89193
90103
|
* sanitized.
|
|
89194
90104
|
*/
|
|
89195
90105
|
branchWorkspacePath(branchRefName) {
|
|
89196
|
-
return
|
|
90106
|
+
return path34.join(this.contentBranchesPath, sanitizeBranchName(branchRefName));
|
|
89197
90107
|
}
|
|
89198
90108
|
/**
|
|
89199
90109
|
* Test-only seam: awaited inside `rebaseActiveBranches()`'s conflict round,
|
|
@@ -89227,8 +90137,8 @@ var CmsWorker = class {
|
|
|
89227
90137
|
// `rebaseActiveBranches` also has a consumer outside the test files:
|
|
89228
90138
|
// apps/test-app/app/api/e2e-test/rebase/route.ts drives it from an e2e
|
|
89229
90139
|
// fixture route. Do not delete it as unused.
|
|
89230
|
-
async rebaseActiveBranches(gatewayPolicy) {
|
|
89231
|
-
return runRebaseCycle(this.ctx(), gatewayPolicy);
|
|
90140
|
+
async rebaseActiveBranches(gatewayPolicy, gitHub) {
|
|
90141
|
+
return runRebaseCycle(this.ctx(), gatewayPolicy, gitHub);
|
|
89232
90142
|
}
|
|
89233
90143
|
// --- Git-sync cluster (worker/git-sync.ts) -----------------------------
|
|
89234
90144
|
//
|
|
@@ -89268,24 +90178,24 @@ var CmsWorker = class {
|
|
|
89268
90178
|
};
|
|
89269
90179
|
|
|
89270
90180
|
// ../canopycms/src/auth/file-based-auth-cache.ts
|
|
89271
|
-
import
|
|
89272
|
-
import
|
|
90181
|
+
import fs33 from "node:fs/promises";
|
|
90182
|
+
import path35 from "node:path";
|
|
89273
90183
|
var log5 = createDebugLogger({ prefix: "FileBasedAuthCache" });
|
|
89274
90184
|
async function writeAuthCacheSnapshot(cachePath, files) {
|
|
89275
|
-
await
|
|
90185
|
+
await fs33.mkdir(cachePath, { recursive: true });
|
|
89276
90186
|
const timestamp2 = Date.now();
|
|
89277
|
-
const snapshotDir =
|
|
89278
|
-
await
|
|
90187
|
+
const snapshotDir = path35.join(cachePath, `snapshot-${timestamp2}`);
|
|
90188
|
+
await fs33.mkdir(snapshotDir, { recursive: true });
|
|
89279
90189
|
for (const [fileName, data3] of Object.entries(files)) {
|
|
89280
|
-
const tmpPath =
|
|
89281
|
-
const finalPath =
|
|
89282
|
-
await
|
|
89283
|
-
await
|
|
89284
|
-
}
|
|
89285
|
-
const currentLink =
|
|
89286
|
-
const tmpLink =
|
|
89287
|
-
await
|
|
89288
|
-
await
|
|
90190
|
+
const tmpPath = path35.join(snapshotDir, `${fileName}.tmp`);
|
|
90191
|
+
const finalPath = path35.join(snapshotDir, fileName);
|
|
90192
|
+
await fs33.writeFile(tmpPath, JSON.stringify(data3, null, 2), "utf-8");
|
|
90193
|
+
await fs33.rename(tmpPath, finalPath);
|
|
90194
|
+
}
|
|
90195
|
+
const currentLink = path35.join(cachePath, "current");
|
|
90196
|
+
const tmpLink = path35.join(cachePath, `current-${timestamp2}`);
|
|
90197
|
+
await fs33.symlink(path35.basename(snapshotDir), tmpLink);
|
|
90198
|
+
await fs33.rename(tmpLink, currentLink);
|
|
89289
90199
|
await cleanupOldSnapshots(cachePath, 2);
|
|
89290
90200
|
return snapshotDir;
|
|
89291
90201
|
}
|
|
@@ -89302,14 +90212,14 @@ async function writeAuthSnapshot(cachePath, snapshot) {
|
|
|
89302
90212
|
async function cleanupOldSnapshots(cachePath, keepCount) {
|
|
89303
90213
|
let entries;
|
|
89304
90214
|
try {
|
|
89305
|
-
entries = await
|
|
90215
|
+
entries = await fs33.readdir(cachePath);
|
|
89306
90216
|
} catch {
|
|
89307
90217
|
return;
|
|
89308
90218
|
}
|
|
89309
90219
|
const snapshots = entries.filter((e9) => e9.startsWith("snapshot-")).sort().reverse();
|
|
89310
90220
|
for (const snapshot of snapshots.slice(keepCount)) {
|
|
89311
90221
|
try {
|
|
89312
|
-
await
|
|
90222
|
+
await fs33.rm(path35.join(cachePath, snapshot), {
|
|
89313
90223
|
recursive: true,
|
|
89314
90224
|
force: true
|
|
89315
90225
|
});
|
|
@@ -89561,7 +90471,7 @@ async function completeTerminationLifecycleAction(options = {}) {
|
|
|
89561
90471
|
|
|
89562
90472
|
// worker/run.ts
|
|
89563
90473
|
init_error();
|
|
89564
|
-
import
|
|
90474
|
+
import path36 from "node:path";
|
|
89565
90475
|
|
|
89566
90476
|
// worker/github-app-auth.ts
|
|
89567
90477
|
var import_auth_app = __toESM(require_dist_node20(), 1);
|
|
@@ -93946,10 +94856,10 @@ var SessionAPI = class extends AbstractAPI {
|
|
|
93946
94856
|
*/
|
|
93947
94857
|
async getToken(sessionId, template, expiresInSeconds) {
|
|
93948
94858
|
this.requireId(sessionId);
|
|
93949
|
-
const
|
|
94859
|
+
const path37 = template ? joinPaths(basePath29, sessionId, "tokens", template) : joinPaths(basePath29, sessionId, "tokens");
|
|
93950
94860
|
const requestOptions = {
|
|
93951
94861
|
method: "POST",
|
|
93952
|
-
path:
|
|
94862
|
+
path: path37
|
|
93953
94863
|
};
|
|
93954
94864
|
if (expiresInSeconds !== void 0) {
|
|
93955
94865
|
requestOptions.bodyParams = { expires_in_seconds: expiresInSeconds };
|
|
@@ -96699,12 +97609,12 @@ function buildRequest(options) {
|
|
|
96699
97609
|
userAgent = USER_AGENT2,
|
|
96700
97610
|
skipApiVersionInUrl = false
|
|
96701
97611
|
} = options;
|
|
96702
|
-
const { path:
|
|
97612
|
+
const { path: path37, method, queryParams, headerParams, bodyParams, formData, options: opts } = requestOptions;
|
|
96703
97613
|
const { deepSnakecaseBodyParamKeys = false } = opts || {};
|
|
96704
97614
|
if (requireSecretKey) {
|
|
96705
97615
|
assertValidSecretKey(secretKey);
|
|
96706
97616
|
}
|
|
96707
|
-
const url = skipApiVersionInUrl ? joinPaths(apiUrl,
|
|
97617
|
+
const url = skipApiVersionInUrl ? joinPaths(apiUrl, path37) : joinPaths(apiUrl, apiVersion, path37);
|
|
96708
97618
|
const finalUrl = new URL(url);
|
|
96709
97619
|
if (queryParams) {
|
|
96710
97620
|
const snakecasedQueryParams = snakecase_keys_default({ ...queryParams });
|
|
@@ -99228,7 +100138,7 @@ async function buildSingleProcessWorker(deps, workspacePath) {
|
|
|
99228
100138
|
const { githubToken, githubTokenSecret, githubAppAuth, clerkSecret } = await readWorkerCredentials(env2, deps.getSecret);
|
|
99229
100139
|
const refreshAuthCache = createClerkAuthCacheRefresher({
|
|
99230
100140
|
secret: clerkSecret,
|
|
99231
|
-
cachePath:
|
|
100141
|
+
cachePath: path36.join(workspacePath, ".cache"),
|
|
99232
100142
|
useOrganizationsAsGroups
|
|
99233
100143
|
});
|
|
99234
100144
|
const worker = deps.createWorker({
|
|
@@ -99308,7 +100218,7 @@ async function buildSplitWorker(deps, workspacePath, socketPath, onGatewayWait)
|
|
|
99308
100218
|
}
|
|
99309
100219
|
const refreshAuthCache = health.clerkConfigured ? async () => {
|
|
99310
100220
|
const snapshot = await gateway.authSnapshot();
|
|
99311
|
-
await deps.writeAuthSnapshot(
|
|
100221
|
+
await deps.writeAuthSnapshot(path36.join(workspacePath, ".cache"), snapshot);
|
|
99312
100222
|
workerLog(` ${snapshot.users.length} users, ${snapshot.groups.length} groups`);
|
|
99313
100223
|
} : void 0;
|
|
99314
100224
|
const worker = deps.createWorker({
|