@forinda/kickjs-cli 8.7.4 → 8.7.5
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-D1NiioiC.mjs → agent-docs-B3qf_4hD.mjs} +4 -4
- package/dist/agent-docs-B3qf_4hD.mjs.map +1 -0
- package/dist/{agent-docs-eYzqOuhH.mjs → agent-docs-D64d3LTb.mjs} +3 -3
- package/dist/{build-Dn_E-sU-.mjs → build-E-EKdC43.mjs} +2 -2
- package/dist/{build-C8hFoe4D.mjs → build-lva8WFtm.mjs} +3 -3
- package/dist/{build-C8hFoe4D.mjs.map → build-lva8WFtm.mjs.map} +1 -1
- package/dist/{builtins-9-5q51ha.mjs → builtins-BjXFvkRo.mjs} +2 -2
- package/dist/{builtins-BVbO6V8X.mjs → builtins-VnrJ1ZDQ.mjs} +5 -5
- package/dist/cli.mjs +2 -2
- package/dist/{config-SmN68KnC.mjs → config-D0vkaGtR.mjs} +2 -2
- package/dist/{config-Bz95PNHt.mjs → config-DQT4CMA_.mjs} +3 -3
- package/dist/{config-Bz95PNHt.mjs.map → config-DQT4CMA_.mjs.map} +1 -1
- package/dist/{doctor-Dkavyt1v.mjs → doctor-BNOcXL4A.mjs} +4 -4
- package/dist/{doctor-Dkavyt1v.mjs.map → doctor-BNOcXL4A.mjs.map} +1 -1
- package/dist/{fs-BOhfpM_y.mjs → fs-BZxW7vGY.mjs} +2 -2
- package/dist/{fs-BOhfpM_y.mjs.map → fs-BZxW7vGY.mjs.map} +1 -1
- package/dist/{fs-BIgSYmdZ.mjs → fs-Cz5zEifl.mjs} +1 -1
- package/dist/{fullstack-BJIm48KV.mjs → fullstack-BHD2K7By.mjs} +4 -4
- package/dist/{fullstack-BJIm48KV.mjs.map → fullstack-BHD2K7By.mjs.map} +1 -1
- package/dist/{fullstack-4Yb4WDLh.mjs → fullstack-tqIxAJRc.mjs} +3 -3
- package/dist/index.mjs +2 -2
- package/dist/{plugin-CM08_8-x.mjs → plugin-BqOSSxfR.mjs} +2 -2
- package/dist/{plugin-q9-AlF6C.mjs → plugin-KrSqxiyg.mjs} +2 -2
- package/dist/{project-B3xCFdaS.mjs → project-CCZI3qVg.mjs} +5 -5
- package/dist/{project-B3xCFdaS.mjs.map → project-CCZI3qVg.mjs.map} +1 -1
- package/dist/{project-D_obb3C8.mjs → project-Czuzz8xB.mjs} +4 -4
- package/dist/{project-root-BkMyQ-hx.mjs → project-root-CKYl6tCJ.mjs} +2 -2
- package/dist/{project-root-gBoWn2mp.mjs → project-root-DotXmvyG.mjs} +3 -3
- package/dist/{project-root-gBoWn2mp.mjs.map → project-root-DotXmvyG.mjs.map} +1 -1
- package/dist/{prompts-_yTG-mXU.mjs → prompts-B5EAbTYl.mjs} +2 -2
- package/dist/{prompts-_yTG-mXU.mjs.map → prompts-B5EAbTYl.mjs.map} +1 -1
- package/dist/{rolldown-runtime-dZfrrS4X.mjs → rolldown-runtime-D-zUBK7H.mjs} +1 -1
- package/dist/{run-plugins-BIQikATV.mjs → run-plugins-8wx6Jt8B.mjs} +5 -5
- package/dist/run-plugins-8wx6Jt8B.mjs.map +1 -0
- package/dist/{typegen-F8fT5eSE.mjs → typegen-DCQXDET7.mjs} +5 -5
- package/dist/{typegen-F8fT5eSE.mjs.map → typegen-DCQXDET7.mjs.map} +1 -1
- package/dist/{typegen-CD1WVcaP.mjs → typegen-Db0XkCjY.mjs} +4 -4
- package/dist/{types-DqUW9c4J.mjs → types-CsAi8YRr.mjs} +1 -1
- package/package.json +5 -5
- package/templates/schema-zod/files/src/config/index.ts +3 -3
- package/dist/agent-docs-D1NiioiC.mjs.map +0 -1
- package/dist/run-plugins-BIQikATV.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.7.
|
|
2
|
+
* @forinda/kickjs-cli v8.7.5
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{a as e,t}from"./config-
|
|
11
|
+
import{a as e,t}from"./config-D0vkaGtR.mjs";import{r as n}from"./fs-Cz5zEifl.mjs";import{existsSync as r,readFileSync as i,readdirSync as a,statSync as o,writeFileSync as s}from"node:fs";import{dirname as c,join as l,resolve as u,sep as d}from"node:path";import{fileURLToPath as f}from"node:url";import{execFile as p,execFileSync as m,execSync as h,spawnSync as g}from"node:child_process";import{promisify as _}from"node:util";import{parseSync as v}from"oxc-parser";const y=_(p),b=/[&|<>^"'`(){}[\];!%\r\n\\]/;function x(e,t,n=process.platform){if(n!==`win32`)return[e,t];if(b.test(e)||t.some(e=>b.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 S(e,t,n={}){let r=x(e,t);if(!r)return null;try{return m(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 C(e,t,n={}){let r=x(e,t);if(!r)throw Error(`Refusing to run '${e}': unsafe arguments`);m(r[0],r[1],{cwd:n.cwd,stdio:`inherit`,windowsHide:!0})}function ee(e,t,n){h(e,{cwd:t,stdio:`inherit`,env:n?{...process.env,...n}:process.env})}function te(e,t,n){let r=g(process.execPath,[e],{cwd:n,stdio:`inherit`,env:{...process.env,...t}});r.status!==0&&process.exit(r.status??1)}async function ne(e,t,n={}){let r=x(e,t);if(!r)return null;try{let{stdout:e}=await y(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 w=c(f(import.meta.url)),T=[l(w,`..`,`templates`),l(w,`..`,`..`,`templates`)].find(e=>r(l(e,`base`)));function re(e){return e.split(`/`).map(e=>e.startsWith(`_dot_`)?`.${e.slice(5)}`:e).join(`/`)}function E(e,t={}){let n=t.templatesDir??T,s=new Map,c=[],u=[],f={},p=[];for(let t of e){let e=l(n,t);if(!r(e))throw Error(`Unknown scaffold layer "${t}" (${e})`);let m=l(e,`feature.json`);if(r(m)){let e=JSON.parse(i(m,`utf-8`));c.push(...e.dependencies??[]),u.push(...e.devDependencies??[]),Object.assign(f,e.builds),p.push(...e.integrations??[])}let h=l(e,`files`);if(r(h))for(let e of a(h,{recursive:!0,encoding:`utf-8`}).toSorted()){let t=l(h,e);if(!o(t).isFile())continue;let n=i(t,`utf-8`),r=re(e.split(d).join(`/`));if(r.endsWith(`.append`)){let e=r.slice(0,-7);s.set(e,(s.get(e)??``)+n)}else s.set(r,n)}}p.push(...t.extra??[]);let m=t.vars??{},h=e=>e.replace(/\{\{(\w+)\}\}/g,(e,t)=>m[t]??e);for(let[e,t]of s)t.includes(`// @kick:`)&&s.set(e,ie(t,p,h));return{files:s,dependencies:[...new Set(c)],devDependencies:[...new Set(u)],builds:f,integrations:p}}function D(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 O=/^([ \t]*)\/\/ @kick:([\w-]+)[ \t]*$/;function ie(e,t,n=e=>e){let r=e.split(`
|
|
12
12
|
`),i=new Set(r.map(e=>O.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=O.exec(r[e]);if(!t){o.push(r[e]);continue}let[,i,s]=t,c=s===`imports`?oe(a.flatMap(e=>e.import?[e.import]:[])):a.filter(e=>e.slot===s&&e.code).map(e=>ae(`${n(e.code)},`,i));if(c.length>0){o.push(...c);continue}o.at(-1)?.trimEnd().endsWith(`[`)&&r[e+1]?.trim().startsWith(`]`)&&(o.pop(),e++)}return o.join(`
|
|
13
13
|
`)}function ae(e,t){return e.split(`
|
|
14
14
|
`).map(e=>e&&t+e).join(`
|
|
@@ -38,8 +38,8 @@ import{a as e,t}from"./config-SmN68KnC.mjs";import{r as n}from"./fs-BIgSYmdZ.mjs
|
|
|
38
38
|
`),console.log(Ce(n).replace(/^/gm,` `)),console.log())}}b?console.log(` Done!
|
|
39
39
|
`):(console.log(` Finished with errors — the install above did not complete.
|
|
40
40
|
`),process.exitCode=1)})}const Y=c(f(import.meta.url)),X=JSON.parse(i([l(Y,`..`,`package.json`),l(Y,`..`,`..`,`package.json`)].find(r),`utf-8`)),Pe=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-schema`,`@forinda/kickjs-vite`,`@forinda/kickjs-swagger`,`@forinda/kickjs-ws`,`@forinda/kickjs-queue`,`@forinda/kickjs-devtools`,`@forinda/kickjs-testing`,`@forinda/kickjs-client`],Fe={react:{fallback:`^19.0.0`},"react-dom":{fallback:`^19.0.0`},"@types/react":{fallback:`^19.0.0`},"@types/react-dom":{fallback:`^19.0.0`},"@vitejs/plugin-react":{fallback:`^5.0.0`},"@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:`^1.0.0`,cap:`^1`},"serve-static":{fallback:`^2.2.0`,cap:`^2`},zod:{fallback:`^4.3.6`,cap:`^4`},valibot:{fallback:`^1.4.1`,cap:`^1`},yup:{fallback:`^1.7.1`,cap:`^1`},ws:{fallback:`^8.18.0`,cap:`^8`},bullmq:{fallback:`^5.0.0`,cap:`^5`},ioredis:{fallback:`^5.0.0`,cap:`^5`}};function Ie(e){if(!e)return null;let t=e.trim();if(/^\d+\.\d+\.\d+/.test(t))return t.split(/\s/)[0];try{let e=JSON.parse(t),n=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`);return n.length>0?n[n.length-1]:null}catch{return null}}function Le(e){return e===`@forinda/kickjs-cli`?`^${X.version}`:`latest`}async function Re(e,t,n){let r=Array.from({length:e.length}),i=0,a=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let t=i++;r[t]=await n(e[t])}});return await Promise.all(a),r}async function Z(){let e=[...Pe.map(e=>({name:e,fallback:Le(e),cap:void 0})),...Object.entries(Fe).map(([e,t])=>({name:e,...t}))],t=Date.now()+2e4,n=await Re(e,8,async({name:e,fallback:n,cap:r})=>{let i=t-Date.now();if(i<=0)return[e,n];let a=r?`${e}@${r}`:e,o=Ie(await ne(`npm`,r?[`view`,a,`version`,`--json`]:[`view`,a,`version`],{timeout:i}));return[e,o?`^${o}`:n]});return Object.fromEntries(n)}function Q(e,t){let n=S(`npm`,[`view`,`${e}@${t}`,`version`],{timeout:2e4});return n&&/^\d+\.\d+\.\d+/.test(n)?n:null}function $(e){return(e??``).replace(/^[\^~>=<\s]+/,``)}function ze(e,t){let n=e=>$(e).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10)||0),[r=0,i=0,a=0]=n(e),[o=0,s=0,c=0]=n(t);return r===o?i===s?a>=c:i>s:r>o}function Be(e,t,n){let r=S(`npm`,[`view`,`${e}@${t}`,`exports`,`--json`],{timeout:2e4});if(!r)return!1;try{let e=JSON.parse(r);return Object.prototype.hasOwnProperty.call(e,n)}catch{return!1}}async function Ve(e){let{name:t,directory:i,packageManager:a=`pnpm`,template:o=`rest`,defaultRepo:s=`inmemory`,packages:c=[],schemaLib:u=`zod`,runtime:d=`express`}=e,f=i,p=e=>console.log(` ${e}`);console.log(`\n Creating KickJS project: ${t}\n`),e.versions||p(`Resolving package versions...`);let m=e.versions??await Z(),g=Object.keys(m).filter(e=>m[e]===`latest`);if(g.length>0&&p(`WARNING: could not reach npm for ${g.join(`, `)} — pinned to 'latest'`),d!==`express`){if(Be(`@forinda/kickjs`,`latest`,`./${d}`))p(`Using @forinda/kickjs@latest (stable ships the ${d} runtime)`);else{let e=[`@forinda/kickjs`,`@forinda/kickjs-cli`,`@forinda/kickjs-vite`],t=[],n=!1;for(let r of e){let e=Q(r,`alpha`);e&&ze(e,$(m[r]))&&(m[r]=`^${e}`,t.push(`${r}@^${e}`),r===`@forinda/kickjs`&&(n=!0))}p(n?`Using the alpha channel for the ${d} runtime: ${t.join(`, `)}`:`WARNING: could not resolve @forinda/kickjs@alpha — the ${d} runtime subpath may be missing. After install, run: ${a} add @forinda/kickjs@alpha`)}}let _=c.filter(e=>!r(l(T,`feature-${e}`)));_.length>0&&p(`WARNING: skipping unknown package(s): ${_.join(`, `)} — add them later with kick add`);let v=E([...Ue({template:o,runtime:d,schemaLib:u,packages:c}),...e.platformConfig===!1?[]:[`host-config`],...e.extraLayers??[]],{vars:{name:t,version:X.version},extra:[{slot:`repo`,code:s===`inmemory`?`repo: 'inmemory'`:`repo: { name: '${s.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}' }`},...e.spaClientDir?[He(e.spaClientDir)]:[]]});await n(l(f,`package.json`),ce(t,m,v));let y=D(v.files,{name:t,template:o,runtime:d,packageManager:a,templateLabel:o===`rest`?`REST API`:`Minimal`,packages:[...v.dependencies,...v.devDependencies].filter(e=>e.startsWith(`@forinda/`)).map(e=>`- \`${e}\``).join(`
|
|
41
|
-
`)});for(let[e,t]of y)await n(l(f,e),t);let{generateAgentDocs:b}=await import(`./agent-docs-
|
|
42
|
-
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${a} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-
|
|
41
|
+
`)});for(let[e,t]of y)await n(l(f,e),t);let{generateAgentDocs:b}=await import(`./agent-docs-D64d3LTb.mjs`).then(e=>e.t);await b({outDir:f,name:t,pm:a,template:o,only:`all`,force:!0});let x={...ke,...J(c),...v.builds};if(e.approveInstallScripts!==!1&&q(a,f,x),e.installDeps){console.log(`\n Installing dependencies with ${a}...\n`);try{h(`${a} install`,{cwd:f,stdio:`inherit`}),console.log(`
|
|
42
|
+
Dependencies installed successfully!`)}catch{console.log(`\n Warning: ${a} install failed. Run it manually.`)}}try{let{runTypegen:e}=await import(`./typegen-Db0XkCjY.mjs`).then(e=>e.n);await e({cwd:f,allowDuplicates:!0,silent:!0})}catch{}if(e.initGit)try{h(`git init`,{cwd:f,stdio:`pipe`}),h(`git branch -M main`,{cwd:f,stdio:`pipe`}),h(`git add -A`,{cwd:f,stdio:`pipe`}),h(`git commit -m "chore: initial commit from kick new"`,{cwd:f,stdio:`pipe`}),p(`Git repository initialized`)}catch{p(`Warning: git init failed (git may not be installed)`)}console.log(`
|
|
43
43
|
Project scaffolded successfully!`),console.log();let S=f!==process.cwd();p(`Next steps:`),S&&p(` cd ${t}`),e.installDeps||p(` ${a} install`);let C={rest:`kick g module user`,minimal:`# add your routes to src/index.ts`};return p(` ${C[o]??C.rest}`),p(` kick dev`),p(``),p(`Commands:`),p(` kick dev Start dev server with Vite HMR`),p(` kick build Production build via Vite`),p(` kick start Run production build`),p(``),p(`Generators:`),p(` kick g module <name> REST module (controller, service, DTOs, repository)`),p(` kick g scaffold <n> <f..> CRUD module from field definitions`),p(` kick g controller <name> Standalone controller`),p(` kick g service <name> @Service() class`),p(` kick g middleware <name> Global connect-style middleware`),p(` kick g guard <name> Route guard (auth, roles, etc.)`),p(` kick g adapter <name> AppAdapter with lifecycle hooks`),p(` kick g dto <name> DTO schema (Zod / Valibot / Yup)`),p(` kick g config Generate kick.config.ts`),p(``),p(`Add packages:`),p(` kick add <pkg> Install a KickJS package + peers`),p(` kick add --list Show all available packages`),p(``),p(`Available: ${we}`),p(``),{builds:x}}function He(e){return{import:{from:`@forinda/kickjs/spa`,names:[`SpaAdapter`]},slot:`adapter`,code:`// Serves the built frontend from this origin in production.
|
|
44
44
|
// Inert until the client build exists, so \`kick dev\` (where Vite
|
|
45
45
|
// serves the client and proxies /api here) is unaffected.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.7.
|
|
2
|
+
* @forinda/kickjs-cli v8.7.5
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as e}from"./rolldown-runtime-
|
|
11
|
+
import{t as e}from"./rolldown-runtime-D-zUBK7H.mjs";import{existsSync as t}from"node:fs";import{dirname as n,parse as r,resolve as i}from"node:path";var a=e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=i(e),{root:s}=r(a),c=null,l=a;for(;;){for(let e of o)if(t(i(l,e)))return l;if(c===null&&t(i(l,`package.json`))&&(c=l),l===s)break;let e=n(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.7.
|
|
2
|
+
* @forinda/kickjs-cli v8.7.5
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as e}from"./rolldown-runtime-
|
|
12
|
-
//# sourceMappingURL=project-root-
|
|
11
|
+
import{t as e}from"./rolldown-runtime-D-zUBK7H.mjs";import{dirname as t,parse as n,resolve as r}from"node:path";import{existsSync as i}from"node:fs";var a=e({findProjectRoot:()=>s});const o=[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`];function s(e=process.cwd()){let a=r(e),{root:s}=n(a),c=null,l=a;for(;;){for(let e of o)if(i(r(l,e)))return l;if(c===null&&i(r(l,`package.json`))&&(c=l),l===s)break;let e=t(l);if(e===l)break;l=e}return c??a}export{a as n,s as t};
|
|
12
|
+
//# sourceMappingURL=project-root-DotXmvyG.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-root-
|
|
1
|
+
{"version":3,"file":"project-root-DotXmvyG.mjs","names":[],"sources":["../src/utils/project-root.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { dirname, parse, resolve } from 'node:path'\n\nconst CONFIG_FILENAMES = ['kick.config.ts', 'kick.config.js', 'kick.config.mjs', 'kick.config.json']\n\n/**\n * Walk up from `startDir` looking for the project root. A directory\n * counts as the root when it contains any of:\n * - `kick.config.{ts,js,mjs,json}` (strongest signal)\n * - `package.json` (fallback when no config file exists yet)\n *\n * Returns the absolute path of the first matching directory, or\n * `startDir` itself when nothing was found (no surprises — callers\n * that didn't find a config still get a reasonable cwd).\n *\n * `kick.config.*` wins over `package.json` when both appear at\n * different levels, so adopters running `kick typegen` from `src/`\n * land on the project root that owns the config, not on the nearest\n * workspace package boundary in a monorepo.\n */\nexport function findProjectRoot(startDir: string = process.cwd()): string {\n const start = resolve(startDir)\n const { root: fsRoot } = parse(start)\n\n let firstPackageJson: string | null = null\n let cursor = start\n while (true) {\n for (const name of CONFIG_FILENAMES) {\n if (existsSync(resolve(cursor, name))) return cursor\n }\n if (firstPackageJson === null && existsSync(resolve(cursor, 'package.json'))) {\n firstPackageJson = cursor\n }\n if (cursor === fsRoot) break\n const parent = dirname(cursor)\n if (parent === cursor) break\n cursor = parent\n }\n\n return firstPackageJson ?? start\n}\n"],"mappings":";;;;;;;;;;sLAGA,MAAM,EAAmB,CAAC,iBAAkB,iBAAkB,kBAAmB,kBAAkB,EAiBnG,SAAgB,EAAgB,EAAmB,QAAQ,IAAI,EAAW,CACxE,IAAM,EAAQ,EAAQ,CAAQ,EACxB,CAAE,KAAM,GAAW,EAAM,CAAK,EAEhC,EAAkC,KAClC,EAAS,EACb,OAAa,CACX,IAAK,IAAM,KAAQ,EACjB,GAAI,EAAW,EAAQ,EAAQ,CAAI,CAAC,EAAG,OAAO,EAKhD,GAHI,IAAqB,MAAQ,EAAW,EAAQ,EAAQ,cAAc,CAAC,IACzE,EAAmB,GAEjB,IAAW,EAAQ,MACvB,IAAM,EAAS,EAAQ,CAAM,EAC7B,GAAI,IAAW,EAAQ,MACvB,EAAS,CACX,CAEA,OAAO,GAAoB,CAC7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.7.
|
|
2
|
+
* @forinda/kickjs-cli v8.7.5
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import*as e from"@clack/prompts";import t from"picocolors";const n={GET:t.green,POST:t.cyan,PUT:t.yellow,PATCH:t.magenta,DELETE:t.red};function r(e){return(n[e]??t.dim)(e.padEnd(7))}function i(e){let n=`[${e}]`.padEnd(10);switch(e){case`CRITICAL`:return t.red(n);case`WARNING`:return t.yellow(n);case`INFO`:return t.blue(t.dim(n));default:return n}}t.green(`✓`),t.red(`✖`),t.yellow(`⚠`),t.blue(`ℹ`);function a(n){e.intro(t.bgCyan(t.black(` ${n} `)))}function o(t){e.outro(t)}function s(t){e.isCancel(t)&&(e.cancel(`Operation cancelled.`),process.exit(0))}async function c(t){let n=await e.text(t);return s(n),n}async function l(t){let n=await e.select(t);return s(n),n}async function u(t){let n=await e.multiselect(t);return s(n),n}async function d(t){let n=await e.confirm(t);return s(n),n}function f(){return e.spinner()}const p=e.log;export{o as a,c,i as d,u as i,r as l,a as n,l as o,p as r,f as s,d as t,t as u};
|
|
12
|
-
//# sourceMappingURL=prompts-
|
|
12
|
+
//# sourceMappingURL=prompts-B5EAbTYl.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts-
|
|
1
|
+
{"version":3,"file":"prompts-B5EAbTYl.mjs","names":["colors"],"sources":["../src/utils/colors.ts","../src/utils/prompts.ts"],"sourcesContent":["import pc from 'picocolors'\n\nexport { pc as colors }\n\nconst METHOD_COLOR_MAP: Record<string, (s: string) => string> = {\n GET: pc.green,\n POST: pc.cyan,\n PUT: pc.yellow,\n PATCH: pc.magenta,\n DELETE: pc.red,\n}\n\n/** Color an HTTP method string for terminal display */\nexport function httpMethodColor(method: string): string {\n const fn = METHOD_COLOR_MAP[method] ?? pc.dim\n return fn(method.padEnd(7))\n}\n\n/** Color a severity tag for terminal display (padded to 10 chars) */\nexport function severityColor(severity: string): string {\n const tag = `[${severity}]`.padEnd(10)\n switch (severity) {\n case 'CRITICAL':\n return pc.red(tag)\n case 'WARNING':\n return pc.yellow(tag)\n case 'INFO':\n return pc.blue(pc.dim(tag))\n default:\n return tag\n }\n}\n","import * as clack from '@clack/prompts'\nimport { colors } from './colors'\n\nexport const symbols = {\n success: colors.green('✓'),\n error: colors.red('✖'),\n warning: colors.yellow('⚠'),\n info: colors.blue('ℹ'),\n}\n\n/** Show branded intro banner */\nexport function intro(title: string): void {\n clack.intro(colors.bgCyan(colors.black(` ${title} `)))\n}\n\n/** Show closing message */\nexport function outro(message: string): void {\n clack.outro(message)\n}\n\n/** Handle cancellation — print message and exit */\nfunction handleCancel(value: unknown): void {\n if (clack.isCancel(value)) {\n clack.cancel('Operation cancelled.')\n process.exit(0)\n }\n}\n\n/** Text input prompt */\nexport async function text(opts: {\n message: string\n placeholder?: string\n defaultValue?: string\n validate?: (value: string) => string | void\n}): Promise<string> {\n const value = await clack.text(opts as any)\n handleCancel(value)\n return value as string\n}\n\n/** Single select prompt */\nexport async function select<T>(opts: {\n message: string\n options: { value: T; label: string; hint?: string }[]\n initialValue?: T\n}): Promise<T> {\n const value = await clack.select(opts as any)\n handleCancel(value)\n return value as T\n}\n\n/** Multi-select prompt with checkboxes */\nexport async function multiSelect<T>(opts: {\n message: string\n options: { value: T; label: string; hint?: string }[]\n required?: boolean\n initialValues?: T[]\n}): Promise<T[]> {\n const value = await clack.multiselect(opts as any)\n handleCancel(value)\n return value as T[]\n}\n\n/** Yes/no confirmation prompt */\nexport async function confirm(opts: {\n message: string\n active?: string\n inactive?: string\n initialValue?: boolean\n}): Promise<boolean> {\n const value = await clack.confirm(opts)\n handleCancel(value)\n return value as boolean\n}\n\n/** Create a spinner for progress indication */\nexport function spinner() {\n return clack.spinner()\n}\n\n/** Log utilities for styled messages inside clack flow */\nexport const log = clack.log\n"],"mappings":";;;;;;;;;;2DAIA,MAAM,EAA0D,CAC9D,IAAK,EAAG,MACR,KAAM,EAAG,KACT,IAAK,EAAG,OACR,MAAO,EAAG,QACV,OAAQ,EAAG,GACb,EAGA,SAAgB,EAAgB,EAAwB,CAEtD,OADW,EAAiB,IAAW,EAAG,IAAA,CAChC,EAAO,OAAO,CAAC,CAAC,CAC5B,CAGA,SAAgB,EAAc,EAA0B,CACtD,IAAM,EAAM,IAAI,EAAS,GAAG,OAAO,EAAE,EACrC,OAAQ,EAAR,CACE,IAAK,WACH,OAAO,EAAG,IAAI,CAAG,EACnB,IAAK,UACH,OAAO,EAAG,OAAO,CAAG,EACtB,IAAK,OACH,OAAO,EAAG,KAAK,EAAG,IAAI,CAAG,CAAC,EAC5B,QACE,OAAO,CACX,CACF,CC3BWA,EAAO,MAAM,GAAG,EAClBA,EAAO,IAAI,GAAG,EACZA,EAAO,OAAO,GAAG,EACpBA,EAAO,KAAK,GAAG,EAIvB,SAAgB,EAAM,EAAqB,CACzC,EAAM,MAAMA,EAAO,OAAOA,EAAO,MAAM,IAAI,EAAM,EAAE,CAAC,CAAC,CACvD,CAGA,SAAgB,EAAM,EAAuB,CAC3C,EAAM,MAAM,CAAO,CACrB,CAGA,SAAS,EAAa,EAAsB,CACtC,EAAM,SAAS,CAAK,IACtB,EAAM,OAAO,sBAAsB,EACnC,QAAQ,KAAK,CAAC,EAElB,CAGA,eAAsB,EAAK,EAKP,CAClB,IAAM,EAAQ,MAAM,EAAM,KAAK,CAAW,EAE1C,OADA,EAAa,CAAK,EACX,CACT,CAGA,eAAsB,EAAU,EAIjB,CACb,IAAM,EAAQ,MAAM,EAAM,OAAO,CAAW,EAE5C,OADA,EAAa,CAAK,EACX,CACT,CAGA,eAAsB,EAAe,EAKpB,CACf,IAAM,EAAQ,MAAM,EAAM,YAAY,CAAW,EAEjD,OADA,EAAa,CAAK,EACX,CACT,CAGA,eAAsB,EAAQ,EAKT,CACnB,IAAM,EAAQ,MAAM,EAAM,QAAQ,CAAI,EAEtC,OADA,EAAa,CAAK,EACX,CACT,CAGA,SAAgB,GAAU,CACxB,OAAO,EAAM,QAAQ,CACvB,CAGA,MAAa,EAAM,EAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v8.7.
|
|
2
|
+
* @forinda/kickjs-cli v8.7.5
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
import{t as e}from"./rolldown-runtime-
|
|
11
|
+
import{t as e}from"./rolldown-runtime-D-zUBK7H.mjs";import{n as t,r as n,t as r}from"./fs-BZxW7vGY.mjs";import{a as i,c as a,d as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p,u as m}from"./prompts-B5EAbTYl.mjs";import{A as h,C as g,D as _,E as v,F as y,M as b,N as ee,O as x,P as S,S as te,T as ne,_ as re,a as ie,b as ae,c as oe,f as se,g as ce,h as le,i as ue,j as de,k as fe,l as pe,m as me,p as he,r as ge,u as _e,v as ve,w as ye,x as be,y as xe}from"./doctor-BNOcXL4A.mjs";import{d as Se,l as Ce,o as we,r as Te,s as Ee,t as De}from"./project-CCZI3qVg.mjs";import{a as Oe,c as ke,i as Ae,l as je,o as C,s as w,u as Me}from"./config-DQT4CMA_.mjs";import{t as T}from"./project-root-DotXmvyG.mjs";import{n as E,t as Ne}from"./types-CsAi8YRr.mjs";import{t as Pe}from"./build-lva8WFtm.mjs";import{n as Fe}from"./agent-docs-B3qf_4hD.mjs";import{C as Ie,S as Le,_ as Re,a as ze,b as Be,c as Ve,d as He,f as Ue,g as We,h as Ge,i as Ke,l as qe,m as Je,o as Ye,p as Xe,r as Ze,s as Qe,t as $e,u as et,v as tt,w as nt,x as D,y as rt}from"./typegen-DCQXDET7.mjs";import{createRequire as it}from"node:module";import O,{basename as at,dirname as k,join as A,relative as j,resolve as M,sep as N}from"node:path";import{cpSync as ot,existsSync as P,mkdirSync as st,readFileSync as F,readdirSync as ct,rmSync as lt,writeFileSync as I}from"node:fs";import{copyFile as ut,mkdir as dt,readFile as L,readdir as ft,rm as pt,stat as mt,writeFile as R}from"node:fs/promises";import{fork as ht,spawn as gt,spawnSync as _t}from"node:child_process";import{fileURLToPath as vt,pathToFileURL as z}from"node:url";import{parseSync as yt}from"oxc-parser";import{arch as bt,platform as xt,release as St}from"node:os";import{createHash as Ct}from"node:crypto";const wt=[{value:`swagger`,label:`Swagger`,hint:`OpenAPI docs`},{value:`ws`,label:`WebSocket`,hint:`rooms, heartbeat`},{value:`queue`,label:`Queue`,hint:`BullMQ/RabbitMQ/Kafka`},{value:`devtools`,label:`DevTools`,hint:`debug dashboard`}];function Tt(e){e.command(`new [name]`).alias(`init`).description(`Create a new KickJS project (use "." for current directory)`).option(`-d, --directory <dir>`,`Target directory (defaults to project name)`).option(`--pm <manager>`,`Package manager: pnpm | npm | yarn | bun`).option(`--git`,`Initialize git repository`).option(`--no-git`,`Skip git initialization`).option(`--install`,`Install dependencies after scaffolding`).option(`--no-install`,`Skip dependency installation`).option(`-f, --force`,`Remove existing files without prompting`).option(`-t, --template <type>`,`Project template: rest | minimal | fullstack`).option(`--runtime <engine>`,`HTTP runtime: express | fastify | h3`).option(`-r, --repo <type>`,`Repository name (inmemory, or any DB name e.g. postgres)`).option(`-s, --schema <lib>`,`Schema library for env / DTOs: zod | valibot | yup (default: zod)`).option(`--frontend <kind>`,`Fullstack web/ scaffold: 'kick' (wired React app) or 'vite' (create-vite, unwired)`).option(`--vite-template <name>`,`create-vite TypeScript template for --frontend vite (default 'react-ts')`).option(`--packages <packages>`,`Comma-separated packages to include (e.g. swagger,ws,queue,devtools)`).option(`-y, --yes`,`Pick safe defaults for every prompt (template=minimal, repo=inmemory, no extras, git+install on)`).option(`--non-interactive`,`alias for --yes`).action(async(e,t)=>{l(`KickJS — Create a new project`);let n=!!(t.yes||t.nonInteractive);e||=n?`my-api`:await a({message:`Project name`,placeholder:`my-api`,defaultValue:`my-api`});let r;if(e===`.`?(r=M(`.`),e=at(r)):r=M(t.directory||e),P(r)){let a=ct(r);if(a.length>0){if(t.force)d.warn(`Clearing existing files in ${r}`);else if(n){d.warn(`Directory "${e}" is not empty. Pass --force to clear it.`),i(`Aborted.`);return}else{d.warn(`Directory "${e}" is not empty:`);let t=a.slice(0,5);for(let e of t)d.message(` - ${e}`);if(a.length>5&&d.message(` ... and ${a.length-5} more`),!await p({message:m.red(`Remove all existing files and proceed?`),initialValue:!1})){i(`Aborted.`);return}}for(let e of a)lt(M(r,e),{recursive:!0,force:!0})}}let o=t.template;o||=n?`minimal`:await u({message:`Project template`,options:[{value:`rest`,label:`REST API`,hint:`Express + Swagger`},{value:`minimal`,label:`Minimal`,hint:`bare Express`},{value:`fullstack`,label:`Fullstack`,hint:`server + Vite React web, typed client`}]});let c=t.runtime;c||=n?`express`:await u({message:`HTTP runtime`,options:[{value:`express`,label:`Express`,hint:`default, zero-config`},{value:`fastify`,label:`Fastify`,hint:`fastify + @fastify/middie`},{value:`h3`,label:`h3`,hint:`Nitro / Nuxt engine`}]});let f=t.pm;f||=n?await Ce(void 0):await u({message:`Package manager`,options:[{value:`pnpm`,label:`pnpm`},{value:`npm`,label:`npm`},{value:`yarn`,label:`yarn`},{value:`bun`,label:`bun`}]});let h=t.repo;h||=n?`inmemory`:await a({message:`Repository name`,placeholder:`inmemory (or a DB name, e.g. postgres)`,defaultValue:`inmemory`}),Me(h);let g=t.schema;g||=n?`zod`:await u({message:`Schema library (env + DTO validation)`,options:[{value:`zod`,label:`Zod`,hint:`default — broad ecosystem`},{value:`valibot`,label:`Valibot`,hint:`smaller bundle`},{value:`yup`,label:`Yup`,hint:`classic API`}]}),[`zod`,`valibot`,`yup`].includes(g)||(d.warn(`Unknown --schema "${g}", falling back to zod.`),g=`zod`);let _;if(t.packages!==void 0){let e=t.packages.trim().toLowerCase();_=e===``||e===`none`||e===`false`?[]:t.packages.split(`,`).map(e=>e.trim()).filter(Boolean)}else _=n?[]:await s({message:`Select packages to include`,options:[...wt],required:!1});let v;v=t.git===void 0?n?!0:await p({message:`Initialize git repository?`,initialValue:!0}):t.git;let y;if(y=t.install===void 0?n?!0:await p({message:`Install dependencies?`,initialValue:!0}):t.install,t.frontend!==void 0&&t.frontend!==`kick`&&t.frontend!==`vite`){d.error(`Unknown --frontend '${String(t.frontend)}'. Use 'kick' (wired React app) or 'vite' (create-vite).`),i(`Aborted.`);return}let{VITE_TEMPLATES:b,DEFAULT_VITE_TEMPLATE:ee}=await import(`./fullstack-BHD2K7By.mjs`);if(t.viteTemplate!==void 0&&!b.some(e=>e.value===t.viteTemplate)){d.error(`Unknown --vite-template '${String(t.viteTemplate)}'. TypeScript templates only: ${b.map(e=>e.value).join(`, `)}.`),i(`Aborted.`);return}let x=t.frontend===`vite`?`vite`:`kick`,S=t.viteTemplate??ee;if(o===`fullstack`&&!t.frontend&&!n&&(x=await u({message:`Frontend for web/`,options:[{value:`kick`,label:`KickJS React app`,hint:`typed client, /api proxy, route types — wired`},{value:`vite`,label:`Delegate to create-vite`,hint:`pick any framework; wiring is manual (guide printed after)`}]})),x===`vite`&&!t.viteTemplate&&!n&&(S=await u({message:`create-vite template`,options:b.map(e=>({value:e.value,label:e.label})),initialValue:ee})),o===`fullstack`){let{initFullstackProject:t}=await import(`./fullstack-BHD2K7By.mjs`);await t({name:e,directory:r,packageManager:f,initGit:v,installDeps:y,schemaLib:g,runtime:c,packages:_,frontend:x,viteTemplate:S}),i(`Done! Next steps: ${m.cyan(`cd ${e} && ${f}${f===`pnpm`?` dev`:` run dev:server`}`)}`);return}await De({name:e,directory:r,packageManager:f,initGit:v,installDeps:y,template:o,defaultRepo:h,packages:_,schemaLib:g,runtime:c}),i(`Done! Next steps: ${m.cyan(`cd ${e} && ${f} dev`)}`)})}function B(e,t=[]){let n=new Map;for(let t of e){let e=(n.get(t.name)??0)+1;if(n.set(t.name,e),e===2)throw new Ne(`plugin`,t.name,[t.name,t.name])}let r=new Map,i=[];for(let t of e)for(let e of t.commands??[]){let n=r.get(e.name);if(n)throw new Ne(`command`,e.name,[n,t.name]);r.set(e.name,t.name),i.push(e)}let a=new Set(t.map(e=>e.name)),o=[...i.filter(e=>!a.has(e.name)),...t],s=new Map,c=[];for(let t of e)for(let e of t.typegens??[]){let n=s.get(e.id);if(n)throw new Ne(`typegen`,e.id,[n,t.name]);s.set(e.id,t.name),c.push(e)}let l=new Map,u=[];for(let t of e)for(let e of t.generators??[]){let n=l.get(e.name);if(n)throw new Ne(`generator`,e.name,[n,t.name]);l.set(e.name,t.name),u.push({source:t.name,spec:e})}return{commands:o,typegens:c,generators:u,register:async(t,n)=>{let r;if(n)r={generators:u,...n};else{let{findProjectRoot:e}=await import(`./project-root-DotXmvyG.mjs`).then(e=>e.n),t=process.cwd();r={cwd:t,projectRoot:e(t),config:null,log:()=>{},generators:u}}for(let n of e)n.register&&await n.register(t,r)}}}async function Et(e){let{name:t,outDir:r}=e,i=S(t),a=y(t),o=[],s=A(r,`${i}.plugin.ts`);return await n(s,`import {
|
|
12
12
|
definePlugin,
|
|
13
13
|
type AppAdapter,
|
|
14
14
|
type AppModuleEntry,
|
|
@@ -273,7 +273,7 @@ ${p}
|
|
|
273
273
|
`||e[l]===`\r`);)l++;let u=e.slice(l),d=/build\s*:\s*\([^)]*\)\s*=>\s*\(\s*\{/g.exec(s);if(!d)return{migrated:null,reason:`build: () => ({...}) not found in defineModule`};let f=d.index+d[0].length-1,p=At(s,f);if(p===-1)return{migrated:null,reason:`unbalanced build() braces`};let m=s.slice(f+1,p),h=V(m,/register\s*\(([^)]*)\)\s*\{/),g=V(m,/contributors\s*\(\s*\)\s*\{/),_=V(m,/routes\s*\(\s*\)\s*\{/);if(!_)return{migrated:null,reason:`routes() method missing inside build()`};let v=Mt(c,{container:h!==null,appModule:!0,moduleRoutes:!0,contributorRegistrations:g!==null}),y=``;return h!==null&&(y+=` register(container: Container): void {${H(h,6,4)} }\n\n`),g!==null&&(y+=` contributors(): ContributorRegistrations {${H(g,6,4)} }\n\n`),y+=` routes(): ModuleRoutes {${H(_,6,4)} }`,{migrated:`${v}${`export class ${r} implements AppModule {
|
|
274
274
|
${y}
|
|
275
275
|
}
|
|
276
|
-
`}${u}`}}function Ft(e,t){return t===`class`?Pt(e):Nt(e)}function It(e,t){let n=e,r=!1;if(t===`define`){/\bAppModuleClass\b/.test(n)&&(n=n.replaceAll(/\bAppModuleClass\b/g,`AppModuleEntry`),r=!0);let e=/(=\s*\[)([\s\S]*?)(])/,t=e.exec(n);if(t){let i=t[1],a=t[3],o=t[2],s=o.replaceAll(/(\b\w+Module)(?![(.])/g,`$1()`);s!==o&&(n=n.replace(e,`${i}${s}${a}`),r=!0)}}else{/\bAppModuleEntry\b/.test(n)&&(n=n.replaceAll(/\bAppModuleEntry\b/g,`AppModuleClass`),r=!0);let e=/(=\s*\[)([\s\S]*?)(])/,t=e.exec(n);if(t){let i=t[1],a=t[3],o=t[2],s=o.replaceAll(/(\b\w+Module)\s*\(\s*\)/g,`$1`);s!==o&&(n=n.replace(e,`${i}${s}${a}`),r=!0)}}return r?{migrated:n}:{migrated:null,reason:`no changes needed`}}async function Lt(e){let t=[];return await n(M(e),0),t;async function n(e,r){let i;try{i=await ft(e)}catch{return}for(let a of i){if(a===`node_modules`||a===`dist`||a===`.kickjs`)continue;let i=A(e,a),o;try{o=await mt(i)}catch{continue}o.isDirectory()?await n(i,r+1):(a.endsWith(`.module.ts`)||a===`index.ts`&&r===1)&&t.push(i)}}}async function Rt(e,t){let n=0;return await r(e,t),n;async function r(e,t){let i;try{i=await ft(e)}catch{return}await dt(t,{recursive:!0});for(let a of i){if(a===`node_modules`||a===`dist`||a===`.kickjs`)continue;let i=A(e,a),o=A(t,a),s;try{s=await mt(i)}catch{continue}s.isDirectory()?await r(i,o):(await ut(i,o),n++)}}}function zt(e){let t=new Date().toISOString().replaceAll(/[:.]/g,`-`);return A(e,`.kickjs`,`codemod-backups`,`${t}-modules`)}async function Bt(e,t){let{dryRun:n=!1,cwd:r=process.cwd(),target:i}=t,a=t.backup??!n,o=await Lt(e),s=await L(A(e,`index.ts`),`utf-8`).then(()=>!0,()=>!1),c=null;a&&(o.length>0||s)&&(c=zt(r),await Rt(e,c));let l=[];for(let e of o){let t=Ft(await L(e,`utf-8`),i);if(t.migrated==null){l.push({path:e,status:`skipped`,reason:t.reason});continue}n||await R(e,t.migrated,`utf-8`),l.push({path:e,status:`migrated`})}let u=A(e,`index.ts`),d=null;try{d=await L(u,`utf-8`)}catch{return{target:i,files:l,indexStatus:`not-found`,indexPath:u,backupDir:c}}let f=It(d,i);return f.migrated==null?{target:i,files:l,indexStatus:`skipped`,indexPath:u,indexReason:f.reason,backupDir:c}:(n||await R(u,f.migrated,`utf-8`),{target:i,files:l,indexStatus:`migrated`,indexPath:u,backupDir:c})}async function Vt(e,t){let n=await Lt(e),r=[],i=t===`define`?/export\s+class\s+\w+Module\s+implements\s+AppModule\s*\{/:/export\s+const\s+\w+Module\s*=\s*defineModule\s*\(/;for(let e of n){let t=await L(e,`utf-8`);i.test(t)&&r.push(e)}return r}const Ht={string:{ts:`string`,zod:`z.string()`},text:{ts:`string`,zod:`z.string()`},number:{ts:`number`,zod:`z.number()`},int:{ts:`number`,zod:`z.number().int()`},float:{ts:`number`,zod:`z.number()`},boolean:{ts:`boolean`,zod:`z.boolean()`},date:{ts:`string`,zod:`z.
|
|
276
|
+
`}${u}`}}function Ft(e,t){return t===`class`?Pt(e):Nt(e)}function It(e,t){let n=e,r=!1;if(t===`define`){/\bAppModuleClass\b/.test(n)&&(n=n.replaceAll(/\bAppModuleClass\b/g,`AppModuleEntry`),r=!0);let e=/(=\s*\[)([\s\S]*?)(])/,t=e.exec(n);if(t){let i=t[1],a=t[3],o=t[2],s=o.replaceAll(/(\b\w+Module)(?![(.])/g,`$1()`);s!==o&&(n=n.replace(e,`${i}${s}${a}`),r=!0)}}else{/\bAppModuleEntry\b/.test(n)&&(n=n.replaceAll(/\bAppModuleEntry\b/g,`AppModuleClass`),r=!0);let e=/(=\s*\[)([\s\S]*?)(])/,t=e.exec(n);if(t){let i=t[1],a=t[3],o=t[2],s=o.replaceAll(/(\b\w+Module)\s*\(\s*\)/g,`$1`);s!==o&&(n=n.replace(e,`${i}${s}${a}`),r=!0)}}return r?{migrated:n}:{migrated:null,reason:`no changes needed`}}async function Lt(e){let t=[];return await n(M(e),0),t;async function n(e,r){let i;try{i=await ft(e)}catch{return}for(let a of i){if(a===`node_modules`||a===`dist`||a===`.kickjs`)continue;let i=A(e,a),o;try{o=await mt(i)}catch{continue}o.isDirectory()?await n(i,r+1):(a.endsWith(`.module.ts`)||a===`index.ts`&&r===1)&&t.push(i)}}}async function Rt(e,t){let n=0;return await r(e,t),n;async function r(e,t){let i;try{i=await ft(e)}catch{return}await dt(t,{recursive:!0});for(let a of i){if(a===`node_modules`||a===`dist`||a===`.kickjs`)continue;let i=A(e,a),o=A(t,a),s;try{s=await mt(i)}catch{continue}s.isDirectory()?await r(i,o):(await ut(i,o),n++)}}}function zt(e){let t=new Date().toISOString().replaceAll(/[:.]/g,`-`);return A(e,`.kickjs`,`codemod-backups`,`${t}-modules`)}async function Bt(e,t){let{dryRun:n=!1,cwd:r=process.cwd(),target:i}=t,a=t.backup??!n,o=await Lt(e),s=await L(A(e,`index.ts`),`utf-8`).then(()=>!0,()=>!1),c=null;a&&(o.length>0||s)&&(c=zt(r),await Rt(e,c));let l=[];for(let e of o){let t=Ft(await L(e,`utf-8`),i);if(t.migrated==null){l.push({path:e,status:`skipped`,reason:t.reason});continue}n||await R(e,t.migrated,`utf-8`),l.push({path:e,status:`migrated`})}let u=A(e,`index.ts`),d=null;try{d=await L(u,`utf-8`)}catch{return{target:i,files:l,indexStatus:`not-found`,indexPath:u,backupDir:c}}let f=It(d,i);return f.migrated==null?{target:i,files:l,indexStatus:`skipped`,indexPath:u,indexReason:f.reason,backupDir:c}:(n||await R(u,f.migrated,`utf-8`),{target:i,files:l,indexStatus:`migrated`,indexPath:u,backupDir:c})}async function Vt(e,t){let n=await Lt(e),r=[],i=t===`define`?/export\s+class\s+\w+Module\s+implements\s+AppModule\s*\{/:/export\s+const\s+\w+Module\s*=\s*defineModule\s*\(/;for(let e of n){let t=await L(e,`utf-8`);i.test(t)&&r.push(e)}return r}const Ht={string:{ts:`string`,zod:`z.string()`},text:{ts:`string`,zod:`z.string()`},number:{ts:`number`,zod:`z.number()`},int:{ts:`number`,zod:`z.number().int()`},float:{ts:`number`,zod:`z.number()`},boolean:{ts:`boolean`,zod:`z.boolean()`},date:{ts:`string`,zod:`z.iso.datetime()`},email:{ts:`string`,zod:`z.email()`},url:{ts:`string`,zod:`z.url()`},uuid:{ts:`string`,zod:`z.uuid()`},json:{ts:`any`,zod:`z.any()`}};function Ut(e){let t=e.map(e=>{let t=e.indexOf(`:`);if(t===-1)throw Error(`Invalid field: "${e}". Use format: name:type (e.g. title:string)`);let n=e.slice(0,t),r=e.slice(t+1);if(!n||!r)throw Error(`Invalid field: "${e}". Use format: name:type (e.g. title:string)`);let i=!1;r.endsWith(`:optional`)&&(r=r.slice(0,-9),i=!0),n.endsWith(`?`)&&(n=n.slice(0,-1),i=!0),r.endsWith(`?`)&&(r=r.slice(0,-1),i=!0);let a=r;if(a.startsWith(`enum:`)){let e=a.slice(5).split(`,`);return{name:n,type:`enum`,tsType:e.map(e=>`'${e}'`).join(` | `),zodType:`z.enum([${e.map(e=>`'${e}'`).join(`, `)}])`,optional:i}}let o=Ht[a];if(!o){let e=[...Object.keys(Ht),`enum:a,b,c`].join(`, `);throw Error(`Unknown field type: "${a}". Valid types: ${e}`)}return{name:n,type:a,tsType:o.ts,zodType:o.zod,optional:i}}),n=new Set;for(let{name:e}of t){if(n.has(e))throw Error(`Duplicate field: "${e}". Each field name may appear once.`);n.add(e)}return t}async function Wt(e){let{name:t,fields:r,modulesDir:i,repo:a=`inmemory`,tokenScope:o=`app`,style:s=`define`}=e,c=e.pluralize!==!1,l=S(t),u=y(t),d=c?de(l):l,f=c?b(u):u,p=A(i,d),m=[],h=async(e,t)=>{let r=A(p,e);await n(r,t),m.push(r)};return await h(`${l}.module.ts`,fe({pascal:u,kebab:l,plural:d,repo:a,style:s})),await h(`${l}.constants.ts`,ne({pascal:u,kebab:l})),await h(`${l}.controller.ts`,x({pascal:u,kebab:l,plural:d,pluralPascal:f,swagger:e.swagger??!1})),await h(`${l}.service.ts`,v({pascal:u,kebab:l})),await h(`dtos/create-${l}.dto.ts`,Gt(u,r)),await h(`dtos/update-${l}.dto.ts`,Kt(u,r)),await h(`dtos/${l}-response.dto.ts`,qt(u,r)),await h(`${l}.repository.ts`,_({pascal:u,kebab:l,repoType:a,dtoPrefix:`./dtos`,tokenScope:o})),await be(i,u,d,l,s),m}function Gt(e,t){return`import { z } from 'zod'
|
|
277
277
|
|
|
278
278
|
export const create${e}Schema = z.object({
|
|
279
279
|
${t.map(e=>{let t=e.zodType;return` ${e.name}: ${t}${e.optional?`.optional()`:``},`}).join(`
|
|
@@ -678,7 +678,7 @@ server.on('exit', () => {
|
|
|
678
678
|
Cancelled.
|
|
679
679
|
`);return}await pt(l,{recursive:!0,force:!0}),console.log(` Deleted: ${l}`);let u=A(n,`index.ts`);if(await r(u)){let e=await L(u,`utf-8`),t=e,n=RegExp(`^import\\s*\\{\\s*${h(s)}Module\\s*\\}\\s*from\\s*['"][^'"]*${h(c)}(?:/[^'"]*)?['"].*\\n?`,`gm`);e=e.replace(n,``),e=ar(e,s),e=e.replace(/\n{3,}/g,`
|
|
680
680
|
|
|
681
|
-
`),e!==t&&(await R(u,e,`utf-8`),console.log(` Unregistered: ${s}Module from ${u}`))}console.log(`\n Module '${c}' removed.\n`)}function sr(e){e.command(`remove`).alias(`rm`).description(`Remove generated code`).command(`module <names...>`).description(`Remove one or more modules (e.g. kick rm module user task)`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular module name`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=await C(process.cwd()),r=w(n),i=t.modulesDir??r.dir??`src/modules`,a=t.pluralize===!1?!1:r.pluralize??!0;for(let n of e)await or({name:n,modulesDir:M(i),force:t.force,pluralize:a})})}function cr(e){if(e!==void 0){if(e===`false`||e===`off`||e===`none`)return!1;if(e===`zod`)return`zod`;if(e===`kickjs-schema`||e===`schema`)return`kickjs-schema`;console.warn(` kick typegen: unknown --schema-validator '${e}' (supported: 'zod', 'kickjs-schema', 'false'). Falling back to project config.`)}}function lr(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function ur(e){e.command(`typegen`).description(`Generate type-safe DI registry and module types into .kickjs/types/`).option(`-w, --watch`,`Watch source files and regenerate on change`).option(`-s, --src <dir>`,`Source directory to scan`,`src`).option(`-o, --out <dir>`,`Output directory`,`.kickjs/types`).option(`--silent`,`Suppress output`).option(`--allow-duplicates`,`Auto-namespace duplicate class names instead of failing (use with caution)`).option(`--schema-validator <name>`,`Schema validator for body/query/params typing (currently 'zod' or 'false')`).option(`--env-file <path>`,`Path to env schema file for KickEnv typing (default 'src/env.ts'; pass 'false' to disable)`).option(`--check`,`CI gate: exit non-zero if any generated file in .kickjs/types/ is out of date (routes, env, db, assets, adopter plugins) instead of writing it`).option(`--fix`,`Patch module import.meta.glob() calls to cover decorated classes that aren't loaded by any glob (orphans)`).option(`--list`,"List every registered typegen plugin id (use to populate `typegen.disable`)").option(`--no-cache`,`Disable the persistent scan cache; re-read + re-extract every file from cold`).action(async e=>{let t=T(process.cwd()),n=await C(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-
|
|
681
|
+
`),e!==t&&(await R(u,e,`utf-8`),console.log(` Unregistered: ${s}Module from ${u}`))}console.log(`\n Module '${c}' removed.\n`)}function sr(e){e.command(`remove`).alias(`rm`).description(`Remove generated code`).command(`module <names...>`).description(`Remove one or more modules (e.g. kick rm module user task)`).option(`--modules-dir <dir>`,`Modules directory`).option(`--no-pluralize`,`Use singular module name`).option(`-f, --force`,`Skip confirmation prompt`).action(async(e,t)=>{let n=await C(process.cwd()),r=w(n),i=t.modulesDir??r.dir??`src/modules`,a=t.pluralize===!1?!1:r.pluralize??!0;for(let n of e)await or({name:n,modulesDir:M(i),force:t.force,pluralize:a})})}function cr(e){if(e!==void 0){if(e===`false`||e===`off`||e===`none`)return!1;if(e===`zod`)return`zod`;if(e===`kickjs-schema`||e===`schema`)return`kickjs-schema`;console.warn(` kick typegen: unknown --schema-validator '${e}' (supported: 'zod', 'kickjs-schema', 'false'). Falling back to project config.`)}}function lr(e){if(e!==void 0)return e===`false`||e===`off`||e===`none`?!1:e}function ur(e){e.command(`typegen`).description(`Generate type-safe DI registry and module types into .kickjs/types/`).option(`-w, --watch`,`Watch source files and regenerate on change`).option(`-s, --src <dir>`,`Source directory to scan`,`src`).option(`-o, --out <dir>`,`Output directory`,`.kickjs/types`).option(`--silent`,`Suppress output`).option(`--allow-duplicates`,`Auto-namespace duplicate class names instead of failing (use with caution)`).option(`--schema-validator <name>`,`Schema validator for body/query/params typing (currently 'zod' or 'false')`).option(`--env-file <path>`,`Path to env schema file for KickEnv typing (default 'src/env.ts'; pass 'false' to disable)`).option(`--check`,`CI gate: exit non-zero if any generated file in .kickjs/types/ is out of date (routes, env, db, assets, adopter plugins) instead of writing it`).option(`--fix`,`Patch module import.meta.glob() calls to cover decorated classes that aren't loaded by any glob (orphans)`).option(`--list`,"List every registered typegen plugin id (use to populate `typegen.disable`)").option(`--no-cache`,`Disable the persistent scan cache; re-read + re-extract every file from cold`).action(async e=>{let t=T(process.cwd()),n=await C(t);if(e.list){let{mergeCliPlugins:e}=await import(`./plugin-KrSqxiyg.mjs`),{builtinCliPlugins:t}=await import(`./builtins-BjXFvkRo.mjs`),r=e([...t,...n?.plugins??[]],n?.commands??[]),i=new Set(n?.typegen?.disable??[]);if(r.typegens.length===0){console.log(` No typegen plugins registered.`);return}let a=Math.max(...r.typegens.map(e=>e.id.length));console.log(`
|
|
682
682
|
Registered typegen plugins:
|
|
683
683
|
`);for(let e of r.typegens){let t=i.has(e.id)?` (disabled)`:``,n=`${e.id.replace(/\//g,`__`)}${e.outExtension??`.d.ts`}`;console.log(` ${e.id.padEnd(a+2)}→ .kickjs/types/${n}${t}`),console.log(` ${` `.repeat(a+2)} watches: ${e.inputs.join(`, `)||`(none)`}`)}console.log(`
|
|
684
684
|
Disable one in kick.config.ts:
|
|
@@ -849,4 +849,4 @@ declare global {
|
|
|
849
849
|
export {}
|
|
850
850
|
`}const Li=()=>({id:`kick/env`,outExtension:`.ts`,inputs:[`src/env.ts`,`src/**/env.ts`,`src/**/*.env.ts`],async generate(e){let t=zi(e);if(t===!1)return null;let n=await e.getScanResult({root:Ri(e),cwd:e.cwd,envFile:t});if(!n.env)return null;let r=e.config?.typegen?.schemaValidator??`zod`,i=O.resolve(e.cwd,`.kickjs/types/kick__env.ts`);return Ii(n.env,i,r)}});function Ri(e){return O.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function zi(e){return e.config?.typegen?.envFile}function Bi(e){return O.resolve(e.cwd,e.config?.typegen?.srcDir??`src`)}function Vi(e){let t=e.config?.typegen?.envFile;if(t!==!1)return t}function $(e){return{root:Bi(e),cwd:e.cwd,envFile:Vi(e)}}const Hi=()=>({id:`kick/registry`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=O.resolve(e.cwd,`.kickjs/types/kick__registry.d.ts`),r=new Set(t.collisions.map(e=>e.className));return Ue(t.classes,n,r)}}),Ui=()=>({id:`kick/services`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e)),n=new Set(t.collisions.map(e=>e.className)),r=qe(t.classes,t.tokens,t.injects,n);return Je(`ServiceToken`,r,"(no tokens discovered — declare with createToken<T>() or `kick g service <name>`)")}}),Wi=()=>({id:`kick/modules`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return Je(`ModuleToken`,Ve(t.classes),"(no @Module classes discovered — `kick g module <name>` to add one)")}}),Gi=()=>({id:`kick/plugins`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return He(t.pluginsAndAdapters)}}),Ki=()=>({id:`kick/context`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return t.contextKeys.length===0?null:et(t.contextKeys)}}),qi=()=>({id:`kick/route-flags`,inputs:[`src/**/*.ts`],async generate(e){let t=await e.getScanResult($(e));return Xe(t.routeFlags)}}),Ji={fastify:{subpath:`@forinda/kickjs/fastify`,typeName:`FastifyRuntimeTypes`},h3:{subpath:`@forinda/kickjs/h3`,typeName:`H3RuntimeTypes`}},Yi=[E({name:`kick/init`,register:Tt}),E({name:`kick/generate`,register:rn}),E({name:`kick/run`,register:vn}),E({name:`kick/info`,register:Cn}),E({name:`kick/inspect`,register:Mn}),E({name:`kick/add`,register:we}),E({name:`kick/list`,register:Ee}),E({name:`kick/explain`,register:Vn}),E({name:`kick/mcp`,register:Zn}),E({name:`kick/tinker`,register:tr}),E({name:`kick/remove`,register:sr}),E({name:`kick/typegen`,register:ur}),E({name:`kick/check`,register:kr}),E({name:`kick/doctor`,register:ge}),E({name:`kick/codemod`,register:jr}),E({name:`kick/deploy`,register:Gr}),E({name:`kick/registry`,typegens:[Hi()]}),E({name:`kick/services`,typegens:[Ui()]}),E({name:`kick/modules`,typegens:[Wi()]}),E({name:`kick/plugins`,typegens:[Gi()]}),E({name:`kick/context`,typegens:[Ki()]}),E({name:`kick/route-flags`,typegens:[qi()]}),E({name:`kick/assets`,typegens:[Kr()]}),E({name:`kick/routes`,typegens:[ni()]}),E({name:`kick/client`,typegens:[Fi()]}),E({name:`kick/env`,typegens:[Li()]}),E({name:`kick/runtime`,typegens:[{id:`kick/runtime`,outExtension:`.ts`,inputs:[`kick.config.ts`,`kick.config.js`,`kick.config.mjs`,`kick.config.json`],async generate(e){let t=e.config?.runtime;if(t!==`fastify`&&t!==`h3`)return null;let{subpath:n,typeName:r}=Ji[t];return[`// Runtime escape-hatch types for the '${t}' engine (kick.config runtime).`,`declare module '@forinda/kickjs' {`,` interface KickRuntimeRegister {`,` runtime: import('${n}').${r}`,` }`,`}`,``,`export {}`,``].join(`
|
|
851
851
|
`)}}]})];export{ln as applyDisableFilter,un as n,B as r,G as runAllPluginTypegens,Yi as t};
|
|
852
|
-
//# sourceMappingURL=run-plugins-
|
|
852
|
+
//# sourceMappingURL=run-plugins-8wx6Jt8B.mjs.map
|