create-koishi-ce 1.9.1 → 1.9.2

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- import { t as start } from "./src-B2UEAnHe.mjs";
2
+ import { t as start } from "./src-BuWh9uz0.mjs";
3
3
  //#region src/bin.ts
4
4
  /**
5
5
  * create-koishi-ce 的 CLI 可执行入口:shebang 由 rolldown 原样保留到
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-B2UEAnHe.mjs";
1
+ import { a as renderManifest, i as readNpmrcRegistry, n as detectAgent, r as getLocalRegistry, t as start } from "./src-BuWh9uz0.mjs";
2
2
  export { detectAgent, getLocalRegistry, readNpmrcRegistry, renderManifest, start };
@@ -9,7 +9,7 @@ import { tmpdir } from "node:os";
9
9
  var package_default = {
10
10
  name: "create-koishi-ce",
11
11
  description: "Setup a Koishi application",
12
- version: "1.9.1",
12
+ version: "1.9.2",
13
13
  type: "module",
14
14
  main: "./lib/index.mjs",
15
15
  module: "./lib/index.mjs",
@@ -212,6 +212,7 @@ const templateFiles = Object.fromEntries(readdirSync(templateDir).filter((file)
212
212
  * 作用域);
213
213
  * - plugin-welcome / plugin-theme-vanilla 不在列(CE 原创,上游无此名);
214
214
  * - plugin-assets 的 CE 对应物是 @koishi-ce/assets(无 plugin 前缀)。
215
+ * 裸名社区包另见 RENAMED_COMMUNITY_OVERRIDES(按需收录,非机械生成)。
215
216
  * 新增 CE 再分发包时须同步本表与 sandbox 生成器的同款清单
216
217
  * (tooling/sandbox/manifest.ts,对账测试防漂移)。
217
218
  */
@@ -260,9 +261,32 @@ for (const name of [
260
261
  "server-temp",
261
262
  "status"
262
263
  ]) UPSTREAM_OVERRIDES[`@koishijs/plugin-${name}`] = `@koishi-ce/plugin-${name}`;
264
+ /**
265
+ * 裸名社区包 → CE 改名再分发的 overrides 兜底映射(包装方式同上)。
266
+ *
267
+ * 与 UPSTREAM_OVERRIDES 的区别:上游是裸名社区包(不在 @koishijs 作用域
268
+ * 内),CE 以改名包 `@koishi-ce/plugin-<名>` 再分发,落盘版本永远满足不了
269
+ * 第三方插件的 `koishi-plugin-<名>` 声明——没有归属时包管理器会自动装下
270
+ * 官方实现,同一份服务就有了第二个实现(CE 宿主里凭空多出官方包)。
271
+ *
272
+ * 收录条件是「有第三方插件把该裸名写进 peer / dependencies」,故本表按需
273
+ * 增补而非按 CE 再分发清单机械生成:puppeteer 的直接证据是
274
+ * koishi-plugin-market-tracker 的 peerDependencies(CE 对应物
275
+ * @koishi-ce/plugin-puppeteer 提供同名 puppeteer 服务);无此证据的裸名
276
+ * 社区包(如 koishi-plugin-cron)不入列,不无谓拦下官方生态的真实依赖。
277
+ *
278
+ * 代价须知(2026-10-07 实测):overrides 是包管理器级强制重写,Bun 遇到
279
+ * 与用户显式直连依赖冲突时既不报错也不提示(npm 会抛 EOVERRIDE),会把
280
+ * `koishi-plugin-puppeteer` 静默替换为 CE 包——即本模板项目里装不上官方
281
+ * 同名实现。这是 CE 生态的取舍得当与否,改本表前须一并权衡。
282
+ */
283
+ const RENAMED_COMMUNITY_OVERRIDES = { "koishi-plugin-puppeteer": "@koishi-ce/plugin-puppeteer" };
263
284
  /** 生成模板 overrides 块:键为上游名,值统一 npm:<CE 包>@^1.0.0。 */
264
285
  function buildUpstreamOverrides() {
265
- return Object.fromEntries(Object.entries(UPSTREAM_OVERRIDES).map(([name, target]) => [name, `npm:${target}@^1.0.0`]));
286
+ return Object.fromEntries(Object.entries({
287
+ ...UPSTREAM_OVERRIDES,
288
+ ...RENAMED_COMMUNITY_OVERRIDES
289
+ }).map(([name, target]) => [name, `npm:${target}@^1.0.0`]));
266
290
  }
267
291
  /**
268
292
  * 内置模板的 package.json 基础内容(name/version 会被 renderManifest 覆写,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-koishi-ce",
3
3
  "description": "Setup a Koishi application",
4
- "version": "1.9.1",
4
+ "version": "1.9.2",
5
5
  "type": "module",
6
6
  "main": "./lib/index.mjs",
7
7
  "module": "./lib/index.mjs",
@@ -267,9 +267,9 @@ test("renderManifest 渲染内置模板:常规改写生效,prod 模式保留
267
267
  );
268
268
  });
269
269
 
270
- test("内置模板 overrides 兜底层:41 个上游名强制重定向 CE 包", () => {
270
+ test("内置模板 overrides 兜底层:42 个上游名/裸名强制重定向 CE 包", () => {
271
271
  const table = baseManifest().overrides ?? {};
272
- expect(Object.keys(table)).toHaveLength(41);
272
+ expect(Object.keys(table)).toHaveLength(42);
273
273
  const keys = Object.keys(table);
274
274
  // 核心九名(钉名六行之外由 overrides 补齐覆盖面)
275
275
  expect(table["koishi"]).toBe(
@@ -299,7 +299,9 @@ test("内置模板 overrides 兜底层:41 个上游名强制重定向 CE 包",
299
299
  expect(table["@koishijs/registry"]).toBe(
300
300
  "npm:@koishi-ce/registry@^1.0.0",
301
301
  );
302
- // CE 原创与上游裸名社区对应物不进清单(不拦官方生态的真实依赖)
302
+ // CE 原创与无第三方声明证据的裸名社区对应物不进清单(不拦官方生态的
303
+ // 真实依赖):welcome / theme-vanilla 是 CE 原创;cron 上游虽是裸名社区
304
+ // 包 koishi-plugin-cron,但未收进按需增补的裸名社区表
303
305
  expect(keys.includes("@koishijs/plugin-welcome")).toBe(
304
306
  false,
305
307
  );
@@ -309,14 +311,25 @@ test("内置模板 overrides 兜底层:41 个上游名强制重定向 CE 包",
309
311
  expect(keys.includes("@koishijs/plugin-cron")).toBe(
310
312
  false,
311
313
  );
314
+ expect(keys.includes("koishi-plugin-cron")).toBe(false);
315
+ // 裸名社区包按需收录:CE 以 @koishi-ce/plugin-<名> 改名再分发,第三方插件
316
+ // 的 peer 声明(market-tracker 声明了 koishi-plugin-puppeteer)无归属时
317
+ // 包管理器会自动装下官方实现,故须顶替
318
+ expect(table["koishi-plugin-puppeteer"]).toBe(
319
+ "npm:@koishi-ce/plugin-puppeteer@^1.0.0",
320
+ );
312
321
  // plugin-assets 的 CE 对应物无 plugin 前缀
313
322
  expect(table["@koishijs/plugin-assets"]).toBe(
314
323
  "npm:@koishi-ce/assets@^1.0.0",
315
324
  );
316
- // 全部值为 npm:@koishi-ce/ 前缀,键全为 @koishijs/ 上游名或 koishi 裸名
325
+ // 全部值为 npm:@koishi-ce/ 前缀,键为 koishi 裸名、@koishijs/ 上游名,
326
+ // 或按需收录的裸名社区包(当前仅 koishi-plugin-puppeteer)
327
+ const renamedCommunityKeys = ["koishi-plugin-puppeteer"];
317
328
  for (const key of keys) {
318
329
  expect(
319
- key === "koishi" || key.startsWith("@koishijs/"),
330
+ key === "koishi" ||
331
+ key.startsWith("@koishijs/") ||
332
+ renamedCommunityKeys.includes(key),
320
333
  ).toBe(true);
321
334
  expect(table[key]).toMatch(/^npm:@koishi-ce\//);
322
335
  }
package/src/template.ts CHANGED
@@ -101,6 +101,7 @@ export const templateFiles: Record<string, string> =
101
101
  * 作用域);
102
102
  * - plugin-welcome / plugin-theme-vanilla 不在列(CE 原创,上游无此名);
103
103
  * - plugin-assets 的 CE 对应物是 @koishi-ce/assets(无 plugin 前缀)。
104
+ * 裸名社区包另见 RENAMED_COMMUNITY_OVERRIDES(按需收录,非机械生成)。
104
105
  * 新增 CE 再分发包时须同步本表与 sandbox 生成器的同款清单
105
106
  * (tooling/sandbox/manifest.ts,对账测试防漂移)。
106
107
  */
@@ -155,15 +156,44 @@ for (const name of [
155
156
  `@koishi-ce/plugin-${name}`;
156
157
  }
157
158
 
159
+ /**
160
+ * 裸名社区包 → CE 改名再分发的 overrides 兜底映射(包装方式同上)。
161
+ *
162
+ * 与 UPSTREAM_OVERRIDES 的区别:上游是裸名社区包(不在 @koishijs 作用域
163
+ * 内),CE 以改名包 `@koishi-ce/plugin-<名>` 再分发,落盘版本永远满足不了
164
+ * 第三方插件的 `koishi-plugin-<名>` 声明——没有归属时包管理器会自动装下
165
+ * 官方实现,同一份服务就有了第二个实现(CE 宿主里凭空多出官方包)。
166
+ *
167
+ * 收录条件是「有第三方插件把该裸名写进 peer / dependencies」,故本表按需
168
+ * 增补而非按 CE 再分发清单机械生成:puppeteer 的直接证据是
169
+ * koishi-plugin-market-tracker 的 peerDependencies(CE 对应物
170
+ * @koishi-ce/plugin-puppeteer 提供同名 puppeteer 服务);无此证据的裸名
171
+ * 社区包(如 koishi-plugin-cron)不入列,不无谓拦下官方生态的真实依赖。
172
+ *
173
+ * 代价须知(2026-10-07 实测):overrides 是包管理器级强制重写,Bun 遇到
174
+ * 与用户显式直连依赖冲突时既不报错也不提示(npm 会抛 EOVERRIDE),会把
175
+ * `koishi-plugin-puppeteer` 静默替换为 CE 包——即本模板项目里装不上官方
176
+ * 同名实现。这是 CE 生态的取舍得当与否,改本表前须一并权衡。
177
+ */
178
+ const RENAMED_COMMUNITY_OVERRIDES: Record<string, string> =
179
+ {
180
+ "koishi-plugin-puppeteer":
181
+ "@koishi-ce/plugin-puppeteer",
182
+ };
183
+
158
184
  /** 生成模板 overrides 块:键为上游名,值统一 npm:<CE 包>@^1.0.0。 */
159
185
  export function buildUpstreamOverrides(): Record<
160
186
  string,
161
187
  string
162
188
  > {
163
189
  return Object.fromEntries(
164
- Object.entries(UPSTREAM_OVERRIDES).map(
165
- ([name, target]) => [name, `npm:${target}@^1.0.0`],
166
- ),
190
+ Object.entries({
191
+ ...UPSTREAM_OVERRIDES,
192
+ ...RENAMED_COMMUNITY_OVERRIDES,
193
+ }).map(([name, target]) => [
194
+ name,
195
+ `npm:${target}@^1.0.0`,
196
+ ]),
167
197
  );
168
198
  }
169
199
 
@@ -269,7 +299,8 @@ export function baseManifest(): Manifest {
269
299
  "@koishijs/components":
270
300
  "npm:@koishi-ce/components-shim@^1.5.22",
271
301
  },
272
- // overrides 兜底层(语义见 UPSTREAM_OVERRIDES 注释):不看版本
302
+ // overrides 兜底层(语义见 UPSTREAM_OVERRIDES 与
303
+ // RENAMED_COMMUNITY_OVERRIDES 注释):不看版本
273
304
  // 满足性强制重写整棵依赖树,拦住钉名覆盖面之外的上游声明
274
305
  overrides: buildUpstreamOverrides(),
275
306
  devDependencies: {