@forinda/kickjs-cli 8.16.0 → 8.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/{agent-docs-DhiaLsBj.mjs → agent-docs-BVFt7K8T.mjs} +3 -3
  2. package/dist/{agent-docs-DhiaLsBj.mjs.map → agent-docs-BVFt7K8T.mjs.map} +1 -1
  3. package/dist/{agent-docs-lNvu1K1x.mjs → agent-docs-DBLN2Mp9.mjs} +2 -2
  4. package/dist/{build-vY0bmwuH.mjs → build-BKGmBYPE.mjs} +3 -3
  5. package/dist/{build-vY0bmwuH.mjs.map → build-BKGmBYPE.mjs.map} +1 -1
  6. package/dist/{build-BNHMWtNY.mjs → build-BmjXHtAh.mjs} +2 -2
  7. package/dist/{builtins-CRRb7Lq1.mjs → builtins-C-qFcIBD.mjs} +2 -2
  8. package/dist/{builtins-tE4nrAZ_.mjs → builtins-NIDfVClB.mjs} +4 -4
  9. package/dist/cli.mjs +2 -2
  10. package/dist/{config-mXO3F69m.mjs → config-C881BGnv.mjs} +2 -2
  11. package/dist/{config-zWl1-NCq.mjs → config-CgoZjmsu.mjs} +3 -3
  12. package/dist/{config-zWl1-NCq.mjs.map → config-CgoZjmsu.mjs.map} +1 -1
  13. package/dist/{doctor-z92r35fo.mjs → doctor-CWP1-2fB.mjs} +4 -4
  14. package/dist/{doctor-z92r35fo.mjs.map → doctor-CWP1-2fB.mjs.map} +1 -1
  15. package/dist/{fullstack-BqevN8LJ.mjs → fullstack-BPB6BkL8.mjs} +4 -4
  16. package/dist/{fullstack-BqevN8LJ.mjs.map → fullstack-BPB6BkL8.mjs.map} +1 -1
  17. package/dist/{fullstack-eMi-9BtZ.mjs → fullstack-_0qGKsG7.mjs} +3 -3
  18. package/dist/index.mjs +2 -2
  19. package/dist/{plugin-CH4X4T0O.mjs → plugin-KpSiVmlT.mjs} +2 -2
  20. package/dist/{plugin-BbbHEAzr.mjs → plugin-_Xkj7vNO.mjs} +2 -2
  21. package/dist/{project-D96UoR0P.mjs → project-CO9buk5F.mjs} +5 -5
  22. package/dist/{project-D96UoR0P.mjs.map → project-CO9buk5F.mjs.map} +1 -1
  23. package/dist/{project-Bp6SIRyt.mjs → project-qHDV333j.mjs} +4 -4
  24. package/dist/{project-root-Bw3CEPC7.mjs → project-root-BAZV1qId.mjs} +3 -3
  25. package/dist/{project-root-Bw3CEPC7.mjs.map → project-root-BAZV1qId.mjs.map} +1 -1
  26. package/dist/{project-root-DN0YbQE5.mjs → project-root-DdPFoCw6.mjs} +2 -2
  27. package/dist/{rolldown-runtime-CYy3EyO3.mjs → rolldown-runtime-B0Wm12ok.mjs} +1 -1
  28. package/dist/{run-plugins-f7i7TlPV.mjs → run-plugins-DLCZx7uc.mjs} +4 -4
  29. package/dist/{run-plugins-f7i7TlPV.mjs.map → run-plugins-DLCZx7uc.mjs.map} +1 -1
  30. package/dist/{typegen-_x_Q5O0b.mjs → typegen-B8uRTy_3.mjs} +4 -4
  31. package/dist/{typegen-Bq4Fis9G.mjs → typegen-DGq3DowV.mjs} +5 -5
  32. package/dist/{typegen-Bq4Fis9G.mjs.map → typegen-DGq3DowV.mjs.map} +1 -1
  33. package/dist/{types-BLZecxnS.mjs → types-CokUufqE.mjs} +1 -1
  34. package/package.json +4 -4
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.16.0
2
+ * @forinda/kickjs-cli v8.16.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{f as e,o as t,r as n}from"./config-mXO3F69m.mjs";import{C as r,a as i,b as a,o,r as s,s as c,v as l,y as u}from"./agent-docs-lNvu1K1x.mjs";import{existsSync as d,readFileSync as f,writeFileSync as p}from"node:fs";import{dirname as m,join as h,posix as g,relative as _,resolve as v}from"node:path";import{fileURLToPath as y}from"node:url";import{execFile as b,execFileSync as x,execSync as S,spawnSync as C}from"node:child_process";import{promisify as w}from"node:util";import{randomBytes as ee}from"node:crypto";import{parseSync as T}from"oxc-parser";const te=w(b),E=/[&|<>^"'`(){}[\];!%\r\n\\]/;function D(e,t,n=process.platform){if(n!==`win32`)return[e,t];if(E.test(e)||t.some(e=>E.test(e)))return null;let r=[e,...t].map(e=>e.includes(` `)?`"${e}"`:e).join(` `);return[process.env.ComSpec||`cmd.exe`,[`/d`,`/s`,`/c`,r]]}function O(e,t,n={}){let r=D(e,t);if(!r)return null;try{return x(r[0],r[1],{encoding:`utf-8`,timeout:n.timeout??5e3,cwd:n.cwd,stdio:[`ignore`,`pipe`,`ignore`],windowsHide:!0}).toString().trim()||null}catch{return null}}function k(e,t,n={}){let r=D(e,t);if(!r)throw Error(`Refusing to run '${e}': unsafe arguments`);x(r[0],r[1],{cwd:n.cwd,stdio:`inherit`,windowsHide:!0})}function A(e,t,n){S(e,{cwd:t,stdio:`inherit`,env:n?{...process.env,...n}:process.env})}function j(e,t,n){let r=C(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function M(e,t,n={}){let r=D(e,t);if(!r)return null;try{let{stdout:e}=await te(r[0],r[1],{encoding:`utf-8`,timeout:n.timeout??5e3,cwd:n.cwd,windowsHide:!0});return e.toString().trim()||null}catch{return null}}function ne(e,t){let n=e[t];if(!n)throw Error(`generatePackageJson: missing resolved version for ${t}. Add it to SIBLING_PACKAGES or THIRD_PARTY_PACKAGES in generators/project.ts.`);return n}function N(e,t){return Object.fromEntries(e.toSorted().map(e=>[e,ne(t,e)]))}function re(e){try{let t=x(e,[`--version`],{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`],timeout:1e4}).trim();return/^\d+\.\d+\.\d+$/.test(t)?`${e}@${t}`:void 0}catch{return}}function ie(e){let t=e?.match(/@(\d+)\.(\d+)\./);return t?[Number(t[1]),Number(t[2])]:void 0}function ae(e,t){let n=ie(t)?.[0];return e===`yarn`&&n!==void 0&&n>=2?`nodeLinker: node-modules
11
+ import{f as e,o as t,r as n}from"./config-C881BGnv.mjs";import{C as r,a as i,b as a,o,r as s,s as c,v as l,y as u}from"./agent-docs-DBLN2Mp9.mjs";import{existsSync as d,readFileSync as f,writeFileSync as p}from"node:fs";import{dirname as m,join as h,posix as g,relative as _,resolve as v}from"node:path";import{fileURLToPath as y}from"node:url";import{execFile as b,execFileSync as x,execSync as S,spawnSync as C}from"node:child_process";import{promisify as w}from"node:util";import{randomBytes as ee}from"node:crypto";import{parseSync as T}from"oxc-parser";const te=w(b),E=/[&|<>^"'`(){}[\];!%\r\n\\]/;function D(e,t,n=process.platform){if(n!==`win32`)return[e,t];if(E.test(e)||t.some(e=>E.test(e)))return null;let r=[e,...t].map(e=>e.includes(` `)?`"${e}"`:e).join(` `);return[process.env.ComSpec||`cmd.exe`,[`/d`,`/s`,`/c`,r]]}function O(e,t,n={}){let r=D(e,t);if(!r)return null;try{return x(r[0],r[1],{encoding:`utf-8`,timeout:n.timeout??5e3,cwd:n.cwd,stdio:[`ignore`,`pipe`,`ignore`],windowsHide:!0}).toString().trim()||null}catch{return null}}function k(e,t,n={}){let r=D(e,t);if(!r)throw Error(`Refusing to run '${e}': unsafe arguments`);x(r[0],r[1],{cwd:n.cwd,stdio:`inherit`,windowsHide:!0})}function A(e,t,n){S(e,{cwd:t,stdio:`inherit`,env:n?{...process.env,...n}:process.env})}function j(e,t,n){let r=C(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function M(e,t,n={}){let r=D(e,t);if(!r)return null;try{let{stdout:e}=await te(r[0],r[1],{encoding:`utf-8`,timeout:n.timeout??5e3,cwd:n.cwd,windowsHide:!0});return e.toString().trim()||null}catch{return null}}function ne(e,t){let n=e[t];if(!n)throw Error(`generatePackageJson: missing resolved version for ${t}. Add it to SIBLING_PACKAGES or THIRD_PARTY_PACKAGES in generators/project.ts.`);return n}function N(e,t){return Object.fromEntries(e.toSorted().map(e=>[e,ne(t,e)]))}function re(e){try{let t=x(e,[`--version`],{encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`],timeout:1e4}).trim();return/^\d+\.\d+\.\d+$/.test(t)?`${e}@${t}`:void 0}catch{return}}function ie(e){let t=e?.match(/@(\d+)\.(\d+)\./);return t?[Number(t[1]),Number(t[2])]:void 0}function ae(e,t){let n=ie(t)?.[0];return e===`yarn`&&n!==void 0&&n>=2?`nodeLinker: node-modules
12
12
  `:void 0}function oe(e,t,n,r){return JSON.stringify({name:e,...r?{packageManager:r}:{},version:`0.0.0`,type:`module`,scripts:{dev:`kick dev`,build:`kick build`,start:`kick start`,test:`vitest run --passWithNoTests`,...n.scripts},dependencies:N(n.dependencies,t),devDependencies:N(n.devDependencies,t)},null,2)}function se(e,t){let n=Object.entries(t);if(n.length===0)return e;let r=e===``?[]:e.replace(/\n$/,``).split(`
13
13
  `),i=e=>e.trim().replace(/^['"]|['"]$/g,``),a=e=>/^[\w-]+$/.test(e)?e:`'${e}'`,o=(e,t)=>{let n=r.findIndex(t=>t.replace(/\s+$/,``)===`${e}:`);if(n===-1){if(!t)return;r.length>0&&r[r.length-1]!==``&&r.push(``),r.push(`${e}:`),n=r.length-1}let i=n+1;for(let e=n+1;e<r.length&&/^(\s|$)/.test(r[e]);e++)r[e].trim()!==``&&(i=e+1);return{start:n,end:i}},s=[];for(let[e,t]of n){let{start:n,end:c}=o(`allowBuilds`,!0),l=r.slice(n+1,c).findIndex(t=>i(t.split(`:`)[0])===e),u=l===-1?void 0:/:\s*(true|false)\s*$/.exec(r[n+1+l]);if(u){s.push([e,u[1]===`true`]);continue}let d=` ${a(e)}: ${t}`;l===-1?r.splice(c,0,d):r[n+1+l]=d,s.push([e,t])}let c=[`onlyBuiltDependencies`,`ignoredBuiltDependencies`];for(let[e,t]of s){if(c.some(t=>{let n=o(t,!1);return n!==void 0&&r.slice(n.start+1,n.end).some(t=>i(t.replace(/^\s*-/,``))===e)}))continue;let{end:n}=o(t?c[0]:c[1],!0);r.splice(n,0,` - ${a(e)}`)}return`${r.join(`
14
14
  `)}\n`}const P=`node:22-slim`,ce={pnpm:{lockfile:`pnpm-lock.yaml`,installFiles:[`pnpm-workspace.yaml`],install:`pnpm install --frozen-lockfile`,installProd:`pnpm install --prod --frozen-lockfile`,run:e=>`pnpm run ${e}`,image:P,setup:`RUN corepack enable`},npm:{lockfile:`package-lock.json`,installFiles:[],install:`npm ci`,installProd:`npm ci --omit=dev`,run:e=>`npm run ${e}`,image:P},yarn:{lockfile:`yarn.lock`,installFiles:[],install:`yarn install --frozen-lockfile`,installProd:`yarn install --production --frozen-lockfile`,run:e=>`yarn run ${e}`,image:P,setup:`RUN corepack enable`},bun:{lockfile:`bun.lock`,installFiles:[],install:`bun install --frozen-lockfile`,installProd:`bun install --production --frozen-lockfile`,run:e=>`bun run ${e}`,image:`oven/bun:1`}},F={lockfile:`yarn.lock`,installFiles:[`.yarnrc.yml`],install:`yarn install --immutable`,installProd:`yarn workspaces focus --all --production`,run:e=>`yarn run ${e}`,image:P,setup:`RUN corepack enable`},le={api:`docker run -p 3000:3000 <name>`,inertia:`docker run -p 3000:3000 -e SESSION_SECRET=<a long random string> -e APP_URL=<https://your.site> <name>`,fullstack:`docker run -p 3000:3000 <name>`};function ue(e,t,n,r){let[i=0,a=0]=ie(r)??[],o=t===`yarn`&&i>=2?i>=4?F:{...F,installProd:F.install}:t===`bun`&&r&&(i<1||i===1&&a<2)?{...ce.bun,lockfile:`bun.lockb`}:ce[t],s=`${o.setup?`\n${o.setup}`:``}
@@ -124,8 +124,8 @@ CMD ["node", "dist/index.js"]
124
124
  `),console.log(p.replace(/^/gm,` `)),console.log());let m=[...new Set(e.map(e=>De[e]).filter(Boolean))];for(let e of await s(g,m,n))console.log(` Created ${e}`)}}w?console.log(` Done!
125
125
  `):(console.log(` Finished with errors — the install above did not complete.
126
126
  `),process.exitCode=1)})}const tt=m(y(import.meta.url));function nt(t){return{kick:n(t,`kick`),runDev:e(t,`dev`),runBuild:e(t,`build`),runStart:e(t,`start`),runTest:e(t,`test`)}}const Q=JSON.parse(f([h(tt,`..`,`package.json`),h(tt,`..`,`..`,`package.json`)].find(d),`utf-8`)),rt=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-schema`,`@forinda/kickjs-vite`,`@forinda/kickjs-swagger`,`@forinda/kickjs-ws`,`@forinda/kickjs-queue`,`@forinda/kickjs-devtools`,`@forinda/kickjs-testing`,`@forinda/kickjs-client`,`@forinda/kickjs-inertia`,`@forinda/kickjs-storage`,`@forinda/kickjs-view`],it={react:{fallback:`^19.0.0`},"react-dom":{fallback:`^19.0.0`},"@types/react":{fallback:`^19.0.0`},"@types/react-dom":{fallback:`^19.0.0`},"@vitejs/plugin-react":{fallback:`^5.0.0`},"@inertiajs/react":{fallback:`^3.9.0`,cap:`^3`},"@inertiajs/core":{fallback:`^3.9.0`,cap:`^3`},"@types/node":{fallback:`^25.0.0`},"@types/supertest":{fallback:`^7.2.1`},supertest:{fallback:`^7.2.2`},vitest:{fallback:`^4.1.2`},"@swc/core":{fallback:`^1.15.21`},"unplugin-swc":{fallback:`^1.5.9`},oxfmt:{fallback:`^0.65.0`},oxlint:{fallback:`^1.80.0`},dotenv:{fallback:`^17.3.1`,cap:`^17`},"reflect-metadata":{fallback:`^0.2.2`},vite:{fallback:`^8.0.3`,cap:`^8`},typescript:{fallback:`^7.0.2`,cap:`^7`},"@typescript/typescript6":{fallback:`^6.0.2`,cap:`^6`},express:{fallback:`^5.1.0`,cap:`^5`},"@types/express":{fallback:`^5.0.6`,cap:`^5`},fastify:{fallback:`^5.0.0`,cap:`^5`},"@fastify/middie":{fallback:`^9.0.0`,cap:`^9`},h3:{fallback:`^2.0.2`,cap:`^2`},"serve-static":{fallback:`^2.2.0`,cap:`^2`},zod:{fallback:`^4.3.6`,cap:`^4`},valibot:{fallback:`^1.4.1`,cap:`^1`},"@valibot/to-json-schema":{fallback:`^1.8.0`,cap:`^1`},yup:{fallback:`^1.7.1`,cap:`^1`},ws:{fallback:`^8.18.0`,cap:`^8`},bullmq:{fallback:`^5.0.0`,cap:`^5`},ioredis:{fallback:`^5.0.0`,cap:`^5`}};function $(e){if(!e)return null;let t=e.trim();if(/^\d+\.\d+\.\d+/.test(t))return t.split(/\s/)[0];try{let e=JSON.parse(t),n=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`);return n.length>0?n[n.length-1]:null}catch{return null}}function at(e){return e===`@forinda/kickjs-cli`?`^${Q.version}`:`latest`}async function ot(e,t,n){let r=Array.from({length:e.length}),i=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let t=i++;r[t]=await n(e[t])}});return await Promise.all(a),r}async function st(){let e=[...rt.map(e=>({name:e,fallback:at(e),cap:void 0})),...Object.entries(it).map(([e,t])=>({name:e,...t}))],t=Date.now()+2e4,n=await ot(e,8,async({name:e,fallback:n,cap:r})=>{let i=t-Date.now();if(i<=0)return[e,n];let a=r?`${e}@${r}`:e,o=$(await M(`npm`,r?[`view`,a,`version`,`--json`]:[`view`,a,`version`],{timeout:i}));return[e,o?`^${o}`:n]});return Object.fromEntries(n)}function ct(e,t){let n=O(`npm`,[`view`,`${e}@${t}`,`version`],{timeout:2e4});return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}function lt(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function ut(e,t){let n=e=>lt(e).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10)||0),[r=0,i=0,a=0]=n(e),[o=0,s=0,c=0]=n(t);return r===o?i===s?a>=c:i>s:r>o}const dt=Q.version;async function ft(){let e=$(await M(`npm`,[`view`,`@forinda/kickjs-cli`,`version`],{timeout:5e3}));return e&&pt(dt,e)?e:null}function pt(e,t){return e.split(`-`)[0]===t.split(`-`)[0]?e.includes(`-`)&&!t.includes(`-`):!ut(e,t)}function mt(e,t,n){let r=O(`npm`,[`view`,`${e}@${t}`,`exports`,`--json`],{timeout:2e4});if(!r)return!1;try{let e=JSON.parse(r);return Object.prototype.hasOwnProperty.call(e,n)}catch{return!1}}async function ht(t){let{name:i,directory:o,packageManager:s=`pnpm`,template:c=`rest`,defaultRepo:f=`inmemory`,packages:p=[],schemaLib:m=`zod`,runtime:g=`express`}=t,_=o,v=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${i}\n`),t.versions||v(`Resolving package versions...`);let y=t.versions??await st(),b=Object.keys(y).filter(e=>y[e]===`latest`);if(b.length>0&&v(`WARNING: could not reach npm for ${b.join(`, `)} — pinned to 'latest'`),g!==`express`){if(mt(`@forinda/kickjs`,`latest`,`./${g}`))v(`Using @forinda/kickjs@latest (stable ships the ${g} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=ct(r,`alpha`);e&&ut(e,lt(y[r]))&&(y[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}v(n?`Using the alpha channel for the ${g} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${g} runtime subpath may be missing. After install, run: ${s} add @forinda/kickjs@alpha`)}}let x=p.filter(e=>!d(h(l,`feature-${e}`)));x.length>0&&v(`WARNING: skipping unknown package(s): ${x.join(`, `)} — add them later with kick add`);let C=a([...vt({template:c,runtime:g,schemaLib:m,packages:p}),...t.extraLayers??[]],{vars:{name:i,version:Q.version},extra:[{slot:`repo`,code:f===`inmemory`?`repo: 'inmemory'`:`repo: { name: '${f.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}' }`},...t.spaClientDir?[_t(t.spaClientDir)]:[]]}),w=t.platformConfig===!1?void 0:re(s);await r(h(_,`package.json`),oe(i,y,C,w));let T=ae(s,w);T&&await r(h(_,`.yarnrc.yml`),T);let te=u(C.files,{name:i,template:c,runtime:g,packageManager:s,...nt(s),templateLabel:{rest:`REST API`,minimal:`Minimal`,inertia:`Inertia (React)`}[c],sessionSecret:ee(32).toString(`hex`),packages:[...C.dependencies,...C.devDependencies].filter(e=>e.startsWith(`@forinda/`)).map(e=>`- \`${e}\``).join(`
127
- `)});for(let[e,t]of te)await r(h(_,e),t);t.deploy?.length&&t.platformConfig!==!1&&await z({dir:_,targets:t.deploy,pm:s,force:!0});let{generateAgentDocs:E}=await import(`./agent-docs-lNvu1K1x.mjs`).then(e=>e.t);await E({outDir:_,name:i,pm:s,template:c,only:`both`,force:!0});let D={...Ye,...Ze(p),...C.builds};if(t.approveInstallScripts!==!1&&Z(s,_,D),t.installDeps){console.log(`\n Installing dependencies with ${s}...\n`);try{S(`${s} install`,{cwd:_,stdio:`inherit`}),console.log(`
128
- Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${s} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-_x_Q5O0b.mjs`).then(e=>e.n);await e({cwd:_,allowDuplicates:!0,silent:!0})}catch{}if(t.initGit)try{S(`git init`,{cwd:_,stdio:`pipe`}),S(`git branch -M main`,{cwd:_,stdio:`pipe`}),S(`git add -A`,{cwd:_,stdio:`pipe`}),S(`git commit -m "chore: initial commit from kick new"`,{cwd:_,stdio:`pipe`}),v(`Git repository initialized`)}catch{v(`Warning: git init failed (git may not be installed)`)}console.log(`
127
+ `)});for(let[e,t]of te)await r(h(_,e),t);t.deploy?.length&&t.platformConfig!==!1&&await z({dir:_,targets:t.deploy,pm:s,force:!0});let{generateAgentDocs:E}=await import(`./agent-docs-DBLN2Mp9.mjs`).then(e=>e.t);await E({outDir:_,name:i,pm:s,template:c,only:`both`,force:!0});let D={...Ye,...Ze(p),...C.builds};if(t.approveInstallScripts!==!1&&Z(s,_,D),t.installDeps){console.log(`\n Installing dependencies with ${s}...\n`);try{S(`${s} install`,{cwd:_,stdio:`inherit`}),console.log(`
128
+ Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${s} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-B8uRTy_3.mjs`).then(e=>e.n);await e({cwd:_,allowDuplicates:!0,silent:!0})}catch{}if(t.initGit)try{S(`git init`,{cwd:_,stdio:`pipe`}),S(`git branch -M main`,{cwd:_,stdio:`pipe`}),S(`git add -A`,{cwd:_,stdio:`pipe`}),S(`git commit -m "chore: initial commit from kick new"`,{cwd:_,stdio:`pipe`}),v(`Git repository initialized`)}catch{v(`Warning: git init failed (git may not be installed)`)}console.log(`
129
129
  Project scaffolded successfully!`),console.log();let O=_!==process.cwd();v(`Next steps:`),O&&v(` cd ${i}`),t.installDeps||v(` ${s} install`);let k=n(s,`kick`),A={rest:`${k} g module user`,minimal:`# add your routes to src/index.ts`,inertia:`# pages: src/modules/pages + src/client/pages`};v(` ${A[c]??A.rest}`),v(` ${e(s,`dev`)}`);let j=e=>{let t=Math.max(...e.map(([e])=>e.length))+2;for(let[n,r]of e)v(` ${n.padEnd(t)}${r}`)};return v(``),v(`Commands:`),j([[e(s,`dev`),`Start dev server with Vite HMR`],[e(s,`build`),`Production build via Vite`],[e(s,`start`),`Run production build`]]),v(``),v(`Generators:`),j([[`${k} g module <name>`,`REST module (controller, service, DTOs, repository)`],[`${k} g scaffold <n> <f..>`,`CRUD module from field definitions`],[`${k} g controller <name>`,`Standalone controller`],[`${k} g service <name>`,`@Service() class`],[`${k} g middleware <name>`,`Global connect-style middleware`],[`${k} g guard <name>`,`Route guard (auth, roles, etc.)`],[`${k} g adapter <name>`,`AppAdapter with lifecycle hooks`],[`${k} g dto <name>`,`DTO schema (Zod / Valibot / Yup)`],[`${k} g config`,`Generate kick.config.ts`]]),v(``),v(`Add packages:`),j([[`${k} add <pkg>`,`Install a KickJS package + peers`],[`${k} add --list`,`Show all available packages`]]),v(``),v(`Available: ${Ue}`),v(``),{builds:D}}const gt=e=>`'${JSON.stringify(e).slice(1,-1).replaceAll(`\\"`,`"`).replaceAll(`'`,`\\'`)}'`;function _t(e){return{import:{from:`@forinda/kickjs/spa`,names:[`SpaAdapter`]},slot:`adapter`,code:`// Serves the built frontend from this origin in production.
130
130
  // Inert until the client build exists, so \`kick dev\` (where Vite
131
131
  // serves the client and proxies /api here) is unaffected.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.16.0
2
+ * @forinda/kickjs-cli v8.16.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{t as e}from"./rolldown-runtime-CYy3EyO3.mjs";import{dirname as t,parse as n,resolve as r}from"node:path";import{existsSync as i}from"node:fs";var a=/* @__PURE__ */ e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=r(e),{root:s}=n(a),c=null,l=a;for(;;){for(let e of o)if(i(r(l,e)))return l;if(c===null&&i(r(l,`package.json`))&&(c=l),l===s)break;let e=t(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
12
- //# sourceMappingURL=project-root-Bw3CEPC7.mjs.map
11
+ import{t as e}from"./rolldown-runtime-B0Wm12ok.mjs";import{dirname as t,parse as n,resolve as r}from"node:path";import{existsSync as i}from"node:fs";var a=/* @__PURE__ */ e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=r(e),{root:s}=n(a),c=null,l=a;for(;;){for(let e of o)if(i(r(l,e)))return l;if(c===null&&i(r(l,`package.json`))&&(c=l),l===s)break;let e=t(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
12
+ //# sourceMappingURL=project-root-BAZV1qId.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"project-root-Bw3CEPC7.mjs","names":["__exportAll","project_root_exports","findProjectRoot","CONFIG_FILENAMES","start","resolve","startDir","fsRoot","parse","firstPackageJson","cursor","name","existsSync","parent","dirname"],"sources":["../src/utils/project-root.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { dirname, parse, resolve } from 'node:path'\n\nconst CONFIG_FILENAMES = ['kick.config.ts', 'kick.config.js', 'kick.config.mjs', 'kick.config.json']\n\n/**\n * Walk up from `startDir` looking for the project root. A directory\n * counts as the root when it contains any of:\n * - `kick.config.{ts,js,mjs,json}` (strongest signal)\n * - `package.json` (fallback when no config file exists yet)\n *\n * Returns the absolute path of the first matching directory, or\n * `startDir` itself when nothing was found (no surprises — callers\n * that didn't find a config still get a reasonable cwd).\n *\n * `kick.config.*` wins over `package.json` when both appear at\n * different levels, so adopters running `kick typegen` from `src/`\n * land on the project root that owns the config, not on the nearest\n * workspace package boundary in a monorepo.\n */\nexport function findProjectRoot(startDir: string = process.cwd()): string {\n const start = resolve(startDir)\n const { root: fsRoot } = parse(start)\n\n let firstPackageJson: string | null = null\n let cursor = start\n while (true) {\n for (const name of CONFIG_FILENAMES) {\n if (existsSync(resolve(cursor, name))) return cursor\n }\n if (firstPackageJson === null && existsSync(resolve(cursor, 'package.json'))) {\n firstPackageJson = cursor\n }\n if (cursor === fsRoot) break\n const parent = dirname(cursor)\n if (parent === cursor) break\n cursor = parent\n }\n\n return firstPackageJson ?? start\n}\n"],"mappings":";;;;;;;;;;sMAGA,MAAMG,EAAmB,CAAC,iBAAkB,iBAAkB,kBAAmB,kBAAkB,EAiBnG,SAAgBD,EAAgB,EAAmB,QAAQ,IAAI,EAAW,CACxE,IAAME,EAAQC,EAAQC,CAAQ,EACxB,CAAE,KAAMC,GAAWC,EAAMJ,CAAK,EAEhCK,EAAkC,KAClCC,EAASN,EACb,OAAa,CACX,IAAK,IAAMO,KAAQR,EACjB,GAAIS,EAAWP,EAAQK,EAAQC,CAAI,CAAC,EAAG,OAAOD,EAKhD,GAHID,IAAqB,MAAQG,EAAWP,EAAQK,EAAQ,cAAc,CAAC,IACzE,EAAmBA,GAEjBA,IAAWH,EAAQ,MACvB,IAAMM,EAASC,EAAQJ,CAAM,EAC7B,GAAIG,IAAWH,EAAQ,MACvB,EAASG,CACX,CAEA,OAAOJ,GAAoBL,CAC7B"}
1
+ {"version":3,"file":"project-root-BAZV1qId.mjs","names":["__exportAll","project_root_exports","findProjectRoot","CONFIG_FILENAMES","start","resolve","startDir","fsRoot","parse","firstPackageJson","cursor","name","existsSync","parent","dirname"],"sources":["../src/utils/project-root.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { dirname, parse, resolve } from 'node:path'\n\nconst CONFIG_FILENAMES = ['kick.config.ts', 'kick.config.js', 'kick.config.mjs', 'kick.config.json']\n\n/**\n * Walk up from `startDir` looking for the project root. A directory\n * counts as the root when it contains any of:\n * - `kick.config.{ts,js,mjs,json}` (strongest signal)\n * - `package.json` (fallback when no config file exists yet)\n *\n * Returns the absolute path of the first matching directory, or\n * `startDir` itself when nothing was found (no surprises — callers\n * that didn't find a config still get a reasonable cwd).\n *\n * `kick.config.*` wins over `package.json` when both appear at\n * different levels, so adopters running `kick typegen` from `src/`\n * land on the project root that owns the config, not on the nearest\n * workspace package boundary in a monorepo.\n */\nexport function findProjectRoot(startDir: string = process.cwd()): string {\n const start = resolve(startDir)\n const { root: fsRoot } = parse(start)\n\n let firstPackageJson: string | null = null\n let cursor = start\n while (true) {\n for (const name of CONFIG_FILENAMES) {\n if (existsSync(resolve(cursor, name))) return cursor\n }\n if (firstPackageJson === null && existsSync(resolve(cursor, 'package.json'))) {\n firstPackageJson = cursor\n }\n if (cursor === fsRoot) break\n const parent = dirname(cursor)\n if (parent === cursor) break\n cursor = parent\n }\n\n return firstPackageJson ?? start\n}\n"],"mappings":";;;;;;;;;;sMAGA,MAAMG,EAAmB,CAAC,iBAAkB,iBAAkB,kBAAmB,kBAAkB,EAiBnG,SAAgBD,EAAgB,EAAmB,QAAQ,IAAI,EAAW,CACxE,IAAME,EAAQC,EAAQC,CAAQ,EACxB,CAAE,KAAMC,GAAWC,EAAMJ,CAAK,EAEhCK,EAAkC,KAClCC,EAASN,EACb,OAAa,CACX,IAAK,IAAMO,KAAQR,EACjB,GAAIS,EAAWP,EAAQK,EAAQC,CAAI,CAAC,EAAG,OAAOD,EAKhD,GAHID,IAAqB,MAAQG,EAAWP,EAAQK,EAAQ,cAAc,CAAC,IACzE,EAAmBA,GAEjBA,IAAWH,EAAQ,MACvB,IAAMM,EAASC,EAAQJ,CAAM,EAC7B,GAAIG,IAAWH,EAAQ,MACvB,EAASG,CACX,CAEA,OAAOJ,GAAoBL,CAC7B"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.16.0
2
+ * @forinda/kickjs-cli v8.16.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -8,4 +8,4 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import{t as e}from"./rolldown-runtime-CYy3EyO3.mjs";import{existsSync as t}from"node:fs";import{dirname as n,parse as r,resolve as i}from"node:path";var a=/* @__PURE__ */ e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=i(e),{root:s}=r(a),c=null,l=a;for(;;){for(let e of o)if(t(i(l,e)))return l;if(c===null&&t(i(l,`package.json`))&&(c=l),l===s)break;let e=n(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
11
+ import{t as e}from"./rolldown-runtime-B0Wm12ok.mjs";import{existsSync as t}from"node:fs";import{dirname as n,parse as r,resolve as i}from"node:path";var a=/* @__PURE__ */ e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=i(e),{root:s}=r(a),c=null,l=a;for(;;){for(let e of o)if(t(i(l,e)))return l;if(c===null&&t(i(l,`package.json`))&&(c=l),l===s)break;let e=n(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.16.0
2
+ * @forinda/kickjs-cli v8.16.1
3
3
  *
4
4
  * Copyright (c) Felix Orinda
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @forinda/kickjs-cli v8.16.0
2
+ * @forinda/kickjs-cli v8.16.1
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-CYy3EyO3.mjs";import{C as t,S as n,_ as r,a as i,b as a,d as o,f as s,g as c,h as l,i as u,m as d,n as f,o as p,p as m,u as h,v as g,x as _,y as v}from"./agent-docs-DhiaLsBj.mjs";import{A as y,C as b,D as x,E as ee,F as S,M as te,N as ne,O as re,P as C,S as ie,T as ae,_ as oe,a as se,b as ce,c as le,f as ue,g as de,h as fe,i as pe,j as me,k as he,l as ge,m as _e,p as ve,r as ye,u as be,v as xe,w as Se,x as Ce,y as we}from"./doctor-z92r35fo.mjs";import{a as Te,c as w,d as Ee,f as De,h as Oe,l as T,m as ke,o as Ae,p as je,s as E,u as Me}from"./config-zWl1-NCq.mjs";import{_ as Ne,a as Pe,b as Fe,d as Ie,g as Le,h as Re,l as ze,m as Be,n as Ve,o as He,p as Ue,r as We,s as D,t as Ge,u as Ke,v as qe,x as Je,y as Ye}from"./project-D96UoR0P.mjs";import{t as O}from"./project-root-Bw3CEPC7.mjs";import{n as k,t as Xe}from"./types-BLZecxnS.mjs";import{t as Ze}from"./build-vY0bmwuH.mjs";import{C as Qe,S as $e,_ as et,a as tt,b as nt,c as rt,d as it,f as at,g as ot,h as st,i as ct,l as lt,m as ut,o as dt,p as ft,r as pt,s as mt,t as ht,u as gt,v as _t,w as vt,x as A,y as yt}from"./typegen-Bq4Fis9G.mjs";import{createRequire as bt}from"node:module";import j,{basename as xt,dirname as M,join as N,relative as P,resolve as F,sep as I}from"node:path";import{cpSync as St,existsSync as L,mkdirSync as Ct,readFileSync as R,readdirSync as z,rmSync as wt,statSync as Tt,writeFileSync as B}from"node:fs";import{copyFile as Et,mkdir as Dt,readFile as V,readdir as Ot,rm as kt,stat as At,writeFile as jt}from"node:fs/promises";import{fork as Mt,spawn as Nt,spawnSync as Pt}from"node:child_process";import{createHash as Ft}from"node:crypto";import{fileURLToPath as It,pathToFileURL as H}from"node:url";import{parseSync as Lt}from"oxc-parser";import{arch as Rt,platform as zt,release as Bt}from"node:os";const Vt=[{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 Ht(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(`-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)=>{o(`KickJS — Create a new project`);let n=We(),a=e=>{e&&s.warn(`kick ${Ge} is behind the latest release, ${e} — templates and options added since are missing. Upgrade: npm i -g @forinda/kickjs-cli@latest`)},c=[];try{c=t.deploy?Je(t.deploy):[]}catch(e){s.error(e.message),d(`Aborted.`),process.exitCode=1;return}let u=!!(t.yes||t.nonInteractive);e||=u?`my-api`:await r({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let f;if(e===`.`?(f=F(`.`),e=xt(f)):f=F(t.directory||e),L(f)){let n=z(f);if(n.length>0){if(t.force)s.warn(`Clearing existing files in ${f}`);else if(u){s.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),d(`Aborted.`);return}else{s.warn(`Directory "${e}" is not empty:`);let t=n.slice(0,5);for(let e of t)s.message(` - ${e}`);if(n.length>5&&s.message(` ... and ${n.length-5} more`),!await h({message:v.red(`Remove all existing files and proceed?`),initialValue:!1})){d(`Aborted.`);return}}for(let e of n)wt(F(f,e),{recursive:!0,force:!0})}}u||a(await Promise.race([n,new Promise(e=>setTimeout(e,3e3,null).unref())]));let p=t.template;p||=u?`minimal`:await l({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 pages, one app, SSR`}]});let g=t.runtime;g||=u?`express`:await l({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 _=t.pm;_||=u?await i(void 0):await l({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let y=t.repo;y||=u?`inmemory`:await r({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),Oe(y);let b=t.schema;p===`inertia`&&(b&&b!==`zod`&&s.warn(`The inertia template uses zod — ignoring --schema ${b}.`),b=`zod`),b||=u?`zod`:await l({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(b)||(s.warn(`Unknown --schema "${b}", falling back to zod.`),b=`zod`);let x;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();x=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else x=u?[]:await m({message:`Select packages to include`,options:[...Vt],required:!1});let ee;ee=t.git===void 0?u?!0:await h({message:`Initialize git repository?`,initialValue:!0}):t.git;let S;if(S=t.install===void 0?u?!0:await h({message:`Install dependencies?`,initialValue:!0}):t.install,t.frontend!==void 0&&t.frontend!==`kick`&&t.frontend!==`vite`){s.error(`Unknown --frontend '${String(t.frontend)}'. Use 'kick' (wired React app) or 'vite' (create-vite).`),d(`Aborted.`);return}let{VITE_TEMPLATES:te,DEFAULT_VITE_TEMPLATE:ne}=await import(`./fullstack-BqevN8LJ.mjs`);if(t.viteTemplate!==void 0&&!te.some(e=>e.value===t.viteTemplate)){s.error(`Unknown --vite-template '${String(t.viteTemplate)}'. TypeScript templates only: ${te.map(e=>e.value).join(`, `)}.`),d(`Aborted.`);return}let re=t.frontend===`vite`?`vite`:`kick`,C=t.viteTemplate??ne;if(p===`fullstack`&&!t.frontend&&!u&&(re=await l({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)`}]})),re===`vite`&&!t.viteTemplate&&!u&&(C=await l({message:`create-vite template`,options:te.map(e=>({value:e.value,label:e.label})),initialValue:ne})),p===`fullstack`){let{initFullstackProject:t}=await import(`./fullstack-BqevN8LJ.mjs`);await t({name:e,directory:f,packageManager:_,initGit:ee,installDeps:S,schemaLib:b,runtime:g,packages:x,frontend:re,viteTemplate:C,deploy:c}),u&&a(await n),d(`Done! Next steps: ${v.cyan(`cd ${e} && ${_}${_===`pnpm`?` dev`:` run dev:server`}`)}`)}else await Ve({name:e,directory:f,packageManager:_,initGit:ee,installDeps:S,template:p,defaultRepo:y,packages:x,schemaLib:b,runtime:g,deploy:c}),u&&a(await n),d(`Done! Next steps: ${v.cyan(`cd ${e} && ${je(_,`dev`)}`)}`)})}function Ut(e,t=[]){let n=/* @__PURE__ */ new Map;for(let t of e){let e=(n.get(t.name)??0)+1;if(n.set(t.name,e),e===2)throw new Xe(`plugin`,t.name,[t.name,t.name])}let r=/* @__PURE__ */ new Map,i=[];for(let t of e)for(let e of t.commands??[]){let n=r.get(e.name);if(n)throw new Xe(`command`,e.name,[n,t.name]);r.set(e.name,t.name),i.push(e)}let a=new Set(t.map(e=>e.name)),o=[...i.filter(e=>!a.has(e.name)),...t],s=/* @__PURE__ */ new Map,c=[];for(let t of e)for(let e of t.typegens??[]){let n=s.get(e.id);if(n)throw new Xe(`typegen`,e.id,[n,t.name]);s.set(e.id,t.name),c.push(e)}let l=/* @__PURE__ */ new Map,u=[];for(let t of e)for(let e of t.generators??[]){let n=l.get(e.name);if(n)throw new Xe(`generator`,e.name,[n,t.name]);l.set(e.name,t.name),u.push({source:t.name,spec:e})}return{commands:o,typegens:c,generators:u,register:async(t,n)=>{let r;if(n)r={generators:u,...n};else{let{findProjectRoot:e}=await import(`./project-root-Bw3CEPC7.mjs`).then(e=>e.n),t=process.cwd();r={cwd:t,projectRoot:e(t),config:null,log:()=>{},generators:u}}for(let n of e)n.register&&await n.register(t,r)}}}async function Wt(e){let{name:n,outDir:r}=e,i=C(n),a=S(n),o=[],s=N(r,`${i}.plugin.ts`);return await t(s,`import {
11
+ import{t as e}from"./rolldown-runtime-B0Wm12ok.mjs";import{C as t,S as n,_ as r,a as i,b as a,d as o,f as s,g as c,h as l,i as u,m as d,n as f,o as p,p as m,u as h,v as g,x as _,y as v}from"./agent-docs-BVFt7K8T.mjs";import{A as y,C as b,D as x,E as ee,F as S,M as te,N as ne,O as re,P as C,S as ie,T as ae,_ as oe,a as se,b as ce,c as le,f as ue,g as de,h as fe,i as pe,j as me,k as he,l as ge,m as _e,p as ve,r as ye,u as be,v as xe,w as Se,x as Ce,y as we}from"./doctor-CWP1-2fB.mjs";import{a as Te,c as w,d as Ee,f as De,h as Oe,l as T,m as ke,o as Ae,p as je,s as E,u as Me}from"./config-CgoZjmsu.mjs";import{_ as Ne,a as Pe,b as Fe,d as Ie,g as Le,h as Re,l as ze,m as Be,n as Ve,o as He,p as Ue,r as We,s as D,t as Ge,u as Ke,v as qe,x as Je,y as Ye}from"./project-CO9buk5F.mjs";import{t as O}from"./project-root-BAZV1qId.mjs";import{n as k,t as Xe}from"./types-CokUufqE.mjs";import{t as Ze}from"./build-BKGmBYPE.mjs";import{C as Qe,S as $e,_ as et,a as tt,b as nt,c as rt,d as it,f as at,g as ot,h as st,i as ct,l as lt,m as ut,o as dt,p as ft,r as pt,s as mt,t as ht,u as gt,v as _t,w as vt,x as A,y as yt}from"./typegen-DGq3DowV.mjs";import{createRequire as bt}from"node:module";import j,{basename as xt,dirname as M,join as N,relative as P,resolve as F,sep as I}from"node:path";import{cpSync as St,existsSync as L,mkdirSync as Ct,readFileSync as R,readdirSync as z,rmSync as wt,statSync as Tt,writeFileSync as B}from"node:fs";import{copyFile as Et,mkdir as Dt,readFile as V,readdir as Ot,rm as kt,stat as At,writeFile as jt}from"node:fs/promises";import{fork as Mt,spawn as Nt,spawnSync as Pt}from"node:child_process";import{createHash as Ft}from"node:crypto";import{fileURLToPath as It,pathToFileURL as H}from"node:url";import{parseSync as Lt}from"oxc-parser";import{arch as Rt,platform as zt,release as Bt}from"node:os";const Vt=[{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 Ht(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(`-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)=>{o(`KickJS — Create a new project`);let n=We(),a=e=>{e&&s.warn(`kick ${Ge} is behind the latest release, ${e} — templates and options added since are missing. Upgrade: npm i -g @forinda/kickjs-cli@latest`)},c=[];try{c=t.deploy?Je(t.deploy):[]}catch(e){s.error(e.message),d(`Aborted.`),process.exitCode=1;return}let u=!!(t.yes||t.nonInteractive);e||=u?`my-api`:await r({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let f;if(e===`.`?(f=F(`.`),e=xt(f)):f=F(t.directory||e),L(f)){let n=z(f);if(n.length>0){if(t.force)s.warn(`Clearing existing files in ${f}`);else if(u){s.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),d(`Aborted.`);return}else{s.warn(`Directory "${e}" is not empty:`);let t=n.slice(0,5);for(let e of t)s.message(` - ${e}`);if(n.length>5&&s.message(` ... and ${n.length-5} more`),!await h({message:v.red(`Remove all existing files and proceed?`),initialValue:!1})){d(`Aborted.`);return}}for(let e of n)wt(F(f,e),{recursive:!0,force:!0})}}u||a(await Promise.race([n,new Promise(e=>setTimeout(e,3e3,null).unref())]));let p=t.template;p||=u?`minimal`:await l({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 pages, one app, SSR`}]});let g=t.runtime;g||=u?`express`:await l({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 _=t.pm;_||=u?await i(void 0):await l({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let y=t.repo;y||=u?`inmemory`:await r({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),Oe(y);let b=t.schema;p===`inertia`&&(b&&b!==`zod`&&s.warn(`The inertia template uses zod — ignoring --schema ${b}.`),b=`zod`),b||=u?`zod`:await l({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(b)||(s.warn(`Unknown --schema "${b}", falling back to zod.`),b=`zod`);let x;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();x=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else x=u?[]:await m({message:`Select packages to include`,options:[...Vt],required:!1});let ee;ee=t.git===void 0?u?!0:await h({message:`Initialize git repository?`,initialValue:!0}):t.git;let S;if(S=t.install===void 0?u?!0:await h({message:`Install dependencies?`,initialValue:!0}):t.install,t.frontend!==void 0&&t.frontend!==`kick`&&t.frontend!==`vite`){s.error(`Unknown --frontend '${String(t.frontend)}'. Use 'kick' (wired React app) or 'vite' (create-vite).`),d(`Aborted.`);return}let{VITE_TEMPLATES:te,DEFAULT_VITE_TEMPLATE:ne}=await import(`./fullstack-BPB6BkL8.mjs`);if(t.viteTemplate!==void 0&&!te.some(e=>e.value===t.viteTemplate)){s.error(`Unknown --vite-template '${String(t.viteTemplate)}'. TypeScript templates only: ${te.map(e=>e.value).join(`, `)}.`),d(`Aborted.`);return}let re=t.frontend===`vite`?`vite`:`kick`,C=t.viteTemplate??ne;if(p===`fullstack`&&!t.frontend&&!u&&(re=await l({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)`}]})),re===`vite`&&!t.viteTemplate&&!u&&(C=await l({message:`create-vite template`,options:te.map(e=>({value:e.value,label:e.label})),initialValue:ne})),p===`fullstack`){let{initFullstackProject:t}=await import(`./fullstack-BPB6BkL8.mjs`);await t({name:e,directory:f,packageManager:_,initGit:ee,installDeps:S,schemaLib:b,runtime:g,packages:x,frontend:re,viteTemplate:C,deploy:c}),u&&a(await n),d(`Done! Next steps: ${v.cyan(`cd ${e} && ${_}${_===`pnpm`?` dev`:` run dev:server`}`)}`)}else await Ve({name:e,directory:f,packageManager:_,initGit:ee,installDeps:S,template:p,defaultRepo:y,packages:x,schemaLib:b,runtime:g,deploy:c}),u&&a(await n),d(`Done! Next steps: ${v.cyan(`cd ${e} && ${je(_,`dev`)}`)}`)})}function Ut(e,t=[]){let n=/* @__PURE__ */ new Map;for(let t of e){let e=(n.get(t.name)??0)+1;if(n.set(t.name,e),e===2)throw new Xe(`plugin`,t.name,[t.name,t.name])}let r=/* @__PURE__ */ new Map,i=[];for(let t of e)for(let e of t.commands??[]){let n=r.get(e.name);if(n)throw new Xe(`command`,e.name,[n,t.name]);r.set(e.name,t.name),i.push(e)}let a=new Set(t.map(e=>e.name)),o=[...i.filter(e=>!a.has(e.name)),...t],s=/* @__PURE__ */ new Map,c=[];for(let t of e)for(let e of t.typegens??[]){let n=s.get(e.id);if(n)throw new Xe(`typegen`,e.id,[n,t.name]);s.set(e.id,t.name),c.push(e)}let l=/* @__PURE__ */ new Map,u=[];for(let t of e)for(let e of t.generators??[]){let n=l.get(e.name);if(n)throw new Xe(`generator`,e.name,[n,t.name]);l.set(e.name,t.name),u.push({source:t.name,spec:e})}return{commands:o,typegens:c,generators:u,register:async(t,n)=>{let r;if(n)r={generators:u,...n};else{let{findProjectRoot:e}=await import(`./project-root-BAZV1qId.mjs`).then(e=>e.n),t=process.cwd();r={cwd:t,projectRoot:e(t),config:null,log:()=>{},generators:u}}for(let n of e)n.register&&await n.register(t,r)}}}async function Wt(e){let{name:n,outDir:r}=e,i=C(n),a=S(n),o=[],s=N(r,`${i}.plugin.ts`);return await t(s,`import {
12
12
  definePlugin,
13
13
  type AppAdapter,
14
14
  type AppModuleEntry,
@@ -682,7 +682,7 @@ server.on('exit', () => {
682
682
  Cancelled.
683
683
  `);return}await kt(l,{recursive:!0,force:!0}),console.log(` Deleted: ${l}`);let u=N(r,`index.ts`);if(await _(u)){let e=await V(u,`utf-8`),n=e,r=RegExp(`^import\\s*\\{\\s*${y(s)}Module\\s*\\}\\s*from\\s*['"][^'"]*${y(c)}(?:/[^'"]*)?['"].*\\n?`,`gm`);e=e.replace(r,``),e=Xr(e,s),e=e.replace(/\n{3,}/g,`
684
684
 
685
- `),e!==n&&(await t(u,e),console.log(` Unregistered: ${s}Module from ${u}`))}console.log(`\n Module '${c}' removed.\n`)}function Qr(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 E(process.cwd()),r=w(n),i=t.modulesDir??r.dir??`src/modules`,a=T(t.pluralize,r);for(let n of e)await Zr({name:n,modulesDir:F(i),force:t.force,pluralize:a})})}function $r(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 ei(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function ti(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=O(process.cwd()),n=await E(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-BbbHEAzr.mjs`),{builtinCliPlugins:t}=await import(`./builtins-CRRb7Lq1.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!==n&&(await t(u,e),console.log(` Unregistered: ${s}Module from ${u}`))}console.log(`\n Module '${c}' removed.\n`)}function Qr(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 E(process.cwd()),r=w(n),i=t.modulesDir??r.dir??`src/modules`,a=T(t.pluralize,r);for(let n of e)await Zr({name:n,modulesDir:F(i),force:t.force,pluralize:a})})}function $r(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 ei(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function ti(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=O(process.cwd()),n=await E(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-_Xkj7vNO.mjs`),{builtinCliPlugins:t}=await import(`./builtins-C-qFcIBD.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=j.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return Wa(n.env,i,r)}});function Ka(e){return j.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function qa(e){return e.config?.typegen?.envFile}function Ja(e){return j.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Ya(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function $(e){return{root:Ja(e),cwd:e.cwd,envFile:Ya(e)}}const Xa=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=j.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return at(t.classes,n,r)}}),Za=()=>({id:`kick/services`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=new Set(t.collisions.map(e=>e.className)),r=lt(t.classes,t.tokens,t.injects,n);return ut(`ServiceToken`,r,"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),Qa=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return ut(`ModuleToken`,rt(t.classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),$a=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return it(t.pluginsAndAdapters)}}),eo=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return t.contextKeys.length===0?null:gt(t.contextKeys)}}),to=()=>({id:`kick/route-flags`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return ft(t.routeFlags)}}),no={express:{subpath:`@forinda/kickjs/express`,typeName:`ExpressRuntimeTypes`},fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},ro=[k({name:`kick/init`,register:Ht}),k({name:`kick/generate`,register:Sn}),k({name:`kick/run`,register:Vn}),k({name:`kick/info`,register:Kn}),k({name:`kick/inspect`,register:nr}),k({name:`kick/add`,register:Ke}),k({name:`kick/runtime-swap`,register:vr}),k({name:`kick/list`,register:Ie}),k({name:`kick/explain`,register:jr}),k({name:`kick/mcp`,register:Hr}),k({name:`kick/tinker`,register:Kr}),k({name:`kick/remove`,register:Qr}),k({name:`kick/typegen`,register:ti}),k({name:`kick/check`,register:bi}),k({name:`kick/doctor`,register:ye}),k({name:`kick/env-command`,register:Di}),k({name:`kick/codemod`,register:ki}),k({name:`kick/deploy`,register:$i}),k({name:`kick/registry`,typegens:[Xa()]}),k({name:`kick/services`,typegens:[Za()]}),k({name:`kick/modules`,typegens:[Qa()]}),k({name:`kick/plugins`,typegens:[$a()]}),k({name:`kick/context`,typegens:[eo()]}),k({name:`kick/route-flags`,typegens:[to()]}),k({name:`kick/assets`,typegens:[ea()]}),k({name:`kick/routes`,typegens:[ua()]}),k({name:`kick/client`,typegens:[Ua()]}),k({name:`kick/env`,typegens:[Ga()]}),k({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}=no[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{Dn as applyDisableFilter,On as n,Ut as r,kn as runAllPluginTypegens,ro as t};
879
- //# sourceMappingURL=run-plugins-f7i7TlPV.mjs.map
879
+ //# sourceMappingURL=run-plugins-DLCZx7uc.mjs.map