create-koishi-ce 1.7.0 → 1.8.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/lib/bin.mjs +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.mjs +1 -1
- package/lib/{src-Cj4uFpkr.mjs → src-D36TrO6G.mjs} +70 -1
- package/package.json +1 -1
- package/src/__tests__/template.test.ts +71 -7
- package/src/manifest.ts +1 -0
- package/src/template.ts +85 -0
package/lib/bin.mjs
CHANGED
package/lib/index.d.ts
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-D36TrO6G.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.8.0",
|
|
13
13
|
type: "module",
|
|
14
14
|
main: "./lib/index.mjs",
|
|
15
15
|
module: "./lib/index.mjs",
|
|
@@ -197,6 +197,74 @@ const dotFiles = {
|
|
|
197
197
|
/** 模板静态文件(相对项目根的路径 → 文件内容),package.json 另行渲染 */
|
|
198
198
|
const templateFiles = Object.fromEntries(readdirSync(templateDir).filter((file) => !file.startsWith(".")).map((file) => [dotFiles[file] ?? file, readFileSync(join(templateDir, file), "utf8")]));
|
|
199
199
|
/**
|
|
200
|
+
* 上游名 → CE 对应包的 overrides 兜底映射(值统一 npm:<目标>@^1.0.0,
|
|
201
|
+
* 经 buildUpstreamOverrides 包装)。
|
|
202
|
+
*
|
|
203
|
+
* 六行钉名依赖「落盘版本满足声明范围」:第三方插件的声明超出冻结线
|
|
204
|
+
* (如未来上游升线后的 ^6)或引用清单外的上游名(如 dependencies 直接
|
|
205
|
+
* 依赖 @koishijs/plugin-admin / @koishijs/utils)时,官方包仍会落盘。
|
|
206
|
+
* overrides 是包管理器级的强制重写——不看版本满足性,把整棵依赖树中对
|
|
207
|
+
* 这些上游名的解析一律改指 CE 对应包,与钉名构成双层防线(napuketto
|
|
208
|
+
* 事件 2026-09-19 后补)。
|
|
209
|
+
*
|
|
210
|
+
* 清单 = CE 已再分发且官方同名的包,2026-09-19 逐一 npm view 核实:
|
|
211
|
+
* - plugin-cron 不在列(上游是裸名社区包 koishi-plugin-cron,非 @koishijs
|
|
212
|
+
* 作用域);
|
|
213
|
+
* - plugin-welcome / plugin-theme-vanilla 不在列(CE 原创,上游无此名);
|
|
214
|
+
* - plugin-assets 的 CE 对应物是 @koishi-ce/assets(无 plugin 前缀)。
|
|
215
|
+
* 新增 CE 再分发包时须同步本表与 sandbox 生成器的同款清单
|
|
216
|
+
* (tooling/sandbox/manifest.ts,对账测试防漂移)。
|
|
217
|
+
*/
|
|
218
|
+
const UPSTREAM_OVERRIDES = {
|
|
219
|
+
koishi: "@koishi-ce/koishi",
|
|
220
|
+
"@koishijs/core": "@koishi-ce/koishi",
|
|
221
|
+
"@koishijs/loader": "@koishi-ce/koishi",
|
|
222
|
+
"@koishijs/utils": "@koishi-ce/utils",
|
|
223
|
+
"@koishijs/i18n-utils": "@koishi-ce/i18n-utils",
|
|
224
|
+
"@koishijs/client": "@koishi-ce/client",
|
|
225
|
+
"@koishijs/components": "@koishi-ce/components",
|
|
226
|
+
"@koishijs/console": "@koishi-ce/console",
|
|
227
|
+
"@koishijs/registry": "@koishi-ce/registry",
|
|
228
|
+
"@koishijs/plugin-console": "@koishi-ce/plugin-console",
|
|
229
|
+
"@koishijs/plugin-assets": "@koishi-ce/assets"
|
|
230
|
+
};
|
|
231
|
+
for (const name of [
|
|
232
|
+
"actions",
|
|
233
|
+
"admin",
|
|
234
|
+
"analytics",
|
|
235
|
+
"assets-local",
|
|
236
|
+
"auth",
|
|
237
|
+
"bind",
|
|
238
|
+
"broadcast",
|
|
239
|
+
"callme",
|
|
240
|
+
"commands",
|
|
241
|
+
"config",
|
|
242
|
+
"database-sqlite",
|
|
243
|
+
"dataview",
|
|
244
|
+
"echo",
|
|
245
|
+
"explorer",
|
|
246
|
+
"help",
|
|
247
|
+
"hmr",
|
|
248
|
+
"insight",
|
|
249
|
+
"inspect",
|
|
250
|
+
"locales",
|
|
251
|
+
"logger",
|
|
252
|
+
"market",
|
|
253
|
+
"mock",
|
|
254
|
+
"notifier",
|
|
255
|
+
"oobe",
|
|
256
|
+
"proxy-agent",
|
|
257
|
+
"rate-limit",
|
|
258
|
+
"sandbox",
|
|
259
|
+
"server",
|
|
260
|
+
"server-temp",
|
|
261
|
+
"status"
|
|
262
|
+
]) UPSTREAM_OVERRIDES[`@koishijs/plugin-${name}`] = `@koishi-ce/plugin-${name}`;
|
|
263
|
+
/** 生成模板 overrides 块:键为上游名,值统一 npm:<CE 包>@^1.0.0。 */
|
|
264
|
+
function buildUpstreamOverrides() {
|
|
265
|
+
return Object.fromEntries(Object.entries(UPSTREAM_OVERRIDES).map(([name, target]) => [name, `npm:${target}@^1.0.0`]));
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
200
268
|
* 内置模板的 package.json 基础内容(name/version 会被 renderManifest 覆写,
|
|
201
269
|
* prod 模式下 workspaces 与 devDependencies 会被移除)。
|
|
202
270
|
*/
|
|
@@ -261,6 +329,7 @@ function baseManifest() {
|
|
|
261
329
|
"@koishijs/client": "npm:@koishi-ce/client-shim@^5.30.11",
|
|
262
330
|
"@koishijs/components": "npm:@koishi-ce/components-shim@^1.5.22"
|
|
263
331
|
},
|
|
332
|
+
overrides: buildUpstreamOverrides(),
|
|
264
333
|
devDependencies: {
|
|
265
334
|
"@koishi-ce/client": "^1.0.0",
|
|
266
335
|
"@koishi-ce/plugin-hmr": "^1.0.0",
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { expect, test } from "bun:test";
|
|
|
5
5
|
import { renderManifest } from "../index.ts";
|
|
6
6
|
import {
|
|
7
7
|
baseManifest,
|
|
8
|
+
buildUpstreamOverrides,
|
|
8
9
|
templateFiles,
|
|
9
10
|
} from "../template.ts";
|
|
10
11
|
|
|
@@ -178,13 +179,14 @@ test("koishi.yml 预写策略:sqlite 默认启用开箱数据库,非必需
|
|
|
178
179
|
expect(yml).toContain(name);
|
|
179
180
|
}
|
|
180
181
|
expect(yml).not.toContain("database-mongo");
|
|
181
|
-
// 模板依赖里不得出现官方 adapter / database
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
// 模板依赖里不得出现官方 adapter / database 包名(只预写不预装)。
|
|
183
|
+
// 断言只扫 dependencies——overrides 的键含官方名是重写所需,属预期
|
|
184
|
+
expect(
|
|
185
|
+
JSON.stringify(baseManifest().dependencies),
|
|
186
|
+
).not.toContain("adapter-");
|
|
187
|
+
expect(
|
|
188
|
+
JSON.stringify(baseManifest().dependencies),
|
|
189
|
+
).not.toContain("@koishijs/plugin-database-");
|
|
188
190
|
});
|
|
189
191
|
|
|
190
192
|
test("koishi.yml 预写条目与模板依赖对账:CE 插件必须在册,官方 adapter 只预写不预装", () => {
|
|
@@ -264,3 +266,65 @@ test("renderManifest 渲染内置模板:常规改写生效,prod 模式保留
|
|
|
264
266
|
"npm:@koishi-ce/koishi-shim@^4.18.11",
|
|
265
267
|
);
|
|
266
268
|
});
|
|
269
|
+
|
|
270
|
+
test("内置模板 overrides 兜底层:41 个上游名强制重定向 CE 包", () => {
|
|
271
|
+
const table = baseManifest().overrides ?? {};
|
|
272
|
+
expect(Object.keys(table)).toHaveLength(41);
|
|
273
|
+
const keys = Object.keys(table);
|
|
274
|
+
// 核心九名(钉名六行之外由 overrides 补齐覆盖面)
|
|
275
|
+
expect(table["koishi"]).toBe(
|
|
276
|
+
"npm:@koishi-ce/koishi@^1.0.0",
|
|
277
|
+
);
|
|
278
|
+
expect(table["@koishijs/core"]).toBe(
|
|
279
|
+
"npm:@koishi-ce/koishi@^1.0.0",
|
|
280
|
+
);
|
|
281
|
+
expect(table["@koishijs/loader"]).toBe(
|
|
282
|
+
"npm:@koishi-ce/koishi@^1.0.0",
|
|
283
|
+
);
|
|
284
|
+
expect(table["@koishijs/utils"]).toBe(
|
|
285
|
+
"npm:@koishi-ce/utils@^1.0.0",
|
|
286
|
+
);
|
|
287
|
+
expect(table["@koishijs/i18n-utils"]).toBe(
|
|
288
|
+
"npm:@koishi-ce/i18n-utils@^1.0.0",
|
|
289
|
+
);
|
|
290
|
+
expect(table["@koishijs/client"]).toBe(
|
|
291
|
+
"npm:@koishi-ce/client@^1.0.0",
|
|
292
|
+
);
|
|
293
|
+
expect(table["@koishijs/components"]).toBe(
|
|
294
|
+
"npm:@koishi-ce/components@^1.0.0",
|
|
295
|
+
);
|
|
296
|
+
expect(table["@koishijs/console"]).toBe(
|
|
297
|
+
"npm:@koishi-ce/console@^1.0.0",
|
|
298
|
+
);
|
|
299
|
+
expect(table["@koishijs/registry"]).toBe(
|
|
300
|
+
"npm:@koishi-ce/registry@^1.0.0",
|
|
301
|
+
);
|
|
302
|
+
// CE 原创与上游裸名社区对应物不进清单(不拦官方生态的真实依赖)
|
|
303
|
+
expect(keys.includes("@koishijs/plugin-welcome")).toBe(
|
|
304
|
+
false,
|
|
305
|
+
);
|
|
306
|
+
expect(
|
|
307
|
+
keys.includes("@koishijs/plugin-theme-vanilla"),
|
|
308
|
+
).toBe(false);
|
|
309
|
+
expect(keys.includes("@koishijs/plugin-cron")).toBe(
|
|
310
|
+
false,
|
|
311
|
+
);
|
|
312
|
+
// plugin-assets 的 CE 对应物无 plugin 前缀
|
|
313
|
+
expect(table["@koishijs/plugin-assets"]).toBe(
|
|
314
|
+
"npm:@koishi-ce/assets@^1.0.0",
|
|
315
|
+
);
|
|
316
|
+
// 全部值为 npm:@koishi-ce/ 前缀,键全为 @koishijs/ 上游名或 koishi 裸名
|
|
317
|
+
for (const key of keys) {
|
|
318
|
+
expect(
|
|
319
|
+
key === "koishi" || key.startsWith("@koishijs/"),
|
|
320
|
+
).toBe(true);
|
|
321
|
+
expect(table[key]).toMatch(/^npm:@koishi-ce\//);
|
|
322
|
+
}
|
|
323
|
+
// buildUpstreamOverrides 与 baseManifest().overrides 同源
|
|
324
|
+
expect(buildUpstreamOverrides()).toEqual(table);
|
|
325
|
+
// renderManifest 全程透传 overrides(prod 模式也不删)
|
|
326
|
+
const prod = JSON.parse(
|
|
327
|
+
renderManifest(baseManifest(), "my-app", true),
|
|
328
|
+
);
|
|
329
|
+
expect(prod.overrides).toEqual(table);
|
|
330
|
+
});
|
package/src/manifest.ts
CHANGED
package/src/template.ts
CHANGED
|
@@ -85,6 +85,88 @@ export const templateFiles: Record<string, string> =
|
|
|
85
85
|
]),
|
|
86
86
|
);
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* 上游名 → CE 对应包的 overrides 兜底映射(值统一 npm:<目标>@^1.0.0,
|
|
90
|
+
* 经 buildUpstreamOverrides 包装)。
|
|
91
|
+
*
|
|
92
|
+
* 六行钉名依赖「落盘版本满足声明范围」:第三方插件的声明超出冻结线
|
|
93
|
+
* (如未来上游升线后的 ^6)或引用清单外的上游名(如 dependencies 直接
|
|
94
|
+
* 依赖 @koishijs/plugin-admin / @koishijs/utils)时,官方包仍会落盘。
|
|
95
|
+
* overrides 是包管理器级的强制重写——不看版本满足性,把整棵依赖树中对
|
|
96
|
+
* 这些上游名的解析一律改指 CE 对应包,与钉名构成双层防线(napuketto
|
|
97
|
+
* 事件 2026-09-19 后补)。
|
|
98
|
+
*
|
|
99
|
+
* 清单 = CE 已再分发且官方同名的包,2026-09-19 逐一 npm view 核实:
|
|
100
|
+
* - plugin-cron 不在列(上游是裸名社区包 koishi-plugin-cron,非 @koishijs
|
|
101
|
+
* 作用域);
|
|
102
|
+
* - plugin-welcome / plugin-theme-vanilla 不在列(CE 原创,上游无此名);
|
|
103
|
+
* - plugin-assets 的 CE 对应物是 @koishi-ce/assets(无 plugin 前缀)。
|
|
104
|
+
* 新增 CE 再分发包时须同步本表与 sandbox 生成器的同款清单
|
|
105
|
+
* (tooling/sandbox/manifest.ts,对账测试防漂移)。
|
|
106
|
+
*/
|
|
107
|
+
const UPSTREAM_OVERRIDES: Record<string, string> = {
|
|
108
|
+
koishi: "@koishi-ce/koishi",
|
|
109
|
+
"@koishijs/core": "@koishi-ce/koishi",
|
|
110
|
+
"@koishijs/loader": "@koishi-ce/koishi",
|
|
111
|
+
"@koishijs/utils": "@koishi-ce/utils",
|
|
112
|
+
"@koishijs/i18n-utils": "@koishi-ce/i18n-utils",
|
|
113
|
+
"@koishijs/client": "@koishi-ce/client",
|
|
114
|
+
"@koishijs/components": "@koishi-ce/components",
|
|
115
|
+
"@koishijs/console": "@koishi-ce/console",
|
|
116
|
+
"@koishijs/registry": "@koishi-ce/registry",
|
|
117
|
+
"@koishijs/plugin-console": "@koishi-ce/plugin-console",
|
|
118
|
+
"@koishijs/plugin-assets": "@koishi-ce/assets",
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// CE 与上游同名再分发的 plugin-*:机械一一对应
|
|
122
|
+
for (const name of [
|
|
123
|
+
"actions",
|
|
124
|
+
"admin",
|
|
125
|
+
"analytics",
|
|
126
|
+
"assets-local",
|
|
127
|
+
"auth",
|
|
128
|
+
"bind",
|
|
129
|
+
"broadcast",
|
|
130
|
+
"callme",
|
|
131
|
+
"commands",
|
|
132
|
+
"config",
|
|
133
|
+
"database-sqlite",
|
|
134
|
+
"dataview",
|
|
135
|
+
"echo",
|
|
136
|
+
"explorer",
|
|
137
|
+
"help",
|
|
138
|
+
"hmr",
|
|
139
|
+
"insight",
|
|
140
|
+
"inspect",
|
|
141
|
+
"locales",
|
|
142
|
+
"logger",
|
|
143
|
+
"market",
|
|
144
|
+
"mock",
|
|
145
|
+
"notifier",
|
|
146
|
+
"oobe",
|
|
147
|
+
"proxy-agent",
|
|
148
|
+
"rate-limit",
|
|
149
|
+
"sandbox",
|
|
150
|
+
"server",
|
|
151
|
+
"server-temp",
|
|
152
|
+
"status",
|
|
153
|
+
]) {
|
|
154
|
+
UPSTREAM_OVERRIDES[`@koishijs/plugin-${name}`] =
|
|
155
|
+
`@koishi-ce/plugin-${name}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** 生成模板 overrides 块:键为上游名,值统一 npm:<CE 包>@^1.0.0。 */
|
|
159
|
+
export function buildUpstreamOverrides(): Record<
|
|
160
|
+
string,
|
|
161
|
+
string
|
|
162
|
+
> {
|
|
163
|
+
return Object.fromEntries(
|
|
164
|
+
Object.entries(UPSTREAM_OVERRIDES).map(
|
|
165
|
+
([name, target]) => [name, `npm:${target}@^1.0.0`],
|
|
166
|
+
),
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
88
170
|
/**
|
|
89
171
|
* 内置模板的 package.json 基础内容(name/version 会被 renderManifest 覆写,
|
|
90
172
|
* prod 模式下 workspaces 与 devDependencies 会被移除)。
|
|
@@ -187,6 +269,9 @@ export function baseManifest(): Manifest {
|
|
|
187
269
|
"@koishijs/components":
|
|
188
270
|
"npm:@koishi-ce/components-shim@^1.5.22",
|
|
189
271
|
},
|
|
272
|
+
// overrides 兜底层(语义见 UPSTREAM_OVERRIDES 注释):不看版本
|
|
273
|
+
// 满足性强制重写整棵依赖树,拦住钉名覆盖面之外的上游声明
|
|
274
|
+
overrides: buildUpstreamOverrides(),
|
|
190
275
|
devDependencies: {
|
|
191
276
|
"@koishi-ce/client": "^1.0.0",
|
|
192
277
|
"@koishi-ce/plugin-hmr": "^1.0.0",
|