@forinda/kickjs-cli 8.7.8 → 8.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.js +2 -2
- package/dist/{agent-docs-z03QAZuD.mjs → agent-docs-BsXKM5QH.mjs} +16 -12
- package/dist/agent-docs-BsXKM5QH.mjs.map +1 -0
- package/dist/{agent-docs-JuchqDDh.mjs → agent-docs-DQksWOe5.mjs} +15 -11
- package/dist/{build-CLWPSTR5.mjs → build-Bnd_mk4h.mjs} +3 -3
- package/dist/build-Bnd_mk4h.mjs.map +1 -0
- package/dist/{build-BGkoUXcD.mjs → build-DPUojF2G.mjs} +2 -2
- package/dist/{builtins-qf1biU2Q.mjs → builtins-BEBO5upe.mjs} +2 -2
- package/dist/{builtins-D36W_Nic.mjs → builtins-CJTP3xQj.mjs} +52 -52
- package/dist/cli.mjs +2 -2
- package/dist/config-F9g6CNDA.mjs +13 -0
- package/dist/config-F9g6CNDA.mjs.map +1 -0
- package/dist/config-ty1Nc3PN.mjs +12 -0
- package/dist/{doctor-Cv8P4-Af.mjs → doctor-C8TAKn1d.mjs} +10 -10
- package/dist/doctor-C8TAKn1d.mjs.map +1 -0
- package/dist/fs-BB3QxPj8.mjs +12 -0
- package/dist/fs-BB3QxPj8.mjs.map +1 -0
- package/dist/fs-BGHl3dHm.mjs +11 -0
- package/dist/{fullstack-C88SUSlQ.mjs → fullstack-D25STbVk.mjs} +5 -5
- package/dist/{fullstack-JqamVcE-.mjs → fullstack-DWcfo-zl.mjs} +6 -6
- package/dist/fullstack-DWcfo-zl.mjs.map +1 -0
- package/dist/index.d.mts +10 -14
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/plugin-C4Dl_s4-.mjs +11 -0
- package/dist/{plugin-gT0vvcCm.mjs → plugin-Y7BoYk1K.mjs} +2 -2
- package/dist/project-3LsfnPLE.mjs +47 -0
- package/dist/project-3LsfnPLE.mjs.map +1 -0
- package/dist/project-BIq7_Fzk.mjs +46 -0
- package/dist/project-root-BDRPMlb9.mjs +11 -0
- package/dist/project-root-CFrn6ftT.mjs +12 -0
- package/dist/project-root-CFrn6ftT.mjs.map +1 -0
- package/dist/{prompts-CV5JHDs4.mjs → prompts-BJTp1w0l.mjs} +2 -2
- package/dist/prompts-BJTp1w0l.mjs.map +1 -0
- package/dist/{rolldown-runtime-DBz5c2Bd.mjs → rolldown-runtime-OACgOwtl.mjs} +1 -1
- package/dist/{run-plugins-C3w0I62s.mjs → run-plugins-2DJy76gx.mjs} +33 -33
- package/dist/run-plugins-2DJy76gx.mjs.map +1 -0
- package/dist/typegen-BBzX2LDz.mjs +107 -0
- package/dist/typegen-BBzX2LDz.mjs.map +1 -0
- package/dist/typegen-COAIhZZ4.mjs +106 -0
- package/dist/{types-BDzIj0W_.mjs → types-gy6PkRFW.mjs} +2 -2
- package/package.json +6 -6
- package/templates/template-inertia/feature.json +29 -0
- package/templates/template-inertia/files/_dot_env.append +2 -0
- package/templates/template-inertia/files/_dot_env.example.append +2 -0
- package/templates/template-inertia/files/_dot_env.test.append +1 -0
- package/templates/template-inertia/files/_dot_env.test.example.append +1 -0
- package/templates/template-inertia/files/public/favicon.svg +1 -0
- package/templates/template-inertia/files/public/robots.txt +4 -0
- package/templates/template-inertia/files/src/client/Layout.tsx +20 -0
- package/templates/template-inertia/files/src/client/app.css +8 -0
- package/templates/template-inertia/files/src/client/main.tsx +14 -0
- package/templates/template-inertia/files/src/client/pages/Error.tsx +14 -0
- package/templates/template-inertia/files/src/client/pages/Home.tsx +13 -0
- package/templates/template-inertia/files/src/client/pages/Posts/Index.tsx +38 -0
- package/templates/template-inertia/files/src/client/ssr.tsx +17 -0
- package/templates/template-inertia/files/src/index.ts +46 -0
- package/templates/template-inertia/files/src/modules/index.ts +7 -0
- package/templates/template-inertia/files/src/modules/pages/pages.controller.ts +37 -0
- package/templates/template-inertia/files/src/modules/pages/pages.module.ts +12 -0
- package/templates/template-inertia/files/tsconfig.json +22 -0
- package/templates/template-inertia/files/vite.client.config.ts +19 -0
- package/templates/template-inertia/files/vite.config.ts +40 -0
- package/templates/web-kick/files/web/src/api.ts +5 -2
- package/templates/web-kick/files/web/tsconfig.json +1 -1
- package/dist/agent-docs-z03QAZuD.mjs.map +0 -1
- package/dist/build-CLWPSTR5.mjs.map +0 -1
- package/dist/config-2x1N_mV1.mjs +0 -12
- package/dist/config-wzsPHJ1r.mjs +0 -13
- package/dist/config-wzsPHJ1r.mjs.map +0 -1
- package/dist/doctor-Cv8P4-Af.mjs.map +0 -1
- package/dist/fs-Cng50pl3.mjs +0 -12
- package/dist/fs-Cng50pl3.mjs.map +0 -1
- package/dist/fs-fU5dBnRJ.mjs +0 -11
- package/dist/fullstack-JqamVcE-.mjs.map +0 -1
- package/dist/plugin-Bn3_FodU.mjs +0 -11
- package/dist/project-B74aWTOZ.mjs +0 -46
- package/dist/project-root-B7nAxOl7.mjs +0 -11
- package/dist/project-root-uvQJBEg3.mjs +0 -12
- package/dist/project-root-uvQJBEg3.mjs.map +0 -1
- package/dist/project-ty_X8Qx9.mjs +0 -47
- package/dist/project-ty_X8Qx9.mjs.map +0 -1
- package/dist/prompts-CV5JHDs4.mjs.map +0 -1
- package/dist/run-plugins-C3w0I62s.mjs.map +0 -1
- package/dist/typegen-OdQgDQBP.mjs +0 -107
- package/dist/typegen-OdQgDQBP.mjs.map +0 -1
- package/dist/typegen-vKaJDE2e.mjs +0 -106
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.
|
|
2
|
+
* @forinda/kickjs-cli v8.8.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{r as e}from"./fs-
|
|
11
|
+
import{r as e}from"./fs-BB3QxPj8.mjs";import{a as t,f as n,n as r,p as i,t as a,u as o}from"./project-3LsfnPLE.mjs";import{join as s}from"node:path";import{execFileSync as c}from"node:child_process";const l=`https://kickjs.app/guide/fullstack-frontend.html`,u=[{value:`react-ts`,label:`React`},{value:`react-compiler-ts`,label:`React + Compiler`},{value:`vue-ts`,label:`Vue`},{value:`svelte-ts`,label:`Svelte`},{value:`solid-ts`,label:`Solid`},{value:`preact-ts`,label:`Preact`},{value:`lit-ts`,label:`Lit`},{value:`qwik-ts`,label:`Qwik`},{value:`vanilla-ts`,label:`Vanilla`}],d=`react-ts`;function f(e,t,n=d){let r=[`--template`,n,`--no-interactive`,`--no-immediate`];return e===`yarn`||e===`bun`?[e,`create`,`vite`,t,...r]:e===`npm`?[e,`create`,`vite@latest`,t,`--`,...r]:[e,`create`,`vite@latest`,t,...r]}async function p(u){let{name:p,directory:_,schemaLib:v=`zod`,runtime:y=`express`,packages:b=[],frontend:x=`kick`,viteTemplate:S=d}=u,C=[`pnpm`,`npm`,`yarn`,`bun`].includes(u.packageManager),w=C?u.packageManager:`pnpm`,T=_,E=e=>console.log(` ${e}`);u.packageManager!==void 0&&!C&&E(`Warning: unknown package manager '${String(u.packageManager)}' — falling back to pnpm.`),console.log(`\n Creating fullstack KickJS workspace: ${p}\n`),console.log(` Resolving package versions...`);let D=await r(),O=await a({name:`${p}-server`,directory:s(T,`server`),packageManager:w,template:`minimal`,schemaLib:v,runtime:y,packages:b,extraLayers:[`server-fullstack`],approveInstallScripts:!1,platformConfig:!1,initGit:!1,installDeps:!1,spaClientDir:`../web/dist`,versions:D});if(x===`vite`){console.log(`\n Handing web/ to create-vite (${S})...\n`);let[e,...t]=f(w,`web`,S);o(e,t,{cwd:T})}else await e(s(T,`web/package.json`),m(p,D));await e(s(T,`package.json`),h(p,w,D[`@forinda/kickjs-cli`])),w===`pnpm`&&await e(s(T,`pnpm-workspace.yaml`),`packages:
|
|
12
12
|
- server
|
|
13
13
|
- web
|
|
14
|
-
`),t(w,T,O.builds);let k=[`fullstack-root`,...x===`vite`?[]:[`web-kick`]],A=n(i(k).files,{name:p,packageManager:w});for(let[t,n]of A)await e(s(T,t),n);await e(s(T,`README.md`),g(p,w,x));let{generateAgentDocs:j}=await import(`./agent-docs-
|
|
15
|
-
Fullstack workspace scaffolded!`),console.log(),E(`Next steps:`),E(` cd ${p}`),u.installDeps||E(` ${w} install`),w===`pnpm`?E(` pnpm dev # runs server (kick dev) + web (vite) together`):(E(` ${w} run dev:server # terminal 1`),E(` ${w} run dev:web # terminal 2`)),E(``),x===`vite`?(E(`web/ is create-vite output, unwired. To type it against the API:`),E(` ${l}`)):(E(`The web app calls the API through @forinda/kickjs-client —`),E(
|
|
14
|
+
`),t(w,T,O.builds);let k=[`fullstack-root`,...x===`vite`?[]:[`web-kick`]],A=n(i(k).files,{name:p,packageManager:w});for(let[t,n]of A)await e(s(T,t),n);await e(s(T,`README.md`),g(p,w,x));let{generateAgentDocs:j}=await import(`./agent-docs-BsXKM5QH.mjs`).then(e=>e.t);if(await j({outDir:T,name:p,pm:w,template:`fullstack`,only:`all`,force:!0}),u.installDeps){console.log(`\n Installing workspace dependencies with ${w}...\n`);try{o(w,[`install`],{cwd:T})}catch{console.log(`\n Warning: ${w} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-BBzX2LDz.mjs`).then(e=>e.n);await e({cwd:s(T,`server`),allowDuplicates:!0,silent:!0})}catch{}if(u.initGit)try{c(`git`,[`init`],{cwd:T,stdio:`pipe`}),c(`git`,[`branch`,`-M`,`main`],{cwd:T,stdio:`pipe`}),c(`git`,[`add`,`-A`],{cwd:T,stdio:`pipe`}),c(`git`,[`commit`,`-m`,`chore: initial commit from kick new (fullstack)`],{cwd:T,stdio:`pipe`}),E(`Git repository initialized`)}catch{E(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
15
|
+
Fullstack workspace scaffolded!`),console.log(),E(`Next steps:`),E(` cd ${p}`),u.installDeps||E(` ${w} install`),w===`pnpm`?E(` pnpm dev # runs server (kick dev) + web (vite) together`):(E(` ${w} run dev:server # terminal 1`),E(` ${w} run dev:web # terminal 2`)),E(``),x===`vite`?(E(`web/ is create-vite output, unwired. To type it against the API:`),E(` ${l}`)):(E(`The web app calls the API through @forinda/kickjs-client —`),E("edit server/src/modules/hello, run `kick typegen` in server/, and"),E(`web/src/App.tsx's types follow.`)),E(``)}function m(e,t){let n=e=>t[e]??`latest`;return`${JSON.stringify({name:`${e}-web`,private:!0,version:`0.0.0`,type:`module`,scripts:{dev:`vite`,build:`tsc --noEmit && vite build`,preview:`vite preview`,typecheck:`tsc --noEmit`},dependencies:{"@forinda/kickjs-client":n(`@forinda/kickjs-client`),react:n(`react`),"react-dom":n(`react-dom`)},devDependencies:{"@types/react":n(`@types/react`),"@types/react-dom":n(`@types/react-dom`),"@vitejs/plugin-react":n(`@vitejs/plugin-react`),typescript:n(`typescript`),vite:n(`vite`)}},null,2)}\n`}function h(e,t,n){let r=t===`pnpm`?{dev:`pnpm --parallel -r run dev`,start:`pnpm --filter ./server run start`,"dev:server":`pnpm --filter ./server dev`,"dev:web":`pnpm --filter ./web dev`,build:`pnpm --filter ./server exec kick typegen && pnpm -r run build`,"build:netlify":`pnpm build && pnpm --filter ./server exec kick build:netlify`,"build:vercel":`pnpm build && pnpm --filter ./server exec kick build:vercel`,typecheck:`kick typecheck --cwd server && kick typecheck --cwd web`}:{start:`cd server && ${t} run start`,"dev:server":`cd server && ${t} run dev`,"dev:web":`cd web && ${t} run dev`,build:`cd server && ${t} exec kick typegen && cd .. && ${t} run build:server && ${t} run build:web`,"build:netlify":`${t} run build && cd server && ${t} exec kick build:netlify`,"build:vercel":`${t} run build && cd server && ${t} exec kick build:vercel`,"build:server":`cd server && ${t} run build`,"build:web":`cd web && ${t} run build`,typecheck:`kick typecheck --cwd server && kick typecheck --cwd web`};return`${JSON.stringify({name:e,private:!0,version:`0.0.0`,type:`module`,scripts:r,devDependencies:{"@forinda/kickjs-cli":n},workspaces:[`server`,`web`]},null,2)}\n`}function g(e,t,n=`kick`){let r=`# ${e}
|
|
16
16
|
|
|
17
17
|
Fullstack KickJS workspace — typed end to end.
|
|
18
18
|
|
|
@@ -51,7 +51,7 @@ stops compiling. That's the point.
|
|
|
51
51
|
\`server/.kickjs/types/kick__client.d.ts\` is generated, and \`web\` reads it as
|
|
52
52
|
an ambient type package. Two things follow.
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
**\`kick dev\` writes it at startup, not on save.** Resolving it builds a whole TypeScript
|
|
55
55
|
program over the server, which is a build-step cost rather than a per-save one,
|
|
56
56
|
so a renamed response field surfaces on the next \`kick typegen\` rather than on
|
|
57
57
|
save. Everything else in \`.kickjs/types\` still updates on save. Add
|
|
@@ -93,4 +93,4 @@ Four steps — typed client, \`/api\` dev proxy, route-map types, \`src/api.ts\`
|
|
|
93
93
|
|
|
94
94
|
${l}
|
|
95
95
|
`}export{d as DEFAULT_VITE_TEMPLATE,u as VITE_TEMPLATES,p as initFullstackProject};
|
|
96
|
-
//# sourceMappingURL=fullstack-
|
|
96
|
+
//# sourceMappingURL=fullstack-DWcfo-zl.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fullstack-DWcfo-zl.mjs","names":["writeFileSafe","approveInstallScripts","fillVars","resolveSiblingVersions","renderLayers","initProject","runCommand","FRONTEND_WIRING_URL","VITE_TEMPLATES","DEFAULT_VITE_TEMPLATE","createViteCommand","flags","template","pm","dir","initFullstackProject","options","pmValid","packageManager","directory","log","msg","name","versions","server","join","frontend","viteTemplate","file","args","webPackageJson","rootPackageJson","layers","files","path","contents","rootReadme","n","generateAgentDocs","runTypegen","execFileSync","dep","pkg","scripts","cliVersion","readme","typeLoop"],"sources":["../src/generators/fullstack.ts"],"sourcesContent":["// `kick new --template fullstack` — a pnpm-workspace monorepo:\n//\n// my-app/\n// server/ KickJS API (the standard scaffold, minus its own git/install)\n// web/ Vite + React frontend typed end-to-end via\n// @forinda/kickjs-client + the server's generated KickClientApi.Api\n//\n// The type loop: server controllers use return-value handlers → `kick\n// typegen` (run here once, then by the root `build` script and `kick dev` startup — not on save) emits\n// server/.kickjs/types/kick__client.d.ts → web tsconfig `types` (ambient)\n// side-effect-imports that file (type-only, erased at runtime) → the web\n// client calls `api.get('/hello')` with the handler's actual response type.\n\nimport { join } from 'node:path'\nimport { execFileSync } from 'node:child_process'\n\nimport { writeFileSafe } from '../utils/fs'\nimport { runCommand } from '../utils/shell'\nimport { initProject, resolveSiblingVersions } from './project'\nimport { approveInstallScripts } from '../commands/add'\nimport { fillVars, renderLayers } from '../scaffold/overlay'\n\n/** Wiring a frontend we did not scaffold: typed client, proxy, route types. */\nexport const FRONTEND_WIRING_URL = 'https://kickjs.app/guide/fullstack-frontend.html'\n\n/**\n * create-vite's TypeScript templates, in the order it lists them. Only the\n * `-ts` half: the wiring is typed — the route map is a `.d.ts` and the client\n * is `createClient<KickClientApi.Api>` — so a JavaScript template would leave\n * the reader following a guide that cannot apply.\n */\nexport const VITE_TEMPLATES = [\n { value: 'react-ts', label: 'React' },\n { value: 'react-compiler-ts', label: 'React + Compiler' },\n { value: 'vue-ts', label: 'Vue' },\n { value: 'svelte-ts', label: 'Svelte' },\n { value: 'solid-ts', label: 'Solid' },\n { value: 'preact-ts', label: 'Preact' },\n { value: 'lit-ts', label: 'Lit' },\n { value: 'qwik-ts', label: 'Qwik' },\n { value: 'vanilla-ts', label: 'Vanilla' },\n] as const\n\nexport const DEFAULT_VITE_TEMPLATE = 'react-ts'\n\n/**\n * How each package manager runs create-vite, with the framework decided here\n * rather than by its prompts:\n *\n * - `--template` picks a TypeScript template, so the wiring guide applies;\n * - `--no-interactive` means it never waits for input (CI, `--yes`);\n * - `--no-immediate` stops it installing and launching a dev server — the\n * workspace install happens once, at the root, after this returns.\n */\nexport function createViteCommand(\n pm: 'pnpm' | 'npm' | 'yarn' | 'bun',\n dir: string,\n template: string = DEFAULT_VITE_TEMPLATE,\n): string[] {\n const flags = ['--template', template, '--no-interactive', '--no-immediate']\n // yarn and bun resolve `create vite` to create-vite themselves; npm and pnpm\n // take the versioned package name, and npm needs `--` before the flags or it\n // eats them itself.\n if (pm === 'yarn' || pm === 'bun') return [pm, 'create', 'vite', dir, ...flags]\n if (pm === 'npm') return [pm, 'create', 'vite@latest', dir, '--', ...flags]\n return [pm, 'create', 'vite@latest', dir, ...flags]\n}\n\nexport interface InitFullstackOptions {\n name: string\n directory: string\n packageManager?: 'pnpm' | 'npm' | 'yarn' | 'bun'\n /**\n * Who scaffolds `web/`. `'kick'` writes the wired React app (typed client,\n * dev proxy, route-map types). `'vite'` hands the directory to\n * `create-vite` and wires nothing — you pick the framework, and the guide\n * at {@link FRONTEND_WIRING_URL} covers connecting it.\n */\n frontend?: 'kick' | 'vite'\n /** create-vite template for `frontend: 'vite'`. Default `react-ts`. */\n viteTemplate?: string\n initGit?: boolean\n installDeps?: boolean\n schemaLib?: 'zod' | 'valibot' | 'yup'\n runtime?: 'express' | 'fastify' | 'h3'\n /** Optional packages (`--packages`), wired into the server like a plain scaffold. */\n packages?: string[]\n}\n\nexport async function initFullstackProject(options: InitFullstackOptions): Promise<void> {\n const {\n name,\n directory,\n schemaLib = 'zod',\n runtime = 'express',\n packages = [],\n frontend = 'kick',\n viteTemplate = DEFAULT_VITE_TEMPLATE,\n } = options\n // `--pm` arrives as a free CLI string — allowlist before it reaches a\n // process invocation (execFileSync takes an argv array, no shell, but a\n // bogus binary name is still a confusing failure).\n const pmValid = (['pnpm', 'npm', 'yarn', 'bun'] as const).includes(\n options.packageManager as never,\n )\n const packageManager = pmValid\n ? (options.packageManager as 'pnpm' | 'npm' | 'yarn' | 'bun')\n : 'pnpm'\n const dir = directory\n const log = (msg: string) => console.log(` ${msg}`)\n if (options.packageManager !== undefined && !pmValid) {\n log(\n `Warning: unknown package manager '${String(options.packageManager)}' — falling back to pnpm.`,\n )\n }\n\n console.log(`\\n Creating fullstack KickJS workspace: ${name}\\n`)\n\n // One map for both packages: the workspace shares a toolchain, so server/\n // and web/ must not end up on different vite or TypeScript majors.\n console.log(' Resolving package versions...')\n const versions = await resolveSiblingVersions()\n\n // ── server/ — the standard scaffold, deferred install/git ──────────\n const server = await initProject({\n name: `${name}-server`,\n directory: join(dir, 'server'),\n packageManager,\n template: 'minimal',\n schemaLib,\n runtime,\n packages,\n // The client route map web/ reads (with the compiler API it needs), and a\n // strict port — web/vite.config.ts proxies /api to it, so moving to\n // another port would silently reach the wrong process.\n extraLayers: ['server-fullstack'],\n // server/ is a workspace member; the root records the approvals.\n approveInstallScripts: false,\n // netlify.toml / vercel.json live at the workspace root, written below.\n platformConfig: false,\n // Root owns install + git so the lockfile/commit cover the workspace.\n initGit: false,\n installDeps: false,\n // Production single-origin serving. `web/` builds to `web/dist`, and\n // nothing served it before — `pnpm build` produced a frontend the API had\n // no way to hand out, so every deploy needed a hand-wired static host or\n // a second process. The adapter is inert until `../web/dist` exists, so\n // `dev` (Vite serves the client and proxies /api here) is untouched.\n spaClientDir: '../web/dist',\n versions,\n })\n\n // ── web/ — either our wired React app, or whatever create-vite makes ──\n if (frontend === 'vite') {\n // create-vite scaffolds it with the chosen TypeScript template. Nothing\n // is patched afterwards: a scaffold we didn't write is not ours to\n // rewrite, and the wiring is four steps in the guide.\n console.log(`\\n Handing web/ to create-vite (${viteTemplate})...\\n`)\n const [file, ...args] = createViteCommand(packageManager, 'web', viteTemplate)\n runCommand(file!, args, { cwd: dir })\n } else {\n // The wired React app (typed client, dev proxy, route-map types): its\n // package.json here, its files from the web-kick layer below.\n await writeFileSafe(join(dir, 'web/package.json'), webPackageJson(name, versions))\n }\n\n // ── workspace root ──────────────────────────────────────────────────\n await writeFileSafe(\n join(dir, 'package.json'),\n rootPackageJson(name, packageManager, versions['@forinda/kickjs-cli']),\n )\n // Only pnpm reads this file. npm / yarn / bun declare workspaces via the\n // `workspaces` field in the root package.json instead — see rootPackageJson.\n if (packageManager === 'pnpm') {\n await writeFileSafe(join(dir, 'pnpm-workspace.yaml'), 'packages:\\n - server\\n - web\\n')\n }\n // Before install, at the root every package manager reads them from.\n approveInstallScripts(packageManager, dir, server.builds)\n // .gitignore, and netlify.toml / vercel.json at the root both platforms\n // build from; plus the kick web app's files under web/.\n const layers = ['fullstack-root', ...(frontend === 'vite' ? [] : ['web-kick'])]\n const files = fillVars(renderLayers(layers).files, { name, packageManager })\n for (const [path, contents] of files) {\n await writeFileSafe(join(dir, path), contents)\n }\n await writeFileSafe(join(dir, 'README.md'), rootReadme(name, packageManager, frontend))\n\n // Workspace-root agent docs (CLAUDE.md + .agents/) flavored for the\n // fullstack layout — the server/ subdir keeps its own generated set.\n const { generateAgentDocs } = await import('./agent-docs')\n await generateAgentDocs({\n outDir: dir,\n name,\n pm: packageManager,\n template: 'fullstack',\n only: 'all',\n force: true,\n })\n\n // ── install (root — covers both workspace packages) ────────────────\n if (options.installDeps) {\n console.log(`\\n Installing workspace dependencies with ${packageManager}...\\n`)\n try {\n // `runCommand`, not bare execFileSync — on Windows every package\n // manager is a `.cmd` shim that execFileSync cannot spawn.\n runCommand(packageManager, ['install'], { cwd: dir })\n } catch {\n console.log(`\\n Warning: ${packageManager} install failed. Run it manually.`)\n }\n }\n\n // ── typegen (server) so web's KickClientApi.Api resolves immediately ──\n try {\n const { runTypegen } = await import('../typegen')\n await runTypegen({ cwd: join(dir, 'server'), allowDuplicates: true, silent: true })\n } catch {\n // Non-fatal — `kick typegen` in server/ (or the root `build`) writes it later.\n }\n\n // ── git (root) ──────────────────────────────────────────────────────\n if (options.initGit) {\n try {\n execFileSync('git', ['init'], { cwd: dir, stdio: 'pipe' })\n execFileSync('git', ['branch', '-M', 'main'], { cwd: dir, stdio: 'pipe' })\n execFileSync('git', ['add', '-A'], { cwd: dir, stdio: 'pipe' })\n execFileSync('git', ['commit', '-m', 'chore: initial commit from kick new (fullstack)'], {\n cwd: dir,\n stdio: 'pipe',\n })\n log('Git repository initialized')\n } catch {\n log('Warning: git init failed (git may not be installed)')\n }\n }\n\n console.log('\\n Fullstack workspace scaffolded!')\n console.log()\n log('Next steps:')\n log(` cd ${name}`)\n if (!options.installDeps) log(` ${packageManager} install`)\n if (packageManager === 'pnpm') {\n log(' pnpm dev # runs server (kick dev) + web (vite) together')\n } else {\n log(` ${packageManager} run dev:server # terminal 1`)\n log(` ${packageManager} run dev:web # terminal 2`)\n }\n log('')\n if (frontend === 'vite') {\n // Nothing in web/ knows about the API yet — say so, and say where the\n // four wiring steps live rather than half-wiring someone else's scaffold.\n log('web/ is create-vite output, unwired. To type it against the API:')\n log(` ${FRONTEND_WIRING_URL}`)\n } else {\n log('The web app calls the API through @forinda/kickjs-client —')\n log('edit server/src/modules/hello, run `kick typegen` in server/, and')\n log(\"web/src/App.tsx's types follow.\")\n }\n log('')\n}\n\n// ── web templates ─────────────────────────────────────────────────────\n\nfunction webPackageJson(name: string, versions: Record<string, string>): string {\n // Every range here is resolved at scaffold time — see THIRD_PARTY_PACKAGES.\n const dep = (pkg: string) => versions[pkg] ?? 'latest'\n return `${JSON.stringify(\n {\n name: `${name}-web`,\n private: true,\n version: '0.0.0',\n type: 'module',\n scripts: {\n dev: 'vite',\n build: 'tsc --noEmit && vite build',\n preview: 'vite preview',\n typecheck: 'tsc --noEmit',\n },\n dependencies: {\n '@forinda/kickjs-client': dep('@forinda/kickjs-client'),\n react: dep('react'),\n 'react-dom': dep('react-dom'),\n },\n devDependencies: {\n '@types/react': dep('@types/react'),\n '@types/react-dom': dep('@types/react-dom'),\n '@vitejs/plugin-react': dep('@vitejs/plugin-react'),\n // Same majors as the server package: one workspace, one toolchain.\n typescript: dep('typescript'),\n vite: dep('vite'),\n },\n },\n null,\n 2,\n )}\\n`\n}\n\n// ── root templates ────────────────────────────────────────────────────\n\nfunction rootPackageJson(name: string, pm: string, cliVersion: string): string {\n const scripts: Record<string, string> =\n pm === 'pnpm'\n ? {\n dev: 'pnpm --parallel -r run dev',\n // One origin: the server serves `web/dist` through SpaAdapter.\n start: 'pnpm --filter ./server run start',\n 'dev:server': 'pnpm --filter ./server dev',\n 'dev:web': 'pnpm --filter ./web dev',\n // Typegen first: web's `tsc` reads server/.kickjs/types, which is\n // git-ignored, so a fresh clone (CI, Netlify, Vercel) has none and\n // `pnpm -r run build` races the two packages anyway.\n build: 'pnpm --filter ./server exec kick typegen && pnpm -r run build',\n 'build:netlify': 'pnpm build && pnpm --filter ./server exec kick build:netlify',\n 'build:vercel': 'pnpm build && pnpm --filter ./server exec kick build:vercel',\n // No `npx`: the binary is `kick` but the package is\n // `@forinda/kickjs-cli`, so npx cannot map one to the other and\n // falls back to the REGISTRY — where `kick` is an unrelated\n // AngularJS scaffolder. It runs, prints its own help, and exits 0,\n // so this script would pass without type-checking anything.\n //\n // Every package manager puts `node_modules/.bin` on PATH for\n // scripts, so the bare name resolves locally, and a missing install\n // fails loudly instead of fetching a stranger.\n typecheck: 'kick typecheck --cwd server && kick typecheck --cwd web',\n }\n : {\n // cd-based scripts — the one form npm, yarn (classic AND berry),\n // and bun all run identically; workspace-filter flags differ per\n // manager (--workspace vs `yarn workspace <name>` vs --filter).\n start: `cd server && ${pm} run start`,\n 'dev:server': `cd server && ${pm} run dev`,\n 'dev:web': `cd web && ${pm} run dev`,\n // Typegen first — see the pnpm branch above.\n build: `cd server && ${pm} exec kick typegen && cd .. && ${pm} run build:server && ${pm} run build:web`,\n 'build:netlify': `${pm} run build && cd server && ${pm} exec kick build:netlify`,\n 'build:vercel': `${pm} run build && cd server && ${pm} exec kick build:vercel`,\n 'build:server': `cd server && ${pm} run build`,\n 'build:web': `cd web && ${pm} run build`,\n // No `npx`: the binary is `kick` but the package is\n // `@forinda/kickjs-cli`, so npx cannot map one to the other and\n // falls back to the REGISTRY — where `kick` is an unrelated\n // AngularJS scaffolder. It runs, prints its own help, and exits 0,\n // so this script would pass without type-checking anything.\n //\n // Every package manager puts `node_modules/.bin` on PATH for\n // scripts, so the bare name resolves locally, and a missing install\n // fails loudly instead of fetching a stranger.\n typecheck: 'kick typecheck --cwd server && kick typecheck --cwd web',\n }\n return `${JSON.stringify(\n {\n name,\n private: true,\n version: '0.0.0',\n type: 'module',\n scripts,\n // The CLI is a ROOT dependency so the bare `kick` in the scripts above\n // resolves: package managers put `node_modules/.bin` on PATH for\n // scripts, and the CLI otherwise lives only in `server/node_modules`.\n devDependencies: { '@forinda/kickjs-cli': cliVersion },\n workspaces: ['server', 'web'],\n },\n null,\n 2,\n )}\\n`\n}\n\nexport function rootReadme(name: string, pm: string, frontend: 'kick' | 'vite' = 'kick'): string {\n const readme = `# ${name}\n\nFullstack KickJS workspace — typed end to end.\n\n| Package | What |\n| --------- | ----------------------------------------------------------------- |\n| \\`server/\\` | KickJS API (decorators, DI, \\`kick dev\\` with typegen watch) |\n| \\`web/\\` | Vite + React, typed against the API via \\`@forinda/kickjs-client\\` |\n\n## Develop\n\n\\`\\`\\`bash\n${pm} install\n${pm === 'pnpm' ? 'pnpm dev # server (kick dev) + web (vite), in parallel' : `${pm} run dev:server # terminal 1\\n${pm} run dev:web # terminal 2`}\n\\`\\`\\`\n\nServer: http://localhost:3000 · Web: http://localhost:5173 (Vite proxies \\`/api\\`).\n\n## The type loop\n\n1. Server handlers **return** their payloads (\\`return this.service.greet(...)\\`).\n2. \\`kick typegen\\` emits \\`server/.kickjs/types/kick__client.d.ts\\` — the flat\n route map with every response type resolved to a literal shape.\n3. \\`web/tsconfig.json\\` lists that file in \\`types\\`, so \\`KickClientApi\\` is\n ambient — no import, no bridge file.\n4. \\`web/src/api.ts\\`'s \\`createClient<KickClientApi.Api>\\` types every call site.\n\nBecause the map holds resolved types rather than references to controllers,\n\\`web\\` never compiles server source: no \\`experimentalDecorators\\`, no path\naliases into \\`server/src\\`.\n\nRename a field in \\`server/src/modules/hello/hello.service.ts\\` → \\`web/src/App.tsx\\`\nstops compiling. That's the point.\n\n### Keeping the map fresh\n\n\\`server/.kickjs/types/kick__client.d.ts\\` is generated, and \\`web\\` reads it as\nan ambient type package. Two things follow.\n\n**\\`kick dev\\` writes it at startup, not on save.** Resolving it builds a whole TypeScript\nprogram over the server, which is a build-step cost rather than a per-save one,\nso a renamed response field surfaces on the next \\`kick typegen\\` rather than on\nsave. Everything else in \\`.kickjs/types\\` still updates on save. Add\n\\`kick typegen --check\\` to CI and a stale map fails the build.\n\n**It needs a compiler API.** TypeScript 7 ships none, so \\`server\\` depends on\n\\`@typescript/typescript6\\`. Remove it and typegen skips this one file, saying\nso; \\`web\\` then reports \\`TS2688\\` because the file it lists in \\`types\\` is gone.\n\n### The other way to wire it\n\nA \\`types\\` entry says \"this is a global type package\", which is what the map is,\nand it fails loudly when the file is missing. If you would rather it be quiet\nwhen absent — say, a repo where the map is not always generated — use\n\\`include\\` instead:\n\n\\`\\`\\`json\n{ \"include\": [\"src\", \"../server/.kickjs/types/kick__client.d.ts\"] }\n\\`\\`\\`\n\nThat tolerates the file not existing, at the cost of \\`KickClientApi\\` silently\nnot resolving. Note \\`types\\` replaces TypeScript's automatic \\`@types\\`\ninclusion, so if you add entries there, list the ones you rely on too\n(\\`\"types\": [\"node\", \"../server/.kickjs/types/kick__client\"]\\`).\n\nOr skip the global entirely — the same file exports the type:\n\n\\`\\`\\`ts\nimport type { Api } from '../../server/.kickjs/types/kick__client'\n\nexport const api = createClient<Api>({ baseUrl: '/api/v1' })\n\\`\\`\\`\n\nDocs: https://kickjs.app/guide/typed-client.html\n`\n\n if (frontend !== 'vite') return readme\n\n // create-vite's output is not ours to describe: it has no typed client, no\n // proxy and no route-map types until the reader wires them. Everything from\n // \"The type loop\" on is about files that do not exist in that scaffold.\n const typeLoop = readme.indexOf('## The type loop')\n return `${readme\n .slice(0, typeLoop)\n .replace(\n 'Vite + React, typed against the API via `@forinda/kickjs-client`',\n 'create-vite scaffold — unwired (see below) ',\n )\n .replace(' (Vite proxies `/api`)', '')}## Wiring web/ to the API\n\n\\`web/\\` is whatever create-vite scaffolded; nothing connects it to the API yet.\nFour steps — typed client, \\`/api\\` dev proxy, route-map types, \\`src/api.ts\\`:\n\n${FRONTEND_WIRING_URL}\n`\n}\n"],"mappings":";;;;;;;;;;uMAuBA,MAAaO,EAAsB,m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AMS,EAAS,KAAKvB,EAAK;;;;;;;;;;;;EAYzBT,EAAG;EACHA,IAAO,OAAS,oEAAsE,GAAGA,EAAG,kCAAkCA,EAAG,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+DjK,GAAIa,IAAa,OAAQ,OAAOmB,EAKhC,IAAMC,EAAWD,EAAO,QAAQ,kBAAkB,EAClD,MAAO,GAAGA,EACP,MAAM,EAAGC,CAAQ,CAAC,CAClB,QACC,mEACA,mEACF,CAAC,CACA,QAAQ,yBAA0B,EAAE,EAAE;;;;;EAKzCvC,EAAoB;CAEtB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -346,18 +346,15 @@ interface TypegenConfig {
|
|
|
346
346
|
* how a frontend ends up type-checking against routes the server no longer
|
|
347
347
|
* serves.
|
|
348
348
|
*
|
|
349
|
-
* Pass an object to tune the expansion. `{ maxDepth }`
|
|
350
|
-
*
|
|
351
|
-
*
|
|
349
|
+
* Pass an object to tune the expansion. `{ maxDepth }` sets how deeply a
|
|
350
|
+
* response type nests inline before the type at that point is hoisted to a
|
|
351
|
+
* declaration of its own. Hoists spend a per-route budget of 1,000; a route
|
|
352
|
+
* that exhausts it — an endlessly growing generic, or a very large response
|
|
353
|
+
* — is emitted as `unknown` with a warning:
|
|
352
354
|
*
|
|
353
355
|
* ```ts
|
|
354
356
|
* typegen: { client: { maxDepth: 24 } }
|
|
355
357
|
* ```
|
|
356
|
-
*
|
|
357
|
-
* The default of 12 truncates nothing on a 1,940-route app — recursion and
|
|
358
|
-
* named types both hoist, which costs one level rather than the whole
|
|
359
|
-
* budget, so only deep *anonymous* nesting spends it. Raise it if a route
|
|
360
|
-
* warns that it exceeded the limit; the warning names the route.
|
|
361
358
|
*/
|
|
362
359
|
client?: boolean | ClientTypegenConfig;
|
|
363
360
|
}
|
|
@@ -366,11 +363,10 @@ interface ClientTypegenConfig {
|
|
|
366
363
|
/** On, unless explicitly false. Lets `{ maxDepth }` alone mean "on". */
|
|
367
364
|
enabled?: boolean;
|
|
368
365
|
/**
|
|
369
|
-
* Levels of inline nesting
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
* correctness. Default 12.
|
|
366
|
+
* Levels of inline nesting before a type is hoisted to its own declaration
|
|
367
|
+
* (`interface __Tn` / `type __Tn`). Each hoist spends from a per-route budget
|
|
368
|
+
* of 1,000, so a higher value hoists fewer types and lets a larger response
|
|
369
|
+
* through. Default 12.
|
|
374
370
|
*/
|
|
375
371
|
maxDepth?: number;
|
|
376
372
|
}
|
|
@@ -871,7 +867,7 @@ interface GenerateDtoOptions {
|
|
|
871
867
|
export declare function generateDto(options: GenerateDtoOptions): Promise<string[]>;
|
|
872
868
|
//#endregion
|
|
873
869
|
//#region src/generators/project.d.ts
|
|
874
|
-
type ProjectTemplate = 'rest' | 'minimal';
|
|
870
|
+
type ProjectTemplate = 'rest' | 'minimal' | 'inertia';
|
|
875
871
|
type SchemaLib = 'zod' | 'valibot' | 'yup';
|
|
876
872
|
interface InitProjectOptions {
|
|
877
873
|
name: string;
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/commands/add.ts","../src/commands/doctor.ts","../src/plugin/types.ts","../src/config.ts","../src/generators/templates/types.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/utils/project-root.ts","../src/typegen/scanner.ts","../src/typegen/plugin.ts","../src/typegen/token-conventions.ts","../src/typegen/index.ts","../src/typegen/run-plugins.ts","../src/asset-manager/build.ts","../src/typegen/dev-watcher.ts","../src/generator-extension/discover.ts","../src/generator-extension/context.ts","../src/utils/naming.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["KitCliPluginContext","KitCliPlugin","BuiltinRepoType","_$__commands_doctor0.DoctorExtension","SchemaLib","SchemaLib","SchemaLib"],"sources":["../src/commands/add.ts","../src/commands/doctor.ts","../src/plugin/types.ts","../src/config.ts","../src/generators/templates/types.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/utils/project-root.ts","../src/typegen/scanner.ts","../src/typegen/plugin.ts","../src/typegen/token-conventions.ts","../src/typegen/index.ts","../src/typegen/run-plugins.ts","../src/asset-manager/build.ts","../src/typegen/dev-watcher.ts","../src/generator-extension/discover.ts","../src/generator-extension/context.ts","../src/utils/naming.ts"],"mappings":";;;;KAyQY;;;;;;;;;;;;;;;;;;;UC9OK;EACf;EACA;;;;;;;EAOA;;;;;;EAMA,SAAS;;UAGM;;EAEf;EACA;;EAEA;;EAEA;;KAGU,eACV,KAAK,kBACF,eAAe,wBAAwB,QAAQ,eAAe;;;;;;UAOlD;;EAEf,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqCK,sBAAsB,KAAK,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;wBA0B7C,kBAAkB,OAAO,cAAc;;;;KChG3C,uBAAuBA,uBAAoB;;KAG3C,gBAAgBC,gBAAa;;;;UC5BxB;;EAEf;;EAEA;;;;;;;;;EASA;;EAEA;;;KAIU;;KAGA;;;;;;;;;;;;;KAgBAC;;UA0BK;EACf;;;KAIU,iBAAiBA,oBAAkB;;;;;;;;;;;KAYnC;;;;;;UAOK;;;;;;;EAOf;;;;;;;EAOA;;;;;;EAMA;;;;;;;;;;;;;;;;;;;;;;EAsBA;;;;;;;;;;;;;;;;;;;;;;;;UAyBe;;;;;EAKf;;;;;EAKA;;EAEA;;EAEA;;;;;;;EAOA;;;;;;;EAOA,0BAA0B;;;UAIX;;;;;EAKf;;;;;EAKA;;;;;;;;;;;;;EAaA,kBAAkB;;;;;;;;;;EAUlB;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;EAUhB,SAAS;;UAGM;;EAEf;;;;;;;EAOA;;EAEA;;;UAIe;EACf;EACA;EACA;;;;;;EAMA;;;UAIe;EACf;EACA,SAAS;;EAET,UAAU;;;;;;;;;;;;;iBAcU,YACpB,QAAQ,mBACR,MAAM,qBACL,QAAQ;;;;;;;;qBCrDE;KAED;;UAGK;EACf,mBAAmB;EACnB,6BAA6B;EAC7B,8BAA8B;EAC9B,oBAAoB;;UAGL;EACf;;EAEA,QAAQ;;;;;EAKR,cAAc;;;;;;EAMd;;EAEA;;EAEA,WAAW;;UAGI;;EAEf,iBAAiB,OAAO,mBAAmB;;;;;EAK3C;;;;;;EAMA;;EAEA;;wBAGc,wBAAwB,MAAM,2BAA2B;;;;;;;;UC3ExD;EACf;EACA,MAAM;;;;;;;UAQS;EACf,YAAY;;EAEZ;;;;;EAKA,QAAQ;IAAQ;IAAgB;;;;;;;;;;;wBCblB,sBAAsB;EACpC;EACA;EACA,QAAQ;EACR;EACA;;;;;;;EAOA;EACA;IACE;;;;wBC5BY,aAAa;;wBAOb,YAAY;;wBAMZ,YAAY;;;;;;wBAYZ,UAAU"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.
|
|
2
|
+
* @forinda/kickjs-cli v8.8.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{C as e,F as t,N as n,P as r,_ as i,c as a,d as o,g as s,h as c,j as l,l as u,m as d,n as f,o as p,p as m,s as h,t as g,y as _}from"./doctor-
|
|
11
|
+
import{C as e,F as t,N as n,P as r,_ as i,c as a,d as o,g as s,h as c,j as l,l as u,m as d,n as f,o as p,p as m,s as h,t as g,y as _}from"./doctor-C8TAKn1d.mjs";import{t as v}from"./project-3LsfnPLE.mjs";import{o as y,r as b}from"./config-F9g6CNDA.mjs";import{t as x}from"./project-root-CFrn6ftT.mjs";import{n as S,t as C}from"./types-gy6PkRFW.mjs";export{C as KickPluginConflictError,a as TYPEGEN_OWNER_KEY,p as buildGeneratorContext,u as createTypegenDevWatcher,S as defineCliPlugin,b as defineConfig,g as defineDoctorCheck,f as defineDoctorExtension,h as defineGenerator,o as defineTypegen,x as findProjectRoot,_ as generateAdapter,d as generateController,m as generateDto,s as generateGuard,i as generateMiddleware,e as generateModule,c as generateService,v as initProject,y as loadKickConfig,l as pluralize,n as toCamelCase,r as toKebabCase,t as toPascalCase};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-cli v8.8.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{t as e}from"./rolldown-runtime-OACgOwtl.mjs";import{KickPluginConflictError as t,defineCliPlugin as n}from"@forinda/kickjs-cli-kit";function r(e,n=[]){let r=/* @__PURE__ */ new Map;for(let n of e){let e=(r.get(n.name)??0)+1;if(r.set(n.name,e),e===2)throw new t(`plugin`,n.name,[n.name,n.name])}let i=/* @__PURE__ */ new Map,a=[];for(let n of e)for(let e of n.commands??[]){let r=i.get(e.name);if(r)throw new t(`command`,e.name,[r,n.name]);i.set(e.name,n.name),a.push(e)}let o=new Set(n.map(e=>e.name)),s=[...a.filter(e=>!o.has(e.name)),...n],c=/* @__PURE__ */ new Map,l=[];for(let n of e)for(let e of n.typegens??[]){let r=c.get(e.id);if(r)throw new t(`typegen`,e.id,[r,n.name]);c.set(e.id,n.name),l.push(e)}let u=/* @__PURE__ */ new Map,d=[];for(let n of e)for(let e of n.generators??[]){let r=u.get(e.name);if(r)throw new t(`generator`,e.name,[r,n.name]);u.set(e.name,n.name),d.push({source:n.name,spec:e})}return{commands:s,typegens:l,generators:d,register:async(t,n)=>{let r;if(n)r={generators:d,...n};else{let{findProjectRoot:e}=await import(`./project-root-BDRPMlb9.mjs`).then(e=>e.n),t=process.cwd();r={cwd:t,projectRoot:e(t),config:null,log:()=>{},generators:d}}for(let n of e)n.register&&await n.register(t,r)}}}var i=/* @__PURE__ */ e({mergeCliPlugins:()=>r});export{r as n,n as r,i as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.
|
|
2
|
+
* @forinda/kickjs-cli v8.8.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"./types-
|
|
11
|
+
import"./types-gy6PkRFW.mjs";export{r as mergeCliPlugins}from"./run-plugins-2DJy76gx.mjs";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-cli v8.8.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-BB3QxPj8.mjs";import{o as t,t as n}from"./config-F9g6CNDA.mjs";import{dirname as r,join as i,resolve as a,sep as o}from"node:path";import{existsSync as s,readFileSync as c,readdirSync as l,statSync as u,writeFileSync as d}from"node:fs";import{execFile as f,execFileSync as p,execSync as m,spawnSync as h}from"node:child_process";import{randomBytes as g}from"node:crypto";import{fileURLToPath as _}from"node:url";import{promisify as v}from"node:util";import{parseSync as y}from"oxc-parser";const b=r(_(import.meta.url)),x=[i(b,`..`,`templates`),i(b,`..`,`..`,`templates`)].find(e=>s(i(e,`base`)));function S(e){return e.split(`/`).map(e=>e.startsWith(`_dot_`)?`.${e.slice(5)}`:e).join(`/`)}function C(e,t={}){let n=t.templatesDir??x,r=/* @__PURE__ */ new Map,a=[],d=[],f={},p=[],m={};for(let t of e){let e=i(n,t);if(!s(e))throw Error(`Unknown scaffold layer "${t}" (${e})`);let h=i(e,`feature.json`);if(s(h)){let e=JSON.parse(c(h,`utf-8`));a.push(...e.dependencies??[]),d.push(...e.devDependencies??[]),Object.assign(f,e.builds),p.push(...e.integrations??[]),Object.assign(m,e.scripts)}let g=i(e,`files`);if(s(g))for(let e of l(g,{recursive:!0,encoding:`utf-8`}).toSorted()){let t=i(g,e);if(!u(t).isFile())continue;let n=c(t,`utf-8`),a=S(e.split(o).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(d)],builds:f,integrations:p,scripts:m}}function w(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`?ee(a.flatMap(e=>e.import?[e.import]:[])):a.filter(e=>e.slot===s&&e.code).map(e=>D(`${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 D(e,t){return e.split(`
|
|
14
|
+
`).map(e=>e&&t+e).join(`
|
|
15
|
+
`)}function ee(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 te=v(f),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 p(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 ne(e,t,n={}){let r=k(e,t);if(!r)throw Error(`Refusing to run '${e}': unsafe arguments`);p(r[0],r[1],{cwd:n.cwd,stdio:`inherit`,windowsHide:!0})}function re(e,t,n){let r=h(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function ie(e,t,n={}){let r=k(e,t);if(!r)return null;try{let{stdout:e}=await te(r[0],r[1],{encoding:`utf-8`,timeout:n.timeout??5e3,cwd:n.cwd,windowsHide:!0});return e.toString().trim()||null}catch{return null}}function ae(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 j(e,t){return Object.fromEntries(e.toSorted().map(e=>[e,ae(t,e)]))}function oe(e,t,n){return JSON.stringify({name:e,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:j(n.dependencies,t),devDependencies:j(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(`
|
|
17
|
+
`),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(`
|
|
18
|
+
`)}\n`}const ce={adapter:`adapters`,middleware:`middlewares`};function le(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=ce[e.slot],a=n(e.code),o=fe(a),s=y(r,i.source).program,c=t?ue(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?de(s,e.import.from,o):o;l&&u&&i.source.slice(l.value.start,l.value.end).includes(`${u}(`)?i.present.push(o??M(a)):(i.source=l?pe(i.source,l.value,a):me(i.source,c,t,a),e.import&&(i.source=he(i.source,e.import,r)),i.added.push(o??M(a)))}return i}function ue(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 de(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 fe(e){let t=e.split(`
|
|
19
|
+
`).find(e=>e.trim()&&!e.trim().startsWith(`//`));return/^\s*([A-Za-z_$][\w$.]*)\s*\(/.exec(t??``)?.[1]}const M=e=>e.split(`
|
|
20
|
+
`).find(e=>e.trim()&&!e.trim().startsWith(`//`))?.trim()??e,N=(e,t)=>/^[ \t]*/.exec(e.slice(e.lastIndexOf(`
|
|
21
|
+
`,t-1)+1))[0],P=(e,t)=>e.split(`
|
|
22
|
+
`).map(e=>e&&t+e).join(`
|
|
23
|
+
`);function pe(e,t,n){let r=t.elements.filter(Boolean),i=N(e,t.start);if(r.length===0){let r=P(`${n},`,`${i} `);return`${e.slice(0,t.start)}[\n${r}\n${i}]${e.slice(t.end)}`}let a=r.at(-1),o=N(e,a.start),s=e.slice(a.end,t.end-1).match(/^\s*,/),c=s?a.end+s[0].length:a.end,l=`\n${P(`${n},`,o)}`;return s?e.slice(0,c)+l+e.slice(c):`${e.slice(0,c)},${l.replace(/,$/,``)}${e.slice(c)}`}function me(e,t,n,r){let i=t.properties.at(-1),a=i?N(e,i.start):`${N(e,t.start)} `,o=`${a}${n}: [\n${P(`${r},`,`${a} `)}\n${a}],`;if(!i)return`${e.slice(0,t.start)}{\n${o}\n${N(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 he(e,t,n=`src/index.ts`){let r=y(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 ge={swagger:`feature-swagger`,devtools:`feature-devtools`,ws:`feature-ws`,queue:`feature-queue`,"queue:bullmq":`feature-queue`};function _e(e){let t=[...new Set(e.map(e=>ge[e]).filter(Boolean))];return t.length>0?C(t):void 0}function ve(e,t){return(t?[t]:[`src/index.ts`,`src/main.ts`]).find(t=>s(i(e,t)))}function ye(e,t){try{return p(`git`,[`status`,`--porcelain`,`--`,...t],{cwd:e,encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]}).split(`
|
|
24
|
+
`).filter(Boolean).map(e=>e.slice(3))}catch{return[]}}async function be(t,n){let r=[];for(let[a,o]of n){let n=i(t,a);if(!s(n)){await e(n,o),r.push(a);continue}let l=c(n,`utf-8`),u=new Set(l.split(`
|
|
25
|
+
`).map(e=>F(e)??e)),d=o.split(`
|
|
26
|
+
`).filter(e=>e.trim()&&!u.has(F(e)??e));if(d.length===0)continue;let f=l===``||l.endsWith(`
|
|
27
|
+
`)?``:`
|
|
28
|
+
`;await e(n,`${l}${f}${d.join(`
|
|
29
|
+
`)}\n`),r.push(a)}return r}const F=e=>/^\s*([A-Za-z_][\w]*)\s*=/.exec(e)?.[1];async function xe(t,n,r){let a=i(t,n),o=c(a,`utf-8`),s=le(o,r,I(t),n);return s.source!==o&&await e(a,s.source),s}function I(e){let t=Se(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 Se(e){try{return JSON.parse(c(i(e,`package.json`),`utf-8`))}catch{return{}}}function Ce(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(`
|
|
30
|
+
`)}const L={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`},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}},we=Object.entries(L).filter(([e,t])=>!t.core&&!t.deprecated&&!e.includes(`:`)&&![`pg`,`sqlite`,`mysql`,`zod`,`valibot`,`yup`].includes(e)).map(([e])=>e).join(`, `),R={express:[`express`],fastify:[`fastify`,`@fastify/middie`,`serve-static`],h3:[`h3@^2`,`serve-static`]},z={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 B(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 V(e=process.cwd()){return(await H(e)).runtime}async function H(e=process.cwd()){let n=(await t(e))?.runtime;return n===`express`||n===`fastify`||n===`h3`?{runtime:n,candidates:[n],ambiguous:!1,fromConfig:!0}:{...Te(e),fromConfig:!1}}const U=[[`express`,`express`],[`fastify`,`fastify`],[`h3`,`h3`]];function Te(e=process.cwd()){let t=W(`package.json`,e);if(!t)return{runtime:`express`,candidates:[],ambiguous:!1};let n={},r={};try{let e=JSON.parse(c(a(t,`package.json`),`utf-8`));n=e.dependencies??{},r=e.devDependencies??{}}catch{return{runtime:`express`,candidates:[],ambiguous:!1}}let i=U.filter(([e])=>e in n).map(([,e])=>e),o=U.filter(([e])=>e in r&&!(e in n)).map(([,e])=>e),s=[...i,...o];return i.length===1?{runtime:i[0],candidates:s,ambiguous:!1}:i.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 W(e,t=process.cwd()){let n=t;for(;;){if(s(a(n,e)))return n;let t=r(n);if(t===n)return null;n=t}}function Ee(){return W(`pnpm-lock.yaml`)?`pnpm`:W(`yarn.lock`)?`yarn`:W(`bun.lockb`)||W(`bun.lock`)?`bun`:W(`package-lock.json`)?`npm`:null}function De(){let e=process.cwd();for(;e;){let t=a(e,`package.json`);if(s(t))try{let e=JSON.parse(c(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 G(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=De();if(i)return{pm:i,source:`package.json`};let a=Ee();return a?{pm:a,source:`lockfile`}:{pm:`npm`,source:`default`}}async function Oe(e){let{pm:t}=await G(e);return t}function K(e=!1,t){let n=Object.entries(L),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,...R[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(`
|
|
31
|
+
Core packages (always installed by \`kick new\`):
|
|
32
|
+
`);for(let e of i)console.log(o(e));if(e){console.log(`
|
|
33
|
+
Optional packages (add as needed):
|
|
34
|
+
`);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(`
|
|
35
|
+
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 ke={"@swc/core":!0,esbuild:!0};function q(e,t,n){if(e===`pnpm`){let e=a(t,`pnpm-workspace.yaml`),r=s(e)?c(e,`utf-8`):``,i=se(r,n);return i===r?void 0:(d(e,i),e)}if(e!==`npm`&&e!==`bun`)return;let r=a(t,`package.json`);if(!s(r))return;let i=JSON.parse(c(r,`utf-8`)),o=!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,o=!0);i.allowScripts=e}else{let e=i.trustedDependencies??[];for(let[t,r]of Object.entries(n))r&&!e.includes(t)&&(e.push(t),o=!0);i.trustedDependencies=e}if(o)return d(r,`${JSON.stringify(i,null,2)}\n`),r}function Ae(e){if(e===`pnpm`)return W(`pnpm-workspace.yaml`)??process.cwd();for(let e=process.cwd();;e=r(e)){try{if(JSON.parse(c(a(e,`package.json`),`utf-8`)).workspaces)return e}catch{}if(r(e)===e)return process.cwd()}}function J(e){return Object.assign({},...e.map(e=>L[e]?.builds??{}))}function je(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=z[n];s.push(`upload (${n}): ${e.note}`),e.prod&&(t?i:r).add(e.prod),e.dev&&i.add(e.dev);continue}let e=L[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=R[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 Me(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=>{K(!!e.all,B(e.runtime)??await V())})}function Ne(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){K(!!t.all,B(t.runtime)??await V());return}let{pm:n,source:r}=await G(t.pm);console.log(`\n Using ${n} (resolved from ${r})`);let i=B(t.runtime),o=await H(process.cwd()),c=i??o.runtime;if(!i&&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 l=je(e,!!t.dev,c),{unknown:u,warnings:d,notices:f}=l,{prodDeps:p,devDeps:h}=l,g=process.cwd();if(t.entry&&!s(a(g,t.entry))){console.error(`\n --entry ${t.entry} does not exist.\n`),process.exitCode=1;return}let _=t.wire===!1?void 0:_e(e),v=_?ve(g,t.entry):void 0;if(_){p=[.../* @__PURE__ */ new Set([...p,..._.dependencies])],h=[...new Set([...h,..._.devDependencies].filter(e=>!p.includes(e)))];let e=ye(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.
|
|
36
|
+
`),p.length===0&&h.length===0))return;let y={...J(e),..._?.builds};if(Object.keys(y).length>0){let e=q(n,Ae(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{m(t,{stdio:`inherit`})}catch{b=!1,console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(h.length>0){let e=h,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{m(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.
|
|
37
|
+
`);else{for(let e of await be(g,_.files))console.log(` Updated ${e}`);let e=v?await xe(g,v,_.integrations):void 0;for(let t of e?.added??[])console.log(` Added ${t} to ${v}`);for(let t of e?.present??[])console.log(` ${t} is already in ${v}`);let t=I(g),n=e?e.manual:_.integrations.filter(e=>e.slot&&e.code).map(e=>({...e,code:t(e.code)}));n.length>0&&(console.log(`\n ${v?`Could not find bootstrap({ adapters: [...] }) in ${v}`:`No entry file found`} — add this yourself:
|
|
38
|
+
`),console.log(Ce(n).replace(/^/gm,` `)),console.log())}}b?console.log(` Done!
|
|
39
|
+
`):(console.log(` Finished with errors — the install above did not complete.
|
|
40
|
+
`),process.exitCode=1)})}const Y=r(_(import.meta.url)),X=JSON.parse(c([i(Y,`..`,`package.json`),i(Y,`..`,`..`,`package.json`)].find(s),`utf-8`)),Pe=[`@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`],Fe={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 Ie(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 Le(e){return e===`@forinda/kickjs-cli`?`^${X.version}`:`latest`}async function Re(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 Z(){let e=[...Pe.map(e=>({name:e,fallback:Le(e),cap:void 0})),...Object.entries(Fe).map(([e,t])=>({name:e,...t}))],t=Date.now()+2e4,n=await Re(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=Ie(await ie(`npm`,r?[`view`,a,`version`,`--json`]:[`view`,a,`version`],{timeout:i}));return[e,o?`^${o}`:n]});return Object.fromEntries(n)}function Q(e,t){let n=A(`npm`,[`view`,`${e}@${t}`,`version`],{timeout:2e4});return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}function $(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function ze(e,t){let n=e=>$(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 Be(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 Ve(t){let{name:n,directory:r,packageManager:a=`pnpm`,template:o=`rest`,defaultRepo:c=`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 h=t.versions??await Z(),_=Object.keys(h).filter(e=>h[e]===`latest`);if(_.length>0&&p(`WARNING: could not reach npm for ${_.join(`, `)} — pinned to 'latest'`),d!==`express`){if(Be(`@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=Q(r,`alpha`);e&&ze(e,$(h[r]))&&(h[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=>!s(i(x,`feature-${e}`)));v.length>0&&p(`WARNING: skipping unknown package(s): ${v.join(`, `)} — add them later with kick add`);let y=C([...Ue({template:o,runtime:d,schemaLib:u,packages:l}),...t.platformConfig===!1?[]:[`host-config`],...t.extraLayers??[]],{vars:{name:n,version:X.version},extra:[{slot:`repo`,code:c===`inmemory`?`repo: 'inmemory'`:`repo: { name: '${c.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}' }`},...t.spaClientDir?[He(t.spaClientDir)]:[]]});await e(i(f,`package.json`),oe(n,h,y));let b=w(y.files,{name:n,template:o,runtime:d,packageManager:a,templateLabel:{rest:`REST API`,minimal:`Minimal`,inertia:`Inertia (React)`}[o],sessionSecret:g(32).toString(`hex`),packages:[...y.dependencies,...y.devDependencies].filter(e=>e.startsWith(`@forinda/`)).map(e=>`- \`${e}\``).join(`
|
|
41
|
+
`)});for(let[t,n]of b)await e(i(f,t),n);let{generateAgentDocs:S}=await import(`./agent-docs-BsXKM5QH.mjs`).then(e=>e.t);await S({outDir:f,name:n,pm:a,template:o,only:`all`,force:!0});let T={...ke,...J(l),...y.builds};if(t.approveInstallScripts!==!1&&q(a,f,T),t.installDeps){console.log(`\n Installing dependencies with ${a}...\n`);try{m(`${a} install`,{cwd:f,stdio:`inherit`}),console.log(`
|
|
42
|
+
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${a} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-BBzX2LDz.mjs`).then(e=>e.n);await e({cwd:f,allowDuplicates:!0,silent:!0})}catch{}if(t.initGit)try{m(`git init`,{cwd:f,stdio:`pipe`}),m(`git branch -M main`,{cwd:f,stdio:`pipe`}),m(`git add -A`,{cwd:f,stdio:`pipe`}),m(`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(`
|
|
43
|
+
Project scaffolded successfully!`),console.log();let E=f!==process.cwd();p(`Next steps:`),E&&p(` cd ${n}`),t.installDeps||p(` ${a} install`);let D={rest:`kick g module user`,minimal:`# add your routes to src/index.ts`,inertia:`# pages: src/modules/pages + src/client/pages`};return p(` ${D[o]??D.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: ${we}`),p(``),{builds:T}}function He(e){return{import:{from:`@forinda/kickjs/spa`,names:[`SpaAdapter`]},slot:`adapter`,code:`// Serves the built frontend from this origin in production.
|
|
44
|
+
// Inert until the client build exists, so \`kick dev\` (where Vite
|
|
45
|
+
// serves the client and proxies /api here) is unaffected.
|
|
46
|
+
SpaAdapter({ clientDir: ${JSON.stringify(e)} })`}}function Ue(e){return[`base`,`template-${e.template}`,`runtime-${e.runtime}`,`schema-${e.schemaLib}`,...e.packages.filter(e=>s(i(x,`feature-${e}`))).map(e=>`feature-${e}`)]}export{q as a,V as c,re as d,w as f,z as i,Oe as l,Z as n,Ne as o,C as p,L as r,Me as s,Ve as t,ne as u};
|
|
47
|
+
//# sourceMappingURL=project-3LsfnPLE.mjs.map
|