contentbit 0.5.0 → 0.6.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 +13 -0
- package/dist/bin.js +4807 -501
- package/dist/commands/agents.d.ts +6 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/brief.d.ts +12 -0
- package/dist/commands/brief.d.ts.map +1 -0
- package/dist/commands/docs.d.ts +6 -1
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/doctor.d.ts +13 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/init.d.ts +12 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/instructions.d.ts +8 -1
- package/dist/commands/instructions.d.ts.map +1 -1
- package/dist/commands/links.d.ts +7 -1
- package/dist/commands/links.d.ts.map +1 -1
- package/dist/commands/render.d.ts +8 -1
- package/dist/commands/render.d.ts.map +1 -1
- package/dist/commands/stats.d.ts +7 -1
- package/dist/commands/stats.d.ts.map +1 -1
- package/dist/commands/studio.d.ts +13 -1
- package/dist/commands/studio.d.ts.map +1 -1
- package/dist/commands/validate.d.ts +8 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/content-project.d.ts +2 -22
- package/dist/content-project.d.ts.map +1 -1
- package/dist/link-options.d.ts +5 -0
- package/dist/link-options.d.ts.map +1 -1
- package/dist/load-registry.d.ts +1 -6
- package/dist/load-registry.d.ts.map +1 -1
- package/dist/run.d.ts +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4805 -499
- package/dist/seo-config.d.ts +12 -0
- package/dist/seo-config.d.ts.map +1 -0
- package/package.json +6 -5
- package/dist/cli-format.js +0 -63
- package/dist/commands/agents.js +0 -73
- package/dist/commands/docs.js +0 -21
- package/dist/commands/doctor.js +0 -149
- package/dist/commands/init-targets.js +0 -280
- package/dist/commands/init.js +0 -343
- package/dist/commands/instructions.js +0 -26
- package/dist/commands/links.js +0 -101
- package/dist/commands/render.js +0 -45
- package/dist/commands/stats.js +0 -48
- package/dist/commands/studio.js +0 -78
- package/dist/commands/validate.js +0 -64
- package/dist/content-project.js +0 -34
- package/dist/link-options.js +0 -31
- package/dist/links-io.js +0 -14
- package/dist/load-registry.js +0 -26
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { parseArgs } from 'node:util';
|
|
2
|
-
import { formatDiagnosticForCli, formatRows, section } from '../cli-format.js';
|
|
3
|
-
import { loadContentProject } from '../content-project.js';
|
|
4
|
-
import { linkResolverOptions } from '../link-options.js';
|
|
5
|
-
export async function validateCommand(args, io) {
|
|
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
|
-
});
|
|
20
|
-
const { files, scan } = await loadContentProject({
|
|
21
|
-
cmd: 'validate',
|
|
22
|
-
positionals,
|
|
23
|
-
registry: values.registry,
|
|
24
|
-
includeGenericBlocks: !values['no-generic-blocks'],
|
|
25
|
-
linkOptions: linkResolverOptions(values),
|
|
26
|
-
scan: { includeStatsFindings: false },
|
|
27
|
-
});
|
|
28
|
-
let errors = 0;
|
|
29
|
-
let warnings = 0;
|
|
30
|
-
for (const finding of scan.findings) {
|
|
31
|
-
io.stderr(formatDiagnosticForCli(diagnosticFromFinding(finding), finding.file));
|
|
32
|
-
if (finding.severity === 'error')
|
|
33
|
-
errors++;
|
|
34
|
-
else if (finding.severity === 'warning')
|
|
35
|
-
warnings++;
|
|
36
|
-
}
|
|
37
|
-
io.stdout([
|
|
38
|
-
section('Validation'),
|
|
39
|
-
...formatRows([
|
|
40
|
-
{ label: 'Files', value: files.length },
|
|
41
|
-
{ label: 'Errors', value: errors, tone: errors > 0 ? 'error' : 'success' },
|
|
42
|
-
{ label: 'Warnings', value: warnings, tone: warnings > 0 ? 'warning' : 'success' },
|
|
43
|
-
]),
|
|
44
|
-
].join('\n'));
|
|
45
|
-
if (errors > 0)
|
|
46
|
-
return 1;
|
|
47
|
-
if (warnings > 0 && values['strict-warnings'])
|
|
48
|
-
return 1;
|
|
49
|
-
return 0;
|
|
50
|
-
}
|
|
51
|
-
function diagnosticFromFinding(finding) {
|
|
52
|
-
const line = finding.line ?? 1;
|
|
53
|
-
const column = finding.column ?? 1;
|
|
54
|
-
return {
|
|
55
|
-
code: finding.code,
|
|
56
|
-
severity: finding.severity,
|
|
57
|
-
message: finding.message,
|
|
58
|
-
...(finding.hint ? { hint: finding.hint } : {}),
|
|
59
|
-
position: {
|
|
60
|
-
start: { line, column, offset: 0 },
|
|
61
|
-
end: { line, column, offset: 0 },
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
}
|
package/dist/content-project.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { scanContentProject, } from '@contentbit/core';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import { glob } from 'tinyglobby';
|
|
4
|
-
import { loadRegistry } from './load-registry.js';
|
|
5
|
-
import { CliError } from './run.js';
|
|
6
|
-
/** Glob the positionals into sorted absolute paths. Throws CliError (exit 2). */
|
|
7
|
-
export async function resolveContentFiles(positionals, cmd) {
|
|
8
|
-
if (positionals.length === 0) {
|
|
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;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* The "loaded content project" seam: turns (positional globs, flags) into a
|
|
19
|
-
* ready-to-use project — resolved files, loaded registry, read sources, and the
|
|
20
|
-
* produced content project scan. The single input path shared by the `validate`,
|
|
21
|
-
* `doctor`, and `stats` read-commands. Throws CliError on input failures.
|
|
22
|
-
*/
|
|
23
|
-
export async function loadContentProject(input) {
|
|
24
|
-
const files = await resolveContentFiles(input.positionals, input.cmd);
|
|
25
|
-
const registry = await loadRegistry(input.registry, {
|
|
26
|
-
includeGenericBlocks: input.includeGenericBlocks,
|
|
27
|
-
});
|
|
28
|
-
const sources = await Promise.all(files.map(async (path) => ({ path, source: await readFile(path, 'utf8') })));
|
|
29
|
-
const scan = scanContentProject(sources, registry, {
|
|
30
|
-
linkOptions: input.linkOptions,
|
|
31
|
-
...input.scan,
|
|
32
|
-
});
|
|
33
|
-
return { files, registry, sources, linkOptions: input.linkOptions, scan };
|
|
34
|
-
}
|
package/dist/link-options.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export function linkResolverOptions(values) {
|
|
2
|
-
const out = {};
|
|
3
|
-
const resolve = stringValue(values['link-resolve']);
|
|
4
|
-
if (resolve) {
|
|
5
|
-
if (!isResolveMode(resolve))
|
|
6
|
-
throw new Error(`invalid --link-resolve ${resolve}`);
|
|
7
|
-
out.resolve = resolve;
|
|
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']);
|
|
13
|
-
if (localeField)
|
|
14
|
-
out.localeField = localeField;
|
|
15
|
-
if (slugField)
|
|
16
|
-
out.slugField = slugField;
|
|
17
|
-
if (keyField)
|
|
18
|
-
out.keyField = keyField;
|
|
19
|
-
if (defaultLocale)
|
|
20
|
-
out.defaultLocale = defaultLocale;
|
|
21
|
-
return out;
|
|
22
|
-
}
|
|
23
|
-
function stringValue(value) {
|
|
24
|
-
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
25
|
-
}
|
|
26
|
-
function isResolveMode(value) {
|
|
27
|
-
return (value === 'global-slug' ||
|
|
28
|
-
value === 'same-locale-slug' ||
|
|
29
|
-
value === 'same-locale-key' ||
|
|
30
|
-
value === 'prefer-same-locale-key-fallback-slug');
|
|
31
|
-
}
|
package/dist/links-io.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { extractFrontmatter } from '@contentbit/core';
|
|
2
|
-
import { readFile } from 'node:fs/promises';
|
|
3
|
-
// Read each file's frontmatter (head only — bodies are never parsed) into the
|
|
4
|
-
// LinkInput shape the core link functions consume. Files with no frontmatter
|
|
5
|
-
// contribute an empty data object (a non-participating page).
|
|
6
|
-
export async function collectLinkInputs(files) {
|
|
7
|
-
const inputs = [];
|
|
8
|
-
for (const path of files) {
|
|
9
|
-
const source = await readFile(path, 'utf8');
|
|
10
|
-
const fm = extractFrontmatter(source);
|
|
11
|
-
inputs.push({ path, data: fm?.data ?? {} });
|
|
12
|
-
}
|
|
13
|
-
return inputs;
|
|
14
|
-
}
|
package/dist/load-registry.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { genericBlocks } from '@contentbit/blocks';
|
|
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
|
-
}
|