@cloudbase/cli 2.6.0-alpha.8 → 2.7.0-alpha.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.
@@ -28,4 +28,4 @@ __exportStar(require("./smart"), exports);
28
28
  __exportStar(require("./lowcode"), exports);
29
29
  __exportStar(require("./run"), exports);
30
30
  __exportStar(require("./db"), exports);
31
- __exportStar(require("./fun"), exports);
31
+ __exportStar(require("./iac"), exports);
@@ -60,11 +60,12 @@ function promisifyProcess(p, pipe = false) {
60
60
  exports.promisifyProcess = promisifyProcess;
61
61
  function getLowcodeCli() {
62
62
  return __awaiter(this, void 0, void 0, function* () {
63
+ var _a;
63
64
  const key = '@cloudbase/lowcode-cli';
64
65
  const cache = new Map();
65
66
  let result;
66
67
  if (!cache.get(key)) {
67
- const module = yield Promise.resolve().then(() => __importStar(require(key)));
68
+ const module = yield (_a = key, Promise.resolve().then(() => __importStar(require(_a))));
68
69
  cache.set(key, module);
69
70
  }
70
71
  result = cache.get(key);
@@ -18,6 +18,15 @@ const debug_logger_1 = require("../debug-logger");
18
18
  let commonCredential;
19
19
  const isTokenExpired = (credential, gap = 120) => credential.accessTokenExpired && Number(credential.accessTokenExpired) < Date.now() + gap * 1000;
20
20
  class CloudApiService {
21
+ static getInstance(service) {
22
+ var _a;
23
+ if ((_a = CloudApiService.serviceCacheMap) === null || _a === void 0 ? void 0 : _a[service]) {
24
+ return CloudApiService.serviceCacheMap[service];
25
+ }
26
+ const apiService = new CloudApiService(service);
27
+ CloudApiService.serviceCacheMap[service] = apiService;
28
+ return apiService;
29
+ }
21
30
  constructor(service, baseParams, version = '') {
22
31
  this.apiService = new cloud_api_1.CloudApiService({
23
32
  service,
@@ -38,15 +47,6 @@ class CloudApiService {
38
47
  })
39
48
  });
40
49
  }
41
- static getInstance(service) {
42
- var _a;
43
- if ((_a = CloudApiService.serviceCacheMap) === null || _a === void 0 ? void 0 : _a[service]) {
44
- return CloudApiService.serviceCacheMap[service];
45
- }
46
- const apiService = new CloudApiService(service);
47
- CloudApiService.serviceCacheMap[service] = apiService;
48
- return apiService;
49
- }
50
50
  request(action, data = {}, method = 'POST') {
51
51
  return __awaiter(this, void 0, void 0, function* () {
52
52
  const region = this.region || (yield (0, toolbox_1.getRegion)());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cli",
3
- "version": "2.6.0-alpha.8",
3
+ "version": "2.7.0-alpha.2",
4
4
  "description": "cli tool for cloudbase",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -20,8 +20,8 @@
20
20
  "url": "https://github.com/TencentCloudBase/cloud-base-cli.git"
21
21
  },
22
22
  "bin": {
23
- "cloudbase": "bin/cloudbase.js",
24
- "tcb": "bin/tcb.js"
23
+ "tcb": "bin/tcb.js",
24
+ "cloudbase": "bin/cloudbase.js"
25
25
  },
26
26
  "husky": {
27
27
  "hooks": {
@@ -33,7 +33,7 @@
33
33
  "dependencies": {
34
34
  "@cloudbase/cloud-api": "^0.5.5",
35
35
  "@cloudbase/framework-core": "^1.9.7",
36
- "@cloudbase/functions-framework": "1.0.0-beta.11",
36
+ "@cloudbase/iac-core": "^0.0.2-alpha.4",
37
37
  "@cloudbase/lowcode-cli": "^0.21.1",
38
38
  "@cloudbase/manager-node": "4.2.8",
39
39
  "@cloudbase/toolbox": "^0.7.5",
@@ -49,13 +49,13 @@
49
49
  "fs-extra": "^8.1.0",
50
50
  "https-proxy-agent": "^5.0.1",
51
51
  "inquirer": "^6.5.0",
52
+ "inquirer-autocomplete-prompt": "2.0.1",
52
53
  "json-schema-to-typescript": "^14.0.5",
53
54
  "lodash": "^4.17.21",
54
55
  "log-symbols": "^3.0.0",
55
56
  "lowdb": "^1.0.0",
56
57
  "make-dir": "^3.0.0",
57
58
  "node-fetch": "^2.6.0",
58
- "nodemon": "^3.1.4",
59
59
  "open": "^7.0.0",
60
60
  "ora": "^4.0.2",
61
61
  "portfinder": "^1.0.28",
@@ -73,6 +73,7 @@
73
73
  },
74
74
  "devDependencies": {
75
75
  "@types/fs-extra": "^11.0.4",
76
+ "@types/inquirer-autocomplete-prompt": "^3.0.3",
76
77
  "@types/jest": "^27",
77
78
  "@types/koa__router": "^8.0.11",
78
79
  "@types/lodash": "^4.14.182",
@@ -0,0 +1,58 @@
1
+ import { Logger } from '../../decorators';
2
+ import { Command, ICommandOptions } from '../common';
3
+ export declare class IaCInitRepo extends Command {
4
+ get options(): {
5
+ cmd: string;
6
+ childCmd: string;
7
+ options: {
8
+ flags: string;
9
+ desc: string;
10
+ }[];
11
+ desc: string;
12
+ requiredEnvId: boolean;
13
+ autoRunLogin: boolean;
14
+ };
15
+ execute(ctx: any, options: any, log: Logger): Promise<void>;
16
+ }
17
+ export declare class IaCPullRepoConfig extends Command {
18
+ get options(): {
19
+ cmd: string;
20
+ childCmd: string;
21
+ options: {
22
+ flags: string;
23
+ desc: string;
24
+ }[];
25
+ desc: string;
26
+ requiredEnvId: boolean;
27
+ autoRunLogin: boolean;
28
+ };
29
+ execute(ctx: any, options: any, log: Logger): Promise<void>;
30
+ }
31
+ export declare class IaCInit extends Command {
32
+ get options(): ICommandOptions;
33
+ execute(ctx: any, options: any, log: Logger): Promise<void>;
34
+ }
35
+ export declare class IaCPull extends Command {
36
+ get options(): ICommandOptions;
37
+ execute(ctx: any, options: any, log: Logger): Promise<void>;
38
+ }
39
+ export declare class IaCBuild extends Command {
40
+ get options(): ICommandOptions;
41
+ execute(ctx: any, options: any, log: Logger): Promise<void>;
42
+ }
43
+ export declare class IaCDev extends Command {
44
+ get options(): ICommandOptions;
45
+ execute(ctx: any, options: any, log: Logger): Promise<void>;
46
+ }
47
+ export declare class IaCApply extends Command {
48
+ get options(): ICommandOptions;
49
+ execute(ctx: any, options: any, log: Logger): Promise<void>;
50
+ }
51
+ export declare class IaCDestory extends Command {
52
+ get options(): ICommandOptions;
53
+ execute(ctx: any, options: any, log: Logger): Promise<void>;
54
+ }
55
+ export declare class IaCState extends Command {
56
+ get options(): ICommandOptions;
57
+ execute(ctx: any, options: any, log: Logger): Promise<void>;
58
+ }
@@ -12,4 +12,4 @@ export * from './smart';
12
12
  export * from './lowcode';
13
13
  export * from './run';
14
14
  export * from './db';
15
- export * from './fun';
15
+ export * from './iac';
@@ -1,4 +1,4 @@
1
1
  import { ParamTypes } from '../constants';
2
- declare type GetterFunction = (target: any) => Promise<any> | any;
2
+ type GetterFunction = (target: any) => Promise<any> | any;
3
3
  export declare const createParamDecorator: (paramtype: ParamTypes, getter: GetterFunction) => () => (target: any, key: string | symbol, index: number) => void;
4
4
  export {};
package/types/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- export declare type CustomEvent = 'logout';
2
+ export type CustomEvent = 'logout';
3
3
  export interface ICommandContext {
4
4
  cmd: string;
5
5
  envId: string;
@@ -33,7 +33,7 @@ export interface TmpCredential {
33
33
  uin?: string;
34
34
  hash?: string;
35
35
  }
36
- export declare type Credential = TmpCredential & PermanentCredential;
36
+ export type Credential = TmpCredential & PermanentCredential;
37
37
  export interface AuthSecret {
38
38
  secretId: string;
39
39
  secretKey: string;
@@ -10,7 +10,7 @@ export interface IArgs {
10
10
  }
11
11
  export declare const getArgs: () => Arguments<IArgs>;
12
12
  export declare function getPrivateSettings(config: ICloudBaseRcSettings, cmd?: string): undefined | IPrivateSettings;
13
- declare type IAbsUrl = `http://${string}` | `https://${string}`;
13
+ type IAbsUrl = `http://${string}` | `https://${string}`;
14
14
  export interface IPrivateSettings {
15
15
  credential: Credential;
16
16
  endpoints: {
@@ -1,5 +1,5 @@
1
1
  export * from './del';
2
- export declare type SizeUnit = 'KB' | 'MB' | 'GB';
2
+ export type SizeUnit = 'KB' | 'MB' | 'GB';
3
3
  export declare function checkFullAccess(dest: string, throwError?: boolean): boolean;
4
4
  export declare function checkWritable(dest: string, throwError?: boolean): boolean;
5
5
  export declare function checkReadable(dest: string, throwError?: boolean): boolean;
@@ -1,7 +1,7 @@
1
1
  import _fetch, { RequestInit } from 'node-fetch';
2
- declare type fetchReturnType = ReturnType<typeof _fetch>;
3
- declare type UnPromisify<T> = T extends PromiseLike<infer U> ? U : T;
4
- declare type fetchReturnTypeExtracted = UnPromisify<fetchReturnType>;
2
+ type fetchReturnType = ReturnType<typeof _fetch>;
3
+ type UnPromisify<T> = T extends PromiseLike<infer U> ? U : T;
4
+ type fetchReturnTypeExtracted = UnPromisify<fetchReturnType>;
5
5
  export declare function fetch(url: string, config?: RequestInit): Promise<any>;
6
6
  export declare function postFetch(url: string, data?: Record<string, any>): Promise<any>;
7
7
  export declare function fetchStream(url: any, config?: Record<string, any>): Promise<fetchReturnTypeExtracted>;
@@ -8,7 +8,7 @@ declare class Loading {
8
8
  fail(text: string): void;
9
9
  }
10
10
  export declare const loadingFactory: () => Loading;
11
- declare type Task<T> = (flush: (text: string) => void, ...args: any[]) => Promise<T>;
11
+ type Task<T> = (flush: (text: string) => void, ...args: any[]) => Promise<T>;
12
12
  export interface ILoadingOptions {
13
13
  startTip?: string;
14
14
  successTip?: string;
@@ -1,4 +1,4 @@
1
- export declare type AsyncTask = () => Promise<any>;
1
+ export type AsyncTask = () => Promise<any>;
2
2
  export declare class AsyncTaskParallelController {
3
3
  maxParallel: number;
4
4
  tasks: AsyncTask[];
@@ -1,4 +1,4 @@
1
- declare type SimpleValue = number | string | boolean;
1
+ type SimpleValue = number | string | boolean;
2
2
  export declare function assertTruthy(val: SimpleValue | SimpleValue[], errMsg: string): void;
3
3
  export declare function assertHas(obj: any, prop: string, errMsg: any): void;
4
4
  export declare const validateIp: (ip: string) => boolean;
@@ -1,52 +0,0 @@
1
- import _ from 'lodash'
2
- import { Command, ICommand } from '../common'
3
- import { watchApp } from '@cloudbase/lowcode-cli'
4
- import { InjectParams, Log, Logger, CmdContext, ArgsOptions } from '../../decorators'
5
-
6
- @ICommand()
7
- export class LowCodeWatch extends Command {
8
- get options() {
9
- return {
10
- cmd: 'lowcode',
11
- childCmd: 'watch',
12
- options: [
13
- {
14
- flags: '--verbose',
15
- desc: '是否打印详细日志'
16
- },
17
- {
18
- flags: '--wx-devtool-path <wxDevtoolPath>',
19
- desc: '微信开发者工具的安装路径'
20
- }
21
- ],
22
- desc: '开启云开发低码的本地构建模式',
23
- requiredEnvId: false
24
- }
25
- }
26
-
27
- @InjectParams()
28
- async execute(@CmdContext() ctx, @ArgsOptions() options) {
29
- await watchApp({
30
- watchPort: 8288,
31
- wxDevtoolPath: options?.wxDevtoolPath
32
- })
33
- }
34
- }
35
-
36
- @ICommand()
37
- export class DanielWatch extends Command {
38
- get options() {
39
- return {
40
- cmd: 'lowcode',
41
- childCmd: 'watch-ws',
42
- options: [],
43
- desc: '开启云开发低码的本地开发模式',
44
- requiredEnvId: false
45
- }
46
- }
47
-
48
- @InjectParams()
49
- async execute(@CmdContext() ctx, @ArgsOptions() options) {
50
- console.log('>>> 启动啦')
51
- }
52
- }
@@ -1,34 +0,0 @@
1
- import _ from 'lodash'
2
- import { Command, ICommand } from '../common'
3
- import { watchApp } from '@cloudbase/lowcode-cli'
4
- import { InjectParams, Log, Logger, CmdContext, ArgsOptions } from '../../decorators'
5
-
6
- @ICommand()
7
- export class LowCodeWatch extends Command {
8
- get options() {
9
- return {
10
- cmd: 'lowcode',
11
- childCmd: 'watch',
12
- options: [
13
- {
14
- flags: '--verbose',
15
- desc: '是否打印详细日志'
16
- },
17
- {
18
- flags: '--wx-devtool-path <wxDevtoolPath>',
19
- desc: '微信开发者工具的安装路径'
20
- }
21
- ],
22
- desc: '开启云开发低码的本地构建模式',
23
- requiredEnvId: false
24
- }
25
- }
26
-
27
- @InjectParams()
28
- async execute(@CmdContext() ctx, @ArgsOptions() options) {
29
- await watchApp({
30
- watchPort: 8288,
31
- wxDevtoolPath: options?.wxDevtoolPath
32
- })
33
- }
34
- }
@@ -1,34 +0,0 @@
1
- import _ from 'lodash'
2
- import { Command, ICommand } from '../common'
3
- import { watchApp } from '@cloudbase/lowcode-cli'
4
- import { InjectParams, Log, Logger, CmdContext, ArgsOptions } from '../../decorators'
5
-
6
- @ICommand()
7
- export class LowCodeWatch extends Command {
8
- get options() {
9
- return {
10
- cmd: 'lowcode',
11
- childCmd: 'watch',
12
- options: [
13
- {
14
- flags: '--verbose',
15
- desc: '是否打印详细日志'
16
- },
17
- {
18
- flags: '--wx-devtool-path <wxDevtoolPath>',
19
- desc: '微信开发者工具的安装路径'
20
- }
21
- ],
22
- desc: '开启微搭低代码的本地构建模式',
23
- requiredEnvId: false
24
- }
25
- }
26
-
27
- @InjectParams()
28
- async execute(@CmdContext() ctx, @ArgsOptions() options) {
29
- await watchApp({
30
- watchPort: 8288,
31
- wxDevtoolPath: options?.wxDevtoolPath
32
- })
33
- }
34
- }
@@ -1,13 +0,0 @@
1
- import 'reflect-metadata'
2
- import { registerCommands } from './commands/common'
3
- import './commands'
4
-
5
- export { smartDeploy } from './commands'
6
-
7
- registerCommands()
8
-
9
- // HACK: 部分依赖使用了 globalThis,会在 Node12 以下的版本报错
10
- if (typeof globalThis === undefined) {
11
- // eslint-disable-next-line no-undef
12
- ;(globalThis as any) = global
13
- }
@@ -1,15 +0,0 @@
1
- import 'reflect-metadata'
2
- import { registerCommands } from './commands/common'
3
- import './commands'
4
-
5
- export { smartDeploy } from './commands'
6
-
7
- registerCommands()
8
-
9
- // HACK: 部分依赖使用了 globalThis,会在 Node12 以下的版本报错
10
- if (typeof globalThis === undefined) {
11
- // eslint-disable-next-line no-undef
12
- ;(globalThis as any) = global
13
- }
14
-
15
- console.log("daniel tcb")
@@ -1,13 +0,0 @@
1
- import 'reflect-metadata'
2
- import { registerCommands } from './commands/common'
3
- import './commands'
4
-
5
- export { smartDeploy } from './commands'
6
-
7
- registerCommands()
8
-
9
- // HACK: 部分依赖使用了 globalThis,会在 Node12 以下的版本报错
10
- if (typeof globalThis === undefined) {
11
- // eslint-disable-next-line no-undef
12
- ;(globalThis as any) = global
13
- }
package/.yarnrc.yml DELETED
@@ -1 +0,0 @@
1
- nodeLinker: node-modules
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnvStatus = exports.EnvSource = void 0;
4
- exports.EnvSource = {
5
- MINIAPP: 'miniapp',
6
- QCLOUD: 'qcloud'
7
- };
8
- exports.EnvStatus = {
9
- NORMAL: 'NORMAL',
10
- UNAVAILABLE: 'UNAVAILABLE'
11
- };