create-ailk 0.36.0 → 0.37.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/README.md +20 -2
- package/component-catalog.json +40 -1
- package/component-catalog.md +7 -5
- package/dist/add-route.d.ts +5 -0
- package/dist/add-route.js +10 -2
- package/dist/surfaces.js +60 -19
- package/dist/sync-routes.d.ts +15 -1
- package/dist/sync-routes.js +58 -6
- package/dist/template-record.d.ts +11 -0
- package/dist/template-record.js +18 -0
- package/dist/update.d.ts +33 -1
- package/dist/update.js +439 -56
- package/package.json +3 -3
- package/templates/.env.example +17 -0
- package/templates/apps/api/.env.example +38 -0
- package/templates/apps/api/CLAUDE.md +3 -0
- package/templates/apps/api/src/lib/__mocks__/prisma.ts +7 -0
- package/templates/apps/mcp/CLAUDE.md +1 -1
- package/templates/apps/web/CLAUDE.md +28 -1
- package/templates/apps/web/app/[locale]/(auth)/reset-password/__tests__/return.test.tsx +179 -0
- package/templates/apps/web/app/[locale]/(auth)/reset-password/page.tsx +22 -2
- package/templates/apps/web/app/[locale]/(auth)/reset-password/reset-password-card.tsx +9 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/billing.test.tsx +240 -76
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/general.test.tsx +242 -28
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/hub-mode.test.tsx +369 -196
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/item.test.tsx +26 -1
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/layout.test.tsx +17 -6
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-menu.test.tsx +51 -12
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/new-popups.test.tsx +17 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/notifications.test.tsx +153 -2
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/page.test.tsx +206 -23
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/popups.test.tsx +150 -188
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/privacy.test.tsx +235 -177
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/rich-translator.ts +63 -0
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/security.test.tsx +0 -3
- package/templates/apps/web/app/[locale]/(authed)/account/__tests__/thread.test.tsx +340 -0
- package/templates/apps/web/app/[locale]/(authed)/account/account-data.ts +7 -5
- package/templates/apps/web/app/[locale]/(authed)/account/account-frame.tsx +19 -3
- package/templates/apps/web/app/[locale]/(authed)/account/actions.ts +8 -4
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/[slug]/page.tsx +161 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/__tests__/page.test.tsx +426 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/appointments-data.ts +76 -0
- package/templates/apps/web/app/[locale]/(authed)/account/appointments/page.tsx +139 -0
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/page.tsx +92 -24
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/[pieceId]/versions/[version]/file/route.ts +32 -1
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/file-route.test.ts +76 -3
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/__tests__/page.test.tsx +290 -41
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/artifact-data.ts +109 -11
- package/templates/apps/web/app/[locale]/(authed)/account/artifacts/page.tsx +43 -44
- package/templates/apps/web/app/[locale]/(authed)/account/billing/__tests__/offerings.test.ts +99 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/offerings.ts +123 -0
- package/templates/apps/web/app/[locale]/(authed)/account/billing/page.tsx +309 -113
- package/templates/apps/web/app/[locale]/(authed)/account/billing-source.ts +192 -65
- package/templates/apps/web/app/[locale]/(authed)/account/components/request-quote.tsx +52 -7
- package/templates/apps/web/app/[locale]/(authed)/account/general/account-name.ts +36 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-actions.ts +70 -2
- package/templates/apps/web/app/[locale]/(authed)/account/general/contact-details.tsx +42 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/page.tsx +55 -58
- package/templates/apps/web/app/[locale]/(authed)/account/general/phone-verification.tsx +2 -1
- package/templates/apps/web/app/[locale]/(authed)/account/general/photo-actions.ts +73 -0
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-form.tsx +12 -9
- package/templates/apps/web/app/[locale]/(authed)/account/general/profile-source.ts +18 -4
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/[kind]/[id]/page.tsx +20 -2
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/member-thread-composer.tsx +43 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/page.tsx +125 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-data.ts +88 -0
- package/templates/apps/web/app/[locale]/(authed)/account/inbox/thread/thread-write.ts +31 -0
- package/templates/apps/web/app/[locale]/(authed)/account/layout.tsx +3 -2
- package/templates/apps/web/app/[locale]/(authed)/account/new-menu.tsx +33 -8
- package/templates/apps/web/app/[locale]/(authed)/account/new-popups.tsx +31 -52
- package/templates/apps/web/app/[locale]/(authed)/account/notifications/page.tsx +44 -4
- package/templates/apps/web/app/[locale]/(authed)/account/page.tsx +69 -49
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/__tests__/export-route.test.ts +173 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/actions.ts +42 -4
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/export/route.ts +102 -0
- package/templates/apps/web/app/[locale]/(authed)/account/privacy/page.tsx +147 -137
- package/templates/apps/web/app/[locale]/(authed)/account/security/__tests__/hub-variant.test.tsx +258 -0
- package/templates/apps/web/app/[locale]/(authed)/account/security/page.tsx +18 -21
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-panel.tsx +34 -6
- package/templates/apps/web/app/[locale]/(authed)/account/security/security-source.ts +37 -7
- package/templates/apps/web/app/[locale]/(authed)/account/settings/page.tsx +0 -2
- package/templates/apps/web/app/[locale]/(authed)/account/settings-frame.tsx +8 -5
- package/templates/apps/web/app/[locale]/flows/[slug]/results/[payload]/ResultsClient.tsx +3 -2
- package/templates/apps/web/app/api/auth/hub/password/__tests__/return.test.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/__tests__/route.test.ts +368 -0
- package/templates/apps/web/app/api/auth/hub/password/return.ts +86 -0
- package/templates/apps/web/app/api/auth/hub/password/route.ts +171 -0
- package/templates/apps/web/app/api/hub-session/__tests__/routes.test.ts +263 -0
- package/templates/apps/web/app/api/hub-session/password/return/route.ts +69 -0
- package/templates/apps/web/app/api/hub-session/password/route.ts +106 -0
- package/templates/apps/web/lib/__tests__/account-config.test.ts +129 -1
- package/templates/apps/web/lib/__tests__/offerings-pricing.test.ts +33 -0
- package/templates/apps/web/lib/account-config.ts +132 -8
- package/templates/apps/web/lib/auth-routes.ts +11 -6
- package/templates/apps/web/lib/offerings-pricing.ts +4 -1
- package/templates/apps/web/messages/en.json +156 -80
- package/versions.json +48 -48
- package/templates/apps/web/app/[locale]/(authed)/account/components/schedule-service.tsx +0 -276
- package/templates/apps/web/app/[locale]/(authed)/account/components/send-message.tsx +0 -128
- package/templates/apps/web/app/[locale]/(authed)/account/settings/__tests__/theme-modes.test.ts +0 -42
- package/templates/apps/web/app/[locale]/(authed)/account/settings/theme-modes.ts +0 -40
package/dist/update.js
CHANGED
|
@@ -40,6 +40,34 @@
|
|
|
40
40
|
* mdx-body page is escaped as `\{`, kept only when the site's own MDX parser
|
|
41
41
|
* reads the page clean (#10773, `mdx-braces.ts`).
|
|
42
42
|
*
|
|
43
|
+
* The hold-back is one file's, never its import cluster's (#11147). A
|
|
44
|
+
* recorded file whose bytes are ANY published template version's copy in
|
|
45
|
+
* the record's range is a stale copy, not a site edit: it moves, and the
|
|
46
|
+
* report names the version. A file left alone does not hold back an
|
|
47
|
+
* importer whose own bytes are the record's — the importer moves, unless it
|
|
48
|
+
* names an export the held copy lacks — and the report lists the held file
|
|
49
|
+
* with the import edge that depends on it. A removal a still-present file
|
|
50
|
+
* imports is held with that file, so the tree stays type-checkable. A site
|
|
51
|
+
* edit that touches only comment lines is reported as `comment-only edit`,
|
|
52
|
+
* takes the template's copy on a conflict, and never counts as a site edit
|
|
53
|
+
* for the cascade.
|
|
54
|
+
*
|
|
55
|
+
* An unrecorded file at a template path — one a `sync-routes --apply` or
|
|
56
|
+
* `add-route` copied before #11213 recorded its copies — is adopted when
|
|
57
|
+
* its bytes are that path's template copy in any published version from
|
|
58
|
+
* the record's oldest (the manifest's `patternVersion`) to the running one:
|
|
59
|
+
* recorded, and moved forward as an untouched copy is, named with the
|
|
60
|
+
* version it matched. One matching no published copy is the site's own:
|
|
61
|
+
* held as a site edit, never overwritten, and counted in the report.
|
|
62
|
+
*
|
|
63
|
+
* A skipped file never holds another (#11216): the run has decided not to
|
|
64
|
+
* manage it, so only a file under review, and what is held with it, holds.
|
|
65
|
+
* A relative import a written file names that the site lacks is added when
|
|
66
|
+
* the template supplies it — listed under "Added", its importer moving with
|
|
67
|
+
* it — and, when the template does not, holds the importer only when this
|
|
68
|
+
* write introduces the import; a site copy already naming it moves, and the
|
|
69
|
+
* report names the path under "Not in this site or the template".
|
|
70
|
+
*
|
|
43
71
|
* Pure module: no `import.meta.url` — the CLI supplies `templatesDir`, the
|
|
44
72
|
* `adopt.ts` / `add-route.ts` split.
|
|
45
73
|
*/
|
|
@@ -54,7 +82,8 @@ import { buildScaffoldMarkers, isExcluded, isTextFile, renderTemplateFile, templ
|
|
|
54
82
|
import { deriveArchitecture } from "./derive-architecture.js";
|
|
55
83
|
import { EnvContractError, planEnvRows, readEnvContract, readManifestTopology, } from "./lib/declared-env.js";
|
|
56
84
|
import { ENV_CATALOG } from "./lib/env-catalog.js";
|
|
57
|
-
import {
|
|
85
|
+
import { assertContentLengthWithinLimit, assertHttpsRegistryUrl, fetchTimeoutSignal, } from "./lib/fetch-guard.js";
|
|
86
|
+
import { DEFAULT_AILK_NPM_REGISTRY_URL, fetchTemplateSnapshot } from "./lib/fetch-template-snapshot.js";
|
|
58
87
|
import { exportsName, listFilesUnder, namedImportsOf } from "./lib/import-graph.js";
|
|
59
88
|
import { mergeThreeWay } from "./lib/merge-three-way.js";
|
|
60
89
|
import { publicTreeRemoved } from "./lib/site-modules.js";
|
|
@@ -81,6 +110,8 @@ function markersForVersion(projectName, version) {
|
|
|
81
110
|
return { ...buildScaffoldMarkers(projectName), CREATE_AILK_VERSION: version };
|
|
82
111
|
}
|
|
83
112
|
const VERSION_TUPLE = /^(\d+)\.(\d+)\.(\d+)/;
|
|
113
|
+
/** A published release — never a pre-release tag, which `versionOlder` would sort beside its release. */
|
|
114
|
+
const RELEASE_VERSION = /^\d+\.\d+\.\d+$/;
|
|
84
115
|
/** `true` iff semver `a` is strictly older than semver `b` (major, minor, patch, numerically). */
|
|
85
116
|
function versionOlder(a, b) {
|
|
86
117
|
const ma = VERSION_TUPLE.exec(a);
|
|
@@ -96,6 +127,8 @@ function versionOlder(a, b) {
|
|
|
96
127
|
return false;
|
|
97
128
|
}
|
|
98
129
|
/** The reason a boot file is skipped on a site whose `database/` is still the copied package (#9569 DD8). */
|
|
130
|
+
/** The `skipped` reason of an unrecorded in-scope file whose bytes match no published template copy (#11213). */
|
|
131
|
+
const UNRECORDED_SITE_EDIT = "exists, not in the record; a site edit (no template copy matched)";
|
|
99
132
|
const DATABASE_PACKAGE_GUARD = "database/ is still a package here — convert it to the thin consumer first";
|
|
100
133
|
/**
|
|
101
134
|
* Every file under `templatesDir`'s three app trees, plus each of the
|
|
@@ -163,6 +196,92 @@ function backfillProjectName(targetDir) {
|
|
|
163
196
|
}
|
|
164
197
|
return targetDir.split(sep).filter(Boolean).pop() ?? targetDir;
|
|
165
198
|
}
|
|
199
|
+
/** The `patternVersion` of `.ailk-site-manifest.json`, or `undefined` when there is none to read. */
|
|
200
|
+
function readPatternVersion(targetDir) {
|
|
201
|
+
const manifestPath = join(targetDir, SITE_ROSTER_PATH);
|
|
202
|
+
if (!existsSync(manifestPath))
|
|
203
|
+
return undefined;
|
|
204
|
+
try {
|
|
205
|
+
const doc = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
206
|
+
const value = doc["patternVersion"];
|
|
207
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return undefined;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/** A source module: the files whose comment lines `summarizeEdit` can tell from code. */
|
|
214
|
+
const SOURCE_FILE = /\.[cm]?[jt]sx?$/;
|
|
215
|
+
/**
|
|
216
|
+
* `lines` with every blank line and every whole-line comment — a `//` line,
|
|
217
|
+
* or the lines of a `/* … *\/` block that opens at a line's start — left
|
|
218
|
+
* out, each remaining line trimmed. A comment that follows code on its line
|
|
219
|
+
* stays with the line: only whole lines are comment lines (#11147).
|
|
220
|
+
*/
|
|
221
|
+
function codeLines(lines) {
|
|
222
|
+
const out = [];
|
|
223
|
+
let inBlock = false;
|
|
224
|
+
for (const raw of lines) {
|
|
225
|
+
const line = raw.trim();
|
|
226
|
+
if (inBlock) {
|
|
227
|
+
const end = line.indexOf("*/");
|
|
228
|
+
if (end === -1)
|
|
229
|
+
continue;
|
|
230
|
+
inBlock = false;
|
|
231
|
+
const rest = line.slice(end + 2).trim();
|
|
232
|
+
if (rest.length > 0)
|
|
233
|
+
out.push(rest);
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (line.length === 0 || line.startsWith("//"))
|
|
237
|
+
continue;
|
|
238
|
+
if (line.startsWith("/*")) {
|
|
239
|
+
const end = line.indexOf("*/", 2);
|
|
240
|
+
if (end === -1) {
|
|
241
|
+
inBlock = true;
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const rest = line.slice(end + 2).trim();
|
|
245
|
+
if (rest.length > 0)
|
|
246
|
+
out.push(rest);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
out.push(line);
|
|
250
|
+
}
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* The site's edit of `path` against the record's copy (#11147): the one
|
|
255
|
+
* changed region's size and first line (`+2 −1 at line 12`), and whether
|
|
256
|
+
* the edit is comment lines only — a source file whose code lines are the
|
|
257
|
+
* same on both sides. A region that opens inside a template literal (an odd
|
|
258
|
+
* number of backticks before it) is never comment-only: its `//` lines are
|
|
259
|
+
* text, not comments.
|
|
260
|
+
*/
|
|
261
|
+
function summarizeEdit(path, base, ours) {
|
|
262
|
+
const a = base.split("\n");
|
|
263
|
+
const b = ours.split("\n");
|
|
264
|
+
let prefix = 0;
|
|
265
|
+
while (prefix < a.length && prefix < b.length && a[prefix] === b[prefix])
|
|
266
|
+
prefix++;
|
|
267
|
+
let suffix = 0;
|
|
268
|
+
while (suffix < a.length - prefix &&
|
|
269
|
+
suffix < b.length - prefix &&
|
|
270
|
+
a[a.length - 1 - suffix] === b[b.length - 1 - suffix]) {
|
|
271
|
+
suffix++;
|
|
272
|
+
}
|
|
273
|
+
const removed = a.length - prefix - suffix;
|
|
274
|
+
const added = b.length - prefix - suffix;
|
|
275
|
+
const summary = `+${added} −${removed} at line ${prefix + 1}`;
|
|
276
|
+
const inTemplateLiteral = a.slice(0, prefix).join("\n").split("`").length % 2 === 0;
|
|
277
|
+
const codeA = codeLines(a);
|
|
278
|
+
const codeB = codeLines(b);
|
|
279
|
+
const commentOnly = SOURCE_FILE.test(path) &&
|
|
280
|
+
!inTemplateLiteral &&
|
|
281
|
+
codeA.length === codeB.length &&
|
|
282
|
+
codeA.every((line, i) => line === codeB[i]);
|
|
283
|
+
return { commentOnly, summary };
|
|
284
|
+
}
|
|
166
285
|
/** The highest directory or file missing on disk on `destRel`'s chain below `apps/<app>/` (D4 rule iii). */
|
|
167
286
|
function highestMissingAncestor(destRel, targetDir) {
|
|
168
287
|
const segments = destRel.split("/");
|
|
@@ -219,10 +338,10 @@ function relativeImportCandidates(fromPath, specifier) {
|
|
|
219
338
|
function isLocal(fromPath, specifier) {
|
|
220
339
|
return specifier.startsWith(".") || (specifier.startsWith("@/") && fromPath.startsWith(WEB_ROOT));
|
|
221
340
|
}
|
|
222
|
-
/** The local module specifiers `text` names. */
|
|
341
|
+
/** The local module specifiers `text` names — in its code lines, never a `jest.mock(…)` a comment cites (#11147). */
|
|
223
342
|
function localSpecifiers(fromPath, text) {
|
|
224
343
|
const out = new Set();
|
|
225
|
-
for (const match of text.matchAll(IMPORT_SPECIFIER)) {
|
|
344
|
+
for (const match of codeLines(text.split("\n")).join("\n").matchAll(IMPORT_SPECIFIER)) {
|
|
226
345
|
const specifier = match[1] ?? match[2] ?? match[3];
|
|
227
346
|
if (specifier !== undefined && isLocal(fromPath, specifier))
|
|
228
347
|
out.add(specifier);
|
|
@@ -868,6 +987,7 @@ export async function updateSite(opts) {
|
|
|
868
987
|
const version = opts.version;
|
|
869
988
|
// ── Load the record, or determine the backfill (D8) ──────────────────
|
|
870
989
|
const recordPath = join(targetDir, TEMPLATE_RECORD_PATH);
|
|
990
|
+
const patternVersion = readPatternVersion(targetDir);
|
|
871
991
|
let record;
|
|
872
992
|
let backfillPatternVersion;
|
|
873
993
|
// #10173 — a row at a path a later create-ailk no longer records (a
|
|
@@ -884,19 +1004,7 @@ export async function updateSite(opts) {
|
|
|
884
1004
|
}
|
|
885
1005
|
}
|
|
886
1006
|
else {
|
|
887
|
-
|
|
888
|
-
let patternVersion;
|
|
889
|
-
if (existsSync(manifestPath)) {
|
|
890
|
-
try {
|
|
891
|
-
const doc = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
892
|
-
const value = doc["patternVersion"];
|
|
893
|
-
if (typeof value === "string" && value.length > 0)
|
|
894
|
-
patternVersion = value;
|
|
895
|
-
}
|
|
896
|
-
catch {
|
|
897
|
-
// an unreadable manifest is the same refusal as a missing one, below.
|
|
898
|
-
}
|
|
899
|
-
}
|
|
1007
|
+
// An unreadable manifest is the same refusal as a missing one.
|
|
900
1008
|
if (patternVersion === undefined) {
|
|
901
1009
|
throw new UpdateRefusedError(`no ${TEMPLATE_RECORD_PATH} and no "patternVersion" in ${SITE_ROSTER_PATH} to rebuild it from; run \`create-ailk adopt\` first`);
|
|
902
1010
|
}
|
|
@@ -1014,6 +1122,56 @@ export async function updateSite(opts) {
|
|
|
1014
1122
|
versionCache.set(v, result);
|
|
1015
1123
|
return result;
|
|
1016
1124
|
}
|
|
1125
|
+
// ── The versions a stale copy could be (#11147) ───────────────────────
|
|
1126
|
+
// Every published version from the record's oldest (its rows' versions,
|
|
1127
|
+
// and the manifest's `patternVersion`) up to, not including, the running
|
|
1128
|
+
// one, newest first — read once from the registry's version list, which
|
|
1129
|
+
// the stub `fetchImpl` of a test may not serve. When it cannot be read,
|
|
1130
|
+
// the record's own versions are the list; never a refusal of the run.
|
|
1131
|
+
let versionsInRange;
|
|
1132
|
+
async function listVersionsInRange() {
|
|
1133
|
+
const known = new Set([...recordedVersions, ...(patternVersion !== undefined ? [patternVersion] : [])]);
|
|
1134
|
+
const floor = [...known].reduce((oldest, v) => (versionOlder(v, oldest) ? v : oldest), version);
|
|
1135
|
+
if (!versionOlder(floor, version))
|
|
1136
|
+
return []; // nothing recorded is older: no range, no request
|
|
1137
|
+
try {
|
|
1138
|
+
const registryUrl = opts.registryUrl ?? process.env["AILK_NPM_REGISTRY_URL"] ?? DEFAULT_AILK_NPM_REGISTRY_URL;
|
|
1139
|
+
assertHttpsRegistryUrl(registryUrl, Error);
|
|
1140
|
+
const response = await (opts.fetchImpl ?? fetch)(`${registryUrl.replace(/\/+$/, "")}/create-ailk`, {
|
|
1141
|
+
method: "GET",
|
|
1142
|
+
headers: { Accept: "application/vnd.npm.install-v1+json" },
|
|
1143
|
+
redirect: "error",
|
|
1144
|
+
signal: fetchTimeoutSignal(),
|
|
1145
|
+
});
|
|
1146
|
+
if (response.ok) {
|
|
1147
|
+
assertContentLengthWithinLimit(response, Error);
|
|
1148
|
+
const versions = (await response.json()).versions;
|
|
1149
|
+
if (isPlainObject(versions)) {
|
|
1150
|
+
for (const v of Object.keys(versions))
|
|
1151
|
+
if (RELEASE_VERSION.test(v))
|
|
1152
|
+
known.add(v);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
catch {
|
|
1157
|
+
// The record's own versions are the list.
|
|
1158
|
+
}
|
|
1159
|
+
return [...known]
|
|
1160
|
+
.filter((v) => !versionOlder(v, floor) && versionOlder(v, version))
|
|
1161
|
+
.sort((a, b) => (versionOlder(a, b) ? 1 : versionOlder(b, a) ? -1 : 0));
|
|
1162
|
+
}
|
|
1163
|
+
/** The version in range whose rendered copy of `path` hashes to `diskHash`, newest first, or `undefined`. */
|
|
1164
|
+
async function staleCopyOf(path, diskHash) {
|
|
1165
|
+
for (const v of await (versionsInRange ??= listVersionsInRange())) {
|
|
1166
|
+
const snapshot = await loadVersionMap(v);
|
|
1167
|
+
if ("error" in snapshot)
|
|
1168
|
+
continue;
|
|
1169
|
+
const bytes = snapshot.get(path);
|
|
1170
|
+
if (bytes !== undefined && sha256Hex(bytes) === diskHash)
|
|
1171
|
+
return v;
|
|
1172
|
+
}
|
|
1173
|
+
return undefined;
|
|
1174
|
+
}
|
|
1017
1175
|
// ── The backfill: fetch the old base and build the synthetic record ──
|
|
1018
1176
|
// Every in-scope snapshot path gets a row at the snapshot's hash, present
|
|
1019
1177
|
// on disk or not (#9527): an absent one then reads as "deleted locally"
|
|
@@ -1080,6 +1238,13 @@ export async function updateSite(opts) {
|
|
|
1080
1238
|
...(apiMove?.review ?? []),
|
|
1081
1239
|
];
|
|
1082
1240
|
const skipped = [];
|
|
1241
|
+
// #11147 — the edited rows sorted: a stale copy of another version, a
|
|
1242
|
+
// comment-only edit, or a site edit with its hunk summary (the cascade's).
|
|
1243
|
+
const staleCopies = [];
|
|
1244
|
+
const commentOnlyEdits = [];
|
|
1245
|
+
// #11213 — the unrecorded files adopted, with the version each matched.
|
|
1246
|
+
const adopted = [];
|
|
1247
|
+
const siteEdits = new Map();
|
|
1083
1248
|
const nextFiles = { ...record.files };
|
|
1084
1249
|
const writes = [];
|
|
1085
1250
|
const deletes = [];
|
|
@@ -1131,8 +1296,13 @@ export async function updateSite(opts) {
|
|
|
1131
1296
|
if (newBytes === undefined) {
|
|
1132
1297
|
// #9654 — the bytes are a pre-#9460 template copy, just not the one
|
|
1133
1298
|
// the row names: not an edit, so it is retired as an untouched copy
|
|
1134
|
-
// is, on the move's run or any later one.
|
|
1135
|
-
|
|
1299
|
+
// is, on the move's run or any later one. #11147 — so is a copy of
|
|
1300
|
+
// any other published version in the record's range.
|
|
1301
|
+
const priorMcpCopy = path.startsWith(`${MCP_SRC}/`) && PRIOR_MCP_TEMPLATE_HASHES.has(diskHash);
|
|
1302
|
+
const stale = priorMcpCopy ? undefined : await staleCopyOf(path, diskHash);
|
|
1303
|
+
if (priorMcpCopy || stale !== undefined) {
|
|
1304
|
+
if (stale !== undefined)
|
|
1305
|
+
staleCopies.push({ path, version: stale });
|
|
1136
1306
|
deletes.push(path);
|
|
1137
1307
|
delete nextFiles[path];
|
|
1138
1308
|
removed.push(path);
|
|
@@ -1149,6 +1319,16 @@ export async function updateSite(opts) {
|
|
|
1149
1319
|
current.push(path);
|
|
1150
1320
|
continue;
|
|
1151
1321
|
}
|
|
1322
|
+
// #11147 — another published version's copy is a stale copy, not an
|
|
1323
|
+
// edit: overwritten as an untouched file is, named with its version.
|
|
1324
|
+
const stale = await staleCopyOf(path, diskHash);
|
|
1325
|
+
if (stale !== undefined) {
|
|
1326
|
+
staleCopies.push({ path, version: stale });
|
|
1327
|
+
writes.push({ path, bytes: Buffer.from(newBytes) });
|
|
1328
|
+
nextFiles[path] = { sha256: newHash, version };
|
|
1329
|
+
updated.push(path);
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1152
1332
|
// Template changed, and the edit does not already match it: three-way merge.
|
|
1153
1333
|
const base = await loadVersionMap(rec.version);
|
|
1154
1334
|
if ("error" in base) {
|
|
@@ -1177,9 +1357,18 @@ export async function updateSite(opts) {
|
|
|
1177
1357
|
review.push({ path, reason: "edited here; binary files are not merged" });
|
|
1178
1358
|
continue;
|
|
1179
1359
|
}
|
|
1360
|
+
const oursText = diskBytes.toString("utf8");
|
|
1361
|
+
const baseText = Buffer.from(baseBytes).toString("utf8");
|
|
1362
|
+
// #11147 — the edit, for the report and the cascade: a comment-only one
|
|
1363
|
+
// is never a site edit.
|
|
1364
|
+
const edit = summarizeEdit(path, baseText, oursText);
|
|
1365
|
+
if (edit.commentOnly)
|
|
1366
|
+
commentOnlyEdits.push(path);
|
|
1367
|
+
else
|
|
1368
|
+
siteEdits.set(path, edit.summary);
|
|
1180
1369
|
const mergeResult = mergeThreeWay({
|
|
1181
|
-
ours:
|
|
1182
|
-
base:
|
|
1370
|
+
ours: oursText,
|
|
1371
|
+
base: baseText,
|
|
1183
1372
|
theirs: Buffer.from(newBytes).toString("utf8"),
|
|
1184
1373
|
oursLabel: "yours",
|
|
1185
1374
|
baseLabel: `template ${rec.version}`,
|
|
@@ -1216,6 +1405,13 @@ export async function updateSite(opts) {
|
|
|
1216
1405
|
merged.push(path);
|
|
1217
1406
|
}
|
|
1218
1407
|
}
|
|
1408
|
+
else if (mergeResult.status === "conflict" && edit.commentOnly) {
|
|
1409
|
+
// #11147 — the site touched only comment lines, on the lines the
|
|
1410
|
+
// template changed: the template's copy lands, reported as such.
|
|
1411
|
+
writes.push({ path, bytes: Buffer.from(newBytes) });
|
|
1412
|
+
nextFiles[path] = { sha256: newHash, version };
|
|
1413
|
+
updated.push(path);
|
|
1414
|
+
}
|
|
1219
1415
|
else if (mergeResult.status === "conflict") {
|
|
1220
1416
|
review.push({
|
|
1221
1417
|
path,
|
|
@@ -1250,26 +1446,39 @@ export async function updateSite(opts) {
|
|
|
1250
1446
|
}
|
|
1251
1447
|
const abs = join(targetDir, ...path.split("/"));
|
|
1252
1448
|
const newBytes = newMap.get(path);
|
|
1253
|
-
|
|
1254
|
-
|
|
1449
|
+
const present = existsSync(abs) && !retired.has(path);
|
|
1450
|
+
if (outOfScope(path, addExcludedRoutes)) {
|
|
1451
|
+
// rule i/ii — never written here, so a copy on disk is left unscanned.
|
|
1452
|
+
if (present)
|
|
1453
|
+
skipped.push({ path, reason: "exists, not in the record; outside this site's scope" });
|
|
1454
|
+
continue;
|
|
1455
|
+
}
|
|
1456
|
+
if (present) {
|
|
1457
|
+
// #11213 — an unrecorded file whose bytes are a published template
|
|
1458
|
+
// copy (the running version's, or any version's in the record's
|
|
1459
|
+
// range) is adopted: recorded, and moved forward as an untouched file
|
|
1460
|
+
// is, named with the version it matched — the boot files (#9569 DD8)
|
|
1461
|
+
// and root tools/ files (#9654) among them. One matching no copy is
|
|
1462
|
+
// the site's own: held, never overwritten.
|
|
1463
|
+
const diskHash = sha256Hex(readFileSync(abs));
|
|
1255
1464
|
const newHash = sha256Hex(newBytes);
|
|
1256
|
-
if (
|
|
1257
|
-
skipped.push({ path, reason: "exists, not in the record" });
|
|
1258
|
-
}
|
|
1259
|
-
else if (DATABASE_BOOT_FILES.includes(path) || ROOT_TOOL_FILES.includes(path)) {
|
|
1260
|
-
// Adoption (#9569 DD8): a thin site converted by hand, or scaffolded
|
|
1261
|
-
// before the boot files were recorded, gains the row for a copy that
|
|
1262
|
-
// already equals the running template's — and so (#9654) does a root
|
|
1263
|
-
// tools/ file a site scaffolded before tools/ was recorded, or copied
|
|
1264
|
-
// by hand. App paths keep today's behaviour: an unrecorded, identical
|
|
1265
|
-
// copy stays unrecorded.
|
|
1465
|
+
if (diskHash === newHash) {
|
|
1266
1466
|
nextFiles[path] = { sha256: newHash, version };
|
|
1267
1467
|
current.push(path);
|
|
1468
|
+
adopted.push({ path, version });
|
|
1469
|
+
continue;
|
|
1470
|
+
}
|
|
1471
|
+
const stale = await staleCopyOf(path, diskHash);
|
|
1472
|
+
if (stale !== undefined) {
|
|
1473
|
+
writes.push({ path, bytes: Buffer.from(newBytes) });
|
|
1474
|
+
nextFiles[path] = { sha256: newHash, version };
|
|
1475
|
+
updated.push(path);
|
|
1476
|
+
adopted.push({ path, version: stale });
|
|
1477
|
+
continue;
|
|
1268
1478
|
}
|
|
1479
|
+
skipped.push({ path, reason: UNRECORDED_SITE_EDIT });
|
|
1269
1480
|
continue;
|
|
1270
1481
|
}
|
|
1271
|
-
if (outOfScope(path, addExcludedRoutes))
|
|
1272
|
-
continue; // rule i/ii
|
|
1273
1482
|
// #10774 D3 — a surface this run declares was never copied, so its
|
|
1274
1483
|
// missing directory is no owner's deletion: rule iii does not apply.
|
|
1275
1484
|
const highest = isExcluded(path, declaredRouteDirs) ? undefined : highestMissingAncestor(path, targetDir);
|
|
@@ -1294,9 +1503,15 @@ export async function updateSite(opts) {
|
|
|
1294
1503
|
// new, is not added), so the written tree never imports an export the held
|
|
1295
1504
|
// file lacks. A written file whose relative import names a file the site
|
|
1296
1505
|
// will not have once the run lands is held too, under that missing path.
|
|
1297
|
-
// Only the bytes being written are read for a
|
|
1298
|
-
// own copy already compiles against what it has.
|
|
1299
|
-
|
|
1506
|
+
// Only the bytes being written are read for that check, a test's too: the
|
|
1507
|
+
// site's own copy already compiles against what it has.
|
|
1508
|
+
//
|
|
1509
|
+
// #11216 — a skipped file is inert: the run has decided not to manage it,
|
|
1510
|
+
// so only a file under review, and what is held with it, holds. Its
|
|
1511
|
+
// exports are still read by the named-import checks below, as any file
|
|
1512
|
+
// staying at the site's version. A missing import the template supplies
|
|
1513
|
+
// is no holder either — the file is added with its importer (below).
|
|
1514
|
+
const heldFiles = new Set(review.map((row) => row.path));
|
|
1300
1515
|
// The files left alone outright, before any hold-back joins them.
|
|
1301
1516
|
const leftAlone = new Set(heldFiles);
|
|
1302
1517
|
const writtenBytes = new Map(writes.map((w) => [w.path, w.bytes]));
|
|
@@ -1304,6 +1519,15 @@ export async function updateSite(opts) {
|
|
|
1304
1519
|
const deleting = new Set([...deletes, ...(mcpMove?.deletes ?? []), ...(apiMove?.deletes ?? [])]);
|
|
1305
1520
|
const adding = new Set(added);
|
|
1306
1521
|
const heldBackByFile = new Map();
|
|
1522
|
+
// #11147 — per held file, the importers that moved anyway: a file whose
|
|
1523
|
+
// own bytes were the record's follows no held import, unless it names an
|
|
1524
|
+
// export the held copy lacks (below). Only a test, or a file the site
|
|
1525
|
+
// itself edited, is held with what it imports.
|
|
1526
|
+
const heldImportsByFile = new Map();
|
|
1527
|
+
// #11216 — per missing import the template does not supply, the importers
|
|
1528
|
+
// that moved anyway; and the dependencies the template supplied, added.
|
|
1529
|
+
const missingImportsByFile = new Map();
|
|
1530
|
+
const dependenciesAdded = new Set();
|
|
1307
1531
|
const heldPaths = new Set();
|
|
1308
1532
|
const moving = [...new Set([...updated, ...merged, ...added, ...removed, ...current])].sort();
|
|
1309
1533
|
const isFileCache = new Map();
|
|
@@ -1359,7 +1583,6 @@ export async function updateSite(opts) {
|
|
|
1359
1583
|
}
|
|
1360
1584
|
sourcesOf.set(path, { all, written });
|
|
1361
1585
|
}
|
|
1362
|
-
const SOURCE_FILE = /\.[cm]?[jt]sx?$/;
|
|
1363
1586
|
const hold = (path, file, missing) => {
|
|
1364
1587
|
const entry = heldBackByFile.get(file) ?? { tests: [], importers: [], missing };
|
|
1365
1588
|
const list = TEST_FILE.test(path) ? entry.tests : entry.importers;
|
|
@@ -1381,6 +1604,19 @@ export async function updateSite(opts) {
|
|
|
1381
1604
|
}
|
|
1382
1605
|
return textCache.get(path);
|
|
1383
1606
|
};
|
|
1607
|
+
const candidatesCache = new Map();
|
|
1608
|
+
/** Every path the local specifiers of `path`'s copy on disk can resolve to. */
|
|
1609
|
+
const importCandidatesOf = (path) => {
|
|
1610
|
+
let hit = candidatesCache.get(path);
|
|
1611
|
+
if (hit === undefined) {
|
|
1612
|
+
const text = diskText(path);
|
|
1613
|
+
hit = new Set(text === undefined
|
|
1614
|
+
? []
|
|
1615
|
+
: localSpecifiers(path, text).flatMap((specifier) => relativeImportCandidates(path, specifier)));
|
|
1616
|
+
candidatesCache.set(path, hit);
|
|
1617
|
+
}
|
|
1618
|
+
return hit;
|
|
1619
|
+
};
|
|
1384
1620
|
// Every app source file this run does not write: the code that keeps the
|
|
1385
1621
|
// site's version and must still find what it imports.
|
|
1386
1622
|
const stayingFiles = [...listFilesUnder(targetDir, ["apps/web", "apps/api", "apps/mcp"])]
|
|
@@ -1392,36 +1628,102 @@ export async function updateSite(opts) {
|
|
|
1392
1628
|
heldFiles.add(path);
|
|
1393
1629
|
grew = true;
|
|
1394
1630
|
};
|
|
1631
|
+
/** Adds the template's copy of `path` (#11216): written, recorded, and read for its own imports on the next pass. */
|
|
1632
|
+
const addDependency = (path, raw) => {
|
|
1633
|
+
const bytes = Buffer.from(raw);
|
|
1634
|
+
const text = bytes.toString("utf8");
|
|
1635
|
+
writes.push({ path, bytes });
|
|
1636
|
+
writtenBytes.set(path, bytes);
|
|
1637
|
+
nextFiles[path] = { sha256: sha256Hex(bytes), version };
|
|
1638
|
+
added.push(path);
|
|
1639
|
+
adding.add(path);
|
|
1640
|
+
dependenciesAdded.add(path);
|
|
1641
|
+
moving.push(path);
|
|
1642
|
+
sourcesOf.set(path, { all: [text], written: text });
|
|
1643
|
+
grew = true;
|
|
1644
|
+
};
|
|
1395
1645
|
while (grew) {
|
|
1396
1646
|
grew = false;
|
|
1647
|
+
// #11147 — a removal a still-present file imports — the site's own
|
|
1648
|
+
// code, a file left alone, or a file held with one — is held with that
|
|
1649
|
+
// importer, so the run never removes what the tree still imports. The
|
|
1650
|
+
// moves' removals (#9567, #9566) retire server copies and are not read.
|
|
1651
|
+
// A written importer held as `missing` on one pass can be what holds the
|
|
1652
|
+
// removal on the next; it then stays held — conservative, never wrong.
|
|
1653
|
+
for (const path of deletes) {
|
|
1654
|
+
if (heldPaths.has(path))
|
|
1655
|
+
continue;
|
|
1656
|
+
const importer = [...stayingFiles, ...heldPaths].find((file) => !rewrittenLater.has(file) && importCandidatesOf(file).has(path));
|
|
1657
|
+
if (importer === undefined)
|
|
1658
|
+
continue;
|
|
1659
|
+
holdPath(path);
|
|
1660
|
+
hold(path, importer, false);
|
|
1661
|
+
}
|
|
1397
1662
|
for (const path of moving) {
|
|
1398
1663
|
if (heldPaths.has(path))
|
|
1399
1664
|
continue;
|
|
1400
1665
|
const { all, written } = sourcesOf.get(path);
|
|
1401
|
-
const
|
|
1666
|
+
const cascades = TEST_FILE.test(path) || siteEdits.has(path);
|
|
1667
|
+
const importedHeld = new Set(all.flatMap((text) => importedHeldFiles(path, text, heldFiles)));
|
|
1668
|
+
if (!cascades) {
|
|
1669
|
+
for (const file of importedHeld) {
|
|
1670
|
+
const importers = heldImportsByFile.get(file) ?? [];
|
|
1671
|
+
if (!importers.includes(path))
|
|
1672
|
+
importers.push(path);
|
|
1673
|
+
heldImportsByFile.set(file, importers);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
const imported = cascades ? importedHeld : new Set();
|
|
1402
1677
|
const missing = new Set();
|
|
1403
|
-
if (written !== undefined
|
|
1678
|
+
if (written !== undefined) {
|
|
1404
1679
|
for (const specifier of localSpecifiers(path, written)) {
|
|
1405
1680
|
const candidates = relativeImportCandidates(path, specifier);
|
|
1406
|
-
if (candidates.some((c) => heldFiles.has(c)
|
|
1681
|
+
if (candidates.some((c) => (heldFiles.has(c) ? isFileOnDisk(c) : presentAfter(c))))
|
|
1407
1682
|
continue;
|
|
1408
1683
|
// A dot-directory (`.source/`, `.next/`) is build output the site
|
|
1409
1684
|
// generates, never a file update could have carried.
|
|
1410
1685
|
if (/(^|\/)\.[^./][^/]*\//.test(candidates[0]))
|
|
1411
1686
|
continue;
|
|
1687
|
+
// #11216 — the template supplies it: added, never a holder. A
|
|
1688
|
+
// dependency is a module the written code imports, never a page or
|
|
1689
|
+
// route file, so the rules that gate what a site SERVES (rule
|
|
1690
|
+
// i/ii, a dropped marketing tree, #10040 D10, an owner-deleted
|
|
1691
|
+
// directory, rule iii) do not hold it back — the hub's
|
|
1692
|
+
// `pricing-page.ts` needs `contact/contact-form-text.ts` whether
|
|
1693
|
+
// or not `/contact` serves. A guarded boot path (#9569 DD8) is a
|
|
1694
|
+
// file on disk the run must not touch, so it stays missing.
|
|
1695
|
+
const supplied = candidates.find((c) => newMap.get(c) !== undefined && !heldPaths.has(c) && !bootFileGuarded(c));
|
|
1696
|
+
if (supplied !== undefined) {
|
|
1697
|
+
addDependency(supplied, newMap.get(supplied));
|
|
1698
|
+
continue;
|
|
1699
|
+
}
|
|
1700
|
+
// #11216 — the site's own copy already names it, and the template
|
|
1701
|
+
// has no copy (one it has was held): this write introduces no
|
|
1702
|
+
// import, so the importer moves and the path is named.
|
|
1703
|
+
if (candidates.every((c) => newMap.get(c) === undefined) &&
|
|
1704
|
+
candidates.some((c) => importCandidatesOf(path).has(c))) {
|
|
1705
|
+
const importers = missingImportsByFile.get(candidates[0]) ?? [];
|
|
1706
|
+
if (!importers.includes(path))
|
|
1707
|
+
importers.push(path);
|
|
1708
|
+
missingImportsByFile.set(candidates[0], importers);
|
|
1709
|
+
continue;
|
|
1710
|
+
}
|
|
1412
1711
|
missing.add(candidates[0]);
|
|
1413
1712
|
}
|
|
1414
1713
|
}
|
|
1415
1714
|
// A named import the file it resolves to — staying at the site's
|
|
1416
|
-
// version — does not export (a regenerated
|
|
1715
|
+
// version, or held back (#11147) — does not export (a regenerated
|
|
1716
|
+
// nav-config, say).
|
|
1417
1717
|
const lacking = new Set();
|
|
1418
1718
|
if (written !== undefined) {
|
|
1419
1719
|
for (const { specifier, names } of namedImportsOf(written)) {
|
|
1420
1720
|
if (!isLocal(path, specifier))
|
|
1421
1721
|
continue;
|
|
1422
1722
|
const target = relativeImportCandidates(path, specifier).find(isFileOnDisk);
|
|
1423
|
-
if (target === undefined ||
|
|
1723
|
+
if (target === undefined || rewrittenLater.has(target))
|
|
1424
1724
|
continue;
|
|
1725
|
+
if (heldFiles.has(target) && cascades)
|
|
1726
|
+
continue; // held with it above
|
|
1425
1727
|
if (writtenBytes.has(target) && !heldPaths.has(target))
|
|
1426
1728
|
continue;
|
|
1427
1729
|
if (deleting.has(target))
|
|
@@ -1483,14 +1785,36 @@ export async function updateSite(opts) {
|
|
|
1483
1785
|
delete nextFiles[path];
|
|
1484
1786
|
}
|
|
1485
1787
|
const notHeld = (path) => !heldPaths.has(path);
|
|
1788
|
+
// #11216 — a dependency added this run is in the site after all.
|
|
1789
|
+
for (let i = skipped.length - 1; i >= 0; i--) {
|
|
1790
|
+
const path = skipped[i].path;
|
|
1791
|
+
if (dependenciesAdded.has(path) && notHeld(path))
|
|
1792
|
+
skipped.splice(i, 1);
|
|
1793
|
+
}
|
|
1794
|
+
const missingImports = [...missingImportsByFile.entries()]
|
|
1795
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
1796
|
+
.map(([file, importers]) => ({ file, importers: importers.filter(notHeld).sort() }))
|
|
1797
|
+
.filter((entry) => entry.importers.length > 0);
|
|
1486
1798
|
const heldBack = [...heldBackByFile.entries()]
|
|
1487
1799
|
.sort(([a], [b]) => a.localeCompare(b))
|
|
1488
1800
|
.map(([file, { tests, importers, missing }]) => ({
|
|
1489
1801
|
file,
|
|
1490
1802
|
tests: tests.sort(),
|
|
1491
1803
|
...(importers.length > 0 ? { importers: importers.sort() } : {}),
|
|
1492
|
-
|
|
1804
|
+
// A removal held back (#11147) is in this site after all.
|
|
1805
|
+
...(missing && !heldPaths.has(file) ? { missing: true } : {}),
|
|
1493
1806
|
}));
|
|
1807
|
+
const leftAloneReason = new Map([...review, ...skipped].map((row) => [row.path, row.reason]));
|
|
1808
|
+
const heldImports = [...heldImportsByFile.entries()]
|
|
1809
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
1810
|
+
.map(([file, importers]) => ({
|
|
1811
|
+
file,
|
|
1812
|
+
importers: importers.filter(notHeld).sort(),
|
|
1813
|
+
edit: siteEdits.has(file)
|
|
1814
|
+
? `the site edit is ${siteEdits.get(file)}`
|
|
1815
|
+
: (leftAloneReason.get(file) ?? "held back with another file"),
|
|
1816
|
+
}))
|
|
1817
|
+
.filter((entry) => entry.importers.length > 0);
|
|
1494
1818
|
// ── Apply: writes and removals, then the record (D4 Order) ───────────
|
|
1495
1819
|
// #9566 — the API move's removals first: a retired file at a boot-set
|
|
1496
1820
|
// path is overwritten by the write that follows, never deleted after it.
|
|
@@ -1512,7 +1836,7 @@ export async function updateSite(opts) {
|
|
|
1512
1836
|
const moved = {
|
|
1513
1837
|
updated: updated.filter(notHeld),
|
|
1514
1838
|
merged: merged.filter(notHeld),
|
|
1515
|
-
added: added.filter(notHeld),
|
|
1839
|
+
added: added.filter(notHeld).sort(),
|
|
1516
1840
|
removed: removed.filter(notHeld),
|
|
1517
1841
|
current: current.filter(notHeld),
|
|
1518
1842
|
};
|
|
@@ -1662,6 +1986,15 @@ export async function updateSite(opts) {
|
|
|
1662
1986
|
review,
|
|
1663
1987
|
skipped,
|
|
1664
1988
|
heldBack,
|
|
1989
|
+
...(heldImports.length > 0 ? { heldImports } : {}),
|
|
1990
|
+
...(missingImports.length > 0 ? { missingImports } : {}),
|
|
1991
|
+
...(staleCopies.some((row) => notHeld(row.path))
|
|
1992
|
+
? { staleCopies: staleCopies.filter((row) => notHeld(row.path)) }
|
|
1993
|
+
: {}),
|
|
1994
|
+
...(commentOnlyEdits.some(notHeld) ? { commentOnlyEdits: commentOnlyEdits.filter(notHeld) } : {}),
|
|
1995
|
+
...(adopted.some((row) => notHeld(row.path))
|
|
1996
|
+
? { adopted: adopted.filter((row) => notHeld(row.path)) }
|
|
1997
|
+
: {}),
|
|
1665
1998
|
headingsAdded: headings.written.map(sitePath),
|
|
1666
1999
|
bracesEscaped,
|
|
1667
2000
|
...(backfilled !== undefined ? { backfilled } : {}),
|
|
@@ -1720,11 +2053,25 @@ export function formatUpdateReport(result) {
|
|
|
1720
2053
|
["Page heading added", result.headingsAdded],
|
|
1721
2054
|
["Placeholder brace escaped", result.bracesEscaped],
|
|
1722
2055
|
];
|
|
2056
|
+
// #11147 — why a moved file's bytes were not the site's.
|
|
2057
|
+
const notes = new Map();
|
|
2058
|
+
for (const { path, version } of result.staleCopies ?? [])
|
|
2059
|
+
notes.set(path, `a stale copy of the ${version} template`);
|
|
2060
|
+
for (const path of result.commentOnlyEdits ?? [])
|
|
2061
|
+
notes.set(path, "comment-only edit");
|
|
2062
|
+
// #11213 — an adopted file is listed once, under its own heading, with
|
|
2063
|
+
// the version it matched.
|
|
2064
|
+
const adoptedPaths = new Set((result.adopted ?? []).map((row) => row.path));
|
|
1723
2065
|
for (const [label, paths] of sections) {
|
|
1724
|
-
|
|
2066
|
+
const listed = paths.filter((path) => !adoptedPaths.has(path));
|
|
2067
|
+
if (listed.length === 0)
|
|
1725
2068
|
continue;
|
|
1726
|
-
lines.push(`${label} (${
|
|
1727
|
-
lines.push(...
|
|
2069
|
+
lines.push(`${label} (${listed.length}):`);
|
|
2070
|
+
lines.push(...listed.map((path) => (notes.has(path) ? ` ${path} — ${notes.get(path)}` : ` ${path}`)));
|
|
2071
|
+
}
|
|
2072
|
+
if (result.adopted !== undefined) {
|
|
2073
|
+
lines.push(`Adopted (${result.adopted.length}):`);
|
|
2074
|
+
lines.push(...result.adopted.map(({ path, version }) => ` ${path} — matched the ${version} template`));
|
|
1728
2075
|
}
|
|
1729
2076
|
if (result.review.length > 0) {
|
|
1730
2077
|
lines.push(`Needs review (${result.review.length}):`);
|
|
@@ -1735,6 +2082,16 @@ export function formatUpdateReport(result) {
|
|
|
1735
2082
|
lines.push(`Held back with ${file}${missing ? " (not in this site)" : ""} (${held.length}):`);
|
|
1736
2083
|
lines.push(...held.map((path) => ` ${path}`));
|
|
1737
2084
|
}
|
|
2085
|
+
for (const { file, importers, edit } of result.heldImports ?? []) {
|
|
2086
|
+
const count = `${importers.length} moved file${importers.length === 1 ? "" : "s"}`;
|
|
2087
|
+
lines.push(`Held back: ${file} — imported by ${count}; ${edit}`);
|
|
2088
|
+
lines.push(...importers.map((path) => ` ${path}`));
|
|
2089
|
+
}
|
|
2090
|
+
for (const { file, importers } of result.missingImports ?? []) {
|
|
2091
|
+
const count = `${importers.length} moved file${importers.length === 1 ? "" : "s"}`;
|
|
2092
|
+
lines.push(`Not in this site or the template: ${file} — imported by ${count}`);
|
|
2093
|
+
lines.push(...importers.map((path) => ` ${path}`));
|
|
2094
|
+
}
|
|
1738
2095
|
if (result.envRowsAdded !== undefined) {
|
|
1739
2096
|
lines.push(`project.yaml env_contract rows added (${result.envRowsAdded.length}):`);
|
|
1740
2097
|
lines.push(...result.envRowsAdded.map((name) => ` ${name}`));
|
|
@@ -1755,6 +2112,12 @@ export function formatUpdateReport(result) {
|
|
|
1755
2112
|
lines.push(`Skipped (${result.skipped.length}):`);
|
|
1756
2113
|
lines.push(...result.skipped.map((row) => ` ${row.path} — ${row.reason}`));
|
|
1757
2114
|
}
|
|
2115
|
+
// #11213 — how many unrecorded files the run left as the site's own,
|
|
2116
|
+
// whenever an unrecorded file was sorted either way.
|
|
2117
|
+
const siteEditsHeld = result.skipped.filter((row) => row.reason === UNRECORDED_SITE_EDIT).length;
|
|
2118
|
+
if (result.adopted !== undefined || siteEditsHeld > 0) {
|
|
2119
|
+
lines.push(`Held as site edits, not in the record: ${siteEditsHeld}`);
|
|
2120
|
+
}
|
|
1758
2121
|
const nothingHappened = result.backfilled === undefined &&
|
|
1759
2122
|
result.updated.length === 0 &&
|
|
1760
2123
|
result.merged.length === 0 &&
|
|
@@ -1765,6 +2128,7 @@ export function formatUpdateReport(result) {
|
|
|
1765
2128
|
result.bracesEscaped.length === 0 &&
|
|
1766
2129
|
result.review.length === 0 &&
|
|
1767
2130
|
result.skipped.length === 0 &&
|
|
2131
|
+
result.heldBack.length === 0 &&
|
|
1768
2132
|
result.envRowsAdded === undefined &&
|
|
1769
2133
|
result.droppedRows === undefined &&
|
|
1770
2134
|
result.surfacesDeclared === undefined &&
|
|
@@ -1801,14 +2165,33 @@ edited file whose template copy also changed is three-way merged with
|
|
|
1801
2165
|
\`git\` (git must be on PATH); a conflict leaves the file alone and is
|
|
1802
2166
|
listed under "Needs review"; an apps/web/messages catalog instead gains the
|
|
1803
2167
|
template's new keys and keeps every value it has, and is reviewed only when a
|
|
1804
|
-
key is an object on one side and a value on the other.
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
2168
|
+
key is an object on one side and a value on the other. An edited file whose
|
|
2169
|
+
bytes are another published create-ailk version's copy is a stale copy, not
|
|
2170
|
+
an edit: it is overwritten or removed as an untouched file is, listed with
|
|
2171
|
+
the version it matched. An edit that touches only comment lines is listed as
|
|
2172
|
+
"comment-only edit"; on a conflict the template's copy lands. A file at a
|
|
2173
|
+
template path that is not in the record (one an earlier sync-routes --apply
|
|
2174
|
+
or add-route copied without recording it) whose bytes are a published
|
|
2175
|
+
create-ailk version's copy — from the version the site was scaffolded at to
|
|
2176
|
+
this one — is adopted: recorded and moved forward as an untouched file is,
|
|
2177
|
+
listed under "Adopted" with the version it matched. One whose bytes match no
|
|
2178
|
+
published copy is a site edit: skipped, never overwritten, and counted under
|
|
2179
|
+
"Held as site edits, not in the record". Every template
|
|
2180
|
+
test, and every site-edited template file, that imports a file left under
|
|
2181
|
+
"Needs review" (by a relative or @/ import, transitively) is held
|
|
2182
|
+
at the site's version with it, its record entry is not advanced, and it is
|
|
2183
|
+
listed under "Held back with <file>" — reconcile the file, then run update
|
|
2184
|
+
again to bring it forward. A skipped file never holds another. A file whose
|
|
2185
|
+
own bytes are the record's is not held by what it imports: it moves, unless
|
|
2186
|
+
it names an export the held copy lacks, and the held file is listed as
|
|
2187
|
+
"Held back: <file> — imported by N moved files; the site edit is <hunk
|
|
2188
|
+
summary>". A written file whose import names a file the site lacks gets it
|
|
2189
|
+
added when this template supplies it; otherwise it is held the same way,
|
|
2190
|
+
under "Held back with <file> (not in this site)", unless its own copy
|
|
2191
|
+
already named the file — then it moves and the path is listed under "Not in
|
|
2192
|
+
this site or the template: <file>". A file the template removed is kept
|
|
2193
|
+
while any file still in the site imports it. Every other file in the run
|
|
2194
|
+
still updates. When project.yaml has an env_contract block, each
|
|
1812
2195
|
env var the written files read that has no row gains one; no row is edited.
|
|
1813
2196
|
A record row at a path create-ailk no longer records is dropped and listed.
|
|
1814
2197
|
A surface the site's .ailk-site-manifest.json names a page on but
|