@cloudbase/cli 2.5.1-alpha.3 → 2.5.1-alpha.4

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.
@@ -134,7 +134,7 @@ class Command extends events_1.EventEmitter {
134
134
  }
135
135
  }
136
136
  createProgram(instance, deprecate, newCmd) {
137
- const { cmd, desc, options, requiredEnvId = true, withoutAuth = false } = this.options;
137
+ const { cmd, desc, options, requiredEnvId = true, withoutAuth = false, autoRunLogin = false } = this.options;
138
138
  instance.storeOptionsAsProperties(false);
139
139
  options.forEach((option) => {
140
140
  const { hideHelp } = option;
@@ -161,7 +161,13 @@ class Command extends events_1.EventEmitter {
161
161
  loginState = (yield utils_1.authSupevisor.getLoginState());
162
162
  }
163
163
  if (!withoutAuth && !loginState) {
164
- throw new error_1.CloudBaseError('无有效身份信息,请使用 cloudbase login 登录');
164
+ if (autoRunLogin) {
165
+ console.log(chalk_1.default.bold.yellowBright('无有效身份信息,将自动为您打开授权页面。授权成功后请再重新执行命令'));
166
+ yield commander_1.program.parseAsync(['node', 'tcb', 'login']);
167
+ }
168
+ else {
169
+ throw new error_1.CloudBaseError('无有效身份信息,请使用 cloudbase login 登录');
170
+ }
165
171
  }
166
172
  if (!envId && requiredEnvId) {
167
173
  throw new error_1.CloudBaseError('未识别到有效的环境 Id,请使用 cloudbaserc 配置文件进行操作或通过 -e 参数指定环境 Id');
@@ -335,7 +335,8 @@ let ModelTypeSync = class ModelTypeSync extends common_1.Command {
335
335
  }
336
336
  ],
337
337
  desc: '同步数据模型类型定义文件',
338
- requiredEnvId: true
338
+ requiredEnvId: true,
339
+ autoRunLogin: true
339
340
  };
340
341
  }
341
342
  execute(ctx, log, options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cli",
3
- "version": "2.5.1-alpha.3",
3
+ "version": "2.5.1-alpha.4",
4
4
  "description": "cli tool for cloudbase",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -18,6 +18,7 @@ export interface ICommandOptions {
18
18
  desc: string;
19
19
  requiredEnvId?: boolean;
20
20
  withoutAuth?: boolean;
21
+ autoRunLogin?: boolean;
21
22
  }
22
23
  interface ICommandDecoratorOptions {
23
24
  supportPrivate: boolean | 'only';
@@ -76,6 +76,7 @@ export declare class ModelTypeSync extends Command {
76
76
  }[];
77
77
  desc: string;
78
78
  requiredEnvId: boolean;
79
+ autoRunLogin: boolean;
79
80
  };
80
81
  execute(ctx: ICommandContext, log: Logger, options: any): Promise<void>;
81
82
  }