@cloudbase/cli 2.0.12 → 2.1.0
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.
- package/.history/.gitignore_20220624162613 +84 -0
- package/.history/.gitignore_20220627114054 +86 -0
- package/.history/package_20220711204706.json +88 -0
- package/.history/package_20220711204818.json +88 -0
- package/.history/package_20220712151717.json +88 -0
- package/.history/package_20220712212537.json +88 -0
- package/.history/package_20220722205058.json +88 -0
- package/.history/package_20220726110155.json +88 -0
- package/.history/package_20220726110201.json +88 -0
- package/.history/package_20220728110905.json +88 -0
- package/.history/package_20220728110936.json +88 -0
- package/.history/package_20220728111531.json +89 -0
- package/.history/package_20220728111810.json +89 -0
- package/.history/src/commands/lowcode/app_20220728111717.ts +52 -0
- package/{src/commands/lowcode/app.ts → .history/src/commands/lowcode/app_20220728112031.ts} +2 -2
- package/{src/index.ts → .history/src/index_20220624162613.ts} +0 -0
- package/.history/src/index_20220627113609.ts +15 -0
- package/.history/src/index_20220627114102.ts +13 -0
- package/.vscode/launch.json +10 -0
- package/bin/cloudbase.js +0 -0
- package/bin/tcb.js +5 -5
- package/lib/commands/account/login.js +3 -6
- package/lib/commands/env/index.js +0 -1
- package/lib/commands/lowcode/app.js +1 -1
- package/lib/commands/run/index.js +0 -1
- package/lib/commands/run/service/deploy.js +6 -1
- package/lib/commands/run/service/index.js +0 -1
- package/lib/commands/run/service/update.js +4 -0
- package/lib/constant.js +15 -1
- package/lib/env/index.js +1 -11
- package/lib/run/index.js +0 -1
- package/lib/run/service/common.js +20 -7
- package/lib/run/service/config.js +2 -3
- package/lib/run/service/deployPackage.js +2 -9
- package/lib/run/service/index.js +0 -1
- package/lib/run/service/update.js +1 -1
- package/lib/utils/debug-logger.js +30 -0
- package/lib/utils/net/cloud-api-request.js +7 -1
- package/lib/utils/net/http-request.js +16 -5
- package/package.json +2 -2
- package/types/commands/env/index.d.ts +0 -1
- package/types/commands/run/index.d.ts +0 -1
- package/types/commands/run/service/index.d.ts +0 -1
- package/types/env/index.d.ts +0 -6
- package/types/run/index.d.ts +0 -1
- package/types/run/service/common.d.ts +8 -1
- package/types/run/service/index.d.ts +0 -1
- package/types/types.d.ts +4 -0
- package/types/utils/debug-logger.d.ts +1 -0
- package/types/utils/net/http-request.d.ts +6 -2
- package/lib/commands/env/create.js +0 -115
- package/lib/commands/run/create.js +0 -162
- package/lib/commands/run/service/create.js +0 -144
- package/lib/run/create.js +0 -19
- package/lib/run/service/create.js +0 -67
- package/src/auth/index.ts +0 -2
- package/src/auth/login.ts +0 -91
- package/src/auth/logout.ts +0 -7
- package/src/commands/account/index.ts +0 -2
- package/src/commands/account/login.ts +0 -192
- package/src/commands/account/logout.ts +0 -24
- package/src/commands/common.ts +0 -246
- package/src/commands/env/base.ts +0 -90
- package/src/commands/env/create.ts +0 -92
- package/src/commands/env/domain.ts +0 -186
- package/src/commands/env/index.ts +0 -4
- package/src/commands/env/login.ts +0 -235
- package/src/commands/framework/index.ts +0 -124
- package/src/commands/functions/alias/getRoute.ts +0 -76
- package/src/commands/functions/alias/index.ts +0 -2
- package/src/commands/functions/alias/setRoute.ts +0 -82
- package/src/commands/functions/code-download.ts +0 -100
- package/src/commands/functions/code-update.ts +0 -62
- package/src/commands/functions/concurrency/delete.ts +0 -45
- package/src/commands/functions/concurrency/index.ts +0 -3
- package/src/commands/functions/concurrency/list.ts +0 -58
- package/src/commands/functions/concurrency/set.ts +0 -47
- package/src/commands/functions/config-update.ts +0 -76
- package/src/commands/functions/copy.ts +0 -62
- package/src/commands/functions/delete.ts +0 -79
- package/src/commands/functions/deploy.ts +0 -293
- package/src/commands/functions/detail.ts +0 -138
- package/src/commands/functions/index.ts +0 -16
- package/src/commands/functions/invoke.ts +0 -121
- package/src/commands/functions/layer/bind.ts +0 -182
- package/src/commands/functions/layer/common.ts +0 -8
- package/src/commands/functions/layer/create.ts +0 -49
- package/src/commands/functions/layer/delete.ts +0 -73
- package/src/commands/functions/layer/download.ts +0 -92
- package/src/commands/functions/layer/index.ts +0 -7
- package/src/commands/functions/layer/list.ts +0 -94
- package/src/commands/functions/layer/sort.ts +0 -76
- package/src/commands/functions/list.ts +0 -68
- package/src/commands/functions/log.ts +0 -148
- package/src/commands/functions/run.ts +0 -249
- package/src/commands/functions/trigger-create.ts +0 -79
- package/src/commands/functions/trigger-delete.ts +0 -105
- package/src/commands/functions/version/index.ts +0 -2
- package/src/commands/functions/version/list.ts +0 -73
- package/src/commands/functions/version/publish.ts +0 -43
- package/src/commands/gateway/create.ts +0 -109
- package/src/commands/gateway/delete.ts +0 -81
- package/src/commands/gateway/domain.ts +0 -159
- package/src/commands/gateway/index.ts +0 -5
- package/src/commands/gateway/list.ts +0 -76
- package/src/commands/gateway/switch.ts +0 -107
- package/src/commands/helpers/index.ts +0 -3
- package/src/commands/helpers/init.ts +0 -431
- package/src/commands/helpers/new.ts +0 -117
- package/src/commands/helpers/open.ts +0 -67
- package/src/commands/hosting/hosting.ts +0 -360
- package/src/commands/hosting/index.ts +0 -1
- package/src/commands/index.ts +0 -13
- package/src/commands/lowcode/comps.ts +0 -325
- package/src/commands/lowcode/index.ts +0 -2
- package/src/commands/lowcode/utils.ts +0 -25
- package/src/commands/run/create.ts +0 -153
- package/src/commands/run/delete.ts +0 -77
- package/src/commands/run/image/common.ts +0 -8
- package/src/commands/run/image/delete.ts +0 -68
- package/src/commands/run/image/download.ts +0 -68
- package/src/commands/run/image/index.ts +0 -5
- package/src/commands/run/image/list.ts +0 -84
- package/src/commands/run/image/upload.ts +0 -76
- package/src/commands/run/index.ts +0 -7
- package/src/commands/run/list.ts +0 -83
- package/src/commands/run/service/config.ts +0 -81
- package/src/commands/run/service/create.ts +0 -122
- package/src/commands/run/service/deploy.ts +0 -125
- package/src/commands/run/service/index.ts +0 -5
- package/src/commands/run/service/list.ts +0 -94
- package/src/commands/run/service/update.ts +0 -108
- package/src/commands/run/standalonegateway/common.ts +0 -8
- package/src/commands/run/standalonegateway/create.ts +0 -85
- package/src/commands/run/standalonegateway/destroy.ts +0 -59
- package/src/commands/run/standalonegateway/index.ts +0 -5
- package/src/commands/run/standalonegateway/list.ts +0 -53
- package/src/commands/run/standalonegateway/package.ts +0 -62
- package/src/commands/run/standalonegateway/turn.ts +0 -63
- package/src/commands/run/version/common.ts +0 -8
- package/src/commands/run/version/create.ts +0 -369
- package/src/commands/run/version/delete.ts +0 -64
- package/src/commands/run/version/index.ts +0 -5
- package/src/commands/run/version/list.ts +0 -91
- package/src/commands/run/version/modify.ts +0 -137
- package/src/commands/run/version/update.ts +0 -398
- package/src/commands/smart.ts +0 -132
- package/src/commands/storage/index.ts +0 -1
- package/src/commands/storage/storage.ts +0 -464
- package/src/commands/third/index.ts +0 -1
- package/src/commands/third/thirdAttach.ts +0 -49
- package/src/completion/index.ts +0 -13
- package/src/constant.ts +0 -154
- package/src/decorators/captureError.ts +0 -25
- package/src/decorators/constants.ts +0 -12
- package/src/decorators/deprecate.ts +0 -25
- package/src/decorators/guard.ts +0 -42
- package/src/decorators/index.ts +0 -7
- package/src/decorators/injectParams.ts +0 -54
- package/src/decorators/params/common.ts +0 -28
- package/src/decorators/params/index.ts +0 -35
- package/src/env/domain.ts +0 -33
- package/src/env/index.ts +0 -63
- package/src/env/login.ts +0 -80
- package/src/error.ts +0 -36
- package/src/function/alias.ts +0 -43
- package/src/function/base.ts +0 -253
- package/src/function/code.ts +0 -55
- package/src/function/concurrency.ts +0 -57
- package/src/function/create.ts +0 -78
- package/src/function/delete.ts +0 -42
- package/src/function/index.ts +0 -11
- package/src/function/layer/attach.ts +0 -68
- package/src/function/layer/create.ts +0 -63
- package/src/function/layer/delete.ts +0 -21
- package/src/function/layer/download.ts +0 -54
- package/src/function/layer/index.ts +0 -7
- package/src/function/layer/list.ts +0 -32
- package/src/function/layer/sort.ts +0 -24
- package/src/function/trigger.ts +0 -97
- package/src/function/update.ts +0 -35
- package/src/function/version.ts +0 -39
- package/src/function/vpc.ts +0 -22
- package/src/gateway/index.ts +0 -137
- package/src/help.ts +0 -50
- package/src/hosting.ts +0 -212
- package/src/logger.ts +0 -17
- package/src/run/create.ts +0 -23
- package/src/run/delete.ts +0 -15
- package/src/run/image/build.ts +0 -36
- package/src/run/image/delete.ts +0 -14
- package/src/run/image/index.ts +0 -4
- package/src/run/image/info.ts +0 -27
- package/src/run/image/list.ts +0 -23
- package/src/run/index.ts +0 -8
- package/src/run/list.ts +0 -30
- package/src/run/repo.ts +0 -25
- package/src/run/service/common.ts +0 -311
- package/src/run/service/config.ts +0 -77
- package/src/run/service/create.ts +0 -52
- package/src/run/service/deployPackage.ts +0 -65
- package/src/run/service/index.ts +0 -7
- package/src/run/service/list.ts +0 -29
- package/src/run/service/showLogs.ts +0 -98
- package/src/run/service/update.ts +0 -82
- package/src/run/standalonegateway/create.ts +0 -24
- package/src/run/standalonegateway/destroy.ts +0 -19
- package/src/run/standalonegateway/index.ts +0 -5
- package/src/run/standalonegateway/list.ts +0 -74
- package/src/run/standalonegateway/package/index.ts +0 -1
- package/src/run/standalonegateway/package/list.ts +0 -24
- package/src/run/standalonegateway/turn/index.ts +0 -2
- package/src/run/standalonegateway/turn/off.ts +0 -19
- package/src/run/standalonegateway/turn/on.ts +0 -19
- package/src/run/version/create.ts +0 -68
- package/src/run/version/delete.ts +0 -16
- package/src/run/version/index.ts +0 -6
- package/src/run/version/list.ts +0 -17
- package/src/run/version/modify.ts +0 -17
- package/src/run/version/repo.ts +0 -28
- package/src/run/version/update.ts +0 -59
- package/src/storage.ts +0 -114
- package/src/third/index.ts +0 -13
- package/src/types.ts +0 -672
- package/src/utils/auth.ts +0 -15
- package/src/utils/checkTcbrEnv.ts +0 -69
- package/src/utils/cli-table.ts +0 -23
- package/src/utils/commonParamsCheck.ts +0 -65
- package/src/utils/config.ts +0 -39
- package/src/utils/env.ts +0 -244
- package/src/utils/fs/del.ts +0 -5
- package/src/utils/fs/index.ts +0 -71
- package/src/utils/function-packer.ts +0 -97
- package/src/utils/index.ts +0 -25
- package/src/utils/log.ts +0 -82
- package/src/utils/net/cloud-api-request.ts +0 -62
- package/src/utils/net/credential.ts +0 -53
- package/src/utils/net/http-request.ts +0 -84
- package/src/utils/net/index.ts +0 -5
- package/src/utils/net/manager-service.ts +0 -36
- package/src/utils/net/proxy.ts +0 -6
- package/src/utils/notice.ts +0 -28
- package/src/utils/output/highlight.ts +0 -5
- package/src/utils/output/index.ts +0 -3
- package/src/utils/output/link.ts +0 -10
- package/src/utils/output/loading.ts +0 -82
- package/src/utils/parallel.ts +0 -82
- package/src/utils/platform/index.ts +0 -3
- package/src/utils/platform/mac.ts +0 -21
- package/src/utils/platform/os.ts +0 -64
- package/src/utils/platform/port.ts +0 -10
- package/src/utils/progress-bar.ts +0 -38
- package/src/utils/prompt/index.ts +0 -1
- package/src/utils/prompt/select.ts +0 -60
- package/src/utils/reporter/agree.ts +0 -20
- package/src/utils/reporter/download.ts +0 -26
- package/src/utils/reporter/index.ts +0 -3
- package/src/utils/reporter/usage.ts +0 -20
- package/src/utils/store/auth.ts +0 -49
- package/src/utils/store/common.ts +0 -8
- package/src/utils/store/db.ts +0 -68
- package/src/utils/store/index.ts +0 -5
- package/src/utils/store/usage.ts +0 -12
- package/src/utils/tcbrApi/callTcbrApi.ts +0 -28
- package/src/utils/tcbrApi/index.ts +0 -1
- package/src/utils/template.ts +0 -170
- package/src/utils/tools/encoding.ts +0 -8
- package/src/utils/tools/index.ts +0 -4
- package/src/utils/tools/object.ts +0 -33
- package/src/utils/tools/time.ts +0 -38
- package/src/utils/tools/uid.ts +0 -19
- package/src/utils/validator.ts +0 -65
- package/types/commands/env/create.d.ts +0 -12
- package/types/commands/run/create.d.ts +0 -13
- package/types/commands/run/service/create.d.ts +0 -13
- package/types/run/create.d.ts +0 -2
- package/types/run/service/create.d.ts +0 -7
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import inquirer from 'inquirer'
|
|
2
|
-
import { CloudBaseError } from '../../error'
|
|
3
|
-
import { Command, ICommand } from '../common'
|
|
4
|
-
import { printHorizontalTable, loadingFactory } from '../../utils'
|
|
5
|
-
import { InjectParams, EnvId, ArgsParams, Log, Logger } from '../../decorators'
|
|
6
|
-
import { getEnvAuthDomains, createEnvDomain, deleteEnvDomain } from '../../env'
|
|
7
|
-
|
|
8
|
-
@ICommand()
|
|
9
|
-
export class ListAuthDoaminCommand extends Command {
|
|
10
|
-
get options() {
|
|
11
|
-
return {
|
|
12
|
-
cmd: 'env',
|
|
13
|
-
childCmd: {
|
|
14
|
-
cmd: 'domain',
|
|
15
|
-
desc: '域名管理'
|
|
16
|
-
},
|
|
17
|
-
childSubCmd: 'list',
|
|
18
|
-
deprecateCmd: 'env:domain:list',
|
|
19
|
-
options: [
|
|
20
|
-
{
|
|
21
|
-
flags: '-e, --envId <envId>',
|
|
22
|
-
desc: '环境 Id'
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
desc: '列出环境的安全域名列表'
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@InjectParams()
|
|
30
|
-
async execute(@EnvId() envId) {
|
|
31
|
-
const domains = await getEnvAuthDomains({
|
|
32
|
-
envId: envId
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
if (domains.length === 0) {
|
|
36
|
-
console.log('安全域名为空!')
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const head = ['域名 Id', '域名', '创建时间', '状态']
|
|
41
|
-
const tableData = domains.map((item) => [
|
|
42
|
-
item.Id,
|
|
43
|
-
item.Domain,
|
|
44
|
-
item.CreateTime,
|
|
45
|
-
item.Status === 'ENABLE' ? '启用中' : '禁用中'
|
|
46
|
-
])
|
|
47
|
-
|
|
48
|
-
printHorizontalTable(head, tableData)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@ICommand()
|
|
53
|
-
export class CreateAuthDomainCommand extends Command {
|
|
54
|
-
get options() {
|
|
55
|
-
return {
|
|
56
|
-
cmd: 'env',
|
|
57
|
-
childCmd: {
|
|
58
|
-
cmd: 'domain',
|
|
59
|
-
desc: '域名管理'
|
|
60
|
-
},
|
|
61
|
-
childSubCmd: 'create <domain>',
|
|
62
|
-
deprecateCmd: 'env:domain:create <domain>',
|
|
63
|
-
options: [
|
|
64
|
-
{
|
|
65
|
-
flags: '-e, --envId <envId>',
|
|
66
|
-
desc: '环境 Id'
|
|
67
|
-
}
|
|
68
|
-
],
|
|
69
|
-
desc: '添加环境安全域名,多个以斜杠 / 分隔'
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
@InjectParams()
|
|
74
|
-
async execute(@ArgsParams() params, @EnvId() envId, @Log() log: Logger) {
|
|
75
|
-
log.verbose(params)
|
|
76
|
-
|
|
77
|
-
const domain = params?.[0]
|
|
78
|
-
const domains = domain.split('/')
|
|
79
|
-
|
|
80
|
-
const { confirm } = await inquirer.prompt({
|
|
81
|
-
type: 'confirm',
|
|
82
|
-
name: 'confirm',
|
|
83
|
-
message: `确认添加以下安全域名: ${domains} ?`,
|
|
84
|
-
default: true
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
if (!confirm) {
|
|
88
|
-
throw new CloudBaseError('操作终止!')
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// 检查域名是否已经添加,重复添加会报错
|
|
92
|
-
let envDomains = await getEnvAuthDomains({
|
|
93
|
-
envId
|
|
94
|
-
})
|
|
95
|
-
envDomains = envDomains.map((item) => item.Domain)
|
|
96
|
-
const exitDomains = []
|
|
97
|
-
|
|
98
|
-
domains.forEach((item) => {
|
|
99
|
-
if (envDomains.includes(item)) {
|
|
100
|
-
exitDomains.push(item)
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
if (exitDomains.length) {
|
|
105
|
-
throw new CloudBaseError(`域名 [${exitDomains.join(', ')}] 已存在!`)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
await createEnvDomain({
|
|
109
|
-
envId,
|
|
110
|
-
domains: domains
|
|
111
|
-
})
|
|
112
|
-
log.success('添加安全域名成功!')
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
@ICommand()
|
|
117
|
-
export class DeleteAuthDomainCommand extends Command {
|
|
118
|
-
get options() {
|
|
119
|
-
return {
|
|
120
|
-
cmd: 'env',
|
|
121
|
-
childCmd: {
|
|
122
|
-
cmd: 'domain',
|
|
123
|
-
desc: '域名管理'
|
|
124
|
-
},
|
|
125
|
-
childSubCmd: 'delete',
|
|
126
|
-
deprecateCmd: 'env:domain:delete',
|
|
127
|
-
options: [
|
|
128
|
-
{
|
|
129
|
-
flags: '-e, --envId <envId>',
|
|
130
|
-
desc: '环境 Id'
|
|
131
|
-
}
|
|
132
|
-
],
|
|
133
|
-
desc: '删除环境的安全域名'
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
@InjectParams()
|
|
138
|
-
async execute(@EnvId() envId, @Log() log: Logger) {
|
|
139
|
-
const loading = loadingFactory()
|
|
140
|
-
|
|
141
|
-
loading.start('拉取环境安全域名中')
|
|
142
|
-
|
|
143
|
-
const domains = await getEnvAuthDomains({
|
|
144
|
-
envId
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
if (domains.length === 0) {
|
|
148
|
-
loading.fail('域名安全为空,不能执行删除操作!')
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
loading.succeed('拉取环境安全域名成功!')
|
|
153
|
-
|
|
154
|
-
const domainList = domains.map((item) => item.Domain)
|
|
155
|
-
|
|
156
|
-
const { selectDomains } = await inquirer.prompt({
|
|
157
|
-
type: 'checkbox',
|
|
158
|
-
name: 'selectDomains',
|
|
159
|
-
message: '请选择需要删除的域名(可多选)>',
|
|
160
|
-
choices: domainList,
|
|
161
|
-
default: true
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
const { confirm } = await inquirer.prompt({
|
|
165
|
-
type: 'confirm',
|
|
166
|
-
name: 'confirm',
|
|
167
|
-
message: `确认删除以下安全域名: ${selectDomains} ?`,
|
|
168
|
-
default: true
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
if (!confirm) {
|
|
172
|
-
throw new CloudBaseError('操作终止!')
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const domainIds = domains
|
|
176
|
-
.filter((item) => selectDomains.includes(item.Domain))
|
|
177
|
-
.map((item) => item.Id)
|
|
178
|
-
|
|
179
|
-
const deleted = await deleteEnvDomain({
|
|
180
|
-
domainIds,
|
|
181
|
-
envId
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
log.success(`成功删除了 ${deleted} 个域名!`)
|
|
185
|
-
}
|
|
186
|
-
}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import inquirer from 'inquirer'
|
|
2
|
-
import { Command, ICommand } from '../common'
|
|
3
|
-
import { CloudBaseError } from '../../error'
|
|
4
|
-
import { printHorizontalTable } from '../../utils'
|
|
5
|
-
import { InjectParams, EnvId, Log, Logger } from '../../decorators'
|
|
6
|
-
import { getLoginConfigList, updateLoginConfig, createLoginConfig } from '../../env'
|
|
7
|
-
|
|
8
|
-
const platformMap = {
|
|
9
|
-
'WECHAT-OPEN': '微信开放平台',
|
|
10
|
-
'WECHAT-PUBLIC': '微信公众平台',
|
|
11
|
-
ANONYMOUS: '匿名登录'
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@ICommand()
|
|
15
|
-
export class ListLoginCommand extends Command {
|
|
16
|
-
get options() {
|
|
17
|
-
return {
|
|
18
|
-
cmd: 'env',
|
|
19
|
-
childCmd: {
|
|
20
|
-
cmd: 'login',
|
|
21
|
-
desc: '登录授权管理'
|
|
22
|
-
},
|
|
23
|
-
childSubCmd: 'list',
|
|
24
|
-
deprecateCmd: 'env:login:list',
|
|
25
|
-
options: [
|
|
26
|
-
{
|
|
27
|
-
flags: '-e, --envId <envId>',
|
|
28
|
-
desc: '环境 Id'
|
|
29
|
-
}
|
|
30
|
-
],
|
|
31
|
-
desc: '列出环境登录配置'
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@InjectParams()
|
|
36
|
-
async execute(@EnvId() envId) {
|
|
37
|
-
const configList = await getLoginConfigList({
|
|
38
|
-
envId
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const head = ['平台', '平台 Id', '创建时间', '状态']
|
|
42
|
-
const tableData = configList.map((item) => [
|
|
43
|
-
platformMap[item.Platform] ? platformMap[item.Platform] : item.Platform,
|
|
44
|
-
item.PlatformId,
|
|
45
|
-
item.CreateTime,
|
|
46
|
-
item.Status === 'ENABLE' ? '启用' : '禁用'
|
|
47
|
-
])
|
|
48
|
-
printHorizontalTable(head, tableData)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
@ICommand()
|
|
53
|
-
export class CreateLoginCommand extends Command {
|
|
54
|
-
get options() {
|
|
55
|
-
return {
|
|
56
|
-
cmd: 'env',
|
|
57
|
-
childCmd: 'login',
|
|
58
|
-
childSubCmd: 'create',
|
|
59
|
-
deprecateCmd: 'env:login:create',
|
|
60
|
-
options: [
|
|
61
|
-
{
|
|
62
|
-
flags: '-e, --envId <envId>',
|
|
63
|
-
desc: '环境 Id'
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
desc: '添加环境登录方式配置'
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@InjectParams()
|
|
71
|
-
async execute(@EnvId() envId, @Log() log: Logger) {
|
|
72
|
-
const { platform } = await inquirer.prompt([
|
|
73
|
-
{
|
|
74
|
-
type: 'list',
|
|
75
|
-
name: 'platform',
|
|
76
|
-
choices: [
|
|
77
|
-
{
|
|
78
|
-
name: '微信公众平台',
|
|
79
|
-
value: 'WECHAT-PUBLIC'
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: '微信开放平台',
|
|
83
|
-
value: 'WECHAT-OPEN'
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: '匿名登录',
|
|
87
|
-
value: 'ANONYMOUS'
|
|
88
|
-
}
|
|
89
|
-
],
|
|
90
|
-
message: '请选择登录方式:',
|
|
91
|
-
default: 'WECHAT-PUBLIC'
|
|
92
|
-
}
|
|
93
|
-
])
|
|
94
|
-
|
|
95
|
-
let appId
|
|
96
|
-
let appSecret
|
|
97
|
-
|
|
98
|
-
// 微信登录,需要配置 AppId 和 AppSecret
|
|
99
|
-
if (platform === 'WECHAT-OPEN' || platform === 'WECHAT-PUBLIC') {
|
|
100
|
-
const input = await inquirer.prompt([
|
|
101
|
-
{
|
|
102
|
-
type: 'input',
|
|
103
|
-
name: 'appId',
|
|
104
|
-
message: '请输入 AppId:'
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
type: 'input',
|
|
108
|
-
name: 'appSecret',
|
|
109
|
-
message: '请输入 AppSecret:'
|
|
110
|
-
}
|
|
111
|
-
])
|
|
112
|
-
|
|
113
|
-
appId = input?.appId
|
|
114
|
-
appSecret = input?.appSecret
|
|
115
|
-
|
|
116
|
-
if (!appId || !appSecret) {
|
|
117
|
-
throw new CloudBaseError('appId 和 appSecret 不能为空!')
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// 匿名登录
|
|
122
|
-
if (platform === 'ANONYMOUS') {
|
|
123
|
-
appId = 'anonymous'
|
|
124
|
-
appSecret = 'anonymous'
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
try {
|
|
128
|
-
await createLoginConfig({
|
|
129
|
-
envId,
|
|
130
|
-
appId,
|
|
131
|
-
appSecret,
|
|
132
|
-
platform
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
log.success('创建登录方式成功!')
|
|
136
|
-
} catch (e) {
|
|
137
|
-
if (e.code === 'ResourceInUse') {
|
|
138
|
-
log.error('登录方式已开启')
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
@ICommand()
|
|
145
|
-
export class UpdateLogin extends Command {
|
|
146
|
-
get options() {
|
|
147
|
-
return {
|
|
148
|
-
cmd: 'env',
|
|
149
|
-
childCmd: 'login',
|
|
150
|
-
childSubCmd: 'update',
|
|
151
|
-
deprecateCmd: 'env:login:update',
|
|
152
|
-
options: [
|
|
153
|
-
{
|
|
154
|
-
flags: '-e, --envId <envId>',
|
|
155
|
-
desc: '环境 Id'
|
|
156
|
-
}
|
|
157
|
-
],
|
|
158
|
-
desc: '更新环境登录方式配置'
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
@InjectParams()
|
|
163
|
-
async execute(@EnvId() envId, @Log() log: Logger) {
|
|
164
|
-
const configList = await getLoginConfigList({
|
|
165
|
-
envId
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
const configChoices = configList.map((item) => ({
|
|
169
|
-
name: `${platformMap[item.Platform]}:${item.PlatformId} [${
|
|
170
|
-
item.Status === 'ENABLE' ? '启用' : '禁用'
|
|
171
|
-
}]`,
|
|
172
|
-
value: item,
|
|
173
|
-
short: `${platformMap[item.Platform]}:${item.PlatformId}`
|
|
174
|
-
}))
|
|
175
|
-
|
|
176
|
-
const { config, status } = await inquirer.prompt([
|
|
177
|
-
{
|
|
178
|
-
type: 'list',
|
|
179
|
-
name: 'config',
|
|
180
|
-
choices: configChoices,
|
|
181
|
-
message: '请选择需要配置的条目:'
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
type: 'list',
|
|
185
|
-
name: 'status',
|
|
186
|
-
choices: [
|
|
187
|
-
{
|
|
188
|
-
name: '启用',
|
|
189
|
-
value: 'ENABLE'
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
name: '禁用',
|
|
193
|
-
value: 'DISABLE'
|
|
194
|
-
}
|
|
195
|
-
],
|
|
196
|
-
message: '请选择登录方式状态:',
|
|
197
|
-
default: '启用'
|
|
198
|
-
}
|
|
199
|
-
])
|
|
200
|
-
|
|
201
|
-
const platform = config.Platform
|
|
202
|
-
|
|
203
|
-
let appId
|
|
204
|
-
let appSecret
|
|
205
|
-
|
|
206
|
-
if (platform === 'WECHAT-OPEN' || platform === 'WECHAT-PUBLIC') {
|
|
207
|
-
const input = await inquirer.prompt([
|
|
208
|
-
{
|
|
209
|
-
type: 'input',
|
|
210
|
-
name: 'appId',
|
|
211
|
-
message: '请输入 AppId(配置状态时可不填):'
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
type: 'input',
|
|
215
|
-
name: 'appSecret',
|
|
216
|
-
message: '请输入 AppSecret(配置状态时可不填):'
|
|
217
|
-
}
|
|
218
|
-
])
|
|
219
|
-
|
|
220
|
-
appId = input?.appId
|
|
221
|
-
appSecret = input?.appSecret
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// 检查平台配置是否存在,若存在则更新配置,否则创建配置
|
|
225
|
-
await updateLoginConfig({
|
|
226
|
-
envId,
|
|
227
|
-
configId: config.Id,
|
|
228
|
-
appId,
|
|
229
|
-
appSecret,
|
|
230
|
-
status
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
log.success('更新登录方式成功!')
|
|
234
|
-
}
|
|
235
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { run } from '@cloudbase/framework-core'
|
|
2
|
-
import { Command, ICommand } from '../common'
|
|
3
|
-
import { ICommandContext } from '../../types'
|
|
4
|
-
import { InjectParams, CmdContext, ArgsParams, Log, Logger, ArgsOptions } from '../../decorators'
|
|
5
|
-
|
|
6
|
-
import * as Hosting from '../../hosting'
|
|
7
|
-
import * as Function from '../../function'
|
|
8
|
-
import { authSupevisor } from '../../utils'
|
|
9
|
-
|
|
10
|
-
async function callFramework(ctx, command, module, params?) {
|
|
11
|
-
const { envId, config } = ctx
|
|
12
|
-
const { bumpVersion, versionRemark } = ctx.options
|
|
13
|
-
|
|
14
|
-
const loginState = await authSupevisor.getLoginState()
|
|
15
|
-
const { token, secretId, secretKey } = loginState
|
|
16
|
-
|
|
17
|
-
await run(
|
|
18
|
-
{
|
|
19
|
-
projectPath: process.cwd(),
|
|
20
|
-
cloudbaseConfig: {
|
|
21
|
-
secretId,
|
|
22
|
-
secretKey,
|
|
23
|
-
token,
|
|
24
|
-
envId
|
|
25
|
-
},
|
|
26
|
-
config,
|
|
27
|
-
logLevel: process.argv.includes('--verbose') ? 'debug' : 'info',
|
|
28
|
-
resourceProviders: {
|
|
29
|
-
hosting: Hosting,
|
|
30
|
-
function: Function
|
|
31
|
-
},
|
|
32
|
-
bumpVersion: Boolean(bumpVersion),
|
|
33
|
-
versionRemark
|
|
34
|
-
},
|
|
35
|
-
command,
|
|
36
|
-
module,
|
|
37
|
-
params
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@ICommand()
|
|
42
|
-
export class FrameworkDeploy extends Command {
|
|
43
|
-
get options() {
|
|
44
|
-
return {
|
|
45
|
-
cmd: 'framework',
|
|
46
|
-
childCmd: 'deploy [module]',
|
|
47
|
-
deprecateCmd: 'framework:deploy [module]',
|
|
48
|
-
options: [
|
|
49
|
-
{
|
|
50
|
-
flags: '-e, --envId <envId>',
|
|
51
|
-
desc: '环境 Id'
|
|
52
|
-
},
|
|
53
|
-
{ flags: '--verbose', desc: '是否打印详细日志' }
|
|
54
|
-
],
|
|
55
|
-
desc: '云开发 Serverless 应用框架:部署全栈应用'
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@InjectParams()
|
|
60
|
-
async execute(@CmdContext() ctx: ICommandContext, @Log() logger: Logger, @ArgsParams() params) {
|
|
61
|
-
const [module] = params || []
|
|
62
|
-
await callFramework(ctx, 'deploy', module)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@ICommand()
|
|
67
|
-
export class FrameworkCompile extends Command {
|
|
68
|
-
get options() {
|
|
69
|
-
return {
|
|
70
|
-
cmd: 'framework',
|
|
71
|
-
childCmd: 'compile [module]',
|
|
72
|
-
deprecateCmd: 'framework:compile [module]',
|
|
73
|
-
options: [
|
|
74
|
-
{
|
|
75
|
-
flags: '-e, --envId <envId>',
|
|
76
|
-
desc: '环境 Id'
|
|
77
|
-
},
|
|
78
|
-
{ flags: '--verbose', desc: '是否打印详细日志' },
|
|
79
|
-
{ flags: '--bumpVersion', desc: '是否生成新版本' },
|
|
80
|
-
{
|
|
81
|
-
flags: '--versionRemark <versionRemark>',
|
|
82
|
-
desc: '新版本描述信息'
|
|
83
|
-
}
|
|
84
|
-
],
|
|
85
|
-
desc: '云开发 Serverless 应用框架:编译应用描述文件'
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@InjectParams()
|
|
90
|
-
async execute(@CmdContext() ctx: ICommandContext, @Log() logger: Logger, @ArgsParams() params) {
|
|
91
|
-
const [module] = params || []
|
|
92
|
-
await callFramework(ctx, 'compile', module)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@ICommand()
|
|
97
|
-
export class FrameworkRun extends Command {
|
|
98
|
-
get options() {
|
|
99
|
-
return {
|
|
100
|
-
cmd: 'framework',
|
|
101
|
-
childCmd: 'run [command]',
|
|
102
|
-
deprecateCmd: 'framework:run [command]',
|
|
103
|
-
options: [
|
|
104
|
-
{
|
|
105
|
-
flags: '-e, --envId <envId>',
|
|
106
|
-
desc: '环境 Id'
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
flags: '--plugin <plugin>',
|
|
110
|
-
desc: '执行命令的插件'
|
|
111
|
-
}
|
|
112
|
-
],
|
|
113
|
-
desc: '云开发 Serverless 应用框架:执行自定义命令'
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
@InjectParams()
|
|
118
|
-
async execute(@CmdContext() ctx: ICommandContext, @Log() logger: Logger, @ArgsParams() params, @ArgsOptions() options) {
|
|
119
|
-
const [command] = params || []
|
|
120
|
-
const { plugin } = options
|
|
121
|
-
|
|
122
|
-
await callFramework(ctx, 'run', plugin, { runCommandKey: command })
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Command, ICommand } from '../../common'
|
|
3
|
-
import { loadingFactory, printHorizontalTable } from '../../../utils'
|
|
4
|
-
import { getFunctionAliasConfig } from '../../../function'
|
|
5
|
-
import { InjectParams, CmdContext, ArgsParams, ArgsOptions } from '../../../decorators'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function parseRoutingConfigValue(expression: string) {
|
|
9
|
-
const commaIndex = expression.indexOf(',')
|
|
10
|
-
const valueExpression = expression.substring(commaIndex + 1, expression.length - 1)
|
|
11
|
-
return valueExpression
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@ICommand()
|
|
15
|
-
export class getFunctionRoutingConfig extends Command {
|
|
16
|
-
get options() {
|
|
17
|
-
return {
|
|
18
|
-
cmd: 'fn',
|
|
19
|
-
childCmd: 'get-route <name>',
|
|
20
|
-
options: [
|
|
21
|
-
{
|
|
22
|
-
flags: '-e, --envId <envId>',
|
|
23
|
-
desc: '环境 Id'
|
|
24
|
-
}
|
|
25
|
-
],
|
|
26
|
-
desc: '查看函数版本流量配置'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@InjectParams()
|
|
31
|
-
async execute(@CmdContext() ctx, @ArgsParams() params) {
|
|
32
|
-
const name = params?.[0]
|
|
33
|
-
|
|
34
|
-
const {
|
|
35
|
-
envId
|
|
36
|
-
} = ctx
|
|
37
|
-
|
|
38
|
-
const loading = loadingFactory()
|
|
39
|
-
loading.start(`查询函数 [${name}] 版本流量配置中...`)
|
|
40
|
-
|
|
41
|
-
const aliasRes = await getFunctionAliasConfig({
|
|
42
|
-
envId,
|
|
43
|
-
functionName: name,
|
|
44
|
-
name: '$DEFAULT'
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
const routingConfig = aliasRes?.RoutingConfig?.AddtionVersionMatchs
|
|
48
|
-
let finalConfig = []
|
|
49
|
-
if (routingConfig.length === 1) {
|
|
50
|
-
finalConfig.push({
|
|
51
|
-
version: routingConfig[0].Version,
|
|
52
|
-
value: parseRoutingConfigValue(routingConfig[0].Expression)
|
|
53
|
-
})
|
|
54
|
-
} else if (routingConfig.length === 2) {
|
|
55
|
-
finalConfig.push({
|
|
56
|
-
version: routingConfig[0].Version,
|
|
57
|
-
value: parseRoutingConfigValue(routingConfig[0].Expression)
|
|
58
|
-
}, {
|
|
59
|
-
version: routingConfig[1].Version,
|
|
60
|
-
value: 100 - Number(parseRoutingConfigValue(routingConfig[0].Expression))
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
loading.stop()
|
|
65
|
-
|
|
66
|
-
const head: string[] = ['版本', '流量比例']
|
|
67
|
-
|
|
68
|
-
const tableData = finalConfig.map((item) => [
|
|
69
|
-
item.version,
|
|
70
|
-
item.value
|
|
71
|
-
])
|
|
72
|
-
|
|
73
|
-
printHorizontalTable(head, tableData)
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
}
|