@optima-chat/dev-skills 0.7.12 → 0.7.14
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
执行 SQL 查询,支持 CI/Stage/Prod 三个环境。
|
|
4
4
|
|
|
5
|
-
**版本**: v0.
|
|
5
|
+
**版本**: v0.7.0
|
|
6
6
|
|
|
7
7
|
## 使用场景
|
|
8
8
|
|
|
@@ -182,11 +182,11 @@ INFISICAL_TOKEN=$(curl -s -X POST "${INFISICAL_URL}/api/v1/auth/universal-auth/l
|
|
|
182
182
|
| python3 -c "import sys, json; print(json.load(sys.stdin)['accessToken'])")
|
|
183
183
|
|
|
184
184
|
# 3. 从 Infisical 获取数据库配置(以 commerce-backend 为例)
|
|
185
|
-
|
|
185
|
+
# 项目: optima-secrets-v2, 路径: /shared-secrets/database-users
|
|
186
|
+
curl -s "${INFISICAL_URL}/api/v3/secrets/raw?workspaceId=${INFISICAL_PROJECT_ID}&environment=staging&secretPath=/shared-secrets/database-users" \
|
|
186
187
|
-H "Authorization: Bearer ${INFISICAL_TOKEN}" | python3 -c "
|
|
187
188
|
import sys, json
|
|
188
189
|
secrets = {s['secretKey']: s['secretValue'] for s in json.load(sys.stdin)['secrets']}
|
|
189
|
-
print(f\"DATABASE_HOST={secrets['DATABASE_HOST']}\")
|
|
190
190
|
print(f\"COMMERCE_DB_USER={secrets['COMMERCE_DB_USER']}\")
|
|
191
191
|
print(f\"COMMERCE_DB_PASSWORD={secrets['COMMERCE_DB_PASSWORD']}\")
|
|
192
192
|
" > /tmp/stage_db_config.sh && source /tmp/stage_db_config.sh
|
|
@@ -216,7 +216,7 @@ pkill -f "ssh.*15432:${DATABASE_HOST}:5432"
|
|
|
216
216
|
# 使用 BI_DB_USER, BI_DB_PASSWORD, 数据库: optima_bi
|
|
217
217
|
|
|
218
218
|
# session-gateway (注意: Stage 数据库名是 optima_shell)
|
|
219
|
-
# 使用
|
|
219
|
+
# 使用 AI_SHELL_DB_USER, AI_SHELL_DB_PASSWORD, 数据库: optima_shell
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
**数据库配置映射**:
|
|
@@ -242,12 +242,12 @@ pkill -f "ssh.*15432:${DATABASE_HOST}:5432"
|
|
|
242
242
|
|
|
243
243
|
- `session-gateway`:
|
|
244
244
|
- 数据库: `optima_shell` ⚠️ (Stage 与 Prod 不同)
|
|
245
|
-
- 用户: Infisical `
|
|
246
|
-
- 密码: Infisical `
|
|
245
|
+
- 用户: Infisical `AI_SHELL_DB_USER`
|
|
246
|
+
- 密码: Infisical `AI_SHELL_DB_PASSWORD`
|
|
247
247
|
|
|
248
248
|
**说明**:
|
|
249
249
|
- Infisical 配置从 GitHub Variables 获取
|
|
250
|
-
- 数据库密钥从 Infisical 动态获取(项目: optima-secrets, 环境: staging, 路径: /
|
|
250
|
+
- 数据库密钥从 Infisical 动态获取(项目: optima-secrets-v2, 环境: staging, 路径: /shared-secrets/database-users)
|
|
251
251
|
- Stage RDS: `optima-stage-postgres.ctg866o0ehac.ap-southeast-1.rds.amazonaws.com`
|
|
252
252
|
- Shared EC2 IP: `13.251.46.219`
|
|
253
253
|
- SSH 隧道: 本地端口 `15432` → Shared EC2 → Stage RDS `5432`
|
|
@@ -280,11 +280,11 @@ INFISICAL_TOKEN=$(curl -s -X POST "${INFISICAL_URL}/api/v1/auth/universal-auth/l
|
|
|
280
280
|
| python3 -c "import sys, json; print(json.load(sys.stdin)['accessToken'])")
|
|
281
281
|
|
|
282
282
|
# 3. 从 Infisical 获取数据库配置(以 commerce-backend 为例)
|
|
283
|
-
|
|
283
|
+
# 项目: optima-secrets-v2, 路径: /shared-secrets/database-users
|
|
284
|
+
curl -s "${INFISICAL_URL}/api/v3/secrets/raw?workspaceId=${INFISICAL_PROJECT_ID}&environment=prod&secretPath=/shared-secrets/database-users" \
|
|
284
285
|
-H "Authorization: Bearer ${INFISICAL_TOKEN}" | python3 -c "
|
|
285
286
|
import sys, json
|
|
286
287
|
secrets = {s['secretKey']: s['secretValue'] for s in json.load(sys.stdin)['secrets']}
|
|
287
|
-
print(f\"DATABASE_HOST={secrets['DATABASE_HOST']}\")
|
|
288
288
|
print(f\"COMMERCE_DB_USER={secrets['COMMERCE_DB_USER']}\")
|
|
289
289
|
print(f\"COMMERCE_DB_PASSWORD={secrets['COMMERCE_DB_PASSWORD']}\")
|
|
290
290
|
" > /tmp/prod_db_config.sh && source /tmp/prod_db_config.sh
|
|
@@ -345,7 +345,7 @@ pkill -f "ssh.*15433:${DATABASE_HOST}:5432"
|
|
|
345
345
|
|
|
346
346
|
**说明**:
|
|
347
347
|
- Infisical 配置从 GitHub Variables 获取
|
|
348
|
-
- 数据库密钥从 Infisical 动态获取(项目: optima-secrets, 环境: prod, 路径: /
|
|
348
|
+
- 数据库密钥从 Infisical 动态获取(项目: optima-secrets-v2, 环境: prod, 路径: /shared-secrets/database-users)
|
|
349
349
|
- Prod RDS: `optima-prod-postgres.ctg866o0ehac.ap-southeast-1.rds.amazonaws.com`
|
|
350
350
|
- Shared EC2 IP: `13.251.46.219`
|
|
351
351
|
- SSH 隧道: 本地端口 `15433` → Shared EC2 → Prod RDS `5432`
|
|
@@ -36,23 +36,34 @@ optima-generate-test-token [options]
|
|
|
36
36
|
### 基本使用
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
#
|
|
39
|
+
# CI 环境(默认)
|
|
40
40
|
optima-generate-test-token
|
|
41
41
|
|
|
42
|
-
#
|
|
43
|
-
optima-generate-test-token --env
|
|
42
|
+
# Stage 环境
|
|
43
|
+
optima-generate-test-token --env stage
|
|
44
|
+
|
|
45
|
+
# Prod 环境
|
|
46
|
+
optima-generate-test-token --env prod
|
|
44
47
|
|
|
45
48
|
# 自定义商户名称
|
|
46
|
-
optima-generate-test-token --business-name "我的测试店铺" --env
|
|
49
|
+
optima-generate-test-token --business-name "我的测试店铺" --env stage
|
|
47
50
|
|
|
48
51
|
# 完全自定义
|
|
49
52
|
optima-generate-test-token \
|
|
50
53
|
--email "test@example.com" \
|
|
51
54
|
--password "MyPassword123" \
|
|
52
55
|
--business-name "测试商店" \
|
|
53
|
-
--env
|
|
56
|
+
--env prod
|
|
54
57
|
```
|
|
55
58
|
|
|
59
|
+
### 环境说明
|
|
60
|
+
|
|
61
|
+
| 环境 | Auth URL | API URL |
|
|
62
|
+
|------|----------|---------|
|
|
63
|
+
| ci | `auth.optima.chat` | `api.optima.chat` |
|
|
64
|
+
| stage | `auth.stage.optima.onl` | `api.stage.optima.onl` |
|
|
65
|
+
| prod | `auth.optima.onl` | `api.optima.onl` |
|
|
66
|
+
|
|
56
67
|
### 使用生成的 Token
|
|
57
68
|
|
|
58
69
|
工具执行后会输出 token 文件路径,例如:`/tmp/optima-test-token-1763997011780.txt`
|
|
@@ -62,12 +73,12 @@ optima-generate-test-token \
|
|
|
62
73
|
```bash
|
|
63
74
|
# 查询商品列表
|
|
64
75
|
OPTIMA_TOKEN=$(cat /tmp/optima-test-token-xxx.txt) \
|
|
65
|
-
OPTIMA_ENV=
|
|
76
|
+
OPTIMA_ENV=ci \
|
|
66
77
|
commerce product list
|
|
67
78
|
|
|
68
79
|
# 创建商品
|
|
69
80
|
OPTIMA_TOKEN=$(cat /tmp/optima-test-token-xxx.txt) \
|
|
70
|
-
OPTIMA_ENV=
|
|
81
|
+
OPTIMA_ENV=ci \
|
|
71
82
|
commerce product create \
|
|
72
83
|
--title "测试商品" \
|
|
73
84
|
--description "这是一个测试商品" \
|
|
@@ -101,7 +112,7 @@ curl -H "Authorization: Bearer $(cat /tmp/optima-test-token-xxx.txt)" \
|
|
|
101
112
|
3. 使用 token 创建商品:
|
|
102
113
|
```bash
|
|
103
114
|
OPTIMA_TOKEN=$(cat /tmp/optima-test-token-xxx.txt) \
|
|
104
|
-
OPTIMA_ENV=
|
|
115
|
+
OPTIMA_ENV=ci \
|
|
105
116
|
commerce product create --title "测试商品" --price 99.99 --stock 100
|
|
106
117
|
```
|
|
107
118
|
|
|
@@ -115,7 +126,7 @@ curl -H "Authorization: Bearer $(cat /tmp/optima-test-token-xxx.txt)" \
|
|
|
115
126
|
3. 使用 token 查询订单:
|
|
116
127
|
```bash
|
|
117
128
|
OPTIMA_TOKEN=$(cat /tmp/optima-test-token-xxx.txt) \
|
|
118
|
-
OPTIMA_ENV=
|
|
129
|
+
OPTIMA_ENV=ci \
|
|
119
130
|
commerce order list
|
|
120
131
|
```
|
|
121
132
|
|
|
@@ -130,10 +141,10 @@ curl -H "Authorization: Bearer $(cat /tmp/optima-test-token-xxx.txt)" \
|
|
|
130
141
|
TOKEN_FILE=/tmp/optima-test-token-xxx.txt
|
|
131
142
|
|
|
132
143
|
# 创建多个商品
|
|
133
|
-
OPTIMA_TOKEN=$(cat $TOKEN_FILE) OPTIMA_ENV=
|
|
144
|
+
OPTIMA_TOKEN=$(cat $TOKEN_FILE) OPTIMA_ENV=ci \
|
|
134
145
|
commerce product create --title "商品A" --price 49.99 --stock 50
|
|
135
146
|
|
|
136
|
-
OPTIMA_TOKEN=$(cat $TOKEN_FILE) OPTIMA_ENV=
|
|
147
|
+
OPTIMA_TOKEN=$(cat $TOKEN_FILE) OPTIMA_ENV=ci \
|
|
137
148
|
commerce product create --title "商品B" --price 89.99 --stock 30
|
|
138
149
|
```
|
|
139
150
|
|
|
@@ -150,7 +161,7 @@ curl -H "Authorization: Bearer $(cat /tmp/optima-test-token-xxx.txt)" \
|
|
|
150
161
|
|
|
151
162
|
# 在环境变量中设置
|
|
152
163
|
export OPTIMA_TOKEN=$(cat $TOKEN_FILE)
|
|
153
|
-
export OPTIMA_ENV=
|
|
164
|
+
export OPTIMA_ENV=ci
|
|
154
165
|
|
|
155
166
|
# 运行测试
|
|
156
167
|
npm run test:api
|
|
@@ -179,7 +190,7 @@ curl -H "Authorization: Bearer $(cat /tmp/optima-test-token-xxx.txt)" \
|
|
|
179
190
|
TOKEN=$(cat /tmp/optima-test-token-1763997011780.txt)
|
|
180
191
|
|
|
181
192
|
# Use with commerce CLI:
|
|
182
|
-
OPTIMA_TOKEN=$(cat /tmp/optima-test-token-1763997011780.txt) OPTIMA_ENV=
|
|
193
|
+
OPTIMA_TOKEN=$(cat /tmp/optima-test-token-1763997011780.txt) OPTIMA_ENV=ci commerce product list
|
|
183
194
|
|
|
184
195
|
# Use in curl:
|
|
185
196
|
curl -H "Authorization: Bearer $(cat /tmp/optima-test-token-1763997011780.txt)" https://api.optima.chat/api/products
|
|
@@ -196,7 +207,7 @@ curl -H "Authorization: Bearer $(cat /tmp/optima-test-token-xxx.txt)" \
|
|
|
196
207
|
|
|
197
208
|
使用 commerce CLI 时**必须**设置环境变量:
|
|
198
209
|
```bash
|
|
199
|
-
OPTIMA_ENV=
|
|
210
|
+
OPTIMA_ENV=ci # 必需,指定环境 (ci/stage/prod)
|
|
200
211
|
OPTIMA_TOKEN=$(cat /tmp/optima-test-token-xxx.txt) # 必需,读取 token
|
|
201
212
|
```
|
|
202
213
|
|
|
@@ -212,13 +223,17 @@ OPTIMA_TOKEN=$(cat /tmp/optima-test-token-xxx.txt) # 必需,读取 token
|
|
|
212
223
|
- 系统重启后可能被清理
|
|
213
224
|
- 建议在使用完成后手动删除敏感文件
|
|
214
225
|
|
|
215
|
-
###
|
|
226
|
+
### 支持的环境
|
|
227
|
+
|
|
228
|
+
工具支持三个环境,使用 `--env` 参数指定:
|
|
229
|
+
|
|
230
|
+
| 环境 | Auth API | Commerce API |
|
|
231
|
+
|------|----------|--------------|
|
|
232
|
+
| ci (默认) | `https://auth.optima.chat` | `https://api.optima.chat` |
|
|
233
|
+
| stage | `https://auth.stage.optima.onl` | `https://api.stage.optima.onl` |
|
|
234
|
+
| prod | `https://auth.optima.onl` | `https://api.optima.onl` |
|
|
216
235
|
|
|
217
|
-
|
|
218
|
-
- API 地址:
|
|
219
|
-
- Auth: `https://auth.optima.chat`
|
|
220
|
-
- Commerce: `https://api.optima.chat`
|
|
221
|
-
- **不能用于** production 或 stage 环境
|
|
236
|
+
⚠️ **注意**:Prod 环境创建的账户会出现在生产系统中,请谨慎使用。
|
|
222
237
|
|
|
223
238
|
## 💡 最佳实践
|
|
224
239
|
|
|
@@ -241,8 +256,8 @@ OPTIMA_TOKEN=$(cat "$TOKEN_FILE")
|
|
|
241
256
|
export TOKEN_FILE=/tmp/optima-test-token-1763997011780.txt
|
|
242
257
|
|
|
243
258
|
# 后续使用
|
|
244
|
-
OPTIMA_TOKEN=$(cat $TOKEN_FILE) OPTIMA_ENV=
|
|
245
|
-
OPTIMA_TOKEN=$(cat $TOKEN_FILE) OPTIMA_ENV=
|
|
259
|
+
OPTIMA_TOKEN=$(cat $TOKEN_FILE) OPTIMA_ENV=ci commerce product list
|
|
260
|
+
OPTIMA_TOKEN=$(cat $TOKEN_FILE) OPTIMA_ENV=ci commerce order list
|
|
246
261
|
```
|
|
247
262
|
|
|
248
263
|
### 3. 自定义账户信息(可选)
|
|
@@ -275,7 +290,7 @@ rm /tmp/optima-test-token-*.txt
|
|
|
275
290
|
|
|
276
291
|
**解决方案**:
|
|
277
292
|
- Token 已过期(15分钟),重新生成
|
|
278
|
-
- 环境变量设置错误,检查 `OPTIMA_ENV=
|
|
293
|
+
- 环境变量设置错误,检查 `OPTIMA_ENV=ci`
|
|
279
294
|
- Token 文件路径错误,检查文件是否存在
|
|
280
295
|
|
|
281
296
|
### 问题 2:Merchant profile 未设置
|
|
@@ -178,6 +178,33 @@ optima-query-db commerce-backend "SELECT status, COUNT(*) FROM orders GROUP BY s
|
|
|
178
178
|
- 通过 SSH 隧道访问 RDS
|
|
179
179
|
- ⚠️ 谨慎使用
|
|
180
180
|
|
|
181
|
+
## 🔧 技术架构
|
|
182
|
+
|
|
183
|
+
### Infisical 配置(v0.7.0+)
|
|
184
|
+
|
|
185
|
+
数据库凭证从 Infisical 动态获取:
|
|
186
|
+
- **项目**: `optima-secrets-v2`
|
|
187
|
+
- **路径**: `/shared-secrets/database-users`
|
|
188
|
+
- **环境**: Stage 用 `staging`,Prod 用 `prod`
|
|
189
|
+
|
|
190
|
+
**凭证 Key 映射**:
|
|
191
|
+
| 服务 | 用户 Key | 密码 Key |
|
|
192
|
+
|------|----------|----------|
|
|
193
|
+
| commerce-backend | `COMMERCE_DB_USER` | `COMMERCE_DB_PASSWORD` |
|
|
194
|
+
| user-auth | `AUTH_DB_USER` | `AUTH_DB_PASSWORD` |
|
|
195
|
+
| agentic-chat | `CHAT_DB_USER` | `CHAT_DB_PASSWORD` |
|
|
196
|
+
| bi-backend | `BI_DB_USER` | `BI_DB_PASSWORD` |
|
|
197
|
+
| session-gateway | `AI_SHELL_DB_USER` | `AI_SHELL_DB_PASSWORD` |
|
|
198
|
+
|
|
199
|
+
### RDS 连接
|
|
200
|
+
|
|
201
|
+
| 环境 | RDS Host | 本地端口 |
|
|
202
|
+
|------|----------|----------|
|
|
203
|
+
| Stage | `optima-stage-postgres.ctg866o0ehac.ap-southeast-1.rds.amazonaws.com` | 15432 |
|
|
204
|
+
| Prod | `optima-prod-postgres.ctg866o0ehac.ap-southeast-1.rds.amazonaws.com` | 15433 |
|
|
205
|
+
|
|
206
|
+
**跳板机**: `13.251.46.219` (Shared EC2)
|
|
207
|
+
|
|
181
208
|
## 🔗 相关命令
|
|
182
209
|
|
|
183
210
|
- `optima-query-db` - CLI 查询工具(推荐)
|
|
@@ -24,7 +24,7 @@ interface MerchantSetupResponse {
|
|
|
24
24
|
user_id: string;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
type Environment = '
|
|
27
|
+
type Environment = 'ci' | 'stage' | 'prod';
|
|
28
28
|
|
|
29
29
|
interface EnvironmentConfig {
|
|
30
30
|
authUrl: string;
|
|
@@ -34,17 +34,23 @@ interface EnvironmentConfig {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const ENV_CONFIG: Record<Environment, EnvironmentConfig> = {
|
|
37
|
-
|
|
37
|
+
ci: {
|
|
38
38
|
authUrl: 'https://auth.optima.chat',
|
|
39
39
|
apiUrl: 'https://api.optima.chat',
|
|
40
40
|
clientId: 'dev-skill-cli-he7fjmsp',
|
|
41
|
-
envName: '
|
|
41
|
+
envName: 'ci'
|
|
42
42
|
},
|
|
43
|
-
|
|
44
|
-
authUrl: 'https://auth.optima.
|
|
45
|
-
apiUrl: 'https://api.optima.
|
|
46
|
-
clientId: '
|
|
47
|
-
envName: '
|
|
43
|
+
stage: {
|
|
44
|
+
authUrl: 'https://auth.stage.optima.onl',
|
|
45
|
+
apiUrl: 'https://api.stage.optima.onl',
|
|
46
|
+
clientId: 'commerce-cli-stage-ihbbwplz',
|
|
47
|
+
envName: 'stage'
|
|
48
|
+
},
|
|
49
|
+
prod: {
|
|
50
|
+
authUrl: 'https://auth.optima.onl',
|
|
51
|
+
apiUrl: 'https://api.optima.onl',
|
|
52
|
+
clientId: 'commerce-cli-ecs-pro-i2r5of1h',
|
|
53
|
+
envName: 'prod'
|
|
48
54
|
}
|
|
49
55
|
};
|
|
50
56
|
|
|
@@ -166,7 +172,7 @@ async function main() {
|
|
|
166
172
|
let businessName = defaultBusinessName;
|
|
167
173
|
let phone: string | undefined;
|
|
168
174
|
let address: string | undefined;
|
|
169
|
-
let environment: Environment = '
|
|
175
|
+
let environment: Environment = 'ci';
|
|
170
176
|
|
|
171
177
|
// 解析命令行参数
|
|
172
178
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -184,15 +190,15 @@ async function main() {
|
|
|
184
190
|
address = args[++i];
|
|
185
191
|
} else if (arg === '--env' && args[i + 1]) {
|
|
186
192
|
const envArg = args[++i];
|
|
187
|
-
if (envArg === '
|
|
193
|
+
if (envArg === 'ci' || envArg === 'stage' || envArg === 'prod') {
|
|
188
194
|
environment = envArg;
|
|
189
195
|
} else {
|
|
190
|
-
console.error(`❌ Invalid environment: ${envArg}. Must be '
|
|
196
|
+
console.error(`❌ Invalid environment: ${envArg}. Must be 'ci', 'stage', or 'prod'.`);
|
|
191
197
|
process.exit(1);
|
|
192
198
|
}
|
|
193
199
|
} else if (arg === '--help' || arg === '-h') {
|
|
194
200
|
console.log(`
|
|
195
|
-
Usage: generate-test-token [options]
|
|
201
|
+
Usage: optima-generate-test-token [options]
|
|
196
202
|
|
|
197
203
|
Options:
|
|
198
204
|
--email <email> User email (default: auto-generated)
|
|
@@ -200,14 +206,19 @@ Options:
|
|
|
200
206
|
--business-name <name> Merchant business name (default: auto-generated)
|
|
201
207
|
--phone <phone> Merchant phone number (optional)
|
|
202
208
|
--address <address> Merchant address (optional)
|
|
203
|
-
--env <environment> Environment:
|
|
209
|
+
--env <environment> Environment: ci (default), stage, or prod
|
|
204
210
|
--help, -h Show this help message
|
|
205
211
|
|
|
212
|
+
Environments:
|
|
213
|
+
ci CI 环境 (auth.optima.chat, api.optima.chat)
|
|
214
|
+
stage Stage 环境 (auth.stage.optima.onl, api.stage.optima.onl)
|
|
215
|
+
prod Prod 环境 (auth.optima.onl, api.optima.onl)
|
|
216
|
+
|
|
206
217
|
Example:
|
|
207
|
-
generate-test-token
|
|
208
|
-
generate-test-token --env
|
|
209
|
-
generate-test-token --
|
|
210
|
-
generate-test-token --
|
|
218
|
+
optima-generate-test-token
|
|
219
|
+
optima-generate-test-token --env stage
|
|
220
|
+
optima-generate-test-token --env prod
|
|
221
|
+
optima-generate-test-token --business-name "My Test Shop" --env stage
|
|
211
222
|
`);
|
|
212
223
|
process.exit(0);
|
|
213
224
|
}
|
|
@@ -38,17 +38,23 @@ const fs = __importStar(require("fs"));
|
|
|
38
38
|
const os = __importStar(require("os"));
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
40
|
const ENV_CONFIG = {
|
|
41
|
-
|
|
41
|
+
ci: {
|
|
42
42
|
authUrl: 'https://auth.optima.chat',
|
|
43
43
|
apiUrl: 'https://api.optima.chat',
|
|
44
44
|
clientId: 'dev-skill-cli-he7fjmsp',
|
|
45
|
-
envName: '
|
|
45
|
+
envName: 'ci'
|
|
46
46
|
},
|
|
47
|
-
|
|
48
|
-
authUrl: 'https://auth.optima.
|
|
49
|
-
apiUrl: 'https://api.optima.
|
|
50
|
-
clientId: '
|
|
51
|
-
envName: '
|
|
47
|
+
stage: {
|
|
48
|
+
authUrl: 'https://auth.stage.optima.onl',
|
|
49
|
+
apiUrl: 'https://api.stage.optima.onl',
|
|
50
|
+
clientId: 'commerce-cli-stage-ihbbwplz',
|
|
51
|
+
envName: 'stage'
|
|
52
|
+
},
|
|
53
|
+
prod: {
|
|
54
|
+
authUrl: 'https://auth.optima.onl',
|
|
55
|
+
apiUrl: 'https://api.optima.onl',
|
|
56
|
+
clientId: 'commerce-cli-ecs-pro-i2r5of1h',
|
|
57
|
+
envName: 'prod'
|
|
52
58
|
}
|
|
53
59
|
};
|
|
54
60
|
async function httpRequest(url, options = {}) {
|
|
@@ -149,7 +155,7 @@ async function main() {
|
|
|
149
155
|
let businessName = defaultBusinessName;
|
|
150
156
|
let phone;
|
|
151
157
|
let address;
|
|
152
|
-
let environment = '
|
|
158
|
+
let environment = 'ci';
|
|
153
159
|
// 解析命令行参数
|
|
154
160
|
for (let i = 0; i < args.length; i++) {
|
|
155
161
|
const arg = args[i];
|
|
@@ -170,17 +176,17 @@ async function main() {
|
|
|
170
176
|
}
|
|
171
177
|
else if (arg === '--env' && args[i + 1]) {
|
|
172
178
|
const envArg = args[++i];
|
|
173
|
-
if (envArg === '
|
|
179
|
+
if (envArg === 'ci' || envArg === 'stage' || envArg === 'prod') {
|
|
174
180
|
environment = envArg;
|
|
175
181
|
}
|
|
176
182
|
else {
|
|
177
|
-
console.error(`❌ Invalid environment: ${envArg}. Must be '
|
|
183
|
+
console.error(`❌ Invalid environment: ${envArg}. Must be 'ci', 'stage', or 'prod'.`);
|
|
178
184
|
process.exit(1);
|
|
179
185
|
}
|
|
180
186
|
}
|
|
181
187
|
else if (arg === '--help' || arg === '-h') {
|
|
182
188
|
console.log(`
|
|
183
|
-
Usage: generate-test-token [options]
|
|
189
|
+
Usage: optima-generate-test-token [options]
|
|
184
190
|
|
|
185
191
|
Options:
|
|
186
192
|
--email <email> User email (default: auto-generated)
|
|
@@ -188,14 +194,19 @@ Options:
|
|
|
188
194
|
--business-name <name> Merchant business name (default: auto-generated)
|
|
189
195
|
--phone <phone> Merchant phone number (optional)
|
|
190
196
|
--address <address> Merchant address (optional)
|
|
191
|
-
--env <environment> Environment:
|
|
197
|
+
--env <environment> Environment: ci (default), stage, or prod
|
|
192
198
|
--help, -h Show this help message
|
|
193
199
|
|
|
200
|
+
Environments:
|
|
201
|
+
ci CI 环境 (auth.optima.chat, api.optima.chat)
|
|
202
|
+
stage Stage 环境 (auth.stage.optima.onl, api.stage.optima.onl)
|
|
203
|
+
prod Prod 环境 (auth.optima.onl, api.optima.onl)
|
|
204
|
+
|
|
194
205
|
Example:
|
|
195
|
-
generate-test-token
|
|
196
|
-
generate-test-token --env
|
|
197
|
-
generate-test-token --
|
|
198
|
-
generate-test-token --
|
|
206
|
+
optima-generate-test-token
|
|
207
|
+
optima-generate-test-token --env stage
|
|
208
|
+
optima-generate-test-token --env prod
|
|
209
|
+
optima-generate-test-token --business-name "My Test Shop" --env stage
|
|
199
210
|
`);
|
|
200
211
|
process.exit(0);
|
|
201
212
|
}
|