@forinda/kickjs-cli 8.16.6 → 8.17.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-Co6gNCPR.mjs → agent-docs-BCgn3jTD.mjs} +2 -2
- package/dist/{agent-docs-DkNYs02k.mjs → agent-docs-BkoYR-bq.mjs} +3 -3
- package/dist/{agent-docs-DkNYs02k.mjs.map → agent-docs-BkoYR-bq.mjs.map} +1 -1
- package/dist/{build-BcA_6lV5.mjs → build-B0DNAPYL.mjs} +2 -2
- package/dist/{build-CThTYJkx.mjs → build-ByZMvCD0.mjs} +3 -3
- package/dist/{build-CThTYJkx.mjs.map → build-ByZMvCD0.mjs.map} +1 -1
- package/dist/{builtins-PK_3S0ny.mjs → builtins-BXCr0VP8.mjs} +2 -2
- package/dist/{builtins-Br7-KTWh.mjs → builtins-DAucpgiM.mjs} +32 -32
- package/dist/cli.mjs +2 -2
- package/dist/{config-L3YMlOva.mjs → config-BdvviVyU.mjs} +3 -3
- package/dist/{config-L3YMlOva.mjs.map → config-BdvviVyU.mjs.map} +1 -1
- package/dist/{config-CoLtqHMH.mjs → config-CjQ2Z43B.mjs} +2 -2
- package/dist/{doctor-Dh-A3EgY.mjs → doctor-C7UorUoN.mjs} +4 -4
- package/dist/{doctor-Dh-A3EgY.mjs.map → doctor-C7UorUoN.mjs.map} +1 -1
- package/dist/{fullstack-DwQ6HvNn.mjs → fullstack-BRCCVrIH.mjs} +4 -4
- package/dist/{fullstack-DwQ6HvNn.mjs.map → fullstack-BRCCVrIH.mjs.map} +1 -1
- package/dist/{fullstack-DzddVmAR.mjs → fullstack-DjyPVpMg.mjs} +3 -3
- package/dist/index.mjs +2 -2
- package/dist/{plugin-DqckXz1S.mjs → plugin-BLiFnUHv.mjs} +2 -2
- package/dist/{plugin-6OBUgRZi.mjs → plugin-DJ8l55--.mjs} +2 -2
- package/dist/{project-px_XYlx-.mjs → project-BktGFUEX.mjs} +4 -4
- package/dist/{project-BkwT5EMP.mjs → project-a6ySsOdn.mjs} +5 -5
- package/dist/{project-BkwT5EMP.mjs.map → project-a6ySsOdn.mjs.map} +1 -1
- package/dist/{project-root-g1n6Eew6.mjs → project-root-B440ayQv.mjs} +3 -3
- package/dist/{project-root-g1n6Eew6.mjs.map → project-root-B440ayQv.mjs.map} +1 -1
- package/dist/{project-root-MlzwegBa.mjs → project-root-DXjh5yeq.mjs} +2 -2
- package/dist/{rolldown-runtime-BCRSjbvn.mjs → rolldown-runtime-CP6a3t1y.mjs} +1 -1
- package/dist/{run-plugins-DvvSUlHD.mjs → run-plugins-DA8d-SRc.mjs} +33 -33
- package/dist/run-plugins-DA8d-SRc.mjs.map +1 -0
- package/dist/{typegen-BcJogb9b.mjs → typegen-BSqoTT4o.mjs} +5 -5
- package/dist/{typegen-BcJogb9b.mjs.map → typegen-BSqoTT4o.mjs.map} +1 -1
- package/dist/{typegen-Ctjwprpx.mjs → typegen-CV1AL1yd.mjs} +4 -4
- package/dist/{types-DU_QbQd8.mjs → types-Dhmt7m7y.mjs} +1 -1
- package/package.json +8 -8
- package/templates/base/files/README.md +1 -1
- package/dist/run-plugins-DvvSUlHD.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.
|
|
2
|
+
* @forinda/kickjs-cli v8.17.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,c as t,l as n}from"./agent-docs-
|
|
11
|
+
import{C as e,c as t,l as n}from"./agent-docs-BkoYR-bq.mjs";import{i as r,p as i}from"./config-BdvviVyU.mjs";import{C as a,S as o,b as s,c,i as l,n as u,v as d}from"./project-a6ySsOdn.mjs";import{join as f}from"node:path";import{execFileSync as p}from"node:child_process";const m=`https://kickjs.app/guide/fullstack-frontend.html`,h=[{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`}],g=`react-ts`;function _(e,t,n=g){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 v(i){let{name:h,directory:v,schemaLib:S=`zod`,runtime:C=`express`,packages:w=[],frontend:T=`kick`,viteTemplate:E=g}=i,D=[`pnpm`,`npm`,`yarn`,`bun`].includes(i.packageManager),O=D?i.packageManager:`pnpm`,k=v,A=e=>console.log(` ${e}`);i.packageManager!==void 0&&!D&&A(`Warning: unknown package manager '${String(i.packageManager)}' — falling back to pnpm.`),console.log(`\n Creating fullstack KickJS workspace: ${h}\n`),console.log(` Resolving package versions...`);let j=await l(),M=await u({name:`${h}-server`,directory:f(k,`server`),packageManager:O,template:`minimal`,schemaLib:S,runtime:C,packages:w,extraLayers:[`server-fullstack`],approveInstallScripts:!1,platformConfig:!1,initGit:!1,installDeps:!1,spaClientDir:`../web/dist`,versions:j});if(T===`vite`){console.log(`\n Handing web/ to create-vite (${E})...\n`);let[e,...t]=_(O,`web`,E);d(e,t,{cwd:k})}else await e(f(k,`web/package.json`),y(h,j));let N=o(O);await e(f(k,`package.json`),b(h,O,j[`@forinda/kickjs-cli`],N));let P=a(O,N);P&&await e(f(k,`.yarnrc.yml`),P),O===`pnpm`&&await e(f(k,`pnpm-workspace.yaml`),`packages:
|
|
12
12
|
- server
|
|
13
13
|
- web
|
|
14
|
-
`),c(O,k,M.builds);let F=[`fullstack-root`,...T===`vite`?[]:[`web-kick`]],I=t(n(F).files,{name:h,packageManager:O});for(let[t,n]of I)await e(f(k,t),n);await e(f(k,`README.md`),x(h,O,T)),i.deploy?.length&&await s({dir:k,targets:i.deploy,pm:O,force:!0});let{generateAgentDocs:L}=await import(`./agent-docs-
|
|
14
|
+
`),c(O,k,M.builds);let F=[`fullstack-root`,...T===`vite`?[]:[`web-kick`]],I=t(n(F).files,{name:h,packageManager:O});for(let[t,n]of I)await e(f(k,t),n);await e(f(k,`README.md`),x(h,O,T)),i.deploy?.length&&await s({dir:k,targets:i.deploy,pm:O,force:!0});let{generateAgentDocs:L}=await import(`./agent-docs-BkoYR-bq.mjs`).then(e=>e.t);if(await L({outDir:k,name:h,pm:O,template:`fullstack`,only:`both`,force:!0}),i.installDeps){console.log(`\n Installing workspace dependencies with ${O}...\n`);try{d(O,[`install`],{cwd:k})}catch{console.log(`\n Warning: ${O} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-BSqoTT4o.mjs`).then(e=>e.n);await e({cwd:f(k,`server`),allowDuplicates:!0,silent:!0})}catch{}if(i.initGit)try{p(`git`,[`init`],{cwd:k,stdio:`pipe`}),p(`git`,[`branch`,`-M`,`main`],{cwd:k,stdio:`pipe`}),p(`git`,[`add`,`-A`],{cwd:k,stdio:`pipe`}),p(`git`,[`commit`,`-m`,`chore: initial commit from kick new (fullstack)`],{cwd:k,stdio:`pipe`}),A(`Git repository initialized`)}catch{A(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
15
15
|
Fullstack workspace scaffolded!`),console.log(),A(`Next steps:`),A(` cd ${h}`),i.installDeps||A(` ${O} install`),O===`pnpm`?A(` pnpm dev # runs server (kick dev) + web (vite) together`):(A(` ${O} run dev:server # terminal 1`),A(` ${O} run dev:web # terminal 2`)),A(``),T===`vite`?(A(`web/ is create-vite output, unwired. To type it against the API:`),A(` ${m}`)):(A(`The web app calls the API through @forinda/kickjs-client —`),A(`edit server/src/modules/hello, run \`${r(O,`kick`)} typegen\` in server/, and`),A(`web/src/App.tsx's types follow.`)),A(``)}function y(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:{"@forinda/kickjs-vite":n(`@forinda/kickjs-vite`),"@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 b(e,t,n,r=o(t)){let i=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`,typecheck:`kick typecheck --cwd server && kick typecheck --cwd web --no-typegen`,test:`pnpm --filter ./server test`,format:`cd server && kick format`}:{start:`cd server && ${t} run start`,"dev:server":`cd server && ${t} run dev`,"dev:web":`cd web && ${t} run dev`,build:`cd server && kick typegen && cd .. && ${t} run build:server && ${t} run build:web`,"build:server":`cd server && ${t} run build`,"build:web":`cd web && ${t} run build`,typecheck:`kick typecheck --cwd server && kick typecheck --cwd web --no-typegen`,test:`cd server && ${t} run test`,format:`cd server && kick format`};return`${JSON.stringify({name:e,private:!0,version:`0.0.0`,type:`module`,...r?{packageManager:r}:{},scripts:i,devDependencies:{"@forinda/kickjs-cli":n},workspaces:[`server`,`web`]},null,2)}\n`}function x(e,t,n=`kick`){let a=`# ${e}
|
|
16
16
|
|
|
17
17
|
Fullstack KickJS workspace — typed end to end.
|
|
@@ -108,4 +108,4 @@ Four steps — typed client, \`/api\` dev proxy, route-map types, \`src/api.ts\`
|
|
|
108
108
|
|
|
109
109
|
${m}
|
|
110
110
|
`}export{g as DEFAULT_VITE_TEMPLATE,h as VITE_TEMPLATES,v as initFullstackProject};
|
|
111
|
-
//# sourceMappingURL=fullstack-
|
|
111
|
+
//# sourceMappingURL=fullstack-BRCCVrIH.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fullstack-DwQ6HvNn.mjs","names":["writeFileSafe","fillVars","renderLayers","execBin","runScript","yarnrc","packageManagerSpec","generateDeploy","resolveSiblingVersions","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","pmSpec","rootPackageJson","yarnConfig","approveInstallScripts","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 { execBin, runScript, type PackageManager } from '../config'\nimport { packageManagerSpec, yarnrc } from './templates/project-config'\nimport { generateDeploy, type DeployTarget } from './deploy'\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 /** Deploy targets to write files for, at the workspace root — `kick new --deploy`. */\n deploy?: DeployTarget[]\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 // The root owns the packageManager field and the deploy files.\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 const pmSpec = packageManagerSpec(packageManager)\n await writeFileSafe(\n join(dir, 'package.json'),\n rootPackageJson(name, packageManager, versions['@forinda/kickjs-cli'], pmSpec),\n )\n const yarnConfig = yarnrc(packageManager, pmSpec)\n if (yarnConfig) await writeFileSafe(join(dir, '.yarnrc.yml'), yarnConfig)\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, 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 // Deploy files only for the targets asked for — `kick g deploy` from the\n // root adds the rest later.\n if (options.deploy?.length) {\n await generateDeploy({ dir, targets: options.deploy, pm: packageManager, force: true })\n }\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: 'both',\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(\n `edit server/src/modules/hello, run \\`${execBin(packageManager, 'kick')} typegen\\` in server/, and`,\n )\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 '@forinda/kickjs-vite': dep('@forinda/kickjs-vite'),\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\nexport function rootPackageJson(\n name: string,\n pm: string,\n cliVersion: string,\n pmSpec = packageManagerSpec(pm),\n): 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 // 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 //\n // `--no-typegen` for web: it has no kick project to generate types\n // for (it reads the server's), and typegen there left a stray\n // web/.kickjs behind.\n typecheck: 'kick typecheck --cwd server && kick typecheck --cwd web --no-typegen',\n test: 'pnpm --filter ./server test',\n // The server's own `format` command (kick.config.ts).\n format: 'cd server && kick format',\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. A bare `kick`, not\n // `<pm> exec kick` (`bun exec` runs a shell string): the root depends\n // on the CLI, so scripts have it on PATH — see `typecheck` below.\n build: `cd server && kick typegen && cd .. && ${pm} run build:server && ${pm} run build:web`,\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 --no-typegen',\n test: `cd server && ${pm} run test`,\n // The server's own `format` command (kick.config.ts).\n format: 'cd server && kick format',\n }\n return `${JSON.stringify(\n {\n name,\n private: true,\n version: '0.0.0',\n type: 'module',\n ...(pmSpec ? { packageManager: pmSpec } : {}),\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\nFrom this root: \\`${runScript(pm as PackageManager, 'test')}\\` (the server's tests), \\`${runScript(pm as PackageManager, 'typecheck')}\\` (both packages),\n\\`${runScript(pm as PackageManager, 'format')}\\` and \\`${runScript(pm as PackageManager, 'build')}\\`. The \\`kick\\` CLI itself runs in \\`server/\\`, which holds\n\\`kick.config.ts\\`: \\`cd server && ${execBin(pm as PackageManager, 'kick')} typegen\\`.\n\n## Deploy\n\nDeploy files are added when you need them, from this folder:\n\n\\`\\`\\`bash\n${execBin(pm as PackageManager, 'kick')} g deploy docker # Dockerfile for the whole app\n${execBin(pm as PackageManager, 'kick')} g deploy netlify vercel # serverless: platform config, entry and build script\n\\`\\`\\`\n\nSee [Serverless](https://kickjs.app/guide/serverless).\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":";;;;;;;;;;gRA0BA,MAAaW,EAAsB,mDAQtBC,EAAiB,CAC5B,CAAE,MAAO,WAAY,MAAO,OAAQ,EACpC,CAAE,MAAO,oBAAqB,MAAO,kBAAmB,EACxD,CAAE,MAAO,SAAU,MAAO,KAAM,EAChC,CAAE,MAAO,YAAa,MAAO,QAAS,EACtC,CAAE,MAAO,WAAY,MAAO,OAAQ,EACpC,CAAE,MAAO,YAAa,MAAO,QAAS,EACtC,CAAE,MAAO,SAAU,MAAO,KAAM,EAChC,CAAE,MAAO,UAAW,MAAO,MAAO,EAClC,CAAE,MAAO,aAAc,MAAO,SAAU,CAC1C,EAEaC,EAAwB,WAWrC,SAAgBC,EACd,EACA,EACA,EAAmBD,EACT,CACV,IAAME,EAAQ,CAAC,aAAcC,EAAU,mBAAoB,gBAAgB,EAM3E,OAFIC,IAAO,QAAUA,IAAO,MAAc,CAACA,EAAI,SAAU,OAAQC,EAAK,GAAGH,CAAK,EAC1EE,IAAO,MAAc,CAACA,EAAI,SAAU,cAAeC,EAAK,KAAM,GAAGH,CAAK,EACnE,CAACE,EAAI,SAAU,cAAeC,EAAK,GAAGH,CAAK,CACpD,CAyBA,eAAsBI,EAAqB,EAA8C,CACvF,GAAM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AE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+DtC,GAAIa,IAAa,OAAQ,OAAOsB,EAKhC,IAAMC,EAAWD,EAAO,QAAQ,kBAAkB,EAClD,MAAO,GAAGA,EACP,MAAM,EAAGC,CAAQ,CAAC,CAClB,QACC,mEACA,mEACF,CAAC,CACA,QAAQ,yBAA0B,EAAE,EAAE;;;;;EAKzC1C,EAAoB;CAEtB"}
|
|
1
|
+
{"version":3,"file":"fullstack-BRCCVrIH.mjs","names":["writeFileSafe","fillVars","renderLayers","execBin","runScript","yarnrc","packageManagerSpec","generateDeploy","resolveSiblingVersions","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","pmSpec","rootPackageJson","yarnConfig","approveInstallScripts","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 { execBin, runScript, type PackageManager } from '../config'\nimport { packageManagerSpec, yarnrc } from './templates/project-config'\nimport { generateDeploy, type DeployTarget } from './deploy'\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 /** Deploy targets to write files for, at the workspace root — `kick new --deploy`. */\n deploy?: DeployTarget[]\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 // The root owns the packageManager field and the deploy files.\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 const pmSpec = packageManagerSpec(packageManager)\n await writeFileSafe(\n join(dir, 'package.json'),\n rootPackageJson(name, packageManager, versions['@forinda/kickjs-cli'], pmSpec),\n )\n const yarnConfig = yarnrc(packageManager, pmSpec)\n if (yarnConfig) await writeFileSafe(join(dir, '.yarnrc.yml'), yarnConfig)\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, 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 // Deploy files only for the targets asked for — `kick g deploy` from the\n // root adds the rest later.\n if (options.deploy?.length) {\n await generateDeploy({ dir, targets: options.deploy, pm: packageManager, force: true })\n }\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: 'both',\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(\n `edit server/src/modules/hello, run \\`${execBin(packageManager, 'kick')} typegen\\` in server/, and`,\n )\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 '@forinda/kickjs-vite': dep('@forinda/kickjs-vite'),\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\nexport function rootPackageJson(\n name: string,\n pm: string,\n cliVersion: string,\n pmSpec = packageManagerSpec(pm),\n): 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 // 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 //\n // `--no-typegen` for web: it has no kick project to generate types\n // for (it reads the server's), and typegen there left a stray\n // web/.kickjs behind.\n typecheck: 'kick typecheck --cwd server && kick typecheck --cwd web --no-typegen',\n test: 'pnpm --filter ./server test',\n // The server's own `format` command (kick.config.ts).\n format: 'cd server && kick format',\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. A bare `kick`, not\n // `<pm> exec kick` (`bun exec` runs a shell string): the root depends\n // on the CLI, so scripts have it on PATH — see `typecheck` below.\n build: `cd server && kick typegen && cd .. && ${pm} run build:server && ${pm} run build:web`,\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 --no-typegen',\n test: `cd server && ${pm} run test`,\n // The server's own `format` command (kick.config.ts).\n format: 'cd server && kick format',\n }\n return `${JSON.stringify(\n {\n name,\n private: true,\n version: '0.0.0',\n type: 'module',\n ...(pmSpec ? { packageManager: pmSpec } : {}),\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\nFrom this root: \\`${runScript(pm as PackageManager, 'test')}\\` (the server's tests), \\`${runScript(pm as PackageManager, 'typecheck')}\\` (both packages),\n\\`${runScript(pm as PackageManager, 'format')}\\` and \\`${runScript(pm as PackageManager, 'build')}\\`. The \\`kick\\` CLI itself runs in \\`server/\\`, which holds\n\\`kick.config.ts\\`: \\`cd server && ${execBin(pm as PackageManager, 'kick')} typegen\\`.\n\n## Deploy\n\nDeploy files are added when you need them, from this folder:\n\n\\`\\`\\`bash\n${execBin(pm as PackageManager, 'kick')} g deploy docker # Dockerfile for the whole app\n${execBin(pm as PackageManager, 'kick')} g deploy netlify vercel # serverless: platform config, entry and build script\n\\`\\`\\`\n\nSee [Serverless](https://kickjs.app/guide/serverless).\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":";;;;;;;;;;gRA0BA,MAAaW,EAAsB,mDAQtBC,EAAiB,CAC5B,CAAE,MAAO,WAAY,MAAO,OAAQ,EACpC,CAAE,MAAO,oBAAqB,MAAO,kBAAmB,EACxD,CAAE,MAAO,SAAU,MAAO,KAAM,EAChC,CAAE,MAAO,YAAa,MAAO,QAAS,EACtC,CAAE,MAAO,WAAY,MAAO,OAAQ,EACpC,CAAE,MAAO,YAAa,MAAO,QAAS,EACtC,CAAE,MAAO,SAAU,MAAO,KAAM,EAChC,CAAE,MAAO,UAAW,MAAO,MAAO,EAClC,CAAE,MAAO,aAAc,MAAO,SAAU,CAC1C,EAEaC,EAAwB,WAWrC,SAAgBC,EACd,EACA,EACA,EAAmBD,EACT,CACV,IAAME,EAAQ,CAAC,aAAcC,EAAU,mBAAoB,gBAAgB,EAM3E,OAFIC,IAAO,QAAUA,IAAO,MAAc,CAACA,EAAI,SAA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EAAsB,WAAW,EAAE;IAClIb,EAAUa,EAAsB,QAAQ,EAAE,WAAWb,EAAUa,EAAsB,OAAO,EAAE;qCAC7Dd,EAAQc,EAAsB,MAAM,EAAE;;;;;;;EAOzEd,EAAQc,EAAsB,MAAM,EAAE;EACtCd,EAAQc,EAAsB,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+DtC,GAAIa,IAAa,OAAQ,OAAOsB,EAKhC,IAAMC,EAAWD,EAAO,QAAQ,kBAAkB,EAClD,MAAO,GAAGA,EACP,MAAM,EAAGC,CAAQ,CAAC,CAClB,QACC,mEACA,mEACF,CAAC,CACA,QAAQ,yBAA0B,EAAE,EAAE;;;;;EAKzC1C,EAAoB;CAEtB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.
|
|
2
|
+
* @forinda/kickjs-cli v8.17.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{S as e,b as t,c as n,i as r,n as i,v as a,x as o}from"./project-
|
|
11
|
+
import{S as e,b as t,c as n,i as r,n as i,v as a,x as o}from"./project-BktGFUEX.mjs";import{f as s,r as c}from"./config-CjQ2Z43B.mjs";import{C as l,b as u,y as d}from"./agent-docs-BCgn3jTD.mjs";import{join as f}from"node:path";import{execFileSync as p}from"node:child_process";const m=`https://kickjs.app/guide/fullstack-frontend.html`,h=[{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`}],g=`react-ts`;function _(e,t,n=g){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 v(s){let{name:h,directory:v,schemaLib:S=`zod`,runtime:C=`express`,packages:w=[],frontend:T=`kick`,viteTemplate:E=g}=s,D=[`pnpm`,`npm`,`yarn`,`bun`].includes(s.packageManager),O=D?s.packageManager:`pnpm`,k=v,A=e=>console.log(` ${e}`);s.packageManager!==void 0&&!D&&A(`Warning: unknown package manager '${String(s.packageManager)}' — falling back to pnpm.`),console.log(`\n Creating fullstack KickJS workspace: ${h}\n`),console.log(` Resolving package versions...`);let j=await r(),M=await i({name:`${h}-server`,directory:f(k,`server`),packageManager:O,template:`minimal`,schemaLib:S,runtime:C,packages:w,extraLayers:[`server-fullstack`],approveInstallScripts:!1,platformConfig:!1,initGit:!1,installDeps:!1,spaClientDir:`../web/dist`,versions:j});if(T===`vite`){console.log(`\n Handing web/ to create-vite (${E})...\n`);let[t,...n]=_(O,`web`,E);e(t,n,{cwd:k})}else await l(f(k,`web/package.json`),y(h,j));let N=t(O);await l(f(k,`package.json`),b(h,O,j[`@forinda/kickjs-cli`],N));let P=o(O,N);P&&await l(f(k,`.yarnrc.yml`),P),O===`pnpm`&&await l(f(k,`pnpm-workspace.yaml`),`packages:
|
|
12
12
|
- server
|
|
13
13
|
- web
|
|
14
|
-
`),n(O,k,M.builds);let F=[`fullstack-root`,...T===`vite`?[]:[`web-kick`]],I=d(u(F).files,{name:h,packageManager:O});for(let[e,t]of I)await l(f(k,e),t);await l(f(k,`README.md`),x(h,O,T)),s.deploy?.length&&await a({dir:k,targets:s.deploy,pm:O,force:!0});let{generateAgentDocs:L}=await import(`./agent-docs-
|
|
14
|
+
`),n(O,k,M.builds);let F=[`fullstack-root`,...T===`vite`?[]:[`web-kick`]],I=d(u(F).files,{name:h,packageManager:O});for(let[e,t]of I)await l(f(k,e),t);await l(f(k,`README.md`),x(h,O,T)),s.deploy?.length&&await a({dir:k,targets:s.deploy,pm:O,force:!0});let{generateAgentDocs:L}=await import(`./agent-docs-BCgn3jTD.mjs`).then(e=>e.t);if(await L({outDir:k,name:h,pm:O,template:`fullstack`,only:`both`,force:!0}),s.installDeps){console.log(`\n Installing workspace dependencies with ${O}...\n`);try{e(O,[`install`],{cwd:k})}catch{console.log(`\n Warning: ${O} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-CV1AL1yd.mjs`).then(e=>e.n);await e({cwd:f(k,`server`),allowDuplicates:!0,silent:!0})}catch{}if(s.initGit)try{p(`git`,[`init`],{cwd:k,stdio:`pipe`}),p(`git`,[`branch`,`-M`,`main`],{cwd:k,stdio:`pipe`}),p(`git`,[`add`,`-A`],{cwd:k,stdio:`pipe`}),p(`git`,[`commit`,`-m`,`chore: initial commit from kick new (fullstack)`],{cwd:k,stdio:`pipe`}),A(`Git repository initialized`)}catch{A(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
15
15
|
Fullstack workspace scaffolded!`),console.log(),A(`Next steps:`),A(` cd ${h}`),s.installDeps||A(` ${O} install`),O===`pnpm`?A(` pnpm dev # runs server (kick dev) + web (vite) together`):(A(` ${O} run dev:server # terminal 1`),A(` ${O} run dev:web # terminal 2`)),A(``),T===`vite`?(A(`web/ is create-vite output, unwired. To type it against the API:`),A(` ${m}`)):(A(`The web app calls the API through @forinda/kickjs-client —`),A(`edit server/src/modules/hello, run \`${c(O,`kick`)} typegen\` in server/, and`),A(`web/src/App.tsx's types follow.`)),A(``)}function y(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:{"@forinda/kickjs-vite":n(`@forinda/kickjs-vite`),"@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 b(e,n,r,i=t(n)){let a=n===`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`,typecheck:`kick typecheck --cwd server && kick typecheck --cwd web --no-typegen`,test:`pnpm --filter ./server test`,format:`cd server && kick format`}:{start:`cd server && ${n} run start`,"dev:server":`cd server && ${n} run dev`,"dev:web":`cd web && ${n} run dev`,build:`cd server && kick typegen && cd .. && ${n} run build:server && ${n} run build:web`,"build:server":`cd server && ${n} run build`,"build:web":`cd web && ${n} run build`,typecheck:`kick typecheck --cwd server && kick typecheck --cwd web --no-typegen`,test:`cd server && ${n} run test`,format:`cd server && kick format`};return`${JSON.stringify({name:e,private:!0,version:`0.0.0`,type:`module`,...i?{packageManager:i}:{},scripts:a,devDependencies:{"@forinda/kickjs-cli":r},workspaces:[`server`,`web`]},null,2)}\n`}function x(e,t,n=`kick`){let r=`# ${e}
|
|
16
16
|
|
|
17
17
|
Fullstack KickJS workspace — typed end to end.
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.
|
|
2
|
+
* @forinda/kickjs-cli v8.17.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-C7UorUoN.mjs";import{r as v,s as y}from"./config-BdvviVyU.mjs";import{n as b}from"./project-a6ySsOdn.mjs";import{t as x}from"./project-root-B440ayQv.mjs";import{n as S,t as C}from"./types-Dhmt7m7y.mjs";export{C as KickPluginConflictError,a as TYPEGEN_OWNER_KEY,p as buildGeneratorContext,u as createTypegenDevWatcher,S as defineCliPlugin,v 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,b as initProject,y as loadKickConfig,l as pluralize,n as toCamelCase,r as toKebabCase,t as toPascalCase};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.
|
|
2
|
+
* @forinda/kickjs-cli v8.17.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-Dhmt7m7y.mjs";export{r as mergeCliPlugins}from"./run-plugins-DA8d-SRc.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.
|
|
2
|
+
* @forinda/kickjs-cli v8.17.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-CP6a3t1y.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-DXjh5yeq.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.17.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{f as e,o as t,r as n}from"./config-
|
|
11
|
+
import{f as e,o as t,r as n}from"./config-CjQ2Z43B.mjs";import{C as r,a as i,b as a,o,r as s,s as c,v as l,y as u}from"./agent-docs-BCgn3jTD.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 ee=w(b),D=/[&|<>^"'`(){}[\];!%\r\n\\]/;function O(e,t,n=process.platform){if(n!==`win32`)return[e,t];if(D.test(e)||t.some(e=>D.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 k(e,t,n={}){let r=O(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 A(e,t,n={}){let r=O(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 te(e,t,n={}){let r=O(e,t);if(!r)return null;try{let{stdout:e}=await ee(r[0],r[1],{encoding:`utf-8`,timeout:n.timeout??5e3,cwd:n.cwd,windowsHide:!0});return e.toString().trim()||null}catch{return null}}function ne(e,t){let n=e[t];if(!n)throw Error(`generatePackageJson: missing resolved version for ${t}. Add it to SIBLING_PACKAGES or THIRD_PARTY_PACKAGES in generators/project.ts.`);return n}function N(e,t){return Object.fromEntries(e.toSorted().map(e=>[e,ne(t,e)]))}function P(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 re(e){let t=e?.match(/@(\d+)\.(\d+)\./);return t?[Number(t[1]),Number(t[2])]:void 0}function ie(e,t){let n=re(t)?.[0];return e===`yarn`&&n!==void 0&&n>=2?`nodeLinker: node-modules
|
|
12
12
|
`:void 0}function ae(e,t,n,r){return JSON.stringify({name:e,...r?{packageManager:r}:{},version:`0.0.0`,type:`module`,scripts:{dev:`kick dev`,build:`kick build`,start:`kick start`,test:`vitest run --passWithNoTests`,...n.scripts},dependencies:N(n.dependencies,t),devDependencies:N(n.devDependencies,t)},null,2)}function oe(e,t){let n=Object.entries(t);if(n.length===0)return e;let r=e===``?[]:e.replace(/\n$/,``).split(`
|
|
13
13
|
`),i=e=>e.trim().replace(/^['"]|['"]$/g,``),a=e=>/^[\w-]+$/.test(e)?e:`'${e}'`,o=(e,t)=>{let n=r.findIndex(t=>t.replace(/\s+$/,``)===`${e}:`);if(n===-1){if(!t)return;r.length>0&&r[r.length-1]!==``&&r.push(``),r.push(`${e}:`),n=r.length-1}let i=n+1;for(let e=n+1;e<r.length&&/^(\s|$)/.test(r[e]);e++)r[e].trim()!==``&&(i=e+1);return{start:n,end:i}},s=[];for(let[e,t]of n){let{start:n,end:c}=o(`allowBuilds`,!0),l=r.slice(n+1,c).findIndex(t=>i(t.split(`:`)[0])===e),u=l===-1?void 0:/:\s*(true|false)\s*$/.exec(r[n+1+l]);if(u){s.push([e,u[1]===`true`]);continue}let d=` ${a(e)}: ${t}`;l===-1?r.splice(c,0,d):r[n+1+l]=d,s.push([e,t])}let c=[`onlyBuiltDependencies`,`ignoredBuiltDependencies`];for(let[e,t]of s){if(c.some(t=>{let n=o(t,!1);return n!==void 0&&r.slice(n.start+1,n.end).some(t=>i(t.replace(/^\s*-/,``))===e)}))continue;let{end:n}=o(t?c[0]:c[1],!0);r.splice(n,0,` - ${a(e)}`)}return`${r.join(`
|
|
14
14
|
`)}\n`}const F=`node:22-slim`,se={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:F,setup:`RUN corepack enable`},npm:{lockfile:`package-lock.json`,installFiles:[],install:`npm ci`,installProd:`npm ci --omit=dev`,run:e=>`npm run ${e}`,image:F},yarn:{lockfile:`yarn.lock`,installFiles:[],install:`yarn install --frozen-lockfile`,installProd:`yarn install --production --frozen-lockfile`,run:e=>`yarn run ${e}`,image:F,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`}},I={lockfile:`yarn.lock`,installFiles:[`.yarnrc.yml`],install:`yarn install --immutable`,installProd:`yarn workspaces focus --all --production`,run:e=>`yarn run ${e}`,image:F,setup:`RUN corepack enable`},ce={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 le(e,t,n,r){let[i=0,a=0]=re(r)??[],o=t===`yarn`&&i>=2?i>=4?I:{...I,installProd:I.install}:t===`bun`&&r&&(i<1||i===1&&a<2)?{...se.bun,lockfile:`bun.lockb`}:se[t],s=`${o.setup?`\n${o.setup}`:``}
|
|
@@ -131,8 +131,8 @@ CMD ["node", "dist/index.js"]
|
|
|
131
131
|
`),console.log(g.replace(/^/gm,` `)),console.log());let S=[...new Set(e.map(e=>De[e]).filter(Boolean))];for(let e of await s(_,S,n))console.log(` Created ${e}`)}}T?console.log(` Done!
|
|
132
132
|
`):(console.log(` Finished with errors — the install above did not complete.
|
|
133
133
|
`),process.exitCode=1)})}const tt=m(y(import.meta.url));function nt(t){return{kick:n(t,`kick`),runDev:e(t,`dev`),runBuild:e(t,`build`),runStart:e(t,`start`),runTest:e(t,`test`)}}const Q=JSON.parse(f([h(tt,`..`,`package.json`),h(tt,`..`,`..`,`package.json`)].find(d),`utf-8`)),rt=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-schema`,`@forinda/kickjs-vite`,`@forinda/kickjs-swagger`,`@forinda/kickjs-ws`,`@forinda/kickjs-queue`,`@forinda/kickjs-devtools`,`@forinda/kickjs-testing`,`@forinda/kickjs-client`,`@forinda/kickjs-inertia`,`@forinda/kickjs-storage`,`@forinda/kickjs-view`],it={react:{fallback:`^19.0.0`},"react-dom":{fallback:`^19.0.0`},"@types/react":{fallback:`^19.0.0`},"@types/react-dom":{fallback:`^19.0.0`},"@vitejs/plugin-react":{fallback:`^5.0.0`},"@inertiajs/react":{fallback:`^3.9.0`,cap:`^3`},"@inertiajs/core":{fallback:`^3.9.0`,cap:`^3`},"@types/node":{fallback:`^25.0.0`},"@types/supertest":{fallback:`^7.2.1`},supertest:{fallback:`^7.2.2`},vitest:{fallback:`^4.1.2`},"@swc/core":{fallback:`^1.15.21`},"unplugin-swc":{fallback:`^1.5.9`},oxfmt:{fallback:`^0.65.0`},oxlint:{fallback:`^1.80.0`},dotenv:{fallback:`^17.3.1`,cap:`^17`},"reflect-metadata":{fallback:`^0.2.2`},vite:{fallback:`^8.0.3`,cap:`^8`},typescript:{fallback:`^7.0.2`,cap:`^7`},"@typescript/typescript6":{fallback:`^6.0.2`,cap:`^6`},express:{fallback:`^5.1.0`,cap:`^5`},"@types/express":{fallback:`^5.0.6`,cap:`^5`},fastify:{fallback:`^5.0.0`,cap:`^5`},"@fastify/middie":{fallback:`^9.0.0`,cap:`^9`},h3:{fallback:`^2.0.2`,cap:`^2`},"serve-static":{fallback:`^2.2.0`,cap:`^2`},zod:{fallback:`^4.3.6`,cap:`^4`},valibot:{fallback:`^1.4.1`,cap:`^1`},"@valibot/to-json-schema":{fallback:`^1.8.0`,cap:`^1`},yup:{fallback:`^1.7.1`,cap:`^1`},ws:{fallback:`^8.18.0`,cap:`^8`},bullmq:{fallback:`^5.0.0`,cap:`^5`},ioredis:{fallback:`^5.0.0`,cap:`^5`}};function $(e){if(!e)return null;let t=e.trim();if(/^\d+\.\d+\.\d+/.test(t))return t.split(/\s/)[0];try{let e=JSON.parse(t),n=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`);return n.length>0?n[n.length-1]:null}catch{return null}}function at(e){return e===`@forinda/kickjs-cli`?`^${Q.version}`:`latest`}async function ot(e,t,n){let r=Array.from({length:e.length}),i=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let t=i++;r[t]=await n(e[t])}});return await Promise.all(a),r}async function st(){let e=[...rt.map(e=>({name:e,fallback:at(e),cap:void 0})),...Object.entries(it).map(([e,t])=>({name:e,...t}))],t=Date.now()+2e4,n=await ot(e,8,async({name:e,fallback:n,cap:r})=>{let i=t-Date.now();if(i<=0)return[e,n];let a=r?`${e}@${r}`:e,o=$(await te(`npm`,r?[`view`,a,`version`,`--json`]:[`view`,a,`version`],{timeout:i}));return[e,o?`^${o}`:n]});return Object.fromEntries(n)}function ct(e,t){let n=k(`npm`,[`view`,`${e}@${t}`,`version`],{timeout:2e4});return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}function lt(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function ut(e,t){let n=e=>lt(e).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10)||0),[r=0,i=0,a=0]=n(e),[o=0,s=0,c=0]=n(t);return r===o?i===s?a>=c:i>s:r>o}const dt=Q.version;async function ft(){let e=$(await te(`npm`,[`view`,`@forinda/kickjs-cli`,`version`],{timeout:5e3}));return e&&pt(dt,e)?e:null}function pt(e,t){return e.split(`-`)[0]===t.split(`-`)[0]?e.includes(`-`)&&!t.includes(`-`):!ut(e,t)}function mt(e,t,n){let r=k(`npm`,[`view`,`${e}@${t}`,`exports`,`--json`],{timeout:2e4});if(!r)return!1;try{let e=JSON.parse(r);return Object.prototype.hasOwnProperty.call(e,n)}catch{return!1}}async function ht(t){let{name:i,directory:o,packageManager:s=`pnpm`,template:c=`rest`,defaultRepo:f=`inmemory`,packages:p=[],schemaLib:m=`zod`,runtime:g=`express`}=t,_=o,v=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${i}\n`),t.versions||v(`Resolving package versions...`);let y=t.versions??await st(),b=Object.keys(y).filter(e=>y[e]===`latest`);if(b.length>0&&v(`WARNING: could not reach npm for ${b.join(`, `)} — pinned to 'latest'`),g!==`express`){if(mt(`@forinda/kickjs`,`latest`,`./${g}`))v(`Using @forinda/kickjs@latest (stable ships the ${g} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=ct(r,`alpha`);e&&ut(e,lt(y[r]))&&(y[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}v(n?`Using the alpha channel for the ${g} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${g} runtime subpath may be missing. After install, run: ${s} add @forinda/kickjs@alpha`)}}let x=p.filter(e=>!d(h(l,`feature-${e}`)));x.length>0&&v(`WARNING: skipping unknown package(s): ${x.join(`, `)} — add them later with kick add`);let C=a([...vt({template:c,runtime:g,schemaLib:m,packages:p}),...t.extraLayers??[]],{vars:{name:i,version:Q.version},extra:[{slot:`repo`,code:f===`inmemory`?`repo: 'inmemory'`:`repo: { name: '${f.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}' }`},...t.spaClientDir?[_t(t.spaClientDir)]:[]]}),w=t.platformConfig===!1?void 0:P(s);await r(h(_,`package.json`),ae(i,y,C,w));let E=ie(s,w);E&&await r(h(_,`.yarnrc.yml`),E);let ee=u(C.files,{name:i,template:c,runtime:g,packageManager:s,...nt(s),templateLabel:{rest:`REST API`,minimal:`Minimal`,inertia:`Inertia (React)`}[c],sessionSecret:T(32).toString(`hex`),packages:[...C.dependencies,...C.devDependencies].filter(e=>e.startsWith(`@forinda/`)).map(e=>`- \`${e}\``).join(`
|
|
134
|
-
`)});for(let[e,t]of ee)await r(h(_,e),t);t.deploy?.length&&t.platformConfig!==!1&&await z({dir:_,targets:t.deploy,pm:s,force:!0});let{generateAgentDocs:D}=await import(`./agent-docs-
|
|
135
|
-
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${s} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-
|
|
134
|
+
`)});for(let[e,t]of ee)await r(h(_,e),t);t.deploy?.length&&t.platformConfig!==!1&&await z({dir:_,targets:t.deploy,pm:s,force:!0});let{generateAgentDocs:D}=await import(`./agent-docs-BCgn3jTD.mjs`).then(e=>e.t);await D({outDir:_,name:i,pm:s,template:c,only:`both`,force:!0});let O={...Ye,...Ze(p),...C.builds};if(t.approveInstallScripts!==!1&&Z(s,_,O),t.installDeps){console.log(`\n Installing dependencies with ${s}...\n`);try{S(`${s} install`,{cwd:_,stdio:`inherit`}),console.log(`
|
|
135
|
+
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${s} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-CV1AL1yd.mjs`).then(e=>e.n);await e({cwd:_,allowDuplicates:!0,silent:!0})}catch{}if(t.initGit)try{S(`git init`,{cwd:_,stdio:`pipe`}),S(`git branch -M main`,{cwd:_,stdio:`pipe`}),S(`git add -A`,{cwd:_,stdio:`pipe`}),S(`git commit -m "chore: initial commit from kick new"`,{cwd:_,stdio:`pipe`}),v(`Git repository initialized`)}catch{v(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
136
136
|
Project scaffolded successfully!`),console.log();let k=_!==process.cwd();v(`Next steps:`),k&&v(` cd ${i}`),t.installDeps||v(` ${s} install`);let A=n(s,`kick`),j={rest:`${A} g module user`,minimal:`# add your routes to src/index.ts`,inertia:`# pages: src/modules/pages + src/client/pages`};v(` ${j[c]??j.rest}`),v(` ${e(s,`dev`)}`);let M=e=>{let t=Math.max(...e.map(([e])=>e.length))+2;for(let[n,r]of e)v(` ${n.padEnd(t)}${r}`)};return v(``),v(`Commands:`),M([[e(s,`dev`),`Start dev server with Vite HMR`],[e(s,`build`),`Production build via Vite`],[e(s,`start`),`Run production build`]]),v(``),v(`Generators:`),M([[`${A} g module <name>`,`REST module (controller, service, DTOs, repository)`],[`${A} g scaffold <n> <f..>`,`CRUD module from field definitions`],[`${A} g controller <name>`,`Standalone controller`],[`${A} g service <name>`,`@Service() class`],[`${A} g middleware <name>`,`Global connect-style middleware`],[`${A} g guard <name>`,`Route guard (auth, roles, etc.)`],[`${A} g adapter <name>`,`AppAdapter with lifecycle hooks`],[`${A} g dto <name>`,`DTO schema (Zod / Valibot / Yup)`],[`${A} g config`,`Generate kick.config.ts`]]),v(``),v(`Add packages:`),M([[`${A} add <pkg>`,`Install a KickJS package + peers`],[`${A} add --list`,`Show all available packages`]]),v(``),v(`Available: ${Ue}`),v(``),{builds:O}}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.
|
|
137
137
|
// Inert until the client build exists, so \`kick dev\` (where Vite
|
|
138
138
|
// serves the client and proxies /api here) is unaffected.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.
|
|
2
|
+
* @forinda/kickjs-cli v8.17.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{C as e,a as t,c as n,l as r,o as i,r as a,s as o,u as s}from"./agent-docs-
|
|
11
|
+
import{C as e,a as t,c as n,l as r,o as i,r as a,s as o,u as s}from"./agent-docs-BkoYR-bq.mjs";import{i as c,p as l,s as u}from"./config-BdvviVyU.mjs";import{dirname as d,join as f,posix as p,relative as m,resolve as h}from"node:path";import{existsSync as g,readFileSync as _,writeFileSync as v}from"node:fs";import{execFile as y,execFileSync as b,execSync as x,spawnSync as S}from"node:child_process";import{randomBytes as C}from"node:crypto";import{fileURLToPath as w}from"node:url";import{promisify as T}from"node:util";import{parseSync as E}from"oxc-parser";function D(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 O(e,t){return Object.fromEntries(e.toSorted().map(e=>[e,D(t,e)]))}function k(e){try{let t=b(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 A(e){let t=e?.match(/@(\d+)\.(\d+)\./);return t?[Number(t[1]),Number(t[2])]:void 0}function ee(e,t){let n=A(t)?.[0];return e===`yarn`&&n!==void 0&&n>=2?`nodeLinker: node-modules
|
|
12
12
|
`:void 0}function te(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:O(n.dependencies,t),devDependencies:O(n.devDependencies,t)},null,2)}function j(e,t){let n=Object.entries(t);if(n.length===0)return e;let r=e===``?[]:e.replace(/\n$/,``).split(`
|
|
13
13
|
`),i=e=>e.trim().replace(/^['"]|['"]$/g,``),a=e=>/^[\w-]+$/.test(e)?e:`'${e}'`,o=(e,t)=>{let n=r.findIndex(t=>t.replace(/\s+$/,``)===`${e}:`);if(n===-1){if(!t)return;r.length>0&&r[r.length-1]!==``&&r.push(``),r.push(`${e}:`),n=r.length-1}let i=n+1;for(let e=n+1;e<r.length&&/^(\s|$)/.test(r[e]);e++)r[e].trim()!==``&&(i=e+1);return{start:n,end:i}},s=[];for(let[e,t]of n){let{start:n,end:c}=o(`allowBuilds`,!0),l=r.slice(n+1,c).findIndex(t=>i(t.split(`:`)[0])===e),u=l===-1?void 0:/:\s*(true|false)\s*$/.exec(r[n+1+l]);if(u){s.push([e,u[1]===`true`]);continue}let d=` ${a(e)}: ${t}`;l===-1?r.splice(c,0,d):r[n+1+l]=d,s.push([e,t])}let c=[`onlyBuiltDependencies`,`ignoredBuiltDependencies`];for(let[e,t]of s){if(c.some(t=>{let n=o(t,!1);return n!==void 0&&r.slice(n.start+1,n.end).some(t=>i(t.replace(/^\s*-/,``))===e)}))continue;let{end:n}=o(t?c[0]:c[1],!0);r.splice(n,0,` - ${a(e)}`)}return`${r.join(`
|
|
14
14
|
`)}\n`}const M=`node:22-slim`,N={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:M,setup:`RUN corepack enable`},npm:{lockfile:`package-lock.json`,installFiles:[],install:`npm ci`,installProd:`npm ci --omit=dev`,run:e=>`npm run ${e}`,image:M},yarn:{lockfile:`yarn.lock`,installFiles:[],install:`yarn install --frozen-lockfile`,installProd:`yarn install --production --frozen-lockfile`,run:e=>`yarn run ${e}`,image:M,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`}},P={lockfile:`yarn.lock`,installFiles:[`.yarnrc.yml`],install:`yarn install --immutable`,installProd:`yarn workspaces focus --all --production`,run:e=>`yarn run ${e}`,image:M,setup:`RUN corepack enable`},ne={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 re(e,t,n,r){let[i=0,a=0]=A(r)??[],o=t===`yarn`&&i>=2?i>=4?P:{...P,installProd:P.install}:t===`bun`&&r&&(i<1||i===1&&a<2)?{...N.bun,lockfile:`bun.lockb`}:N[t],s=`${o.setup?`\n${o.setup}`:``}
|
|
@@ -131,10 +131,10 @@ CMD ["node", "dist/index.js"]
|
|
|
131
131
|
`),console.log(m.replace(/^/gm,` `)),console.log());let x=[...new Set(e.map(e=>Te[e]).filter(Boolean))];for(let e of await a(v,x,n))console.log(` Created ${e}`)}}T?console.log(` Done!
|
|
132
132
|
`):(console.log(` Finished with errors — the install above did not complete.
|
|
133
133
|
`),process.exitCode=1)})}const $e=d(w(import.meta.url));function et(e){return{kick:c(e,`kick`),runDev:l(e,`dev`),runBuild:l(e,`build`),runStart:l(e,`start`),runTest:l(e,`test`)}}const $=JSON.parse(_([f($e,`..`,`package.json`),f($e,`..`,`..`,`package.json`)].find(g),`utf-8`)),tt=[`@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`],nt={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 rt(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 it(e){return e===`@forinda/kickjs-cli`?`^${$.version}`:`latest`}async function at(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 ot(){let e=[...tt.map(e=>({name:e,fallback:it(e),cap:void 0})),...Object.entries(nt).map(([e,t])=>({name:e,...t}))],t=Date.now()+2e4,n=await at(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=rt(await z(`npm`,r?[`view`,a,`version`,`--json`]:[`view`,a,`version`],{timeout:i}));return[e,o?`^${o}`:n]});return Object.fromEntries(n)}function st(e,t){let n=R(`npm`,[`view`,`${e}@${t}`,`version`],{timeout:2e4});return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}function ct(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function lt(e,t){let n=e=>ct(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 ut=$.version;async function dt(){let e=rt(await z(`npm`,[`view`,`@forinda/kickjs-cli`,`version`],{timeout:5e3}));return e&&ft(ut,e)?e:null}function ft(e,t){return e.split(`-`)[0]===t.split(`-`)[0]?e.includes(`-`)&&!t.includes(`-`):!lt(e,t)}function pt(e,t,n){let r=R(`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 mt(t){let{name:i,directory:a,packageManager:s=`pnpm`,template:u=`rest`,defaultRepo:d=`inmemory`,packages:p=[],schemaLib:m=`zod`,runtime:h=`express`}=t,_=a,v=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${i}\n`),t.versions||v(`Resolving package versions...`);let y=t.versions??await ot(),b=Object.keys(y).filter(e=>y[e]===`latest`);if(b.length>0&&v(`WARNING: could not reach npm for ${b.join(`, `)} — pinned to 'latest'`),h!==`express`){if(pt(`@forinda/kickjs`,`latest`,`./${h}`))v(`Using @forinda/kickjs@latest (stable ships the ${h} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=st(r,`alpha`);e&<(e,ct(y[r]))&&(y[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}v(n?`Using the alpha channel for the ${h} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${h} runtime subpath may be missing. After install, run: ${s} add @forinda/kickjs@alpha`)}}let S=p.filter(e=>!g(f(o,`feature-${e}`)));S.length>0&&v(`WARNING: skipping unknown package(s): ${S.join(`, `)} — add them later with kick add`);let w=r([..._t({template:u,runtime:h,schemaLib:m,packages:p}),...t.extraLayers??[]],{vars:{name:i,version:$.version},extra:[{slot:`repo`,code:d===`inmemory`?`repo: 'inmemory'`:`repo: { name: '${d.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}' }`},...t.spaClientDir?[gt(t.spaClientDir)]:[]]}),T=t.platformConfig===!1?void 0:k(s);await e(f(_,`package.json`),te(i,y,w,T));let E=ee(s,T);E&&await e(f(_,`.yarnrc.yml`),E);let D=n(w.files,{name:i,template:u,runtime:h,packageManager:s,...et(s),templateLabel:{rest:`REST API`,minimal:`Minimal`,inertia:`Inertia (React)`}[u],sessionSecret:C(32).toString(`hex`),packages:[...w.dependencies,...w.devDependencies].filter(e=>e.startsWith(`@forinda/`)).map(e=>`- \`${e}\``).join(`
|
|
134
|
-
`)});for(let[t,n]of D)await e(f(_,t),n);t.deploy?.length&&t.platformConfig!==!1&&await F({dir:_,targets:t.deploy,pm:s,force:!0});let{generateAgentDocs:O}=await import(`./agent-docs-
|
|
135
|
-
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${s} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-
|
|
134
|
+
`)});for(let[t,n]of D)await e(f(_,t),n);t.deploy?.length&&t.platformConfig!==!1&&await F({dir:_,targets:t.deploy,pm:s,force:!0});let{generateAgentDocs:O}=await import(`./agent-docs-BkoYR-bq.mjs`).then(e=>e.t);await O({outDir:_,name:i,pm:s,template:u,only:`both`,force:!0});let A={...qe,...Ye(p),...w.builds};if(t.approveInstallScripts!==!1&&Q(s,_,A),t.installDeps){console.log(`\n Installing dependencies with ${s}...\n`);try{x(`${s} install`,{cwd:_,stdio:`inherit`}),console.log(`
|
|
135
|
+
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${s} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-BSqoTT4o.mjs`).then(e=>e.n);await e({cwd:_,allowDuplicates:!0,silent:!0})}catch{}if(t.initGit)try{x(`git init`,{cwd:_,stdio:`pipe`}),x(`git branch -M main`,{cwd:_,stdio:`pipe`}),x(`git add -A`,{cwd:_,stdio:`pipe`}),x(`git commit -m "chore: initial commit from kick new"`,{cwd:_,stdio:`pipe`}),v(`Git repository initialized`)}catch{v(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
136
136
|
Project scaffolded successfully!`),console.log();let j=_!==process.cwd();v(`Next steps:`),j&&v(` cd ${i}`),t.installDeps||v(` ${s} install`);let M=c(s,`kick`),N={rest:`${M} g module user`,minimal:`# add your routes to src/index.ts`,inertia:`# pages: src/modules/pages + src/client/pages`};v(` ${N[u]??N.rest}`),v(` ${l(s,`dev`)}`);let P=e=>{let t=Math.max(...e.map(([e])=>e.length))+2;for(let[n,r]of e)v(` ${n.padEnd(t)}${r}`)};return v(``),v(`Commands:`),P([[l(s,`dev`),`Start dev server with Vite HMR`],[l(s,`build`),`Production build via Vite`],[l(s,`start`),`Run production build`]]),v(``),v(`Generators:`),P([[`${M} g module <name>`,`REST module (controller, service, DTOs, repository)`],[`${M} g scaffold <n> <f..>`,`CRUD module from field definitions`],[`${M} g controller <name>`,`Standalone controller`],[`${M} g service <name>`,`@Service() class`],[`${M} g middleware <name>`,`Global connect-style middleware`],[`${M} g guard <name>`,`Route guard (auth, roles, etc.)`],[`${M} g adapter <name>`,`AppAdapter with lifecycle hooks`],[`${M} g dto <name>`,`DTO schema (Zod / Valibot / Yup)`],[`${M} g config`,`Generate kick.config.ts`]]),v(``),v(`Add packages:`),P([[`${M} add <pkg>`,`Install a KickJS package + peers`],[`${M} add --list`,`Show all available packages`]]),v(``),v(`Available: ${Ve}`),v(``),{builds:A}}const ht=e=>`'${JSON.stringify(e).slice(1,-1).replaceAll(`\\"`,`"`).replaceAll(`'`,`\\'`)}'`;function gt(e){return{import:{from:`@forinda/kickjs/spa`,names:[`SpaAdapter`]},slot:`adapter`,code:`// Serves the built frontend from this origin in production.
|
|
137
137
|
// Inert until the client build exists, so \`kick dev\` (where Vite
|
|
138
138
|
// serves the client and proxies /api here) is unaffected.
|
|
139
139
|
SpaAdapter({ clientDir: ${ht(e)} })`}}function _t(e){return[`base`,`template-${e.template}`,`runtime-${e.runtime}`,`schema-${e.schemaLib}`,...e.packages.filter(e=>g(f(o,`feature-${e}`))).map(e=>`feature-${e}`)]}export{ee as C,k as S,B as _,J as a,F as b,Q as c,Ze as d,X as f,we as g,De as h,ot as i,Y as l,Oe as m,mt as n,q as o,Z as p,dt as r,He as s,ut as t,Qe as u,pe as v,le as x,me as y};
|
|
140
|
-
//# sourceMappingURL=project-
|
|
140
|
+
//# sourceMappingURL=project-a6ySsOdn.mjs.map
|