@forinda/kickjs-cli 5.2.0 → 5.2.3

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.
Files changed (34) hide show
  1. package/dist/builtins-BdvmVAJ1.mjs +3740 -0
  2. package/dist/builtins-Du70nybS.mjs +1066 -0
  3. package/dist/builtins-Du70nybS.mjs.map +1 -0
  4. package/dist/cli.mjs +2 -120
  5. package/dist/config-Dzw8Ws4d.mjs +11 -0
  6. package/dist/config-lCKbrRnt.mjs +12 -0
  7. package/dist/{config-DDrgs-I3.mjs.map → config-lCKbrRnt.mjs.map} +1 -1
  8. package/dist/generator-extension-Cp5FUUAw.mjs +2687 -0
  9. package/dist/generator-extension-Cp5FUUAw.mjs.map +1 -0
  10. package/dist/index.mjs +2 -5
  11. package/dist/plugin-Dv2gKsuC.mjs +11 -0
  12. package/dist/plugin-VPl_QQGb.mjs +12 -0
  13. package/dist/{plugin-6_YlK-JG.mjs.map → plugin-VPl_QQGb.mjs.map} +1 -1
  14. package/dist/rolldown-runtime-B6QC8dMY.mjs +11 -0
  15. package/dist/{run-plugins-B1R0HG0g.mjs → run-plugins-CM1Af-4B.mjs} +2 -3
  16. package/dist/typegen-C6ZfoYTC.mjs +114 -0
  17. package/dist/typegen-CBI7dNXr.mjs +115 -0
  18. package/dist/{typegen-DugZmi-0.mjs.map → typegen-CBI7dNXr.mjs.map} +1 -1
  19. package/dist/types-n4LRUF_c.mjs +12 -0
  20. package/dist/{types-CGB8BiQh.mjs.map → types-n4LRUF_c.mjs.map} +1 -1
  21. package/package.json +5 -5
  22. package/dist/builtins-BW3g09hP.mjs +0 -8538
  23. package/dist/builtins-C_VfEGdg.mjs +0 -4182
  24. package/dist/builtins-C_VfEGdg.mjs.map +0 -1
  25. package/dist/config-DDrgs-I3.mjs +0 -171
  26. package/dist/config-DsQe2yzy.mjs +0 -169
  27. package/dist/generator-extension-DRNQpoZP.mjs +0 -4380
  28. package/dist/generator-extension-DRNQpoZP.mjs.map +0 -1
  29. package/dist/plugin-6_YlK-JG.mjs +0 -71
  30. package/dist/plugin-CQ0yYXyr.mjs +0 -80
  31. package/dist/rolldown-runtime-CYBbkZNy.mjs +0 -24
  32. package/dist/typegen-CYCsmCRF.mjs +0 -1351
  33. package/dist/typegen-DugZmi-0.mjs +0 -1353
  34. package/dist/types-CGB8BiQh.mjs +0 -25
@@ -1,171 +0,0 @@
1
- /**
2
- * @forinda/kickjs-cli v5.2.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 { t as __exportAll } from "./rolldown-runtime-CYBbkZNy.mjs";
12
- import { isAbsolute, join, relative, resolve } from "node:path";
13
- import { existsSync, readFileSync } from "node:fs";
14
- import { access, readFile } from "node:fs/promises";
15
- //#region src/config.ts
16
- var config_exports = /* @__PURE__ */ __exportAll({
17
- BUILTIN_REPO_TYPES: () => BUILTIN_REPO_TYPES,
18
- PACKAGE_MANAGERS: () => PACKAGE_MANAGERS,
19
- defineConfig: () => defineConfig,
20
- loadKickConfig: () => loadKickConfig,
21
- resolveModuleConfig: () => resolveModuleConfig,
22
- resolveTokenScope: () => resolveTokenScope,
23
- validateAssetMap: () => validateAssetMap
24
- });
25
- const PACKAGE_MANAGERS = [
26
- "pnpm",
27
- "npm",
28
- "yarn",
29
- "bun"
30
- ];
31
- const BUILTIN_REPO_TYPES = [
32
- "drizzle",
33
- "inmemory",
34
- "prisma"
35
- ];
36
- /** Helper to define a type-safe kick.config.ts */
37
- function defineConfig(config) {
38
- return config;
39
- }
40
- /** Resolve module config from `modules.*` block. */
41
- /**
42
- * Resolve the project's DI token scope for code generators.
43
- * Falls back through kick.config.ts → package.json → `'app'`.
44
- *
45
- * @param config Loaded `kick.config.ts` (null when not present)
46
- * @param cwd Project root — used to read package.json
47
- */
48
- function resolveTokenScope(config, cwd) {
49
- if (config?.tokenScope && typeof config.tokenScope === "string" && config.tokenScope.length > 0) {
50
- const sanitised = sanitizeScope(config.tokenScope);
51
- if (sanitised.length > 0) return sanitised;
52
- }
53
- try {
54
- const pkgPath = join(cwd, "package.json");
55
- if (existsSync(pkgPath)) {
56
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
57
- if (typeof pkg.name === "string" && pkg.name.length > 0) {
58
- const scoped = pkg.name.match(/^@([^/]+)\//);
59
- const candidate = scoped ? sanitizeScope(scoped[1]) : sanitizeScope(pkg.name);
60
- if (candidate.length > 0) return candidate;
61
- }
62
- }
63
- } catch {}
64
- return "app";
65
- }
66
- /** Lowercase + strip characters that would break a token literal. */
67
- function sanitizeScope(raw) {
68
- return raw.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
69
- }
70
- function resolveModuleConfig(config) {
71
- if (!config) return {};
72
- const mc = {
73
- dir: config.modules?.dir,
74
- repo: config.modules?.repo,
75
- schemaDir: config.modules?.schemaDir,
76
- pluralize: config.modules?.pluralize,
77
- prismaClientPath: config.modules?.prismaClientPath
78
- };
79
- if (mc.repo && typeof mc.repo === "string" && !BUILTIN_REPO_TYPES.includes(mc.repo)) console.warn(` Warning: modules.repo '${mc.repo}' is not a built-in type (${BUILTIN_REPO_TYPES.join(", ")}). It will generate a stub repository. Use { name: '${mc.repo}' } to silence this warning.`);
80
- return mc;
81
- }
82
- const CONFIG_FILES = [
83
- "kick.config.ts",
84
- "kick.config.js",
85
- "kick.config.mjs",
86
- "kick.config.json"
87
- ];
88
- /** Load kick.config.* from the project root */
89
- async function loadKickConfig(cwd) {
90
- for (const filename of CONFIG_FILES) {
91
- const filepath = join(cwd, filename);
92
- try {
93
- await access(filepath);
94
- } catch {
95
- continue;
96
- }
97
- if (filename.endsWith(".json")) {
98
- const content = await readFile(filepath, "utf-8");
99
- return JSON.parse(content);
100
- }
101
- try {
102
- const { pathToFileURL } = await import("node:url");
103
- const mod = await import(pathToFileURL(filepath).href);
104
- const config = mod.default ?? mod;
105
- const warnings = validateAssetMap(config, cwd);
106
- for (const warning of warnings) console.warn(` Warning: ${warning}`);
107
- return config;
108
- } catch {
109
- if (filename.endsWith(".ts")) console.warn(`Warning: Failed to load ${filename}. TypeScript config files require a runtime loader (e.g. tsx, ts-node) or use kick.config.js/.mjs instead.`);
110
- continue;
111
- }
112
- }
113
- return null;
114
- }
115
- /**
116
- * Validate `assetMap` entries on a loaded config. Returns a list of
117
- * human-readable warnings; the caller decides how to surface them
118
- * (typically `console.warn`). Never throws — `kick g` and other
119
- * unrelated commands should keep working even when the assetMap is
120
- * misconfigured.
121
- *
122
- * Checks:
123
- *
124
- * - Each entry's `src` is a non-empty string.
125
- * - The `src` directory exists on disk (otherwise the typegen + build
126
- * steps will fail later with cryptic errors).
127
- * - `dest` doesn't escape the project root (defensive — a `dest:
128
- * '../../etc'` typo could write files outside the workspace).
129
- * - The namespace key is a non-empty string and doesn't include a
130
- * `/` (would conflict with the `<namespace>/<key>` manifest format).
131
- */
132
- function validateAssetMap(config, cwd) {
133
- const warnings = [];
134
- if (!config?.assetMap) return warnings;
135
- const root = resolve(cwd);
136
- for (const [namespace, entry] of Object.entries(config.assetMap)) {
137
- if (!namespace || namespace.includes("/")) {
138
- warnings.push(`assetMap key '${namespace}' is invalid — must be a non-empty string without '/'`);
139
- continue;
140
- }
141
- if (typeof entry?.src !== "string" || entry.src.length === 0) {
142
- warnings.push(`assetMap.${namespace} is missing a non-empty 'src' field`);
143
- continue;
144
- }
145
- if (!existsSync(resolve(cwd, entry.src))) warnings.push(`assetMap.${namespace}.src ('${entry.src}') does not exist — typegen + build will fail`);
146
- if (entry.dest) {
147
- if (escapesRoot(resolve(cwd, entry.dest), root)) warnings.push(`assetMap.${namespace}.dest ('${entry.dest}') resolves outside the project root — refusing to copy`);
148
- }
149
- }
150
- return warnings;
151
- }
152
- /**
153
- * Returns true when `path` (absolute) resolves outside of `root`
154
- * (also absolute). Uses `path.relative` for accuracy:
155
- *
156
- * - The result is empty when paths are identical (inside).
157
- * - It starts with `..` when the path traverses outside the root.
158
- * - It's absolute (Windows: cross-drive) when there's no relative
159
- * path between them.
160
- *
161
- * Avoids the prefix-match pitfalls of `startsWith` (e.g. `/app`
162
- * matching `/app2/...`, or case-mismatches on macOS / Windows).
163
- */
164
- function escapesRoot(path, root) {
165
- const rel = relative(root, path);
166
- return rel === "" ? false : rel.startsWith("..") || isAbsolute(rel);
167
- }
168
- //#endregion
169
- export { resolveModuleConfig as a, loadKickConfig as i, config_exports as n, resolveTokenScope as o, defineConfig as r, PACKAGE_MANAGERS as t };
170
-
171
- //# sourceMappingURL=config-DDrgs-I3.mjs.map
@@ -1,169 +0,0 @@
1
- /**
2
- * @forinda/kickjs-cli v5.2.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 { t as __exportAll } from "./rolldown-runtime-CYBbkZNy.mjs";
12
- import { existsSync, readFileSync } from "node:fs";
13
- import { isAbsolute, join, relative, resolve } from "node:path";
14
- import { access, readFile } from "node:fs/promises";
15
- //#region src/config.ts
16
- var config_exports = /* @__PURE__ */ __exportAll({
17
- BUILTIN_REPO_TYPES: () => BUILTIN_REPO_TYPES,
18
- PACKAGE_MANAGERS: () => PACKAGE_MANAGERS,
19
- defineConfig: () => defineConfig,
20
- loadKickConfig: () => loadKickConfig,
21
- resolveModuleConfig: () => resolveModuleConfig,
22
- resolveTokenScope: () => resolveTokenScope,
23
- validateAssetMap: () => validateAssetMap
24
- });
25
- const PACKAGE_MANAGERS = [
26
- "pnpm",
27
- "npm",
28
- "yarn",
29
- "bun"
30
- ];
31
- const BUILTIN_REPO_TYPES = [
32
- "drizzle",
33
- "inmemory",
34
- "prisma"
35
- ];
36
- /** Helper to define a type-safe kick.config.ts */
37
- function defineConfig(config) {
38
- return config;
39
- }
40
- /** Resolve module config from `modules.*` block. */
41
- /**
42
- * Resolve the project's DI token scope for code generators.
43
- * Falls back through kick.config.ts → package.json → `'app'`.
44
- *
45
- * @param config Loaded `kick.config.ts` (null when not present)
46
- * @param cwd Project root — used to read package.json
47
- */
48
- function resolveTokenScope(config, cwd) {
49
- if (config?.tokenScope && typeof config.tokenScope === "string" && config.tokenScope.length > 0) {
50
- const sanitised = sanitizeScope(config.tokenScope);
51
- if (sanitised.length > 0) return sanitised;
52
- }
53
- try {
54
- const pkgPath = join(cwd, "package.json");
55
- if (existsSync(pkgPath)) {
56
- const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
57
- if (typeof pkg.name === "string" && pkg.name.length > 0) {
58
- const scoped = pkg.name.match(/^@([^/]+)\//);
59
- const candidate = scoped ? sanitizeScope(scoped[1]) : sanitizeScope(pkg.name);
60
- if (candidate.length > 0) return candidate;
61
- }
62
- }
63
- } catch {}
64
- return "app";
65
- }
66
- /** Lowercase + strip characters that would break a token literal. */
67
- function sanitizeScope(raw) {
68
- return raw.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, "-");
69
- }
70
- function resolveModuleConfig(config) {
71
- if (!config) return {};
72
- const mc = {
73
- dir: config.modules?.dir,
74
- repo: config.modules?.repo,
75
- schemaDir: config.modules?.schemaDir,
76
- pluralize: config.modules?.pluralize,
77
- prismaClientPath: config.modules?.prismaClientPath
78
- };
79
- if (mc.repo && typeof mc.repo === "string" && !BUILTIN_REPO_TYPES.includes(mc.repo)) console.warn(` Warning: modules.repo '${mc.repo}' is not a built-in type (${BUILTIN_REPO_TYPES.join(", ")}). It will generate a stub repository. Use { name: '${mc.repo}' } to silence this warning.`);
80
- return mc;
81
- }
82
- const CONFIG_FILES = [
83
- "kick.config.ts",
84
- "kick.config.js",
85
- "kick.config.mjs",
86
- "kick.config.json"
87
- ];
88
- /** Load kick.config.* from the project root */
89
- async function loadKickConfig(cwd) {
90
- for (const filename of CONFIG_FILES) {
91
- const filepath = join(cwd, filename);
92
- try {
93
- await access(filepath);
94
- } catch {
95
- continue;
96
- }
97
- if (filename.endsWith(".json")) {
98
- const content = await readFile(filepath, "utf-8");
99
- return JSON.parse(content);
100
- }
101
- try {
102
- const { pathToFileURL } = await import("node:url");
103
- const mod = await import(pathToFileURL(filepath).href);
104
- const config = mod.default ?? mod;
105
- const warnings = validateAssetMap(config, cwd);
106
- for (const warning of warnings) console.warn(` Warning: ${warning}`);
107
- return config;
108
- } catch {
109
- if (filename.endsWith(".ts")) console.warn(`Warning: Failed to load ${filename}. TypeScript config files require a runtime loader (e.g. tsx, ts-node) or use kick.config.js/.mjs instead.`);
110
- continue;
111
- }
112
- }
113
- return null;
114
- }
115
- /**
116
- * Validate `assetMap` entries on a loaded config. Returns a list of
117
- * human-readable warnings; the caller decides how to surface them
118
- * (typically `console.warn`). Never throws — `kick g` and other
119
- * unrelated commands should keep working even when the assetMap is
120
- * misconfigured.
121
- *
122
- * Checks:
123
- *
124
- * - Each entry's `src` is a non-empty string.
125
- * - The `src` directory exists on disk (otherwise the typegen + build
126
- * steps will fail later with cryptic errors).
127
- * - `dest` doesn't escape the project root (defensive — a `dest:
128
- * '../../etc'` typo could write files outside the workspace).
129
- * - The namespace key is a non-empty string and doesn't include a
130
- * `/` (would conflict with the `<namespace>/<key>` manifest format).
131
- */
132
- function validateAssetMap(config, cwd) {
133
- const warnings = [];
134
- if (!config?.assetMap) return warnings;
135
- const root = resolve(cwd);
136
- for (const [namespace, entry] of Object.entries(config.assetMap)) {
137
- if (!namespace || namespace.includes("/")) {
138
- warnings.push(`assetMap key '${namespace}' is invalid — must be a non-empty string without '/'`);
139
- continue;
140
- }
141
- if (typeof entry?.src !== "string" || entry.src.length === 0) {
142
- warnings.push(`assetMap.${namespace} is missing a non-empty 'src' field`);
143
- continue;
144
- }
145
- if (!existsSync(resolve(cwd, entry.src))) warnings.push(`assetMap.${namespace}.src ('${entry.src}') does not exist — typegen + build will fail`);
146
- if (entry.dest) {
147
- if (escapesRoot(resolve(cwd, entry.dest), root)) warnings.push(`assetMap.${namespace}.dest ('${entry.dest}') resolves outside the project root — refusing to copy`);
148
- }
149
- }
150
- return warnings;
151
- }
152
- /**
153
- * Returns true when `path` (absolute) resolves outside of `root`
154
- * (also absolute). Uses `path.relative` for accuracy:
155
- *
156
- * - The result is empty when paths are identical (inside).
157
- * - It starts with `..` when the path traverses outside the root.
158
- * - It's absolute (Windows: cross-drive) when there's no relative
159
- * path between them.
160
- *
161
- * Avoids the prefix-match pitfalls of `startsWith` (e.g. `/app`
162
- * matching `/app2/...`, or case-mismatches on macOS / Windows).
163
- */
164
- function escapesRoot(path, root) {
165
- const rel = relative(root, path);
166
- return rel === "" ? false : rel.startsWith("..") || isAbsolute(rel);
167
- }
168
- //#endregion
169
- export { resolveTokenScope as a, resolveModuleConfig as i, config_exports as n, loadKickConfig as r, PACKAGE_MANAGERS as t };