create-koishi-ce 1.6.4 → 1.7.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 +1 -1
- package/lib/bin.mjs +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{src-D2Fw0uXq.mjs → src-Cj4uFpkr.mjs} +11 -7
- package/package.json +1 -1
- package/src/__tests__/template.test.ts +14 -2
- package/src/index.ts +4 -1
- package/src/template/README.md +1 -1
- package/src/template.ts +15 -4
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ npm create koishi-ce my-app
|
|
|
27
27
|
|
|
28
28
|
## 生成的项目
|
|
29
29
|
|
|
30
|
-
- **package.json**:`type: module`、`packageManager` 钉 Bun、workspaces 含 `plugins/*` 与 `external/*`;dependencies 预装全套 `@koishi-ce` 常用插件(console、config、market、auth、admin、help、sandbox、database-sqlite
|
|
30
|
+
- **package.json**:`type: module`、`packageManager` 钉 Bun、workspaces 含 `plugins/*` 与 `external/*`;dependencies 预装全套 `@koishi-ce` 常用插件(console、config、market、auth、admin、help、sandbox、database-sqlite 等),并预置六行 npm alias 钉住上游名——`koishi` / `@koishijs/core` / `@koishijs/loader` 指向 `@koishi-ce/koishi-shim`、`@koishijs/plugin-console` 指向 `@koishi-ce/console-shim`、`@koishijs/client` / `@koishijs/components` 分别指向 `@koishi-ce/client-shim` / `@koishi-ce/components-shim`,社区插件(含把上游前端库写进 dependencies 的 webui 插件)由此全部解析到 CE 对应包;
|
|
31
31
|
- **koishi.yml**:按 server(端口 5140-5149)/ basic / console(自动打开、市场指向 registry.koishi.chat 镜像)/ storage / adapter / develop(开发模式启用热重载)分组预写;官方 adapter 插件以 `~` 停用条目预写、不预装,装好后在控制台按需启用;数据库开箱即用——`database-sqlite` 默认启用,mongo / mysql / postgres 等其余 database 不预写占位条目,市场安装后自动出现;
|
|
32
32
|
- **开发工具链**:devDependencies 预置 `@koishi-ce/client`、`@koishi-ce/plugin-hmr` 与 `@koishi-ce/scripts`(`koishi-scripts setup` 可在 external/ 下继续创建插件项目)。
|
|
33
33
|
|
package/lib/bin.mjs
CHANGED
package/lib/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as renderManifest, i as readNpmrcRegistry, n as detectAgent, r as getLocalRegistry, t as start } from "./src-
|
|
1
|
+
import { a as renderManifest, i as readNpmrcRegistry, n as detectAgent, r as getLocalRegistry, t as start } from "./src-Cj4uFpkr.mjs";
|
|
2
2
|
export { detectAgent, getLocalRegistry, readNpmrcRegistry, renderManifest, start };
|
|
@@ -9,7 +9,7 @@ import { downloadTemplate } from "giget";
|
|
|
9
9
|
var package_default = {
|
|
10
10
|
name: "create-koishi-ce",
|
|
11
11
|
description: "Setup a Koishi application",
|
|
12
|
-
version: "1.
|
|
12
|
+
version: "1.7.0",
|
|
13
13
|
type: "module",
|
|
14
14
|
main: "./lib/index.mjs",
|
|
15
15
|
module: "./lib/index.mjs",
|
|
@@ -157,10 +157,12 @@ function writePackageJson(rootDir, project, prod) {
|
|
|
157
157
|
* 均以 Bun 为准(ESM-only 产物,Bun 原生加载 TS / yml);脚本里的环境
|
|
158
158
|
* 变量注入直接写 `NODE_ENV=... ` 前缀——bun run 走 Bun Shell,跨平台
|
|
159
159
|
* 原生支持,无需 cross-env 一类的依赖;
|
|
160
|
-
* - "koishi" 裸名与 @koishijs/core / @koishijs/loader / @koishijs/plugin-console
|
|
161
|
-
* 上游名用 npm alias 钉到 @koishi-ce
|
|
162
|
-
*
|
|
163
|
-
*
|
|
160
|
+
* - "koishi" 裸名与 @koishijs/core / @koishijs/loader / @koishijs/plugin-console /
|
|
161
|
+
* @koishijs/client / @koishijs/components 上游名用 npm alias 钉到 @koishi-ce
|
|
162
|
+
* shim(版本冻结线,见 packages/shim):上游官方 adapter / database 插件与
|
|
163
|
+
* 社区 koishi-plugin-* 的 peer 由此满足,webui 插件写进 dependencies 的
|
|
164
|
+
* client / components 亦被钉住(满足性判定看落盘版本),不会拉入 npm
|
|
165
|
+
* 官方全家桶形成第二份框架副本;市场安装亦不改写该声明
|
|
164
166
|
* (installer 的 isGuardedRequest 护栏将 npm:@koishi-ce alias 与
|
|
165
167
|
* workspace: 同等保护);
|
|
166
168
|
* - koishi.yml 采用配置页导出形态:插件键带 uid 实例后缀,分组带中文
|
|
@@ -255,7 +257,9 @@ function baseManifest() {
|
|
|
255
257
|
koishi: "npm:@koishi-ce/koishi-shim@^4.18.11",
|
|
256
258
|
"@koishijs/plugin-console": "npm:@koishi-ce/console-shim@^5.30.11",
|
|
257
259
|
"@koishijs/core": "npm:@koishi-ce/koishi-shim@4.18.11",
|
|
258
|
-
"@koishijs/loader": "npm:@koishi-ce/koishi-shim@^4.18.11"
|
|
260
|
+
"@koishijs/loader": "npm:@koishi-ce/koishi-shim@^4.18.11",
|
|
261
|
+
"@koishijs/client": "npm:@koishi-ce/client-shim@^5.30.11",
|
|
262
|
+
"@koishijs/components": "npm:@koishi-ce/components-shim@^1.5.22"
|
|
259
263
|
},
|
|
260
264
|
devDependencies: {
|
|
261
265
|
"@koishi-ce/client": "^1.0.0",
|
|
@@ -390,7 +394,7 @@ async function getName() {
|
|
|
390
394
|
initialValue: "koishi-app",
|
|
391
395
|
validate: (value) => value?.trim() ? void 0 : "项目名不能为空"
|
|
392
396
|
});
|
|
393
|
-
if (p.isCancel(answer)) process.exit(0);
|
|
397
|
+
if (p.isCancel(answer) || typeof answer !== "string") process.exit(0);
|
|
394
398
|
const trimmed = answer.trim();
|
|
395
399
|
if (!trimmed) process.exit(0);
|
|
396
400
|
return trimmed;
|
package/package.json
CHANGED
|
@@ -10,13 +10,16 @@ import {
|
|
|
10
10
|
|
|
11
11
|
test("内置模板依赖纯度:不含任何 @koishijs / koishi-plugin 官方生态包", () => {
|
|
12
12
|
const { dependencies, devDependencies } = baseManifest();
|
|
13
|
-
//
|
|
14
|
-
// @koishijs/core / @koishijs/loader
|
|
13
|
+
// 六个上游名是刻意的 npm alias 占位(koishi 裸名 / @koishijs/plugin-console /
|
|
14
|
+
// @koishijs/core / @koishijs/loader / @koishijs/client / @koishijs/components),
|
|
15
|
+
// 其余必须是 @koishi-ce 作用域
|
|
15
16
|
const guarded = new Set([
|
|
16
17
|
"koishi",
|
|
17
18
|
"@koishijs/plugin-console",
|
|
18
19
|
"@koishijs/core",
|
|
19
20
|
"@koishijs/loader",
|
|
21
|
+
"@koishijs/client",
|
|
22
|
+
"@koishijs/components",
|
|
20
23
|
]);
|
|
21
24
|
for (const key of Object.keys(dependencies ?? {})) {
|
|
22
25
|
expect(
|
|
@@ -96,6 +99,15 @@ test("内置模板钉住 console / core / loader 上游 peer 名,防 Bun 自
|
|
|
96
99
|
expect(dependencies?.["@koishijs/loader"]).toBe(
|
|
97
100
|
"npm:@koishi-ce/koishi-shim@^4.18.11",
|
|
98
101
|
);
|
|
102
|
+
// webui 插件把 client 写进 dependencies 的形态(napuketto 实证):
|
|
103
|
+
// 版本冻结 5.30.x 线满足 ^5.x,官方 client(连带 components)不再落盘
|
|
104
|
+
expect(dependencies?.["@koishijs/client"]).toBe(
|
|
105
|
+
"npm:@koishi-ce/client-shim@^5.30.11",
|
|
106
|
+
);
|
|
107
|
+
// 官方 client 的硬依赖、插件生态常直接依赖;冻结 1.5.x 线满足 ^1.5
|
|
108
|
+
expect(dependencies?.["@koishijs/components"]).toBe(
|
|
109
|
+
"npm:@koishi-ce/components-shim@^1.5.22",
|
|
110
|
+
);
|
|
99
111
|
});
|
|
100
112
|
|
|
101
113
|
test("内置模板静态文件齐备,koishi.yml 预配 market 镜像源", () => {
|
package/src/index.ts
CHANGED
|
@@ -115,7 +115,10 @@ async function getName(): Promise<string> {
|
|
|
115
115
|
validate: (value) =>
|
|
116
116
|
value?.trim() ? undefined : "项目名不能为空",
|
|
117
117
|
});
|
|
118
|
-
|
|
118
|
+
// @clack/core 1.5 的 isCancel 只收窄 unique symbol,而 text() 返回泛型
|
|
119
|
+
// symbol,需叠加 typeof 才能把类型收窄到 string
|
|
120
|
+
if (p.isCancel(answer) || typeof answer !== "string")
|
|
121
|
+
process.exit(0);
|
|
119
122
|
const trimmed = answer.trim();
|
|
120
123
|
if (!trimmed) process.exit(0);
|
|
121
124
|
return trimmed;
|
package/src/template/README.md
CHANGED
|
@@ -26,7 +26,7 @@ bun run dev # 启动(开发模式,启用 HMR 热更新)
|
|
|
26
26
|
|
|
27
27
|
推荐在控制台「插件市场」页安装(已预配 registry.koishi.chat 镜像源);也可以手动 `bun add <包名>` 后在 `koishi.yml` 中启用。
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
根依赖中的六行 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"`、`"@koishijs/client": "npm:@koishi-ce/client-shim@^5.30.11"`、`"@koishijs/components": "npm:@koishi-ce/components-shim@^1.5.22"`——已把上游生态的 peer 与 dependencies 声明全部钉回 @koishi-ce 对应包(涉及 koishi-shim / console-shim / client-shim / components-shim 四个包;**请勿删除或改写这六行**),不会形成第二份框架 / console / 前端库副本。
|
|
30
30
|
|
|
31
31
|
## 更新依赖
|
|
32
32
|
|
package/src/template.ts
CHANGED
|
@@ -19,10 +19,12 @@
|
|
|
19
19
|
* 均以 Bun 为准(ESM-only 产物,Bun 原生加载 TS / yml);脚本里的环境
|
|
20
20
|
* 变量注入直接写 `NODE_ENV=... ` 前缀——bun run 走 Bun Shell,跨平台
|
|
21
21
|
* 原生支持,无需 cross-env 一类的依赖;
|
|
22
|
-
* - "koishi" 裸名与 @koishijs/core / @koishijs/loader / @koishijs/plugin-console
|
|
23
|
-
* 上游名用 npm alias 钉到 @koishi-ce
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* - "koishi" 裸名与 @koishijs/core / @koishijs/loader / @koishijs/plugin-console /
|
|
23
|
+
* @koishijs/client / @koishijs/components 上游名用 npm alias 钉到 @koishi-ce
|
|
24
|
+
* shim(版本冻结线,见 packages/shim):上游官方 adapter / database 插件与
|
|
25
|
+
* 社区 koishi-plugin-* 的 peer 由此满足,webui 插件写进 dependencies 的
|
|
26
|
+
* client / components 亦被钉住(满足性判定看落盘版本),不会拉入 npm
|
|
27
|
+
* 官方全家桶形成第二份框架副本;市场安装亦不改写该声明
|
|
26
28
|
* (installer 的 isGuardedRequest 护栏将 npm:@koishi-ce alias 与
|
|
27
29
|
* workspace: 同等保护);
|
|
28
30
|
* - koishi.yml 采用配置页导出形态:插件键带 uid 实例后缀,分组带中文
|
|
@@ -175,6 +177,15 @@ export function baseManifest(): Manifest {
|
|
|
175
177
|
// koishi-shim(4.18.11 满足 ^4.6.11),勿指回已废弃的 loader-shim
|
|
176
178
|
"@koishijs/loader":
|
|
177
179
|
"npm:@koishi-ce/koishi-shim@^4.18.11",
|
|
180
|
+
// 上游 client 名占位:第三方 webui 插件常把 @koishijs/client 写进
|
|
181
|
+
// dependencies(非 peer,napuketto 实证),无归属时 Bun 装下官方
|
|
182
|
+
// client 并连带官方 components 全家桶;版本冻结 5.30.x 线满足 ^5.x
|
|
183
|
+
"@koishijs/client":
|
|
184
|
+
"npm:@koishi-ce/client-shim@^5.30.11",
|
|
185
|
+
// 上游 components 名占位:官方 client 的硬依赖,插件生态亦常直接
|
|
186
|
+
// 依赖(element-plus 系共享组件库);版本冻结 1.5.x 线满足 ^1.5
|
|
187
|
+
"@koishijs/components":
|
|
188
|
+
"npm:@koishi-ce/components-shim@^1.5.22",
|
|
178
189
|
},
|
|
179
190
|
devDependencies: {
|
|
180
191
|
"@koishi-ce/client": "^1.0.0",
|