cascivo 1.8.0 → 1.8.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/dist/{app-DDq0Utmj.mjs → app-DGscFgup.mjs} +3 -3
- package/dist/{app-DDq0Utmj.mjs.map → app-DGscFgup.mjs.map} +1 -1
- package/dist/{blueprint-eOLGuyAi.mjs → blueprint-BTogmP-c.mjs} +2 -2
- package/dist/{blueprint-eOLGuyAi.mjs.map → blueprint-BTogmP-c.mjs.map} +1 -1
- package/dist/cmdspec.json +1 -1
- package/dist/{create-BA9GQ8nl.mjs → create-BRCCjfRB.mjs} +163 -147
- package/dist/create-BRCCjfRB.mjs.map +1 -0
- package/dist/generated/audit-contract.json +97 -23
- package/dist/index.mjs +31 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/create-BA9GQ8nl.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as e}from"./config-CTk7uDrh.mjs";import{i as t}from"./fs-B7O-fNID.mjs";import{n,t as r}from"./args-B4PN85cC.mjs";import{t as i}from"./merge-D332dc_m.mjs";import{buildScaffold as a,n as o,optionsError as s}from"./create-
|
|
1
|
+
import{a as e}from"./config-CTk7uDrh.mjs";import{i as t}from"./fs-B7O-fNID.mjs";import{n,t as r}from"./args-B4PN85cC.mjs";import{t as i}from"./merge-D332dc_m.mjs";import{buildScaffold as a,n as o,optionsError as s}from"./create-BRCCjfRB.mjs";import{blueprintOptions as c,parseBlueprint as l}from"./blueprint-BTogmP-c.mjs";import{existsSync as u,mkdtempSync as d,readFileSync as f,readdirSync as p,rmSync as m,statSync as h,writeFileSync as g}from"node:fs";import{join as _,relative as v}from"node:path";import{spawnSync as y}from"node:child_process";import{tmpdir as b}from"node:os";const x=`cascivo.app.json`;function S(e,t){let n={...c(l(e,x)),pm:t};return new Map(a(n).map(e=>[e.path,e.contents]))}function C(e){let t=/* @__PURE__ */ new Map,n=r=>{for(let i of p(r)){let a=_(r,i);h(a).isDirectory()?n(a):t.set(v(e,a).replaceAll(`\\`,`/`),f(a,`utf8`))}};return n(e),t}function w(e,t){let{cascivo:n,name:r}=l(e,x);if(!n||n===`1.8.1`)return S(e,t);let i=d(_(b(),`cascivo-base-`));try{return g(_(i,x),JSON.stringify(e)),y(`npx`,[`-y`,`cascivo@${n}`,`create`,`--from`,x,`--pm`,t],{cwd:i,encoding:`utf8`}).status===0?C(_(i,r)):(console.warn(`Could not run cascivo@${n} to rebuild this app's original files; merging against cascivo@${o}'s instead, so its template changes may show up as conflicts.`),S(e,t))}finally{m(i,{recursive:!0,force:!0})}}async function T(n,r,o,d=w){let p=c(l(o,x)),m=s(p);if(m)throw Error(m);let h=e(n,{preferLockfileOverUserAgent:!0}),g=d(r,h),v=[],y=``;for(let{path:e,contents:r}of a({...p,pm:h})){if(e===x){y=r;continue}let a=g.get(e);if(a===r)continue;let o=_(n,e),s=u(o)?f(o,`utf8`):void 0;if(s===r)continue;if(s===void 0||s===a){await t(o,r),v.push({path:e,outcome:`written`});continue}let c=i(a??``,s,r);await t(o,c.text),v.push({path:e,outcome:c.conflicts>0?`conflict`:`merged`})}return await t(_(n,x),y),v}const E=`Usage:
|
|
2
2
|
cascivo app add page "<title>" [--block <name>]
|
|
3
3
|
cascivo app add example <name>
|
|
4
|
-
cascivo app upgrade`;function D(e,t){let[i,a,s]=n(t,[`block`]);if(i===`upgrade`&&a===void 0)return e.cascivo===`1.8.
|
|
5
|
-
//# sourceMappingURL=app-
|
|
4
|
+
cascivo app upgrade`;function D(e,t){let[i,a,s]=n(t,[`block`]);if(i===`upgrade`&&a===void 0)return e.cascivo===`1.8.1`?`Already generated by cascivo@${o}.`:{after:e,done:`Upgraded to cascivo@${o}.`};if(i!==`add`||!s)return E;if(a===`page`){let n=r(t,`block`),i=Array.isArray(e.pages)?e.pages:[];return{after:{...e,pages:[...i,{title:s,...n?{block:n}:{}}]},done:`Added the "${s}" page.`}}if(a===`example`){let t=Array.isArray(e.examples)?e.examples:[];return t.includes(s)?`The app already has the ${s} example.`:{after:{...e,examples:[...t,s]},done:`Added the ${s} example.`}}return E}async function O(e,t=process.cwd()){let n=_(t,x);if(!u(n)){console.error(`No ${x} here. \`cascivo app\` changes apps made with \`cascivo create\`; run it in the app's directory.`),process.exitCode=1;return}let r,i;try{let a=JSON.parse(f(n,`utf8`));if(l(a,x),typeof a!=`object`||!a||Array.isArray(a))throw Error(`${x} must be a JSON object.`);let o=D({...a},e);if(o===E){console.error(E),process.exitCode=1;return}if(typeof o==`string`){console.log(o);return}i=o.done,r=await T(t,a,o.after)}catch(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1;return}console.log(i);for(let e of r){let t=e.outcome===`merged`?` (merged with your edits)`:e.outcome===`conflict`?` — CONFLICT: resolve the <<<<<<< markers`:``;console.log(` ${e.path}${t}`)}r.some(e=>e.outcome===`conflict`)&&(process.exitCode=1)}export{O as app};
|
|
5
|
+
//# sourceMappingURL=app-DGscFgup.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-DDq0Utmj.mjs","names":["detectPackageManager","writeFileSafe","flagValue","merge","CLI_VERSION","BLUEPRINT","scaffoldOf","options","blueprintOptions","parseBlueprint","blueprint","buildScaffold","f","readTree","out","walk","entry","readdirSync","d","full","join","statSync","relative","dir","readFileSync","originalScaffold","version","pm","work","mkdtempSync","tmpdir","writeFileSync","spawnSync","name","rmSync","applyBlueprint","nextOptions","after","problem","optionsError","cwd","base","original","before","changes","path","contents","generated","target","current","existsSync","merged","USAGE","changed","action","kind","value","positionalArgs","args","block","pages","examples","app","file","done","request","change","note","c"],"sources":["../src/commands/app.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process'\nimport {\n existsSync,\n mkdtempSync,\n readFileSync,\n readdirSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { join, relative } from 'node:path'\nimport { CLI_VERSION } from '../generated/versions.js'\nimport { blueprintOptions, parseBlueprint } from '../scaffold/blueprint.js'\nimport { flagValue, positionalArgs } from '../utils/args.js'\nimport { detectPackageManager } from '../utils/config.js'\nimport type { PackageManager } from '../utils/config.js'\nimport { writeFileSafe } from '../utils/fs.js'\nimport { merge } from '../utils/merge.js'\nimport { buildScaffold, optionsError } from './create.js'\n\nconst BLUEPRINT = 'cascivo.app.json'\n\nexport interface AppChange {\n path: string\n /** `written`: new or untouched since it was generated; `merged`: your edits kept. */\n outcome: 'written' | 'merged' | 'conflict'\n}\n\n/** The files a blueprint generates, as `path → contents`. */\nexport type Generate = (blueprint: unknown, pm: PackageManager) => Map<string, string>\n\nfunction scaffoldOf(blueprint: unknown, pm: PackageManager): Map<string, string> {\n const options = { ...blueprintOptions(parseBlueprint(blueprint, BLUEPRINT)), pm }\n return new Map(buildScaffold(options).map((f) => [f.path, f.contents]))\n}\n\n/** Every file under `dir`, relative to it. */\nfunction readTree(dir: string): Map<string, string> {\n const out = new Map<string, string>()\n const walk = (d: string) => {\n for (const entry of readdirSync(d)) {\n const full = join(d, entry)\n if (statSync(full).isDirectory()) walk(full)\n else out.set(relative(dir, full).replaceAll('\\\\', '/'), readFileSync(full, 'utf8'))\n }\n }\n walk(dir)\n return out\n}\n\n/**\n * What the app's own CLI version generated from `blueprint`: the merge base. A newer CLI's\n * templates differ, and merging against them would read every template change as your edit.\n * With no `cascivo` stamp, or the same version, that is this CLI's output; otherwise the\n * recorded version is run (`npx cascivo@<version>`), falling back to this one with a warning.\n */\nexport function originalScaffold(blueprint: unknown, pm: PackageManager): Map<string, string> {\n const { cascivo: version, name } = parseBlueprint(blueprint, BLUEPRINT)\n if (!version || version === CLI_VERSION) return scaffoldOf(blueprint, pm)\n const work = mkdtempSync(join(tmpdir(), 'cascivo-base-'))\n try {\n writeFileSync(join(work, BLUEPRINT), JSON.stringify(blueprint))\n const result = spawnSync(\n 'npx',\n // No name argument: it would override the blueprint's, and every file that spells the\n // app's name would then differ from what was really generated.\n ['-y', `cascivo@${version}`, 'create', '--from', BLUEPRINT, '--pm', pm],\n { cwd: work, encoding: 'utf8' },\n )\n if (result.status === 0) return readTree(join(work, name))\n console.warn(\n `Could not run cascivo@${version} to rebuild this app's original files; merging against ` +\n `cascivo@${CLI_VERSION}'s instead, so its template changes may show up as conflicts.`,\n )\n return scaffoldOf(blueprint, pm)\n } finally {\n rmSync(work, { recursive: true, force: true })\n }\n}\n\n/**\n * Change a blueprint app from `before` to `after`. Every file the new blueprint generates\n * differently from the original is merged three ways: what was generated, what is on disk now,\n * and what this CLI generates from `after`. A file nobody edited is replaced; an edited one\n * keeps the edits; a clash is left with conflict markers. The blueprint is rewritten last,\n * stamped with this CLI's version.\n */\nexport async function applyBlueprint(\n cwd: string,\n before: unknown,\n after: unknown,\n original: Generate = originalScaffold,\n): Promise<AppChange[]> {\n const nextOptions = blueprintOptions(parseBlueprint(after, BLUEPRINT))\n const problem = optionsError(nextOptions)\n if (problem) throw new Error(problem)\n const pm = detectPackageManager(cwd, { preferLockfileOverUserAgent: true })\n const base = original(before, pm)\n\n const changes: AppChange[] = []\n let blueprint = ''\n for (const { path, contents } of buildScaffold({ ...nextOptions, pm })) {\n if (path === BLUEPRINT) {\n blueprint = contents\n continue\n }\n const generated = base.get(path)\n if (generated === contents) continue\n const target = join(cwd, path)\n const current = existsSync(target) ? readFileSync(target, 'utf8') : undefined\n if (current === contents) continue\n if (current === undefined || current === generated) {\n await writeFileSafe(target, contents)\n changes.push({ path, outcome: 'written' })\n continue\n }\n const merged = merge(generated ?? '', current, contents)\n await writeFileSafe(target, merged.text)\n changes.push({ path, outcome: merged.conflicts > 0 ? 'conflict' : 'merged' })\n }\n await writeFileSafe(join(cwd, BLUEPRINT), blueprint)\n return changes\n}\n\nconst USAGE = `Usage:\n cascivo app add page \"<title>\" [--block <name>]\n cascivo app add example <name>\n cascivo app upgrade`\n\n/** The change a command line asks for, as the blueprint after it. */\nfunction changed(\n before: Record<string, unknown>,\n args: string[],\n): { after: Record<string, unknown>; done: string } | string {\n const [action, kind, value] = positionalArgs(args, ['block'])\n if (action === 'upgrade' && kind === undefined) {\n if (before.cascivo === CLI_VERSION) return `Already generated by cascivo@${CLI_VERSION}.`\n return { after: before, done: `Upgraded to cascivo@${CLI_VERSION}.` }\n }\n if (action !== 'add' || !value) return USAGE\n if (kind === 'page') {\n const block = flagValue(args, 'block')\n const pages = Array.isArray(before.pages) ? before.pages : []\n return {\n after: { ...before, pages: [...pages, { title: value, ...(block ? { block } : {}) }] },\n done: `Added the \"${value}\" page.`,\n }\n }\n if (kind === 'example') {\n const examples = Array.isArray(before.examples) ? before.examples : []\n if (examples.includes(value)) return `The app already has the ${value} example.`\n return {\n after: { ...before, examples: [...examples, value] },\n done: `Added the ${value} example.`,\n }\n }\n return USAGE\n}\n\n/** `cascivo app add page|example …` and `cascivo app upgrade`. */\nexport async function app(args: string[], cwd: string = process.cwd()): Promise<void> {\n const file = join(cwd, BLUEPRINT)\n if (!existsSync(file)) {\n console.error(\n `No ${BLUEPRINT} here. \\`cascivo app\\` changes apps made with \\`cascivo create\\`; run it in the app's directory.`,\n )\n process.exitCode = 1\n return\n }\n\n let changes: AppChange[]\n let done: string\n try {\n const before: unknown = JSON.parse(readFileSync(file, 'utf8'))\n parseBlueprint(before, BLUEPRINT) // the app's own blueprint must be valid before it changes\n if (typeof before !== 'object' || before === null || Array.isArray(before)) {\n throw new Error(`${BLUEPRINT} must be a JSON object.`)\n }\n const request = changed({ ...before }, args)\n if (request === USAGE) {\n console.error(USAGE)\n process.exitCode = 1\n return\n }\n if (typeof request === 'string') {\n console.log(request)\n return\n }\n done = request.done\n changes = await applyBlueprint(cwd, before, request.after)\n } catch (e) {\n console.error(e instanceof Error ? e.message : String(e))\n process.exitCode = 1\n return\n }\n\n console.log(done)\n for (const change of changes) {\n const note =\n change.outcome === 'merged'\n ? ' (merged with your edits)'\n : change.outcome === 'conflict'\n ? ' — CONFLICT: resolve the <<<<<<< markers'\n : ''\n console.log(` ${change.path}${note}`)\n }\n if (chang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AAM,EACvE,MAAU,MAAM,GAAGtC,EAAU,wBAAwB,EAEvD,IAAM4D,EAAUZ,EAAQ,CAAE,GAAGV,CAAO,EAAGe,CAAI,EAC3C,GAAIO,IAAYb,EAAO,CACrB,QAAQ,MAAMA,CAAK,EACnB,QAAQ,SAAW,EACnB,MACF,CACA,GAAI,OAAOa,GAAY,SAAU,CAC/B,QAAQ,IAAIA,CAAO,EACnB,MACF,CACA,EAAOA,EAAQ,KACf,EAAU,MAAM9B,EAAeK,EAAKG,EAAQsB,EAAQ,KAAK,CAC3D,OAAS,EAAG,CACV,QAAQ,MAAM,aAAa,MAAQ,EAAE,QAAU,OAAO,CAAC,CAAC,EACxD,QAAQ,SAAW,EACnB,MACF,CAEA,QAAQ,IAAID,CAAI,EAChB,IAAK,IAAME,KAAUtB,EAAS,CAC5B,IAAMuB,EACJD,EAAO,UAAY,SACf,4BACAA,EAAO,UAAY,WACjB,2CACA,GACR,QAAQ,IAAI,KAAKA,EAAO,OAAOC,GAAM,CACvC,CACIvB,EAAQ,KAAM,GAAMwB,EAAE,UAAY,UAAU,IAAG,QAAQ,SAAW,EACxE"}
|
|
1
|
+
{"version":3,"file":"app-DGscFgup.mjs","names":["detectPackageManager","writeFileSafe","flagValue","merge","CLI_VERSION","BLUEPRINT","scaffoldOf","options","blueprintOptions","parseBlueprint","blueprint","buildScaffold","f","readTree","out","walk","entry","readdirSync","d","full","join","statSync","relative","dir","readFileSync","originalScaffold","version","pm","work","mkdtempSync","tmpdir","writeFileSync","spawnSync","name","rmSync","applyBlueprint","nextOptions","after","problem","optionsError","cwd","base","original","before","changes","path","contents","generated","target","current","existsSync","merged","USAGE","changed","action","kind","value","positionalArgs","args","block","pages","examples","app","file","done","request","change","note","c"],"sources":["../src/commands/app.ts"],"sourcesContent":["import { spawnSync } from 'node:child_process'\nimport {\n existsSync,\n mkdtempSync,\n readFileSync,\n readdirSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { join, relative } from 'node:path'\nimport { CLI_VERSION } from '../generated/versions.js'\nimport { blueprintOptions, parseBlueprint } from '../scaffold/blueprint.js'\nimport { flagValue, positionalArgs } from '../utils/args.js'\nimport { detectPackageManager } from '../utils/config.js'\nimport type { PackageManager } from '../utils/config.js'\nimport { writeFileSafe } from '../utils/fs.js'\nimport { merge } from '../utils/merge.js'\nimport { buildScaffold, optionsError } from './create.js'\n\nconst BLUEPRINT = 'cascivo.app.json'\n\nexport interface AppChange {\n path: string\n /** `written`: new or untouched since it was generated; `merged`: your edits kept. */\n outcome: 'written' | 'merged' | 'conflict'\n}\n\n/** The files a blueprint generates, as `path → contents`. */\nexport type Generate = (blueprint: unknown, pm: PackageManager) => Map<string, string>\n\nfunction scaffoldOf(blueprint: unknown, pm: PackageManager): Map<string, string> {\n const options = { ...blueprintOptions(parseBlueprint(blueprint, BLUEPRINT)), pm }\n return new Map(buildScaffold(options).map((f) => [f.path, f.contents]))\n}\n\n/** Every file under `dir`, relative to it. */\nfunction readTree(dir: string): Map<string, string> {\n const out = new Map<string, string>()\n const walk = (d: string) => {\n for (const entry of readdirSync(d)) {\n const full = join(d, entry)\n if (statSync(full).isDirectory()) walk(full)\n else out.set(relative(dir, full).replaceAll('\\\\', '/'), readFileSync(full, 'utf8'))\n }\n }\n walk(dir)\n return out\n}\n\n/**\n * What the app's own CLI version generated from `blueprint`: the merge base. A newer CLI's\n * templates differ, and merging against them would read every template change as your edit.\n * With no `cascivo` stamp, or the same version, that is this CLI's output; otherwise the\n * recorded version is run (`npx cascivo@<version>`), falling back to this one with a warning.\n */\nexport function originalScaffold(blueprint: unknown, pm: PackageManager): Map<string, string> {\n const { cascivo: version, name } = parseBlueprint(blueprint, BLUEPRINT)\n if (!version || version === CLI_VERSION) return scaffoldOf(blueprint, pm)\n const work = mkdtempSync(join(tmpdir(), 'cascivo-base-'))\n try {\n writeFileSync(join(work, BLUEPRINT), JSON.stringify(blueprint))\n const result = spawnSync(\n 'npx',\n // No name argument: it would override the blueprint's, and every file that spells the\n // app's name would then differ from what was really generated.\n ['-y', `cascivo@${version}`, 'create', '--from', BLUEPRINT, '--pm', pm],\n { cwd: work, encoding: 'utf8' },\n )\n if (result.status === 0) return readTree(join(work, name))\n console.warn(\n `Could not run cascivo@${version} to rebuild this app's original files; merging against ` +\n `cascivo@${CLI_VERSION}'s instead, so its template changes may show up as conflicts.`,\n )\n return scaffoldOf(blueprint, pm)\n } finally {\n rmSync(work, { recursive: true, force: true })\n }\n}\n\n/**\n * Change a blueprint app from `before` to `after`. Every file the new blueprint generates\n * differently from the original is merged three ways: what was generated, what is on disk now,\n * and what this CLI generates from `after`. A file nobody edited is replaced; an edited one\n * keeps the edits; a clash is left with conflict markers. The blueprint is rewritten last,\n * stamped with this CLI's version.\n */\nexport async function applyBlueprint(\n cwd: string,\n before: unknown,\n after: unknown,\n original: Generate = originalScaffold,\n): Promise<AppChange[]> {\n const nextOptions = blueprintOptions(parseBlueprint(after, BLUEPRINT))\n const problem = optionsError(nextOptions)\n if (problem) throw new Error(problem)\n const pm = detectPackageManager(cwd, { preferLockfileOverUserAgent: true })\n const base = original(before, pm)\n\n const changes: AppChange[] = []\n let blueprint = ''\n for (const { path, contents } of buildScaffold({ ...nextOptions, pm })) {\n if (path === BLUEPRINT) {\n blueprint = contents\n continue\n }\n const generated = base.get(path)\n if (generated === contents) continue\n const target = join(cwd, path)\n const current = existsSync(target) ? readFileSync(target, 'utf8') : undefined\n if (current === contents) continue\n if (current === undefined || current === generated) {\n await writeFileSafe(target, contents)\n changes.push({ path, outcome: 'written' })\n continue\n }\n const merged = merge(generated ?? '', current, contents)\n await writeFileSafe(target, merged.text)\n changes.push({ path, outcome: merged.conflicts > 0 ? 'conflict' : 'merged' })\n }\n await writeFileSafe(join(cwd, BLUEPRINT), blueprint)\n return changes\n}\n\nconst USAGE = `Usage:\n cascivo app add page \"<title>\" [--block <name>]\n cascivo app add example <name>\n cascivo app upgrade`\n\n/** The change a command line asks for, as the blueprint after it. */\nfunction changed(\n before: Record<string, unknown>,\n args: string[],\n): { after: Record<string, unknown>; done: string } | string {\n const [action, kind, value] = positionalArgs(args, ['block'])\n if (action === 'upgrade' && kind === undefined) {\n if (before.cascivo === CLI_VERSION) return `Already generated by cascivo@${CLI_VERSION}.`\n return { after: before, done: `Upgraded to cascivo@${CLI_VERSION}.` }\n }\n if (action !== 'add' || !value) return USAGE\n if (kind === 'page') {\n const block = flagValue(args, 'block')\n const pages = Array.isArray(before.pages) ? before.pages : []\n return {\n after: { ...before, pages: [...pages, { title: value, ...(block ? { block } : {}) }] },\n done: `Added the \"${value}\" page.`,\n }\n }\n if (kind === 'example') {\n const examples = Array.isArray(before.examples) ? before.examples : []\n if (examples.includes(value)) return `The app already has the ${value} example.`\n return {\n after: { ...before, examples: [...examples, value] },\n done: `Added the ${value} example.`,\n }\n }\n return USAGE\n}\n\n/** `cascivo app add page|example …` and `cascivo app upgrade`. */\nexport async function app(args: string[], cwd: string = process.cwd()): Promise<void> {\n const file = join(cwd, BLUEPRINT)\n if (!existsSync(file)) {\n console.error(\n `No ${BLUEPRINT} here. \\`cascivo app\\` changes apps made with \\`cascivo create\\`; run it in the app's directory.`,\n )\n process.exitCode = 1\n return\n }\n\n let changes: AppChange[]\n let done: string\n try {\n const before: unknown = JSON.parse(readFileSync(file, 'utf8'))\n parseBlueprint(before, BLUEPRINT) // the app's own blueprint must be valid before it changes\n if (typeof before !== 'object' || before === null || Array.isArray(before)) {\n throw new Error(`${BLUEPRINT} must be a JSON object.`)\n }\n const request = changed({ ...before }, args)\n if (request === USAGE) {\n console.error(USAGE)\n process.exitCode = 1\n return\n }\n if (typeof request === 'string') {\n console.log(request)\n return\n }\n done = request.done\n changes = await applyBlueprint(cwd, before, request.after)\n } catch (e) {\n console.error(e instanceof Error ? e.message : String(e))\n process.exitCode = 1\n return\n }\n\n console.log(done)\n for (const change of changes) {\n const note =\n change.outcome === 'merged'\n ? ' (merged with your edits)'\n : change.outcome === 'conflict'\n ? ' — CONFLICT: resolve the <<<<<<< markers'\n : ''\n console.log(` ${change.path}${note}`)\n }\n if (changes.some((c) => c.outcome === 'conflict')) process.exitCode = 1\n}\n"],"mappings":"ukBAqBA,MAAMK,EAAY,mBAWlB,SAASC,EAAW,EAAoB,EAAyC,CAC/E,IAAMC,EAAU,CAAE,GAAGC,EAAiBC,EAAeC,EAAWL,CAAS,CAAC,EAAG,IAAG,EAChF,OAAO,IAAI,IAAIM,EAAcJ,CAAO,CAAC,CAAC,IAAK,GAAM,CAACK,EAAE,KAAMA,EAAE,QAAQ,CAAC,CAAC,CACxE,CAGA,SAASC,EAAS,EAAkC,CAClD,IAAMC,kBAAM,IAAI,IACVC,EAAQ,GAAc,CAC1B,IAAK,IAAMC,KAASC,EAAYC,CAAC,EAAG,CAClC,IAAMC,EAAOC,EAAKF,EAAGF,CAAK,EACtBK,EAASF,CAAI,CAAC,CAAC,YAAY,EAAGJ,EAAKI,CAAI,EACtCL,EAAI,IAAIQ,EAASC,EAAKJ,CAAI,CAAC,CAAC,WAAW,KAAM,GAAG,EAAGK,EAAaL,EAAM,MAAM,CAAC,CACpF,CACF,EAEA,OADAJ,EAAKQ,CAAG,EACDT,CACT,CAQA,SAAgBW,EAAiB,EAAoB,EAAyC,CAC5F,GAAM,CAAE,QAASC,EAAS,QAASjB,EAAeC,EAAWL,CAAS,EACtE,GAAI,CAACqB,GAAWA,IAAA,QAAyB,OAAOpB,EAAWI,EAAWiB,CAAE,EACxE,IAAMC,EAAOC,EAAYT,EAAKU,EAAO,EAAG,eAAe,CAAC,EACxD,GAAI,CAcF,OAbAC,EAAcX,EAAKQ,EAAMvB,CAAS,EAAG,KAAK,UAAUK,CAAS,CAAC,EAC/CsB,EACb,MAGA,CAAC,KAAM,WAAWN,IAAW,SAAU,SAAUrB,EAAW,OAAQsB,CAAE,EACtE,CAAE,IAAKC,EAAM,SAAU,MAAO,CAEvB,CAAC,CAAC,SAAW,EAAUf,EAASO,EAAKQ,EAAMK,CAAI,CAAC,GACzD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C,CAAS,EAC5B,OAAOsC,GAAW,WAAYA,GAAmB,MAAM,QAAQA,CAAM,EACvE,MAAU,MAAM,GAAGtC,EAAU,wBAAwB,EAEvD,IAAM4D,EAAUZ,EAAQ,CAAE,GAAGV,CAAO,EAAGe,CAAI,EAC3C,GAAIO,IAAYb,EAAO,CACrB,QAAQ,MAAMA,CAAK,EACnB,QAAQ,SAAW,EACnB,MACF,CACA,GAAI,OAAOa,GAAY,SAAU,CAC/B,QAAQ,IAAIA,CAAO,EACnB,MACF,CACA,EAAOA,EAAQ,KACf,EAAU,MAAM9B,EAAeK,EAAKG,EAAQsB,EAAQ,KAAK,CAC3D,OAAS,EAAG,CACV,QAAQ,MAAM,aAAa,MAAQ,EAAE,QAAU,OAAO,CAAC,CAAC,EACxD,QAAQ,SAAW,EACnB,MACF,CAEA,QAAQ,IAAID,CAAI,EAChB,IAAK,IAAME,KAAUtB,EAAS,CAC5B,IAAMuB,EACJD,EAAO,UAAY,SACf,4BACAA,EAAO,UAAY,WACjB,2CACA,GACR,QAAQ,IAAI,KAAKA,EAAO,OAAOC,GAAM,CACvC,CACIvB,EAAQ,KAAM,GAAMwB,EAAE,UAAY,UAAU,IAAG,QAAQ,SAAW,EACxE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./config-CTk7uDrh.mjs";import{EXAMPLES as t,FRAMEWORKS as n,RUNTIMES as r,isExample as i,isRuntime as a,parseAuth as o,t as s}from"./create-
|
|
2
|
-
//# sourceMappingURL=blueprint-
|
|
1
|
+
import{r as e}from"./config-CTk7uDrh.mjs";import{EXAMPLES as t,FRAMEWORKS as n,RUNTIMES as r,isExample as i,isRuntime as a,parseAuth as o,t as s}from"./create-BRCCjfRB.mjs";const c=/* @__PURE__ */ new Set([`$schema`,`name`,`framework`,`theme`,`pages`,`runtime`,`examples`,`auth`,`cascivo`]);function l(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function u(e,t,n,r){if(typeof e==`string`&&t.includes(e))return e;throw Error(`${r}: "${n}" must be one of: ${t.join(`, `)}.`)}function d(d,f){if(!l(d))throw Error(`${f}: a blueprint must be a JSON object.`);let p=Object.keys(d).filter(e=>!c.has(e));if(p.length>0)throw Error(`${f}: unknown field ${p.map(e=>`"${e}"`).join(`, `)}. Fields: ${[...c].slice(1).join(`, `)}.`);let{name:m,framework:h=`react-vite`,theme:g=`light`,pages:_,runtime:v,examples:y,auth:b}=d;if(typeof m!=`string`||m.trim()===``||/[/\\\u0000-\u001f]/.test(m)||/^\.+$/.test(m.trim()))throw Error(`${f}: "name" must be a project directory name, not a path.`);let x={name:m,framework:u(h,n,`framework`,f),theme:u(g,e,`theme`,f),pages:[]};if(!Array.isArray(_)||_.length===0)throw Error(`${f}: "pages" must be a non-empty array of { "title", "block"? }.`);let S=s();for(let[e,t]of _.entries()){if(!l(t)||typeof t.title!=`string`||t.title.trim()===``)throw Error(`${f}: pages[${e}] needs a non-empty "title".`);let n=Object.keys(t).filter(e=>e!==`title`&&e!==`block`);if(n.length>0)throw Error(`${f}: pages[${e}] has unknown field "${n[0]}". Fields: title, block.`);let{block:r}=t;if(r!==void 0&&(typeof r!=`string`||!S.includes(r)))throw Error(`${f}: pages[${e}].block ${JSON.stringify(r)} is not a block. Blocks: ${S.join(`, `)}.`);x.pages.push({title:t.title,...r===void 0?{}:{block:r}})}if(x.framework===`astro`&&x.pages.some(e=>e.block))throw Error(`${f}: blocks need "framework" react-vite or cloudflare.`);if(v!==void 0){if(typeof v!=`string`||!a(v))throw Error(`${f}: "runtime" must be one of: ${r.join(`, `)}.`);x.runtime=v}if(y!==void 0){let e=Array.isArray(y)?y.filter(e=>typeof e==`string`&&i(e)):[];if(!Array.isArray(y)||e.length!==y.length)throw Error(`${f}: "examples" must be an array of: ${t.join(`, `)}.`);x.examples=e}if(b!==void 0){let e=o(typeof b==`string`?b:void 0);if(e===null||e===`invalid`)throw Error(`${f}: "auth" must be one of: access, email, oauth, email,oauth.`);x.auth=e}if(d.cascivo!==void 0){if(typeof d.cascivo!=`string`||!/^\d+\.\d+\.\d+(-[\w.]+)?$/.test(d.cascivo))throw Error(`${f}: "cascivo" must be the version of the CLI that generated the app.`);x.cascivo=d.cascivo}return x}function f(e){return{name:e.name,framework:e.framework,theme:e.theme,sections:e.pages.map(e=>e.title),blocks:e.pages.map(e=>e.block),...e.runtime?{runtime:e.runtime}:{},...e.examples?{examples:e.examples}:{},...e.auth?{auth:e.auth}:{}}}export{f as blueprintOptions,d as parseBlueprint};
|
|
2
|
+
//# sourceMappingURL=blueprint-BTogmP-c.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blueprint-
|
|
1
|
+
{"version":3,"file":"blueprint-BTogmP-c.mjs","names":["THEMES","blockNames","KEYS","isRecord","value","oneOf","allowed","source","field","parseBlueprint","raw","unknown","key","k","name","blueprint","framework","FRAMEWORKS","theme","pages","blocks","i","page","extra","block","p","runtime","isRuntime","RUNTIMES","examples","valid","isExample","EXAMPLES","auth","parsed","parseAuth","blueprintOptions"],"sources":["../src/scaffold/blueprint.ts"],"sourcesContent":["import { THEMES } from '../utils/config.js'\nimport type { ThemeName } from '../utils/config.js'\nimport {\n EXAMPLES,\n FRAMEWORKS,\n RUNTIMES,\n isExample,\n isRuntime,\n parseAuth,\n} from '../commands/create.js'\nimport type { Auth, Example, Framework, Runtime, ScaffoldOptions } from '../commands/create.js'\nimport { blockNames } from './recipes.js'\n\n/**\n * A blueprint (`cascivo.app.json`) describes an app in the vocabulary of `cascivo create`'s\n * flags, plus one thing the flags cannot say: which registry block each page renders. An\n * agent writes a few hundred bytes of it instead of the app's source; the CLI compiles it.\n */\nexport interface Blueprint {\n name: string\n framework: Framework\n theme: ThemeName\n pages: BlueprintPage[]\n runtime?: Runtime\n examples?: Example[]\n auth?: Auth\n /** The CLI version that generated the app; `cascivo app` rebuilds its merge base with it. */\n cascivo?: string\n}\n\nexport interface BlueprintPage {\n /** The nav label and page heading. The first page is the app's home (`/`). */\n title: string\n /** A block from `blockNames()`; without one the page is a placeholder to build out. */\n block?: string\n}\n\nconst KEYS = new Set([\n '$schema',\n 'name',\n 'framework',\n 'theme',\n 'pages',\n 'runtime',\n 'examples',\n 'auth',\n 'cascivo',\n])\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction oneOf<T extends string>(\n value: unknown,\n allowed: readonly T[],\n field: string,\n source: string,\n): T {\n if (typeof value === 'string' && (allowed as readonly string[]).includes(value)) return value as T\n throw new Error(`${source}: \"${field}\" must be one of: ${allowed.join(', ')}.`)\n}\n\n/** Parse a blueprint. `source` names the file in errors; every error names the field. */\nexport function parseBlueprint(raw: unknown, source: string): Blueprint {\n if (!isRecord(raw)) throw new Error(`${source}: a blueprint must be a JSON object.`)\n const unknown = Object.keys(raw).filter((key) => !KEYS.has(key))\n if (unknown.length > 0) {\n throw new Error(\n `${source}: unknown field ${unknown.map((k) => `\"${k}\"`).join(', ')}. Fields: ${[...KEYS].slice(1).join(', ')}.`,\n )\n }\n const { name, framework = 'react-vite', theme = 'light', pages, runtime, examples, auth } = raw\n // The name becomes the directory the app is written to, so it must stay one plain segment:\n // no separators, no control characters, not \".\" or \"..\".\n // eslint-disable-next-line no-control-regex -- control characters are exactly what it rejects\n const unsafe = /[/\\\\\\u0000-\\u001f]/\n if (\n typeof name !== 'string' ||\n name.trim() === '' ||\n unsafe.test(name) ||\n /^\\.+$/.test(name.trim())\n ) {\n throw new Error(`${source}: \"name\" must be a project directory name, not a path.`)\n }\n const blueprint: Blueprint = {\n name,\n framework: oneOf(framework, FRAMEWORKS, 'framework', source),\n theme: oneOf(theme, THEMES, 'theme', source),\n pages: [],\n }\n\n if (!Array.isArray(pages) || pages.length === 0) {\n throw new Error(`${source}: \"pages\" must be a non-empty array of { \"title\", \"block\"? }.`)\n }\n const blocks = blockNames()\n for (const [i, page] of pages.entries()) {\n if (!isRecord(page) || typeof page.title !== 'string' || page.title.trim() === '') {\n throw new Error(`${source}: pages[${i}] needs a non-empty \"title\".`)\n }\n const extra = Object.keys(page).filter((key) => key !== 'title' && key !== 'block')\n if (extra.length > 0) {\n throw new Error(\n `${source}: pages[${i}] has unknown field \"${extra[0]}\". Fields: title, block.`,\n )\n }\n const { block } = page\n if (block !== undefined && (typeof block !== 'string' || !blocks.includes(block))) {\n throw new Error(\n `${source}: pages[${i}].block ${JSON.stringify(block)} is not a block. Blocks: ${blocks.join(', ')}.`,\n )\n }\n blueprint.pages.push({ title: page.title, ...(block !== undefined ? { block } : {}) })\n }\n if (blueprint.framework === 'astro' && blueprint.pages.some((p) => p.block)) {\n throw new Error(`${source}: blocks need \"framework\" react-vite or cloudflare.`)\n }\n\n if (runtime !== undefined) {\n if (typeof runtime !== 'string' || !isRuntime(runtime)) {\n throw new Error(`${source}: \"runtime\" must be one of: ${RUNTIMES.join(', ')}.`)\n }\n blueprint.runtime = runtime\n }\n if (examples !== undefined) {\n const valid = Array.isArray(examples)\n ? examples.filter((e): e is Example => typeof e === 'string' && isExample(e))\n : []\n if (!Array.isArray(examples) || valid.length !== examples.length) {\n throw new Error(`${source}: \"examples\" must be an array of: ${EXAMPLES.join(', ')}.`)\n }\n blueprint.examples = valid\n }\n if (auth !== undefined) {\n const parsed = parseAuth(typeof auth === 'string' ? auth : undefined)\n if (parsed === null || parsed === 'invalid') {\n throw new Error(`${source}: \"auth\" must be one of: access, email, oauth, email,oauth.`)\n }\n blueprint.auth = parsed\n }\n if (raw.cascivo !== undefined) {\n if (typeof raw.cascivo !== 'string' || !/^\\d+\\.\\d+\\.\\d+(-[\\w.]+)?$/.test(raw.cascivo)) {\n throw new Error(`${source}: \"cascivo\" must be the version of the CLI that generated the app.`)\n }\n blueprint.cascivo = raw.cascivo\n }\n return blueprint\n}\n\n/** The scaffold a blueprint compiles to. */\nexport function blueprintOptions(blueprint: Blueprint): Omit<ScaffoldOptions, 'pm'> {\n return {\n name: blueprint.name,\n framework: blueprint.framework,\n theme: blueprint.theme,\n sections: blueprint.pages.map((p) => p.title),\n blocks: blueprint.pages.map((p) => p.block),\n ...(blueprint.runtime ? { runtime: blueprint.runtime } : {}),\n ...(blueprint.examples ? { examples: blueprint.examples } : {}),\n ...(blueprint.auth ? { auth: blueprint.auth } : {}),\n }\n}\n"],"mappings":"6KAqCA,MAAME,kBAAO,IAAI,IAAI,CACnB,UACA,OACA,YACA,QACA,QACA,UACA,WACA,OACA,SACF,CAAC,EAED,SAASC,EAAS,EAAkD,CAClE,OAAO,OAAOC,GAAU,YAAYA,GAAkB,CAAC,MAAM,QAAQA,CAAK,CAC5E,CAEA,SAASC,EACP,EACA,EACA,EACA,EACG,CACH,GAAI,OAAOD,GAAU,UAAaE,EAA8B,SAASF,CAAK,EAAG,OAAOA,EACxF,MAAU,MAAM,GAAGG,EAAO,KAAKC,EAAM,oBAAoBF,EAAQ,KAAK,IAAI,EAAE,EAAE,CAChF,CAGA,SAAgBG,EAAe,EAAc,EAA2B,CACtE,GAAI,CAACN,EAASO,CAAG,EAAG,MAAU,MAAM,GAAGH,EAAO,qCAAqC,EACnF,IAAMI,EAAU,OAAO,KAAKD,CAAG,CAAC,CAAC,OAAQ,GAAQ,CAACR,EAAK,IAAIU,CAAG,CAAC,EAC/D,GAAID,EAAQ,OAAS,EACnB,MAAU,MACR,GAAGJ,EAAO,kBAAkBI,EAAQ,IAAK,GAAM,IAAIE,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,YAAY,CAAC,GAAGX,CAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,EAChH,EAEF,GAAM,CAAE,OAAM,YAAY,aAAc,QAAQ,QAAS,QAAO,UAAS,WAAU,QAASQ,EAK5F,GACE,OAAOI,GAAS,UAChBA,EAAK,KAAK,IAAM,IAChB,qBAAO,KAAKA,CAAI,GAChB,QAAQ,KAAKA,EAAK,KAAK,CAAC,EAExB,MAAU,MAAM,GAAGP,EAAO,uDAAuD,EAEnF,IAAMQ,EAAuB,CAC3B,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|
4
4
|
"info": {
|
|
5
5
|
"name": "cascivo",
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.1",
|
|
7
7
|
"summary": "Add, update and audit cascivo components in your project",
|
|
8
8
|
"description": "The cascivo CLI. Components are copied into your project as source you own (the shadcn model); the CLI resolves their dependencies, installs the runtime packages they need, and checks your code against the cascivo contract.\n\nRun it without installing: `npx cascivo <command>`.",
|
|
9
9
|
"homepage": "https://cascivo.com",
|