canopycms-cdk 0.8.1 → 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 +1475 -610
- 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
|
}
|
|
@@ -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
|
}
|
|
@@ -79739,7 +79741,7 @@ function reviewTime(at) {
|
|
|
79739
79741
|
const time3 = typeof at === "string" ? new Date(at) : void 0;
|
|
79740
79742
|
return time3 && !Number.isNaN(time3.getTime()) ? `${time3.toISOString().slice(0, 16).replace("T", " ")} UTC` : void 0;
|
|
79741
79743
|
}
|
|
79742
|
-
function buildReviewBlock(review) {
|
|
79744
|
+
function buildReviewBlock(review, keptOverGitHub = []) {
|
|
79743
79745
|
const verdict = review?.state === "approved" ? "Approved" : review?.state === "changes-requested" ? "Changes requested" : void 0;
|
|
79744
79746
|
let status = "Not yet reviewed in CanopyCMS.";
|
|
79745
79747
|
if (review && verdict) {
|
|
@@ -79747,10 +79749,26 @@ function buildReviewBlock(review) {
|
|
|
79747
79749
|
const when = reviewTime(review.at);
|
|
79748
79750
|
status = `${verdict} in CanopyCMS by ${name2 ? codeSpan(name2) : "a reviewer"}${when ? ` on ${when}` : ""}.`;
|
|
79749
79751
|
}
|
|
79752
|
+
const kept = keptOverGitHubNote(keptOverGitHub);
|
|
79750
79753
|
return `${PR_REVIEW_START}
|
|
79751
79754
|
${status}
|
|
79752
79755
|
${REVIEW_NOT_A_GITHUB_REVIEW}
|
|
79753
|
-
${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
|
+
` : ""}`;
|
|
79754
79772
|
}
|
|
79755
79773
|
var MAX_LISTED_THREADS = 50;
|
|
79756
79774
|
var MAX_EXCERPT_LENGTH = 80;
|
|
@@ -81637,6 +81655,11 @@ var MirrorSession = class {
|
|
|
81637
81655
|
}
|
|
81638
81656
|
return usable;
|
|
81639
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
|
+
}
|
|
81640
81663
|
/**
|
|
81641
81664
|
* Whether every one of `commits` is reachable from one of `tips`, in ONE walk: rev-list fed the
|
|
81642
81665
|
* commits and a `^<tip>` per tip lists what the tips do not reach, so empty output means all
|
|
@@ -81802,6 +81825,10 @@ var MirrorSession = class {
|
|
|
81802
81825
|
);
|
|
81803
81826
|
}
|
|
81804
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);
|
|
81805
81832
|
options.onPushing?.();
|
|
81806
81833
|
const status = await this.githubBound(
|
|
81807
81834
|
credential,
|
|
@@ -81809,7 +81836,7 @@ var MirrorSession = class {
|
|
|
81809
81836
|
"push",
|
|
81810
81837
|
"--porcelain",
|
|
81811
81838
|
"--progress",
|
|
81812
|
-
...
|
|
81839
|
+
...lease ? [`--force-with-lease=refs/heads/${branch}:${lease}`] : [],
|
|
81813
81840
|
"--end-of-options",
|
|
81814
81841
|
credential.url,
|
|
81815
81842
|
`${sha}:refs/heads/${branch}`
|
|
@@ -82483,6 +82510,7 @@ var LocalGitHubGateway = class {
|
|
|
82483
82510
|
async pushOnce(request, bundle, reach, signal) {
|
|
82484
82511
|
assertObjectId(request.sha, "a commit ID");
|
|
82485
82512
|
if (request.lease !== void 0) assertObjectId(request.lease, "a commit ID");
|
|
82513
|
+
if (request.seen !== void 0) assertObjectId(request.seen, "a commit ID");
|
|
82486
82514
|
if (request.prerequisites.length > MAX_PUSH_PREREQUISITES) {
|
|
82487
82515
|
throw new Error(`A push names at most ${MAX_PUSH_PREREQUISITES} prerequisites`);
|
|
82488
82516
|
}
|
|
@@ -82492,6 +82520,7 @@ var LocalGitHubGateway = class {
|
|
|
82492
82520
|
const credential = () => resolved ??= this.credential(reach);
|
|
82493
82521
|
const session = (received) => this.afterGitHubFetch(
|
|
82494
82522
|
async () => {
|
|
82523
|
+
if (request.seen !== void 0) this.githubFetch = null;
|
|
82495
82524
|
const snapshot = await this.joinGitHubFetchForPush(credential, request.branch, signal);
|
|
82496
82525
|
await credential();
|
|
82497
82526
|
return snapshot;
|
|
@@ -82544,8 +82573,16 @@ var LocalGitHubGateway = class {
|
|
|
82544
82573
|
} else {
|
|
82545
82574
|
repo = await mirror.quarantine(received, request, heads, signal);
|
|
82546
82575
|
}
|
|
82547
|
-
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, {
|
|
82548
82584
|
lease,
|
|
82585
|
+
pin,
|
|
82549
82586
|
signal,
|
|
82550
82587
|
repo,
|
|
82551
82588
|
policy: this.policy,
|
|
@@ -82553,7 +82590,8 @@ var LocalGitHubGateway = class {
|
|
|
82553
82590
|
onPushing: () => this.invalidateGitHubFetch()
|
|
82554
82591
|
});
|
|
82555
82592
|
try {
|
|
82556
|
-
|
|
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 };
|
|
82557
82595
|
} catch (err) {
|
|
82558
82596
|
if (err instanceof RefusedPushError || err instanceof GitHubTransientError) throw err;
|
|
82559
82597
|
const message2 = getErrorMessage(err);
|
|
@@ -82631,7 +82669,9 @@ var LocalGitHubGateway = class {
|
|
|
82631
82669
|
merged_at: data3.merged_at,
|
|
82632
82670
|
state: data3.state,
|
|
82633
82671
|
node_id: data3.node_id,
|
|
82634
|
-
body: ours ? data3.body ?? "" : null
|
|
82672
|
+
body: ours ? data3.body ?? "" : null,
|
|
82673
|
+
mergeable_state: data3.mergeable_state,
|
|
82674
|
+
baseRef: data3.base.ref
|
|
82635
82675
|
};
|
|
82636
82676
|
});
|
|
82637
82677
|
}
|
|
@@ -82819,11 +82859,12 @@ async function unreachableFrom(ctx, gitDir, ids, tips) {
|
|
|
82819
82859
|
return unreachable;
|
|
82820
82860
|
}
|
|
82821
82861
|
async function pushToGitHub(ctx, request, readSha, signal) {
|
|
82822
|
-
const { prerequisiteBranches, ...rest } = request;
|
|
82862
|
+
const { prerequisiteBranches, readSeen, ...rest } = request;
|
|
82823
82863
|
for (let restarts = 0; ; restarts++) {
|
|
82824
82864
|
const sha = await readSha();
|
|
82865
|
+
const seen = await readSeen?.();
|
|
82825
82866
|
const prerequisites = await trackingTips(ctx.remoteGitPath, prerequisiteBranches);
|
|
82826
|
-
const ask = { ...rest, sha, prerequisites };
|
|
82867
|
+
const ask = { ...rest, sha, ...seen ? { seen } : {}, prerequisites };
|
|
82827
82868
|
const first2 = await ctx.github().push(ask, void 0, signal);
|
|
82828
82869
|
if (first2.kind === "pushed") return { sha, outcome: outcomeOf(first2) };
|
|
82829
82870
|
const bundle = await startBundle(ctx, request.branch, sha, first2.usable, signal);
|
|
@@ -83122,7 +83163,7 @@ init_error();
|
|
|
83122
83163
|
init_worker_status();
|
|
83123
83164
|
|
|
83124
83165
|
// ../canopycms/src/version.ts
|
|
83125
|
-
var CANOPYCMS_VERSION = "0.8.
|
|
83166
|
+
var CANOPYCMS_VERSION = "0.8.2";
|
|
83126
83167
|
|
|
83127
83168
|
// ../canopycms/src/worker/schema-gate.ts
|
|
83128
83169
|
import fs14 from "node:fs/promises";
|
|
@@ -83448,9 +83489,20 @@ var branchMetadataShape = {
|
|
|
83448
83489
|
mergedAt: external_exports.string().optional(),
|
|
83449
83490
|
rebaseFailure: external_exports.object({ message: external_exports.string(), firstAt: external_exports.string(), lastAt: external_exports.string() }).optional(),
|
|
83450
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(),
|
|
83451
83498
|
syncFailureReason: external_exports.string().optional(),
|
|
83452
83499
|
editors: external_exports.array(external_exports.string()).optional(),
|
|
83453
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),
|
|
83454
83506
|
// Dropped when malformed: it only decorates the PR body, so it never fails a read.
|
|
83455
83507
|
review: external_exports.object({
|
|
83456
83508
|
state: external_exports.enum(["approved", "changes-requested"]),
|
|
@@ -84090,14 +84142,18 @@ function mergeBranchMetadata(existing, version, incoming, now = (/* @__PURE__ */
|
|
|
84090
84142
|
}
|
|
84091
84143
|
};
|
|
84092
84144
|
}
|
|
84093
|
-
|
|
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()) {
|
|
84094
84148
|
return {
|
|
84095
84149
|
status: "archived",
|
|
84096
84150
|
pullRequestState: "merged",
|
|
84097
84151
|
mergedAt: now.toISOString(),
|
|
84098
84152
|
// The merge settled every conflict the record named.
|
|
84099
84153
|
conflictStatus: "clean",
|
|
84100
|
-
conflictFiles: []
|
|
84154
|
+
conflictFiles: [],
|
|
84155
|
+
submitUnfinished: void 0,
|
|
84156
|
+
...owesSubmit(branch) ? { unpublishedAtMerge: true } : {}
|
|
84101
84157
|
};
|
|
84102
84158
|
}
|
|
84103
84159
|
var getBranchMetadataFileManager = (branchRoot, baseRoot, options) => {
|
|
@@ -84206,7 +84262,7 @@ async function readStatusObject(taskDir) {
|
|
|
84206
84262
|
}
|
|
84207
84263
|
|
|
84208
84264
|
// ../canopycms/src/worker/task-runner.ts
|
|
84209
|
-
import
|
|
84265
|
+
import fs22 from "node:fs/promises";
|
|
84210
84266
|
init_branch_name();
|
|
84211
84267
|
init_error();
|
|
84212
84268
|
|
|
@@ -84229,6 +84285,7 @@ var pushRequest = external_exports.object({
|
|
|
84229
84285
|
branch: name,
|
|
84230
84286
|
sha: objectId,
|
|
84231
84287
|
lease: objectId.optional(),
|
|
84288
|
+
seen: objectId.optional(),
|
|
84232
84289
|
prerequisites: external_exports.array(objectId).max(3),
|
|
84233
84290
|
/** Whether the request body is a bundle; without one it is empty. */
|
|
84234
84291
|
bundle: external_exports.boolean()
|
|
@@ -84286,7 +84343,9 @@ var answers = {
|
|
|
84286
84343
|
merged_at: external_exports.string().max(64).nullable(),
|
|
84287
84344
|
state: external_exports.enum(["open", "closed"]),
|
|
84288
84345
|
node_id: external_exports.string().max(256),
|
|
84289
|
-
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()
|
|
84290
84349
|
}).strict(),
|
|
84291
84350
|
createOrUpdatePullRequest: pullRequestRef.extend({ created: external_exports.boolean() }).strict(),
|
|
84292
84351
|
convertPullRequestToDraft: empty,
|
|
@@ -84389,7 +84448,7 @@ var errorEnvelope = external_exports.discriminatedUnion("kind", [
|
|
|
84389
84448
|
}).strict(),
|
|
84390
84449
|
external_exports.object({
|
|
84391
84450
|
kind: external_exports.literal("push"),
|
|
84392
|
-
pushKind: external_exports.enum(["rejected", "rejected-after-stale-lease"]),
|
|
84451
|
+
pushKind: external_exports.enum(["rejected", "rejected-after-stale-lease", "seen-commit-gone"]),
|
|
84393
84452
|
message
|
|
84394
84453
|
}).strict(),
|
|
84395
84454
|
external_exports.object({
|
|
@@ -84602,13 +84661,19 @@ async function readPublishedSha(ctx, branchRef) {
|
|
|
84602
84661
|
return null;
|
|
84603
84662
|
}
|
|
84604
84663
|
}
|
|
84605
|
-
async function markHistoryRewritten(ctx, branchPath, branchRef, expectedSha) {
|
|
84664
|
+
async function markHistoryRewritten(ctx, branchPath, branchRef, expectedSha, rewrittenTip) {
|
|
84606
84665
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
84607
84666
|
let marked = false;
|
|
84608
84667
|
await meta.update((current) => {
|
|
84609
84668
|
marked = current?.branch.name === branchRef;
|
|
84610
|
-
if (!marked
|
|
84611
|
-
|
|
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
|
+
};
|
|
84612
84677
|
});
|
|
84613
84678
|
return marked;
|
|
84614
84679
|
}
|
|
@@ -84701,6 +84766,15 @@ async function hasPendingHistoryRewrite(ctx, branchName) {
|
|
|
84701
84766
|
return false;
|
|
84702
84767
|
}
|
|
84703
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
|
+
}
|
|
84704
84778
|
|
|
84705
84779
|
// ../canopycms/src/worker/task-runner.ts
|
|
84706
84780
|
init_worker_status();
|
|
@@ -84930,18 +85004,23 @@ var SYNC_PR_COMMENTS_ACTION = "sync-pr-comments";
|
|
|
84930
85004
|
async function renderPrCommentsBody(options) {
|
|
84931
85005
|
const original = options.body;
|
|
84932
85006
|
let next = original;
|
|
84933
|
-
|
|
84934
|
-
|
|
84935
|
-
|
|
84936
|
-
|
|
84937
|
-
|
|
84938
|
-
|
|
84939
|
-
|
|
84940
|
-
|
|
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
|
+
}
|
|
84941
85017
|
}
|
|
84942
85018
|
try {
|
|
84943
85019
|
const file = await readBranchMetadataFile(options.branchRoot);
|
|
84944
|
-
if (file)
|
|
85020
|
+
if (file) {
|
|
85021
|
+
const block = buildReviewBlock(file.branch.review, file.branch.keptOverGitHub);
|
|
85022
|
+
next = mergeReviewBlock(next, block) ?? next;
|
|
85023
|
+
}
|
|
84945
85024
|
} catch (err) {
|
|
84946
85025
|
if (!(err instanceof BranchMetadataCorruptError)) throw err;
|
|
84947
85026
|
options.warn(
|
|
@@ -84963,7 +85042,10 @@ async function refreshCommentsBlock(options) {
|
|
|
84963
85042
|
}
|
|
84964
85043
|
try {
|
|
84965
85044
|
const file = await readBranchMetadataFile(options.branchRoot);
|
|
84966
|
-
if (file)
|
|
85045
|
+
if (file) {
|
|
85046
|
+
const block = buildReviewBlock(file.branch.review, file.branch.keptOverGitHub);
|
|
85047
|
+
section = mergeReviewBlock(section, block) ?? section;
|
|
85048
|
+
}
|
|
84967
85049
|
} catch (err) {
|
|
84968
85050
|
options.warn(
|
|
84969
85051
|
`Could not re-read the review state of ${options.branch}; the PR gets it from submit time: ${getErrorMessage(err)}`
|
|
@@ -84972,6 +85054,454 @@ async function refreshCommentsBlock(options) {
|
|
|
84972
85054
|
return section;
|
|
84973
85055
|
}
|
|
84974
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
|
+
|
|
84975
85505
|
// ../canopycms/src/worker/task-runner.ts
|
|
84976
85506
|
var PermanentTaskError = class extends Error {
|
|
84977
85507
|
};
|
|
@@ -84979,6 +85509,9 @@ var TaskAbortedForShutdownError = class extends Error {
|
|
|
84979
85509
|
};
|
|
84980
85510
|
var NothingToSubmitTaskError = class extends PermanentTaskError {
|
|
84981
85511
|
};
|
|
85512
|
+
var SUBMIT_ACTION = "push-and-create-or-update-pr";
|
|
85513
|
+
var GitHubMovedTaskError = class extends PermanentTaskError {
|
|
85514
|
+
};
|
|
84982
85515
|
function isPermanentTaskFailure(err) {
|
|
84983
85516
|
if (err instanceof PermanentTaskError || err instanceof GatewayRefusalError || err instanceof GatewayRequestRefusedError) {
|
|
84984
85517
|
return true;
|
|
@@ -85064,7 +85597,13 @@ async function processTaskQueue(ctx) {
|
|
|
85064
85597
|
const permanent = isPermanentTaskFailure(err);
|
|
85065
85598
|
const retryCount = task.retryCount ?? 0;
|
|
85066
85599
|
const maxRetries = task.maxRetries ?? ctx.maxRetries;
|
|
85067
|
-
|
|
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) {
|
|
85068
85607
|
await retryTask(ctx.taskDir, task.id, persistedMessage, ctx.log);
|
|
85069
85608
|
workerLog(` Will retry (attempt ${retryCount + 1}/${maxRetries})`);
|
|
85070
85609
|
} else {
|
|
@@ -85073,7 +85612,7 @@ async function processTaskQueue(ctx) {
|
|
|
85073
85612
|
unlock: err instanceof NothingToSubmitTaskError
|
|
85074
85613
|
});
|
|
85075
85614
|
workerLogError(
|
|
85076
|
-
permanent ? " Permanently failed (non-retryable error)" : ` Permanently failed after ${maxRetries} retries`
|
|
85615
|
+
permanent && !waitsForSync ? " Permanently failed (non-retryable error)" : ` Permanently failed after ${maxRetries} retries`
|
|
85077
85616
|
);
|
|
85078
85617
|
}
|
|
85079
85618
|
}
|
|
@@ -85148,6 +85687,10 @@ async function executeTask(ctx, task, signal) {
|
|
|
85148
85687
|
}
|
|
85149
85688
|
case "push-and-create-or-update-pr": {
|
|
85150
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
|
+
}
|
|
85151
85694
|
const base = optionalString(payload3, "baseBranch", ctx.baseBranch);
|
|
85152
85695
|
if (sanitizeBranchName(branch) === ctx.sanitizedBaseBranch) {
|
|
85153
85696
|
throw new PermanentTaskError(
|
|
@@ -85273,6 +85816,7 @@ async function executeTask(ctx, task, signal) {
|
|
|
85273
85816
|
branch: editorBranchOf(payload3, branch),
|
|
85274
85817
|
editorUrl,
|
|
85275
85818
|
body: pr.body,
|
|
85819
|
+
reviewBlockOnly: payload3.reviewBlockOnly === true,
|
|
85276
85820
|
warn: workerLogWarn
|
|
85277
85821
|
});
|
|
85278
85822
|
if (body === void 0) return { updated: false, skipped: "unchanged" };
|
|
@@ -85284,6 +85828,21 @@ async function executeTask(ctx, task, signal) {
|
|
|
85284
85828
|
throw new PermanentTaskError(`Unknown task action: ${action}`);
|
|
85285
85829
|
}
|
|
85286
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
|
+
}
|
|
85287
85846
|
function editorBranchOf(payload3, branch) {
|
|
85288
85847
|
return optionalString(payload3, "editorBranch", branch);
|
|
85289
85848
|
}
|
|
@@ -85299,32 +85858,55 @@ async function updateBranchMetadata(ctx, task, result) {
|
|
|
85299
85858
|
if (!branch) return;
|
|
85300
85859
|
const branchPath = ctx.branchWorkspacePath(branch);
|
|
85301
85860
|
try {
|
|
85302
|
-
await
|
|
85861
|
+
await fs22.stat(branchPath);
|
|
85303
85862
|
} catch {
|
|
85304
85863
|
return;
|
|
85305
85864
|
}
|
|
85306
85865
|
try {
|
|
85307
85866
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
85308
|
-
|
|
85309
|
-
|
|
85310
|
-
|
|
85311
|
-
|
|
85312
|
-
|
|
85313
|
-
|
|
85314
|
-
|
|
85315
|
-
|
|
85316
|
-
|
|
85317
|
-
|
|
85318
|
-
|
|
85319
|
-
|
|
85320
|
-
|
|
85321
|
-
|
|
85322
|
-
|
|
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}`);
|
|
85323
85896
|
}
|
|
85324
|
-
|
|
85325
|
-
|
|
85326
|
-
|
|
85327
|
-
|
|
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`);
|
|
85328
85910
|
} catch (err) {
|
|
85329
85911
|
workerLogError(
|
|
85330
85912
|
`Failed to update metadata for ${branch}:`,
|
|
@@ -85337,7 +85919,7 @@ async function updateBranchMetadataOnFailure(ctx, task, error3, options) {
|
|
|
85337
85919
|
if (!branch) return;
|
|
85338
85920
|
const branchPath = ctx.branchWorkspacePath(branch);
|
|
85339
85921
|
try {
|
|
85340
|
-
await
|
|
85922
|
+
await fs22.stat(branchPath);
|
|
85341
85923
|
} catch {
|
|
85342
85924
|
return;
|
|
85343
85925
|
}
|
|
@@ -85356,11 +85938,30 @@ async function updateBranchMetadataOnFailure(ctx, task, error3, options) {
|
|
|
85356
85938
|
(existing) => existing?.branch.name === branch && existing.branch.status === "submitted" && existing.branch.pullRequestNumber === void 0 && existing.branch.submittedAt === submittedAt
|
|
85357
85939
|
) !== null;
|
|
85358
85940
|
if (!unlocked) {
|
|
85359
|
-
|
|
85360
|
-
|
|
85361
|
-
|
|
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 }
|
|
85362
85962
|
);
|
|
85363
|
-
if (
|
|
85963
|
+
if (!found) noMetadataToRecord(branch, `${task.action} failure`);
|
|
85964
|
+
if (revoked && saved !== null) await enqueueReviewBlockSync(ctx, branch, saved);
|
|
85364
85965
|
}
|
|
85365
85966
|
} catch (err) {
|
|
85366
85967
|
workerLogError(
|
|
@@ -85390,8 +85991,17 @@ async function pushBranchToGitHub(ctx, branch, signal) {
|
|
|
85390
85991
|
);
|
|
85391
85992
|
}
|
|
85392
85993
|
const branchPath = ctx.branchWorkspacePath(branch);
|
|
85393
|
-
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();
|
|
85394
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
|
+
}
|
|
85395
86005
|
const readSha = async () => {
|
|
85396
86006
|
const sha = await readPublishedSha(ctx, branch);
|
|
85397
86007
|
if (sha === null) {
|
|
@@ -85399,6 +86009,10 @@ async function pushBranchToGitHub(ctx, branch, signal) {
|
|
|
85399
86009
|
}
|
|
85400
86010
|
return sha;
|
|
85401
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
|
+
};
|
|
85402
86016
|
let outgoingSha;
|
|
85403
86017
|
let outcome;
|
|
85404
86018
|
try {
|
|
@@ -85408,6 +86022,7 @@ async function pushBranchToGitHub(ctx, branch, signal) {
|
|
|
85408
86022
|
{
|
|
85409
86023
|
branch,
|
|
85410
86024
|
lease: marker,
|
|
86025
|
+
readSeen,
|
|
85411
86026
|
prerequisiteBranches: [branch, ctx.baseBranch]
|
|
85412
86027
|
},
|
|
85413
86028
|
readSha,
|
|
@@ -85416,17 +86031,21 @@ async function pushBranchToGitHub(ctx, branch, signal) {
|
|
|
85416
86031
|
} catch (err) {
|
|
85417
86032
|
if (err instanceof RefusedPushError) throw new PermanentTaskError(err.message);
|
|
85418
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
|
+
}
|
|
85419
86038
|
throwIfWorkflowRefusal(branch, err.message);
|
|
85420
86039
|
if (err.kind === "rejected-after-stale-lease") {
|
|
85421
86040
|
if (isNonFastForwardRejection(err.message)) {
|
|
85422
|
-
throw new
|
|
86041
|
+
throw new GitHubMovedTaskError(
|
|
85423
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.`
|
|
85424
86043
|
);
|
|
85425
86044
|
}
|
|
85426
86045
|
throw new Error(err.message);
|
|
85427
86046
|
}
|
|
85428
86047
|
if (isNonFastForwardRejection(err.message)) {
|
|
85429
|
-
throw new
|
|
86048
|
+
throw new GitHubMovedTaskError(
|
|
85430
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.`
|
|
85431
86050
|
);
|
|
85432
86051
|
}
|
|
@@ -85434,14 +86053,14 @@ async function pushBranchToGitHub(ctx, branch, signal) {
|
|
|
85434
86053
|
}
|
|
85435
86054
|
if (outcome.pastStaleLease) {
|
|
85436
86055
|
await clearHistoryRewrittenMarker(ctx, branchPath, branch);
|
|
85437
|
-
await recordPushedToGitHub(ctx, branchPath, branch);
|
|
86056
|
+
await recordPushedToGitHub(ctx, branchPath, branch, outgoingSha);
|
|
85438
86057
|
logPushOutcome(ctx, branch, outcome, "GitHub had already moved past the rewritten commit");
|
|
85439
86058
|
return;
|
|
85440
86059
|
}
|
|
85441
86060
|
if (marker && outgoingSha !== marker) {
|
|
85442
86061
|
await clearHistoryRewrittenMarker(ctx, branchPath, branch);
|
|
85443
86062
|
}
|
|
85444
|
-
await recordPushedToGitHub(ctx, branchPath, branch);
|
|
86063
|
+
await recordPushedToGitHub(ctx, branchPath, branch, outgoingSha);
|
|
85445
86064
|
logPushOutcome(ctx, branch, outcome);
|
|
85446
86065
|
}
|
|
85447
86066
|
function logPushOutcome(ctx, branch, outcome, note) {
|
|
@@ -85452,17 +86071,17 @@ function logPushOutcome(ctx, branch, outcome, note) {
|
|
|
85452
86071
|
ctx.log.debug(`${branch} already up to date on GitHub${suffix}`);
|
|
85453
86072
|
}
|
|
85454
86073
|
}
|
|
85455
|
-
async function recordPushedToGitHub(ctx, branchPath, branch) {
|
|
86074
|
+
async function recordPushedToGitHub(ctx, branchPath, branch, sha) {
|
|
85456
86075
|
if (isSettingsBranch(branch)) return;
|
|
85457
86076
|
try {
|
|
85458
|
-
await
|
|
86077
|
+
await fs22.stat(branchPath);
|
|
85459
86078
|
} catch {
|
|
85460
86079
|
return;
|
|
85461
86080
|
}
|
|
85462
86081
|
try {
|
|
85463
|
-
const saved = await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).
|
|
85464
|
-
{ branch: { pushedToGitHubAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
85465
|
-
|
|
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 }
|
|
85466
86085
|
);
|
|
85467
86086
|
if (saved === null) noMetadataToRecord(branch, "GitHub push");
|
|
85468
86087
|
} catch (err) {
|
|
@@ -85471,19 +86090,17 @@ async function recordPushedToGitHub(ctx, branchPath, branch) {
|
|
|
85471
86090
|
}
|
|
85472
86091
|
|
|
85473
86092
|
// ../canopycms/src/worker/rebase.ts
|
|
85474
|
-
import
|
|
85475
|
-
import
|
|
86093
|
+
import fs24 from "node:fs/promises";
|
|
86094
|
+
import path26 from "node:path";
|
|
85476
86095
|
init_branch_name();
|
|
85477
|
-
init_normalize();
|
|
85478
|
-
init_types2();
|
|
85479
86096
|
|
|
85480
86097
|
// ../canopycms/src/utils/content-write-lock.ts
|
|
85481
86098
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
85482
|
-
import
|
|
86099
|
+
import path24 from "node:path";
|
|
85483
86100
|
var META_DIR2 = ".canopy-meta";
|
|
85484
86101
|
var CONTENT_WRITE_LOCK_NAME = "content-write.lock";
|
|
85485
86102
|
function lockTargetDir(branchRoot) {
|
|
85486
|
-
return
|
|
86103
|
+
return path24.join(path24.resolve(branchRoot), META_DIR2);
|
|
85487
86104
|
}
|
|
85488
86105
|
var CONTENT_WRITE_LOCK_STALE_MS = 3e4;
|
|
85489
86106
|
function tryAcquireContentWriteLock(branchRoot, onCompromised) {
|
|
@@ -85498,8 +86115,8 @@ function tryAcquireContentWriteLock(branchRoot, onCompromised) {
|
|
|
85498
86115
|
var heldRoots = new AsyncLocalStorage();
|
|
85499
86116
|
|
|
85500
86117
|
// ../canopycms/src/worker/provisioned-workspace.ts
|
|
85501
|
-
import
|
|
85502
|
-
import
|
|
86118
|
+
import fs23 from "node:fs/promises";
|
|
86119
|
+
import path25 from "node:path";
|
|
85503
86120
|
init_error();
|
|
85504
86121
|
async function holdProvisionedWorkspace(contentBranchesPath, dirName) {
|
|
85505
86122
|
let release2;
|
|
@@ -85519,13 +86136,13 @@ async function holdProvisionedWorkspace(contentBranchesPath, dirName) {
|
|
|
85519
86136
|
if (isNodeError(err) && err.code === "ELOCKED") return { kind: "locked" };
|
|
85520
86137
|
throw err;
|
|
85521
86138
|
}
|
|
85522
|
-
const root5 =
|
|
86139
|
+
const root5 = path25.join(contentBranchesPath, dirName);
|
|
85523
86140
|
const [gitIsDir, hasMetadata] = await Promise.all([
|
|
85524
|
-
|
|
86141
|
+
fs23.stat(path25.join(root5, ".git")).then(
|
|
85525
86142
|
(stat) => stat.isDirectory(),
|
|
85526
86143
|
() => false
|
|
85527
86144
|
),
|
|
85528
|
-
|
|
86145
|
+
fs23.stat(path25.join(root5, BRANCH_META_DIR, BRANCH_META_FILE)).then(
|
|
85529
86146
|
() => true,
|
|
85530
86147
|
() => false
|
|
85531
86148
|
)
|
|
@@ -85546,7 +86163,7 @@ async function releaseProvisionedWorkspace(release2, dirName) {
|
|
|
85546
86163
|
init_error();
|
|
85547
86164
|
async function pollMergeState(ctx, branchDir, branchPath, metaFile) {
|
|
85548
86165
|
const prNumber2 = metaFile?.branch.pullRequestNumber;
|
|
85549
|
-
if (!prNumber2) return;
|
|
86166
|
+
if (!prNumber2) return null;
|
|
85550
86167
|
const sameBranch2 = (current) => current?.branch.name === metaFile?.branch.name;
|
|
85551
86168
|
const controller = new AbortController();
|
|
85552
86169
|
const timer = setTimeout(() => controller.abort(), ctx.taskTimeoutMs);
|
|
@@ -85554,23 +86171,27 @@ async function pollMergeState(ctx, branchDir, branchPath, metaFile) {
|
|
|
85554
86171
|
const data3 = await ctx.github().getPullRequest(prNumber2, controller.signal);
|
|
85555
86172
|
if (data3.merged) {
|
|
85556
86173
|
const meta2 = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
85557
|
-
const saved2 = await meta2.
|
|
85558
|
-
{
|
|
85559
|
-
branch: buildMergedBranchUpdate(
|
|
85560
|
-
|
|
85561
|
-
|
|
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
|
|
85562
86181
|
);
|
|
85563
86182
|
if (saved2) workerLog(` PR #${prNumber2} for ${branchDir} is merged -> archived`);
|
|
85564
|
-
return;
|
|
86183
|
+
return null;
|
|
85565
86184
|
}
|
|
85566
86185
|
const newState = data3.state === "closed" ? "closed" : "open";
|
|
85567
86186
|
const currentMeta = await BranchMetadataFileManager.loadOnly(branchPath);
|
|
85568
|
-
if (currentMeta?.branch.pullRequestState === newState) return;
|
|
86187
|
+
if (currentMeta?.branch.pullRequestState === newState) return data3;
|
|
85569
86188
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
85570
86189
|
const saved = await meta.saveIf({ branch: { pullRequestState: newState } }, sameBranch2);
|
|
85571
86190
|
if (saved) workerLog(` PR #${prNumber2} for ${branchDir}: pullRequestState -> ${newState}`);
|
|
86191
|
+
return data3;
|
|
85572
86192
|
} catch (err) {
|
|
85573
86193
|
workerLogWarn(` Failed to poll PR #${prNumber2} for ${branchDir}: ${getErrorMessage(err)}`);
|
|
86194
|
+
return null;
|
|
85574
86195
|
} finally {
|
|
85575
86196
|
clearTimeout(timer);
|
|
85576
86197
|
}
|
|
@@ -85601,6 +86222,13 @@ async function recordRebaseFailure(ctx, branchPath, branchDir, message2, branchR
|
|
|
85601
86222
|
}
|
|
85602
86223
|
}
|
|
85603
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
|
+
}
|
|
85604
86232
|
async function runRebaseRounds(ctx, branchGit, branchDir, fetchedBaseTip, isLockCompromised) {
|
|
85605
86233
|
const conflictedFiles = [];
|
|
85606
86234
|
let nextAction = "start";
|
|
@@ -85661,34 +86289,12 @@ async function runRebaseRounds(ctx, branchGit, branchDir, fetchedBaseTip, isLock
|
|
|
85661
86289
|
}
|
|
85662
86290
|
return { completed, conflictedFiles, failureReason };
|
|
85663
86291
|
}
|
|
85664
|
-
function conflictFilesToContentIds(conflictedFiles, contentRoot) {
|
|
85665
|
-
const normalizedContentRoot = normalizeFilesystemPath(contentRoot);
|
|
85666
|
-
const conflictIds = [...new Set(conflictedFiles)].map((f9) => {
|
|
85667
|
-
const fileId = extractIdFromFilename(path25.basename(f9));
|
|
85668
|
-
if (fileId) return fileId;
|
|
85669
|
-
const parentDir = path25.basename(path25.dirname(f9));
|
|
85670
|
-
const dirId = extractIdFromFilename(parentDir);
|
|
85671
|
-
if (dirId) return dirId;
|
|
85672
|
-
const parentPath = normalizeFilesystemPath(path25.dirname(f9));
|
|
85673
|
-
if (path25.basename(f9) === ".collection.json" && parentPath === normalizedContentRoot) {
|
|
85674
|
-
return ROOT_COLLECTION_ID;
|
|
85675
|
-
}
|
|
85676
|
-
return null;
|
|
85677
|
-
}).filter((id) => id !== null);
|
|
85678
|
-
return [...new Set(conflictIds)];
|
|
85679
|
-
}
|
|
85680
|
-
function recordConflicts(recorded, found) {
|
|
85681
|
-
const conflictFiles = [.../* @__PURE__ */ new Set([...recorded ?? [], ...found])];
|
|
85682
|
-
return {
|
|
85683
|
-
conflictStatus: conflictFiles.length > 0 ? "conflicts-detected" : "clean",
|
|
85684
|
-
conflictFiles
|
|
85685
|
-
};
|
|
85686
|
-
}
|
|
85687
86292
|
async function carryForwardRewrittenHistory(ctx, args) {
|
|
85688
86293
|
const { branchPath, branchDir, branchRef, publishedSha, preRebaseHead, gatewayPolicy } = args;
|
|
86294
|
+
const { rebasedHead } = args;
|
|
85689
86295
|
if (publishedSha !== null) {
|
|
85690
86296
|
if (publishedSha === preRebaseHead) {
|
|
85691
|
-
if (!await markHistoryRewritten(ctx, branchPath, branchRef, publishedSha)) {
|
|
86297
|
+
if (!await markHistoryRewritten(ctx, branchPath, branchRef, publishedSha, rebasedHead)) {
|
|
85692
86298
|
workerLogWarn(
|
|
85693
86299
|
` ${branchDir}: rebased, but its branch.json is gone or names another branch than ${branchRef}, so the rewrite is not published`
|
|
85694
86300
|
);
|
|
@@ -85704,14 +86310,14 @@ async function carryForwardRewrittenHistory(ctx, args) {
|
|
|
85704
86310
|
}
|
|
85705
86311
|
}
|
|
85706
86312
|
}
|
|
85707
|
-
async function runRebaseCycle(ctx, gatewayPolicy) {
|
|
86313
|
+
async function runRebaseCycle(ctx, gatewayPolicy, gitHub) {
|
|
85708
86314
|
const rebased = [];
|
|
85709
86315
|
const skippedDirty = [];
|
|
85710
86316
|
const skippedLocked = [];
|
|
85711
86317
|
const failed = [];
|
|
85712
86318
|
let branchDirs;
|
|
85713
86319
|
try {
|
|
85714
|
-
branchDirs = await
|
|
86320
|
+
branchDirs = await fs24.readdir(ctx.contentBranchesPath);
|
|
85715
86321
|
} catch {
|
|
85716
86322
|
return { rebased, skippedDirty, skippedLocked, failed };
|
|
85717
86323
|
}
|
|
@@ -85723,10 +86329,10 @@ async function runRebaseCycle(ctx, gatewayPolicy) {
|
|
|
85723
86329
|
if (branchDir.startsWith(".") || branchDir === "branches.json") {
|
|
85724
86330
|
continue;
|
|
85725
86331
|
}
|
|
85726
|
-
const branchPath =
|
|
85727
|
-
const gitDir =
|
|
86332
|
+
const branchPath = path26.join(ctx.contentBranchesPath, branchDir);
|
|
86333
|
+
const gitDir = path26.join(branchPath, ".git");
|
|
85728
86334
|
try {
|
|
85729
|
-
const stat = await
|
|
86335
|
+
const stat = await fs24.stat(gitDir);
|
|
85730
86336
|
if (!stat.isDirectory()) {
|
|
85731
86337
|
workerLog(` Skipping ${branchDir}: .git is not a directory`);
|
|
85732
86338
|
continue;
|
|
@@ -85743,7 +86349,7 @@ async function runRebaseCycle(ctx, gatewayPolicy) {
|
|
|
85743
86349
|
workerLogWarn(` Skipping ${branchDir}: settings branch, never a content workspace`);
|
|
85744
86350
|
continue;
|
|
85745
86351
|
}
|
|
85746
|
-
const outcome = await holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy);
|
|
86352
|
+
const outcome = await holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy, gitHub);
|
|
85747
86353
|
if (outcome.kind === "rebased") rebased.push(branchDir);
|
|
85748
86354
|
else if (outcome.kind === "skippedDirty") skippedDirty.push(branchDir);
|
|
85749
86355
|
else if (outcome.kind === "skippedLocked") skippedLocked.push(branchDir);
|
|
@@ -85756,7 +86362,7 @@ async function runRebaseCycle(ctx, gatewayPolicy) {
|
|
|
85756
86362
|
}
|
|
85757
86363
|
async function readCloneRef(branchPath) {
|
|
85758
86364
|
try {
|
|
85759
|
-
const head = (await
|
|
86365
|
+
const head = (await fs24.readFile(path26.join(branchPath, ".git", "HEAD"), "utf-8")).trim();
|
|
85760
86366
|
return head.startsWith("ref: refs/heads/") ? head.slice("ref: refs/heads/".length) : null;
|
|
85761
86367
|
} catch {
|
|
85762
86368
|
return null;
|
|
@@ -85788,7 +86394,7 @@ async function restoreRenamedBranch(ctx, branchDir, branchPath, metaFile, namesp
|
|
|
85788
86394
|
return metaFile;
|
|
85789
86395
|
}
|
|
85790
86396
|
}
|
|
85791
|
-
async function holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy) {
|
|
86397
|
+
async function holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy, gitHub) {
|
|
85792
86398
|
let hold;
|
|
85793
86399
|
try {
|
|
85794
86400
|
hold = await holdProvisionedWorkspace(ctx.contentBranchesPath, branchDir);
|
|
@@ -85803,12 +86409,200 @@ async function holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy)
|
|
|
85803
86409
|
}
|
|
85804
86410
|
if (hold.kind === "not-provisioned") return { kind: "none" };
|
|
85805
86411
|
try {
|
|
85806
|
-
return await rebaseOneBranch(
|
|
86412
|
+
return await rebaseOneBranch(
|
|
86413
|
+
ctx,
|
|
86414
|
+
branchDir,
|
|
86415
|
+
branchPath,
|
|
86416
|
+
hold.isCompromised,
|
|
86417
|
+
gatewayPolicy,
|
|
86418
|
+
gitHub
|
|
86419
|
+
);
|
|
85807
86420
|
} finally {
|
|
85808
86421
|
await releaseProvisionedWorkspace(hold.release, branchDir);
|
|
85809
86422
|
}
|
|
85810
86423
|
}
|
|
85811
|
-
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) {
|
|
85812
86606
|
let didRebase = false;
|
|
85813
86607
|
try {
|
|
85814
86608
|
const metaFile = await restoreRenamedBranch(
|
|
@@ -85819,10 +86613,33 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85819
86613
|
gatewayPolicy?.namespace
|
|
85820
86614
|
);
|
|
85821
86615
|
const branchStatus2 = metaFile?.branch.status;
|
|
85822
|
-
if (branchStatus2 === "submitted" || branchStatus2 === "approved") {
|
|
86616
|
+
if (metaFile !== null && (branchStatus2 === "submitted" || branchStatus2 === "approved")) {
|
|
85823
86617
|
workerLog(` Skipping ${branchDir} (${branchStatus2})`);
|
|
85824
|
-
|
|
85825
|
-
|
|
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;
|
|
85826
86643
|
}
|
|
85827
86644
|
if (branchStatus2 === "archived") {
|
|
85828
86645
|
workerLog(` Skipping ${branchDir} (${branchStatus2})`);
|
|
@@ -85860,7 +86677,7 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85860
86677
|
` ${branchDir}: found an interrupted rebase (this worker's own abandoned work) -- aborting it to recover the branch`
|
|
85861
86678
|
);
|
|
85862
86679
|
try {
|
|
85863
|
-
await branchGit
|
|
86680
|
+
await abortRebase(branchGit, branchPath);
|
|
85864
86681
|
} catch (abortErr) {
|
|
85865
86682
|
const reason = redactCredentials(
|
|
85866
86683
|
`could not abort interrupted rebase: ${getErrorMessage(abortErr)}`
|
|
@@ -85876,6 +86693,30 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85876
86693
|
dirtyCheck = await branchGit.status([...SHARED_REPO_STATUS_ARGS]);
|
|
85877
86694
|
}
|
|
85878
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
|
+
}
|
|
85879
86720
|
if (editorDirt.length > 0) {
|
|
85880
86721
|
workerLog(` Skipping ${branchDir}: has uncommitted changes`);
|
|
85881
86722
|
return { kind: "skippedDirty" };
|
|
@@ -85890,8 +86731,6 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85890
86731
|
await recordRebaseFailure(ctx, branchPath, branchDir, reason);
|
|
85891
86732
|
return { kind: "failed", error: reason };
|
|
85892
86733
|
}
|
|
85893
|
-
const branchRef = (await branchGit.revparse(["--abbrev-ref", "HEAD"])).trim();
|
|
85894
|
-
const canPublish = branchRef.length > 0 && branchRef !== "HEAD";
|
|
85895
86734
|
if (canPublish && metaFile?.branch.historyRewrittenFrom) {
|
|
85896
86735
|
await reconcilePendingRewrite(ctx, {
|
|
85897
86736
|
branchPath,
|
|
@@ -85914,6 +86753,9 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85914
86753
|
if (currentMeta?.branch.rebaseFailure === void 0) {
|
|
85915
86754
|
return { kind: "none" };
|
|
85916
86755
|
}
|
|
86756
|
+
if (canPublish && await lacksPublishedCommits(ctx, branchGit, branchRef)) {
|
|
86757
|
+
return { kind: "none" };
|
|
86758
|
+
}
|
|
85917
86759
|
const storedName = currentMeta.branch.name;
|
|
85918
86760
|
await meta.saveIf(
|
|
85919
86761
|
{ branch: { rebaseFailure: void 0 } },
|
|
@@ -85921,6 +86763,23 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85921
86763
|
);
|
|
85922
86764
|
return { kind: "none" };
|
|
85923
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
|
+
}
|
|
85924
86783
|
workerLog(`Rebasing ${branchDir} (${behindCount} commits behind)...`);
|
|
85925
86784
|
const preRebaseHead = (await branchGit.revparse(["HEAD"])).trim();
|
|
85926
86785
|
const publishedSha = canPublish ? await readPublishedSha(ctx, branchRef) : null;
|
|
@@ -85937,7 +86796,7 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85937
86796
|
workerLogWarn(
|
|
85938
86797
|
` Skipping ${branchDir}: a lock it held was compromised mid-rebase (retrying next cycle)`
|
|
85939
86798
|
);
|
|
85940
|
-
await branchGit
|
|
86799
|
+
await abortRebase(branchGit, branchPath).catch(() => {
|
|
85941
86800
|
});
|
|
85942
86801
|
return { kind: "skippedLocked" };
|
|
85943
86802
|
}
|
|
@@ -85950,7 +86809,7 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85950
86809
|
workerLogWarn(
|
|
85951
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`
|
|
85952
86811
|
);
|
|
85953
|
-
await branchGit
|
|
86812
|
+
await abortRebase(branchGit, branchPath).catch(() => {
|
|
85954
86813
|
});
|
|
85955
86814
|
const rebaseFailureMessage = failureReason ?? `did not complete within ${MAX_REBASE_ROUNDS} rounds`;
|
|
85956
86815
|
const redactedRebaseFailureMessage = redactCredentials(rebaseFailureMessage);
|
|
@@ -85980,6 +86839,7 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85980
86839
|
branchRef,
|
|
85981
86840
|
publishedSha,
|
|
85982
86841
|
preRebaseHead,
|
|
86842
|
+
rebasedHead: (await branchGit.revparse(["HEAD"])).trim(),
|
|
85983
86843
|
gatewayPolicy
|
|
85984
86844
|
});
|
|
85985
86845
|
return { kind: "rebased" };
|
|
@@ -85989,7 +86849,7 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85989
86849
|
workerLogWarn(
|
|
85990
86850
|
` ${branchDir}: rebase still in progress on exit -- aborting so the clone is not left wedged`
|
|
85991
86851
|
);
|
|
85992
|
-
await branchGit
|
|
86852
|
+
await abortRebase(branchGit, branchPath);
|
|
85993
86853
|
}
|
|
85994
86854
|
} catch (abortErr) {
|
|
85995
86855
|
workerLogWarn(
|
|
@@ -86012,16 +86872,16 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
86012
86872
|
}
|
|
86013
86873
|
|
|
86014
86874
|
// ../canopycms/src/worker/git-sync.ts
|
|
86015
|
-
import
|
|
86016
|
-
import
|
|
86875
|
+
import fs29 from "node:fs/promises";
|
|
86876
|
+
import path31 from "node:path";
|
|
86017
86877
|
|
|
86018
86878
|
// ../canopycms/src/branch-health.ts
|
|
86019
86879
|
var ORPHAN_YOUTH_THRESHOLD_MS = 15 * 6e4;
|
|
86020
86880
|
|
|
86021
86881
|
// ../canopycms/src/branch-provisioning.ts
|
|
86022
86882
|
import { createHash, randomBytes as randomBytes2 } from "node:crypto";
|
|
86023
|
-
import
|
|
86024
|
-
import
|
|
86883
|
+
import fs25 from "node:fs/promises";
|
|
86884
|
+
import path27 from "node:path";
|
|
86025
86885
|
init_branch_name();
|
|
86026
86886
|
init_error();
|
|
86027
86887
|
init_logger();
|
|
@@ -86054,7 +86914,7 @@ var DELETING_PREFIX = ".deleting-";
|
|
|
86054
86914
|
var NO_GIT = { hasGitDir: false, configLock: false, hasIndex: false };
|
|
86055
86915
|
async function listDir(dirPath) {
|
|
86056
86916
|
try {
|
|
86057
|
-
return await
|
|
86917
|
+
return await fs25.readdir(dirPath);
|
|
86058
86918
|
} catch (err) {
|
|
86059
86919
|
if (isNodeError(err) && (err.code === "ENOENT" || err.code === "ENOTDIR")) return null;
|
|
86060
86920
|
throw err;
|
|
@@ -86076,19 +86936,19 @@ function gitConfigRemoteUrls(text) {
|
|
|
86076
86936
|
}
|
|
86077
86937
|
function sameRemote(url, expected) {
|
|
86078
86938
|
if (isNetworkRemoteUrl(url) || isNetworkRemoteUrl(expected)) return url === expected;
|
|
86079
|
-
const local = (value) =>
|
|
86939
|
+
const local = (value) => path27.resolve(value.replace(/^file:\/\//i, ""));
|
|
86080
86940
|
return local(url) === local(expected);
|
|
86081
86941
|
}
|
|
86082
86942
|
async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
86083
86943
|
let stat;
|
|
86084
86944
|
try {
|
|
86085
|
-
stat = await
|
|
86945
|
+
stat = await fs25.lstat(dirPath);
|
|
86086
86946
|
} catch (err) {
|
|
86087
86947
|
if (isNotFoundError2(err)) return { kind: "vacant" };
|
|
86088
86948
|
throw err;
|
|
86089
86949
|
}
|
|
86090
86950
|
if (!stat.isDirectory()) return { kind: "residue", signature: NO_GIT };
|
|
86091
|
-
const metaEntries = await listDir(
|
|
86951
|
+
const metaEntries = await listDir(path27.join(dirPath, BRANCH_META_DIR)) ?? [];
|
|
86092
86952
|
if (metaEntries.includes(BRANCH_META_FILE)) {
|
|
86093
86953
|
try {
|
|
86094
86954
|
return await readBranchMetadataFile(dirPath) ? { kind: "live" } : { kind: "protected" };
|
|
@@ -86100,10 +86960,10 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
|
86100
86960
|
if (metaEntries.some((name2) => name2.startsWith(`${BRANCH_META_FILE}.corrupt-`))) {
|
|
86101
86961
|
return { kind: "protected" };
|
|
86102
86962
|
}
|
|
86103
|
-
const gitPath =
|
|
86963
|
+
const gitPath = path27.join(dirPath, ".git");
|
|
86104
86964
|
let gitStat;
|
|
86105
86965
|
try {
|
|
86106
|
-
gitStat = await
|
|
86966
|
+
gitStat = await fs25.lstat(gitPath);
|
|
86107
86967
|
} catch (err) {
|
|
86108
86968
|
if (isNotFoundError2(err)) return { kind: "residue", signature: NO_GIT };
|
|
86109
86969
|
throw err;
|
|
@@ -86117,7 +86977,7 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
|
86117
86977
|
};
|
|
86118
86978
|
let config;
|
|
86119
86979
|
try {
|
|
86120
|
-
config = await
|
|
86980
|
+
config = await fs25.readFile(path27.join(gitPath, "config"), "utf8");
|
|
86121
86981
|
} catch {
|
|
86122
86982
|
return { kind: "residue", signature };
|
|
86123
86983
|
}
|
|
@@ -86126,7 +86986,7 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
|
86126
86986
|
async function quietAgeMs(dirPath, now = Date.now()) {
|
|
86127
86987
|
const mtimes = await Promise.all(
|
|
86128
86988
|
["", ".git", BRANCH_META_DIR].map(
|
|
86129
|
-
(sub) =>
|
|
86989
|
+
(sub) => fs25.lstat(path27.join(dirPath, sub)).then(
|
|
86130
86990
|
(stat) => stat.mtimeMs,
|
|
86131
86991
|
() => 0
|
|
86132
86992
|
)
|
|
@@ -86135,25 +86995,25 @@ async function quietAgeMs(dirPath, now = Date.now()) {
|
|
|
86135
86995
|
return now - Math.max(...mtimes);
|
|
86136
86996
|
}
|
|
86137
86997
|
async function quarantineResidueAt(baseRoot, dirName, options) {
|
|
86138
|
-
const finalPath =
|
|
86998
|
+
const finalPath = path27.join(baseRoot, dirName);
|
|
86139
86999
|
let inode;
|
|
86140
87000
|
try {
|
|
86141
|
-
inode = (await
|
|
87001
|
+
inode = (await fs25.lstat(finalPath)).ino;
|
|
86142
87002
|
} catch (err) {
|
|
86143
87003
|
if (isNotFoundError2(err)) return { kind: "vacant" };
|
|
86144
87004
|
throw err;
|
|
86145
87005
|
}
|
|
86146
87006
|
const candidateName = stampedName(REPAIR_PREFIX, dirName, /* @__PURE__ */ new Date());
|
|
86147
|
-
const candidate =
|
|
87007
|
+
const candidate = path27.join(baseRoot, candidateName);
|
|
86148
87008
|
try {
|
|
86149
|
-
await
|
|
87009
|
+
await fs25.rename(finalPath, candidate);
|
|
86150
87010
|
} catch (err) {
|
|
86151
87011
|
if (isNotFoundError2(err)) return { kind: "vacant" };
|
|
86152
87012
|
throw err;
|
|
86153
87013
|
}
|
|
86154
87014
|
const moveBack = async (why) => {
|
|
86155
87015
|
try {
|
|
86156
|
-
await
|
|
87016
|
+
await fs25.rename(candidate, finalPath);
|
|
86157
87017
|
} catch (err) {
|
|
86158
87018
|
canopyLogError(
|
|
86159
87019
|
`[canopy] Could not move '${dirName}' back from ${candidateName} after ${why}: ${getErrorMessage(err)}. The worker's sweep restores or trashes it.`
|
|
@@ -86168,7 +87028,7 @@ async function quarantineResidueAt(baseRoot, dirName, options) {
|
|
|
86168
87028
|
);
|
|
86169
87029
|
if (reason === void 0 && state3.kind === "residue") {
|
|
86170
87030
|
const trashName = stampedName(TRASH_PREFIX, dirName, /* @__PURE__ */ new Date());
|
|
86171
|
-
await
|
|
87031
|
+
await fs25.rename(candidate, path27.join(baseRoot, trashName));
|
|
86172
87032
|
const { hasGitDir, configLock, hasIndex } = state3.signature;
|
|
86173
87033
|
canopyLogWarn(
|
|
86174
87034
|
`[canopy] Quarantined unfinished branch directory '${dirName}' as ${trashName} (git=${hasGitDir} config.lock=${configLock} index=${hasIndex} quiet=${Math.round(quiet / 1e3)}s)`
|
|
@@ -86180,7 +87040,7 @@ async function quarantineResidueAt(baseRoot, dirName, options) {
|
|
|
86180
87040
|
}
|
|
86181
87041
|
async function judgeQuarantineCandidate(candidate, inode, options) {
|
|
86182
87042
|
const state3 = await classifyFinalDir(candidate, options.expectedRemoteUrl);
|
|
86183
|
-
const moved = await
|
|
87043
|
+
const moved = await fs25.lstat(candidate).catch(() => null);
|
|
86184
87044
|
const quiet = await quietAgeMs(candidate, options.now);
|
|
86185
87045
|
let reason;
|
|
86186
87046
|
if (!moved || moved.ino !== inode) reason = "replaced";
|
|
@@ -86197,7 +87057,7 @@ async function sweepByAge(root5, rules, now) {
|
|
|
86197
87057
|
const stamp = rule ? parseDirStamp(name2) : null;
|
|
86198
87058
|
if (!rule || !stamp || now - stamp.getTime() < rule.maxAgeMs) continue;
|
|
86199
87059
|
try {
|
|
86200
|
-
await
|
|
87060
|
+
await fs25.rm(path27.join(root5, name2), {
|
|
86201
87061
|
recursive: true,
|
|
86202
87062
|
force: true,
|
|
86203
87063
|
maxRetries: 3,
|
|
@@ -86211,7 +87071,7 @@ async function sweepByAge(root5, rules, now) {
|
|
|
86211
87071
|
return actions;
|
|
86212
87072
|
}
|
|
86213
87073
|
async function recoverRepairDir(baseRoot, name2) {
|
|
86214
|
-
const repairPath =
|
|
87074
|
+
const repairPath = path27.join(baseRoot, name2);
|
|
86215
87075
|
const meta = await readBranchMetadataFile(repairPath).catch(() => null);
|
|
86216
87076
|
const dirName = meta ? sanitizeBranchName(meta.branch.name) : void 0;
|
|
86217
87077
|
if (dirName && name2.startsWith(`${REPAIR_PREFIX}${shortDirName(dirName)}-`)) {
|
|
@@ -86225,9 +87085,9 @@ async function recoverRepairDir(baseRoot, name2) {
|
|
|
86225
87085
|
throw err;
|
|
86226
87086
|
}
|
|
86227
87087
|
try {
|
|
86228
|
-
const finalPath =
|
|
86229
|
-
if (await
|
|
86230
|
-
await
|
|
87088
|
+
const finalPath = path27.join(baseRoot, dirName);
|
|
87089
|
+
if (await fs25.lstat(finalPath).catch(() => null) === null) {
|
|
87090
|
+
await fs25.rename(repairPath, finalPath);
|
|
86231
87091
|
return { name: name2, action: "restored", detail: dirName };
|
|
86232
87092
|
}
|
|
86233
87093
|
} finally {
|
|
@@ -86236,7 +87096,7 @@ async function recoverRepairDir(baseRoot, name2) {
|
|
|
86236
87096
|
}
|
|
86237
87097
|
}
|
|
86238
87098
|
const trashName = `${TRASH_PREFIX}${name2.slice(REPAIR_PREFIX.length)}`;
|
|
86239
|
-
await
|
|
87099
|
+
await fs25.rename(repairPath, path27.join(baseRoot, trashName));
|
|
86240
87100
|
return { name: name2, action: "trashed", detail: trashName };
|
|
86241
87101
|
}
|
|
86242
87102
|
async function sweepProvisioningLeftovers(baseRoot, workspaceRoot, now = Date.now()) {
|
|
@@ -86287,12 +87147,12 @@ async function maintainRemoteGit(gitDir) {
|
|
|
86287
87147
|
}
|
|
86288
87148
|
|
|
86289
87149
|
// ../canopycms/src/worker/sparse-cone.ts
|
|
86290
|
-
import
|
|
86291
|
-
import
|
|
87150
|
+
import fs27 from "node:fs/promises";
|
|
87151
|
+
import path29 from "node:path";
|
|
86292
87152
|
|
|
86293
87153
|
// ../canopycms/src/branch-sparse.ts
|
|
86294
|
-
import
|
|
86295
|
-
import
|
|
87154
|
+
import fs26 from "node:fs/promises";
|
|
87155
|
+
import path28 from "node:path";
|
|
86296
87156
|
init_error();
|
|
86297
87157
|
function sameCone(a9, b10) {
|
|
86298
87158
|
if (a9 === null || b10 === null) return a9 === b10;
|
|
@@ -86301,12 +87161,12 @@ function sameCone(a9, b10) {
|
|
|
86301
87161
|
}
|
|
86302
87162
|
var SPARSE_CONE_RECORD = ".sparse-cone.json";
|
|
86303
87163
|
function isConeDir(dir) {
|
|
86304
|
-
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 === "..");
|
|
86305
87165
|
}
|
|
86306
87166
|
async function readRecordedSparseCone(contentBranchesRoot) {
|
|
86307
87167
|
let raw;
|
|
86308
87168
|
try {
|
|
86309
|
-
raw = await
|
|
87169
|
+
raw = await fs26.readFile(path28.join(contentBranchesRoot, SPARSE_CONE_RECORD), "utf8");
|
|
86310
87170
|
} catch (err) {
|
|
86311
87171
|
if (isNodeError(err) && err.code === "ENOENT") return void 0;
|
|
86312
87172
|
throw err;
|
|
@@ -86339,15 +87199,15 @@ async function reapplySparseCones(ctx) {
|
|
|
86339
87199
|
if (!recorded) return report;
|
|
86340
87200
|
let entries;
|
|
86341
87201
|
try {
|
|
86342
|
-
entries = await
|
|
87202
|
+
entries = await fs27.readdir(ctx.contentBranchesPath, { withFileTypes: true });
|
|
86343
87203
|
} catch (err) {
|
|
86344
87204
|
if (isNodeError(err) && err.code === "ENOENT") return report;
|
|
86345
87205
|
throw err;
|
|
86346
87206
|
}
|
|
86347
87207
|
const dirNames = entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).sort();
|
|
86348
87208
|
for (const dirName of dirNames) {
|
|
86349
|
-
const branchPath =
|
|
86350
|
-
const isClone = await
|
|
87209
|
+
const branchPath = path29.join(ctx.contentBranchesPath, dirName);
|
|
87210
|
+
const isClone = await fs27.stat(path29.join(branchPath, ".git")).then(
|
|
86351
87211
|
(stat) => stat.isDirectory(),
|
|
86352
87212
|
() => false
|
|
86353
87213
|
);
|
|
@@ -86379,7 +87239,7 @@ async function reapplySparseCones(ctx) {
|
|
|
86379
87239
|
return report;
|
|
86380
87240
|
}
|
|
86381
87241
|
async function reapplyOne(contentBranchesPath, dirName, git, target) {
|
|
86382
|
-
const branchPath =
|
|
87242
|
+
const branchPath = path29.join(contentBranchesPath, dirName);
|
|
86383
87243
|
const hold = await holdProvisionedWorkspace(contentBranchesPath, dirName);
|
|
86384
87244
|
if (hold.kind !== "held") return "skipped";
|
|
86385
87245
|
try {
|
|
@@ -86419,11 +87279,11 @@ async function reapplyOne(contentBranchesPath, dirName, git, target) {
|
|
|
86419
87279
|
|
|
86420
87280
|
// ../canopycms/src/worker/stale-mirror.ts
|
|
86421
87281
|
init_branch_name();
|
|
86422
|
-
import
|
|
86423
|
-
import
|
|
87282
|
+
import fs28 from "node:fs/promises";
|
|
87283
|
+
import path30 from "node:path";
|
|
86424
87284
|
init_error();
|
|
86425
87285
|
async function readEditorWork(ctx) {
|
|
86426
|
-
const workspaces = new Set(await
|
|
87286
|
+
const workspaces = new Set(await fs28.readdir(ctx.contentBranchesPath).catch(() => []));
|
|
86427
87287
|
const queuedPushes = /* @__PURE__ */ new Set();
|
|
86428
87288
|
for (const status of ["pending", "processing"]) {
|
|
86429
87289
|
for (const task of await listTasks(ctx.taskDir, status, Number.POSITIVE_INFINITY)) {
|
|
@@ -86458,7 +87318,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
|
|
|
86458
87318
|
throw err;
|
|
86459
87319
|
}
|
|
86460
87320
|
try {
|
|
86461
|
-
if ((await
|
|
87321
|
+
if ((await fs28.readdir(ctx.contentBranchesPath)).includes(dirName)) {
|
|
86462
87322
|
return { kind: "kept", state: "workspace" };
|
|
86463
87323
|
}
|
|
86464
87324
|
const ref = `refs/heads/${name2}`;
|
|
@@ -86468,7 +87328,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
|
|
|
86468
87328
|
);
|
|
86469
87329
|
} catch (err) {
|
|
86470
87330
|
const message2 = getErrorMessage(err);
|
|
86471
|
-
if (lockHeld(message2) ===
|
|
87331
|
+
if (lockHeld(message2) === path30.join(ctx.remoteGitPath, "packed-refs.lock")) {
|
|
86472
87332
|
return { kind: "packed-refs-locked" };
|
|
86473
87333
|
}
|
|
86474
87334
|
if (/cannot lock ref|Unable to create '[^']*\.lock': File exists/.test(message2)) {
|
|
@@ -86483,7 +87343,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
|
|
|
86483
87343
|
}
|
|
86484
87344
|
function lockHeld(message2) {
|
|
86485
87345
|
const match2 = /Unable to create '([^']*)': File exists/.exec(message2);
|
|
86486
|
-
return match2 ?
|
|
87346
|
+
return match2 ? path30.normalize(match2[1]) : null;
|
|
86487
87347
|
}
|
|
86488
87348
|
async function sharesHistory(git, head, baseTip) {
|
|
86489
87349
|
try {
|
|
@@ -86652,11 +87512,12 @@ async function reconcileTrackedBranches(ctx, git, githubTips) {
|
|
|
86652
87512
|
}
|
|
86653
87513
|
}
|
|
86654
87514
|
try {
|
|
87515
|
+
if (name2 !== ctx.baseBranch) await recordSeenOnGitHub(ctx, name2, trackedSha);
|
|
86655
87516
|
await git.raw(["update-ref", "--no-deref", localRef, trackedSha, localSha]);
|
|
86656
87517
|
fastForwarded.push(name2);
|
|
86657
87518
|
} catch (err) {
|
|
86658
87519
|
workerLogWarn(
|
|
86659
|
-
` 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))}`
|
|
86660
87521
|
);
|
|
86661
87522
|
}
|
|
86662
87523
|
} else if (localBehindCount === 0 && localAheadCount > 0) {
|
|
@@ -86749,7 +87610,7 @@ function divergedWarning({ name: name2, local, github, state: state3, error: err
|
|
|
86749
87610
|
// The reason is part of what was said, so a head first kept as `busy` is reported again with
|
|
86750
87611
|
// the reason that keeps it.
|
|
86751
87612
|
said: `${local} ${github} ${state3}`,
|
|
86752
|
-
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.`
|
|
86753
87614
|
};
|
|
86754
87615
|
}
|
|
86755
87616
|
function warnOnce2(warned3, lines) {
|
|
@@ -86789,6 +87650,7 @@ async function syncGit(ctx) {
|
|
|
86789
87650
|
workerLogWarn(`remote.git maintenance failed: ${getErrorMessage(err)}`);
|
|
86790
87651
|
}
|
|
86791
87652
|
if (stoppedForDrain(ctx, "the GitHub fetch")) return;
|
|
87653
|
+
const fetchedAt = Date.now();
|
|
86792
87654
|
const { refs: githubTips, needsOperator } = await fetchGitHubIntoRemoteGit(
|
|
86793
87655
|
ctx,
|
|
86794
87656
|
ctx.shutdownSignal()
|
|
@@ -86824,7 +87686,10 @@ async function syncGit(ctx) {
|
|
|
86824
87686
|
(writeErr) => workerLogError("Failed to write worker status:", getErrorMessage(writeErr))
|
|
86825
87687
|
);
|
|
86826
87688
|
}
|
|
86827
|
-
const rebaseSummary = await runRebaseCycle(ctx, branchPolicy
|
|
87689
|
+
const rebaseSummary = await runRebaseCycle(ctx, branchPolicy, {
|
|
87690
|
+
tips: githubTips,
|
|
87691
|
+
fetchedAt
|
|
87692
|
+
});
|
|
86828
87693
|
if (stoppedForDrain(ctx, "the cleanup sweeps")) return;
|
|
86829
87694
|
await cleanupOldTasks(ctx.taskDir, void 0, ctx.log);
|
|
86830
87695
|
if (health && branchPolicy) {
|
|
@@ -86886,7 +87751,7 @@ var reportedForeignDirs = /* @__PURE__ */ new Set();
|
|
|
86886
87751
|
async function repairBranchDirResidue(ctx, now = Date.now()) {
|
|
86887
87752
|
let entries;
|
|
86888
87753
|
try {
|
|
86889
|
-
entries = await
|
|
87754
|
+
entries = await fs29.readdir(ctx.contentBranchesPath, { withFileTypes: true });
|
|
86890
87755
|
} catch (err) {
|
|
86891
87756
|
if (isNodeError(err) && err.code === "ENOENT") return;
|
|
86892
87757
|
throw err;
|
|
@@ -86901,7 +87766,7 @@ async function repairBranchDirResidue(ctx, now = Date.now()) {
|
|
|
86901
87766
|
}
|
|
86902
87767
|
const leftovers = await sweepProvisioningLeftovers(
|
|
86903
87768
|
ctx.contentBranchesPath,
|
|
86904
|
-
|
|
87769
|
+
path31.dirname(ctx.contentBranchesPath),
|
|
86905
87770
|
now
|
|
86906
87771
|
);
|
|
86907
87772
|
for (const { name: name2, action, detail } of leftovers) {
|
|
@@ -86912,8 +87777,8 @@ async function repairBranchDirResidue(ctx, now = Date.now()) {
|
|
|
86912
87777
|
}
|
|
86913
87778
|
}
|
|
86914
87779
|
async function repairOneBranchDir(ctx, dirName, now) {
|
|
86915
|
-
const dirPath =
|
|
86916
|
-
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(
|
|
86917
87782
|
() => true,
|
|
86918
87783
|
() => false
|
|
86919
87784
|
);
|
|
@@ -86949,7 +87814,7 @@ async function repairOneBranchDir(ctx, dirName, now) {
|
|
|
86949
87814
|
async function cleanupTrashedBranchDirs(ctx) {
|
|
86950
87815
|
let entries;
|
|
86951
87816
|
try {
|
|
86952
|
-
entries = await
|
|
87817
|
+
entries = await fs29.readdir(ctx.contentBranchesPath);
|
|
86953
87818
|
} catch (err) {
|
|
86954
87819
|
if (isNodeError(err) && err.code === "ENOENT") return 0;
|
|
86955
87820
|
throw err;
|
|
@@ -86969,7 +87834,7 @@ async function cleanupTrashedBranchDirs(ctx) {
|
|
|
86969
87834
|
}
|
|
86970
87835
|
if (now - stampDate.getTime() < TRASH_RETENTION_MS) continue;
|
|
86971
87836
|
try {
|
|
86972
|
-
await
|
|
87837
|
+
await fs29.rm(path31.join(ctx.contentBranchesPath, name2), {
|
|
86973
87838
|
recursive: true,
|
|
86974
87839
|
force: true,
|
|
86975
87840
|
maxRetries: 3,
|
|
@@ -86987,7 +87852,7 @@ async function cleanupTrashedBranchDirs(ctx) {
|
|
|
86987
87852
|
}
|
|
86988
87853
|
var warnedTrackedCanopyState = /* @__PURE__ */ new Set();
|
|
86989
87854
|
async function refreshBaseBranchWorkspace(ctx) {
|
|
86990
|
-
const basePath37 =
|
|
87855
|
+
const basePath37 = path31.join(ctx.contentBranchesPath, ctx.sanitizedBaseBranch);
|
|
86991
87856
|
let trackedCanopyMeta;
|
|
86992
87857
|
let releaseProvisioning;
|
|
86993
87858
|
let releaseContentLock;
|
|
@@ -87145,10 +88010,10 @@ async function refreshBaseBranchWorkspace(ctx) {
|
|
|
87145
88010
|
// ../canopycms/src/worker/github-gateway-http.ts
|
|
87146
88011
|
init_error();
|
|
87147
88012
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
87148
|
-
import
|
|
88013
|
+
import fs30 from "node:fs/promises";
|
|
87149
88014
|
import http from "node:http";
|
|
87150
88015
|
import net from "node:net";
|
|
87151
|
-
import
|
|
88016
|
+
import path32 from "node:path";
|
|
87152
88017
|
import { PassThrough } from "node:stream";
|
|
87153
88018
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
87154
88019
|
var MAX_POLL_WAIT_MS = 25e3;
|
|
@@ -87171,11 +88036,11 @@ async function serveGitHubGateway(gateway, listen, options = {}) {
|
|
|
87171
88036
|
if ("fd" in listen) {
|
|
87172
88037
|
await listenOn(server, { fd: listen.fd });
|
|
87173
88038
|
} else {
|
|
87174
|
-
await assertPrivateDirectory(
|
|
88039
|
+
await assertPrivateDirectory(path32.dirname(listen.path));
|
|
87175
88040
|
await removeStaleSocket(listen.path);
|
|
87176
88041
|
await listenOn(server, { path: listen.path });
|
|
87177
88042
|
try {
|
|
87178
|
-
await
|
|
88043
|
+
await fs30.chmod(listen.path, 384);
|
|
87179
88044
|
} catch (err) {
|
|
87180
88045
|
await closeServer(server, handler);
|
|
87181
88046
|
throw err;
|
|
@@ -87216,7 +88081,7 @@ function listenOn(server, options) {
|
|
|
87216
88081
|
});
|
|
87217
88082
|
}
|
|
87218
88083
|
async function assertPrivateDirectory(dir) {
|
|
87219
|
-
const stat = await
|
|
88084
|
+
const stat = await fs30.lstat(dir);
|
|
87220
88085
|
const uid = process.getuid?.();
|
|
87221
88086
|
if (!stat.isDirectory() || uid !== void 0 && (stat.uid !== uid || (stat.mode & 63) !== 0)) {
|
|
87222
88087
|
throw new Error(
|
|
@@ -87227,7 +88092,7 @@ async function assertPrivateDirectory(dir) {
|
|
|
87227
88092
|
async function removeStaleSocket(socketPath) {
|
|
87228
88093
|
let stat;
|
|
87229
88094
|
try {
|
|
87230
|
-
stat = await
|
|
88095
|
+
stat = await fs30.lstat(socketPath);
|
|
87231
88096
|
} catch (err) {
|
|
87232
88097
|
if (isNodeError(err) && err.code === "ENOENT") return;
|
|
87233
88098
|
throw err;
|
|
@@ -87243,7 +88108,7 @@ async function removeStaleSocket(socketPath) {
|
|
|
87243
88108
|
`Refusing to serve the GitHub gateway at ${socketPath}: a gateway already serves there`
|
|
87244
88109
|
);
|
|
87245
88110
|
}
|
|
87246
|
-
await
|
|
88111
|
+
await fs30.unlink(socketPath);
|
|
87247
88112
|
}
|
|
87248
88113
|
function isServed(socketPath) {
|
|
87249
88114
|
return new Promise((resolve) => {
|
|
@@ -87303,11 +88168,8 @@ var GatewayRequestHandler = class {
|
|
|
87303
88168
|
return {};
|
|
87304
88169
|
},
|
|
87305
88170
|
getPullRequest: async ({ number }, signal) => {
|
|
87306
|
-
const { merged, merged_at, state: state3, node_id, body } = await gateway.getPullRequest(
|
|
87307
|
-
|
|
87308
|
-
signal
|
|
87309
|
-
);
|
|
87310
|
-
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 };
|
|
87311
88173
|
},
|
|
87312
88174
|
createOrUpdatePullRequest: async (input, signal) => {
|
|
87313
88175
|
const { number, url, created } = await gateway.createOrUpdatePullRequest(input, signal);
|
|
@@ -87782,6 +88644,7 @@ var GitHubGatewayClient = class {
|
|
|
87782
88644
|
branch: request.branch,
|
|
87783
88645
|
sha: request.sha,
|
|
87784
88646
|
...request.lease === void 0 ? {} : { lease: request.lease },
|
|
88647
|
+
...request.seen === void 0 ? {} : { seen: request.seen },
|
|
87785
88648
|
prerequisites: [...request.prerequisites],
|
|
87786
88649
|
bundle: bundle !== void 0
|
|
87787
88650
|
});
|
|
@@ -87977,9 +88840,9 @@ init_branch_namespace();
|
|
|
87977
88840
|
|
|
87978
88841
|
// ../canopycms/src/worker/self-checks.ts
|
|
87979
88842
|
init_error();
|
|
87980
|
-
import
|
|
88843
|
+
import fs31 from "node:fs/promises";
|
|
87981
88844
|
import net2 from "node:net";
|
|
87982
|
-
import
|
|
88845
|
+
import path33 from "node:path";
|
|
87983
88846
|
var IMDS_HOST = "169.254.169.254";
|
|
87984
88847
|
var IMDS_CONNECT_TIMEOUT_MS = 1e3;
|
|
87985
88848
|
var NO_ROUTE_CODES = /* @__PURE__ */ new Set(["ENETUNREACH", "EAFNOSUPPORT"]);
|
|
@@ -88034,10 +88897,10 @@ async function imdsUnreachable(environment = {}) {
|
|
|
88034
88897
|
};
|
|
88035
88898
|
}
|
|
88036
88899
|
async function onlyLoopback(environment = {}) {
|
|
88037
|
-
const file =
|
|
88900
|
+
const file = path33.join(rootOf(environment), "proc", "self", "net", "dev");
|
|
88038
88901
|
let text;
|
|
88039
88902
|
try {
|
|
88040
|
-
text = await
|
|
88903
|
+
text = await fs31.readFile(file, "utf8");
|
|
88041
88904
|
} catch (err) {
|
|
88042
88905
|
return {
|
|
88043
88906
|
check: "network-namespace",
|
|
@@ -88054,21 +88917,21 @@ async function onlyLoopback(environment = {}) {
|
|
|
88054
88917
|
};
|
|
88055
88918
|
}
|
|
88056
88919
|
async function procShowsOnlyOwnProcesses(environment = {}) {
|
|
88057
|
-
const proc =
|
|
88920
|
+
const proc = path33.join(rootOf(environment), "proc");
|
|
88058
88921
|
const uid = environment.uid ?? process.getuid?.();
|
|
88059
88922
|
if (uid === void 0) {
|
|
88060
88923
|
return { check: "proc", ok: false, detail: "this platform has no process uid to compare" };
|
|
88061
88924
|
}
|
|
88062
88925
|
let entries;
|
|
88063
88926
|
try {
|
|
88064
|
-
entries = await
|
|
88927
|
+
entries = await fs31.readdir(proc);
|
|
88065
88928
|
} catch (err) {
|
|
88066
88929
|
return { check: "proc", ok: false, detail: `cannot list ${proc}: ${getErrorMessage(err)}` };
|
|
88067
88930
|
}
|
|
88068
88931
|
const others = [];
|
|
88069
88932
|
for (const entry of entries.filter((name2) => /^\d+$/.test(name2))) {
|
|
88070
88933
|
try {
|
|
88071
|
-
const stat = await
|
|
88934
|
+
const stat = await fs31.stat(path33.join(proc, entry));
|
|
88072
88935
|
if (stat.uid !== uid) others.push(`${entry} (uid ${stat.uid})`);
|
|
88073
88936
|
} catch (err) {
|
|
88074
88937
|
if (!(isNodeError(err) && err.code === "ENOENT")) {
|
|
@@ -88084,9 +88947,9 @@ async function procShowsOnlyOwnProcesses(environment = {}) {
|
|
|
88084
88947
|
};
|
|
88085
88948
|
}
|
|
88086
88949
|
async function homeIsEmpty(environment = {}) {
|
|
88087
|
-
const home =
|
|
88950
|
+
const home = path33.join(rootOf(environment), "home");
|
|
88088
88951
|
try {
|
|
88089
|
-
const entries = await
|
|
88952
|
+
const entries = await fs31.readdir(home);
|
|
88090
88953
|
return {
|
|
88091
88954
|
check: "home",
|
|
88092
88955
|
ok: entries.length === 0,
|
|
@@ -88109,9 +88972,9 @@ function noSecretsInEnv(environment = {}) {
|
|
|
88109
88972
|
};
|
|
88110
88973
|
}
|
|
88111
88974
|
async function efsUnreadable(environment = {}) {
|
|
88112
|
-
const efs =
|
|
88975
|
+
const efs = path33.join(rootOf(environment), "mnt", "efs");
|
|
88113
88976
|
try {
|
|
88114
|
-
await
|
|
88977
|
+
await fs31.readdir(efs);
|
|
88115
88978
|
} catch (err) {
|
|
88116
88979
|
const code = isNodeError(err) ? err.code : void 0;
|
|
88117
88980
|
const denied = code === "EACCES" || code === "EPERM";
|
|
@@ -88128,9 +88991,9 @@ async function efsUnreadable(environment = {}) {
|
|
|
88128
88991
|
};
|
|
88129
88992
|
}
|
|
88130
88993
|
async function corePatternNotPiped(environment = {}) {
|
|
88131
|
-
const file =
|
|
88994
|
+
const file = path33.join(rootOf(environment), "proc", "sys", "kernel", "core_pattern");
|
|
88132
88995
|
try {
|
|
88133
|
-
const pattern = (await
|
|
88996
|
+
const pattern = (await fs31.readFile(file, "utf8")).trim();
|
|
88134
88997
|
const ok = !pattern.startsWith("|");
|
|
88135
88998
|
return {
|
|
88136
88999
|
check: "core-pattern",
|
|
@@ -88146,10 +89009,10 @@ async function corePatternNotPiped(environment = {}) {
|
|
|
88146
89009
|
}
|
|
88147
89010
|
}
|
|
88148
89011
|
async function coreLimitZero(environment = {}) {
|
|
88149
|
-
const file =
|
|
89012
|
+
const file = path33.join(rootOf(environment), "proc", "self", "limits");
|
|
88150
89013
|
let text;
|
|
88151
89014
|
try {
|
|
88152
|
-
text = await
|
|
89015
|
+
text = await fs31.readFile(file, "utf8");
|
|
88153
89016
|
} catch (err) {
|
|
88154
89017
|
return {
|
|
88155
89018
|
check: "core-limit",
|
|
@@ -88171,11 +89034,11 @@ async function socketAccessIsOthers(environment = {}) {
|
|
|
88171
89034
|
const uid = environment.uid ?? process.getuid?.();
|
|
88172
89035
|
if (uid === void 0) return fail("this platform has no process uid to compare");
|
|
88173
89036
|
const fd = environment.listenFd ?? 3;
|
|
88174
|
-
const proc =
|
|
89037
|
+
const proc = path33.join(rootOf(environment), "proc", "self");
|
|
88175
89038
|
let socketPath;
|
|
88176
89039
|
try {
|
|
88177
|
-
const inode = (await
|
|
88178
|
-
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");
|
|
88179
89042
|
for (const line of table.split("\n").slice(1)) {
|
|
88180
89043
|
const fields = line.trim().split(/\s+/);
|
|
88181
89044
|
if (fields[6] === String(inode) && fields.length > 7) socketPath = fields.slice(7).join(" ");
|
|
@@ -88183,12 +89046,12 @@ async function socketAccessIsOthers(environment = {}) {
|
|
|
88183
89046
|
} catch (err) {
|
|
88184
89047
|
return fail(`cannot find the socket on descriptor ${fd}: ${getErrorMessage(err)}`);
|
|
88185
89048
|
}
|
|
88186
|
-
if (socketPath === void 0 || !
|
|
89049
|
+
if (socketPath === void 0 || !path33.isAbsolute(socketPath)) {
|
|
88187
89050
|
return fail(`the socket on descriptor ${fd} is not bound to a path`);
|
|
88188
89051
|
}
|
|
88189
89052
|
let node;
|
|
88190
89053
|
try {
|
|
88191
|
-
node = await
|
|
89054
|
+
node = await fs31.lstat(socketPath);
|
|
88192
89055
|
} catch (err) {
|
|
88193
89056
|
return fail(`cannot read ${socketPath}: ${getErrorMessage(err)}`);
|
|
88194
89057
|
}
|
|
@@ -88235,8 +89098,8 @@ function tcpConnect(host, port, timeoutMs) {
|
|
|
88235
89098
|
|
|
88236
89099
|
// ../canopycms/src/worker/cms-worker.ts
|
|
88237
89100
|
function defaultStateDirectory(workspacePath) {
|
|
88238
|
-
const key = createHash2("sha256").update(
|
|
88239
|
-
return
|
|
89101
|
+
const key = createHash2("sha256").update(path34.resolve(workspacePath)).digest("hex").slice(0, 16);
|
|
89102
|
+
return path34.join(os.tmpdir(), `canopycms-worker-${key}`);
|
|
88240
89103
|
}
|
|
88241
89104
|
var MAX_REFS_LISTED = 20;
|
|
88242
89105
|
var RemoteGitKeptError = class extends Error {
|
|
@@ -88287,7 +89150,7 @@ function lockWorkerTaskDir(taskDir, lockStaleMs, options) {
|
|
|
88287
89150
|
const waitMs = options.waitMs ?? 0;
|
|
88288
89151
|
const intervalMs = Math.max(250, Math.min(5e3, Math.floor(lockStaleMs / 4)));
|
|
88289
89152
|
return import_proper_lockfile3.default.lock(taskDir, {
|
|
88290
|
-
lockfilePath:
|
|
89153
|
+
lockfilePath: path34.join(taskDir, ".worker-lock"),
|
|
88291
89154
|
stale: lockStaleMs,
|
|
88292
89155
|
onCompromised: options.onCompromised,
|
|
88293
89156
|
...waitMs > 0 ? {
|
|
@@ -88313,10 +89176,10 @@ async function readCarriedFields(taskDir) {
|
|
|
88313
89176
|
};
|
|
88314
89177
|
}
|
|
88315
89178
|
async function recordWorkerStartupFailure(options) {
|
|
88316
|
-
const taskDir =
|
|
89179
|
+
const taskDir = path34.join(options.workspacePath, ".tasks");
|
|
88317
89180
|
let release2;
|
|
88318
89181
|
try {
|
|
88319
|
-
await
|
|
89182
|
+
await fs32.mkdir(taskDir, { recursive: true });
|
|
88320
89183
|
release2 = await lockWorkerTaskDir(taskDir, 2 * (options.lockStaleMs ?? DEFAULT_LOCK_STALE_MS), {
|
|
88321
89184
|
onCompromised: (err) => workerLogError("Worker lock lost while recording a startup failure:", getErrorMessage(err))
|
|
88322
89185
|
});
|
|
@@ -88371,17 +89234,18 @@ var CmsWorker = class {
|
|
|
88371
89234
|
this.selfStopped = new Promise((resolve) => {
|
|
88372
89235
|
this.settleSelfStopped = resolve;
|
|
88373
89236
|
});
|
|
88374
|
-
this.taskDir =
|
|
88375
|
-
this.remoteGitPath =
|
|
88376
|
-
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(
|
|
88377
89240
|
config.stateDirectory ?? defaultStateDirectory(config.workspacePath)
|
|
88378
89241
|
);
|
|
88379
|
-
this.contentBranchesPath =
|
|
89242
|
+
this.contentBranchesPath = path34.join(config.workspacePath, "content-branches");
|
|
88380
89243
|
if (config.baseBranch !== void 0) this.setBaseBranch(config.baseBranch);
|
|
88381
89244
|
this.maxTasksPerCycle = config.maxTasksPerCycle ?? 10;
|
|
88382
89245
|
this.taskTimeoutMs = config.taskTimeoutMs ?? DEFAULT_TASK_TIMEOUT;
|
|
89246
|
+
this.gitSyncIntervalMs = config.gitSyncInterval ?? 5 * 6e4;
|
|
88383
89247
|
this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES2;
|
|
88384
|
-
this.lockFilePath =
|
|
89248
|
+
this.lockFilePath = path34.join(config.workspacePath, ".tasks", ".worker-lock");
|
|
88385
89249
|
this.lockStaleMs = config.lockStaleMs ?? DEFAULT_LOCK_STALE_MS;
|
|
88386
89250
|
this.drainDeadlineMs = config.drainDeadlineMs ?? DEFAULT_DRAIN_DEADLINE_MS;
|
|
88387
89251
|
this.contentRoot = config.contentRoot ?? "content";
|
|
@@ -88454,6 +89318,7 @@ var CmsWorker = class {
|
|
|
88454
89318
|
contentRoot: this.contentRoot,
|
|
88455
89319
|
schemaHoldMaxMs: this.schemaHoldMaxMs,
|
|
88456
89320
|
taskTimeoutMs: this.taskTimeoutMs,
|
|
89321
|
+
gitSyncIntervalMs: this.gitSyncIntervalMs,
|
|
88457
89322
|
maxTasksPerCycle: this.maxTasksPerCycle,
|
|
88458
89323
|
maxRetries: this.maxRetries,
|
|
88459
89324
|
log: this.log,
|
|
@@ -88560,7 +89425,7 @@ var CmsWorker = class {
|
|
|
88560
89425
|
}
|
|
88561
89426
|
if (this.stopping) return;
|
|
88562
89427
|
const taskInterval = this.config.taskPollInterval ?? 5e3;
|
|
88563
|
-
const gitInterval = this.
|
|
89428
|
+
const gitInterval = this.gitSyncIntervalMs;
|
|
88564
89429
|
this.scheduleLoop("task queue", () => this.processTaskQueue(), taskInterval);
|
|
88565
89430
|
this.scheduleLoop("git sync", () => this.syncGit(), gitInterval);
|
|
88566
89431
|
if (this.config.refreshAuthCache) {
|
|
@@ -88673,7 +89538,7 @@ var CmsWorker = class {
|
|
|
88673
89538
|
* is negligible at the default TTL; a badly wrong clock misjudges liveness.
|
|
88674
89539
|
*/
|
|
88675
89540
|
async acquireLock() {
|
|
88676
|
-
await
|
|
89541
|
+
await fs32.mkdir(this.taskDir, { recursive: true });
|
|
88677
89542
|
try {
|
|
88678
89543
|
this.releaseLockFn = await lockWorkerTaskDir(this.taskDir, this.lockStaleMs, {
|
|
88679
89544
|
onCompromised: (err) => {
|
|
@@ -88807,7 +89672,7 @@ var CmsWorker = class {
|
|
|
88807
89672
|
);
|
|
88808
89673
|
let remoteGitExists;
|
|
88809
89674
|
try {
|
|
88810
|
-
remoteGitExists = await
|
|
89675
|
+
remoteGitExists = await fs32.stat(this.remoteGitPath).then(
|
|
88811
89676
|
() => true,
|
|
88812
89677
|
(err) => {
|
|
88813
89678
|
if (isNodeError(err) && err.code === "ENOENT") return false;
|
|
@@ -88885,7 +89750,7 @@ var CmsWorker = class {
|
|
|
88885
89750
|
);
|
|
88886
89751
|
if (current === this.baseBranch) return;
|
|
88887
89752
|
await sharedRepoGit(gitDir, "bare").raw(["symbolic-ref", "HEAD", ref]);
|
|
88888
|
-
workerLog(`${
|
|
89753
|
+
workerLog(`${path34.basename(gitDir)} HEAD now names the base branch '${this.baseBranch}'`);
|
|
88889
89754
|
}
|
|
88890
89755
|
/**
|
|
88891
89756
|
* Whether the bare repo at `gitDir` has a local `refs/heads/<baseBranch>`.
|
|
@@ -88985,7 +89850,7 @@ var CmsWorker = class {
|
|
|
88985
89850
|
async ensureRemoteGit() {
|
|
88986
89851
|
let exists3;
|
|
88987
89852
|
try {
|
|
88988
|
-
await
|
|
89853
|
+
await fs32.stat(this.remoteGitPath);
|
|
88989
89854
|
exists3 = true;
|
|
88990
89855
|
} catch {
|
|
88991
89856
|
exists3 = false;
|
|
@@ -89005,7 +89870,7 @@ var CmsWorker = class {
|
|
|
89005
89870
|
}
|
|
89006
89871
|
workerLog("Initializing remote.git from GitHub...");
|
|
89007
89872
|
const stagingPath = await this.seedRemoteGitStaging();
|
|
89008
|
-
await
|
|
89873
|
+
await fs32.rename(stagingPath, this.remoteGitPath);
|
|
89009
89874
|
workerLog("remote.git initialized");
|
|
89010
89875
|
}
|
|
89011
89876
|
/**
|
|
@@ -89061,7 +89926,7 @@ var CmsWorker = class {
|
|
|
89061
89926
|
if (err instanceof RemoteGitKeptError) throw err;
|
|
89062
89927
|
throw notReplaced(redactCredentials(getErrorMessage(err)));
|
|
89063
89928
|
});
|
|
89064
|
-
const discardStaging = () =>
|
|
89929
|
+
const discardStaging = () => fs32.rm(stagingPath, { recursive: true, force: true });
|
|
89065
89930
|
let current;
|
|
89066
89931
|
try {
|
|
89067
89932
|
current = await listRemoteGitRefs(this.remoteGitPath);
|
|
@@ -89079,21 +89944,21 @@ var CmsWorker = class {
|
|
|
89079
89944
|
}
|
|
89080
89945
|
const replaced = `${this.remoteGitPath}.replaced-${Date.now()}`;
|
|
89081
89946
|
try {
|
|
89082
|
-
await
|
|
89947
|
+
await fs32.rename(this.remoteGitPath, replaced);
|
|
89083
89948
|
} catch (err) {
|
|
89084
89949
|
await discardStaging();
|
|
89085
89950
|
throw err;
|
|
89086
89951
|
}
|
|
89087
89952
|
try {
|
|
89088
|
-
await
|
|
89953
|
+
await fs32.rename(stagingPath, this.remoteGitPath);
|
|
89089
89954
|
} catch (err) {
|
|
89090
|
-
await
|
|
89955
|
+
await fs32.rename(replaced, this.remoteGitPath);
|
|
89091
89956
|
await discardStaging();
|
|
89092
89957
|
throw err;
|
|
89093
89958
|
}
|
|
89094
89959
|
const after = await listRemoteGitRefs(replaced).catch(() => null);
|
|
89095
89960
|
if (after !== null && sameRefs(refs, after)) {
|
|
89096
|
-
await
|
|
89961
|
+
await fs32.rm(replaced, { recursive: true, force: true, maxRetries: 3 }).catch((err) => {
|
|
89097
89962
|
workerLogWarn(
|
|
89098
89963
|
`Could not remove the replaced remote.git at ${replaced}: ${getErrorMessage(err)}`
|
|
89099
89964
|
);
|
|
@@ -89113,7 +89978,7 @@ var CmsWorker = class {
|
|
|
89113
89978
|
*/
|
|
89114
89979
|
async seedRemoteGitStaging(check) {
|
|
89115
89980
|
const stagingPath = `${this.remoteGitPath}.cloning`;
|
|
89116
|
-
await
|
|
89981
|
+
await fs32.rm(stagingPath, { recursive: true, force: true });
|
|
89117
89982
|
try {
|
|
89118
89983
|
const githubBranches = await seedFromGitHub(
|
|
89119
89984
|
this.transferContext(),
|
|
@@ -89129,7 +89994,7 @@ var CmsWorker = class {
|
|
|
89129
89994
|
if (!(err instanceof RemoteGitKeptError)) {
|
|
89130
89995
|
workerLogError(`remote.git seeding failed: ${redactCredentials(getErrorMessage(err))}`);
|
|
89131
89996
|
}
|
|
89132
|
-
await
|
|
89997
|
+
await fs32.rm(stagingPath, { recursive: true, force: true });
|
|
89133
89998
|
if (err instanceof RemoteGitKeptError) throw err;
|
|
89134
89999
|
if (err instanceof SharedRepoRefusalError) {
|
|
89135
90000
|
throw new SharedRepoRefusalError(
|
|
@@ -89238,7 +90103,7 @@ var CmsWorker = class {
|
|
|
89238
90103
|
* sanitized.
|
|
89239
90104
|
*/
|
|
89240
90105
|
branchWorkspacePath(branchRefName) {
|
|
89241
|
-
return
|
|
90106
|
+
return path34.join(this.contentBranchesPath, sanitizeBranchName(branchRefName));
|
|
89242
90107
|
}
|
|
89243
90108
|
/**
|
|
89244
90109
|
* Test-only seam: awaited inside `rebaseActiveBranches()`'s conflict round,
|
|
@@ -89272,8 +90137,8 @@ var CmsWorker = class {
|
|
|
89272
90137
|
// `rebaseActiveBranches` also has a consumer outside the test files:
|
|
89273
90138
|
// apps/test-app/app/api/e2e-test/rebase/route.ts drives it from an e2e
|
|
89274
90139
|
// fixture route. Do not delete it as unused.
|
|
89275
|
-
async rebaseActiveBranches(gatewayPolicy) {
|
|
89276
|
-
return runRebaseCycle(this.ctx(), gatewayPolicy);
|
|
90140
|
+
async rebaseActiveBranches(gatewayPolicy, gitHub) {
|
|
90141
|
+
return runRebaseCycle(this.ctx(), gatewayPolicy, gitHub);
|
|
89277
90142
|
}
|
|
89278
90143
|
// --- Git-sync cluster (worker/git-sync.ts) -----------------------------
|
|
89279
90144
|
//
|
|
@@ -89313,24 +90178,24 @@ var CmsWorker = class {
|
|
|
89313
90178
|
};
|
|
89314
90179
|
|
|
89315
90180
|
// ../canopycms/src/auth/file-based-auth-cache.ts
|
|
89316
|
-
import
|
|
89317
|
-
import
|
|
90181
|
+
import fs33 from "node:fs/promises";
|
|
90182
|
+
import path35 from "node:path";
|
|
89318
90183
|
var log5 = createDebugLogger({ prefix: "FileBasedAuthCache" });
|
|
89319
90184
|
async function writeAuthCacheSnapshot(cachePath, files) {
|
|
89320
|
-
await
|
|
90185
|
+
await fs33.mkdir(cachePath, { recursive: true });
|
|
89321
90186
|
const timestamp2 = Date.now();
|
|
89322
|
-
const snapshotDir =
|
|
89323
|
-
await
|
|
90187
|
+
const snapshotDir = path35.join(cachePath, `snapshot-${timestamp2}`);
|
|
90188
|
+
await fs33.mkdir(snapshotDir, { recursive: true });
|
|
89324
90189
|
for (const [fileName, data3] of Object.entries(files)) {
|
|
89325
|
-
const tmpPath =
|
|
89326
|
-
const finalPath =
|
|
89327
|
-
await
|
|
89328
|
-
await
|
|
89329
|
-
}
|
|
89330
|
-
const currentLink =
|
|
89331
|
-
const tmpLink =
|
|
89332
|
-
await
|
|
89333
|
-
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);
|
|
89334
90199
|
await cleanupOldSnapshots(cachePath, 2);
|
|
89335
90200
|
return snapshotDir;
|
|
89336
90201
|
}
|
|
@@ -89347,14 +90212,14 @@ async function writeAuthSnapshot(cachePath, snapshot) {
|
|
|
89347
90212
|
async function cleanupOldSnapshots(cachePath, keepCount) {
|
|
89348
90213
|
let entries;
|
|
89349
90214
|
try {
|
|
89350
|
-
entries = await
|
|
90215
|
+
entries = await fs33.readdir(cachePath);
|
|
89351
90216
|
} catch {
|
|
89352
90217
|
return;
|
|
89353
90218
|
}
|
|
89354
90219
|
const snapshots = entries.filter((e9) => e9.startsWith("snapshot-")).sort().reverse();
|
|
89355
90220
|
for (const snapshot of snapshots.slice(keepCount)) {
|
|
89356
90221
|
try {
|
|
89357
|
-
await
|
|
90222
|
+
await fs33.rm(path35.join(cachePath, snapshot), {
|
|
89358
90223
|
recursive: true,
|
|
89359
90224
|
force: true
|
|
89360
90225
|
});
|
|
@@ -89606,7 +90471,7 @@ async function completeTerminationLifecycleAction(options = {}) {
|
|
|
89606
90471
|
|
|
89607
90472
|
// worker/run.ts
|
|
89608
90473
|
init_error();
|
|
89609
|
-
import
|
|
90474
|
+
import path36 from "node:path";
|
|
89610
90475
|
|
|
89611
90476
|
// worker/github-app-auth.ts
|
|
89612
90477
|
var import_auth_app = __toESM(require_dist_node20(), 1);
|
|
@@ -93991,10 +94856,10 @@ var SessionAPI = class extends AbstractAPI {
|
|
|
93991
94856
|
*/
|
|
93992
94857
|
async getToken(sessionId, template, expiresInSeconds) {
|
|
93993
94858
|
this.requireId(sessionId);
|
|
93994
|
-
const
|
|
94859
|
+
const path37 = template ? joinPaths(basePath29, sessionId, "tokens", template) : joinPaths(basePath29, sessionId, "tokens");
|
|
93995
94860
|
const requestOptions = {
|
|
93996
94861
|
method: "POST",
|
|
93997
|
-
path:
|
|
94862
|
+
path: path37
|
|
93998
94863
|
};
|
|
93999
94864
|
if (expiresInSeconds !== void 0) {
|
|
94000
94865
|
requestOptions.bodyParams = { expires_in_seconds: expiresInSeconds };
|
|
@@ -96744,12 +97609,12 @@ function buildRequest(options) {
|
|
|
96744
97609
|
userAgent = USER_AGENT2,
|
|
96745
97610
|
skipApiVersionInUrl = false
|
|
96746
97611
|
} = options;
|
|
96747
|
-
const { path:
|
|
97612
|
+
const { path: path37, method, queryParams, headerParams, bodyParams, formData, options: opts } = requestOptions;
|
|
96748
97613
|
const { deepSnakecaseBodyParamKeys = false } = opts || {};
|
|
96749
97614
|
if (requireSecretKey) {
|
|
96750
97615
|
assertValidSecretKey(secretKey);
|
|
96751
97616
|
}
|
|
96752
|
-
const url = skipApiVersionInUrl ? joinPaths(apiUrl,
|
|
97617
|
+
const url = skipApiVersionInUrl ? joinPaths(apiUrl, path37) : joinPaths(apiUrl, apiVersion, path37);
|
|
96753
97618
|
const finalUrl = new URL(url);
|
|
96754
97619
|
if (queryParams) {
|
|
96755
97620
|
const snakecasedQueryParams = snakecase_keys_default({ ...queryParams });
|
|
@@ -99273,7 +100138,7 @@ async function buildSingleProcessWorker(deps, workspacePath) {
|
|
|
99273
100138
|
const { githubToken, githubTokenSecret, githubAppAuth, clerkSecret } = await readWorkerCredentials(env2, deps.getSecret);
|
|
99274
100139
|
const refreshAuthCache = createClerkAuthCacheRefresher({
|
|
99275
100140
|
secret: clerkSecret,
|
|
99276
|
-
cachePath:
|
|
100141
|
+
cachePath: path36.join(workspacePath, ".cache"),
|
|
99277
100142
|
useOrganizationsAsGroups
|
|
99278
100143
|
});
|
|
99279
100144
|
const worker = deps.createWorker({
|
|
@@ -99353,7 +100218,7 @@ async function buildSplitWorker(deps, workspacePath, socketPath, onGatewayWait)
|
|
|
99353
100218
|
}
|
|
99354
100219
|
const refreshAuthCache = health.clerkConfigured ? async () => {
|
|
99355
100220
|
const snapshot = await gateway.authSnapshot();
|
|
99356
|
-
await deps.writeAuthSnapshot(
|
|
100221
|
+
await deps.writeAuthSnapshot(path36.join(workspacePath, ".cache"), snapshot);
|
|
99357
100222
|
workerLog(` ${snapshot.users.length} users, ${snapshot.groups.length} groups`);
|
|
99358
100223
|
} : void 0;
|
|
99359
100224
|
const worker = deps.createWorker({
|