create-koishi-ce 1.1.0 → 1.2.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/lib/bin.mjs +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{src-CUSQBq1d.mjs → src-CwJZjC5d.mjs} +6 -3
- package/package.json +1 -1
- package/src/__tests__/template.test.ts +36 -3
- package/src/template.ts +16 -4
package/lib/bin.mjs
CHANGED
package/lib/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as start, i as renderManifest, n as getLocalRegistry, r as readNpmrcRegistry, t as detectAgent } from "./src-
|
|
1
|
+
import { a as start, i as renderManifest, n as getLocalRegistry, r as readNpmrcRegistry, t as detectAgent } from "./src-CwJZjC5d.mjs";
|
|
2
2
|
export { detectAgent, getLocalRegistry, readNpmrcRegistry, renderManifest, start };
|
|
@@ -11,7 +11,7 @@ import parse from "yargs-parser";
|
|
|
11
11
|
var package_default = {
|
|
12
12
|
name: "create-koishi-ce",
|
|
13
13
|
description: "Setup a Koishi application",
|
|
14
|
-
version: "1.1
|
|
14
|
+
version: "1.2.1",
|
|
15
15
|
type: "module",
|
|
16
16
|
main: "./lib/index.mjs",
|
|
17
17
|
module: "./lib/index.mjs",
|
|
@@ -147,7 +147,7 @@ bun run dev # 启动(开发模式,启用 HMR 热更新)
|
|
|
147
147
|
|
|
148
148
|
推荐在控制台「插件市场」页安装(已预配 registry.koishi.chat 镜像源);也可以手动 \`bun add <包名>\` 后在 \`koishi.yml\` 中启用。
|
|
149
149
|
|
|
150
|
-
上游官方 adapter(如 adapter-discord / adapter-telegram)、数据库插件(如 database-sqlite)与社区 koishi-plugin-*
|
|
150
|
+
上游官方 adapter(如 adapter-discord / adapter-telegram)、数据库插件(如 database-sqlite)与社区 koishi-plugin-* 插件均可直接安装:根依赖中的四行 npm alias——\`"koishi": "npm:@koishi-ce/koishi-shim@^4.18.11"\`、\`"@koishijs/plugin-console": "npm:@koishi-ce/console-shim@^5.30.11"\`、\`"@koishijs/core": "npm:@koishi-ce/koishi-shim@4.18.11"\`、\`"@koishijs/loader": "npm:@koishi-ce/koishi-shim@^4.18.11"\`——已把上游生态的 peer 依赖全部钉回 @koishi-ce 框架(前两行与后两行分别只涉及 koishi-shim / console-shim 两个包;**请勿删除或改写这四行**),不会形成第二份框架 / console / loader 副本。analytics 等依赖数据库的插件请先安装数据库插件,再去掉配置中对应的 \`~\` 前缀启用。
|
|
151
151
|
|
|
152
152
|
## 自定义插件
|
|
153
153
|
|
|
@@ -191,7 +191,10 @@ function baseManifest() {
|
|
|
191
191
|
"@koishi-ce/plugin-sandbox": "^1.0.0",
|
|
192
192
|
"@koishi-ce/plugin-server": "^1.0.0",
|
|
193
193
|
"@koishi-ce/plugin-status": "^1.0.0",
|
|
194
|
-
koishi: "npm:@koishi-ce/koishi-shim@^4.18.11"
|
|
194
|
+
koishi: "npm:@koishi-ce/koishi-shim@^4.18.11",
|
|
195
|
+
"@koishijs/plugin-console": "npm:@koishi-ce/console-shim@^5.30.11",
|
|
196
|
+
"@koishijs/core": "npm:@koishi-ce/koishi-shim@4.18.11",
|
|
197
|
+
"@koishijs/loader": "npm:@koishi-ce/koishi-shim@^4.18.11"
|
|
195
198
|
},
|
|
196
199
|
devDependencies: {
|
|
197
200
|
"@koishi-ce/client": "^1.0.0",
|
package/package.json
CHANGED
|
@@ -4,9 +4,16 @@ import { baseManifest, templateFiles } from "../template.ts";
|
|
|
4
4
|
|
|
5
5
|
test("内置模板依赖纯度:不含任何 @koishijs / koishi-plugin 官方生态包", () => {
|
|
6
6
|
const { dependencies, devDependencies } = baseManifest();
|
|
7
|
+
// 四个上游名是刻意的 npm alias 占位(koishi 裸名 / @koishijs/plugin-console /
|
|
8
|
+
// @koishijs/core / @koishijs/loader),其余必须是 @koishi-ce 作用域
|
|
9
|
+
const guarded = new Set([
|
|
10
|
+
"koishi",
|
|
11
|
+
"@koishijs/plugin-console",
|
|
12
|
+
"@koishijs/core",
|
|
13
|
+
"@koishijs/loader",
|
|
14
|
+
]);
|
|
7
15
|
for (const key of Object.keys(dependencies ?? {})) {
|
|
8
|
-
|
|
9
|
-
expect(key === "koishi" || key.startsWith("@koishi-ce/")).toBe(true);
|
|
16
|
+
expect(guarded.has(key) || key.startsWith("@koishi-ce/")).toBe(true);
|
|
10
17
|
}
|
|
11
18
|
const toolchain = new Set(["bun-types", "cross-env"]);
|
|
12
19
|
for (const key of Object.keys(devDependencies ?? {})) {
|
|
@@ -22,6 +29,23 @@ test("内置模板以 npm alias 钉住 koishi 裸名,版本保持 4.18.x 冻
|
|
|
22
29
|
expect(request ?? "").toMatch(/^npm:@koishi-ce\/koishi-shim@\^4\./);
|
|
23
30
|
});
|
|
24
31
|
|
|
32
|
+
test("内置模板钉住 console / core / loader 上游 peer 名,防 Bun 自动装官方全家桶", () => {
|
|
33
|
+
const { dependencies } = baseManifest();
|
|
34
|
+
// CE webui 插件 peer ^5.30.11:alias 版本冻结 5.30.x 线
|
|
35
|
+
expect(dependencies?.["@koishijs/plugin-console"]).toBe(
|
|
36
|
+
"npm:@koishi-ce/console-shim@^5.30.11",
|
|
37
|
+
);
|
|
38
|
+
// @koishi-ce/loader 的 peer 精确锁 4.18.11:alias 必须逐字相等(不带 ^)
|
|
39
|
+
expect(dependencies?.["@koishijs/core"]).toBe(
|
|
40
|
+
"npm:@koishi-ce/koishi-shim@4.18.11",
|
|
41
|
+
);
|
|
42
|
+
// config / hmr 插件的 loader peer:koishi-shim 是 core + loader 的合并
|
|
43
|
+
// 再导出(与上游 koishi 主包同构),4.18.11 满足 ^4.6.11
|
|
44
|
+
expect(dependencies?.["@koishijs/loader"]).toBe(
|
|
45
|
+
"npm:@koishi-ce/koishi-shim@^4.18.11",
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
25
49
|
test("内置模板静态文件齐备,koishi.yml 预配 market 镜像源", () => {
|
|
26
50
|
for (const file of [
|
|
27
51
|
".env",
|
|
@@ -52,6 +76,15 @@ test("renderManifest 渲染内置模板:常规改写生效,prod 模式保留
|
|
|
52
76
|
const prod = JSON.parse(renderManifest(baseManifest(), "my-app", true));
|
|
53
77
|
expect("workspaces" in prod).toBe(false);
|
|
54
78
|
expect("devDependencies" in prod).toBe(false);
|
|
55
|
-
//
|
|
79
|
+
// 四个上游名 alias 是运行时依赖,prod 模式下必须原样保留
|
|
56
80
|
expect(prod.dependencies.koishi).toBe("npm:@koishi-ce/koishi-shim@^4.18.11");
|
|
81
|
+
expect(prod.dependencies["@koishijs/plugin-console"]).toBe(
|
|
82
|
+
"npm:@koishi-ce/console-shim@^5.30.11",
|
|
83
|
+
);
|
|
84
|
+
expect(prod.dependencies["@koishijs/core"]).toBe(
|
|
85
|
+
"npm:@koishi-ce/koishi-shim@4.18.11",
|
|
86
|
+
);
|
|
87
|
+
expect(prod.dependencies["@koishijs/loader"]).toBe(
|
|
88
|
+
"npm:@koishi-ce/koishi-shim@^4.18.11",
|
|
89
|
+
);
|
|
57
90
|
});
|
package/src/template.ts
CHANGED
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
* 模板要点:
|
|
11
11
|
* - 运行时 Bun:koishi CLI(@koishi-ce/koishi 的 bin)与 loader 插件加载链
|
|
12
12
|
* 均以 Bun 为准(ESM-only 产物,Bun 原生加载 TS / yml);
|
|
13
|
-
* - "koishi"
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* - "koishi" 裸名与 @koishijs/core / @koishijs/loader 上游名用 npm alias
|
|
14
|
+
* 钉到 @koishi-ce/koishi-shim(4.18.x 冻结线,见 packages/shim/koishi-shim):
|
|
15
|
+
* 上游官方 adapter / database 插件与社区
|
|
16
|
+
* koishi-plugin-* 的 peer `koishi ^4.x` 等由此满足,不会拉入 npm 官方
|
|
16
17
|
* koishi 形成第二份框架副本;市场安装亦不改写该声明(installer 的
|
|
17
18
|
* isGuardedRequest 护栏将 npm:@koishi-ce alias 与 workspace: 同等保护);
|
|
18
19
|
* - 本仓没有 adapter / database 插件的再分发,模板不预装这两类;依赖数据库
|
|
@@ -107,7 +108,7 @@ bun run dev # 启动(开发模式,启用 HMR 热更新)
|
|
|
107
108
|
|
|
108
109
|
推荐在控制台「插件市场」页安装(已预配 registry.koishi.chat 镜像源);也可以手动 \`bun add <包名>\` 后在 \`koishi.yml\` 中启用。
|
|
109
110
|
|
|
110
|
-
上游官方 adapter(如 adapter-discord / adapter-telegram)、数据库插件(如 database-sqlite)与社区 koishi-plugin-*
|
|
111
|
+
上游官方 adapter(如 adapter-discord / adapter-telegram)、数据库插件(如 database-sqlite)与社区 koishi-plugin-* 插件均可直接安装:根依赖中的四行 npm alias——\`"koishi": "npm:@koishi-ce/koishi-shim@^4.18.11"\`、\`"@koishijs/plugin-console": "npm:@koishi-ce/console-shim@^5.30.11"\`、\`"@koishijs/core": "npm:@koishi-ce/koishi-shim@4.18.11"\`、\`"@koishijs/loader": "npm:@koishi-ce/koishi-shim@^4.18.11"\`——已把上游生态的 peer 依赖全部钉回 @koishi-ce 框架(前两行与后两行分别只涉及 koishi-shim / console-shim 两个包;**请勿删除或改写这四行**),不会形成第二份框架 / console / loader 副本。analytics 等依赖数据库的插件请先安装数据库插件,再去掉配置中对应的 \`~\` 前缀启用。
|
|
111
112
|
|
|
112
113
|
## 自定义插件
|
|
113
114
|
|
|
@@ -155,6 +156,17 @@ export function baseManifest(): Manifest {
|
|
|
155
156
|
// 上游裸名占位:npm alias 钉到 @koishi-ce 的 koishi shim(勿删,
|
|
156
157
|
// 语义见文件头注释);版本必须保持 4.18.x 冻结线以满足 ^4 peer
|
|
157
158
|
koishi: "npm:@koishi-ce/koishi-shim@^4.18.11",
|
|
159
|
+
// 上游 console 名占位:CE 插件的 peer 声明上游名,无归属时 Bun
|
|
160
|
+
// 会自动装下 npm 官方 console 全家桶形成双实例;版本冻结 5.30.x
|
|
161
|
+
"@koishijs/plugin-console": "npm:@koishi-ce/console-shim@^5.30.11",
|
|
162
|
+
// 上游 core 名占位:@koishi-ce/loader 的 peer 精确锁 4.18.11,
|
|
163
|
+
// alias 须逐字相等(不带 ^),版本冻结勿 bump。core 与 loader
|
|
164
|
+
// 两个名字共用 koishi-shim:@koishi-ce/koishi 是 core + loader
|
|
165
|
+
// 的合并再导出(与上游 koishi 主包同构),named 导出全覆盖
|
|
166
|
+
"@koishijs/core": "npm:@koishi-ce/koishi-shim@4.18.11",
|
|
167
|
+
// 上游 loader 名占位:config / hmr 插件的 peer;同样指向
|
|
168
|
+
// koishi-shim(4.18.11 满足 ^4.6.11),勿指回已废弃的 loader-shim
|
|
169
|
+
"@koishijs/loader": "npm:@koishi-ce/koishi-shim@^4.18.11",
|
|
158
170
|
},
|
|
159
171
|
devDependencies: {
|
|
160
172
|
"@koishi-ce/client": "^1.0.0",
|