canopycms-cdk 0.7.1 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constructs/cms-service.d.ts +55 -0
- package/dist/constructs/cms-service.js +169 -15
- package/dist/constructs/worker-lifecycle.d.ts +1 -1
- package/dist/constructs/worker-lifecycle.js +1 -0
- package/package.json +4 -4
- package/worker/canopy-github.service +1 -1
- package/worker/canopy-worker.service +1 -1
- package/worker/dist/index.js +1674 -883
- package/worker/dist/index.js.contract +1 -1
- package/worker/dist/index.js.sha256 +1 -1
- package/worker/dist/instance-files.sh +2 -2
- package/worker/gateway.env.example +12 -0
package/worker/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// canopy-worker-contract:
|
|
2
|
+
// canopy-worker-contract: 3
|
|
3
3
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -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(fs33) {
|
|
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(fs33);
|
|
73
|
+
}
|
|
74
|
+
if (!fs33.lutimes) {
|
|
75
|
+
patchLutimes(fs33);
|
|
76
|
+
}
|
|
77
|
+
fs33.chown = chownFix(fs33.chown);
|
|
78
|
+
fs33.fchown = chownFix(fs33.fchown);
|
|
79
|
+
fs33.lchown = chownFix(fs33.lchown);
|
|
80
|
+
fs33.chmod = chmodFix(fs33.chmod);
|
|
81
|
+
fs33.fchmod = chmodFix(fs33.fchmod);
|
|
82
|
+
fs33.lchmod = chmodFix(fs33.lchmod);
|
|
83
|
+
fs33.chownSync = chownFixSync(fs33.chownSync);
|
|
84
|
+
fs33.fchownSync = chownFixSync(fs33.fchownSync);
|
|
85
|
+
fs33.lchownSync = chownFixSync(fs33.lchownSync);
|
|
86
|
+
fs33.chmodSync = chmodFixSync(fs33.chmodSync);
|
|
87
|
+
fs33.fchmodSync = chmodFixSync(fs33.fchmodSync);
|
|
88
|
+
fs33.lchmodSync = chmodFixSync(fs33.lchmodSync);
|
|
89
|
+
fs33.stat = statFix(fs33.stat);
|
|
90
|
+
fs33.fstat = statFix(fs33.fstat);
|
|
91
|
+
fs33.lstat = statFix(fs33.lstat);
|
|
92
|
+
fs33.statSync = statFixSync(fs33.statSync);
|
|
93
|
+
fs33.fstatSync = statFixSync(fs33.fstatSync);
|
|
94
|
+
fs33.lstatSync = statFixSync(fs33.lstatSync);
|
|
95
|
+
if (fs33.chmod && !fs33.lchmod) {
|
|
96
|
+
fs33.lchmod = function(path36, mode, cb) {
|
|
97
97
|
if (cb) process.nextTick(cb);
|
|
98
98
|
};
|
|
99
|
-
|
|
99
|
+
fs33.lchmodSync = function() {
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
if (
|
|
103
|
-
|
|
102
|
+
if (fs33.chown && !fs33.lchown) {
|
|
103
|
+
fs33.lchown = function(path36, uid, gid, cb) {
|
|
104
104
|
if (cb) process.nextTick(cb);
|
|
105
105
|
};
|
|
106
|
-
|
|
106
|
+
fs33.lchownSync = function() {
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
109
|
if (platform2 === "win32") {
|
|
110
|
-
|
|
110
|
+
fs33.rename = typeof fs33.rename !== "function" ? fs33.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
|
+
fs33.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
|
+
})(fs33.rename);
|
|
134
134
|
}
|
|
135
|
-
|
|
135
|
+
fs33.read = typeof fs33.read !== "function" ? fs33.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(fs33, 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(fs33, 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
|
+
})(fs33.read);
|
|
153
|
+
fs33.readSync = typeof fs33.readSync !== "function" ? fs33.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(fs33, 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
|
+
})(fs33.readSync);
|
|
169
|
+
function patchLchmod(fs34) {
|
|
170
|
+
fs34.lchmod = function(path36, mode, callback) {
|
|
171
|
+
fs34.open(
|
|
172
|
+
path36,
|
|
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
|
+
fs34.fchmod(fd, mode, function(err2) {
|
|
181
|
+
fs34.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
|
+
fs34.lchmodSync = function(path36, mode) {
|
|
189
|
+
var fd = fs34.openSync(path36, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
|
|
190
190
|
var threw = true;
|
|
191
191
|
var ret;
|
|
192
192
|
try {
|
|
193
|
-
ret =
|
|
193
|
+
ret = fs34.fchmodSync(fd, mode);
|
|
194
194
|
threw = false;
|
|
195
195
|
} finally {
|
|
196
196
|
if (threw) {
|
|
197
197
|
try {
|
|
198
|
-
|
|
198
|
+
fs34.closeSync(fd);
|
|
199
199
|
} catch (er) {
|
|
200
200
|
}
|
|
201
201
|
} else {
|
|
202
|
-
|
|
202
|
+
fs34.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(fs34) {
|
|
209
|
+
if (constants2.hasOwnProperty("O_SYMLINK") && fs34.futimes) {
|
|
210
|
+
fs34.lutimes = function(path36, at, mt, cb) {
|
|
211
|
+
fs34.open(path36, constants2.O_SYMLINK, function(er, fd) {
|
|
212
212
|
if (er) {
|
|
213
213
|
if (cb) cb(er);
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
|
-
|
|
217
|
-
|
|
216
|
+
fs34.futimes(fd, at, mt, function(er2) {
|
|
217
|
+
fs34.close(fd, function(er22) {
|
|
218
218
|
if (cb) cb(er2 || er22);
|
|
219
219
|
});
|
|
220
220
|
});
|
|
221
221
|
});
|
|
222
222
|
};
|
|
223
|
-
|
|
224
|
-
var fd =
|
|
223
|
+
fs34.lutimesSync = function(path36, at, mt) {
|
|
224
|
+
var fd = fs34.openSync(path36, constants2.O_SYMLINK);
|
|
225
225
|
var ret;
|
|
226
226
|
var threw = true;
|
|
227
227
|
try {
|
|
228
|
-
ret =
|
|
228
|
+
ret = fs34.futimesSync(fd, at, mt);
|
|
229
229
|
threw = false;
|
|
230
230
|
} finally {
|
|
231
231
|
if (threw) {
|
|
232
232
|
try {
|
|
233
|
-
|
|
233
|
+
fs34.closeSync(fd);
|
|
234
234
|
} catch (er) {
|
|
235
235
|
}
|
|
236
236
|
} else {
|
|
237
|
-
|
|
237
|
+
fs34.closeSync(fd);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
return ret;
|
|
241
241
|
};
|
|
242
|
-
} else if (
|
|
243
|
-
|
|
242
|
+
} else if (fs34.futimes) {
|
|
243
|
+
fs34.lutimes = function(_a4, _b, _c9, cb) {
|
|
244
244
|
if (cb) process.nextTick(cb);
|
|
245
245
|
};
|
|
246
|
-
|
|
246
|
+
fs34.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(fs33, 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(fs33, 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(fs33, 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(fs33, 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(fs33, target, options, callback) : orig.call(fs33, 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(fs33, target, options) : orig.call(fs33, 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(fs33) {
|
|
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(path36, options) {
|
|
343
|
+
if (!(this instanceof ReadStream2)) return new ReadStream2(path36, options);
|
|
344
344
|
Stream.call(this);
|
|
345
345
|
var self2 = this;
|
|
346
|
-
this.path =
|
|
346
|
+
this.path = path36;
|
|
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
|
+
fs33.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(path36, options) {
|
|
392
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path36, options);
|
|
393
393
|
Stream.call(this);
|
|
394
|
-
this.path =
|
|
394
|
+
this.path = path36;
|
|
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 = fs33.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 fs33 = __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 (!fs33[gracefulQueue]) {
|
|
487
487
|
queue = global[gracefulQueue] || [];
|
|
488
|
-
publishQueue(
|
|
489
|
-
|
|
488
|
+
publishQueue(fs33, queue);
|
|
489
|
+
fs33.close = (function(fs$close) {
|
|
490
490
|
function close(fd, cb) {
|
|
491
|
-
return fs$close.call(
|
|
491
|
+
return fs$close.call(fs33, 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
|
+
})(fs33.close);
|
|
504
|
+
fs33.closeSync = (function(fs$closeSync) {
|
|
505
505
|
function closeSync(fd) {
|
|
506
|
-
fs$closeSync.apply(
|
|
506
|
+
fs$closeSync.apply(fs33, 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
|
+
})(fs33.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(fs33[gracefulQueue]);
|
|
517
|
+
__require("assert").equal(fs33[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, fs33[gracefulQueue]);
|
|
524
|
+
}
|
|
525
|
+
module.exports = patch(clone(fs33));
|
|
526
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs33.__patched) {
|
|
527
|
+
module.exports = patch(fs33);
|
|
528
|
+
fs33.__patched = true;
|
|
529
|
+
}
|
|
530
|
+
function patch(fs34) {
|
|
531
|
+
polyfills(fs34);
|
|
532
|
+
fs34.gracefulify = patch;
|
|
533
|
+
fs34.createReadStream = createReadStream;
|
|
534
|
+
fs34.createWriteStream = createWriteStream;
|
|
535
|
+
var fs$readFile = fs34.readFile;
|
|
536
|
+
fs34.readFile = readFile3;
|
|
537
|
+
function readFile3(path36, 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(path36, options, cb);
|
|
541
|
+
function go$readFile(path37, options2, cb2, startTime) {
|
|
542
|
+
return fs$readFile(path37, options2, function(err) {
|
|
543
543
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
544
|
-
enqueue([go$readFile, [
|
|
544
|
+
enqueue([go$readFile, [path37, 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 = fs34.writeFile;
|
|
553
|
+
fs34.writeFile = writeFile;
|
|
554
|
+
function writeFile(path36, 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(path36, data3, options, cb);
|
|
558
|
+
function go$writeFile(path37, data4, options2, cb2, startTime) {
|
|
559
|
+
return fs$writeFile(path37, data4, options2, function(err) {
|
|
560
560
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
561
|
-
enqueue([go$writeFile, [
|
|
561
|
+
enqueue([go$writeFile, [path37, 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 = fs34.appendFile;
|
|
570
570
|
if (fs$appendFile)
|
|
571
|
-
|
|
572
|
-
function appendFile(
|
|
571
|
+
fs34.appendFile = appendFile;
|
|
572
|
+
function appendFile(path36, 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(path36, data3, options, cb);
|
|
576
|
+
function go$appendFile(path37, data4, options2, cb2, startTime) {
|
|
577
|
+
return fs$appendFile(path37, data4, options2, function(err) {
|
|
578
578
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
579
|
-
enqueue([go$appendFile, [
|
|
579
|
+
enqueue([go$appendFile, [path37, 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 = fs34.copyFile;
|
|
588
588
|
if (fs$copyFile)
|
|
589
|
-
|
|
589
|
+
fs34.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 = fs34.readdir;
|
|
608
|
+
fs34.readdir = readdir;
|
|
609
609
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
610
|
-
function readdir(
|
|
610
|
+
function readdir(path36, 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(path37, options2, cb2, startTime) {
|
|
614
|
+
return fs$readdir(path37, fs$readdirCallback(
|
|
615
|
+
path37,
|
|
616
616
|
options2,
|
|
617
617
|
cb2,
|
|
618
618
|
startTime
|
|
619
619
|
));
|
|
620
|
-
} : function go$readdir2(
|
|
621
|
-
return fs$readdir(
|
|
622
|
-
|
|
620
|
+
} : function go$readdir2(path37, options2, cb2, startTime) {
|
|
621
|
+
return fs$readdir(path37, options2, fs$readdirCallback(
|
|
622
|
+
path37,
|
|
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(path36, options, cb);
|
|
629
|
+
function fs$readdirCallback(path37, 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
|
+
[path37, 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(fs34);
|
|
650
650
|
ReadStream2 = legStreams.ReadStream;
|
|
651
651
|
WriteStream = legStreams.WriteStream;
|
|
652
652
|
}
|
|
653
|
-
var fs$ReadStream =
|
|
653
|
+
var fs$ReadStream = fs34.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 = fs34.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(fs34, "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(fs34, "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(fs34, "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(fs34, "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(path36, 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(path36, 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(path36, options) {
|
|
744
|
+
return new fs34.ReadStream(path36, options);
|
|
745
745
|
}
|
|
746
|
-
function createWriteStream(
|
|
747
|
-
return new
|
|
746
|
+
function createWriteStream(path36, options) {
|
|
747
|
+
return new fs34.WriteStream(path36, options);
|
|
748
748
|
}
|
|
749
|
-
var fs$open =
|
|
750
|
-
|
|
751
|
-
function open(
|
|
749
|
+
var fs$open = fs34.open;
|
|
750
|
+
fs34.open = open;
|
|
751
|
+
function open(path36, 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(path36, flags, mode, cb);
|
|
755
|
+
function go$open(path37, flags2, mode2, cb2, startTime) {
|
|
756
|
+
return fs$open(path37, flags2, mode2, function(err, fd) {
|
|
757
757
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
758
|
-
enqueue([go$open, [
|
|
758
|
+
enqueue([go$open, [path37, 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 fs34;
|
|
767
767
|
}
|
|
768
768
|
function enqueue(elem) {
|
|
769
769
|
debug2("ENQUEUE", elem[0].name, elem[1]);
|
|
770
|
-
|
|
770
|
+
fs33[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 < fs33[gracefulQueue].length; ++i10) {
|
|
777
|
+
if (fs33[gracefulQueue][i10].length > 2) {
|
|
778
|
+
fs33[gracefulQueue][i10][3] = now;
|
|
779
|
+
fs33[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 (fs33[gracefulQueue].length === 0)
|
|
788
788
|
return;
|
|
789
|
-
var elem =
|
|
789
|
+
var elem = fs33[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
|
+
fs33[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, fs33, callback) {
|
|
1247
|
+
const cachedPrecision = fs33[cacheSymbol];
|
|
1248
1248
|
if (cachedPrecision) {
|
|
1249
|
-
return
|
|
1249
|
+
return fs33.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
|
+
fs33.utimes(file, mtime, mtime, (err) => {
|
|
1258
1258
|
if (err) {
|
|
1259
1259
|
return callback(err);
|
|
1260
1260
|
}
|
|
1261
|
-
|
|
1261
|
+
fs33.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(fs33, 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 path36 = __require("path");
|
|
1288
|
+
var fs33 = 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, path36.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: fs33,
|
|
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: fs33,
|
|
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: fs33,
|
|
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 fs33 = require_graceful_fs();
|
|
1525
|
+
function createSyncFs(fs34) {
|
|
1526
1526
|
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
1527
|
-
const newFs = { ...
|
|
1527
|
+
const newFs = { ...fs34 };
|
|
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 = fs34[`${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 || fs33);
|
|
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
|
}
|
|
@@ -2058,10 +2058,10 @@ var require_browser = __commonJS({
|
|
|
2058
2058
|
exports.useColors = useColors;
|
|
2059
2059
|
exports.storage = localstorage();
|
|
2060
2060
|
exports.destroy = /* @__PURE__ */ (() => {
|
|
2061
|
-
let
|
|
2061
|
+
let warned3 = false;
|
|
2062
2062
|
return () => {
|
|
2063
|
-
if (!
|
|
2064
|
-
|
|
2063
|
+
if (!warned3) {
|
|
2064
|
+
warned3 = true;
|
|
2065
2065
|
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
2066
2066
|
}
|
|
2067
2067
|
};
|
|
@@ -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(path36, isFile, isDirectory) {
|
|
2534
|
+
log6(`checking %s`, path36);
|
|
2535
2535
|
try {
|
|
2536
|
-
const stat = fs_1.statSync(
|
|
2536
|
+
const stat = fs_1.statSync(path36);
|
|
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(path36, type = exports.READABLE) {
|
|
2557
|
+
return check(path36, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
2558
2558
|
}
|
|
2559
2559
|
exports.exists = exists3;
|
|
2560
2560
|
exports.FILE = 1;
|
|
@@ -3029,8 +3029,8 @@ var init_parseUtil = __esm({
|
|
|
3029
3029
|
init_errors();
|
|
3030
3030
|
init_en();
|
|
3031
3031
|
makeIssue = (params) => {
|
|
3032
|
-
const { data: data3, path:
|
|
3033
|
-
const fullPath = [...
|
|
3032
|
+
const { data: data3, path: path36, errorMaps, issueData } = params;
|
|
3033
|
+
const fullPath = [...path36, ...issueData.path || []];
|
|
3034
3034
|
const fullIssue = {
|
|
3035
3035
|
...issueData,
|
|
3036
3036
|
path: fullPath
|
|
@@ -3338,11 +3338,11 @@ var init_types = __esm({
|
|
|
3338
3338
|
init_parseUtil();
|
|
3339
3339
|
init_util2();
|
|
3340
3340
|
ParseInputLazyPath = class {
|
|
3341
|
-
constructor(parent, value,
|
|
3341
|
+
constructor(parent, value, path36, key) {
|
|
3342
3342
|
this._cachedPath = [];
|
|
3343
3343
|
this.parent = parent;
|
|
3344
3344
|
this.data = value;
|
|
3345
|
-
this._path =
|
|
3345
|
+
this._path = path36;
|
|
3346
3346
|
this._key = key;
|
|
3347
3347
|
}
|
|
3348
3348
|
get path() {
|
|
@@ -7003,9 +7003,28 @@ var require_dist3 = __commonJS({
|
|
|
7003
7003
|
}
|
|
7004
7004
|
});
|
|
7005
7005
|
|
|
7006
|
+
// ../canopycms/src/paths/branch-name.ts
|
|
7007
|
+
function sanitizeBranchName(branchName) {
|
|
7008
|
+
const replaced = branchName.replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
7009
|
+
const squashed = replaced.replace(/-+/g, "-");
|
|
7010
|
+
const trimmedDots = squashed.replace(/^\.+/, "").replace(/(?<!\.)\.+$/, "");
|
|
7011
|
+
return trimmedDots || "branch";
|
|
7012
|
+
}
|
|
7013
|
+
function isSettingsBranchName(branchName, settingsBranchName) {
|
|
7014
|
+
const sanitized = sanitizeBranchName(branchName);
|
|
7015
|
+
return sanitized.startsWith(RESERVED_SETTINGS_BRANCH_PREFIX) || settingsBranchName !== void 0 && sanitized === sanitizeBranchName(settingsBranchName);
|
|
7016
|
+
}
|
|
7017
|
+
var RESERVED_SETTINGS_BRANCH_PREFIX;
|
|
7018
|
+
var init_branch_name = __esm({
|
|
7019
|
+
"../canopycms/src/paths/branch-name.ts"() {
|
|
7020
|
+
"use strict";
|
|
7021
|
+
RESERVED_SETTINGS_BRANCH_PREFIX = "canopycms-settings-";
|
|
7022
|
+
}
|
|
7023
|
+
});
|
|
7024
|
+
|
|
7006
7025
|
// ../canopycms/src/paths/normalize.ts
|
|
7007
|
-
function normalizeFilesystemPath(
|
|
7008
|
-
return
|
|
7026
|
+
function normalizeFilesystemPath(path36) {
|
|
7027
|
+
return path36.split(/[\\/]+/).filter(Boolean).join("/");
|
|
7009
7028
|
}
|
|
7010
7029
|
var init_normalize = __esm({
|
|
7011
7030
|
"../canopycms/src/paths/normalize.ts"() {
|
|
@@ -7013,6 +7032,57 @@ var init_normalize = __esm({
|
|
|
7013
7032
|
}
|
|
7014
7033
|
});
|
|
7015
7034
|
|
|
7035
|
+
// ../canopycms/src/paths/validation.ts
|
|
7036
|
+
function isValidContentId(id) {
|
|
7037
|
+
return CONTENT_ID_PATTERN.test(id);
|
|
7038
|
+
}
|
|
7039
|
+
function parseBranchRef(name2) {
|
|
7040
|
+
if (!name2 || typeof name2 !== "string") {
|
|
7041
|
+
return { ok: false, error: "Branch name is required" };
|
|
7042
|
+
}
|
|
7043
|
+
if (name2.length > MAX_BRANCH_NAME_LENGTH) {
|
|
7044
|
+
return { ok: false, error: `Branch name too long (max ${MAX_BRANCH_NAME_LENGTH} characters)` };
|
|
7045
|
+
}
|
|
7046
|
+
if (name2.includes("..")) {
|
|
7047
|
+
return { ok: false, error: 'Branch name cannot contain ".."' };
|
|
7048
|
+
}
|
|
7049
|
+
if (name2.startsWith("/") || name2.endsWith("/") || name2.includes("//")) {
|
|
7050
|
+
return { ok: false, error: "Invalid branch name format (invalid slashes)" };
|
|
7051
|
+
}
|
|
7052
|
+
if (name2.includes(" ")) {
|
|
7053
|
+
return { ok: false, error: "Branch name cannot contain spaces" };
|
|
7054
|
+
}
|
|
7055
|
+
if (name2.startsWith("-")) {
|
|
7056
|
+
return { ok: false, error: 'Branch name cannot start with "-"' };
|
|
7057
|
+
}
|
|
7058
|
+
if (name2.startsWith(".") || name2.endsWith(".")) {
|
|
7059
|
+
return { ok: false, error: "Branch name cannot start or end with a dot" };
|
|
7060
|
+
}
|
|
7061
|
+
if (name2.includes("@{")) {
|
|
7062
|
+
return { ok: false, error: 'Branch name cannot contain "@{"' };
|
|
7063
|
+
}
|
|
7064
|
+
if (name2 === "HEAD" || name2 === "@") {
|
|
7065
|
+
return { ok: false, error: 'Branch name cannot be the reserved ref "HEAD" or "@"' };
|
|
7066
|
+
}
|
|
7067
|
+
if (/[~^:?*[\\\x00-\x1f\x7f]/.test(name2)) {
|
|
7068
|
+
return { ok: false, error: "Branch name contains invalid characters" };
|
|
7069
|
+
}
|
|
7070
|
+
if (name2.endsWith(".lock")) {
|
|
7071
|
+
return { ok: false, error: 'Branch name cannot end with ".lock"' };
|
|
7072
|
+
}
|
|
7073
|
+
return { ok: true, name: name2 };
|
|
7074
|
+
}
|
|
7075
|
+
var BASE58_PATTERN, CONTENT_ID_PATTERN, PHYSICAL_SEGMENT_PATTERN, MAX_BRANCH_NAME_LENGTH;
|
|
7076
|
+
var init_validation = __esm({
|
|
7077
|
+
"../canopycms/src/paths/validation.ts"() {
|
|
7078
|
+
"use strict";
|
|
7079
|
+
BASE58_PATTERN = "[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]";
|
|
7080
|
+
CONTENT_ID_PATTERN = new RegExp(`^${BASE58_PATTERN}{12}$`);
|
|
7081
|
+
PHYSICAL_SEGMENT_PATTERN = new RegExp(`\\.${BASE58_PATTERN}{12}(?:\\.[a-z]+)?$`);
|
|
7082
|
+
MAX_BRANCH_NAME_LENGTH = 250;
|
|
7083
|
+
}
|
|
7084
|
+
});
|
|
7085
|
+
|
|
7016
7086
|
// ../canopycms/src/paths/types.ts
|
|
7017
7087
|
var ROOT_COLLECTION_ID;
|
|
7018
7088
|
var init_types2 = __esm({
|
|
@@ -8258,15 +8328,15 @@ var require_dist_node9 = __commonJS({
|
|
|
8258
8328
|
octokit.log.debug("request", options);
|
|
8259
8329
|
const start = Date.now();
|
|
8260
8330
|
const requestOptions = octokit.request.endpoint.parse(options);
|
|
8261
|
-
const
|
|
8331
|
+
const path36 = requestOptions.url.replace(options.baseUrl, "");
|
|
8262
8332
|
return request(options).then((response) => {
|
|
8263
8333
|
octokit.log.info(
|
|
8264
|
-
`${requestOptions.method} ${
|
|
8334
|
+
`${requestOptions.method} ${path36} - ${response.status} in ${Date.now() - start}ms`
|
|
8265
8335
|
);
|
|
8266
8336
|
return response;
|
|
8267
8337
|
}).catch((error3) => {
|
|
8268
8338
|
octokit.log.info(
|
|
8269
|
-
`${requestOptions.method} ${
|
|
8339
|
+
`${requestOptions.method} ${path36} - ${error3.status} in ${Date.now() - start}ms`
|
|
8270
8340
|
);
|
|
8271
8341
|
throw error3;
|
|
8272
8342
|
});
|
|
@@ -12360,7 +12430,7 @@ var require_dist_node13 = __commonJS({
|
|
|
12360
12430
|
];
|
|
12361
12431
|
function routeMatcher(paths) {
|
|
12362
12432
|
const regexes = paths.map(
|
|
12363
|
-
(
|
|
12433
|
+
(path36) => path36.split("/").map((c11) => c11.startsWith("{") ? "(?:.+?)" : c11).join("/")
|
|
12364
12434
|
);
|
|
12365
12435
|
const regex2 = `^(?:${regexes.map((r10) => `(?:${r10})`).join("|")})[^/]*$`;
|
|
12366
12436
|
return new RegExp(regex2, "i");
|
|
@@ -12530,6 +12600,92 @@ var init_deployment_name = __esm({
|
|
|
12530
12600
|
}
|
|
12531
12601
|
});
|
|
12532
12602
|
|
|
12603
|
+
// ../canopycms/src/operating-mode/branch-namespace.ts
|
|
12604
|
+
function warnOnce(message2) {
|
|
12605
|
+
if (warned2) return;
|
|
12606
|
+
warned2 = true;
|
|
12607
|
+
canopyLogWarn(message2);
|
|
12608
|
+
}
|
|
12609
|
+
function branchNamespaceProblem(namespace) {
|
|
12610
|
+
if (!namespace.endsWith("/")) return 'it must end with "/"';
|
|
12611
|
+
const sample = `${namespace}x`;
|
|
12612
|
+
if (!/^[\x21-\x7e]+$/.test(namespace)) return "it is not printable ASCII without spaces";
|
|
12613
|
+
if (/["%{}]/.test(namespace)) return 'it contains ", %, { or }';
|
|
12614
|
+
if (/^(?:refs|heads|tags|remotes)\//i.test(namespace)) {
|
|
12615
|
+
return "it starts with 'refs/', 'heads/', 'tags/' or 'remotes/'";
|
|
12616
|
+
}
|
|
12617
|
+
const parsed = parseBranchRef(sample);
|
|
12618
|
+
if (!parsed.ok) return `a branch in it would be refused (${parsed.error})`;
|
|
12619
|
+
if (sample.split("/").some((part) => part.startsWith(".") || part.endsWith(".lock"))) {
|
|
12620
|
+
return "a part of it starts with '.' or ends with '.lock'";
|
|
12621
|
+
}
|
|
12622
|
+
const directoryPrefix = sanitizeBranchName(namespace);
|
|
12623
|
+
if (RESERVED_SETTINGS_BRANCH_PREFIX.startsWith(directoryPrefix) || sanitizeBranchName(sample).startsWith(RESERVED_SETTINGS_BRANCH_PREFIX)) {
|
|
12624
|
+
return `some branches in it would be ${RESERVED_SETTINGS_BRANCH_PREFIX}* settings branches`;
|
|
12625
|
+
}
|
|
12626
|
+
return null;
|
|
12627
|
+
}
|
|
12628
|
+
function namespaceAncestors(namespace) {
|
|
12629
|
+
const parts = namespace.split("/").filter(Boolean);
|
|
12630
|
+
return parts.map((_3, i10) => parts.slice(0, i10 + 1).join("/"));
|
|
12631
|
+
}
|
|
12632
|
+
function resolveBranchNamespaceTemplate(template, deploymentName, source) {
|
|
12633
|
+
const unknown = template.replaceAll(DEPLOYMENT_PLACEHOLDER, "").match(/\{[^}]*\}?/);
|
|
12634
|
+
if (unknown) {
|
|
12635
|
+
throw new Error(
|
|
12636
|
+
`CanopyCMS: invalid branch namespace ${JSON.stringify(template)} (from ${source}): ${JSON.stringify(unknown[0])} is not a placeholder; the only one is ${DEPLOYMENT_PLACEHOLDER}`
|
|
12637
|
+
);
|
|
12638
|
+
}
|
|
12639
|
+
const namespace = template.replaceAll(DEPLOYMENT_PLACEHOLDER, deploymentName);
|
|
12640
|
+
const problem = branchNamespaceProblem(namespace);
|
|
12641
|
+
if (problem !== null) {
|
|
12642
|
+
throw new Error(
|
|
12643
|
+
`CanopyCMS: invalid branch namespace ${JSON.stringify(namespace)} (from ${source}): ${problem}`
|
|
12644
|
+
);
|
|
12645
|
+
}
|
|
12646
|
+
return namespace;
|
|
12647
|
+
}
|
|
12648
|
+
function resolveBranchNamespace(config, modeDefault, env2 = process.env) {
|
|
12649
|
+
const fromEnv2 = env2[BRANCH_NAMESPACE_ENV]?.trim();
|
|
12650
|
+
const [template, source] = fromEnv2 ? [fromEnv2, BRANCH_NAMESPACE_ENV] : config.branchNamespace !== void 0 ? [config.branchNamespace, "config.branchNamespace"] : [DEFAULT_BRANCH_NAMESPACE_TEMPLATE, "the default"];
|
|
12651
|
+
const deploymentName = resolveDeploymentName(
|
|
12652
|
+
{ deploymentName: config.deploymentName },
|
|
12653
|
+
modeDefault
|
|
12654
|
+
);
|
|
12655
|
+
const namespace = resolveBranchNamespaceTemplate(template, deploymentName, source);
|
|
12656
|
+
if (fromEnv2 && config.branchNamespace !== void 0) {
|
|
12657
|
+
let fromConfig = null;
|
|
12658
|
+
try {
|
|
12659
|
+
fromConfig = resolveBranchNamespaceTemplate(
|
|
12660
|
+
config.branchNamespace,
|
|
12661
|
+
deploymentName,
|
|
12662
|
+
"config.branchNamespace"
|
|
12663
|
+
);
|
|
12664
|
+
} catch {
|
|
12665
|
+
}
|
|
12666
|
+
if (fromConfig !== namespace) {
|
|
12667
|
+
warnOnce(
|
|
12668
|
+
`CanopyCMS: ${BRANCH_NAMESPACE_ENV} (${JSON.stringify(fromEnv2)}) and config.branchNamespace (${JSON.stringify(config.branchNamespace)}) do not resolve to the same valid namespace; using the environment variable, which infrastructure stamps per stack.`
|
|
12669
|
+
);
|
|
12670
|
+
}
|
|
12671
|
+
}
|
|
12672
|
+
return namespace;
|
|
12673
|
+
}
|
|
12674
|
+
var warned2, DEPLOYMENT_PLACEHOLDER, DEFAULT_BRANCH_NAMESPACE_TEMPLATE, BRANCH_NAMESPACE_ENV;
|
|
12675
|
+
var init_branch_namespace = __esm({
|
|
12676
|
+
"../canopycms/src/operating-mode/branch-namespace.ts"() {
|
|
12677
|
+
"use strict";
|
|
12678
|
+
init_branch_name();
|
|
12679
|
+
init_validation();
|
|
12680
|
+
init_logger();
|
|
12681
|
+
init_deployment_name();
|
|
12682
|
+
warned2 = false;
|
|
12683
|
+
DEPLOYMENT_PLACEHOLDER = "{deployment}";
|
|
12684
|
+
DEFAULT_BRANCH_NAMESPACE_TEMPLATE = `canopycms/${DEPLOYMENT_PLACEHOLDER}/`;
|
|
12685
|
+
BRANCH_NAMESPACE_ENV = "CANOPYCMS_BRANCH_NAMESPACE";
|
|
12686
|
+
}
|
|
12687
|
+
});
|
|
12688
|
+
|
|
12533
12689
|
// ../canopycms/src/task-queue/worker-status.ts
|
|
12534
12690
|
import fs12 from "node:fs/promises";
|
|
12535
12691
|
import path13 from "node:path";
|
|
@@ -13375,9 +13531,9 @@ var init_createPaginator = __esm({
|
|
|
13375
13531
|
command5 = withCommand(command5) ?? command5;
|
|
13376
13532
|
return await client.send(command5, ...args);
|
|
13377
13533
|
};
|
|
13378
|
-
get = (fromObject,
|
|
13534
|
+
get = (fromObject, path36) => {
|
|
13379
13535
|
let cursor3 = fromObject;
|
|
13380
|
-
const pathComponents =
|
|
13536
|
+
const pathComponents = path36.split(".");
|
|
13381
13537
|
for (const step of pathComponents) {
|
|
13382
13538
|
if (!cursor3 || typeof cursor3 !== "object") {
|
|
13383
13539
|
return void 0;
|
|
@@ -14395,12 +14551,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
14395
14551
|
const password = request.password ?? "";
|
|
14396
14552
|
auth = `${username}:${password}`;
|
|
14397
14553
|
}
|
|
14398
|
-
let
|
|
14554
|
+
let path36 = request.path;
|
|
14399
14555
|
if (queryString) {
|
|
14400
|
-
|
|
14556
|
+
path36 += `?${queryString}`;
|
|
14401
14557
|
}
|
|
14402
14558
|
if (request.fragment) {
|
|
14403
|
-
|
|
14559
|
+
path36 += `#${request.fragment}`;
|
|
14404
14560
|
}
|
|
14405
14561
|
let hostname = request.hostname ?? "";
|
|
14406
14562
|
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
@@ -14412,7 +14568,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
14412
14568
|
headers: request.headers,
|
|
14413
14569
|
host: hostname,
|
|
14414
14570
|
method: request.method,
|
|
14415
|
-
path:
|
|
14571
|
+
path: path36,
|
|
14416
14572
|
port: request.port,
|
|
14417
14573
|
agent,
|
|
14418
14574
|
auth
|
|
@@ -14695,16 +14851,16 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
14695
14851
|
reject(err);
|
|
14696
14852
|
};
|
|
14697
14853
|
const queryString = querystringBuilder.buildQueryString(query || {});
|
|
14698
|
-
let
|
|
14854
|
+
let path36 = request.path;
|
|
14699
14855
|
if (queryString) {
|
|
14700
|
-
|
|
14856
|
+
path36 += `?${queryString}`;
|
|
14701
14857
|
}
|
|
14702
14858
|
if (request.fragment) {
|
|
14703
|
-
|
|
14859
|
+
path36 += `#${request.fragment}`;
|
|
14704
14860
|
}
|
|
14705
14861
|
const req = session.request({
|
|
14706
14862
|
...request.headers,
|
|
14707
|
-
[http2.constants.HTTP2_HEADER_PATH]:
|
|
14863
|
+
[http2.constants.HTTP2_HEADER_PATH]: path36,
|
|
14708
14864
|
[http2.constants.HTTP2_HEADER_METHOD]: method
|
|
14709
14865
|
});
|
|
14710
14866
|
session.ref();
|
|
@@ -14891,13 +15047,13 @@ var require_dist_cjs14 = __commonJS({
|
|
|
14891
15047
|
const abortError = buildAbortError(abortSignal);
|
|
14892
15048
|
return Promise.reject(abortError);
|
|
14893
15049
|
}
|
|
14894
|
-
let
|
|
15050
|
+
let path36 = request.path;
|
|
14895
15051
|
const queryString = querystringBuilder.buildQueryString(request.query || {});
|
|
14896
15052
|
if (queryString) {
|
|
14897
|
-
|
|
15053
|
+
path36 += `?${queryString}`;
|
|
14898
15054
|
}
|
|
14899
15055
|
if (request.fragment) {
|
|
14900
|
-
|
|
15056
|
+
path36 += `#${request.fragment}`;
|
|
14901
15057
|
}
|
|
14902
15058
|
let auth = "";
|
|
14903
15059
|
if (request.username != null || request.password != null) {
|
|
@@ -14906,7 +15062,7 @@ var require_dist_cjs14 = __commonJS({
|
|
|
14906
15062
|
auth = `${username}:${password}@`;
|
|
14907
15063
|
}
|
|
14908
15064
|
const { port, method } = request;
|
|
14909
|
-
const url = `${request.protocol}//${auth}${request.hostname}${port ? `:${port}` : ""}${
|
|
15065
|
+
const url = `${request.protocol}//${auth}${request.hostname}${port ? `:${port}` : ""}${path36}`;
|
|
14910
15066
|
const body = method === "GET" || method === "HEAD" ? void 0 : request.body;
|
|
14911
15067
|
const requestOptions = {
|
|
14912
15068
|
body,
|
|
@@ -17138,13 +17294,13 @@ function __disposeResources(env2) {
|
|
|
17138
17294
|
}
|
|
17139
17295
|
return next();
|
|
17140
17296
|
}
|
|
17141
|
-
function __rewriteRelativeImportExtension(
|
|
17142
|
-
if (typeof
|
|
17143
|
-
return
|
|
17297
|
+
function __rewriteRelativeImportExtension(path36, preserveJsx) {
|
|
17298
|
+
if (typeof path36 === "string" && /^\.\.?\//.test(path36)) {
|
|
17299
|
+
return path36.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function(m7, tsx, d9, ext, cm) {
|
|
17144
17300
|
return tsx ? preserveJsx ? ".jsx" : ".js" : d9 && (!ext || !cm) ? m7 : d9 + ext + "." + cm.toLowerCase() + "js";
|
|
17145
17301
|
});
|
|
17146
17302
|
}
|
|
17147
|
-
return
|
|
17303
|
+
return path36;
|
|
17148
17304
|
}
|
|
17149
17305
|
var extendStatics, __assign, __createBinding, __setModuleDefault, ownKeys, _SuppressedError, tslib_es6_default;
|
|
17150
17306
|
var init_tslib_es6 = __esm({
|
|
@@ -18042,11 +18198,11 @@ var init_HttpBindingProtocol = __esm({
|
|
|
18042
18198
|
const opTraits = translateTraits(operationSchema.traits);
|
|
18043
18199
|
if (opTraits.http) {
|
|
18044
18200
|
request.method = opTraits.http[0];
|
|
18045
|
-
const [
|
|
18201
|
+
const [path36, search] = opTraits.http[1].split("?");
|
|
18046
18202
|
if (request.path == "/") {
|
|
18047
|
-
request.path =
|
|
18203
|
+
request.path = path36;
|
|
18048
18204
|
} else {
|
|
18049
|
-
request.path +=
|
|
18205
|
+
request.path += path36;
|
|
18050
18206
|
}
|
|
18051
18207
|
const traitSearchParams = new URLSearchParams(search ?? "");
|
|
18052
18208
|
Object.assign(query, Object.fromEntries(traitSearchParams));
|
|
@@ -18449,8 +18605,8 @@ var init_requestBuilder = __esm({
|
|
|
18449
18605
|
return this;
|
|
18450
18606
|
}
|
|
18451
18607
|
p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
|
|
18452
|
-
this.resolvePathStack.push((
|
|
18453
|
-
this.path = resolvedPath(
|
|
18608
|
+
this.resolvePathStack.push((path36) => {
|
|
18609
|
+
this.path = resolvedPath(path36, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
|
|
18454
18610
|
});
|
|
18455
18611
|
return this;
|
|
18456
18612
|
}
|
|
@@ -19100,18 +19256,18 @@ var require_dist_cjs20 = __commonJS({
|
|
|
19100
19256
|
}
|
|
19101
19257
|
};
|
|
19102
19258
|
var booleanEquals2 = (value1, value2) => value1 === value2;
|
|
19103
|
-
var getAttrPathList2 = (
|
|
19104
|
-
const parts =
|
|
19259
|
+
var getAttrPathList2 = (path36) => {
|
|
19260
|
+
const parts = path36.split(".");
|
|
19105
19261
|
const pathList = [];
|
|
19106
19262
|
for (const part of parts) {
|
|
19107
19263
|
const squareBracketIndex = part.indexOf("[");
|
|
19108
19264
|
if (squareBracketIndex !== -1) {
|
|
19109
19265
|
if (part.indexOf("]") !== part.length - 1) {
|
|
19110
|
-
throw new EndpointError2(`Path: '${
|
|
19266
|
+
throw new EndpointError2(`Path: '${path36}' does not end with ']'`);
|
|
19111
19267
|
}
|
|
19112
19268
|
const arrayIndex = part.slice(squareBracketIndex + 1, -1);
|
|
19113
19269
|
if (Number.isNaN(parseInt(arrayIndex))) {
|
|
19114
|
-
throw new EndpointError2(`Invalid array index: '${arrayIndex}' in path: '${
|
|
19270
|
+
throw new EndpointError2(`Invalid array index: '${arrayIndex}' in path: '${path36}'`);
|
|
19115
19271
|
}
|
|
19116
19272
|
if (squareBracketIndex !== 0) {
|
|
19117
19273
|
pathList.push(part.slice(0, squareBracketIndex));
|
|
@@ -19123,9 +19279,9 @@ var require_dist_cjs20 = __commonJS({
|
|
|
19123
19279
|
}
|
|
19124
19280
|
return pathList;
|
|
19125
19281
|
};
|
|
19126
|
-
var getAttr2 = (value,
|
|
19282
|
+
var getAttr2 = (value, path36) => getAttrPathList2(path36).reduce((acc, index) => {
|
|
19127
19283
|
if (typeof acc !== "object") {
|
|
19128
|
-
throw new EndpointError2(`Index '${index}' in '${
|
|
19284
|
+
throw new EndpointError2(`Index '${index}' in '${path36}' not found in '${JSON.stringify(value)}'`);
|
|
19129
19285
|
} else if (Array.isArray(acc)) {
|
|
19130
19286
|
return acc[parseInt(index)];
|
|
19131
19287
|
}
|
|
@@ -19144,8 +19300,8 @@ var require_dist_cjs20 = __commonJS({
|
|
|
19144
19300
|
return value;
|
|
19145
19301
|
}
|
|
19146
19302
|
if (typeof value === "object" && "hostname" in value) {
|
|
19147
|
-
const { hostname: hostname2, port, protocol: protocol2 = "", path:
|
|
19148
|
-
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${
|
|
19303
|
+
const { hostname: hostname2, port, protocol: protocol2 = "", path: path36 = "", query = {} } = value;
|
|
19304
|
+
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path36}`);
|
|
19149
19305
|
url.search = Object.entries(query).map(([k10, v5]) => `${k10}=${v5}`).join("&");
|
|
19150
19306
|
return url;
|
|
19151
19307
|
}
|
|
@@ -20590,10 +20746,10 @@ ${longDate}
|
|
|
20590
20746
|
${credentialScope}
|
|
20591
20747
|
${utilHexEncoding.toHex(hashedRequest)}`;
|
|
20592
20748
|
}
|
|
20593
|
-
getCanonicalPath({ path:
|
|
20749
|
+
getCanonicalPath({ path: path36 }) {
|
|
20594
20750
|
if (this.uriEscapePath) {
|
|
20595
20751
|
const normalizedPathSegments = [];
|
|
20596
|
-
for (const pathSegment of
|
|
20752
|
+
for (const pathSegment of path36.split("/")) {
|
|
20597
20753
|
if (pathSegment?.length === 0)
|
|
20598
20754
|
continue;
|
|
20599
20755
|
if (pathSegment === ".")
|
|
@@ -20604,11 +20760,11 @@ ${utilHexEncoding.toHex(hashedRequest)}`;
|
|
|
20604
20760
|
normalizedPathSegments.push(pathSegment);
|
|
20605
20761
|
}
|
|
20606
20762
|
}
|
|
20607
|
-
const normalizedPath = `${
|
|
20763
|
+
const normalizedPath = `${path36?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path36?.endsWith("/") ? "/" : ""}`;
|
|
20608
20764
|
const doubleEncoded = utilUriEscape.escapeUri(normalizedPath);
|
|
20609
20765
|
return doubleEncoded.replace(/%2F/g, "/");
|
|
20610
20766
|
}
|
|
20611
|
-
return
|
|
20767
|
+
return path36;
|
|
20612
20768
|
}
|
|
20613
20769
|
validateResolvedCredentials(credentials) {
|
|
20614
20770
|
if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
|
|
@@ -21912,11 +22068,11 @@ var init_SmithyRpcV2CborProtocol = __esm({
|
|
|
21912
22068
|
}
|
|
21913
22069
|
}
|
|
21914
22070
|
const { service, operation: operation3 } = (0, import_util_middleware5.getSmithyContext)(context);
|
|
21915
|
-
const
|
|
22071
|
+
const path36 = `/service/${service}/operation/${operation3}`;
|
|
21916
22072
|
if (request.path.endsWith("/")) {
|
|
21917
|
-
request.path +=
|
|
22073
|
+
request.path += path36.slice(1);
|
|
21918
22074
|
} else {
|
|
21919
|
-
request.path +=
|
|
22075
|
+
request.path += path36;
|
|
21920
22076
|
}
|
|
21921
22077
|
return request;
|
|
21922
22078
|
}
|
|
@@ -27561,14 +27717,14 @@ var require_readFile = __commonJS({
|
|
|
27561
27717
|
var promises_1 = __require("node:fs/promises");
|
|
27562
27718
|
exports.filePromises = {};
|
|
27563
27719
|
exports.fileIntercept = {};
|
|
27564
|
-
var readFile3 = (
|
|
27565
|
-
if (exports.fileIntercept[
|
|
27566
|
-
return exports.fileIntercept[
|
|
27720
|
+
var readFile3 = (path36, options) => {
|
|
27721
|
+
if (exports.fileIntercept[path36] !== void 0) {
|
|
27722
|
+
return exports.fileIntercept[path36];
|
|
27567
27723
|
}
|
|
27568
|
-
if (!exports.filePromises[
|
|
27569
|
-
exports.filePromises[
|
|
27724
|
+
if (!exports.filePromises[path36] || options?.ignoreCache) {
|
|
27725
|
+
exports.filePromises[path36] = (0, promises_1.readFile)(path36, "utf8");
|
|
27570
27726
|
}
|
|
27571
|
-
return exports.filePromises[
|
|
27727
|
+
return exports.filePromises[path36];
|
|
27572
27728
|
};
|
|
27573
27729
|
exports.readFile = readFile3;
|
|
27574
27730
|
}
|
|
@@ -27581,7 +27737,7 @@ var require_dist_cjs33 = __commonJS({
|
|
|
27581
27737
|
var getHomeDir2 = require_getHomeDir();
|
|
27582
27738
|
var getSSOTokenFilepath2 = require_getSSOTokenFilepath();
|
|
27583
27739
|
var getSSOTokenFromFile2 = require_getSSOTokenFromFile();
|
|
27584
|
-
var
|
|
27740
|
+
var path36 = __require("path");
|
|
27585
27741
|
var types = require_dist_cjs();
|
|
27586
27742
|
var readFile3 = require_readFile();
|
|
27587
27743
|
var ENV_PROFILE2 = "AWS_PROFILE";
|
|
@@ -27603,9 +27759,9 @@ var require_dist_cjs33 = __commonJS({
|
|
|
27603
27759
|
...data3.default && { default: data3.default }
|
|
27604
27760
|
});
|
|
27605
27761
|
var ENV_CONFIG_PATH2 = "AWS_CONFIG_FILE";
|
|
27606
|
-
var getConfigFilepath2 = () => process.env[ENV_CONFIG_PATH2] ||
|
|
27762
|
+
var getConfigFilepath2 = () => process.env[ENV_CONFIG_PATH2] || path36.join(getHomeDir2.getHomeDir(), ".aws", "config");
|
|
27607
27763
|
var ENV_CREDENTIALS_PATH2 = "AWS_SHARED_CREDENTIALS_FILE";
|
|
27608
|
-
var getCredentialsFilepath2 = () => process.env[ENV_CREDENTIALS_PATH2] ||
|
|
27764
|
+
var getCredentialsFilepath2 = () => process.env[ENV_CREDENTIALS_PATH2] || path36.join(getHomeDir2.getHomeDir(), ".aws", "credentials");
|
|
27609
27765
|
var prefixKeyRegex2 = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
|
|
27610
27766
|
var profileNameBlockList2 = ["__proto__", "profile __proto__"];
|
|
27611
27767
|
var parseIni2 = (iniData) => {
|
|
@@ -27660,11 +27816,11 @@ var require_dist_cjs33 = __commonJS({
|
|
|
27660
27816
|
const relativeHomeDirPrefix = "~/";
|
|
27661
27817
|
let resolvedFilepath = filepath;
|
|
27662
27818
|
if (filepath.startsWith(relativeHomeDirPrefix)) {
|
|
27663
|
-
resolvedFilepath =
|
|
27819
|
+
resolvedFilepath = path36.join(homeDir, filepath.slice(2));
|
|
27664
27820
|
}
|
|
27665
27821
|
let resolvedConfigFilepath = configFilepath;
|
|
27666
27822
|
if (configFilepath.startsWith(relativeHomeDirPrefix)) {
|
|
27667
|
-
resolvedConfigFilepath =
|
|
27823
|
+
resolvedConfigFilepath = path36.join(homeDir, configFilepath.slice(2));
|
|
27668
27824
|
}
|
|
27669
27825
|
const parsedFiles = await Promise.all([
|
|
27670
27826
|
readFile3.readFile(resolvedConfigFilepath, {
|
|
@@ -27703,8 +27859,8 @@ var require_dist_cjs33 = __commonJS({
|
|
|
27703
27859
|
getFileRecord() {
|
|
27704
27860
|
return readFile3.fileIntercept;
|
|
27705
27861
|
},
|
|
27706
|
-
interceptFile(
|
|
27707
|
-
readFile3.fileIntercept[
|
|
27862
|
+
interceptFile(path37, contents) {
|
|
27863
|
+
readFile3.fileIntercept[path37] = Promise.resolve(contents);
|
|
27708
27864
|
},
|
|
27709
27865
|
getTokenRecord() {
|
|
27710
27866
|
return getSSOTokenFromFile2.tokenIntercept;
|
|
@@ -28029,8 +28185,8 @@ var require_dist_cjs36 = __commonJS({
|
|
|
28029
28185
|
return endpoint.url.href;
|
|
28030
28186
|
}
|
|
28031
28187
|
if ("hostname" in endpoint) {
|
|
28032
|
-
const { protocol, hostname, port, path:
|
|
28033
|
-
return `${protocol}//${hostname}${port ? ":" + port : ""}${
|
|
28188
|
+
const { protocol, hostname, port, path: path36 } = endpoint;
|
|
28189
|
+
return `${protocol}//${hostname}${port ? ":" + port : ""}${path36}`;
|
|
28034
28190
|
}
|
|
28035
28191
|
}
|
|
28036
28192
|
return endpoint;
|
|
@@ -38064,14 +38220,14 @@ var init_readFile = __esm({
|
|
|
38064
38220
|
"../../node_modules/.pnpm/@smithy+core@3.29.7/node_modules/@smithy/core/dist-es/submodules/config/shared-ini-file-loader/readFile.js"() {
|
|
38065
38221
|
filePromises = {};
|
|
38066
38222
|
fileIntercept = {};
|
|
38067
|
-
readFile2 = (
|
|
38068
|
-
if (fileIntercept[
|
|
38069
|
-
return fileIntercept[
|
|
38223
|
+
readFile2 = (path36, options) => {
|
|
38224
|
+
if (fileIntercept[path36] !== void 0) {
|
|
38225
|
+
return fileIntercept[path36];
|
|
38070
38226
|
}
|
|
38071
|
-
if (!filePromises[
|
|
38072
|
-
filePromises[
|
|
38227
|
+
if (!filePromises[path36] || options?.ignoreCache) {
|
|
38228
|
+
filePromises[path36] = fsReadFile(path36, "utf8");
|
|
38073
38229
|
}
|
|
38074
|
-
return filePromises[
|
|
38230
|
+
return filePromises[path36];
|
|
38075
38231
|
};
|
|
38076
38232
|
}
|
|
38077
38233
|
});
|
|
@@ -38183,8 +38339,8 @@ var init_externalDataInterceptor = __esm({
|
|
|
38183
38339
|
getFileRecord() {
|
|
38184
38340
|
return fileIntercept;
|
|
38185
38341
|
},
|
|
38186
|
-
interceptFile(
|
|
38187
|
-
fileIntercept[
|
|
38342
|
+
interceptFile(path36, contents) {
|
|
38343
|
+
fileIntercept[path36] = Promise.resolve(contents);
|
|
38188
38344
|
},
|
|
38189
38345
|
getTokenRecord() {
|
|
38190
38346
|
return tokenIntercept;
|
|
@@ -41118,8 +41274,8 @@ var init_createConfigValueProvider = __esm({
|
|
|
41118
41274
|
return endpoint.url.href;
|
|
41119
41275
|
}
|
|
41120
41276
|
if ("hostname" in endpoint) {
|
|
41121
|
-
const { protocol, hostname, port, path:
|
|
41122
|
-
return `${protocol}//${hostname}${port ? ":" + port : ""}${
|
|
41277
|
+
const { protocol, hostname, port, path: path36 } = endpoint;
|
|
41278
|
+
return `${protocol}//${hostname}${port ? ":" + port : ""}${path36}`;
|
|
41123
41279
|
}
|
|
41124
41280
|
}
|
|
41125
41281
|
return endpoint;
|
|
@@ -41494,18 +41650,18 @@ var getAttrPathList;
|
|
|
41494
41650
|
var init_getAttrPathList = __esm({
|
|
41495
41651
|
"../../node_modules/.pnpm/@smithy+core@3.29.7/node_modules/@smithy/core/dist-es/submodules/endpoints/util-endpoints/lib/getAttrPathList.js"() {
|
|
41496
41652
|
init_types4();
|
|
41497
|
-
getAttrPathList = (
|
|
41498
|
-
const parts =
|
|
41653
|
+
getAttrPathList = (path36) => {
|
|
41654
|
+
const parts = path36.split(".");
|
|
41499
41655
|
const pathList = [];
|
|
41500
41656
|
for (const part of parts) {
|
|
41501
41657
|
const squareBracketIndex = part.indexOf("[");
|
|
41502
41658
|
if (squareBracketIndex !== -1) {
|
|
41503
41659
|
if (part.indexOf("]") !== part.length - 1) {
|
|
41504
|
-
throw new EndpointError(`Path: '${
|
|
41660
|
+
throw new EndpointError(`Path: '${path36}' does not end with ']'`);
|
|
41505
41661
|
}
|
|
41506
41662
|
const arrayIndex = part.slice(squareBracketIndex + 1, -1);
|
|
41507
41663
|
if (Number.isNaN(parseInt(arrayIndex))) {
|
|
41508
|
-
throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${
|
|
41664
|
+
throw new EndpointError(`Invalid array index: '${arrayIndex}' in path: '${path36}'`);
|
|
41509
41665
|
}
|
|
41510
41666
|
if (squareBracketIndex !== 0) {
|
|
41511
41667
|
pathList.push(part.slice(0, squareBracketIndex));
|
|
@@ -41526,9 +41682,9 @@ var init_getAttr = __esm({
|
|
|
41526
41682
|
"../../node_modules/.pnpm/@smithy+core@3.29.7/node_modules/@smithy/core/dist-es/submodules/endpoints/util-endpoints/lib/getAttr.js"() {
|
|
41527
41683
|
init_types4();
|
|
41528
41684
|
init_getAttrPathList();
|
|
41529
|
-
getAttr = (value,
|
|
41685
|
+
getAttr = (value, path36) => getAttrPathList(path36).reduce((acc, index) => {
|
|
41530
41686
|
if (typeof acc !== "object") {
|
|
41531
|
-
throw new EndpointError(`Index '${index}' in '${
|
|
41687
|
+
throw new EndpointError(`Index '${index}' in '${path36}' not found in '${JSON.stringify(value)}'`);
|
|
41532
41688
|
} else if (Array.isArray(acc)) {
|
|
41533
41689
|
const i10 = parseInt(index);
|
|
41534
41690
|
return acc[i10 < 0 ? acc.length + i10 : i10];
|
|
@@ -41589,8 +41745,8 @@ var init_parseURL = __esm({
|
|
|
41589
41745
|
return value;
|
|
41590
41746
|
}
|
|
41591
41747
|
if (typeof value === "object" && "hostname" in value) {
|
|
41592
|
-
const { hostname: hostname2, port, protocol: protocol2 = "", path:
|
|
41593
|
-
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${
|
|
41748
|
+
const { hostname: hostname2, port, protocol: protocol2 = "", path: path36 = "", query = {} } = value;
|
|
41749
|
+
const url = new URL(`${protocol2}//${hostname2}${port ? `:${port}` : ""}${path36}`);
|
|
41594
41750
|
url.search = Object.entries(query).map(([k10, v5]) => `${k10}=${v5}`).join("&");
|
|
41595
41751
|
return url;
|
|
41596
41752
|
}
|
|
@@ -44827,11 +44983,11 @@ var init_HttpBindingProtocol2 = __esm({
|
|
|
44827
44983
|
const opTraits = translateTraits2(operationSchema.traits);
|
|
44828
44984
|
if (opTraits.http) {
|
|
44829
44985
|
request.method = opTraits.http[0];
|
|
44830
|
-
const [
|
|
44986
|
+
const [path36, search] = opTraits.http[1].split("?");
|
|
44831
44987
|
if (request.path == "/") {
|
|
44832
|
-
request.path =
|
|
44988
|
+
request.path = path36;
|
|
44833
44989
|
} else {
|
|
44834
|
-
request.path +=
|
|
44990
|
+
request.path += path36;
|
|
44835
44991
|
}
|
|
44836
44992
|
const traitSearchParams = new URLSearchParams(search ?? "");
|
|
44837
44993
|
for (const [key, value] of traitSearchParams) {
|
|
@@ -45232,8 +45388,8 @@ var init_requestBuilder3 = __esm({
|
|
|
45232
45388
|
return this;
|
|
45233
45389
|
}
|
|
45234
45390
|
p(memberName, labelValueProvider, uriLabel, isGreedyLabel) {
|
|
45235
|
-
this.resolvePathStack.push((
|
|
45236
|
-
this.path = resolvedPath2(
|
|
45391
|
+
this.resolvePathStack.push((path36) => {
|
|
45392
|
+
this.path = resolvedPath2(path36, this.input, memberName, labelValueProvider, uriLabel, isGreedyLabel);
|
|
45237
45393
|
});
|
|
45238
45394
|
return this;
|
|
45239
45395
|
}
|
|
@@ -45872,9 +46028,9 @@ var init_createPaginator2 = __esm({
|
|
|
45872
46028
|
command5 = withCommand(command5) ?? command5;
|
|
45873
46029
|
return await client.send(command5, ...args);
|
|
45874
46030
|
};
|
|
45875
|
-
get2 = (fromObject,
|
|
46031
|
+
get2 = (fromObject, path36) => {
|
|
45876
46032
|
let cursor3 = fromObject;
|
|
45877
|
-
const pathComponents =
|
|
46033
|
+
const pathComponents = path36.split(".");
|
|
45878
46034
|
for (const step of pathComponents) {
|
|
45879
46035
|
if (!cursor3 || typeof cursor3 !== "object") {
|
|
45880
46036
|
return void 0;
|
|
@@ -49445,10 +49601,10 @@ ${longDate}
|
|
|
49445
49601
|
${credentialScope}
|
|
49446
49602
|
${toHex2(hashedRequest)}`;
|
|
49447
49603
|
}
|
|
49448
|
-
getCanonicalPath({ path:
|
|
49604
|
+
getCanonicalPath({ path: path36 }) {
|
|
49449
49605
|
if (this.uriEscapePath) {
|
|
49450
49606
|
const normalizedPathSegments = [];
|
|
49451
|
-
for (const pathSegment of
|
|
49607
|
+
for (const pathSegment of path36.split("/")) {
|
|
49452
49608
|
if (pathSegment?.length === 0)
|
|
49453
49609
|
continue;
|
|
49454
49610
|
if (pathSegment === ".")
|
|
@@ -49459,11 +49615,11 @@ ${toHex2(hashedRequest)}`;
|
|
|
49459
49615
|
normalizedPathSegments.push(pathSegment);
|
|
49460
49616
|
}
|
|
49461
49617
|
}
|
|
49462
|
-
const normalizedPath = `${
|
|
49618
|
+
const normalizedPath = `${path36?.startsWith("/") ? "/" : ""}${normalizedPathSegments.join("/")}${normalizedPathSegments.length > 0 && path36?.endsWith("/") ? "/" : ""}`;
|
|
49463
49619
|
const doubleEncoded = escapeUri2(normalizedPath);
|
|
49464
49620
|
return doubleEncoded.replace(/%2F/g, "/");
|
|
49465
49621
|
}
|
|
49466
|
-
return
|
|
49622
|
+
return path36;
|
|
49467
49623
|
}
|
|
49468
49624
|
validateResolvedCredentials(credentials) {
|
|
49469
49625
|
if (typeof credentials !== "object" || typeof credentials.accessKeyId !== "string" || typeof credentials.secretAccessKey !== "string") {
|
|
@@ -51032,11 +51188,11 @@ var init_SmithyRpcV2CborProtocol2 = __esm({
|
|
|
51032
51188
|
}
|
|
51033
51189
|
}
|
|
51034
51190
|
const { service, operation: operation3 } = getSmithyContext11(context);
|
|
51035
|
-
const
|
|
51191
|
+
const path36 = `/service/${service}/operation/${operation3}`;
|
|
51036
51192
|
if (request.path.endsWith("/")) {
|
|
51037
|
-
request.path +=
|
|
51193
|
+
request.path += path36.slice(1);
|
|
51038
51194
|
} else {
|
|
51039
|
-
request.path +=
|
|
51195
|
+
request.path += path36;
|
|
51040
51196
|
}
|
|
51041
51197
|
return request;
|
|
51042
51198
|
}
|
|
@@ -54440,12 +54596,12 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
54440
54596
|
const password = request.password ?? "";
|
|
54441
54597
|
auth = `${username}:${password}`;
|
|
54442
54598
|
}
|
|
54443
|
-
let
|
|
54599
|
+
let path36 = request.path;
|
|
54444
54600
|
if (queryString) {
|
|
54445
|
-
|
|
54601
|
+
path36 += `?${queryString}`;
|
|
54446
54602
|
}
|
|
54447
54603
|
if (request.fragment) {
|
|
54448
|
-
|
|
54604
|
+
path36 += `#${request.fragment}`;
|
|
54449
54605
|
}
|
|
54450
54606
|
let hostname = request.hostname ?? "";
|
|
54451
54607
|
if (hostname[0] === "[" && hostname.endsWith("]")) {
|
|
@@ -54457,7 +54613,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
54457
54613
|
headers: request.headers,
|
|
54458
54614
|
host: hostname,
|
|
54459
54615
|
method: request.method,
|
|
54460
|
-
path:
|
|
54616
|
+
path: path36,
|
|
54461
54617
|
port: request.port,
|
|
54462
54618
|
agent,
|
|
54463
54619
|
auth
|
|
@@ -54860,16 +55016,16 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
54860
55016
|
reject(err);
|
|
54861
55017
|
};
|
|
54862
55018
|
const queryString = query ? buildQueryString2(query) : "";
|
|
54863
|
-
let
|
|
55019
|
+
let path36 = request.path;
|
|
54864
55020
|
if (queryString) {
|
|
54865
|
-
|
|
55021
|
+
path36 += `?${queryString}`;
|
|
54866
55022
|
}
|
|
54867
55023
|
if (request.fragment) {
|
|
54868
|
-
|
|
55024
|
+
path36 += `#${request.fragment}`;
|
|
54869
55025
|
}
|
|
54870
55026
|
const clientHttp2Stream = session.request({
|
|
54871
55027
|
...request.headers,
|
|
54872
|
-
[constants2.HTTP2_HEADER_PATH]:
|
|
55028
|
+
[constants2.HTTP2_HEADER_PATH]: path36,
|
|
54873
55029
|
[constants2.HTTP2_HEADER_METHOD]: method
|
|
54874
55030
|
});
|
|
54875
55031
|
if (effectiveRequestTimeout) {
|
|
@@ -54951,7 +55107,7 @@ var require_dist_cjs60 = __commonJS({
|
|
|
54951
55107
|
var { setCredentialFeature: setCredentialFeature3 } = (init_client4(), __toCommonJS(client_exports3));
|
|
54952
55108
|
var { CredentialsProviderError: CredentialsProviderError2 } = (init_config3(), __toCommonJS(config_exports));
|
|
54953
55109
|
var { NodeHttpHandler } = require_dist_cjs59();
|
|
54954
|
-
var
|
|
55110
|
+
var fs33 = __require("node:fs/promises");
|
|
54955
55111
|
var { HttpRequest: HttpRequest11 } = (init_protocols3(), __toCommonJS(protocols_exports3));
|
|
54956
55112
|
var { sdkStreamMixin: sdkStreamMixin4, parseRfc3339DateTime: parseRfc3339DateTime3 } = (init_serde2(), __toCommonJS(serde_exports2));
|
|
54957
55113
|
var ECS_CONTAINER_HOST = "169.254.170.2";
|
|
@@ -55075,7 +55231,7 @@ Set AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI
|
|
|
55075
55231
|
const provider = retryWrapper(async () => {
|
|
55076
55232
|
const request = createGetRequest(url);
|
|
55077
55233
|
if (tokenFile) {
|
|
55078
|
-
request.headers.Authorization = validateToken((await
|
|
55234
|
+
request.headers.Authorization = validateToken((await fs33.readFile(tokenFile)).toString());
|
|
55079
55235
|
} else if (token) {
|
|
55080
55236
|
request.headers.Authorization = validateToken(token);
|
|
55081
55237
|
}
|
|
@@ -69212,7 +69368,7 @@ var require_truncate = __commonJS({
|
|
|
69212
69368
|
var require_lrucache = __commonJS({
|
|
69213
69369
|
"../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/lrucache.js"(exports, module) {
|
|
69214
69370
|
"use strict";
|
|
69215
|
-
var
|
|
69371
|
+
var LRUCache2 = class {
|
|
69216
69372
|
constructor() {
|
|
69217
69373
|
this.max = 1e3;
|
|
69218
69374
|
this.map = /* @__PURE__ */ new Map();
|
|
@@ -69242,7 +69398,7 @@ var require_lrucache = __commonJS({
|
|
|
69242
69398
|
return this;
|
|
69243
69399
|
}
|
|
69244
69400
|
};
|
|
69245
|
-
module.exports =
|
|
69401
|
+
module.exports = LRUCache2;
|
|
69246
69402
|
}
|
|
69247
69403
|
});
|
|
69248
69404
|
|
|
@@ -71318,16 +71474,16 @@ var require_commonjs = __commonJS({
|
|
|
71318
71474
|
"use strict";
|
|
71319
71475
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71320
71476
|
exports.LRUCache = void 0;
|
|
71321
|
-
var
|
|
71322
|
-
var
|
|
71323
|
-
var
|
|
71324
|
-
var
|
|
71325
|
-
typeof
|
|
71326
|
-
};
|
|
71327
|
-
var
|
|
71328
|
-
var
|
|
71329
|
-
if (typeof
|
|
71330
|
-
|
|
71477
|
+
var perf2 = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
|
|
71478
|
+
var warned3 = /* @__PURE__ */ new Set();
|
|
71479
|
+
var PROCESS2 = typeof process === "object" && !!process ? process : {};
|
|
71480
|
+
var emitWarning2 = (msg, type, code, fn) => {
|
|
71481
|
+
typeof PROCESS2.emitWarning === "function" ? PROCESS2.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
71482
|
+
};
|
|
71483
|
+
var AC2 = globalThis.AbortController;
|
|
71484
|
+
var AS2 = globalThis.AbortSignal;
|
|
71485
|
+
if (typeof AC2 === "undefined") {
|
|
71486
|
+
AS2 = class AbortSignal {
|
|
71331
71487
|
onabort;
|
|
71332
71488
|
_onabort = [];
|
|
71333
71489
|
reason;
|
|
@@ -71336,11 +71492,11 @@ var require_commonjs = __commonJS({
|
|
|
71336
71492
|
this._onabort.push(fn);
|
|
71337
71493
|
}
|
|
71338
71494
|
};
|
|
71339
|
-
|
|
71495
|
+
AC2 = class AbortController {
|
|
71340
71496
|
constructor() {
|
|
71341
71497
|
warnACPolyfill();
|
|
71342
71498
|
}
|
|
71343
|
-
signal = new
|
|
71499
|
+
signal = new AS2();
|
|
71344
71500
|
abort(reason) {
|
|
71345
71501
|
if (this.signal.aborted)
|
|
71346
71502
|
return;
|
|
@@ -71352,16 +71508,16 @@ var require_commonjs = __commonJS({
|
|
|
71352
71508
|
this.signal.onabort?.(reason);
|
|
71353
71509
|
}
|
|
71354
71510
|
};
|
|
71355
|
-
let printACPolyfillWarning =
|
|
71511
|
+
let printACPolyfillWarning = PROCESS2.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
|
|
71356
71512
|
const warnACPolyfill = () => {
|
|
71357
71513
|
if (!printACPolyfillWarning)
|
|
71358
71514
|
return;
|
|
71359
71515
|
printACPolyfillWarning = false;
|
|
71360
|
-
|
|
71516
|
+
emitWarning2("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill);
|
|
71361
71517
|
};
|
|
71362
71518
|
}
|
|
71363
|
-
var shouldWarn = (code) => !
|
|
71364
|
-
var
|
|
71519
|
+
var shouldWarn = (code) => !warned3.has(code);
|
|
71520
|
+
var TYPE2 = Symbol("type");
|
|
71365
71521
|
var isPosInt = (n7) => n7 && n7 === Math.floor(n7) && n7 > 0 && isFinite(n7);
|
|
71366
71522
|
var getUintArray = (max) => !isPosInt(max) ? null : max <= Math.pow(2, 8) ? Uint8Array : max <= Math.pow(2, 16) ? Uint16Array : max <= Math.pow(2, 32) ? Uint32Array : max <= Number.MAX_SAFE_INTEGER ? ZeroArray : null;
|
|
71367
71523
|
var ZeroArray = class extends Array {
|
|
@@ -71398,7 +71554,7 @@ var require_commonjs = __commonJS({
|
|
|
71398
71554
|
return this.heap[--this.length];
|
|
71399
71555
|
}
|
|
71400
71556
|
};
|
|
71401
|
-
var
|
|
71557
|
+
var LRUCache2 = class _LRUCache {
|
|
71402
71558
|
// options that cannot be changed without disaster
|
|
71403
71559
|
#max;
|
|
71404
71560
|
#maxSize;
|
|
@@ -71654,9 +71810,9 @@ var require_commonjs = __commonJS({
|
|
|
71654
71810
|
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
|
71655
71811
|
const code = "LRU_CACHE_UNBOUNDED";
|
|
71656
71812
|
if (shouldWarn(code)) {
|
|
71657
|
-
|
|
71813
|
+
warned3.add(code);
|
|
71658
71814
|
const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
|
|
71659
|
-
|
|
71815
|
+
emitWarning2(msg, "UnboundedCacheWarning", code, _LRUCache);
|
|
71660
71816
|
}
|
|
71661
71817
|
}
|
|
71662
71818
|
}
|
|
@@ -71672,7 +71828,7 @@ var require_commonjs = __commonJS({
|
|
|
71672
71828
|
const starts = new ZeroArray(this.#max);
|
|
71673
71829
|
this.#ttls = ttls;
|
|
71674
71830
|
this.#starts = starts;
|
|
71675
|
-
this.#setItemTTL = (index, ttl, start =
|
|
71831
|
+
this.#setItemTTL = (index, ttl, start = perf2.now()) => {
|
|
71676
71832
|
starts[index] = ttl !== 0 ? start : 0;
|
|
71677
71833
|
ttls[index] = ttl;
|
|
71678
71834
|
if (ttl !== 0 && this.ttlAutopurge) {
|
|
@@ -71687,7 +71843,7 @@ var require_commonjs = __commonJS({
|
|
|
71687
71843
|
}
|
|
71688
71844
|
};
|
|
71689
71845
|
this.#updateItemAge = (index) => {
|
|
71690
|
-
starts[index] = ttls[index] !== 0 ?
|
|
71846
|
+
starts[index] = ttls[index] !== 0 ? perf2.now() : 0;
|
|
71691
71847
|
};
|
|
71692
71848
|
this.#statusTTL = (status, index) => {
|
|
71693
71849
|
if (ttls[index]) {
|
|
@@ -71704,7 +71860,7 @@ var require_commonjs = __commonJS({
|
|
|
71704
71860
|
};
|
|
71705
71861
|
let cachedNow = 0;
|
|
71706
71862
|
const getNow = () => {
|
|
71707
|
-
const n7 =
|
|
71863
|
+
const n7 = perf2.now();
|
|
71708
71864
|
if (this.ttlResolution > 0) {
|
|
71709
71865
|
cachedNow = n7;
|
|
71710
71866
|
const t6 = setTimeout(() => cachedNow = 0, this.ttlResolution);
|
|
@@ -72007,7 +72163,7 @@ var require_commonjs = __commonJS({
|
|
|
72007
72163
|
const ttl = this.#ttls[i10];
|
|
72008
72164
|
const start = this.#starts[i10];
|
|
72009
72165
|
if (ttl && start) {
|
|
72010
|
-
const remain = ttl - (
|
|
72166
|
+
const remain = ttl - (perf2.now() - start);
|
|
72011
72167
|
entry.ttl = remain;
|
|
72012
72168
|
entry.start = Date.now();
|
|
72013
72169
|
}
|
|
@@ -72041,7 +72197,7 @@ var require_commonjs = __commonJS({
|
|
|
72041
72197
|
const entry = { value };
|
|
72042
72198
|
if (this.#ttls && this.#starts) {
|
|
72043
72199
|
entry.ttl = this.#ttls[i10];
|
|
72044
|
-
const age =
|
|
72200
|
+
const age = perf2.now() - this.#starts[i10];
|
|
72045
72201
|
entry.start = Math.floor(Date.now() - age);
|
|
72046
72202
|
}
|
|
72047
72203
|
if (this.#sizes) {
|
|
@@ -72065,7 +72221,7 @@ var require_commonjs = __commonJS({
|
|
|
72065
72221
|
for (const [key, entry] of arr) {
|
|
72066
72222
|
if (entry.start) {
|
|
72067
72223
|
const age = Date.now() - entry.start;
|
|
72068
|
-
entry.start =
|
|
72224
|
+
entry.start = perf2.now() - age;
|
|
72069
72225
|
}
|
|
72070
72226
|
this.set(key, entry.value, entry);
|
|
72071
72227
|
}
|
|
@@ -72305,7 +72461,7 @@ var require_commonjs = __commonJS({
|
|
|
72305
72461
|
if (this.#isBackgroundFetch(v5)) {
|
|
72306
72462
|
return v5;
|
|
72307
72463
|
}
|
|
72308
|
-
const ac = new
|
|
72464
|
+
const ac = new AC2();
|
|
72309
72465
|
const { signal } = options;
|
|
72310
72466
|
signal?.addEventListener("abort", () => ac.abort(signal.reason), {
|
|
72311
72467
|
signal: ac.signal
|
|
@@ -72411,7 +72567,7 @@ var require_commonjs = __commonJS({
|
|
|
72411
72567
|
if (!this.#hasFetchMethod)
|
|
72412
72568
|
return false;
|
|
72413
72569
|
const b10 = p8;
|
|
72414
|
-
return !!b10 && b10 instanceof Promise && b10.hasOwnProperty("__staleWhileFetching") && b10.__abortController instanceof
|
|
72570
|
+
return !!b10 && b10 instanceof Promise && b10.hasOwnProperty("__staleWhileFetching") && b10.__abortController instanceof AC2;
|
|
72415
72571
|
}
|
|
72416
72572
|
async fetch(k10, fetchOptions = {}) {
|
|
72417
72573
|
const {
|
|
@@ -72685,7 +72841,7 @@ var require_commonjs = __commonJS({
|
|
|
72685
72841
|
}
|
|
72686
72842
|
}
|
|
72687
72843
|
};
|
|
72688
|
-
exports.LRUCache =
|
|
72844
|
+
exports.LRUCache = LRUCache2;
|
|
72689
72845
|
}
|
|
72690
72846
|
});
|
|
72691
72847
|
|
|
@@ -72759,9 +72915,9 @@ var require_dist_node20 = __commonJS({
|
|
|
72759
72915
|
}
|
|
72760
72916
|
}
|
|
72761
72917
|
}
|
|
72762
|
-
var
|
|
72918
|
+
var import_lru_cache2 = require_commonjs();
|
|
72763
72919
|
function getCache() {
|
|
72764
|
-
return new
|
|
72920
|
+
return new import_lru_cache2.LRUCache({
|
|
72765
72921
|
// cache max. 15000 tokens, that will use less than 10mb memory
|
|
72766
72922
|
max: 15e3,
|
|
72767
72923
|
// Cache for 1 minute less than GitHub expiry
|
|
@@ -73157,9 +73313,9 @@ var require_dist_node20 = __commonJS({
|
|
|
73157
73313
|
// ../canopycms/src/worker/cms-worker.ts
|
|
73158
73314
|
var import_proper_lockfile3 = __toESM(require_proper_lockfile(), 1);
|
|
73159
73315
|
import { createHash as createHash2 } from "node:crypto";
|
|
73160
|
-
import
|
|
73316
|
+
import fs31 from "node:fs/promises";
|
|
73161
73317
|
import os from "node:os";
|
|
73162
|
-
import
|
|
73318
|
+
import path33 from "node:path";
|
|
73163
73319
|
|
|
73164
73320
|
// ../canopycms/src/utils/debug.ts
|
|
73165
73321
|
var envFlag = (name2) => typeof process !== "undefined" && process.env[name2] === "true";
|
|
@@ -74344,8 +74500,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
74344
74500
|
function forEachLineWithContent(input, callback) {
|
|
74345
74501
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
74346
74502
|
}
|
|
74347
|
-
function folderExists(
|
|
74348
|
-
return (0, import_file_exists.exists)(
|
|
74503
|
+
function folderExists(path36) {
|
|
74504
|
+
return (0, import_file_exists.exists)(path36, import_file_exists.FOLDER);
|
|
74349
74505
|
}
|
|
74350
74506
|
function append(target, item) {
|
|
74351
74507
|
if (Array.isArray(target)) {
|
|
@@ -74747,8 +74903,8 @@ function checkIsRepoRootTask() {
|
|
|
74747
74903
|
commands: commands9,
|
|
74748
74904
|
format: "utf-8",
|
|
74749
74905
|
onError,
|
|
74750
|
-
parser(
|
|
74751
|
-
return /^\.(git)?$/.test(
|
|
74906
|
+
parser(path36) {
|
|
74907
|
+
return /^\.(git)?$/.test(path36.trim());
|
|
74752
74908
|
}
|
|
74753
74909
|
};
|
|
74754
74910
|
}
|
|
@@ -75182,11 +75338,11 @@ function parseGrep(grep) {
|
|
|
75182
75338
|
const paths = /* @__PURE__ */ new Set();
|
|
75183
75339
|
const results = {};
|
|
75184
75340
|
forEachLineWithContent(grep, (input) => {
|
|
75185
|
-
const [
|
|
75186
|
-
paths.add(
|
|
75187
|
-
(results[
|
|
75341
|
+
const [path36, line, preview] = input.split(NULL);
|
|
75342
|
+
paths.add(path36);
|
|
75343
|
+
(results[path36] = results[path36] || []).push({
|
|
75188
75344
|
line: asNumber(line),
|
|
75189
|
-
path:
|
|
75345
|
+
path: path36,
|
|
75190
75346
|
preview
|
|
75191
75347
|
});
|
|
75192
75348
|
});
|
|
@@ -75950,14 +76106,14 @@ var init_hash_object = __esm2({
|
|
|
75950
76106
|
init_task();
|
|
75951
76107
|
}
|
|
75952
76108
|
});
|
|
75953
|
-
function parseInit(bare,
|
|
76109
|
+
function parseInit(bare, path36, text) {
|
|
75954
76110
|
const response = String(text).trim();
|
|
75955
76111
|
let result;
|
|
75956
76112
|
if (result = initResponseRegex.exec(response)) {
|
|
75957
|
-
return new InitSummary(bare,
|
|
76113
|
+
return new InitSummary(bare, path36, false, result[1]);
|
|
75958
76114
|
}
|
|
75959
76115
|
if (result = reInitResponseRegex.exec(response)) {
|
|
75960
|
-
return new InitSummary(bare,
|
|
76116
|
+
return new InitSummary(bare, path36, true, result[1]);
|
|
75961
76117
|
}
|
|
75962
76118
|
let gitDir = "";
|
|
75963
76119
|
const tokens = response.split(" ");
|
|
@@ -75968,7 +76124,7 @@ function parseInit(bare, path35, text) {
|
|
|
75968
76124
|
break;
|
|
75969
76125
|
}
|
|
75970
76126
|
}
|
|
75971
|
-
return new InitSummary(bare,
|
|
76127
|
+
return new InitSummary(bare, path36, /^re/i.test(response), gitDir);
|
|
75972
76128
|
}
|
|
75973
76129
|
var InitSummary;
|
|
75974
76130
|
var initResponseRegex;
|
|
@@ -75977,9 +76133,9 @@ var init_InitSummary = __esm2({
|
|
|
75977
76133
|
"src/lib/responses/InitSummary.ts"() {
|
|
75978
76134
|
"use strict";
|
|
75979
76135
|
InitSummary = class {
|
|
75980
|
-
constructor(bare,
|
|
76136
|
+
constructor(bare, path36, existing, gitDir) {
|
|
75981
76137
|
this.bare = bare;
|
|
75982
|
-
this.path =
|
|
76138
|
+
this.path = path36;
|
|
75983
76139
|
this.existing = existing;
|
|
75984
76140
|
this.gitDir = gitDir;
|
|
75985
76141
|
}
|
|
@@ -75991,7 +76147,7 @@ var init_InitSummary = __esm2({
|
|
|
75991
76147
|
function hasBareCommand(command5) {
|
|
75992
76148
|
return command5.includes(bareCommand);
|
|
75993
76149
|
}
|
|
75994
|
-
function initTask(bare = false,
|
|
76150
|
+
function initTask(bare = false, path36, customArgs) {
|
|
75995
76151
|
const commands9 = ["init", ...customArgs];
|
|
75996
76152
|
if (bare && !hasBareCommand(commands9)) {
|
|
75997
76153
|
commands9.splice(1, 0, bareCommand);
|
|
@@ -76000,7 +76156,7 @@ function initTask(bare = false, path35, customArgs) {
|
|
|
76000
76156
|
commands: commands9,
|
|
76001
76157
|
format: "utf-8",
|
|
76002
76158
|
parser(text) {
|
|
76003
|
-
return parseInit(commands9.includes("--bare"),
|
|
76159
|
+
return parseInit(commands9.includes("--bare"), path36, text);
|
|
76004
76160
|
}
|
|
76005
76161
|
};
|
|
76006
76162
|
}
|
|
@@ -76815,12 +76971,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
76815
76971
|
"use strict";
|
|
76816
76972
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
76817
76973
|
FileStatusSummary = class {
|
|
76818
|
-
constructor(
|
|
76819
|
-
this.path =
|
|
76974
|
+
constructor(path36, index, working_dir) {
|
|
76975
|
+
this.path = path36;
|
|
76820
76976
|
this.index = index;
|
|
76821
76977
|
this.working_dir = working_dir;
|
|
76822
76978
|
if (index === "R" || working_dir === "R") {
|
|
76823
|
-
const detail = fromPathRegex.exec(
|
|
76979
|
+
const detail = fromPathRegex.exec(path36) || [null, path36, path36];
|
|
76824
76980
|
this.from = detail[2] || "";
|
|
76825
76981
|
this.path = detail[1] || "";
|
|
76826
76982
|
}
|
|
@@ -76851,14 +77007,14 @@ function splitLine(result, lineStr) {
|
|
|
76851
77007
|
default:
|
|
76852
77008
|
return;
|
|
76853
77009
|
}
|
|
76854
|
-
function data3(index, workingDir,
|
|
77010
|
+
function data3(index, workingDir, path36) {
|
|
76855
77011
|
const raw = `${index}${workingDir}`;
|
|
76856
77012
|
const handler = parsers6.get(raw);
|
|
76857
77013
|
if (handler) {
|
|
76858
|
-
handler(result,
|
|
77014
|
+
handler(result, path36);
|
|
76859
77015
|
}
|
|
76860
77016
|
if (raw !== "##" && raw !== "!!") {
|
|
76861
|
-
result.files.push(new FileStatusSummary(
|
|
77017
|
+
result.files.push(new FileStatusSummary(path36, index, workingDir));
|
|
76862
77018
|
}
|
|
76863
77019
|
}
|
|
76864
77020
|
}
|
|
@@ -77209,9 +77365,9 @@ var init_simple_git_api = __esm2({
|
|
|
77209
77365
|
next
|
|
77210
77366
|
);
|
|
77211
77367
|
}
|
|
77212
|
-
hashObject(
|
|
77368
|
+
hashObject(path36, write) {
|
|
77213
77369
|
return this._runTask(
|
|
77214
|
-
hashObjectTask(
|
|
77370
|
+
hashObjectTask(path36, write === true),
|
|
77215
77371
|
trailingFunctionArgument(arguments)
|
|
77216
77372
|
);
|
|
77217
77373
|
}
|
|
@@ -77565,8 +77721,8 @@ var init_branch = __esm2({
|
|
|
77565
77721
|
}
|
|
77566
77722
|
});
|
|
77567
77723
|
function toPath(input) {
|
|
77568
|
-
const
|
|
77569
|
-
return
|
|
77724
|
+
const path36 = input.trim().replace(/^["']|["']$/g, "");
|
|
77725
|
+
return path36 && normalize(path36);
|
|
77570
77726
|
}
|
|
77571
77727
|
var parseCheckIgnore;
|
|
77572
77728
|
var init_CheckIgnore = __esm2({
|
|
@@ -77851,8 +78007,8 @@ __export2(sub_module_exports, {
|
|
|
77851
78007
|
subModuleTask: () => subModuleTask,
|
|
77852
78008
|
updateSubModuleTask: () => updateSubModuleTask
|
|
77853
78009
|
});
|
|
77854
|
-
function addSubModuleTask(repo,
|
|
77855
|
-
return subModuleTask(["add", repo,
|
|
78010
|
+
function addSubModuleTask(repo, path36) {
|
|
78011
|
+
return subModuleTask(["add", repo, path36]);
|
|
77856
78012
|
}
|
|
77857
78013
|
function initSubModuleTask(customArgs) {
|
|
77858
78014
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -78166,8 +78322,8 @@ var require_git = __commonJS2({
|
|
|
78166
78322
|
}
|
|
78167
78323
|
return this._runTask(straightThroughStringTask2(command5, this._trimmed), next);
|
|
78168
78324
|
};
|
|
78169
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
78170
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
78325
|
+
Git2.prototype.submoduleAdd = function(repo, path36, then) {
|
|
78326
|
+
return this._runTask(addSubModuleTask2(repo, path36), trailingFunctionArgument2(arguments));
|
|
78171
78327
|
};
|
|
78172
78328
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
78173
78329
|
return this._runTask(
|
|
@@ -78782,18 +78938,53 @@ function isGenerationCurrent(snapshotToken, read) {
|
|
|
78782
78938
|
return read.ok && read.token === snapshotToken;
|
|
78783
78939
|
}
|
|
78784
78940
|
|
|
78785
|
-
//
|
|
78786
|
-
var
|
|
78787
|
-
|
|
78788
|
-
|
|
78789
|
-
|
|
78790
|
-
|
|
78791
|
-
var
|
|
78792
|
-
|
|
78793
|
-
|
|
78941
|
+
// ../../node_modules/.pnpm/lru-cache@10.4.3/node_modules/lru-cache/dist/esm/index.js
|
|
78942
|
+
var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
|
|
78943
|
+
var PROCESS = typeof process === "object" && !!process ? process : {};
|
|
78944
|
+
var emitWarning = (msg, type, code, fn) => {
|
|
78945
|
+
typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
|
|
78946
|
+
};
|
|
78947
|
+
var AC = globalThis.AbortController;
|
|
78948
|
+
var AS = globalThis.AbortSignal;
|
|
78949
|
+
if (typeof AC === "undefined") {
|
|
78950
|
+
AS = class AbortSignal {
|
|
78951
|
+
onabort;
|
|
78952
|
+
_onabort = [];
|
|
78953
|
+
reason;
|
|
78954
|
+
aborted = false;
|
|
78955
|
+
addEventListener(_3, fn) {
|
|
78956
|
+
this._onabort.push(fn);
|
|
78957
|
+
}
|
|
78958
|
+
};
|
|
78959
|
+
AC = class AbortController {
|
|
78960
|
+
constructor() {
|
|
78961
|
+
warnACPolyfill();
|
|
78962
|
+
}
|
|
78963
|
+
signal = new AS();
|
|
78964
|
+
abort(reason) {
|
|
78965
|
+
if (this.signal.aborted)
|
|
78966
|
+
return;
|
|
78967
|
+
this.signal.reason = reason;
|
|
78968
|
+
this.signal.aborted = true;
|
|
78969
|
+
for (const fn of this.signal._onabort) {
|
|
78970
|
+
fn(reason);
|
|
78971
|
+
}
|
|
78972
|
+
this.signal.onabort?.(reason);
|
|
78973
|
+
}
|
|
78974
|
+
};
|
|
78975
|
+
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1";
|
|
78976
|
+
const warnACPolyfill = () => {
|
|
78977
|
+
if (!printACPolyfillWarning)
|
|
78978
|
+
return;
|
|
78979
|
+
printACPolyfillWarning = false;
|
|
78980
|
+
emitWarning("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", warnACPolyfill);
|
|
78981
|
+
};
|
|
78794
78982
|
}
|
|
78983
|
+
var TYPE = Symbol("type");
|
|
78795
78984
|
|
|
78796
78985
|
// ../canopycms/src/id.ts
|
|
78986
|
+
var import_short_uuid = __toESM(require_dist3(), 1);
|
|
78987
|
+
init_validation();
|
|
78797
78988
|
var isValidId = isValidContentId;
|
|
78798
78989
|
|
|
78799
78990
|
// ../canopycms/src/utils/format.ts
|
|
@@ -78913,6 +79104,7 @@ async function readHeadBranch(gitDir, git = simpleGit()) {
|
|
|
78913
79104
|
}
|
|
78914
79105
|
|
|
78915
79106
|
// ../canopycms/src/branch-schema-cache.ts
|
|
79107
|
+
var SNAPSHOT_MEMO_MAX_BYTES = 64 * 1024 * 1024;
|
|
78916
79108
|
var SCHEMA_CACHE_FILE = "schema-cache.json";
|
|
78917
79109
|
var SCHEMA_GENERATION_RESOURCE = "schema";
|
|
78918
79110
|
|
|
@@ -79008,6 +79200,201 @@ async function tryAcquireProvisioningLock(lockTargetDir2, lockName, onCompromise
|
|
|
79008
79200
|
return releaseIgnoringAlreadyReleased(release2, lockPath);
|
|
79009
79201
|
}
|
|
79010
79202
|
|
|
79203
|
+
// ../canopycms/src/worker/git-process.ts
|
|
79204
|
+
init_error();
|
|
79205
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
79206
|
+
import { Readable, Transform, Writable } from "node:stream";
|
|
79207
|
+
import { pipeline } from "node:stream/promises";
|
|
79208
|
+
var GitProcessError = class extends Error {
|
|
79209
|
+
constructor(message2, exitCode, stderr) {
|
|
79210
|
+
super(message2);
|
|
79211
|
+
this.exitCode = exitCode;
|
|
79212
|
+
this.stderr = stderr;
|
|
79213
|
+
this.name = "GitProcessError";
|
|
79214
|
+
}
|
|
79215
|
+
};
|
|
79216
|
+
var STDERR_CAP_BYTES = 64 * 1024;
|
|
79217
|
+
var KILL_GRACE_MS = 2e3;
|
|
79218
|
+
function spawnGit(args, options) {
|
|
79219
|
+
const child = spawn2("git", [...(options.config ?? []).flatMap((c11) => ["-c", c11]), ...args], {
|
|
79220
|
+
cwd: options.cwd,
|
|
79221
|
+
// An app's own ProcessEnv augmentation (Next.js requires NODE_ENV) says nothing about git's.
|
|
79222
|
+
env: options.env,
|
|
79223
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
79224
|
+
// Its own process group, so a stop reaches what git spawned too (bundle create's
|
|
79225
|
+
// pack-objects), which would otherwise outlive it holding the pipes open.
|
|
79226
|
+
detached: process.platform !== "win32"
|
|
79227
|
+
});
|
|
79228
|
+
const { stdout } = child;
|
|
79229
|
+
if (stdout === null) throw new Error("git was spawned without a stdout pipe");
|
|
79230
|
+
const command5 = args.find((arg) => !arg.startsWith("-")) ?? "git";
|
|
79231
|
+
let stderr = "";
|
|
79232
|
+
let stderrBytes = 0;
|
|
79233
|
+
let killedFor = null;
|
|
79234
|
+
let closed = false;
|
|
79235
|
+
let exitedCleanly = false;
|
|
79236
|
+
let inactivity;
|
|
79237
|
+
const idle = () => {
|
|
79238
|
+
if (stdout.readableLength > 0 && !stdout.destroyed) {
|
|
79239
|
+
inactivity = setTimeout(idle, options.inactivityTimeoutMs);
|
|
79240
|
+
return;
|
|
79241
|
+
}
|
|
79242
|
+
stop(`git ${command5} wrote nothing for ${options.inactivityTimeoutMs}ms`);
|
|
79243
|
+
};
|
|
79244
|
+
const touch = () => {
|
|
79245
|
+
options.onActivity?.();
|
|
79246
|
+
clearTimeout(inactivity);
|
|
79247
|
+
if (exitedCleanly) return;
|
|
79248
|
+
inactivity = setTimeout(idle, options.inactivityTimeoutMs);
|
|
79249
|
+
};
|
|
79250
|
+
const stop = (reason) => {
|
|
79251
|
+
if (closed || killedFor !== null) return;
|
|
79252
|
+
if (child.exitCode === 0 || child.exitCode === null && child.signalCode === null) {
|
|
79253
|
+
killedFor = reason;
|
|
79254
|
+
}
|
|
79255
|
+
terminate(child);
|
|
79256
|
+
stdout.destroy();
|
|
79257
|
+
};
|
|
79258
|
+
child.on("exit", (code) => {
|
|
79259
|
+
if (code !== 0) return;
|
|
79260
|
+
exitedCleanly = true;
|
|
79261
|
+
clearTimeout(inactivity);
|
|
79262
|
+
clearTimeout(deadline);
|
|
79263
|
+
});
|
|
79264
|
+
child.stderr?.on("data", (chunk) => {
|
|
79265
|
+
touch();
|
|
79266
|
+
if (stderrBytes < STDERR_CAP_BYTES) {
|
|
79267
|
+
stderr += chunk.subarray(0, STDERR_CAP_BYTES - stderrBytes).toString("utf8");
|
|
79268
|
+
}
|
|
79269
|
+
stderrBytes += chunk.length;
|
|
79270
|
+
});
|
|
79271
|
+
stdout.on("data", touch);
|
|
79272
|
+
const deadline = options.deadlineMs === void 0 ? void 0 : setTimeout(
|
|
79273
|
+
() => stop(`git ${command5} ran longer than ${options.deadlineMs}ms`),
|
|
79274
|
+
options.deadlineMs
|
|
79275
|
+
);
|
|
79276
|
+
const onAbort = () => stop(`git ${command5} was aborted`);
|
|
79277
|
+
if (options.signal?.aborted) onAbort();
|
|
79278
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
79279
|
+
const input = feedStdin(
|
|
79280
|
+
child,
|
|
79281
|
+
options.stdin,
|
|
79282
|
+
touch,
|
|
79283
|
+
(err) => stop(`git ${command5}'s input failed: ${getErrorMessage(err)}`)
|
|
79284
|
+
);
|
|
79285
|
+
input.catch(() => void 0);
|
|
79286
|
+
touch();
|
|
79287
|
+
const exited = new Promise((resolve, reject) => {
|
|
79288
|
+
child.on("error", (err) => {
|
|
79289
|
+
if (child.pid === void 0) {
|
|
79290
|
+
clearTimeout(inactivity);
|
|
79291
|
+
clearTimeout(deadline);
|
|
79292
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
79293
|
+
reject(new GitProcessError(`git ${command5} could not run: ${err.message}`, null, ""));
|
|
79294
|
+
}
|
|
79295
|
+
});
|
|
79296
|
+
child.on("close", (code, signal) => {
|
|
79297
|
+
closed = true;
|
|
79298
|
+
clearTimeout(inactivity);
|
|
79299
|
+
clearTimeout(deadline);
|
|
79300
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
79301
|
+
const written = stderrBytes > STDERR_CAP_BYTES ? `${stderr}
|
|
79302
|
+
[stderr truncated]` : stderr;
|
|
79303
|
+
if (killedFor === null && code === 0) {
|
|
79304
|
+
input.then(
|
|
79305
|
+
resolve,
|
|
79306
|
+
(err) => reject(
|
|
79307
|
+
new GitProcessError(
|
|
79308
|
+
`git ${command5}'s input failed: ${getErrorMessage(err)}`,
|
|
79309
|
+
0,
|
|
79310
|
+
written
|
|
79311
|
+
)
|
|
79312
|
+
)
|
|
79313
|
+
);
|
|
79314
|
+
return;
|
|
79315
|
+
}
|
|
79316
|
+
const why = killedFor ?? (written.trim() || (code === null ? `git ${command5} was killed by ${signal ?? "a signal"}` : `git ${command5} exited with code ${code}`));
|
|
79317
|
+
reject(new GitProcessError(why, code, written));
|
|
79318
|
+
});
|
|
79319
|
+
});
|
|
79320
|
+
exited.catch(() => void 0);
|
|
79321
|
+
return { stdout, exited, kill: stop };
|
|
79322
|
+
}
|
|
79323
|
+
async function runGit(args, options) {
|
|
79324
|
+
const max = options.maxStdoutBytes ?? 64 * 1024 * 1024;
|
|
79325
|
+
const proc = spawnGit(args, options);
|
|
79326
|
+
const chunks = [];
|
|
79327
|
+
let total = 0;
|
|
79328
|
+
const collect = new Writable({
|
|
79329
|
+
write(chunk, _encoding, callback) {
|
|
79330
|
+
total += chunk.length;
|
|
79331
|
+
if (total > max) {
|
|
79332
|
+
proc.kill(`git printed more than ${max} bytes`);
|
|
79333
|
+
callback();
|
|
79334
|
+
return;
|
|
79335
|
+
}
|
|
79336
|
+
chunks.push(chunk);
|
|
79337
|
+
callback();
|
|
79338
|
+
}
|
|
79339
|
+
});
|
|
79340
|
+
try {
|
|
79341
|
+
await Promise.all([pipeline(proc.stdout, collect).catch(() => void 0), proc.exited]);
|
|
79342
|
+
} catch (err) {
|
|
79343
|
+
if (options.stdoutInFailure && err instanceof GitProcessError && chunks.length > 0) {
|
|
79344
|
+
throw new GitProcessError(
|
|
79345
|
+
`${Buffer.concat(chunks).toString("utf8")}${err.message}`,
|
|
79346
|
+
err.exitCode,
|
|
79347
|
+
err.stderr
|
|
79348
|
+
);
|
|
79349
|
+
}
|
|
79350
|
+
throw err;
|
|
79351
|
+
}
|
|
79352
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
79353
|
+
}
|
|
79354
|
+
function terminate(child) {
|
|
79355
|
+
signalGroup(child, "SIGTERM");
|
|
79356
|
+
const timer = setTimeout(() => signalGroup(child, "SIGKILL"), KILL_GRACE_MS);
|
|
79357
|
+
timer.unref();
|
|
79358
|
+
child.once("close", () => clearTimeout(timer));
|
|
79359
|
+
}
|
|
79360
|
+
function signalGroup(child, signal) {
|
|
79361
|
+
if (child.pid !== void 0 && process.platform !== "win32") {
|
|
79362
|
+
try {
|
|
79363
|
+
process.kill(-child.pid, signal);
|
|
79364
|
+
return;
|
|
79365
|
+
} catch {
|
|
79366
|
+
}
|
|
79367
|
+
}
|
|
79368
|
+
child.kill(signal);
|
|
79369
|
+
}
|
|
79370
|
+
function feedStdin(child, source, touch, onSourceError) {
|
|
79371
|
+
const sink = child.stdin;
|
|
79372
|
+
if (sink === null) return Promise.resolve();
|
|
79373
|
+
sink.on("error", () => void 0);
|
|
79374
|
+
if (source === void 0) {
|
|
79375
|
+
sink.end();
|
|
79376
|
+
return Promise.resolve();
|
|
79377
|
+
}
|
|
79378
|
+
const readable = typeof source === "string" ? Readable.from([Buffer.from(source)]) : source;
|
|
79379
|
+
const counted = new Transform({
|
|
79380
|
+
transform(chunk, _encoding, callback) {
|
|
79381
|
+
touch();
|
|
79382
|
+
callback(null, chunk);
|
|
79383
|
+
}
|
|
79384
|
+
});
|
|
79385
|
+
return new Promise((resolve, reject) => {
|
|
79386
|
+
readable.once("error", (err) => {
|
|
79387
|
+
onSourceError(err);
|
|
79388
|
+
reject(err);
|
|
79389
|
+
});
|
|
79390
|
+
sink.once("close", () => {
|
|
79391
|
+
if (!readable.readableEnded) readable.destroy();
|
|
79392
|
+
resolve();
|
|
79393
|
+
});
|
|
79394
|
+
readable.pipe(counted).pipe(sink);
|
|
79395
|
+
});
|
|
79396
|
+
}
|
|
79397
|
+
|
|
79011
79398
|
// ../canopycms/src/git-manager.ts
|
|
79012
79399
|
var log2 = createDebugLogger({ prefix: "GitManager" });
|
|
79013
79400
|
var GIT_ENV_PASSTHROUGH = /^(PATH|HOME|USER|LANG|LC_[A-Z]+|TZ|TMPDIR|GIT_(AUTHOR|COMMITTER)_(NAME|EMAIL|DATE)|GIT_TERMINAL_PROMPT|GIT_TRACE[0-9A-Z_]*)$/;
|
|
@@ -79285,201 +79672,6 @@ function hasOnlyHead(header, sha, branch) {
|
|
|
79285
79672
|
return header.heads.length === 1 && header.heads[0].equals(expectedHead(sha, branch));
|
|
79286
79673
|
}
|
|
79287
79674
|
|
|
79288
|
-
// ../canopycms/src/worker/git-process.ts
|
|
79289
|
-
init_error();
|
|
79290
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
79291
|
-
import { Readable, Transform, Writable } from "node:stream";
|
|
79292
|
-
import { pipeline } from "node:stream/promises";
|
|
79293
|
-
var GitProcessError = class extends Error {
|
|
79294
|
-
constructor(message2, exitCode, stderr) {
|
|
79295
|
-
super(message2);
|
|
79296
|
-
this.exitCode = exitCode;
|
|
79297
|
-
this.stderr = stderr;
|
|
79298
|
-
this.name = "GitProcessError";
|
|
79299
|
-
}
|
|
79300
|
-
};
|
|
79301
|
-
var STDERR_CAP_BYTES = 64 * 1024;
|
|
79302
|
-
var KILL_GRACE_MS = 2e3;
|
|
79303
|
-
function spawnGit(args, options) {
|
|
79304
|
-
const child = spawn2("git", [...(options.config ?? []).flatMap((c11) => ["-c", c11]), ...args], {
|
|
79305
|
-
cwd: options.cwd,
|
|
79306
|
-
// An app's own ProcessEnv augmentation (Next.js requires NODE_ENV) says nothing about git's.
|
|
79307
|
-
env: options.env,
|
|
79308
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
79309
|
-
// Its own process group, so a stop reaches what git spawned too (bundle create's
|
|
79310
|
-
// pack-objects), which would otherwise outlive it holding the pipes open.
|
|
79311
|
-
detached: process.platform !== "win32"
|
|
79312
|
-
});
|
|
79313
|
-
const { stdout } = child;
|
|
79314
|
-
if (stdout === null) throw new Error("git was spawned without a stdout pipe");
|
|
79315
|
-
const command5 = args.find((arg) => !arg.startsWith("-")) ?? "git";
|
|
79316
|
-
let stderr = "";
|
|
79317
|
-
let stderrBytes = 0;
|
|
79318
|
-
let killedFor = null;
|
|
79319
|
-
let closed = false;
|
|
79320
|
-
let exitedCleanly = false;
|
|
79321
|
-
let inactivity;
|
|
79322
|
-
const idle = () => {
|
|
79323
|
-
if (stdout.readableLength > 0 && !stdout.destroyed) {
|
|
79324
|
-
inactivity = setTimeout(idle, options.inactivityTimeoutMs);
|
|
79325
|
-
return;
|
|
79326
|
-
}
|
|
79327
|
-
stop(`git ${command5} wrote nothing for ${options.inactivityTimeoutMs}ms`);
|
|
79328
|
-
};
|
|
79329
|
-
const touch = () => {
|
|
79330
|
-
options.onActivity?.();
|
|
79331
|
-
clearTimeout(inactivity);
|
|
79332
|
-
if (exitedCleanly) return;
|
|
79333
|
-
inactivity = setTimeout(idle, options.inactivityTimeoutMs);
|
|
79334
|
-
};
|
|
79335
|
-
const stop = (reason) => {
|
|
79336
|
-
if (closed || killedFor !== null) return;
|
|
79337
|
-
if (child.exitCode === 0 || child.exitCode === null && child.signalCode === null) {
|
|
79338
|
-
killedFor = reason;
|
|
79339
|
-
}
|
|
79340
|
-
terminate(child);
|
|
79341
|
-
stdout.destroy();
|
|
79342
|
-
};
|
|
79343
|
-
child.on("exit", (code) => {
|
|
79344
|
-
if (code !== 0) return;
|
|
79345
|
-
exitedCleanly = true;
|
|
79346
|
-
clearTimeout(inactivity);
|
|
79347
|
-
clearTimeout(deadline);
|
|
79348
|
-
});
|
|
79349
|
-
child.stderr?.on("data", (chunk) => {
|
|
79350
|
-
touch();
|
|
79351
|
-
if (stderrBytes < STDERR_CAP_BYTES) {
|
|
79352
|
-
stderr += chunk.subarray(0, STDERR_CAP_BYTES - stderrBytes).toString("utf8");
|
|
79353
|
-
}
|
|
79354
|
-
stderrBytes += chunk.length;
|
|
79355
|
-
});
|
|
79356
|
-
stdout.on("data", touch);
|
|
79357
|
-
const deadline = options.deadlineMs === void 0 ? void 0 : setTimeout(
|
|
79358
|
-
() => stop(`git ${command5} ran longer than ${options.deadlineMs}ms`),
|
|
79359
|
-
options.deadlineMs
|
|
79360
|
-
);
|
|
79361
|
-
const onAbort = () => stop(`git ${command5} was aborted`);
|
|
79362
|
-
if (options.signal?.aborted) onAbort();
|
|
79363
|
-
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
79364
|
-
const input = feedStdin(
|
|
79365
|
-
child,
|
|
79366
|
-
options.stdin,
|
|
79367
|
-
touch,
|
|
79368
|
-
(err) => stop(`git ${command5}'s input failed: ${getErrorMessage(err)}`)
|
|
79369
|
-
);
|
|
79370
|
-
input.catch(() => void 0);
|
|
79371
|
-
touch();
|
|
79372
|
-
const exited = new Promise((resolve, reject) => {
|
|
79373
|
-
child.on("error", (err) => {
|
|
79374
|
-
if (child.pid === void 0) {
|
|
79375
|
-
clearTimeout(inactivity);
|
|
79376
|
-
clearTimeout(deadline);
|
|
79377
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
79378
|
-
reject(new GitProcessError(`git ${command5} could not run: ${err.message}`, null, ""));
|
|
79379
|
-
}
|
|
79380
|
-
});
|
|
79381
|
-
child.on("close", (code, signal) => {
|
|
79382
|
-
closed = true;
|
|
79383
|
-
clearTimeout(inactivity);
|
|
79384
|
-
clearTimeout(deadline);
|
|
79385
|
-
options.signal?.removeEventListener("abort", onAbort);
|
|
79386
|
-
const written = stderrBytes > STDERR_CAP_BYTES ? `${stderr}
|
|
79387
|
-
[stderr truncated]` : stderr;
|
|
79388
|
-
if (killedFor === null && code === 0) {
|
|
79389
|
-
input.then(
|
|
79390
|
-
resolve,
|
|
79391
|
-
(err) => reject(
|
|
79392
|
-
new GitProcessError(
|
|
79393
|
-
`git ${command5}'s input failed: ${getErrorMessage(err)}`,
|
|
79394
|
-
0,
|
|
79395
|
-
written
|
|
79396
|
-
)
|
|
79397
|
-
)
|
|
79398
|
-
);
|
|
79399
|
-
return;
|
|
79400
|
-
}
|
|
79401
|
-
const why = killedFor ?? (written.trim() || (code === null ? `git ${command5} was killed by ${signal ?? "a signal"}` : `git ${command5} exited with code ${code}`));
|
|
79402
|
-
reject(new GitProcessError(why, code, written));
|
|
79403
|
-
});
|
|
79404
|
-
});
|
|
79405
|
-
exited.catch(() => void 0);
|
|
79406
|
-
return { stdout, exited, kill: stop };
|
|
79407
|
-
}
|
|
79408
|
-
async function runGit(args, options) {
|
|
79409
|
-
const max = options.maxStdoutBytes ?? 64 * 1024 * 1024;
|
|
79410
|
-
const proc = spawnGit(args, options);
|
|
79411
|
-
const chunks = [];
|
|
79412
|
-
let total = 0;
|
|
79413
|
-
const collect = new Writable({
|
|
79414
|
-
write(chunk, _encoding, callback) {
|
|
79415
|
-
total += chunk.length;
|
|
79416
|
-
if (total > max) {
|
|
79417
|
-
proc.kill(`git printed more than ${max} bytes`);
|
|
79418
|
-
callback();
|
|
79419
|
-
return;
|
|
79420
|
-
}
|
|
79421
|
-
chunks.push(chunk);
|
|
79422
|
-
callback();
|
|
79423
|
-
}
|
|
79424
|
-
});
|
|
79425
|
-
try {
|
|
79426
|
-
await Promise.all([pipeline(proc.stdout, collect).catch(() => void 0), proc.exited]);
|
|
79427
|
-
} catch (err) {
|
|
79428
|
-
if (options.stdoutInFailure && err instanceof GitProcessError && chunks.length > 0) {
|
|
79429
|
-
throw new GitProcessError(
|
|
79430
|
-
`${Buffer.concat(chunks).toString("utf8")}${err.message}`,
|
|
79431
|
-
err.exitCode,
|
|
79432
|
-
err.stderr
|
|
79433
|
-
);
|
|
79434
|
-
}
|
|
79435
|
-
throw err;
|
|
79436
|
-
}
|
|
79437
|
-
return Buffer.concat(chunks).toString("utf8");
|
|
79438
|
-
}
|
|
79439
|
-
function terminate(child) {
|
|
79440
|
-
signalGroup(child, "SIGTERM");
|
|
79441
|
-
const timer = setTimeout(() => signalGroup(child, "SIGKILL"), KILL_GRACE_MS);
|
|
79442
|
-
timer.unref();
|
|
79443
|
-
child.once("close", () => clearTimeout(timer));
|
|
79444
|
-
}
|
|
79445
|
-
function signalGroup(child, signal) {
|
|
79446
|
-
if (child.pid !== void 0 && process.platform !== "win32") {
|
|
79447
|
-
try {
|
|
79448
|
-
process.kill(-child.pid, signal);
|
|
79449
|
-
return;
|
|
79450
|
-
} catch {
|
|
79451
|
-
}
|
|
79452
|
-
}
|
|
79453
|
-
child.kill(signal);
|
|
79454
|
-
}
|
|
79455
|
-
function feedStdin(child, source, touch, onSourceError) {
|
|
79456
|
-
const sink = child.stdin;
|
|
79457
|
-
if (sink === null) return Promise.resolve();
|
|
79458
|
-
sink.on("error", () => void 0);
|
|
79459
|
-
if (source === void 0) {
|
|
79460
|
-
sink.end();
|
|
79461
|
-
return Promise.resolve();
|
|
79462
|
-
}
|
|
79463
|
-
const readable = typeof source === "string" ? Readable.from([Buffer.from(source)]) : source;
|
|
79464
|
-
const counted = new Transform({
|
|
79465
|
-
transform(chunk, _encoding, callback) {
|
|
79466
|
-
touch();
|
|
79467
|
-
callback(null, chunk);
|
|
79468
|
-
}
|
|
79469
|
-
});
|
|
79470
|
-
return new Promise((resolve, reject) => {
|
|
79471
|
-
readable.once("error", (err) => {
|
|
79472
|
-
onSourceError(err);
|
|
79473
|
-
reject(err);
|
|
79474
|
-
});
|
|
79475
|
-
sink.once("close", () => {
|
|
79476
|
-
if (!readable.readableEnded) readable.destroy();
|
|
79477
|
-
resolve();
|
|
79478
|
-
});
|
|
79479
|
-
readable.pipe(counted).pipe(sink);
|
|
79480
|
-
});
|
|
79481
|
-
}
|
|
79482
|
-
|
|
79483
79675
|
// ../canopycms/src/worker/github-gateway.ts
|
|
79484
79676
|
import fs10 from "node:fs/promises";
|
|
79485
79677
|
import path11 from "node:path";
|
|
@@ -79490,6 +79682,12 @@ var import_plugin_throttling = __toESM(require_dist_node13(), 1);
|
|
|
79490
79682
|
init_error();
|
|
79491
79683
|
init_logger();
|
|
79492
79684
|
|
|
79685
|
+
// ../canopycms/src/auth/person-name.ts
|
|
79686
|
+
function personName(id, name2) {
|
|
79687
|
+
const trimmed2 = name2?.trim();
|
|
79688
|
+
return trimmed2 && trimmed2 !== id ? trimmed2 : void 0;
|
|
79689
|
+
}
|
|
79690
|
+
|
|
79493
79691
|
// ../canopycms/src/editor-url.ts
|
|
79494
79692
|
function editorDeepLink(editorUrl, branch, entryPath) {
|
|
79495
79693
|
const url = new URL(editorUrl);
|
|
@@ -79504,6 +79702,8 @@ var PR_SECTION_START = "<!-- canopycms:submission:start -->";
|
|
|
79504
79702
|
var PR_SECTION_END = "<!-- canopycms:submission:end -->";
|
|
79505
79703
|
var PR_COMMENTS_START = "<!-- canopycms:comments:start -->";
|
|
79506
79704
|
var PR_COMMENTS_END = "<!-- canopycms:comments:end -->";
|
|
79705
|
+
var PR_REVIEW_START = "<!-- canopycms:review:start -->";
|
|
79706
|
+
var PR_REVIEW_END = "<!-- canopycms:review:end -->";
|
|
79507
79707
|
var INVISIBLE_OR_CONTROL = /[\p{Cc}\p{Cf}\p{Cs}\p{Zl}\p{Zp}]/gu;
|
|
79508
79708
|
var STRUCTURAL = /[<>()`\\]/g;
|
|
79509
79709
|
function truncate(value, max) {
|
|
@@ -79519,6 +79719,9 @@ function cleanText(raw, max) {
|
|
|
79519
79719
|
const cleaned = raw.normalize("NFKC").replace(INVISIBLE_OR_CONTROL, " ").replace(STRUCTURAL, "").replace(/\s+/g, " ").trim();
|
|
79520
79720
|
return cleaned ? truncate(cleaned, max) : void 0;
|
|
79521
79721
|
}
|
|
79722
|
+
function sanitizeDisplayName(raw) {
|
|
79723
|
+
return cleanText(raw, MAX_NAME_LENGTH);
|
|
79724
|
+
}
|
|
79522
79725
|
function codeSpan(value) {
|
|
79523
79726
|
return `\`${value}\``;
|
|
79524
79727
|
}
|
|
@@ -79531,6 +79734,24 @@ function markdownHref(href) {
|
|
|
79531
79734
|
function editorLinker(branch, editorUrl) {
|
|
79532
79735
|
return (entryPath) => branch && editorUrl ? markdownHref(editorDeepLink(editorUrl, branch, entryPath)) : void 0;
|
|
79533
79736
|
}
|
|
79737
|
+
var REVIEW_NOT_A_GITHUB_REVIEW = "Approval in CanopyCMS is not a GitHub review.";
|
|
79738
|
+
function reviewTime(at) {
|
|
79739
|
+
const time3 = typeof at === "string" ? new Date(at) : void 0;
|
|
79740
|
+
return time3 && !Number.isNaN(time3.getTime()) ? `${time3.toISOString().slice(0, 16).replace("T", " ")} UTC` : void 0;
|
|
79741
|
+
}
|
|
79742
|
+
function buildReviewBlock(review) {
|
|
79743
|
+
const verdict = review?.state === "approved" ? "Approved" : review?.state === "changes-requested" ? "Changes requested" : void 0;
|
|
79744
|
+
let status = "Not yet reviewed in CanopyCMS.";
|
|
79745
|
+
if (review && verdict) {
|
|
79746
|
+
const name2 = personName(review.by.userId, sanitizeDisplayName(review.by.name));
|
|
79747
|
+
const when = reviewTime(review.at);
|
|
79748
|
+
status = `${verdict} in CanopyCMS by ${name2 ? codeSpan(name2) : "a reviewer"}${when ? ` on ${when}` : ""}.`;
|
|
79749
|
+
}
|
|
79750
|
+
return `${PR_REVIEW_START}
|
|
79751
|
+
${status}
|
|
79752
|
+
${REVIEW_NOT_A_GITHUB_REVIEW}
|
|
79753
|
+
${PR_REVIEW_END}`;
|
|
79754
|
+
}
|
|
79534
79755
|
var MAX_LISTED_THREADS = 50;
|
|
79535
79756
|
var MAX_EXCERPT_LENGTH = 80;
|
|
79536
79757
|
var MAX_COMMENTS_LENGTH = 15e3;
|
|
@@ -79611,6 +79832,15 @@ function mergeCommentsBlock(existing, block) {
|
|
|
79611
79832
|
if (start < 0 || end < 0 || end > section.end) return void 0;
|
|
79612
79833
|
return body.slice(0, start) + block + body.slice(end + PR_COMMENTS_END.length);
|
|
79613
79834
|
}
|
|
79835
|
+
function mergeReviewBlock(existing, block) {
|
|
79836
|
+
const body = existing ?? "";
|
|
79837
|
+
const section = findPrSection(body);
|
|
79838
|
+
if (!section) return void 0;
|
|
79839
|
+
const start = body.indexOf(PR_REVIEW_START, section.start);
|
|
79840
|
+
const end = start < 0 ? -1 : body.indexOf(PR_REVIEW_END, start);
|
|
79841
|
+
if (start < 0 || end < 0 || end > section.end) return void 0;
|
|
79842
|
+
return body.slice(0, start) + block + body.slice(end + PR_REVIEW_END.length);
|
|
79843
|
+
}
|
|
79614
79844
|
|
|
79615
79845
|
// ../canopycms/src/github-service.ts
|
|
79616
79846
|
var ThrottledOctokit = import_rest.Octokit.plugin(import_plugin_throttling.throttling);
|
|
@@ -79948,22 +80178,11 @@ async function walk(dir, visit) {
|
|
|
79948
80178
|
}
|
|
79949
80179
|
}
|
|
79950
80180
|
|
|
79951
|
-
// ../canopycms/src/paths/branch-name.ts
|
|
79952
|
-
function sanitizeBranchName(branchName) {
|
|
79953
|
-
const replaced = branchName.replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
79954
|
-
const squashed = replaced.replace(/-+/g, "-");
|
|
79955
|
-
const trimmedDots = squashed.replace(/^\.+/, "").replace(/(?<!\.)\.+$/, "");
|
|
79956
|
-
return trimmedDots || "branch";
|
|
79957
|
-
}
|
|
79958
|
-
var RESERVED_SETTINGS_BRANCH_PREFIX = "canopycms-settings-";
|
|
79959
|
-
function isSettingsBranchName(branchName, settingsBranchName) {
|
|
79960
|
-
const sanitized = sanitizeBranchName(branchName);
|
|
79961
|
-
return sanitized.startsWith(RESERVED_SETTINGS_BRANCH_PREFIX) || settingsBranchName !== void 0 && sanitized === sanitizeBranchName(settingsBranchName);
|
|
79962
|
-
}
|
|
79963
|
-
|
|
79964
80181
|
// ../canopycms/src/worker/branch-policy.ts
|
|
80182
|
+
init_branch_namespace();
|
|
80183
|
+
init_branch_name();
|
|
79965
80184
|
var DEFAULT_BRANCH_TTL_MS = 10 * 6e4;
|
|
79966
|
-
var
|
|
80185
|
+
var MAX_BRANCH_NAME_LENGTH2 = 255;
|
|
79967
80186
|
var MAX_PULL_REQUEST_TITLE_LENGTH = 1024;
|
|
79968
80187
|
var MAX_PULL_REQUEST_BODY_LENGTH = 65536;
|
|
79969
80188
|
var GatewayRefusalError = class extends Error {
|
|
@@ -79978,9 +80197,30 @@ var GatewayRefusalError = class extends Error {
|
|
|
79978
80197
|
var deleting = (branch) => `Refusing to delete ${JSON.stringify(branch)} on GitHub`;
|
|
79979
80198
|
var openingFrom = (head) => `Refusing to open a pull request from ${JSON.stringify(head)}`;
|
|
79980
80199
|
var PROTECTED_WHY = "it is protected (the base branch, GitHub's default branch, or a name protectedBranches lists), which the CanopyCMS worker never changes. Nothing in CanopyCMS queues this; find out what wrote this task.";
|
|
80200
|
+
var outsideNamespaceWhy = (namespace) => `it is outside this deployment's branch namespace (names starting ${namespace}), and is neither its settings branch nor on its legacyBranches list. CanopyCMS creates every branch it edits in that namespace; a branch made before it reaches GitHub only once legacyBranches lists it.`;
|
|
80201
|
+
var outsideNamespaceDeleteWhy = (namespace) => `it is outside this deployment's branch namespace (names starting ${namespace}), and is neither its settings branch nor on its legacyBranches list, so the branch stays on GitHub. To delete it there, add it to legacyBranches, retry this task in System health, then remove the entry.`;
|
|
80202
|
+
function pushRefusalMessage(branch, reason, namespace) {
|
|
80203
|
+
const refusing = `Refusing to push ${JSON.stringify(branch)} to GitHub`;
|
|
80204
|
+
switch (reason) {
|
|
80205
|
+
case "protected":
|
|
80206
|
+
return `${refusing}: ${PROTECTED_WHY}`;
|
|
80207
|
+
case "settings":
|
|
80208
|
+
return `${refusing} under a lease: a settings branch only ever fast-forwards. Find out what set a history-rewrite marker on it.`;
|
|
80209
|
+
case "other-settings":
|
|
80210
|
+
return `${refusing}: it is a settings branch, and not this deployment's, which is the only one this gateway pushes. Check that CANOPYCMS_DEPLOYMENT_NAME and CANOPYCMS_SETTINGS_BRANCH match the CMS's own settings branch; if they do, find out what asked for this push.`;
|
|
80211
|
+
case "outside-namespace":
|
|
80212
|
+
return `${refusing}: ${outsideNamespaceWhy(namespace)}`;
|
|
80213
|
+
}
|
|
80214
|
+
}
|
|
80215
|
+
function namespaceBlockedMessage(branch, blocker) {
|
|
80216
|
+
return `Refusing to push ${JSON.stringify(branch)} to GitHub: GitHub has a branch named ${JSON.stringify(blocker)}, which is part of this deployment's branch namespace, and git cannot hold a branch inside another. Rename or delete that branch on GitHub.`;
|
|
80217
|
+
}
|
|
80218
|
+
function branchInsideMessage(branch, inside) {
|
|
80219
|
+
return `Refusing to push ${JSON.stringify(branch)} to GitHub: GitHub has a branch named ${JSON.stringify(inside)} inside it, and git cannot hold both. Rename or delete that branch on GitHub.`;
|
|
80220
|
+
}
|
|
79981
80221
|
function branchNameProblem(branch) {
|
|
79982
|
-
if (branch.length === 0 || branch.length >
|
|
79983
|
-
return `a branch name is 1 to ${
|
|
80222
|
+
if (branch.length === 0 || branch.length > MAX_BRANCH_NAME_LENGTH2) {
|
|
80223
|
+
return `a branch name is 1 to ${MAX_BRANCH_NAME_LENGTH2} characters`;
|
|
79984
80224
|
}
|
|
79985
80225
|
if (!/^[\x21-\x7e]+$/.test(branch)) return "it is not printable ASCII";
|
|
79986
80226
|
if (/["%{}]/.test(branch)) return 'it contains ", %, { or }';
|
|
@@ -80006,6 +80246,20 @@ function protectedPatternProblem(pattern) {
|
|
|
80006
80246
|
}
|
|
80007
80247
|
return null;
|
|
80008
80248
|
}
|
|
80249
|
+
function legacyBranchProblem(entry) {
|
|
80250
|
+
if (entry.includes("*")) return "an entry is an exact branch name, and * is not a wildcard here";
|
|
80251
|
+
if (entry.includes(",")) return "it contains a comma, which separates entries";
|
|
80252
|
+
if (entry.startsWith(RESERVED_SETTINGS_BRANCH_PREFIX)) {
|
|
80253
|
+
return "it is a settings branch, which the gateway pushes without being listed";
|
|
80254
|
+
}
|
|
80255
|
+
const problem = protectedPatternProblem(entry);
|
|
80256
|
+
if (problem !== null) return problem;
|
|
80257
|
+
if (entry === "HEAD" || entry === "@") return `git reserves ${JSON.stringify(entry)}`;
|
|
80258
|
+
if (entry.split("/").some((part) => part.startsWith(".") || part.endsWith(".lock"))) {
|
|
80259
|
+
return "a part of it starts with '.' or ends with '.lock', which git refuses";
|
|
80260
|
+
}
|
|
80261
|
+
return null;
|
|
80262
|
+
}
|
|
80009
80263
|
function matchesBranchPattern(pattern, name2) {
|
|
80010
80264
|
const parts = pattern.split("*");
|
|
80011
80265
|
const first2 = parts[0];
|
|
@@ -80023,10 +80277,38 @@ function matchesBranchPattern(pattern, name2) {
|
|
|
80023
80277
|
return true;
|
|
80024
80278
|
}
|
|
80025
80279
|
var MAX_PROTECTED_BRANCHES = 1024;
|
|
80280
|
+
var MAX_LEGACY_BRANCHES = 1024;
|
|
80281
|
+
var DEFAULT_BRANCH_NAMESPACE = resolveBranchNamespaceTemplate(
|
|
80282
|
+
DEFAULT_BRANCH_NAMESPACE_TEMPLATE,
|
|
80283
|
+
"prod",
|
|
80284
|
+
"the default"
|
|
80285
|
+
);
|
|
80026
80286
|
var BranchPolicy = class {
|
|
80027
80287
|
constructor(options = {}) {
|
|
80028
80288
|
this.githubDefault = null;
|
|
80029
80289
|
this.now = options.now ?? (() => Date.now());
|
|
80290
|
+
this.namespace = options.namespace ?? DEFAULT_BRANCH_NAMESPACE;
|
|
80291
|
+
const namespaceProblem = branchNamespaceProblem(this.namespace);
|
|
80292
|
+
if (namespaceProblem !== null) {
|
|
80293
|
+
throw new Error(
|
|
80294
|
+
`Invalid branch namespace ${JSON.stringify(this.namespace)}: ${namespaceProblem}`
|
|
80295
|
+
);
|
|
80296
|
+
}
|
|
80297
|
+
for (const [what, name2] of [
|
|
80298
|
+
["base branch", options.baseBranch],
|
|
80299
|
+
["settings branch", options.settingsBranch]
|
|
80300
|
+
]) {
|
|
80301
|
+
if (name2 !== void 0 && (name2.startsWith(this.namespace) || sanitizeBranchName(name2).startsWith(sanitizeBranchName(this.namespace)))) {
|
|
80302
|
+
throw new Error(
|
|
80303
|
+
`The ${what} ${JSON.stringify(name2)} is inside the branch namespace ${JSON.stringify(this.namespace)}, or shares a workspace directory with a branch in it, and the namespace holds only the branches editors create; choose a namespace it is outside`
|
|
80304
|
+
);
|
|
80305
|
+
}
|
|
80306
|
+
if (name2 !== void 0 && this.namespace.startsWith(`${name2}/`)) {
|
|
80307
|
+
throw new Error(
|
|
80308
|
+
`The ${what} ${JSON.stringify(name2)} is a branch named after part of the branch namespace ${JSON.stringify(this.namespace)}, so git can hold no branch in it; choose another namespace`
|
|
80309
|
+
);
|
|
80310
|
+
}
|
|
80311
|
+
}
|
|
80030
80312
|
const entries = [...options.protectedBranches ?? []];
|
|
80031
80313
|
if (entries.length > MAX_PROTECTED_BRANCHES) {
|
|
80032
80314
|
throw new Error(
|
|
@@ -80042,26 +80324,87 @@ var BranchPolicy = class {
|
|
|
80042
80324
|
if (options.baseBranch !== void 0) entries.push(options.baseBranch);
|
|
80043
80325
|
this.exact = entries.filter((entry) => !entry.includes("*"));
|
|
80044
80326
|
this.globs = entries.filter((entry) => entry.includes("*"));
|
|
80327
|
+
const settingsBranch = options.settingsBranch;
|
|
80328
|
+
if (settingsBranch !== void 0) {
|
|
80329
|
+
const problem = branchNameProblem(settingsBranch);
|
|
80330
|
+
if (problem !== null) {
|
|
80331
|
+
throw new Error(`Invalid settings branch ${JSON.stringify(settingsBranch)}: ${problem}`);
|
|
80332
|
+
}
|
|
80333
|
+
}
|
|
80334
|
+
this.settingsBranch = settingsBranch ?? null;
|
|
80335
|
+
const legacy = options.legacyBranches ?? [];
|
|
80336
|
+
if (legacy.length > MAX_LEGACY_BRANCHES) {
|
|
80337
|
+
throw new Error(
|
|
80338
|
+
`legacyBranches has ${legacy.length} entries; the most it takes is ${MAX_LEGACY_BRANCHES}`
|
|
80339
|
+
);
|
|
80340
|
+
}
|
|
80341
|
+
for (const entry of legacy) {
|
|
80342
|
+
const problem = entry.startsWith(this.namespace) ? `it starts with ${this.namespace}, so it is already in the namespace` : this.namespace.startsWith(`${entry}/`) ? `it is a branch named after part of the namespace ${this.namespace}, so git can hold no branch in it` : legacyBranchProblem(entry);
|
|
80343
|
+
if (problem !== null) {
|
|
80344
|
+
throw new Error(`Invalid legacyBranches entry ${JSON.stringify(entry)}: ${problem}`);
|
|
80345
|
+
}
|
|
80346
|
+
}
|
|
80347
|
+
if (new Set(legacy).size !== legacy.length) {
|
|
80348
|
+
throw new Error("legacyBranches lists a branch more than once");
|
|
80349
|
+
}
|
|
80350
|
+
this.legacy = new Set(legacy);
|
|
80045
80351
|
}
|
|
80046
|
-
/** The
|
|
80352
|
+
/** The policy as it stands. */
|
|
80047
80353
|
describe() {
|
|
80048
80354
|
return {
|
|
80049
80355
|
configured: [...this.exact, ...this.globs],
|
|
80050
|
-
githubDefault: this.githubDefault?.name ?? null
|
|
80356
|
+
githubDefault: this.githubDefault?.name ?? null,
|
|
80357
|
+
namespace: this.namespace,
|
|
80358
|
+
legacy: [...this.legacy],
|
|
80359
|
+
settingsBranch: this.settingsBranch
|
|
80051
80360
|
};
|
|
80052
80361
|
}
|
|
80362
|
+
/** Whether the gateway may write `branch` at all: the namespace, the settings branch, the list. */
|
|
80363
|
+
inNamespace(branch) {
|
|
80364
|
+
return branch.startsWith(this.namespace) || branch === this.settingsBranch || this.legacy.has(branch);
|
|
80365
|
+
}
|
|
80366
|
+
/**
|
|
80367
|
+
* Whether the gateway opens and updates a pull request from `head`, protection aside: a branch it
|
|
80368
|
+
* writes that is not a settings branch. `isProtected`, which may read GitHub, judges the rest.
|
|
80369
|
+
*/
|
|
80370
|
+
takesPullRequestFrom(head) {
|
|
80371
|
+
return !this.isSettings(head) && this.inNamespace(head);
|
|
80372
|
+
}
|
|
80373
|
+
/**
|
|
80374
|
+
* The branch among `branches` named after part of the namespace, or null. While one exists git
|
|
80375
|
+
* holds no branch in the namespace, so the gateway refuses a push into it rather than send it.
|
|
80376
|
+
*/
|
|
80377
|
+
namespaceBlocker(branches) {
|
|
80378
|
+
return namespaceAncestors(this.namespace).find((name2) => branches.has(name2)) ?? null;
|
|
80379
|
+
}
|
|
80053
80380
|
/** Whether `branch` is protected; GitHub's default is read only when nothing else matches. */
|
|
80054
80381
|
async isProtected(branch, readDefault) {
|
|
80055
80382
|
if (this.matchesConfigured(branch)) return true;
|
|
80056
80383
|
const githubDefault = await this.githubDefaultBranch(readDefault);
|
|
80057
80384
|
return githubDefault !== null && sameBranch(githubDefault, branch);
|
|
80058
80385
|
}
|
|
80059
|
-
/**
|
|
80386
|
+
/**
|
|
80387
|
+
* Whether `branch` is GitHub's default branch as last read, even once that read has expired:
|
|
80388
|
+
* what protection is judged by when a fresh read fails.
|
|
80389
|
+
*/
|
|
80390
|
+
matchesLastReadDefault(branch) {
|
|
80391
|
+
const name2 = this.githubDefault?.name ?? null;
|
|
80392
|
+
return name2 !== null && sameBranch(name2, branch);
|
|
80393
|
+
}
|
|
80394
|
+
/**
|
|
80395
|
+
* Refuse a push to a protected branch, a leased push to a settings branch, a push to another
|
|
80396
|
+
* deployment's settings branch, and a push outside the namespace.
|
|
80397
|
+
*/
|
|
80060
80398
|
async assertPushAllowed(branch, lease, readDefault, refuse) {
|
|
80061
|
-
|
|
80062
|
-
if (
|
|
80399
|
+
const refusal2 = (reason) => refuse(reason, pushRefusalMessage(branch, reason, this.namespace));
|
|
80400
|
+
if (await this.isProtected(branch, readDefault)) throw refusal2("protected");
|
|
80401
|
+
if (this.isSettings(branch)) {
|
|
80402
|
+
if (lease !== void 0) throw refusal2("settings");
|
|
80403
|
+
if (branch !== this.settingsBranch) throw refusal2("other-settings");
|
|
80404
|
+
}
|
|
80405
|
+
if (!this.inNamespace(branch)) throw refusal2("outside-namespace");
|
|
80063
80406
|
}
|
|
80064
|
-
/** Refuse to delete a protected branch
|
|
80407
|
+
/** Refuse to delete a protected branch, a settings branch, or one outside the namespace. */
|
|
80065
80408
|
async assertDeleteAllowed(branch, readDefault) {
|
|
80066
80409
|
if (this.isSettings(branch)) {
|
|
80067
80410
|
throw new GatewayRefusalError(
|
|
@@ -80079,21 +80422,36 @@ var BranchPolicy = class {
|
|
|
80079
80422
|
`${deleting(branch)}: ${PROTECTED_WHY}`
|
|
80080
80423
|
);
|
|
80081
80424
|
}
|
|
80425
|
+
if (!this.inNamespace(branch)) {
|
|
80426
|
+
throw new GatewayRefusalError(
|
|
80427
|
+
"delete",
|
|
80428
|
+
branch,
|
|
80429
|
+
"outside-namespace",
|
|
80430
|
+
`${deleting(branch)}: ${outsideNamespaceDeleteWhy(this.namespace)}`
|
|
80431
|
+
);
|
|
80432
|
+
}
|
|
80082
80433
|
}
|
|
80083
80434
|
/**
|
|
80084
|
-
* Refuse a pull request whose head is protected
|
|
80085
|
-
* cap. The base is not restricted: a branch keeps the base it was created
|
|
80086
|
-
* adopter moves theirs, and a pull request merges nothing by itself.
|
|
80435
|
+
* Refuse a pull request whose head is protected, a settings branch or outside the namespace, or
|
|
80436
|
+
* whose text is over its cap. The base is not restricted: a branch keeps the base it was created
|
|
80437
|
+
* from after the adopter moves theirs, and a pull request merges nothing by itself.
|
|
80087
80438
|
*/
|
|
80088
80439
|
async assertPullRequestAllowed(request, readDefault) {
|
|
80089
80440
|
const { head } = request;
|
|
80090
80441
|
assertPullRequestText(openingFrom(head), head, request);
|
|
80442
|
+
await this.assertPullRequestHeadAllowed(openingFrom(head), head, readDefault);
|
|
80443
|
+
}
|
|
80444
|
+
/**
|
|
80445
|
+
* Refuse a pull request head the gateway may not open one from, or act on one with. `refusing`
|
|
80446
|
+
* opens the message and names `head`, which the rest calls "it".
|
|
80447
|
+
*/
|
|
80448
|
+
async assertPullRequestHeadAllowed(refusing, head, readDefault) {
|
|
80091
80449
|
if (this.isSettings(head)) {
|
|
80092
80450
|
throw new GatewayRefusalError(
|
|
80093
80451
|
"pull-request",
|
|
80094
80452
|
head,
|
|
80095
80453
|
"settings",
|
|
80096
|
-
`${
|
|
80454
|
+
`${refusing}: it is a settings branch, which never gets one`
|
|
80097
80455
|
);
|
|
80098
80456
|
}
|
|
80099
80457
|
if (await this.isProtected(head, readDefault)) {
|
|
@@ -80101,12 +80459,20 @@ var BranchPolicy = class {
|
|
|
80101
80459
|
"pull-request",
|
|
80102
80460
|
head,
|
|
80103
80461
|
"protected",
|
|
80104
|
-
`${
|
|
80462
|
+
`${refusing}: ${PROTECTED_WHY}`
|
|
80463
|
+
);
|
|
80464
|
+
}
|
|
80465
|
+
if (!this.takesPullRequestFrom(head)) {
|
|
80466
|
+
throw new GatewayRefusalError(
|
|
80467
|
+
"pull-request",
|
|
80468
|
+
head,
|
|
80469
|
+
"outside-namespace",
|
|
80470
|
+
`${refusing}: ${outsideNamespaceWhy(this.namespace)}`
|
|
80105
80471
|
);
|
|
80106
80472
|
}
|
|
80107
80473
|
}
|
|
80108
80474
|
isSettings(branch) {
|
|
80109
|
-
return branch.startsWith(RESERVED_SETTINGS_BRANCH_PREFIX);
|
|
80475
|
+
return branch.startsWith(RESERVED_SETTINGS_BRANCH_PREFIX) || branch === this.settingsBranch;
|
|
80110
80476
|
}
|
|
80111
80477
|
matchesConfigured(branch) {
|
|
80112
80478
|
return this.exact.some((name2) => sameBranch(name2, branch)) || // A glob never takes in a settings branch, whose one allowed push (plain) the worker needs:
|
|
@@ -80131,6 +80497,16 @@ var BranchPolicy = class {
|
|
|
80131
80497
|
return name2;
|
|
80132
80498
|
}
|
|
80133
80499
|
};
|
|
80500
|
+
function publishesBranch(policy, branch) {
|
|
80501
|
+
if (policy.namespace === "") return false;
|
|
80502
|
+
const settings = branch.startsWith(RESERVED_SETTINGS_BRANCH_PREFIX) || branch === policy.settingsBranch;
|
|
80503
|
+
const protectedMatch = policy.configured.some(
|
|
80504
|
+
(entry) => entry.includes("*") ? !settings && matchesBranchPattern(entry, branch) : sameBranch(entry, branch)
|
|
80505
|
+
) || policy.githubDefault !== null && sameBranch(policy.githubDefault, branch);
|
|
80506
|
+
if (protectedMatch) return false;
|
|
80507
|
+
if (settings) return branch === policy.settingsBranch;
|
|
80508
|
+
return branch.startsWith(policy.namespace) || policy.legacy.includes(branch);
|
|
80509
|
+
}
|
|
80134
80510
|
function assertPullRequestText(refusing, branch, text) {
|
|
80135
80511
|
const over = (text.title?.length ?? 0) > MAX_PULL_REQUEST_TITLE_LENGTH ? `its title is longer than ${MAX_PULL_REQUEST_TITLE_LENGTH} characters` : (text.body?.length ?? 0) > MAX_PULL_REQUEST_BODY_LENGTH ? `its body is longer than ${MAX_PULL_REQUEST_BODY_LENGTH} characters` : null;
|
|
80136
80512
|
if (over !== null) {
|
|
@@ -81066,12 +81442,12 @@ async function assertOwnDirectory(dir) {
|
|
|
81066
81442
|
}
|
|
81067
81443
|
}
|
|
81068
81444
|
var RefusedPushError = class extends GatewayRefusalError {
|
|
81069
|
-
constructor(branch, reason, sha) {
|
|
81445
|
+
constructor(branch, reason, sha, message2) {
|
|
81070
81446
|
super(
|
|
81071
81447
|
"push",
|
|
81072
81448
|
branch,
|
|
81073
81449
|
reason,
|
|
81074
|
-
reason === "invalid" ? `Refusing to push ${JSON.stringify(branch)} to GitHub: it is not a valid branch name.` : reason === "
|
|
81450
|
+
message2 ?? (reason === "invalid" ? `Refusing to push ${JSON.stringify(branch)} to GitHub: it is not a valid branch name.` : reason === "not-a-commit" ? `Refusing to push "${branch}" to GitHub: ${sha ?? "the object asked for"} is not a commit, and a branch can only point at one. Find out what put it at refs/heads/${branch} in remote.git.` : `Refusing to push ${JSON.stringify(branch)} to GitHub (${reason}).`)
|
|
81075
81451
|
);
|
|
81076
81452
|
this.name = "RefusedPushError";
|
|
81077
81453
|
}
|
|
@@ -81083,7 +81459,7 @@ async function assertPlainBranchName(branch, git = simpleGit(), operation3 = "pu
|
|
|
81083
81459
|
"invalid",
|
|
81084
81460
|
`Refusing ${JSON.stringify(branch)}: it is not a valid branch name (${why}).`
|
|
81085
81461
|
);
|
|
81086
|
-
const problem = shape ? branchNameProblem(branch) : branch.startsWith("-") ? "it starts with '-'" : branch.length >
|
|
81462
|
+
const problem = shape ? branchNameProblem(branch) : branch.startsWith("-") ? "it starts with '-'" : branch.length > MAX_BRANCH_NAME_LENGTH2 ? `it is longer than ${MAX_BRANCH_NAME_LENGTH2} characters` : null;
|
|
81087
81463
|
if (problem !== null) throw invalid(problem);
|
|
81088
81464
|
let normalized;
|
|
81089
81465
|
try {
|
|
@@ -81403,8 +81779,29 @@ var MirrorSession = class {
|
|
|
81403
81779
|
`Could not read GitHub's default branch before pushing ${branch}: ` + redactEgress(getErrorMessage(err)).trim()
|
|
81404
81780
|
);
|
|
81405
81781
|
}),
|
|
81406
|
-
(reason) => new RefusedPushError(branch, reason)
|
|
81782
|
+
(reason, message2) => new RefusedPushError(branch, reason, void 0, message2)
|
|
81407
81783
|
);
|
|
81784
|
+
if (branch.startsWith(options.policy.namespace)) {
|
|
81785
|
+
const heads = await this.heads();
|
|
81786
|
+
const blocker = options.policy.namespaceBlocker(heads);
|
|
81787
|
+
if (blocker !== null) {
|
|
81788
|
+
throw new RefusedPushError(
|
|
81789
|
+
branch,
|
|
81790
|
+
"invalid",
|
|
81791
|
+
void 0,
|
|
81792
|
+
namespaceBlockedMessage(branch, blocker)
|
|
81793
|
+
);
|
|
81794
|
+
}
|
|
81795
|
+
const inside = [...heads.keys()].find((name2) => name2.startsWith(`${branch}/`));
|
|
81796
|
+
if (inside !== void 0) {
|
|
81797
|
+
throw new RefusedPushError(
|
|
81798
|
+
branch,
|
|
81799
|
+
"invalid",
|
|
81800
|
+
void 0,
|
|
81801
|
+
branchInsideMessage(branch, inside)
|
|
81802
|
+
);
|
|
81803
|
+
}
|
|
81804
|
+
}
|
|
81408
81805
|
options.onPushing?.();
|
|
81409
81806
|
const status = await this.githubBound(
|
|
81410
81807
|
credential,
|
|
@@ -81677,7 +82074,10 @@ var LocalGitHubGateway = class {
|
|
|
81677
82074
|
);
|
|
81678
82075
|
this.policy = new BranchPolicy({
|
|
81679
82076
|
baseBranch: options.baseBranch,
|
|
81680
|
-
protectedBranches: options.protectedBranches
|
|
82077
|
+
protectedBranches: options.protectedBranches,
|
|
82078
|
+
settingsBranch: options.settingsBranch,
|
|
82079
|
+
legacyBranches: options.legacyBranches,
|
|
82080
|
+
namespace: options.branchNamespace
|
|
81681
82081
|
});
|
|
81682
82082
|
}
|
|
81683
82083
|
get repo() {
|
|
@@ -81919,7 +82319,7 @@ var LocalGitHubGateway = class {
|
|
|
81919
82319
|
fatalError,
|
|
81920
82320
|
preflight: this.preflight,
|
|
81921
82321
|
clerkConfigured: this.options.authSnapshot !== void 0,
|
|
81922
|
-
|
|
82322
|
+
branchPolicy: this.policy.describe()
|
|
81923
82323
|
};
|
|
81924
82324
|
}
|
|
81925
82325
|
/**
|
|
@@ -82184,7 +82584,9 @@ var LocalGitHubGateway = class {
|
|
|
82184
82584
|
}
|
|
82185
82585
|
updatePullRequest(number, update, signal) {
|
|
82186
82586
|
return this.credentialed(signal, async (reach) => {
|
|
82187
|
-
|
|
82587
|
+
const refusing = `Refusing to ${update.state === "closed" ? "close" : "update"} pull request #${number}`;
|
|
82588
|
+
assertPullRequestText(refusing, `#${number}`, update);
|
|
82589
|
+
await this.assertOwnPullRequest(reach, number, refusing, signal);
|
|
82188
82590
|
await this.api(
|
|
82189
82591
|
reach,
|
|
82190
82592
|
() => this.octokit.pulls.update({
|
|
@@ -82196,14 +82598,67 @@ var LocalGitHubGateway = class {
|
|
|
82196
82598
|
);
|
|
82197
82599
|
});
|
|
82198
82600
|
}
|
|
82601
|
+
/**
|
|
82602
|
+
* Pull request `number`'s merge state, for any number, and its body only when `updatePullRequest`
|
|
82603
|
+
* would take its head: a branch of this repository that `BranchPolicy.takesPullRequestFrom`
|
|
82604
|
+
* admits (the namespace or a `legacyBranches` entry) and that is not protected, whoever opened
|
|
82605
|
+
* the pull request. Withholding more would protect nothing a write cannot change. When GitHub's
|
|
82606
|
+
* default branch cannot be read, the configured protected set and the default as last read
|
|
82607
|
+
* decide. The number comes from the worker, which a compromised CMS Lambda can steer; the head is
|
|
82608
|
+
* GitHub's record.
|
|
82609
|
+
*/
|
|
82199
82610
|
getPullRequest(number, signal) {
|
|
82200
|
-
return this.credentialed(signal, (reach) =>
|
|
82611
|
+
return this.credentialed(signal, async (reach) => {
|
|
82612
|
+
const { data: data3 } = await this.api(
|
|
82613
|
+
reach,
|
|
82614
|
+
() => this.octokit.pulls.get({ ...this.repo, pull_number: number, request: { signal } })
|
|
82615
|
+
);
|
|
82616
|
+
const head = data3.head.ref;
|
|
82617
|
+
let ours = data3.head.repo?.id === data3.base.repo.id && this.policy.takesPullRequestFrom(head);
|
|
82618
|
+
if (ours) {
|
|
82619
|
+
try {
|
|
82620
|
+
ours = !await this.policy.isProtected(head, () => this.readDefaultBranch(reach, signal));
|
|
82621
|
+
} catch (err) {
|
|
82622
|
+
if (signal?.aborted) throw err;
|
|
82623
|
+
if (this.policy.matchesLastReadDefault(head)) ours = false;
|
|
82624
|
+
gatewayLogWarn(
|
|
82625
|
+
`Could not read GitHub's default branch for pull request #${number} (${redactEgress(getErrorMessage(err))}); judging its head by the configured protected set and the default as last read`
|
|
82626
|
+
);
|
|
82627
|
+
}
|
|
82628
|
+
}
|
|
82629
|
+
return {
|
|
82630
|
+
merged: data3.merged,
|
|
82631
|
+
merged_at: data3.merged_at,
|
|
82632
|
+
state: data3.state,
|
|
82633
|
+
node_id: data3.node_id,
|
|
82634
|
+
body: ours ? data3.body ?? "" : null
|
|
82635
|
+
};
|
|
82636
|
+
});
|
|
82201
82637
|
}
|
|
82202
|
-
|
|
82638
|
+
/**
|
|
82639
|
+
* Read pull request `number` and refuse it unless its head is a branch of this repository that
|
|
82640
|
+
* a pull request may come from (`BranchPolicy.assertPullRequestHeadAllowed`). The number comes
|
|
82641
|
+
* from the worker; the head is GitHub's record, which the worker cannot choose.
|
|
82642
|
+
*/
|
|
82643
|
+
async assertOwnPullRequest(reach, number, refusing, signal) {
|
|
82203
82644
|
const { data: data3 } = await this.api(
|
|
82204
82645
|
reach,
|
|
82205
82646
|
() => this.octokit.pulls.get({ ...this.repo, pull_number: number, request: { signal } })
|
|
82206
82647
|
);
|
|
82648
|
+
const head = data3.head.ref;
|
|
82649
|
+
if (data3.head.repo?.id !== data3.base.repo.id) {
|
|
82650
|
+
throw new GatewayRefusalError(
|
|
82651
|
+
"pull-request",
|
|
82652
|
+
head,
|
|
82653
|
+
"outside-namespace",
|
|
82654
|
+
`${refusing}: its head is not a branch of this repository`
|
|
82655
|
+
);
|
|
82656
|
+
}
|
|
82657
|
+
await this.policy.assertPullRequestHeadAllowed(
|
|
82658
|
+
`${refusing}, whose head is ${JSON.stringify(head)}`,
|
|
82659
|
+
head,
|
|
82660
|
+
() => this.readDefaultBranch(reach, signal)
|
|
82661
|
+
);
|
|
82207
82662
|
return data3;
|
|
82208
82663
|
}
|
|
82209
82664
|
createOrUpdatePullRequest(request, signal) {
|
|
@@ -82223,7 +82678,12 @@ var LocalGitHubGateway = class {
|
|
|
82223
82678
|
}
|
|
82224
82679
|
convertPullRequestToDraft(number, signal) {
|
|
82225
82680
|
return this.credentialed(signal, async (reach) => {
|
|
82226
|
-
const pr = await this.
|
|
82681
|
+
const pr = await this.assertOwnPullRequest(
|
|
82682
|
+
reach,
|
|
82683
|
+
number,
|
|
82684
|
+
`Refusing to convert pull request #${number} to a draft`,
|
|
82685
|
+
signal
|
|
82686
|
+
);
|
|
82227
82687
|
await this.api(
|
|
82228
82688
|
reach,
|
|
82229
82689
|
() => this.octokit.graphql(
|
|
@@ -82655,12 +83115,14 @@ async function trackingTips(gitDir, branches) {
|
|
|
82655
83115
|
var OBJECT_ID = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
82656
83116
|
|
|
82657
83117
|
// ../canopycms/src/worker/cms-worker.ts
|
|
83118
|
+
init_branch_name();
|
|
83119
|
+
init_branch_namespace();
|
|
82658
83120
|
init_deployment_name();
|
|
82659
83121
|
init_error();
|
|
82660
83122
|
init_worker_status();
|
|
82661
83123
|
|
|
82662
83124
|
// ../canopycms/src/version.ts
|
|
82663
|
-
var CANOPYCMS_VERSION = "0.
|
|
83125
|
+
var CANOPYCMS_VERSION = "0.8.1";
|
|
82664
83126
|
|
|
82665
83127
|
// ../canopycms/src/worker/schema-gate.ts
|
|
82666
83128
|
import fs14 from "node:fs/promises";
|
|
@@ -82909,8 +83371,9 @@ async function decideBaseAdvance(input) {
|
|
|
82909
83371
|
return { kind: "advance-expired", hold: { ...hold, expired: true } };
|
|
82910
83372
|
}
|
|
82911
83373
|
|
|
82912
|
-
// ../canopycms/src/worker/
|
|
82913
|
-
import
|
|
83374
|
+
// ../canopycms/src/worker/unpublishable-branches.ts
|
|
83375
|
+
import fs19 from "node:fs/promises";
|
|
83376
|
+
import path20 from "node:path";
|
|
82914
83377
|
|
|
82915
83378
|
// ../canopycms/src/branch-metadata.ts
|
|
82916
83379
|
import fs18 from "node:fs/promises";
|
|
@@ -82987,7 +83450,13 @@ var branchMetadataShape = {
|
|
|
82987
83450
|
historyRewrittenFrom: external_exports.string().optional(),
|
|
82988
83451
|
syncFailureReason: external_exports.string().optional(),
|
|
82989
83452
|
editors: external_exports.array(external_exports.string()).optional(),
|
|
82990
|
-
uncommittedEditors: external_exports.array(external_exports.string()).optional()
|
|
83453
|
+
uncommittedEditors: external_exports.array(external_exports.string()).optional(),
|
|
83454
|
+
// Dropped when malformed: it only decorates the PR body, so it never fails a read.
|
|
83455
|
+
review: external_exports.object({
|
|
83456
|
+
state: external_exports.enum(["approved", "changes-requested"]),
|
|
83457
|
+
by: external_exports.object({ userId: external_exports.string(), name: external_exports.string().optional() }),
|
|
83458
|
+
at: external_exports.string()
|
|
83459
|
+
}).optional().catch(void 0)
|
|
82991
83460
|
};
|
|
82992
83461
|
var branchMetadataSchema = external_exports.object(branchMetadataShape).passthrough();
|
|
82993
83462
|
var branchMetadataFileSchema = external_exports.object({
|
|
@@ -83130,12 +83599,21 @@ var BranchRegistry = class {
|
|
|
83130
83599
|
* genuinely-absent branch costs at most one extra scan per window.
|
|
83131
83600
|
*/
|
|
83132
83601
|
async get(name2) {
|
|
83133
|
-
|
|
83134
|
-
|
|
83602
|
+
return this.find((b10) => b10.branch.name === name2);
|
|
83603
|
+
}
|
|
83604
|
+
/**
|
|
83605
|
+
* Returns the branch whose workspace directory is `key` (`sanitizeBranchName` of its ref),
|
|
83606
|
+
* whatever its name, with {@link get}'s backstop.
|
|
83607
|
+
*/
|
|
83608
|
+
async getByKey(key) {
|
|
83609
|
+
return this.find((b10) => path17.basename(b10.branchRoot) === key);
|
|
83610
|
+
}
|
|
83611
|
+
async find(matches2) {
|
|
83612
|
+
const found = (await this.list()).find(matches2);
|
|
83135
83613
|
if (found) return found;
|
|
83136
83614
|
if (!this.shouldForceRefresh()) return void 0;
|
|
83137
83615
|
const refreshed = await this.regenerate();
|
|
83138
|
-
return refreshed.find(
|
|
83616
|
+
return refreshed.find(matches2);
|
|
83139
83617
|
}
|
|
83140
83618
|
shouldForceRefresh() {
|
|
83141
83619
|
const now = Date.now();
|
|
@@ -83612,9 +84090,8 @@ function mergeBranchMetadata(existing, version, incoming, now = (/* @__PURE__ */
|
|
|
83612
84090
|
}
|
|
83613
84091
|
};
|
|
83614
84092
|
}
|
|
83615
|
-
function buildMergedBranchUpdate(
|
|
84093
|
+
function buildMergedBranchUpdate(now = /* @__PURE__ */ new Date()) {
|
|
83616
84094
|
return {
|
|
83617
|
-
name: branchName,
|
|
83618
84095
|
status: "archived",
|
|
83619
84096
|
pullRequestState: "merged",
|
|
83620
84097
|
mergedAt: now.toISOString(),
|
|
@@ -83627,7 +84104,110 @@ var getBranchMetadataFileManager = (branchRoot, baseRoot, options) => {
|
|
|
83627
84104
|
return BranchMetadataFileManager.get(branchRoot, baseRoot, options);
|
|
83628
84105
|
};
|
|
83629
84106
|
|
|
84107
|
+
// ../canopycms/src/worker/unpublishable-branches.ts
|
|
84108
|
+
init_branch_namespace();
|
|
84109
|
+
init_worker_status();
|
|
84110
|
+
init_error();
|
|
84111
|
+
var MAX_UNPUBLISHABLE_LISTED = 50;
|
|
84112
|
+
function reasonFor(name2, namespace) {
|
|
84113
|
+
if (namespace.startsWith(`${name2}/`)) return "blocks-namespace";
|
|
84114
|
+
if (legacyBranchProblem(name2) !== null) return "unlistable";
|
|
84115
|
+
return void 0;
|
|
84116
|
+
}
|
|
84117
|
+
async function findUnpublishableBranches(ctx, policy) {
|
|
84118
|
+
let entries;
|
|
84119
|
+
try {
|
|
84120
|
+
entries = await fs19.readdir(ctx.contentBranchesPath, { withFileTypes: true });
|
|
84121
|
+
} catch (err) {
|
|
84122
|
+
if (!isNodeError(err) || err.code !== "ENOENT") throw err;
|
|
84123
|
+
if (typeof err.path !== "string" || path20.resolve(err.path) !== path20.resolve(ctx.contentBranchesPath)) {
|
|
84124
|
+
throw err;
|
|
84125
|
+
}
|
|
84126
|
+
entries = [];
|
|
84127
|
+
}
|
|
84128
|
+
const dirs = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
84129
|
+
const branches = [];
|
|
84130
|
+
for (const dir of dirs.sort()) {
|
|
84131
|
+
if (dir.startsWith(".") || dir === ctx.sanitizedBaseBranch) continue;
|
|
84132
|
+
let meta;
|
|
84133
|
+
try {
|
|
84134
|
+
meta = await BranchMetadataFileManager.loadOnly(path20.join(ctx.contentBranchesPath, dir));
|
|
84135
|
+
} catch (err) {
|
|
84136
|
+
const notABranch = err instanceof BranchMetadataCorruptError || isNodeError(err) && err.code === "ENOENT";
|
|
84137
|
+
if (!notABranch) throw err;
|
|
84138
|
+
meta = null;
|
|
84139
|
+
}
|
|
84140
|
+
const branch = meta?.branch;
|
|
84141
|
+
if (!branch || branch.status === "archived") continue;
|
|
84142
|
+
if (publishesBranch(policy, branch.name)) continue;
|
|
84143
|
+
const reason = reasonFor(branch.name, policy.namespace);
|
|
84144
|
+
branches.push(reason ? { name: branch.name, reason } : { name: branch.name });
|
|
84145
|
+
}
|
|
84146
|
+
return { branches: branches.slice(0, MAX_UNPUBLISHABLE_LISTED), count: branches.length };
|
|
84147
|
+
}
|
|
84148
|
+
var REASONS = /* @__PURE__ */ new Set([
|
|
84149
|
+
"blocks-namespace",
|
|
84150
|
+
"unlistable"
|
|
84151
|
+
]);
|
|
84152
|
+
function isReason(value) {
|
|
84153
|
+
return REASONS.has(value);
|
|
84154
|
+
}
|
|
84155
|
+
var MAX_CARRIED_COUNT = 1e5;
|
|
84156
|
+
var MAX_CARRIED_AT_LENGTH = 32;
|
|
84157
|
+
function carriedReport(value) {
|
|
84158
|
+
if (typeof value !== "object" || value === null) return void 0;
|
|
84159
|
+
if (!("branches" in value) || !("count" in value) || !("at" in value)) return void 0;
|
|
84160
|
+
const { branches, count, at } = value;
|
|
84161
|
+
if (typeof at !== "string" || at.length > MAX_CARRIED_AT_LENGTH || !Number.isFinite(Date.parse(at)) || !Array.isArray(branches) || branches.length > MAX_UNPUBLISHABLE_LISTED || typeof count !== "number" || !Number.isInteger(count) || count < branches.length || count > MAX_CARRIED_COUNT) {
|
|
84162
|
+
return void 0;
|
|
84163
|
+
}
|
|
84164
|
+
const carried = [];
|
|
84165
|
+
for (const entry of branches) {
|
|
84166
|
+
if (typeof entry !== "object" || entry === null || !("name" in entry) || typeof entry.name !== "string" || entry.name.length > MAX_BRANCH_NAME_LENGTH2) {
|
|
84167
|
+
return void 0;
|
|
84168
|
+
}
|
|
84169
|
+
if (!("reason" in entry)) {
|
|
84170
|
+
carried.push({ name: entry.name });
|
|
84171
|
+
} else if (isReason(entry.reason)) {
|
|
84172
|
+
carried.push({ name: entry.name, reason: entry.reason });
|
|
84173
|
+
} else {
|
|
84174
|
+
return void 0;
|
|
84175
|
+
}
|
|
84176
|
+
}
|
|
84177
|
+
return { branches: carried, count, at };
|
|
84178
|
+
}
|
|
84179
|
+
async function readCarriedUnpublishableBranches(taskDir) {
|
|
84180
|
+
const parsed = await readStatusObject(taskDir);
|
|
84181
|
+
if (parsed === void 0 || !("unpublishableBranches" in parsed)) return void 0;
|
|
84182
|
+
return carriedReport(parsed.unpublishableBranches);
|
|
84183
|
+
}
|
|
84184
|
+
async function readCarriedGatewayPolicy(taskDir) {
|
|
84185
|
+
const parsed = await readStatusObject(taskDir);
|
|
84186
|
+
if (parsed === void 0 || !("gatewayBranchNamespace" in parsed)) return {};
|
|
84187
|
+
const namespace = parsed.gatewayBranchNamespace;
|
|
84188
|
+
if (typeof namespace !== "string" || branchNamespaceProblem(namespace) !== null) return {};
|
|
84189
|
+
const names = "gatewayProtectedBranches" in parsed ? parsed.gatewayProtectedBranches : void 0;
|
|
84190
|
+
return isExactNameList(names) ? { gatewayBranchNamespace: namespace, gatewayProtectedBranches: names } : { gatewayBranchNamespace: namespace };
|
|
84191
|
+
}
|
|
84192
|
+
function isExactNameList(value) {
|
|
84193
|
+
return Array.isArray(value) && value.length <= MAX_PROTECTED_BRANCHES + 1 && value.every(
|
|
84194
|
+
(name2) => typeof name2 === "string" && name2.length > 0 && name2.length <= MAX_BRANCH_NAME_LENGTH2 && !name2.includes("*")
|
|
84195
|
+
);
|
|
84196
|
+
}
|
|
84197
|
+
async function readStatusObject(taskDir) {
|
|
84198
|
+
try {
|
|
84199
|
+
const parsed = JSON.parse(
|
|
84200
|
+
await fs19.readFile(path20.join(taskDir, WORKER_STATUS_FILE), "utf-8")
|
|
84201
|
+
);
|
|
84202
|
+
return typeof parsed === "object" && parsed !== null ? parsed : void 0;
|
|
84203
|
+
} catch {
|
|
84204
|
+
return void 0;
|
|
84205
|
+
}
|
|
84206
|
+
}
|
|
84207
|
+
|
|
83630
84208
|
// ../canopycms/src/worker/task-runner.ts
|
|
84209
|
+
import fs21 from "node:fs/promises";
|
|
84210
|
+
init_branch_name();
|
|
83631
84211
|
init_error();
|
|
83632
84212
|
|
|
83633
84213
|
// ../canopycms/src/worker/github-gateway-wire.ts
|
|
@@ -83689,9 +84269,12 @@ var answers = {
|
|
|
83689
84269
|
fatalError: message.nullable(),
|
|
83690
84270
|
preflight: external_exports.enum(["not-an-app", "verified", "unverified", "pending"]),
|
|
83691
84271
|
clerkConfigured: external_exports.boolean(),
|
|
83692
|
-
|
|
84272
|
+
branchPolicy: external_exports.object({
|
|
83693
84273
|
configured: external_exports.array(name).max(MAX_PROTECTED_BRANCHES + 1),
|
|
83694
|
-
githubDefault: name.nullable()
|
|
84274
|
+
githubDefault: name.nullable(),
|
|
84275
|
+
namespace: name,
|
|
84276
|
+
legacy: external_exports.array(name).max(MAX_LEGACY_BRANCHES),
|
|
84277
|
+
settingsBranch: name.nullable()
|
|
83695
84278
|
}).strict()
|
|
83696
84279
|
}).strict(),
|
|
83697
84280
|
defaultBranch: external_exports.object({ branch: name }).strict(),
|
|
@@ -83793,7 +84376,15 @@ var errorEnvelope = external_exports.discriminatedUnion("kind", [
|
|
|
83793
84376
|
push: external_exports.boolean(),
|
|
83794
84377
|
operation: external_exports.enum(["push", "delete", "pull-request"]),
|
|
83795
84378
|
branch: name,
|
|
83796
|
-
reason: external_exports.enum([
|
|
84379
|
+
reason: external_exports.enum([
|
|
84380
|
+
"invalid",
|
|
84381
|
+
"protected",
|
|
84382
|
+
"settings",
|
|
84383
|
+
"other-settings",
|
|
84384
|
+
"outside-namespace",
|
|
84385
|
+
"not-a-commit",
|
|
84386
|
+
"too-long"
|
|
84387
|
+
]),
|
|
83797
84388
|
message
|
|
83798
84389
|
}).strict(),
|
|
83799
84390
|
external_exports.object({
|
|
@@ -83995,7 +84586,8 @@ function decodePushHeader(value) {
|
|
|
83995
84586
|
}
|
|
83996
84587
|
|
|
83997
84588
|
// ../canopycms/src/worker/history-rewrite.ts
|
|
83998
|
-
import
|
|
84589
|
+
import path21 from "node:path";
|
|
84590
|
+
init_branch_name();
|
|
83999
84591
|
init_error();
|
|
84000
84592
|
async function readPublishedSha(ctx, branchRef) {
|
|
84001
84593
|
try {
|
|
@@ -84010,19 +84602,26 @@ async function readPublishedSha(ctx, branchRef) {
|
|
|
84010
84602
|
return null;
|
|
84011
84603
|
}
|
|
84012
84604
|
}
|
|
84013
|
-
async function markHistoryRewritten(ctx, branchPath,
|
|
84014
|
-
const current = await BranchMetadataFileManager.loadOnly(branchPath);
|
|
84015
|
-
if (typeof current?.branch.historyRewrittenFrom === "string") return;
|
|
84605
|
+
async function markHistoryRewritten(ctx, branchPath, branchRef, expectedSha) {
|
|
84016
84606
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
84017
|
-
|
|
84607
|
+
let marked = false;
|
|
84608
|
+
await meta.update((current) => {
|
|
84609
|
+
marked = current?.branch.name === branchRef;
|
|
84610
|
+
if (!marked || typeof current?.branch.historyRewrittenFrom === "string") return null;
|
|
84611
|
+
return { branch: { historyRewrittenFrom: expectedSha } };
|
|
84612
|
+
});
|
|
84613
|
+
return marked;
|
|
84018
84614
|
}
|
|
84019
|
-
async function clearHistoryRewrittenMarker(ctx, branchPath,
|
|
84615
|
+
async function clearHistoryRewrittenMarker(ctx, branchPath, branchRef) {
|
|
84020
84616
|
try {
|
|
84021
84617
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
84022
|
-
await meta.
|
|
84618
|
+
await meta.saveIf(
|
|
84619
|
+
{ branch: { historyRewrittenFrom: void 0 } },
|
|
84620
|
+
(current) => current?.branch.name === branchRef && typeof current.branch.historyRewrittenFrom === "string"
|
|
84621
|
+
);
|
|
84023
84622
|
} catch (err) {
|
|
84024
84623
|
workerLogWarn(
|
|
84025
|
-
` Failed to clear history-rewrite marker for ${
|
|
84624
|
+
` Failed to clear history-rewrite marker for ${branchRef}: ${getErrorMessage(err)}`
|
|
84026
84625
|
);
|
|
84027
84626
|
}
|
|
84028
84627
|
}
|
|
@@ -84050,7 +84649,13 @@ async function forcePublishToLocalRemote(ctx, branchPath, branchRef, expectedSha
|
|
|
84050
84649
|
return false;
|
|
84051
84650
|
}
|
|
84052
84651
|
}
|
|
84053
|
-
async function enqueueGitHubPush(ctx, branchRef) {
|
|
84652
|
+
async function enqueueGitHubPush(ctx, branchRef, gatewayPolicy) {
|
|
84653
|
+
if (gatewayPolicy && !publishesBranch(gatewayPolicy, branchRef)) {
|
|
84654
|
+
workerLog(
|
|
84655
|
+
` Not queueing a GitHub push for ${escapeForLog(branchRef)}: the GitHub gateway would refuse it`
|
|
84656
|
+
);
|
|
84657
|
+
return;
|
|
84658
|
+
}
|
|
84054
84659
|
try {
|
|
84055
84660
|
for (const status of ["pending", "processing"]) {
|
|
84056
84661
|
const inFlight = await listTasks(ctx.taskDir, status);
|
|
@@ -84065,7 +84670,7 @@ async function enqueueGitHubPush(ctx, branchRef) {
|
|
|
84065
84670
|
}
|
|
84066
84671
|
}
|
|
84067
84672
|
async function reconcilePendingRewrite(ctx, options) {
|
|
84068
|
-
const { branchPath, branchDir, branchRef, headSha, marker } = options;
|
|
84673
|
+
const { branchPath, branchDir, branchRef, headSha, marker, gatewayPolicy } = options;
|
|
84069
84674
|
const publishedSha = await readPublishedSha(ctx, branchRef);
|
|
84070
84675
|
if (publishedSha === null) {
|
|
84071
84676
|
workerLogWarn(
|
|
@@ -84074,12 +84679,12 @@ async function reconcilePendingRewrite(ctx, options) {
|
|
|
84074
84679
|
return;
|
|
84075
84680
|
}
|
|
84076
84681
|
if (publishedSha === headSha) {
|
|
84077
|
-
await enqueueGitHubPush(ctx, branchRef);
|
|
84682
|
+
await enqueueGitHubPush(ctx, branchRef, gatewayPolicy);
|
|
84078
84683
|
return;
|
|
84079
84684
|
}
|
|
84080
84685
|
if (publishedSha === marker) {
|
|
84081
84686
|
if (await forcePublishToLocalRemote(ctx, branchPath, branchRef, marker)) {
|
|
84082
|
-
await enqueueGitHubPush(ctx, branchRef);
|
|
84687
|
+
await enqueueGitHubPush(ctx, branchRef, gatewayPolicy);
|
|
84083
84688
|
}
|
|
84084
84689
|
return;
|
|
84085
84690
|
}
|
|
@@ -84089,7 +84694,7 @@ async function reconcilePendingRewrite(ctx, options) {
|
|
|
84089
84694
|
}
|
|
84090
84695
|
async function hasPendingHistoryRewrite(ctx, branchName) {
|
|
84091
84696
|
try {
|
|
84092
|
-
const branchPath =
|
|
84697
|
+
const branchPath = path21.join(ctx.contentBranchesPath, sanitizeBranchName(branchName));
|
|
84093
84698
|
const metaFile = await BranchMetadataFileManager.loadOnly(branchPath);
|
|
84094
84699
|
return typeof metaFile?.branch.historyRewrittenFrom === "string";
|
|
84095
84700
|
} catch {
|
|
@@ -84101,8 +84706,8 @@ async function hasPendingHistoryRewrite(ctx, branchName) {
|
|
|
84101
84706
|
init_worker_status();
|
|
84102
84707
|
|
|
84103
84708
|
// ../canopycms/src/comment-store.ts
|
|
84104
|
-
import
|
|
84105
|
-
import
|
|
84709
|
+
import fs20 from "node:fs/promises";
|
|
84710
|
+
import path22 from "node:path";
|
|
84106
84711
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
84107
84712
|
init_error();
|
|
84108
84713
|
var CommentStoreConflictError = class extends Error {
|
|
@@ -84114,9 +84719,11 @@ var CommentStoreConflictError = class extends Error {
|
|
|
84114
84719
|
function ownThread(data3, threadId) {
|
|
84115
84720
|
return Object.prototype.hasOwnProperty.call(data3.threads, threadId) ? data3.threads[threadId] : void 0;
|
|
84116
84721
|
}
|
|
84722
|
+
var CommentsFileMalformedError = class extends Error {
|
|
84723
|
+
};
|
|
84117
84724
|
var CommentStore = class {
|
|
84118
84725
|
constructor(branchRoot, options) {
|
|
84119
|
-
this.filePath =
|
|
84726
|
+
this.filePath = path22.join(path22.resolve(branchRoot), ".canopy-meta", "comments.json");
|
|
84120
84727
|
this.settleMs = options?.settleMs;
|
|
84121
84728
|
}
|
|
84122
84729
|
/**
|
|
@@ -84126,7 +84733,7 @@ var CommentStore = class {
|
|
|
84126
84733
|
async listThreadsStrict() {
|
|
84127
84734
|
let content;
|
|
84128
84735
|
try {
|
|
84129
|
-
content = await
|
|
84736
|
+
content = await fs20.readFile(this.filePath, "utf-8");
|
|
84130
84737
|
} catch (err) {
|
|
84131
84738
|
if (isNotFoundError2(err)) return [];
|
|
84132
84739
|
throw err;
|
|
@@ -84134,7 +84741,7 @@ var CommentStore = class {
|
|
|
84134
84741
|
const parsed = JSON.parse(content);
|
|
84135
84742
|
const threads = typeof parsed === "object" && parsed !== null ? parsed.threads : void 0;
|
|
84136
84743
|
if (typeof threads !== "object" || threads === null) {
|
|
84137
|
-
throw new
|
|
84744
|
+
throw new CommentsFileMalformedError("comments.json has no threads object");
|
|
84138
84745
|
}
|
|
84139
84746
|
return Object.values(threads);
|
|
84140
84747
|
}
|
|
@@ -84150,7 +84757,7 @@ var CommentStore = class {
|
|
|
84150
84757
|
*/
|
|
84151
84758
|
async loadWithVersion() {
|
|
84152
84759
|
try {
|
|
84153
|
-
const content = await
|
|
84760
|
+
const content = await fs20.readFile(this.filePath, "utf-8");
|
|
84154
84761
|
const parsed = JSON.parse(content);
|
|
84155
84762
|
const version = parsed.version ?? 0;
|
|
84156
84763
|
return { data: { ...parsed, version }, version };
|
|
@@ -84321,24 +84928,48 @@ var CommentStore = class {
|
|
|
84321
84928
|
init_error();
|
|
84322
84929
|
var SYNC_PR_COMMENTS_ACTION = "sync-pr-comments";
|
|
84323
84930
|
async function renderPrCommentsBody(options) {
|
|
84324
|
-
const
|
|
84325
|
-
|
|
84326
|
-
|
|
84327
|
-
|
|
84328
|
-
|
|
84329
|
-
|
|
84931
|
+
const original = options.body;
|
|
84932
|
+
let next = original;
|
|
84933
|
+
try {
|
|
84934
|
+
const threads = await new CommentStore(options.branchRoot).listThreadsStrict();
|
|
84935
|
+
next = mergeCommentsBlock(next, buildCommentsBlock(threads, options.branch, options.editorUrl)) ?? next;
|
|
84936
|
+
} catch (err) {
|
|
84937
|
+
if (!(err instanceof SyntaxError || err instanceof CommentsFileMalformedError)) throw err;
|
|
84938
|
+
options.warn(
|
|
84939
|
+
`Could not read the editor comments of ${options.branch}; the PR keeps its summary: ${getErrorMessage(err)}`
|
|
84940
|
+
);
|
|
84941
|
+
}
|
|
84942
|
+
try {
|
|
84943
|
+
const file = await readBranchMetadataFile(options.branchRoot);
|
|
84944
|
+
if (file) next = mergeReviewBlock(next, buildReviewBlock(file.branch.review)) ?? next;
|
|
84945
|
+
} catch (err) {
|
|
84946
|
+
if (!(err instanceof BranchMetadataCorruptError)) throw err;
|
|
84947
|
+
options.warn(
|
|
84948
|
+
`Could not read the review state of ${options.branch}; the PR keeps its review block: ${getErrorMessage(err)}`
|
|
84949
|
+
);
|
|
84950
|
+
}
|
|
84951
|
+
return next === original ? void 0 : next;
|
|
84330
84952
|
}
|
|
84331
84953
|
async function refreshCommentsBlock(options) {
|
|
84954
|
+
let section = options.section;
|
|
84332
84955
|
try {
|
|
84333
84956
|
const threads = await new CommentStore(options.branchRoot).listThreadsStrict();
|
|
84334
84957
|
const block = buildCommentsBlock(threads, options.branch, options.editorUrl);
|
|
84335
|
-
|
|
84958
|
+
section = mergeCommentsBlock(section, block) ?? section;
|
|
84336
84959
|
} catch (err) {
|
|
84337
84960
|
options.warn(
|
|
84338
84961
|
`Could not re-read the editor comments of ${options.branch}; the PR gets the summary from submit time: ${getErrorMessage(err)}`
|
|
84339
84962
|
);
|
|
84340
|
-
return options.section;
|
|
84341
84963
|
}
|
|
84964
|
+
try {
|
|
84965
|
+
const file = await readBranchMetadataFile(options.branchRoot);
|
|
84966
|
+
if (file) section = mergeReviewBlock(section, buildReviewBlock(file.branch.review)) ?? section;
|
|
84967
|
+
} catch (err) {
|
|
84968
|
+
options.warn(
|
|
84969
|
+
`Could not re-read the review state of ${options.branch}; the PR gets it from submit time: ${getErrorMessage(err)}`
|
|
84970
|
+
);
|
|
84971
|
+
}
|
|
84972
|
+
return section;
|
|
84342
84973
|
}
|
|
84343
84974
|
|
|
84344
84975
|
// ../canopycms/src/worker/task-runner.ts
|
|
@@ -84492,7 +85123,7 @@ async function executeTask(ctx, task, signal) {
|
|
|
84492
85123
|
{
|
|
84493
85124
|
head: branch,
|
|
84494
85125
|
base: optionalString(payload3, "baseBranch", ctx.baseBranch),
|
|
84495
|
-
title: optionalString(payload3, "title", `Submit ${branch}`),
|
|
85126
|
+
title: optionalString(payload3, "title", `Submit ${editorBranchOf(payload3, branch)}`),
|
|
84496
85127
|
body: optionalString(payload3, "body", "")
|
|
84497
85128
|
},
|
|
84498
85129
|
signal
|
|
@@ -84507,7 +85138,7 @@ async function executeTask(ctx, task, signal) {
|
|
|
84507
85138
|
await ctx.github().updatePullRequest(
|
|
84508
85139
|
prNumber2,
|
|
84509
85140
|
{
|
|
84510
|
-
title: optionalString(payload3, "title", `Submit ${branch}`),
|
|
85141
|
+
title: optionalString(payload3, "title", `Submit ${editorBranchOf(payload3, branch)}`),
|
|
84511
85142
|
body: optionalString(payload3, "body", "")
|
|
84512
85143
|
},
|
|
84513
85144
|
signal
|
|
@@ -84533,7 +85164,7 @@ async function executeTask(ctx, task, signal) {
|
|
|
84533
85164
|
const queuedBody = optionalString(payload3, "body", "");
|
|
84534
85165
|
const body = mergeSectionIntoBody ? await refreshCommentsBlock({
|
|
84535
85166
|
branchRoot: ctx.branchWorkspacePath(branch),
|
|
84536
|
-
branch,
|
|
85167
|
+
branch: editorBranchOf(payload3, branch),
|
|
84537
85168
|
editorUrl: typeof payload3.editorUrl === "string" ? payload3.editorUrl : void 0,
|
|
84538
85169
|
section: queuedBody,
|
|
84539
85170
|
warn: workerLogWarn
|
|
@@ -84544,7 +85175,7 @@ async function executeTask(ctx, task, signal) {
|
|
|
84544
85175
|
{
|
|
84545
85176
|
head: branch,
|
|
84546
85177
|
base,
|
|
84547
|
-
title: optionalString(payload3, "title", `Submit ${branch}`),
|
|
85178
|
+
title: optionalString(payload3, "title", `Submit ${editorBranchOf(payload3, branch)}`),
|
|
84548
85179
|
body,
|
|
84549
85180
|
// Content submits (api/github-sync.ts) set both.
|
|
84550
85181
|
markReadyIfDraft: payload3.markReadyIfDraft === true,
|
|
@@ -84633,57 +85264,67 @@ async function executeTask(ctx, task, signal) {
|
|
|
84633
85264
|
}
|
|
84634
85265
|
const pr = await ctx.github().getPullRequest(prNumber2, signal);
|
|
84635
85266
|
if (pr.state !== "open") return { updated: false, skipped: "not-open" };
|
|
85267
|
+
if (pr.body === null) {
|
|
85268
|
+
workerLog(`Not updating PR #${prNumber2} for ${branch}: the gateway withholds its body`);
|
|
85269
|
+
return { updated: false, skipped: "body-withheld" };
|
|
85270
|
+
}
|
|
84636
85271
|
const body = await renderPrCommentsBody({
|
|
84637
85272
|
branchRoot: branchPath,
|
|
84638
|
-
branch,
|
|
85273
|
+
branch: editorBranchOf(payload3, branch),
|
|
84639
85274
|
editorUrl,
|
|
84640
|
-
body: pr.body
|
|
84641
|
-
|
|
84642
|
-
if (err instanceof SyntaxError) throw new PermanentTaskError(getErrorMessage(err));
|
|
84643
|
-
throw err;
|
|
85275
|
+
body: pr.body,
|
|
85276
|
+
warn: workerLogWarn
|
|
84644
85277
|
});
|
|
84645
85278
|
if (body === void 0) return { updated: false, skipped: "unchanged" };
|
|
84646
85279
|
await ctx.github().updatePullRequest(prNumber2, { body }, signal);
|
|
84647
|
-
workerLog(`Updated the
|
|
85280
|
+
workerLog(`Updated the comment and review blocks of PR #${prNumber2} for ${branch}`);
|
|
84648
85281
|
return { updated: true };
|
|
84649
85282
|
}
|
|
84650
85283
|
default:
|
|
84651
85284
|
throw new PermanentTaskError(`Unknown task action: ${action}`);
|
|
84652
85285
|
}
|
|
84653
85286
|
}
|
|
85287
|
+
function editorBranchOf(payload3, branch) {
|
|
85288
|
+
return optionalString(payload3, "editorBranch", branch);
|
|
85289
|
+
}
|
|
84654
85290
|
function metadataBranchOf(task) {
|
|
84655
85291
|
if (task.action === "delete-remote-branch" || task.action === SYNC_PR_COMMENTS_ACTION) return null;
|
|
84656
85292
|
return typeof task.payload.branch === "string" ? task.payload.branch : null;
|
|
84657
85293
|
}
|
|
85294
|
+
function noMetadataToRecord(branch, what) {
|
|
85295
|
+
workerLogWarn(`Not recording the ${what} for ${branch}: its workspace has no branch.json for it`);
|
|
85296
|
+
}
|
|
84658
85297
|
async function updateBranchMetadata(ctx, task, result) {
|
|
84659
85298
|
const branch = metadataBranchOf(task);
|
|
84660
85299
|
if (!branch) return;
|
|
84661
85300
|
const branchPath = ctx.branchWorkspacePath(branch);
|
|
84662
85301
|
try {
|
|
84663
|
-
await
|
|
85302
|
+
await fs21.stat(branchPath);
|
|
84664
85303
|
} catch {
|
|
84665
85304
|
return;
|
|
84666
85305
|
}
|
|
84667
85306
|
try {
|
|
84668
85307
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
84669
|
-
const
|
|
84670
|
-
name
|
|
84671
|
-
|
|
84672
|
-
|
|
84673
|
-
|
|
84674
|
-
|
|
84675
|
-
|
|
84676
|
-
|
|
84677
|
-
|
|
84678
|
-
|
|
84679
|
-
|
|
84680
|
-
|
|
84681
|
-
|
|
84682
|
-
|
|
84683
|
-
|
|
84684
|
-
|
|
84685
|
-
|
|
84686
|
-
|
|
85308
|
+
const saved = await meta.update((existing) => {
|
|
85309
|
+
if (existing?.branch.name !== branch) return null;
|
|
85310
|
+
const updates = {
|
|
85311
|
+
syncStatus: "synced",
|
|
85312
|
+
// save()'s merge only overwrites keys present in this update, so a prior
|
|
85313
|
+
// syncFailureReason would survive this successful sync forever unless
|
|
85314
|
+
// cleared explicitly (same pattern as rebaseFailure elsewhere).
|
|
85315
|
+
syncFailureReason: void 0
|
|
85316
|
+
};
|
|
85317
|
+
if (result.prUrl) updates.pullRequestUrl = result.prUrl;
|
|
85318
|
+
if (result.prNumber) {
|
|
85319
|
+
updates.pullRequestNumber = result.prNumber;
|
|
85320
|
+
const terminal = existing.branch.status === "archived" || existing.branch.pullRequestState === "merged" || existing.branch.pullRequestState === "closed";
|
|
85321
|
+
if (!terminal) {
|
|
85322
|
+
updates.pullRequestState = "open";
|
|
85323
|
+
}
|
|
85324
|
+
}
|
|
85325
|
+
return { branch: updates };
|
|
85326
|
+
});
|
|
85327
|
+
if (saved === null) noMetadataToRecord(branch, `${task.action} outcome`);
|
|
84687
85328
|
} catch (err) {
|
|
84688
85329
|
workerLogError(
|
|
84689
85330
|
`Failed to update metadata for ${branch}:`,
|
|
@@ -84696,13 +85337,13 @@ async function updateBranchMetadataOnFailure(ctx, task, error3, options) {
|
|
|
84696
85337
|
if (!branch) return;
|
|
84697
85338
|
const branchPath = ctx.branchWorkspacePath(branch);
|
|
84698
85339
|
try {
|
|
84699
|
-
await
|
|
85340
|
+
await fs21.stat(branchPath);
|
|
84700
85341
|
} catch {
|
|
84701
85342
|
return;
|
|
84702
85343
|
}
|
|
84703
85344
|
try {
|
|
84704
85345
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
84705
|
-
const failed = {
|
|
85346
|
+
const failed = { syncStatus: "sync-failed", syncFailureReason: error3 };
|
|
84706
85347
|
const submittedAt = task.payload.submittedAt;
|
|
84707
85348
|
const unlocked = options.unlock && typeof submittedAt === "string" && await meta.saveIf(
|
|
84708
85349
|
{
|
|
@@ -84712,9 +85353,15 @@ async function updateBranchMetadataOnFailure(ctx, task, error3, options) {
|
|
|
84712
85353
|
syncFailureReason: `${error3} The branch is unlocked for editing; save a change, then submit again.`
|
|
84713
85354
|
}
|
|
84714
85355
|
},
|
|
84715
|
-
(existing) => existing?.branch.status === "submitted" && existing.branch.pullRequestNumber === void 0 && existing.branch.submittedAt === submittedAt
|
|
85356
|
+
(existing) => existing?.branch.name === branch && existing.branch.status === "submitted" && existing.branch.pullRequestNumber === void 0 && existing.branch.submittedAt === submittedAt
|
|
84716
85357
|
) !== null;
|
|
84717
|
-
if (!unlocked)
|
|
85358
|
+
if (!unlocked) {
|
|
85359
|
+
const saved = await meta.saveIf(
|
|
85360
|
+
{ branch: failed },
|
|
85361
|
+
(existing) => existing?.branch.name === branch
|
|
85362
|
+
);
|
|
85363
|
+
if (saved === null) noMetadataToRecord(branch, `${task.action} failure`);
|
|
85364
|
+
}
|
|
84718
85365
|
} catch (err) {
|
|
84719
85366
|
workerLogError(
|
|
84720
85367
|
`Failed to update failure metadata for ${branch}:`,
|
|
@@ -84808,32 +85455,35 @@ function logPushOutcome(ctx, branch, outcome, note) {
|
|
|
84808
85455
|
async function recordPushedToGitHub(ctx, branchPath, branch) {
|
|
84809
85456
|
if (isSettingsBranch(branch)) return;
|
|
84810
85457
|
try {
|
|
84811
|
-
await
|
|
85458
|
+
await fs21.stat(branchPath);
|
|
84812
85459
|
} catch {
|
|
84813
85460
|
return;
|
|
84814
85461
|
}
|
|
84815
85462
|
try {
|
|
84816
|
-
await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).
|
|
84817
|
-
branch: {
|
|
84818
|
-
|
|
85463
|
+
const saved = await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).saveIf(
|
|
85464
|
+
{ branch: { pushedToGitHubAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
85465
|
+
(existing) => existing?.branch.name === branch
|
|
85466
|
+
);
|
|
85467
|
+
if (saved === null) noMetadataToRecord(branch, "GitHub push");
|
|
84819
85468
|
} catch (err) {
|
|
84820
85469
|
workerLogError(`Failed to record the GitHub push for ${branch}:`, getErrorMessage(err));
|
|
84821
85470
|
}
|
|
84822
85471
|
}
|
|
84823
85472
|
|
|
84824
85473
|
// ../canopycms/src/worker/rebase.ts
|
|
84825
|
-
import
|
|
84826
|
-
import
|
|
85474
|
+
import fs23 from "node:fs/promises";
|
|
85475
|
+
import path25 from "node:path";
|
|
85476
|
+
init_branch_name();
|
|
84827
85477
|
init_normalize();
|
|
84828
85478
|
init_types2();
|
|
84829
85479
|
|
|
84830
85480
|
// ../canopycms/src/utils/content-write-lock.ts
|
|
84831
85481
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
84832
|
-
import
|
|
85482
|
+
import path23 from "node:path";
|
|
84833
85483
|
var META_DIR2 = ".canopy-meta";
|
|
84834
85484
|
var CONTENT_WRITE_LOCK_NAME = "content-write.lock";
|
|
84835
85485
|
function lockTargetDir(branchRoot) {
|
|
84836
|
-
return
|
|
85486
|
+
return path23.join(path23.resolve(branchRoot), META_DIR2);
|
|
84837
85487
|
}
|
|
84838
85488
|
var CONTENT_WRITE_LOCK_STALE_MS = 3e4;
|
|
84839
85489
|
function tryAcquireContentWriteLock(branchRoot, onCompromised) {
|
|
@@ -84848,8 +85498,8 @@ function tryAcquireContentWriteLock(branchRoot, onCompromised) {
|
|
|
84848
85498
|
var heldRoots = new AsyncLocalStorage();
|
|
84849
85499
|
|
|
84850
85500
|
// ../canopycms/src/worker/provisioned-workspace.ts
|
|
84851
|
-
import
|
|
84852
|
-
import
|
|
85501
|
+
import fs22 from "node:fs/promises";
|
|
85502
|
+
import path24 from "node:path";
|
|
84853
85503
|
init_error();
|
|
84854
85504
|
async function holdProvisionedWorkspace(contentBranchesPath, dirName) {
|
|
84855
85505
|
let release2;
|
|
@@ -84869,13 +85519,13 @@ async function holdProvisionedWorkspace(contentBranchesPath, dirName) {
|
|
|
84869
85519
|
if (isNodeError(err) && err.code === "ELOCKED") return { kind: "locked" };
|
|
84870
85520
|
throw err;
|
|
84871
85521
|
}
|
|
84872
|
-
const root5 =
|
|
85522
|
+
const root5 = path24.join(contentBranchesPath, dirName);
|
|
84873
85523
|
const [gitIsDir, hasMetadata] = await Promise.all([
|
|
84874
|
-
|
|
85524
|
+
fs22.stat(path24.join(root5, ".git")).then(
|
|
84875
85525
|
(stat) => stat.isDirectory(),
|
|
84876
85526
|
() => false
|
|
84877
85527
|
),
|
|
84878
|
-
|
|
85528
|
+
fs22.stat(path24.join(root5, BRANCH_META_DIR, BRANCH_META_FILE)).then(
|
|
84879
85529
|
() => true,
|
|
84880
85530
|
() => false
|
|
84881
85531
|
)
|
|
@@ -84897,34 +85547,35 @@ init_error();
|
|
|
84897
85547
|
async function pollMergeState(ctx, branchDir, branchPath, metaFile) {
|
|
84898
85548
|
const prNumber2 = metaFile?.branch.pullRequestNumber;
|
|
84899
85549
|
if (!prNumber2) return;
|
|
85550
|
+
const sameBranch2 = (current) => current?.branch.name === metaFile?.branch.name;
|
|
84900
85551
|
const controller = new AbortController();
|
|
84901
85552
|
const timer = setTimeout(() => controller.abort(), ctx.taskTimeoutMs);
|
|
84902
85553
|
try {
|
|
84903
85554
|
const data3 = await ctx.github().getPullRequest(prNumber2, controller.signal);
|
|
84904
85555
|
if (data3.merged) {
|
|
84905
85556
|
const meta2 = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
84906
|
-
await meta2.
|
|
84907
|
-
|
|
84908
|
-
|
|
84909
|
-
|
|
84910
|
-
|
|
84911
|
-
|
|
84912
|
-
workerLog(` PR #${prNumber2} for ${branchDir} is merged -> archived`);
|
|
85557
|
+
const saved2 = await meta2.saveIf(
|
|
85558
|
+
{
|
|
85559
|
+
branch: buildMergedBranchUpdate(data3.merged_at ? new Date(data3.merged_at) : void 0)
|
|
85560
|
+
},
|
|
85561
|
+
sameBranch2
|
|
85562
|
+
);
|
|
85563
|
+
if (saved2) workerLog(` PR #${prNumber2} for ${branchDir} is merged -> archived`);
|
|
84913
85564
|
return;
|
|
84914
85565
|
}
|
|
84915
85566
|
const newState = data3.state === "closed" ? "closed" : "open";
|
|
84916
85567
|
const currentMeta = await BranchMetadataFileManager.loadOnly(branchPath);
|
|
84917
85568
|
if (currentMeta?.branch.pullRequestState === newState) return;
|
|
84918
85569
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
84919
|
-
await meta.
|
|
84920
|
-
workerLog(` PR #${prNumber2} for ${branchDir}: pullRequestState -> ${newState}`);
|
|
85570
|
+
const saved = await meta.saveIf({ branch: { pullRequestState: newState } }, sameBranch2);
|
|
85571
|
+
if (saved) workerLog(` PR #${prNumber2} for ${branchDir}: pullRequestState -> ${newState}`);
|
|
84921
85572
|
} catch (err) {
|
|
84922
85573
|
workerLogWarn(` Failed to poll PR #${prNumber2} for ${branchDir}: ${getErrorMessage(err)}`);
|
|
84923
85574
|
} finally {
|
|
84924
85575
|
clearTimeout(timer);
|
|
84925
85576
|
}
|
|
84926
85577
|
}
|
|
84927
|
-
async function recordRebaseFailure(ctx, branchPath, branchDir, message2) {
|
|
85578
|
+
async function recordRebaseFailure(ctx, branchPath, branchDir, message2, branchRef) {
|
|
84928
85579
|
const RECORD_REFRESH_MS = 60 * 60 * 1e3;
|
|
84929
85580
|
const redactedMessage = redactCredentials(message2);
|
|
84930
85581
|
try {
|
|
@@ -84941,12 +85592,10 @@ async function recordRebaseFailure(ctx, branchPath, branchDir, message2) {
|
|
|
84941
85592
|
const nowIso = now.toISOString();
|
|
84942
85593
|
const firstAt = sameMessage ? prior.firstAt : nowIso;
|
|
84943
85594
|
const meta = getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath);
|
|
84944
|
-
await meta.
|
|
84945
|
-
branch: {
|
|
84946
|
-
|
|
84947
|
-
|
|
84948
|
-
}
|
|
84949
|
-
});
|
|
85595
|
+
await meta.saveIf(
|
|
85596
|
+
{ branch: { rebaseFailure: { message: redactedMessage, firstAt, lastAt: nowIso } } },
|
|
85597
|
+
(current) => current !== null && (branchRef === void 0 || current.branch.name === branchRef)
|
|
85598
|
+
);
|
|
84950
85599
|
} catch (err) {
|
|
84951
85600
|
workerLogWarn(` Failed to record rebase failure for ${branchDir}: ${getErrorMessage(err)}`);
|
|
84952
85601
|
}
|
|
@@ -85015,13 +85664,13 @@ async function runRebaseRounds(ctx, branchGit, branchDir, fetchedBaseTip, isLock
|
|
|
85015
85664
|
function conflictFilesToContentIds(conflictedFiles, contentRoot) {
|
|
85016
85665
|
const normalizedContentRoot = normalizeFilesystemPath(contentRoot);
|
|
85017
85666
|
const conflictIds = [...new Set(conflictedFiles)].map((f9) => {
|
|
85018
|
-
const fileId = extractIdFromFilename(
|
|
85667
|
+
const fileId = extractIdFromFilename(path25.basename(f9));
|
|
85019
85668
|
if (fileId) return fileId;
|
|
85020
|
-
const parentDir =
|
|
85669
|
+
const parentDir = path25.basename(path25.dirname(f9));
|
|
85021
85670
|
const dirId = extractIdFromFilename(parentDir);
|
|
85022
85671
|
if (dirId) return dirId;
|
|
85023
|
-
const parentPath = normalizeFilesystemPath(
|
|
85024
|
-
if (
|
|
85672
|
+
const parentPath = normalizeFilesystemPath(path25.dirname(f9));
|
|
85673
|
+
if (path25.basename(f9) === ".collection.json" && parentPath === normalizedContentRoot) {
|
|
85025
85674
|
return ROOT_COLLECTION_ID;
|
|
85026
85675
|
}
|
|
85027
85676
|
return null;
|
|
@@ -85036,28 +85685,33 @@ function recordConflicts(recorded, found) {
|
|
|
85036
85685
|
};
|
|
85037
85686
|
}
|
|
85038
85687
|
async function carryForwardRewrittenHistory(ctx, args) {
|
|
85039
|
-
const { branchPath, branchDir, branchRef, publishedSha, preRebaseHead } = args;
|
|
85688
|
+
const { branchPath, branchDir, branchRef, publishedSha, preRebaseHead, gatewayPolicy } = args;
|
|
85040
85689
|
if (publishedSha !== null) {
|
|
85041
85690
|
if (publishedSha === preRebaseHead) {
|
|
85042
|
-
await markHistoryRewritten(ctx, branchPath,
|
|
85691
|
+
if (!await markHistoryRewritten(ctx, branchPath, branchRef, publishedSha)) {
|
|
85692
|
+
workerLogWarn(
|
|
85693
|
+
` ${branchDir}: rebased, but its branch.json is gone or names another branch than ${branchRef}, so the rewrite is not published`
|
|
85694
|
+
);
|
|
85695
|
+
return;
|
|
85696
|
+
}
|
|
85043
85697
|
if (await forcePublishToLocalRemote(ctx, branchPath, branchRef, publishedSha)) {
|
|
85044
|
-
await enqueueGitHubPush(ctx, branchRef);
|
|
85698
|
+
await enqueueGitHubPush(ctx, branchRef, gatewayPolicy);
|
|
85045
85699
|
}
|
|
85046
85700
|
} else {
|
|
85047
85701
|
const divergence = `rebased locally, but remote.git holds ${publishedSha} for ${branchRef}, which this clone never had (a direct push to the branch?). Left untouched -- reconcile it before submitting again.`;
|
|
85048
85702
|
workerLogWarn(` ${branchDir}: ${divergence}`);
|
|
85049
|
-
await recordRebaseFailure(ctx, branchPath, branchDir, divergence);
|
|
85703
|
+
await recordRebaseFailure(ctx, branchPath, branchDir, divergence, branchRef);
|
|
85050
85704
|
}
|
|
85051
85705
|
}
|
|
85052
85706
|
}
|
|
85053
|
-
async function runRebaseCycle(ctx) {
|
|
85707
|
+
async function runRebaseCycle(ctx, gatewayPolicy) {
|
|
85054
85708
|
const rebased = [];
|
|
85055
85709
|
const skippedDirty = [];
|
|
85056
85710
|
const skippedLocked = [];
|
|
85057
85711
|
const failed = [];
|
|
85058
85712
|
let branchDirs;
|
|
85059
85713
|
try {
|
|
85060
|
-
branchDirs = await
|
|
85714
|
+
branchDirs = await fs23.readdir(ctx.contentBranchesPath);
|
|
85061
85715
|
} catch {
|
|
85062
85716
|
return { rebased, skippedDirty, skippedLocked, failed };
|
|
85063
85717
|
}
|
|
@@ -85069,10 +85723,10 @@ async function runRebaseCycle(ctx) {
|
|
|
85069
85723
|
if (branchDir.startsWith(".") || branchDir === "branches.json") {
|
|
85070
85724
|
continue;
|
|
85071
85725
|
}
|
|
85072
|
-
const branchPath =
|
|
85073
|
-
const gitDir =
|
|
85726
|
+
const branchPath = path25.join(ctx.contentBranchesPath, branchDir);
|
|
85727
|
+
const gitDir = path25.join(branchPath, ".git");
|
|
85074
85728
|
try {
|
|
85075
|
-
const stat = await
|
|
85729
|
+
const stat = await fs23.stat(gitDir);
|
|
85076
85730
|
if (!stat.isDirectory()) {
|
|
85077
85731
|
workerLog(` Skipping ${branchDir}: .git is not a directory`);
|
|
85078
85732
|
continue;
|
|
@@ -85089,7 +85743,7 @@ async function runRebaseCycle(ctx) {
|
|
|
85089
85743
|
workerLogWarn(` Skipping ${branchDir}: settings branch, never a content workspace`);
|
|
85090
85744
|
continue;
|
|
85091
85745
|
}
|
|
85092
|
-
const outcome = await holdAndRebaseOneBranch(ctx, branchDir, branchPath);
|
|
85746
|
+
const outcome = await holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy);
|
|
85093
85747
|
if (outcome.kind === "rebased") rebased.push(branchDir);
|
|
85094
85748
|
else if (outcome.kind === "skippedDirty") skippedDirty.push(branchDir);
|
|
85095
85749
|
else if (outcome.kind === "skippedLocked") skippedLocked.push(branchDir);
|
|
@@ -85100,7 +85754,41 @@ async function runRebaseCycle(ctx) {
|
|
|
85100
85754
|
}
|
|
85101
85755
|
return { rebased, skippedDirty, skippedLocked, failed };
|
|
85102
85756
|
}
|
|
85103
|
-
async function
|
|
85757
|
+
async function readCloneRef(branchPath) {
|
|
85758
|
+
try {
|
|
85759
|
+
const head = (await fs23.readFile(path25.join(branchPath, ".git", "HEAD"), "utf-8")).trim();
|
|
85760
|
+
return head.startsWith("ref: refs/heads/") ? head.slice("ref: refs/heads/".length) : null;
|
|
85761
|
+
} catch {
|
|
85762
|
+
return null;
|
|
85763
|
+
}
|
|
85764
|
+
}
|
|
85765
|
+
async function restoreRenamedBranch(ctx, branchDir, branchPath, metaFile, namespace) {
|
|
85766
|
+
if (metaFile === null || namespace === void 0 || metaFile.branch.name.startsWith(namespace)) {
|
|
85767
|
+
return metaFile;
|
|
85768
|
+
}
|
|
85769
|
+
const staleName = metaFile.branch.name;
|
|
85770
|
+
const ref = await readCloneRef(branchPath);
|
|
85771
|
+
if (ref === null || !ref.startsWith(namespace) || sanitizeBranchName(ref) !== branchDir) {
|
|
85772
|
+
return metaFile;
|
|
85773
|
+
}
|
|
85774
|
+
try {
|
|
85775
|
+
const restored = await getBranchMetadataFileManager(branchPath, ctx.contentBranchesPath).update(
|
|
85776
|
+
(existing) => existing?.branch.name === staleName ? { branch: { name: ref } } : null,
|
|
85777
|
+
{ keepUpdatedAt: true }
|
|
85778
|
+
);
|
|
85779
|
+
if (restored === null) return BranchMetadataFileManager.loadOnly(branchPath);
|
|
85780
|
+
workerLog(
|
|
85781
|
+
` ${branchDir}: restored its name ${escapeForLog(ref)} from ${escapeForLog(staleName)}`
|
|
85782
|
+
);
|
|
85783
|
+
return restored;
|
|
85784
|
+
} catch (err) {
|
|
85785
|
+
workerLogWarn(
|
|
85786
|
+
` ${branchDir}: could not restore its name ${escapeForLog(ref)}: ${getErrorMessage(err)}`
|
|
85787
|
+
);
|
|
85788
|
+
return metaFile;
|
|
85789
|
+
}
|
|
85790
|
+
}
|
|
85791
|
+
async function holdAndRebaseOneBranch(ctx, branchDir, branchPath, gatewayPolicy) {
|
|
85104
85792
|
let hold;
|
|
85105
85793
|
try {
|
|
85106
85794
|
hold = await holdProvisionedWorkspace(ctx.contentBranchesPath, branchDir);
|
|
@@ -85115,15 +85803,21 @@ async function holdAndRebaseOneBranch(ctx, branchDir, branchPath) {
|
|
|
85115
85803
|
}
|
|
85116
85804
|
if (hold.kind === "not-provisioned") return { kind: "none" };
|
|
85117
85805
|
try {
|
|
85118
|
-
return await rebaseOneBranch(ctx, branchDir, branchPath, hold.isCompromised);
|
|
85806
|
+
return await rebaseOneBranch(ctx, branchDir, branchPath, hold.isCompromised, gatewayPolicy);
|
|
85119
85807
|
} finally {
|
|
85120
85808
|
await releaseProvisionedWorkspace(hold.release, branchDir);
|
|
85121
85809
|
}
|
|
85122
85810
|
}
|
|
85123
|
-
async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCompromised) {
|
|
85811
|
+
async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCompromised, gatewayPolicy) {
|
|
85124
85812
|
let didRebase = false;
|
|
85125
85813
|
try {
|
|
85126
|
-
const metaFile = await
|
|
85814
|
+
const metaFile = await restoreRenamedBranch(
|
|
85815
|
+
ctx,
|
|
85816
|
+
branchDir,
|
|
85817
|
+
branchPath,
|
|
85818
|
+
await BranchMetadataFileManager.loadOnly(branchPath),
|
|
85819
|
+
gatewayPolicy?.namespace
|
|
85820
|
+
);
|
|
85127
85821
|
const branchStatus2 = metaFile?.branch.status;
|
|
85128
85822
|
if (branchStatus2 === "submitted" || branchStatus2 === "approved") {
|
|
85129
85823
|
workerLog(` Skipping ${branchDir} (${branchStatus2})`);
|
|
@@ -85204,7 +85898,8 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85204
85898
|
branchDir,
|
|
85205
85899
|
branchRef,
|
|
85206
85900
|
headSha: (await branchGit.revparse(["HEAD"])).trim(),
|
|
85207
|
-
marker: metaFile.branch.historyRewrittenFrom
|
|
85901
|
+
marker: metaFile.branch.historyRewrittenFrom,
|
|
85902
|
+
gatewayPolicy
|
|
85208
85903
|
});
|
|
85209
85904
|
}
|
|
85210
85905
|
await fetchFromRemoteGit(branchGit, ctx.remoteGitPath, ctx.baseBranch);
|
|
@@ -85219,7 +85914,11 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85219
85914
|
if (currentMeta?.branch.rebaseFailure === void 0) {
|
|
85220
85915
|
return { kind: "none" };
|
|
85221
85916
|
}
|
|
85222
|
-
|
|
85917
|
+
const storedName = currentMeta.branch.name;
|
|
85918
|
+
await meta.saveIf(
|
|
85919
|
+
{ branch: { rebaseFailure: void 0 } },
|
|
85920
|
+
(existing) => existing?.branch.name === storedName
|
|
85921
|
+
);
|
|
85223
85922
|
return { kind: "none" };
|
|
85224
85923
|
}
|
|
85225
85924
|
workerLog(`Rebasing ${branchDir} (${behindCount} commits behind)...`);
|
|
@@ -85264,22 +85963,24 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85264
85963
|
workerLog(
|
|
85265
85964
|
hadConflicts ? ` Rebased ${branchDir} (kept branch version for ${conflictIdsDeduped.length} conflicting file(s))` : ` Rebased ${branchDir} successfully`
|
|
85266
85965
|
);
|
|
85267
|
-
await meta.update(
|
|
85268
|
-
branch
|
|
85269
|
-
|
|
85270
|
-
|
|
85271
|
-
|
|
85272
|
-
|
|
85273
|
-
|
|
85274
|
-
|
|
85275
|
-
|
|
85966
|
+
await meta.update(
|
|
85967
|
+
(existing) => existing !== null && existing.branch.name === metaFile?.branch.name ? {
|
|
85968
|
+
branch: {
|
|
85969
|
+
...recordConflicts(existing.branch.conflictFiles, conflictIdsDeduped),
|
|
85970
|
+
// The cycle completed, so clear any prior failure record regardless
|
|
85971
|
+
// of the conflict outcome.
|
|
85972
|
+
rebaseFailure: void 0
|
|
85973
|
+
}
|
|
85974
|
+
} : null
|
|
85975
|
+
);
|
|
85276
85976
|
didRebase = true;
|
|
85277
85977
|
await carryForwardRewrittenHistory(ctx, {
|
|
85278
85978
|
branchPath,
|
|
85279
85979
|
branchDir,
|
|
85280
85980
|
branchRef,
|
|
85281
85981
|
publishedSha,
|
|
85282
|
-
preRebaseHead
|
|
85982
|
+
preRebaseHead,
|
|
85983
|
+
gatewayPolicy
|
|
85283
85984
|
});
|
|
85284
85985
|
return { kind: "rebased" };
|
|
85285
85986
|
} finally {
|
|
@@ -85311,16 +86012,17 @@ async function rebaseOneBranch(ctx, branchDir, branchPath, isProvisioningLockCom
|
|
|
85311
86012
|
}
|
|
85312
86013
|
|
|
85313
86014
|
// ../canopycms/src/worker/git-sync.ts
|
|
85314
|
-
import
|
|
85315
|
-
import
|
|
86015
|
+
import fs28 from "node:fs/promises";
|
|
86016
|
+
import path30 from "node:path";
|
|
85316
86017
|
|
|
85317
86018
|
// ../canopycms/src/branch-health.ts
|
|
85318
86019
|
var ORPHAN_YOUTH_THRESHOLD_MS = 15 * 6e4;
|
|
85319
86020
|
|
|
85320
86021
|
// ../canopycms/src/branch-provisioning.ts
|
|
85321
86022
|
import { createHash, randomBytes as randomBytes2 } from "node:crypto";
|
|
85322
|
-
import
|
|
85323
|
-
import
|
|
86023
|
+
import fs24 from "node:fs/promises";
|
|
86024
|
+
import path26 from "node:path";
|
|
86025
|
+
init_branch_name();
|
|
85324
86026
|
init_error();
|
|
85325
86027
|
init_logger();
|
|
85326
86028
|
var STAGING_MAX_AGE_MS = 20 * 6e4;
|
|
@@ -85352,7 +86054,7 @@ var DELETING_PREFIX = ".deleting-";
|
|
|
85352
86054
|
var NO_GIT = { hasGitDir: false, configLock: false, hasIndex: false };
|
|
85353
86055
|
async function listDir(dirPath) {
|
|
85354
86056
|
try {
|
|
85355
|
-
return await
|
|
86057
|
+
return await fs24.readdir(dirPath);
|
|
85356
86058
|
} catch (err) {
|
|
85357
86059
|
if (isNodeError(err) && (err.code === "ENOENT" || err.code === "ENOTDIR")) return null;
|
|
85358
86060
|
throw err;
|
|
@@ -85374,19 +86076,19 @@ function gitConfigRemoteUrls(text) {
|
|
|
85374
86076
|
}
|
|
85375
86077
|
function sameRemote(url, expected) {
|
|
85376
86078
|
if (isNetworkRemoteUrl(url) || isNetworkRemoteUrl(expected)) return url === expected;
|
|
85377
|
-
const local = (value) =>
|
|
86079
|
+
const local = (value) => path26.resolve(value.replace(/^file:\/\//i, ""));
|
|
85378
86080
|
return local(url) === local(expected);
|
|
85379
86081
|
}
|
|
85380
86082
|
async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
85381
86083
|
let stat;
|
|
85382
86084
|
try {
|
|
85383
|
-
stat = await
|
|
86085
|
+
stat = await fs24.lstat(dirPath);
|
|
85384
86086
|
} catch (err) {
|
|
85385
86087
|
if (isNotFoundError2(err)) return { kind: "vacant" };
|
|
85386
86088
|
throw err;
|
|
85387
86089
|
}
|
|
85388
86090
|
if (!stat.isDirectory()) return { kind: "residue", signature: NO_GIT };
|
|
85389
|
-
const metaEntries = await listDir(
|
|
86091
|
+
const metaEntries = await listDir(path26.join(dirPath, BRANCH_META_DIR)) ?? [];
|
|
85390
86092
|
if (metaEntries.includes(BRANCH_META_FILE)) {
|
|
85391
86093
|
try {
|
|
85392
86094
|
return await readBranchMetadataFile(dirPath) ? { kind: "live" } : { kind: "protected" };
|
|
@@ -85398,10 +86100,10 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
|
85398
86100
|
if (metaEntries.some((name2) => name2.startsWith(`${BRANCH_META_FILE}.corrupt-`))) {
|
|
85399
86101
|
return { kind: "protected" };
|
|
85400
86102
|
}
|
|
85401
|
-
const gitPath =
|
|
86103
|
+
const gitPath = path26.join(dirPath, ".git");
|
|
85402
86104
|
let gitStat;
|
|
85403
86105
|
try {
|
|
85404
|
-
gitStat = await
|
|
86106
|
+
gitStat = await fs24.lstat(gitPath);
|
|
85405
86107
|
} catch (err) {
|
|
85406
86108
|
if (isNotFoundError2(err)) return { kind: "residue", signature: NO_GIT };
|
|
85407
86109
|
throw err;
|
|
@@ -85415,7 +86117,7 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
|
85415
86117
|
};
|
|
85416
86118
|
let config;
|
|
85417
86119
|
try {
|
|
85418
|
-
config = await
|
|
86120
|
+
config = await fs24.readFile(path26.join(gitPath, "config"), "utf8");
|
|
85419
86121
|
} catch {
|
|
85420
86122
|
return { kind: "residue", signature };
|
|
85421
86123
|
}
|
|
@@ -85424,7 +86126,7 @@ async function classifyFinalDir(dirPath, expectedRemoteUrl) {
|
|
|
85424
86126
|
async function quietAgeMs(dirPath, now = Date.now()) {
|
|
85425
86127
|
const mtimes = await Promise.all(
|
|
85426
86128
|
["", ".git", BRANCH_META_DIR].map(
|
|
85427
|
-
(sub) =>
|
|
86129
|
+
(sub) => fs24.lstat(path26.join(dirPath, sub)).then(
|
|
85428
86130
|
(stat) => stat.mtimeMs,
|
|
85429
86131
|
() => 0
|
|
85430
86132
|
)
|
|
@@ -85433,25 +86135,25 @@ async function quietAgeMs(dirPath, now = Date.now()) {
|
|
|
85433
86135
|
return now - Math.max(...mtimes);
|
|
85434
86136
|
}
|
|
85435
86137
|
async function quarantineResidueAt(baseRoot, dirName, options) {
|
|
85436
|
-
const finalPath =
|
|
86138
|
+
const finalPath = path26.join(baseRoot, dirName);
|
|
85437
86139
|
let inode;
|
|
85438
86140
|
try {
|
|
85439
|
-
inode = (await
|
|
86141
|
+
inode = (await fs24.lstat(finalPath)).ino;
|
|
85440
86142
|
} catch (err) {
|
|
85441
86143
|
if (isNotFoundError2(err)) return { kind: "vacant" };
|
|
85442
86144
|
throw err;
|
|
85443
86145
|
}
|
|
85444
86146
|
const candidateName = stampedName(REPAIR_PREFIX, dirName, /* @__PURE__ */ new Date());
|
|
85445
|
-
const candidate =
|
|
86147
|
+
const candidate = path26.join(baseRoot, candidateName);
|
|
85446
86148
|
try {
|
|
85447
|
-
await
|
|
86149
|
+
await fs24.rename(finalPath, candidate);
|
|
85448
86150
|
} catch (err) {
|
|
85449
86151
|
if (isNotFoundError2(err)) return { kind: "vacant" };
|
|
85450
86152
|
throw err;
|
|
85451
86153
|
}
|
|
85452
86154
|
const moveBack = async (why) => {
|
|
85453
86155
|
try {
|
|
85454
|
-
await
|
|
86156
|
+
await fs24.rename(candidate, finalPath);
|
|
85455
86157
|
} catch (err) {
|
|
85456
86158
|
canopyLogError(
|
|
85457
86159
|
`[canopy] Could not move '${dirName}' back from ${candidateName} after ${why}: ${getErrorMessage(err)}. The worker's sweep restores or trashes it.`
|
|
@@ -85466,7 +86168,7 @@ async function quarantineResidueAt(baseRoot, dirName, options) {
|
|
|
85466
86168
|
);
|
|
85467
86169
|
if (reason === void 0 && state3.kind === "residue") {
|
|
85468
86170
|
const trashName = stampedName(TRASH_PREFIX, dirName, /* @__PURE__ */ new Date());
|
|
85469
|
-
await
|
|
86171
|
+
await fs24.rename(candidate, path26.join(baseRoot, trashName));
|
|
85470
86172
|
const { hasGitDir, configLock, hasIndex } = state3.signature;
|
|
85471
86173
|
canopyLogWarn(
|
|
85472
86174
|
`[canopy] Quarantined unfinished branch directory '${dirName}' as ${trashName} (git=${hasGitDir} config.lock=${configLock} index=${hasIndex} quiet=${Math.round(quiet / 1e3)}s)`
|
|
@@ -85478,7 +86180,7 @@ async function quarantineResidueAt(baseRoot, dirName, options) {
|
|
|
85478
86180
|
}
|
|
85479
86181
|
async function judgeQuarantineCandidate(candidate, inode, options) {
|
|
85480
86182
|
const state3 = await classifyFinalDir(candidate, options.expectedRemoteUrl);
|
|
85481
|
-
const moved = await
|
|
86183
|
+
const moved = await fs24.lstat(candidate).catch(() => null);
|
|
85482
86184
|
const quiet = await quietAgeMs(candidate, options.now);
|
|
85483
86185
|
let reason;
|
|
85484
86186
|
if (!moved || moved.ino !== inode) reason = "replaced";
|
|
@@ -85495,7 +86197,7 @@ async function sweepByAge(root5, rules, now) {
|
|
|
85495
86197
|
const stamp = rule ? parseDirStamp(name2) : null;
|
|
85496
86198
|
if (!rule || !stamp || now - stamp.getTime() < rule.maxAgeMs) continue;
|
|
85497
86199
|
try {
|
|
85498
|
-
await
|
|
86200
|
+
await fs24.rm(path26.join(root5, name2), {
|
|
85499
86201
|
recursive: true,
|
|
85500
86202
|
force: true,
|
|
85501
86203
|
maxRetries: 3,
|
|
@@ -85509,7 +86211,7 @@ async function sweepByAge(root5, rules, now) {
|
|
|
85509
86211
|
return actions;
|
|
85510
86212
|
}
|
|
85511
86213
|
async function recoverRepairDir(baseRoot, name2) {
|
|
85512
|
-
const repairPath =
|
|
86214
|
+
const repairPath = path26.join(baseRoot, name2);
|
|
85513
86215
|
const meta = await readBranchMetadataFile(repairPath).catch(() => null);
|
|
85514
86216
|
const dirName = meta ? sanitizeBranchName(meta.branch.name) : void 0;
|
|
85515
86217
|
if (dirName && name2.startsWith(`${REPAIR_PREFIX}${shortDirName(dirName)}-`)) {
|
|
@@ -85523,9 +86225,9 @@ async function recoverRepairDir(baseRoot, name2) {
|
|
|
85523
86225
|
throw err;
|
|
85524
86226
|
}
|
|
85525
86227
|
try {
|
|
85526
|
-
const finalPath =
|
|
85527
|
-
if (await
|
|
85528
|
-
await
|
|
86228
|
+
const finalPath = path26.join(baseRoot, dirName);
|
|
86229
|
+
if (await fs24.lstat(finalPath).catch(() => null) === null) {
|
|
86230
|
+
await fs24.rename(repairPath, finalPath);
|
|
85529
86231
|
return { name: name2, action: "restored", detail: dirName };
|
|
85530
86232
|
}
|
|
85531
86233
|
} finally {
|
|
@@ -85534,7 +86236,7 @@ async function recoverRepairDir(baseRoot, name2) {
|
|
|
85534
86236
|
}
|
|
85535
86237
|
}
|
|
85536
86238
|
const trashName = `${TRASH_PREFIX}${name2.slice(REPAIR_PREFIX.length)}`;
|
|
85537
|
-
await
|
|
86239
|
+
await fs24.rename(repairPath, path26.join(baseRoot, trashName));
|
|
85538
86240
|
return { name: name2, action: "trashed", detail: trashName };
|
|
85539
86241
|
}
|
|
85540
86242
|
async function sweepProvisioningLeftovers(baseRoot, workspaceRoot, now = Date.now()) {
|
|
@@ -85569,6 +86271,7 @@ async function sweepProvisioningLeftovers(baseRoot, workspaceRoot, now = Date.no
|
|
|
85569
86271
|
}
|
|
85570
86272
|
|
|
85571
86273
|
// ../canopycms/src/worker/git-sync.ts
|
|
86274
|
+
init_branch_name();
|
|
85572
86275
|
init_error();
|
|
85573
86276
|
init_worker_status();
|
|
85574
86277
|
|
|
@@ -85584,12 +86287,12 @@ async function maintainRemoteGit(gitDir) {
|
|
|
85584
86287
|
}
|
|
85585
86288
|
|
|
85586
86289
|
// ../canopycms/src/worker/sparse-cone.ts
|
|
85587
|
-
import
|
|
85588
|
-
import
|
|
86290
|
+
import fs26 from "node:fs/promises";
|
|
86291
|
+
import path28 from "node:path";
|
|
85589
86292
|
|
|
85590
86293
|
// ../canopycms/src/branch-sparse.ts
|
|
85591
|
-
import
|
|
85592
|
-
import
|
|
86294
|
+
import fs25 from "node:fs/promises";
|
|
86295
|
+
import path27 from "node:path";
|
|
85593
86296
|
init_error();
|
|
85594
86297
|
function sameCone(a9, b10) {
|
|
85595
86298
|
if (a9 === null || b10 === null) return a9 === b10;
|
|
@@ -85598,12 +86301,12 @@ function sameCone(a9, b10) {
|
|
|
85598
86301
|
}
|
|
85599
86302
|
var SPARSE_CONE_RECORD = ".sparse-cone.json";
|
|
85600
86303
|
function isConeDir(dir) {
|
|
85601
|
-
return typeof dir === "string" && dir.length > 0 && !
|
|
86304
|
+
return typeof dir === "string" && dir.length > 0 && !path27.isAbsolute(dir) && !dir.split("/").some((segment) => segment === "" || segment === "." || segment === "..");
|
|
85602
86305
|
}
|
|
85603
86306
|
async function readRecordedSparseCone(contentBranchesRoot) {
|
|
85604
86307
|
let raw;
|
|
85605
86308
|
try {
|
|
85606
|
-
raw = await
|
|
86309
|
+
raw = await fs25.readFile(path27.join(contentBranchesRoot, SPARSE_CONE_RECORD), "utf8");
|
|
85607
86310
|
} catch (err) {
|
|
85608
86311
|
if (isNodeError(err) && err.code === "ENOENT") return void 0;
|
|
85609
86312
|
throw err;
|
|
@@ -85636,15 +86339,15 @@ async function reapplySparseCones(ctx) {
|
|
|
85636
86339
|
if (!recorded) return report;
|
|
85637
86340
|
let entries;
|
|
85638
86341
|
try {
|
|
85639
|
-
entries = await
|
|
86342
|
+
entries = await fs26.readdir(ctx.contentBranchesPath, { withFileTypes: true });
|
|
85640
86343
|
} catch (err) {
|
|
85641
86344
|
if (isNodeError(err) && err.code === "ENOENT") return report;
|
|
85642
86345
|
throw err;
|
|
85643
86346
|
}
|
|
85644
86347
|
const dirNames = entries.filter((entry) => entry.isDirectory() && !entry.name.startsWith(".")).map((entry) => entry.name).sort();
|
|
85645
86348
|
for (const dirName of dirNames) {
|
|
85646
|
-
const branchPath =
|
|
85647
|
-
const isClone = await
|
|
86349
|
+
const branchPath = path28.join(ctx.contentBranchesPath, dirName);
|
|
86350
|
+
const isClone = await fs26.stat(path28.join(branchPath, ".git")).then(
|
|
85648
86351
|
(stat) => stat.isDirectory(),
|
|
85649
86352
|
() => false
|
|
85650
86353
|
);
|
|
@@ -85676,7 +86379,7 @@ async function reapplySparseCones(ctx) {
|
|
|
85676
86379
|
return report;
|
|
85677
86380
|
}
|
|
85678
86381
|
async function reapplyOne(contentBranchesPath, dirName, git, target) {
|
|
85679
|
-
const branchPath =
|
|
86382
|
+
const branchPath = path28.join(contentBranchesPath, dirName);
|
|
85680
86383
|
const hold = await holdProvisionedWorkspace(contentBranchesPath, dirName);
|
|
85681
86384
|
if (hold.kind !== "held") return "skipped";
|
|
85682
86385
|
try {
|
|
@@ -85715,11 +86418,12 @@ async function reapplyOne(contentBranchesPath, dirName, git, target) {
|
|
|
85715
86418
|
}
|
|
85716
86419
|
|
|
85717
86420
|
// ../canopycms/src/worker/stale-mirror.ts
|
|
85718
|
-
|
|
85719
|
-
import
|
|
86421
|
+
init_branch_name();
|
|
86422
|
+
import fs27 from "node:fs/promises";
|
|
86423
|
+
import path29 from "node:path";
|
|
85720
86424
|
init_error();
|
|
85721
86425
|
async function readEditorWork(ctx) {
|
|
85722
|
-
const workspaces = new Set(await
|
|
86426
|
+
const workspaces = new Set(await fs27.readdir(ctx.contentBranchesPath).catch(() => []));
|
|
85723
86427
|
const queuedPushes = /* @__PURE__ */ new Set();
|
|
85724
86428
|
for (const status of ["pending", "processing"]) {
|
|
85725
86429
|
for (const task of await listTasks(ctx.taskDir, status, Number.POSITIVE_INFINITY)) {
|
|
@@ -85754,7 +86458,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
|
|
|
85754
86458
|
throw err;
|
|
85755
86459
|
}
|
|
85756
86460
|
try {
|
|
85757
|
-
if ((await
|
|
86461
|
+
if ((await fs27.readdir(ctx.contentBranchesPath)).includes(dirName)) {
|
|
85758
86462
|
return { kind: "kept", state: "workspace" };
|
|
85759
86463
|
}
|
|
85760
86464
|
const ref = `refs/heads/${name2}`;
|
|
@@ -85764,7 +86468,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
|
|
|
85764
86468
|
);
|
|
85765
86469
|
} catch (err) {
|
|
85766
86470
|
const message2 = getErrorMessage(err);
|
|
85767
|
-
if (lockHeld(message2) ===
|
|
86471
|
+
if (lockHeld(message2) === path29.join(ctx.remoteGitPath, "packed-refs.lock")) {
|
|
85768
86472
|
return { kind: "packed-refs-locked" };
|
|
85769
86473
|
}
|
|
85770
86474
|
if (/cannot lock ref|Unable to create '[^']*\.lock': File exists/.test(message2)) {
|
|
@@ -85779,7 +86483,7 @@ async function settleStaleMirror(ctx, git, head, ownSettingsBranch, editorWork,
|
|
|
85779
86483
|
}
|
|
85780
86484
|
function lockHeld(message2) {
|
|
85781
86485
|
const match2 = /Unable to create '([^']*)': File exists/.exec(message2);
|
|
85782
|
-
return match2 ?
|
|
86486
|
+
return match2 ? path29.normalize(match2[1]) : null;
|
|
85783
86487
|
}
|
|
85784
86488
|
async function sharesHistory(git, head, baseTip) {
|
|
85785
86489
|
try {
|
|
@@ -85991,7 +86695,7 @@ async function reconcileTrackedBranches(ctx, git, githubTips) {
|
|
|
85991
86695
|
else if (outcome.error !== void 0) uncheckedOrphans.push({ name: name2, error: outcome.error });
|
|
85992
86696
|
}
|
|
85993
86697
|
}
|
|
85994
|
-
|
|
86698
|
+
warnOnce2(ctx.warnedDivergences(), [
|
|
85995
86699
|
...diverged.map(divergedWarning),
|
|
85996
86700
|
...uncheckedOrphans.map(({ name: name2, error: error3 }) => ({
|
|
85997
86701
|
// ':' cannot appear in a ref name, so this key never collides with a branch's.
|
|
@@ -86048,12 +86752,12 @@ function divergedWarning({ name: name2, local, github, state: state3, error: err
|
|
|
86048
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}). Publishing it fails until the two are reconciled; System health lists it.`
|
|
86049
86753
|
};
|
|
86050
86754
|
}
|
|
86051
|
-
function
|
|
86755
|
+
function warnOnce2(warned3, lines) {
|
|
86052
86756
|
const current = new Set(lines.map((entry) => entry.key));
|
|
86053
|
-
for (const key of
|
|
86757
|
+
for (const key of warned3.keys()) if (!current.has(key)) warned3.delete(key);
|
|
86054
86758
|
for (const { key, said, line } of lines) {
|
|
86055
|
-
if (
|
|
86056
|
-
|
|
86759
|
+
if (warned3.get(key) === said) continue;
|
|
86760
|
+
warned3.set(key, said);
|
|
86057
86761
|
workerLogWarn(line);
|
|
86058
86762
|
}
|
|
86059
86763
|
}
|
|
@@ -86105,9 +86809,39 @@ async function syncGit(ctx) {
|
|
|
86105
86809
|
if (stoppedForDrain(ctx, "the base-branch refresh")) return;
|
|
86106
86810
|
const baseRefresh = await refreshBaseBranchWorkspace(ctx);
|
|
86107
86811
|
if (stoppedForDrain(ctx, "the rebase cycle")) return;
|
|
86108
|
-
|
|
86812
|
+
let health;
|
|
86813
|
+
try {
|
|
86814
|
+
health = await ctx.github().health(ctx.shutdownSignal());
|
|
86815
|
+
} catch (err) {
|
|
86816
|
+
workerLogWarn(`Could not read the GitHub gateway's branch policy: ${getErrorMessage(err)}`);
|
|
86817
|
+
}
|
|
86818
|
+
const branchPolicy = health && health.branchPolicy.namespace !== "" ? health.branchPolicy : void 0;
|
|
86819
|
+
if (branchPolicy) {
|
|
86820
|
+
const report2 = ctx.ensureStatusReport();
|
|
86821
|
+
report2.gatewayBranchNamespace = branchPolicy.namespace;
|
|
86822
|
+
report2.gatewayProtectedBranches = branchPolicy.configured.filter((n7) => !n7.includes("*"));
|
|
86823
|
+
await writeWorkerStatus(ctx.taskDir, report2).catch(
|
|
86824
|
+
(writeErr) => workerLogError("Failed to write worker status:", getErrorMessage(writeErr))
|
|
86825
|
+
);
|
|
86826
|
+
}
|
|
86827
|
+
const rebaseSummary = await runRebaseCycle(ctx, branchPolicy);
|
|
86109
86828
|
if (stoppedForDrain(ctx, "the cleanup sweeps")) return;
|
|
86110
86829
|
await cleanupOldTasks(ctx.taskDir, void 0, ctx.log);
|
|
86830
|
+
if (health && branchPolicy) {
|
|
86831
|
+
const report2 = ctx.ensureStatusReport();
|
|
86832
|
+
if (health.fatalError === null) {
|
|
86833
|
+
try {
|
|
86834
|
+
const unpublishable = await findUnpublishableBranches(ctx, branchPolicy);
|
|
86835
|
+
if (unpublishable.count > 0) {
|
|
86836
|
+
report2.unpublishableBranches = { ...unpublishable, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
86837
|
+
} else delete report2.unpublishableBranches;
|
|
86838
|
+
} catch (err) {
|
|
86839
|
+
workerLogWarn(
|
|
86840
|
+
`Could not list the branches the gateway will not publish: ${getErrorMessage(err)}`
|
|
86841
|
+
);
|
|
86842
|
+
}
|
|
86843
|
+
}
|
|
86844
|
+
}
|
|
86111
86845
|
const trashRemoved = await cleanupTrashedBranchDirs(ctx);
|
|
86112
86846
|
if (trashRemoved > 0) {
|
|
86113
86847
|
workerLog(`Removed ${trashRemoved} expired trashed branch dir(s)`);
|
|
@@ -86152,7 +86886,7 @@ var reportedForeignDirs = /* @__PURE__ */ new Set();
|
|
|
86152
86886
|
async function repairBranchDirResidue(ctx, now = Date.now()) {
|
|
86153
86887
|
let entries;
|
|
86154
86888
|
try {
|
|
86155
|
-
entries = await
|
|
86889
|
+
entries = await fs28.readdir(ctx.contentBranchesPath, { withFileTypes: true });
|
|
86156
86890
|
} catch (err) {
|
|
86157
86891
|
if (isNodeError(err) && err.code === "ENOENT") return;
|
|
86158
86892
|
throw err;
|
|
@@ -86167,7 +86901,7 @@ async function repairBranchDirResidue(ctx, now = Date.now()) {
|
|
|
86167
86901
|
}
|
|
86168
86902
|
const leftovers = await sweepProvisioningLeftovers(
|
|
86169
86903
|
ctx.contentBranchesPath,
|
|
86170
|
-
|
|
86904
|
+
path30.dirname(ctx.contentBranchesPath),
|
|
86171
86905
|
now
|
|
86172
86906
|
);
|
|
86173
86907
|
for (const { name: name2, action, detail } of leftovers) {
|
|
@@ -86178,8 +86912,8 @@ async function repairBranchDirResidue(ctx, now = Date.now()) {
|
|
|
86178
86912
|
}
|
|
86179
86913
|
}
|
|
86180
86914
|
async function repairOneBranchDir(ctx, dirName, now) {
|
|
86181
|
-
const dirPath =
|
|
86182
|
-
const hasMeta = await
|
|
86915
|
+
const dirPath = path30.join(ctx.contentBranchesPath, dirName);
|
|
86916
|
+
const hasMeta = await fs28.access(path30.join(dirPath, BRANCH_META_DIR, BRANCH_META_FILE)).then(
|
|
86183
86917
|
() => true,
|
|
86184
86918
|
() => false
|
|
86185
86919
|
);
|
|
@@ -86215,7 +86949,7 @@ async function repairOneBranchDir(ctx, dirName, now) {
|
|
|
86215
86949
|
async function cleanupTrashedBranchDirs(ctx) {
|
|
86216
86950
|
let entries;
|
|
86217
86951
|
try {
|
|
86218
|
-
entries = await
|
|
86952
|
+
entries = await fs28.readdir(ctx.contentBranchesPath);
|
|
86219
86953
|
} catch (err) {
|
|
86220
86954
|
if (isNodeError(err) && err.code === "ENOENT") return 0;
|
|
86221
86955
|
throw err;
|
|
@@ -86235,7 +86969,7 @@ async function cleanupTrashedBranchDirs(ctx) {
|
|
|
86235
86969
|
}
|
|
86236
86970
|
if (now - stampDate.getTime() < TRASH_RETENTION_MS) continue;
|
|
86237
86971
|
try {
|
|
86238
|
-
await
|
|
86972
|
+
await fs28.rm(path30.join(ctx.contentBranchesPath, name2), {
|
|
86239
86973
|
recursive: true,
|
|
86240
86974
|
force: true,
|
|
86241
86975
|
maxRetries: 3,
|
|
@@ -86253,7 +86987,7 @@ async function cleanupTrashedBranchDirs(ctx) {
|
|
|
86253
86987
|
}
|
|
86254
86988
|
var warnedTrackedCanopyState = /* @__PURE__ */ new Set();
|
|
86255
86989
|
async function refreshBaseBranchWorkspace(ctx) {
|
|
86256
|
-
const basePath37 =
|
|
86990
|
+
const basePath37 = path30.join(ctx.contentBranchesPath, ctx.sanitizedBaseBranch);
|
|
86257
86991
|
let trackedCanopyMeta;
|
|
86258
86992
|
let releaseProvisioning;
|
|
86259
86993
|
let releaseContentLock;
|
|
@@ -86411,10 +87145,10 @@ async function refreshBaseBranchWorkspace(ctx) {
|
|
|
86411
87145
|
// ../canopycms/src/worker/github-gateway-http.ts
|
|
86412
87146
|
init_error();
|
|
86413
87147
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
86414
|
-
import
|
|
87148
|
+
import fs29 from "node:fs/promises";
|
|
86415
87149
|
import http from "node:http";
|
|
86416
87150
|
import net from "node:net";
|
|
86417
|
-
import
|
|
87151
|
+
import path31 from "node:path";
|
|
86418
87152
|
import { PassThrough } from "node:stream";
|
|
86419
87153
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
86420
87154
|
var MAX_POLL_WAIT_MS = 25e3;
|
|
@@ -86437,11 +87171,11 @@ async function serveGitHubGateway(gateway, listen, options = {}) {
|
|
|
86437
87171
|
if ("fd" in listen) {
|
|
86438
87172
|
await listenOn(server, { fd: listen.fd });
|
|
86439
87173
|
} else {
|
|
86440
|
-
await assertPrivateDirectory(
|
|
87174
|
+
await assertPrivateDirectory(path31.dirname(listen.path));
|
|
86441
87175
|
await removeStaleSocket(listen.path);
|
|
86442
87176
|
await listenOn(server, { path: listen.path });
|
|
86443
87177
|
try {
|
|
86444
|
-
await
|
|
87178
|
+
await fs29.chmod(listen.path, 384);
|
|
86445
87179
|
} catch (err) {
|
|
86446
87180
|
await closeServer(server, handler);
|
|
86447
87181
|
throw err;
|
|
@@ -86482,7 +87216,7 @@ function listenOn(server, options) {
|
|
|
86482
87216
|
});
|
|
86483
87217
|
}
|
|
86484
87218
|
async function assertPrivateDirectory(dir) {
|
|
86485
|
-
const stat = await
|
|
87219
|
+
const stat = await fs29.lstat(dir);
|
|
86486
87220
|
const uid = process.getuid?.();
|
|
86487
87221
|
if (!stat.isDirectory() || uid !== void 0 && (stat.uid !== uid || (stat.mode & 63) !== 0)) {
|
|
86488
87222
|
throw new Error(
|
|
@@ -86493,7 +87227,7 @@ async function assertPrivateDirectory(dir) {
|
|
|
86493
87227
|
async function removeStaleSocket(socketPath) {
|
|
86494
87228
|
let stat;
|
|
86495
87229
|
try {
|
|
86496
|
-
stat = await
|
|
87230
|
+
stat = await fs29.lstat(socketPath);
|
|
86497
87231
|
} catch (err) {
|
|
86498
87232
|
if (isNodeError(err) && err.code === "ENOENT") return;
|
|
86499
87233
|
throw err;
|
|
@@ -86509,7 +87243,7 @@ async function removeStaleSocket(socketPath) {
|
|
|
86509
87243
|
`Refusing to serve the GitHub gateway at ${socketPath}: a gateway already serves there`
|
|
86510
87244
|
);
|
|
86511
87245
|
}
|
|
86512
|
-
await
|
|
87246
|
+
await fs29.unlink(socketPath);
|
|
86513
87247
|
}
|
|
86514
87248
|
function isServed(socketPath) {
|
|
86515
87249
|
return new Promise((resolve) => {
|
|
@@ -86573,7 +87307,7 @@ var GatewayRequestHandler = class {
|
|
|
86573
87307
|
number,
|
|
86574
87308
|
signal
|
|
86575
87309
|
);
|
|
86576
|
-
return { merged, merged_at, state: state3, node_id, body
|
|
87310
|
+
return { merged, merged_at, state: state3, node_id, body };
|
|
86577
87311
|
},
|
|
86578
87312
|
createOrUpdatePullRequest: async (input, signal) => {
|
|
86579
87313
|
const { number, url, created } = await gateway.createOrUpdatePullRequest(input, signal);
|
|
@@ -87238,11 +87972,14 @@ async function readAnswer(res, schema, signal) {
|
|
|
87238
87972
|
return value.data;
|
|
87239
87973
|
}
|
|
87240
87974
|
|
|
87975
|
+
// ../canopycms/src/worker/cms-worker.ts
|
|
87976
|
+
init_branch_namespace();
|
|
87977
|
+
|
|
87241
87978
|
// ../canopycms/src/worker/self-checks.ts
|
|
87242
87979
|
init_error();
|
|
87243
|
-
import
|
|
87980
|
+
import fs30 from "node:fs/promises";
|
|
87244
87981
|
import net2 from "node:net";
|
|
87245
|
-
import
|
|
87982
|
+
import path32 from "node:path";
|
|
87246
87983
|
var IMDS_HOST = "169.254.169.254";
|
|
87247
87984
|
var IMDS_CONNECT_TIMEOUT_MS = 1e3;
|
|
87248
87985
|
var NO_ROUTE_CODES = /* @__PURE__ */ new Set(["ENETUNREACH", "EAFNOSUPPORT"]);
|
|
@@ -87297,10 +88034,10 @@ async function imdsUnreachable(environment = {}) {
|
|
|
87297
88034
|
};
|
|
87298
88035
|
}
|
|
87299
88036
|
async function onlyLoopback(environment = {}) {
|
|
87300
|
-
const file =
|
|
88037
|
+
const file = path32.join(rootOf(environment), "proc", "self", "net", "dev");
|
|
87301
88038
|
let text;
|
|
87302
88039
|
try {
|
|
87303
|
-
text = await
|
|
88040
|
+
text = await fs30.readFile(file, "utf8");
|
|
87304
88041
|
} catch (err) {
|
|
87305
88042
|
return {
|
|
87306
88043
|
check: "network-namespace",
|
|
@@ -87317,21 +88054,21 @@ async function onlyLoopback(environment = {}) {
|
|
|
87317
88054
|
};
|
|
87318
88055
|
}
|
|
87319
88056
|
async function procShowsOnlyOwnProcesses(environment = {}) {
|
|
87320
|
-
const proc =
|
|
88057
|
+
const proc = path32.join(rootOf(environment), "proc");
|
|
87321
88058
|
const uid = environment.uid ?? process.getuid?.();
|
|
87322
88059
|
if (uid === void 0) {
|
|
87323
88060
|
return { check: "proc", ok: false, detail: "this platform has no process uid to compare" };
|
|
87324
88061
|
}
|
|
87325
88062
|
let entries;
|
|
87326
88063
|
try {
|
|
87327
|
-
entries = await
|
|
88064
|
+
entries = await fs30.readdir(proc);
|
|
87328
88065
|
} catch (err) {
|
|
87329
88066
|
return { check: "proc", ok: false, detail: `cannot list ${proc}: ${getErrorMessage(err)}` };
|
|
87330
88067
|
}
|
|
87331
88068
|
const others = [];
|
|
87332
88069
|
for (const entry of entries.filter((name2) => /^\d+$/.test(name2))) {
|
|
87333
88070
|
try {
|
|
87334
|
-
const stat = await
|
|
88071
|
+
const stat = await fs30.stat(path32.join(proc, entry));
|
|
87335
88072
|
if (stat.uid !== uid) others.push(`${entry} (uid ${stat.uid})`);
|
|
87336
88073
|
} catch (err) {
|
|
87337
88074
|
if (!(isNodeError(err) && err.code === "ENOENT")) {
|
|
@@ -87347,9 +88084,9 @@ async function procShowsOnlyOwnProcesses(environment = {}) {
|
|
|
87347
88084
|
};
|
|
87348
88085
|
}
|
|
87349
88086
|
async function homeIsEmpty(environment = {}) {
|
|
87350
|
-
const home =
|
|
88087
|
+
const home = path32.join(rootOf(environment), "home");
|
|
87351
88088
|
try {
|
|
87352
|
-
const entries = await
|
|
88089
|
+
const entries = await fs30.readdir(home);
|
|
87353
88090
|
return {
|
|
87354
88091
|
check: "home",
|
|
87355
88092
|
ok: entries.length === 0,
|
|
@@ -87372,9 +88109,9 @@ function noSecretsInEnv(environment = {}) {
|
|
|
87372
88109
|
};
|
|
87373
88110
|
}
|
|
87374
88111
|
async function efsUnreadable(environment = {}) {
|
|
87375
|
-
const efs =
|
|
88112
|
+
const efs = path32.join(rootOf(environment), "mnt", "efs");
|
|
87376
88113
|
try {
|
|
87377
|
-
await
|
|
88114
|
+
await fs30.readdir(efs);
|
|
87378
88115
|
} catch (err) {
|
|
87379
88116
|
const code = isNodeError(err) ? err.code : void 0;
|
|
87380
88117
|
const denied = code === "EACCES" || code === "EPERM";
|
|
@@ -87391,9 +88128,9 @@ async function efsUnreadable(environment = {}) {
|
|
|
87391
88128
|
};
|
|
87392
88129
|
}
|
|
87393
88130
|
async function corePatternNotPiped(environment = {}) {
|
|
87394
|
-
const file =
|
|
88131
|
+
const file = path32.join(rootOf(environment), "proc", "sys", "kernel", "core_pattern");
|
|
87395
88132
|
try {
|
|
87396
|
-
const pattern = (await
|
|
88133
|
+
const pattern = (await fs30.readFile(file, "utf8")).trim();
|
|
87397
88134
|
const ok = !pattern.startsWith("|");
|
|
87398
88135
|
return {
|
|
87399
88136
|
check: "core-pattern",
|
|
@@ -87409,10 +88146,10 @@ async function corePatternNotPiped(environment = {}) {
|
|
|
87409
88146
|
}
|
|
87410
88147
|
}
|
|
87411
88148
|
async function coreLimitZero(environment = {}) {
|
|
87412
|
-
const file =
|
|
88149
|
+
const file = path32.join(rootOf(environment), "proc", "self", "limits");
|
|
87413
88150
|
let text;
|
|
87414
88151
|
try {
|
|
87415
|
-
text = await
|
|
88152
|
+
text = await fs30.readFile(file, "utf8");
|
|
87416
88153
|
} catch (err) {
|
|
87417
88154
|
return {
|
|
87418
88155
|
check: "core-limit",
|
|
@@ -87434,11 +88171,11 @@ async function socketAccessIsOthers(environment = {}) {
|
|
|
87434
88171
|
const uid = environment.uid ?? process.getuid?.();
|
|
87435
88172
|
if (uid === void 0) return fail("this platform has no process uid to compare");
|
|
87436
88173
|
const fd = environment.listenFd ?? 3;
|
|
87437
|
-
const proc =
|
|
88174
|
+
const proc = path32.join(rootOf(environment), "proc", "self");
|
|
87438
88175
|
let socketPath;
|
|
87439
88176
|
try {
|
|
87440
|
-
const inode = (await
|
|
87441
|
-
const table = await
|
|
88177
|
+
const inode = (await fs30.stat(path32.join(proc, "fd", String(fd)))).ino;
|
|
88178
|
+
const table = await fs30.readFile(path32.join(proc, "net", "unix"), "utf8");
|
|
87442
88179
|
for (const line of table.split("\n").slice(1)) {
|
|
87443
88180
|
const fields = line.trim().split(/\s+/);
|
|
87444
88181
|
if (fields[6] === String(inode) && fields.length > 7) socketPath = fields.slice(7).join(" ");
|
|
@@ -87446,12 +88183,12 @@ async function socketAccessIsOthers(environment = {}) {
|
|
|
87446
88183
|
} catch (err) {
|
|
87447
88184
|
return fail(`cannot find the socket on descriptor ${fd}: ${getErrorMessage(err)}`);
|
|
87448
88185
|
}
|
|
87449
|
-
if (socketPath === void 0 || !
|
|
88186
|
+
if (socketPath === void 0 || !path32.isAbsolute(socketPath)) {
|
|
87450
88187
|
return fail(`the socket on descriptor ${fd} is not bound to a path`);
|
|
87451
88188
|
}
|
|
87452
88189
|
let node;
|
|
87453
88190
|
try {
|
|
87454
|
-
node = await
|
|
88191
|
+
node = await fs30.lstat(socketPath);
|
|
87455
88192
|
} catch (err) {
|
|
87456
88193
|
return fail(`cannot read ${socketPath}: ${getErrorMessage(err)}`);
|
|
87457
88194
|
}
|
|
@@ -87498,8 +88235,8 @@ function tcpConnect(host, port, timeoutMs) {
|
|
|
87498
88235
|
|
|
87499
88236
|
// ../canopycms/src/worker/cms-worker.ts
|
|
87500
88237
|
function defaultStateDirectory(workspacePath) {
|
|
87501
|
-
const key = createHash2("sha256").update(
|
|
87502
|
-
return
|
|
88238
|
+
const key = createHash2("sha256").update(path33.resolve(workspacePath)).digest("hex").slice(0, 16);
|
|
88239
|
+
return path33.join(os.tmpdir(), `canopycms-worker-${key}`);
|
|
87503
88240
|
}
|
|
87504
88241
|
var MAX_REFS_LISTED = 20;
|
|
87505
88242
|
var RemoteGitKeptError = class extends Error {
|
|
@@ -87524,6 +88261,9 @@ async function listRemoteGitRefs(gitDir) {
|
|
|
87524
88261
|
function sameRefs(a9, b10) {
|
|
87525
88262
|
return a9.size === b10.size && [...a9].every(([ref, id]) => b10.get(ref) === id);
|
|
87526
88263
|
}
|
|
88264
|
+
function resolveWorkerSettingsBranch(config) {
|
|
88265
|
+
return config.settingsBranch ?? `${RESERVED_SETTINGS_BRANCH_PREFIX}${resolveDeploymentName({ deploymentName: config.deploymentName }, "prod")}`;
|
|
88266
|
+
}
|
|
87527
88267
|
var DEFAULT_TASK_TIMEOUT = 6e4;
|
|
87528
88268
|
var DEFAULT_MAX_RETRIES2 = 3;
|
|
87529
88269
|
var DEFAULT_LOCK_STALE_MS = 6e4;
|
|
@@ -87547,7 +88287,7 @@ function lockWorkerTaskDir(taskDir, lockStaleMs, options) {
|
|
|
87547
88287
|
const waitMs = options.waitMs ?? 0;
|
|
87548
88288
|
const intervalMs = Math.max(250, Math.min(5e3, Math.floor(lockStaleMs / 4)));
|
|
87549
88289
|
return import_proper_lockfile3.default.lock(taskDir, {
|
|
87550
|
-
lockfilePath:
|
|
88290
|
+
lockfilePath: path33.join(taskDir, ".worker-lock"),
|
|
87551
88291
|
stale: lockStaleMs,
|
|
87552
88292
|
onCompromised: options.onCompromised,
|
|
87553
88293
|
...waitMs > 0 ? {
|
|
@@ -87563,22 +88303,25 @@ function lockWorkerTaskDir(taskDir, lockStaleMs, options) {
|
|
|
87563
88303
|
async function readCarriedFields(taskDir) {
|
|
87564
88304
|
const { lastFatalError, lastShutdown } = await readCarriedOverStatus(taskDir);
|
|
87565
88305
|
const baseHold = await readCarriedBaseHold(taskDir);
|
|
88306
|
+
const unpublishableBranches = await readCarriedUnpublishableBranches(taskDir);
|
|
87566
88307
|
return {
|
|
87567
88308
|
...lastFatalError ? { lastFatalError } : {},
|
|
87568
88309
|
...lastShutdown ? { lastShutdown } : {},
|
|
87569
|
-
...baseHold ? { baseHold } : {}
|
|
88310
|
+
...baseHold ? { baseHold } : {},
|
|
88311
|
+
...unpublishableBranches ? { unpublishableBranches } : {},
|
|
88312
|
+
...await readCarriedGatewayPolicy(taskDir)
|
|
87570
88313
|
};
|
|
87571
88314
|
}
|
|
87572
88315
|
async function recordWorkerStartupFailure(options) {
|
|
87573
|
-
const taskDir =
|
|
88316
|
+
const taskDir = path33.join(options.workspacePath, ".tasks");
|
|
87574
88317
|
let release2;
|
|
87575
88318
|
try {
|
|
87576
|
-
await
|
|
88319
|
+
await fs31.mkdir(taskDir, { recursive: true });
|
|
87577
88320
|
release2 = await lockWorkerTaskDir(taskDir, 2 * (options.lockStaleMs ?? DEFAULT_LOCK_STALE_MS), {
|
|
87578
88321
|
onCompromised: (err) => workerLogError("Worker lock lost while recording a startup failure:", getErrorMessage(err))
|
|
87579
88322
|
});
|
|
87580
88323
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
87581
|
-
const { lastFatalError,
|
|
88324
|
+
const { lastFatalError, ...carried } = await readCarriedFields(taskDir);
|
|
87582
88325
|
if (lastFatalError && options.keepRecordedFatal && lastFatalError.workerStartedAt === await readWorkerStatusStartedAt(taskDir) && options.keepRecordedFatal(lastFatalError)) {
|
|
87583
88326
|
return;
|
|
87584
88327
|
}
|
|
@@ -87587,8 +88330,7 @@ async function recordWorkerStartupFailure(options) {
|
|
|
87587
88330
|
workerVersion: CANOPYCMS_VERSION,
|
|
87588
88331
|
startedAt: now,
|
|
87589
88332
|
updatedAt: now,
|
|
87590
|
-
...
|
|
87591
|
-
...baseHold ? { baseHold } : {},
|
|
88333
|
+
...carried,
|
|
87592
88334
|
lastFatalError: {
|
|
87593
88335
|
// [REDACT] Served to the browser by the admin panel and the API's not-ready answer.
|
|
87594
88336
|
message: redactCredentials(getErrorMessage(options.error)),
|
|
@@ -87629,17 +88371,17 @@ var CmsWorker = class {
|
|
|
87629
88371
|
this.selfStopped = new Promise((resolve) => {
|
|
87630
88372
|
this.settleSelfStopped = resolve;
|
|
87631
88373
|
});
|
|
87632
|
-
this.taskDir =
|
|
87633
|
-
this.remoteGitPath =
|
|
87634
|
-
this.stateDirectory =
|
|
88374
|
+
this.taskDir = path33.join(config.workspacePath, ".tasks");
|
|
88375
|
+
this.remoteGitPath = path33.join(path33.resolve(config.workspacePath), "remote.git");
|
|
88376
|
+
this.stateDirectory = path33.resolve(
|
|
87635
88377
|
config.stateDirectory ?? defaultStateDirectory(config.workspacePath)
|
|
87636
88378
|
);
|
|
87637
|
-
this.contentBranchesPath =
|
|
88379
|
+
this.contentBranchesPath = path33.join(config.workspacePath, "content-branches");
|
|
87638
88380
|
if (config.baseBranch !== void 0) this.setBaseBranch(config.baseBranch);
|
|
87639
88381
|
this.maxTasksPerCycle = config.maxTasksPerCycle ?? 10;
|
|
87640
88382
|
this.taskTimeoutMs = config.taskTimeoutMs ?? DEFAULT_TASK_TIMEOUT;
|
|
87641
88383
|
this.maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES2;
|
|
87642
|
-
this.lockFilePath =
|
|
88384
|
+
this.lockFilePath = path33.join(config.workspacePath, ".tasks", ".worker-lock");
|
|
87643
88385
|
this.lockStaleMs = config.lockStaleMs ?? DEFAULT_LOCK_STALE_MS;
|
|
87644
88386
|
this.drainDeadlineMs = config.drainDeadlineMs ?? DEFAULT_DRAIN_DEADLINE_MS;
|
|
87645
88387
|
this.contentRoot = config.contentRoot ?? "content";
|
|
@@ -87688,7 +88430,7 @@ var CmsWorker = class {
|
|
|
87688
88430
|
*/
|
|
87689
88431
|
ensureSettingsBranch() {
|
|
87690
88432
|
if (this.settingsBranchResolved === void 0) {
|
|
87691
|
-
this.settingsBranchResolved =
|
|
88433
|
+
this.settingsBranchResolved = resolveWorkerSettingsBranch(this.config);
|
|
87692
88434
|
}
|
|
87693
88435
|
return this.settingsBranchResolved;
|
|
87694
88436
|
}
|
|
@@ -87749,10 +88491,8 @@ var CmsWorker = class {
|
|
|
87749
88491
|
this.ensureStatusReport();
|
|
87750
88492
|
await this.acquireLock();
|
|
87751
88493
|
try {
|
|
87752
|
-
const { lastFatalError,
|
|
87753
|
-
const report = this.ensureStatusReport();
|
|
87754
|
-
if (lastShutdown) report.lastShutdown = lastShutdown;
|
|
87755
|
-
if (baseHold) report.baseHold = baseHold;
|
|
88494
|
+
const { lastFatalError, ...carried } = await readCarriedFields(this.taskDir);
|
|
88495
|
+
const report = Object.assign(this.ensureStatusReport(), carried);
|
|
87756
88496
|
await writeWorkerStatus(this.taskDir, {
|
|
87757
88497
|
...report,
|
|
87758
88498
|
...lastFatalError ? { lastFatalError } : {}
|
|
@@ -87933,7 +88673,7 @@ var CmsWorker = class {
|
|
|
87933
88673
|
* is negligible at the default TTL; a badly wrong clock misjudges liveness.
|
|
87934
88674
|
*/
|
|
87935
88675
|
async acquireLock() {
|
|
87936
|
-
await
|
|
88676
|
+
await fs31.mkdir(this.taskDir, { recursive: true });
|
|
87937
88677
|
try {
|
|
87938
88678
|
this.releaseLockFn = await lockWorkerTaskDir(this.taskDir, this.lockStaleMs, {
|
|
87939
88679
|
onCompromised: (err) => {
|
|
@@ -88067,7 +88807,7 @@ var CmsWorker = class {
|
|
|
88067
88807
|
);
|
|
88068
88808
|
let remoteGitExists;
|
|
88069
88809
|
try {
|
|
88070
|
-
remoteGitExists = await
|
|
88810
|
+
remoteGitExists = await fs31.stat(this.remoteGitPath).then(
|
|
88071
88811
|
() => true,
|
|
88072
88812
|
(err) => {
|
|
88073
88813
|
if (isNodeError(err) && err.code === "ENOENT") return false;
|
|
@@ -88145,7 +88885,7 @@ var CmsWorker = class {
|
|
|
88145
88885
|
);
|
|
88146
88886
|
if (current === this.baseBranch) return;
|
|
88147
88887
|
await sharedRepoGit(gitDir, "bare").raw(["symbolic-ref", "HEAD", ref]);
|
|
88148
|
-
workerLog(`${
|
|
88888
|
+
workerLog(`${path33.basename(gitDir)} HEAD now names the base branch '${this.baseBranch}'`);
|
|
88149
88889
|
}
|
|
88150
88890
|
/**
|
|
88151
88891
|
* Whether the bare repo at `gitDir` has a local `refs/heads/<baseBranch>`.
|
|
@@ -88245,7 +88985,7 @@ var CmsWorker = class {
|
|
|
88245
88985
|
async ensureRemoteGit() {
|
|
88246
88986
|
let exists3;
|
|
88247
88987
|
try {
|
|
88248
|
-
await
|
|
88988
|
+
await fs31.stat(this.remoteGitPath);
|
|
88249
88989
|
exists3 = true;
|
|
88250
88990
|
} catch {
|
|
88251
88991
|
exists3 = false;
|
|
@@ -88265,7 +89005,7 @@ var CmsWorker = class {
|
|
|
88265
89005
|
}
|
|
88266
89006
|
workerLog("Initializing remote.git from GitHub...");
|
|
88267
89007
|
const stagingPath = await this.seedRemoteGitStaging();
|
|
88268
|
-
await
|
|
89008
|
+
await fs31.rename(stagingPath, this.remoteGitPath);
|
|
88269
89009
|
workerLog("remote.git initialized");
|
|
88270
89010
|
}
|
|
88271
89011
|
/**
|
|
@@ -88321,7 +89061,7 @@ var CmsWorker = class {
|
|
|
88321
89061
|
if (err instanceof RemoteGitKeptError) throw err;
|
|
88322
89062
|
throw notReplaced(redactCredentials(getErrorMessage(err)));
|
|
88323
89063
|
});
|
|
88324
|
-
const discardStaging = () =>
|
|
89064
|
+
const discardStaging = () => fs31.rm(stagingPath, { recursive: true, force: true });
|
|
88325
89065
|
let current;
|
|
88326
89066
|
try {
|
|
88327
89067
|
current = await listRemoteGitRefs(this.remoteGitPath);
|
|
@@ -88339,21 +89079,21 @@ var CmsWorker = class {
|
|
|
88339
89079
|
}
|
|
88340
89080
|
const replaced = `${this.remoteGitPath}.replaced-${Date.now()}`;
|
|
88341
89081
|
try {
|
|
88342
|
-
await
|
|
89082
|
+
await fs31.rename(this.remoteGitPath, replaced);
|
|
88343
89083
|
} catch (err) {
|
|
88344
89084
|
await discardStaging();
|
|
88345
89085
|
throw err;
|
|
88346
89086
|
}
|
|
88347
89087
|
try {
|
|
88348
|
-
await
|
|
89088
|
+
await fs31.rename(stagingPath, this.remoteGitPath);
|
|
88349
89089
|
} catch (err) {
|
|
88350
|
-
await
|
|
89090
|
+
await fs31.rename(replaced, this.remoteGitPath);
|
|
88351
89091
|
await discardStaging();
|
|
88352
89092
|
throw err;
|
|
88353
89093
|
}
|
|
88354
89094
|
const after = await listRemoteGitRefs(replaced).catch(() => null);
|
|
88355
89095
|
if (after !== null && sameRefs(refs, after)) {
|
|
88356
|
-
await
|
|
89096
|
+
await fs31.rm(replaced, { recursive: true, force: true, maxRetries: 3 }).catch((err) => {
|
|
88357
89097
|
workerLogWarn(
|
|
88358
89098
|
`Could not remove the replaced remote.git at ${replaced}: ${getErrorMessage(err)}`
|
|
88359
89099
|
);
|
|
@@ -88373,7 +89113,7 @@ var CmsWorker = class {
|
|
|
88373
89113
|
*/
|
|
88374
89114
|
async seedRemoteGitStaging(check) {
|
|
88375
89115
|
const stagingPath = `${this.remoteGitPath}.cloning`;
|
|
88376
|
-
await
|
|
89116
|
+
await fs31.rm(stagingPath, { recursive: true, force: true });
|
|
88377
89117
|
try {
|
|
88378
89118
|
const githubBranches = await seedFromGitHub(
|
|
88379
89119
|
this.transferContext(),
|
|
@@ -88389,7 +89129,7 @@ var CmsWorker = class {
|
|
|
88389
89129
|
if (!(err instanceof RemoteGitKeptError)) {
|
|
88390
89130
|
workerLogError(`remote.git seeding failed: ${redactCredentials(getErrorMessage(err))}`);
|
|
88391
89131
|
}
|
|
88392
|
-
await
|
|
89132
|
+
await fs31.rm(stagingPath, { recursive: true, force: true });
|
|
88393
89133
|
if (err instanceof RemoteGitKeptError) throw err;
|
|
88394
89134
|
if (err instanceof SharedRepoRefusalError) {
|
|
88395
89135
|
throw new SharedRepoRefusalError(
|
|
@@ -88447,9 +89187,11 @@ var CmsWorker = class {
|
|
|
88447
89187
|
if (this.config.githubAppAuth !== void 0) conflicting.push("githubAppAuth");
|
|
88448
89188
|
if (this.config.refreshGitHubToken !== void 0) conflicting.push("refreshGitHubToken");
|
|
88449
89189
|
if ((this.config.protectedBranches?.length ?? 0) > 0) conflicting.push("protectedBranches");
|
|
89190
|
+
if ((this.config.legacyBranches?.length ?? 0) > 0) conflicting.push("legacyBranches");
|
|
89191
|
+
if (this.config.branchNamespace !== void 0) conflicting.push("branchNamespace");
|
|
88450
89192
|
if (conflicting.length > 0) {
|
|
88451
89193
|
throw new Error(
|
|
88452
|
-
`CmsWorker: githubGateway is exclusive with ${conflicting.join(", ")}, which configure the in-process gateway; the gateway it is given holds the credential and the
|
|
89194
|
+
`CmsWorker: githubGateway is exclusive with ${conflicting.join(", ")}, which configure the in-process gateway; the gateway it is given holds the credential and the branch policy`
|
|
88453
89195
|
);
|
|
88454
89196
|
}
|
|
88455
89197
|
this.gateway = githubGateway;
|
|
@@ -88474,7 +89216,10 @@ var CmsWorker = class {
|
|
|
88474
89216
|
workspacePath: this.config.workspacePath,
|
|
88475
89217
|
timeoutMs: this.taskTimeoutMs,
|
|
88476
89218
|
baseBranch: this.config.baseBranch,
|
|
88477
|
-
protectedBranches: this.config.protectedBranches
|
|
89219
|
+
protectedBranches: this.config.protectedBranches,
|
|
89220
|
+
settingsBranch: this.ensureSettingsBranch(),
|
|
89221
|
+
legacyBranches: this.config.legacyBranches,
|
|
89222
|
+
branchNamespace: resolveBranchNamespace(this.config, "prod")
|
|
88478
89223
|
};
|
|
88479
89224
|
}
|
|
88480
89225
|
/**
|
|
@@ -88493,7 +89238,7 @@ var CmsWorker = class {
|
|
|
88493
89238
|
* sanitized.
|
|
88494
89239
|
*/
|
|
88495
89240
|
branchWorkspacePath(branchRefName) {
|
|
88496
|
-
return
|
|
89241
|
+
return path33.join(this.contentBranchesPath, sanitizeBranchName(branchRefName));
|
|
88497
89242
|
}
|
|
88498
89243
|
/**
|
|
88499
89244
|
* Test-only seam: awaited inside `rebaseActiveBranches()`'s conflict round,
|
|
@@ -88527,8 +89272,8 @@ var CmsWorker = class {
|
|
|
88527
89272
|
// `rebaseActiveBranches` also has a consumer outside the test files:
|
|
88528
89273
|
// apps/test-app/app/api/e2e-test/rebase/route.ts drives it from an e2e
|
|
88529
89274
|
// fixture route. Do not delete it as unused.
|
|
88530
|
-
async rebaseActiveBranches() {
|
|
88531
|
-
return runRebaseCycle(this.ctx());
|
|
89275
|
+
async rebaseActiveBranches(gatewayPolicy) {
|
|
89276
|
+
return runRebaseCycle(this.ctx(), gatewayPolicy);
|
|
88532
89277
|
}
|
|
88533
89278
|
// --- Git-sync cluster (worker/git-sync.ts) -----------------------------
|
|
88534
89279
|
//
|
|
@@ -88568,24 +89313,24 @@ var CmsWorker = class {
|
|
|
88568
89313
|
};
|
|
88569
89314
|
|
|
88570
89315
|
// ../canopycms/src/auth/file-based-auth-cache.ts
|
|
88571
|
-
import
|
|
88572
|
-
import
|
|
89316
|
+
import fs32 from "node:fs/promises";
|
|
89317
|
+
import path34 from "node:path";
|
|
88573
89318
|
var log5 = createDebugLogger({ prefix: "FileBasedAuthCache" });
|
|
88574
89319
|
async function writeAuthCacheSnapshot(cachePath, files) {
|
|
88575
|
-
await
|
|
89320
|
+
await fs32.mkdir(cachePath, { recursive: true });
|
|
88576
89321
|
const timestamp2 = Date.now();
|
|
88577
|
-
const snapshotDir =
|
|
88578
|
-
await
|
|
89322
|
+
const snapshotDir = path34.join(cachePath, `snapshot-${timestamp2}`);
|
|
89323
|
+
await fs32.mkdir(snapshotDir, { recursive: true });
|
|
88579
89324
|
for (const [fileName, data3] of Object.entries(files)) {
|
|
88580
|
-
const tmpPath =
|
|
88581
|
-
const finalPath =
|
|
88582
|
-
await
|
|
88583
|
-
await
|
|
88584
|
-
}
|
|
88585
|
-
const currentLink =
|
|
88586
|
-
const tmpLink =
|
|
88587
|
-
await
|
|
88588
|
-
await
|
|
89325
|
+
const tmpPath = path34.join(snapshotDir, `${fileName}.tmp`);
|
|
89326
|
+
const finalPath = path34.join(snapshotDir, fileName);
|
|
89327
|
+
await fs32.writeFile(tmpPath, JSON.stringify(data3, null, 2), "utf-8");
|
|
89328
|
+
await fs32.rename(tmpPath, finalPath);
|
|
89329
|
+
}
|
|
89330
|
+
const currentLink = path34.join(cachePath, "current");
|
|
89331
|
+
const tmpLink = path34.join(cachePath, `current-${timestamp2}`);
|
|
89332
|
+
await fs32.symlink(path34.basename(snapshotDir), tmpLink);
|
|
89333
|
+
await fs32.rename(tmpLink, currentLink);
|
|
88589
89334
|
await cleanupOldSnapshots(cachePath, 2);
|
|
88590
89335
|
return snapshotDir;
|
|
88591
89336
|
}
|
|
@@ -88602,14 +89347,14 @@ async function writeAuthSnapshot(cachePath, snapshot) {
|
|
|
88602
89347
|
async function cleanupOldSnapshots(cachePath, keepCount) {
|
|
88603
89348
|
let entries;
|
|
88604
89349
|
try {
|
|
88605
|
-
entries = await
|
|
89350
|
+
entries = await fs32.readdir(cachePath);
|
|
88606
89351
|
} catch {
|
|
88607
89352
|
return;
|
|
88608
89353
|
}
|
|
88609
89354
|
const snapshots = entries.filter((e9) => e9.startsWith("snapshot-")).sort().reverse();
|
|
88610
89355
|
for (const snapshot of snapshots.slice(keepCount)) {
|
|
88611
89356
|
try {
|
|
88612
|
-
await
|
|
89357
|
+
await fs32.rm(path34.join(cachePath, snapshot), {
|
|
88613
89358
|
recursive: true,
|
|
88614
89359
|
force: true
|
|
88615
89360
|
});
|
|
@@ -88756,7 +89501,8 @@ var GITHUB_GATEWAY_SOCKET_ENV = "CANOPYCMS_GITHUB_GATEWAY_SOCKET";
|
|
|
88756
89501
|
var GATEWAY_SPLIT_CONTRACT = 2;
|
|
88757
89502
|
var WORKER_CONTRACT_REQUIREMENTS = [
|
|
88758
89503
|
"StateDirectory=canopy-worker",
|
|
88759
|
-
`canopy-github.socket and canopy-github.service, and ${GITHUB_GATEWAY_SOCKET_ENV} on the worker unit
|
|
89504
|
+
`canopy-github.socket and canopy-github.service, and ${GITHUB_GATEWAY_SOCKET_ENV} on the worker unit`,
|
|
89505
|
+
"CANOPYCMS_DEPLOYMENT_NAME, and CANOPYCMS_SETTINGS_BRANCH when set, in gateway.env"
|
|
88760
89506
|
];
|
|
88761
89507
|
var WORKER_CONTRACT_VERSION = WORKER_CONTRACT_REQUIREMENTS.length;
|
|
88762
89508
|
var WORKER_CONTRACT_ENV = "CANOPYCMS_WORKER_CONTRACT";
|
|
@@ -88860,7 +89606,7 @@ async function completeTerminationLifecycleAction(options = {}) {
|
|
|
88860
89606
|
|
|
88861
89607
|
// worker/run.ts
|
|
88862
89608
|
init_error();
|
|
88863
|
-
import
|
|
89609
|
+
import path35 from "node:path";
|
|
88864
89610
|
|
|
88865
89611
|
// worker/github-app-auth.ts
|
|
88866
89612
|
var import_auth_app = __toESM(require_dist_node20(), 1);
|
|
@@ -93245,10 +93991,10 @@ var SessionAPI = class extends AbstractAPI {
|
|
|
93245
93991
|
*/
|
|
93246
93992
|
async getToken(sessionId, template, expiresInSeconds) {
|
|
93247
93993
|
this.requireId(sessionId);
|
|
93248
|
-
const
|
|
93994
|
+
const path36 = template ? joinPaths(basePath29, sessionId, "tokens", template) : joinPaths(basePath29, sessionId, "tokens");
|
|
93249
93995
|
const requestOptions = {
|
|
93250
93996
|
method: "POST",
|
|
93251
|
-
path:
|
|
93997
|
+
path: path36
|
|
93252
93998
|
};
|
|
93253
93999
|
if (expiresInSeconds !== void 0) {
|
|
93254
94000
|
requestOptions.bodyParams = { expires_in_seconds: expiresInSeconds };
|
|
@@ -95998,12 +96744,12 @@ function buildRequest(options) {
|
|
|
95998
96744
|
userAgent = USER_AGENT2,
|
|
95999
96745
|
skipApiVersionInUrl = false
|
|
96000
96746
|
} = options;
|
|
96001
|
-
const { path:
|
|
96747
|
+
const { path: path36, method, queryParams, headerParams, bodyParams, formData, options: opts } = requestOptions;
|
|
96002
96748
|
const { deepSnakecaseBodyParamKeys = false } = opts || {};
|
|
96003
96749
|
if (requireSecretKey) {
|
|
96004
96750
|
assertValidSecretKey(secretKey);
|
|
96005
96751
|
}
|
|
96006
|
-
const url = skipApiVersionInUrl ? joinPaths(apiUrl,
|
|
96752
|
+
const url = skipApiVersionInUrl ? joinPaths(apiUrl, path36) : joinPaths(apiUrl, apiVersion, path36);
|
|
96007
96753
|
const finalUrl = new URL(url);
|
|
96008
96754
|
if (queryParams) {
|
|
96009
96755
|
const snakecasedQueryParams = snakecase_keys_default({ ...queryParams });
|
|
@@ -98401,8 +99147,16 @@ function isRecentGatewayFatal(recorded, now = Date.now()) {
|
|
|
98401
99147
|
return recorded.phase === "startup" && recorded.message.startsWith(GATEWAY_FATAL_PREFIX) && age >= 0 && age < GATEWAY_AWAY_KEEP_MS;
|
|
98402
99148
|
}
|
|
98403
99149
|
var PROTECTED_BRANCHES_ENV = "CANOPYCMS_PROTECTED_BRANCHES";
|
|
99150
|
+
var BRANCH_NAMESPACE_ENV2 = "CANOPYCMS_BRANCH_NAMESPACE";
|
|
99151
|
+
var LEGACY_BRANCHES_ENV = "CANOPYCMS_LEGACY_BRANCHES";
|
|
99152
|
+
function parseBranchList(env2, name2) {
|
|
99153
|
+
return (env2[name2] ?? "").split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
|
|
99154
|
+
}
|
|
98404
99155
|
function parseProtectedBranches(env2) {
|
|
98405
|
-
return (env2
|
|
99156
|
+
return parseBranchList(env2, PROTECTED_BRANCHES_ENV);
|
|
99157
|
+
}
|
|
99158
|
+
function parseLegacyBranches(env2) {
|
|
99159
|
+
return parseBranchList(env2, LEGACY_BRANCHES_ENV);
|
|
98406
99160
|
}
|
|
98407
99161
|
var WORKER_STATE_DIRECTORY_MISSING = 'StateDirectory=canopy-worker is not set on the worker unit, and every worker contract requires it, so the worker does not start without it. Add it to the [Service] section of canopy-worker.service (see "The worker instance" in docs/deploying-to-aws.md).';
|
|
98408
99162
|
function readRepoEnv(env2, missingStateDirectory) {
|
|
@@ -98519,7 +99273,7 @@ async function buildSingleProcessWorker(deps, workspacePath) {
|
|
|
98519
99273
|
const { githubToken, githubTokenSecret, githubAppAuth, clerkSecret } = await readWorkerCredentials(env2, deps.getSecret);
|
|
98520
99274
|
const refreshAuthCache = createClerkAuthCacheRefresher({
|
|
98521
99275
|
secret: clerkSecret,
|
|
98522
|
-
cachePath:
|
|
99276
|
+
cachePath: path35.join(workspacePath, ".cache"),
|
|
98523
99277
|
useOrganizationsAsGroups
|
|
98524
99278
|
});
|
|
98525
99279
|
const worker = deps.createWorker({
|
|
@@ -98534,6 +99288,8 @@ async function buildSingleProcessWorker(deps, workspacePath) {
|
|
|
98534
99288
|
refreshGitHubToken: () => githubTokenSecret.refresh(),
|
|
98535
99289
|
refreshAuthCache,
|
|
98536
99290
|
protectedBranches: parseProtectedBranches(env2),
|
|
99291
|
+
legacyBranches: parseLegacyBranches(env2),
|
|
99292
|
+
branchNamespace: env2[BRANCH_NAMESPACE_ENV2]?.trim() || void 0,
|
|
98537
99293
|
...commonWorkerConfig(env2)
|
|
98538
99294
|
});
|
|
98539
99295
|
return {
|
|
@@ -98552,10 +99308,16 @@ async function buildSplitWorker(deps, workspacePath, socketPath, onGatewayWait)
|
|
|
98552
99308
|
env2,
|
|
98553
99309
|
WORKER_STATE_DIRECTORY_MISSING
|
|
98554
99310
|
);
|
|
98555
|
-
|
|
98556
|
-
|
|
98557
|
-
|
|
98558
|
-
)
|
|
99311
|
+
for (const [name2, entries] of [
|
|
99312
|
+
[PROTECTED_BRANCHES_ENV, parseProtectedBranches(env2)],
|
|
99313
|
+
[LEGACY_BRANCHES_ENV, parseLegacyBranches(env2)],
|
|
99314
|
+
[BRANCH_NAMESPACE_ENV2, env2[BRANCH_NAMESPACE_ENV2]?.trim() ? [env2[BRANCH_NAMESPACE_ENV2]] : []]
|
|
99315
|
+
]) {
|
|
99316
|
+
if (entries.length > 0) {
|
|
99317
|
+
throw new Error(
|
|
99318
|
+
`${name2} is set on the worker unit, but beside the GitHub gateway it is the gateway's setting: move it to the gateway's environment (gateway.env)`
|
|
99319
|
+
);
|
|
99320
|
+
}
|
|
98559
99321
|
}
|
|
98560
99322
|
if (env2[CLERK_ORGANIZATIONS_AS_GROUPS_ENV]) {
|
|
98561
99323
|
throw new Error(
|
|
@@ -98579,9 +99341,19 @@ async function buildSplitWorker(deps, workspacePath, socketPath, onGatewayWait)
|
|
|
98579
99341
|
throw new Error(`${GATEWAY_FATAL_PREFIX}${health.fatalError}`);
|
|
98580
99342
|
}
|
|
98581
99343
|
if (!health.ready) throw new Error("The GitHub gateway is not ready");
|
|
99344
|
+
const settingsBranch = resolveWorkerSettingsBranch({
|
|
99345
|
+
settingsBranch: env2.CANOPYCMS_SETTINGS_BRANCH,
|
|
99346
|
+
deploymentName: env2.CANOPYCMS_DEPLOYMENT_NAME
|
|
99347
|
+
});
|
|
99348
|
+
const gatewaySettingsBranch = health.branchPolicy.settingsBranch;
|
|
99349
|
+
if (gatewaySettingsBranch !== settingsBranch) {
|
|
99350
|
+
throw new Error(
|
|
99351
|
+
`The GitHub gateway pushes the settings branch ${JSON.stringify(gatewaySettingsBranch)}, but this worker's is ${JSON.stringify(settingsBranch)}: set CANOPYCMS_DEPLOYMENT_NAME and CANOPYCMS_SETTINGS_BRANCH alike in the worker's .env and gateway.env`
|
|
99352
|
+
);
|
|
99353
|
+
}
|
|
98582
99354
|
const refreshAuthCache = health.clerkConfigured ? async () => {
|
|
98583
99355
|
const snapshot = await gateway.authSnapshot();
|
|
98584
|
-
await deps.writeAuthSnapshot(
|
|
99356
|
+
await deps.writeAuthSnapshot(path35.join(workspacePath, ".cache"), snapshot);
|
|
98585
99357
|
workerLog(` ${snapshot.users.length} users, ${snapshot.groups.length} groups`);
|
|
98586
99358
|
} : void 0;
|
|
98587
99359
|
const worker = deps.createWorker({
|
|
@@ -98762,6 +99534,19 @@ async function buildGateway(deps, listen) {
|
|
|
98762
99534
|
timeoutMs: DEFAULT_TASK_TIMEOUT,
|
|
98763
99535
|
baseBranch: env2.CANOPYCMS_BASE_BRANCH || void 0,
|
|
98764
99536
|
protectedBranches: parseProtectedBranches(env2),
|
|
99537
|
+
// Resolved as the worker resolves its own (`CANOPYCMS_SETTINGS_BRANCH`, else from
|
|
99538
|
+
// `CANOPYCMS_DEPLOYMENT_NAME`), so the one settings branch pushed is the worker's.
|
|
99539
|
+
settingsBranch: resolveWorkerSettingsBranch({
|
|
99540
|
+
settingsBranch: env2.CANOPYCMS_SETTINGS_BRANCH,
|
|
99541
|
+
deploymentName: env2.CANOPYCMS_DEPLOYMENT_NAME
|
|
99542
|
+
}),
|
|
99543
|
+
legacyBranches: parseLegacyBranches(env2),
|
|
99544
|
+
// From this unit's own environment: never from anything the CMS Lambda can write.
|
|
99545
|
+
branchNamespace: resolveBranchNamespace(
|
|
99546
|
+
{ deploymentName: env2.CANOPYCMS_DEPLOYMENT_NAME },
|
|
99547
|
+
"prod",
|
|
99548
|
+
env2
|
|
99549
|
+
),
|
|
98765
99550
|
authSnapshot: createClerkSnapshotFetcher({
|
|
98766
99551
|
secret: clerkSecret,
|
|
98767
99552
|
useOrganizationsAsGroups,
|
|
@@ -98781,7 +99566,13 @@ function failedGateway(message2, instance) {
|
|
|
98781
99566
|
fatalError: message2,
|
|
98782
99567
|
preflight: "pending",
|
|
98783
99568
|
clerkConfigured: false,
|
|
98784
|
-
|
|
99569
|
+
branchPolicy: {
|
|
99570
|
+
configured: [],
|
|
99571
|
+
githubDefault: null,
|
|
99572
|
+
namespace: "",
|
|
99573
|
+
legacy: [],
|
|
99574
|
+
settingsBranch: null
|
|
99575
|
+
}
|
|
98785
99576
|
}),
|
|
98786
99577
|
defaultBranch: refuse,
|
|
98787
99578
|
isProtectedBranch: refuse,
|