Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions src/compiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,9 @@ async function seedThenFinalize(
draft: CompileStateDraft | null,
): Promise<void> {
await maybeSeedPages(root, schema, generation, options);
await finalizeWiki(
root,
draft,
generation.writtenPages,
generation.seedSlugs,
options.changeFilter !== undefined,
);
await finalizeWiki(root, draft, generation.writtenPages, generation.seedSlugs, {
scoped: options.changeFilter !== undefined,
});
}

/** Inner pipeline, runs under lock protection. Returns structured CompileResult. */
Expand Down Expand Up @@ -530,6 +526,25 @@ async function markDeletedAsOrphaned(
}
}

/**
* Behavioural switches for {@link finalizeWiki}, named rather than positional.
*
* They arrive as an object because they are same-typed booleans that each
* INVERT a behaviour: as adjacent positional parameters, transposing two of
* them type-checks silently and the compile does the opposite of what the
* caller asked, on paths whose whole point is that they run less than the
* default. One flag was tolerable; a second one arriving is the signal to name
* them rather than to add a sixth parameter.
*/
interface FinalizeFlags {
/**
* The run recompiled a SUBSET by design (`refresh --stale` supplies a
* `changeFilter`), so it must not record the prompt-modifier selection as
* true of the whole project — see the flush below.
*/
scoped?: boolean;
}

/**
* Resolve interlinks, regenerate index/MOC, refresh embeddings
* post-write. Seed-page slugs are folded into both the changed-slug
Expand All @@ -543,8 +558,9 @@ async function finalizeWiki(
draft: CompileStateDraft | null,
pages: MergedConcept[],
seedSlugs: string[] = [],
scoped = false,
flags: FinalizeFlags = {},
): Promise<void> {
const { scoped = false } = flags;
const conceptChangedSlugs = pages.map((entry) => entry.slug);
const conceptNewSlugs = pages
.filter((entry) => entry.concept.is_new)
Expand Down
Loading