@zhin.js/scaffold-wizard 1.1.1 → 1.1.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/README.md +5 -0
- package/lib/apply.d.ts +1 -1
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +7 -0
- package/lib/apply.js.map +1 -1
- package/lib/database-definitions.d.ts +28 -0
- package/lib/database-definitions.d.ts.map +1 -0
- package/lib/database-definitions.js +290 -0
- package/lib/database-definitions.js.map +1 -0
- package/lib/database.d.ts.map +1 -1
- package/lib/database.js +69 -51
- package/lib/database.js.map +1 -1
- package/lib/env.d.ts +6 -0
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +51 -0
- package/lib/env.js.map +1 -1
- package/lib/index.d.ts +5 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- package/lib/types.d.ts +3 -2
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +6 -8
- package/lib/types.js.map +1 -1
- package/lib/zhin-stack-deps.d.ts +7 -6
- package/lib/zhin-stack-deps.d.ts.map +1 -1
- package/lib/zhin-stack-deps.js +14 -9
- package/lib/zhin-stack-deps.js.map +1 -1
- package/package.json +2 -2
- package/src/apply.ts +8 -1
- package/src/database-definitions.ts +336 -0
- package/src/database.ts +77 -52
- package/src/env.ts +52 -0
- package/src/index.ts +16 -3
- package/src/types.ts +12 -9
- package/src/zhin-stack-deps.ts +14 -9
package/src/database.ts
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
2
|
import { DatabaseConfig } from './types.js';
|
|
3
|
+
import {
|
|
4
|
+
DATABASE_DIALECT_DEFINITIONS,
|
|
5
|
+
databaseChoiceLabel,
|
|
6
|
+
getDatabaseDialectDefinition,
|
|
7
|
+
validateDatabaseConfig,
|
|
8
|
+
type DatabaseDialect,
|
|
9
|
+
} from './database-definitions.js';
|
|
10
|
+
|
|
11
|
+
function schemaDefault(dialect: DatabaseDialect, ...path: string[]): unknown {
|
|
12
|
+
let schema = getDatabaseDialectDefinition(dialect)?.schema as Record<string, unknown> | undefined;
|
|
13
|
+
for (const segment of path) {
|
|
14
|
+
const properties = schema?.properties as Record<string, Record<string, unknown>> | undefined;
|
|
15
|
+
schema = properties?.[segment];
|
|
16
|
+
}
|
|
17
|
+
return schema?.default;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function parseIntegerInput(input: unknown, minimum: number, maximum = Number.MAX_SAFE_INTEGER): number | string {
|
|
21
|
+
const raw = String(input).trim();
|
|
22
|
+
if (!/^\d+$/u.test(raw)) return `请输入有效的整数 (${minimum}-${maximum})`;
|
|
23
|
+
const value = Number(raw);
|
|
24
|
+
if (!Number.isSafeInteger(value) || value < minimum || value > maximum) {
|
|
25
|
+
return `请输入有效的整数 (${minimum}-${maximum})`;
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
3
29
|
|
|
4
30
|
// 配置数据库选项
|
|
5
31
|
export async function configureDatabaseOptions(): Promise<DatabaseConfig> {
|
|
@@ -8,31 +34,42 @@ export async function configureDatabaseOptions(): Promise<DatabaseConfig> {
|
|
|
8
34
|
type: 'select',
|
|
9
35
|
name: 'dialect',
|
|
10
36
|
message: '选择数据库类型:',
|
|
11
|
-
choices:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{ name: 'MongoDB', value: 'mongodb' },
|
|
16
|
-
{ name: 'Redis', value: 'redis' }
|
|
17
|
-
],
|
|
37
|
+
choices: DATABASE_DIALECT_DEFINITIONS.map((definition) => ({
|
|
38
|
+
name: databaseChoiceLabel(definition),
|
|
39
|
+
value: definition.dialect,
|
|
40
|
+
})),
|
|
18
41
|
default: 'sqlite'
|
|
19
42
|
}
|
|
20
43
|
]);
|
|
21
44
|
|
|
45
|
+
let config: DatabaseConfig;
|
|
22
46
|
switch (dialect) {
|
|
23
47
|
case 'sqlite':
|
|
24
|
-
|
|
48
|
+
config = await configureSQLite();
|
|
49
|
+
break;
|
|
25
50
|
case 'mysql':
|
|
26
|
-
|
|
51
|
+
config = await configureMySQL();
|
|
52
|
+
break;
|
|
27
53
|
case 'pg':
|
|
28
|
-
|
|
54
|
+
config = await configurePostgreSQL();
|
|
55
|
+
break;
|
|
29
56
|
case 'mongodb':
|
|
30
|
-
|
|
57
|
+
config = await configureMongoDB();
|
|
58
|
+
break;
|
|
31
59
|
case 'redis':
|
|
32
|
-
|
|
60
|
+
config = await configureRedis();
|
|
61
|
+
break;
|
|
62
|
+
case 'memory':
|
|
63
|
+
config = { dialect: 'memory' };
|
|
64
|
+
break;
|
|
33
65
|
default:
|
|
34
66
|
throw new Error(`未支持的数据库类型: ${dialect}`);
|
|
35
67
|
}
|
|
68
|
+
const issues = validateDatabaseConfig(config);
|
|
69
|
+
if (issues.length > 0) {
|
|
70
|
+
throw new TypeError(`数据库配置不符合 Schema:${issues.map((issue) => issue.message).join(';')}`);
|
|
71
|
+
}
|
|
72
|
+
return config;
|
|
36
73
|
}
|
|
37
74
|
|
|
38
75
|
// SQLite 配置
|
|
@@ -42,7 +79,7 @@ async function configureSQLite(): Promise<DatabaseConfig> {
|
|
|
42
79
|
type: 'input',
|
|
43
80
|
name: 'filename',
|
|
44
81
|
message: 'SQLite 数据库文件路径:',
|
|
45
|
-
default: '
|
|
82
|
+
default: schemaDefault('sqlite', 'filename'),
|
|
46
83
|
validate: (input: string) => {
|
|
47
84
|
if (!input.trim()) return '文件路径不能为空';
|
|
48
85
|
return true;
|
|
@@ -57,7 +94,7 @@ async function configureSQLite(): Promise<DatabaseConfig> {
|
|
|
57
94
|
{ name: 'DELETE (默认)', value: 'delete' },
|
|
58
95
|
{ name: 'MEMORY (内存数据库)', value: 'memory' }
|
|
59
96
|
],
|
|
60
|
-
default: '
|
|
97
|
+
default: schemaDefault('sqlite', 'mode')
|
|
61
98
|
}
|
|
62
99
|
]);
|
|
63
100
|
|
|
@@ -75,26 +112,23 @@ async function configureMySQL(): Promise<DatabaseConfig> {
|
|
|
75
112
|
type: 'input',
|
|
76
113
|
name: 'host',
|
|
77
114
|
message: 'MySQL 主机地址:',
|
|
78
|
-
default: '
|
|
115
|
+
default: schemaDefault('mysql', 'host')
|
|
79
116
|
},
|
|
80
117
|
{
|
|
81
118
|
type: 'input',
|
|
82
119
|
name: 'port',
|
|
83
120
|
message: 'MySQL 端口:',
|
|
84
|
-
default: '
|
|
121
|
+
default: String(schemaDefault('mysql', 'port')),
|
|
85
122
|
validate: (input: string) => {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
return '请输入有效的端口号 (1-65535)';
|
|
89
|
-
}
|
|
90
|
-
return true;
|
|
123
|
+
const value = parseIntegerInput(input, 1, 65535);
|
|
124
|
+
return typeof value === 'number' ? true : value;
|
|
91
125
|
}
|
|
92
126
|
},
|
|
93
127
|
{
|
|
94
128
|
type: 'input',
|
|
95
129
|
name: 'user',
|
|
96
130
|
message: 'MySQL 用户名:',
|
|
97
|
-
default: '
|
|
131
|
+
default: schemaDefault('mysql', 'user')
|
|
98
132
|
},
|
|
99
133
|
{
|
|
100
134
|
type: 'password',
|
|
@@ -105,7 +139,7 @@ async function configureMySQL(): Promise<DatabaseConfig> {
|
|
|
105
139
|
type: 'input',
|
|
106
140
|
name: 'database',
|
|
107
141
|
message: 'MySQL 数据库名:',
|
|
108
|
-
default: '
|
|
142
|
+
default: schemaDefault('mysql', 'database'),
|
|
109
143
|
validate: (input: string) => {
|
|
110
144
|
if (!input.trim()) return '数据库名不能为空';
|
|
111
145
|
return true;
|
|
@@ -116,7 +150,7 @@ async function configureMySQL(): Promise<DatabaseConfig> {
|
|
|
116
150
|
return {
|
|
117
151
|
dialect: 'mysql',
|
|
118
152
|
host: config.host,
|
|
119
|
-
port:
|
|
153
|
+
port: Number(config.port),
|
|
120
154
|
user: config.user,
|
|
121
155
|
password: config.password,
|
|
122
156
|
database: config.database
|
|
@@ -130,26 +164,23 @@ async function configurePostgreSQL(): Promise<DatabaseConfig> {
|
|
|
130
164
|
type: 'input',
|
|
131
165
|
name: 'host',
|
|
132
166
|
message: 'PostgreSQL 主机地址:',
|
|
133
|
-
default: '
|
|
167
|
+
default: schemaDefault('pg', 'host')
|
|
134
168
|
},
|
|
135
169
|
{
|
|
136
170
|
type: 'input',
|
|
137
171
|
name: 'port',
|
|
138
172
|
message: 'PostgreSQL 端口:',
|
|
139
|
-
default: '
|
|
173
|
+
default: String(schemaDefault('pg', 'port')),
|
|
140
174
|
validate: (input: string) => {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
return '请输入有效的端口号 (1-65535)';
|
|
144
|
-
}
|
|
145
|
-
return true;
|
|
175
|
+
const value = parseIntegerInput(input, 1, 65535);
|
|
176
|
+
return typeof value === 'number' ? true : value;
|
|
146
177
|
}
|
|
147
178
|
},
|
|
148
179
|
{
|
|
149
180
|
type: 'input',
|
|
150
181
|
name: 'user',
|
|
151
182
|
message: 'PostgreSQL 用户名:',
|
|
152
|
-
default: '
|
|
183
|
+
default: schemaDefault('pg', 'user')
|
|
153
184
|
},
|
|
154
185
|
{
|
|
155
186
|
type: 'password',
|
|
@@ -160,7 +191,7 @@ async function configurePostgreSQL(): Promise<DatabaseConfig> {
|
|
|
160
191
|
type: 'input',
|
|
161
192
|
name: 'database',
|
|
162
193
|
message: 'PostgreSQL 数据库名:',
|
|
163
|
-
default: '
|
|
194
|
+
default: schemaDefault('pg', 'database'),
|
|
164
195
|
validate: (input: string) => {
|
|
165
196
|
if (!input.trim()) return '数据库名不能为空';
|
|
166
197
|
return true;
|
|
@@ -171,7 +202,7 @@ async function configurePostgreSQL(): Promise<DatabaseConfig> {
|
|
|
171
202
|
return {
|
|
172
203
|
dialect: 'pg',
|
|
173
204
|
host: config.host,
|
|
174
|
-
port:
|
|
205
|
+
port: Number(config.port),
|
|
175
206
|
user: config.user,
|
|
176
207
|
password: config.password,
|
|
177
208
|
database: config.database
|
|
@@ -185,7 +216,7 @@ async function configureMongoDB(): Promise<DatabaseConfig> {
|
|
|
185
216
|
type: 'input',
|
|
186
217
|
name: 'url',
|
|
187
218
|
message: 'MongoDB 连接字符串:',
|
|
188
|
-
default: 'mongodb
|
|
219
|
+
default: schemaDefault('mongodb', 'url'),
|
|
189
220
|
validate: (input: string) => {
|
|
190
221
|
if (!input.trim()) return '连接字符串不能为空';
|
|
191
222
|
if (!input.startsWith('mongodb://') && !input.startsWith('mongodb+srv://')) {
|
|
@@ -198,7 +229,7 @@ async function configureMongoDB(): Promise<DatabaseConfig> {
|
|
|
198
229
|
type: 'input',
|
|
199
230
|
name: 'dbName',
|
|
200
231
|
message: 'MongoDB 数据库名:',
|
|
201
|
-
default: '
|
|
232
|
+
default: schemaDefault('mongodb', 'dbName'),
|
|
202
233
|
validate: (input: string) => {
|
|
203
234
|
if (!input.trim()) return '数据库名不能为空';
|
|
204
235
|
return true;
|
|
@@ -220,19 +251,16 @@ async function configureRedis(): Promise<DatabaseConfig> {
|
|
|
220
251
|
type: 'input',
|
|
221
252
|
name: 'host',
|
|
222
253
|
message: 'Redis 主机地址:',
|
|
223
|
-
default: '
|
|
254
|
+
default: schemaDefault('redis', 'socket', 'host')
|
|
224
255
|
},
|
|
225
256
|
{
|
|
226
257
|
type: 'input',
|
|
227
258
|
name: 'port',
|
|
228
259
|
message: 'Redis 端口:',
|
|
229
|
-
default: '
|
|
260
|
+
default: String(schemaDefault('redis', 'socket', 'port')),
|
|
230
261
|
validate: (input: string) => {
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
return '请输入有效的端口号 (1-65535)';
|
|
234
|
-
}
|
|
235
|
-
return true;
|
|
262
|
+
const value = parseIntegerInput(input, 1, 65535);
|
|
263
|
+
return typeof value === 'number' ? true : value;
|
|
236
264
|
}
|
|
237
265
|
},
|
|
238
266
|
{
|
|
@@ -244,13 +272,10 @@ async function configureRedis(): Promise<DatabaseConfig> {
|
|
|
244
272
|
type: 'input',
|
|
245
273
|
name: 'db',
|
|
246
274
|
message: 'Redis 数据库索引:',
|
|
247
|
-
default: '
|
|
275
|
+
default: String(schemaDefault('redis', 'database')),
|
|
248
276
|
validate: (input: string) => {
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
return '请输入有效的数据库索引 (>= 0)';
|
|
252
|
-
}
|
|
253
|
-
return true;
|
|
277
|
+
const value = parseIntegerInput(input, 0);
|
|
278
|
+
return typeof value === 'number' ? true : '请输入有效的数据库索引 (>= 0)';
|
|
254
279
|
}
|
|
255
280
|
}
|
|
256
281
|
]);
|
|
@@ -259,9 +284,9 @@ async function configureRedis(): Promise<DatabaseConfig> {
|
|
|
259
284
|
dialect: 'redis',
|
|
260
285
|
socket: {
|
|
261
286
|
host: config.host,
|
|
262
|
-
port:
|
|
287
|
+
port: Number(config.port)
|
|
263
288
|
},
|
|
264
289
|
password: config.password || undefined,
|
|
265
|
-
database:
|
|
290
|
+
database: Number(config.db)
|
|
266
291
|
};
|
|
267
|
-
}
|
|
292
|
+
}
|
package/src/env.ts
CHANGED
|
@@ -104,6 +104,7 @@ export function generateDatabaseEnvVars(config: DatabaseConfig): string {
|
|
|
104
104
|
);
|
|
105
105
|
break;
|
|
106
106
|
case 'sqlite':
|
|
107
|
+
case 'memory':
|
|
107
108
|
default:
|
|
108
109
|
// SQLite 不需要额外的环境变量
|
|
109
110
|
break;
|
|
@@ -111,3 +112,54 @@ export function generateDatabaseEnvVars(config: DatabaseConfig): string {
|
|
|
111
112
|
|
|
112
113
|
return envVars.length > 0 ? `\n\n${envVars.join('\n')}` : '';
|
|
113
114
|
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Generate a version-control-safe database section for `.env.example`.
|
|
118
|
+
* User-entered passwords and credential-bearing connection URLs are never
|
|
119
|
+
* copied from the interactive wizard.
|
|
120
|
+
*/
|
|
121
|
+
export function generateDatabaseEnvExample(config: DatabaseConfig): string {
|
|
122
|
+
let lines: string[] = [];
|
|
123
|
+
switch (config.dialect) {
|
|
124
|
+
case 'mysql':
|
|
125
|
+
lines = [
|
|
126
|
+
'# MySQL 数据库配置',
|
|
127
|
+
'DB_HOST=127.0.0.1',
|
|
128
|
+
'DB_PORT=3306',
|
|
129
|
+
'DB_USER=root',
|
|
130
|
+
'DB_PASSWORD=change-me',
|
|
131
|
+
'DB_DATABASE=zhin_bot',
|
|
132
|
+
];
|
|
133
|
+
break;
|
|
134
|
+
case 'pg':
|
|
135
|
+
lines = [
|
|
136
|
+
'# PostgreSQL 数据库配置',
|
|
137
|
+
'DB_HOST=127.0.0.1',
|
|
138
|
+
'DB_PORT=5432',
|
|
139
|
+
'DB_USER=postgres',
|
|
140
|
+
'DB_PASSWORD=change-me',
|
|
141
|
+
'DB_DATABASE=zhin_bot',
|
|
142
|
+
];
|
|
143
|
+
break;
|
|
144
|
+
case 'mongodb':
|
|
145
|
+
lines = [
|
|
146
|
+
'# MongoDB 数据库配置',
|
|
147
|
+
'DB_URL=mongodb://127.0.0.1:27017',
|
|
148
|
+
'DB_NAME=zhin_bot',
|
|
149
|
+
];
|
|
150
|
+
break;
|
|
151
|
+
case 'redis':
|
|
152
|
+
lines = [
|
|
153
|
+
'# Redis 数据库配置',
|
|
154
|
+
'REDIS_HOST=127.0.0.1',
|
|
155
|
+
'REDIS_PORT=6379',
|
|
156
|
+
'REDIS_PASSWORD=',
|
|
157
|
+
'REDIS_DB=0',
|
|
158
|
+
];
|
|
159
|
+
break;
|
|
160
|
+
case 'sqlite':
|
|
161
|
+
case 'memory':
|
|
162
|
+
return '';
|
|
163
|
+
}
|
|
164
|
+
return `\n\n${lines.join('\n')}`;
|
|
165
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
export type { InitOptions, DatabaseConfig } from './types.js';
|
|
2
|
-
export { DATABASE_PACKAGES } from './types.js';
|
|
2
|
+
export { DATABASE_DRIVER_VERSIONS, DATABASE_PACKAGES } from './types.js';
|
|
3
|
+
export {
|
|
4
|
+
DATABASE_DIALECT_DEFINITIONS,
|
|
5
|
+
databaseChoiceLabel,
|
|
6
|
+
getDatabaseDialectDefinition,
|
|
7
|
+
validateDatabaseConfig,
|
|
8
|
+
} from './database-definitions.js';
|
|
9
|
+
export type {
|
|
10
|
+
DatabaseDialect,
|
|
11
|
+
DatabaseDialectDefinition,
|
|
12
|
+
DatabaseDriverDefinition,
|
|
13
|
+
DatabaseSchemaIssue,
|
|
14
|
+
} from './database-definitions.js';
|
|
3
15
|
|
|
4
16
|
export type { AdapterSetupResult, AdapterPluginInstance, AdapterDefinition } from './adapter.js';
|
|
5
17
|
export {
|
|
@@ -35,6 +47,7 @@ export { configureDatabaseOptions } from './database.js';
|
|
|
35
47
|
export {
|
|
36
48
|
formatEnvValue,
|
|
37
49
|
mergeEnvText,
|
|
50
|
+
generateDatabaseEnvExample,
|
|
38
51
|
generateDatabaseEnvVars,
|
|
39
52
|
} from './env.js';
|
|
40
53
|
|
|
@@ -60,9 +73,9 @@ export type { AiStackIncompatibility } from './project-deps.js';
|
|
|
60
73
|
export {
|
|
61
74
|
ZHIN_STACK_VERSIONS,
|
|
62
75
|
DEFAULT_CREATE_BOT_HTTP_PORT,
|
|
63
|
-
|
|
76
|
+
CREATE_BOT_PACKAGE_MANAGER,
|
|
64
77
|
getCreateBotBaseDependencies,
|
|
65
|
-
|
|
78
|
+
getCreateBotPnpmWorkspaceConfig,
|
|
66
79
|
getRequiredZhinDependenciesForConfig,
|
|
67
80
|
diagnoseZhinStackDependencies,
|
|
68
81
|
formatZhinStackFixCommand,
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AISetupConfig } from './ai.js';
|
|
2
2
|
import type { AdapterSetupResult } from './adapter.js';
|
|
3
|
+
import { DATABASE_DIALECT_DEFINITIONS } from './database-definitions.js';
|
|
3
4
|
|
|
4
5
|
export type { AISetupConfig } from './ai.js';
|
|
5
6
|
export type { AdapterSetupResult } from './adapter.js';
|
|
@@ -19,15 +20,17 @@ export interface InitOptions {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export interface DatabaseConfig {
|
|
22
|
-
dialect: 'sqlite' | 'mysql' | 'pg' | 'mongodb' | 'redis';
|
|
23
|
+
dialect: 'sqlite' | 'mysql' | 'pg' | 'mongodb' | 'redis' | 'memory';
|
|
23
24
|
[key: string]: any;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
//
|
|
27
|
-
export const DATABASE_PACKAGES
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
// 数据库驱动映射(SQLite / Memory 使用内置实现,无需额外安装)
|
|
28
|
+
export const DATABASE_PACKAGES = Object.freeze(Object.fromEntries(
|
|
29
|
+
DATABASE_DIALECT_DEFINITIONS.map((definition) => [definition.dialect, definition.driver?.package]),
|
|
30
|
+
)) as Readonly<Record<DatabaseConfig['dialect'], string | undefined>>;
|
|
31
|
+
|
|
32
|
+
export const DATABASE_DRIVER_VERSIONS = Object.freeze(Object.fromEntries(
|
|
33
|
+
DATABASE_DIALECT_DEFINITIONS.flatMap((definition) => definition.driver
|
|
34
|
+
? [[definition.driver.package, definition.driver.version] as const]
|
|
35
|
+
: []),
|
|
36
|
+
)) as Readonly<Record<string, string>>;
|
package/src/zhin-stack-deps.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { DATABASE_PACKAGES } from './types.js';
|
|
4
|
+
import { DATABASE_DRIVER_VERSIONS, DATABASE_PACKAGES } from './types.js';
|
|
5
5
|
import { findMissingPackageDependencies, findUnresolvedPackageInstalls, isAiEnabledInConfig, type PackageJsonLike } from './project-deps.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* User project dependency policy: scaffolded
|
|
9
|
-
*
|
|
8
|
+
* User project dependency policy: scaffolded Zhin packages intentionally float to latest.
|
|
9
|
+
* Database drivers use the live-tested ranges declared by the database definitions.
|
|
10
|
+
* WARNING: `latest` is not reproducible; pin Zhin package versions for production.
|
|
10
11
|
*/
|
|
11
12
|
export const ZHIN_STACK_VERSIONS = {
|
|
12
13
|
'zhin.js': 'latest',
|
|
@@ -114,13 +115,17 @@ function resolveStackVersion(packageName: string): string {
|
|
|
114
115
|
/** create-zhin / minimal-bot 默认 Host 端口(避免与常见 8086 占用冲突) */
|
|
115
116
|
export const DEFAULT_CREATE_BOT_HTTP_PORT = 8068;
|
|
116
117
|
|
|
117
|
-
/** create-zhin
|
|
118
|
-
export const
|
|
118
|
+
/** create-zhin 生成项目固定使用的 pnpm 版本。 */
|
|
119
|
+
export const CREATE_BOT_PACKAGE_MANAGER = 'pnpm@11.27.1';
|
|
119
120
|
|
|
120
|
-
/** create-zhin 生成项目的 pnpm
|
|
121
|
-
export function
|
|
121
|
+
/** create-zhin 生成项目的 pnpm-workspace.yaml 配置。 */
|
|
122
|
+
export function getCreateBotPnpmWorkspaceConfig(): Record<string, unknown> {
|
|
122
123
|
return {
|
|
123
|
-
|
|
124
|
+
packages: ['.', 'plugins/*', 'packages/*'],
|
|
125
|
+
strictPeerDependencies: false,
|
|
126
|
+
allowBuilds: {
|
|
127
|
+
esbuild: true,
|
|
128
|
+
},
|
|
124
129
|
};
|
|
125
130
|
}
|
|
126
131
|
|
|
@@ -147,7 +152,7 @@ export function getRequiredZhinDependenciesForConfig(config: Record<string, unkn
|
|
|
147
152
|
const dialect = String((database as Record<string, unknown>).dialect ?? '');
|
|
148
153
|
const driver = DATABASE_PACKAGES[dialect as keyof typeof DATABASE_PACKAGES];
|
|
149
154
|
if (driver) {
|
|
150
|
-
deps[driver] =
|
|
155
|
+
deps[driver] = DATABASE_DRIVER_VERSIONS[driver];
|
|
151
156
|
}
|
|
152
157
|
}
|
|
153
158
|
|