@cloudbase/cli 2.9.10-beta.0 → 2.9.11

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.
@@ -65,6 +65,10 @@ let AICommand = class AICommand extends common_1.Command {
65
65
  {
66
66
  flags: '--template <template>',
67
67
  desc: (0, i18n_1.t)('指定模板类型 (miniprogram, react, vue, uniapp, rules)')
68
+ },
69
+ {
70
+ flags: '-y, --yes',
71
+ desc: (0, i18n_1.t)('自动设置默认模板规则')
68
72
  }
69
73
  ],
70
74
  desc: (0, i18n_1.t)('CloudBase AI ToolKit CLI - 快速启动和配置主流 AI 编程工具\n\n示例:\n tcb ai -a claude -- --continue\n tcb ai -a codebuddy -- mcp list\n\n说明:-- 后的参数会直接传递给目标 AI CLI。'),
@@ -76,7 +80,7 @@ let AICommand = class AICommand extends common_1.Command {
76
80
  execute(options, ctx, log) {
77
81
  return __awaiter(this, void 0, void 0, function* () {
78
82
  yield (0, ensureFiles_1.ensureFiles)();
79
- const { envId, setup, config, reset, template } = options;
83
+ const { envId, setup, config, reset, template, yes: useDefaultConfig } = options;
80
84
  let { agent } = options;
81
85
  try {
82
86
  yield (0, banner_1.showBanner)(log);
@@ -104,7 +108,8 @@ let AICommand = class AICommand extends common_1.Command {
104
108
  log,
105
109
  agent: agent || (yield configManager.loadConfig()).defaultAgent,
106
110
  envId,
107
- template
111
+ template,
112
+ useDefaultConfig
108
113
  });
109
114
  }
110
115
  catch (error) {
@@ -532,6 +532,11 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
532
532
  flags: '--force',
533
533
  desc: (0, i18n_1.t)('强制部署,跳过所有确认提示'),
534
534
  defaultValue: false
535
+ },
536
+ {
537
+ flags: '--installDependency <installDependency>',
538
+ desc: '在线安装依赖',
539
+ defaultValue: true
535
540
  }
536
541
  ],
537
542
  requiredEnvId: false,
@@ -542,7 +547,7 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
542
547
  execute(ctx, envId, log, options) {
543
548
  var _a, _b;
544
549
  return __awaiter(this, void 0, void 0, function* () {
545
- let { serviceName, source, force, port, createAgent } = options;
550
+ let { serviceName, source, force, port, createAgent, installDependency = true } = options;
546
551
  const targetDir = path_1.default.resolve(source || process.cwd());
547
552
  if (!envId) {
548
553
  const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(targetDir));
@@ -660,7 +665,7 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
660
665
  yield cloudrunService.deploy({
661
666
  serverName: serviceName,
662
667
  targetPath: targetDir,
663
- serverConfig: Object.assign({}, (port ? { Port: Number(port) } : {}))
668
+ serverConfig: Object.assign(Object.assign({}, (port ? { Port: Number(port) } : {})), { InstallDependency: installDependency !== 'false' })
664
669
  });
665
670
  utils_2.trackCallback === null || utils_2.trackCallback === void 0 ? void 0 : (0, utils_2.trackCallback)({
666
671
  details: (0, i18n_1.t)('提交{{serverType}} {{serviceName}} 已完成!', { serverType: ResourceTitle[serverType], serviceName }),
@@ -719,6 +724,7 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
719
724
  details: `${e.message}`,
720
725
  originalError: e
721
726
  }, log);
727
+ throw e;
722
728
  }
723
729
  }
724
730
  });
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var _a, _b;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.DEFAULT_CONFIGS = exports.CONFIGS = void 0;
4
5
  const i18n_1 = require("../../i18n");
@@ -6,14 +7,14 @@ exports.CONFIGS = {
6
7
  isIntl: {
7
8
  key: 'isIntl',
8
9
  type: 'boolean',
9
- value: false,
10
+ value: ((_a = process.env.TCB_IS_INTL) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'true',
10
11
  description: (0, i18n_1.t)('是否使用国际站'),
11
12
  envKey: 'TCB_IS_INTL'
12
13
  },
13
14
  lang: {
14
15
  key: 'lang',
15
16
  type: 'string',
16
- value: 'zh',
17
+ value: process.env.TCB_LANG || ((_b = process.env.LANG) === null || _b === void 0 ? void 0 : _b.startsWith('zh')) ? 'zh' : 'en',
17
18
  description: (0, i18n_1.t)('语言,可用值:zh(中文), en(English)'),
18
19
  envKey: 'TCB_LANG'
19
20
  }
@@ -103,7 +103,7 @@ class AICommandRouter {
103
103
  constructor() {
104
104
  this.configManager = new config_1.AIConfigManager();
105
105
  }
106
- execute({ agent, addtionalArgs, log, template }) {
106
+ execute({ agent, addtionalArgs, log, template, useDefaultConfig }) {
107
107
  var _a;
108
108
  return __awaiter(this, void 0, void 0, function* () {
109
109
  if ((0, config_1.isValidAgent)(agent) !== true) {
@@ -123,7 +123,7 @@ class AICommandRouter {
123
123
  }
124
124
  log.info((0, i18n_1.t)('🚀 启动 {{agent}} AI CLI 工具', { agent: chalk_1.default.bold(agentUpperCased) }));
125
125
  try {
126
- yield this.checkToolkitConfig(agent, log, template);
126
+ yield this.checkToolkitConfig({ agent, log, template, useDefaultConfig });
127
127
  }
128
128
  catch (e) {
129
129
  log.warn((0, i18n_1.t)('⚠️ 云开发功能检查失败,但 AI 工具仍可正常使用'));
@@ -136,8 +136,9 @@ class AICommandRouter {
136
136
  this.executeAgentWithConfig(agent, agentConfig, this.parseArgs(addtionalArgs), log);
137
137
  });
138
138
  }
139
- checkToolkitConfig(agent, log, template) {
139
+ checkToolkitConfig(checkOptions) {
140
140
  return __awaiter(this, void 0, void 0, function* () {
141
+ const { agent, log, template, useDefaultConfig } = checkOptions;
141
142
  const { missingFiles } = yield this.configManager.checkToolkitConfig(agent);
142
143
  if (missingFiles.length > 0) {
143
144
  const skipTemplate = yield this.checkSkipTemplateConfig();
@@ -146,7 +147,7 @@ class AICommandRouter {
146
147
  return;
147
148
  }
148
149
  log.log('');
149
- yield this.downloadTemplate(log, template);
150
+ yield this.downloadTemplate({ log, template, agent, useDefaultConfig });
150
151
  log.log('');
151
152
  }
152
153
  });
@@ -176,31 +177,37 @@ class AICommandRouter {
176
177
  }
177
178
  });
178
179
  }
179
- downloadTemplate(log, template) {
180
+ downloadTemplate(options) {
180
181
  return __awaiter(this, void 0, void 0, function* () {
182
+ const { log, template, agent, useDefaultConfig } = options;
181
183
  try {
182
184
  let templateType;
183
185
  if (template) {
184
186
  templateType = template;
185
187
  }
186
188
  else {
187
- const { templateType: selectedType } = yield inquirer_1.default.prompt([
188
- {
189
- type: 'list',
190
- name: 'templateType',
191
- message: (0, i18n_1.t)('下载模板以获取完整的开发体验: {{hint}}', { hint: const_1.LIST_HINT }),
192
- choices: [
193
- { name: (0, i18n_1.t)('🟦 微信小程序 + CloudBase'), value: 'miniprogram' },
194
- { name: (0, i18n_1.t)('🚀 Web 应用 - React + CloudBase'), value: 'react' },
195
- { name: (0, i18n_1.t)('🟢 Web 应用 - Vue + CloudBase'), value: 'vue' },
196
- { name: (0, i18n_1.t)('🌈 跨端应用 - UniApp + CloudBase'), value: 'uniapp' },
197
- { name: (0, i18n_1.t)('🧩 只下载 AI 规则和配置'), value: 'rules' },
198
- { name: (0, i18n_1.t)('🚫 不下载模板'), value: 'none' }
199
- ],
200
- default: 'miniprogram'
201
- }
202
- ]);
203
- templateType = selectedType;
189
+ if (useDefaultConfig) {
190
+ templateType = 'rules';
191
+ }
192
+ else {
193
+ const { templateType: selectedType } = yield inquirer_1.default.prompt([
194
+ {
195
+ type: 'list',
196
+ name: 'templateType',
197
+ message: (0, i18n_1.t)('下载模板以获取完整的开发体验: {{hint}}', { hint: const_1.LIST_HINT }),
198
+ choices: [
199
+ { name: (0, i18n_1.t)('🟦 微信小程序 + CloudBase'), value: 'miniprogram' },
200
+ { name: (0, i18n_1.t)('🚀 Web 应用 - React + CloudBase'), value: 'react' },
201
+ { name: (0, i18n_1.t)('🟢 Web 应用 - Vue + CloudBase'), value: 'vue' },
202
+ { name: (0, i18n_1.t)('🌈 跨端应用 - UniApp + CloudBase'), value: 'uniapp' },
203
+ { name: (0, i18n_1.t)('🧩 只下载 AI 规则和配置'), value: 'rules' },
204
+ { name: (0, i18n_1.t)('🚫 不下载模板'), value: 'none' }
205
+ ],
206
+ default: 'miniprogram'
207
+ }
208
+ ]);
209
+ templateType = selectedType;
210
+ }
204
211
  }
205
212
  if (templateType === 'none') {
206
213
  log.info((0, i18n_1.t)('🚫 跳过模板下载'));
@@ -208,7 +215,7 @@ class AICommandRouter {
208
215
  return;
209
216
  }
210
217
  log.info((0, i18n_1.t)('📦 正在下载并解压 {{templateType}} 模板...', { templateType }));
211
- yield this.downloadAndExtractTemplate(templateType, log);
218
+ yield this.downloadAndExtractTemplate({ templateType, log, agent: agent, useDefaultConfig: useDefaultConfig || false });
212
219
  log.info((0, i18n_1.t)('✅ {{templateType}} 模板配置完成', { templateType }));
213
220
  }
214
221
  catch (error) {
@@ -217,7 +224,7 @@ class AICommandRouter {
217
224
  }
218
225
  });
219
226
  }
220
- downloadAndExtractTemplate(templateType, log) {
227
+ downloadAndExtractTemplate(options) {
221
228
  var _a, e_1, _b, _c;
222
229
  return __awaiter(this, void 0, void 0, function* () {
223
230
  const fs = yield Promise.resolve().then(() => __importStar(require('fs-extra')));
@@ -226,6 +233,7 @@ class AICommandRouter {
226
233
  const unzipper = yield Promise.resolve().then(() => __importStar(require('unzipper')));
227
234
  const https = yield Promise.resolve().then(() => __importStar(require('https')));
228
235
  let ConfigParser;
236
+ const { templateType, log, agent, useDefaultConfig } = options;
229
237
  try {
230
238
  ConfigParser = (yield Promise.resolve().then(() => __importStar(require('@cloudbase/toolbox')))).ConfigParser;
231
239
  }
@@ -275,6 +283,7 @@ class AICommandRouter {
275
283
  });
276
284
  const extractDir = process.cwd();
277
285
  const zipStream = fs.createReadStream(zipPath).pipe(unzipper.Parse({ forceStream: true }));
286
+ const agentDirs = ['.claude', '.codex', '.qwen', '.codebuddy', '.cursor'];
278
287
  try {
279
288
  for (var _e = true, _f = __asyncValues(zipStream), _g; _g = yield _f.next(), _a = _g.done, !_a;) {
280
289
  _c = _g.value;
@@ -283,6 +292,15 @@ class AICommandRouter {
283
292
  const entry = _c;
284
293
  const entryPath = entry.path;
285
294
  const destPath = path.join(extractDir, entryPath);
295
+ if (useDefaultConfig && agent) {
296
+ const currentAgentDir = `.${agent}`;
297
+ const isAgentDir = agentDirs.some(dir => entryPath.startsWith(dir + '/') || entryPath === dir);
298
+ if (isAgentDir && !entryPath.startsWith(currentAgentDir + '/') && entryPath !== currentAgentDir) {
299
+ log.debug && log.debug((0, i18n_1.t)('跳过不匹配的 agent 目录: {{entryPath}} (当前 agent: {{agent}})', { entryPath, agent }));
300
+ entry.autodrain();
301
+ continue;
302
+ }
303
+ }
286
304
  if (entry.type === 'Directory') {
287
305
  yield fs.ensureDir(destPath);
288
306
  entry.autodrain();
@@ -327,6 +345,10 @@ class AICommandRouter {
327
345
  continue;
328
346
  }
329
347
  if (yield fs.pathExists(destPath)) {
348
+ if (useDefaultConfig) {
349
+ entry.autodrain();
350
+ continue;
351
+ }
330
352
  const { confirmOverwriteFile } = yield inquirer_1.default.prompt([
331
353
  {
332
354
  type: 'confirm',
@@ -55,10 +55,11 @@ class LocalStore {
55
55
  return db;
56
56
  }
57
57
  get(key) {
58
+ var _a;
58
59
  return __awaiter(this, void 0, void 0, function* () {
59
60
  const defaultValue = this.defaults[key];
60
61
  const db = yield this.getDB();
61
- return db.get(key).value() || defaultValue;
62
+ return (_a = db.get(key).value()) !== null && _a !== void 0 ? _a : defaultValue;
62
63
  });
63
64
  }
64
65
  set(key, value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cli",
3
- "version": "2.9.10-beta.0",
3
+ "version": "2.9.11",
4
4
  "description": "cli tool for cloudbase",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -55,7 +55,7 @@
55
55
  "@cloudbase/functions-framework": "1.16.0",
56
56
  "@cloudbase/iac-core": "0.0.3-alpha.11",
57
57
  "@cloudbase/lowcode-cli": "^0.22.2",
58
- "@cloudbase/manager-node": "4.6.4",
58
+ "@cloudbase/manager-node": "4.6.5",
59
59
  "@cloudbase/toolbox": "^0.7.9",
60
60
  "@dotenvx/dotenvx": "^1.48.3",
61
61
  "@musistudio/claude-code-router": "1.0.36",
@@ -138,6 +138,7 @@ export declare class CloudRunDeployCommand extends Command {
138
138
  force?: boolean;
139
139
  port?: number;
140
140
  createAgent?: boolean;
141
+ installDependency?: string;
141
142
  }): Promise<void>;
142
143
  }
143
144
  export declare class CloudRunRunCommand extends Command {
@@ -5,11 +5,12 @@ interface IExecute {
5
5
  addtionalArgs: string[];
6
6
  log: Logger;
7
7
  template?: string;
8
+ useDefaultConfig?: boolean;
8
9
  }
9
10
  export declare class AICommandRouter {
10
11
  private configManager;
11
12
  constructor();
12
- execute({ agent, addtionalArgs, log, template }: IExecute): Promise<void>;
13
+ execute({ agent, addtionalArgs, log, template, useDefaultConfig }: IExecute): Promise<void>;
13
14
  private checkToolkitConfig;
14
15
  private checkSkipTemplateConfig;
15
16
  private saveSkipTemplateConfig;
Binary file