@forinda/kickjs-cli 8.17.4 → 8.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-docs-BKbdsDUQ.mjs → agent-docs-D10r5OEG.mjs} +3 -3
- package/dist/agent-docs-D10r5OEG.mjs.map +1 -0
- package/dist/{agent-docs-sMPVd5vN.mjs → agent-docs-D_L3RIUM.mjs} +2 -2
- package/dist/{build-NyFTqWDy.mjs → build-BkfEhRpx.mjs} +3 -3
- package/dist/{build-NyFTqWDy.mjs.map → build-BkfEhRpx.mjs.map} +1 -1
- package/dist/{build-DWbnilcJ.mjs → build-CChfKQA_.mjs} +2 -2
- package/dist/{builtins-MVDZcuck.mjs → builtins-C1mgGr8D.mjs} +147 -147
- package/dist/{builtins-DaPdtAiN.mjs → builtins-cZC3AQMK.mjs} +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/{config-kPWo_HS4.mjs → config-Bb-FdTKY.mjs} +3 -3
- package/dist/config-Bb-FdTKY.mjs.map +1 -0
- package/dist/{config-BVw4TFDJ.mjs → config-xN3ZYiN-.mjs} +2 -2
- package/dist/{doctor-Bmm7jTXk.mjs → doctor-CDdF_pWU.mjs} +4 -4
- package/dist/doctor-CDdF_pWU.mjs.map +1 -0
- package/dist/{fullstack-HXrTvDQS.mjs → fullstack-CHNFDgBX.mjs} +3 -3
- package/dist/{fullstack-Dj6nndJI.mjs → fullstack-D0Yim7JS.mjs} +4 -4
- package/dist/fullstack-D0Yim7JS.mjs.map +1 -0
- package/dist/index.d.mts +98 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/{plugin-DxBBBZKs.mjs → plugin-CFT_4ept.mjs} +2 -2
- package/dist/{plugin-CEIikRk4.mjs → plugin-DxXeitAU.mjs} +2 -2
- package/dist/{project-BFGUN5KK.mjs → project-B9sWWiFy.mjs} +12 -12
- package/dist/project-B9sWWiFy.mjs.map +1 -0
- package/dist/{project--dWQ_c8m.mjs → project-DDQFJyNi.mjs} +31 -31
- package/dist/{project-root-tvtMzer4.mjs → project-root-ClOtJ6MM.mjs} +2 -2
- package/dist/{project-root-CKK8LRzQ.mjs → project-root-DNQ4RQHQ.mjs} +3 -3
- package/dist/{project-root-CKK8LRzQ.mjs.map → project-root-DNQ4RQHQ.mjs.map} +1 -1
- package/dist/rolldown-runtime-SDDZy9Be.mjs +11 -0
- package/dist/{run-plugins-CisH0EMY.mjs → run-plugins-lJqFqRny.mjs} +72 -72
- package/dist/run-plugins-lJqFqRny.mjs.map +1 -0
- package/dist/{typegen-_fQVGRr8.mjs → typegen-Bkikzy45.mjs} +5 -5
- package/dist/typegen-Bkikzy45.mjs.map +1 -0
- package/dist/{typegen-dZuP30n-.mjs → typegen-DlnhNbzD.mjs} +4 -4
- package/dist/{types-DNpeagtq.mjs → types-ew1loX4G.mjs} +1 -1
- package/package.json +13 -13
- package/templates/feature-views/files/src/views/shared.ts +19 -0
- package/templates/feature-views/skills/views-forms.txt +1 -1
- package/templates/inertia-react/feature.json +13 -0
- package/templates/inertia-svelte/feature.json +13 -0
- package/templates/inertia-svelte/files/src/client/Layout.svelte +19 -0
- package/templates/inertia-svelte/files/src/client/Seo.svelte +47 -0
- package/templates/inertia-svelte/files/src/client/main.ts +16 -0
- package/templates/inertia-svelte/files/src/client/pages/Error.svelte +14 -0
- package/templates/inertia-svelte/files/src/client/pages/Home.svelte +13 -0
- package/templates/inertia-svelte/files/src/client/pages/Posts/Index.svelte +33 -0
- package/templates/inertia-svelte/files/src/client/ssr.ts +16 -0
- package/templates/inertia-svelte/files/src/client/svelte.d.ts +7 -0
- package/templates/inertia-svelte/files/vite.client.config.ts +32 -0
- package/templates/inertia-svelte/files/vite.config.ts +42 -0
- package/templates/inertia-vue/feature.json +13 -0
- package/templates/inertia-vue/files/src/client/Layout.vue +21 -0
- package/templates/inertia-vue/files/src/client/Seo.ts +49 -0
- package/templates/inertia-vue/files/src/client/main.ts +17 -0
- package/templates/inertia-vue/files/src/client/pages/Error.vue +16 -0
- package/templates/inertia-vue/files/src/client/pages/Home.vue +15 -0
- package/templates/inertia-vue/files/src/client/pages/Posts/Index.vue +31 -0
- package/templates/inertia-vue/files/src/client/ssr.ts +21 -0
- package/templates/inertia-vue/files/src/client/vue.d.ts +7 -0
- package/templates/inertia-vue/files/vite.client.config.ts +32 -0
- package/templates/inertia-vue/files/vite.config.ts +42 -0
- package/templates/template-inertia/feature.json +3 -13
- package/templates/template-inertia/files/src/client/app.css +1 -1
- package/templates/template-inertia/files/src/index.ts +4 -4
- package/templates/template-inertia/files/src/modules/pages/pages.controller.ts +1 -1
- package/dist/agent-docs-BKbdsDUQ.mjs.map +0 -1
- package/dist/config-kPWo_HS4.mjs.map +0 -1
- package/dist/doctor-Bmm7jTXk.mjs.map +0 -1
- package/dist/fullstack-Dj6nndJI.mjs.map +0 -1
- package/dist/project-BFGUN5KK.mjs.map +0 -1
- package/dist/rolldown-runtime-BxKUidhj.mjs +0 -11
- package/dist/run-plugins-CisH0EMY.mjs.map +0 -1
- package/dist/typegen-_fQVGRr8.mjs.map +0 -1
- /package/templates/{template-inertia → inertia-react}/files/src/client/Layout.tsx +0 -0
- /package/templates/{template-inertia → inertia-react}/files/src/client/Seo.tsx +0 -0
- /package/templates/{template-inertia → inertia-react}/files/src/client/main.tsx +0 -0
- /package/templates/{template-inertia → inertia-react}/files/src/client/pages/Error.tsx +0 -0
- /package/templates/{template-inertia → inertia-react}/files/src/client/pages/Home.tsx +0 -0
- /package/templates/{template-inertia → inertia-react}/files/src/client/pages/Posts/Index.tsx +0 -0
- /package/templates/{template-inertia → inertia-react}/files/src/client/ssr.tsx +0 -0
- /package/templates/{template-inertia → inertia-react}/files/vite.client.config.ts +0 -0
- /package/templates/{template-inertia → inertia-react}/files/vite.config.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.
|
|
2
|
+
* @forinda/kickjs-cli v8.19.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{C as e,a as t,b as n,o as r,r as i,s as a,v as o,y as s}from"./agent-docs-
|
|
12
|
-
`:void 0}function
|
|
11
|
+
import{C as e,a as t,b as n,o as r,r as i,s as a,v as o,y as s}from"./agent-docs-D_L3RIUM.mjs";import{f as c,o as l,r as u}from"./config-xN3ZYiN-.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 T}from"node:crypto";import{parseSync as E}from"oxc-parser";const D=w(b),O=/[&|<>^"'`(){}[\];!%\r\n\\]/;function k(e,t,n=process.platform){if(n!==`win32`)return[e,t];if(O.test(e)||t.some(e=>O.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 A(e,t,n={}){let r=k(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 ee(e,t,n={}){let r=k(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 j(e,t,n){S(e,{cwd:t,stdio:`inherit`,env:n?{...process.env,...n}:process.env})}function M(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 N(e,t,n={}){let r=k(e,t);if(!r)return null;try{let{stdout:e}=await D(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 te(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 ne(e,t){return Object.fromEntries(e.toSorted().map(e=>[e,te(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
|
+
`: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:ne(n.dependencies,t),devDependencies:ne(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
|
-
`)}\n`}const
|
|
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}`:``}
|
|
15
15
|
# Compilers for native addons (better-sqlite3, …) that have no prebuilt binary.
|
|
16
16
|
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ \\
|
|
17
17
|
&& rm -rf /var/lib/apt/lists/*`,c=`# The build stage generates the Prisma client, if any.
|
|
@@ -20,7 +20,7 @@ ENV PRISMA_SKIP_POSTINSTALL_GENERATE=1`,l=(e===`fullstack`?[`package.json`,o.loc
|
|
|
20
20
|
# ${n} — the long-running server in one image.
|
|
21
21
|
#
|
|
22
22
|
# docker build -t ${n} .
|
|
23
|
-
# ${
|
|
23
|
+
# ${le[e].replace(`<name>`,n)}
|
|
24
24
|
#
|
|
25
25
|
# Environment comes from the platform or \`docker run\`; .env files are not
|
|
26
26
|
# copied into the image. The lockfile must be committed — installs are frozen.
|
|
@@ -47,7 +47,7 @@ RUN mkdir -p node_modules/.prisma server/node_modules/.prisma
|
|
|
47
47
|
# kick/db migrations and seeds, read at runtime (empty without kick/db).
|
|
48
48
|
RUN mkdir -p server/db
|
|
49
49
|
|
|
50
|
-
FROM ${
|
|
50
|
+
FROM ${P}
|
|
51
51
|
ENV NODE_ENV=production PORT=3000
|
|
52
52
|
WORKDIR /app
|
|
53
53
|
COPY --from=deps /app/node_modules ./node_modules
|
|
@@ -83,7 +83,7 @@ RUN mkdir -p node_modules/.prisma
|
|
|
83
83
|
# kick/db migrations and seeds, read at runtime (empty without kick/db).
|
|
84
84
|
RUN mkdir -p db
|
|
85
85
|
|
|
86
|
-
FROM ${
|
|
86
|
+
FROM ${P}
|
|
87
87
|
ENV NODE_ENV=production PORT=3000
|
|
88
88
|
WORKDIR /app
|
|
89
89
|
COPY --from=deps /app/node_modules ./node_modules
|
|
@@ -98,7 +98,7 @@ RUN mkdir -p data && chown node:node data
|
|
|
98
98
|
USER node
|
|
99
99
|
EXPOSE 3000
|
|
100
100
|
CMD ["node", "dist/index.js"]
|
|
101
|
-
`}function
|
|
101
|
+
`}function de(){return`# Rebuilt inside the image.
|
|
102
102
|
**/node_modules
|
|
103
103
|
**/dist
|
|
104
104
|
**/.kickjs
|
|
@@ -112,41 +112,41 @@ CMD ["node", "dist/index.js"]
|
|
|
112
112
|
.git
|
|
113
113
|
**/coverage
|
|
114
114
|
*.log
|
|
115
|
-
`}const
|
|
115
|
+
`}const fe=[`netlify`,`vercel`,`docker`],pe=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`],I=e=>pe.some(t=>d(h(e,t)));function me(e){return I(h(e,`server`))&&d(h(e,`web`))}function he(e){let t=(typeof e==`string`?e.split(`,`):e).map(e=>e.trim().toLowerCase()).filter(Boolean),n=t.filter(e=>!fe.includes(e));if(n.length>0)throw Error(`Unknown deploy target: ${n.join(`, `)} — expected ${fe.join(`, `)}`);return[...new Set(t)]}function L(e){return JSON.parse(f(e,`utf-8`))}function ge(e,t){return e===`pnpm`?`pnpm build && pnpm --filter ./server exec kick build:${t}`:`${e} run build && cd server && kick build:${t}`}async function R(r){let{dir:i,targets:o}=r,c=me(i);if(!c&&!I(i))throw Error(`${i} is not a KickJS project (no kick.config) — run kick g deploy from the project, or from a fullstack workspace's root.`);let l=c?h(i,`server`):i,u=h(i,`package.json`),f=L(u),p=c?L(h(l,`package.json`)):f,m=await t(r.pm,i),g=`@forinda/kickjs-inertia`in{...p.dependencies,...p.devDependencies},v=/* @__PURE__ */ new Map,y={},b=()=>{for(let[e,t]of n([`deploy-serverless`]).files)v.set(h(l,e),t)},x=(e,t)=>{let r=s(n([t]).files,{packageManager:m,netlifyPublish:g?`dist/client`:`dist/public`});for(let[e,t]of r)v.set(h(i,e),t);b(),y[`build:${e}`]=c?ge(m,e):`${f.scripts?.build??`kick build`} && kick build:${e}`};for(let e of o)if(e===`netlify`)x(`netlify`,c?`deploy-netlify-workspace`:`deploy-netlify`);else if(e===`vercel`)x(`vercel`,`deploy-vercel`);else{let e=c?`fullstack`:g?`inertia`:`api`;v.set(h(i,`Dockerfile`),ue(e,m,String(f.name??`app`),f.packageManager)),v.set(h(i,`.dockerignore`),de())}let S=[];for(let[t,n]of v)(!d(t)||r.force||!t.endsWith(h(`src`,`serverless.ts`))&&await a({message:`${_(i,t)} already exists. Overwrite?`,initialValue:!1}))&&(await e(t,n),S.push(t));let C=Object.entries(y).filter(([e])=>!f.scripts?.[e]);return C.length>0&&(f.scripts={...f.scripts,...Object.fromEntries(C)},await e(u,`${JSON.stringify(f,null,2)}\n`),S.push(u)),S}const _e={adapter:`adapters`,middleware:`middlewares`};function z(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||e.slot.startsWith(`env-`)||e.slot.startsWith(`config-`))continue;let t=_e[e.slot],a=n(e.code),o=ye(a),s=E(r,i.source).program,c=t?ve(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?B(s,e.import.from,o):o;l&&u&&i.source.slice(l.value.start,l.value.end).includes(`${u}(`)?i.present.push(o??V(a)):(i.source=l?be(i.source,l.value,l.value.elements,a):Ee(i.source,c,t,a),e.import&&(i.source=De(i.source,e.import,r)),i.added.push(o??V(a)))}return i}function ve(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 B(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 ye(e){let t=e.split(`
|
|
116
116
|
`).filter(e=>!e.trim().startsWith(`//`)).join(`
|
|
117
|
-
`),n=/^\s*([A-Za-z_$][\w$.]*)\s*\(/.exec(t)?.[1];if(n)return n;for(let e of t.matchAll(/(?<![\w$])([A-Za-z_$][\w$]*)\s*\(/g))if(e[1]!==`import`)return e[1]}const
|
|
118
|
-
`).find(e=>e.trim()&&!e.trim().startsWith(`//`))?.trim()??e,
|
|
119
|
-
`,t-1)+1))[0],
|
|
117
|
+
`),n=/^\s*([A-Za-z_$][\w$.]*)\s*\(/.exec(t)?.[1];if(n)return n;for(let e of t.matchAll(/(?<![\w$])([A-Za-z_$][\w$]*)\s*\(/g))if(e[1]!==`import`)return e[1]}const V=e=>e.split(`
|
|
118
|
+
`).find(e=>e.trim()&&!e.trim().startsWith(`//`))?.trim()??e,H=(e,t)=>/^[ \t]*/.exec(e.slice(e.lastIndexOf(`
|
|
119
|
+
`,t-1)+1))[0],U=(e,t)=>e.split(`
|
|
120
120
|
`).map(e=>e&&t+e).join(`
|
|
121
|
-
`);function
|
|
122
|
-
`).filter(Boolean))]}catch{return[]}}function
|
|
123
|
-
`).map(e=>
|
|
124
|
-
`).filter(e=>e.trim()&&!c.has(
|
|
121
|
+
`);function be(e,t,n,r){let i=n.filter(Boolean),a=H(e,t.start);if(i.length===0){let n=U(`${r},`,`${a} `),[i,o]=t.type===`ObjectExpression`?[`{`,`}`]:[`[`,`]`];return`${e.slice(0,t.start)}${i}\n${n}\n${a}${o}${e.slice(t.end)}`}let o=i.at(-1),s=H(e,o.start),c=e.slice(o.end,t.end-1).match(/^\s*,/),l=c?o.end+c[0].length:o.end,u=`\n${U(`${r},`,s)}`;return c?e.slice(0,l)+u+e.slice(l):`${e.slice(0,l)},${u.replace(/,$/,``)}${e.slice(l)}`}const xe=[`zod`,`valibot`,`yup`];function Se(e,t,n=`src/config/index.ts`){let r={source:e,added:[],present:[],manual:[]},{lib:i,object:a}=Te(E(n,e).program),o=t.filter(e=>e.slot===`env-${i??`zod`}`&&e.code);if(o.length===0)return r;if(!i||!a)return r.manual.push(...o),r;for(let e of o){let t=Ce(e.code),i=Te(E(n,r.source).program).object;i.properties.some(e=>e.type===`Property`&&(e.key?.name??e.key?.value)===t)?r.present.push(t):(r.source=be(r.source,i,i.properties,e.code),r.added.push(t))}return r}const Ce=e=>/^\s*['"]?(\w+)['"]?\s*:/m.exec(e)?.[1]??V(e),we=e=>e?.type===`CallExpression`&&e.callee?.type===`MemberExpression`&&e.callee.property?.name===`object`&&e.arguments?.[0]?.type===`ObjectExpression`?e.arguments[0]:void 0;function Te(e){let t=e.body,n=/* @__PURE__ */ new Map;for(let r of xe){let i=`from${r[0].toUpperCase()}${r.slice(1)}`;t.some(e=>e.type===`ImportDeclaration`&&e.source.value===`@forinda/kickjs-schema/${r}`&&e.specifiers.some(e=>(e.imported?.name??e.imported?.value)===i))&&n.set(B(e,`@forinda/kickjs-schema/${r}`,i),r)}let r=[],i=[],a=e=>{if(!e||typeof e!=`object`)return;if(Array.isArray(e))return e.forEach(a);let t=e,o=we(t);o&&i.push(o);let s=t.type===`CallExpression`?n.get(t.callee?.name):void 0,c=we(t.arguments?.[0]);s&&c&&r.push({call:t,lib:s,object:c});for(let e in t)a(t[e])};if(a(e),r.length>0){let e=t.find(e=>e.type===`ExportDefaultDeclaration`)?.declaration;if(e?.type===`Identifier`){let n=e.name;e=t.map(e=>e.type===`ExportNamedDeclaration`?e.declaration:e).filter(e=>e?.type===`VariableDeclaration`).flatMap(e=>e.declarations).find(e=>e.id?.name===n)?.init}let{lib:n,object:i}=r.find(t=>t.call===e)??r[0];return{lib:n,object:i}}return{lib:xe.find(e=>t.some(t=>t.type===`ImportDeclaration`&&t.source.value===e)),object:i[0]}}function Ee(e,t,n,r){let i=t.properties.at(-1),a=i?H(e,i.start):`${H(e,t.start)} `,o=`${a}${n}: [\n${U(`${r},`,`${a} `)}\n${a}],`;if(!i)return`${e.slice(0,t.start)}{\n${o}\n${H(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 De(e,t,n=`src/index.ts`){let r=E(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 Oe={swagger:`feature-swagger`,devtools:`feature-devtools`,ws:`feature-ws`,queue:`feature-queue`,"queue:bullmq":`feature-queue`,storage:`feature-storage`,views:`feature-views`};function ke(e){let t=[...new Set(e.map(e=>Oe[e]).filter(Boolean))];return t.length>0?n(t):void 0}function Ae(e,t){return(t?[t]:[`src/index.ts`,`src/main.ts`]).find(t=>d(h(e,t)))}function je(e,t){try{let n=x(`git`,[`ls-files`,`--modified`,`--`,...t],{cwd:e,encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]});return[...new Set(n.split(`
|
|
122
|
+
`).filter(Boolean))]}catch{return[]}}function Me(e){return[`src/config/index.ts`,`src/env.ts`].find(t=>d(h(e,t)))}async function Ne(t,n,r){let i=h(t,n),a=f(i,`utf-8`),o=Se(a,r,n);return o.source!==a&&await e(i,o.source),o}const W=/\.(?:[cm]?[jt]sx?|kick)$/;function Pe(e,t){return[...t].filter(([t,n])=>{let r=h(e,t);return W.test(t)&&d(r)&&f(r,`utf-8`)!==n}).map(([e])=>e)}async function Fe(t,n){let r=[],i=[];for(let[a,o]of n){let n=h(t,a);if(!d(n)){await e(n,o),r.push(a);continue}if(W.test(a))continue;let s=f(n,`utf-8`),c=new Set(s.split(`
|
|
123
|
+
`).map(e=>Re(e)??e)),l=o.split(`
|
|
124
|
+
`).filter(e=>e.trim()&&!c.has(Re(e)??e));if(l.length===0)continue;let u=s===``||s.endsWith(`
|
|
125
125
|
`)?``:`
|
|
126
126
|
`;await e(n,`${s}${u}${l.join(`
|
|
127
|
-
`)}\n`),i.push(a)}return{created:r,updated:i}}function
|
|
127
|
+
`)}\n`),i.push(a)}return{created:r,updated:i}}function Ie(e,t,n){let r=e.import?.from;if(!r?.startsWith(`.`))return!1;let i=g.join(g.dirname(t.replaceAll(`\\`,`/`)),r);return n.some(e=>e.replace(W,``)===i)}function Le(e,t){let n=g.dirname(t.replaceAll(`\\`,`/`));return e.map(e=>{let t=e.import?.from;if(!t?.startsWith(`.`))return e;let r=g.relative(n,g.join(`src`,t));return{...e,import:{...e.import,from:r.startsWith(`.`)?r:`./${r}`}}})}const Re=e=>/^\s*([A-Za-z_][\w]*)\s*=/.exec(e)?.[1];async function ze(t,n,r){let i=h(t,n),a=f(i,`utf-8`),o=z(a,r,Be(t),n);return o.source!==a&&await e(i,o.source),o}function Be(e){let t=Ve(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 Ve(e){try{return JSON.parse(f(h(e,`package.json`),`utf-8`))}catch{return{}}}function He(e,t=``){let n=/\bplugins\s*:\s*\[([^\]]*)\]/.exec(t)?.[1]??``,r=e.filter(e=>e.slot===`config-plugin`&&e.code&&!RegExp(`\\b${e.code.split(`
|
|
128
128
|
`).at(-1).trim()}\\b`).test(n));if(!r.length)return;let i=r.flatMap(e=>e.import?.names?.length?[`import { ${e.import.names.join(`, `)} } from '${e.import.from}'`]:[]),a=r.map(e=>e.code.split(`
|
|
129
129
|
`).at(-1).trim());return[...i,``,`// in defineConfig({ ... }):`,`plugins: [${a.join(`, `)}],`].join(`
|
|
130
|
-
`)}function
|
|
131
|
-
`)}const
|
|
130
|
+
`)}function Ue(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(`
|
|
131
|
+
`)}const G={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`},views:{pkg:`@forinda/kickjs-view`,peers:[],description:`Server-rendered .kick templates: layouts, components, pipes, forms`},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:[`ws`],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}},We=Object.entries(G).filter(([e,t])=>!t.core&&!t.deprecated&&!e.includes(`:`)&&![`pg`,`sqlite`,`mysql`,`zod`,`valibot`,`yup`].includes(e)).map(([e])=>e).concat(`upload`).join(`, `),K={express:[`express`],fastify:[`fastify`,`@fastify/middie`,`serve-static`],h3:[`h3@^2`,`serve-static`]},Ge={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 q(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 J(e=process.cwd()){return(await Y(e)).runtime}async function Y(e=process.cwd()){let t=(await l(e))?.runtime;return t===`express`||t===`fastify`||t===`h3`?{runtime:t,candidates:[t],ambiguous:!1,fromConfig:!0}:{...qe(e),fromConfig:!1}}const Ke=[[`express`,`express`],[`fastify`,`fastify`],[`h3`,`h3`]];function qe(e=process.cwd()){let t=Je(`package.json`,e);if(!t)return{runtime:`express`,candidates:[],ambiguous:!1};let n={},r={};try{let e=JSON.parse(f(v(t,`package.json`),`utf-8`));n=e.dependencies??{},r=e.devDependencies??{}}catch{return{runtime:`express`,candidates:[],ambiguous:!1}}let i=Ke.filter(([e])=>e in n).map(([,e])=>e),a=Ke.filter(([e])=>e in r&&!(e in n)).map(([,e])=>e),o=[...i,...a];return i.length===1?{runtime:i[0],candidates:o,ambiguous:!1}:i.length===0&&a.length===1?{runtime:a[0],candidates:o,ambiguous:!1}:o.length===0?{runtime:`express`,candidates:o,ambiguous:!1}:{runtime:`express`,candidates:o,ambiguous:!0}}function Je(e,t=process.cwd()){let n=t;for(;;){if(d(v(n,e)))return n;let t=m(n);if(t===n)return null;n=t}}function Ye(e=!1,t){let n=Object.entries(G),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,...K[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(`
|
|
132
132
|
Core packages (always installed by \`kick new\`):
|
|
133
133
|
`);for(let e of i)console.log(o(e));if(e){console.log(`
|
|
134
134
|
Optional packages (add as needed):
|
|
135
135
|
`);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(`
|
|
136
|
-
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
|
|
137
|
-
`),h.length===0&&g.length===0))return;let w={...
|
|
138
|
-
`);else{let t=
|
|
136
|
+
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 Xe={"@swc/core":!0,esbuild:!0};function X(e,t,n){if(e===`pnpm`){let e=v(t,`pnpm-workspace.yaml`),r=d(e)?f(e,`utf-8`):``,i=se(r,n);return i===r?void 0:(p(e,i),e)}if(e!==`npm`&&e!==`bun`)return;let r=v(t,`package.json`);if(!d(r))return;let i=JSON.parse(f(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 p(r,`${JSON.stringify(i,null,2)}\n`),r}function Ze(e){if(e===`pnpm`)return Je(`pnpm-workspace.yaml`)??process.cwd();for(let e=process.cwd();;e=m(e)){try{if(JSON.parse(f(v(e,`package.json`),`utf-8`)).workspaces)return e}catch{}if(m(e)===e)return process.cwd()}}function Qe(e){return Object.assign({},...e.map(e=>G[e]?.builds??{}))}function $e(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=Ge[n];s.push(`upload (${n}): ${e.note}`),e.prod&&(t?i:r).add(e.prod),e.dev&&i.add(e.dev);continue}let e=G[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=K[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 et(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=>{Ye(!!e.all,q(e.runtime)??await J())})}function tt(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){Ye(!!t.all,q(t.runtime)??await J());return}let{pm:n,source:a}=await r(t.pm);console.log(`\n Using ${n} (resolved from ${a})`);let o=q(t.runtime),s=await Y(process.cwd()),c=o??s.runtime;if(!o&&s.ambiguous){console.error(`\n Cannot tell which HTTP engine this app boots on: found ${s.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 <${s.candidates.join(`|`)}> for this command\n`),process.exitCode=1;return}let l=$e(e,!!t.dev,c),{unknown:u,warnings:p,notices:m}=l,{prodDeps:h,devDeps:g}=l,_=process.cwd();if(t.entry&&!d(v(_,t.entry))){console.error(`\n --entry ${t.entry} does not exist.\n`),process.exitCode=1;return}let y=t.wire===!1?void 0:ke(e),b=y?Ae(_,t.entry):void 0;y&&b&&(y.integrations=Le(y.integrations,b));let x=y?.integrations.filter(e=>e.slot?.startsWith(`env-`))??[],C=x.length>0?Me(_):void 0;if(y){h=[.../* @__PURE__ */ new Set([...h,...y.dependencies])],g=[...new Set([...g,...y.devDependencies].filter(e=>!h.includes(e)))];let e=je(_,[...b?[b]:[],...C?[C]:[],...y.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, stage (git add) or stash them first, rerun with --force to edit anyway, or with --no-wire to install only.\n`),process.exitCode=1;return}}for(let e of p)console.warn(`\n WARNING: ${e}`);for(let e of m)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.
|
|
137
|
+
`),h.length===0&&g.length===0))return;let w={...Qe(e),...y?.builds};if(Object.keys(w).length>0){let e=X(n,Ze(n),w);e&&console.log(`\n Approved install scripts in ${e}`)}let T=!0;if(h.length>0){let e=h,t=`${n} add ${e.join(` `)}`;console.log(`\n Installing ${e.length} dependency(ies):`);for(let t of e)console.log(` + ${t}`);console.log();try{S(t,{stdio:`inherit`})}catch{T=!1,console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(g.length>0){let e=g,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{S(t,{stdio:`inherit`})}catch{T=!1,console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(y){if(!T)console.log(` Skipped wiring — the install did not finish.
|
|
138
|
+
`);else{let t=Pe(_,y.files),{created:r,updated:a}=await Fe(_,y.files);for(let e of r)console.log(` Created ${e}`);for(let e of a)console.log(` Updated ${e}`);let o=b?y.integrations.filter(e=>Ie(e,b,t)):[],s=y.integrations.filter(e=>!o.includes(e)),c=b?await ze(_,b,s):void 0;for(let e of c?.added??[])console.log(` Added ${e} to ${b}`);for(let e of c?.present??[])console.log(` ${e} is already in ${b}`);let l=C?await Ne(_,C,x):void 0;l?.added.length&&console.log(` Declared ${l.added.join(`, `)} in ${C}`);let u=l?l.manual:x.filter(e=>e.slot===`env-zod`);u.length>0&&(console.log(`\n ${C?`Could not find the env schema object in ${C}`:`No env schema (src/config/index.ts) found`} — declare these keys in it yourself:
|
|
139
139
|
`),console.log(u.map(e=>`${e.code},`).join(`
|
|
140
|
-
`).replace(/^/gm,` `)),console.log());let p=
|
|
141
|
-
`),console.log(`${
|
|
142
|
-
`),console.log(
|
|
140
|
+
`).replace(/^/gm,` `)),console.log());let p=Be(_),m=c?c.manual:y.integrations.filter(e=>e.slot&&e.code&&!e.slot.startsWith(`env-`)&&!e.slot.startsWith(`config-`)).map(e=>({...e,code:p(e.code)}));if(t.length>0){let e=o.map(e=>({...e,code:p(e.code??``)}));console.log(`\n ${t.join(`, `)} already exist${t.length===1?`s`:``} — left as ${t.length===1?`it is`:`they are`}. Merge in what the layer needs, then wire it yourself:
|
|
141
|
+
`),console.log(`${Ue(e)}`.replace(/^/gm,` `)),console.log()}m.length>0&&(console.log(`\n ${b?`Could not find bootstrap({ adapters: [...] }) in ${b}`:`No entry file found`} — add this yourself:
|
|
142
|
+
`),console.log(Ue(m).replace(/^/gm,` `)),console.log());let h=v(_,`kick.config.ts`),g=He(y.integrations,d(h)?f(h,`utf-8`):``);g&&(console.log(`
|
|
143
143
|
Add this to kick.config.ts:
|
|
144
|
-
`),console.log(g.replace(/^/gm,` `)),console.log());let S=[...new Set(e.map(e=>
|
|
144
|
+
`),console.log(g.replace(/^/gm,` `)),console.log());let S=[...new Set(e.map(e=>Oe[e]).filter(Boolean))];for(let e of await i(_,S,n))console.log(` Created ${e}`)}}T?console.log(` Done!
|
|
145
145
|
`):(console.log(` Finished with errors — the install above did not complete.
|
|
146
|
-
`),process.exitCode=1)})}const
|
|
147
|
-
`)});for(let[t,n]of
|
|
148
|
-
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${a} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-
|
|
149
|
-
Project scaffolded successfully!`),console.log();let
|
|
146
|
+
`),process.exitCode=1)})}const nt=m(y(import.meta.url));function rt(e){return{kick:u(e,`kick`),runDev:c(e,`dev`),runBuild:c(e,`build`),runStart:c(e,`start`),runTest:c(e,`test`)}}const Z=JSON.parse(f([h(nt,`..`,`package.json`),h(nt,`..`,`..`,`package.json`)].find(d),`utf-8`)),it=[`@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`],at={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`},"@inertiajs/vue3":{fallback:`^3.9.0`,cap:`^3`},"@inertiajs/svelte":{fallback:`^3.9.0`,cap:`^3`},vue:{fallback:`^3.5.0`,cap:`^3`},"@vitejs/plugin-vue":{fallback:`^6.0.0`},svelte:{fallback:`^5.46.4`,cap:`^5`},"@sveltejs/vite-plugin-svelte":{fallback:`^7.0.0`},"@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 Q(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 ot(e){return e===`@forinda/kickjs-cli`?`^${Z.version}`:`latest`}async function st(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 ct(){let e=[...it.map(e=>({name:e,fallback:ot(e),cap:void 0})),...Object.entries(at).map(([e,t])=>({name:e,...t}))],t=Date.now()+2e4,n=await st(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=Q(await N(`npm`,r?[`view`,a,`version`,`--json`]:[`view`,a,`version`],{timeout:i}));return[e,o?`^${o}`:n]});return Object.fromEntries(n)}function lt(e,t){let n=A(`npm`,[`view`,`${e}@${t}`,`version`],{timeout:2e4});return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}function ut(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function dt(e,t){let n=e=>ut(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 $=Z.version;async function ft(){let e=Q(await N(`npm`,[`view`,`@forinda/kickjs-cli`,`version`],{timeout:5e3}));return e&&pt($,e)?e:null}function pt(e,t){return e.split(`-`)[0]===t.split(`-`)[0]?e.includes(`-`)&&!t.includes(`-`):!dt(e,t)}function mt(e,t,n){let r=A(`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:r,directory:i,packageManager:a=`pnpm`,template:l=`rest`,client:f=`react`,defaultRepo:p=`inmemory`,packages:m=[],schemaLib:g=`zod`,runtime:_=`express`}=t,v=i,y=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${r}\n`),t.versions||y(`Resolving package versions...`);let b=t.versions??await ct(),x=Object.keys(b).filter(e=>b[e]===`latest`);if(x.length>0&&y(`WARNING: could not reach npm for ${x.join(`, `)} — pinned to 'latest'`),_!==`express`){if(mt(`@forinda/kickjs`,`latest`,`./${_}`))y(`Using @forinda/kickjs@latest (stable ships the ${_} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=lt(r,`alpha`);e&&dt(e,ut(b[r]))&&(b[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}y(n?`Using the alpha channel for the ${_} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${_} runtime subpath may be missing. After install, run: ${a} add @forinda/kickjs@alpha`)}}let C=m.filter(e=>!d(h(o,`feature-${e}`)));C.length>0&&y(`WARNING: skipping unknown package(s): ${C.join(`, `)} — add them later with kick add`);let w=n([...vt({template:l,client:f,runtime:_,schemaLib:g,packages:m}),...t.extraLayers??[]],{vars:{name:r,version:Z.version},extra:[{slot:`repo`,code:p===`inmemory`?`repo: 'inmemory'`:`repo: { name: '${p.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}' }`},...t.spaClientDir?[_t(t.spaClientDir)]:[]]}),E=t.platformConfig===!1?void 0:re(a);await e(h(v,`package.json`),oe(r,b,w,E));let D=ae(a,E);D&&await e(h(v,`.yarnrc.yml`),D);let O=s(w.files,{name:r,template:l,runtime:_,packageManager:a,...rt(a),templateLabel:{rest:`REST API`,minimal:`Minimal`,inertia:`Inertia (${{react:`React`,vue:`Vue`,svelte:`Svelte`}[f]})`}[l],sessionSecret:T(32).toString(`hex`),packages:[...w.dependencies,...w.devDependencies].filter(e=>e.startsWith(`@forinda/`)).map(e=>`- \`${e}\``).join(`
|
|
147
|
+
`)});for(let[t,n]of O)await e(h(v,t),n);t.deploy?.length&&t.platformConfig!==!1&&await R({dir:v,targets:t.deploy,pm:a,force:!0});let{generateAgentDocs:k}=await import(`./agent-docs-D_L3RIUM.mjs`).then(e=>e.t);await k({outDir:v,name:r,pm:a,template:l,only:`both`,force:!0});let A={...Xe,...Qe(m),...w.builds};if(t.approveInstallScripts!==!1&&X(a,v,A),t.installDeps){console.log(`\n Installing dependencies with ${a}...\n`);try{S(`${a} install`,{cwd:v,stdio:`inherit`}),console.log(`
|
|
148
|
+
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${a} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-DlnhNbzD.mjs`).then(e=>e.n);await e({cwd:v,allowDuplicates:!0,silent:!0})}catch{}if(t.initGit)try{S(`git init`,{cwd:v,stdio:`pipe`}),S(`git branch -M main`,{cwd:v,stdio:`pipe`}),S(`git add -A`,{cwd:v,stdio:`pipe`}),S(`git commit -m "chore: initial commit from kick new"`,{cwd:v,stdio:`pipe`}),y(`Git repository initialized`)}catch{y(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
149
|
+
Project scaffolded successfully!`),console.log();let ee=v!==process.cwd();y(`Next steps:`),ee&&y(` cd ${r}`),t.installDeps||y(` ${a} install`);let j=u(a,`kick`),M={rest:`${j} g module user`,minimal:`# add your routes to src/index.ts`,inertia:`# pages: src/modules/pages + src/client/pages`};y(` ${M[l]??M.rest}`),y(` ${c(a,`dev`)}`);let N=e=>{let t=Math.max(...e.map(([e])=>e.length))+2;for(let[n,r]of e)y(` ${n.padEnd(t)}${r}`)};return y(``),y(`Commands:`),N([[c(a,`dev`),`Start dev server with Vite HMR`],[c(a,`build`),`Production build via Vite`],[c(a,`start`),`Run production build`]]),y(``),y(`Generators:`),N([[`${j} g module <name>`,`REST module (controller, service, DTOs, repository)`],[`${j} g scaffold <n> <f..>`,`CRUD module from field definitions`],[`${j} g controller <name>`,`Standalone controller`],[`${j} g service <name>`,`@Service() class`],[`${j} g middleware <name>`,`Global connect-style middleware`],[`${j} g guard <name>`,`Route guard (auth, roles, etc.)`],[`${j} g adapter <name>`,`AppAdapter with lifecycle hooks`],[`${j} g dto <name>`,`DTO schema (Zod / Valibot / Yup)`],[`${j} g config`,`Generate kick.config.ts`]]),y(``),y(`Add packages:`),N([[`${j} add <pkg>`,`Install a KickJS package + peers`],[`${j} add --list`,`Show all available packages`]]),y(``),y(`Available: ${We}`),y(``),{builds:A}}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.
|
|
150
150
|
// Inert until the client build exists, so \`kick dev\` (where Vite
|
|
151
151
|
// serves the client and proxies /api here) is unaffected.
|
|
152
|
-
SpaAdapter({ clientDir: ${gt(e)} })`}}function vt(e){return[`base`,`template-${e.template}
|
|
152
|
+
SpaAdapter({ clientDir: ${gt(e)} })`}}function vt(e){return[`base`,`template-${e.template}`,...e.template===`inertia`?[`inertia-${e.client??`react`}`]:[],`runtime-${e.runtime}`,`schema-${e.schemaLib}`,...e.packages.filter(e=>d(h(o,`feature-${e}`))).map(e=>`feature-${e}`)]}export{M as C,ee as S,z as _,K as a,re as b,X as c,et as d,J as f,De as g,Ae as h,ct as i,q as l,je as m,ht as n,G as o,Y as p,ft as r,Ge as s,$ as t,tt as u,R as v,j as w,ae as x,he as y};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.
|
|
2
|
+
* @forinda/kickjs-cli v8.19.0
|
|
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-
|
|
11
|
+
import{t as e}from"./rolldown-runtime-SDDZy9Be.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.
|
|
2
|
+
* @forinda/kickjs-cli v8.19.0
|
|
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-
|
|
12
|
-
//# sourceMappingURL=project-root-
|
|
11
|
+
import{t as e}from"./rolldown-runtime-SDDZy9Be.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-DNQ4RQHQ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-root-
|
|
1
|
+
{"version":3,"file":"project-root-DNQ4RQHQ.mjs","names":["__exportAll","dirname","parse","resolve","existsSync","project_root_exports","findProjectRoot","CONFIG_FILENAMES","startDir","start","fsRoot","firstPackageJson","cursor","name","parent"],"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":";;;;;;;;;;A,sMAGA,MAAMO,EAAmB,CAAC,iBAAkB,iBAAkB,kBAAmB,kBAAkB,EAiBnG,SAAgBD,EAAgBE,EAAmB,QAAQ,IAAI,EAAW,CACxE,IAAMC,EAAQN,EAAQK,CAAQ,EACxB,CAAE,KAAME,GAAWR,EAAMO,CAAK,EAEhCE,EAAkC,KAClCC,EAASH,EACb,OAAa,CACX,IAAK,IAAMI,KAAQN,EACjB,GAAIH,EAAWD,EAAQS,EAAQC,CAAI,CAAC,EAAG,OAAOD,EAKhD,GAHID,IAAqB,MAAQP,EAAWD,EAAQS,EAAQ,cAAc,CAAC,IACzED,EAAmBC,GAEjBA,IAAWF,EAAQ,MACvB,IAAMI,EAASb,EAAQW,CAAM,EAC7B,GAAIE,IAAWF,EAAQ,MACvBA,EAASE,CACX,CAEA,OAAOH,GAAoBF,CAC7B,C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-cli v8.19.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
|
+
var e=Object.defineProperty,t=(t,n)=>{let r=Object.setPrototypeOf({},null);for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n&1||e(r,Symbol.toStringTag,{value:`Module`}),n&2?r:Object.preventExtensions(r)};export{t};
|