create-ailk 0.37.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/dist/add-route.d.ts +5 -0
- package/dist/add-route.js +10 -2
- 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 +15 -1
- package/dist/update.js +155 -30
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -296,6 +296,14 @@ scaffold's). It never rewrites or deletes an existing file, writes nothing
|
|
|
296
296
|
outside `apps/web/app/[locale]/` except the local modules those routes import
|
|
297
297
|
(below), runs no install, and a second run is a no-op. `--apply` exits 0 on success.
|
|
298
298
|
|
|
299
|
+
**What `--apply` copies, it records.** Every file it writes gets a row in
|
|
300
|
+
`.ailk-template-files.json` — the sha256 of the bytes written and the
|
|
301
|
+
create-ailk version that copied it — so `create-ailk update` (below) reads it
|
|
302
|
+
as the untouched template copy it is and carries it forward, instead of
|
|
303
|
+
holding it as "exists, not in the record" on the next release. A site with no
|
|
304
|
+
record gets none; a malformed record refuses the run before anything is
|
|
305
|
+
copied. `add-route` runs the same sync, so it records what it copies too.
|
|
306
|
+
|
|
299
307
|
**Scope.** Every core route (`about`, `contact`, `faq`, `thanks/[slug]`,
|
|
300
308
|
`sign-in`) is always checked, and so is the `(authed)` route GROUP —
|
|
301
309
|
`layout.tsx`, `account/`, and `waitlist/` — even though
|
|
@@ -403,10 +411,20 @@ merge-file` against the recorded version's own copy as the base. A clean
|
|
|
403
411
|
dropped from the roster after the writes, every other byte of the file
|
|
404
412
|
kept. Reported as **Roster rows dropped, no route serves them**.
|
|
405
413
|
|
|
414
|
+
- A file at a template path that exists on disk but was never recorded —
|
|
415
|
+
one an earlier `sync-routes --apply` or `add-route` copied without
|
|
416
|
+
recording it — is **Adopted** when its bytes are that path's template
|
|
417
|
+
copy in any published create-ailk version from the site's
|
|
418
|
+
`patternVersion` up to the one being applied: its row is written and the
|
|
419
|
+
file moves forward as an untouched copy does, listed under **Adopted**
|
|
420
|
+
with the version it matched. One matching no published copy is the
|
|
421
|
+
site's own: skipped as a site edit, never overwritten, and counted under
|
|
422
|
+
**Held as site edits, not in the record**.
|
|
423
|
+
|
|
406
424
|
A file outside the gated-off surfaces and spoke exclusions the site's scope
|
|
407
425
|
no longer covers is **Skipped**, as is one that exists on disk but was never
|
|
408
|
-
recorded (a module bundle's own file, say) when its bytes
|
|
409
|
-
|
|
426
|
+
recorded (a module bundle's own file, say) when its bytes match no template
|
|
427
|
+
copy. Nothing the base scaffold did not write is ever touched. No
|
|
410
428
|
template change at all means `Already up to date` and zero files written.
|
|
411
429
|
|
|
412
430
|
**Tests are held back with the file they test.** When a file is left under
|
package/dist/add-route.d.ts
CHANGED
|
@@ -19,6 +19,11 @@ export interface AddRouteOptions {
|
|
|
19
19
|
templatesDir: string;
|
|
20
20
|
/** The package's `site-templates/` dir — the `_base` layer's seeds. */
|
|
21
21
|
siteTemplatesDir: string;
|
|
22
|
+
/**
|
|
23
|
+
* The create-ailk version the copied route files are recorded at
|
|
24
|
+
* (#11213); defaults to the running package's own, as `syncRoutes` does.
|
|
25
|
+
*/
|
|
26
|
+
version?: string;
|
|
22
27
|
}
|
|
23
28
|
export interface AddRouteResult {
|
|
24
29
|
/** Resolved absolute path to the site. */
|
package/dist/add-route.js
CHANGED
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
* against the site's module set — a route another module delivers is
|
|
13
13
|
* refused, naming the module and `add-module`, before any write;
|
|
14
14
|
* - the surface's route dirs are synced in (`syncRoutes` with it forced
|
|
15
|
-
* carried
|
|
16
|
-
*
|
|
15
|
+
* carried, which records every file it copies in
|
|
16
|
+
* `.ailk-template-files.json`, #11213), `architecture.yaml` is
|
|
17
|
+
* regenerated with it declared, and the nav follows unless the site has
|
|
18
|
+
* edited it (`syncNavConfig`);
|
|
17
19
|
* - the surface's seed content is written from the two shared layers a
|
|
18
20
|
* fresh scaffold keeps it from (the `templates/` overlay, then `_base`),
|
|
19
21
|
* never over a file the site already has.
|
|
@@ -50,6 +52,7 @@ import { GATEABLE_SURFACES, MODULE_SURFACES, parseSurfaces, resolveSurfaces, } f
|
|
|
50
52
|
import { syncRoutes } from "./sync-routes.js";
|
|
51
53
|
import { BASE_LAYER_DIR } from "./template-manifest.js";
|
|
52
54
|
import { templatePageSeeds } from "./template-pages.js";
|
|
55
|
+
import { TEMPLATE_RECORD_PATH } from "./template-record.js";
|
|
53
56
|
import { TopologyError, readSiteTopology } from "./topology.js";
|
|
54
57
|
/** A refusal the CLI exits 2 on, thrown before anything is written. */
|
|
55
58
|
export class AddRouteRefusedError extends Error {
|
|
@@ -117,6 +120,7 @@ export function addRouteToScaffold(opts) {
|
|
|
117
120
|
versions: opts.versions,
|
|
118
121
|
apply: true,
|
|
119
122
|
forceSurfaces: [route],
|
|
123
|
+
...(opts.version !== undefined ? { version: opts.version } : {}),
|
|
120
124
|
});
|
|
121
125
|
const report = seedSurfaceContent(targetAbs, route, opts);
|
|
122
126
|
seedGeneratedContent(targetAbs, route, report);
|
|
@@ -255,6 +259,7 @@ export function formatAddRouteReport(result) {
|
|
|
255
259
|
applied: [],
|
|
256
260
|
refused: [],
|
|
257
261
|
appliedDependencies: [],
|
|
262
|
+
recorded: [],
|
|
258
263
|
missingMessageNamespaces: [],
|
|
259
264
|
};
|
|
260
265
|
const lines = [
|
|
@@ -273,6 +278,9 @@ export function formatAddRouteReport(result) {
|
|
|
273
278
|
lines.push(`Also copied ${routes.appliedDependencies.length} file(s) those routes import:`);
|
|
274
279
|
lines.push(...routes.appliedDependencies.map((dep) => ` ${dep}`));
|
|
275
280
|
}
|
|
281
|
+
if (routes.recorded.length > 0) {
|
|
282
|
+
lines.push(`Recorded ${routes.recorded.length} copied file(s) in ${TEMPLATE_RECORD_PATH}, so create-ailk update carries them forward.`);
|
|
283
|
+
}
|
|
276
284
|
if (routes.refused.length > 0) {
|
|
277
285
|
lines.push(`Routes not copied (${routes.refused.length}) — an import does not resolve (run create-ailk sync-routes for the paths): ${routes.refused.join(", ")}`);
|
|
278
286
|
}
|
package/dist/sync-routes.d.ts
CHANGED
|
@@ -17,6 +17,13 @@ export interface SyncRoutesOptions {
|
|
|
17
17
|
versions: WorkspaceVersionMap;
|
|
18
18
|
/** Copy the missing routes into the target. Default false = check only. */
|
|
19
19
|
apply?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The create-ailk version the copied files are recorded at in
|
|
22
|
+
* `.ailk-template-files.json` (#11213). Defaults to the running package's
|
|
23
|
+
* own — the scaffold marker `CREATE_AILK_VERSION`, which `scaffold()`
|
|
24
|
+
* records a fresh copy at too. Only read with `apply`.
|
|
25
|
+
*/
|
|
26
|
+
version?: string;
|
|
20
27
|
/**
|
|
21
28
|
* Surface ids to treat as carried whether or not any of their route dirs
|
|
22
29
|
* exists yet (#6653 D8) — `add-module` passes the added module's
|
|
@@ -70,6 +77,13 @@ export interface SyncRoutesResult {
|
|
|
70
77
|
missingDependencies: string[];
|
|
71
78
|
/** Dependency files copied this run. Sorted. */
|
|
72
79
|
appliedDependencies: string[];
|
|
80
|
+
/**
|
|
81
|
+
* The copied files `--apply` recorded in `.ailk-template-files.json`
|
|
82
|
+
* (#11213): every recordable route and dependency file it wrote, when the
|
|
83
|
+
* site has a record. Empty without `apply`, and for a site with none.
|
|
84
|
+
* Sorted.
|
|
85
|
+
*/
|
|
86
|
+
recorded: string[];
|
|
73
87
|
/**
|
|
74
88
|
* `ROUTE_MESSAGE_NAMESPACES` dot-paths, of any route in `missing`, absent
|
|
75
89
|
* from the target's `messages/en.json`. CHECK-ONLY — never copied (see
|
|
@@ -190,7 +204,7 @@ export interface SyncRoutesArgs {
|
|
|
190
204
|
apply: boolean;
|
|
191
205
|
help: boolean;
|
|
192
206
|
}
|
|
193
|
-
export declare const SYNC_ROUTES_HELP = "create-ailk sync-routes \u2014 copy template routes an existing site is missing.\n\nUsage:\n create-ailk sync-routes [<target-dir>] [--apply]\n\nArguments:\n <target-dir> An already-scaffolded repo (contains\n architecture.yaml). Defaults to the current dir.\n\nOptions:\n --apply Copy the missing route directories into the target.\n Without it the command only reports: exit 1 when a\n route is missing, 0 when in sync.\n --help, -h Print this message.\n\nChecks every core route plus the routes of each surface the site carries; a\nsurface gated off at scaffold time is skipped, not drift. A route the site has\nchanged locally is reported and never overwritten. Nothing is deleted except,\non a spoke, the retired legacy checkout's files that still match create-ailk's\ncopy: --apply removes them and rewrites the generated billing action (#9142).\n";
|
|
207
|
+
export declare const SYNC_ROUTES_HELP = "create-ailk sync-routes \u2014 copy template routes an existing site is missing.\n\nUsage:\n create-ailk sync-routes [<target-dir>] [--apply]\n\nArguments:\n <target-dir> An already-scaffolded repo (contains\n architecture.yaml). Defaults to the current dir.\n\nOptions:\n --apply Copy the missing route directories into the target.\n Without it the command only reports: exit 1 when a\n route is missing, 0 when in sync.\n --help, -h Print this message.\n\nChecks every core route plus the routes of each surface the site carries; a\nsurface gated off at scaffold time is skipped, not drift. A route the site has\nchanged locally is reported and never overwritten. Nothing is deleted except,\non a spoke, the retired legacy checkout's files that still match create-ailk's\ncopy: --apply removes them and rewrites the generated billing action (#9142).\nEvery file --apply copies is recorded in .ailk-template-files.json, when the\nsite has one, so `create-ailk update` carries it forward (#11213).\n";
|
|
194
208
|
/**
|
|
195
209
|
* Parse the argv AFTER the `sync-routes` word. Strict `node:util` parseArgs,
|
|
196
210
|
* like `parseCliArgs`; at most one positional.
|
package/dist/sync-routes.js
CHANGED
|
@@ -30,6 +30,13 @@
|
|
|
30
30
|
* byte-identical to the template record and rewrites the generated
|
|
31
31
|
* billing action off them (`retireLegacySpokeCheckout`); an edited or
|
|
32
32
|
* unrecorded file is reported and left alone.
|
|
33
|
+
* - What `--apply` copies, it records (#11213). Every recordable file it
|
|
34
|
+
* writes gets a row in `.ailk-template-files.json` — the sha256 of the
|
|
35
|
+
* bytes written and the create-ailk version doing the copy — so
|
|
36
|
+
* `create-ailk update` carries it forward as the untouched template
|
|
37
|
+
* copy it is, never holding it as "exists, not in the record". A site
|
|
38
|
+
* with no record gets none; a malformed one refuses the run before the
|
|
39
|
+
* first write.
|
|
33
40
|
*
|
|
34
41
|
* Pure module: no `import.meta.url`, so jest can import it directly. The
|
|
35
42
|
* package's own `templates/` dir is supplied by programmatic.ts.
|
|
@@ -38,14 +45,14 @@ import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSyn
|
|
|
38
45
|
import { tmpdir } from "node:os";
|
|
39
46
|
import { basename, dirname, join, posix, resolve, sep } from "node:path";
|
|
40
47
|
import { parseArgs } from "node:util";
|
|
41
|
-
import { copyTemplate, renderTemplateFile } from "./copy.js";
|
|
48
|
+
import { buildScaffoldMarkers, copyTemplate, renderTemplateFile } from "./copy.js";
|
|
42
49
|
import { SPOKE_BILLING_ACTION_PATH } from "./derive-architecture.js";
|
|
43
50
|
import { appendEnvRows } from "./lib/declared-env.js";
|
|
44
51
|
import { ENV_CATALOG } from "./lib/env-catalog.js";
|
|
45
52
|
import { publicTreeRemoved } from "./lib/site-modules.js";
|
|
46
53
|
import { BILLING_ACTION, BILLING_ACTION_MARKER, RETIRED_CHECKOUT_E2E_MARKER, RETIRED_CHECKOUT_E2E_WORKFLOW_PATH, RETIRED_SPOKE_CHECKOUT_PATHS, } from "./spoke-checkout.js";
|
|
47
54
|
import { GATEABLE_SURFACES, HUB_KEPT_ROUTE_DIRS, NON_ROUTE_DIRS, ROUTE_DEPENDENCIES, ROUTE_MESSAGE_NAMESPACES, ROUTE_SINCE, surfaceForRouteDir, } from "./surfaces.js";
|
|
48
|
-
import { TEMPLATE_RECORD_PATH, parseTemplateRecord, serializeTemplateRecord, sha256Hex, } from "./template-record.js";
|
|
55
|
+
import { TEMPLATE_RECORD_PATH, parseTemplateRecord, recordCopiedFiles, serializeTemplateRecord, sha256Hex, } from "./template-record.js";
|
|
49
56
|
import { SPOKE_SEAM_FILES, isSpokeExcluded, readSpokeShape, spokeExclusions, } from "./topology.js";
|
|
50
57
|
/** Template-relative prefix every `apps/web` route directory sits under. */
|
|
51
58
|
const ROUTE_ROOT = "apps/web/app/[locale]";
|
|
@@ -748,7 +755,32 @@ export function syncRoutes(opts) {
|
|
|
748
755
|
].sort();
|
|
749
756
|
const applied = [];
|
|
750
757
|
const appliedDependencies = [];
|
|
758
|
+
const recorded = [];
|
|
751
759
|
if (opts.apply === true) {
|
|
760
|
+
// #11213 — the site's record, read before the first write: every
|
|
761
|
+
// recordable file copied below is recorded at the create-ailk version
|
|
762
|
+
// doing the copy, so `update` never reads a synced file as "exists, not
|
|
763
|
+
// in the record". A site with no record gets none; a malformed one
|
|
764
|
+
// refuses the run. A row at a path no longer recorded is dropped, as
|
|
765
|
+
// `update` drops it (#10173).
|
|
766
|
+
const recordPath = join(targetAbs, TEMPLATE_RECORD_PATH);
|
|
767
|
+
let recording;
|
|
768
|
+
if (existsSync(recordPath)) {
|
|
769
|
+
let record;
|
|
770
|
+
try {
|
|
771
|
+
record = parseTemplateRecord(readFileSync(recordPath, "utf8"), { onUnrecordable: () => { } });
|
|
772
|
+
}
|
|
773
|
+
catch (err) {
|
|
774
|
+
throw new Error(`${err.message}; nothing copied`, { cause: err });
|
|
775
|
+
}
|
|
776
|
+
const version = opts.version ?? buildScaffoldMarkers(markers.PROJECT_NAME)["CREATE_AILK_VERSION"];
|
|
777
|
+
if (version === undefined) {
|
|
778
|
+
throw new Error(`cannot record the copied files in ${TEMPLATE_RECORD_PATH}: no create-ailk version; nothing copied`);
|
|
779
|
+
}
|
|
780
|
+
recording = { record, version };
|
|
781
|
+
}
|
|
782
|
+
/** Site-relative path → sha256 of the bytes written, for the record. */
|
|
783
|
+
const copied = new Map();
|
|
752
784
|
const writable = missingRoutes.filter((r) => !refusedSet.has(r));
|
|
753
785
|
// #6786 — the closure a fresh spoke scaffold drops, not only its seeds:
|
|
754
786
|
// a template file that imports a seed goes with it here too.
|
|
@@ -780,6 +812,7 @@ export function syncRoutes(opts) {
|
|
|
780
812
|
? []
|
|
781
813
|
: spokeExcludedUnder(templateRouteRoot, route, spokeShape)),
|
|
782
814
|
],
|
|
815
|
+
onWrite: (rel, bytes) => copied.set(`${ROUTE_ROOT}/${route}/${rel}`, sha256Hex(bytes)),
|
|
783
816
|
});
|
|
784
817
|
}
|
|
785
818
|
for (const dep of missingDependencies) {
|
|
@@ -787,9 +820,18 @@ export function syncRoutes(opts) {
|
|
|
787
820
|
if (!dst.startsWith(targetAbs + sep)) {
|
|
788
821
|
throw new Error(`refusing to write outside target dir: ${dst}`);
|
|
789
822
|
}
|
|
790
|
-
copyDependencyFile(opts.templatesDir, dep, dst, opts.versions, markers);
|
|
823
|
+
const bytes = copyDependencyFile(opts.templatesDir, dep, dst, opts.versions, markers);
|
|
824
|
+
if (bytes !== undefined)
|
|
825
|
+
copied.set(dep, sha256Hex(bytes));
|
|
791
826
|
appliedDependencies.push(dep);
|
|
792
827
|
}
|
|
828
|
+
if (recording !== undefined) {
|
|
829
|
+
const next = recordCopiedFiles(recording.record, copied, recording.version);
|
|
830
|
+
if (next.recorded.length > 0) {
|
|
831
|
+
writeFileSync(recordPath, serializeTemplateRecord(next.record));
|
|
832
|
+
recorded.push(...next.recorded);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
793
835
|
// #7874 D9 — a spoke declares what the copied routes read, as the last
|
|
794
836
|
// write. A malformed env_contract block throws EnvContractError naming
|
|
795
837
|
// its line; the files copied above stay.
|
|
@@ -807,6 +849,7 @@ export function syncRoutes(opts) {
|
|
|
807
849
|
routeImports,
|
|
808
850
|
missingDependencies,
|
|
809
851
|
appliedDependencies,
|
|
852
|
+
recorded,
|
|
810
853
|
missingMessageNamespaces,
|
|
811
854
|
skippedSurfaces,
|
|
812
855
|
publicTreeRemoved: publicTreeSkipped,
|
|
@@ -848,14 +891,17 @@ function hasMessageNamespace(targetAbs, namespace) {
|
|
|
848
891
|
* (`./logo.png`, #9406) is copied byte-for-byte. Never overwrites: the caller
|
|
849
892
|
* (`syncRoutes`) only calls this for a path already confirmed absent from the
|
|
850
893
|
* target, but the check is repeated here so this helper is safe to call on
|
|
851
|
-
* its own.
|
|
894
|
+
* its own. Returns the bytes written, for the record (#11213) — `undefined`
|
|
895
|
+
* when the file was already there.
|
|
852
896
|
*/
|
|
853
897
|
function copyDependencyFile(templatesDir, rel, dst, versions, markers) {
|
|
854
898
|
if (existsSync(dst))
|
|
855
|
-
return;
|
|
899
|
+
return undefined;
|
|
856
900
|
mkdirSync(dirname(dst), { recursive: true });
|
|
857
901
|
const bytes = readFileSync(join(templatesDir, ...rel.split("/")));
|
|
858
|
-
|
|
902
|
+
const rendered = renderTemplateFile(bytes, rel, versions, markers);
|
|
903
|
+
writeFileSync(dst, rendered);
|
|
904
|
+
return rendered;
|
|
859
905
|
}
|
|
860
906
|
/** Render the report the CLI prints after a run. Ends with a newline. */
|
|
861
907
|
export function formatSyncRoutesReport(result, apply) {
|
|
@@ -919,6 +965,10 @@ export function formatSyncRoutesReport(result, apply) {
|
|
|
919
965
|
: `[create-ailk] Also required — ${result.missingDependencies.length} file(s) the above route(s) import:`);
|
|
920
966
|
lines.push(...result.missingDependencies.map((dep) => ` ${dep}`));
|
|
921
967
|
}
|
|
968
|
+
// #11213 — what the record gained, so the next `update` carries it forward.
|
|
969
|
+
if (result.recorded.length > 0) {
|
|
970
|
+
lines.push(`[create-ailk] Recorded ${result.recorded.length} copied file(s) in ${TEMPLATE_RECORD_PATH}, so \`create-ailk update\` carries them forward.`);
|
|
971
|
+
}
|
|
922
972
|
if (result.missingMessageNamespaces.length > 0) {
|
|
923
973
|
lines.push(`[create-ailk] Also required — message namespace(s) not found in apps/web/messages/en.json (add manually, not auto-merged):`);
|
|
924
974
|
lines.push(...result.missingMessageNamespaces.map((ns) => ` ${ns}`));
|
|
@@ -974,6 +1024,8 @@ surface gated off at scaffold time is skipped, not drift. A route the site has
|
|
|
974
1024
|
changed locally is reported and never overwritten. Nothing is deleted except,
|
|
975
1025
|
on a spoke, the retired legacy checkout's files that still match create-ailk's
|
|
976
1026
|
copy: --apply removes them and rewrites the generated billing action (#9142).
|
|
1027
|
+
Every file --apply copies is recorded in .ailk-template-files.json, when the
|
|
1028
|
+
site has one, so \`create-ailk update\` carries it forward (#11213).
|
|
977
1029
|
`;
|
|
978
1030
|
/**
|
|
979
1031
|
* Parse the argv AFTER the `sync-routes` word. Strict `node:util` parseArgs,
|
|
@@ -85,3 +85,14 @@ export interface PlanTemplateRecordOptions {
|
|
|
85
85
|
* `create-ailk update` keeps current for it.
|
|
86
86
|
*/
|
|
87
87
|
export declare function planTemplateRecord(opts: PlanTemplateRecordOptions): TemplateRecord;
|
|
88
|
+
/**
|
|
89
|
+
* `record` with a row for every recordable path of `copied` at `version`
|
|
90
|
+
* (#11213) — what `sync-routes --apply` (and `add-route`, which runs it)
|
|
91
|
+
* records for the template files it copies, so `update` reads each as the
|
|
92
|
+
* untouched template copy it is. A row already at a copied path is
|
|
93
|
+
* replaced. Pure: the caller reads and writes the file.
|
|
94
|
+
*/
|
|
95
|
+
export declare function recordCopiedFiles(record: TemplateRecord, copied: ReadonlyMap<string, string>, version: string): {
|
|
96
|
+
record: TemplateRecord;
|
|
97
|
+
recorded: string[];
|
|
98
|
+
};
|
package/dist/template-record.js
CHANGED
|
@@ -222,3 +222,21 @@ export function planTemplateRecord(opts) {
|
|
|
222
222
|
}
|
|
223
223
|
return { schema: 1, projectName: opts.projectName, files };
|
|
224
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* `record` with a row for every recordable path of `copied` at `version`
|
|
227
|
+
* (#11213) — what `sync-routes --apply` (and `add-route`, which runs it)
|
|
228
|
+
* records for the template files it copies, so `update` reads each as the
|
|
229
|
+
* untouched template copy it is. A row already at a copied path is
|
|
230
|
+
* replaced. Pure: the caller reads and writes the file.
|
|
231
|
+
*/
|
|
232
|
+
export function recordCopiedFiles(record, copied, version) {
|
|
233
|
+
const files = { ...record.files };
|
|
234
|
+
const recorded = [];
|
|
235
|
+
for (const [path, sha256] of copied) {
|
|
236
|
+
if (!isRecordable(path))
|
|
237
|
+
continue;
|
|
238
|
+
files[path] = { sha256, version };
|
|
239
|
+
recorded.push(path);
|
|
240
|
+
}
|
|
241
|
+
return { record: { ...record, files }, recorded: recorded.sort() };
|
|
242
|
+
}
|
package/dist/update.d.ts
CHANGED
|
@@ -71,6 +71,15 @@ export interface UpdateResult {
|
|
|
71
71
|
importers: string[];
|
|
72
72
|
edit: string;
|
|
73
73
|
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Per relative import a moved file names that neither the site nor the
|
|
76
|
+
* template has (#11216): the importers that moved anyway, because their
|
|
77
|
+
* own copies already named it — this run introduced no import.
|
|
78
|
+
*/
|
|
79
|
+
missingImports?: Array<{
|
|
80
|
+
file: string;
|
|
81
|
+
importers: string[];
|
|
82
|
+
}>;
|
|
74
83
|
/** The recorded files whose bytes were another published template version's copy, moved as untouched (#11147). */
|
|
75
84
|
staleCopies?: Array<{
|
|
76
85
|
path: string;
|
|
@@ -78,6 +87,11 @@ export interface UpdateResult {
|
|
|
78
87
|
}>;
|
|
79
88
|
/** The recorded files whose site edit was comment lines only (#11147): merged, or on a conflict the template's copy. */
|
|
80
89
|
commentOnlyEdits?: string[];
|
|
90
|
+
/** The unrecorded files whose bytes were a published template copy (#11213): recorded and moved forward, with the version each matched. */
|
|
91
|
+
adopted?: Array<{
|
|
92
|
+
path: string;
|
|
93
|
+
version: string;
|
|
94
|
+
}>;
|
|
81
95
|
/** The `project.yaml` `env_contract` rows added for env vars the written files read (#10172). */
|
|
82
96
|
envRowsAdded?: string[];
|
|
83
97
|
/** Record rows dropped because the path is no longer recordable (#10173). */
|
|
@@ -127,6 +141,6 @@ export interface UpdateArgs {
|
|
|
127
141
|
target: string | undefined;
|
|
128
142
|
help: boolean;
|
|
129
143
|
}
|
|
130
|
-
export declare const UPDATE_HELP = "create-ailk update \u2014 bring template fixes into a site's copied app code.\n\nUsage:\n create-ailk update [<target-dir>]\n\nArguments:\n <target-dir> The existing site. Defaults to the current dir.\n\nOptions:\n --help, -h Print this message.\n\nReads .ailk-template-files.json (written beside .ailk-site-manifest.json by\nevery template scaffold) to tell an untouched copy from an edit. An\nuntouched apps/web, apps/api or apps/mcp file, or a root tools/jest file the\napp jest configs require, whose template copy changed is overwritten. An\nedited file whose template copy also changed is three-way merged with\n`git` (git must be on PATH); a conflict leaves the file alone and is\nlisted under \"Needs review\"; an apps/web/messages catalog instead gains the\ntemplate's new keys and keeps every value it has, and is reviewed only when a\nkey is an object on one side and a value on the other. An edited file whose\nbytes are another published create-ailk version's copy is a stale copy, not\nan edit: it is overwritten or removed as an untouched file is, listed with\nthe version it matched. An edit that touches only comment lines is listed as\n\"comment-only edit\"; on a conflict the template's copy lands. Every template\ntest, and every site-edited template file, that imports a file left under\n\"Needs review\"
|
|
144
|
+
export declare const UPDATE_HELP = "create-ailk update \u2014 bring template fixes into a site's copied app code.\n\nUsage:\n create-ailk update [<target-dir>]\n\nArguments:\n <target-dir> The existing site. Defaults to the current dir.\n\nOptions:\n --help, -h Print this message.\n\nReads .ailk-template-files.json (written beside .ailk-site-manifest.json by\nevery template scaffold) to tell an untouched copy from an edit. An\nuntouched apps/web, apps/api or apps/mcp file, or a root tools/jest file the\napp jest configs require, whose template copy changed is overwritten. An\nedited file whose template copy also changed is three-way merged with\n`git` (git must be on PATH); a conflict leaves the file alone and is\nlisted under \"Needs review\"; an apps/web/messages catalog instead gains the\ntemplate's new keys and keeps every value it has, and is reviewed only when a\nkey is an object on one side and a value on the other. An edited file whose\nbytes are another published create-ailk version's copy is a stale copy, not\nan edit: it is overwritten or removed as an untouched file is, listed with\nthe version it matched. An edit that touches only comment lines is listed as\n\"comment-only edit\"; on a conflict the template's copy lands. A file at a\ntemplate path that is not in the record (one an earlier sync-routes --apply\nor add-route copied without recording it) whose bytes are a published\ncreate-ailk version's copy \u2014 from the version the site was scaffolded at to\nthis one \u2014 is adopted: recorded and moved forward as an untouched file is,\nlisted under \"Adopted\" with the version it matched. One whose bytes match no\npublished copy is a site edit: skipped, never overwritten, and counted under\n\"Held as site edits, not in the record\". Every template\ntest, and every site-edited template file, that imports a file left under\n\"Needs review\" (by a relative or @/ import, transitively) is held\nat the site's version with it, its record entry is not advanced, and it is\nlisted under \"Held back with <file>\" \u2014 reconcile the file, then run update\nagain to bring it forward. A skipped file never holds another. A file whose\nown bytes are the record's is not held by what it imports: it moves, unless\nit names an export the held copy lacks, and the held file is listed as\n\"Held back: <file> \u2014 imported by N moved files; the site edit is <hunk\nsummary>\". A written file whose import names a file the site lacks gets it\nadded when this template supplies it; otherwise it is held the same way,\nunder \"Held back with <file> (not in this site)\", unless its own copy\nalready named the file \u2014 then it moves and the path is listed under \"Not in\nthis site or the template: <file>\". A file the template removed is kept\nwhile any file still in the site imports it. Every other file in the run\nstill updates. When project.yaml has an env_contract block, each\nenv var the written files read that has no row gains one; no row is edited.\nA record row at a path create-ailk no longer records is dropped and listed.\nA surface the site's .ailk-site-manifest.json names a page on but\narchitecture.yaml does not declare (one no module owns, such as projects)\ngets its route files added and is declared, listed under \"Surfaces declared\nfrom the roster\". A code-route row of that roster no page file serves is\ndropped, listed under \"Roster rows dropped, no route serves them\".\nA site with no record gets one on its first run, from the version its\n.ailk-site-manifest.json already records. A site scaffolded before\n@working-theory/mcp-server has its copied apps/mcp moved to the boot set:\nthe server and each module's paid MCP pack join apps/mcp/package.json, the\ncopied server files go, and apps/mcp/src/lib/paid-tools.generated.ts is\nrewritten on every run. A site scaffolded before @working-theory/api has its\ncopied apps/api moved to the boot file: the app becomes @working-theory/app-api,\nthe package and the six @working-theory/api-<module> packages join\napps/api/package.json, its bins and build:vercel delegate to the package, and\nthe copied server files go. Run `pnpm install` after either move, since the\napp's package.json gained dependencies. Each mdx-body page in content/ with no\n'# ' heading gets its title and description written into its body as its\nheading and intro, listed under \"Page heading added\"; a page with one heading\nis left as it is, and one with several, or one whose frontmatter it cannot\nread, is listed under \"Needs review\". Each bare { on an mdx-body page is\nescaped as \\{ when the site's own MDX parser then reads the page clean, listed\nunder \"Placeholder brace escaped\"; a page it cannot escape safely, or any page\nwith one while the site's dependencies are not installed, is listed under\n\"Needs review\". Commit before running, and review the diff after.\n";
|
|
131
145
|
/** Parse the argv AFTER the `update` word. Strict `node:util` parseArgs, like `parseAdoptArgs`. */
|
|
132
146
|
export declare function parseUpdateArgs(argv: string[]): UpdateArgs;
|
package/dist/update.js
CHANGED
|
@@ -52,6 +52,22 @@
|
|
|
52
52
|
* takes the template's copy on a conflict, and never counts as a site edit
|
|
53
53
|
* for the cascade.
|
|
54
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
|
+
*
|
|
55
71
|
* Pure module: no `import.meta.url` — the CLI supplies `templatesDir`, the
|
|
56
72
|
* `adopt.ts` / `add-route.ts` split.
|
|
57
73
|
*/
|
|
@@ -111,6 +127,8 @@ function versionOlder(a, b) {
|
|
|
111
127
|
return false;
|
|
112
128
|
}
|
|
113
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)";
|
|
114
132
|
const DATABASE_PACKAGE_GUARD = "database/ is still a package here — convert it to the thin consumer first";
|
|
115
133
|
/**
|
|
116
134
|
* Every file under `templatesDir`'s three app trees, plus each of the
|
|
@@ -1224,6 +1242,8 @@ export async function updateSite(opts) {
|
|
|
1224
1242
|
// comment-only edit, or a site edit with its hunk summary (the cascade's).
|
|
1225
1243
|
const staleCopies = [];
|
|
1226
1244
|
const commentOnlyEdits = [];
|
|
1245
|
+
// #11213 — the unrecorded files adopted, with the version each matched.
|
|
1246
|
+
const adopted = [];
|
|
1227
1247
|
const siteEdits = new Map();
|
|
1228
1248
|
const nextFiles = { ...record.files };
|
|
1229
1249
|
const writes = [];
|
|
@@ -1426,26 +1446,39 @@ export async function updateSite(opts) {
|
|
|
1426
1446
|
}
|
|
1427
1447
|
const abs = join(targetDir, ...path.split("/"));
|
|
1428
1448
|
const newBytes = newMap.get(path);
|
|
1429
|
-
|
|
1430
|
-
|
|
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));
|
|
1431
1464
|
const newHash = sha256Hex(newBytes);
|
|
1432
|
-
if (
|
|
1433
|
-
skipped.push({ path, reason: "exists, not in the record" });
|
|
1434
|
-
}
|
|
1435
|
-
else if (DATABASE_BOOT_FILES.includes(path) || ROOT_TOOL_FILES.includes(path)) {
|
|
1436
|
-
// Adoption (#9569 DD8): a thin site converted by hand, or scaffolded
|
|
1437
|
-
// before the boot files were recorded, gains the row for a copy that
|
|
1438
|
-
// already equals the running template's — and so (#9654) does a root
|
|
1439
|
-
// tools/ file a site scaffolded before tools/ was recorded, or copied
|
|
1440
|
-
// by hand. App paths keep today's behaviour: an unrecorded, identical
|
|
1441
|
-
// copy stays unrecorded.
|
|
1465
|
+
if (diskHash === newHash) {
|
|
1442
1466
|
nextFiles[path] = { sha256: newHash, version };
|
|
1443
1467
|
current.push(path);
|
|
1468
|
+
adopted.push({ path, version });
|
|
1469
|
+
continue;
|
|
1444
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;
|
|
1478
|
+
}
|
|
1479
|
+
skipped.push({ path, reason: UNRECORDED_SITE_EDIT });
|
|
1445
1480
|
continue;
|
|
1446
1481
|
}
|
|
1447
|
-
if (outOfScope(path, addExcludedRoutes))
|
|
1448
|
-
continue; // rule i/ii
|
|
1449
1482
|
// #10774 D3 — a surface this run declares was never copied, so its
|
|
1450
1483
|
// missing directory is no owner's deletion: rule iii does not apply.
|
|
1451
1484
|
const highest = isExcluded(path, declaredRouteDirs) ? undefined : highestMissingAncestor(path, targetDir);
|
|
@@ -1470,9 +1503,15 @@ export async function updateSite(opts) {
|
|
|
1470
1503
|
// new, is not added), so the written tree never imports an export the held
|
|
1471
1504
|
// file lacks. A written file whose relative import names a file the site
|
|
1472
1505
|
// will not have once the run lands is held too, under that missing path.
|
|
1473
|
-
// Only the bytes being written are read for a
|
|
1474
|
-
// own copy already compiles against what it has.
|
|
1475
|
-
|
|
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));
|
|
1476
1515
|
// The files left alone outright, before any hold-back joins them.
|
|
1477
1516
|
const leftAlone = new Set(heldFiles);
|
|
1478
1517
|
const writtenBytes = new Map(writes.map((w) => [w.path, w.bytes]));
|
|
@@ -1485,6 +1524,10 @@ export async function updateSite(opts) {
|
|
|
1485
1524
|
// export the held copy lacks (below). Only a test, or a file the site
|
|
1486
1525
|
// itself edited, is held with what it imports.
|
|
1487
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();
|
|
1488
1531
|
const heldPaths = new Set();
|
|
1489
1532
|
const moving = [...new Set([...updated, ...merged, ...added, ...removed, ...current])].sort();
|
|
1490
1533
|
const isFileCache = new Map();
|
|
@@ -1585,6 +1628,20 @@ export async function updateSite(opts) {
|
|
|
1585
1628
|
heldFiles.add(path);
|
|
1586
1629
|
grew = true;
|
|
1587
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
|
+
};
|
|
1588
1645
|
while (grew) {
|
|
1589
1646
|
grew = false;
|
|
1590
1647
|
// #11147 — a removal a still-present file imports — the site's own
|
|
@@ -1618,7 +1675,7 @@ export async function updateSite(opts) {
|
|
|
1618
1675
|
}
|
|
1619
1676
|
const imported = cascades ? importedHeld : new Set();
|
|
1620
1677
|
const missing = new Set();
|
|
1621
|
-
if (written !== undefined
|
|
1678
|
+
if (written !== undefined) {
|
|
1622
1679
|
for (const specifier of localSpecifiers(path, written)) {
|
|
1623
1680
|
const candidates = relativeImportCandidates(path, specifier);
|
|
1624
1681
|
if (candidates.some((c) => (heldFiles.has(c) ? isFileOnDisk(c) : presentAfter(c))))
|
|
@@ -1627,6 +1684,30 @@ export async function updateSite(opts) {
|
|
|
1627
1684
|
// generates, never a file update could have carried.
|
|
1628
1685
|
if (/(^|\/)\.[^./][^/]*\//.test(candidates[0]))
|
|
1629
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
|
+
}
|
|
1630
1711
|
missing.add(candidates[0]);
|
|
1631
1712
|
}
|
|
1632
1713
|
}
|
|
@@ -1704,6 +1785,16 @@ export async function updateSite(opts) {
|
|
|
1704
1785
|
delete nextFiles[path];
|
|
1705
1786
|
}
|
|
1706
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);
|
|
1707
1798
|
const heldBack = [...heldBackByFile.entries()]
|
|
1708
1799
|
.sort(([a], [b]) => a.localeCompare(b))
|
|
1709
1800
|
.map(([file, { tests, importers, missing }]) => ({
|
|
@@ -1745,7 +1836,7 @@ export async function updateSite(opts) {
|
|
|
1745
1836
|
const moved = {
|
|
1746
1837
|
updated: updated.filter(notHeld),
|
|
1747
1838
|
merged: merged.filter(notHeld),
|
|
1748
|
-
added: added.filter(notHeld),
|
|
1839
|
+
added: added.filter(notHeld).sort(),
|
|
1749
1840
|
removed: removed.filter(notHeld),
|
|
1750
1841
|
current: current.filter(notHeld),
|
|
1751
1842
|
};
|
|
@@ -1896,10 +1987,14 @@ export async function updateSite(opts) {
|
|
|
1896
1987
|
skipped,
|
|
1897
1988
|
heldBack,
|
|
1898
1989
|
...(heldImports.length > 0 ? { heldImports } : {}),
|
|
1990
|
+
...(missingImports.length > 0 ? { missingImports } : {}),
|
|
1899
1991
|
...(staleCopies.some((row) => notHeld(row.path))
|
|
1900
1992
|
? { staleCopies: staleCopies.filter((row) => notHeld(row.path)) }
|
|
1901
1993
|
: {}),
|
|
1902
1994
|
...(commentOnlyEdits.some(notHeld) ? { commentOnlyEdits: commentOnlyEdits.filter(notHeld) } : {}),
|
|
1995
|
+
...(adopted.some((row) => notHeld(row.path))
|
|
1996
|
+
? { adopted: adopted.filter((row) => notHeld(row.path)) }
|
|
1997
|
+
: {}),
|
|
1903
1998
|
headingsAdded: headings.written.map(sitePath),
|
|
1904
1999
|
bracesEscaped,
|
|
1905
2000
|
...(backfilled !== undefined ? { backfilled } : {}),
|
|
@@ -1964,11 +2059,19 @@ export function formatUpdateReport(result) {
|
|
|
1964
2059
|
notes.set(path, `a stale copy of the ${version} template`);
|
|
1965
2060
|
for (const path of result.commentOnlyEdits ?? [])
|
|
1966
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));
|
|
1967
2065
|
for (const [label, paths] of sections) {
|
|
1968
|
-
|
|
2066
|
+
const listed = paths.filter((path) => !adoptedPaths.has(path));
|
|
2067
|
+
if (listed.length === 0)
|
|
1969
2068
|
continue;
|
|
1970
|
-
lines.push(`${label} (${
|
|
1971
|
-
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`));
|
|
1972
2075
|
}
|
|
1973
2076
|
if (result.review.length > 0) {
|
|
1974
2077
|
lines.push(`Needs review (${result.review.length}):`);
|
|
@@ -1984,6 +2087,11 @@ export function formatUpdateReport(result) {
|
|
|
1984
2087
|
lines.push(`Held back: ${file} — imported by ${count}; ${edit}`);
|
|
1985
2088
|
lines.push(...importers.map((path) => ` ${path}`));
|
|
1986
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
|
+
}
|
|
1987
2095
|
if (result.envRowsAdded !== undefined) {
|
|
1988
2096
|
lines.push(`project.yaml env_contract rows added (${result.envRowsAdded.length}):`);
|
|
1989
2097
|
lines.push(...result.envRowsAdded.map((name) => ` ${name}`));
|
|
@@ -2004,6 +2112,12 @@ export function formatUpdateReport(result) {
|
|
|
2004
2112
|
lines.push(`Skipped (${result.skipped.length}):`);
|
|
2005
2113
|
lines.push(...result.skipped.map((row) => ` ${row.path} — ${row.reason}`));
|
|
2006
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
|
+
}
|
|
2007
2121
|
const nothingHappened = result.backfilled === undefined &&
|
|
2008
2122
|
result.updated.length === 0 &&
|
|
2009
2123
|
result.merged.length === 0 &&
|
|
@@ -2014,6 +2128,7 @@ export function formatUpdateReport(result) {
|
|
|
2014
2128
|
result.bracesEscaped.length === 0 &&
|
|
2015
2129
|
result.review.length === 0 &&
|
|
2016
2130
|
result.skipped.length === 0 &&
|
|
2131
|
+
result.heldBack.length === 0 &&
|
|
2017
2132
|
result.envRowsAdded === undefined &&
|
|
2018
2133
|
result.droppedRows === undefined &&
|
|
2019
2134
|
result.surfacesDeclared === undefined &&
|
|
@@ -2054,17 +2169,27 @@ key is an object on one side and a value on the other. An edited file whose
|
|
|
2054
2169
|
bytes are another published create-ailk version's copy is a stale copy, not
|
|
2055
2170
|
an edit: it is overwritten or removed as an untouched file is, listed with
|
|
2056
2171
|
the version it matched. An edit that touches only comment lines is listed as
|
|
2057
|
-
"comment-only edit"; on a conflict the template's copy lands.
|
|
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
|
|
2058
2180
|
test, and every site-edited template file, that imports a file left under
|
|
2059
|
-
"Needs review"
|
|
2181
|
+
"Needs review" (by a relative or @/ import, transitively) is held
|
|
2060
2182
|
at the site's version with it, its record entry is not advanced, and it is
|
|
2061
2183
|
listed under "Held back with <file>" — reconcile the file, then run update
|
|
2062
|
-
again to bring it forward. A file
|
|
2063
|
-
held by what it imports: it moves, unless
|
|
2064
|
-
lacks, and the held file is listed as
|
|
2065
|
-
moved files; the site edit is <hunk
|
|
2066
|
-
|
|
2067
|
-
|
|
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
|
|
2068
2193
|
while any file still in the site imports it. Every other file in the run
|
|
2069
2194
|
still updates. When project.yaml has an env_contract block, each
|
|
2070
2195
|
env var the written files read that has no row gains one; no row is edited.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ailk",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.1",
|
|
4
4
|
"description": "Scaffolder for AI Launch Kit — `pnpm create ailk@latest <dir>` produces a starter repo consuming @working-theory/* from npm (per ADR 0007).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"tar": "^7.5.21"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@working-theory/
|
|
32
|
-
"@working-theory/
|
|
31
|
+
"@working-theory/templates": "0.61.0",
|
|
32
|
+
"@working-theory/schema": "0.61.0"
|
|
33
33
|
},
|
|
34
34
|
"repository": {
|
|
35
35
|
"type": "git",
|