cascivo 1.7.0 → 1.8.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 +1 -0
- package/dist/app-DDq0Utmj.mjs +5 -0
- package/dist/app-DDq0Utmj.mjs.map +1 -0
- package/dist/{args-DEL5BZq7.mjs → args-B4PN85cC.mjs} +2 -2
- package/dist/{args-DEL5BZq7.mjs.map → args-B4PN85cC.mjs.map} +1 -1
- package/dist/blueprint-eOLGuyAi.mjs +2 -0
- package/dist/blueprint-eOLGuyAi.mjs.map +1 -0
- package/dist/cmdspec.json +107 -2
- package/dist/config-CTk7uDrh.mjs +2 -0
- package/dist/config-CTk7uDrh.mjs.map +1 -0
- package/dist/create-BA9GQ8nl.mjs +1991 -0
- package/dist/create-BA9GQ8nl.mjs.map +1 -0
- package/dist/{email-BzLRydvR.mjs → email-Drn2bDlp.mjs} +2 -2
- package/dist/{email-BzLRydvR.mjs.map → email-Drn2bDlp.mjs.map} +1 -1
- package/dist/generated/audit-contract.json +38 -38
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +64 -49
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-CqX_Yi06.mjs +2 -0
- package/dist/mcp-CqX_Yi06.mjs.map +1 -0
- package/dist/merge-D332dc_m.mjs +8 -0
- package/dist/merge-D332dc_m.mjs.map +1 -0
- package/dist/rolldown-runtime-DT7IzrpZ.mjs +1 -0
- package/package.json +5 -4
- package/readme.body.md +1 -0
- package/recipes/README.md +21 -0
- package/recipes/accounts/recipe.json +12 -0
- package/recipes/accounts/src/auth.ts +7 -0
- package/recipes/agent/recipe.json +16 -0
- package/recipes/agent/src/assistant.module.css +33 -0
- package/recipes/agent/src/assistant.ts +26 -0
- package/recipes/agent/src/routes/assistant.tsx +130 -0
- package/recipes/agent/worker/assistant.ts +55 -0
- package/recipes/agent/worker/scripted-model.ts +102 -0
- package/recipes/auth-email/recipe.json +7 -0
- package/recipes/auth-email/src/routes/signin/verify.tsx +50 -0
- package/recipes/auth-email/worker/auth.ts +37 -0
- package/recipes/billing/recipe.json +14 -0
- package/recipes/billing/src/billing.ts +90 -0
- package/recipes/billing/src/routes/billing.tsx +150 -0
- package/recipes/billing/worker/billing.ts +325 -0
- package/recipes/block-auth-login/recipe.json +7 -0
- package/recipes/block-auth-login/src/blocks/auth-login.module.css +86 -0
- package/recipes/block-auth-login/src/blocks/auth-login.tsx +80 -0
- package/recipes/block-auth-signup/recipe.json +7 -0
- package/recipes/block-auth-signup/src/blocks/auth-signup.module.css +80 -0
- package/recipes/block-auth-signup/src/blocks/auth-signup.tsx +118 -0
- package/recipes/block-dashboard-charts/recipe.json +9 -0
- package/recipes/block-dashboard-charts/src/blocks/dashboard-charts.tsx +80 -0
- package/recipes/block-dashboard-overview/recipe.json +7 -0
- package/recipes/block-dashboard-overview/src/blocks/dashboard-overview.module.css +83 -0
- package/recipes/block-dashboard-overview/src/blocks/dashboard-overview.tsx +53 -0
- package/recipes/block-dashboard-table/recipe.json +7 -0
- package/recipes/block-dashboard-table/src/blocks/dashboard-table.module.css +74 -0
- package/recipes/block-dashboard-table/src/blocks/dashboard-table.tsx +203 -0
- package/recipes/block-empty-dashboard/recipe.json +6 -0
- package/recipes/block-empty-dashboard/src/blocks/empty-dashboard.tsx +20 -0
- package/recipes/block-faq/recipe.json +7 -0
- package/recipes/block-faq/src/blocks/faq.module.css +35 -0
- package/recipes/block-faq/src/blocks/faq.tsx +55 -0
- package/recipes/block-login-page/recipe.json +6 -0
- package/recipes/block-login-page/src/blocks/login-page.tsx +51 -0
- package/recipes/block-marketing-features/recipe.json +7 -0
- package/recipes/block-marketing-features/src/blocks/marketing-features.module.css +77 -0
- package/recipes/block-marketing-features/src/blocks/marketing-features.tsx +71 -0
- package/recipes/block-marketing-hero/recipe.json +7 -0
- package/recipes/block-marketing-hero/src/blocks/marketing-hero.module.css +51 -0
- package/recipes/block-marketing-hero/src/blocks/marketing-hero.tsx +38 -0
- package/recipes/block-notification-center/recipe.json +6 -0
- package/recipes/block-notification-center/src/blocks/notification-center.tsx +62 -0
- package/recipes/block-page-with-breadcrumb/recipe.json +6 -0
- package/recipes/block-page-with-breadcrumb/src/blocks/page-with-breadcrumb.tsx +23 -0
- package/recipes/block-pricing/recipe.json +7 -0
- package/recipes/block-pricing/src/blocks/pricing.module.css +102 -0
- package/recipes/block-pricing/src/blocks/pricing.tsx +90 -0
- package/recipes/block-settings-form-page/recipe.json +6 -0
- package/recipes/block-settings-form-page/src/blocks/settings-form-page.tsx +85 -0
- package/recipes/block-settings-profile/recipe.json +7 -0
- package/recipes/block-settings-profile/src/blocks/settings-profile.module.css +92 -0
- package/recipes/block-settings-profile/src/blocks/settings-profile.tsx +127 -0
- package/recipes/block-site-footer/recipe.json +7 -0
- package/recipes/block-site-footer/src/blocks/site-footer.module.css +83 -0
- package/recipes/block-site-footer/src/blocks/site-footer.tsx +72 -0
- package/recipes/block-stats-cards/recipe.json +6 -0
- package/recipes/block-stats-cards/src/blocks/stats-cards.tsx +49 -0
- package/recipes/block-testimonials/recipe.json +7 -0
- package/recipes/block-testimonials/src/blocks/testimonials.module.css +67 -0
- package/recipes/block-testimonials/src/blocks/testimonials.tsx +57 -0
- package/recipes/block-users-table-page/recipe.json +6 -0
- package/recipes/block-users-table-page/src/blocks/users-table-page.tsx +60 -0
- package/recipes/board/recipe.json +14 -0
- package/recipes/board/src/board.module.css +40 -0
- package/recipes/board/src/board.ts +51 -0
- package/recipes/board/src/routes/board.tsx +124 -0
- package/recipes/checkout/recipe.json +15 -0
- package/recipes/checkout/src/checkout.ts +93 -0
- package/recipes/checkout/src/routes/checkout/[order].tsx +131 -0
- package/recipes/checkout/src/routes/checkout.tsx +70 -0
- package/recipes/checkout/worker/checkout.ts +357 -0
- package/recipes/cloudflare/recipe.json +10 -0
- package/recipes/cloudflare/src/LiveCard.tsx +55 -0
- package/recipes/cloudflare/src/live.ts +43 -0
- package/recipes/cloudflare/src/main.tsx +17 -0
- package/recipes/cloudflare/src/router.ts +6 -0
- package/recipes/cloudflare/src/routes/404.tsx +5 -0
- package/recipes/crud/recipe.json +16 -0
- package/recipes/crud/src/customers-page.ts +55 -0
- package/recipes/crud/src/customers.ts +76 -0
- package/recipes/crud/src/routes/customers.tsx +180 -0
- package/recipes/crud/worker/customers.ts +69 -0
- package/recipes/crud/worker/migrations.ts +50 -0
- package/recipes/digest/recipe.json +14 -0
- package/recipes/digest/src/digest.ts +47 -0
- package/recipes/digest/src/routes/digest.tsx +82 -0
- package/recipes/digest/worker/digest.ts +129 -0
- package/recipes/export/recipe.json +12 -0
- package/recipes/export/src/routes/report.tsx +68 -0
- package/recipes/files/recipe.json +15 -0
- package/recipes/files/src/files.module.css +16 -0
- package/recipes/files/src/files.ts +37 -0
- package/recipes/files/src/routes/files.tsx +81 -0
- package/recipes/files/src/upload-policy.ts +12 -0
- package/recipes/import/recipe.json +15 -0
- package/recipes/import/src/import-job.ts +60 -0
- package/recipes/import/src/import-page.ts +36 -0
- package/recipes/import/src/routes/import.tsx +112 -0
- package/recipes/import/worker/import-job.ts +86 -0
- package/recipes/live/recipe.json +13 -0
- package/recipes/live/src/ops.ts +22 -0
- package/recipes/live/src/routes/ops.tsx +123 -0
- package/recipes/newsletter/recipe.json +22 -0
- package/recipes/newsletter/src/newsletter.ts +139 -0
- package/recipes/newsletter/src/routes/newsletter/confirm.tsx +58 -0
- package/recipes/newsletter/src/routes/newsletter/send.tsx +192 -0
- package/recipes/newsletter/src/routes/newsletter/unsubscribe.tsx +56 -0
- package/recipes/newsletter/src/routes/newsletter.tsx +82 -0
- package/recipes/newsletter/worker/newsletter-email.ts +90 -0
- package/recipes/newsletter/worker/newsletter.ts +455 -0
- package/recipes/notes/recipe.json +13 -0
- package/recipes/notes/src/notes.ts +61 -0
- package/recipes/notes/src/routes/notes.tsx +76 -0
- package/recipes/publish/recipe.json +16 -0
- package/recipes/publish/src/pages.ts +72 -0
- package/recipes/publish/src/routes/p/[slug].tsx +50 -0
- package/recipes/publish/src/routes/publish.tsx +160 -0
- package/recipes/publish/worker/page-html.ts +126 -0
- package/recipes/publish/worker/pages.ts +65 -0
- package/recipes/publish-preview/recipe.json +6 -0
- package/recipes/publish-preview/worker/page-preview.ts +57 -0
- package/recipes/search/recipe.json +15 -0
- package/recipes/search/src/routes/search.tsx +128 -0
- package/recipes/search/src/search.ts +64 -0
- package/recipes/search/worker/articles.ts +126 -0
- package/recipes/search/worker/search.ts +146 -0
- package/recipes/social/recipe.json +15 -0
- package/recipes/social/src/routes/social.tsx +456 -0
- package/recipes/social/src/social.ts +349 -0
- package/recipes/social/worker/social-post.ts +199 -0
- package/recipes/social/worker/social.ts +719 -0
- package/recipes/usage/recipe.json +14 -0
- package/recipes/usage/src/routes/usage.tsx +88 -0
- package/recipes/usage/src/usage.ts +61 -0
- package/recipes/usage/worker/usage.ts +75 -0
- package/recipes/voice/recipe.json +15 -0
- package/recipes/voice/src/routes/voice.tsx +117 -0
- package/recipes/voice/src/voice.ts +91 -0
- package/recipes/voice/worker/scripted-voice.ts +46 -0
- package/recipes/voice/worker/voice.ts +64 -0
- package/recipes/webhooks/recipe.json +14 -0
- package/recipes/webhooks/src/routes/webhooks.tsx +106 -0
- package/recipes/webhooks/src/webhooks.ts +43 -0
- package/recipes/webhooks/worker/webhooks.ts +118 -0
- package/dist/config-CpoAu8C-.mjs +0 -2
- package/dist/config-CpoAu8C-.mjs.map +0 -1
- package/dist/create-BcfPWm1F.mjs +0 -9976
- package/dist/create-BcfPWm1F.mjs.map +0 -1
- package/dist/mcp-jwnfOQIt.mjs +0 -2
- package/dist/mcp-jwnfOQIt.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ npx cascivo create my-app # scaffold a full app — Vite + React, app s
|
|
|
24
24
|
npx cascivo create my-app --framework astro # …as an Astro site instead (file routing, zero-JS pages)
|
|
25
25
|
npx cascivo create my-app --framework cloudflare # …as a client app + API on one Cloudflare Worker
|
|
26
26
|
npx cascivo create my-app --template owner/repo/dashboard # …and start from a template
|
|
27
|
+
npx cascivo create --from cascivo.app.json # …from a blueprint: pages that render registry blocks
|
|
27
28
|
npx cascivo init # scaffold cascivo.config.ts + tokens; detects your package manager
|
|
28
29
|
cascivo add button card # copy component source from the registry into your project
|
|
29
30
|
cascivo add owner/repo/button # install from any third-party registry
|
|
@@ -0,0 +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-BA9GQ8nl.mjs";import{blueprintOptions as c,parseBlueprint as l}from"./blueprint-eOLGuyAi.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.0`)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
|
+
cascivo app add page "<title>" [--block <name>]
|
|
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.0`?`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-DDq0Utmj.mjs.map
|
|
@@ -0,0 +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 (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,OAD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M,GAAMwB,EAAE,UAAY,UAAU,IAAG,QAAQ,SAAW,EACxE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as e}from"./config-
|
|
2
|
-
//# sourceMappingURL=args-
|
|
1
|
+
import{c as e}from"./config-CTk7uDrh.mjs";function t(e,t){let n=e.find(e=>e.startsWith(`--${t}=`));if(n)return n.slice(t.length+3);let r=e.indexOf(`--${t}`),i=r===-1?void 0:e[r+1];return i&&!i.startsWith(`--`)?i:void 0}function n(e,t=[]){let n=[];for(let r=0;r<e.length;r++){let i=e[r];if(i.startsWith(`-`)){let n=i.replace(/^--?/,``).split(`=`)[0],a=e[r+1];t.includes(n)&&!i.includes(`=`)&&a!==void 0&&!a.startsWith(`-`)&&r++;continue}n.push(i)}return n}function r(n){let r=t(n,`package-manager`)??t(n,`pm`);return r===void 0?{pm:void 0}:e(r)?{pm:r}:{error:`Unknown package manager "${r}". Use one of: pnpm, yarn, npm, bun.`}}export{n,r,t};
|
|
2
|
+
//# sourceMappingURL=args-B4PN85cC.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args-
|
|
1
|
+
{"version":3,"file":"args-B4PN85cC.mjs","names":["isPackageManager","flagValue","eq","args","a","key","idx","next","positionalArgs","out","i","token","valueFlags","resolvePackageManagerFlag","raw"],"sources":["../src/utils/args.ts"],"sourcesContent":["import { isPackageManager, type PackageManager } from './config.js'\n\n/**\n * Read `--key value` or `--key=value` from an argv slice. Ignores a following\n * token that is itself a flag (so `--tokens --dry-run` yields undefined, not\n * `--dry-run`).\n */\nexport function flagValue(args: string[], key: string): string | undefined {\n const eq = args.find((a) => a.startsWith(`--${key}=`))\n if (eq) return eq.slice(key.length + 3)\n const idx = args.indexOf(`--${key}`)\n const next = idx !== -1 ? args[idx + 1] : undefined\n return next && !next.startsWith('--') ? next : undefined\n}\n\n/**\n * Extract positional (non-flag) arguments from an argv slice. Any token starting\n * with `-` is dropped, as is the value token immediately following a flag named\n * in `valueFlags` (e.g. `pnpm` in `--pm pnpm`), so component names never pick up\n * a flag or its value.\n */\nexport function positionalArgs(args: string[], valueFlags: string[] = []): string[] {\n const out: string[] = []\n for (let i = 0; i < args.length; i++) {\n const token = args[i]!\n if (token.startsWith('-')) {\n const key = token.replace(/^--?/, '').split('=')[0]!\n const next = args[i + 1]\n if (\n valueFlags.includes(key) &&\n !token.includes('=') &&\n next !== undefined &&\n !next.startsWith('-')\n ) {\n i++ // skip the flag's value token\n }\n continue\n }\n out.push(token)\n }\n return out\n}\n\n/**\n * Resolve the `--package-manager` / `--pm` flag to a validated PackageManager.\n * Absent flag → `{ pm: undefined }` (fall back to auto-detection). Unknown value\n * → `{ error }` so the caller can print it and exit non-zero.\n */\nexport function resolvePackageManagerFlag(\n args: string[],\n): { pm: PackageManager | undefined } | { error: string } {\n const raw = flagValue(args, 'package-manager') ?? flagValue(args, 'pm')\n if (raw === undefined) return { pm: undefined }\n if (isPackageManager(raw)) return { pm: raw }\n return { error: `Unknown package manager \"${raw}\". Use one of: pnpm, yarn, npm, bun.` }\n}\n"],"mappings":"0CAOA,SAAgBC,EAAU,EAAgB,EAAiC,CACzE,IAAMC,EAAKC,EAAK,KAAM,GAAMC,EAAE,WAAW,KAAKC,EAAI,EAAE,CAAC,EACrD,GAAIH,EAAI,OAAOA,EAAG,MAAMG,EAAI,OAAS,CAAC,EACtC,IAAMC,EAAMH,EAAK,QAAQ,KAAKE,GAAK,EAC7BE,EAAOD,IAAQ,GAAqB,IAAA,GAAhBH,EAAKG,EAAM,GACrC,OAAOC,GAAQ,CAACA,EAAK,WAAW,IAAI,EAAIA,EAAO,IAAA,EACjD,CAQA,SAAgBC,EAAe,EAAgB,EAAuB,CAAC,EAAa,CAClF,IAAMC,EAAgB,CAAC,EACvB,IAAK,IAAIC,EAAI,EAAGA,EAAIP,EAAK,OAAQ,IAAK,CACpC,IAAMQ,EAAQR,EAAKO,GACnB,GAAIC,EAAM,WAAW,GAAG,EAAG,CACzB,IAAMN,EAAMM,EAAM,QAAQ,OAAQ,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,GAC3CJ,EAAOJ,EAAKO,EAAI,GAEpBE,EAAW,SAASP,CAAG,GACvB,CAACM,EAAM,SAAS,GAAG,GACnBJ,IAAS,IAAA,IACT,CAACA,EAAK,WAAW,GAAG,GAEpB,IAEF,QACF,CACAE,EAAI,KAAKE,CAAK,CAChB,CACA,OAAOF,CACT,CAOA,SAAgBI,EACd,EACwD,CACxD,IAAMC,EAAMb,EAAUE,EAAM,iBAAiB,GAAKF,EAAUE,EAAM,IAAI,EAGtE,OAFIW,IAAQ,IAAA,GAAkB,CAAE,GAAI,IAAA,EAAU,EAC1Cd,EAAiBc,CAAG,EAAU,CAAE,GAAIA,CAAI,EACrC,CAAE,MAAO,4BAA4BA,EAAI,qCAAsC,CACxF"}
|
|
@@ -0,0 +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-BA9GQ8nl.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-eOLGuyAi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blueprint-eOLGuyAi.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,GAA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AS,SAAWA,EAAO,IAAA,EAAS,EACpE,GAAIC,IAAW,MAAQA,IAAW,UAChC,MAAU,MAAM,GAAG3B,EAAO,4DAA4D,EAExF,EAAU,KAAO2B,CACnB,CACA,GAAIxB,EAAI,UAAY,IAAA,GAAW,CAC7B,GAAI,OAAOA,EAAI,SAAY,UAAY,CAAC,4BAA4B,KAAKA,EAAI,OAAO,EAClF,MAAU,MAAM,GAAGH,EAAO,mEAAmE,EAE/F,EAAU,QAAUG,EAAI,OAC1B,CACA,OAAOK,CACT,CAGA,SAAgBqB,EAAiB,EAAmD,CAClF,MAAO,CACL,KAAMrB,EAAU,KAChB,UAAWA,EAAU,UACrB,MAAOA,EAAU,MACjB,SAAUA,EAAU,MAAM,IAAK,GAAMU,EAAE,KAAK,EAC5C,OAAQV,EAAU,MAAM,IAAK,GAAMU,EAAE,KAAK,EAC1C,GAAIV,EAAU,QAAU,CAAE,QAASA,EAAU,OAAQ,EAAI,CAAC,EAC1D,GAAIA,EAAU,SAAW,CAAE,SAAUA,EAAU,QAAS,EAAI,CAAC,EAC7D,GAAIA,EAAU,KAAO,CAAE,KAAMA,EAAU,IAAK,EAAI,CAAC,CACnD,CACF"}
|
package/dist/cmdspec.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"cmdspec": "0.1",
|
|
4
4
|
"info": {
|
|
5
5
|
"name": "cascivo",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.8.0",
|
|
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",
|
|
@@ -122,6 +122,24 @@
|
|
|
122
122
|
"network"
|
|
123
123
|
]
|
|
124
124
|
},
|
|
125
|
+
{
|
|
126
|
+
"name": "--workspace",
|
|
127
|
+
"summary": "Put the app in a pnpm workspace",
|
|
128
|
+
"description": "apps/web is the app, packages/ui holds the team's own components, Vite+ (vp run) runs every package's typecheck, lint, test and build, and a GitHub Actions workflow runs the same. React + Vite apps get a Vitest smoke test. Implies pnpm; not for astro."
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"name": "--from",
|
|
132
|
+
"summary": "Compile a blueprint file (cascivo.app.json)",
|
|
133
|
+
"description": "A blueprint names the app, its framework, theme, runtime, examples and auth, and its pages as [{ \"title\", \"block\"? }]: each page renders that registry block, wired into the routes and the side nav. It replaces the other options; the blueprint is copied into the app as cascivo.app.json.",
|
|
134
|
+
"value": {
|
|
135
|
+
"name": "file",
|
|
136
|
+
"format": "file"
|
|
137
|
+
},
|
|
138
|
+
"effects": [
|
|
139
|
+
"read",
|
|
140
|
+
"write"
|
|
141
|
+
]
|
|
142
|
+
},
|
|
125
143
|
{
|
|
126
144
|
"name": "--theme",
|
|
127
145
|
"summary": "Theme to install",
|
|
@@ -607,7 +625,7 @@
|
|
|
607
625
|
"value": {
|
|
608
626
|
"name": "file",
|
|
609
627
|
"format": "file",
|
|
610
|
-
"defaultDescription": "
|
|
628
|
+
"defaultDescription": "<config>.tsx beside the input"
|
|
611
629
|
},
|
|
612
630
|
"effects": [
|
|
613
631
|
"read",
|
|
@@ -624,6 +642,13 @@
|
|
|
624
642
|
"format": "directory",
|
|
625
643
|
"default": "./src/components/ui"
|
|
626
644
|
}
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
"name": "--from",
|
|
648
|
+
"summary": "Import every component from one package instead of the components directory",
|
|
649
|
+
"value": {
|
|
650
|
+
"name": "package"
|
|
651
|
+
}
|
|
627
652
|
}
|
|
628
653
|
],
|
|
629
654
|
"effects": [
|
|
@@ -775,6 +800,86 @@
|
|
|
775
800
|
}
|
|
776
801
|
]
|
|
777
802
|
},
|
|
803
|
+
{
|
|
804
|
+
"name": "app",
|
|
805
|
+
"summary": "Change an app made by cascivo create",
|
|
806
|
+
"subcommandRequired": true,
|
|
807
|
+
"commands": [
|
|
808
|
+
{
|
|
809
|
+
"name": "add",
|
|
810
|
+
"summary": "Add to the app",
|
|
811
|
+
"subcommandRequired": true,
|
|
812
|
+
"commands": [
|
|
813
|
+
{
|
|
814
|
+
"name": "page",
|
|
815
|
+
"summary": "Add a page, optionally rendering a registry block",
|
|
816
|
+
"description": "Appends the page to cascivo.app.json and writes the page, its block and the route and nav entries. Files edited since they were generated are merged three ways; a clash is left with conflict markers and the command exits non-zero.",
|
|
817
|
+
"arguments": [
|
|
818
|
+
{
|
|
819
|
+
"name": "title",
|
|
820
|
+
"required": true,
|
|
821
|
+
"summary": "Nav label and page heading"
|
|
822
|
+
}
|
|
823
|
+
],
|
|
824
|
+
"options": [
|
|
825
|
+
{
|
|
826
|
+
"name": "--block",
|
|
827
|
+
"summary": "The registry block the page renders",
|
|
828
|
+
"value": {
|
|
829
|
+
"name": "name"
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
],
|
|
833
|
+
"effects": [
|
|
834
|
+
"read",
|
|
835
|
+
"write"
|
|
836
|
+
],
|
|
837
|
+
"examples": [
|
|
838
|
+
{
|
|
839
|
+
"run": "npx cascivo app add page \"Users\" --block users-table-page"
|
|
840
|
+
}
|
|
841
|
+
]
|
|
842
|
+
},
|
|
843
|
+
{
|
|
844
|
+
"name": "example",
|
|
845
|
+
"summary": "Add a cloudflare example (the names --example takes)",
|
|
846
|
+
"arguments": [
|
|
847
|
+
{
|
|
848
|
+
"name": "name",
|
|
849
|
+
"required": true,
|
|
850
|
+
"summary": "The example"
|
|
851
|
+
}
|
|
852
|
+
],
|
|
853
|
+
"effects": [
|
|
854
|
+
"read",
|
|
855
|
+
"write"
|
|
856
|
+
],
|
|
857
|
+
"examples": [
|
|
858
|
+
{
|
|
859
|
+
"run": "npx cascivo app add example crud"
|
|
860
|
+
}
|
|
861
|
+
]
|
|
862
|
+
}
|
|
863
|
+
]
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
"name": "upgrade",
|
|
867
|
+
"summary": "Regenerate the app with this CLI's templates, keeping your edits",
|
|
868
|
+
"description": "Rebuilds the app's original files with the CLI version recorded in cascivo.app.json (npx cascivo@<version>), then merges this version's output three ways.",
|
|
869
|
+
"effects": [
|
|
870
|
+
"read",
|
|
871
|
+
"write",
|
|
872
|
+
"network",
|
|
873
|
+
"exec"
|
|
874
|
+
],
|
|
875
|
+
"examples": [
|
|
876
|
+
{
|
|
877
|
+
"run": "npx cascivo app upgrade"
|
|
878
|
+
}
|
|
879
|
+
]
|
|
880
|
+
}
|
|
881
|
+
]
|
|
882
|
+
},
|
|
778
883
|
{
|
|
779
884
|
"name": "registry",
|
|
780
885
|
"summary": "Build a static registry",
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DT7IzrpZ.mjs";import{pathToFileURL as t}from"node:url";import{existsSync as n,readFileSync as r}from"node:fs";import{dirname as i,join as a}from"node:path";var o=/* @__PURE__ */ e({CASCIVO_HOST:()=>s,DEFAULT_CONFIG:()=>l,THEMES:()=>c,applyEnvOverrides:()=>f,detectPackageManager:()=>v,installCommand:()=>x,installHint:()=>S,isPackageManager:()=>m,loadConfig:()=>p,pinSpecifier:()=>y,resolveConfig:()=>d});const s=`https://cascivo.com`,c=[`light`,`dark`,`warm`,`flat`,`minimal`,`midnight`,`pastel`,`brutalist`,`corporate`,`terminal`,`cyberpunk`,`arcade`],l={registry:`${s}/registry.json`,outputDir:`src/components/ui`,theme:`light`},u=[`cascivo.config.ts`,`cascivo.config.js`,`cascivo.config.mjs`];function d(e){return{...l,...e}}function f(e,t=process.env){return{...e,...t.CASCIVO_REGISTRY?{registry:t.CASCIVO_REGISTRY}:{},...t.CASCIVO_OUTPUT_DIR?{outputDir:t.CASCIVO_OUTPUT_DIR}:{}}}async function p(e=process.cwd()){for(let r of u){let i=a(e,r);if(n(i))try{let e=await import(t(i).href);return f(d(e.default??e))}catch{return f(d(null))}}return f(d(null))}function m(e){return e===`pnpm`||e===`yarn`||e===`npm`||e===`bun`}const h=[[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`bun.lockb`,`bun`],[`bun.lock`,`bun`],[`package-lock.json`,`npm`]];function g(e){if(!e)return;let t=e.split(`/`)[0];return m(t)?t:void 0}function _(e){try{let t=JSON.parse(r(a(e,`package.json`),`utf8`)).packageManager?.split(`@`)[0];return m(t)?t:void 0}catch{return}}function v(e=process.cwd(),t={}){let r=t.env??process.env;if(m(t.override))return t.override;let o=r.CASCIVO_PACKAGE_MANAGER;if(m(o))return o;let s=g(r.npm_config_user_agent);if(s&&!t.preferLockfileOverUserAgent)return s;let c=e;for(;;){for(let[e,t]of h)if(n(a(c,e)))return t;let e=_(c);if(e)return e;if(n(a(c,`.git`)))break;let t=i(c);if(t===c)break;c=t}return s??`npm`}function y(e,t={}){if(!e.startsWith(`@cascivo/`)&&e!==`cascivo`||e.includes(`@`,1))return e;let n=t[e];return n?.startsWith(`>=`)?`${e}@${n.slice(2)} - x`:`${e}@latest`}function b(e){return e===`yarn`||e===`bun`?`--exact`:`--save-exact`}function x(e,t,n={}){let r=e===`npm`?`install`:`add`,i=n.dev?[e===`npm`?`--save-dev`:`-D`]:[],a=t.map(e=>n.pin&&(e.startsWith(`@cascivo/`)||e===`cascivo`)?`${e}@${n.pin}`:y(e,n.floors??{}));return[e,[r,...i,b(e),...a]]}function S(e,t,n={}){let[r,i]=x(e,t,n);return`${r} ${i.join(` `)}`}export{v as a,m as c,o as i,p as l,l as n,x as o,c as r,S as s,s as t};
|
|
2
|
+
//# sourceMappingURL=config-CTk7uDrh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-CTk7uDrh.mjs","names":["__exportAll","config_exports","CASCIVO_HOST","DEFAULT_CONFIG","THEMES","applyEnvOverrides","detectPackageManager","installCommand","installHint","isPackageManager","loadConfig","pinSpecifier","resolveConfig","CONFIG_FILES","partial","config","env","file","path","join","cwd","existsSync","mod","pathToFileURL","value","PM_LOCKFILES","pmFromUserAgent","ua","name","pmFromPackageJson","readFileSync","dir","opts","envPm","uaPm","current","pm","fromField","parent","dirname","pkg","floor","floors","exactFlag","verb","devFlag","specs","packages","p","cmd","args"],"sources":["../src/utils/config.ts"],"sourcesContent":["import { existsSync, readFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { pathToFileURL } from 'node:url'\n\n/**\n * Canonical (and only) host for hosted cascivo artifacts (registry.json, per-item\n * r/<name>.json, marketplace.json, /llms/*, /context/*). The legacy docs.cascivo.com\n * subdomain is retired and 301s here. Keep in sync with CASCIVO_HOST in packages/mcp.\n */\nexport const CASCIVO_HOST = 'https://cascivo.com'\n\n/** All first-party themes shipped by @cascivo/themes (selectable via data-theme). */\nexport const THEMES = [\n 'light',\n 'dark',\n 'warm',\n 'flat',\n 'minimal',\n 'midnight',\n 'pastel',\n 'brutalist',\n 'corporate',\n 'terminal',\n 'cyberpunk',\n 'arcade',\n] as const\n\nexport type ThemeName = (typeof THEMES)[number]\n\nexport type RegistryNamespaceConfig =\n | string\n | { url: string; headers?: Record<string, string>; params?: Record<string, string> }\n\nexport interface CascadeConfig {\n /** URL of the registry.json index. */\n registry: string\n /** Directory (relative to project root) where components are written. */\n outputDir: string\n /** Default theme imported by `cascade init`. */\n theme: ThemeName\n /** Namespace → registry URL template (with {name} placeholder) or auth config. */\n registries?: Record<string, RegistryNamespaceConfig>\n /** Whether to copy test files (*.contract.test.tsx) when adding components. */\n tests?: boolean\n}\n\nexport const DEFAULT_CONFIG: CascadeConfig = {\n // Canonical hosted registry index (served from the landing site, documented in\n // llms.txt). Prefer this over a branch's GitHub raw URL, which 404s for\n // unauthenticated/private-repo requests and breaks `cascivo list`/`add`.\n registry: `${CASCIVO_HOST}/registry.json`,\n outputDir: 'src/components/ui',\n theme: 'light',\n}\n\nconst CONFIG_FILES = ['cascivo.config.ts', 'cascivo.config.js', 'cascivo.config.mjs']\n\n/** Apply defaults over a (possibly partial) user config object. */\nexport function resolveConfig(partial: Partial<CascadeConfig> | null | undefined): CascadeConfig {\n return { ...DEFAULT_CONFIG, ...partial }\n}\n\n/** Let env vars override config — used by the MCP server to pass `outputDir`. */\nexport function applyEnvOverrides(\n config: CascadeConfig,\n env: NodeJS.ProcessEnv = process.env,\n): CascadeConfig {\n return {\n ...config,\n ...(env.CASCIVO_REGISTRY ? { registry: env.CASCIVO_REGISTRY } : {}),\n ...(env.CASCIVO_OUTPUT_DIR ? { outputDir: env.CASCIVO_OUTPUT_DIR } : {}),\n }\n}\n\n/**\n * Locate and load `cascivo.config.{ts,js,mjs}` from `cwd`. Falls back to the\n * default config when no file is found or the file cannot be loaded. Env vars\n * (`CASCIVO_REGISTRY`, `CASCIVO_OUTPUT_DIR`) take precedence.\n */\nexport async function loadConfig(cwd: string = process.cwd()): Promise<CascadeConfig> {\n for (const file of CONFIG_FILES) {\n const path = join(cwd, file)\n if (!existsSync(path)) continue\n try {\n const mod = (await import(pathToFileURL(path).href)) as {\n default?: Partial<CascadeConfig>\n }\n return applyEnvOverrides(resolveConfig(mod.default ?? (mod as Partial<CascadeConfig>)))\n } catch {\n // Unloadable config (e.g. unsupported TS syntax) — fall back to defaults.\n return applyEnvOverrides(resolveConfig(null))\n }\n }\n return applyEnvOverrides(resolveConfig(null))\n}\n\nexport type PackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun'\n\n/** Narrow an arbitrary string to a known PackageManager. */\nexport function isPackageManager(value: string | undefined): value is PackageManager {\n return value === 'pnpm' || value === 'yarn' || value === 'npm' || value === 'bun'\n}\n\n/**\n * Lock files in probe order. `bun.lock` (bun ≥ 1.2 text lockfile) sits beside the\n * legacy binary `bun.lockb`; `package-lock.json` is npm's marker so a walk that\n * reaches an npm workspace root still resolves to npm rather than the default.\n */\nconst PM_LOCKFILES: readonly [string, PackageManager][] = [\n ['pnpm-lock.yaml', 'pnpm'],\n ['yarn.lock', 'yarn'],\n ['bun.lockb', 'bun'],\n ['bun.lock', 'bun'],\n ['package-lock.json', 'npm'],\n]\n\n/** The package manager that invoked this process, from `npm_config_user_agent`. */\nfunction pmFromUserAgent(ua: string | undefined): PackageManager | undefined {\n if (!ua) return undefined\n const name = ua.split('/')[0]\n return isPackageManager(name) ? name : undefined\n}\n\n/** The `packageManager` corepack field of a package.json, if it names a known PM. */\nfunction pmFromPackageJson(dir: string): PackageManager | undefined {\n try {\n const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')) as {\n packageManager?: string\n }\n const name = pkg.packageManager?.split('@')[0]\n return isPackageManager(name) ? name : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * Detect the package manager in use. Precedence, highest first:\n * 1. explicit override (the `--package-manager`/`--pm` flag)\n * 2. `CASCIVO_PACKAGE_MANAGER` env var\n * 3. `npm_config_user_agent` (the PM that spawned the CLI, e.g. `pnpm dlx`)\n * 4. an upward walk from `cwd` for a lock file or `packageManager` field —\n * this is what makes detection work inside a workspace, where the lock\n * file lives at the repo root, not in the app subdirectory the user runs\n * the CLI from. The walk stops after a directory containing `.git`.\n * 5. default `npm`.\n */\nexport function detectPackageManager(\n cwd: string = process.cwd(),\n opts: {\n override?: string\n env?: NodeJS.ProcessEnv\n /**\n * Let a lock file found by walking up from `cwd` outrank `npm_config_user_agent`.\n *\n * For `init`/`add`, which run *inside* an existing project, the user agent is the right\n * first signal: it is the tool the developer just invoked. For `create` it is the wrong\n * one. `npx cascivo create` always reports a `npm/…` agent regardless of what the\n * surrounding workspace uses, and it short-circuited before the walk-up ever ran — so a\n * 2026-08-14 adopter scaffolding into a pnpm workspace with a root `pnpm-lock.yaml` was\n * told to run `npm install`. Where the new project LANDS is a stronger signal than which\n * launcher started the CLI.\n */\n preferLockfileOverUserAgent?: boolean\n } = {},\n): PackageManager {\n const env = opts.env ?? process.env\n\n if (isPackageManager(opts.override)) return opts.override\n\n const envPm = env.CASCIVO_PACKAGE_MANAGER\n if (isPackageManager(envPm)) return envPm\n\n const uaPm = pmFromUserAgent(env.npm_config_user_agent)\n if (uaPm && !opts.preferLockfileOverUserAgent) return uaPm\n\n let current = cwd\n for (;;) {\n for (const [file, pm] of PM_LOCKFILES) {\n if (existsSync(join(current, file))) return pm\n }\n const fromField = pmFromPackageJson(current)\n if (fromField) return fromField\n // A `.git` directory marks the repo root — do not walk past it.\n if (existsSync(join(current, '.git'))) break\n const parent = dirname(current)\n if (parent === current) break\n current = parent\n }\n\n // No lock file anywhere up the tree: fall back to the launcher, which for a brand-new\n // project in an empty directory is the only signal there is.\n return uaPm ?? 'npm'\n}\n\n/**\n * Pin every `@cascivo/*` package to an explicit version specifier.\n *\n * A bare name lets the package manager reuse whatever it already has resolvable. In a pnpm\n * workspace a sibling package's lockfile entry won and `@cascivo/i18n` resolved to **0.2.14**\n * while latest was **0.16.0** — then cascivo warned the adopter about the version it had\n * just installed itself. `add name@latest` (or the registry's known floor) makes the intent\n * explicit instead of leaving it to resolution order.\n *\n * Non-cascivo packages (`@preact/signals-react`) keep their bare name: their version is the\n * app's business, and cascivo has no floor to assert.\n */\nexport function pinSpecifier(pkg: string, floors: Record<string, string> = {}): string {\n if (!pkg.startsWith('@cascivo/') && pkg !== 'cascivo') return pkg\n if (pkg.includes('@', 1)) return pkg // already carries an explicit version\n const floor = floors[pkg]\n // `>=x.y.z` is not an installable specifier on its own; widen it to a range the package\n // manager understands, so a known floor is honoured rather than silently ignored.\n if (floor?.startsWith('>=')) return `${pkg}@${floor.slice(2)} - x`\n return `${pkg}@latest`\n}\n\n/**\n * The flag that makes each package manager write `1.2.3` rather than `^1.2.3`.\n *\n * Every cascivo doc tells adopters to pin exact versions, and no documented command did it:\n * the CLI resolved `pkg@latest`, which the package manager still records with a caret, so an\n * adopter ended up with carets *by following the instruction* (2026-08-31 report §26).\n * yarn and bun spell the flag `--exact`; npm and pnpm spell it `--save-exact`.\n */\nfunction exactFlag(pm: PackageManager): string {\n return pm === 'yarn' || pm === 'bun' ? '--exact' : '--save-exact'\n}\n\n/** The install subcommand each package manager uses to add dependencies. */\nexport function installCommand(\n pm: PackageManager,\n packages: string[],\n opts: { dev?: boolean; floors?: Record<string, string>; pin?: string } = {},\n): [string, string[]] {\n const verb = pm === 'npm' ? 'install' : 'add'\n const devFlag = opts.dev ? [pm === 'npm' ? '--save-dev' : '-D'] : []\n const specs = packages.map((p) =>\n opts.pin && (p.startsWith('@cascivo/') || p === 'cascivo')\n ? `${p}@${opts.pin}`\n : pinSpecifier(p, opts.floors ?? {}),\n )\n return [pm, [verb, ...devFlag, exactFlag(pm), ...specs]]\n}\n\n/** Human-readable install command a user can copy-paste, e.g. `pnpm add -D cascivo`. */\nexport function installHint(\n pm: PackageManager,\n packages: string[],\n opts: { dev?: boolean } = {},\n): string {\n const [cmd, args] = installCommand(pm, packages, opts)\n return `${cmd} ${args.join(' ')}`\n}\n"],"mappings":"2bASA,MAAaE,EAAe,sBAGfE,EAAS,CACpB,QACA,OACA,OACA,OACA,UACA,WACA,SACA,YACA,YACA,WACA,YACA,QACF,EAqBaD,EAAgC,CAI3C,SAAU,GAAGD,EAAa,gBAC1B,UAAW,oBACX,MAAO,OACT,EAEMW,EAAe,CAAC,oBAAqB,oBAAqB,oBAAoB,EAGpF,SAAgBD,EAAc,EAAmE,CAC/F,MAAO,CAAE,GAAGT,EAAgB,GAAGW,CAAQ,CACzC,CAGA,SAAgBT,EACd,EACA,EAAyB,QAAQ,IAClB,CACf,MAAO,CACL,GAAGU,EACH,GAAIC,EAAI,iBAAmB,CAAE,SAAUA,EAAI,gBAAiB,EAAI,CAAC,EACjE,GAAIA,EAAI,mBAAqB,CAAE,UAAWA,EAAI,kBAAmB,EAAI,CAAC,CACxE,CACF,CAOA,eAAsBN,EAAW,EAAc,QAAQ,IAAI,EAA2B,CACpF,IAAK,IAAMO,KAAQJ,EAAc,CAC/B,IAAMK,EAAOC,EAAKC,EAAKH,CAAI,EAC3B,GAAKI,EAAWH,CAAI,EACpB,GAAI,CACF,IAAMI,EAAO,MAAM,OAAOC,EAAcL,CAAI,CAAC,CAAC,MAG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