contentbit 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/bin.js +4802 -501
- package/dist/commands/agents.d.ts +6 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +4 -13
- package/dist/commands/brief.d.ts +12 -0
- package/dist/commands/brief.d.ts.map +1 -0
- package/dist/commands/brief.js +52 -0
- package/dist/commands/docs.d.ts +6 -1
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +5 -14
- package/dist/commands/doctor.d.ts +13 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +58 -34
- package/dist/commands/init.d.ts +12 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +70 -31
- package/dist/commands/instructions.d.ts +8 -1
- package/dist/commands/instructions.d.ts.map +1 -1
- package/dist/commands/instructions.js +7 -18
- package/dist/commands/links.d.ts +7 -1
- package/dist/commands/links.d.ts.map +1 -1
- package/dist/commands/links.js +11 -28
- package/dist/commands/render.d.ts +8 -1
- package/dist/commands/render.d.ts.map +1 -1
- package/dist/commands/render.js +8 -20
- package/dist/commands/stats.d.ts +7 -1
- package/dist/commands/stats.d.ts.map +1 -1
- package/dist/commands/stats.js +7 -17
- package/dist/commands/studio.d.ts +13 -1
- package/dist/commands/studio.d.ts.map +1 -1
- package/dist/commands/studio.js +17 -30
- package/dist/commands/validate.d.ts +8 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +6 -21
- package/dist/content-project.d.ts +2 -22
- package/dist/content-project.d.ts.map +1 -1
- package/dist/content-project.js +13 -22
- package/dist/link-options.d.ts +5 -0
- package/dist/link-options.d.ts.map +1 -1
- package/dist/link-options.js +5 -5
- package/dist/load-registry.d.ts +1 -6
- package/dist/load-registry.d.ts.map +1 -1
- package/dist/load-registry.js +1 -26
- package/dist/run.d.ts +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4800 -499
- package/dist/seo-config.d.ts +12 -0
- package/dist/seo-config.d.ts.map +1 -0
- package/dist/seo-config.js +21 -0
- package/package.json +6 -4
package/dist/commands/links.js
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
import { aliasReplacementsForPage, buildLinkIndex, extractFrontmatter, serializeLinkIndex, validateLinks, } from '@contentbit/core';
|
|
1
|
+
import { aliasReplacementsForPage, buildLinkIndex, extractFrontmatter, linkGraphSummary, serializeLinkIndex, validateLinks, } from '@contentbit/core';
|
|
2
2
|
import { mkdir, readFile } from 'node:fs/promises';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
|
-
import { parseArgs } from 'node:util';
|
|
5
4
|
import { formatDiagnosticForCli, formatRows, section } from '../cli-format.js';
|
|
6
5
|
import { resolveContentFiles } from '../content-project.js';
|
|
7
6
|
import { linkResolverOptions } from '../link-options.js';
|
|
8
7
|
import { collectLinkInputs } from '../links-io.js';
|
|
9
|
-
export async function linksCommand(
|
|
10
|
-
const
|
|
11
|
-
args,
|
|
12
|
-
allowPositionals: true,
|
|
13
|
-
options: {
|
|
14
|
-
out: { type: 'string' },
|
|
15
|
-
fix: { type: 'boolean', default: false },
|
|
16
|
-
'link-resolve': { type: 'string' },
|
|
17
|
-
'locale-field': { type: 'string' },
|
|
18
|
-
'slug-field': { type: 'string' },
|
|
19
|
-
'key-field': { type: 'string' },
|
|
20
|
-
'default-locale': { type: 'string' },
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
const files = await resolveContentFiles(positionals, 'links');
|
|
8
|
+
export async function linksCommand(input, io) {
|
|
9
|
+
const files = await resolveContentFiles(input.globs, 'links');
|
|
24
10
|
const inputs = await collectLinkInputs(files);
|
|
25
|
-
const linkOptions = linkResolverOptions(
|
|
11
|
+
const linkOptions = linkResolverOptions(input);
|
|
26
12
|
let errors = 0;
|
|
27
13
|
let warnings = 0;
|
|
28
14
|
for (const { file, diagnostic } of validateLinks(inputs, linkOptions)) {
|
|
@@ -33,10 +19,10 @@ export async function linksCommand(args, io) {
|
|
|
33
19
|
warnings++;
|
|
34
20
|
}
|
|
35
21
|
const index = buildLinkIndex(inputs, linkOptions);
|
|
36
|
-
if (
|
|
22
|
+
if (input.fix && errors > 0) {
|
|
37
23
|
io.stderr('links: --fix skipped because link errors must be resolved first.');
|
|
38
24
|
}
|
|
39
|
-
else if (
|
|
25
|
+
else if (input.fix && index.aliases.size > 0) {
|
|
40
26
|
for (const file of files) {
|
|
41
27
|
const source = await readFile(file, 'utf8');
|
|
42
28
|
const fm = extractFrontmatter(source);
|
|
@@ -72,21 +58,18 @@ export async function linksCommand(args, io) {
|
|
|
72
58
|
}
|
|
73
59
|
}
|
|
74
60
|
}
|
|
75
|
-
const outPath =
|
|
61
|
+
const outPath = input.out ?? join(process.cwd(), '.contentbit', 'link-index.json');
|
|
76
62
|
// The default target lives in a .contentbit/ dir that may not exist yet, and
|
|
77
63
|
// the shared Io.writeFile is a thin fs wrapper that won't create it.
|
|
78
64
|
await mkdir(dirname(outPath), { recursive: true });
|
|
79
65
|
await io.writeFile(outPath, JSON.stringify(serializeLinkIndex(index), null, 2) + '\n');
|
|
80
|
-
|
|
81
|
-
for (const p of index.pages.values())
|
|
82
|
-
edges += p.linksTo.length;
|
|
83
|
-
const orphans = [...index.pages.values()].filter((p) => p.linkedFrom.length === 0).length;
|
|
66
|
+
const graph = linkGraphSummary(index);
|
|
84
67
|
io.stdout([
|
|
85
68
|
section('Link Index'),
|
|
86
69
|
...formatRows([
|
|
87
|
-
{ label: 'Pages', value:
|
|
88
|
-
{ label: 'Links', value:
|
|
89
|
-
{ label: 'Orphans', value: orphans, tone: orphans > 0 ? 'warning' : 'success' },
|
|
70
|
+
{ label: 'Pages', value: graph.pages },
|
|
71
|
+
{ label: 'Links', value: graph.links },
|
|
72
|
+
{ label: 'Orphans', value: graph.orphans, tone: graph.orphans > 0 ? 'warning' : 'success' },
|
|
90
73
|
{ label: 'Errors', value: errors, tone: errors > 0 ? 'error' : 'success' },
|
|
91
74
|
{ label: 'Warnings', value: warnings, tone: warnings > 0 ? 'warning' : 'success' },
|
|
92
75
|
]),
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { Io } from '../run.js';
|
|
2
|
-
export
|
|
2
|
+
export interface RenderCommandInput {
|
|
3
|
+
file?: string;
|
|
4
|
+
target?: string;
|
|
5
|
+
registry?: string;
|
|
6
|
+
noGenericBlocks?: boolean;
|
|
7
|
+
out?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function renderCommand(input: RenderCommandInput, io: Io): Promise<number>;
|
|
3
10
|
//# sourceMappingURL=render.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/commands/render.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/commands/render.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAKnC,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBtF"}
|
package/dist/commands/render.js
CHANGED
|
@@ -1,40 +1,28 @@
|
|
|
1
1
|
import { genericMarkdownRenderers } from '@contentbit/blocks';
|
|
2
2
|
import { parseDocument, renderToMarkdown, stripFrontmatter, validateDocument, } from '@contentbit/core';
|
|
3
3
|
import { readFile } from 'node:fs/promises';
|
|
4
|
-
import { parseArgs } from 'node:util';
|
|
5
4
|
import { formatDiagnosticForCli } from '../cli-format.js';
|
|
6
5
|
import { loadRegistry } from '../load-registry.js';
|
|
7
|
-
export async function renderCommand(
|
|
8
|
-
|
|
9
|
-
args,
|
|
10
|
-
allowPositionals: true,
|
|
11
|
-
options: {
|
|
12
|
-
target: { type: 'string', default: 'markdown' },
|
|
13
|
-
registry: { type: 'string' },
|
|
14
|
-
'no-generic-blocks': { type: 'boolean', default: false },
|
|
15
|
-
out: { type: 'string' },
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
const file = positionals[0];
|
|
19
|
-
if (!file || values.target !== 'markdown') {
|
|
6
|
+
export async function renderCommand(input, io) {
|
|
7
|
+
if (!input.file || (input.target ?? 'markdown') !== 'markdown') {
|
|
20
8
|
io.stderr('render: usage: render <file> [--target markdown] ' +
|
|
21
9
|
'[--registry <module.ts>] [--no-generic-blocks] [--out <file>]');
|
|
22
10
|
return 2;
|
|
23
11
|
}
|
|
24
|
-
const includeGenericBlocks = !
|
|
25
|
-
const registry = await loadRegistry(
|
|
26
|
-
const source = await readFile(file, 'utf8');
|
|
12
|
+
const includeGenericBlocks = !input.noGenericBlocks;
|
|
13
|
+
const registry = await loadRegistry(input.registry, { includeGenericBlocks });
|
|
14
|
+
const source = await readFile(input.file, 'utf8');
|
|
27
15
|
const result = validateDocument(parseDocument(stripFrontmatter(source)), registry);
|
|
28
16
|
if (!result.ok) {
|
|
29
17
|
for (const d of result.diagnostics)
|
|
30
|
-
io.stderr(formatDiagnosticForCli(d, file));
|
|
18
|
+
io.stderr(formatDiagnosticForCli(d, input.file));
|
|
31
19
|
return 1;
|
|
32
20
|
}
|
|
33
21
|
const output = renderToMarkdown(result.document, {
|
|
34
22
|
renderers: includeGenericBlocks ? genericMarkdownRenderers : genericMarkdownFallbackRenderers,
|
|
35
23
|
});
|
|
36
|
-
if (
|
|
37
|
-
await io.writeFile(
|
|
24
|
+
if (input.out)
|
|
25
|
+
await io.writeFile(input.out, output);
|
|
38
26
|
else
|
|
39
27
|
io.stdout(output);
|
|
40
28
|
return 0;
|
package/dist/commands/stats.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Io } from '../run.js';
|
|
2
|
-
export
|
|
2
|
+
export interface StatsCommandInput {
|
|
3
|
+
globs: string[];
|
|
4
|
+
registry?: string;
|
|
5
|
+
noGenericBlocks?: boolean;
|
|
6
|
+
noValidate?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function statsCommand(input: StatsCommandInput, io: Io): Promise<number>;
|
|
3
9
|
//# sourceMappingURL=stats.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/commands/stats.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/commands/stats.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAOnC,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAQpF"}
|
package/dist/commands/stats.js
CHANGED
|
@@ -1,32 +1,22 @@
|
|
|
1
1
|
import { analyzeDocument } from '@contentbit/core';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { parseArgs } from 'node:util';
|
|
4
3
|
import { loadContentProject, resolveContentFiles } from '../content-project.js';
|
|
5
|
-
export async function statsCommand(
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
options: {
|
|
10
|
-
registry: { type: 'string' },
|
|
11
|
-
'no-generic-blocks': { type: 'boolean', default: false },
|
|
12
|
-
'no-validate': { type: 'boolean', default: false },
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
const all = values['no-validate']
|
|
16
|
-
? await statsOnly(positionals)
|
|
17
|
-
: await statsWithValidation(values, positionals);
|
|
4
|
+
export async function statsCommand(input, io) {
|
|
5
|
+
const all = input.noValidate
|
|
6
|
+
? await statsOnly(input.globs)
|
|
7
|
+
: await statsWithValidation(input, input.globs);
|
|
18
8
|
// A single file keeps the flat object shape; multiple files emit an array.
|
|
19
9
|
io.stdout(JSON.stringify(all.length === 1 ? all[0] : all, null, 2));
|
|
20
10
|
return 0;
|
|
21
11
|
}
|
|
22
12
|
/** Default path: cross the loaded-content-project seam so stats and the other
|
|
23
13
|
* read-commands share one validation path. */
|
|
24
|
-
async function statsWithValidation(
|
|
14
|
+
async function statsWithValidation(input, positionals) {
|
|
25
15
|
const { scan } = await loadContentProject({
|
|
26
16
|
cmd: 'stats',
|
|
27
17
|
positionals,
|
|
28
|
-
registry:
|
|
29
|
-
includeGenericBlocks: !
|
|
18
|
+
registry: input.registry,
|
|
19
|
+
includeGenericBlocks: !input.noGenericBlocks,
|
|
30
20
|
linkOptions: {},
|
|
31
21
|
});
|
|
32
22
|
return scan.files.map((file) => {
|
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import type { Io } from '../run.js';
|
|
2
|
-
|
|
2
|
+
import { type LinkOptionValues } from '../link-options.js';
|
|
3
|
+
export interface StudioCommandInput extends LinkOptionValues {
|
|
4
|
+
globs: string[];
|
|
5
|
+
registry?: string;
|
|
6
|
+
port?: string;
|
|
7
|
+
host?: string;
|
|
8
|
+
noOpen?: boolean;
|
|
9
|
+
noGenericBlocks?: boolean;
|
|
10
|
+
minSectionWords?: string;
|
|
11
|
+
seoConfig?: string;
|
|
12
|
+
noSeo?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function studioCommand(input: StudioCommandInput, io: Io): Promise<number>;
|
|
3
15
|
//# sourceMappingURL=studio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio.d.ts","sourceRoot":"","sources":["../../src/commands/studio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"studio.d.ts","sourceRoot":"","sources":["../../src/commands/studio.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAG/E,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAqDtF"}
|
package/dist/commands/studio.js
CHANGED
|
@@ -1,49 +1,36 @@
|
|
|
1
|
-
import { parseArgs } from 'node:util';
|
|
2
1
|
import { formatRows, section } from '../cli-format.js';
|
|
3
2
|
import { resolveContentFiles } from '../content-project.js';
|
|
4
3
|
import { linkResolverOptions } from '../link-options.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
allowPositionals: true,
|
|
9
|
-
options: {
|
|
10
|
-
registry: { type: 'string' },
|
|
11
|
-
port: { type: 'string' },
|
|
12
|
-
host: { type: 'string' },
|
|
13
|
-
'no-open': { type: 'boolean', default: false },
|
|
14
|
-
'no-generic-blocks': { type: 'boolean', default: false },
|
|
15
|
-
'min-section-words': { type: 'string' },
|
|
16
|
-
'link-resolve': { type: 'string' },
|
|
17
|
-
'locale-field': { type: 'string' },
|
|
18
|
-
'slug-field': { type: 'string' },
|
|
19
|
-
'key-field': { type: 'string' },
|
|
20
|
-
'default-locale': { type: 'string' },
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
const port = parsePort(values.port);
|
|
4
|
+
import { loadSeoConfig } from '../seo-config.js';
|
|
5
|
+
export async function studioCommand(input, io) {
|
|
6
|
+
const port = parsePort(input.port);
|
|
24
7
|
if (port === null) {
|
|
25
8
|
io.stderr('studio: --port must be an integer between 0 and 65535.');
|
|
26
9
|
return 2;
|
|
27
10
|
}
|
|
28
|
-
const minSectionWords = parseMinSectionWords(
|
|
11
|
+
const minSectionWords = parseMinSectionWords(input.minSectionWords);
|
|
29
12
|
if (minSectionWords === null) {
|
|
30
13
|
io.stderr('studio: --min-section-words must be a non-negative integer.');
|
|
31
14
|
return 2;
|
|
32
15
|
}
|
|
33
16
|
// Guard empty/no-match the same way the read-commands do; startStudio does its
|
|
34
17
|
// own globbing from `positionals`, so we only need the shared check here.
|
|
35
|
-
await resolveContentFiles(
|
|
18
|
+
await resolveContentFiles(input.globs, 'studio');
|
|
19
|
+
const seoConfig = await loadSeoConfig({ seoConfig: input.seoConfig, noSeo: input.noSeo });
|
|
36
20
|
const { startStudio } = (await import('@contentbit/studio'));
|
|
37
|
-
const
|
|
38
|
-
globs:
|
|
39
|
-
registryPath:
|
|
40
|
-
includeGenericBlocks: !
|
|
41
|
-
host:
|
|
21
|
+
const studioOptions = {
|
|
22
|
+
globs: input.globs,
|
|
23
|
+
registryPath: input.registry,
|
|
24
|
+
includeGenericBlocks: !input.noGenericBlocks,
|
|
25
|
+
host: input.host,
|
|
42
26
|
...(port !== undefined ? { port } : {}),
|
|
43
|
-
open: !
|
|
44
|
-
linkOptions: linkResolverOptions(
|
|
27
|
+
open: !input.noOpen,
|
|
28
|
+
linkOptions: linkResolverOptions(input),
|
|
45
29
|
minSectionWords,
|
|
46
|
-
|
|
30
|
+
seoConfig: seoConfig.config,
|
|
31
|
+
seoConfigPath: seoConfig.path,
|
|
32
|
+
};
|
|
33
|
+
const server = await startStudio(studioOptions);
|
|
47
34
|
io.stdout([
|
|
48
35
|
section('contentbit studio'),
|
|
49
36
|
...formatRows([
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import type { Io } from '../run.js';
|
|
2
|
-
|
|
2
|
+
import { type LinkOptionValues } from '../link-options.js';
|
|
3
|
+
export interface ValidateCommandInput extends LinkOptionValues {
|
|
4
|
+
globs: string[];
|
|
5
|
+
registry?: string;
|
|
6
|
+
noGenericBlocks?: boolean;
|
|
7
|
+
strictWarnings?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function validateCommand(input: ValidateCommandInput, io: Io): Promise<number>;
|
|
3
10
|
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/commands/validate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE/E,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,oBAAoB,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA+B1F"}
|
|
@@ -1,28 +1,13 @@
|
|
|
1
|
-
import { parseArgs } from 'node:util';
|
|
2
1
|
import { formatDiagnosticForCli, formatRows, section } from '../cli-format.js';
|
|
3
2
|
import { loadContentProject } from '../content-project.js';
|
|
4
3
|
import { linkResolverOptions } from '../link-options.js';
|
|
5
|
-
export async function validateCommand(
|
|
6
|
-
const { values, positionals } = parseArgs({
|
|
7
|
-
args,
|
|
8
|
-
allowPositionals: true,
|
|
9
|
-
options: {
|
|
10
|
-
registry: { type: 'string' },
|
|
11
|
-
'no-generic-blocks': { type: 'boolean', default: false },
|
|
12
|
-
'strict-warnings': { type: 'boolean', default: false },
|
|
13
|
-
'link-resolve': { type: 'string' },
|
|
14
|
-
'locale-field': { type: 'string' },
|
|
15
|
-
'slug-field': { type: 'string' },
|
|
16
|
-
'key-field': { type: 'string' },
|
|
17
|
-
'default-locale': { type: 'string' },
|
|
18
|
-
},
|
|
19
|
-
});
|
|
4
|
+
export async function validateCommand(input, io) {
|
|
20
5
|
const { files, scan } = await loadContentProject({
|
|
21
6
|
cmd: 'validate',
|
|
22
|
-
positionals,
|
|
23
|
-
registry:
|
|
24
|
-
includeGenericBlocks: !
|
|
25
|
-
linkOptions: linkResolverOptions(
|
|
7
|
+
positionals: input.globs,
|
|
8
|
+
registry: input.registry,
|
|
9
|
+
includeGenericBlocks: !input.noGenericBlocks,
|
|
10
|
+
linkOptions: linkResolverOptions(input),
|
|
26
11
|
scan: { includeStatsFindings: false },
|
|
27
12
|
});
|
|
28
13
|
let errors = 0;
|
|
@@ -44,7 +29,7 @@ export async function validateCommand(args, io) {
|
|
|
44
29
|
].join('\n'));
|
|
45
30
|
if (errors > 0)
|
|
46
31
|
return 1;
|
|
47
|
-
if (warnings > 0 &&
|
|
32
|
+
if (warnings > 0 && input.strictWarnings)
|
|
48
33
|
return 1;
|
|
49
34
|
return 0;
|
|
50
35
|
}
|
|
@@ -1,27 +1,7 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type LoadedContentProject, type LoadContentProjectInput } from '@contentbit/project';
|
|
2
|
+
export type { LoadedContentProject, LoadContentProjectInput };
|
|
2
3
|
/** Glob the positionals into sorted absolute paths. Throws CliError (exit 2). */
|
|
3
4
|
export declare function resolveContentFiles(positionals: string[], cmd: string): Promise<string[]>;
|
|
4
|
-
export interface LoadContentProjectInput {
|
|
5
|
-
/** Command name, used to namespace input-error messages. */
|
|
6
|
-
cmd: string;
|
|
7
|
-
positionals: string[];
|
|
8
|
-
/** Path to a user `--registry` module, if any. */
|
|
9
|
-
registry?: string;
|
|
10
|
-
includeGenericBlocks: boolean;
|
|
11
|
-
linkOptions: LinkResolverOptions;
|
|
12
|
-
/** Forwarded to `scanContentProject` (per-command knobs). */
|
|
13
|
-
scan?: {
|
|
14
|
-
includeStatsFindings?: boolean;
|
|
15
|
-
minSectionWords?: number;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export interface LoadedContentProject {
|
|
19
|
-
files: string[];
|
|
20
|
-
registry: BlockRegistry;
|
|
21
|
-
sources: ContentProjectSourceFile[];
|
|
22
|
-
linkOptions: LinkResolverOptions;
|
|
23
|
-
scan: ContentProjectScan;
|
|
24
|
-
}
|
|
25
5
|
/**
|
|
26
6
|
* The "loaded content project" seam: turns (positional globs, flags) into a
|
|
27
7
|
* ready-to-use project — resolved files, loaded registry, read sources, and the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-project.d.ts","sourceRoot":"","sources":["../src/content-project.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"content-project.d.ts","sourceRoot":"","sources":["../src/content-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAA;AAI5B,YAAY,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,CAAA;AAE7D,iFAAiF;AACjF,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAE/F;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAE/B"}
|
package/dist/content-project.js
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { glob } from 'tinyglobby';
|
|
4
|
-
import { loadRegistry } from './load-registry.js';
|
|
1
|
+
import { loadContentProject as loadProjectContent, ProjectLoadError, resolveContentFiles as resolveProjectContentFiles, } from '@contentbit/project';
|
|
5
2
|
import { CliError } from './run.js';
|
|
6
3
|
/** Glob the positionals into sorted absolute paths. Throws CliError (exit 2). */
|
|
7
4
|
export async function resolveContentFiles(positionals, cmd) {
|
|
8
|
-
|
|
9
|
-
throw new CliError(2, `${cmd}: provide at least one file or glob.`);
|
|
10
|
-
}
|
|
11
|
-
const files = (await glob(positionals, { absolute: true })).sort();
|
|
12
|
-
if (files.length === 0) {
|
|
13
|
-
throw new CliError(2, `${cmd}: no files matched ${positionals.join(' ')}`);
|
|
14
|
-
}
|
|
15
|
-
return files;
|
|
5
|
+
return withCliErrors(() => resolveProjectContentFiles(positionals, cmd));
|
|
16
6
|
}
|
|
17
7
|
/**
|
|
18
8
|
* The "loaded content project" seam: turns (positional globs, flags) into a
|
|
@@ -21,14 +11,15 @@ export async function resolveContentFiles(positionals, cmd) {
|
|
|
21
11
|
* `doctor`, and `stats` read-commands. Throws CliError on input failures.
|
|
22
12
|
*/
|
|
23
13
|
export async function loadContentProject(input) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
14
|
+
return withCliErrors(() => loadProjectContent(input));
|
|
15
|
+
}
|
|
16
|
+
async function withCliErrors(load) {
|
|
17
|
+
try {
|
|
18
|
+
return await load();
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
if (err instanceof ProjectLoadError)
|
|
22
|
+
throw new CliError(err.exitCode, err.message);
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
34
25
|
}
|
package/dist/link-options.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { LinkResolverOptions } from '@contentbit/core';
|
|
2
2
|
export interface LinkOptionValues {
|
|
3
|
+
linkResolve?: string | boolean;
|
|
4
|
+
localeField?: string | boolean;
|
|
5
|
+
slugField?: string | boolean;
|
|
6
|
+
keyField?: string | boolean;
|
|
7
|
+
defaultLocale?: string | boolean;
|
|
3
8
|
'link-resolve'?: string | boolean;
|
|
4
9
|
'locale-field'?: string | boolean;
|
|
5
10
|
'slug-field'?: string | boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-options.d.ts","sourceRoot":"","sources":["../src/link-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACjC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACjC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC9B,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACpC;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,mBAAmB,CAgBjF"}
|
|
1
|
+
{"version":3,"file":"link-options.d.ts","sourceRoot":"","sources":["../src/link-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAE3D,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAChC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACjC,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACjC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC9B,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACpC;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,mBAAmB,CAgBjF"}
|
package/dist/link-options.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export function linkResolverOptions(values) {
|
|
2
2
|
const out = {};
|
|
3
|
-
const resolve = stringValue(values['link-resolve']);
|
|
3
|
+
const resolve = stringValue(values.linkResolve ?? values['link-resolve']);
|
|
4
4
|
if (resolve) {
|
|
5
5
|
if (!isResolveMode(resolve))
|
|
6
6
|
throw new Error(`invalid --link-resolve ${resolve}`);
|
|
7
7
|
out.resolve = resolve;
|
|
8
8
|
}
|
|
9
|
-
const localeField = stringValue(values['locale-field']);
|
|
10
|
-
const slugField = stringValue(values['slug-field']);
|
|
11
|
-
const keyField = stringValue(values['key-field']);
|
|
12
|
-
const defaultLocale = stringValue(values['default-locale']);
|
|
9
|
+
const localeField = stringValue(values.localeField ?? values['locale-field']);
|
|
10
|
+
const slugField = stringValue(values.slugField ?? values['slug-field']);
|
|
11
|
+
const keyField = stringValue(values.keyField ?? values['key-field']);
|
|
12
|
+
const defaultLocale = stringValue(values.defaultLocale ?? values['default-locale']);
|
|
13
13
|
if (localeField)
|
|
14
14
|
out.localeField = localeField;
|
|
15
15
|
if (slugField)
|
package/dist/load-registry.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export interface LoadRegistryOptions {
|
|
3
|
-
includeGenericBlocks?: boolean;
|
|
4
|
-
}
|
|
5
|
-
/** Generic pack + optional user module (default export: BlockDefinition[]). */
|
|
6
|
-
export declare function loadRegistry(registryPath?: string, options?: LoadRegistryOptions): Promise<BlockRegistry>;
|
|
1
|
+
export { loadRegistry, type LoadRegistryOptions } from '@contentbit/project';
|
|
7
2
|
//# sourceMappingURL=load-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-registry.d.ts","sourceRoot":"","sources":["../src/load-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"load-registry.d.ts","sourceRoot":"","sources":["../src/load-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/load-registry.js
CHANGED
|
@@ -1,26 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { createBlockRegistry } from '@contentbit/core';
|
|
3
|
-
import { pathToFileURL } from 'node:url';
|
|
4
|
-
/** Generic pack + optional user module (default export: BlockDefinition[]). */
|
|
5
|
-
export async function loadRegistry(registryPath, options = {}) {
|
|
6
|
-
const registry = createBlockRegistry();
|
|
7
|
-
if (options.includeGenericBlocks !== false)
|
|
8
|
-
registry.use(genericBlocks());
|
|
9
|
-
if (registryPath) {
|
|
10
|
-
let mod;
|
|
11
|
-
try {
|
|
12
|
-
mod = (await import(pathToFileURL(registryPath).href));
|
|
13
|
-
}
|
|
14
|
-
catch (err) {
|
|
15
|
-
if (err instanceof Error && 'code' in err && err.code === 'ERR_UNKNOWN_FILE_EXTENSION') {
|
|
16
|
-
throw new Error(`Importing a TypeScript registry needs Node 22.18+ (native type stripping): ${registryPath}`);
|
|
17
|
-
}
|
|
18
|
-
throw err;
|
|
19
|
-
}
|
|
20
|
-
if (!Array.isArray(mod.default)) {
|
|
21
|
-
throw new Error(`--registry module must default-export an array of block definitions: ${registryPath}`);
|
|
22
|
-
}
|
|
23
|
-
registry.use(mod.default);
|
|
24
|
-
}
|
|
25
|
-
return registry;
|
|
26
|
-
}
|
|
1
|
+
export { loadRegistry } from '@contentbit/project';
|
package/dist/run.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ export declare class CliError extends Error {
|
|
|
12
12
|
readonly exitCode: number;
|
|
13
13
|
constructor(exitCode: number, message: string);
|
|
14
14
|
}
|
|
15
|
-
export declare const USAGE = "contentbit\n\nUsage:\n contentbit <command> [options]\n\nCommands:\n init scaffold Content Blocks into a project\n validate check Markdown blocks and internal links\n doctor inspect content health and repair suggestions\n studio browse content locally\n stats print document stats as JSON\n render render one file to plain Markdown\n instructions print LLM authoring instructions\n docs print human authoring docs\n agents install coding-agent guidance\n links build or fix the internal link index\n\nSetup:\n init [-t react|markdown|astro] [--md ...] [-y] [--no-install] [--no-page] [--no-agents]\n agents [--claude] [--no-agents-md]\n\nCommon:\n validate <globs...> [--registry <module.ts>] [--no-generic-blocks] [--strict-warnings] [--link-resolve <mode>]\n doctor <globs...> [--registry <module.ts>] [--no-generic-blocks] [--strict-warnings] [--json] [--min-section-words <n>] [--link-resolve <mode>]\n studio <globs...> [--registry <module.ts>] [--port <n>] [--host <host>] [--no-open] [--no-generic-blocks] [--link-resolve <mode>]\n stats <globs...> [--registry <module.ts>] [--no-generic-blocks] [--no-validate]\n render <file> [--target markdown] [--registry <module.ts>] [--no-generic-blocks] [--out <file>]\n instructions [--audience llm|human] [--no-examples] [--registry <module.ts>] [--no-generic-blocks] [--out <file>]\n docs [--registry <module.ts>] [--no-generic-blocks] [--out <file>]\n links <globs...> [--fix] [--out <file>] [--link-resolve <mode>]";
|
|
15
|
+
export declare const USAGE = "contentbit\n\nUsage:\n contentbit <command> [options]\n\nCommands:\n init scaffold Content Blocks into a project\n validate check Markdown blocks and internal links\n brief print an agent-ready SEO brief\n doctor inspect content health and repair suggestions\n studio browse content locally\n stats print document stats as JSON\n render render one file to plain Markdown\n instructions print LLM authoring instructions\n docs print human authoring docs\n agents install coding-agent guidance\n links build or fix the internal link index\n\nSetup:\n init [-t react|markdown|astro] [--md ...] [-y] [--seo] [--no-install] [--no-page] [--no-agents]\n agents [--claude] [--no-agents-md]\n\nCommon:\n validate <globs...> [--registry <module.ts>] [--no-generic-blocks] [--strict-warnings] [--link-resolve <mode>]\n brief <key-or-slug> [globs...] [--registry <module.ts>] [--no-generic-blocks] [--seo-config <module.ts>] [--json]\n doctor <globs...> [--registry <module.ts>] [--no-generic-blocks] [--strict-warnings] [--strict-seo] [--seo-config <module.ts>] [--no-seo] [--json] [--min-section-words <n>] [--link-resolve <mode>]\n studio <globs...> [--registry <module.ts>] [--port <n>] [--host <host>] [--no-open] [--no-generic-blocks] [--seo-config <module.ts>] [--no-seo] [--link-resolve <mode>]\n stats <globs...> [--registry <module.ts>] [--no-generic-blocks] [--no-validate]\n render <file> [--target markdown] [--registry <module.ts>] [--no-generic-blocks] [--out <file>]\n instructions [--audience llm|human] [--no-examples] [--registry <module.ts>] [--no-generic-blocks] [--out <file>]\n docs [--registry <module.ts>] [--no-generic-blocks] [--out <file>]\n links <globs...> [--fix] [--out <file>] [--link-resolve <mode>]";
|
|
16
16
|
export declare function run(argv: string[], io: Io): Promise<number>;
|
|
17
17
|
//# sourceMappingURL=run.d.ts.map
|
package/dist/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,EAAE;IACjB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxD;AAED;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,KAAK;IAE/B,QAAQ,CAAC,QAAQ,EAAE,MAAM;gBAAhB,QAAQ,EAAE,MAAM,EACzB,OAAO,EAAE,MAAM;CAKlB;AAED,eAAO,MAAM,KAAK,iyDA+BgD,CAAA;AAElE,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAoCjE"}
|