koishi-plugin-market-bundle-workbench 0.1.0-alpha.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/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # koishi-plugin-market-bundle-workbench
2
+
3
+ `market-bundle-workbench` is a developer workbench for creating Koishi Market NEXT plugin bundles (`koishi-plugin-pa-*`).
4
+
5
+ It helps authors assemble a bundle manifest, validate npm metadata, generate `package.json` / `koishi.bundle` / README snippets, and run `npm pack --dry-run` before publishing.
6
+
7
+ The workbench is intentionally separate from `koishi-plugin-market-next`: Market NEXT installs and manages bundles, while this plugin helps developers build them.
8
+
9
+ ## Features
10
+
11
+ - Optional Console page, controlled by `enableWorkbench`.
12
+ - Generate npm-valid bundle package metadata.
13
+ - Validate package names, versions, semver ranges, duplicate members, self references, direct cycles, npm existence, and published versions.
14
+ - Pick installed plugins as members or enter package names manually.
15
+ - Edit required/optional members and preset config JSON.
16
+ - Generate dry-run and publish commands without storing npm tokens.
17
+
18
+ ## Usage
19
+
20
+ 1. Install and enable this plugin in Koishi.
21
+ 2. Turn on `enableWorkbench`.
22
+ 3. Open **插件包工作台** in the Console.
23
+ 4. Build the member list, validate, generate files, then run the suggested npm commands in your project.
24
+
25
+ The first version does not publish packages directly. It only generates files and commands so authors can review the final output.
@@ -0,0 +1,8 @@
1
+ <template>
2
+ <svg class="k-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" aria-hidden="true">
3
+ <path
4
+ fill="currentColor"
5
+ d="M128 72c0-22.1 17.9-40 40-40h112c81.7 0 148 66.3 148 148 0 55.5-30.5 103.8-75.7 129.1l65.2 106.2c11.6 18.8-3.6 42.7-25.6 42.7h-43.8c-13.9 0-26.8-7.2-34.1-19l-61-99h-41v78c0 22.1-17.9 40-40 40h-4c-22.1 0-40-17.9-40-40V72Zm84 76v116h68c32 0 58-26 58-58s-26-58-58-58h-68Z"
6
+ />
7
+ </svg>
8
+ </template>
@@ -0,0 +1,5 @@
1
+ import { icons } from '@koishijs/client'
2
+
3
+ import BundleWorkbench from './activity/bundle-workbench.vue'
4
+
5
+ icons.register('activity:bundle-workbench', BundleWorkbench)
@@ -0,0 +1,45 @@
1
+ import { Context, store } from '@koishijs/client'
2
+ import Workbench from './workbench.vue'
3
+ import './icons'
4
+
5
+ function findWorkbenchConfig(plugins: any): any {
6
+ let fallback: any
7
+
8
+ function visit(object: any): any {
9
+ if (!object || typeof object !== 'object') return
10
+ for (const rawKey of Object.keys(object)) {
11
+ if (rawKey.startsWith('$')) continue
12
+ const value = object[rawKey]
13
+ if (!value || typeof value !== 'object') continue
14
+ const disabled = rawKey.startsWith('~')
15
+ const key = disabled ? rawKey.slice(1) : rawKey
16
+ const name = key.split(':', 1)[0]
17
+ if (name === 'market-bundle-workbench' || name === 'koishi-plugin-market-bundle-workbench') {
18
+ if (!disabled) return value
19
+ fallback ||= value
20
+ }
21
+ const nested = visit(value)
22
+ if (nested) return nested
23
+ }
24
+ }
25
+
26
+ return visit(plugins) ?? fallback
27
+ }
28
+
29
+ export function isWorkbenchEnabled() {
30
+ return findWorkbenchConfig((store as any).config?.plugins)?.enableWorkbench === true
31
+ }
32
+
33
+ export default (ctx: Context) => {
34
+ ctx.page({
35
+ id: 'bundle-workbench',
36
+ path: '/bundle-workbench',
37
+ name: '插件包工作台',
38
+ icon: 'activity:bundle-workbench',
39
+ order: 760,
40
+ authority: 4,
41
+ fields: ['config', 'packages'],
42
+ disabled: () => !isWorkbenchEnabled(),
43
+ component: Workbench,
44
+ })
45
+ }