@forinda/kickjs-cli 8.8.0 → 8.10.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 (59) hide show
  1. package/dist/{agent-docs-BsXKM5QH.mjs → agent-docs-CmPrfpaP.mjs} +39 -13
  2. package/dist/agent-docs-CmPrfpaP.mjs.map +1 -0
  3. package/dist/{agent-docs-DQksWOe5.mjs → agent-docs-CvBsLoE4.mjs} +38 -12
  4. package/dist/{build-Bnd_mk4h.mjs → build-Dr7_JT3S.mjs} +3 -3
  5. package/dist/{build-Bnd_mk4h.mjs.map → build-Dr7_JT3S.mjs.map} +1 -1
  6. package/dist/{build-DPUojF2G.mjs → build-Snjzr08O.mjs} +2 -2
  7. package/dist/{builtins-CJTP3xQj.mjs → builtins-BTPvizzK.mjs} +137 -114
  8. package/dist/{builtins-BEBO5upe.mjs → builtins-MG6t5uS3.mjs} +2 -2
  9. package/dist/cli.mjs +2 -2
  10. package/dist/{config-F9g6CNDA.mjs → config-B7ZUrOl6.mjs} +3 -3
  11. package/dist/config-B7ZUrOl6.mjs.map +1 -0
  12. package/dist/{config-ty1Nc3PN.mjs → config-DO4J2xgV.mjs} +2 -2
  13. package/dist/{doctor-C8TAKn1d.mjs → doctor-C-VSGhJ6.mjs} +4 -4
  14. package/dist/{doctor-C8TAKn1d.mjs.map → doctor-C-VSGhJ6.mjs.map} +1 -1
  15. package/dist/{fs-BGHl3dHm.mjs → fs-CT9PRuSw.mjs} +1 -1
  16. package/dist/{fs-BB3QxPj8.mjs → fs-gRPNbfZO.mjs} +2 -2
  17. package/dist/{fs-BB3QxPj8.mjs.map → fs-gRPNbfZO.mjs.map} +1 -1
  18. package/dist/fullstack-CTB1yuCK.mjs +95 -0
  19. package/dist/fullstack-bVcLaFbj.mjs +96 -0
  20. package/dist/fullstack-bVcLaFbj.mjs.map +1 -0
  21. package/dist/index.d.mts +6 -0
  22. package/dist/index.d.mts.map +1 -1
  23. package/dist/index.mjs +2 -2
  24. package/dist/{plugin-C4Dl_s4-.mjs → plugin-BpfANLIW.mjs} +2 -2
  25. package/dist/{plugin-Y7BoYk1K.mjs → plugin-E910l1_e.mjs} +2 -2
  26. package/dist/project-BAmOMd-l.mjs +113 -0
  27. package/dist/project-D7x753R7.mjs +114 -0
  28. package/dist/project-D7x753R7.mjs.map +1 -0
  29. package/dist/{project-root-BDRPMlb9.mjs → project-root-D74lbi2U.mjs} +2 -2
  30. package/dist/{project-root-CFrn6ftT.mjs → project-root-DO7MsZOq.mjs} +3 -3
  31. package/dist/{project-root-CFrn6ftT.mjs.map → project-root-DO7MsZOq.mjs.map} +1 -1
  32. package/dist/{prompts-BJTp1w0l.mjs → prompts-DKR7UZkc.mjs} +2 -2
  33. package/dist/{prompts-BJTp1w0l.mjs.map → prompts-DKR7UZkc.mjs.map} +1 -1
  34. package/dist/{rolldown-runtime-OACgOwtl.mjs → rolldown-runtime-vT0bVE76.mjs} +1 -1
  35. package/dist/{run-plugins-2DJy76gx.mjs → run-plugins-BXNfws9R.mjs} +102 -79
  36. package/dist/run-plugins-BXNfws9R.mjs.map +1 -0
  37. package/dist/{typegen-BBzX2LDz.mjs → typegen-B90QMhV8.mjs} +5 -5
  38. package/dist/{typegen-BBzX2LDz.mjs.map → typegen-B90QMhV8.mjs.map} +1 -1
  39. package/dist/{typegen-COAIhZZ4.mjs → typegen-BmyEoY3Z.mjs} +4 -4
  40. package/dist/{types-gy6PkRFW.mjs → types-C2QNIHnD.mjs} +1 -1
  41. package/package.json +6 -6
  42. package/templates/base/files/src/serverless.ts +6 -0
  43. package/templates/feature-storage/feature.json +13 -0
  44. package/templates/feature-storage/files/_dot_env.example.append +6 -0
  45. package/templates/feature-storage/files/_dot_gitignore.append +2 -0
  46. package/templates/feature-storage/files/src/storage.ts +16 -0
  47. package/templates/host-config/files/netlify.toml +1 -1
  48. package/templates/template-inertia/files/src/index.ts +4 -2
  49. package/templates/template-inertia/files/vite.client.config.ts +14 -3
  50. package/templates/template-inertia/files/vite.config.ts +9 -5
  51. package/dist/agent-docs-BsXKM5QH.mjs.map +0 -1
  52. package/dist/config-F9g6CNDA.mjs.map +0 -1
  53. package/dist/fullstack-D25STbVk.mjs +0 -95
  54. package/dist/fullstack-DWcfo-zl.mjs +0 -96
  55. package/dist/fullstack-DWcfo-zl.mjs.map +0 -1
  56. package/dist/project-3LsfnPLE.mjs +0 -47
  57. package/dist/project-3LsfnPLE.mjs.map +0 -1
  58. package/dist/project-BIq7_Fzk.mjs +0 -46
  59. package/dist/run-plugins-2DJy76gx.mjs.map +0 -1
@@ -0,0 +1,113 @@
1
+ /**
2
+ * @forinda/kickjs-cli v8.10.0
3
+ *
4
+ * Copyright (c) Felix Orinda
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import{a as e,t}from"./config-DO4J2xgV.mjs";import{r as n}from"./fs-CT9PRuSw.mjs";import{existsSync as r,readFileSync as i,readdirSync as a,statSync as o,writeFileSync as s}from"node:fs";import{dirname as c,join as l,posix as u,resolve as d,sep as f}from"node:path";import{fileURLToPath as p}from"node:url";import{execFile as m,execFileSync as h,execSync as g,spawnSync as _}from"node:child_process";import{promisify as v}from"node:util";import{randomBytes as y}from"node:crypto";import{parseSync as b}from"oxc-parser";const x=v(m),S=/[&|<>^"'`(){}[\];!%\r\n\\]/;function C(e,t,n=process.platform){if(n!==`win32`)return[e,t];if(S.test(e)||t.some(e=>S.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 w(e,t,n={}){let r=C(e,t);if(!r)return null;try{return h(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 ee(e,t,n={}){let r=C(e,t);if(!r)throw Error(`Refusing to run '${e}': unsafe arguments`);h(r[0],r[1],{cwd:n.cwd,stdio:`inherit`,windowsHide:!0})}function te(e,t,n){g(e,{cwd:t,stdio:`inherit`,env:n?{...process.env,...n}:process.env})}function ne(e,t,n){let r=_(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function re(e,t,n={}){let r=C(e,t);if(!r)return null;try{let{stdout:e}=await x(r[0],r[1],{encoding:`utf-8`,timeout:n.timeout??5e3,cwd:n.cwd,windowsHide:!0});return e.toString().trim()||null}catch{return null}}const ie=c(p(import.meta.url)),T=[l(ie,`..`,`templates`),l(ie,`..`,`..`,`templates`)].find(e=>r(l(e,`base`)));function ae(e){return e.split(`/`).map(e=>e.startsWith(`_dot_`)?`.${e.slice(5)}`:e).join(`/`)}function E(e,t={}){let n=t.templatesDir??T,s=/* @__PURE__ */ new Map,c=[],u=[],d={},p=[],m={};for(let t of e){let e=l(n,t);if(!r(e))throw Error(`Unknown scaffold layer "${t}" (${e})`);let h=l(e,`feature.json`);if(r(h)){let e=JSON.parse(i(h,`utf-8`));c.push(...e.dependencies??[]),u.push(...e.devDependencies??[]),Object.assign(d,e.builds),p.push(...e.integrations??[]),Object.assign(m,e.scripts)}let g=l(e,`files`);if(r(g))for(let e of a(g,{recursive:!0,encoding:`utf-8`}).toSorted()){let t=l(g,e);if(!o(t).isFile())continue;let n=i(t,`utf-8`),r=ae(e.split(f).join(`/`));if(r.endsWith(`.append`)){let e=r.slice(0,-7);s.set(e,(s.get(e)??``)+n)}else s.set(r,n)}}p.push(...t.extra??[]);let h=t.vars??{},g=e=>e.replace(/\{\{(\w+)\}\}/g,(e,t)=>h[t]??e);for(let[e,t]of s)t.includes(`// @kick:`)&&s.set(e,oe(t,p,g));return{files:s,dependencies:[...new Set(c)],devDependencies:[...new Set(u)],builds:d,integrations:p,scripts:m}}function D(e,t){let n=e=>e.replace(/\{\{(\w+)\}\}/g,(e,n)=>n in t?t[n]:e);return new Map([...e].map(([e,t])=>[e,n(t)]))}const O=/^([ \t]*)\/\/ @kick:([\w-]+)[ \t]*$/;function oe(e,t,n=e=>e){let r=e.split(`
12
+ `),i=new Set(r.map(e=>O.exec(e)?.[2]).filter(Boolean)),a=t.filter(e=>!e.slot||i.has(e.slot)),o=[];for(let e=0;e<r.length;e++){let t=O.exec(r[e]);if(!t){o.push(r[e]);continue}let[,i,s]=t,c=s===`imports`?ce(a.flatMap(e=>e.import?[e.import]:[])):a.filter(e=>e.slot===s&&e.code).map(e=>se(`${n(e.code)},`,i));c.length>0?o.push(...c):o.at(-1)?.trimEnd().endsWith(`[`)&&r[e+1]?.trim().startsWith(`]`)&&(o.pop(),e++)}return o.join(`
13
+ `)}function se(e,t){return e.split(`
14
+ `).map(e=>e&&t+e).join(`
15
+ `)}function ce(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.from)??{names:[]};e.default??=n.default;for(let t of n.names??[])e.names.includes(t)||e.names.push(t);t.set(n.from,e)}return[...t].map(([e,{names:t,default:n}])=>{let r=`import ${[n,t.length?`{ ${t.join(`, `)} }`:void 0].filter(Boolean).join(`, `)} from '${e}'`;return r.length<=100||t.length===0?r:`import ${n?`${n}, `:``}{\n${t.map(e=>` ${e},`).join(`
16
+ `)}\n} from '${e}'`})}const k=`node:22-slim`,le={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:k,setup:`RUN corepack enable`},npm:{lockfile:`package-lock.json`,installFiles:[],install:`npm ci`,installProd:`npm ci --omit=dev`,run:e=>`npm run ${e}`,image:k},yarn:{lockfile:`yarn.lock`,installFiles:[],install:`yarn install --frozen-lockfile`,installProd:`yarn install --production --frozen-lockfile`,run:e=>`yarn run ${e}`,image:k,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`}},ue={api:`docker run -p 3000:3000 <name>`,inertia:`docker run -p 3000:3000 -e SESSION_SECRET=<a long random string> <name>`,fullstack:`docker run -p 3000:3000 <name>`};function A(e,t,n){let r=le[t],i=r.setup?`\n${r.setup}`:``,a=(e===`fullstack`?[`package.json`,r.lockfile,...r.installFiles,`server/package.json`,`web/package.json`]:[`package.json`,r.lockfile,...r.installFiles]).map(e=>`COPY ${e} ./${e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)+1):``}`).join(`
17
+ `),o=`# syntax=docker/dockerfile:1
18
+ # ${n} — the long-running server in one image.
19
+ #
20
+ # docker build -t ${n} .
21
+ # ${ue[e].replace(`<name>`,n)}
22
+ #
23
+ # Environment comes from the platform or \`docker run\`; .env files are not
24
+ # copied into the image. The lockfile must be committed — installs are frozen.
25
+ `;if(e===`fullstack`)return`${o}
26
+ FROM ${r.image} AS base
27
+ WORKDIR /app${i}
28
+
29
+ # Production dependencies of every workspace member.
30
+ FROM base AS deps
31
+ ${a}
32
+ RUN ${r.installProd}
33
+ # Hoisting may leave a member without its own node_modules; the runtime copies both.
34
+ RUN mkdir -p node_modules server/node_modules
35
+
36
+ # The server bundle and the built web app.
37
+ FROM base AS build
38
+ ${a}
39
+ RUN ${r.install}
40
+ COPY . .
41
+ RUN ${r.run(`build`)}
42
+
43
+ FROM ${k}
44
+ ENV NODE_ENV=production PORT=3000
45
+ WORKDIR /app
46
+ COPY --from=deps /app/node_modules ./node_modules
47
+ COPY --from=deps /app/server/node_modules ./server/node_modules
48
+ COPY --from=build /app/package.json ./
49
+ COPY --from=build /app/server/package.json ./server/
50
+ COPY --from=build /app/server/dist ./server/dist
51
+ # SpaAdapter serves ../web/dist relative to the server.
52
+ COPY --from=build /app/web/dist ./web/dist
53
+ WORKDIR /app/server
54
+ USER node
55
+ EXPOSE 3000
56
+ CMD ["node", "dist/index.js"]
57
+ `;let s=e===`inertia`?`# The server, the pages (dist/client) and the SSR bundle (dist/ssr).`:`# The server bundle.`;return`${o}
58
+ FROM ${r.image} AS base
59
+ WORKDIR /app${i}
60
+
61
+ FROM base AS deps
62
+ ${a}
63
+ RUN ${r.installProd}
64
+
65
+ ${s}
66
+ FROM base AS build
67
+ ${a}
68
+ RUN ${r.install}
69
+ COPY . .
70
+ RUN ${r.run(`build`)}
71
+
72
+ FROM ${k}
73
+ ENV NODE_ENV=production PORT=3000
74
+ WORKDIR /app
75
+ COPY --from=deps /app/node_modules ./node_modules
76
+ COPY --from=build /app/package.json ./
77
+ COPY --from=build /app/dist ./dist
78
+ USER node
79
+ EXPOSE 3000
80
+ CMD ["node", "dist/index.js"]
81
+ `}function j(){return`${[`# Rebuilt inside the image.`,`**/node_modules`,`**/dist`,`**/.kickjs`,`# Secrets stay out of the image; pass them at run time.`,`**/.env`,`**/.env.*`,`!**/.env.example`,`# Platform and tooling output.`,`.netlify`,`.vercel`,`.git`,`**/coverage`,`*.log`].join(`
82
+ `)}\n`}function de(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 M(e,t){return Object.fromEntries(e.toSorted().map(e=>[e,de(t,e)]))}function N(e){try{let t=h(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 fe(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`,"build:netlify":`kick build && kick build:netlify`,"build:vercel":`kick build && kick build:vercel`,...n.scripts},dependencies:M(n.dependencies,t),devDependencies:M(n.devDependencies,t)},null,2)}function pe(e,t){let n=Object.entries(t);if(n.length===0)return e;let r=e===``?[]:e.replace(/\n$/,``).split(`
83
+ `),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(`
84
+ `)}\n`}const me={adapter:`adapters`,middleware:`middlewares`};function he(e,t,n=e=>e,r=`src/index.ts`){let i={source:e,added:[],present:[],manual:[]};for(let e of t){if(!e.slot||!e.code)continue;let t=me[e.slot],a=n(e.code),o=ve(a),s=b(r,i.source).program,c=t?ge(s):void 0;if(!c){i.manual.push({...e,code:a});continue}let l=c.properties.find(e=>e.type===`Property`&&(e.key?.name??e.key?.value)===t);if(l&&l.value.type!==`ArrayExpression`){i.manual.push({...e,code:a});continue}let u=o&&e.import?_e(s,e.import.from,o):o;l&&u&&i.source.slice(l.value.start,l.value.end).includes(`${u}(`)?i.present.push(o??P(a)):(i.source=l?ye(i.source,l.value,a):be(i.source,c,t,a),e.import&&(i.source=xe(i.source,e.import,r)),i.added.push(o??P(a)))}return i}function ge(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 _e(e,t,n){for(let r of e.body)if(r.type===`ImportDeclaration`&&r.source.value===t)for(let e of r.specifiers){let t=e.imported?.name??e.imported?.value;if(e.type===`ImportSpecifier`&&t===n)return e.local.name}return n}function ve(e){let t=e.split(`
85
+ `).find(e=>e.trim()&&!e.trim().startsWith(`//`));return/^\s*([A-Za-z_$][\w$.]*)\s*\(/.exec(t??``)?.[1]}const P=e=>e.split(`
86
+ `).find(e=>e.trim()&&!e.trim().startsWith(`//`))?.trim()??e,F=(e,t)=>/^[ \t]*/.exec(e.slice(e.lastIndexOf(`
87
+ `,t-1)+1))[0],I=(e,t)=>e.split(`
88
+ `).map(e=>e&&t+e).join(`
89
+ `);function ye(e,t,n){let r=t.elements.filter(Boolean),i=F(e,t.start);if(r.length===0){let r=I(`${n},`,`${i} `);return`${e.slice(0,t.start)}[\n${r}\n${i}]${e.slice(t.end)}`}let a=r.at(-1),o=F(e,a.start),s=e.slice(a.end,t.end-1).match(/^\s*,/),c=s?a.end+s[0].length:a.end,l=`\n${I(`${n},`,o)}`;return s?e.slice(0,c)+l+e.slice(c):`${e.slice(0,c)},${l.replace(/,$/,``)}${e.slice(c)}`}function be(e,t,n,r){let i=t.properties.at(-1),a=i?F(e,i.start):`${F(e,t.start)} `,o=`${a}${n}: [\n${I(`${r},`,`${a} `)}\n${a}],`;if(!i)return`${e.slice(0,t.start)}{\n${o}\n${F(e,t.start)}}${e.slice(t.end)}`;let s=e.slice(i.end,t.end-1).match(/^\s*,/),c=s?i.end+s[0].length:i.end;return`${e.slice(0,c)}${s?``:`,`}\n${o}${e.slice(c)}`}function xe(e,t,n=`src/index.ts`){let r=b(n,e).program.body.filter(e=>e.type===`ImportDeclaration`),i=r.find(e=>e.source.value===t.from&&e.importKind!==`type`&&e.specifiers.length>0&&!e.specifiers.some(e=>e.type===`ImportNamespaceSpecifier`)),a=t.names??[];if(i){let t=new Set(i.specifiers.map(e=>e.local?.name)),n=a.filter(e=>!t.has(e));if(n.length===0)return e;let r=i.specifiers.filter(e=>e.type===`ImportSpecifier`);if(r.length>0){let t=r.at(-1).end;return`${e.slice(0,t)}, ${n.join(`, `)}${e.slice(t)}`}let o=i.specifiers[0];return`${e.slice(0,o.end)}, { ${n.join(`, `)} }${e.slice(o.end)}`}let o=`import ${[t.default,a.length?`{ ${a.join(`, `)} }`:void 0].filter(Boolean).join(`, `)} from '${t.from}'`,s=r.at(-1);return s?`${e.slice(0,s.end)}\n${o}${e.slice(s.end)}`:`${o}\n${e}`}const Se={swagger:`feature-swagger`,devtools:`feature-devtools`,ws:`feature-ws`,queue:`feature-queue`,"queue:bullmq":`feature-queue`,storage:`feature-storage`};function Ce(e){let t=[...new Set(e.map(e=>Se[e]).filter(Boolean))];return t.length>0?E(t):void 0}function we(e,t){return(t?[t]:[`src/index.ts`,`src/main.ts`]).find(t=>r(l(e,t)))}function Te(e,t){try{return h(`git`,[`status`,`--porcelain`,`--`,...t],{cwd:e,encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).split(`
90
+ `).filter(Boolean).map(e=>e.slice(3))}catch{return[]}}const L=/\.(?:[cm]?[jt]sx?)$/;function Ee(e,t){return[...t].filter(([t,n])=>{let a=l(e,t);return L.test(t)&&r(a)&&i(a,`utf-8`)!==n}).map(([e])=>e)}async function De(e,t){let a=[];for(let[o,s]of t){let t=l(e,o);if(!r(t)){await n(t,s),a.push(o);continue}if(L.test(o))continue;let c=i(t,`utf-8`),u=new Set(c.split(`
91
+ `).map(e=>R(e)??e)),d=s.split(`
92
+ `).filter(e=>e.trim()&&!u.has(R(e)??e));if(d.length===0)continue;let f=c===``||c.endsWith(`
93
+ `)?``:`
94
+ `;await n(t,`${c}${f}${d.join(`
95
+ `)}\n`),a.push(o)}return a}function Oe(e,t,n){let r=e.import?.from;if(!r?.startsWith(`.`))return!1;let i=u.join(u.dirname(t.replaceAll(`\\`,`/`)),r);return n.some(e=>e.replace(L,``)===i)}const R=e=>/^\s*([A-Za-z_][\w]*)\s*=/.exec(e)?.[1];async function ke(e,t,r){let a=l(e,t),o=i(a,`utf-8`),s=he(o,r,z(e),t);return s.source!==o&&await n(a,s.source),s}function z(e){let t=Ae(e),n={name:String(t.name??`app`),version:String(t.version??`0.0.0`)};return e=>e.replace(/\{\{(\w+)\}\}/g,(e,t)=>n[t]??e)}function Ae(e){try{return JSON.parse(i(l(e,`package.json`),`utf-8`))}catch{return{}}}function B(e){let t=e.flatMap(e=>e.import?[e.import]:[]).map(e=>`import ${[e.default,e.names?.length?`{ ${e.names.join(`, `)} }`:void 0].filter(Boolean).join(`, `)} from '${e.from}'`),n=e.map(e=>`${e.code},`);return[...t,``,`// in bootstrap({ adapters: [ ... ] }):`,...n].join(`
96
+ `)}const V={kickjs:{pkg:`@forinda/kickjs`,peers:[],enginePeers:!0,description:`Unified framework: DI, decorators, routing, middleware`,core:!0},vite:{pkg:`@forinda/kickjs-vite`,peers:[`vite`],description:`Vite plugin: dev server, HMR, module discovery`,dev:!0,core:!0},cli:{pkg:`@forinda/kickjs-cli`,peers:[],description:`CLI tool and code generators`,dev:!0,core:!0},zod:{pkg:`zod`,peers:[],description:`Zod schema validation (env, DTOs, OpenAPI) — wrap with fromZod()`},valibot:{pkg:`valibot`,peers:[],description:`Valibot schema validation — wrap with fromValibot()`},yup:{pkg:`yup`,peers:[],description:`Yup schema validation — wrap with fromYup()`},ai:{pkg:`@forinda/kickjs-ai`,peers:[`zod`],description:`AI toolkit — LLM providers, tool definitions from controllers`},storage:{pkg:`@forinda/kickjs-storage`,peers:[],description:`File storage — memory, disk, S3-compatible buckets, signed URLs`},swagger:{pkg:`@forinda/kickjs-swagger`,peers:[],description:`OpenAPI spec + Swagger UI + ReDoc`,builds:{"@scarf/scarf":!0}},db:{pkg:`@forinda/kickjs-db`,peers:[],description:`kick/db core — schema DSL, migrations, KickDbClient, customType`},pg:{pkg:`@forinda/kickjs-db`,peers:[`pg`],typePeers:[`@types/pg`],description:`kick/db + PostgreSQL driver (use @forinda/kickjs-db/pg)`},sqlite:{pkg:`@forinda/kickjs-db`,peers:[`better-sqlite3`],builds:{"better-sqlite3":!0},typePeers:[`@types/better-sqlite3`],description:`kick/db + SQLite driver (use @forinda/kickjs-db/sqlite)`},mysql:{pkg:`@forinda/kickjs-db`,peers:[`mysql2`],description:`kick/db + MySQL driver (use @forinda/kickjs-db/mysql)`},ws:{pkg:`@forinda/kickjs-ws`,peers:[`ws`],description:`WebSocket with @WsController decorators`},devtools:{pkg:`@forinda/kickjs-devtools`,peers:[],description:`Development dashboard — routes, DI, metrics, health`,dev:!0},queue:{pkg:`@forinda/kickjs-queue`,peers:[],description:`Queue adapter (BullMQ/RabbitMQ/Kafka)`},"queue:bullmq":{pkg:`@forinda/kickjs-queue`,peers:[`bullmq`,`ioredis`],builds:{"msgpackr-extract":!1},description:`Queue with BullMQ + Redis`},"queue:rabbitmq":{pkg:`@forinda/kickjs-queue`,peers:[`amqplib`],description:`Queue with RabbitMQ`},"queue:kafka":{pkg:`@forinda/kickjs-queue`,peers:[`kafkajs`],description:`Queue with Kafka`},"queue:redis-pubsub":{pkg:`@forinda/kickjs-queue`,peers:[`ioredis`],description:`Lightweight pub/sub via Redis (no persistence)`},mcp:{pkg:`@forinda/kickjs-mcp`,peers:[`@modelcontextprotocol/server`],description:`Model Context Protocol server — expose @Controller endpoints as AI tools`},testing:{pkg:`@forinda/kickjs-testing`,peers:[],description:`Test utilities and TestModule builder`,dev:!0}},je=Object.entries(V).filter(([e,t])=>!t.core&&!t.deprecated&&!e.includes(`:`)&&![`pg`,`sqlite`,`mysql`,`zod`,`valibot`,`yup`].includes(e)).map(([e])=>e).join(`, `),H={express:[`express`],fastify:[`fastify`,`@fastify/middie`,`serve-static`],h3:[`h3@^2`,`serve-static`]},U={express:{prod:`multer`,dev:`@types/multer`,note:`Express uploads use multer (memory/disk storage, ctx.file / ctx.files).`},fastify:{prod:`@fastify/multipart`,note:`Fastify uploads use @fastify/multipart (buffered into ctx.file / ctx.files).`},h3:{note:`h3 parses multipart natively (readMultipartFormData) — no driver to install.`}};function W(e){if(e!==void 0){if(e===`express`||e===`fastify`||e===`h3`)return e;throw Error(`Invalid --runtime '${String(e)}'. Expected express, fastify or h3.`)}}async function G(e=process.cwd()){return(await K(e)).runtime}async function K(t=process.cwd()){let n=(await e(t))?.runtime;return n===`express`||n===`fastify`||n===`h3`?{runtime:n,candidates:[n],ambiguous:!1,fromConfig:!0}:{...Me(t),fromConfig:!1}}const q=[[`express`,`express`],[`fastify`,`fastify`],[`h3`,`h3`]];function Me(e=process.cwd()){let t=J(`package.json`,e);if(!t)return{runtime:`express`,candidates:[],ambiguous:!1};let n={},r={};try{let e=JSON.parse(i(d(t,`package.json`),`utf-8`));n=e.dependencies??{},r=e.devDependencies??{}}catch{return{runtime:`express`,candidates:[],ambiguous:!1}}let a=q.filter(([e])=>e in n).map(([,e])=>e),o=q.filter(([e])=>e in r&&!(e in n)).map(([,e])=>e),s=[...a,...o];return a.length===1?{runtime:a[0],candidates:s,ambiguous:!1}:a.length===0&&o.length===1?{runtime:o[0],candidates:s,ambiguous:!1}:s.length===0?{runtime:`express`,candidates:s,ambiguous:!1}:{runtime:`express`,candidates:s,ambiguous:!0}}function J(e,t=process.cwd()){let n=t;for(;;){if(r(d(n,e)))return n;let t=c(n);if(t===n)return null;n=t}}function Ne(){return J(`pnpm-lock.yaml`)?`pnpm`:J(`yarn.lock`)?`yarn`:J(`bun.lockb`)||J(`bun.lock`)?`bun`:J(`package-lock.json`)?`npm`:null}function Pe(){let e=process.cwd();for(;e;){let n=d(e,`package.json`);if(r(n))try{let e=JSON.parse(i(n,`utf-8`)).packageManager;if(typeof e==`string`){let n=e.split(`@`)[0];if(t.includes(n))return n}}catch{}let a=c(e);if(a===e)return null;e=a}return null}async function Y(n){if(n&&t.includes(n))return{pm:n,source:`flag`};let r=await e(process.cwd());if(r?.packageManager&&t.includes(r.packageManager))return{pm:r.packageManager,source:`config`};let i=Pe();if(i)return{pm:i,source:`package.json`};let a=Ne();return a?{pm:a,source:`lockfile`}:{pm:`npm`,source:`default`}}async function Fe(e){let{pm:t}=await Y(e);return t}function X(e=!1,t){let n=Object.entries(V),r=Math.max(...n.map(([e])=>e.length)),i=n.filter(([,e])=>e.core),a=n.filter(([,e])=>!e.core),o=([e,n])=>{let i=e.padEnd(r+2),a=n.enginePeers?[...n.peers,...H[t??`express`]]:n.peers,o=n.enginePeers?` [${t??`express`} engine]`:``,s=a.length?` (+ ${a.join(`, `)})${o}`:``,c=n.deprecated?` [DEPRECATED — ${n.deprecated}]`:``;return` ${i} ${n.description}${s}${c}`};console.log(`
97
+ Core packages (always installed by \`kick new\`):
98
+ `);for(let e of i)console.log(o(e));if(e){console.log(`
99
+ Optional packages (add as needed):
100
+ `);for(let e of a)console.log(o(e))}else console.log(`\n Plus ${a.length} optional packages (swagger, db, queue, …).`),console.log(" Run `kick add --list --all` for the full catalog.");console.log(`
101
+ Usage: kick add ai db swagger`),console.log(` kick add queue:bullmq`),console.log(` kick add upload # installs the multipart driver for your runtime`),console.log()}const Ie={"@swc/core":!0,esbuild:!0};function Z(e,t,n){if(e===`pnpm`){let e=d(t,`pnpm-workspace.yaml`),a=r(e)?i(e,`utf-8`):``,o=pe(a,n);return o===a?void 0:(s(e,o),e)}if(e!==`npm`&&e!==`bun`)return;let a=d(t,`package.json`);if(!r(a))return;let o=JSON.parse(i(a,`utf-8`)),c=!1;if(e===`npm`){let e=o.allowScripts??{};for(let[t,r]of Object.entries(n))Object.keys(e).some(e=>e===t||e.startsWith(`${t}@`))||(e[t]=r,c=!0);o.allowScripts=e}else{let e=o.trustedDependencies??[];for(let[t,r]of Object.entries(n))r&&!e.includes(t)&&(e.push(t),c=!0);o.trustedDependencies=e}if(c)return s(a,`${JSON.stringify(o,null,2)}\n`),a}function Le(e){if(e===`pnpm`)return J(`pnpm-workspace.yaml`)??process.cwd();for(let e=process.cwd();;e=c(e)){try{if(JSON.parse(i(d(e,`package.json`),`utf-8`)).workspaces)return e}catch{}if(c(e)===e)return process.cwd()}}function Q(e){return Object.assign({},...e.map(e=>V[e]?.builds??{}))}function Re(e,t,n=`express`){let r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=[],o=[],s=[];for(let c of e){if(c===`upload`){let e=U[n];s.push(`upload (${n}): ${e.note}`),e.prod&&(t?i:r).add(e.prod),e.dev&&i.add(e.dev);continue}let e=V[c];if(!e){a.push(c);continue}e.deprecated&&o.push(`'${c}' (${e.pkg}) is deprecated — ${e.deprecated}`);let l=t||e.dev?i:r;l.add(e.pkg);for(let t of e.peers)l.add(t);for(let t of e.typePeers??[])i.add(t);if(e.enginePeers){let e=H[n];for(let t of e)l.add(t);s.push(`${c} (${n}): engine peers ${e.join(`, `)}`)}}return{prodDeps:[...r],devDeps:[...i],unknown:a,warnings:o,notices:s}}function ze(e){e.command(`list`).alias(`ls`).description(`List KickJS packages (core only; pair with --all for the full catalog)`).option(`--all`,`Include the full optional catalog`).option(`--runtime <engine>`,`HTTP engine to show peers for: express | fastify | h3`).action(async e=>{X(!!e.all,W(e.runtime)??await G())})}function Be(e){e.command(`add [packages...]`).description(`Add KickJS packages with their required dependencies`).option(`--pm <manager>`,`Package manager override`).option(`-D, --dev`,`Install as dev dependency`).option(`--list`,`List packages (core only by default; pair with --all)`).option(`--runtime <engine>`,`HTTP engine for peer resolution: express | fastify | h3 (overrides kick.config.ts)`).option(`--all`,`When listing, include the full optional catalog`).option(`--no-wire`,`Install only — do not add adapters to the entry file or .env`).option(`--entry <file>`,`Entry file to wire (default: src/index.ts, then src/main.ts)`).option(`-f, --force`,`Wire even when the files it edits have uncommitted changes`).action(async(e,t)=>{if(t.list||e.length===0){X(!!t.all,W(t.runtime)??await G());return}let{pm:n,source:i}=await Y(t.pm);console.log(`\n Using ${n} (resolved from ${i})`);let a=W(t.runtime),o=await K(process.cwd()),s=a??o.runtime;if(!a&&o.ambiguous){console.error(`\n Cannot tell which HTTP engine this app boots on: found ${o.candidates.join(`, `)} in package.json.\n\n Installing engine peers for the wrong one is worse than not installing them, so:\n • set \`runtime: '<engine>'\` in kick.config.ts (permanent, also fixes kick doctor), or\n • pass --runtime <${o.candidates.join(`|`)}> for this command\n`),process.exitCode=1;return}let c=Re(e,!!t.dev,s),{unknown:l,warnings:u,notices:f}=c,{prodDeps:p,devDeps:m}=c,h=process.cwd();if(t.entry&&!r(d(h,t.entry))){console.error(`\n --entry ${t.entry} does not exist.\n`),process.exitCode=1;return}let _=t.wire===!1?void 0:Ce(e),v=_?we(h,t.entry):void 0;if(_){p=[.../* @__PURE__ */ new Set([...p,..._.dependencies])],m=[...new Set([...m,..._.devDependencies].filter(e=>!p.includes(e)))];let e=Te(h,[...v?[v]:[],..._.files.keys()]);if(e.length>0&&!t.force){console.error(`\n ${e.join(`, `)} ${e.length===1?`has`:`have`} uncommitted changes, and kick add would edit ${e.length===1?`it`:`them`}.\n Commit or stash first, pass --force to edit anyway, or --no-wire to install only.\n`),process.exitCode=1;return}}for(let e of u)console.warn(`\n WARNING: ${e}`);for(let e of f)console.log(`\n ${e}`);if(l.length>0&&(console.log(`\n Unknown packages: ${l.join(`, `)}`),console.log(` Run "kick add --list" to see available packages.
102
+ `),p.length===0&&m.length===0))return;let y={...Q(e),..._?.builds};if(Object.keys(y).length>0){let e=Z(n,Le(n),y);e&&console.log(`\n Approved install scripts in ${e}`)}let b=!0;if(p.length>0){let e=p,t=`${n} add ${e.join(` `)}`;console.log(`\n Installing ${e.length} dependency(ies):`);for(let t of e)console.log(` + ${t}`);console.log();try{g(t,{stdio:`inherit`})}catch{b=!1,console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(m.length>0){let e=m,t=`${n} add -D ${e.join(` `)}`;console.log(`\n Installing ${e.length} dev dependency(ies):`);for(let t of e)console.log(` + ${t} (dev)`);console.log();try{g(t,{stdio:`inherit`})}catch{b=!1,console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(_){if(!b)console.log(` Skipped wiring — the install did not finish.
103
+ `);else{let e=Ee(h,_.files);for(let e of await De(h,_.files))console.log(` Updated ${e}`);let t=v?_.integrations.filter(t=>Oe(t,v,e)):[],n=_.integrations.filter(e=>!t.includes(e)),r=v?await ke(h,v,n):void 0;for(let e of r?.added??[])console.log(` Added ${e} to ${v}`);for(let e of r?.present??[])console.log(` ${e} is already in ${v}`);let i=z(h),a=r?r.manual:_.integrations.filter(e=>e.slot&&e.code).map(e=>({...e,code:i(e.code)}));if(e.length>0){let n=t.map(e=>({...e,code:i(e.code??``)}));console.log(`\n ${e.join(`, `)} already exist${e.length===1?`s`:``} — left as ${e.length===1?`it is`:`they are`}. Merge in what the layer needs, then wire it yourself:
104
+ `),console.log(`${B(n)}`.replace(/^/gm,` `)),console.log()}a.length>0&&(console.log(`\n ${v?`Could not find bootstrap({ adapters: [...] }) in ${v}`:`No entry file found`} — add this yourself:
105
+ `),console.log(B(a).replace(/^/gm,` `)),console.log())}}b?console.log(` Done!
106
+ `):(console.log(` Finished with errors — the install above did not complete.
107
+ `),process.exitCode=1)})}const $=c(p(import.meta.url)),Ve=JSON.parse(i([l($,`..`,`package.json`),l($,`..`,`..`,`package.json`)].find(r),`utf-8`)),He=[`@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`],Ue={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 We(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 Ge(e){return e===`@forinda/kickjs-cli`?`^${Ve.version}`:`latest`}async function Ke(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 qe(){let e=[...He.map(e=>({name:e,fallback:Ge(e),cap:void 0})),...Object.entries(Ue).map(([e,t])=>({name:e,...t}))],t=Date.now()+2e4,n=await Ke(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=We(await re(`npm`,r?[`view`,a,`version`,`--json`]:[`view`,a,`version`],{timeout:i}));return[e,o?`^${o}`:n]});return Object.fromEntries(n)}function Je(e,t){let n=w(`npm`,[`view`,`${e}@${t}`,`version`],{timeout:2e4});return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}function Ye(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function Xe(e,t){let n=e=>Ye(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}function Ze(e,t,n){let r=w(`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 Qe(e){let{name:t,directory:i,packageManager:a=`pnpm`,template:o=`rest`,defaultRepo:s=`inmemory`,packages:c=[],schemaLib:u=`zod`,runtime:d=`express`}=e,f=i,p=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${t}\n`),e.versions||p(`Resolving package versions...`);let m=e.versions??await qe(),h=Object.keys(m).filter(e=>m[e]===`latest`);if(h.length>0&&p(`WARNING: could not reach npm for ${h.join(`, `)} — pinned to 'latest'`),d!==`express`){if(Ze(`@forinda/kickjs`,`latest`,`./${d}`))p(`Using @forinda/kickjs@latest (stable ships the ${d} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=Je(r,`alpha`);e&&Xe(e,Ye(m[r]))&&(m[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}p(n?`Using the alpha channel for the ${d} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${d} runtime subpath may be missing. After install, run: ${a} add @forinda/kickjs@alpha`)}}let _=c.filter(e=>!r(l(T,`feature-${e}`)));_.length>0&&p(`WARNING: skipping unknown package(s): ${_.join(`, `)} — add them later with kick add`);let v=E([...et({template:o,runtime:d,schemaLib:u,packages:c}),...e.platformConfig===!1?[]:[`host-config`],...e.extraLayers??[]],{vars:{name:t,version:Ve.version},extra:[{slot:`repo`,code:s===`inmemory`?`repo: 'inmemory'`:`repo: { name: '${s.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}' }`},...e.spaClientDir?[$e(e.spaClientDir)]:[]]});await n(l(f,`package.json`),fe(t,m,v,e.platformConfig===!1?void 0:N(a)));let b=D(v.files,{name:t,template:o,runtime:d,packageManager:a,netlifyPublish:o===`inertia`?`dist/client`:`dist/public`,templateLabel:{rest:`REST API`,minimal:`Minimal`,inertia:`Inertia (React)`}[o],sessionSecret:y(32).toString(`hex`),packages:[...v.dependencies,...v.devDependencies].filter(e=>e.startsWith(`@forinda/`)).map(e=>`- \`${e}\``).join(`
108
+ `)});for(let[e,t]of b)await n(l(f,e),t);if(e.platformConfig!==!1){let e=o===`inertia`?`inertia`:`api`;await n(l(f,`Dockerfile`),A(e,a,t)),await n(l(f,`.dockerignore`),j())}let{generateAgentDocs:x}=await import(`./agent-docs-CvBsLoE4.mjs`).then(e=>e.t);await x({outDir:f,name:t,pm:a,template:o,only:`all`,force:!0});let S={...Ie,...Q(c),...v.builds};if(e.approveInstallScripts!==!1&&Z(a,f,S),e.installDeps){console.log(`\n Installing dependencies with ${a}...\n`);try{g(`${a} install`,{cwd:f,stdio:`inherit`}),console.log(`
109
+ Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${a} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-BmyEoY3Z.mjs`).then(e=>e.n);await e({cwd:f,allowDuplicates:!0,silent:!0})}catch{}if(e.initGit)try{g(`git init`,{cwd:f,stdio:`pipe`}),g(`git branch -M main`,{cwd:f,stdio:`pipe`}),g(`git add -A`,{cwd:f,stdio:`pipe`}),g(`git commit -m "chore: initial commit from kick new"`,{cwd:f,stdio:`pipe`}),p(`Git repository initialized`)}catch{p(`Warning: git init failed (git may not be installed)`)}console.log(`
110
+ Project scaffolded successfully!`),console.log();let C=f!==process.cwd();p(`Next steps:`),C&&p(` cd ${t}`),e.installDeps||p(` ${a} install`);let w={rest:`kick g module user`,minimal:`# add your routes to src/index.ts`,inertia:`# pages: src/modules/pages + src/client/pages`};return p(` ${w[o]??w.rest}`),p(` kick dev`),p(``),p(`Commands:`),p(` kick dev Start dev server with Vite HMR`),p(` kick build Production build via Vite`),p(` kick start Run production build`),p(``),p(`Generators:`),p(` kick g module <name> REST module (controller, service, DTOs, repository)`),p(` kick g scaffold <n> <f..> CRUD module from field definitions`),p(` kick g controller <name> Standalone controller`),p(` kick g service <name> @Service() class`),p(` kick g middleware <name> Global connect-style middleware`),p(` kick g guard <name> Route guard (auth, roles, etc.)`),p(` kick g adapter <name> AppAdapter with lifecycle hooks`),p(` kick g dto <name> DTO schema (Zod / Valibot / Yup)`),p(` kick g config Generate kick.config.ts`),p(``),p(`Add packages:`),p(` kick add <pkg> Install a KickJS package + peers`),p(` kick add --list Show all available packages`),p(``),p(`Available: ${je}`),p(``),{builds:S}}function $e(e){return{import:{from:`@forinda/kickjs/spa`,names:[`SpaAdapter`]},slot:`adapter`,code:`// Serves the built frontend from this origin in production.
111
+ // Inert until the client build exists, so \`kick dev\` (where Vite
112
+ // serves the client and proxies /api here) is unaffected.
113
+ SpaAdapter({ clientDir: ${JSON.stringify(e)} })`}}function et(e){return[`base`,`template-${e.template}`,`runtime-${e.runtime}`,`schema-${e.schemaLib}`,...e.packages.filter(e=>r(l(T,`feature-${e}`))).map(e=>`feature-${e}`)]}export{te as _,Z as a,G as c,A as d,j as f,ne as g,ee as h,U as i,Fe as l,E as m,qe as n,Be as o,D as p,V as r,ze as s,Qe as t,N as u};
@@ -0,0 +1,114 @@
1
+ /**
2
+ * @forinda/kickjs-cli v8.10.0
3
+ *
4
+ * Copyright (c) Felix Orinda
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import{r as e}from"./fs-gRPNbfZO.mjs";import{o as t,t as n}from"./config-B7ZUrOl6.mjs";import{dirname as r,join as i,posix as a,resolve as o,sep as s}from"node:path";import{existsSync as c,readFileSync as l,readdirSync as u,statSync as d,writeFileSync as f}from"node:fs";import{execFile as p,execFileSync as m,execSync as h,spawnSync as g}from"node:child_process";import{randomBytes as _}from"node:crypto";import{fileURLToPath as v}from"node:url";import{promisify as y}from"node:util";import{parseSync as b}from"oxc-parser";const x=r(v(import.meta.url)),S=[i(x,`..`,`templates`),i(x,`..`,`..`,`templates`)].find(e=>c(i(e,`base`)));function C(e){return e.split(`/`).map(e=>e.startsWith(`_dot_`)?`.${e.slice(5)}`:e).join(`/`)}function w(e,t={}){let n=t.templatesDir??S,r=/* @__PURE__ */ new Map,a=[],o=[],f={},p=[],m={};for(let t of e){let e=i(n,t);if(!c(e))throw Error(`Unknown scaffold layer "${t}" (${e})`);let h=i(e,`feature.json`);if(c(h)){let e=JSON.parse(l(h,`utf-8`));a.push(...e.dependencies??[]),o.push(...e.devDependencies??[]),Object.assign(f,e.builds),p.push(...e.integrations??[]),Object.assign(m,e.scripts)}let g=i(e,`files`);if(c(g))for(let e of u(g,{recursive:!0,encoding:`utf-8`}).toSorted()){let t=i(g,e);if(!d(t).isFile())continue;let n=l(t,`utf-8`),a=C(e.split(s).join(`/`));if(a.endsWith(`.append`)){let e=a.slice(0,-7);r.set(e,(r.get(e)??``)+n)}else r.set(a,n)}}p.push(...t.extra??[]);let h=t.vars??{},g=e=>e.replace(/\{\{(\w+)\}\}/g,(e,t)=>h[t]??e);for(let[e,t]of r)t.includes(`// @kick:`)&&r.set(e,E(t,p,g));return{files:r,dependencies:[...new Set(a)],devDependencies:[...new Set(o)],builds:f,integrations:p,scripts:m}}function ee(e,t){let n=e=>e.replace(/\{\{(\w+)\}\}/g,(e,n)=>n in t?t[n]:e);return new Map([...e].map(([e,t])=>[e,n(t)]))}const T=/^([ \t]*)\/\/ @kick:([\w-]+)[ \t]*$/;function E(e,t,n=e=>e){let r=e.split(`
12
+ `),i=new Set(r.map(e=>T.exec(e)?.[2]).filter(Boolean)),a=t.filter(e=>!e.slot||i.has(e.slot)),o=[];for(let e=0;e<r.length;e++){let t=T.exec(r[e]);if(!t){o.push(r[e]);continue}let[,i,s]=t,c=s===`imports`?ne(a.flatMap(e=>e.import?[e.import]:[])):a.filter(e=>e.slot===s&&e.code).map(e=>te(`${n(e.code)},`,i));c.length>0?o.push(...c):o.at(-1)?.trimEnd().endsWith(`[`)&&r[e+1]?.trim().startsWith(`]`)&&(o.pop(),e++)}return o.join(`
13
+ `)}function te(e,t){return e.split(`
14
+ `).map(e=>e&&t+e).join(`
15
+ `)}function ne(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.from)??{names:[]};e.default??=n.default;for(let t of n.names??[])e.names.includes(t)||e.names.push(t);t.set(n.from,e)}return[...t].map(([e,{names:t,default:n}])=>{let r=`import ${[n,t.length?`{ ${t.join(`, `)} }`:void 0].filter(Boolean).join(`, `)} from '${e}'`;return r.length<=100||t.length===0?r:`import ${n?`${n}, `:``}{\n${t.map(e=>` ${e},`).join(`
16
+ `)}\n} from '${e}'`})}const D=`node:22-slim`,re={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:D,setup:`RUN corepack enable`},npm:{lockfile:`package-lock.json`,installFiles:[],install:`npm ci`,installProd:`npm ci --omit=dev`,run:e=>`npm run ${e}`,image:D},yarn:{lockfile:`yarn.lock`,installFiles:[],install:`yarn install --frozen-lockfile`,installProd:`yarn install --production --frozen-lockfile`,run:e=>`yarn run ${e}`,image:D,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`}},ie={api:`docker run -p 3000:3000 <name>`,inertia:`docker run -p 3000:3000 -e SESSION_SECRET=<a long random string> <name>`,fullstack:`docker run -p 3000:3000 <name>`};function O(e,t,n){let r=re[t],i=r.setup?`\n${r.setup}`:``,a=(e===`fullstack`?[`package.json`,r.lockfile,...r.installFiles,`server/package.json`,`web/package.json`]:[`package.json`,r.lockfile,...r.installFiles]).map(e=>`COPY ${e} ./${e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)+1):``}`).join(`
17
+ `),o=`# syntax=docker/dockerfile:1
18
+ # ${n} — the long-running server in one image.
19
+ #
20
+ # docker build -t ${n} .
21
+ # ${ie[e].replace(`<name>`,n)}
22
+ #
23
+ # Environment comes from the platform or \`docker run\`; .env files are not
24
+ # copied into the image. The lockfile must be committed — installs are frozen.
25
+ `;if(e===`fullstack`)return`${o}
26
+ FROM ${r.image} AS base
27
+ WORKDIR /app${i}
28
+
29
+ # Production dependencies of every workspace member.
30
+ FROM base AS deps
31
+ ${a}
32
+ RUN ${r.installProd}
33
+ # Hoisting may leave a member without its own node_modules; the runtime copies both.
34
+ RUN mkdir -p node_modules server/node_modules
35
+
36
+ # The server bundle and the built web app.
37
+ FROM base AS build
38
+ ${a}
39
+ RUN ${r.install}
40
+ COPY . .
41
+ RUN ${r.run(`build`)}
42
+
43
+ FROM ${D}
44
+ ENV NODE_ENV=production PORT=3000
45
+ WORKDIR /app
46
+ COPY --from=deps /app/node_modules ./node_modules
47
+ COPY --from=deps /app/server/node_modules ./server/node_modules
48
+ COPY --from=build /app/package.json ./
49
+ COPY --from=build /app/server/package.json ./server/
50
+ COPY --from=build /app/server/dist ./server/dist
51
+ # SpaAdapter serves ../web/dist relative to the server.
52
+ COPY --from=build /app/web/dist ./web/dist
53
+ WORKDIR /app/server
54
+ USER node
55
+ EXPOSE 3000
56
+ CMD ["node", "dist/index.js"]
57
+ `;let s=e===`inertia`?`# The server, the pages (dist/client) and the SSR bundle (dist/ssr).`:`# The server bundle.`;return`${o}
58
+ FROM ${r.image} AS base
59
+ WORKDIR /app${i}
60
+
61
+ FROM base AS deps
62
+ ${a}
63
+ RUN ${r.installProd}
64
+
65
+ ${s}
66
+ FROM base AS build
67
+ ${a}
68
+ RUN ${r.install}
69
+ COPY . .
70
+ RUN ${r.run(`build`)}
71
+
72
+ FROM ${D}
73
+ ENV NODE_ENV=production PORT=3000
74
+ WORKDIR /app
75
+ COPY --from=deps /app/node_modules ./node_modules
76
+ COPY --from=build /app/package.json ./
77
+ COPY --from=build /app/dist ./dist
78
+ USER node
79
+ EXPOSE 3000
80
+ CMD ["node", "dist/index.js"]
81
+ `}function k(){return`${[`# Rebuilt inside the image.`,`**/node_modules`,`**/dist`,`**/.kickjs`,`# Secrets stay out of the image; pass them at run time.`,`**/.env`,`**/.env.*`,`!**/.env.example`,`# Platform and tooling output.`,`.netlify`,`.vercel`,`.git`,`**/coverage`,`*.log`].join(`
82
+ `)}\n`}const ae=y(p),A=/[&|<>^"'`(){}[\];!%\r\n\\]/;function j(e,t,n=process.platform){if(n!==`win32`)return[e,t];if(A.test(e)||t.some(e=>A.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 M(e,t,n={}){let r=j(e,t);if(!r)return null;try{return m(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 oe(e,t,n={}){let r=j(e,t);if(!r)throw Error(`Refusing to run '${e}': unsafe arguments`);m(r[0],r[1],{cwd:n.cwd,stdio:`inherit`,windowsHide:!0})}function se(e,t,n){let r=g(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function ce(e,t,n={}){let r=j(e,t);if(!r)return null;try{let{stdout:e}=await ae(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 le(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,le(t,e)]))}function P(e){try{let t=m(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 ue(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`,"build:netlify":`kick build && kick build:netlify`,"build:vercel":`kick build && kick build:vercel`,...n.scripts},dependencies:N(n.dependencies,t),devDependencies:N(n.devDependencies,t)},null,2)}function de(e,t){let n=Object.entries(t);if(n.length===0)return e;let r=e===``?[]:e.replace(/\n$/,``).split(`
83
+ `),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(`
84
+ `)}\n`}const fe={adapter:`adapters`,middleware:`middlewares`};function pe(e,t,n=e=>e,r=`src/index.ts`){let i={source:e,added:[],present:[],manual:[]};for(let e of t){if(!e.slot||!e.code)continue;let t=fe[e.slot],a=n(e.code),o=ge(a),s=b(r,i.source).program,c=t?me(s):void 0;if(!c){i.manual.push({...e,code:a});continue}let l=c.properties.find(e=>e.type===`Property`&&(e.key?.name??e.key?.value)===t);if(l&&l.value.type!==`ArrayExpression`){i.manual.push({...e,code:a});continue}let u=o&&e.import?he(s,e.import.from,o):o;l&&u&&i.source.slice(l.value.start,l.value.end).includes(`${u}(`)?i.present.push(o??F(a)):(i.source=l?_e(i.source,l.value,a):ve(i.source,c,t,a),e.import&&(i.source=ye(i.source,e.import,r)),i.added.push(o??F(a)))}return i}function me(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 he(e,t,n){for(let r of e.body)if(r.type===`ImportDeclaration`&&r.source.value===t)for(let e of r.specifiers){let t=e.imported?.name??e.imported?.value;if(e.type===`ImportSpecifier`&&t===n)return e.local.name}return n}function ge(e){let t=e.split(`
85
+ `).find(e=>e.trim()&&!e.trim().startsWith(`//`));return/^\s*([A-Za-z_$][\w$.]*)\s*\(/.exec(t??``)?.[1]}const F=e=>e.split(`
86
+ `).find(e=>e.trim()&&!e.trim().startsWith(`//`))?.trim()??e,I=(e,t)=>/^[ \t]*/.exec(e.slice(e.lastIndexOf(`
87
+ `,t-1)+1))[0],L=(e,t)=>e.split(`
88
+ `).map(e=>e&&t+e).join(`
89
+ `);function _e(e,t,n){let r=t.elements.filter(Boolean),i=I(e,t.start);if(r.length===0){let r=L(`${n},`,`${i} `);return`${e.slice(0,t.start)}[\n${r}\n${i}]${e.slice(t.end)}`}let a=r.at(-1),o=I(e,a.start),s=e.slice(a.end,t.end-1).match(/^\s*,/),c=s?a.end+s[0].length:a.end,l=`\n${L(`${n},`,o)}`;return s?e.slice(0,c)+l+e.slice(c):`${e.slice(0,c)},${l.replace(/,$/,``)}${e.slice(c)}`}function ve(e,t,n,r){let i=t.properties.at(-1),a=i?I(e,i.start):`${I(e,t.start)} `,o=`${a}${n}: [\n${L(`${r},`,`${a} `)}\n${a}],`;if(!i)return`${e.slice(0,t.start)}{\n${o}\n${I(e,t.start)}}${e.slice(t.end)}`;let s=e.slice(i.end,t.end-1).match(/^\s*,/),c=s?i.end+s[0].length:i.end;return`${e.slice(0,c)}${s?``:`,`}\n${o}${e.slice(c)}`}function ye(e,t,n=`src/index.ts`){let r=b(n,e).program.body.filter(e=>e.type===`ImportDeclaration`),i=r.find(e=>e.source.value===t.from&&e.importKind!==`type`&&e.specifiers.length>0&&!e.specifiers.some(e=>e.type===`ImportNamespaceSpecifier`)),a=t.names??[];if(i){let t=new Set(i.specifiers.map(e=>e.local?.name)),n=a.filter(e=>!t.has(e));if(n.length===0)return e;let r=i.specifiers.filter(e=>e.type===`ImportSpecifier`);if(r.length>0){let t=r.at(-1).end;return`${e.slice(0,t)}, ${n.join(`, `)}${e.slice(t)}`}let o=i.specifiers[0];return`${e.slice(0,o.end)}, { ${n.join(`, `)} }${e.slice(o.end)}`}let o=`import ${[t.default,a.length?`{ ${a.join(`, `)} }`:void 0].filter(Boolean).join(`, `)} from '${t.from}'`,s=r.at(-1);return s?`${e.slice(0,s.end)}\n${o}${e.slice(s.end)}`:`${o}\n${e}`}const be={swagger:`feature-swagger`,devtools:`feature-devtools`,ws:`feature-ws`,queue:`feature-queue`,"queue:bullmq":`feature-queue`,storage:`feature-storage`};function xe(e){let t=[...new Set(e.map(e=>be[e]).filter(Boolean))];return t.length>0?w(t):void 0}function Se(e,t){return(t?[t]:[`src/index.ts`,`src/main.ts`]).find(t=>c(i(e,t)))}function Ce(e,t){try{return m(`git`,[`status`,`--porcelain`,`--`,...t],{cwd:e,encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).split(`
90
+ `).filter(Boolean).map(e=>e.slice(3))}catch{return[]}}const R=/\.(?:[cm]?[jt]sx?)$/;function we(e,t){return[...t].filter(([t,n])=>{let r=i(e,t);return R.test(t)&&c(r)&&l(r,`utf-8`)!==n}).map(([e])=>e)}async function Te(t,n){let r=[];for(let[a,o]of n){let n=i(t,a);if(!c(n)){await e(n,o),r.push(a);continue}if(R.test(a))continue;let s=l(n,`utf-8`),u=new Set(s.split(`
91
+ `).map(e=>z(e)??e)),d=o.split(`
92
+ `).filter(e=>e.trim()&&!u.has(z(e)??e));if(d.length===0)continue;let f=s===``||s.endsWith(`
93
+ `)?``:`
94
+ `;await e(n,`${s}${f}${d.join(`
95
+ `)}\n`),r.push(a)}return r}function Ee(e,t,n){let r=e.import?.from;if(!r?.startsWith(`.`))return!1;let i=a.join(a.dirname(t.replaceAll(`\\`,`/`)),r);return n.some(e=>e.replace(R,``)===i)}const z=e=>/^\s*([A-Za-z_][\w]*)\s*=/.exec(e)?.[1];async function De(t,n,r){let a=i(t,n),o=l(a,`utf-8`),s=pe(o,r,B(t),n);return s.source!==o&&await e(a,s.source),s}function B(e){let t=Oe(e),n={name:String(t.name??`app`),version:String(t.version??`0.0.0`)};return e=>e.replace(/\{\{(\w+)\}\}/g,(e,t)=>n[t]??e)}function Oe(e){try{return JSON.parse(l(i(e,`package.json`),`utf-8`))}catch{return{}}}function V(e){let t=e.flatMap(e=>e.import?[e.import]:[]).map(e=>`import ${[e.default,e.names?.length?`{ ${e.names.join(`, `)} }`:void 0].filter(Boolean).join(`, `)} from '${e.from}'`),n=e.map(e=>`${e.code},`);return[...t,``,`// in bootstrap({ adapters: [ ... ] }):`,...n].join(`
96
+ `)}const H={kickjs:{pkg:`@forinda/kickjs`,peers:[],enginePeers:!0,description:`Unified framework: DI, decorators, routing, middleware`,core:!0},vite:{pkg:`@forinda/kickjs-vite`,peers:[`vite`],description:`Vite plugin: dev server, HMR, module discovery`,dev:!0,core:!0},cli:{pkg:`@forinda/kickjs-cli`,peers:[],description:`CLI tool and code generators`,dev:!0,core:!0},zod:{pkg:`zod`,peers:[],description:`Zod schema validation (env, DTOs, OpenAPI) — wrap with fromZod()`},valibot:{pkg:`valibot`,peers:[],description:`Valibot schema validation — wrap with fromValibot()`},yup:{pkg:`yup`,peers:[],description:`Yup schema validation — wrap with fromYup()`},ai:{pkg:`@forinda/kickjs-ai`,peers:[`zod`],description:`AI toolkit — LLM providers, tool definitions from controllers`},storage:{pkg:`@forinda/kickjs-storage`,peers:[],description:`File storage — memory, disk, S3-compatible buckets, signed URLs`},swagger:{pkg:`@forinda/kickjs-swagger`,peers:[],description:`OpenAPI spec + Swagger UI + ReDoc`,builds:{"@scarf/scarf":!0}},db:{pkg:`@forinda/kickjs-db`,peers:[],description:`kick/db core — schema DSL, migrations, KickDbClient, customType`},pg:{pkg:`@forinda/kickjs-db`,peers:[`pg`],typePeers:[`@types/pg`],description:`kick/db + PostgreSQL driver (use @forinda/kickjs-db/pg)`},sqlite:{pkg:`@forinda/kickjs-db`,peers:[`better-sqlite3`],builds:{"better-sqlite3":!0},typePeers:[`@types/better-sqlite3`],description:`kick/db + SQLite driver (use @forinda/kickjs-db/sqlite)`},mysql:{pkg:`@forinda/kickjs-db`,peers:[`mysql2`],description:`kick/db + MySQL driver (use @forinda/kickjs-db/mysql)`},ws:{pkg:`@forinda/kickjs-ws`,peers:[`ws`],description:`WebSocket with @WsController decorators`},devtools:{pkg:`@forinda/kickjs-devtools`,peers:[],description:`Development dashboard — routes, DI, metrics, health`,dev:!0},queue:{pkg:`@forinda/kickjs-queue`,peers:[],description:`Queue adapter (BullMQ/RabbitMQ/Kafka)`},"queue:bullmq":{pkg:`@forinda/kickjs-queue`,peers:[`bullmq`,`ioredis`],builds:{"msgpackr-extract":!1},description:`Queue with BullMQ + Redis`},"queue:rabbitmq":{pkg:`@forinda/kickjs-queue`,peers:[`amqplib`],description:`Queue with RabbitMQ`},"queue:kafka":{pkg:`@forinda/kickjs-queue`,peers:[`kafkajs`],description:`Queue with Kafka`},"queue:redis-pubsub":{pkg:`@forinda/kickjs-queue`,peers:[`ioredis`],description:`Lightweight pub/sub via Redis (no persistence)`},mcp:{pkg:`@forinda/kickjs-mcp`,peers:[`@modelcontextprotocol/server`],description:`Model Context Protocol server — expose @Controller endpoints as AI tools`},testing:{pkg:`@forinda/kickjs-testing`,peers:[],description:`Test utilities and TestModule builder`,dev:!0}},ke=Object.entries(H).filter(([e,t])=>!t.core&&!t.deprecated&&!e.includes(`:`)&&![`pg`,`sqlite`,`mysql`,`zod`,`valibot`,`yup`].includes(e)).map(([e])=>e).join(`, `),U={express:[`express`],fastify:[`fastify`,`@fastify/middie`,`serve-static`],h3:[`h3@^2`,`serve-static`]},W={express:{prod:`multer`,dev:`@types/multer`,note:`Express uploads use multer (memory/disk storage, ctx.file / ctx.files).`},fastify:{prod:`@fastify/multipart`,note:`Fastify uploads use @fastify/multipart (buffered into ctx.file / ctx.files).`},h3:{note:`h3 parses multipart natively (readMultipartFormData) — no driver to install.`}};function G(e){if(e!==void 0){if(e===`express`||e===`fastify`||e===`h3`)return e;throw Error(`Invalid --runtime '${String(e)}'. Expected express, fastify or h3.`)}}async function K(e=process.cwd()){return(await q(e)).runtime}async function q(e=process.cwd()){let n=(await t(e))?.runtime;return n===`express`||n===`fastify`||n===`h3`?{runtime:n,candidates:[n],ambiguous:!1,fromConfig:!0}:{...Ae(e),fromConfig:!1}}const J=[[`express`,`express`],[`fastify`,`fastify`],[`h3`,`h3`]];function Ae(e=process.cwd()){let t=Y(`package.json`,e);if(!t)return{runtime:`express`,candidates:[],ambiguous:!1};let n={},r={};try{let e=JSON.parse(l(o(t,`package.json`),`utf-8`));n=e.dependencies??{},r=e.devDependencies??{}}catch{return{runtime:`express`,candidates:[],ambiguous:!1}}let i=J.filter(([e])=>e in n).map(([,e])=>e),a=J.filter(([e])=>e in r&&!(e in n)).map(([,e])=>e),s=[...i,...a];return i.length===1?{runtime:i[0],candidates:s,ambiguous:!1}:i.length===0&&a.length===1?{runtime:a[0],candidates:s,ambiguous:!1}:s.length===0?{runtime:`express`,candidates:s,ambiguous:!1}:{runtime:`express`,candidates:s,ambiguous:!0}}function Y(e,t=process.cwd()){let n=t;for(;;){if(c(o(n,e)))return n;let t=r(n);if(t===n)return null;n=t}}function je(){return Y(`pnpm-lock.yaml`)?`pnpm`:Y(`yarn.lock`)?`yarn`:Y(`bun.lockb`)||Y(`bun.lock`)?`bun`:Y(`package-lock.json`)?`npm`:null}function Me(){let e=process.cwd();for(;e;){let t=o(e,`package.json`);if(c(t))try{let e=JSON.parse(l(t,`utf-8`)).packageManager;if(typeof e==`string`){let t=e.split(`@`)[0];if(n.includes(t))return t}}catch{}let i=r(e);if(i===e)return null;e=i}return null}async function X(e){if(e&&n.includes(e))return{pm:e,source:`flag`};let r=await t(process.cwd());if(r?.packageManager&&n.includes(r.packageManager))return{pm:r.packageManager,source:`config`};let i=Me();if(i)return{pm:i,source:`package.json`};let a=je();return a?{pm:a,source:`lockfile`}:{pm:`npm`,source:`default`}}async function Ne(e){let{pm:t}=await X(e);return t}function Z(e=!1,t){let n=Object.entries(H),r=Math.max(...n.map(([e])=>e.length)),i=n.filter(([,e])=>e.core),a=n.filter(([,e])=>!e.core),o=([e,n])=>{let i=e.padEnd(r+2),a=n.enginePeers?[...n.peers,...U[t??`express`]]:n.peers,o=n.enginePeers?` [${t??`express`} engine]`:``,s=a.length?` (+ ${a.join(`, `)})${o}`:``,c=n.deprecated?` [DEPRECATED — ${n.deprecated}]`:``;return` ${i} ${n.description}${s}${c}`};console.log(`
97
+ Core packages (always installed by \`kick new\`):
98
+ `);for(let e of i)console.log(o(e));if(e){console.log(`
99
+ Optional packages (add as needed):
100
+ `);for(let e of a)console.log(o(e))}else console.log(`\n Plus ${a.length} optional packages (swagger, db, queue, …).`),console.log(" Run `kick add --list --all` for the full catalog.");console.log(`
101
+ Usage: kick add ai db swagger`),console.log(` kick add queue:bullmq`),console.log(` kick add upload # installs the multipart driver for your runtime`),console.log()}const Pe={"@swc/core":!0,esbuild:!0};function Q(e,t,n){if(e===`pnpm`){let e=o(t,`pnpm-workspace.yaml`),r=c(e)?l(e,`utf-8`):``,i=de(r,n);return i===r?void 0:(f(e,i),e)}if(e!==`npm`&&e!==`bun`)return;let r=o(t,`package.json`);if(!c(r))return;let i=JSON.parse(l(r,`utf-8`)),a=!1;if(e===`npm`){let e=i.allowScripts??{};for(let[t,r]of Object.entries(n))Object.keys(e).some(e=>e===t||e.startsWith(`${t}@`))||(e[t]=r,a=!0);i.allowScripts=e}else{let e=i.trustedDependencies??[];for(let[t,r]of Object.entries(n))r&&!e.includes(t)&&(e.push(t),a=!0);i.trustedDependencies=e}if(a)return f(r,`${JSON.stringify(i,null,2)}\n`),r}function Fe(e){if(e===`pnpm`)return Y(`pnpm-workspace.yaml`)??process.cwd();for(let e=process.cwd();;e=r(e)){try{if(JSON.parse(l(o(e,`package.json`),`utf-8`)).workspaces)return e}catch{}if(r(e)===e)return process.cwd()}}function $(e){return Object.assign({},...e.map(e=>H[e]?.builds??{}))}function Ie(e,t,n=`express`){let r=/* @__PURE__ */ new Set,i=/* @__PURE__ */ new Set,a=[],o=[],s=[];for(let c of e){if(c===`upload`){let e=W[n];s.push(`upload (${n}): ${e.note}`),e.prod&&(t?i:r).add(e.prod),e.dev&&i.add(e.dev);continue}let e=H[c];if(!e){a.push(c);continue}e.deprecated&&o.push(`'${c}' (${e.pkg}) is deprecated — ${e.deprecated}`);let l=t||e.dev?i:r;l.add(e.pkg);for(let t of e.peers)l.add(t);for(let t of e.typePeers??[])i.add(t);if(e.enginePeers){let e=U[n];for(let t of e)l.add(t);s.push(`${c} (${n}): engine peers ${e.join(`, `)}`)}}return{prodDeps:[...r],devDeps:[...i],unknown:a,warnings:o,notices:s}}function Le(e){e.command(`list`).alias(`ls`).description(`List KickJS packages (core only; pair with --all for the full catalog)`).option(`--all`,`Include the full optional catalog`).option(`--runtime <engine>`,`HTTP engine to show peers for: express | fastify | h3`).action(async e=>{Z(!!e.all,G(e.runtime)??await K())})}function Re(e){e.command(`add [packages...]`).description(`Add KickJS packages with their required dependencies`).option(`--pm <manager>`,`Package manager override`).option(`-D, --dev`,`Install as dev dependency`).option(`--list`,`List packages (core only by default; pair with --all)`).option(`--runtime <engine>`,`HTTP engine for peer resolution: express | fastify | h3 (overrides kick.config.ts)`).option(`--all`,`When listing, include the full optional catalog`).option(`--no-wire`,`Install only — do not add adapters to the entry file or .env`).option(`--entry <file>`,`Entry file to wire (default: src/index.ts, then src/main.ts)`).option(`-f, --force`,`Wire even when the files it edits have uncommitted changes`).action(async(e,t)=>{if(t.list||e.length===0){Z(!!t.all,G(t.runtime)??await K());return}let{pm:n,source:r}=await X(t.pm);console.log(`\n Using ${n} (resolved from ${r})`);let i=G(t.runtime),a=await q(process.cwd()),s=i??a.runtime;if(!i&&a.ambiguous){console.error(`\n Cannot tell which HTTP engine this app boots on: found ${a.candidates.join(`, `)} in package.json.\n\n Installing engine peers for the wrong one is worse than not installing them, so:\n • set \`runtime: '<engine>'\` in kick.config.ts (permanent, also fixes kick doctor), or\n • pass --runtime <${a.candidates.join(`|`)}> for this command\n`),process.exitCode=1;return}let l=Ie(e,!!t.dev,s),{unknown:u,warnings:d,notices:f}=l,{prodDeps:p,devDeps:m}=l,g=process.cwd();if(t.entry&&!c(o(g,t.entry))){console.error(`\n --entry ${t.entry} does not exist.\n`),process.exitCode=1;return}let _=t.wire===!1?void 0:xe(e),v=_?Se(g,t.entry):void 0;if(_){p=[.../* @__PURE__ */ new Set([...p,..._.dependencies])],m=[...new Set([...m,..._.devDependencies].filter(e=>!p.includes(e)))];let e=Ce(g,[...v?[v]:[],..._.files.keys()]);if(e.length>0&&!t.force){console.error(`\n ${e.join(`, `)} ${e.length===1?`has`:`have`} uncommitted changes, and kick add would edit ${e.length===1?`it`:`them`}.\n Commit or stash first, pass --force to edit anyway, or --no-wire to install only.\n`),process.exitCode=1;return}}for(let e of d)console.warn(`\n WARNING: ${e}`);for(let e of f)console.log(`\n ${e}`);if(u.length>0&&(console.log(`\n Unknown packages: ${u.join(`, `)}`),console.log(` Run "kick add --list" to see available packages.
102
+ `),p.length===0&&m.length===0))return;let y={...$(e),..._?.builds};if(Object.keys(y).length>0){let e=Q(n,Fe(n),y);e&&console.log(`\n Approved install scripts in ${e}`)}let b=!0;if(p.length>0){let e=p,t=`${n} add ${e.join(` `)}`;console.log(`\n Installing ${e.length} dependency(ies):`);for(let t of e)console.log(` + ${t}`);console.log();try{h(t,{stdio:`inherit`})}catch{b=!1,console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(m.length>0){let e=m,t=`${n} add -D ${e.join(` `)}`;console.log(`\n Installing ${e.length} dev dependency(ies):`);for(let t of e)console.log(` + ${t} (dev)`);console.log();try{h(t,{stdio:`inherit`})}catch{b=!1,console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(_){if(!b)console.log(` Skipped wiring — the install did not finish.
103
+ `);else{let e=we(g,_.files);for(let e of await Te(g,_.files))console.log(` Updated ${e}`);let t=v?_.integrations.filter(t=>Ee(t,v,e)):[],n=_.integrations.filter(e=>!t.includes(e)),r=v?await De(g,v,n):void 0;for(let e of r?.added??[])console.log(` Added ${e} to ${v}`);for(let e of r?.present??[])console.log(` ${e} is already in ${v}`);let i=B(g),a=r?r.manual:_.integrations.filter(e=>e.slot&&e.code).map(e=>({...e,code:i(e.code)}));if(e.length>0){let n=t.map(e=>({...e,code:i(e.code??``)}));console.log(`\n ${e.join(`, `)} already exist${e.length===1?`s`:``} — left as ${e.length===1?`it is`:`they are`}. Merge in what the layer needs, then wire it yourself:
104
+ `),console.log(`${V(n)}`.replace(/^/gm,` `)),console.log()}a.length>0&&(console.log(`\n ${v?`Could not find bootstrap({ adapters: [...] }) in ${v}`:`No entry file found`} — add this yourself:
105
+ `),console.log(V(a).replace(/^/gm,` `)),console.log())}}b?console.log(` Done!
106
+ `):(console.log(` Finished with errors — the install above did not complete.
107
+ `),process.exitCode=1)})}const ze=r(v(import.meta.url)),Be=JSON.parse(l([i(ze,`..`,`package.json`),i(ze,`..`,`..`,`package.json`)].find(c),`utf-8`)),Ve=[`@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`],He={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 Ue(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 We(e){return e===`@forinda/kickjs-cli`?`^${Be.version}`:`latest`}async function Ge(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 Ke(){let e=[...Ve.map(e=>({name:e,fallback:We(e),cap:void 0})),...Object.entries(He).map(([e,t])=>({name:e,...t}))],t=Date.now()+2e4,n=await Ge(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=Ue(await ce(`npm`,r?[`view`,a,`version`,`--json`]:[`view`,a,`version`],{timeout:i}));return[e,o?`^${o}`:n]});return Object.fromEntries(n)}function qe(e,t){let n=M(`npm`,[`view`,`${e}@${t}`,`version`],{timeout:2e4});return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}function Je(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function Ye(e,t){let n=e=>Je(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}function Xe(e,t,n){let r=M(`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 Ze(t){let{name:n,directory:r,packageManager:a=`pnpm`,template:o=`rest`,defaultRepo:s=`inmemory`,packages:l=[],schemaLib:u=`zod`,runtime:d=`express`}=t,f=r,p=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${n}\n`),t.versions||p(`Resolving package versions...`);let m=t.versions??await Ke(),g=Object.keys(m).filter(e=>m[e]===`latest`);if(g.length>0&&p(`WARNING: could not reach npm for ${g.join(`, `)} — pinned to 'latest'`),d!==`express`){if(Xe(`@forinda/kickjs`,`latest`,`./${d}`))p(`Using @forinda/kickjs@latest (stable ships the ${d} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=qe(r,`alpha`);e&&Ye(e,Je(m[r]))&&(m[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}p(n?`Using the alpha channel for the ${d} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${d} runtime subpath may be missing. After install, run: ${a} add @forinda/kickjs@alpha`)}}let v=l.filter(e=>!c(i(S,`feature-${e}`)));v.length>0&&p(`WARNING: skipping unknown package(s): ${v.join(`, `)} — add them later with kick add`);let y=w([...$e({template:o,runtime:d,schemaLib:u,packages:l}),...t.platformConfig===!1?[]:[`host-config`],...t.extraLayers??[]],{vars:{name:n,version:Be.version},extra:[{slot:`repo`,code:s===`inmemory`?`repo: 'inmemory'`:`repo: { name: '${s.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}' }`},...t.spaClientDir?[Qe(t.spaClientDir)]:[]]});await e(i(f,`package.json`),ue(n,m,y,t.platformConfig===!1?void 0:P(a)));let b=ee(y.files,{name:n,template:o,runtime:d,packageManager:a,netlifyPublish:o===`inertia`?`dist/client`:`dist/public`,templateLabel:{rest:`REST API`,minimal:`Minimal`,inertia:`Inertia (React)`}[o],sessionSecret:_(32).toString(`hex`),packages:[...y.dependencies,...y.devDependencies].filter(e=>e.startsWith(`@forinda/`)).map(e=>`- \`${e}\``).join(`
108
+ `)});for(let[t,n]of b)await e(i(f,t),n);if(t.platformConfig!==!1){let t=o===`inertia`?`inertia`:`api`;await e(i(f,`Dockerfile`),O(t,a,n)),await e(i(f,`.dockerignore`),k())}let{generateAgentDocs:x}=await import(`./agent-docs-CmPrfpaP.mjs`).then(e=>e.t);await x({outDir:f,name:n,pm:a,template:o,only:`all`,force:!0});let C={...Pe,...$(l),...y.builds};if(t.approveInstallScripts!==!1&&Q(a,f,C),t.installDeps){console.log(`\n Installing dependencies with ${a}...\n`);try{h(`${a} install`,{cwd:f,stdio:`inherit`}),console.log(`
109
+ Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${a} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-B90QMhV8.mjs`).then(e=>e.n);await e({cwd:f,allowDuplicates:!0,silent:!0})}catch{}if(t.initGit)try{h(`git init`,{cwd:f,stdio:`pipe`}),h(`git branch -M main`,{cwd:f,stdio:`pipe`}),h(`git add -A`,{cwd:f,stdio:`pipe`}),h(`git commit -m "chore: initial commit from kick new"`,{cwd:f,stdio:`pipe`}),p(`Git repository initialized`)}catch{p(`Warning: git init failed (git may not be installed)`)}console.log(`
110
+ Project scaffolded successfully!`),console.log();let T=f!==process.cwd();p(`Next steps:`),T&&p(` cd ${n}`),t.installDeps||p(` ${a} install`);let E={rest:`kick g module user`,minimal:`# add your routes to src/index.ts`,inertia:`# pages: src/modules/pages + src/client/pages`};return p(` ${E[o]??E.rest}`),p(` kick dev`),p(``),p(`Commands:`),p(` kick dev Start dev server with Vite HMR`),p(` kick build Production build via Vite`),p(` kick start Run production build`),p(``),p(`Generators:`),p(` kick g module <name> REST module (controller, service, DTOs, repository)`),p(` kick g scaffold <n> <f..> CRUD module from field definitions`),p(` kick g controller <name> Standalone controller`),p(` kick g service <name> @Service() class`),p(` kick g middleware <name> Global connect-style middleware`),p(` kick g guard <name> Route guard (auth, roles, etc.)`),p(` kick g adapter <name> AppAdapter with lifecycle hooks`),p(` kick g dto <name> DTO schema (Zod / Valibot / Yup)`),p(` kick g config Generate kick.config.ts`),p(``),p(`Add packages:`),p(` kick add <pkg> Install a KickJS package + peers`),p(` kick add --list Show all available packages`),p(``),p(`Available: ${ke}`),p(``),{builds:C}}function Qe(e){return{import:{from:`@forinda/kickjs/spa`,names:[`SpaAdapter`]},slot:`adapter`,code:`// Serves the built frontend from this origin in production.
111
+ // Inert until the client build exists, so \`kick dev\` (where Vite
112
+ // serves the client and proxies /api here) is unaffected.
113
+ SpaAdapter({ clientDir: ${JSON.stringify(e)} })`}}function $e(e){return[`base`,`template-${e.template}`,`runtime-${e.runtime}`,`schema-${e.schemaLib}`,...e.packages.filter(e=>c(i(S,`feature-${e}`))).map(e=>`feature-${e}`)]}export{Q as a,K as c,oe as d,se as f,w as g,ee as h,W as i,Ne as l,k as m,Ke as n,Re as o,O as p,H as r,Le as s,Ze as t,P as u};
114
+ //# sourceMappingURL=project-D7x753R7.mjs.map