@forinda/kickjs-cli 5.0.2 → 5.2.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.
@@ -0,0 +1,71 @@
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 { t as KickPluginConflictError } from "./types-CGB8BiQh.mjs";
13
+ //#region src/plugin/merge.ts
14
+ function mergeCliPlugins(plugins, adopterCommands = []) {
15
+ const seenPluginNames = /* @__PURE__ */ new Map();
16
+ for (const p of plugins) {
17
+ const count = (seenPluginNames.get(p.name) ?? 0) + 1;
18
+ seenPluginNames.set(p.name, count);
19
+ if (count === 2) throw new KickPluginConflictError("plugin", p.name, [p.name, p.name]);
20
+ }
21
+ const commandOwners = /* @__PURE__ */ new Map();
22
+ const pluginCommands = [];
23
+ for (const p of plugins) for (const cmd of p.commands ?? []) {
24
+ const prior = commandOwners.get(cmd.name);
25
+ if (prior) throw new KickPluginConflictError("command", cmd.name, [prior, p.name]);
26
+ commandOwners.set(cmd.name, p.name);
27
+ pluginCommands.push(cmd);
28
+ }
29
+ const adopterNames = new Set(adopterCommands.map((c) => c.name));
30
+ const commands = [...pluginCommands.filter((c) => !adopterNames.has(c.name)), ...adopterCommands];
31
+ const typegenOwners = /* @__PURE__ */ new Map();
32
+ const typegens = [];
33
+ for (const p of plugins) for (const tg of p.typegens ?? []) {
34
+ const prior = typegenOwners.get(tg.id);
35
+ if (prior) throw new KickPluginConflictError("typegen", tg.id, [prior, p.name]);
36
+ typegenOwners.set(tg.id, p.name);
37
+ typegens.push(tg);
38
+ }
39
+ const generatorOwners = /* @__PURE__ */ new Map();
40
+ const generators = [];
41
+ for (const p of plugins) for (const spec of p.generators ?? []) {
42
+ const prior = generatorOwners.get(spec.name);
43
+ if (prior) throw new KickPluginConflictError("generator", spec.name, [prior, p.name]);
44
+ generatorOwners.set(spec.name, p.name);
45
+ generators.push({
46
+ source: p.name,
47
+ spec
48
+ });
49
+ }
50
+ const register = async (program, ctx) => {
51
+ const resolved = ctx ?? {
52
+ cwd: process.cwd(),
53
+ config: null,
54
+ log: () => {}
55
+ };
56
+ for (const p of plugins) if (p.register) await p.register(program, resolved);
57
+ };
58
+ return {
59
+ commands,
60
+ typegens,
61
+ generators,
62
+ register
63
+ };
64
+ }
65
+ //#endregion
66
+ //#region src/plugin/index.ts
67
+ var plugin_exports = /* @__PURE__ */ __exportAll({ mergeCliPlugins: () => mergeCliPlugins });
68
+ //#endregion
69
+ export { mergeCliPlugins as n, plugin_exports as t };
70
+
71
+ //# sourceMappingURL=plugin-6_YlK-JG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-6_YlK-JG.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 const register = async (program: Command, ctx?: KickCliPluginContext): Promise<void> => {\n const resolved: KickCliPluginContext = ctx ?? {\n cwd: process.cwd(),\n config: null,\n log: () => {},\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":";;;;;;;;;;;;;AA4CA,SAAgB,gBACd,SACA,kBAAoD,EAAE,EACvC;CAEf,MAAM,kCAAkB,IAAI,KAAqB;AACjD,MAAK,MAAM,KAAK,SAAS;EACvB,MAAM,SAAS,gBAAgB,IAAI,EAAE,KAAK,IAAI,KAAK;AACnD,kBAAgB,IAAI,EAAE,MAAM,MAAM;AAClC,MAAI,UAAU,EACZ,OAAM,IAAI,wBAAwB,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;;CAIzE,MAAM,gCAAgB,IAAI,KAAqB;CAC/C,MAAM,iBAA0C,EAAE;AAClD,MAAK,MAAM,KAAK,QACd,MAAK,MAAM,OAAO,EAAE,YAAY,EAAE,EAAE;EAClC,MAAM,QAAQ,cAAc,IAAI,IAAI,KAAK;AACzC,MAAI,MACF,OAAM,IAAI,wBAAwB,WAAW,IAAI,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC;AAEzE,gBAAc,IAAI,IAAI,MAAM,EAAE,KAAK;AACnC,iBAAe,KAAK,IAAI;;CAI5B,MAA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+ * 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
+ //#region src/plugin/types.ts
13
+ /** Identity helper — exists for type inference + parity with definePlugin. */
14
+ function defineCliPlugin(p) {
15
+ return p;
16
+ }
17
+ var KickPluginConflictError = class extends Error {
18
+ constructor(kind, id, owners) {
19
+ super(`Two plugins registered the same ${kind} '${id}': ${owners.join(", ")}. Plugins must use unique ${kind} names.`);
20
+ this.name = "KickPluginConflictError";
21
+ }
22
+ };
23
+ //#endregion
24
+ //#region src/plugin/merge.ts
25
+ function mergeCliPlugins(plugins, adopterCommands = []) {
26
+ const seenPluginNames = /* @__PURE__ */ new Map();
27
+ for (const p of plugins) {
28
+ const count = (seenPluginNames.get(p.name) ?? 0) + 1;
29
+ seenPluginNames.set(p.name, count);
30
+ if (count === 2) throw new KickPluginConflictError("plugin", p.name, [p.name, p.name]);
31
+ }
32
+ const commandOwners = /* @__PURE__ */ new Map();
33
+ const pluginCommands = [];
34
+ for (const p of plugins) for (const cmd of p.commands ?? []) {
35
+ const prior = commandOwners.get(cmd.name);
36
+ if (prior) throw new KickPluginConflictError("command", cmd.name, [prior, p.name]);
37
+ commandOwners.set(cmd.name, p.name);
38
+ pluginCommands.push(cmd);
39
+ }
40
+ const adopterNames = new Set(adopterCommands.map((c) => c.name));
41
+ const commands = [...pluginCommands.filter((c) => !adopterNames.has(c.name)), ...adopterCommands];
42
+ const typegenOwners = /* @__PURE__ */ new Map();
43
+ const typegens = [];
44
+ for (const p of plugins) for (const tg of p.typegens ?? []) {
45
+ const prior = typegenOwners.get(tg.id);
46
+ if (prior) throw new KickPluginConflictError("typegen", tg.id, [prior, p.name]);
47
+ typegenOwners.set(tg.id, p.name);
48
+ typegens.push(tg);
49
+ }
50
+ const generatorOwners = /* @__PURE__ */ new Map();
51
+ const generators = [];
52
+ for (const p of plugins) for (const spec of p.generators ?? []) {
53
+ const prior = generatorOwners.get(spec.name);
54
+ if (prior) throw new KickPluginConflictError("generator", spec.name, [prior, p.name]);
55
+ generatorOwners.set(spec.name, p.name);
56
+ generators.push({
57
+ source: p.name,
58
+ spec
59
+ });
60
+ }
61
+ const register = async (program, ctx) => {
62
+ const resolved = ctx ?? {
63
+ cwd: process.cwd(),
64
+ config: null,
65
+ log: () => {}
66
+ };
67
+ for (const p of plugins) if (p.register) await p.register(program, resolved);
68
+ };
69
+ return {
70
+ commands,
71
+ typegens,
72
+ generators,
73
+ register
74
+ };
75
+ }
76
+ //#endregion
77
+ //#region src/plugin/index.ts
78
+ var plugin_exports = /* @__PURE__ */ __exportAll({ mergeCliPlugins: () => mergeCliPlugins });
79
+ //#endregion
80
+ export { mergeCliPlugins as n, defineCliPlugin as r, plugin_exports as t };
@@ -0,0 +1,24 @@
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 "node:module";
12
+ //#region \0rolldown/runtime.js
13
+ var __defProp = Object.defineProperty;
14
+ var __exportAll = (all, no_symbols) => {
15
+ let target = {};
16
+ for (var name in all) __defProp(target, name, {
17
+ get: all[name],
18
+ enumerable: true
19
+ });
20
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
21
+ return target;
22
+ };
23
+ //#endregion
24
+ export { __exportAll as t };
@@ -0,0 +1,12 @@
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 { n as applyDisableFilter, t as runAllPluginTypegens } from "./builtins-C_VfEGdg.mjs";
12
+ export { applyDisableFilter, runAllPluginTypegens };