create-zhin-app 1.0.1 → 1.0.3
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 +19 -14
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ npx create-zhin-app@latest my-awesome-bot
|
|
|
31
31
|
|
|
32
32
|
`create-zhin-app` 是 `@zhin.js/cli` 的轻量级包装器,它的工作流程如下:
|
|
33
33
|
|
|
34
|
-
1. **启动脚手架**: 当你运行 `npm create zhin` 时
|
|
34
|
+
1. **启动脚手架**: 当你运行 `npm create zhin-app` 时
|
|
35
35
|
2. **参数解析**: 解析项目名称和所有命令行参数
|
|
36
36
|
3. **调用 CLI**: 自动调用 `zhin init` 命令
|
|
37
37
|
4. **参数转发**: 将所有参数原样传递给 CLI 工具
|
|
@@ -42,7 +42,7 @@ npx create-zhin-app@latest my-awesome-bot
|
|
|
42
42
|
const args = process.argv.slice(2);
|
|
43
43
|
const initArgs = ['init', ...args];
|
|
44
44
|
|
|
45
|
-
spawn('
|
|
45
|
+
spawn('node', [cliPath, ...initArgs], {
|
|
46
46
|
stdio: 'inherit',
|
|
47
47
|
cwd: process.cwd()
|
|
48
48
|
});
|
|
@@ -79,7 +79,7 @@ npm create zhin-app my-bot -- \
|
|
|
79
79
|
|------|--------|------|--------|--------|
|
|
80
80
|
| `--config` | `-c` | 配置文件格式 | `js`, `ts`, `json`, `yaml`, `toml` | `js` |
|
|
81
81
|
| `--package-manager` | `-p` | 包管理器 | `npm`, `yarn`, `pnpm` | `pnpm` |
|
|
82
|
-
| `--runtime` | `-r` | 运行时 | `node`, `bun` | `
|
|
82
|
+
| `--runtime` | `-r` | 运行时 | `node`, `bun` | `node` |
|
|
83
83
|
| `--yes` | `-y` | 跳过交互式配置 | 无 | `false` |
|
|
84
84
|
|
|
85
85
|
## 使用场景
|
|
@@ -96,8 +96,8 @@ npm run dev
|
|
|
96
96
|
### 2. 生产项目创建
|
|
97
97
|
|
|
98
98
|
```bash
|
|
99
|
-
# 使用 TypeScript + pnpm +
|
|
100
|
-
npm create zhin-app production-bot -- -c ts -p pnpm -r
|
|
99
|
+
# 使用 TypeScript + pnpm + node 的生产配置
|
|
100
|
+
npm create zhin-app production-bot -- -c ts -p pnpm -r node
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
### 3. 团队标准项目
|
|
@@ -115,7 +115,7 @@ npm create zhin-app team-bot -- \
|
|
|
115
115
|
|
|
116
116
|
```bash
|
|
117
117
|
# 使用最新技术栈
|
|
118
|
-
npm create zhin-app experimental-bot -- -c ts -r
|
|
118
|
+
npm create zhin-app experimental-bot -- -c ts -r node -y
|
|
119
119
|
```
|
|
120
120
|
|
|
121
121
|
## 生成的项目结构
|
|
@@ -128,7 +128,7 @@ my-awesome-bot/
|
|
|
128
128
|
│ ├── index.ts # 主入口文件
|
|
129
129
|
│ └── plugins/ # 插件目录
|
|
130
130
|
│ └── test-plugin.ts # 示例插件
|
|
131
|
-
├──
|
|
131
|
+
├── dist/ # 构建输出目录
|
|
132
132
|
├── data/ # 数据存储目录
|
|
133
133
|
├── logs/ # 日志目录(如果配置了)
|
|
134
134
|
├── zhin.config.[ext] # 配置文件
|
|
@@ -146,7 +146,7 @@ my-awesome-bot/
|
|
|
146
146
|
|
|
147
147
|
```javascript
|
|
148
148
|
// zhin.config.ts
|
|
149
|
-
import { defineConfig } from '
|
|
149
|
+
import { defineConfig } from 'zhin.js';
|
|
150
150
|
|
|
151
151
|
export default defineConfig(async (env) => {
|
|
152
152
|
return {
|
|
@@ -167,19 +167,24 @@ export default defineConfig(async (env) => {
|
|
|
167
167
|
|
|
168
168
|
```typescript
|
|
169
169
|
// zhin.config.ts
|
|
170
|
-
import { defineConfig } from '
|
|
171
|
-
import type { AppConfig } from '
|
|
170
|
+
import { defineConfig } from 'zhin.js';
|
|
171
|
+
import type { AppConfig } from 'zhin.js';
|
|
172
172
|
|
|
173
173
|
export default defineConfig<AppConfig>(async (env) => {
|
|
174
174
|
return {
|
|
175
175
|
bots: [
|
|
176
176
|
{
|
|
177
|
-
context: '
|
|
178
|
-
name:
|
|
179
|
-
url: env.BOT_URL || 'ws://localhost:8080',
|
|
177
|
+
context: 'process',
|
|
178
|
+
name: `${process.pid}`,
|
|
180
179
|
}
|
|
181
180
|
],
|
|
182
|
-
plugin_dirs: ['./src/plugins'],
|
|
181
|
+
plugin_dirs: ['./src/plugins', 'node_modules'],
|
|
182
|
+
plugins: [
|
|
183
|
+
'adapter-process',
|
|
184
|
+
'http',
|
|
185
|
+
'console',
|
|
186
|
+
'test-plugin'
|
|
187
|
+
],
|
|
183
188
|
debug: process.env.NODE_ENV === 'development'
|
|
184
189
|
};
|
|
185
190
|
});
|
package/lib/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { dirname, join } from 'node:path';
|
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = dirname(__filename);
|
|
8
8
|
// 计算CLI的绝对路径
|
|
9
|
-
const cliPath = join(__dirname, '
|
|
9
|
+
const cliPath = join(__dirname, '..', 'node_modules', '@zhin.js', 'cli', 'lib', 'cli.js');
|
|
10
10
|
// 直接调用 CLI 的 init 命令
|
|
11
11
|
const args = process.argv.slice(2);
|
|
12
12
|
const initArgs = ['init', ...args];
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,WAAW;AACX,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAA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AAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-zhin-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Create a new zhin bot project",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"lib"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@zhin.js/cli": "1.0.
|
|
13
|
+
"@zhin.js/cli": "1.0.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/node": "^24.3.0",
|
|
17
17
|
"typescript": "^5.3.0",
|
|
18
|
-
"@zhin.js/types": "1.0.
|
|
18
|
+
"@zhin.js/types": "1.0.2"
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=18.0.0"
|