@forinda/kickjs-cli 8.18.0 → 8.19.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.
Files changed (46) hide show
  1. package/dist/{agent-docs-xZISEduq.mjs → agent-docs-D10r5OEG.mjs} +3 -3
  2. package/dist/agent-docs-D10r5OEG.mjs.map +1 -0
  3. package/dist/{agent-docs-CbVUB2eN.mjs → agent-docs-D_L3RIUM.mjs} +2 -2
  4. package/dist/{build-BLQQMQtM.mjs → build-BkfEhRpx.mjs} +3 -3
  5. package/dist/{build-BLQQMQtM.mjs.map → build-BkfEhRpx.mjs.map} +1 -1
  6. package/dist/{build-CKmAKaJ1.mjs → build-CChfKQA_.mjs} +2 -2
  7. package/dist/{builtins-4IV5eliu.mjs → builtins-C1mgGr8D.mjs} +141 -141
  8. package/dist/{builtins-4OFjCWYj.mjs → builtins-cZC3AQMK.mjs} +2 -2
  9. package/dist/cli.mjs +2 -2
  10. package/dist/{config-B3kSZiSh.mjs → config-Bb-FdTKY.mjs} +3 -3
  11. package/dist/config-Bb-FdTKY.mjs.map +1 -0
  12. package/dist/{config-v0mtdiYe.mjs → config-xN3ZYiN-.mjs} +2 -2
  13. package/dist/{doctor-DJxEocJ5.mjs → doctor-CDdF_pWU.mjs} +4 -4
  14. package/dist/doctor-CDdF_pWU.mjs.map +1 -0
  15. package/dist/{fullstack-iWO7BFX6.mjs → fullstack-CHNFDgBX.mjs} +3 -3
  16. package/dist/{fullstack-DM0a3A8G.mjs → fullstack-D0Yim7JS.mjs} +4 -4
  17. package/dist/fullstack-D0Yim7JS.mjs.map +1 -0
  18. package/dist/index.d.mts +95 -1
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.mjs +2 -2
  21. package/dist/{plugin-BCMbxzi5.mjs → plugin-CFT_4ept.mjs} +2 -2
  22. package/dist/{plugin-P1F0k7kH.mjs → plugin-DxXeitAU.mjs} +2 -2
  23. package/dist/{project-6h_j0VK0.mjs → project-B9sWWiFy.mjs} +5 -5
  24. package/dist/project-B9sWWiFy.mjs.map +1 -0
  25. package/dist/{project-9QfIRkON.mjs → project-DDQFJyNi.mjs} +4 -4
  26. package/dist/{project-root-rs5vJCt5.mjs → project-root-ClOtJ6MM.mjs} +2 -2
  27. package/dist/{project-root-DcfsBtCw.mjs → project-root-DNQ4RQHQ.mjs} +3 -3
  28. package/dist/{project-root-DcfsBtCw.mjs.map → project-root-DNQ4RQHQ.mjs.map} +1 -1
  29. package/dist/rolldown-runtime-SDDZy9Be.mjs +11 -0
  30. package/dist/{run-plugins-BONtomzM.mjs → run-plugins-lJqFqRny.mjs} +5 -5
  31. package/dist/run-plugins-lJqFqRny.mjs.map +1 -0
  32. package/dist/{typegen-FLvIFR3i.mjs → typegen-Bkikzy45.mjs} +5 -5
  33. package/dist/typegen-Bkikzy45.mjs.map +1 -0
  34. package/dist/{typegen-ZG4nzOUN.mjs → typegen-DlnhNbzD.mjs} +4 -4
  35. package/dist/{types-Doudtd8d.mjs → types-ew1loX4G.mjs} +1 -1
  36. package/package.json +10 -10
  37. package/templates/feature-views/files/src/views/shared.ts +19 -0
  38. package/templates/feature-views/skills/views-forms.txt +1 -1
  39. package/dist/agent-docs-xZISEduq.mjs.map +0 -1
  40. package/dist/config-B3kSZiSh.mjs.map +0 -1
  41. package/dist/doctor-DJxEocJ5.mjs.map +0 -1
  42. package/dist/fullstack-DM0a3A8G.mjs.map +0 -1
  43. package/dist/project-6h_j0VK0.mjs.map +0 -1
  44. package/dist/rolldown-runtime-CQE1JsWD.mjs +0 -11
  45. package/dist/run-plugins-BONtomzM.mjs.map +0 -1
  46. package/dist/typegen-FLvIFR3i.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.18.0
2
+ * @forinda/kickjs-cli v8.19.0
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{t as e}from"./rolldown-runtime-CQE1JsWD.mjs";import{n as t,t as n}from"./types-Doudtd8d.mjs";import{_ as r,a as i,b as a,d as o,g as s,h as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,x as y,y as b}from"./project-6h_j0VK0.mjs";import{C as x,S,_ as ee,a as te,b as C,d as ne,f as w,g as re,h as T,i as E,m as D,n as ie,o as ae,p as oe,u as se,v as ce,x as le,y as O}from"./agent-docs-xZISEduq.mjs";import{a as ue,c as k,d as de,f as fe,h as pe,l as A,m as me,o as he,p as ge,s as j,u as _e}from"./config-B3kSZiSh.mjs";import{A as ve,C as ye,D as be,E as xe,F as Se,M as Ce,N as we,O as Te,P as M,S as Ee,T as De,_ as Oe,a as ke,b as Ae,c as je,f as Me,g as Ne,h as Pe,i as Fe,j as Ie,k as Le,l as Re,m as ze,p as Be,r as Ve,u as He,v as Ue,w as We,x as Ge,y as Ke}from"./doctor-DJxEocJ5.mjs";import{t as N}from"./project-root-DcfsBtCw.mjs";import{C as qe,S as Je,_ as Ye,a as Xe,b as Ze,c as Qe,d as $e,f as et,g as tt,h as nt,i as rt,l as it,m as at,o as ot,p as st,r as ct,s as lt,t as ut,u as dt,v as ft,w as pt,x as P,y as mt}from"./typegen-FLvIFR3i.mjs";import{t as ht}from"./build-BLQQMQtM.mjs";import{createRequire as gt}from"node:module";import F,{basename as _t,dirname as I,join as L,relative as R,resolve as z,sep as B}from"node:path";import{cpSync as vt,existsSync as V,mkdirSync as yt,readFileSync as H,readdirSync as bt,rmSync as xt,statSync as St,writeFileSync as U}from"node:fs";import{copyFile as Ct,mkdir as wt,readFile as W,readdir as Tt,rm as Et,stat as Dt,writeFile as Ot}from"node:fs/promises";import{fork as kt,spawn as At,spawnSync as jt}from"node:child_process";import{createHash as Mt}from"node:crypto";import{fileURLToPath as Nt,pathToFileURL as G}from"node:url";import{parseSync as Pt}from"oxc-parser";import{arch as Ft,platform as It,release as Lt}from"node:os";const Rt=[{value:`swagger`,label:`Swagger`,hint:`OpenAPI docs`},{value:`ws`,label:`WebSocket`,hint:`rooms, heartbeat`},{value:`queue`,label:`Queue`,hint:`BullMQ/RabbitMQ/Kafka`},{value:`devtools`,label:`DevTools`,hint:`debug dashboard`},{value:`storage`,label:`Storage`,hint:`disk, S3 / R2 / MinIO`},{value:`views`,label:`Views`,hint:`server-rendered .kick templates`}];function zt(e){e.command(`new [name]`).alias(`init`).description(`Create a new KickJS project (use "." for current directory)`).option(`-d, --directory <dir>`,`Target directory (defaults to project name)`).option(`--pm <manager>`,`Package manager: pnpm | npm | yarn | bun`).option(`--git`,`Initialize git repository`).option(`--no-git`,`Skip git initialization`).option(`--install`,`Install dependencies after scaffolding`).option(`--no-install`,`Skip dependency installation`).option(`-f, --force`,`Remove existing files without prompting`).option(`-t, --template <type>`,`Project template: rest | minimal | fullstack | inertia`).option(`--runtime <engine>`,`HTTP runtime: express | fastify | h3`).option(`--client <framework>`,`Inertia template pages: react | vue | svelte (default react)`).option(`-r, --repo <type>`,`Repository name (inmemory, or any DB name e.g. postgres)`).option(`-s, --schema <lib>`,`Schema library for env / DTOs: zod | valibot | yup (default: zod)`).option(`--frontend <kind>`,`Fullstack web/ scaffold: 'kick' (wired React app) or 'vite' (create-vite, unwired)`).option(`--vite-template <name>`,`create-vite TypeScript template for --frontend vite (default 'react-ts')`).option(`--packages <packages>`,`Comma-separated packages to include (e.g. swagger,ws,queue,devtools)`).option(`--deploy <targets>`,`Comma-separated deploy targets to write files for: netlify, vercel, docker (later: kick g deploy)`).option(`-y, --yes`,`Pick safe defaults for every prompt (template=minimal, repo=inmemory, no extras, git+install on)`).option(`--non-interactive`,`alias for --yes`).action(async(e,t)=>{ne(`KickJS — Create a new project`);let n=m(),r=e=>{e&&w.warn(`kick ${g} is behind the latest release, ${e} — templates and options added since are missing. Upgrade: npm i -g @forinda/kickjs-cli@latest`)},i=[];try{i=t.deploy?y(t.deploy):[]}catch(e){w.error(e.message),D(`Aborted.`),process.exitCode=1;return}let a=[`react`,`vue`,`svelte`],o=t.client;if(o!==void 0&&!a.includes(o)){w.error(`Unknown --client '${String(o)}'. Use ${a.join(`, `)}.`),D(`Aborted.`),process.exitCode=1;return}let s=!!(t.yes||t.nonInteractive);e||=s?`my-api`:await ee({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let c;if(e===`.`?(c=z(`.`),e=_t(c)):c=z(t.directory||e),V(c)){let n=bt(c);if(n.length>0){if(t.force)w.warn(`Clearing existing files in ${c}`);else if(s){w.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),D(`Aborted.`);return}else{w.warn(`Directory "${e}" is not empty:`);let t=n.slice(0,5);for(let e of t)w.message(` - ${e}`);if(n.length>5&&w.message(` ... and ${n.length-5} more`),!await se({message:O.red(`Remove all existing files and proceed?`),initialValue:!1})){D(`Aborted.`);return}}for(let e of n)xt(z(c,e),{recursive:!0,force:!0})}}s||r(await Promise.race([n,new Promise(e=>setTimeout(e,3e3,null).unref())]));let l=t.template;l||=s?`minimal`:await T({message:`Project template`,options:[{value:`rest`,label:`REST API`,hint:`Express + Swagger`},{value:`minimal`,label:`Minimal`,hint:`bare Express`},{value:`fullstack`,label:`Fullstack`,hint:`server + Vite React web, typed client`},{value:`inertia`,label:`Inertia`,hint:`server-driven React, Vue or Svelte pages, one app, SSR`}]}),l===`inertia`&&o===void 0?o=s?`react`:await T({message:`Pages written in`,options:[{value:`react`,label:`React`},{value:`vue`,label:`Vue`},{value:`svelte`,label:`Svelte`}]}):l!==`inertia`&&o!==void 0&&w.warn(`--client applies to the inertia template only; ignoring it.`);let u=t.runtime;u||=s?`express`:await T({message:`HTTP runtime`,options:[{value:`express`,label:`Express`,hint:`default, zero-config`},{value:`fastify`,label:`Fastify`,hint:`fastify + @fastify/middie`},{value:`h3`,label:`h3`,hint:`Nitro / Nuxt engine`}]});let f=t.pm;f||=s?await te(void 0):await T({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let p=t.repo;p||=s?`inmemory`:await ee({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),pe(p);let h=t.schema;l===`inertia`&&(h&&h!==`zod`&&w.warn(`The inertia template uses zod — ignoring --schema ${h}.`),h=`zod`),h||=s?`zod`:await T({message:`Schema library (env + DTO validation)`,options:[{value:`zod`,label:`Zod`,hint:`default — broad ecosystem`},{value:`valibot`,label:`Valibot`,hint:`smaller bundle`},{value:`yup`,label:`Yup`,hint:`classic API`}]}),[`zod`,`valibot`,`yup`].includes(h)||(w.warn(`Unknown --schema "${h}", falling back to zod.`),h=`zod`);let _;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();_=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else _=s?[]:await oe({message:`Select packages to include`,options:[...Rt],required:!1});let v;v=t.git===void 0?s?!0:await se({message:`Initialize git repository?`,initialValue:!0}):t.git;let b;if(b=t.install===void 0?s?!0:await se({message:`Install dependencies?`,initialValue:!0}):t.install,t.frontend!==void 0&&t.frontend!==`kick`&&t.frontend!==`vite`){w.error(`Unknown --frontend '${String(t.frontend)}'. Use 'kick' (wired React app) or 'vite' (create-vite).`),D(`Aborted.`);return}let{VITE_TEMPLATES:x,DEFAULT_VITE_TEMPLATE:S}=await import(`./fullstack-DM0a3A8G.mjs`);if(t.viteTemplate!==void 0&&!x.some(e=>e.value===t.viteTemplate)){w.error(`Unknown --vite-template '${String(t.viteTemplate)}'. TypeScript templates only: ${x.map(e=>e.value).join(`, `)}.`),D(`Aborted.`);return}let C=t.frontend===`vite`?`vite`:`kick`,re=t.viteTemplate??S;if(l===`fullstack`&&!t.frontend&&!s&&(C=await T({message:`Frontend for web/`,options:[{value:`kick`,label:`KickJS React app`,hint:`typed client, /api proxy, route types — wired`},{value:`vite`,label:`Delegate to create-vite`,hint:`pick any framework; wiring is manual (guide printed after)`}]})),C===`vite`&&!t.viteTemplate&&!s&&(re=await T({message:`create-vite template`,options:x.map(e=>({value:e.value,label:e.label})),initialValue:S})),l===`fullstack`){let{initFullstackProject:t}=await import(`./fullstack-DM0a3A8G.mjs`);await t({name:e,directory:c,packageManager:f,initGit:v,installDeps:b,schemaLib:h,runtime:u,packages:_,frontend:C,viteTemplate:re,deploy:i}),s&&r(await n),D(`Done! Next steps: ${O.cyan(`cd ${e} && ${f}${f===`pnpm`?` dev`:` run dev:server`}`)}`)}else await d({name:e,directory:c,packageManager:f,initGit:v,installDeps:b,template:l,client:o,defaultRepo:p,packages:_,schemaLib:h,runtime:u,deploy:i}),s&&r(await n),D(`Done! Next steps: ${O.cyan(`cd ${e} && ${ge(f,`dev`)}`)}`)})}function Bt(e,t=[]){let r=/* @__PURE__ */ new Map;for(let t of e){let e=(r.get(t.name)??0)+1;if(r.set(t.name,e),e===2)throw new n(`plugin`,t.name,[t.name,t.name])}let i=/* @__PURE__ */ new Map,a=[];for(let t of e)for(let e of t.commands??[]){let r=i.get(e.name);if(r)throw new n(`command`,e.name,[r,t.name]);i.set(e.name,t.name),a.push(e)}let o=new Set(t.map(e=>e.name)),s=[...a.filter(e=>!o.has(e.name)),...t],c=/* @__PURE__ */ new Map,l=[];for(let t of e)for(let e of t.typegens??[]){let r=c.get(e.id);if(r)throw new n(`typegen`,e.id,[r,t.name]);c.set(e.id,t.name),l.push(e)}let u=/* @__PURE__ */ new Map,d=[];for(let t of e)for(let e of t.generators??[]){let r=u.get(e.name);if(r)throw new n(`generator`,e.name,[r,t.name]);u.set(e.name,t.name),d.push({source:t.name,spec:e})}return{commands:s,typegens:l,generators:d,register:async(t,n)=>{let r;if(n)r={generators:d,...n};else{let{findProjectRoot:e}=await import(`./project-root-DcfsBtCw.mjs`).then(e=>e.n),t=process.cwd();r={cwd:t,projectRoot:e(t),config:null,log:()=>{},generators:d}}for(let n of e)n.register&&await n.register(t,r)}}}async function Vt(e){let{name:t,outDir:n}=e,r=M(t),i=Se(t),a=[],o=L(n,`${r}.plugin.ts`);return await x(o,`import {
11
+ import{t as e}from"./rolldown-runtime-SDDZy9Be.mjs";import{n as t,t as n}from"./types-ew1loX4G.mjs";import{_ as r,a as i,b as a,d as o,g as s,h as c,l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,x as y,y as b}from"./project-B9sWWiFy.mjs";import{C as x,S,_ as ee,a as te,b as C,d as ne,f as w,g as re,h as T,i as E,m as D,n as ie,o as ae,p as oe,u as se,v as ce,x as le,y as O}from"./agent-docs-D10r5OEG.mjs";import{a as ue,c as k,d as de,f as fe,h as pe,l as A,m as me,o as he,p as ge,s as j,u as _e}from"./config-Bb-FdTKY.mjs";import{A as ve,C as ye,D as be,E as xe,F as Se,M as Ce,N as we,O as Te,P as M,S as Ee,T as De,_ as Oe,a as ke,b as Ae,c as je,f as Me,g as Ne,h as Pe,i as Fe,j as Ie,k as Le,l as Re,m as ze,p as Be,r as Ve,u as He,v as Ue,w as We,x as Ge,y as Ke}from"./doctor-CDdF_pWU.mjs";import{t as N}from"./project-root-DNQ4RQHQ.mjs";import{C as qe,S as Je,_ as Ye,a as Xe,b as Ze,c as Qe,d as $e,f as et,g as tt,h as nt,i as rt,l as it,m as at,o as ot,p as st,r as ct,s as lt,t as ut,u as dt,v as ft,w as pt,x as P,y as mt}from"./typegen-Bkikzy45.mjs";import{t as ht}from"./build-BkfEhRpx.mjs";import{createRequire as gt}from"node:module";import F,{basename as _t,dirname as I,join as L,relative as R,resolve as z,sep as B}from"node:path";import{cpSync as vt,existsSync as V,mkdirSync as yt,readFileSync as H,readdirSync as bt,rmSync as xt,statSync as St,writeFileSync as U}from"node:fs";import{copyFile as Ct,mkdir as wt,readFile as W,readdir as Tt,rm as Et,stat as Dt,writeFile as Ot}from"node:fs/promises";import{fork as kt,spawn as At,spawnSync as jt}from"node:child_process";import{createHash as Mt}from"node:crypto";import{fileURLToPath as Nt,pathToFileURL as G}from"node:url";import{parseSync as Pt}from"oxc-parser";import{arch as Ft,platform as It,release as Lt}from"node:os";const Rt=[{value:`swagger`,label:`Swagger`,hint:`OpenAPI docs`},{value:`ws`,label:`WebSocket`,hint:`rooms, heartbeat`},{value:`queue`,label:`Queue`,hint:`BullMQ/RabbitMQ/Kafka`},{value:`devtools`,label:`DevTools`,hint:`debug dashboard`},{value:`storage`,label:`Storage`,hint:`disk, S3 / R2 / MinIO`},{value:`views`,label:`Views`,hint:`server-rendered .kick templates`}];function zt(e){e.command(`new [name]`).alias(`init`).description(`Create a new KickJS project (use "." for current directory)`).option(`-d, --directory <dir>`,`Target directory (defaults to project name)`).option(`--pm <manager>`,`Package manager: pnpm | npm | yarn | bun`).option(`--git`,`Initialize git repository`).option(`--no-git`,`Skip git initialization`).option(`--install`,`Install dependencies after scaffolding`).option(`--no-install`,`Skip dependency installation`).option(`-f, --force`,`Remove existing files without prompting`).option(`-t, --template <type>`,`Project template: rest | minimal | fullstack | inertia`).option(`--runtime <engine>`,`HTTP runtime: express | fastify | h3`).option(`--client <framework>`,`Inertia template pages: react | vue | svelte (default react)`).option(`-r, --repo <type>`,`Repository name (inmemory, or any DB name e.g. postgres)`).option(`-s, --schema <lib>`,`Schema library for env / DTOs: zod | valibot | yup (default: zod)`).option(`--frontend <kind>`,`Fullstack web/ scaffold: 'kick' (wired React app) or 'vite' (create-vite, unwired)`).option(`--vite-template <name>`,`create-vite TypeScript template for --frontend vite (default 'react-ts')`).option(`--packages <packages>`,`Comma-separated packages to include (e.g. swagger,ws,queue,devtools)`).option(`--deploy <targets>`,`Comma-separated deploy targets to write files for: netlify, vercel, docker (later: kick g deploy)`).option(`-y, --yes`,`Pick safe defaults for every prompt (template=minimal, repo=inmemory, no extras, git+install on)`).option(`--non-interactive`,`alias for --yes`).action(async(e,t)=>{ne(`KickJS — Create a new project`);let n=m(),r=e=>{e&&w.warn(`kick ${g} is behind the latest release, ${e} — templates and options added since are missing. Upgrade: npm i -g @forinda/kickjs-cli@latest`)},i=[];try{i=t.deploy?y(t.deploy):[]}catch(e){w.error(e.message),D(`Aborted.`),process.exitCode=1;return}let a=[`react`,`vue`,`svelte`],o=t.client;if(o!==void 0&&!a.includes(o)){w.error(`Unknown --client '${String(o)}'. Use ${a.join(`, `)}.`),D(`Aborted.`),process.exitCode=1;return}let s=!!(t.yes||t.nonInteractive);e||=s?`my-api`:await ee({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let c;if(e===`.`?(c=z(`.`),e=_t(c)):c=z(t.directory||e),V(c)){let n=bt(c);if(n.length>0){if(t.force)w.warn(`Clearing existing files in ${c}`);else if(s){w.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),D(`Aborted.`);return}else{w.warn(`Directory "${e}" is not empty:`);let t=n.slice(0,5);for(let e of t)w.message(` - ${e}`);if(n.length>5&&w.message(` ... and ${n.length-5} more`),!await se({message:O.red(`Remove all existing files and proceed?`),initialValue:!1})){D(`Aborted.`);return}}for(let e of n)xt(z(c,e),{recursive:!0,force:!0})}}s||r(await Promise.race([n,new Promise(e=>setTimeout(e,3e3,null).unref())]));let l=t.template;l||=s?`minimal`:await T({message:`Project template`,options:[{value:`rest`,label:`REST API`,hint:`Express + Swagger`},{value:`minimal`,label:`Minimal`,hint:`bare Express`},{value:`fullstack`,label:`Fullstack`,hint:`server + Vite React web, typed client`},{value:`inertia`,label:`Inertia`,hint:`server-driven React, Vue or Svelte pages, one app, SSR`}]}),l===`inertia`&&o===void 0?o=s?`react`:await T({message:`Pages written in`,options:[{value:`react`,label:`React`},{value:`vue`,label:`Vue`},{value:`svelte`,label:`Svelte`}]}):l!==`inertia`&&o!==void 0&&w.warn(`--client applies to the inertia template only; ignoring it.`);let u=t.runtime;u||=s?`express`:await T({message:`HTTP runtime`,options:[{value:`express`,label:`Express`,hint:`default, zero-config`},{value:`fastify`,label:`Fastify`,hint:`fastify + @fastify/middie`},{value:`h3`,label:`h3`,hint:`Nitro / Nuxt engine`}]});let f=t.pm;f||=s?await te(void 0):await T({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let p=t.repo;p||=s?`inmemory`:await ee({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),pe(p);let h=t.schema;l===`inertia`&&(h&&h!==`zod`&&w.warn(`The inertia template uses zod — ignoring --schema ${h}.`),h=`zod`),h||=s?`zod`:await T({message:`Schema library (env + DTO validation)`,options:[{value:`zod`,label:`Zod`,hint:`default — broad ecosystem`},{value:`valibot`,label:`Valibot`,hint:`smaller bundle`},{value:`yup`,label:`Yup`,hint:`classic API`}]}),[`zod`,`valibot`,`yup`].includes(h)||(w.warn(`Unknown --schema "${h}", falling back to zod.`),h=`zod`);let _;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();_=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else _=s?[]:await oe({message:`Select packages to include`,options:[...Rt],required:!1});let v;v=t.git===void 0?s?!0:await se({message:`Initialize git repository?`,initialValue:!0}):t.git;let b;if(b=t.install===void 0?s?!0:await se({message:`Install dependencies?`,initialValue:!0}):t.install,t.frontend!==void 0&&t.frontend!==`kick`&&t.frontend!==`vite`){w.error(`Unknown --frontend '${String(t.frontend)}'. Use 'kick' (wired React app) or 'vite' (create-vite).`),D(`Aborted.`);return}let{VITE_TEMPLATES:x,DEFAULT_VITE_TEMPLATE:S}=await import(`./fullstack-D0Yim7JS.mjs`);if(t.viteTemplate!==void 0&&!x.some(e=>e.value===t.viteTemplate)){w.error(`Unknown --vite-template '${String(t.viteTemplate)}'. TypeScript templates only: ${x.map(e=>e.value).join(`, `)}.`),D(`Aborted.`);return}let C=t.frontend===`vite`?`vite`:`kick`,re=t.viteTemplate??S;if(l===`fullstack`&&!t.frontend&&!s&&(C=await T({message:`Frontend for web/`,options:[{value:`kick`,label:`KickJS React app`,hint:`typed client, /api proxy, route types — wired`},{value:`vite`,label:`Delegate to create-vite`,hint:`pick any framework; wiring is manual (guide printed after)`}]})),C===`vite`&&!t.viteTemplate&&!s&&(re=await T({message:`create-vite template`,options:x.map(e=>({value:e.value,label:e.label})),initialValue:S})),l===`fullstack`){let{initFullstackProject:t}=await import(`./fullstack-D0Yim7JS.mjs`);await t({name:e,directory:c,packageManager:f,initGit:v,installDeps:b,schemaLib:h,runtime:u,packages:_,frontend:C,viteTemplate:re,deploy:i}),s&&r(await n),D(`Done! Next steps: ${O.cyan(`cd ${e} && ${f}${f===`pnpm`?` dev`:` run dev:server`}`)}`)}else await d({name:e,directory:c,packageManager:f,initGit:v,installDeps:b,template:l,client:o,defaultRepo:p,packages:_,schemaLib:h,runtime:u,deploy:i}),s&&r(await n),D(`Done! Next steps: ${O.cyan(`cd ${e} && ${ge(f,`dev`)}`)}`)})}function Bt(e,t=[]){let r=/* @__PURE__ */ new Map;for(let t of e){let e=(r.get(t.name)??0)+1;if(r.set(t.name,e),e===2)throw new n(`plugin`,t.name,[t.name,t.name])}let i=/* @__PURE__ */ new Map,a=[];for(let t of e)for(let e of t.commands??[]){let r=i.get(e.name);if(r)throw new n(`command`,e.name,[r,t.name]);i.set(e.name,t.name),a.push(e)}let o=new Set(t.map(e=>e.name)),s=[...a.filter(e=>!o.has(e.name)),...t],c=/* @__PURE__ */ new Map,l=[];for(let t of e)for(let e of t.typegens??[]){let r=c.get(e.id);if(r)throw new n(`typegen`,e.id,[r,t.name]);c.set(e.id,t.name),l.push(e)}let u=/* @__PURE__ */ new Map,d=[];for(let t of e)for(let e of t.generators??[]){let r=u.get(e.name);if(r)throw new n(`generator`,e.name,[r,t.name]);u.set(e.name,t.name),d.push({source:t.name,spec:e})}return{commands:s,typegens:l,generators:d,register:async(t,n)=>{let r;if(n)r={generators:d,...n};else{let{findProjectRoot:e}=await import(`./project-root-DNQ4RQHQ.mjs`).then(e=>e.n),t=process.cwd();r={cwd:t,projectRoot:e(t),config:null,log:()=>{},generators:d}}for(let n of e)n.register&&await n.register(t,r)}}}async function Vt(e){let{name:t,outDir:n}=e,r=M(t),i=Se(t),a=[],o=L(n,`${r}.plugin.ts`);return await x(o,`import {
12
12
  definePlugin,
13
13
  type AppAdapter,
14
14
  type AppModuleEntry,
@@ -365,7 +365,7 @@ describe('${s}', () => {
365
365
  `)}catch(e){console.error(` ✗ ${e instanceof Error?e.message:String(e)}`),process.exit(1)}}}),e.command(`start`).description(`Start production server`).option(`-e, --entry <file>`,`Entry file`,`dist/index.js`).option(`-p, --port <port>`,`Port number`).action(e=>{let t={NODE_ENV:`production`};e.port&&(t.PORT=String(e.port)),b(e.entry,t)}),e.command(`typecheck`).description(`Type-check the project with its own tsgo/tsc`).option(`--cwd <dir>`,`Directory to type-check`,`.`).option(`--no-typegen`,`Skip refreshing .kickjs/types first`).action(async e=>{let t=z(process.cwd(),e.cwd??`.`);e.typegen!==!1&&await Rn(t);let n=On(t);if(!n){console.error(`
366
366
  No type-checker found. Install one in this project:\n ${E(t)} add -D typescript (tsc)\n ${E(t)} add -D @typescript/native-preview (tsgo, faster)\n`),process.exit(1);return}let r=jt(n.cmd,n.args,{stdio:`inherit`,shell:n.shell,cwd:t});process.exit(r.status??1)}),e.command(`dev:debug`).description(`Start dev server with Node.js inspector attached`).option(`-e, --entry <file>`,`Entry file`,`src/index.ts`).option(`-p, --port <port>`,`Port number`).option(`--inspect-port <port>`,`Inspector port`,`9229`).option(`--inspect-host <host>`,`Inspector bind address (use 0.0.0.0 to reach it from outside a container)`,`127.0.0.1`).action(async e=>{let t=Number(e.inspectPort??`9229`),n=e.inspectHost??`127.0.0.1`;[`127.0.0.1`,`localhost`,`::1`].includes(n)||console.warn(` WARNING: the debugger is bound to ${n}, not loopback. Anyone who can\n reach port ${t} can run code in this process. Use it on a trusted\n network only, and prefer publishing the port from your container instead.`);let r;try{r=await In(t,n)}catch(e){console.error(`\n Could not open the inspector on ${t}: ${e.message??e}\n Another process may already hold it — try --inspect-port <port>.`),process.exit(1);return}console.log(` Debugger: ${r}`);try{await Ln(e.entry,e.port)}catch(e){console.error(`
367
367
  Dev server (debug) failed:`,e.message??e),process.exit(1)}})}function Bn(){try{let e=I(Nt(import.meta.url));return JSON.parse(H(L(e,`..`,`package.json`),`utf-8`)).version??`unknown`}catch{return`unknown`}}const Vn=new Set(Object.values(f).filter(e=>e.deprecated).map(e=>e.pkg));function Hn(e){let t=L(e,`package.json`);if(!V(t))return[];let n;try{n=JSON.parse(H(t,`utf-8`))}catch{return[]}let r={...n.dependencies,...n.devDependencies};return Object.keys(r).filter(e=>e===`@forinda/kickjs`||e.startsWith(`@forinda/kickjs-`)).toSorted().map(t=>{let n=null,i=L(e,`node_modules`,...t.split(`/`),`package.json`);if(V(i))try{n=JSON.parse(H(i,`utf-8`)).version??null}catch{}return{name:t,installed:n,declared:r[t]??null,deprecated:Vn.has(t)}})}function Un(e){let t=e;for(;;){if(V(L(t,`package.json`)))return t;let e=I(t);if(e===t)return null;t=e}}function Wn(e){e.command(`info`).description(`Print system and framework info`).action(()=>{let e=[``,` KickJS CLI v${Bn()}`,``,` System:`,` OS: ${It()} ${Lt()} (${Ft()})`,` Node: ${process.version}`],t=Un(process.cwd()),n=t?Hn(t):[];if(!t)e.push(``,` Packages: (not inside a project — no package.json found)`);else if(n.length===0)e.push(``,` Packages: (no @forinda/kickjs* dependencies in ${t})`);else{e.push(``,` Packages:`);let t=Math.max(...n.map(e=>e.name.length));for(let r of n){let n=r.installed??`${r.declared??`?`} (declared — not installed)`,i=r.deprecated?" [DEPRECATED — see `kick add --list --all`]":``;e.push(` ${r.name.padEnd(t+2)} ${n}${i}`)}}e.push(``),console.log(e.join(`
368
- `))})}const{bold:Y,dim:X,green:Gn,red:Kn,yellow:qn,blue:Jn}=O;function Yn(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=e%60,a=[];return t&&a.push(`${t}d`),n&&a.push(`${n}h`),r&&a.push(`${r}m`),a.push(`${i}s`),a.join(` `)}async function Xn(e){let t=await fetch(e,{signal:AbortSignal.timeout(5e3)});if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.json()}async function Zn(e,t){try{return await Xn(`${e}${t}`)}catch{return null}}async function Qn(e){let[t,n,r,i,a]=await Promise.all([Zn(e,`/health`),Zn(e,`/metrics`),Zn(e,`/routes`),Zn(e,`/container`),Zn(e,`/ws`)]);return{health:t,metrics:n,routes:r,container:i,ws:a}}function $n(e,t){let{health:n,metrics:r,routes:i,container:a,ws:o}=t,s=X(`─`.repeat(60));if(console.log(),console.log(Y(` KickJS Inspector`)+X(` → ${e}`)),console.log(s),n){let e=n.status===`healthy`?Gn(`● healthy`):Kn(`● `+n.status);console.log(` ${Y(`Health:`)} ${e}`)}else console.log(` ${Y(`Health:`)} ${Kn(`● unreachable`)}`);if(r){let e=((r.errorRate??0)*100).toFixed(1),t=r.errorRate>.1?Kn:r.errorRate>0?qn:Gn;console.log(` ${Y(`Uptime:`)} ${Yn(r.uptimeSeconds)}`),console.log(` ${Y(`Requests:`)} ${r.requests}`),console.log(` ${Y(`Errors:`)} ${r.serverErrors} server, ${r.clientErrors??0} client ${X(`(`)}${t(e+`%`)}${X(`)`)}`)}if(a&&console.log(` ${Y(`DI:`)} ${a.count} bindings`),o&&o.enabled&&console.log(` ${Y(`WS:`)} ${o.connections??0} connections, ${o.namespaces??0} namespaces`),i?.routes?.length){console.log(),console.log(Y(` Routes`)),console.log(s),console.log(` ${X(`METHOD`)} ${X(`PATH`.padEnd(36))} ${X(`CONTROLLER`)}`);for(let e of i.routes){let t=e.path.length>36?e.path.slice(0,33)+`...`:e.path.padEnd(36);console.log(` ${ce(e.method)} ${t} ${Jn(e.controller)}.${X(e.handler)}`)}}console.log(s),console.log()}function er(e){e.command(`inspect [url]`).description(`Connect to a running KickJS app and display debug info`).option(`-p, --port <port>`,`Override port`).option(`-w, --watch`,`Poll every 5 seconds`).option(`-j, --json`,`Output raw JSON`).action(async(e,t)=>{let n=e??`http://localhost:3000`;if(t.port)try{let e=new URL(n);e.port=t.port,n=e.origin}catch{n=`http://localhost:${t.port}`}let r=`${n.replace(/\/$/,``)}/_debug`,i=async()=>{try{let e=await Qn(r);t.json?console.log(JSON.stringify(e,null,2)):$n(n,e)}catch(e){t.json?console.log(JSON.stringify({error:String(e)})):(console.error(Kn(` ✖ Could not connect to ${n}`)),console.error(X(` ${e instanceof Error?e.message:String(e)}`))),t.watch||(process.exitCode=1)}};if(t.watch){let e=async()=>{process.stdout.write(`\x1B[2J\x1B[H`),await i()};await e(),setInterval(e,5e3)}else await i()})}const tr={express:{name:`expressRuntime`,from:`@forinda/kickjs`},fastify:{name:`fastifyRuntime`,from:`@forinda/kickjs/fastify`},h3:{name:`h3Runtime`,from:`@forinda/kickjs/h3`}},nr=`// Express needs a body parser; Fastify and h3 parse bodies natively.`;function rr(e,t,n,i=`src/index.ts`){let a={source:e,changes:[],manual:[],blocked:!1},o=tr[t],c=tr[n],l=or(ar(i,a.source));if(!l)return a.manual.push(`No bootstrap({ ... }) call in ${i}: set \`runtime: ${c.name}()\` (import { ${c.name} } from '${c.from}') yourself.`),a;let u=sr(l,`runtime`),d=`${c.name}()`;if(u){let e=u.value,r=ur(ar(i,a.source),o.from,o.name);if(u.shorthand||e.type!==`CallExpression`||e.callee?.type!==`Identifier`||r===void 0||e.callee.name!==r){let e=a.source.slice(u.start,u.end);return a.manual.push(`\`${e}\` in ${i} isn't a call to ${o.name}(): set it to ${d} (import { ${c.name} } from '${c.from}') yourself.`),a.blocked=!0,a}let s=e.arguments;if(s.length>0){let e=a.source.slice(s[0].start,s.at(-1).end);a.manual.push(`The ${t} runtime had options (${e}); ${n} takes its own — see guide/http-runtimes.`)}a.source=a.source.slice(0,e.start)+d+a.source.slice(e.end)}else a.source=cr(a.source,l,`runtime: ${d}`);if(a.changes.push(`runtime: ${d}`),a.source=s(a.source,{from:c.from,names:[c.name]},i),a.source=dr(a.source,o.from,o.name,i),t===`express`&&n!==`express`){let e=lr(a.source,i);e!==a.source&&(a.source=fr(e,`express`,i),a.changes.push(`removed express.json() — ${n} parses bodies itself`))}else if(n===`express`&&t!==`express`){let e=r(a.source,[{import:{from:`express`,default:`express`},slot:`middleware`,code:`${nr}\nexpress.json()`}],void 0,i);a.source=e.source,e.added.length>0&&a.changes.push(`added express.json() to middlewares`),e.manual.length>0&&a.manual.push(`Add express.json() to bootstrap({ middlewares }) yourself.`)}return a}function ir(e,t,n=`kick.config.ts`){let r=ar(n,e).body.find(e=>e.type===`ExportDefaultDeclaration`)?.declaration;for(;r&&(r.type===`TSSatisfiesExpression`||r.type===`TSAsExpression`);)r=r.expression;if(r?.type===`CallExpression`&&(r=r.arguments?.[0]),r?.type!==`ObjectExpression`)return null;let i=sr(r,`runtime`);if(!i)return cr(e,r,`runtime: '${t}'`);let a=i.value;if(a.type!==`Literal`||typeof a.value!=`string`)return null;let o=e[a.start]===`"`?`"`:`'`;return`${e.slice(0,a.start)}${o}${t}${o}${e.slice(a.end)}`}function ar(e,t){return Pt(e,t).program}function or(e){let t,n=e=>{if(t||!e||typeof e!=`object`)return;if(Array.isArray(e))return e.forEach(n);let r=e;if(r.type===`CallExpression`&&r.callee?.type===`Identifier`&&r.callee.name===`bootstrap`&&r.arguments?.[0]?.type===`ObjectExpression`)t=r.arguments[0];else for(let e in r)n(r[e])};return n(e),t}function sr(e,t){return e.properties.find(e=>e.type===`Property`&&(e.key?.name??e.key?.value)===t)}function cr(e,t,n){let r=t.properties[0];if(!r)return`${e.slice(0,t.start)}{ ${n} }${e.slice(t.end)}`;let i=e.lastIndexOf(`
368
+ `))})}const{bold:Y,dim:X,green:Gn,red:Kn,yellow:qn,blue:Jn}=O;function Yn(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=e%60,a=[];return t&&a.push(`${t}d`),n&&a.push(`${n}h`),r&&a.push(`${r}m`),a.push(`${i}s`),a.join(` `)}async function Xn(e){let t=await fetch(e,{signal:AbortSignal.timeout(5e3)});if(!t.ok)throw Error(`${t.status} ${t.statusText}`);return t.json()}async function Zn(e,t){try{return await Xn(`${e}${t}`)}catch{return null}}async function Qn(e){let[t,n,r,i,a]=await Promise.all([Zn(e,`/health`),Zn(e,`/metrics`),Zn(e,`/routes`),Zn(e,`/container`),Zn(e,`/ws`)]);return{health:t,metrics:n,routes:r,container:i,ws:a}}function $n(e,t){let{health:n,metrics:r,routes:i,container:a,ws:o}=t,s=X(`─`.repeat(60));if(console.log(),console.log(Y(` KickJS Inspector`)+X(` → ${e}`)),console.log(s),n){let e=n.status===`healthy`?Gn(`● healthy`):Kn(`● `+n.status);console.log(` ${Y(`Health:`)} ${e}`)}else console.log(` ${Y(`Health:`)} ${Kn(`● unreachable`)}`);if(r){let e=((r.errorRate??0)*100).toFixed(1),t=r.errorRate>.1?Kn:r.errorRate>0?qn:Gn;console.log(` ${Y(`Uptime:`)} ${Yn(r.uptimeSeconds)}`),console.log(` ${Y(`Requests:`)} ${r.requests}`),console.log(` ${Y(`Errors:`)} ${r.serverErrors} server, ${r.clientErrors??0} client ${X(`(`)}${t(e+`%`)}${X(`)`)}`)}if(a&&console.log(` ${Y(`DI:`)} ${a.count} bindings`),o&&o.enabled&&console.log(` ${Y(`WS:`)} ${o.connections??0} connections, ${o.namespaces??0} namespaces`),i?.routes?.length){console.log(),console.log(Y(` Routes`)),console.log(s),console.log(` ${X(`METHOD`)} ${X(`PATH`.padEnd(36))} ${X(`CONTROLLER`)}`);for(let e of i.routes){let t=e.path.length>36?e.path.slice(0,33)+`...`:e.path.padEnd(36);console.log(` ${ce(e.method)} ${t} ${Jn(e.controller)}.${X(e.handler)}`)}}console.log(s),console.log()}function er(e){e.command(`inspect [url]`).description(`Connect to a running KickJS app and display debug info`).option(`-p, --port <port>`,`Override port`).option(`-w, --watch`,`Poll every 5 seconds`).option(`-j, --json`,`Output raw JSON`).action(async(e,t)=>{let n=e??`http://localhost:3000`;if(t.port)try{let e=new URL(n);e.port=t.port,n=e.origin}catch{n=`http://localhost:${t.port}`}let r=`${n.replace(/\/$/,``)}/_debug`,i=async()=>{try{let e=await Qn(r);t.json?console.log(JSON.stringify(e,null,2)):$n(n,e)}catch(e){t.json?console.log(JSON.stringify({error:String(e)})):(console.error(Kn(` ✖ Could not connect to ${n}`)),console.error(X(` ${e instanceof Error?e.message:String(e)}`))),t.watch||(process.exitCode=1)}};if(t.watch){let e=async()=>{process.stdout.write(`\x1B[2J\x1B[H`),await i()};await e(),setInterval(e,5e3)}else await i()})}const tr={express:{name:`expressRuntime`,from:`@forinda/kickjs`},fastify:{name:`fastifyRuntime`,from:`@forinda/kickjs/fastify`},h3:{name:`h3Runtime`,from:`@forinda/kickjs/h3`}},nr=`// Express needs a body parser; Fastify and h3 parse bodies natively.`;function rr(e,t,n,i=`src/index.ts`){let a={source:e,changes:[],manual:[],blocked:!1},o=tr[t],c=tr[n],l=or(ar(i,a.source));if(!l)return a.manual.push(`No bootstrap({ ... }) call in ${i}: set \`runtime: ${c.name}()\` (import { ${c.name} } from '${c.from}') yourself.`),a;let u=sr(l,`runtime`),d=`${c.name}()`;if(u){let e=u.value,r=ur(ar(i,a.source),o.from,o.name);if(u.shorthand||e.type!==`CallExpression`||e.callee?.type!==`Identifier`||r===void 0||e.callee.name!==r){let e=a.source.slice(u.start,u.end);return a.manual.push(`\`${e}\` in ${i} isn't a call to ${o.name}(): set it to ${d} (import { ${c.name} } from '${c.from}') yourself.`),a.blocked=!0,a}let s=e.arguments;if(s.length>0){let e=a.source.slice(s[0].start,s.at(-1).end);a.manual.push(`The ${t} runtime had options (${e}); ${n} takes its own — see https://kickjs.app/guide/http-runtimes`)}a.source=a.source.slice(0,e.start)+d+a.source.slice(e.end)}else a.source=cr(a.source,l,`runtime: ${d}`);if(a.changes.push(`runtime: ${d}`),a.source=s(a.source,{from:c.from,names:[c.name]},i),a.source=dr(a.source,o.from,o.name,i),t===`express`&&n!==`express`){let e=lr(a.source,i);e!==a.source&&(a.source=fr(e,`express`,i),a.changes.push(`removed express.json() — ${n} parses bodies itself`))}else if(n===`express`&&t!==`express`){let e=r(a.source,[{import:{from:`express`,default:`express`},slot:`middleware`,code:`${nr}\nexpress.json()`}],void 0,i);a.source=e.source,e.added.length>0&&a.changes.push(`added express.json() to middlewares`),e.manual.length>0&&a.manual.push(`Add express.json() to bootstrap({ middlewares }) yourself.`)}return a}function ir(e,t,n=`kick.config.ts`){let r=ar(n,e).body.find(e=>e.type===`ExportDefaultDeclaration`)?.declaration;for(;r&&(r.type===`TSSatisfiesExpression`||r.type===`TSAsExpression`);)r=r.expression;if(r?.type===`CallExpression`&&(r=r.arguments?.[0]),r?.type!==`ObjectExpression`)return null;let i=sr(r,`runtime`);if(!i)return cr(e,r,`runtime: '${t}'`);let a=i.value;if(a.type!==`Literal`||typeof a.value!=`string`)return null;let o=e[a.start]===`"`?`"`:`'`;return`${e.slice(0,a.start)}${o}${t}${o}${e.slice(a.end)}`}function ar(e,t){return Pt(e,t).program}function or(e){let t,n=e=>{if(t||!e||typeof e!=`object`)return;if(Array.isArray(e))return e.forEach(n);let r=e;if(r.type===`CallExpression`&&r.callee?.type===`Identifier`&&r.callee.name===`bootstrap`&&r.arguments?.[0]?.type===`ObjectExpression`)t=r.arguments[0];else for(let e in r)n(r[e])};return n(e),t}function sr(e,t){return e.properties.find(e=>e.type===`Property`&&(e.key?.name??e.key?.value)===t)}function cr(e,t,n){let r=t.properties[0];if(!r)return`${e.slice(0,t.start)}{ ${n} }${e.slice(t.end)}`;let i=e.lastIndexOf(`
369
369
  `,r.start)+1,a=e.slice(i,r.start);return/^\s*$/.test(a)?`${e.slice(0,r.start)}${n},\n${a}${e.slice(r.start)}`:`${e.slice(0,r.start)}${n}, ${e.slice(r.start)}`}function lr(e,t){let n=or(ar(t,e)),r=n&&sr(n,`middlewares`);if(!r||r.value.type!==`ArrayExpression`)return e;let i=r.value.elements.find(e=>e?.type===`CallExpression`&&e.callee?.type===`MemberExpression`&&e.callee.object?.name===`express`&&e.callee.property?.name===`json`);if(!i)return e;let a=i.start,o=i.end,s=e.slice(o).match(/^\s*,/);s&&(o+=s[0].length);let c=e.lastIndexOf(`
370
370
  `,a)+1;if(/^\s*$/.test(e.slice(c,a))){a=c;let t=e.lastIndexOf(`
371
371
  `,a-2)+1;e.slice(t,a-1).trim()===nr&&(a=t);let n=e.indexOf(`
@@ -682,7 +682,7 @@ server.on('exit', () => {
682
682
  Cancelled.
683
683
  `);return}await Et(c,{recursive:!0,force:!0}),console.log(` Deleted: ${c}`);let l=L(n,`index.ts`);if(await le(l)){let e=await W(l,`utf-8`),t=e,n=RegExp(`^import\\s*\\{\\s*${ve(o)}Module\\s*\\}\\s*from\\s*['"][^'"]*${ve(s)}(?:/[^'"]*)?['"].*\\n?`,`gm`);e=e.replace(n,``),e=Yr(e,o),e=e.replace(/\n{3,}/g,`
684
684
 
685
- `),e!==t&&(await x(l,e),console.log(` Unregistered: ${o}Module from ${l}`))}console.log(`\n Module '${s}' removed.\n`)}function Zr(e){e.command(`remove`).alias(`rm`).description(`Remove generated code`).command(`module <names...>`).description(`Remove one or more modules (e.g. kick rm module user task)`).option(`--modules-dir <dir>`,`Modules directory`).option(`--pluralize`,`The module folder is pluralized (users/ for user)`).option(`--no-pluralize`,`The module folder is the name as typed (the default)`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=await j(process.cwd()),r=k(n),i=t.modulesDir??r.dir??`src/modules`,a=A(t.pluralize,r);for(let n of e)await Xr({name:n,modulesDir:z(i),force:t.force,pluralize:a})})}function Qr(e){if(e!==void 0){if(e===`false`||e===`off`||e===`none`)return!1;if(e===`zod`)return`zod`;if(e===`kickjs-schema`||e===`schema`)return`kickjs-schema`;console.warn(` kick typegen: unknown --schema-validator '${e}' (supported: 'zod', 'kickjs-schema', 'false'). Falling back to project config.`)}}function $r(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function ei(e){e.command(`typegen`).description(`Generate type-safe DI registry and module types into .kickjs/types/`).option(`-w, --watch`,`Watch source files and regenerate on change`).option(`-s, --src <dir>`,`Source directory to scan`,`src`).option(`-o, --out <dir>`,`Output directory`,`.kickjs/types`).option(`--silent`,`Suppress output`).option(`--allow-duplicates`,`Auto-namespace duplicate class names instead of failing (use with caution)`).option(`--schema-validator <name>`,`Schema validator for body/query/params typing (currently 'zod' or 'false')`).option(`--env-file <path>`,`Path to env schema file for KickEnv typing (default 'src/env.ts'; pass 'false' to disable)`).option(`--check`,`CI gate: exit non-zero if any generated file in .kickjs/types/ is out of date (routes, env, db, assets, adopter plugins) instead of writing it`).option(`--fix`,`Patch module import.meta.glob() calls to cover decorated classes that aren't loaded by any glob (orphans)`).option(`--list`,"List every registered typegen plugin id (use to populate `typegen.disable`)").option(`--no-cache`,`Disable the persistent scan cache; re-read + re-extract every file from cold`).action(async e=>{let t=N(process.cwd()),n=await j(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-BCMbxzi5.mjs`),{builtinCliPlugins:t}=await import(`./builtins-4OFjCWYj.mjs`),r=e([...t,...n?.plugins??[]],n?.commands??[]),i=new Set(n?.typegen?.disable??[]);if(r.typegens.length===0){console.log(` No typegen plugins registered.`);return}let a=Math.max(...r.typegens.map(e=>e.id.length));console.log(`
685
+ `),e!==t&&(await x(l,e),console.log(` Unregistered: ${o}Module from ${l}`))}console.log(`\n Module '${s}' removed.\n`)}function Zr(e){e.command(`remove`).alias(`rm`).description(`Remove generated code`).command(`module <names...>`).description(`Remove one or more modules (e.g. kick rm module user task)`).option(`--modules-dir <dir>`,`Modules directory`).option(`--pluralize`,`The module folder is pluralized (users/ for user)`).option(`--no-pluralize`,`The module folder is the name as typed (the default)`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=await j(process.cwd()),r=k(n),i=t.modulesDir??r.dir??`src/modules`,a=A(t.pluralize,r);for(let n of e)await Xr({name:n,modulesDir:z(i),force:t.force,pluralize:a})})}function Qr(e){if(e!==void 0){if(e===`false`||e===`off`||e===`none`)return!1;if(e===`zod`)return`zod`;if(e===`kickjs-schema`||e===`schema`)return`kickjs-schema`;console.warn(` kick typegen: unknown --schema-validator '${e}' (supported: 'zod', 'kickjs-schema', 'false'). Falling back to project config.`)}}function $r(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function ei(e){e.command(`typegen`).description(`Generate type-safe DI registry and module types into .kickjs/types/`).option(`-w, --watch`,`Watch source files and regenerate on change`).option(`-s, --src <dir>`,`Source directory to scan`,`src`).option(`-o, --out <dir>`,`Output directory`,`.kickjs/types`).option(`--silent`,`Suppress output`).option(`--allow-duplicates`,`Auto-namespace duplicate class names instead of failing (use with caution)`).option(`--schema-validator <name>`,`Schema validator for body/query/params typing (currently 'zod' or 'false')`).option(`--env-file <path>`,`Path to env schema file for KickEnv typing (default 'src/env.ts'; pass 'false' to disable)`).option(`--check`,`CI gate: exit non-zero if any generated file in .kickjs/types/ is out of date (routes, env, db, assets, adopter plugins) instead of writing it`).option(`--fix`,`Patch module import.meta.glob() calls to cover decorated classes that aren't loaded by any glob (orphans)`).option(`--list`,"List every registered typegen plugin id (use to populate `typegen.disable`)").option(`--no-cache`,`Disable the persistent scan cache; re-read + re-extract every file from cold`).action(async e=>{let t=N(process.cwd()),n=await j(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-CFT_4ept.mjs`),{builtinCliPlugins:t}=await import(`./builtins-cZC3AQMK.mjs`),r=e([...t,...n?.plugins??[]],n?.commands??[]),i=new Set(n?.typegen?.disable??[]);if(r.typegens.length===0){console.log(` No typegen plugins registered.`);return}let a=Math.max(...r.typegens.map(e=>e.id.length));console.log(`
686
686
  Registered typegen plugins:
687
687
  `);for(let e of r.typegens){let t=i.has(e.id)?` (disabled)`:``,n=`${e.id.replace(/\//g,`__`)}${e.outExtension??`.d.ts`}`;console.log(` ${e.id.padEnd(a+2)}→ .kickjs/types/${n}${t}`),console.log(` ${` `.repeat(a+2)} watches: ${e.inputs.join(`, `)||`(none)`}`)}console.log(`
688
688
  Disable one in kick.config.ts:
@@ -876,4 +876,4 @@ declare global {
876
876
  export {}
877
877
  `}const Ga=()=>({id:`kick/env`,outExtension:`.ts`,inputs:[`src/env.ts`,`src/**/env.ts`,`src/**/*.env.ts`],async generate(e){let t=qa(e);if(t===!1)return null;let n=await e.getScanResult({root:Ka(e),cwd:e.cwd,envFile:t});if(!n.env)return null;let r=e.config?.typegen?.schemaValidator??`zod`,i=F.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return Wa(n.env,i,r)}});function Ka(e){return F.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function qa(e){return e.config?.typegen?.envFile}function Ja(e){return F.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Ya(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function Xa(e){return{root:Ja(e),cwd:e.cwd,envFile:Ya(e)}}const Za=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult(Xa(e)),n=F.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return et(t.classes,n,r)}}),Qa=()=>({id:`kick/services`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult(Xa(e)),n=new Set(t.collisions.map(e=>e.className)),r=it(t.classes,t.tokens,t.injects,n);return at(`ServiceToken`,r,"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),$a=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult(Xa(e));return at(`ModuleToken`,Qe(t.classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),eo=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult(Xa(e));return $e(t.pluginsAndAdapters)}}),to=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult(Xa(e));return t.contextKeys.length===0?null:dt(t.contextKeys)}}),no=()=>({id:`kick/route-flags`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult(Xa(e));return st(t.routeFlags)}}),ro={express:{subpath:`@forinda/kickjs/express`,typeName:`ExpressRuntimeTypes`},fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},io=[t({name:`kick/init`,register:zt}),t({name:`kick/generate`,register:bn}),t({name:`kick/run`,register:zn}),t({name:`kick/info`,register:Wn}),t({name:`kick/inspect`,register:er}),t({name:`kick/add`,register:_}),t({name:`kick/runtime-swap`,register:_r}),t({name:`kick/list`,register:o}),t({name:`kick/explain`,register:Ar}),t({name:`kick/mcp`,register:Vr}),t({name:`kick/tinker`,register:Gr}),t({name:`kick/remove`,register:Zr}),t({name:`kick/typegen`,register:ei}),t({name:`kick/check`,register:yi}),t({name:`kick/doctor`,register:Ve}),t({name:`kick/env-command`,register:Di}),t({name:`kick/codemod`,register:ki}),t({name:`kick/deploy`,register:$i}),t({name:`kick/registry`,typegens:[Za()]}),t({name:`kick/services`,typegens:[Qa()]}),t({name:`kick/modules`,typegens:[$a()]}),t({name:`kick/plugins`,typegens:[eo()]}),t({name:`kick/context`,typegens:[to()]}),t({name:`kick/route-flags`,typegens:[no()]}),t({name:`kick/assets`,typegens:[ea()]}),t({name:`kick/routes`,typegens:[ua()]}),t({name:`kick/client`,typegens:[Ua()]}),t({name:`kick/env`,typegens:[Ga()]}),t({name:`kick/runtime`,typegens:[{id:`kick/runtime`,outExtension:`.ts`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`],async generate(e){let t=e.config?.runtime??`express`;if(t!==`express`&&t!==`fastify`&&t!==`h3`)return null;let{subpath:n,typeName:r}=ro[t];return[`// Runtime escape-hatch types for the '${t}' engine (kick.config runtime).`,`declare module '@forinda/kickjs' {`,` interface KickRuntimeRegister {`,` runtime: import('${n}').${r}`,` }`,`}`,``,`export {}`,``].join(`
878
878
  `)}}]})];export{Tn as applyDisableFilter,En as n,Bt as r,Dn as runAllPluginTypegens,io as t};
879
- //# sourceMappingURL=run-plugins-BONtomzM.mjs.map
879
+ //# sourceMappingURL=run-plugins-lJqFqRny.mjs.map