@forinda/kickjs-cli 5.0.1 → 5.1.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/builtins-Cb_d-b1S.mjs +8116 -0
- package/dist/builtins-caRjFvKz.mjs +3797 -0
- package/dist/builtins-caRjFvKz.mjs.map +1 -0
- package/dist/cli.mjs +19 -9297
- package/dist/config-8bAt-mLl.mjs +139 -0
- package/dist/config-C_LQNClP.mjs +141 -0
- package/dist/config-C_LQNClP.mjs.map +1 -0
- package/dist/generator-extension-CYY-RI21.mjs +4343 -0
- package/dist/generator-extension-CYY-RI21.mjs.map +1 -0
- package/dist/index.d.mts +232 -138
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -4159
- package/dist/plugin-Bgfg7qMk.mjs +80 -0
- package/dist/plugin-D8K5fG-O.mjs +71 -0
- package/dist/plugin-D8K5fG-O.mjs.map +1 -0
- package/dist/rolldown-runtime-BM29JyaJ.mjs +24 -0
- package/dist/run-plugins-BXvMFPhJ.mjs +12 -0
- package/dist/typegen-8ZeA1B-X.mjs +1532 -0
- package/dist/{typegen-Ebxm_Bhz.mjs.map → typegen-8ZeA1B-X.mjs.map} +1 -1
- package/dist/{typegen-Ebxm_Bhz.mjs → typegen-BNz_RQTb.mjs} +85 -5
- package/dist/types-BBUo1vXh.mjs +25 -0
- package/dist/types-BBUo1vXh.mjs.map +1 -0
- package/package.json +7 -3
- package/dist/index.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-cli v5.0
|
|
2
|
+
* @forinda/kickjs-cli v5.1.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
+
import { t as __exportAll } from "./rolldown-runtime-BM29JyaJ.mjs";
|
|
12
|
+
import { statSync } from "node:fs";
|
|
11
13
|
import { dirname, extname, join, relative, resolve, sep } from "node:path";
|
|
12
14
|
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
13
|
-
import { statSync } from "node:fs";
|
|
14
15
|
import { globSync } from "glob";
|
|
15
16
|
//#region src/typegen/scanner.ts
|
|
16
17
|
/** Decorators that mark a class as DI-managed */
|
|
@@ -1374,6 +1375,10 @@ function suggestRename(name) {
|
|
|
1374
1375
|
*
|
|
1375
1376
|
* @module @forinda/kickjs-cli/typegen
|
|
1376
1377
|
*/
|
|
1378
|
+
var typegen_exports = /* @__PURE__ */ __exportAll({
|
|
1379
|
+
runTypegen: () => runTypegen,
|
|
1380
|
+
watchTypegen: () => watchTypegen
|
|
1381
|
+
});
|
|
1377
1382
|
/** Resolve options to absolute paths */
|
|
1378
1383
|
function resolveOptions(opts) {
|
|
1379
1384
|
const cwd = opts.cwd ?? process.cwd();
|
|
@@ -1444,7 +1449,82 @@ async function runTypegen(opts = {}) {
|
|
|
1444
1449
|
tokenWarnings
|
|
1445
1450
|
};
|
|
1446
1451
|
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Watch mode for `kick typegen --watch`.
|
|
1454
|
+
*
|
|
1455
|
+
* Uses Node's built-in `fs.watch` (recursive, available on Linux 22+ and
|
|
1456
|
+
* macOS 19+). Falls back gracefully if recursive watch is not supported.
|
|
1457
|
+
*
|
|
1458
|
+
* Debounces re-runs by 100ms so a bulk file change (e.g. `kick g module`
|
|
1459
|
+
* creating 5 files at once) emits one regen, not five.
|
|
1460
|
+
*
|
|
1461
|
+
* In watch mode collisions are reported but never thrown — the watcher
|
|
1462
|
+
* keeps running so the user can fix the rename and the next scan
|
|
1463
|
+
* recovers automatically.
|
|
1464
|
+
*
|
|
1465
|
+
* Returns a `stop()` function that closes the watcher.
|
|
1466
|
+
*/
|
|
1467
|
+
async function watchTypegen(opts = {}) {
|
|
1468
|
+
const resolved = resolveOptions(opts);
|
|
1469
|
+
const { srcDir, silent, cwd } = resolved;
|
|
1470
|
+
const runOpts = {
|
|
1471
|
+
...resolved,
|
|
1472
|
+
allowDuplicates: true
|
|
1473
|
+
};
|
|
1474
|
+
const [{ runAllPluginTypegens }, { loadKickConfig }] = await Promise.all([import("./builtins-Cb_d-b1S.mjs").then((n) => n.r), import("./config-8bAt-mLl.mjs").then((n) => n.n)]);
|
|
1475
|
+
const pluginConfig = await loadKickConfig(cwd);
|
|
1476
|
+
const runPlugins = () => runAllPluginTypegens({
|
|
1477
|
+
cwd,
|
|
1478
|
+
config: pluginConfig,
|
|
1479
|
+
silent: true
|
|
1480
|
+
}).catch(() => {});
|
|
1481
|
+
await safeRun(runOpts, silent);
|
|
1482
|
+
await runPlugins();
|
|
1483
|
+
const { watch } = await import("node:fs");
|
|
1484
|
+
let timer = null;
|
|
1485
|
+
const trigger = (filename) => {
|
|
1486
|
+
if (!filename) return;
|
|
1487
|
+
if (!/\.(ts|tsx|mts|cts)$/.test(filename)) return;
|
|
1488
|
+
if (filename.includes(".kickjs")) return;
|
|
1489
|
+
if (filename.endsWith(".d.ts")) return;
|
|
1490
|
+
if (timer) clearTimeout(timer);
|
|
1491
|
+
timer = setTimeout(() => {
|
|
1492
|
+
safeRun(runOpts, silent);
|
|
1493
|
+
runPlugins();
|
|
1494
|
+
}, 100);
|
|
1495
|
+
};
|
|
1496
|
+
let watcher;
|
|
1497
|
+
try {
|
|
1498
|
+
watcher = watch(srcDir, { recursive: true }, (_event, filename) => {
|
|
1499
|
+
trigger(filename);
|
|
1500
|
+
});
|
|
1501
|
+
} catch (err) {
|
|
1502
|
+
if (!silent) console.warn(` kick typegen: watch mode unavailable (${err?.message ?? err}). Falling back to polling.`);
|
|
1503
|
+
const interval = setInterval(() => {
|
|
1504
|
+
safeRun({
|
|
1505
|
+
...runOpts,
|
|
1506
|
+
silent: true
|
|
1507
|
+
}, true);
|
|
1508
|
+
}, 2e3);
|
|
1509
|
+
return () => clearInterval(interval);
|
|
1510
|
+
}
|
|
1511
|
+
return () => {
|
|
1512
|
+
if (timer) clearTimeout(timer);
|
|
1513
|
+
watcher.close();
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
/** Run typegen swallowing errors so the watcher loop never dies */
|
|
1517
|
+
async function safeRun(opts, silent) {
|
|
1518
|
+
try {
|
|
1519
|
+
await runTypegen(opts);
|
|
1520
|
+
} catch (err) {
|
|
1521
|
+
if (silent) return;
|
|
1522
|
+
if (err instanceof TokenCollisionError) console.error("\n" + err.message + "\n");
|
|
1523
|
+
else {
|
|
1524
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1525
|
+
console.error(` kick typegen failed: ${msg}`);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1447
1529
|
//#endregion
|
|
1448
|
-
export { runTypegen };
|
|
1449
|
-
|
|
1450
|
-
//# sourceMappingURL=typegen-Ebxm_Bhz.mjs.map
|
|
1530
|
+
export { discoverAssets as a, TokenCollisionError as i, typegen_exports as n, renderAssetTypes as o, watchTypegen as r, runTypegen as t };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @forinda/kickjs-cli v5.1.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
|
+
//#region src/plugin/types.ts
|
|
12
|
+
/** Identity helper — exists for type inference + parity with definePlugin. */
|
|
13
|
+
function defineCliPlugin(p) {
|
|
14
|
+
return p;
|
|
15
|
+
}
|
|
16
|
+
var KickPluginConflictError = class extends Error {
|
|
17
|
+
constructor(kind, id, owners) {
|
|
18
|
+
super(`Two plugins registered the same ${kind} '${id}': ${owners.join(", ")}. Plugins must use unique ${kind} names.`);
|
|
19
|
+
this.name = "KickPluginConflictError";
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { defineCliPlugin as n, KickPluginConflictError as t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=types-BBUo1vXh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-BBUo1vXh.mjs","names":[],"sources":["../src/plugin/types.ts"],"sourcesContent":["// CLI Plugin shape.\n//\n// The kick CLI is itself a composition of plugins — every built-in\n// command (init, generate, run, typegen, db, …) ships as a KickCliPlugin\n// internally. Adopters extend the same surface from kick.config.ts to\n// add commands, generators, and typegens; the merging + conflict\n// detection runs the same way for built-ins and user plugins.\n//\n// Four contribution kinds:\n//\n// • commands[] — declarative shell-handler commands (same shape as\n// the existing kick.config.ts `commands` field).\n// • register() — programmatic commander registration. Called with\n// `(program, ctx)` so the callback has cwd + config\n// without re-loading.\n// • typegens[] — TypegenPlugin instances that `kick typegen` runs\n// after the legacy pass.\n// • generators[] — `kick g <name>` scaffolders (defineGenerator).\n// Replaces the `package.json > kickjs.generators`\n// discovery; that path stays as a deprecated\n// fallback for one minor version.\n//\n// Mirrors `definePlugin` / `defineAdapter` factory parity so adopters\n// don't have to learn a new helper-naming convention.\n\nimport type { Command } from 'commander'\n\nimport type { TypegenPlugin } from '../typegen/plugin'\nimport type { KickCommandDefinition, KickConfig } from '../config'\nimport type { GeneratorSpec } from '../generator-extension/define'\n\n/**\n * Runtime context handed to `register()` — saves callbacks from\n * re-loading config or guessing cwd. Forward-compatible: future fields\n * land here without changing the callback signature.\n */\nexport interface KickCliPluginContext {\n cwd: string\n /** Resolved kick.config.ts (null if the project has none). */\n config: KickConfig | null\n log: (msg: string) => void\n}\n\nexport interface KickCliPlugin {\n /** Stable identifier — used in error messages on conflict + de-dup. */\n name: string\n commands?: KickCommandDefinition[]\n /** Programmatic command registration. Called once at CLI startup. */\n register?: (program: Command, ctx: KickCliPluginContext) => void | Promise<void>\n typegens?: TypegenPlugin[]\n generators?: GeneratorSpec[]\n}\n\n/** Identity helper — exists for type inference + parity with definePlugin. */\nexport function defineCliPlugin(p: KickCliPlugin): KickCliPlugin {\n return p\n}\n\nexport class KickPluginConflictError extends Error {\n constructor(kind: 'plugin' | 'command' | 'typegen' | 'generator', id: string, owners: string[]) {\n super(\n `Two plugins registered the same ${kind} '${id}': ${owners.join(', ')}. ` +\n `Plugins must use unique ${kind} names.`,\n )\n this.name = 'KickPluginConflictError'\n }\n}\n"],"mappings":";;;;;;;;;;;;AAsDA,SAAgB,gBAAgB,GAAiC;AAC/D,QAAO;;AAGT,IAAa,0BAAb,cAA6C,MAAM;CACjD,YAAY,MAAsD,IAAY,QAAkB;AAC9F,QACE,mCAAmC,KAAK,IAAI,GAAG,KAAK,OAAO,KAAK,KAAK,CAAC,4BACzC,KAAK,SACnC;AACD,OAAK,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forinda/kickjs-cli",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "CLI for KickJS — project scaffolding, DDD module generation, dev/build/start",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kickjs",
|
|
@@ -67,16 +67,20 @@
|
|
|
67
67
|
"commander": "^14.0.3",
|
|
68
68
|
"glob": "^13.0.6",
|
|
69
69
|
"picocolors": "^1.1.1",
|
|
70
|
-
"pluralize": "^8.0.0"
|
|
70
|
+
"pluralize": "^8.0.0",
|
|
71
|
+
"@forinda/kickjs-db": "5.1.0"
|
|
71
72
|
},
|
|
72
73
|
"devDependencies": {
|
|
73
74
|
"@swc/core": "^1.15.30",
|
|
74
75
|
"@types/node": "^25.6.0",
|
|
76
|
+
"@types/pg": "^8.11.10",
|
|
75
77
|
"@types/pluralize": "^0.0.33",
|
|
78
|
+
"pg": "^8.13.1",
|
|
76
79
|
"typescript": "^6.0.3",
|
|
77
80
|
"vite": "^8.0.9",
|
|
78
81
|
"vitest": "^4.1.5",
|
|
79
|
-
"@forinda/kickjs-ai": "5.0
|
|
82
|
+
"@forinda/kickjs-ai": "5.1.0",
|
|
83
|
+
"@forinda/kickjs-db-pg": "5.1.0"
|
|
80
84
|
},
|
|
81
85
|
"publishConfig": {
|
|
82
86
|
"access": "public"
|