@forinda/kickjs-cli-kit 0.1.0 → 0.1.1
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/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/index.mjs +1 -1
- package/package.json +13 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Felix Orinda
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# @forinda/kickjs-cli-kit
|
|
2
|
+
|
|
3
|
+
The shared CLI-plugin contract for KickJS. Defines the types and helpers a package implements to ship `kick`-compatible commands, generators, and typegens — without depending on the full `@forinda/kickjs-cli`.
|
|
4
|
+
|
|
5
|
+
This is a tiny, dependency-free package (one `commander` peer). You only need it if you're **building** a CLI plugin; app authors never import it directly.
|
|
6
|
+
|
|
7
|
+
## Why this package exists
|
|
8
|
+
|
|
9
|
+
The kick CLI mounts first-party plugins (the database tooling, for example). If those packages imported `defineCliPlugin` from `@forinda/kickjs-cli` to describe their commands, that would form a dependency cycle — the CLI already depends on them. Hoisting the **contract** into a standalone package both sides import breaks the cycle:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
@forinda/kickjs-cli ─┐
|
|
13
|
+
├─► @forinda/kickjs-cli-kit (contract only)
|
|
14
|
+
@forinda/kickjs-db ─┘
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`@forinda/kickjs-cli` re-exports the whole contract, so `import { defineCliPlugin } from '@forinda/kickjs-cli'` keeps working for app-side `kick.config.ts` plugins.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @forinda/kickjs-cli-kit commander
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`commander` is a peer dependency (the host CLI provides the `Command` your plugin registers against).
|
|
26
|
+
|
|
27
|
+
## Quick start
|
|
28
|
+
|
|
29
|
+
### A CLI plugin
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { defineCliPlugin } from '@forinda/kickjs-cli-kit'
|
|
33
|
+
|
|
34
|
+
export const helloPlugin = defineCliPlugin({
|
|
35
|
+
name: 'my-org/hello',
|
|
36
|
+
register(program, ctx) {
|
|
37
|
+
program
|
|
38
|
+
.command('hello <name>')
|
|
39
|
+
.description('Say hello')
|
|
40
|
+
.action((name: string) => {
|
|
41
|
+
console.log(`Hello, ${name}! (project: ${ctx.projectRoot})`)
|
|
42
|
+
})
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Mount it in `kick.config.ts`:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { defineConfig } from '@forinda/kickjs-cli'
|
|
51
|
+
import { helloPlugin } from './tools/hello-plugin'
|
|
52
|
+
|
|
53
|
+
export default defineConfig({ plugins: [helloPlugin] })
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
kick hello world
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### A `kick g <name>` generator
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { defineGenerator } from '@forinda/kickjs-cli-kit'
|
|
64
|
+
|
|
65
|
+
export default [
|
|
66
|
+
defineGenerator({
|
|
67
|
+
name: 'widget',
|
|
68
|
+
description: 'Scaffold a widget',
|
|
69
|
+
args: [{ name: 'name', required: true }],
|
|
70
|
+
files: (ctx) => [
|
|
71
|
+
{
|
|
72
|
+
path: `src/widgets/${ctx.kebab}.ts`,
|
|
73
|
+
content: `export class ${ctx.pascal}Widget {}\n`,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
}),
|
|
77
|
+
]
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Contract surface
|
|
81
|
+
|
|
82
|
+
| Export | Purpose |
|
|
83
|
+
| ------------------------- | ------------------------------------------------------------------------------------- |
|
|
84
|
+
| `defineCliPlugin(p)` | Declare a CLI plugin: `name` + `register()` / `commands` / `typegens` / `generators`. |
|
|
85
|
+
| `defineGenerator(spec)` | Declare a `kick g <name>` scaffolder (returns the spec, typed). |
|
|
86
|
+
| `KickCliPlugin<TConfig>` | The plugin shape. `TConfig` is the host config type (`ctx.config`). |
|
|
87
|
+
| `KickCliPluginContext` | What `register()` receives: `cwd`, `projectRoot`, `config`, `log`. |
|
|
88
|
+
| `GeneratorSpec` + co. | `GeneratorContext` / `GeneratorFile` / `GeneratorArg` / `GeneratorFlag`. |
|
|
89
|
+
| `KickCommandDefinition` | A declarative shell-handler command (the `commands` field shape). |
|
|
90
|
+
| `CliTypegen` | Structural typegen shape (the CLI's `TypegenPlugin` satisfies it). |
|
|
91
|
+
| `KickPluginConflictError` | Thrown on duplicate plugin / command / typegen / generator ids. |
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT © Felix Orinda
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forinda/kickjs-cli-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Shared CLI-plugin contract for KickJS — defineCliPlugin, defineGenerator, and the types CLI plugins implement",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kickjs",
|
|
@@ -20,16 +20,10 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
|
-
"dist"
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
24
26
|
],
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsdown",
|
|
27
|
-
"dev": "tsdown --watch",
|
|
28
|
-
"test": "vitest run --passWithNoTests",
|
|
29
|
-
"typecheck": "tsgo --noEmit",
|
|
30
|
-
"clean": "rm -rf dist .wireit",
|
|
31
|
-
"lint": "tsc --noEmit"
|
|
32
|
-
},
|
|
33
27
|
"dependencies": {},
|
|
34
28
|
"peerDependencies": {
|
|
35
29
|
"commander": ">=12.0.0"
|
|
@@ -56,5 +50,13 @@
|
|
|
56
50
|
"author": "Felix Orinda",
|
|
57
51
|
"engines": {
|
|
58
52
|
"node": ">=20.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsdown",
|
|
56
|
+
"dev": "tsdown --watch",
|
|
57
|
+
"test": "vitest run --passWithNoTests",
|
|
58
|
+
"typecheck": "tsgo --noEmit",
|
|
59
|
+
"clean": "rm -rf dist .wireit",
|
|
60
|
+
"lint": "tsc --noEmit"
|
|
59
61
|
}
|
|
60
|
-
}
|
|
62
|
+
}
|