@gadicc/loom 1.23.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/esm/src/cli/mod.d.ts.map +1 -1
- package/esm/src/cli/mod.js +78 -54
- package/esm/src/cli/releaseConfig.d.ts +10 -0
- package/esm/src/cli/releaseConfig.d.ts.map +1 -0
- package/esm/src/cli/releaseConfig.js +22 -0
- package/esm/src/next/pwa/mod.d.ts +10 -2
- package/esm/src/next/pwa/mod.d.ts.map +1 -1
- package/esm/src/next/pwa/mod.js +142 -31
- package/package.json +2 -2
- package/script/src/cli/mod.d.ts.map +1 -1
- package/script/src/cli/mod.js +78 -54
- package/script/src/cli/releaseConfig.d.ts +10 -0
- package/script/src/cli/releaseConfig.d.ts.map +1 -0
- package/script/src/cli/releaseConfig.js +26 -0
- package/script/src/next/pwa/mod.d.ts +10 -2
- package/script/src/next/pwa/mod.d.ts.map +1 -1
- package/script/src/next/pwa/mod.js +142 -31
- package/skills/loom-db/SKILL.md +5 -1
package/esm/src/next/pwa/mod.js
CHANGED
|
@@ -28,13 +28,24 @@ function reportError(error, onError, logger) {
|
|
|
28
28
|
(logger ?? console).error("[PWA] Service worker lifecycle error", error);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const registrations = new WeakMap();
|
|
32
|
+
function registerOnce(serwist) {
|
|
33
|
+
let pending = registrations.get(serwist);
|
|
34
|
+
if (!pending) {
|
|
35
|
+
// React effects can remount while registration is still waiting for load.
|
|
36
|
+
pending = Promise.resolve().then(() => serwist.register());
|
|
37
|
+
registrations.set(serwist, pending);
|
|
38
|
+
void pending.catch(() => registrations.delete(serwist));
|
|
39
|
+
}
|
|
40
|
+
return pending;
|
|
33
41
|
}
|
|
34
42
|
/**
|
|
35
43
|
* Registers Loom's Serwist lifecycle listeners and optional update polling.
|
|
36
44
|
*
|
|
37
|
-
*
|
|
45
|
+
* Cleanup removes this observer's listeners and polling without unregistering
|
|
46
|
+
* the worker or removing offline caches. Pending callbacks cannot activate or
|
|
47
|
+
* reload after cleanup. Registration is shared across effect remounts.
|
|
48
|
+
*
|
|
38
49
|
* In `prompt` mode, a waiting worker is activated only after `canReloadNow` and
|
|
39
50
|
* `confirmUpdate` both allow it; in `manual` mode Loom reports availability but
|
|
40
51
|
* never activates the worker for the app.
|
|
@@ -48,8 +59,19 @@ export function setupLoomPwaLifecycle(options = {}) {
|
|
|
48
59
|
const logger = options.logger === false ? false : options.logger ?? console;
|
|
49
60
|
const reload = options.reload ?? defaultReload;
|
|
50
61
|
let disposed = false;
|
|
51
|
-
let
|
|
62
|
+
let reloaded = false;
|
|
63
|
+
let reloadPending = false;
|
|
64
|
+
let approvedWorker;
|
|
65
|
+
let legacyApproval = false;
|
|
66
|
+
let registration;
|
|
52
67
|
let updateInterval;
|
|
68
|
+
let updatePending = false;
|
|
69
|
+
let promptQueue = Promise.resolve();
|
|
70
|
+
const pendingWaiting = new WeakSet();
|
|
71
|
+
const decidedWaiting = new WeakSet();
|
|
72
|
+
const controller = () => navigator.serviceWorker.controller;
|
|
73
|
+
let previousController = controller();
|
|
74
|
+
let latestControl;
|
|
53
75
|
const makeContext = (reason, event) => ({
|
|
54
76
|
event,
|
|
55
77
|
isUpdate: event.isUpdate ?? reason === "waiting",
|
|
@@ -57,77 +79,166 @@ export function setupLoomPwaLifecycle(options = {}) {
|
|
|
57
79
|
serwist,
|
|
58
80
|
wasWaitingBeforeRegister: event.wasWaitingBeforeRegister,
|
|
59
81
|
});
|
|
82
|
+
const failed = (error) => {
|
|
83
|
+
if (!disposed)
|
|
84
|
+
reportError(error, options.onError, options.logger);
|
|
85
|
+
};
|
|
60
86
|
const deferUpdate = (context) => {
|
|
87
|
+
if (disposed)
|
|
88
|
+
return;
|
|
61
89
|
options.onUpdateDeferred?.(context);
|
|
62
90
|
logger && logger.info("[PWA] Update deferred.");
|
|
63
91
|
};
|
|
92
|
+
const isCurrent = (worker) => !worker || controller() === worker ||
|
|
93
|
+
worker.state === "activating" || worker.state === "activated" ||
|
|
94
|
+
(worker.state !== "redundant" &&
|
|
95
|
+
(!registration || registration.waiting === worker));
|
|
96
|
+
const applyControl = async (context) => {
|
|
97
|
+
const current = controller();
|
|
98
|
+
const approved = approvedWorker
|
|
99
|
+
? current === approvedWorker
|
|
100
|
+
: legacyApproval;
|
|
101
|
+
if (disposed || reloaded || reloadPending ||
|
|
102
|
+
(!approved && (updateMode !== "auto" || !context.isUpdate)))
|
|
103
|
+
return;
|
|
104
|
+
// Reserve before awaiting the app's guard; controller events can overlap.
|
|
105
|
+
reloadPending = true;
|
|
106
|
+
try {
|
|
107
|
+
const allowed = await (options.canReloadNow?.(context) ?? true);
|
|
108
|
+
if (disposed || reloaded || current !== controller())
|
|
109
|
+
return;
|
|
110
|
+
if (!allowed) {
|
|
111
|
+
deferUpdate(context);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
reloaded = true;
|
|
115
|
+
options.onUpdateActivated?.(context);
|
|
116
|
+
if (!disposed)
|
|
117
|
+
reload();
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
reloadPending = false;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
64
123
|
const handleWaiting = async (event) => {
|
|
124
|
+
const key = event.sw ?? event;
|
|
125
|
+
if (disposed || reloaded || decidedWaiting.has(key))
|
|
126
|
+
return;
|
|
65
127
|
const context = makeContext("waiting", event);
|
|
66
128
|
options.onUpdateAvailable?.(context);
|
|
129
|
+
if (disposed)
|
|
130
|
+
return;
|
|
67
131
|
if (updateMode === "manual") {
|
|
68
132
|
deferUpdate(context);
|
|
69
133
|
return;
|
|
70
134
|
}
|
|
71
|
-
|
|
135
|
+
const allowed = await (options.canReloadNow?.(context) ?? true);
|
|
136
|
+
if (disposed || reloaded)
|
|
137
|
+
return;
|
|
138
|
+
if (!allowed || !isCurrent(event.sw)) {
|
|
72
139
|
deferUpdate(context);
|
|
73
140
|
return;
|
|
74
141
|
}
|
|
75
142
|
const accepted = updateMode === "auto"
|
|
76
143
|
? true
|
|
77
144
|
: await (options.confirmUpdate?.(context) ?? defaultConfirmUpdate());
|
|
78
|
-
if (
|
|
145
|
+
if (disposed || reloaded)
|
|
146
|
+
return;
|
|
147
|
+
decidedWaiting.add(key);
|
|
148
|
+
if (!accepted || !isCurrent(event.sw)) {
|
|
79
149
|
deferUpdate(context);
|
|
80
150
|
return;
|
|
81
151
|
}
|
|
82
|
-
|
|
152
|
+
approvedWorker = event.sw;
|
|
153
|
+
legacyApproval = !event.sw;
|
|
83
154
|
options.onUpdateAccepted?.(context);
|
|
84
|
-
|
|
85
|
-
};
|
|
86
|
-
const handleControlling = async (event) => {
|
|
87
|
-
const context = makeContext("controlling", event);
|
|
88
|
-
if (!context.isUpdate || (!reloadOnNextControl && updateMode !== "auto")) {
|
|
155
|
+
if (disposed || reloaded)
|
|
89
156
|
return;
|
|
157
|
+
if (event.sw && controller() === event.sw) {
|
|
158
|
+
// Another tab may have activated the accepted worker during the prompt.
|
|
159
|
+
await applyControl(latestControl ?? makeContext("controlling", {
|
|
160
|
+
type: "controlling",
|
|
161
|
+
isUpdate: true,
|
|
162
|
+
sw: event.sw,
|
|
163
|
+
}));
|
|
90
164
|
}
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
165
|
+
else if (event.sw) {
|
|
166
|
+
// Serwist's messageSkipWaiting selects whichever worker is waiting now.
|
|
167
|
+
// Address the approved identity so a replacement cannot inherit consent.
|
|
168
|
+
if (event.sw.state !== "activating" && event.sw.state !== "activated") {
|
|
169
|
+
event.sw.postMessage({ type: "SKIP_WAITING" });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
// Preserve integrations that implement the original identity-free API.
|
|
174
|
+
await serwist.messageSkipWaiting();
|
|
94
175
|
}
|
|
95
|
-
options.onUpdateActivated?.(context);
|
|
96
|
-
reload();
|
|
97
176
|
};
|
|
98
177
|
const waitingListener = (event) => {
|
|
99
|
-
|
|
178
|
+
const key = event.sw ?? event;
|
|
179
|
+
if (disposed || reloaded || pendingWaiting.has(key))
|
|
180
|
+
return;
|
|
181
|
+
pendingWaiting.add(key);
|
|
182
|
+
// The shared confirmation UI has one dialog. Serialize different workers.
|
|
183
|
+
promptQueue = promptQueue.then(() => handleWaiting(event)).catch(failed)
|
|
184
|
+
.finally(() => pendingWaiting.delete(key));
|
|
100
185
|
};
|
|
101
186
|
const controllingListener = (event) => {
|
|
102
|
-
|
|
187
|
+
if (disposed)
|
|
188
|
+
return;
|
|
189
|
+
const current = controller();
|
|
190
|
+
const context = makeContext("controlling", event);
|
|
191
|
+
// Serwist snapshots isUpdate at registration, even on a first-install page
|
|
192
|
+
// that later receives updates. Its external event.sw can also be outdated.
|
|
193
|
+
context.isUpdate ||= Boolean(previousController && current !== previousController);
|
|
194
|
+
previousController = current;
|
|
195
|
+
latestControl = context;
|
|
196
|
+
void applyControl(context).catch(failed);
|
|
103
197
|
};
|
|
104
198
|
serwist.addEventListener("waiting", waitingListener);
|
|
105
199
|
serwist.addEventListener("controlling", controllingListener);
|
|
200
|
+
const observeRegistration = (value) => {
|
|
201
|
+
if (disposed || !value)
|
|
202
|
+
return;
|
|
203
|
+
registration = value;
|
|
204
|
+
// Cached registration does not emit waiting again when an effect remounts.
|
|
205
|
+
if (value.waiting) {
|
|
206
|
+
waitingListener({
|
|
207
|
+
type: "waiting",
|
|
208
|
+
sw: value.waiting,
|
|
209
|
+
wasWaitingBeforeRegister: true,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
};
|
|
106
213
|
if (options.register ?? true) {
|
|
107
|
-
serwist.
|
|
214
|
+
void registerOnce(serwist).then(observeRegistration).catch(failed);
|
|
108
215
|
}
|
|
109
216
|
if (options.updateCheckIntervalMs !== undefined &&
|
|
110
217
|
options.updateCheckIntervalMs > 0) {
|
|
111
|
-
navigator.serviceWorker.ready
|
|
112
|
-
|
|
113
|
-
if (disposed) {
|
|
218
|
+
void navigator.serviceWorker.ready.then((value) => {
|
|
219
|
+
if (disposed)
|
|
114
220
|
return;
|
|
115
|
-
|
|
116
|
-
logger &&
|
|
117
|
-
logger.info(`[PWA] Will check for updates every ${options.updateCheckIntervalMs / 1000} seconds.`);
|
|
221
|
+
registration = value;
|
|
222
|
+
logger && logger.info(`[PWA] Will check for updates every ${options.updateCheckIntervalMs / 1000} seconds.`);
|
|
118
223
|
updateInterval = setInterval(() => {
|
|
119
|
-
|
|
224
|
+
if (disposed || updatePending)
|
|
225
|
+
return;
|
|
226
|
+
updatePending = true;
|
|
227
|
+
void Promise.resolve().then(() => {
|
|
228
|
+
if (!disposed)
|
|
229
|
+
return value.update();
|
|
230
|
+
}).catch(failed).finally(() => {
|
|
231
|
+
updatePending = false;
|
|
232
|
+
});
|
|
120
233
|
}, options.updateCheckIntervalMs);
|
|
121
|
-
})
|
|
122
|
-
.catch((error) => reportError(error, options.onError, options.logger));
|
|
234
|
+
}).catch(failed);
|
|
123
235
|
}
|
|
124
236
|
return () => {
|
|
125
237
|
disposed = true;
|
|
126
238
|
serwist.removeEventListener("waiting", waitingListener);
|
|
127
239
|
serwist.removeEventListener("controlling", controllingListener);
|
|
128
|
-
if (updateInterval !== undefined)
|
|
240
|
+
if (updateInterval !== undefined)
|
|
129
241
|
clearInterval(updateInterval);
|
|
130
|
-
}
|
|
131
242
|
};
|
|
132
243
|
}
|
|
133
244
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadicc/loom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"description": "Deno-first shared helpers for extracting common Next.js app code.",
|
|
5
5
|
"homepage": "https://github.com/gadicc/loom#readme",
|
|
6
6
|
"repository": {
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
},
|
|
232
232
|
"scripts": {},
|
|
233
233
|
"loom": {
|
|
234
|
-
"gitCommit": "
|
|
234
|
+
"gitCommit": "3a84d424bb19d3b82bd3de2263d820912670e323"
|
|
235
235
|
},
|
|
236
236
|
"bin": {
|
|
237
237
|
"loom": "script/bin/loom.js"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/cli/mod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/cli/mod.ts"],"names":[],"mappings":"AA8CA,OAAO,EAUL,KAAK,cAAc,EAMpB,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAC3C,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAC9C,eAAO,MAAM,oBAAoB,2DACyB,CAAC;AAC3D,eAAO,MAAM,yBAAyB,uCAAuC,CAAC;AAC9E,eAAO,MAAM,uBAAuB,qCAAqC,CAAC;AAC1E,eAAO,MAAM,8BAA8B,8CACE,CAAC;AAC9C,eAAO,MAAM,4BAA4B,4CACE,CAAC;AAC5C,eAAO,MAAM,+BAA+B,6BAA6B,CAAC;AAC1E,eAAO,MAAM,6BAA6B,2BAA2B,CAAC;AACtE,eAAO,MAAM,kCAAkC,yBAAyB,CAAC;AACzE,eAAO,MAAM,mCAAmC,yBAAyB,CAAC;AAI1E,iFAAiF;AACjF,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAAO,CAAC;AAwCtD,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,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CAAC,EAAE,MAAM,CAAA;CAAO,YAoClD;AA0/BD,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,EAAE,SAAS,EACb,OAAO,GAAE;IACP,aAAa,CAAC,EAAE,aAAa,CAAC;CAC1B,mBAiBP;AAymBD,wBAAsB,MAAM,CAC1B,IAAI,MAAwB,EAC5B,EAAE,GAAE,SAGH,mBAuKF"}
|
package/script/src/cli/mod.js
CHANGED
|
@@ -77,6 +77,7 @@ const node_module_1 = require("node:module");
|
|
|
77
77
|
const node_path_1 = require("node:path");
|
|
78
78
|
const node_process_1 = __importDefault(require("node:process"));
|
|
79
79
|
const node_util_1 = require("node:util");
|
|
80
|
+
const releaseConfig_js_1 = require("./releaseConfig.js");
|
|
80
81
|
const retention_js_1 = require("../apiKeys/retention.js");
|
|
81
82
|
const projectSkills_js_1 = require("./projectSkills.js");
|
|
82
83
|
const migrationEnv_js_1 = require("./migrationEnv.js");
|
|
@@ -1272,6 +1273,7 @@ function mergeDbConfig(framework, featureConfig) {
|
|
|
1272
1273
|
...featureConfig?.modules,
|
|
1273
1274
|
},
|
|
1274
1275
|
provider: featureConfig?.provider,
|
|
1276
|
+
release: featureConfig?.release,
|
|
1275
1277
|
};
|
|
1276
1278
|
}
|
|
1277
1279
|
function isIdentifierLikeChar(char) {
|
|
@@ -3293,12 +3295,6 @@ function yamlListContainsToken(lines, startIndex, parentIndent, token) {
|
|
|
3293
3295
|
}
|
|
3294
3296
|
return false;
|
|
3295
3297
|
}
|
|
3296
|
-
function yamlBranchValueContainsMain(value) {
|
|
3297
|
-
return yamlScalarValueContainsToken(value, "main");
|
|
3298
|
-
}
|
|
3299
|
-
function yamlListContainsMainBranch(lines, startIndex, parentIndent) {
|
|
3300
|
-
return yamlListContainsToken(lines, startIndex, parentIndent, "main");
|
|
3301
|
-
}
|
|
3302
3298
|
function findGithubOnPushIndex(lines) {
|
|
3303
3299
|
const onIndex = lines.findIndex((line) => /^\s*on:\s*(?:#.*)?$/.test(line));
|
|
3304
3300
|
if (onIndex === -1) {
|
|
@@ -3321,7 +3317,7 @@ function findGithubOnPushIndex(lines) {
|
|
|
3321
3317
|
}
|
|
3322
3318
|
return -1;
|
|
3323
3319
|
}
|
|
3324
|
-
function
|
|
3320
|
+
function githubWorkflowRunsOnBranchPush(text, productionBranch) {
|
|
3325
3321
|
const normalized = normalizeText(text);
|
|
3326
3322
|
if (/^\s*on:\s*(?:push|\[\s*push\s*\])\s*(?:#.*)?$/m.test(normalized)) {
|
|
3327
3323
|
return true;
|
|
@@ -3333,7 +3329,7 @@ function githubWorkflowRunsOnMainPush(text) {
|
|
|
3333
3329
|
}
|
|
3334
3330
|
const pushIndent = lines[pushIndex].match(/^(\s*)/)?.[1].length ?? 0;
|
|
3335
3331
|
let hasBranchFilter = false;
|
|
3336
|
-
let
|
|
3332
|
+
let ignoresProductionBranch = false;
|
|
3337
3333
|
for (let index = pushIndex + 1; index < lines.length; index++) {
|
|
3338
3334
|
const line = lines[index];
|
|
3339
3335
|
const indent = line.match(/^(\s*)/)?.[1].length ?? 0;
|
|
@@ -3347,20 +3343,20 @@ function githubWorkflowRunsOnMainPush(text) {
|
|
|
3347
3343
|
const branchMatch = line.match(/^\s*branches:\s*(.*)$/);
|
|
3348
3344
|
if (branchMatch) {
|
|
3349
3345
|
hasBranchFilter = true;
|
|
3350
|
-
if (
|
|
3351
|
-
|
|
3346
|
+
if (yamlScalarValueContainsToken(branchMatch[1], productionBranch) ||
|
|
3347
|
+
yamlListContainsToken(lines, index, indent, productionBranch)) {
|
|
3352
3348
|
return true;
|
|
3353
3349
|
}
|
|
3354
3350
|
continue;
|
|
3355
3351
|
}
|
|
3356
3352
|
const branchIgnoreMatch = line.match(/^\s*branches-ignore:\s*(.*)$/);
|
|
3357
3353
|
if (branchIgnoreMatch &&
|
|
3358
|
-
(
|
|
3359
|
-
|
|
3360
|
-
|
|
3354
|
+
(yamlScalarValueContainsToken(branchIgnoreMatch[1], productionBranch) ||
|
|
3355
|
+
yamlListContainsToken(lines, index, indent, productionBranch))) {
|
|
3356
|
+
ignoresProductionBranch = true;
|
|
3361
3357
|
}
|
|
3362
3358
|
}
|
|
3363
|
-
return !hasBranchFilter && !
|
|
3359
|
+
return !hasBranchFilter && !ignoresProductionBranch;
|
|
3364
3360
|
}
|
|
3365
3361
|
function workflowStepRunsDbMigrate(block) {
|
|
3366
3362
|
return /\b(?:deno\s+task\s+db:migrate|pnpm\s+(?:run\s+)?db:migrate|npm\s+run\s+db:migrate|yarn\s+(?:run\s+)?db:migrate|bun\s+run\s+db:migrate)\b/
|
|
@@ -3498,7 +3494,7 @@ function getGithubWorkflowJobBlocks(text) {
|
|
|
3498
3494
|
};
|
|
3499
3495
|
});
|
|
3500
3496
|
}
|
|
3501
|
-
function inspectDbMigrationWorkflow(relativePath, workflowText) {
|
|
3497
|
+
function inspectDbMigrationWorkflow(relativePath, workflowText, productionBranch) {
|
|
3502
3498
|
const normalized = normalizeText(workflowText);
|
|
3503
3499
|
const workflowEnvText = workflowPreambleBeforeJobs(normalized);
|
|
3504
3500
|
const jobs = getGithubWorkflowJobBlocks(normalized).map((job) => {
|
|
@@ -3550,7 +3546,7 @@ function inspectDbMigrationWorkflow(relativePath, workflowText) {
|
|
|
3550
3546
|
});
|
|
3551
3547
|
return {
|
|
3552
3548
|
jobs,
|
|
3553
|
-
|
|
3549
|
+
productionPush: githubWorkflowRunsOnBranchPush(normalized, productionBranch),
|
|
3554
3550
|
usesGithubDatabaseUrlVariable: workflowUsesGithubDatabaseUrlVariable(normalized),
|
|
3555
3551
|
relativePath,
|
|
3556
3552
|
usesGithubDatabaseUrlSecret: workflowUsesGithubDatabaseUrlSecret(normalized),
|
|
@@ -3580,7 +3576,7 @@ function dbMigrationWorkflowIsValid(workflow) {
|
|
|
3580
3576
|
function isJsonObject(value) {
|
|
3581
3577
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3582
3578
|
}
|
|
3583
|
-
function
|
|
3579
|
+
function vercelProductionDeploymentIsDisabled(vercelJson, productionBranch) {
|
|
3584
3580
|
const git = vercelJson.git;
|
|
3585
3581
|
if (!isJsonObject(git)) {
|
|
3586
3582
|
return false;
|
|
@@ -3590,9 +3586,9 @@ function vercelMainDeploymentIsDisabled(vercelJson) {
|
|
|
3590
3586
|
return true;
|
|
3591
3587
|
}
|
|
3592
3588
|
return isJsonObject(deploymentEnabled) &&
|
|
3593
|
-
deploymentEnabled
|
|
3589
|
+
deploymentEnabled[productionBranch] === false;
|
|
3594
3590
|
}
|
|
3595
|
-
async function checkDbProductionMigrationFlow(cwd, production) {
|
|
3591
|
+
async function checkDbProductionMigrationFlow(cwd, production, productionBranch) {
|
|
3596
3592
|
const issues = [];
|
|
3597
3593
|
const suggestions = new Set();
|
|
3598
3594
|
const warnings = [];
|
|
@@ -3600,21 +3596,21 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3600
3596
|
const vercelJsonPath = (0, node_path_1.join)(cwd, "vercel.json");
|
|
3601
3597
|
const vercelJsonText = await readTextIfExists(vercelJsonPath);
|
|
3602
3598
|
if (!vercelJsonText) {
|
|
3603
|
-
findings.push(
|
|
3604
|
-
suggestions.add(
|
|
3599
|
+
findings.push(`DB production migration flow is missing vercel.json with automatic ${productionBranch} deployments disabled.`);
|
|
3600
|
+
suggestions.add(`Add \`git.deploymentEnabled[${JSON.stringify(productionBranch)}]: false\` to vercel.json so production deploys wait for the GitHub Actions migration job.`);
|
|
3605
3601
|
}
|
|
3606
3602
|
else {
|
|
3607
3603
|
try {
|
|
3608
3604
|
const vercelJson = parseJson(vercelJsonText, "vercel.json");
|
|
3609
|
-
if (!
|
|
3610
|
-
findings.push(
|
|
3605
|
+
if (!vercelProductionDeploymentIsDisabled(vercelJson, productionBranch)) {
|
|
3606
|
+
findings.push(`DB production migration flow does not disable Vercel automatic deployments for ${productionBranch} in vercel.json.`);
|
|
3611
3607
|
suggestions.add("Set `git.deploymentEnabled` to `false` in vercel.json so GitHub Actions owns production deployments.");
|
|
3612
3608
|
}
|
|
3613
3609
|
}
|
|
3614
3610
|
catch (error) {
|
|
3615
3611
|
findings.push("DB production migration flow could not inspect vercel.json: " +
|
|
3616
3612
|
(error instanceof Error ? error.message : String(error)));
|
|
3617
|
-
suggestions.add(
|
|
3613
|
+
suggestions.add(`Fix vercel.json so Loom can verify \`git.deploymentEnabled[${JSON.stringify(productionBranch)}]: false\`.`);
|
|
3618
3614
|
}
|
|
3619
3615
|
}
|
|
3620
3616
|
const workflowInspections = [];
|
|
@@ -3623,67 +3619,69 @@ async function checkDbProductionMigrationFlow(cwd, production) {
|
|
|
3623
3619
|
if (!workflowText) {
|
|
3624
3620
|
continue;
|
|
3625
3621
|
}
|
|
3626
|
-
workflowInspections.push(inspectDbMigrationWorkflow(relativePath, workflowText));
|
|
3622
|
+
workflowInspections.push(inspectDbMigrationWorkflow(relativePath, workflowText, productionBranch));
|
|
3627
3623
|
}
|
|
3628
|
-
const
|
|
3629
|
-
const migrationJobs =
|
|
3624
|
+
const productionPushWorkflows = workflowInspections.filter((inspection) => inspection.productionPush);
|
|
3625
|
+
const migrationJobs = productionPushWorkflows.flatMap((inspection) => inspection.jobs.filter((job) => job.migrateStepIndex >= 0));
|
|
3630
3626
|
const migrationWorkflowPaths = [
|
|
3631
3627
|
...new Set(migrationJobs.map((inspection) => inspection.relativePath)),
|
|
3632
3628
|
];
|
|
3633
|
-
const validMigrationWorkflow =
|
|
3634
|
-
const oldDeployHookWorkflows =
|
|
3635
|
-
const duplicatedDatabaseUrlWorkflows =
|
|
3636
|
-
const databaseUrlVariableWorkflows =
|
|
3637
|
-
const legacyUnpooledSecretWorkflows =
|
|
3629
|
+
const validMigrationWorkflow = productionPushWorkflows.find(dbMigrationWorkflowIsValid);
|
|
3630
|
+
const oldDeployHookWorkflows = productionPushWorkflows.filter((inspection) => inspection.usesOldVercelDeployHook);
|
|
3631
|
+
const duplicatedDatabaseUrlWorkflows = productionPushWorkflows.filter((inspection) => inspection.usesGithubDatabaseUrlSecret);
|
|
3632
|
+
const databaseUrlVariableWorkflows = productionPushWorkflows.filter((inspection) => inspection.usesGithubDatabaseUrlVariable);
|
|
3633
|
+
const legacyUnpooledSecretWorkflows = productionPushWorkflows.filter((inspection) => inspection.usesGithubUnpooledDatabaseUrlSecret &&
|
|
3638
3634
|
!inspection.usesGithubMigrationDatabaseUrlSecret);
|
|
3639
|
-
const invalidMigrationValidationPaths =
|
|
3635
|
+
const invalidMigrationValidationPaths = productionPushWorkflows.flatMap((inspection) => inspection.jobs.flatMap((job) => job.migrationVerifyStepIndex >= 0 &&
|
|
3640
3636
|
!job.migrationVerifyUsesPulledSnapshot
|
|
3641
3637
|
? [inspection.relativePath]
|
|
3642
3638
|
: []));
|
|
3643
|
-
const structuralOnlyMigrationValidationPaths =
|
|
3639
|
+
const structuralOnlyMigrationValidationPaths = productionPushWorkflows
|
|
3640
|
+
.flatMap((inspection) => inspection.jobs.flatMap((job) => job.migrationVerifyStepIndex >= 0 && !job.migrationVerifyConnects
|
|
3644
3641
|
? [inspection.relativePath]
|
|
3645
3642
|
: []));
|
|
3646
|
-
const vercelCurlWorkflowPaths =
|
|
3643
|
+
const vercelCurlWorkflowPaths = productionPushWorkflows.flatMap((inspection) => inspection.jobs.some((job) => job.vercelCurlStepIndex >= 0)
|
|
3647
3644
|
? [inspection.relativePath]
|
|
3648
3645
|
: []);
|
|
3649
3646
|
if (!validMigrationWorkflow) {
|
|
3650
|
-
if (
|
|
3651
|
-
findings.push(
|
|
3647
|
+
if (productionPushWorkflows.length === 0) {
|
|
3648
|
+
findings.push(`DB production migration flow is missing a GitHub Actions workflow for pushes to ${productionBranch}.`);
|
|
3652
3649
|
}
|
|
3653
3650
|
else if (migrationJobs.length === 0) {
|
|
3654
|
-
findings.push(
|
|
3655
|
-
|
|
3651
|
+
findings.push(`DB production migration flow does not run \`db:migrate\` in the ${productionBranch} release workflow: ` +
|
|
3652
|
+
productionPushWorkflows.map((inspection) => inspection.relativePath)
|
|
3653
|
+
.join(", "));
|
|
3656
3654
|
}
|
|
3657
3655
|
else if (!migrationJobs.some((inspection) => inspection.hasDatabaseUrlBinding ||
|
|
3658
3656
|
inspection.migrateWithVercelProductionEnvStepIndex >= 0)) {
|
|
3659
3657
|
findings.push("DB production migration flow runs migrations without Vercel production env injection: " +
|
|
3660
3658
|
migrationWorkflowPaths.join(", "));
|
|
3661
3659
|
}
|
|
3662
|
-
else if (!
|
|
3660
|
+
else if (!productionPushWorkflows.some((inspection) => inspection.jobs.some((job) => job.stageStepIndex >= 0))) {
|
|
3663
3661
|
findings.push("DB production migration flow does not stage a prebuilt production deployment before migrations: " +
|
|
3664
3662
|
migrationWorkflowPaths.join(", "));
|
|
3665
3663
|
}
|
|
3666
|
-
else if (!
|
|
3664
|
+
else if (!productionPushWorkflows.some((inspection) => inspection.jobs.some((job) => job.promoteStepIndex >= 0))) {
|
|
3667
3665
|
findings.push("DB production migration flow does not promote the staged deployment after migrations: " +
|
|
3668
3666
|
migrationWorkflowPaths.join(", "));
|
|
3669
3667
|
}
|
|
3670
|
-
else if (!
|
|
3668
|
+
else if (!productionPushWorkflows.some((inspection) => inspection.jobs.some((job) => job.snapshotStepIndex === job.pullStepIndex &&
|
|
3671
3669
|
job.metadataStepIndex > job.pullStepIndex &&
|
|
3672
3670
|
job.prepareBuildEnvStepIndex > job.metadataStepIndex &&
|
|
3673
3671
|
job.verifyBuildEnvStepIndex > job.buildStepIndex))) {
|
|
3674
3672
|
findings.push("DB production migration flow does not preserve the pulled migration env and verify metadata-backed build placeholders: " +
|
|
3675
3673
|
migrationWorkflowPaths.join(", "));
|
|
3676
3674
|
}
|
|
3677
|
-
else if (!
|
|
3675
|
+
else if (!productionPushWorkflows.some((inspection) => inspection.jobs.some((job) => job.migrateStepRestoresPulledEnv))) {
|
|
3678
3676
|
findings.push("DB production migration flow does not restore the untouched pulled env before migrations: " +
|
|
3679
3677
|
migrationWorkflowPaths.join(", "));
|
|
3680
3678
|
}
|
|
3681
|
-
else if (!
|
|
3679
|
+
else if (!productionPushWorkflows.some((inspection) => inspection.usesGithubMigrationDatabaseUrlSecret ||
|
|
3682
3680
|
inspection.usesGithubUnpooledDatabaseUrlSecret)) {
|
|
3683
3681
|
findings.push("DB production migration flow is not ready for Sensitive database variables because it lacks a GitHub migration-secret binding: " +
|
|
3684
3682
|
migrationWorkflowPaths.join(", "));
|
|
3685
3683
|
}
|
|
3686
|
-
else if (
|
|
3684
|
+
else if (productionPushWorkflows.some((inspection) => inspection.jobs.some((job) => dbMigrationJobHasOrderedStagedRelease(job) &&
|
|
3687
3685
|
!job.promoteStepUsesExplicitScope))) {
|
|
3688
3686
|
findings.push("DB production migration flow promotes the staged deployment without an explicit Vercel team scope: " +
|
|
3689
3687
|
migrationWorkflowPaths.join(", "));
|
|
@@ -6465,14 +6463,14 @@ function findGithubVariableValue(name, ...collections) {
|
|
|
6465
6463
|
}
|
|
6466
6464
|
return null;
|
|
6467
6465
|
}
|
|
6468
|
-
async function
|
|
6466
|
+
async function hasProductionPushDbMigrationWorkflow(cwd, productionBranch) {
|
|
6469
6467
|
for (const relativePath of await getGithubWorkflowRelativePaths(cwd)) {
|
|
6470
6468
|
const workflowText = await readTextIfExists((0, node_path_1.join)(cwd, relativePath));
|
|
6471
6469
|
if (!workflowText) {
|
|
6472
6470
|
continue;
|
|
6473
6471
|
}
|
|
6474
|
-
const inspection = inspectDbMigrationWorkflow(relativePath, workflowText);
|
|
6475
|
-
if (inspection.
|
|
6472
|
+
const inspection = inspectDbMigrationWorkflow(relativePath, workflowText, productionBranch);
|
|
6473
|
+
if (inspection.productionPush &&
|
|
6476
6474
|
inspection.jobs.some((job) => job.migrateStepIndex >= 0 ||
|
|
6477
6475
|
job.stageStepIndex >= 0 ||
|
|
6478
6476
|
job.promoteStepIndex >= 0)) {
|
|
@@ -6919,6 +6917,19 @@ async function checkDbNetworkFeature(context) {
|
|
|
6919
6917
|
if (!feature || feature.status !== "active") {
|
|
6920
6918
|
return [];
|
|
6921
6919
|
}
|
|
6920
|
+
let productionBranch;
|
|
6921
|
+
try {
|
|
6922
|
+
productionBranch = (0, releaseConfig_js_1.resolveProductionBranch)(feature.config?.release);
|
|
6923
|
+
}
|
|
6924
|
+
catch (error) {
|
|
6925
|
+
return [{
|
|
6926
|
+
label: "DB release configuration",
|
|
6927
|
+
run: () => Promise.resolve(networkCheckResult("issue", error.message, {
|
|
6928
|
+
issues: [error.message],
|
|
6929
|
+
suggestions: ["Fix features.db.config.release in loom.json."],
|
|
6930
|
+
})),
|
|
6931
|
+
}];
|
|
6932
|
+
}
|
|
6922
6933
|
const provider = feature.config
|
|
6923
6934
|
?.provider;
|
|
6924
6935
|
const state = {
|
|
@@ -7026,7 +7037,7 @@ async function checkDbNetworkFeature(context) {
|
|
|
7026
7037
|
createDbEnvCheckStep("Preview has Neon/Postgres env vars", "preview", "present", state, context),
|
|
7027
7038
|
createDbEnvCheckStep("Development does not have Neon/Postgres env vars", "development", "absent", state, context),
|
|
7028
7039
|
];
|
|
7029
|
-
if (await
|
|
7040
|
+
if (await hasProductionPushDbMigrationWorkflow(context.cwd, productionBranch)) {
|
|
7030
7041
|
steps.push(createGithubReleaseConfigCheckStep(state, context));
|
|
7031
7042
|
}
|
|
7032
7043
|
return steps;
|
|
@@ -7540,6 +7551,7 @@ async function setupGithubVercelRelease(cwd, options = {}) {
|
|
|
7540
7551
|
const manifest = manifestText
|
|
7541
7552
|
? parseJson(manifestText, "loom.json")
|
|
7542
7553
|
: null;
|
|
7554
|
+
const productionBranch = (0, releaseConfig_js_1.resolveProductionBranch)(manifest?.features.db?.config?.release);
|
|
7543
7555
|
const vercelLink = await readVercelProjectLink(cwd);
|
|
7544
7556
|
if (!vercelLink.linked || !vercelLink.orgId || !vercelLink.projectId) {
|
|
7545
7557
|
throw new Error(`${vercelLink.detail} Run \`vercel link\` before \`loom db release setup-github\`.`);
|
|
@@ -7578,8 +7590,8 @@ async function setupGithubVercelRelease(cwd, options = {}) {
|
|
|
7578
7590
|
`repos/:owner/:repo/environments/${environment}/deployment-branch-policies`,
|
|
7579
7591
|
], { cwd, env, stdio: "pipe" });
|
|
7580
7592
|
const branchPolicies = parseJson(branchPoliciesResult.stdout || "{}", "GitHub deployment branch policies");
|
|
7581
|
-
if (!branchPolicies.branch_policies?.some((policy) => policy.name ===
|
|
7582
|
-
await requireCommand(`Allow
|
|
7593
|
+
if (!branchPolicies.branch_policies?.some((policy) => policy.name === productionBranch)) {
|
|
7594
|
+
await requireCommand(`Allow ${productionBranch} to deploy to GitHub ${environment}`, commandRunner, "gh", [
|
|
7583
7595
|
"api",
|
|
7584
7596
|
"--method",
|
|
7585
7597
|
"POST",
|
|
@@ -7589,11 +7601,11 @@ async function setupGithubVercelRelease(cwd, options = {}) {
|
|
|
7589
7601
|
], {
|
|
7590
7602
|
cwd,
|
|
7591
7603
|
env,
|
|
7592
|
-
input: JSON.stringify({ name:
|
|
7604
|
+
input: JSON.stringify({ name: productionBranch, type: "branch" }),
|
|
7593
7605
|
stdio: "pipe",
|
|
7594
7606
|
});
|
|
7595
7607
|
}
|
|
7596
|
-
notes.push(`Ensured GitHub environment \`${environment}\` exists and
|
|
7608
|
+
notes.push(`Ensured GitHub environment \`${environment}\` exists and allows the ${productionBranch} release branch; existing branch policies are preserved.`);
|
|
7597
7609
|
await requireCommand("Set GitHub VERCEL_ORG_ID variable", commandRunner, "gh", [
|
|
7598
7610
|
"variable",
|
|
7599
7611
|
"set",
|
|
@@ -7751,6 +7763,7 @@ async function applyDbFeature(cwd, framework, manifest, activate) {
|
|
|
7751
7763
|
const currentFeature = manifest.features.db;
|
|
7752
7764
|
const currentConfig = currentFeature?.config;
|
|
7753
7765
|
const config = mergeDbConfig(framework, currentConfig);
|
|
7766
|
+
(0, releaseConfig_js_1.resolveProductionBranch)(config.release);
|
|
7754
7767
|
const feature = currentFeature
|
|
7755
7768
|
? structuredClone(currentFeature)
|
|
7756
7769
|
: { status: "planned" };
|
|
@@ -8657,11 +8670,22 @@ async function checkDbFeature(cwd, framework, manifest, options) {
|
|
|
8657
8670
|
return { issues, suggestions: [], warnings };
|
|
8658
8671
|
}
|
|
8659
8672
|
const config = mergeDbConfig(framework, feature.config);
|
|
8673
|
+
let productionBranch;
|
|
8674
|
+
try {
|
|
8675
|
+
productionBranch = (0, releaseConfig_js_1.resolveProductionBranch)(config.release);
|
|
8676
|
+
}
|
|
8677
|
+
catch (error) {
|
|
8678
|
+
return {
|
|
8679
|
+
issues: [error.message],
|
|
8680
|
+
suggestions: ["Fix features.db.config.release in loom.json."],
|
|
8681
|
+
warnings,
|
|
8682
|
+
};
|
|
8683
|
+
}
|
|
8660
8684
|
const { packageJson } = await readProjectPackageJson(cwd);
|
|
8661
8685
|
const tooling = await getProjectTooling(cwd, manifest);
|
|
8662
8686
|
const testRunner = await getDbTestRunner(cwd, tooling);
|
|
8663
8687
|
const expectedScripts = getDbExpectedScripts(config, tooling);
|
|
8664
|
-
const migrationFlowCheck = await checkDbProductionMigrationFlow(cwd, options.production ?? false);
|
|
8688
|
+
const migrationFlowCheck = await checkDbProductionMigrationFlow(cwd, options.production ?? false, productionBranch);
|
|
8665
8689
|
issues.push(...migrationFlowCheck.issues);
|
|
8666
8690
|
warnings.push(...migrationFlowCheck.warnings);
|
|
8667
8691
|
for (const suggestion of migrationFlowCheck.suggestions) {
|