create-koishi-ce 1.2.1 → 1.3.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/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # create-koishi-ce
2
+
3
+ **简体中文** | [English](#english)
4
+
5
+ Koishi CE 生态的项目脚手架。一条命令生成以 Bun 为运行时、纯 `@koishi-ce` 依赖的完整机器人项目:预装常用插件、钉住上游包名 alias、预写分组配置,开箱即可 `koishi start`。
6
+
7
+ ```bash
8
+ bunx create-koishi-ce my-app
9
+ # 或
10
+ npm create koishi-ce my-app
11
+ ```
12
+
13
+ ## 选项
14
+
15
+ | 选项 | 默认值 | 说明 |
16
+ | --- | --- | --- |
17
+ | `[名称]` | 交互询问(初始值 koishi-app) | 项目名,同时作为目标目录名 |
18
+ | `-t, --template <名称>` | 内置模板 | 改用 npm registry 上的远程模板包(逃生舱) |
19
+ | `-r, --ref <引用>` | latest | 远程模板的版本引用 |
20
+ | `-f, --forced` | - | 强制清空目标目录 |
21
+ | `-g, --git` | - | 初始化 git 仓库(分支取 init.defaultBranch,未配置则 main) |
22
+ | `--registry <地址>` | 参数 > npm_config_registry > .npmrc > 官方源 | npm registry |
23
+ | `-p, --prod` | - | 生产模式:删除模板的 workspaces 与 devDependencies |
24
+ | `-y, --yes` | - | 跳过全部询问(含跳过依赖安装) |
25
+
26
+ 交互流程:项目名;目标目录非空时确认是否清空;最后确认是否立即安装依赖并启动(包管理器一律使用 Bun)。
27
+
28
+ ## 生成的项目
29
+
30
+ - **package.json**:`type: module`、`packageManager` 钉 Bun、workspaces 含 `plugins/*` 与 `external/*`;dependencies 预装全套 `@koishi-ce` 常用插件(console、config、market、auth、admin、help、sandbox 等),并预置四行 npm alias 钉住上游名——`koishi` / `@koishijs/core` / `@koishijs/loader` 指向 `@koishi-ce/koishi-shim`、`@koishijs/plugin-console` 指向 `@koishi-ce/console-shim`,社区插件由此全部解析到 CE 框架;
31
+ - **koishi.yml**:按 server(端口 5140-5149)/ basic / console(自动打开、市场指向 registry.koishi.chat 镜像)/ storage / adapter / develop(开发模式启用热重载)分组预写;官方 adapter / database 插件以 `~` 停用条目预写,可按需启用;
32
+ - **开发工具链**:devDependencies 预置 `@koishi-ce/client`、`@koishi-ce/plugin-hmr` 与 `@koishi-ce/scripts`(`koishi-scripts setup` 可在 external/ 下继续创建插件项目)。
33
+
34
+ 不预装任何 adapter 与 database——官方版本可后续从市场安装,peer 已被 alias 钉住不会形成双实例。
35
+
36
+ ## 许可证
37
+
38
+ [MIT](https://github.com/Koishi-CE/koishi/blob/main/LICENSE),本仓库原创作品,版权归 Koishi-CE 贡献者,见 [NOTICE](https://github.com/Koishi-CE/koishi/blob/main/NOTICE)。
39
+
40
+ ---
41
+
42
+ ## English
43
+
44
+ The project scaffold for the Koishi CE ecosystem. One command generates a complete bot project on the Bun runtime with pure `@koishi-ce` dependencies: common plugins preinstalled, upstream-name aliases pinned, grouped config prewritten — ready for `koishi start` out of the box.
45
+
46
+ ```bash
47
+ bunx create-koishi-ce my-app
48
+ # or
49
+ npm create koishi-ce my-app
50
+ ```
51
+
52
+ ## Options
53
+
54
+ | Option | Default | Description |
55
+ | --- | --- | --- |
56
+ | `[name]` | prompted (initial koishi-app) | Project name, also the target directory |
57
+ | `-t, --template <name>` | built-in template | Use a remote template package from the npm registry (escape hatch) |
58
+ | `-r, --ref <ref>` | latest | Version ref of the remote template |
59
+ | `-f, --forced` | - | Force-clean the target directory |
60
+ | `-g, --git` | - | Initialize a git repository (branch from init.defaultBranch, fallback main) |
61
+ | `--registry <url>` | arg > npm_config_registry > .npmrc > official | npm registry |
62
+ | `-p, --prod` | - | Production mode: drop workspaces and devDependencies from the template |
63
+ | `-y, --yes` | - | Skip all prompts (including dependency installation) |
64
+
65
+ Interactive flow: project name; confirm cleaning a non-empty target directory; confirm installing dependencies and starting right away (Bun is always the package manager).
66
+
67
+ ## Generated project
68
+
69
+ - **package.json** — `type: module`, `packageManager` pinned to Bun, workspaces covering `plugins/*` and `external/*`; dependencies preinstall the common `@koishi-ce` plugin set (console, config, market, auth, admin, help, sandbox, etc.) plus the four npm-alias lines pinning the upstream names (`koishi` / `@koishijs/core` / `@koishijs/loader` to `@koishi-ce/koishi-shim`, `@koishijs/plugin-console` to `@koishi-ce/console-shim`), so community plugins all resolve to the CE framework.
70
+ - **koishi.yml** — grouped prewrites for server (ports 5140-5149), basic, console (auto-open, market pointed at the registry.koishi.chat mirror), storage, adapter and develop (HMR in development mode); official adapter / database plugins are prewritten as `~`-disabled entries.
71
+ - **Toolchain** — devDependencies include `@koishi-ce/client`, `@koishi-ce/plugin-hmr` and `@koishi-ce/scripts` (`koishi-scripts setup` scaffolds further plugin projects under external/).
72
+
73
+ No adapter or database is preinstalled — official ones can be installed from the market later; their peers are already pinned by the aliases.
74
+
75
+ ## License
76
+
77
+ [MIT](https://github.com/Koishi-CE/koishi/blob/main/LICENSE), original work of this repository, copyright Koishi-CE contributors — see [NOTICE](https://github.com/Koishi-CE/koishi/blob/main/NOTICE).
package/lib/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- import { a as start } from "./src-CwJZjC5d.mjs";
2
+ import { t as start } from "./src-Dh_67mkm.mjs";
3
3
  //#region src/bin.ts
4
4
  /**
5
5
  * create-koishi-ce 的 CLI 可执行入口:shebang 由 rolldown 原样保留到
package/lib/index.d.ts CHANGED
@@ -1,7 +1,12 @@
1
- //#region src/index.d.ts
1
+ //#region src/manifest.d.ts
2
+ /**
3
+ * 模板项目 package.json 的类型与改写(纯函数域,无副作用):定义本流程
4
+ * 触碰字段的类型并提供渲染函数。内置模板(index.ts 的 scaffoldBuiltin
5
+ * 直接渲染写入)与远程模板(remote.ts 读回解包产物后改写)共用这里。
6
+ */
2
7
  /**
3
- * 模板项目的 package.json(改写目标):只需要类型化本流程触碰的字段,
4
- * 其余字段经 index signature 原样保留。
8
+ * 模板项目的 package.json(改写源 / 目标):只需要类型化本流程触碰的
9
+ * 字段,其余字段经 index signature 原样保留。
5
10
  */
6
11
  interface Manifest {
7
12
  name?: string;
@@ -13,11 +18,12 @@ interface Manifest {
13
18
  [key: string]: unknown;
14
19
  }
15
20
  /**
16
- * 探测后续安装/启动使用的包管理器(Bun-first):yarn / pnpm 用户跟随其
17
- * 生态习惯;其余场景(npm、bun 及探测不到 user-agent)一律走 bun——
18
- * 本 CLI 自身以 bun 为运行时(bin shebang),能执行即已具备 bun 环境。
21
+ * 改写模板的 package.json(纯函数,导出供单测):替换项目名、标记
22
+ * private、版本归零。
19
23
  */
20
- declare function detectAgent(): string;
24
+ declare function renderManifest(source: Manifest, project: string, prod: boolean): string;
25
+ //#endregion
26
+ //#region src/registry.d.ts
21
27
  /**
22
28
  * 从单个 .npmrc 文件提取 registry 配置项(非注释、非 scoped 的 registry= 行)。
23
29
  * 文件不存在或未配置时返回 undefined,读文件异常一律静默吞掉。
@@ -25,22 +31,24 @@ declare function detectAgent(): string;
25
31
  declare function readNpmrcRegistry(file: string): string | undefined;
26
32
  /**
27
33
  * 读取本机 npm registry 配置(优先级对齐 npm 自身:环境变量 > 项目
28
- * .npmrc > 用户 ~/.npmrc)。刻意不 spawn 子进程探测——既有实现按
29
- * user-agent 选 `bun config get registry`,而 Bun 没有 config 子命令,
30
- * bunx 场景下子进程退出码 1 直接炸掉脚手架;读 npmrc 是零依赖、零
31
- * 子进程的等价路径。任何一步都拿不到时返回 undefined,由调用方回落
32
- * 官方源。
34
+ * .npmrc > 用户 ~/.npmrc)。任何一步都拿不到时返回 undefined,由调用方
35
+ * 回落官方源。
33
36
  */
34
37
  declare function getLocalRegistry(cwd?: string, userHome?: string): string | undefined;
38
+ //#endregion
39
+ //#region src/utils.d.ts
35
40
  /**
36
- * 改写模板的 package.json(纯函数,导出供单测):替换项目名、标记
37
- * private、版本归零。
41
+ * 探测后续安装/启动使用的包管理器(Bun-first):yarn / pnpm 用户跟随其
42
+ * 生态习惯;其余场景(npm、bun 及探测不到 user-agent)一律走 bun——
43
+ * 本 CLI 自身以 bun 为运行时(bin shebang),能执行即已具备 bun 环境。
38
44
  */
39
- declare function renderManifest(source: Manifest, project: string, prod: boolean): string;
45
+ declare function detectAgent(): string;
46
+ //#endregion
47
+ //#region src/index.d.ts
40
48
  /**
41
49
  * CLI 主流程:--help 打印用法后即返回;否则依次执行
42
50
  * 项目名询问 → prepare(目录准备)→ scaffold(模板解包)→ initGit → install。
43
51
  */
44
52
  declare function start(): Promise<void>;
45
53
  //#endregion
46
- export { Manifest, detectAgent, getLocalRegistry, readNpmrcRegistry, renderManifest, start };
54
+ export { type Manifest, detectAgent, getLocalRegistry, readNpmrcRegistry, renderManifest, start };
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-CwJZjC5d.mjs";
1
+ import { a as renderManifest, i as readNpmrcRegistry, n as detectAgent, r as getLocalRegistry, t as start } from "./src-Dh_67mkm.mjs";
2
2
  export { detectAgent, getLocalRegistry, readNpmrcRegistry, renderManifest, start };