Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit 9cff9c3

Browse files
committed
optimize ts types definition
1 parent 4dc4bbb commit 9cff9c3

41 files changed

Lines changed: 705 additions & 87 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

lib/auth/logout.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ function logout() {
1717
return __awaiter(this, void 0, void 0, function* () {
1818
const credentail = utils_1.getCredentialData();
1919
try {
20-
yield utils_1.refreshTmpToken(Object.assign(Object.assign({}, credentail), { isLogout: true }));
20+
if (credentail.refreshToken) {
21+
yield utils_1.refreshTmpToken(Object.assign(Object.assign({}, credentail), { isLogout: true }));
22+
}
2123
utils_1.authStore.delete(constant_1.ConfigItems.credentail);
2224
utils_1.authStore.delete(constant_1.ConfigItems.ssh);
2325
logger_1.successLog('注销登录成功!');

lib/commands/doc.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

lib/commands/env/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ commander_1.default
4848
item.CreateTime,
4949
item.Status === 'NORMAL' ? '正常' : '不可用'
5050
]);
51-
utils_1.printCliTable(head, tableData);
51+
utils_1.printHorizontalTable(head, tableData);
5252
const unavailableEnv = data.find(item => item.Status === 'UNAVAILABLE');
5353
if (unavailableEnv) {
5454
logger_1.warnLog(`您的环境中存在不可用的环境:[${unavailableEnv.EnvId}],请留意!`);

lib/commands/env/domain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ commander_1.default
3939
item.CreateTime,
4040
item.Status === 'ENABLE' ? '启用中' : '禁用中'
4141
]);
42-
utils_1.printCliTable(head, tableData);
42+
utils_1.printHorizontalTable(head, tableData);
4343
});
4444
});
4545
commander_1.default

lib/commands/env/login.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ commander_1.default
4141
item.CreateTime,
4242
item.Status === 'ENABLE' ? '启用' : '禁用'
4343
]);
44-
utils_1.printCliTable(head, tableData);
44+
utils_1.printHorizontalTable(head, tableData);
4545
});
4646
});
4747
commander_1.default

lib/commands/functions/debug.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
const path_1 = __importDefault(require("path"));
7+
const child_process_1 = require("child_process");
8+
const bootstrapFilePath = path_1.default.join(__dirname, '../../utils/runtime/nodejs/bootstrap.js');
9+
child_process_1.execFile('node', [bootstrapFilePath], {
10+
cwd: path_1.default.dirname(bootstrapFilePath),
11+
maxBuffer: 1024 * 1024,
12+
timeout: 20,
13+
env: Object.assign(Object.assign({}, process.env), { SCF_FUNCTION_HANDLER: 'index:main', SCF_FUNCTION_NAME: 'main', GLOBAL_USER_FILE_PATH: '/Users/hengechang/Desktop/cloudbase-demo/functions/test/' })
14+
}, (error, stdout, stderr) => {
15+
if (error) {
16+
console.log(error);
17+
}
18+
console.log(stdout);
19+
console.log(stderr);
20+
});

lib/commands/functions/list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function list(ctx, options) {
5252
item.ModTime,
5353
StatusMap[item.Status]
5454
]);
55-
utils_1.printCliTable(head, tableData);
55+
utils_1.printHorizontalTable(head, tableData);
5656
});
5757
}
5858
exports.list = list;

lib/commands/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ require("./env");
77
require("./functions");
88
require("./server");
99
require("./storage");
10+
require("./open");

lib/commands/init.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function initSuccessOutput(projectName) {
5151
logger_1.successLog(`创建项目 ${projectName} 成功!\n`);
5252
const command = chalk_1.default.bold.cyan(`cd ${projectName}`);
5353
console.log(`👉 运行 ${command} 开始您的项目!\n`);
54-
console.log('🎉 欢迎贡献你的模板 👉 https://github.com/TencentCloudBase/cloudbase-examples');
54+
console.log('🎉 欢迎贡献你的模板 👉 https://github.com/TencentCloudBase/cloudbase-templates');
5555
}
5656
commander_1.default
5757
.command('init')

lib/commands/open.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4+
return new (P || (P = Promise))(function (resolve, reject) {
5+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8+
step((generator = generator.apply(thisArg, _arguments || [])).next());
9+
});
10+
};
11+
var __importDefault = (this && this.__importDefault) || function (mod) {
12+
return (mod && mod.__esModule) ? mod : { "default": mod };
13+
};
14+
Object.defineProperty(exports, "__esModule", { value: true });
15+
const open_1 = __importDefault(require("open"));
16+
const chalk_1 = __importDefault(require("chalk"));
17+
const inquirer_1 = __importDefault(require("inquirer"));
18+
const commander_1 = __importDefault(require("commander"));
19+
const error_1 = require("../error");
20+
const links = [
21+
{
22+
name: 'CLI 文档',
23+
value: 'cli-doc',
24+
url: 'https://tencentcloudbase.github.io/2019-09-03-cli/'
25+
}
26+
];
27+
commander_1.default
28+
.command('open [link]')
29+
.description('在浏览器中打开云开发相关连接')
30+
.action((link) => __awaiter(void 0, void 0, void 0, function* () {
31+
let openLink = null;
32+
if (link) {
33+
openLink = links.find(item => item.value === link);
34+
if (!openLink) {
35+
throw new error_1.CloudBaseError(`${link} 链接不存在!`);
36+
}
37+
}
38+
else {
39+
const { selectLink } = yield inquirer_1.default.prompt({
40+
type: 'list',
41+
name: 'selectLink',
42+
message: '请选择需要打开的链接',
43+
choices: links
44+
});
45+
openLink = links.find(item => item.value === selectLink);
46+
}
47+
if (!openLink) {
48+
throw new error_1.CloudBaseError('请指定需要打开的链接!');
49+
}
50+
console.log(`在您的默认浏览器中打开 ${openLink.name} 链接:`);
51+
console.log(chalk_1.default.underline.bold(openLink.url));
52+
open_1.default(openLink.url);
53+
}));

0 commit comments

Comments
 (0)