archidocs 1.2.0 → 1.3.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 +62 -13
- package/dist/cli/commands.d.ts +231 -10
- package/dist/cli/commands.js +134 -9
- package/dist/cli/dev.d.ts +5 -6
- package/dist/cli/dev.js +12 -14
- package/dist/cli/diff-format.d.ts +1 -5
- package/dist/cli/init.d.ts +1 -1
- package/dist/cli/init.js +2 -2
- package/dist/cli/main.js +2 -329
- package/dist/cli/run.d.ts +18 -0
- package/dist/cli/run.js +283 -0
- package/dist/commands/build.d.ts +51 -0
- package/dist/commands/build.js +39 -0
- package/dist/commands/check.d.ts +8 -0
- package/dist/commands/check.js +5 -0
- package/dist/commands/diff.d.ts +29 -0
- package/dist/commands/diff.js +25 -0
- package/dist/commands/export.d.ts +41 -0
- package/dist/commands/export.js +47 -0
- package/dist/commands/history.d.ts +18 -0
- package/dist/commands/history.js +9 -0
- package/dist/commands/index.d.ts +11 -0
- package/dist/commands/index.js +11 -0
- package/dist/core/compare.d.ts +2 -13
- package/dist/core/compare.js +2 -35
- package/dist/core/index.d.ts +3 -6
- package/dist/core/index.js +3 -6
- package/dist/core/load.d.ts +0 -2
- package/dist/core/load.js +5 -6
- package/dist/core/rules.d.ts +10 -0
- package/dist/core/rules.js +186 -7
- package/dist/core/views/compare.d.ts +12 -0
- package/dist/core/views/compare.js +37 -0
- package/dist/core/{deployment-views.d.ts → views/deployment.d.ts} +4 -5
- package/dist/core/{deployment-views.js → views/deployment.js} +5 -7
- package/dist/core/{dynamic-views.d.ts → views/dynamic.d.ts} +1 -3
- package/dist/core/{dynamic-views.js → views/dynamic.js} +4 -8
- package/dist/core/views/generated.d.ts +18 -0
- package/dist/core/views/generated.js +92 -0
- package/dist/core/views/ids.d.ts +36 -0
- package/dist/core/views/ids.js +51 -0
- package/dist/core/views/index.d.ts +13 -0
- package/dist/core/views/index.js +12 -0
- package/dist/core/views/lens.d.ts +27 -0
- package/dist/core/views/lens.js +112 -0
- package/dist/core/views/model.d.ts +21 -0
- package/dist/core/views/model.js +69 -0
- package/dist/core/views/resolve.d.ts +42 -0
- package/dist/core/views/resolve.js +81 -0
- package/dist/core/{save-as-view.d.ts → views/save-as-view.d.ts} +2 -2
- package/dist/core/{save-as-view.js → views/save-as-view.js} +13 -10
- package/dist/core/{saved-views.d.ts → views/saved.d.ts} +4 -18
- package/dist/core/{saved-views.js → views/saved.js} +8 -103
- package/dist/core/views/types.d.ts +91 -0
- package/dist/core/views/types.js +2 -0
- package/dist/core/workspace-files.d.ts +13 -0
- package/dist/core/workspace-files.js +20 -0
- package/dist/git.d.ts +2 -0
- package/dist/git.js +14 -4
- package/dist/history/git.d.ts +0 -10
- package/dist/history/git.js +1 -30
- package/dist/history/index.d.ts +15 -31
- package/dist/history/index.js +47 -43
- package/dist/history/points.d.ts +23 -0
- package/dist/history/points.js +28 -0
- package/dist/history/site.d.ts +30 -0
- package/dist/history/site.js +37 -0
- package/dist/mcp/errors.d.ts +37 -0
- package/dist/mcp/errors.js +35 -0
- package/dist/mcp/history.d.ts +4 -4
- package/dist/mcp/history.js +56 -116
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.js +1 -0
- package/dist/mcp/server.d.ts +1 -2
- package/dist/mcp/server.js +30 -29
- package/dist/mcp/site.d.ts +12 -0
- package/dist/mcp/site.js +46 -0
- package/dist/mcp/source.d.ts +14 -7
- package/dist/mcp/source.js +25 -99
- package/dist/render/layout.d.ts +20 -3
- package/dist/render/layout.js +49 -12
- package/dist/render/sequence-svg.d.ts +1 -1
- package/dist/render/sequence.d.ts +1 -1
- package/dist/render/svg.d.ts +1 -1
- package/dist/render/svg.js +4 -4
- package/dist/revisions/find.d.ts +64 -0
- package/dist/revisions/find.js +85 -0
- package/dist/revisions/index.d.ts +57 -0
- package/dist/revisions/index.js +24 -0
- package/dist/revisions/site.d.ts +82 -0
- package/dist/revisions/site.js +157 -0
- package/dist/revisions/text.d.ts +8 -0
- package/dist/revisions/text.js +17 -0
- package/dist/revisions/touching.d.ts +7 -0
- package/dist/revisions/touching.js +7 -0
- package/dist/schema/adr.js +18 -13
- package/dist/schema/workspace.js +226 -130
- package/dist/viewer/assets/index-C0lIIm8V.js +138 -0
- package/dist/viewer/assets/index-YFA-pYjQ.css +1 -0
- package/dist/viewer/assets/{layout.worker-Bg-OaLVN.js → layout.worker-BRHAGJrD.js} +1 -1
- package/dist/viewer/assets/{png-BDKIXtm5.js → png-DMwnpRCt.js} +1 -1
- package/dist/viewer/assets/{svg-Bulv5YWn.js → svg-DN6lMeZo.js} +2 -2
- package/dist/viewer/index.html +2 -2
- package/dist/workspace/index.d.ts +37 -0
- package/dist/workspace/index.js +52 -0
- package/guide/SKILL.md +1 -1
- package/guide/topics/bootstrap.md +1 -1
- package/guide/topics/relationships.md +1 -1
- package/package.json +4 -3
- package/schemas/adr.schema.json +18 -15
- package/schemas/model.schema.json +637 -1144
- package/schemas/project.schema.json +8 -4
- package/schemas/workspace.schema.json +39 -20
- package/dist/core/views.d.ts +0 -126
- package/dist/core/views.js +0 -217
- package/dist/viewer/assets/index-DvKgCpBr.css +0 -1
- package/dist/viewer/assets/index-gucix3xm.js +0 -113
- /package/dist/{history → revisions}/migrate.d.ts +0 -0
- /package/dist/{history → revisions}/migrate.js +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Issue } from "../core/index.ts";
|
|
2
|
+
import type { Checkout } from "../workspace/index.ts";
|
|
3
|
+
export interface BuildOptions {
|
|
4
|
+
/** The folder to write, absolute. */
|
|
5
|
+
out: string;
|
|
6
|
+
/** The prebuilt viewer, copied as is into a site. */
|
|
7
|
+
viewerDir: string;
|
|
8
|
+
/** How many past Bundles a site keeps: a count or all. */
|
|
9
|
+
keep: number | "all";
|
|
10
|
+
/** Write only the Bundle, not the site. */
|
|
11
|
+
bundleOnly: boolean;
|
|
12
|
+
/** Write a preview site of HEAD against `origin/<base>`; `base` defaults to origin's HEAD branch, else main. */
|
|
13
|
+
preview?: {
|
|
14
|
+
base?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export type BuildResult =
|
|
18
|
+
/** The Workspace has errors; nothing was written. */
|
|
19
|
+
{
|
|
20
|
+
kind: "errors";
|
|
21
|
+
issues: Issue[];
|
|
22
|
+
}
|
|
23
|
+
/** A preview needs git and the Workspace isn't in a repo; nothing was written. */
|
|
24
|
+
| {
|
|
25
|
+
kind: "not-in-git";
|
|
26
|
+
}
|
|
27
|
+
/** A site needs the viewer, and `viewerDir` has none; nothing was written. */
|
|
28
|
+
| {
|
|
29
|
+
kind: "viewer-missing";
|
|
30
|
+
viewerDir: string;
|
|
31
|
+
}
|
|
32
|
+
/** Wrote the Bundle alone, to `file`. */
|
|
33
|
+
| {
|
|
34
|
+
kind: "bundle";
|
|
35
|
+
file: string;
|
|
36
|
+
}
|
|
37
|
+
/** Wrote the site to `out`. */
|
|
38
|
+
| {
|
|
39
|
+
kind: "site";
|
|
40
|
+
out: string;
|
|
41
|
+
}
|
|
42
|
+
/** Wrote the preview site: the PR head against `origin/<base>`. */
|
|
43
|
+
| {
|
|
44
|
+
kind: "preview";
|
|
45
|
+
out: string;
|
|
46
|
+
base: string;
|
|
47
|
+
baseSha: string;
|
|
48
|
+
headSha: string;
|
|
49
|
+
};
|
|
50
|
+
/** The Workspace's Bundle, alone or as a site with the viewer and past Bundles, or as a PR preview site. */
|
|
51
|
+
export declare function build(checkout: Checkout, options: BuildOptions): Promise<BuildResult>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { cp } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { defaultBaseBranch, previewSides, publishHistory, publishPreview, writeSite } from "../history/index.js";
|
|
5
|
+
import { INDEX_VERSION, LATEST_BUNDLE_PATH } from "../revisions/index.js";
|
|
6
|
+
/** The Workspace's Bundle, alone or as a site with the viewer and past Bundles, or as a PR preview site. */
|
|
7
|
+
export async function build(checkout, options) {
|
|
8
|
+
const { out, viewerDir, keep, bundleOnly } = options;
|
|
9
|
+
const { bundle, issues } = await checkout.load();
|
|
10
|
+
if (issues.some((i) => i.severity === "error"))
|
|
11
|
+
return { kind: "errors", issues };
|
|
12
|
+
// A preview finds both sides before writing anything, so a missing base writes no site.
|
|
13
|
+
let preview;
|
|
14
|
+
if (options.preview) {
|
|
15
|
+
const repo = await checkout.repo();
|
|
16
|
+
if (!repo)
|
|
17
|
+
return { kind: "not-in-git" };
|
|
18
|
+
const h = repo.history;
|
|
19
|
+
preview = { h, sides: await previewSides(h, options.preview.base ?? (await defaultBaseBranch(h.repoRoot))) };
|
|
20
|
+
}
|
|
21
|
+
if (bundleOnly) {
|
|
22
|
+
await writeSite(out, { bundle });
|
|
23
|
+
return { kind: "bundle", file: join(out, LATEST_BUNDLE_PATH) };
|
|
24
|
+
}
|
|
25
|
+
if (!existsSync(join(viewerDir, "index.html")))
|
|
26
|
+
return { kind: "viewer-missing", viewerDir };
|
|
27
|
+
await cp(viewerDir, out, { recursive: true });
|
|
28
|
+
// The viewer's exports name the Workspace as `archidocs export` does: by its repo's folder.
|
|
29
|
+
const latest = { bundle, workspace: await checkout.name() };
|
|
30
|
+
if (preview)
|
|
31
|
+
return { kind: "preview", out, ...(await publishPreview(preview.h, out, preview.sides, bundle, latest.workspace)) };
|
|
32
|
+
const repo = await checkout.repo();
|
|
33
|
+
if (repo)
|
|
34
|
+
await publishHistory(repo.history, out, latest, { keep });
|
|
35
|
+
// Outside git, an empty index, so the viewer knows there is no history.
|
|
36
|
+
else
|
|
37
|
+
await writeSite(out, { ...latest, index: { schemaVersion: INDEX_VERSION, revisions: [] } });
|
|
38
|
+
return { kind: "site", out };
|
|
39
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Issue } from "../core/index.ts";
|
|
2
|
+
import type { Checkout } from "../workspace/index.ts";
|
|
3
|
+
export type CheckResult = {
|
|
4
|
+
kind: "checked";
|
|
5
|
+
issues: Issue[];
|
|
6
|
+
};
|
|
7
|
+
/** The Workspace's issues. */
|
|
8
|
+
export declare function check(checkout: Checkout): Promise<CheckResult>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Change } from "../core/index.ts";
|
|
2
|
+
import { type PointFailure } from "../history/index.ts";
|
|
3
|
+
import type { Checkout } from "../workspace/index.ts";
|
|
4
|
+
/** One side of a diff: the point as given and the commit it resolved to (null for the working tree). */
|
|
5
|
+
export interface DiffSide {
|
|
6
|
+
point: string;
|
|
7
|
+
commit: string | null;
|
|
8
|
+
}
|
|
9
|
+
export type DiffResult =
|
|
10
|
+
/** History needs the Workspace in a git repo. */
|
|
11
|
+
{
|
|
12
|
+
kind: "not-in-git";
|
|
13
|
+
}
|
|
14
|
+
/** A point names no commit: an unknown ref, a date before the first Revision, or a prefix of several Revisions' shas. */
|
|
15
|
+
| {
|
|
16
|
+
kind: "unknown-point";
|
|
17
|
+
point: string;
|
|
18
|
+
failure: PointFailure;
|
|
19
|
+
} | {
|
|
20
|
+
kind: "ok";
|
|
21
|
+
from: DiffSide;
|
|
22
|
+
to: DiffSide;
|
|
23
|
+
changes: Change[];
|
|
24
|
+
};
|
|
25
|
+
/** The Changes between two points in history (refs or dates); a missing `to` is the working tree. */
|
|
26
|
+
export declare function diff(checkout: Checkout, points: {
|
|
27
|
+
from: string;
|
|
28
|
+
to?: string;
|
|
29
|
+
}): Promise<DiffResult>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { diff as diffBundles } from "../core/index.js";
|
|
2
|
+
import { bundleAt, resolvePoint } from "../history/index.js";
|
|
3
|
+
/** The Changes between two points in history (refs or dates); a missing `to` is the working tree. */
|
|
4
|
+
export async function diff(checkout, points) {
|
|
5
|
+
const repo = await checkout.repo();
|
|
6
|
+
if (!repo)
|
|
7
|
+
return { kind: "not-in-git" };
|
|
8
|
+
const h = repo.history;
|
|
9
|
+
/** A point's Bundle; with no point, the working tree's. */
|
|
10
|
+
const side = async (point) => {
|
|
11
|
+
if (point === undefined)
|
|
12
|
+
return { ok: true, side: { point: "working tree", commit: null }, bundle: (await checkout.load()).bundle };
|
|
13
|
+
const resolved = await resolvePoint(h, point);
|
|
14
|
+
if (!resolved.ok)
|
|
15
|
+
return { ok: false, result: { kind: "unknown-point", point, failure: resolved } };
|
|
16
|
+
return { ok: true, side: { point, commit: resolved.sha }, bundle: (await bundleAt(h, resolved.sha)).bundle };
|
|
17
|
+
};
|
|
18
|
+
const from = await side(points.from);
|
|
19
|
+
if (!from.ok)
|
|
20
|
+
return from.result;
|
|
21
|
+
const to = await side(points.to);
|
|
22
|
+
if (!to.ok)
|
|
23
|
+
return to.result;
|
|
24
|
+
return { kind: "ok", from: from.side, to: to.side, changes: diffBundles(from.bundle, to.bundle) };
|
|
25
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type Issue } from "../core/index.ts";
|
|
2
|
+
import { type Direction } from "../render/layout.ts";
|
|
3
|
+
import type { Theme } from "../render/tokens.ts";
|
|
4
|
+
import type { Checkout } from "../workspace/index.ts";
|
|
5
|
+
export interface ExportOptions {
|
|
6
|
+
/** The View ids to draw (c1, c2/<system>, project:view-id, …), or every Saved View. */
|
|
7
|
+
views: string[] | "all-saved";
|
|
8
|
+
format: "svg" | "png";
|
|
9
|
+
/** Wins over each View's own direction. */
|
|
10
|
+
direction?: Direction;
|
|
11
|
+
theme: Theme;
|
|
12
|
+
/** Replaces the source line under the title. */
|
|
13
|
+
label?: string;
|
|
14
|
+
/** The folder the pictures go in, absolute; each is named by its View id. */
|
|
15
|
+
out: string;
|
|
16
|
+
/** With one View id: the picture's path, absolute, instead of one named by the id in `out`. */
|
|
17
|
+
file?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ExportedFile {
|
|
20
|
+
view: string;
|
|
21
|
+
/** Absolute. */
|
|
22
|
+
path: string;
|
|
23
|
+
}
|
|
24
|
+
export type ExportResult =
|
|
25
|
+
/** The Workspace has errors; nothing was written. */
|
|
26
|
+
{
|
|
27
|
+
kind: "errors";
|
|
28
|
+
issues: Issue[];
|
|
29
|
+
}
|
|
30
|
+
/** No View has this id; nothing was written. */
|
|
31
|
+
| {
|
|
32
|
+
kind: "unknown-view";
|
|
33
|
+
id: string;
|
|
34
|
+
}
|
|
35
|
+
/** The pictures written, in order. */
|
|
36
|
+
| {
|
|
37
|
+
kind: "written";
|
|
38
|
+
files: ExportedFile[];
|
|
39
|
+
};
|
|
40
|
+
/** Lays out and draws Views to SVG or PNG files. */
|
|
41
|
+
export declare function exportViews(checkout: Checkout, options: ExportOptions): Promise<ExportResult>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { resolveView } from "../core/index.js";
|
|
4
|
+
// The render files themselves, not render/index.ts, which re-exports png.ts and so would load resvg for every caller.
|
|
5
|
+
import { layoutView } from "../render/layout.js";
|
|
6
|
+
import { renderSequenceSvg } from "../render/sequence-svg.js";
|
|
7
|
+
import { renderSvg } from "../render/svg.js";
|
|
8
|
+
/** Lays out and draws Views to SVG or PNG files. */
|
|
9
|
+
export async function exportViews(checkout, options) {
|
|
10
|
+
const { format, direction, theme, label } = options;
|
|
11
|
+
if (options.file !== undefined && (options.views === "all-saved" || options.views.length !== 1))
|
|
12
|
+
throw new Error("`file` names the picture of one View.");
|
|
13
|
+
const { bundle, issues } = await checkout.load();
|
|
14
|
+
if (issues.some((i) => i.severity === "error"))
|
|
15
|
+
return { kind: "errors", issues };
|
|
16
|
+
const views = [];
|
|
17
|
+
if (options.views === "all-saved") {
|
|
18
|
+
for (const saved of bundle.views) {
|
|
19
|
+
const view = resolveView(bundle, saved.id);
|
|
20
|
+
if (view)
|
|
21
|
+
views.push([saved.id, view]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
for (const id of options.views) {
|
|
26
|
+
const view = resolveView(bundle, id);
|
|
27
|
+
if (!view)
|
|
28
|
+
return { kind: "unknown-view", id };
|
|
29
|
+
views.push([id, view]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const source = { workspace: await checkout.name(), commit: bundle.commit, date: bundle.builtAt };
|
|
33
|
+
const toPng = format === "png" ? (await import("../render/node.js")).renderPngInNode : undefined;
|
|
34
|
+
if (options.file === undefined)
|
|
35
|
+
await mkdir(options.out, { recursive: true });
|
|
36
|
+
const files = [];
|
|
37
|
+
for (const [id, view] of views) {
|
|
38
|
+
const path = options.file ?? join(options.out, `${id.replace(/[/:]/g, "-")}.${format}`);
|
|
39
|
+
// A Dynamic View draws as a sequence chart, any other as a diagram.
|
|
40
|
+
const svg = view.kind === "dynamic"
|
|
41
|
+
? renderSequenceSvg({ bundle, view, source, theme, label })
|
|
42
|
+
: renderSvg({ bundle, view, layout: await layoutView(view, direction === undefined ? {} : { direction }), source, theme, label });
|
|
43
|
+
await writeFile(path, toPng ? await toPng(svg) : svg);
|
|
44
|
+
files.push({ view: id, path });
|
|
45
|
+
}
|
|
46
|
+
return { kind: "written", files };
|
|
47
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Checkout } from "../workspace/index.ts";
|
|
2
|
+
export interface BuildHistoryOptions {
|
|
3
|
+
/** Only Revisions at or after this ref or date. */
|
|
4
|
+
since?: string;
|
|
5
|
+
}
|
|
6
|
+
export type BuildHistoryResult =
|
|
7
|
+
/** History needs the Workspace in a git repo. */
|
|
8
|
+
{
|
|
9
|
+
kind: "not-in-git";
|
|
10
|
+
}
|
|
11
|
+
/** How many Revisions are in scope, and how many of those this run built. */
|
|
12
|
+
| {
|
|
13
|
+
kind: "ok";
|
|
14
|
+
revisions: number;
|
|
15
|
+
built: number;
|
|
16
|
+
};
|
|
17
|
+
/** Builds and caches the Bundle of every Revision not yet built. */
|
|
18
|
+
export declare function buildHistory(checkout: Checkout, options?: BuildHistoryOptions): Promise<BuildHistoryResult>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { buildHistory as buildRevisions } from "../history/index.js";
|
|
2
|
+
/** Builds and caches the Bundle of every Revision not yet built. */
|
|
3
|
+
export async function buildHistory(checkout, options = {}) {
|
|
4
|
+
const repo = await checkout.repo();
|
|
5
|
+
if (!repo)
|
|
6
|
+
return { kind: "not-in-git" };
|
|
7
|
+
const { revisions, built } = await buildRevisions(repo.history, options.since === undefined ? {} : { since: options.since });
|
|
8
|
+
return { kind: "ok", revisions, built };
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's commands as functions over a Checkout: each takes options and
|
|
3
|
+
* returns a tagged result, for `run` to format or for the docs site to use.
|
|
4
|
+
* Node-only. None writes to a stream or reads `process`; an expected outcome
|
|
5
|
+
* is a result, and only unexpected failures (git, the disk) throw.
|
|
6
|
+
*/
|
|
7
|
+
export { check, type CheckResult } from "./check.ts";
|
|
8
|
+
export { build, type BuildOptions, type BuildResult } from "./build.ts";
|
|
9
|
+
export { exportViews, type ExportOptions, type ExportResult, type ExportedFile } from "./export.ts";
|
|
10
|
+
export { diff, type DiffResult, type DiffSide } from "./diff.ts";
|
|
11
|
+
export { buildHistory, type BuildHistoryOptions, type BuildHistoryResult } from "./history.ts";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's commands as functions over a Checkout: each takes options and
|
|
3
|
+
* returns a tagged result, for `run` to format or for the docs site to use.
|
|
4
|
+
* Node-only. None writes to a stream or reads `process`; an expected outcome
|
|
5
|
+
* is a result, and only unexpected failures (git, the disk) throw.
|
|
6
|
+
*/
|
|
7
|
+
export { check } from "./check.js";
|
|
8
|
+
export { build } from "./build.js";
|
|
9
|
+
export { exportViews } from "./export.js";
|
|
10
|
+
export { diff } from "./diff.js";
|
|
11
|
+
export { buildHistory } from "./history.js";
|
package/dist/core/compare.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Bundle } from "../schema/bundle.ts";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type CompareMark = "added" | "removed" | "changed" | "unchanged";
|
|
2
|
+
/** An item as text, leaving out where it was written. */
|
|
3
|
+
export declare const withoutSource: (item: object) => string;
|
|
5
4
|
/**
|
|
6
5
|
* One Bundle holding everything either side holds, the later side's version
|
|
7
6
|
* where both do, so a View drawn from it keeps removed things in place.
|
|
@@ -9,13 +8,3 @@ export type CompareMark = "added" | "removed" | "changed" | "unchanged";
|
|
|
9
8
|
* at both sides; each lands on the same edge.
|
|
10
9
|
*/
|
|
11
10
|
export declare function unionBundle(before: Bundle, after: Bundle): Bundle;
|
|
12
|
-
/**
|
|
13
|
-
* A View for Compare: laid out over the union of both sides, with every node
|
|
14
|
-
* and edge marked. A node or edge only the later side's View shows is
|
|
15
|
-
* added, one only the earlier side's shows is removed. One both show is
|
|
16
|
-
* changed when its Element changed, or for a collapsed box when anything
|
|
17
|
-
* inside it was added, removed or changed; an edge when its Relationships
|
|
18
|
-
* did. A View that exists at one side only is drawn from that side.
|
|
19
|
-
* Undefined when neither side has the View.
|
|
20
|
-
*/
|
|
21
|
-
export declare function compareView(before: Bundle, after: Bundle, id: string, options?: Pick<ResolveOptions, "expand">): ResolvedView | undefined;
|
package/dist/core/compare.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const withoutSource = (item) => JSON.stringify({ ...item, source: undefined });
|
|
1
|
+
/** An item as text, leaving out where it was written. */
|
|
2
|
+
export const withoutSource = (item) => JSON.stringify({ ...item, source: undefined });
|
|
4
3
|
/** Items of both sides, each once: the later side's where both have it. */
|
|
5
4
|
function union(before, after, key) {
|
|
6
5
|
const keys = new Set(after.map(key));
|
|
@@ -28,35 +27,3 @@ export function unionBundle(before, after) {
|
|
|
28
27
|
adrs: union(before.adrs, after.adrs, byId),
|
|
29
28
|
};
|
|
30
29
|
}
|
|
31
|
-
/**
|
|
32
|
-
* A View for Compare: laid out over the union of both sides, with every node
|
|
33
|
-
* and edge marked. A node or edge only the later side's View shows is
|
|
34
|
-
* added, one only the earlier side's shows is removed. One both show is
|
|
35
|
-
* changed when its Element changed, or for a collapsed box when anything
|
|
36
|
-
* inside it was added, removed or changed; an edge when its Relationships
|
|
37
|
-
* did. A View that exists at one side only is drawn from that side.
|
|
38
|
-
* Undefined when neither side has the View.
|
|
39
|
-
*/
|
|
40
|
-
export function compareView(before, after, id, options = {}) {
|
|
41
|
-
const view = resolveView(unionBundle(before, after), id, options);
|
|
42
|
-
if (!view)
|
|
43
|
-
return undefined;
|
|
44
|
-
const [b, a] = [resolveView(before, id, options), resolveView(after, id, options)];
|
|
45
|
-
const changed = new Set(diff(before, after).filter((c) => c.kind === "element").map((c) => c.id));
|
|
46
|
-
const model = new ModelIndex(unionBundle(before, after));
|
|
47
|
-
const holdsChange = (nodeId) => [...changed].some((c) => c !== nodeId && model.ancestry(c).includes(nodeId));
|
|
48
|
-
const sides = (list, key) => [b, a].map((v) => new Map((v ? list(v) : []).map((x) => [key(x), x])));
|
|
49
|
-
const [bNodes, aNodes] = sides((v) => v.nodes, (n) => n.id);
|
|
50
|
-
const edgeKey = (e) => `${e.from}\0${e.to}`;
|
|
51
|
-
const [bEdges, aEdges] = sides((v) => v.edges, edgeKey);
|
|
52
|
-
const mark = (inBefore, inAfter, isChanged) => inAfter && !inBefore ? "added" : inBefore && !inAfter ? "removed" : isChanged() ? "changed" : "unchanged";
|
|
53
|
-
for (const node of view.nodes) {
|
|
54
|
-
node.change = mark(bNodes.has(node.id), aNodes.has(node.id), () => changed.has(node.id) || (node.collapsed && holdsChange(node.id)));
|
|
55
|
-
}
|
|
56
|
-
const relationships = (e) => (e?.relationships.map(withoutSource).sort() ?? []).join("\n");
|
|
57
|
-
for (const edge of view.edges) {
|
|
58
|
-
const key = edgeKey(edge);
|
|
59
|
-
edge.change = mark(bEdges.has(key), aEdges.has(key), () => relationships(bEdges.get(key)) !== relationships(aEdges.get(key)));
|
|
60
|
-
}
|
|
61
|
-
return view;
|
|
62
|
-
}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { load, findWorkspaceRoot,
|
|
1
|
+
export { load, findWorkspaceRoot, type LoadOptions, type LoadResult } from "./load.ts";
|
|
2
2
|
export { nodeFileSystem, type FileSystem, type WritableFileSystem, type DirEntry } from "./fs.ts";
|
|
3
3
|
export { rules, removed, ruleDocsUrl, withDocs, RULE_DOCS_BASE_URL, type RuleDefinition, type RemovedRule } from "./rules.ts";
|
|
4
4
|
export type { Issue, Severity } from "./model.ts";
|
|
@@ -7,14 +7,11 @@ export { ruleCatalogue } from "./catalogue.ts";
|
|
|
7
7
|
export { deriveEdges, levelOf, type DerivedEdge, type Level } from "./query.ts";
|
|
8
8
|
export { getDeployments, type DeploymentDetail, type TargetStep } from "./deployments.ts";
|
|
9
9
|
export { search, type SearchMatch, type SearchOptions, type MatchRank } from "./search.ts";
|
|
10
|
-
export {
|
|
11
|
-
export { resolveSaved, type SavedResolution, type BadExpand, type UnresolvedPath } from "./saved-views.ts";
|
|
10
|
+
export { resolveView, listViews, pickedView, compareView, saveAsView, stepViews, dynamicViewsUsing, parseViewId, formatViewId, ownViewId, describeLens, type AnyView, type ViewRef, type ViewSummary, type LensChoice, type ResolveOptions, type ResolvedView, type ViewKind, type ListedKind, type ViewNode, type ViewEdge, type NodeMark, type ImpactSide, type ViewDirection, type CompareMark, type SavedResolution, type BadExpand, type UnresolvedPath, type DynamicResolution, type DynamicProblem, type ResolvedDynamicView, type ResolvedStep, type StepKind, type Screen, type SavedScreen, type SavedViewDefinition, } from "./views/index.ts";
|
|
12
11
|
export { findPaths, type PathsResult, type Path, type Hop, type DirectEdge } from "./paths.ts";
|
|
13
12
|
export { getImpact, type ImpactResult, type ImpactRing, type ImpactedElement, type Direction } from "./impact.ts";
|
|
14
13
|
export { listOwned, type OwnedResult, type OwnedGroup, type OwnedItem, type OwnedKind } from "./ownership.ts";
|
|
15
14
|
export { listAdrs, adrsFor, type ListAdrsOptions, type ListedAdr } from "./adrs.ts";
|
|
16
|
-
export { resolveDynamic, resolveDynamicView, takesPart, stepViews, dynamicViewsUsing, type DynamicResolution, type DynamicProblem, type ResolvedDynamicView, type ResolvedStep, type StepKind } from "./dynamic-views.ts";
|
|
17
15
|
export { diff, countChanges, changedIds, changeKinds, type Change, type ChangeKind, type ChangeType, type ChangeItem, type ChangeCounts } from "./diff.ts";
|
|
18
|
-
export {
|
|
19
|
-
export { compareView, unionBundle, type CompareMark } from "./compare.ts";
|
|
16
|
+
export { unionBundle } from "./compare.ts";
|
|
20
17
|
export { resolveScope, scopeMatcher, filterChanges, type HistoryScope, type ScopeResolution } from "./history-scope.ts";
|
package/dist/core/index.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
export { load, findWorkspaceRoot
|
|
1
|
+
export { load, findWorkspaceRoot } from "./load.js";
|
|
2
2
|
export { nodeFileSystem } from "./fs.js";
|
|
3
3
|
export { rules, removed, ruleDocsUrl, withDocs, RULE_DOCS_BASE_URL } from "./rules.js";
|
|
4
4
|
export { ruleCatalogue } from "./catalogue.js";
|
|
5
5
|
export { deriveEdges, levelOf } from "./query.js";
|
|
6
6
|
export { getDeployments } from "./deployments.js";
|
|
7
7
|
export { search } from "./search.js";
|
|
8
|
-
export {
|
|
9
|
-
export { resolveSaved } from "./saved-views.js";
|
|
8
|
+
export { resolveView, listViews, pickedView, compareView, saveAsView, stepViews, dynamicViewsUsing, parseViewId, formatViewId, ownViewId, describeLens, } from "./views/index.js";
|
|
10
9
|
export { findPaths } from "./paths.js";
|
|
11
10
|
export { getImpact } from "./impact.js";
|
|
12
11
|
export { listOwned } from "./ownership.js";
|
|
13
12
|
export { listAdrs, adrsFor } from "./adrs.js";
|
|
14
|
-
export { resolveDynamic, resolveDynamicView, takesPart, stepViews, dynamicViewsUsing } from "./dynamic-views.js";
|
|
15
13
|
export { diff, countChanges, changedIds, changeKinds } from "./diff.js";
|
|
16
|
-
export {
|
|
17
|
-
export { compareView, unionBundle } from "./compare.js";
|
|
14
|
+
export { unionBundle } from "./compare.js";
|
|
18
15
|
export { resolveScope, scopeMatcher, filterChanges } from "./history-scope.js";
|
package/dist/core/load.d.ts
CHANGED
|
@@ -28,5 +28,3 @@ export declare function loadDetailed(options: LoadOptions): Promise<LoadResult &
|
|
|
28
28
|
}>;
|
|
29
29
|
/** Walks up from `start` to the folder holding `workspace.yaml`, also looking in each folder's `archidocs/`. */
|
|
30
30
|
export declare function findWorkspaceRoot(fs: FileSystem, start: string): Promise<string | undefined>;
|
|
31
|
-
/** The Bundle as written to `workspace.bundle.json`: stable key order, two-space indent. */
|
|
32
|
-
export declare function serializeBundle(bundle: Bundle): string;
|
package/dist/core/load.js
CHANGED
|
@@ -7,6 +7,7 @@ import { checkSchema } from "./schema-check.js";
|
|
|
7
7
|
import { bundleAdrs } from "./adrs.js";
|
|
8
8
|
import { PROJECT_TEMPLATE, readAdr } from "./adr.js";
|
|
9
9
|
import { parseYaml } from "./yaml.js";
|
|
10
|
+
import { isSkippedName, isWorkspaceFile } from "./workspace-files.js";
|
|
10
11
|
const WORKSPACE_FILE = "workspace.yaml";
|
|
11
12
|
const PROJECT_FILE = "project.yaml";
|
|
12
13
|
const ADR_DIR = "adr";
|
|
@@ -117,14 +118,16 @@ async function walk(fs, root) {
|
|
|
117
118
|
const dirs = [root];
|
|
118
119
|
for (let i = 0; i < dirs.length; i++) {
|
|
119
120
|
for (const entry of await fs.readDir(dirs[i])) {
|
|
120
|
-
if (
|
|
121
|
+
if (isSkippedName(entry.name))
|
|
121
122
|
continue;
|
|
122
123
|
const path = join(dirs[i], entry.name);
|
|
123
124
|
if (entry.isDirectory)
|
|
124
125
|
dirs.push(path);
|
|
126
|
+
else if (!isWorkspaceFile(entry.name))
|
|
127
|
+
continue;
|
|
125
128
|
else if (entry.name.endsWith(".yaml"))
|
|
126
129
|
files.push(path);
|
|
127
|
-
else
|
|
130
|
+
else
|
|
128
131
|
markdown.push(path);
|
|
129
132
|
}
|
|
130
133
|
}
|
|
@@ -457,9 +460,5 @@ function toBundle(ws, options) {
|
|
|
457
460
|
// Parsing fixes key order to the schema's.
|
|
458
461
|
return Bundle.parse(bundle);
|
|
459
462
|
}
|
|
460
|
-
/** The Bundle as written to `workspace.bundle.json`: stable key order, two-space indent. */
|
|
461
|
-
export function serializeBundle(bundle) {
|
|
462
|
-
return JSON.stringify(Bundle.parse(bundle), null, 2) + "\n";
|
|
463
|
-
}
|
|
464
463
|
const asRecord = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
465
464
|
const cmp = (a, b) => (a < b ? -1 : a > b ? 1 : 0);
|
package/dist/core/rules.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Bundle } from "../schema/bundle.ts";
|
|
2
2
|
import type { Files } from "./files.ts";
|
|
3
3
|
import type { IssueDraft, LoadedWorkspace, Severity } from "./model.ts";
|
|
4
|
+
/** The part of the Model a rule is about, in the order the docs list them. Every rule is in exactly one. */
|
|
5
|
+
export declare const ruleAreas: readonly ["workspace", "elements", "relationships", "deployments", "views", "decisions"];
|
|
6
|
+
export type RuleArea = (typeof ruleAreas)[number];
|
|
4
7
|
/**
|
|
5
8
|
* A check rule. Its examples are small Workspaces (paths relative to the
|
|
6
9
|
* Workspace root): `failing` triggers the rule, `passing` is the same
|
|
@@ -9,8 +12,15 @@ import type { IssueDraft, LoadedWorkspace, Severity } from "./model.ts";
|
|
|
9
12
|
export interface RuleDefinition {
|
|
10
13
|
id: string;
|
|
11
14
|
severity: Severity;
|
|
15
|
+
area: RuleArea;
|
|
16
|
+
/** The release that first shipped the rule, such as `"1.0.0"`. */
|
|
17
|
+
since: `${number}.${number}.${number}`;
|
|
12
18
|
summary: string;
|
|
19
|
+
/** What goes wrong for a reader of the Model without the rule, in one or two sentences. */
|
|
20
|
+
why: string;
|
|
13
21
|
fix: string;
|
|
22
|
+
/** Other rules worth reading with this one, by id. */
|
|
23
|
+
related?: readonly string[];
|
|
14
24
|
example: {
|
|
15
25
|
failing: Files;
|
|
16
26
|
passing: Files;
|