@forinda/kickjs-cli 6.4.0 → 6.5.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-Xlt6Fk-e.mjs +12 -0
- package/dist/{agent-docs-lDM1Nx6J.mjs.map → agent-docs-Xlt6Fk-e.mjs.map} +1 -1
- package/dist/{build-CBRWV98i.mjs → build-RlkRhDyM.mjs} +3 -3
- package/dist/{build-CBRWV98i.mjs.map → build-RlkRhDyM.mjs.map} +1 -1
- package/dist/{builtins-1-t8nFZe.mjs → builtins-Ce5uoK6s.mjs} +2 -2
- package/dist/cli.mjs +12 -8
- package/dist/{config-C6Na808n.mjs → config-xEbwXlmo.mjs} +3 -3
- package/dist/{config-C6Na808n.mjs.map → config-xEbwXlmo.mjs.map} +1 -1
- package/dist/doctor-DCFgdlJ3.mjs +860 -0
- package/dist/doctor-DCFgdlJ3.mjs.map +1 -0
- package/dist/fullstack-iuAdYQmC.mjs +137 -0
- package/dist/fullstack-pPl60src.mjs +138 -0
- package/dist/fullstack-pPl60src.mjs.map +1 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/{plugin-DlIRWEfP.mjs → plugin-B_40AQRr.mjs} +3 -3
- package/dist/{plugin-DlIRWEfP.mjs.map → plugin-B_40AQRr.mjs.map} +1 -1
- package/dist/project-D_8okjEO.mjs +390 -0
- package/dist/project-D_8okjEO.mjs.map +1 -0
- package/dist/{project-docs-Dr75Phev.mjs → project-docs-MYPeTYsJ.mjs} +9 -9
- package/dist/project-docs-MYPeTYsJ.mjs.map +1 -0
- package/dist/{project-root-BKYv-vPf.mjs → project-root-CWcfpTV4.mjs} +3 -3
- package/dist/{project-root-BKYv-vPf.mjs.map → project-root-CWcfpTV4.mjs.map} +1 -1
- package/dist/prompts-D0mIvDKz.mjs +12 -0
- package/dist/prompts-D0mIvDKz.mjs.map +1 -0
- package/dist/{rolldown-runtime-DLwMHNw-.mjs → rolldown-runtime-wP2RwkAN.mjs} +1 -1
- package/dist/{run-plugins-DaN0MHlX.mjs → run-plugins-USrmMITe.mjs} +53 -53
- package/dist/run-plugins-USrmMITe.mjs.map +1 -0
- package/dist/{typegen-DJGvcWVf.mjs → typegen-Do1rVRd1.mjs} +5 -5
- package/dist/{typegen-DJGvcWVf.mjs.map → typegen-Do1rVRd1.mjs.map} +1 -1
- package/dist/{types-CmiWgylI.mjs → types-CjDOGs_1.mjs} +1 -1
- package/package.json +1 -1
- package/dist/agent-docs-lDM1Nx6J.mjs +0 -12
- package/dist/doctor-DlWMC_2O.mjs +0 -1234
- package/dist/doctor-DlWMC_2O.mjs.map +0 -1
- package/dist/project-docs-Dr75Phev.mjs.map +0 -1
- package/dist/run-plugins-DaN0MHlX.mjs.map +0 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-cli v6.5.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Felix Orinda
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
import{l as e}from"./project-docs-MYPeTYsJ.mjs";import{n as t,t as n}from"./project-D_8okjEO.mjs";import{join as r}from"node:path";import{execFileSync as i}from"node:child_process";async function a(a){let{name:_,directory:v,schemaLib:y=`zod`,runtime:b=`express`}=a,x=[`pnpm`,`npm`,`yarn`,`bun`].includes(a.packageManager),S=x?a.packageManager:`pnpm`,C=v,w=e=>console.log(` ${e}`);a.packageManager!==void 0&&!x&&w(`Warning: unknown package manager '${String(a.packageManager)}' — falling back to pnpm.`),console.log(`\n Creating fullstack KickJS workspace: ${_}\n`),await n({name:`${_}-server`,directory:r(C,`server`),packageManager:S,template:`minimal`,schemaLib:y,runtime:b,initGit:!1,installDeps:!1});let T=(await t())[`@forinda/kickjs-client`]??`^0.1.0`;if(await e(r(C,`web/package.json`),o(_,T)),await e(r(C,`web/vite.config.ts`),s()),await e(r(C,`web/tsconfig.json`),c()),await e(r(C,`web/index.html`),l(_)),await e(r(C,`web/src/main.tsx`),u()),await e(r(C,`web/src/App.tsx`),d()),await e(r(C,`web/src/api.ts`),f()),await e(r(C,`web/src/types/kick-routes.d.ts`),p()),await e(r(C,`package.json`),m(_,S)),await e(r(C,`pnpm-workspace.yaml`),`packages:
|
|
12
|
+
- server
|
|
13
|
+
- web
|
|
14
|
+
`),await e(r(C,`.gitignore`),h()),await e(r(C,`README.md`),g(_,S)),a.installDeps){console.log(`\n Installing workspace dependencies with ${S}...\n`);try{i(S,[`install`],{cwd:C,stdio:`inherit`})}catch{console.log(`\n Warning: ${S} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-Do1rVRd1.mjs`).then(e=>e.n);await e({cwd:r(C,`server`),allowDuplicates:!0,silent:!0})}catch{}if(a.initGit)try{i(`git`,[`init`],{cwd:C,stdio:`pipe`}),i(`git`,[`branch`,`-M`,`main`],{cwd:C,stdio:`pipe`}),i(`git`,[`add`,`-A`],{cwd:C,stdio:`pipe`}),i(`git`,[`commit`,`-m`,`chore: initial commit from kick new (fullstack)`],{cwd:C,stdio:`pipe`}),w(`Git repository initialized`)}catch{w(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
15
|
+
Fullstack workspace scaffolded!`),console.log(),w(`Next steps:`),w(` cd ${_}`),a.installDeps||w(` ${S} install`),S===`pnpm`?w(` pnpm dev # runs server (kick dev) + web (vite) together`):(w(` ${S} run dev:server # terminal 1`),w(` ${S} run dev:web # terminal 2`)),w(``),w(`The web app calls the API through @forinda/kickjs-client —`),w(`edit server/src/modules/hello and watch web/src/App.tsx's types follow.`),w(``)}function o(e,t){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":t,react:`^19.0.0`,"react-dom":`^19.0.0`},devDependencies:{"@types/react":`^19.0.0`,"@types/react-dom":`^19.0.0`,"@vitejs/plugin-react":`^5.0.0`,typescript:`^5.9.0`,vite:`^7.0.0`}},null,2)}\n`}function s(){return`import { defineConfig } from 'vite'
|
|
16
|
+
import react from '@vitejs/plugin-react'
|
|
17
|
+
|
|
18
|
+
export default defineConfig({
|
|
19
|
+
plugins: [react()],
|
|
20
|
+
server: {
|
|
21
|
+
// The KickJS server (kick dev) listens on 3000; the client's baseUrl is
|
|
22
|
+
// the relative '/api/v1', so the browser hits Vite and Vite forwards.
|
|
23
|
+
proxy: {
|
|
24
|
+
'/api': 'http://localhost:3000',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
`}function c(){return`${JSON.stringify({compilerOptions:{target:`ES2022`,lib:[`ES2022`,`DOM`,`DOM.Iterable`],module:`ESNext`,moduleResolution:`bundler`,jsx:`react-jsx`,strict:!0,skipLibCheck:!0,noEmit:!0,isolatedModules:!0,experimentalDecorators:!0,types:[]},include:[`src`]},null,2)}\n`}function l(e){return`<!doctype html>
|
|
29
|
+
<html lang="en">
|
|
30
|
+
<head>
|
|
31
|
+
<meta charset="UTF-8" />
|
|
32
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
33
|
+
<title>${e}</title>
|
|
34
|
+
</head>
|
|
35
|
+
<body>
|
|
36
|
+
<div id="root"></div>
|
|
37
|
+
<script type="module" src="/src/main.tsx"><\/script>
|
|
38
|
+
</body>
|
|
39
|
+
</html>
|
|
40
|
+
`}function u(){return`import { StrictMode } from 'react'
|
|
41
|
+
import { createRoot } from 'react-dom/client'
|
|
42
|
+
import { App } from './App'
|
|
43
|
+
|
|
44
|
+
createRoot(document.getElementById('root')!).render(
|
|
45
|
+
<StrictMode>
|
|
46
|
+
<App />
|
|
47
|
+
</StrictMode>,
|
|
48
|
+
)
|
|
49
|
+
`}function d(){return`import { useEffect, useState } from 'react'
|
|
50
|
+
import { api } from './api'
|
|
51
|
+
|
|
52
|
+
// The response types below are INFERRED from the server's handlers —
|
|
53
|
+
// change server/src/modules/hello/hello.service.ts and these types follow
|
|
54
|
+
// on the next \`kick typegen\` (automatic under \`kick dev\`).
|
|
55
|
+
type Greeting = Awaited<ReturnType<typeof fetchGreeting>>
|
|
56
|
+
|
|
57
|
+
function fetchGreeting() {
|
|
58
|
+
return api.get('/hello')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function App() {
|
|
62
|
+
const [greeting, setGreeting] = useState<Greeting | null>(null)
|
|
63
|
+
const [health, setHealth] = useState<string>('checking…')
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
fetchGreeting().then(setGreeting).catch(console.error)
|
|
67
|
+
api
|
|
68
|
+
.get('/hello/health')
|
|
69
|
+
.then((h) => setHealth(h.status))
|
|
70
|
+
.catch(() => setHealth('down'))
|
|
71
|
+
}, [])
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<main style={{ fontFamily: 'system-ui', maxWidth: 640, margin: '4rem auto', padding: '0 1rem' }}>
|
|
75
|
+
<h1>KickJS fullstack</h1>
|
|
76
|
+
<p>
|
|
77
|
+
<strong>{greeting?.message ?? 'loading…'}</strong>
|
|
78
|
+
</p>
|
|
79
|
+
<p>
|
|
80
|
+
Server said hello at <code>{greeting?.timestamp ?? '…'}</code> — health:{' '}
|
|
81
|
+
<code>{health}</code>
|
|
82
|
+
</p>
|
|
83
|
+
<p style={{ color: '#666' }}>
|
|
84
|
+
This call is typed end to end: <code>api.get('/hello')</code> returns the exact shape
|
|
85
|
+
<code> HelloService.greet()</code> produces. Rename a field on the server and this file
|
|
86
|
+
stops compiling.
|
|
87
|
+
</p>
|
|
88
|
+
</main>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
`}function f(){return`import { createClient } from '@forinda/kickjs-client'
|
|
92
|
+
|
|
93
|
+
// KickRoutes.Api is ambient — populated by server/.kickjs/types (see
|
|
94
|
+
// src/types/kick-routes.d.ts). Keys are module-mount-relative paths;
|
|
95
|
+
// the bootstrap-level '/api/v1' prefix lives here in baseUrl, and the
|
|
96
|
+
// Vite dev proxy forwards it to the KickJS server.
|
|
97
|
+
export const api = createClient<KickRoutes.Api>({ baseUrl: '/api/v1' })
|
|
98
|
+
`}function p(){return`// Type-only bridge to the server's generated route types. The import is
|
|
99
|
+
// erased at build time — no server code ever enters the web bundle.
|
|
100
|
+
// Regenerate with \`kick typegen\` in server/ (automatic under \`kick dev\`).
|
|
101
|
+
import '../../../server/.kickjs/types/kick__routes'
|
|
102
|
+
`}function m(e,t){let n=t===`pnpm`?{dev:`pnpm --parallel -r run dev`,"dev:server":`pnpm --filter ./server dev`,"dev:web":`pnpm --filter ./web dev`,build:`pnpm -r run build`,typecheck:`pnpm -r run typecheck`}:{"dev:server":`cd server && ${t} run dev`,"dev:web":`cd web && ${t} run dev`,build:`${t} run build:server && ${t} run build:web`,"build:server":`cd server && ${t} run build`,"build:web":`cd web && ${t} run build`,typecheck:`cd web && ${t} run typecheck`};return`${JSON.stringify({name:e,private:!0,version:`0.0.0`,type:`module`,scripts:n,workspaces:[`server`,`web`]},null,2)}\n`}function h(){return`node_modules/
|
|
103
|
+
dist/
|
|
104
|
+
.env
|
|
105
|
+
*.log
|
|
106
|
+
.DS_Store
|
|
107
|
+
`}function g(e,t){return`# ${e}
|
|
108
|
+
|
|
109
|
+
Fullstack KickJS workspace — typed end to end.
|
|
110
|
+
|
|
111
|
+
| Package | What |
|
|
112
|
+
| --------- | ----------------------------------------------------------------- |
|
|
113
|
+
| \`server/\` | KickJS API (decorators, DI, \`kick dev\` with typegen watch) |
|
|
114
|
+
| \`web/\` | Vite + React, typed against the API via \`@forinda/kickjs-client\` |
|
|
115
|
+
|
|
116
|
+
## Develop
|
|
117
|
+
|
|
118
|
+
\`\`\`bash
|
|
119
|
+
${t} install
|
|
120
|
+
${t===`pnpm`?`pnpm dev # server (kick dev) + web (vite), in parallel`:`${t} run dev:server # terminal 1\n${t} run dev:web # terminal 2`}
|
|
121
|
+
\`\`\`
|
|
122
|
+
|
|
123
|
+
Server: http://localhost:3000 · Web: http://localhost:5173 (Vite proxies \`/api\`).
|
|
124
|
+
|
|
125
|
+
## The type loop
|
|
126
|
+
|
|
127
|
+
1. Server handlers **return** their payloads (\`return this.service.greet(...)\`).
|
|
128
|
+
2. \`kick typegen\` (auto under \`kick dev\`) emits \`server/.kickjs/types/kick__routes.ts\` —
|
|
129
|
+
including the flat \`KickRoutes.Api\` map with inferred response types.
|
|
130
|
+
3. \`web/src/types/kick-routes.d.ts\` imports that file type-only.
|
|
131
|
+
4. \`web/src/api.ts\`'s \`createClient<KickRoutes.Api>\` types every call site.
|
|
132
|
+
|
|
133
|
+
Rename a field in \`server/src/modules/hello/hello.service.ts\` → \`web/src/App.tsx\`
|
|
134
|
+
stops compiling. That's the point.
|
|
135
|
+
|
|
136
|
+
Docs: https://kickjs.app/guide/typed-client.html
|
|
137
|
+
`}export{a as initFullstackProject};
|
|
138
|
+
//# sourceMappingURL=fullstack-pPl60src.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fullstack-pPl60src.mjs","names":[],"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 KickRoutes.Api\n//\n// The type loop: server controllers use return-value handlers → `kick\n// typegen` (run here once, re-run by `kick dev`) emits\n// server/.kickjs/types/kick__routes.ts → web/src/types/kick-routes.d.ts\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 { initProject, resolveSiblingVersions } from './project'\n\nexport interface InitFullstackOptions {\n name: string\n directory: string\n packageManager?: 'pnpm' | 'npm' | 'yarn' | 'bun'\n initGit?: boolean\n installDeps?: boolean\n schemaLib?: 'zod' | 'valibot' | 'yup'\n runtime?: 'express' | 'fastify' | 'h3'\n}\n\nexport async function initFullstackProject(options: InitFullstackOptions): Promise<void> {\n const { name, directory, schemaLib = 'zod', runtime = 'express' } = 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 // ── server/ — the standard scaffold, deferred install/git ──────────\n await initProject({\n name: `${name}-server`,\n directory: join(dir, 'server'),\n packageManager,\n template: 'minimal',\n schemaLib,\n runtime,\n // Root owns install + git so the lockfile/commit cover the workspace.\n initGit: false,\n installDeps: false,\n })\n\n // ── web/ — Vite + React, typed client ──────────────────────────────\n const versions = await resolveSiblingVersions()\n const clientVersion = versions['@forinda/kickjs-client'] ?? '^0.1.0'\n\n await writeFileSafe(join(dir, 'web/package.json'), webPackageJson(name, clientVersion))\n await writeFileSafe(join(dir, 'web/vite.config.ts'), webViteConfig())\n await writeFileSafe(join(dir, 'web/tsconfig.json'), webTsConfig())\n await writeFileSafe(join(dir, 'web/index.html'), webIndexHtml(name))\n await writeFileSafe(join(dir, 'web/src/main.tsx'), webMain())\n await writeFileSafe(join(dir, 'web/src/App.tsx'), webApp())\n await writeFileSafe(join(dir, 'web/src/api.ts'), webApi())\n await writeFileSafe(join(dir, 'web/src/types/kick-routes.d.ts'), webRouteTypes())\n\n // ── workspace root ──────────────────────────────────────────────────\n await writeFileSafe(join(dir, 'package.json'), rootPackageJson(name, packageManager))\n await writeFileSafe(join(dir, 'pnpm-workspace.yaml'), `packages:\\n - server\\n - web\\n`)\n await writeFileSafe(join(dir, '.gitignore'), rootGitignore())\n await writeFileSafe(join(dir, 'README.md'), rootReadme(name, packageManager))\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 execFileSync(packageManager, ['install'], { cwd: dir, stdio: 'inherit' })\n } catch {\n console.log(`\\n Warning: ${packageManager} install failed. Run it manually.`)\n }\n }\n\n // ── typegen (server) so web's KickRoutes.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 dev` in server/ retries on boot.\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 log('The web app calls the API through @forinda/kickjs-client —')\n log(\"edit server/src/modules/hello and watch web/src/App.tsx's types follow.\")\n log('')\n}\n\n// ── web templates ─────────────────────────────────────────────────────\n\nfunction webPackageJson(name: string, clientVersion: string): string {\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': clientVersion,\n react: '^19.0.0',\n 'react-dom': '^19.0.0',\n },\n devDependencies: {\n '@types/react': '^19.0.0',\n '@types/react-dom': '^19.0.0',\n '@vitejs/plugin-react': '^5.0.0',\n typescript: '^5.9.0',\n vite: '^7.0.0',\n },\n },\n null,\n 2,\n )}\\n`\n}\n\nfunction webViteConfig(): string {\n return `import { defineConfig } from 'vite'\nimport react from '@vitejs/plugin-react'\n\nexport default defineConfig({\n plugins: [react()],\n server: {\n // The KickJS server (kick dev) listens on 3000; the client's baseUrl is\n // the relative '/api/v1', so the browser hits Vite and Vite forwards.\n proxy: {\n '/api': 'http://localhost:3000',\n },\n },\n})\n`\n}\n\nfunction webTsConfig(): string {\n return `${JSON.stringify(\n {\n compilerOptions: {\n target: 'ES2022',\n lib: ['ES2022', 'DOM', 'DOM.Iterable'],\n module: 'ESNext',\n moduleResolution: 'bundler',\n jsx: 'react-jsx',\n strict: true,\n skipLibCheck: true,\n noEmit: true,\n isolatedModules: true,\n // The type bridge pulls server controller sources into this\n // program — they use legacy TS decorators.\n experimentalDecorators: true,\n // The KickRoutes ambient types come from the server's generated\n // typegen output via src/types/kick-routes.d.ts.\n types: [],\n },\n include: ['src'],\n },\n null,\n 2,\n )}\\n`\n}\n\nfunction webIndexHtml(name: string): string {\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>${name}</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/src/main.tsx\"></script>\n </body>\n</html>\n`\n}\n\nfunction webMain(): string {\n return `import { StrictMode } from 'react'\nimport { createRoot } from 'react-dom/client'\nimport { App } from './App'\n\ncreateRoot(document.getElementById('root')!).render(\n <StrictMode>\n <App />\n </StrictMode>,\n)\n`\n}\n\nfunction webApp(): string {\n return `import { useEffect, useState } from 'react'\nimport { api } from './api'\n\n// The response types below are INFERRED from the server's handlers —\n// change server/src/modules/hello/hello.service.ts and these types follow\n// on the next \\`kick typegen\\` (automatic under \\`kick dev\\`).\ntype Greeting = Awaited<ReturnType<typeof fetchGreeting>>\n\nfunction fetchGreeting() {\n return api.get('/hello')\n}\n\nexport function App() {\n const [greeting, setGreeting] = useState<Greeting | null>(null)\n const [health, setHealth] = useState<string>('checking…')\n\n useEffect(() => {\n fetchGreeting().then(setGreeting).catch(console.error)\n api\n .get('/hello/health')\n .then((h) => setHealth(h.status))\n .catch(() => setHealth('down'))\n }, [])\n\n return (\n <main style={{ fontFamily: 'system-ui', maxWidth: 640, margin: '4rem auto', padding: '0 1rem' }}>\n <h1>KickJS fullstack</h1>\n <p>\n <strong>{greeting?.message ?? 'loading…'}</strong>\n </p>\n <p>\n Server said hello at <code>{greeting?.timestamp ?? '…'}</code> — health:{' '}\n <code>{health}</code>\n </p>\n <p style={{ color: '#666' }}>\n This call is typed end to end: <code>api.get('/hello')</code> returns the exact shape\n <code> HelloService.greet()</code> produces. Rename a field on the server and this file\n stops compiling.\n </p>\n </main>\n )\n}\n`\n}\n\nfunction webApi(): string {\n return `import { createClient } from '@forinda/kickjs-client'\n\n// KickRoutes.Api is ambient — populated by server/.kickjs/types (see\n// src/types/kick-routes.d.ts). Keys are module-mount-relative paths;\n// the bootstrap-level '/api/v1' prefix lives here in baseUrl, and the\n// Vite dev proxy forwards it to the KickJS server.\nexport const api = createClient<KickRoutes.Api>({ baseUrl: '/api/v1' })\n`\n}\n\nfunction webRouteTypes(): string {\n return `// Type-only bridge to the server's generated route types. The import is\n// erased at build time — no server code ever enters the web bundle.\n// Regenerate with \\`kick typegen\\` in server/ (automatic under \\`kick dev\\`).\nimport '../../../server/.kickjs/types/kick__routes'\n`\n}\n\n// ── root templates ────────────────────────────────────────────────────\n\nfunction rootPackageJson(name: string, pm: string): string {\n const scripts: Record<string, string> =\n pm === 'pnpm'\n ? {\n dev: 'pnpm --parallel -r run dev',\n 'dev:server': 'pnpm --filter ./server dev',\n 'dev:web': 'pnpm --filter ./web dev',\n build: 'pnpm -r run build',\n typecheck: 'pnpm -r run typecheck',\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 'dev:server': `cd server && ${pm} run dev`,\n 'dev:web': `cd web && ${pm} run dev`,\n build: `${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 typecheck: `cd web && ${pm} run typecheck`,\n }\n return `${JSON.stringify(\n {\n name,\n private: true,\n version: '0.0.0',\n type: 'module',\n scripts,\n workspaces: ['server', 'web'],\n },\n null,\n 2,\n )}\\n`\n}\n\nfunction rootGitignore(): string {\n return `node_modules/\ndist/\n.env\n*.log\n.DS_Store\n`\n}\n\nfunction rootReadme(name: string, pm: string): string {\n return `# ${name}\n\nFullstack KickJS workspace — typed end to end.\n\n| Package | What |\n| --------- | ----------------------------------------------------------------- |\n| \\`server/\\` | KickJS API (decorators, DI, \\`kick dev\\` with typegen watch) |\n| \\`web/\\` | Vite + React, typed against the API via \\`@forinda/kickjs-client\\` |\n\n## Develop\n\n\\`\\`\\`bash\n${pm} install\n${pm === 'pnpm' ? 'pnpm dev # server (kick dev) + web (vite), in parallel' : `${pm} run dev:server # terminal 1\\n${pm} run dev:web # terminal 2`}\n\\`\\`\\`\n\nServer: http://localhost:3000 · Web: http://localhost:5173 (Vite proxies \\`/api\\`).\n\n## The type loop\n\n1. Server handlers **return** their payloads (\\`return this.service.greet(...)\\`).\n2. \\`kick typegen\\` (auto under \\`kick dev\\`) emits \\`server/.kickjs/types/kick__routes.ts\\` —\n including the flat \\`KickRoutes.Api\\` map with inferred response types.\n3. \\`web/src/types/kick-routes.d.ts\\` imports that file type-only.\n4. \\`web/src/api.ts\\`'s \\`createClient<KickRoutes.Api>\\` types every call site.\n\nRename a field in \\`server/src/modules/hello/hello.service.ts\\` → \\`web/src/App.tsx\\`\nstops compiling. That's the point.\n\nDocs: https://kickjs.app/guide/typed-client.html\n`\n}\n"],"mappings":";;;;;;;;;;qLA6BA,eAAsB,EAAqB,EAA8C,CACvF,GAAM,CAAE,OAAM,YAAW,YAAY,MAAO,UAAU,WAAc,EAI9D,EAAW,CAAC,OAAQ,MAAO,OAAQ,KAAK,CAAC,CAAW,SACxD,EAAQ,cACV,EACM,EAAiB,EAClB,EAAQ,eACT,OACE,EAAM,EACN,EAAO,GAAgB,QAAQ,IAAI,KAAK,GAAK,EAC/C,EAAQ,iBAAmB,IAAA,IAAa,CAAC,GAC3C,EACE,qCAAqC,OAAO,EAAQ,cAAc,EAAE,0BACtE,EAGF,QAAQ,IAAI,4CAA4C,EAAK,GAAG,EAGhE,MAAM,EAAY,CAChB,KAAM,GAAG,EAAK,SACd,UAAW,EAAK,EAAK,QAAQ,EAC7B,iBACA,SAAU,UACV,YACA,UAEA,QAAS,GACT,YAAa,EACf,CAAC,EAID,IAAM,GAAgB,MADC,EAAuB,EAAA,CACf,2BAA6B,SAkB5D,GAhBA,MAAM,EAAc,EAAK,EAAK,kBAAkB,EAAG,EAAe,EAAM,CAAa,CAAC,EACtF,MAAM,EAAc,EAAK,EAAK,oBAAoB,EAAG,EAAc,CAAC,EACpE,MAAM,EAAc,EAAK,EAAK,mBAAmB,EAAG,EAAY,CAAC,EACjE,MAAM,EAAc,EAAK,EAAK,gBAAgB,EAAG,EAAa,CAAI,CAAC,EACnE,MAAM,EAAc,EAAK,EAAK,kBAAkB,EAAG,EAAQ,CAAC,EAC5D,MAAM,EAAc,EAAK,EAAK,iBAAiB,EAAG,EAAO,CAAC,EAC1D,MAAM,EAAc,EAAK,EAAK,gBAAgB,EAAG,E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ACJ,IAAO,OACH,CACE,IAAK,6BACL,aAAc,6BACd,UAAW,0BACX,MAAO,oBACP,UAAW,uBACb,EACA,CAIE,aAAc,gBAAgB,EAAG,UACjC,UAAW,aAAa,EAAG,UAC3B,MAAO,GAAG,EAAG,uBAAuB,EAAG,gBACvC,eAAgB,gBAAgB,EAAG,YACnC,YAAa,aAAa,EAAG,YAC7B,UAAW,aAAa,EAAG,eAC7B,EACN,MAAO,GAAG,KAAK,UACb,CACE,OACA,QAAS,GACT,QAAS,QACT,KAAM,SACN,UACA,WAAY,CAAC,SAAU,KAAK,CAC9B,EACA,KACA,CACF,EAAE,GACJ,CAEA,SAAS,GAAwB,CAC/B,MAAO;;;;;CAMT,CAEA,SAAS,EAAW,EAAc,EAAoB,CACpD,MAAO,KAAK,EAAK;;;;;;;;;;;;EAYjB,EAAG;EACH,IAAO,OAAS,oEAAsE,GAAG,EAAG,kCAAkC,EAAG,gCAAgC;;;;;;;;;;;;;;;;;CAkBnK"}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/commands/add.ts","../src/commands/doctor.ts","../src/plugin/types.ts","../src/config.ts","../src/generators/templates/types.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/utils/project-root.ts","../src/typegen/scanner.ts","../src/typegen/plugin.ts","../src/typegen/token-conventions.ts","../src/typegen/index.ts","../src/typegen/run-plugins.ts","../src/asset-manager/build.ts","../src/typegen/dev-watcher.ts","../src/generator-extension/discover.ts","../src/generator-extension/context.ts","../src/utils/naming.ts"],"mappings":";;;KA4OY,UAAA;;;;;AAAZ;;;;AAAsB;;;;ACjNtB;;;;;;UAAiB,aAAA;EACf,GAAA;EACA,GAAA;EACA,QAAA;EAMmB;AAGrB;;;;EAHE,OAAA,EAAS,UAAU;AAAA;AA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ERscT,EAAA,GAAK,iBAAA;EQnc0B;ERqc/B,QAAA,GAAW,qBAAA;EQrc0D;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/commands/add.ts","../src/commands/doctor.ts","../src/plugin/types.ts","../src/config.ts","../src/generators/templates/types.ts","../src/generators/module.ts","../src/generators/adapter.ts","../src/generators/middleware.ts","../src/generators/guard.ts","../src/generators/service.ts","../src/generators/controller.ts","../src/generators/dto.ts","../src/generators/project.ts","../src/utils/project-root.ts","../src/typegen/scanner.ts","../src/typegen/plugin.ts","../src/typegen/token-conventions.ts","../src/typegen/index.ts","../src/typegen/run-plugins.ts","../src/asset-manager/build.ts","../src/typegen/dev-watcher.ts","../src/generator-extension/discover.ts","../src/generator-extension/context.ts","../src/utils/naming.ts"],"mappings":";;;KA4OY,UAAA;;;;;AAAZ;;;;AAAsB;;;;ACjNtB;;;;;;UAAiB,aAAA;EACf,GAAA;EACA,GAAA;EACA,QAAA;EAMmB;AAGrB;;;;EAHE,OAAA,EAAS,UAAU;AAAA;AAAA,UAGJ,YAAA;EAOf;EALA,IAAA;EACA,MAAA;EAOU;EALV,OAAA;;EAEA,GAAA;AAAA;AAAA,KAGU,WAAA,IACV,GAAA,EAAK,aAAA,KACF,YAAA,GAAe,YAAA,YAAwB,OAAA,CAAQ,YAAA,GAAe,YAAA;;;;;;UAOlD,eAAA;EARf;EAUA,MAAA,GAAS,WAAW;AAAA;;;;;AATyD;AAO/E;;;;AAEsB;AAqCtB;;;;;;;;AAA4E;AA0B5E;;;;;;;;AAAkE;;;;AC1FlE;;;iBDgEgB,qBAAA,CAAsB,GAAA,EAAK,eAAA,GAAkB,eAAe;AChEX;AAGjE;;;;AAAmD;;;;AC7BnD;;;;;;;;;AAeS;AAIT;;;ADOiE,iBD0FjD,iBAAA,CAAkB,KAAA,EAAO,WAAA,GAAc,WAAW;;;;KC1FtD,oBAAA,GAAuB,sBAAmB,CAAC,UAAA;;KAG3C,aAAA,GAAgB,e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|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v6.
|
|
2
|
+
* @forinda/kickjs-cli v6.5.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{
|
|
11
|
+
import{M as e,N as t,c as n,d as r,f as i,g as a,j as o,k as s,l as c,m as l,n as u,o as d,p as f,s as p,t as m,u as h,y as g}from"./doctor-DCFgdlJ3.mjs";import{t as _}from"./project-D_8okjEO.mjs";import{i as v,r as y}from"./config-xEbwXlmo.mjs";import{t as b}from"./project-root-CWcfpTV4.mjs";import{n as x,t as S}from"./types-CjDOGs_1.mjs";function C(e){return e}export{S as KickPluginConflictError,n as TYPEGEN_OWNER_KEY,d as buildGeneratorContext,c as createTypegenDevWatcher,x as defineCliPlugin,y as defineConfig,m as defineDoctorCheck,u as defineDoctorExtension,p as defineGenerator,C as defineTypegen,b as findProjectRoot,a as generateAdapter,r as generateController,h as generateDto,f as generateGuard,l as generateMiddleware,g as generateModule,i as generateService,_ as initProject,v as loadKickConfig,s as pluralize,o as toCamelCase,e as toKebabCase,t as toPascalCase};
|
|
12
12
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/typegen/plugin.ts"],"sourcesContent":["// TypegenPlugin contract — M2.B-T7.\n//\n// Each plugin owns a single `.kickjs/types/<id>.d.ts` file. The runner\n// invokes `generate(ctx)` per plugin, prepends a banner, writes only on\n// content change, and surfaces drift in --check mode (CI gate).\n//\n// Built-in plugins (kick/routes, kick/env, kick/assets, kick/db) live under\n// `./builtin`. Adopters register additional plugins via kick.config.ts.\n\nimport type { KickConfig } from '../config'\nimport type { ScanOptions, ScanResult } from './scanner'\n\nexport interface TypegenLogger {\n info(msg: string): void\n warn(msg: string): void\n error(msg: string): void\n}\n\nexport interface TypegenContext {\n cwd: string\n config: KickConfig\n /** Dynamic-import a TS module (Node loader). Used by plugins that need to\n * read the adopter's schema / route map / asset registry at generate time. */\n importTs<T = unknown>(absPath: string): Promise<T>\n /** Write under `cwd`. Caller passes a relPath (e.g. `.kickjs/types/foo.d.ts`). */\n writeFile(relPath: string, contents: string): Promise<void>\n /**\n * Run `scanProject` once per typegen pass, memoizing the result so\n * multiple plugins (`kick/routes`, `kick/env`, future adopter plugins)\n * share a single fs walk + AST extraction.\n *\n * The runner uses an order-independent cache key derived from the\n * resolved options (`root`, `cwd`, `extensions`, `exclude`, `envFile`)\n * — semantically equal options hit the cache regardless of how the\n * caller built the literal. (We deliberately don't `JSON.stringify`\n * the options for caching since that would be sensitive to property\n * insertion order.) Plugins that don't need scanner data can ignore\n * this method entirely.\n *\n * Implementation lives in the runner so test harnesses can inject\n * a stub scanner; plugins only see the function.\n */\n getScanResult(opts: ScanOptions): Promise<ScanResult>\n log: TypegenLogger\n}\n\nexport interface TypegenPlugin {\n /** Stable id — used as filename: `.kickjs/types/${id}<outExtension>` (slashes → `__`). */\n id: string\n /** Glob patterns the Vite watcher subscribes to; change → re-run this plugin. */\n inputs: string[]\n /**\n * Output filename extension. Default `.d.ts` — the right choice for\n * pure module-augmentation plugins (kick/db, kick/assets) since\n * declaration files don't need the runtime-import dance.\n *\n * `kick/routes` overrides to `.ts` because it emits hoisted\n * `import type {...} from '...'` lines at the top of the file. Inline\n * `import('...').X` references inside `.d.ts` silently degrade to\n * `unknown` under `moduleResolution: 'bundler'`; emitting `.ts`\n * sidesteps that quirk and gets full type resolution.\n *\n * Adopter-supplied plugins should leave this unset unless they hit\n * the same hoisted-import constraint.\n */\n outExtension?: string\n /**\n * Return the augmentation source (without banner — runner prepends).\n * Return null to skip emission (e.g. no schema file present).\n */\n generate(ctx: TypegenContext): Promise<string | null>\n}\n\nexport interface TypegenPluginResult {\n id: string\n status: 'written' | 'unchanged' | 'skipped' | 'error'\n outFile?: string\n}\n\n/**\n * Identity factory for {@link TypegenPlugin}. Returns the spec verbatim.\n * Exists for type inference and forward-compatibility — future\n * fields can be added with defaults without breaking adopters.\n *\n * Mirrors {@link defineGenerator} ergonomics. Use at the call site so\n * the plugin's `generate(ctx)` body gets a fully-typed `ctx` without\n * an explicit annotation:\n *\n * @example\n * ```ts\n * import { defineTypegen } from '@forinda/kickjs-cli'\n *\n * export const drizzleTypegen = defineTypegen({\n * id: 'drizzle',\n * inputs: ['src/db/schema.ts'],\n * async generate(ctx) {\n * const schema = await ctx.importTs(`${ctx.cwd}/src/db/schema.ts`)\n * return `// declare module …`\n * },\n * })\n * ```\n */\nexport function defineTypegen(spec: TypegenPlugin): TypegenPlugin {\n return spec\n}\n"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/typegen/plugin.ts"],"sourcesContent":["// TypegenPlugin contract — M2.B-T7.\n//\n// Each plugin owns a single `.kickjs/types/<id>.d.ts` file. The runner\n// invokes `generate(ctx)` per plugin, prepends a banner, writes only on\n// content change, and surfaces drift in --check mode (CI gate).\n//\n// Built-in plugins (kick/routes, kick/env, kick/assets, kick/db) live under\n// `./builtin`. Adopters register additional plugins via kick.config.ts.\n\nimport type { KickConfig } from '../config'\nimport type { ScanOptions, ScanResult } from './scanner'\n\nexport interface TypegenLogger {\n info(msg: string): void\n warn(msg: string): void\n error(msg: string): void\n}\n\nexport interface TypegenContext {\n cwd: string\n config: KickConfig\n /** Dynamic-import a TS module (Node loader). Used by plugins that need to\n * read the adopter's schema / route map / asset registry at generate time. */\n importTs<T = unknown>(absPath: string): Promise<T>\n /** Write under `cwd`. Caller passes a relPath (e.g. `.kickjs/types/foo.d.ts`). */\n writeFile(relPath: string, contents: string): Promise<void>\n /**\n * Run `scanProject` once per typegen pass, memoizing the result so\n * multiple plugins (`kick/routes`, `kick/env`, future adopter plugins)\n * share a single fs walk + AST extraction.\n *\n * The runner uses an order-independent cache key derived from the\n * resolved options (`root`, `cwd`, `extensions`, `exclude`, `envFile`)\n * — semantically equal options hit the cache regardless of how the\n * caller built the literal. (We deliberately don't `JSON.stringify`\n * the options for caching since that would be sensitive to property\n * insertion order.) Plugins that don't need scanner data can ignore\n * this method entirely.\n *\n * Implementation lives in the runner so test harnesses can inject\n * a stub scanner; plugins only see the function.\n */\n getScanResult(opts: ScanOptions): Promise<ScanResult>\n log: TypegenLogger\n}\n\nexport interface TypegenPlugin {\n /** Stable id — used as filename: `.kickjs/types/${id}<outExtension>` (slashes → `__`). */\n id: string\n /** Glob patterns the Vite watcher subscribes to; change → re-run this plugin. */\n inputs: string[]\n /**\n * Output filename extension. Default `.d.ts` — the right choice for\n * pure module-augmentation plugins (kick/db, kick/assets) since\n * declaration files don't need the runtime-import dance.\n *\n * `kick/routes` overrides to `.ts` because it emits hoisted\n * `import type {...} from '...'` lines at the top of the file. Inline\n * `import('...').X` references inside `.d.ts` silently degrade to\n * `unknown` under `moduleResolution: 'bundler'`; emitting `.ts`\n * sidesteps that quirk and gets full type resolution.\n *\n * Adopter-supplied plugins should leave this unset unless they hit\n * the same hoisted-import constraint.\n */\n outExtension?: string\n /**\n * Return the augmentation source (without banner — runner prepends).\n * Return null to skip emission (e.g. no schema file present).\n */\n generate(ctx: TypegenContext): Promise<string | null>\n}\n\nexport interface TypegenPluginResult {\n id: string\n status: 'written' | 'unchanged' | 'skipped' | 'error'\n outFile?: string\n}\n\n/**\n * Identity factory for {@link TypegenPlugin}. Returns the spec verbatim.\n * Exists for type inference and forward-compatibility — future\n * fields can be added with defaults without breaking adopters.\n *\n * Mirrors {@link defineGenerator} ergonomics. Use at the call site so\n * the plugin's `generate(ctx)` body gets a fully-typed `ctx` without\n * an explicit annotation:\n *\n * @example\n * ```ts\n * import { defineTypegen } from '@forinda/kickjs-cli'\n *\n * export const drizzleTypegen = defineTypegen({\n * id: 'drizzle',\n * inputs: ['src/db/schema.ts'],\n * async generate(ctx) {\n * const schema = await ctx.importTs(`${ctx.cwd}/src/db/schema.ts`)\n * return `// declare module …`\n * },\n * })\n * ```\n */\nexport function defineTypegen(spec: TypegenPlugin): TypegenPlugin {\n return spec\n}\n"],"mappings":";;;;;;;;;;sVAsGA,SAAgB,EAAc,EAAoC,CAChE,OAAO,CACT"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v6.
|
|
2
|
+
* @forinda/kickjs-cli v6.5.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as e}from"./rolldown-runtime-
|
|
12
|
-
//# sourceMappingURL=plugin-
|
|
11
|
+
import{t as e}from"./rolldown-runtime-wP2RwkAN.mjs";import{t}from"./types-CjDOGs_1.mjs";function n(e,n=[]){let r=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=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=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=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-CWcfpTV4.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 r=e({mergeCliPlugins:()=>n});export{n,r as t};
|
|
12
|
+
//# sourceMappingURL=plugin-B_40AQRr.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-
|
|
1
|
+
{"version":3,"file":"plugin-B_40AQRr.mjs","names":[],"sources":["../src/plugin/merge.ts","../src/plugin/index.ts"],"sourcesContent":["// Plugin → unified registry merge.\n//\n// Resolution rules (per the v1 spec + dogfood pivot):\n// - duplicate plugin `name` across the input array → conflict error.\n// Catches the double-install case (built-in shipped twice, or\n// adopter requiring the same plugin twice).\n// - plugin commands appear first in the merged list, then adopter\n// commands; adopter `commands` of the same name override the\n// plugin entry (filter pass).\n// - duplicate command name across two plugins → conflict error\n// listing both plugin names. Adopter overriding a plugin is\n// allowed and not an error.\n// - duplicate typegen id across two plugins → same error. Typegens\n// have no adopter override path; only plugins contribute them.\n// - register() functions are collected in input order; the caller\n// invokes each one against the same Command program. They have no\n// id-level conflict surface — owners are responsible for picking\n// non-colliding command names inside their own register().\n// - plugin order = array order. No implicit precedence rules.\n\nimport type { Command } from 'commander'\n\nimport type { KickCommandDefinition } from '../config'\nimport type { TypegenPlugin } from '../typegen/plugin'\nimport type { GeneratorSpec } from '../generator-extension/define'\nimport type { DiscoveredGenerator } from '../generator-extension/discover'\nimport { KickPluginConflictError, type KickCliPlugin, type KickCliPluginContext } from './types'\n\nexport interface MergedPlugins {\n commands: KickCommandDefinition[]\n typegens: TypegenPlugin[]\n /** DiscoveredGenerator shape so this list slots into the existing\n * dispatch path next to package.json-discovered entries. `source`\n * carries the plugin name for error attribution. */\n generators: DiscoveredGenerator[]\n /**\n * Apply every plugin's register() in input order. ctx is optional so\n * tests + lightweight callers can invoke `register(program)` without\n * constructing a full context; it falls back to cwd=process.cwd(),\n * config=null, log=no-op.\n */\n register: (program: Command, ctx?: KickCliPluginContext) => Promise<void>\n}\n\nexport function mergeCliPlugins(\n plugins: readonly KickCliPlugin[],\n adopterCommands: readonly KickCommandDefinition[] = [],\n): MergedPlugins {\n // Plugin-name dedup — catches double-install.\n const seenPluginNames = new Map<string, number>()\n for (const p of plugins) {\n const count = (seenPluginNames.get(p.name) ?? 0) + 1\n seenPluginNames.set(p.name, count)\n if (count === 2) {\n throw new KickPluginConflictError('plugin', p.name, [p.name, p.name])\n }\n }\n\n const commandOwners = new Map<string, string>()\n const pluginCommands: KickCommandDefinition[] = []\n for (const p of plugins) {\n for (const cmd of p.commands ?? []) {\n const prior = commandOwners.get(cmd.name)\n if (prior) {\n throw new KickPluginConflictError('command', cmd.name, [prior, p.name])\n }\n commandOwners.set(cmd.name, p.name)\n pluginCommands.push(cmd)\n }\n }\n\n const adopterNames = new Set(adopterCommands.map((c) => c.name))\n const filteredPlugin = pluginCommands.filter((c) => !adopterNames.has(c.name))\n const commands = [...filteredPlugin, ...adopterCommands]\n\n const typegenOwners = new Map<string, string>()\n const typegens: TypegenPlugin[] = []\n for (const p of plugins) {\n for (const tg of p.typegens ?? []) {\n const prior = typegenOwners.get(tg.id)\n if (prior) {\n throw new KickPluginConflictError('typegen', tg.id, [prior, p.name])\n }\n typegenOwners.set(tg.id, p.name)\n typegens.push(tg)\n }\n }\n\n const generatorOwners = new Map<string, string>()\n const generators: DiscoveredGenerator[] = []\n for (const p of plugins) {\n for (const spec of p.generators ?? []) {\n const prior = generatorOwners.get(spec.name)\n if (prior) {\n throw new KickPluginConflictError('generator', spec.name, [prior, p.name])\n }\n generatorOwners.set(spec.name, p.name)\n generators.push({ source: p.name, spec: spec satisfies GeneratorSpec })\n }\n }\n\n /**\n * Apply every plugin's `register()` callback in input order against the\n * given Commander program. Each callback receives a {@link KickCliPluginContext}:\n * caller-supplied ctx wins (test fixtures can inject a different\n * workspace boundary); otherwise a default ctx is built with\n * `findProjectRoot(process.cwd())` as the project root, `cwd` matching\n * `process.cwd()`, null config, no-op log, and the merged generator set\n * threaded through so the `kick/generate` built-in can surface each as\n * a Commander subcommand. The dynamic import of `findProjectRoot` keeps\n * the caller-supplied fast path zero-cost.\n */\n const register = async (program: Command, ctx?: KickCliPluginContext): Promise<void> => {\n let resolved: KickCliPluginContext\n if (ctx) {\n resolved = { generators, ...ctx }\n } else {\n const { findProjectRoot } = await import('../utils/project-root')\n const cwd = process.cwd()\n resolved = {\n cwd,\n projectRoot: findProjectRoot(cwd),\n config: null,\n log: () => {},\n generators,\n }\n }\n for (const p of plugins) {\n if (p.register) await p.register(program, resolved)\n }\n }\n\n return { commands, typegens, generators, register }\n}\n","// Barrel intentionally omits `./builtins` — that module top-level-imports\n// every register*Command, which pulls heavy modules (project scaffolders,\n// fs reads at import time) into the graph. Importers that need the\n// builtin list go through `./plugin/builtins` directly; tests + adopter\n// plugins consuming only the contract types import from here.\n\nexport type { KickCliPlugin } from './types'\nexport { defineCliPlugin, KickPluginConflictError } from './types'\nexport { mergeCliPlugins, type MergedPlugins } from './merge'\n"],"mappings":";;;;;;;;;;wFA4CA,SAAgB,EACd,EACA,EAAoD,CAAC,EACtC,CAEf,IAAM,EAAkB,IAAI,IAC5B,IAAK,IAAM,KAAK,EAAS,CACvB,IAAM,GAAS,EAAgB,IAAI,EAAE,IAAI,GAAK,GAAK,EAEnD,GADA,EAAgB,IAAI,EAAE,KAAM,CAAK,EAC7B,IAAU,EACZ,MAAM,IAAI,EAAwB,SAAU,EAAE,KAAM,CAAC,EAAE,KAAM,EAAE,IAAI,CAAC,CAExE,CAEA,IAAM,EAAgB,IAAI,IACpB,EAA0C,CAAC,EACjD,IAAK,IAAM,KAAK,EACd,IAAK,IAAM,KAAO,EAAE,UAAY,CAAC,EAAG,CAClC,IAAM,EAAQ,EAAc,IAAI,EAAI,IAAI,EACxC,GAAI,EACF,MAAM,IAAI,EAAwB,UAAW,EAAI,KAAM,CAAC,EAAO,EAAE,IAAI,CAAC,EAExE,EAAc,IAAI,EAAI,KAAM,EAAE,IAAI,EAClC,EAAe,KAAK,CAAG,CACzB,CAGF,IAAM,EAAe,IAAI,IAAI,EAAgB,IAAK,GAAM,EAAE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