@forinda/kickjs-cli 8.12.1 → 8.13.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-GBEi-4ZM.mjs → agent-docs-D0qgHBA8.mjs} +25 -21
- package/dist/{agent-docs-DZJSoa_5.mjs → agent-docs-DD0hT2pE.mjs} +18 -14
- package/dist/agent-docs-DD0hT2pE.mjs.map +1 -0
- package/dist/{build-DkjrK7QX.mjs → build-C1ZgYqj7.mjs} +2 -2
- package/dist/{build-DZtpU_3Z.mjs → build-DEdLI54B.mjs} +3 -3
- package/dist/{build-DZtpU_3Z.mjs.map → build-DEdLI54B.mjs.map} +1 -1
- package/dist/{builtins-h-f_jNxU.mjs → builtins-BWtf5CEP.mjs} +2 -2
- package/dist/{builtins-BMZz5lPx.mjs → builtins-DZ-kQSyt.mjs} +121 -121
- package/dist/cli.mjs +2 -2
- package/dist/{config-aEXDfmSS.mjs → config-CHRM7WLZ.mjs} +3 -3
- package/dist/{config-aEXDfmSS.mjs.map → config-CHRM7WLZ.mjs.map} +1 -1
- package/dist/{config-B7d6wm08.mjs → config-CQGH0FTE.mjs} +2 -2
- package/dist/{doctor-DKtiOCf2.mjs → doctor-D0uazKD7.mjs} +20 -20
- package/dist/{doctor-DKtiOCf2.mjs.map → doctor-D0uazKD7.mjs.map} +1 -1
- package/dist/fullstack-C8k03oM8.mjs +110 -0
- package/dist/fullstack-Cr5tath7.mjs +111 -0
- package/dist/fullstack-Cr5tath7.mjs.map +1 -0
- package/dist/index.d.mts +8 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/package-manager-B-BW1RBj.mjs +11 -0
- package/dist/package-manager-mqxVziQ9.mjs +12 -0
- package/dist/package-manager-mqxVziQ9.mjs.map +1 -0
- package/dist/{plugin-BqNQkm01.mjs → plugin-DSgKyJSD.mjs} +2 -2
- package/dist/{plugin-Dc9DwVlE.mjs → plugin-MPu_4sWN.mjs} +2 -2
- package/dist/project--T8NPgfc.mjs +133 -0
- package/dist/{project-root-By-1PuaD.mjs → project-root-BsIxM6Gj.mjs} +2 -2
- package/dist/{project-root-C_H7sWTH.mjs → project-root-C4lAZePJ.mjs} +3 -3
- package/dist/{project-root-C_H7sWTH.mjs.map → project-root-C4lAZePJ.mjs.map} +1 -1
- package/dist/project-w-OcvS26.mjs +134 -0
- package/dist/project-w-OcvS26.mjs.map +1 -0
- package/dist/{rolldown-runtime-De7_Z3h7.mjs → rolldown-runtime-BVrPnwAV.mjs} +1 -1
- package/dist/{run-plugins-DY4qiPTu.mjs → run-plugins-cqNounm7.mjs} +108 -108
- package/dist/run-plugins-cqNounm7.mjs.map +1 -0
- package/dist/{typegen-ajfH3dB8.mjs → typegen-BfFiyGeh.mjs} +4 -4
- package/dist/{typegen-C13eMf8Q.mjs → typegen-Ctafx65M.mjs} +5 -5
- package/dist/{typegen-C13eMf8Q.mjs.map → typegen-Ctafx65M.mjs.map} +1 -1
- package/dist/{types-m-1iCFmy.mjs → types-CH5itn9u.mjs} +1 -1
- package/package.json +4 -4
- package/templates/base/files/README.md +11 -0
- package/templates/template-inertia/feature.json +1 -3
- package/templates/template-inertia/files/vite.client.config.ts +4 -1
- package/templates/web-kick/files/web/vite.config.ts +4 -1
- package/dist/agent-docs-DZJSoa_5.mjs.map +0 -1
- package/dist/fullstack-B6ZY4jGe.mjs +0 -100
- package/dist/fullstack-B6ZY4jGe.mjs.map +0 -1
- package/dist/fullstack-DBLIBX52.mjs +0 -99
- package/dist/package-manager-2OKBz8KC.mjs +0 -11
- package/dist/package-manager-C9253oKe.mjs +0 -12
- package/dist/package-manager-C9253oKe.mjs.map +0 -1
- package/dist/project-BktC0yLE.mjs +0 -134
- package/dist/project-BktC0yLE.mjs.map +0 -1
- package/dist/project-Cr8KrIZg.mjs +0 -133
- package/dist/prompts-iLmIrMD4.mjs +0 -12
- package/dist/prompts-iLmIrMD4.mjs.map +0 -1
- package/dist/run-plugins-DY4qiPTu.mjs.map +0 -1
- package/templates/host-config/files/vercel.json +0 -5
- /package/templates/{host-config → deploy-netlify}/files/netlify.toml +0 -0
- /package/templates/{fullstack-root → deploy-netlify-workspace}/files/netlify.toml +0 -0
- /package/templates/{base → deploy-serverless}/files/src/serverless.ts +0 -0
- /package/templates/{fullstack-root → deploy-vercel}/files/vercel.json +0 -0
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.12.1
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) Felix Orinda
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
import{a as e,d as t,f as n,h as r,l as i,m as a,n as o,p as s,t as c,u as l}from"./project-Cr8KrIZg.mjs";import{f as u,r as d}from"./config-B7d6wm08.mjs";import{o as f}from"./package-manager-2OKBz8KC.mjs";import{join as p}from"node:path";import{execFileSync as m}from"node:child_process";const h=`https://kickjs.app/guide/fullstack-frontend.html`,g=[{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`}],_=`react-ts`;function v(e,t,n=_){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 y(u){let{name:g,directory:y,schemaLib:C=`zod`,runtime:w=`express`,packages:T=[],frontend:E=`kick`,viteTemplate:D=_}=u,O=[`pnpm`,`npm`,`yarn`,`bun`].includes(u.packageManager),k=O?u.packageManager:`pnpm`,A=y,j=e=>console.log(` ${e}`);u.packageManager!==void 0&&!O&&j(`Warning: unknown package manager '${String(u.packageManager)}' — falling back to pnpm.`),console.log(`\n Creating fullstack KickJS workspace: ${g}\n`),console.log(` Resolving package versions...`);let M=await o(),N=await c({name:`${g}-server`,directory:p(A,`server`),packageManager:k,template:`minimal`,schemaLib:C,runtime:w,packages:T,extraLayers:[`server-fullstack`],approveInstallScripts:!1,platformConfig:!1,initGit:!1,installDeps:!1,spaClientDir:`../web/dist`,versions:M});if(E===`vite`){console.log(`\n Handing web/ to create-vite (${D})...\n`);let[e,...t]=v(k,`web`,D);r(e,t,{cwd:A})}else await f(p(A,`web/package.json`),b(g,M));let P=t(k);await f(p(A,`package.json`),x(g,k,M[`@forinda/kickjs-cli`],P));let F=n(k,P);F&&await f(p(A,`.yarnrc.yml`),F),k===`pnpm`&&await f(p(A,`pnpm-workspace.yaml`),`packages:
|
|
12
|
-
- server
|
|
13
|
-
- web
|
|
14
|
-
`),e(k,A,N.builds);let I=[`fullstack-root`,...E===`vite`?[]:[`web-kick`]],L=s(a(I).files,{name:g,packageManager:k});for(let[e,t]of L)await f(p(A,e),t);await f(p(A,`README.md`),S(g,k,E)),await f(p(A,`Dockerfile`),i(`fullstack`,k,g,P)),await f(p(A,`.dockerignore`),l());let{generateAgentDocs:R}=await import(`./agent-docs-GBEi-4ZM.mjs`).then(e=>e.t);if(await R({outDir:A,name:g,pm:k,template:`fullstack`,only:`all`,force:!0}),u.installDeps){console.log(`\n Installing workspace dependencies with ${k}...\n`);try{r(k,[`install`],{cwd:A})}catch{console.log(`\n Warning: ${k} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-ajfH3dB8.mjs`).then(e=>e.n);await e({cwd:p(A,`server`),allowDuplicates:!0,silent:!0})}catch{}if(u.initGit)try{m(`git`,[`init`],{cwd:A,stdio:`pipe`}),m(`git`,[`branch`,`-M`,`main`],{cwd:A,stdio:`pipe`}),m(`git`,[`add`,`-A`],{cwd:A,stdio:`pipe`}),m(`git`,[`commit`,`-m`,`chore: initial commit from kick new (fullstack)`],{cwd:A,stdio:`pipe`}),j(`Git repository initialized`)}catch{j(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
15
|
-
Fullstack workspace scaffolded!`),console.log(),j(`Next steps:`),j(` cd ${g}`),u.installDeps||j(` ${k} install`),k===`pnpm`?j(` pnpm dev # runs server (kick dev) + web (vite) together`):(j(` ${k} run dev:server # terminal 1`),j(` ${k} run dev:web # terminal 2`)),j(``),E===`vite`?(j(`web/ is create-vite output, unwired. To type it against the API:`),j(` ${h}`)):(j(`The web app calls the API through @forinda/kickjs-client —`),j(`edit server/src/modules/hello, run \`${d(k,`kick`)} typegen\` in server/, and`),j(`web/src/App.tsx's types follow.`)),j(``)}function b(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 x(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`,"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 --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:netlify":`${n} run build && cd server && kick build:netlify`,"build:vercel":`${n} run build && cd server && kick build:vercel`,"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 S(e,t,n=`kick`){let r=`# ${e}
|
|
16
|
-
|
|
17
|
-
Fullstack KickJS workspace — typed end to end.
|
|
18
|
-
|
|
19
|
-
| Package | What |
|
|
20
|
-
| --------- | ----------------------------------------------------------------- |
|
|
21
|
-
| \`server/\` | KickJS API (decorators, DI, \`kick dev\` with typegen watch) |
|
|
22
|
-
| \`web/\` | Vite + React, typed against the API via \`@forinda/kickjs-client\` |
|
|
23
|
-
|
|
24
|
-
## Develop
|
|
25
|
-
|
|
26
|
-
\`\`\`bash
|
|
27
|
-
${t} install
|
|
28
|
-
${t===`pnpm`?`pnpm dev # server (kick dev) + web (vite), in parallel`:`${t} run dev:server # terminal 1\n${t} run dev:web # terminal 2`}
|
|
29
|
-
\`\`\`
|
|
30
|
-
|
|
31
|
-
Server: http://localhost:3000 · Web: http://localhost:5173 (Vite proxies \`/api\`).
|
|
32
|
-
|
|
33
|
-
From this root: \`${u(t,`test`)}\` (the server's tests), \`${u(t,`typecheck`)}\` (both packages),
|
|
34
|
-
\`${u(t,`format`)}\` and \`${u(t,`build`)}\`. The \`kick\` CLI itself runs in \`server/\`, which holds
|
|
35
|
-
\`kick.config.ts\`: \`cd server && ${d(t,`kick`)} typegen\`.
|
|
36
|
-
|
|
37
|
-
## The type loop
|
|
38
|
-
|
|
39
|
-
1. Server handlers **return** their payloads (\`return this.service.greet(...)\`).
|
|
40
|
-
2. \`kick typegen\` emits \`server/.kickjs/types/kick__client.d.ts\` — the flat
|
|
41
|
-
route map with every response type resolved to a literal shape.
|
|
42
|
-
3. \`web/tsconfig.json\` lists that file in \`types\`, so \`KickClientApi\` is
|
|
43
|
-
ambient — no import, no bridge file.
|
|
44
|
-
4. \`web/src/api.ts\`'s \`createClient<KickClientApi.Api>\` types every call site.
|
|
45
|
-
|
|
46
|
-
Because the map holds resolved types rather than references to controllers,
|
|
47
|
-
\`web\` never compiles server source: no \`experimentalDecorators\`, no path
|
|
48
|
-
aliases into \`server/src\`.
|
|
49
|
-
|
|
50
|
-
Rename a field in \`server/src/modules/hello/hello.service.ts\` → \`web/src/App.tsx\`
|
|
51
|
-
stops compiling. That's the point.
|
|
52
|
-
|
|
53
|
-
### Keeping the map fresh
|
|
54
|
-
|
|
55
|
-
\`server/.kickjs/types/kick__client.d.ts\` is generated, and \`web\` reads it as
|
|
56
|
-
an ambient type package. Two things follow.
|
|
57
|
-
|
|
58
|
-
**\`kick dev\` writes it at startup, not on save.** Resolving it builds a whole TypeScript
|
|
59
|
-
program over the server, which is a build-step cost rather than a per-save one,
|
|
60
|
-
so a renamed response field surfaces on the next \`kick typegen\` rather than on
|
|
61
|
-
save. Everything else in \`.kickjs/types\` still updates on save. Add
|
|
62
|
-
\`kick typegen --check\` to CI and a stale map fails the build.
|
|
63
|
-
|
|
64
|
-
**It needs a compiler API.** TypeScript 7 ships none, so \`server\` depends on
|
|
65
|
-
\`@typescript/typescript6\`. Remove it and typegen skips this one file, saying
|
|
66
|
-
so; \`web\` then reports \`TS2688\` because the file it lists in \`types\` is gone.
|
|
67
|
-
|
|
68
|
-
### The other way to wire it
|
|
69
|
-
|
|
70
|
-
A \`types\` entry says "this is a global type package", which is what the map is,
|
|
71
|
-
and it fails loudly when the file is missing. If you would rather it be quiet
|
|
72
|
-
when absent — say, a repo where the map is not always generated — use
|
|
73
|
-
\`include\` instead:
|
|
74
|
-
|
|
75
|
-
\`\`\`json
|
|
76
|
-
{ "include": ["src", "../server/.kickjs/types/kick__client.d.ts"] }
|
|
77
|
-
\`\`\`
|
|
78
|
-
|
|
79
|
-
That tolerates the file not existing, at the cost of \`KickClientApi\` silently
|
|
80
|
-
not resolving. Note \`types\` replaces TypeScript's automatic \`@types\`
|
|
81
|
-
inclusion, so if you add entries there, list the ones you rely on too
|
|
82
|
-
(\`"types": ["node", "../server/.kickjs/types/kick__client"]\`).
|
|
83
|
-
|
|
84
|
-
Or skip the global entirely — the same file exports the type:
|
|
85
|
-
|
|
86
|
-
\`\`\`ts
|
|
87
|
-
import type { Api } from '../../server/.kickjs/types/kick__client'
|
|
88
|
-
|
|
89
|
-
export const api = createClient<Api>({ baseUrl: '/api/v1' })
|
|
90
|
-
\`\`\`
|
|
91
|
-
|
|
92
|
-
Docs: https://kickjs.app/guide/typed-client.html
|
|
93
|
-
`;if(n!==`vite`)return r;let i=r.indexOf(`## The type loop`);return`${r.slice(0,i).replace("Vite + React, typed against the API via `@forinda/kickjs-client`",`create-vite scaffold — unwired (see below) `).replace(" (Vite proxies `/api`)",``)}## Wiring web/ to the API
|
|
94
|
-
|
|
95
|
-
\`web/\` is whatever create-vite scaffolded; nothing connects it to the API yet.
|
|
96
|
-
Four steps — typed client, \`/api\` dev proxy, route-map types, \`src/api.ts\`:
|
|
97
|
-
|
|
98
|
-
${h}
|
|
99
|
-
`}export{_ as DEFAULT_VITE_TEMPLATE,g as VITE_TEMPLATES,y as initFullstackProject};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.12.1
|
|
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{o as e,t}from"./config-B7d6wm08.mjs";import{createRequire as n}from"node:module";import{existsSync as r,readFileSync as i}from"node:fs";import{dirname as a,extname as o,join as s,resolve as c}from"node:path";import{access as l,mkdir as u,readFile as d,writeFile as f}from"node:fs/promises";let p=!1;function m(e){p=e}const h=/* @__PURE__ */ new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`,`.md`]);async function g(e,t){p||(await u(a(e),{recursive:!0}),await f(e,t,`utf-8`),h.has(o(e))&&await y(e,t).catch(()=>{}))}let _;async function v(e){if(_!==void 0)return _;try{_=await import(n(s(e,`package.json`)).resolve(`oxfmt`))}catch{_=await import(`oxfmt`).catch(()=>null)}return _}async function y(e,t){let n=await v(process.cwd());if(!n)return;let r=await x(e);if(r===null)return;let i=await n.format(e,t,r);i.code!==t&&await f(e,i.code,`utf-8`)}const b=/* @__PURE__ */ new Map;async function x(e){let t=a(e),n=t;if(b.has(n))return b.get(n);for(;;){let e=s(t,`.oxfmtrc.json`);if(r(e))try{let t=await d(e,`utf-8`),r=JSON.parse(t);return delete r.$schema,delete r.ignorePatterns,b.set(n,r),r}catch{return b.set(n,null),null}let i=a(t);if(i===t)return b.set(n,null),null;t=i}}async function S(e){try{return await l(e),!0}catch{return!1}}const C=[[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`package-lock.json`,`npm`]];function w(e){for(let t=e;;t=a(t)){let e=C.find(([e])=>r(c(t,e)));if(e)return e[1];if(a(t)===t)return null}}function T(e){let n=e;for(;n;){let e=c(n,`package.json`);if(r(e))try{let n=JSON.parse(i(e,`utf-8`)).packageManager;if(typeof n==`string`){let e=n.split(`@`)[0];if(t.includes(e))return e}}catch{}let o=a(n);if(o===n)return null;n=o}return null}async function E(n,r=process.cwd()){if(n&&t.includes(n))return{pm:n,source:`flag`};let i=await e(r);if(i?.packageManager&&t.includes(i.packageManager))return{pm:i.packageManager,source:`config`};let a=T(r);if(a)return{pm:a,source:`package.json`};let o=w(r);if(o)return{pm:o,source:`lockfile`};let s=process.env.npm_config_user_agent?.split(`/`)[0];return s&&t.includes(s)?{pm:s,source:`user-agent`}:{pm:`npm`,source:`default`}}async function D(e,t=process.cwd()){let{pm:n}=await E(e,t);return n}function O(e=process.cwd()){return T(e)??w(e)??`npm`}export{m as a,S as i,D as n,g as o,E as r,O as t};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.12.1
|
|
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{s as e,t}from"./config-aEXDfmSS.mjs";import{createRequire as n}from"node:module";import{dirname as r,extname as i,join as a,resolve as o}from"node:path";import{existsSync as s,readFileSync as c}from"node:fs";import{access as l,mkdir as u,readFile as d,writeFile as f}from"node:fs/promises";let p=!1;function m(e){p=e}const h=/* @__PURE__ */ new Set([`.ts`,`.tsx`,`.js`,`.jsx`,`.mjs`,`.cjs`,`.json`,`.md`]);async function g(e,t){p||(await u(r(e),{recursive:!0}),await f(e,t,`utf-8`),h.has(i(e))&&await y(e,t).catch(()=>{}))}let _;async function v(e){if(_!==void 0)return _;try{_=await import(n(a(e,`package.json`)).resolve(`oxfmt`))}catch{_=await import(`oxfmt`).catch(()=>null)}return _}async function y(e,t){let n=await v(process.cwd());if(!n)return;let r=await x(e);if(r===null)return;let i=await n.format(e,t,r);i.code!==t&&await f(e,i.code,`utf-8`)}const b=/* @__PURE__ */ new Map;async function x(e){let t=r(e),n=t;if(b.has(n))return b.get(n);for(;;){let e=a(t,`.oxfmtrc.json`);if(s(e))try{let t=await d(e,`utf-8`),r=JSON.parse(t);return delete r.$schema,delete r.ignorePatterns,b.set(n,r),r}catch{return b.set(n,null),null}let i=r(t);if(i===t)return b.set(n,null),null;t=i}}async function S(e){try{return await l(e),!0}catch{return!1}}const C=[[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`package-lock.json`,`npm`]];function w(e){for(let t=e;;t=r(t)){let e=C.find(([e])=>s(o(t,e)));if(e)return e[1];if(r(t)===t)return null}}function T(e){let n=e;for(;n;){let e=o(n,`package.json`);if(s(e))try{let n=JSON.parse(c(e,`utf-8`)).packageManager;if(typeof n==`string`){let e=n.split(`@`)[0];if(t.includes(e))return e}}catch{}let i=r(n);if(i===n)return null;n=i}return null}async function E(n,r=process.cwd()){if(n&&t.includes(n))return{pm:n,source:`flag`};let i=await e(r);if(i?.packageManager&&t.includes(i.packageManager))return{pm:i.packageManager,source:`config`};let a=T(r);if(a)return{pm:a,source:`package.json`};let o=w(r);if(o)return{pm:o,source:`lockfile`};let s=process.env.npm_config_user_agent?.split(`/`)[0];return s&&t.includes(s)?{pm:s,source:`user-agent`}:{pm:`npm`,source:`default`}}async function D(e,t=process.cwd()){let{pm:n}=await E(e,t);return n}function O(e=process.cwd()){return T(e)??w(e)??`npm`}export{m as a,S as i,D as n,g as o,E as r,O as t};
|
|
12
|
-
//# sourceMappingURL=package-manager-C9253oKe.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager-C9253oKe.mjs","names":["loadKickConfig","_dryRun","setDryRun","enabled","FORMATTABLE","writeFileSafe","mkdir","dirname","filePath","writeFile","content","extname","formatFile","_oxfmt","resolveOxfmt","createRequire","join","cwd","oxfmt","options","loadOxfmtConfig","result","_oxfmtConfigCache","dir","startDir","configPath","existsSync","raw","readFile","parsed","\"$schema\"","parent","fileExists","access","LOCKFILES","detectFromLockfile","fromDir","hit","file","resolve","packageManagerFromPackageJson","pkgPath","field","readFileSync","name","PACKAGE_MANAGERS","resolvePackageManagerWithSource","flagPm","config","fromPkg","fromLock","fromAgent","resolvePackageManager","pm","detectPackageManager"],"sources":["../src/utils/fs.ts","../src/utils/package-manager.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { writeFile, mkdir, access, readFile } from 'node:fs/promises'\nimport { createRequire } from 'node:module'\nimport { dirname, extname, join } from 'node:path'\n\nlet _dryRun = false\nlet _format = true\n\n/** Enable/disable dry run mode globally for all writeFileSafe calls */\nexport function setDryRun(enabled: boolean): void {\n _dryRun = enabled\n}\n\n/**\n * Toggle oxfmt post-write formatting. Defaults to enabled — generators\n * always emit formatted output unless the caller opts out (rare; useful\n * for tests that want byte-stable assertions against raw template strings).\n */\nexport function setFormatOnWrite(enabled: boolean): void {\n _format = enabled\n}\n\n/** Extensions oxfmt can format. Anything else is written verbatim. */\nconst FORMATTABLE = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.json', '.md'])\n\n/**\n * Write a file, creating parent directories if needed.\n *\n * After write, runs oxfmt against the file when:\n * - format-on-write is enabled (default)\n * - the extension is in {@link FORMATTABLE}\n * - oxfmt resolves from the user's project (or our own cwd)\n *\n * Failures (missing oxfmt, unparseable source, formatter crash) are\n * swallowed silently — formatting is a polish step, not a correctness\n * gate. The pre-commit hook still catches anything we couldn't format.\n *\n * Skips writing entirely in dry run mode.\n */\nexport async function writeFileSafe(filePath: string, content: string): Promise<void> {\n if (_dryRun) return\n await mkdir(dirname(filePath), { recursive: true })\n await writeFile(filePath, content, 'utf-8')\n if (_format && FORMATTABLE.has(extname(filePath))) {\n await formatFile(filePath, content).catch(() => {\n // Formatter missing or unparseable source — leave the unformatted\n // file in place. Pre-commit hook will catch shipping-blocker\n // formatting issues.\n })\n }\n}\n\ninterface OxfmtFormatResult {\n code: string\n errors: unknown[]\n}\n\ninterface OxfmtModule {\n format(\n fileName: string,\n sourceText: string,\n options?: Record<string, unknown>,\n ): Promise<OxfmtFormatResult>\n}\n\nlet _oxfmt: OxfmtModule | null | undefined = undefined\n\n/** Resolve oxfmt from the user's project, else the CLI's own; cache the result (or null) for the process. */\nasync function resolveOxfmt(cwd: string): Promise<OxfmtModule | null> {\n if (_oxfmt !== undefined) return _oxfmt\n try {\n const req = createRequire(join(cwd, 'package.json'))\n const oxfmtPath = req.resolve('oxfmt')\n _oxfmt = (await import(oxfmtPath)) as OxfmtModule\n } catch {\n // Not installed in the project — `vp migrate` removes it, Vite+ bundles\n // its own. Fall back to the copy the CLI depends on.\n _oxfmt = (await import('oxfmt').catch(() => null)) as OxfmtModule | null\n }\n return _oxfmt\n}\n\nasync function formatFile(filePath: string, content: string): Promise<void> {\n const oxfmt = await resolveOxfmt(process.cwd())\n if (!oxfmt) return\n // The CLI binary auto-discovers `.oxfmtrc.json`, but the JS API\n // does NOT — we walk up from the file being formatted so adopters'\n // workspace config drives the output. Skip formatting entirely\n // when no config is found (matches the old prettier failure mode:\n // raw templates already follow project conventions).\n const options = await loadOxfmtConfig(filePath)\n if (options === null) return\n const result = await oxfmt.format(filePath, content, options)\n if (result.code === content) return\n await writeFile(filePath, result.code, 'utf-8')\n}\n\nconst _oxfmtConfigCache = new Map<string, Record<string, unknown> | null>()\n\n/**\n * Walk up from `filePath`'s directory looking for `.oxfmtrc.json`.\n * Returns `null` when no config is found anywhere on the path —\n * generators then leave the raw template alone (which already\n * follows project conventions). Cached per starting directory so\n * the walk is one-shot per generator run.\n */\nasync function loadOxfmtConfig(filePath: string): Promise<Record<string, unknown> | null> {\n let dir = dirname(filePath)\n const startDir = dir\n if (_oxfmtConfigCache.has(startDir)) return _oxfmtConfigCache.get(startDir)!\n while (true) {\n const configPath = join(dir, '.oxfmtrc.json')\n if (existsSync(configPath)) {\n try {\n const raw = await readFile(configPath, 'utf-8')\n const parsed = JSON.parse(raw) as Record<string, unknown>\n // The `$schema` and `ignorePatterns` fields are runner-only —\n // strip before passing to format() so it doesn't reject them\n // as unknown options.\n delete parsed['$schema']\n delete parsed.ignorePatterns\n _oxfmtConfigCache.set(startDir, parsed)\n return parsed\n } catch {\n _oxfmtConfigCache.set(startDir, null)\n return null\n }\n }\n const parent = dirname(dir)\n if (parent === dir) {\n _oxfmtConfigCache.set(startDir, null)\n return null\n }\n dir = parent\n }\n}\n\n/** Reset cached oxfmt resolution. Tests use this; production code shouldn't. */\nexport function clearFormatCache(): void {\n _oxfmt = undefined\n _oxfmtConfigCache.clear()\n}\n\n/** Ensure a directory exists */\nexport async function ensureDirectory(dir: string): Promise<void> {\n await mkdir(dir, { recursive: true })\n}\n\n/** Check if a file exists */\nexport async function fileExists(filePath: string): Promise<boolean> {\n try {\n await access(filePath)\n return true\n } catch {\n return false\n }\n}\n\n/** Read a JSON file */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function readJsonFile<T = any>(filePath: string): Promise<T> {\n const content = await readFile(filePath, 'utf-8')\n return JSON.parse(content)\n}\n","/**\n * Which package manager a project uses — for installing (`kick add`) and for\n * the commands the CLI prints.\n */\nimport { existsSync, readFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport { loadKickConfig, PACKAGE_MANAGERS, type PackageManager } from '../config'\n\nconst LOCKFILES: [string, PackageManager][] = [\n ['pnpm-lock.yaml', 'pnpm'],\n ['yarn.lock', 'yarn'],\n ['bun.lock', 'bun'],\n ['bun.lockb', 'bun'],\n ['package-lock.json', 'npm'],\n]\n\n/** The package manager of the nearest folder up from `fromDir` holding a lockfile. */\nfunction detectFromLockfile(fromDir: string): PackageManager | null {\n for (let dir = fromDir; ; dir = dirname(dir)) {\n const hit = LOCKFILES.find(([file]) => existsSync(resolve(dir, file)))\n if (hit) return hit[1]\n if (dirname(dir) === dir) return null\n }\n}\n\n/**\n * Read `packageManager` from the nearest ancestor `package.json` that\n * declares the field (corepack convention: `\"pnpm@10.0.0\"`). Climbs so\n * monorepo sub-packages inherit the workspace pm even when their own\n * package.json omits the field.\n */\nfunction packageManagerFromPackageJson(fromDir: string): PackageManager | null {\n let dir: string | null = fromDir\n while (dir) {\n const pkgPath = resolve(dir, 'package.json')\n if (existsSync(pkgPath)) {\n try {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))\n const field: unknown = pkg.packageManager\n if (typeof field === 'string') {\n const name = field.split('@')[0] as PackageManager\n if (PACKAGE_MANAGERS.includes(name)) return name\n }\n } catch {\n // ignore — keep climbing\n }\n }\n const parent = dirname(dir)\n if (parent === dir) return null\n dir = parent\n }\n return null\n}\n\nexport type PackageManagerSource =\n | 'flag'\n | 'config'\n | 'package.json'\n | 'lockfile'\n | 'user-agent'\n | 'default'\n\n/**\n * Resolve which package manager to use, in priority order:\n * 1. `--pm` CLI flag\n * 2. `packageManager` in kick.config\n * 3. `packageManager` in nearest ancestor package.json (corepack)\n * 4. The nearest ancestor folder's lockfile\n * 5. The package manager that launched the CLI (`npm_config_user_agent`)\n * 6. `'npm'` fallback\n *\n * Returns the chosen pm plus the source for callers that want to log\n * the resolution path.\n */\nexport async function resolvePackageManagerWithSource(\n flagPm: string | undefined,\n fromDir = process.cwd(),\n): Promise<{ pm: PackageManager; source: PackageManagerSource }> {\n if (flagPm && PACKAGE_MANAGERS.includes(flagPm as PackageManager)) {\n return { pm: flagPm as PackageManager, source: 'flag' }\n }\n\n const config = await loadKickConfig(fromDir)\n if (config?.packageManager && PACKAGE_MANAGERS.includes(config.packageManager)) {\n return { pm: config.packageManager, source: 'config' }\n }\n\n const fromPkg = packageManagerFromPackageJson(fromDir)\n if (fromPkg) return { pm: fromPkg, source: 'package.json' }\n\n const fromLock = detectFromLockfile(fromDir)\n if (fromLock) return { pm: fromLock, source: 'lockfile' }\n\n // Outside any project: the one that launched the CLI (`pnpm dlx`, `bunx`,\n // `yarn dlx`, `npx`) — e.g. `pnpm dlx @forinda/kickjs-cli new app --yes`.\n const fromAgent = process.env.npm_config_user_agent?.split('/')[0] as PackageManager | undefined\n if (fromAgent && PACKAGE_MANAGERS.includes(fromAgent)) {\n return { pm: fromAgent, source: 'user-agent' }\n }\n\n return { pm: 'npm', source: 'default' }\n}\n\n/** Convenience wrapper for callers that don't care about the source. */\nexport async function resolvePackageManager(\n flagPm: string | undefined,\n fromDir = process.cwd(),\n): Promise<PackageManager> {\n const { pm } = await resolvePackageManagerWithSource(flagPm, fromDir)\n return pm\n}\n\n/**\n * The project's package manager without reading kick.config — for messages\n * printed from synchronous code: `packageManager`, then the lockfile, then npm.\n */\nexport function detectPackageManager(fromDir = process.cwd()): PackageManager {\n return packageManagerFromPackageJson(fromDir) ?? detectFromLockfile(fromDir) ?? 'npm'\n}\n"],"mappings":"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"}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.12.1
|
|
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{o as e,r as t}from"./package-manager-C9253oKe.mjs";import{i as n,p as r,s as i}from"./config-aEXDfmSS.mjs";import{dirname as a,join as o,posix as s,resolve as c,sep as l}from"node:path";import{existsSync as u,readFileSync as d,readdirSync as f,statSync as p,writeFileSync as m}from"node:fs";import{execFile as h,execFileSync as g,execSync as _,spawnSync as v}from"node:child_process";import{randomBytes as y}from"node:crypto";import{fileURLToPath as b}from"node:url";import{promisify as x}from"node:util";import{parseSync as S}from"oxc-parser";const C=a(b(import.meta.url)),w=[o(C,`..`,`templates`),o(C,`..`,`..`,`templates`)].find(e=>u(o(e,`base`)));function ee(e){return e.split(`/`).map(e=>e.startsWith(`_dot_`)?`.${e.slice(5)}`:e).join(`/`)}function T(e,t={}){let n=t.templatesDir??w,r=/* @__PURE__ */ new Map,i=[],a=[],s={},c=[],m={};for(let t of e){let e=o(n,t);if(!u(e))throw Error(`Unknown scaffold layer "${t}" (${e})`);let h=o(e,`feature.json`);if(u(h)){let e=JSON.parse(d(h,`utf-8`));i.push(...e.dependencies??[]),a.push(...e.devDependencies??[]),Object.assign(s,e.builds),c.push(...e.integrations??[]),Object.assign(m,e.scripts)}let g=o(e,`files`);if(u(g))for(let e of f(g,{recursive:!0,encoding:`utf-8`}).toSorted()){let t=o(g,e);if(!p(t).isFile())continue;let n=d(t,`utf-8`),i=ee(e.split(l).join(`/`));if(i.endsWith(`.append`)){let e=i.slice(0,-7);r.set(e,(r.get(e)??``)+n)}else r.set(i,n)}}c.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,D(t,c,g));return{files:r,dependencies:[...new Set(i)],devDependencies:[...new Set(a)],builds:s,integrations:c,scripts:m}}function te(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 E=/^([ \t]*)\/\/ @kick:([\w-]+)[ \t]*$/;function D(e,t,n=e=>e){let r=e.split(`
|
|
12
|
-
`),i=new Set(r.map(e=>E.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=E.exec(r[e]);if(!t){o.push(r[e]);continue}let[,i,s]=t,c=s===`imports`?k(a.flatMap(e=>e.import?[e.import]:[])):a.filter(e=>e.slot===s&&e.code).map(e=>O(`${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 O(e,t){return e.split(`
|
|
14
|
-
`).map(e=>e&&t+e).join(`
|
|
15
|
-
`)}function k(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}'`})}function A(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,A(t,e)]))}function M(e){try{let t=g(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 N(e){let t=e?.match(/@(\d+)\.(\d+)\./);return t?[Number(t[1]),Number(t[2])]:void 0}function P(e,t){let n=N(t)?.[0];return e===`yarn`&&n!==void 0&&n>=2?`nodeLinker: node-modules
|
|
17
|
-
`:void 0}function ne(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`,"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 re(e,t){let n=Object.entries(t);if(n.length===0)return e;let r=e===``?[]:e.replace(/\n$/,``).split(`
|
|
18
|
-
`),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(`
|
|
19
|
-
`)}\n`}const F=`node:22-slim`,ie={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`},ae={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 oe(e,t,n,r){let[i=0,a=0]=N(r)??[],o=t===`yarn`&&i>=2?i>=4?I:{...I,installProd:I.install}:t===`bun`&&r&&(i<1||i===1&&a<2)?{...ie.bun,lockfile:`bun.lockb`}:ie[t],s=`${o.setup?`\n${o.setup}`:``}
|
|
20
|
-
# Compilers for native addons (better-sqlite3, …) that have no prebuilt binary.
|
|
21
|
-
RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ \\
|
|
22
|
-
&& rm -rf /var/lib/apt/lists/*`,c=`# The build stage generates the Prisma client, if any.
|
|
23
|
-
ENV PRISMA_SKIP_POSTINSTALL_GENERATE=1`,l=(e===`fullstack`?[`package.json`,o.lockfile,...o.installFiles,`server/package.json`,`web/package.json`]:[`package.json`,o.lockfile,...o.installFiles]).map(e=>`COPY ${e} ./${e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)+1):``}`).join(`
|
|
24
|
-
`),u=`# syntax=docker/dockerfile:1
|
|
25
|
-
# ${n} — the long-running server in one image.
|
|
26
|
-
#
|
|
27
|
-
# docker build -t ${n} .
|
|
28
|
-
# ${ae[e].replace(`<name>`,n)}
|
|
29
|
-
#
|
|
30
|
-
# Environment comes from the platform or \`docker run\`; .env files are not
|
|
31
|
-
# copied into the image. The lockfile must be committed — installs are frozen.
|
|
32
|
-
`;if(e===`fullstack`)return`${u}
|
|
33
|
-
FROM ${o.image} AS base
|
|
34
|
-
WORKDIR /app${s}
|
|
35
|
-
|
|
36
|
-
# Production dependencies of every workspace member.
|
|
37
|
-
FROM base AS deps
|
|
38
|
-
${c}
|
|
39
|
-
${l}
|
|
40
|
-
RUN ${o.installProd}
|
|
41
|
-
# Hoisting may leave a member without its own node_modules; the runtime copies both.
|
|
42
|
-
RUN mkdir -p node_modules server/node_modules
|
|
43
|
-
|
|
44
|
-
# The server bundle and the built web app.
|
|
45
|
-
FROM base AS build
|
|
46
|
-
${l}
|
|
47
|
-
RUN ${o.install}
|
|
48
|
-
COPY . .
|
|
49
|
-
RUN ${o.run(`build`)}
|
|
50
|
-
# The generated Prisma client lands beside whichever install holds @prisma/client.
|
|
51
|
-
RUN mkdir -p node_modules/.prisma server/node_modules/.prisma
|
|
52
|
-
|
|
53
|
-
FROM ${F}
|
|
54
|
-
ENV NODE_ENV=production PORT=3000
|
|
55
|
-
WORKDIR /app
|
|
56
|
-
COPY --from=deps /app/node_modules ./node_modules
|
|
57
|
-
COPY --from=deps /app/server/node_modules ./server/node_modules
|
|
58
|
-
COPY --from=build /app/node_modules/.prisma ./node_modules/.prisma
|
|
59
|
-
COPY --from=build /app/server/node_modules/.prisma ./server/node_modules/.prisma
|
|
60
|
-
COPY --from=build /app/package.json ./
|
|
61
|
-
COPY --from=build /app/server/package.json ./server/
|
|
62
|
-
COPY --from=build /app/server/dist ./server/dist
|
|
63
|
-
# SpaAdapter serves ../web/dist relative to the server.
|
|
64
|
-
COPY --from=build /app/web/dist ./web/dist
|
|
65
|
-
WORKDIR /app/server
|
|
66
|
-
USER node
|
|
67
|
-
EXPOSE 3000
|
|
68
|
-
CMD ["node", "dist/index.js"]
|
|
69
|
-
`;let d=e===`inertia`?`# The server, the pages (dist/client) and the SSR bundle (dist/ssr).`:`# The server bundle.`;return`${u}
|
|
70
|
-
FROM ${o.image} AS base
|
|
71
|
-
WORKDIR /app${s}
|
|
72
|
-
|
|
73
|
-
FROM base AS deps
|
|
74
|
-
${c}
|
|
75
|
-
${l}
|
|
76
|
-
RUN ${o.installProd}
|
|
77
|
-
|
|
78
|
-
${d}
|
|
79
|
-
FROM base AS build
|
|
80
|
-
${l}
|
|
81
|
-
RUN ${o.install}
|
|
82
|
-
COPY . .
|
|
83
|
-
RUN ${o.run(`build`)}
|
|
84
|
-
RUN mkdir -p node_modules/.prisma
|
|
85
|
-
|
|
86
|
-
FROM ${F}
|
|
87
|
-
ENV NODE_ENV=production PORT=3000
|
|
88
|
-
WORKDIR /app
|
|
89
|
-
COPY --from=deps /app/node_modules ./node_modules
|
|
90
|
-
# A Prisma client generated into node_modules (empty otherwise).
|
|
91
|
-
COPY --from=build /app/node_modules/.prisma ./node_modules/.prisma
|
|
92
|
-
COPY --from=build /app/package.json ./
|
|
93
|
-
COPY --from=build /app/dist ./dist
|
|
94
|
-
# The image's filesystem is replaced on every deploy. Keep a SQLite file (or
|
|
95
|
-
# uploads) in /app/data and mount a volume there: docker run -v ${n}-data:/app/data
|
|
96
|
-
RUN mkdir -p data && chown node:node data
|
|
97
|
-
USER node
|
|
98
|
-
EXPOSE 3000
|
|
99
|
-
CMD ["node", "dist/index.js"]
|
|
100
|
-
`}function L(){return`${[`# Rebuilt inside the image.`,`**/node_modules`,`**/dist`,`**/.kickjs`,`# Secrets stay out of the image; pass them at run time.`,`**/.env`,`**/.env.*`,`!**/.env.example`,`# Platform and tooling output.`,`.netlify`,`.vercel`,`.git`,`**/coverage`,`*.log`].join(`
|
|
101
|
-
`)}\n`}const se=x(h),R=/[&|<>^"'`(){}[\];!%\r\n\\]/;function z(e,t,n=process.platform){if(n!==`win32`)return[e,t];if(R.test(e)||t.some(e=>R.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 B(e,t,n={}){let r=z(e,t);if(!r)return null;try{return g(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 ce(e,t,n={}){let r=z(e,t);if(!r)throw Error(`Refusing to run '${e}': unsafe arguments`);g(r[0],r[1],{cwd:n.cwd,stdio:`inherit`,windowsHide:!0})}function le(e,t,n){let r=v(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function ue(e,t,n={}){let r=z(e,t);if(!r)return null;try{let{stdout:e}=await se(r[0],r[1],{encoding:`utf-8`,timeout:n.timeout??5e3,cwd:n.cwd,windowsHide:!0});return e.toString().trim()||null}catch{return null}}const de={adapter:`adapters`,middleware:`middlewares`};function fe(e,t,n=e=>e,r=`src/index.ts`){let i={source:e,added:[],present:[],manual:[]};for(let e of t){if(!e.slot||!e.code||e.slot.startsWith(`env-`))continue;let t=de[e.slot],a=n(e.code),o=me(a),s=S(r,i.source).program,c=t?pe(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?V(s,e.import.from,o):o;l&&u&&i.source.slice(l.value.start,l.value.end).includes(`${u}(`)?i.present.push(o??H(a)):(i.source=l?G(i.source,l.value,l.value.elements,a):ve(i.source,c,t,a),e.import&&(i.source=ye(i.source,e.import,r)),i.added.push(o??H(a)))}return i}function pe(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 V(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 me(e){let t=e.split(`
|
|
102
|
-
`).filter(e=>!e.trim().startsWith(`//`)).join(`
|
|
103
|
-
`),n=/^\s*([A-Za-z_$][\w$.]*)\s*\(/.exec(t)?.[1];if(n)return n;for(let e of t.matchAll(/(?<![\w$])([A-Za-z_$][\w$]*)\s*\(/g))if(e[1]!==`import`)return e[1]}const H=e=>e.split(`
|
|
104
|
-
`).find(e=>e.trim()&&!e.trim().startsWith(`//`))?.trim()??e,U=(e,t)=>/^[ \t]*/.exec(e.slice(e.lastIndexOf(`
|
|
105
|
-
`,t-1)+1))[0],W=(e,t)=>e.split(`
|
|
106
|
-
`).map(e=>e&&t+e).join(`
|
|
107
|
-
`);function G(e,t,n,r){let i=n.filter(Boolean),a=U(e,t.start);if(i.length===0){let n=W(`${r},`,`${a} `),[i,o]=t.type===`ObjectExpression`?[`{`,`}`]:[`[`,`]`];return`${e.slice(0,t.start)}${i}\n${n}\n${a}${o}${e.slice(t.end)}`}let o=i.at(-1),s=U(e,o.start),c=e.slice(o.end,t.end-1).match(/^\s*,/),l=c?o.end+c[0].length:o.end,u=`\n${W(`${r},`,s)}`;return c?e.slice(0,l)+u+e.slice(l):`${e.slice(0,l)},${u.replace(/,$/,``)}${e.slice(l)}`}const K=[`zod`,`valibot`,`yup`];function he(e,t,n=`src/config/index.ts`){let r={source:e,added:[],present:[],manual:[]},{lib:i,object:a}=_e(S(n,e).program),o=t.filter(e=>e.slot===`env-${i??`zod`}`&&e.code);if(o.length===0)return r;if(!i||!a)return r.manual.push(...o),r;for(let e of o){let t=ge(e.code),i=_e(S(n,r.source).program).object;i.properties.some(e=>e.type===`Property`&&(e.key?.name??e.key?.value)===t)?r.present.push(t):(r.source=G(r.source,i,i.properties,e.code),r.added.push(t))}return r}const ge=e=>/^\s*['"]?(\w+)['"]?\s*:/m.exec(e)?.[1]??H(e),q=e=>e?.type===`CallExpression`&&e.callee?.type===`MemberExpression`&&e.callee.property?.name===`object`&&e.arguments?.[0]?.type===`ObjectExpression`?e.arguments[0]:void 0;function _e(e){let t=e.body,n=/* @__PURE__ */ new Map;for(let r of K){let i=`from${r[0].toUpperCase()}${r.slice(1)}`;t.some(e=>e.type===`ImportDeclaration`&&e.source.value===`@forinda/kickjs-schema/${r}`&&e.specifiers.some(e=>(e.imported?.name??e.imported?.value)===i))&&n.set(V(e,`@forinda/kickjs-schema/${r}`,i),r)}let r=[],i=[],a=e=>{if(!e||typeof e!=`object`)return;if(Array.isArray(e))return e.forEach(a);let t=e,o=q(t);o&&i.push(o);let s=t.type===`CallExpression`?n.get(t.callee?.name):void 0,c=q(t.arguments?.[0]);s&&c&&r.push({call:t,lib:s,object:c});for(let e in t)a(t[e])};if(a(e),r.length>0){let e=t.find(e=>e.type===`ExportDefaultDeclaration`)?.declaration;if(e?.type===`Identifier`){let n=e.name;e=t.map(e=>e.type===`ExportNamedDeclaration`?e.declaration:e).filter(e=>e?.type===`VariableDeclaration`).flatMap(e=>e.declarations).find(e=>e.id?.name===n)?.init}let{lib:n,object:i}=r.find(t=>t.call===e)??r[0];return{lib:n,object:i}}return{lib:K.find(e=>t.some(t=>t.type===`ImportDeclaration`&&t.source.value===e)),object:i[0]}}function ve(e,t,n,r){let i=t.properties.at(-1),a=i?U(e,i.start):`${U(e,t.start)} `,o=`${a}${n}: [\n${W(`${r},`,`${a} `)}\n${a}],`;if(!i)return`${e.slice(0,t.start)}{\n${o}\n${U(e,t.start)}}${e.slice(t.end)}`;let s=e.slice(i.end,t.end-1).match(/^\s*,/),c=s?i.end+s[0].length:i.end;return`${e.slice(0,c)}${s?``:`,`}\n${o}${e.slice(c)}`}function ye(e,t,n=`src/index.ts`){let r=S(n,e).program.body.filter(e=>e.type===`ImportDeclaration`),i=r.find(e=>e.source.value===t.from&&e.importKind!==`type`&&e.specifiers.length>0&&!e.specifiers.some(e=>e.type===`ImportNamespaceSpecifier`)),a=t.names??[];if(i){let t=new Set(i.specifiers.map(e=>e.local?.name)),n=a.filter(e=>!t.has(e));if(n.length===0)return e;let r=i.specifiers.filter(e=>e.type===`ImportSpecifier`);if(r.length>0){let t=r.at(-1).end;return`${e.slice(0,t)}, ${n.join(`, `)}${e.slice(t)}`}let o=i.specifiers[0];return`${e.slice(0,o.end)}, { ${n.join(`, `)} }${e.slice(o.end)}`}let o=`import ${[t.default,a.length?`{ ${a.join(`, `)} }`:void 0].filter(Boolean).join(`, `)} from '${t.from}'`,s=r.at(-1);return s?`${e.slice(0,s.end)}\n${o}${e.slice(s.end)}`:`${o}\n${e}`}const be={swagger:`feature-swagger`,devtools:`feature-devtools`,ws:`feature-ws`,queue:`feature-queue`,"queue:bullmq":`feature-queue`,storage:`feature-storage`};function xe(e){let t=[...new Set(e.map(e=>be[e]).filter(Boolean))];return t.length>0?T(t):void 0}function Se(e,t){return(t?[t]:[`src/index.ts`,`src/main.ts`]).find(t=>u(o(e,t)))}function Ce(e,t){try{let n=g(`git`,[`ls-files`,`--modified`,`--`,...t],{cwd:e,encoding:`utf-8`,stdio:[`ignore`,`pipe`,`ignore`]});return[...new Set(n.split(`
|
|
108
|
-
`).filter(Boolean))]}catch{return[]}}function we(e){return[`src/config/index.ts`,`src/env.ts`].find(t=>u(o(e,t)))}async function Te(t,n,r){let i=o(t,n),a=d(i,`utf-8`),s=he(a,r,n);return s.source!==a&&await e(i,s.source),s}const J=/\.(?:[cm]?[jt]sx?)$/;function Ee(e,t){return[...t].filter(([t,n])=>{let r=o(e,t);return J.test(t)&&u(r)&&d(r,`utf-8`)!==n}).map(([e])=>e)}async function De(t,n){let r=[],i=[];for(let[a,s]of n){let n=o(t,a);if(!u(n)){await e(n,s),r.push(a);continue}if(J.test(a))continue;let c=d(n,`utf-8`),l=new Set(c.split(`
|
|
109
|
-
`).map(e=>Ae(e)??e)),f=s.split(`
|
|
110
|
-
`).filter(e=>e.trim()&&!l.has(Ae(e)??e));if(f.length===0)continue;let p=c===``||c.endsWith(`
|
|
111
|
-
`)?``:`
|
|
112
|
-
`;await e(n,`${c}${p}${f.join(`
|
|
113
|
-
`)}\n`),i.push(a)}return{created:r,updated:i}}function Oe(e,t,n){let r=e.import?.from;if(!r?.startsWith(`.`))return!1;let i=s.join(s.dirname(t.replaceAll(`\\`,`/`)),r);return n.some(e=>e.replace(J,``)===i)}function ke(e,t){let n=s.dirname(t.replaceAll(`\\`,`/`));return e.map(e=>{let t=e.import?.from;if(!t?.startsWith(`.`))return e;let r=s.relative(n,s.join(`src`,t));return{...e,import:{...e.import,from:r.startsWith(`.`)?r:`./${r}`}}})}const Ae=e=>/^\s*([A-Za-z_][\w]*)\s*=/.exec(e)?.[1];async function je(t,n,r){let i=o(t,n),a=d(i,`utf-8`),s=fe(a,r,Me(t),n);return s.source!==a&&await e(i,s.source),s}function Me(e){let t=Ne(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 Ne(e){try{return JSON.parse(d(o(e,`package.json`),`utf-8`))}catch{return{}}}function Pe(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(`
|
|
114
|
-
`)}const Y={kickjs:{pkg:`@forinda/kickjs`,peers:[],enginePeers:!0,description:`Unified framework: DI, decorators, routing, middleware`,core:!0},vite:{pkg:`@forinda/kickjs-vite`,peers:[`vite`],description:`Vite plugin: dev server, HMR, module discovery`,dev:!0,core:!0},cli:{pkg:`@forinda/kickjs-cli`,peers:[],description:`CLI tool and code generators`,dev:!0,core:!0},zod:{pkg:`zod`,peers:[],description:`Zod schema validation (env, DTOs, OpenAPI) — wrap with fromZod()`},valibot:{pkg:`valibot`,peers:[],description:`Valibot schema validation — wrap with fromValibot()`},yup:{pkg:`yup`,peers:[],description:`Yup schema validation — wrap with fromYup()`},ai:{pkg:`@forinda/kickjs-ai`,peers:[`zod`],description:`AI toolkit — LLM providers, tool definitions from controllers`},storage:{pkg:`@forinda/kickjs-storage`,peers:[],description:`File storage — memory, disk, S3-compatible buckets, signed URLs`},swagger:{pkg:`@forinda/kickjs-swagger`,peers:[],description:`OpenAPI spec + Swagger UI + ReDoc`,builds:{"@scarf/scarf":!0}},db:{pkg:`@forinda/kickjs-db`,peers:[],description:`kick/db core — schema DSL, migrations, KickDbClient, customType`},pg:{pkg:`@forinda/kickjs-db`,peers:[`pg`],typePeers:[`@types/pg`],description:`kick/db + PostgreSQL driver (use @forinda/kickjs-db/pg)`},sqlite:{pkg:`@forinda/kickjs-db`,peers:[`better-sqlite3`],builds:{"better-sqlite3":!0},typePeers:[`@types/better-sqlite3`],description:`kick/db + SQLite driver (use @forinda/kickjs-db/sqlite)`},mysql:{pkg:`@forinda/kickjs-db`,peers:[`mysql2`],description:`kick/db + MySQL driver (use @forinda/kickjs-db/mysql)`},ws:{pkg:`@forinda/kickjs-ws`,peers:[`ws`],description:`WebSocket with @WsController decorators`},devtools:{pkg:`@forinda/kickjs-devtools`,peers:[],description:`Development dashboard — routes, DI, metrics, health`,dev:!0},queue:{pkg:`@forinda/kickjs-queue`,peers:[],description:`Queue adapter (BullMQ/RabbitMQ/Kafka)`},"queue:bullmq":{pkg:`@forinda/kickjs-queue`,peers:[`bullmq`,`ioredis`],builds:{"msgpackr-extract":!1},description:`Queue with BullMQ + Redis`},"queue:rabbitmq":{pkg:`@forinda/kickjs-queue`,peers:[`amqplib`],description:`Queue with RabbitMQ`},"queue:kafka":{pkg:`@forinda/kickjs-queue`,peers:[`kafkajs`],description:`Queue with Kafka`},"queue:redis-pubsub":{pkg:`@forinda/kickjs-queue`,peers:[`ioredis`],description:`Lightweight pub/sub via Redis (no persistence)`},mcp:{pkg:`@forinda/kickjs-mcp`,peers:[`@modelcontextprotocol/server`],description:`Model Context Protocol server — expose @Controller endpoints as AI tools`},testing:{pkg:`@forinda/kickjs-testing`,peers:[],description:`Test utilities and TestModule builder`,dev:!0}},Fe=Object.entries(Y).filter(([e,t])=>!t.core&&!t.deprecated&&!e.includes(`:`)&&![`pg`,`sqlite`,`mysql`,`zod`,`valibot`,`yup`].includes(e)).map(([e])=>e).concat(`upload`).join(`, `),Ie={express:[`express`],fastify:[`fastify`,`@fastify/middie`,`serve-static`],h3:[`h3@^2`,`serve-static`]},Le={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 X(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 Z(e=process.cwd()){return(await Re(e)).runtime}async function Re(e=process.cwd()){let t=(await i(e))?.runtime;return t===`express`||t===`fastify`||t===`h3`?{runtime:t,candidates:[t],ambiguous:!1,fromConfig:!0}:{...Be(e),fromConfig:!1}}const ze=[[`express`,`express`],[`fastify`,`fastify`],[`h3`,`h3`]];function Be(e=process.cwd()){let t=Ve(`package.json`,e);if(!t)return{runtime:`express`,candidates:[],ambiguous:!1};let n={},r={};try{let e=JSON.parse(d(c(t,`package.json`),`utf-8`));n=e.dependencies??{},r=e.devDependencies??{}}catch{return{runtime:`express`,candidates:[],ambiguous:!1}}let i=ze.filter(([e])=>e in n).map(([,e])=>e),a=ze.filter(([e])=>e in r&&!(e in n)).map(([,e])=>e),o=[...i,...a];return i.length===1?{runtime:i[0],candidates:o,ambiguous:!1}:i.length===0&&a.length===1?{runtime:a[0],candidates:o,ambiguous:!1}:o.length===0?{runtime:`express`,candidates:o,ambiguous:!1}:{runtime:`express`,candidates:o,ambiguous:!0}}function Ve(e,t=process.cwd()){let n=t;for(;;){if(u(c(n,e)))return n;let t=a(n);if(t===n)return null;n=t}}function He(e=!1,t){let n=Object.entries(Y),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,...Ie[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(`
|
|
115
|
-
Core packages (always installed by \`kick new\`):
|
|
116
|
-
`);for(let e of i)console.log(o(e));if(e){console.log(`
|
|
117
|
-
Optional packages (add as needed):
|
|
118
|
-
`);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(`
|
|
119
|
-
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 Ue={"@swc/core":!0,esbuild:!0};function Q(e,t,n){if(e===`pnpm`){let e=c(t,`pnpm-workspace.yaml`),r=u(e)?d(e,`utf-8`):``,i=re(r,n);return i===r?void 0:(m(e,i),e)}if(e!==`npm`&&e!==`bun`)return;let r=c(t,`package.json`);if(!u(r))return;let i=JSON.parse(d(r,`utf-8`)),a=!1;if(e===`npm`){let e=i.allowScripts??{};for(let[t,r]of Object.entries(n))Object.keys(e).some(e=>e===t||e.startsWith(`${t}@`))||(e[t]=r,a=!0);i.allowScripts=e}else{let e=i.trustedDependencies??[];for(let[t,r]of Object.entries(n))r&&!e.includes(t)&&(e.push(t),a=!0);i.trustedDependencies=e}if(a)return m(r,`${JSON.stringify(i,null,2)}\n`),r}function We(e){if(e===`pnpm`)return Ve(`pnpm-workspace.yaml`)??process.cwd();for(let e=process.cwd();;e=a(e)){try{if(JSON.parse(d(c(e,`package.json`),`utf-8`)).workspaces)return e}catch{}if(a(e)===e)return process.cwd()}}function $(e){return Object.assign({},...e.map(e=>Y[e]?.builds??{}))}function Ge(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=Le[n];s.push(`upload (${n}): ${e.note}`),e.prod&&(t?i:r).add(e.prod),e.dev&&i.add(e.dev);continue}let e=Y[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=Ie[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 Ke(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=>{He(!!e.all,X(e.runtime)??await Z())})}function qe(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,n)=>{if(n.list||e.length===0){He(!!n.all,X(n.runtime)??await Z());return}let{pm:r,source:i}=await t(n.pm);console.log(`\n Using ${r} (resolved from ${i})`);let a=X(n.runtime),o=await Re(process.cwd()),s=a??o.runtime;if(!a&&o.ambiguous){console.error(`\n Cannot tell which HTTP engine this app boots on: found ${o.candidates.join(`, `)} in package.json.\n\n Installing engine peers for the wrong one is worse than not installing them, so:\n • set \`runtime: '<engine>'\` in kick.config.ts (permanent, also fixes kick doctor), or\n • pass --runtime <${o.candidates.join(`|`)}> for this command\n`),process.exitCode=1;return}let l=Ge(e,!!n.dev,s),{unknown:d,warnings:f,notices:p}=l,{prodDeps:m,devDeps:h}=l,g=process.cwd();if(n.entry&&!u(c(g,n.entry))){console.error(`\n --entry ${n.entry} does not exist.\n`),process.exitCode=1;return}let v=n.wire===!1?void 0:xe(e),y=v?Se(g,n.entry):void 0;v&&y&&(v.integrations=ke(v.integrations,y));let b=v?.integrations.filter(e=>e.slot?.startsWith(`env-`))??[],x=b.length>0?we(g):void 0;if(v){m=[.../* @__PURE__ */ new Set([...m,...v.dependencies])],h=[...new Set([...h,...v.devDependencies].filter(e=>!m.includes(e)))];let e=Ce(g,[...y?[y]:[],...x?[x]:[],...v.files.keys()]);if(e.length>0&&!n.force){console.error(`\n ${e.join(`, `)} ${e.length===1?`has`:`have`} uncommitted changes, and kick add would edit ${e.length===1?`it`:`them`}.\n Commit, stage (git add) or stash them first, rerun with --force to edit anyway, or with --no-wire to install only.\n`),process.exitCode=1;return}}for(let e of f)console.warn(`\n WARNING: ${e}`);for(let e of p)console.log(`\n ${e}`);if(d.length>0&&(console.log(`\n Unknown packages: ${d.join(`, `)}`),console.log(` Run "kick add --list" to see available packages.
|
|
120
|
-
`),m.length===0&&h.length===0))return;let S={...$(e),...v?.builds};if(Object.keys(S).length>0){let e=Q(r,We(r),S);e&&console.log(`\n Approved install scripts in ${e}`)}let C=!0;if(m.length>0){let e=m,t=`${r} add ${e.join(` `)}`;console.log(`\n Installing ${e.length} dependency(ies):`);for(let t of e)console.log(` + ${t}`);console.log();try{_(t,{stdio:`inherit`})}catch{C=!1,console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(h.length>0){let e=h,t=`${r} 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{_(t,{stdio:`inherit`})}catch{C=!1,console.log(`\n Installation failed. Run manually:\n ${t}\n`)}}if(v){if(!C)console.log(` Skipped wiring — the install did not finish.
|
|
121
|
-
`);else{let e=Ee(g,v.files),{created:t,updated:n}=await De(g,v.files);for(let e of t)console.log(` Created ${e}`);for(let e of n)console.log(` Updated ${e}`);let r=y?v.integrations.filter(t=>Oe(t,y,e)):[],i=v.integrations.filter(e=>!r.includes(e)),a=y?await je(g,y,i):void 0;for(let e of a?.added??[])console.log(` Added ${e} to ${y}`);for(let e of a?.present??[])console.log(` ${e} is already in ${y}`);let o=x?await Te(g,x,b):void 0;o?.added.length&&console.log(` Declared ${o.added.join(`, `)} in ${x}`);let s=o?o.manual:b.filter(e=>e.slot===`env-zod`);s.length>0&&(console.log(`\n ${x?`Could not find the env schema object in ${x}`:`No env schema (src/config/index.ts) found`} — declare these keys in it yourself:
|
|
122
|
-
`),console.log(s.map(e=>`${e.code},`).join(`
|
|
123
|
-
`).replace(/^/gm,` `)),console.log());let c=Me(g),l=a?a.manual:v.integrations.filter(e=>e.slot&&e.code&&!e.slot.startsWith(`env-`)).map(e=>({...e,code:c(e.code)}));if(e.length>0){let t=r.map(e=>({...e,code:c(e.code??``)}));console.log(`\n ${e.join(`, `)} already exist${e.length===1?`s`:``} — left as ${e.length===1?`it is`:`they are`}. Merge in what the layer needs, then wire it yourself:
|
|
124
|
-
`),console.log(`${Pe(t)}`.replace(/^/gm,` `)),console.log()}l.length>0&&(console.log(`\n ${y?`Could not find bootstrap({ adapters: [...] }) in ${y}`:`No entry file found`} — add this yourself:
|
|
125
|
-
`),console.log(Pe(l).replace(/^/gm,` `)),console.log())}}C?console.log(` Done!
|
|
126
|
-
`):(console.log(` Finished with errors — the install above did not complete.
|
|
127
|
-
`),process.exitCode=1)})}const Je=a(b(import.meta.url));function Ye(e){return{kick:n(e,`kick`),runDev:r(e,`dev`),runBuild:r(e,`build`),runStart:r(e,`start`),runTest:r(e,`test`)}}const Xe=JSON.parse(d([o(Je,`..`,`package.json`),o(Je,`..`,`..`,`package.json`)].find(u),`utf-8`)),Ze=[`@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`],Qe={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(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 et(e){return e===`@forinda/kickjs-cli`?`^${Xe.version}`:`latest`}async function tt(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 nt(){let e=[...Ze.map(e=>({name:e,fallback:et(e),cap:void 0})),...Object.entries(Qe).map(([e,t])=>({name:e,...t}))],t=Date.now()+2e4,n=await tt(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=$e(await ue(`npm`,r?[`view`,a,`version`,`--json`]:[`view`,a,`version`],{timeout:i}));return[e,o?`^${o}`:n]});return Object.fromEntries(n)}function rt(e,t){let n=B(`npm`,[`view`,`${e}@${t}`,`version`],{timeout:2e4});return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}function it(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function at(e,t){let n=e=>it(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 ot(e,t,n){let r=B(`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 st(t){let{name:i,directory:a,packageManager:s=`pnpm`,template:c=`rest`,defaultRepo:l=`inmemory`,packages:d=[],schemaLib:f=`zod`,runtime:p=`express`}=t,m=a,h=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${i}\n`),t.versions||h(`Resolving package versions...`);let g=t.versions??await nt(),v=Object.keys(g).filter(e=>g[e]===`latest`);if(v.length>0&&h(`WARNING: could not reach npm for ${v.join(`, `)} — pinned to 'latest'`),p!==`express`){if(ot(`@forinda/kickjs`,`latest`,`./${p}`))h(`Using @forinda/kickjs@latest (stable ships the ${p} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=rt(r,`alpha`);e&&at(e,it(g[r]))&&(g[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}h(n?`Using the alpha channel for the ${p} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${p} runtime subpath may be missing. After install, run: ${s} add @forinda/kickjs@alpha`)}}let b=d.filter(e=>!u(o(w,`feature-${e}`)));b.length>0&&h(`WARNING: skipping unknown package(s): ${b.join(`, `)} — add them later with kick add`);let x=T([...ut({template:c,runtime:p,schemaLib:f,packages:d}),...t.platformConfig===!1?[]:[`host-config`],...t.extraLayers??[]],{vars:{name:i,version:Xe.version},extra:[{slot:`repo`,code:l===`inmemory`?`repo: 'inmemory'`:`repo: { name: '${l.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}' }`},...t.spaClientDir?[lt(t.spaClientDir)]:[]]}),S=t.platformConfig===!1?void 0:M(s);await e(o(m,`package.json`),ne(i,g,x,S));let C=P(s,S);C&&await e(o(m,`.yarnrc.yml`),C);let ee=te(x.files,{name:i,template:c,runtime:p,packageManager:s,...Ye(s),netlifyPublish:c===`inertia`?`dist/client`:`dist/public`,templateLabel:{rest:`REST API`,minimal:`Minimal`,inertia:`Inertia (React)`}[c],sessionSecret:y(32).toString(`hex`),packages:[...x.dependencies,...x.devDependencies].filter(e=>e.startsWith(`@forinda/`)).map(e=>`- \`${e}\``).join(`
|
|
128
|
-
`)});for(let[t,n]of ee)await e(o(m,t),n);if(t.platformConfig!==!1){let t=c===`inertia`?`inertia`:`api`;await e(o(m,`Dockerfile`),oe(t,s,i,S)),await e(o(m,`.dockerignore`),L())}let{generateAgentDocs:E}=await import(`./agent-docs-DZJSoa_5.mjs`).then(e=>e.t);await E({outDir:m,name:i,pm:s,template:c,only:`all`,force:!0});let D={...Ue,...$(d),...x.builds};if(t.approveInstallScripts!==!1&&Q(s,m,D),t.installDeps){console.log(`\n Installing dependencies with ${s}...\n`);try{_(`${s} install`,{cwd:m,stdio:`inherit`}),console.log(`
|
|
129
|
-
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${s} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-C13eMf8Q.mjs`).then(e=>e.n);await e({cwd:m,allowDuplicates:!0,silent:!0})}catch{}if(t.initGit)try{_(`git init`,{cwd:m,stdio:`pipe`}),_(`git branch -M main`,{cwd:m,stdio:`pipe`}),_(`git add -A`,{cwd:m,stdio:`pipe`}),_(`git commit -m "chore: initial commit from kick new"`,{cwd:m,stdio:`pipe`}),h(`Git repository initialized`)}catch{h(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
130
|
-
Project scaffolded successfully!`),console.log();let O=m!==process.cwd();h(`Next steps:`),O&&h(` cd ${i}`),t.installDeps||h(` ${s} install`);let k=n(s,`kick`),A={rest:`${k} g module user`,minimal:`# add your routes to src/index.ts`,inertia:`# pages: src/modules/pages + src/client/pages`};h(` ${A[c]??A.rest}`),h(` ${r(s,`dev`)}`);let j=e=>{let t=Math.max(...e.map(([e])=>e.length))+2;for(let[n,r]of e)h(` ${n.padEnd(t)}${r}`)};return h(``),h(`Commands:`),j([[r(s,`dev`),`Start dev server with Vite HMR`],[r(s,`build`),`Production build via Vite`],[r(s,`start`),`Run production build`]]),h(``),h(`Generators:`),j([[`${k} g module <name>`,`REST module (controller, service, DTOs, repository)`],[`${k} g scaffold <n> <f..>`,`CRUD module from field definitions`],[`${k} g controller <name>`,`Standalone controller`],[`${k} g service <name>`,`@Service() class`],[`${k} g middleware <name>`,`Global connect-style middleware`],[`${k} g guard <name>`,`Route guard (auth, roles, etc.)`],[`${k} g adapter <name>`,`AppAdapter with lifecycle hooks`],[`${k} g dto <name>`,`DTO schema (Zod / Valibot / Yup)`],[`${k} g config`,`Generate kick.config.ts`]]),h(``),h(`Add packages:`),j([[`${k} add <pkg>`,`Install a KickJS package + peers`],[`${k} add --list`,`Show all available packages`]]),h(``),h(`Available: ${Fe}`),h(``),{builds:D}}const ct=e=>`'${JSON.stringify(e).slice(1,-1).replaceAll(`\\"`,`"`).replaceAll(`'`,`\\'`)}'`;function lt(e){return{import:{from:`@forinda/kickjs/spa`,names:[`SpaAdapter`]},slot:`adapter`,code:`// Serves the built frontend from this origin in production.
|
|
131
|
-
// Inert until the client build exists, so \`kick dev\` (where Vite
|
|
132
|
-
// serves the client and proxies /api here) is unaffected.
|
|
133
|
-
SpaAdapter({ clientDir: ${ct(e)} })`}}function ut(e){return[`base`,`template-${e.template}`,`runtime-${e.runtime}`,`schema-${e.schemaLib}`,...e.packages.filter(e=>u(o(w,`feature-${e}`))).map(e=>`feature-${e}`)]}export{Q as a,Z as c,oe as d,L as f,T as g,te as h,Le as i,ce as l,P as m,nt as n,qe as o,M as p,Y as r,Ke as s,st as t,le as u};
|
|
134
|
-
//# sourceMappingURL=project-BktC0yLE.mjs.map
|