@velocity-astro/cms-astro 0.1.0-beta.1 → 0.1.0-beta.12
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/agents/cms.md +145 -0
- package/agents/skills/cms-add-content-type/SKILL.md +81 -0
- package/agents/skills/cms-add-form/SKILL.md +85 -0
- package/agents/skills/cms-add-section/SKILL.md +97 -0
- package/agents/skills/cms-add-to-site/SKILL.md +57 -0
- package/agents/skills/cms-connect-page/SKILL.md +64 -0
- package/agents/skills/cms-deploy/SKILL.md +64 -0
- package/agents/skills/cms-import-content/SKILL.md +63 -0
- package/agents/skills/cms-set-up-crm/SKILL.md +53 -0
- package/agents/skills/cms-write-plugin/SKILL.md +81 -0
- package/dist/admin-files.d.ts +2 -2
- package/dist/admin-files.d.ts.map +1 -1
- package/dist/admin-files.js +13 -7
- package/dist/admin-files.js.map +1 -1
- package/dist/agent-files.d.ts +23 -0
- package/dist/agent-files.d.ts.map +1 -0
- package/dist/agent-files.js +84 -0
- package/dist/agent-files.js.map +1 -0
- package/dist/challenge.d.ts +35 -0
- package/dist/challenge.d.ts.map +1 -0
- package/dist/challenge.js +84 -0
- package/dist/challenge.js.map +1 -0
- package/dist/check.d.ts +38 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +194 -0
- package/dist/check.js.map +1 -0
- package/dist/cli-content.d.ts +22 -0
- package/dist/cli-content.d.ts.map +1 -0
- package/dist/cli-content.js +309 -0
- package/dist/cli-content.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +130 -6
- package/dist/cli.js.map +1 -1
- package/dist/connection.d.ts +1 -0
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +31 -6
- package/dist/connection.js.map +1 -1
- package/dist/editor.d.ts +2 -0
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +10 -1
- package/dist/editor.js.map +1 -1
- package/dist/form-post.d.ts +9 -1
- package/dist/form-post.d.ts.map +1 -1
- package/dist/form-post.js +10 -3
- package/dist/form-post.js.map +1 -1
- package/dist/hosted.d.ts +76 -0
- package/dist/hosted.d.ts.map +1 -0
- package/dist/hosted.js +104 -0
- package/dist/hosted.js.map +1 -0
- package/dist/image-optimizer.d.ts +35 -0
- package/dist/image-optimizer.d.ts.map +1 -0
- package/dist/image-optimizer.js +76 -0
- package/dist/image-optimizer.js.map +1 -0
- package/dist/import-files.d.ts +30 -0
- package/dist/import-files.d.ts.map +1 -0
- package/dist/import-files.js +100 -0
- package/dist/import-files.js.map +1 -0
- package/dist/index.d.ts +12 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +2 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +16 -1
- package/dist/init.js.map +1 -1
- package/dist/integration.d.ts +9 -0
- package/dist/integration.d.ts.map +1 -1
- package/dist/integration.js +15 -1
- package/dist/integration.js.map +1 -1
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +6 -2
- package/dist/link.js.map +1 -1
- package/dist/live-loader.d.ts +7 -3
- package/dist/live-loader.d.ts.map +1 -1
- package/dist/live-loader.js +12 -6
- package/dist/live-loader.js.map +1 -1
- package/dist/media-store.d.ts +15 -0
- package/dist/media-store.d.ts.map +1 -1
- package/dist/media-store.js +26 -2
- package/dist/media-store.js.map +1 -1
- package/dist/page-marks.d.ts +50 -0
- package/dist/page-marks.d.ts.map +1 -0
- package/dist/page-marks.js +90 -0
- package/dist/page-marks.js.map +1 -0
- package/dist/preview.d.ts +34 -2
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +81 -15
- package/dist/preview.js.map +1 -1
- package/dist/resend-mailer.d.ts +18 -1
- package/dist/resend-mailer.d.ts.map +1 -1
- package/dist/resend-mailer.js +24 -3
- package/dist/resend-mailer.js.map +1 -1
- package/dist/secret.d.ts +1 -1
- package/dist/secret.d.ts.map +1 -1
- package/dist/secret.js +3 -2
- package/dist/secret.js.map +1 -1
- package/dist/single.d.ts +18 -0
- package/dist/single.d.ts.map +1 -0
- package/dist/single.js +37 -0
- package/dist/single.js.map +1 -0
- package/dist/site-client.d.ts +37 -0
- package/dist/site-client.d.ts.map +1 -0
- package/dist/site-client.js +73 -0
- package/dist/site-client.js.map +1 -0
- package/dist/site-editor.d.ts +1 -1
- package/dist/site-editor.d.ts.map +1 -1
- package/dist/site-editor.js +36 -6
- package/dist/site-editor.js.map +1 -1
- package/dist/site-forms.d.ts +11 -0
- package/dist/site-forms.d.ts.map +1 -1
- package/dist/site-forms.js +37 -19
- package/dist/site-forms.js.map +1 -1
- package/dist/site-mail.d.ts +45 -0
- package/dist/site-mail.d.ts.map +1 -0
- package/dist/site-mail.js +84 -0
- package/dist/site-mail.js.map +1 -0
- package/dist/site-media.d.ts +5 -1
- package/dist/site-media.d.ts.map +1 -1
- package/dist/site-media.js +14 -5
- package/dist/site-media.js.map +1 -1
- package/dist/site-name.d.ts +9 -0
- package/dist/site-name.d.ts.map +1 -0
- package/dist/site-name.js +21 -0
- package/dist/site-name.js.map +1 -0
- package/dist/site-storage.d.ts +34 -0
- package/dist/site-storage.d.ts.map +1 -0
- package/dist/site-storage.js +118 -0
- package/dist/site-storage.js.map +1 -0
- package/package.json +12 -8
- package/routes/editor.ts +7 -6
- package/routes/form-client.js.ts +68 -0
- package/routes/media.ts +2 -2
- package/routes/preview-client.js.ts +11 -56
- package/routes/published.ts +2 -2
- package/routes/sitemap-live.xml.ts +4 -1
- package/routes/sites.ts +11 -0
package/dist/check.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { liveFields } from '@velocity-astro/cms-core';
|
|
4
|
+
import { AGENT_FILES_VERSION, CMS_RULES_FILE } from './agent-files.js';
|
|
5
|
+
import { readEnvFile } from './init.js';
|
|
6
|
+
const CONFIG_FILES = ['astro.config.mjs', 'astro.config.ts', 'astro.config.js', 'astro.config.mts'];
|
|
7
|
+
const SOURCE = /\.(astro|ts|tsx|js|jsx|mjs|mts)$/;
|
|
8
|
+
/** What a template calls to read the CMS for a page. A file that calls one draws CMS content. */
|
|
9
|
+
const READERS = /\b(entryPage|single|menuLinks|linkTo|siteForm|pageHead|getLiveCollection|getLiveEntry)\s*\(/;
|
|
10
|
+
const PACKAGE = '@velocity-astro/cms-astro';
|
|
11
|
+
/** Every source file under a folder, from the site's folder, skipping what is built or installed. */
|
|
12
|
+
function filesUnder(dir, folder) {
|
|
13
|
+
const root = path.join(dir, folder);
|
|
14
|
+
if (!fs.existsSync(root))
|
|
15
|
+
return [];
|
|
16
|
+
return fs
|
|
17
|
+
.readdirSync(root, { recursive: true, encoding: 'utf8' })
|
|
18
|
+
.filter((name) => SOURCE.test(name) && !/(^|[\\/])(node_modules|dist|\.astro)[\\/]/.test(name))
|
|
19
|
+
.map((name) => path.join(folder, name).split(path.sep).join('/'));
|
|
20
|
+
}
|
|
21
|
+
/** The files a file imports by path, resolved from the site's folder (`@/` is `src/`). Packages are left out. */
|
|
22
|
+
function importsOf(dir, file, text) {
|
|
23
|
+
const found = [];
|
|
24
|
+
for (const match of text.matchAll(/(?:import|from)\s*['"]([^'"]+)['"]/g)) {
|
|
25
|
+
const spec = match[1] ?? '';
|
|
26
|
+
const base = spec.startsWith('@/') ? path.join('src', spec.slice(2)) : spec.startsWith('.') ? path.join(path.dirname(file), spec) : null;
|
|
27
|
+
if (base === null)
|
|
28
|
+
continue;
|
|
29
|
+
for (const candidate of [base, `${base}.ts`, `${base}.astro`, `${base}.js`, `${base}.tsx`, path.join(base, 'index.ts')]) {
|
|
30
|
+
if (fs.existsSync(path.join(dir, candidate)) && fs.statSync(path.join(dir, candidate)).isFile()) {
|
|
31
|
+
found.push(candidate.split(path.sep).join('/'));
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return found;
|
|
37
|
+
}
|
|
38
|
+
/** A page's own setting: `true` for `prerender = true`, `false` for `prerender = false`, `null` when it says nothing. */
|
|
39
|
+
function prerenderOf(text) {
|
|
40
|
+
const match = /export\s+const\s+prerender\s*=\s*(true|false)/.exec(text);
|
|
41
|
+
return match ? match[1] === 'true' : null;
|
|
42
|
+
}
|
|
43
|
+
/** The keys of an object literal that maps blocks to components: `export const blocks = { hero: Hero, 'call-to-action': Cta }`. */
|
|
44
|
+
export function blockMapKeys(text) {
|
|
45
|
+
const start = /export\s+const\s+blocks\b[^=]*=\s*\{/.exec(text);
|
|
46
|
+
if (!start)
|
|
47
|
+
return null;
|
|
48
|
+
let depth = 1;
|
|
49
|
+
let at = start.index + start[0].length;
|
|
50
|
+
const begin = at;
|
|
51
|
+
while (at < text.length && depth > 0) {
|
|
52
|
+
if (text[at] === '{')
|
|
53
|
+
depth += 1;
|
|
54
|
+
if (text[at] === '}')
|
|
55
|
+
depth -= 1;
|
|
56
|
+
at += 1;
|
|
57
|
+
}
|
|
58
|
+
const body = text.slice(begin, at - 1);
|
|
59
|
+
const map = new Map();
|
|
60
|
+
for (const match of body.matchAll(/(?:^|[,{\s])(?:'([^']+)'|"([^"]+)"|([A-Za-z_$][\w$]*))\s*:\s*([A-Za-z_$][\w$]*)/g)) {
|
|
61
|
+
map.set(match[1] ?? match[2] ?? match[3] ?? '', match[4] ?? '');
|
|
62
|
+
}
|
|
63
|
+
return map;
|
|
64
|
+
}
|
|
65
|
+
/** The blocks a site's pages can be built from today: those of every top-level field of sections. */
|
|
66
|
+
function siteBlocks(types) {
|
|
67
|
+
const blocks = new Map();
|
|
68
|
+
for (const type of types) {
|
|
69
|
+
for (const field of liveFields(type.fields)) {
|
|
70
|
+
const allowed = field.options.blocks;
|
|
71
|
+
if (!Array.isArray(allowed))
|
|
72
|
+
continue;
|
|
73
|
+
for (const block of allowed)
|
|
74
|
+
if (block.retiredAt === undefined)
|
|
75
|
+
blocks.set(block.key, block);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return blocks;
|
|
79
|
+
}
|
|
80
|
+
export function checkSite({ dir, types, typesSkipped, env = {} }) {
|
|
81
|
+
const findings = [];
|
|
82
|
+
const skipped = [];
|
|
83
|
+
const add = (finding) => findings.push(finding);
|
|
84
|
+
const read = (file) => fs.readFileSync(path.join(dir, file), 'utf8');
|
|
85
|
+
// 1. Setup: the integration, an adapter, an address, a secret kept out of git.
|
|
86
|
+
const configFile = CONFIG_FILES.find((file) => fs.existsSync(path.join(dir, file)));
|
|
87
|
+
const config = configFile ? read(configFile) : '';
|
|
88
|
+
if (!configFile) {
|
|
89
|
+
add({ rule: 'no-astro-site', level: 'error', file: '.', message: 'There is no Astro config here.', see: 'Setup', fix: 'Run the check in the site\'s own folder.' });
|
|
90
|
+
return { findings, skipped };
|
|
91
|
+
}
|
|
92
|
+
if (!config.includes(PACKAGE))
|
|
93
|
+
add({ rule: 'no-integration', level: 'error', file: configFile, message: 'The CMS is not in the Astro config.', see: 'Setup', fix: 'Run `npx velocity-cms init`, or add `velocityCms()` to `integrations`.' });
|
|
94
|
+
if (!/\badapter\s*:/.test(config))
|
|
95
|
+
add({ rule: 'no-adapter', level: 'error', file: configFile, message: 'The site has no server adapter, and the editor and live pages run on a server.', see: 'Setup', fix: 'Add one for where the site will live, such as `npx astro add node`.' });
|
|
96
|
+
if (!/\bsite\s*:/.test(config))
|
|
97
|
+
add({ rule: 'no-site-address', level: 'warning', file: configFile, message: 'The config has no `site`, so sign-in links have no address to lead to once deployed.', see: 'Setup', fix: 'Set `site` to the site\'s address (or `VELOCITY_CMS_ORIGIN` on the host).' });
|
|
98
|
+
if (/\boutput\s*:\s*['"]server['"]/.test(config))
|
|
99
|
+
add({ rule: 'output-server', level: 'warning', file: configFile, message: 'The whole site renders on demand (`output: \'server\'`).', see: 'Live pages', fix: 'Remove it, and mark only the pages that read the CMS with `export const prerender = false`.' });
|
|
100
|
+
if (!/tags\s*:\s*\[[^\]]*['"]cms['"]/.test(config)) {
|
|
101
|
+
add({ rule: 'no-cms-cache-tag', level: 'warning', file: configFile, message: 'No route rule tags pages with `cms`, so a page that reads the CMS through a layout may be kept after a publish.', see: 'Live pages', fix: 'Add `routeRules: { \'/[...path]\': { maxAge: 86400, tags: [\'cms\'] } }` and a `cache` provider, as the starter does.' });
|
|
102
|
+
}
|
|
103
|
+
const dotEnv = fs.existsSync(path.join(dir, '.env')) ? readEnvFile(read('.env')) : {};
|
|
104
|
+
if (!env['VELOCITY_CMS_SECRET'] && !dotEnv['VELOCITY_CMS_SECRET'])
|
|
105
|
+
add({ rule: 'no-secret', level: 'error', file: '.env', message: 'VELOCITY_CMS_SECRET is not set.', see: 'Setup', fix: 'Run `npx velocity-cms init`, which writes one. Set the same name on your host.' });
|
|
106
|
+
const ignored = fs.existsSync(path.join(dir, '.gitignore')) ? read('.gitignore').split(/\r?\n/).map((line) => line.trim().replace(/^\//, '')) : [];
|
|
107
|
+
if (fs.existsSync(path.join(dir, '.env')) && !ignored.some((line) => line === '.env' || line === '.env*')) {
|
|
108
|
+
add({ rule: 'env-in-git', level: 'error', file: '.gitignore', message: '.env is not left out of git, and it holds the site\'s secret and tokens.', see: 'Setup', fix: 'Add `.env` to .gitignore (`npx velocity-cms init` does).' });
|
|
109
|
+
}
|
|
110
|
+
// 2. Pages that read the CMS must be drawn on demand, or a publish never reaches them.
|
|
111
|
+
const sources = filesUnder(dir, 'src');
|
|
112
|
+
const texts = new Map(sources.map((file) => [file, read(file)]));
|
|
113
|
+
const readsCms = new Set(sources.filter((file) => READERS.test(texts.get(file) ?? '') && ((texts.get(file) ?? '').includes(PACKAGE) || (texts.get(file) ?? '').includes('astro:content'))));
|
|
114
|
+
const pages = sources.filter((file) => file.startsWith('src/pages/') && /\.(astro|ts|js|mjs)$/.test(file));
|
|
115
|
+
const prerenderedByDefault = !/\boutput\s*:\s*['"]server['"]/.test(config);
|
|
116
|
+
for (const page of pages) {
|
|
117
|
+
const text = texts.get(page) ?? '';
|
|
118
|
+
const through = readsCms.has(page) ? page : importsOf(dir, page, text).find((file) => readsCms.has(file));
|
|
119
|
+
if (!through)
|
|
120
|
+
continue;
|
|
121
|
+
const prerender = prerenderOf(text);
|
|
122
|
+
if (prerender === true || (prerender === null && prerenderedByDefault)) {
|
|
123
|
+
add({
|
|
124
|
+
rule: 'prerendered-cms-page',
|
|
125
|
+
level: 'error',
|
|
126
|
+
file: page,
|
|
127
|
+
message: through === page ? 'This page reads the CMS but is built ahead of time, so a publish never reaches it.' : `This page reads the CMS through ${through} but is built ahead of time, so a publish never reaches it.`,
|
|
128
|
+
see: 'Live pages',
|
|
129
|
+
fix: 'Add `export const prerender = false;` to the page.',
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const drawsEntries = sources.some((file) => /\b(entryPage|getLiveEntry|getLiveCollection)\s*\(/.test(texts.get(file) ?? ''));
|
|
134
|
+
if (drawsEntries && !sources.some((file) => /\bpageHead\s*\(/.test(texts.get(file) ?? ''))) {
|
|
135
|
+
add({ rule: 'no-page-head', level: 'warning', file: 'src/layouts', message: 'Pages draw CMS entries, but nothing calls `pageHead`, so the SEO plugin and the editor\'s titles never reach the page\'s head.', see: 'Template helpers', fix: 'In the layout, call `const head = await pageHead(Astro, { title, description })` and write `head.title`, `head.description` and `head.robots`.' });
|
|
136
|
+
}
|
|
137
|
+
for (const file of sources) {
|
|
138
|
+
const text = texts.get(file) ?? '';
|
|
139
|
+
if (/\b(sharedConnection|createCms)\s*\(/.test(text) || /\.content\.(find|get|findBySlug)\s*\(/.test(text)) {
|
|
140
|
+
add({ rule: 'reads-around-helpers', level: 'warning', file, message: 'This file reads the CMS around the helpers, which is how drafts leak onto pages and previews break.', see: 'Drafts never leak', fix: 'Read through `entryPage`, `single`, `menuLinks`, `linkTo` or the live loader (`getLiveCollection`, `getLiveEntry`).' });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// 3. Every block has a component, and every component a block.
|
|
144
|
+
const mapFile = sources.find((file) => /export\s+const\s+blocks\b/.test(texts.get(file) ?? '') && blockMapKeys(texts.get(file) ?? '') !== null);
|
|
145
|
+
if (!types) {
|
|
146
|
+
skipped.push(`Blocks and forms were not compared with the model: ${typesSkipped ?? 'the content types could not be read'}.`);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
const blocks = siteBlocks(types);
|
|
150
|
+
if (blocks.size > 0 && !mapFile) {
|
|
151
|
+
add({ rule: 'no-block-map', level: 'error', file: 'src', message: `Pages are built from ${blocks.size} blocks, but no file maps them to components.`, see: 'Sections', fix: 'Write `export const blocks = { <block key>: Component }` (as `src/components/blocks.ts` in the starter) and draw a page\'s sections from it.' });
|
|
152
|
+
}
|
|
153
|
+
if (mapFile) {
|
|
154
|
+
const mapText = texts.get(mapFile) ?? '';
|
|
155
|
+
const mapped = blockMapKeys(mapText) ?? new Map();
|
|
156
|
+
for (const [key, block] of blocks) {
|
|
157
|
+
if (!mapped.has(key))
|
|
158
|
+
add({ rule: 'block-without-component', level: 'error', file: mapFile, message: `The block "${key}" has no component, so its sections are left off every page.`, see: 'Sections', fix: `Write its component, import it here and add \`'${key}': Component\` to \`blocks\`.` });
|
|
159
|
+
const takesForm = liveFields(block.fields).some((field) => field.type === 'form');
|
|
160
|
+
const component = mapped.get(key);
|
|
161
|
+
if (!takesForm || !component)
|
|
162
|
+
continue;
|
|
163
|
+
const from = new RegExp(`import\\s+${component}\\s+from\\s+['"]([^'"]+)['"]`).exec(mapText)?.[1];
|
|
164
|
+
const resolved = from ? importsOf(dir, mapFile, `import x from '${from}'`)[0] : undefined;
|
|
165
|
+
if (resolved && !/\bsiteForm\s*\(/.test(texts.get(resolved) ?? '')) {
|
|
166
|
+
add({ rule: 'form-section-without-form', level: 'error', file: resolved, message: `The block "${key}" lets editors choose a form, but its component never calls \`siteForm\`, so the form is not drawn and nothing is received.`, see: 'Forms', fix: 'Call `const form = await siteForm(Astro, { id })` with the field\'s value and draw its fields, `form.hidden` and `form.trap`, posting to `form.action`.' });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
for (const key of mapped.keys()) {
|
|
170
|
+
if (!blocks.has(key))
|
|
171
|
+
add({ rule: 'component-without-block', level: 'warning', file: mapFile, message: `"${key}" has a component but no block in the model, so editors cannot add it.`, see: 'Sections', fix: `Describe a block with the key "${key}" in the model and apply it (\`schema.define\`), or remove it here.` });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// 4. The agent files are there, and are this version's.
|
|
176
|
+
const rules = path.join(dir, CMS_RULES_FILE);
|
|
177
|
+
if (!fs.existsSync(rules)) {
|
|
178
|
+
add({ rule: 'no-agent-rules', level: 'warning', file: CMS_RULES_FILE, message: 'The CMS\'s rules for agents are not installed.', see: 'Setup', fix: 'Run `npx velocity-cms agents`.' });
|
|
179
|
+
}
|
|
180
|
+
else if (!fs.readFileSync(rules, 'utf8').includes(`velocity-cms ${AGENT_FILES_VERSION}`)) {
|
|
181
|
+
add({ rule: 'old-agent-rules', level: 'warning', file: CMS_RULES_FILE, message: 'The CMS\'s rules for agents are from another version of the CMS.', see: 'Setup', fix: 'Run `npx velocity-cms agents` to bring them up to date.' });
|
|
182
|
+
}
|
|
183
|
+
return { findings, skipped };
|
|
184
|
+
}
|
|
185
|
+
/** The result as a person reads it: one finding a few lines, the errors first. */
|
|
186
|
+
export function formatCheck({ findings, skipped }) {
|
|
187
|
+
const ordered = [...findings].sort((a, b) => (a.level === b.level ? 0 : a.level === 'error' ? -1 : 1));
|
|
188
|
+
const lines = ordered.map((finding) => `${finding.level === 'error' ? 'Error' : 'Warning'}: ${finding.file}\n ${finding.message}\n Rule: "${finding.see}" in ${CMS_RULES_FILE} (${finding.rule})\n Fix: ${finding.fix}`);
|
|
189
|
+
const errors = findings.filter((finding) => finding.level === 'error').length;
|
|
190
|
+
const warnings = findings.length - errors;
|
|
191
|
+
const summary = findings.length === 0 ? 'velocity-cms check: no problems found.' : `velocity-cms check: ${errors} error${errors === 1 ? '' : 's'}, ${warnings} warning${warnings === 1 ? '' : 's'}.`;
|
|
192
|
+
return [...lines, ...skipped.map((line) => `Not checked: ${line}`), summary].join('\n\n');
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAsC,MAAM,0BAA0B,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAsCxC,MAAM,YAAY,GAAG,CAAC,kBAAkB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;AACpG,MAAM,MAAM,GAAG,kCAAkC,CAAC;AAClD,iGAAiG;AACjG,MAAM,OAAO,GAAG,6FAA6F,CAAC;AAC9G,MAAM,OAAO,GAAG,2BAA2B,CAAC;AAE5C,qGAAqG;AACrG,SAAS,UAAU,CAAC,GAAW,EAAE,MAAc;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,OAAO,EAAE;SACN,WAAW,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;SACxD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,2CAA2C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC9F,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE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AAQ,CAAC,MAAM,GAAG,MAAM,CAAC;IAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC,uBAAuB,MAAM,SAAS,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,QAAQ,WAAW,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;IACrM,OAAO,CAAC,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** A command's words, split into what it names in order and what it sets with `--name value` or `--flag`. */
|
|
2
|
+
export interface Parsed {
|
|
3
|
+
readonly positional: readonly string[];
|
|
4
|
+
readonly flags: Readonly<Record<string, string | true>>;
|
|
5
|
+
/** Every value a flag was given, for one that may be given more than once (`--map a=b --map c=d`). */
|
|
6
|
+
readonly all: Readonly<Record<string, readonly string[]>>;
|
|
7
|
+
}
|
|
8
|
+
export declare function parseArgs(args: readonly string[]): Parsed;
|
|
9
|
+
export interface ContentEnvironment {
|
|
10
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
11
|
+
readonly print: (line: string) => void;
|
|
12
|
+
readonly dir: string;
|
|
13
|
+
/** Lines read from the agent, for `mcp`. Defaults to the process's standard input. */
|
|
14
|
+
readonly input?: AsyncIterable<string>;
|
|
15
|
+
readonly fetch?: typeof fetch;
|
|
16
|
+
}
|
|
17
|
+
/** The commands that work with a site's content, over its API. Each answers with the exit code, or `null` for a command it does not know. */
|
|
18
|
+
export declare const CONTENT_COMMANDS: Set<string>;
|
|
19
|
+
export declare const CONTENT_USAGE = "Content, over the site's API (needs VELOCITY_CMS_TOKEN, and VELOCITY_CMS_ORIGIN for a site that is not on this computer):\n velocity-cms types The content types and their fields.\n velocity-cms type <type> One content type in full, with the blocks its pages take.\n velocity-cms entries <type> [--status s] [--locale l] [--limit n]\n velocity-cms entry <id> One entry, its values by field key.\n velocity-cms create <type> <slug> --data '<json>' [--locale l] [--publish]\n velocity-cms update <id> --data '<json>' [--publish]\n velocity-cms publish <id> | unpublish <id>\n velocity-cms sections <id> A page's sections, in order.\n velocity-cms import <type> <file.json | file.md | folder> [--publish] [--body <field>] [--map old=new] [--update] [--dry-run]\n velocity-cms export <type> [--out <file.json>]\n velocity-cms upload <image> Prints the name an image field stores.\n velocity-cms forms | submissions <form> | pipeline\n velocity-cms mcp An MCP server on standard input and output, for an agent on this computer.\n Add --json to print what the site answered as it is.";
|
|
20
|
+
/** Runs one content command. */
|
|
21
|
+
export declare function runContentCommand(command: string, parsed: Parsed, environment: ContentEnvironment): Promise<number>;
|
|
22
|
+
//# sourceMappingURL=cli-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-content.d.ts","sourceRoot":"","sources":["../src/cli-content.ts"],"names":[],"mappings":"AAKA,6GAA6G;AAC7G,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IACxD,sGAAsG;IACtG,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;CAC3D;AAKD,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAkBzD;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,sFAAsF;IACtF,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CAC/B;AAED,6IAA6I;AAC7I,eAAO,MAAM,gBAAgB,aAAkL,CAAC;AAEhN,eAAO,MAAM,aAAa,+sCAc6B,CAAC;AAExD,gCAAgC;AAChC,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAyGzH"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { readImport, slugFrom } from './import-files.js';
|
|
4
|
+
import { SiteClient, SiteRefusal } from './site-client.js';
|
|
5
|
+
/** Flags that take no value. Every other flag takes the word after it. */
|
|
6
|
+
const SWITCHES = new Set(['json', 'publish', 'personal-data', 'save', 'update', 'dry-run', 'help']);
|
|
7
|
+
export function parseArgs(args) {
|
|
8
|
+
const positional = [];
|
|
9
|
+
const flags = {};
|
|
10
|
+
const all = {};
|
|
11
|
+
for (let at = 0; at < args.length; at++) {
|
|
12
|
+
const arg = args[at] ?? '';
|
|
13
|
+
const flag = /^--([a-z][a-z-]*)(?:=(.*))?$/.exec(arg);
|
|
14
|
+
if (!flag) {
|
|
15
|
+
positional.push(arg);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const name = flag[1] ?? '';
|
|
19
|
+
const value = flag[2] ?? (SWITCHES.has(name) ? true : args[++at]);
|
|
20
|
+
if (value === undefined)
|
|
21
|
+
continue;
|
|
22
|
+
flags[name] = value;
|
|
23
|
+
if (typeof value === 'string')
|
|
24
|
+
(all[name] ??= []).push(value);
|
|
25
|
+
}
|
|
26
|
+
return { positional, flags, all };
|
|
27
|
+
}
|
|
28
|
+
/** The commands that work with a site's content, over its API. Each answers with the exit code, or `null` for a command it does not know. */
|
|
29
|
+
export const CONTENT_COMMANDS = new Set(['types', 'type', 'entries', 'entry', 'create', 'update', 'publish', 'unpublish', 'sections', 'import', 'export', 'forms', 'submissions', 'pipeline', 'upload', 'mcp']);
|
|
30
|
+
export const CONTENT_USAGE = `Content, over the site's API (needs VELOCITY_CMS_TOKEN, and VELOCITY_CMS_ORIGIN for a site that is not on this computer):
|
|
31
|
+
velocity-cms types The content types and their fields.
|
|
32
|
+
velocity-cms type <type> One content type in full, with the blocks its pages take.
|
|
33
|
+
velocity-cms entries <type> [--status s] [--locale l] [--limit n]
|
|
34
|
+
velocity-cms entry <id> One entry, its values by field key.
|
|
35
|
+
velocity-cms create <type> <slug> --data '<json>' [--locale l] [--publish]
|
|
36
|
+
velocity-cms update <id> --data '<json>' [--publish]
|
|
37
|
+
velocity-cms publish <id> | unpublish <id>
|
|
38
|
+
velocity-cms sections <id> A page's sections, in order.
|
|
39
|
+
velocity-cms import <type> <file.json | file.md | folder> [--publish] [--body <field>] [--map old=new] [--update] [--dry-run]
|
|
40
|
+
velocity-cms export <type> [--out <file.json>]
|
|
41
|
+
velocity-cms upload <image> Prints the name an image field stores.
|
|
42
|
+
velocity-cms forms | submissions <form> | pipeline
|
|
43
|
+
velocity-cms mcp An MCP server on standard input and output, for an agent on this computer.
|
|
44
|
+
Add --json to print what the site answered as it is.`;
|
|
45
|
+
/** Runs one content command. */
|
|
46
|
+
export async function runContentCommand(command, parsed, environment) {
|
|
47
|
+
const { print } = environment;
|
|
48
|
+
const origin = (typeof parsed.flags['site'] === 'string' ? parsed.flags['site'] : undefined) ?? environment.env['VELOCITY_CMS_ORIGIN'];
|
|
49
|
+
const token = (typeof parsed.flags['token'] === 'string' ? parsed.flags['token'] : undefined) ?? environment.env['VELOCITY_CMS_TOKEN'];
|
|
50
|
+
if (!origin) {
|
|
51
|
+
print('VELOCITY_CMS_ORIGIN is not set. Run `velocity-cms init` in the site\'s folder, or pass --site https://example.com.');
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
if (!token) {
|
|
55
|
+
print('VELOCITY_CMS_TOKEN is not set. Make a token with `velocity-cms token "<what it is for>" --save`, or in the editor under Settings, Access tokens, and put it in .env.');
|
|
56
|
+
return 1;
|
|
57
|
+
}
|
|
58
|
+
const site = new SiteClient({ origin, token, ...(environment.fetch && { fetch: environment.fetch }) });
|
|
59
|
+
const json = parsed.flags['json'] === true;
|
|
60
|
+
const show = (value) => print(JSON.stringify(value, null, 2));
|
|
61
|
+
const [first, second] = parsed.positional;
|
|
62
|
+
const need = (value, what) => {
|
|
63
|
+
if (value === undefined || value === '')
|
|
64
|
+
throw new SiteRefusal(`Give ${what}.\n\n${CONTENT_USAGE}`);
|
|
65
|
+
return value;
|
|
66
|
+
};
|
|
67
|
+
const data = () => {
|
|
68
|
+
const raw = typeof parsed.flags['data'] === 'string' ? parsed.flags['data'] : typeof parsed.flags['file'] === 'string' ? fs.readFileSync(path.resolve(environment.dir, parsed.flags['file']), 'utf8') : '{}';
|
|
69
|
+
try {
|
|
70
|
+
const value = JSON.parse(raw);
|
|
71
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value))
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Said below, in one place.
|
|
76
|
+
}
|
|
77
|
+
throw new SiteRefusal('--data must be a JSON object of values by field key, such as \'{"title": "Hello"}\'.');
|
|
78
|
+
};
|
|
79
|
+
const publish = parsed.flags['publish'] === true;
|
|
80
|
+
try {
|
|
81
|
+
switch (command) {
|
|
82
|
+
case 'mcp':
|
|
83
|
+
return await relay(site, environment);
|
|
84
|
+
case 'types': {
|
|
85
|
+
const site_ = await site.tool('describe_site');
|
|
86
|
+
if (json)
|
|
87
|
+
show(site_);
|
|
88
|
+
else
|
|
89
|
+
for (const type of site_.contentTypes)
|
|
90
|
+
print(`${type.key} (${type.kind}${type.urlPattern ? `, ${type.urlPattern}` : ''}): ${type.fields.join(', ')}`);
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
case 'type':
|
|
94
|
+
show(await site.tool('get_content_type', { type: need(first, 'a content type\'s key') }));
|
|
95
|
+
return 0;
|
|
96
|
+
case 'entries': {
|
|
97
|
+
const list = await site.tool('list_entries', {
|
|
98
|
+
type: need(first, 'a content type\'s key'),
|
|
99
|
+
...(typeof parsed.flags['status'] === 'string' && { status: parsed.flags['status'] }),
|
|
100
|
+
...(typeof parsed.flags['locale'] === 'string' && { locale: parsed.flags['locale'] }),
|
|
101
|
+
...(typeof parsed.flags['slug'] === 'string' && { slug: parsed.flags['slug'] }),
|
|
102
|
+
...(typeof parsed.flags['limit'] === 'string' && { limit: Number(parsed.flags['limit']) }),
|
|
103
|
+
});
|
|
104
|
+
if (json)
|
|
105
|
+
show(list);
|
|
106
|
+
else {
|
|
107
|
+
for (const entry of list.items)
|
|
108
|
+
print(`${entry.id} ${entry.status.padEnd(9)} ${entry.locale} ${entry.slug} ${entry.title}`);
|
|
109
|
+
print(`${list.items.length} of ${list.total}.`);
|
|
110
|
+
}
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
case 'entry':
|
|
114
|
+
show(await site.tool('get_entry', { id: need(first, 'an entry\'s id') }));
|
|
115
|
+
return 0;
|
|
116
|
+
case 'create':
|
|
117
|
+
show(await site.tool('create_entry', { type: need(first, 'a content type\'s key'), slug: need(second, 'a slug'), data: data(), publish, ...(typeof parsed.flags['locale'] === 'string' && { locale: parsed.flags['locale'] }) }));
|
|
118
|
+
return 0;
|
|
119
|
+
case 'update':
|
|
120
|
+
show(await site.tool('update_entry', { id: need(first, 'an entry\'s id'), data: data(), publish }));
|
|
121
|
+
return 0;
|
|
122
|
+
case 'publish':
|
|
123
|
+
case 'unpublish':
|
|
124
|
+
show(await site.tool(`${command}_entry`, { id: need(first, 'an entry\'s id') }));
|
|
125
|
+
return 0;
|
|
126
|
+
case 'sections':
|
|
127
|
+
show(await site.tool('get_sections', { id: need(first, 'an entry\'s id') }));
|
|
128
|
+
return 0;
|
|
129
|
+
case 'forms':
|
|
130
|
+
show(await site.tool('list_forms'));
|
|
131
|
+
return 0;
|
|
132
|
+
case 'submissions':
|
|
133
|
+
show(await site.tool('list_submissions', { form: need(first, 'a form\'s key') }));
|
|
134
|
+
return 0;
|
|
135
|
+
case 'pipeline':
|
|
136
|
+
show(await site.tool('get_pipeline'));
|
|
137
|
+
return 0;
|
|
138
|
+
case 'upload': {
|
|
139
|
+
const file = path.resolve(environment.dir, need(first, 'an image file'));
|
|
140
|
+
const image = await site.upload(path.basename(file), fs.readFileSync(file));
|
|
141
|
+
if (json)
|
|
142
|
+
show(image);
|
|
143
|
+
else
|
|
144
|
+
print(image.name);
|
|
145
|
+
return 0;
|
|
146
|
+
}
|
|
147
|
+
case 'export':
|
|
148
|
+
return await exportType(site, need(first, 'a content type\'s key'), parsed, environment);
|
|
149
|
+
case 'import':
|
|
150
|
+
return await importInto(site, need(first, 'a content type\'s key'), path.resolve(environment.dir, need(second, 'a file or a folder to import')), parsed, environment);
|
|
151
|
+
default:
|
|
152
|
+
print(CONTENT_USAGE);
|
|
153
|
+
return 1;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
if (!(error instanceof SiteRefusal))
|
|
158
|
+
throw error;
|
|
159
|
+
print(error.message);
|
|
160
|
+
return 1;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* An MCP server on standard input and output, for an agent that starts a command: each message
|
|
165
|
+
* is handed to the site's own MCP server with the token, and its answer printed back. Nothing is
|
|
166
|
+
* decided here, so the agent gets exactly what the site would give it over HTTP.
|
|
167
|
+
*/
|
|
168
|
+
async function relay(site, environment) {
|
|
169
|
+
const write = (line) => process.stdout.write(`${line}\n`);
|
|
170
|
+
const input = environment.input ?? readLines(process.stdin);
|
|
171
|
+
for await (const line of input) {
|
|
172
|
+
if (line.trim() === '')
|
|
173
|
+
continue;
|
|
174
|
+
let id = null;
|
|
175
|
+
try {
|
|
176
|
+
id = JSON.parse(line).id ?? null;
|
|
177
|
+
const answer = await site.relay(line);
|
|
178
|
+
if (answer !== null)
|
|
179
|
+
write(answer);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (id === null)
|
|
183
|
+
continue;
|
|
184
|
+
const message = error instanceof SiteRefusal ? error.message : 'The site could not be reached.';
|
|
185
|
+
write(JSON.stringify({ jsonrpc: '2.0', id, error: { code: -32603, message } }));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return 0;
|
|
189
|
+
}
|
|
190
|
+
async function* readLines(stream) {
|
|
191
|
+
let rest = '';
|
|
192
|
+
for await (const chunk of stream) {
|
|
193
|
+
rest += String(chunk);
|
|
194
|
+
const lines = rest.split('\n');
|
|
195
|
+
rest = lines.pop() ?? '';
|
|
196
|
+
yield* lines;
|
|
197
|
+
}
|
|
198
|
+
if (rest !== '')
|
|
199
|
+
yield rest;
|
|
200
|
+
}
|
|
201
|
+
async function exportType(site, type, parsed, { print, dir }) {
|
|
202
|
+
const entries = [];
|
|
203
|
+
for (let offset = 0;; offset += 200) {
|
|
204
|
+
const page = await site.tool('list_entries', { type, limit: 200, offset });
|
|
205
|
+
for (const item of page.items) {
|
|
206
|
+
const entry = await site.tool('get_entry', { id: item.id });
|
|
207
|
+
entries.push({ slug: entry.slug, locale: entry.locale, status: entry.status, data: entry.data });
|
|
208
|
+
}
|
|
209
|
+
if (page.items.length === 0 || offset + page.items.length >= page.total)
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
const text = `${JSON.stringify(entries, null, 2)}\n`;
|
|
213
|
+
const out = parsed.flags['out'];
|
|
214
|
+
if (typeof out === 'string') {
|
|
215
|
+
fs.writeFileSync(path.resolve(dir, out), text);
|
|
216
|
+
print(`Wrote ${entries.length} ${type} to ${out}. \`velocity-cms import ${type} ${out}\` brings them into another site.`);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
print(text.trimEnd());
|
|
220
|
+
}
|
|
221
|
+
return 0;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Brings entries in from files, as drafts unless `--publish`: keys the content type has no field
|
|
225
|
+
* for are left out and named, a picture an image field names by a path on this computer is
|
|
226
|
+
* uploaded, and the Markdown under front matter goes into the formatted text field. An entry
|
|
227
|
+
* whose slug is taken is left as it is unless `--update`. Ends with what came in and what did not.
|
|
228
|
+
*/
|
|
229
|
+
async function importInto(site, typeKey, target, parsed, { print }) {
|
|
230
|
+
if (!fs.existsSync(target))
|
|
231
|
+
throw new SiteRefusal(`There is nothing at ${target}.`);
|
|
232
|
+
const type = await site.tool('get_content_type', { type: typeKey });
|
|
233
|
+
const fields = new Map(type.fields.map((field) => [field.key, field]));
|
|
234
|
+
const renames = new Map((parsed.all['map'] ?? []).map((pair) => pair.split('=')).filter(([from, to]) => from && to));
|
|
235
|
+
const asked = parsed.flags['body'];
|
|
236
|
+
const rich = type.fields.filter((field) => field.type === 'richtext');
|
|
237
|
+
const bodyKey = typeof asked === 'string' ? asked : (rich.find((field) => ['body', 'content', 'text'].includes(field.key)) ?? rich[0])?.key;
|
|
238
|
+
const titleKey = type.fields.find((field) => field.key === 'title')?.key ?? type.fields.find((field) => field.type === 'text')?.key;
|
|
239
|
+
const dryRun = parsed.flags['dry-run'] === true;
|
|
240
|
+
const items = readImport(target);
|
|
241
|
+
const leftOut = new Set();
|
|
242
|
+
const report = { created: 0, updated: 0, unchanged: [], refused: [], pictures: 0 };
|
|
243
|
+
for (const item of items) {
|
|
244
|
+
const values = {};
|
|
245
|
+
for (const [rawKey, value] of Object.entries(item.values)) {
|
|
246
|
+
const key = renames.get(rawKey) ?? rawKey;
|
|
247
|
+
const field = fields.get(key);
|
|
248
|
+
if (!field) {
|
|
249
|
+
leftOut.add(rawKey);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
values[key] = value;
|
|
253
|
+
// A picture named by a path on this computer is uploaded, and the field holds its name.
|
|
254
|
+
const local = typeof value === 'string' && field.type === 'image' && !/^[a-z]+:\/\//i.test(value) ? path.resolve(item.dir, value.replace(/^\//, '')) : null;
|
|
255
|
+
if (local && fs.existsSync(local)) {
|
|
256
|
+
if (!dryRun)
|
|
257
|
+
values[key] = (await site.upload(path.basename(local), fs.readFileSync(local))).name;
|
|
258
|
+
report.pictures += 1;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (item.body !== undefined && item.body.trim() !== '') {
|
|
262
|
+
if (bodyKey && fields.has(bodyKey))
|
|
263
|
+
values[bodyKey] = { markdown: item.body };
|
|
264
|
+
else
|
|
265
|
+
leftOut.add('(the text under the front matter: name a field with --body)');
|
|
266
|
+
}
|
|
267
|
+
const title = titleKey ? values[titleKey] : undefined;
|
|
268
|
+
const slug = item.slug !== '' ? item.slug : typeof title === 'string' ? slugFrom(title) : '';
|
|
269
|
+
if (slug === '') {
|
|
270
|
+
report.refused.push(`${item.source}: no slug, and no title to make one from.`);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (dryRun) {
|
|
274
|
+
report.created += 1;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
const found = await site.tool('list_entries', { type: typeKey, slug, ...(item.locale && { locale: item.locale }), limit: 1 });
|
|
279
|
+
const existing = found.items[0];
|
|
280
|
+
if (existing && parsed.flags['update'] !== true) {
|
|
281
|
+
report.unchanged.push(`${item.source}: ${slug} is already here (add --update to change it).`);
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if (existing) {
|
|
285
|
+
await site.tool('update_entry', { id: existing.id, data: values, publish: parsed.flags['publish'] === true });
|
|
286
|
+
report.updated += 1;
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
await site.tool('create_entry', { type: typeKey, slug, data: values, publish: parsed.flags['publish'] === true, ...(item.locale && { locale: item.locale }) });
|
|
290
|
+
report.created += 1;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
if (!(error instanceof SiteRefusal))
|
|
295
|
+
throw error;
|
|
296
|
+
report.refused.push(`${item.source}: ${error.message.split('\n').join(' ')}`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const state = parsed.flags['publish'] === true ? 'published' : 'as drafts';
|
|
300
|
+
print(`${dryRun ? 'Would import' : 'Imported'} ${report.created} new ${typeKey} ${state}${report.updated > 0 ? ` and updated ${report.updated}` : ''}, from ${items.length} found.${report.pictures > 0 ? ` ${report.pictures} pictures ${dryRun ? 'would be' : 'were'} uploaded.` : ''}`);
|
|
301
|
+
if (leftOut.size > 0)
|
|
302
|
+
print(`Left out, since ${typeKey} has no field for them: ${[...leftOut].join(', ')}. Name a field with --map old=new to keep one.`);
|
|
303
|
+
if (items.some((item) => item.body?.includes('![')))
|
|
304
|
+
print('Pictures inside the text were left out: formatted text holds no pictures. Add them to an image field, or as sections.');
|
|
305
|
+
for (const line of [...report.unchanged, ...report.refused])
|
|
306
|
+
print(` ${line}`);
|
|
307
|
+
return report.refused.length > 0 ? 1 : 0;
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=cli-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-content.js","sourceRoot":"","sources":["../src/cli-content.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAU3D,0EAA0E;AAC1E,MAAM,QAAQ,GAAG,IAAI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IAAI,MAAM,CAAC,OAAO,QAAQ,OAAO,IAAI,KAAK,GAAG,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,KAAK,CAAC,MAAM,UAAU,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,aAAa,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3R,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC;QAAE,KAAK,CAAC,mBAAmB,OAAO,2BAA2B,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;IAC1J,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAAE,KAAK,CAAC,uHAAuH,CAAC,CAAC;IACpL,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,MAAM,CAAC,SAAS,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC;QAAE,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAChF,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ export interface CliEnvironment {
|
|
|
3
3
|
readonly print: (line: string) => void;
|
|
4
4
|
/** The folder the command is run in. Defaults to the process's own. */
|
|
5
5
|
readonly dir?: string;
|
|
6
|
+
/** Lines read from an agent, for `mcp`. Defaults to standard input. */
|
|
7
|
+
readonly input?: AsyncIterable<string>;
|
|
8
|
+
readonly fetch?: typeof fetch;
|
|
6
9
|
}
|
|
7
10
|
/** The `velocity-cms` command. Returns the exit code. */
|
|
8
11
|
export declare function runCli(args: readonly string[], environment: CliEnvironment): Promise<number>;
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,uEAAuE;IACvE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CAC/B;AAkBD,yDAAyD;AACzD,wBAAsB,MAAM,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAyElG"}
|