@cloudbase/cli 2.10.0 → 2.11.0-beta.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/lib/auth/login.js +51 -65
- package/lib/auth/logout.js +3 -14
- package/lib/commands/account/login.js +136 -149
- package/lib/commands/account/logout.js +3 -14
- package/lib/commands/ag/base.js +203 -0
- package/lib/commands/ag/create.js +301 -0
- package/lib/commands/ag/debug/index.html +699 -0
- package/lib/commands/ag/delete.js +200 -0
- package/lib/commands/ag/deploy.js +185 -0
- package/lib/commands/ag/detail.js +113 -0
- package/lib/commands/ag/index.js +22 -0
- package/lib/commands/ag/list.js +155 -0
- package/lib/commands/ag/run.js +644 -0
- package/lib/commands/ai/index.js +76 -95
- package/lib/commands/cloudfunction/base.js +182 -203
- package/lib/commands/cloudrun/base.js +578 -603
- package/lib/commands/common.js +48 -63
- package/lib/commands/config/delete.js +16 -27
- package/lib/commands/config/get.js +13 -24
- package/lib/commands/config/list.js +16 -27
- package/lib/commands/config/set.js +33 -44
- package/lib/commands/db/base.js +221 -240
- package/lib/commands/env/base.js +36 -49
- package/lib/commands/env/domain.js +79 -94
- package/lib/commands/env/login.js +120 -135
- package/lib/commands/framework/index.js +32 -49
- package/lib/commands/fun/base.js +223 -244
- package/lib/commands/functions/alias/getRoute.js +33 -44
- package/lib/commands/functions/alias/setRoute.js +36 -47
- package/lib/commands/functions/code-download.js +43 -54
- package/lib/commands/functions/code-update.js +23 -34
- package/lib/commands/functions/concurrency/delete.js +11 -22
- package/lib/commands/functions/concurrency/list.js +20 -31
- package/lib/commands/functions/concurrency/set.js +13 -24
- package/lib/commands/functions/config-update.js +30 -41
- package/lib/commands/functions/copy.js +12 -23
- package/lib/commands/functions/delete.js +30 -41
- package/lib/commands/functions/deploy.js +184 -202
- package/lib/commands/functions/detail.js +23 -34
- package/lib/commands/functions/invoke.js +69 -75
- package/lib/commands/functions/layer/bind.js +102 -105
- package/lib/commands/functions/layer/create.js +29 -35
- package/lib/commands/functions/layer/delete.js +42 -48
- package/lib/commands/functions/layer/download.js +52 -58
- package/lib/commands/functions/layer/list.js +44 -50
- package/lib/commands/functions/layer/sort.js +39 -45
- package/lib/commands/functions/list.js +25 -36
- package/lib/commands/functions/log.js +65 -73
- package/lib/commands/functions/run.js +118 -116
- package/lib/commands/functions/trigger-create.js +32 -43
- package/lib/commands/functions/trigger-delete.js +50 -61
- package/lib/commands/functions/version/list.js +29 -40
- package/lib/commands/functions/version/publish.js +11 -22
- package/lib/commands/gateway/create.js +50 -61
- package/lib/commands/gateway/delete.js +38 -49
- package/lib/commands/gateway/domain.js +65 -80
- package/lib/commands/gateway/list.js +31 -42
- package/lib/commands/gateway/switch.js +48 -61
- package/lib/commands/helpers/init.js +226 -249
- package/lib/commands/helpers/new.js +35 -46
- package/lib/commands/helpers/open.js +22 -33
- package/lib/commands/hosting/hosting.js +157 -178
- package/lib/commands/index.js +1 -0
- package/lib/commands/lowcode/app.js +114 -144
- package/lib/commands/lowcode/comps.js +136 -127
- package/lib/commands/lowcode/utils.js +11 -22
- package/lib/commands/pull/pull.js +33 -46
- package/lib/commands/run/delete.js +35 -46
- package/lib/commands/run/image/delete.js +32 -39
- package/lib/commands/run/image/download.js +26 -33
- package/lib/commands/run/image/list.js +41 -48
- package/lib/commands/run/image/upload.js +26 -33
- package/lib/commands/run/list.js +32 -43
- package/lib/commands/run/service/config.js +17 -28
- package/lib/commands/run/service/deploy.js +15 -26
- package/lib/commands/run/service/list.js +48 -59
- package/lib/commands/run/service/update.js +7 -18
- package/lib/commands/run/standalonegateway/create.js +35 -42
- package/lib/commands/run/standalonegateway/destroy.js +23 -30
- package/lib/commands/run/standalonegateway/list.js +19 -26
- package/lib/commands/run/standalonegateway/package.js +31 -38
- package/lib/commands/run/standalonegateway/turn.js +27 -34
- package/lib/commands/run/version/create.js +198 -205
- package/lib/commands/run/version/delete.js +31 -38
- package/lib/commands/run/version/list.js +42 -49
- package/lib/commands/run/version/modify.js +27 -34
- package/lib/commands/run/version/update.js +201 -208
- package/lib/commands/runf/base.js +216 -237
- package/lib/commands/self-update.js +59 -72
- package/lib/commands/smart.js +66 -79
- package/lib/commands/storage/storage.js +192 -219
- package/lib/commands/third/thirdAttach.js +16 -27
- package/lib/commands/utils.js +119 -149
- package/lib/db/index.js +48 -67
- package/lib/decorators/captureError.js +10 -21
- package/lib/decorators/guard.js +11 -22
- package/lib/decorators/injectParams.js +29 -40
- package/lib/decorators/params/common.js +5 -2
- package/lib/decorators/params/index.js +3 -12
- package/lib/env/domain.js +13 -28
- package/lib/env/index.js +25 -44
- package/lib/env/login.js +30 -45
- package/lib/function/alias.js +31 -44
- package/lib/function/base.js +187 -215
- package/lib/function/code.js +8 -19
- package/lib/function/concurrency.js +43 -58
- package/lib/function/create.js +43 -53
- package/lib/function/delete.js +22 -35
- package/lib/function/layer/attach.js +33 -46
- package/lib/function/layer/create.js +34 -45
- package/lib/function/layer/delete.js +5 -16
- package/lib/function/layer/download.js +11 -22
- package/lib/function/layer/list.js +12 -25
- package/lib/function/layer/sort.js +6 -17
- package/lib/function/trigger.js +65 -82
- package/lib/function/update.js +24 -32
- package/lib/function/version.js +29 -42
- package/lib/function/vpc.js +12 -25
- package/lib/gateway/index.js +77 -104
- package/lib/hosting.js +157 -188
- package/lib/run/delete.js +3 -12
- package/lib/run/image/build.js +6 -15
- package/lib/run/image/delete.js +3 -12
- package/lib/run/image/info.js +3 -12
- package/lib/run/image/list.js +6 -15
- package/lib/run/list.js +19 -30
- package/lib/run/repo.js +6 -15
- package/lib/run/service/common.js +160 -173
- package/lib/run/service/config.js +44 -57
- package/lib/run/service/deployPackage.js +33 -44
- package/lib/run/service/list.js +8 -14
- package/lib/run/service/showLogs.js +69 -90
- package/lib/run/service/update.js +50 -63
- package/lib/run/standalonegateway/create.js +3 -12
- package/lib/run/standalonegateway/destroy.js +3 -12
- package/lib/run/standalonegateway/list.js +3 -12
- package/lib/run/standalonegateway/package/list.js +3 -12
- package/lib/run/standalonegateway/turn/off.js +3 -12
- package/lib/run/standalonegateway/turn/on.js +3 -12
- package/lib/run/version/create.js +41 -31
- package/lib/run/version/delete.js +3 -12
- package/lib/run/version/list.js +3 -12
- package/lib/run/version/modify.js +3 -12
- package/lib/run/version/repo.js +6 -15
- package/lib/run/version/update.js +37 -26
- package/lib/storage.js +62 -93
- package/lib/third/index.js +6 -17
- package/lib/utils/ai/banner.js +49 -60
- package/lib/utils/ai/claudeWindows.js +2 -2
- package/lib/utils/ai/config.js +169 -206
- package/lib/utils/ai/ensureFiles.js +6 -17
- package/lib/utils/ai/env.js +16 -27
- package/lib/utils/ai/envLocalManager.js +35 -52
- package/lib/utils/ai/router.js +927 -1005
- package/lib/utils/ai/setup.js +527 -563
- package/lib/utils/auth.js +3 -14
- package/lib/utils/checkTcbrEnv.js +20 -31
- package/lib/utils/cli-table.js +6 -1
- package/lib/utils/config.js +4 -13
- package/lib/utils/dts.js +98 -113
- package/lib/utils/env.js +154 -175
- package/lib/utils/function-packer.js +29 -42
- package/lib/utils/log.js +10 -21
- package/lib/utils/mcp-config-modifier.js +105 -120
- package/lib/utils/net/cloud-api-request.js +15 -23
- package/lib/utils/net/credential.js +26 -39
- package/lib/utils/net/http-request.js +63 -80
- package/lib/utils/net/manager-service.js +22 -35
- package/lib/utils/notice.js +16 -27
- package/lib/utils/output/loading.js +3 -12
- package/lib/utils/parallel.js +32 -43
- package/lib/utils/platform/mac.js +4 -15
- package/lib/utils/platform/port.js +4 -15
- package/lib/utils/prompt/select.js +6 -15
- package/lib/utils/report.js +28 -33
- package/lib/utils/reporter/agree.js +11 -22
- package/lib/utils/reporter/download.js +17 -28
- package/lib/utils/reporter/usage.js +12 -23
- package/lib/utils/store/auth.js +17 -30
- package/lib/utils/store/config.js +11 -25
- package/lib/utils/store/db.js +17 -36
- package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
- package/lib/utils/template-manager.js +215 -242
- package/lib/utils/template.js +81 -96
- package/lib/utils/tools/common.js +45 -56
- package/lib/utils/tools/time.js +5 -16
- package/lib/utils/url.js +10 -4
- package/package.json +2 -2
- package/specs/ag-command/design.md +421 -0
- package/specs/ag-command/doc.md +204 -0
- package/specs/ag-command/requirements.md +173 -0
- package/specs/ag-command/summary.md +174 -0
- package/specs/ag-command/tasks.md +197 -0
- package/specs/ag-command/usage-guide.md +420 -0
- package/tsconfig.json +1 -1
- package/types/commands/ag/base.d.ts +44 -0
- package/types/commands/ag/create.d.ts +25 -0
- package/types/commands/ag/delete.d.ts +32 -0
- package/types/commands/ag/deploy.d.ts +31 -0
- package/types/commands/ag/detail.d.ts +28 -0
- package/types/commands/ag/index.d.ts +6 -0
- package/types/commands/ag/list.d.ts +35 -0
- package/types/commands/ag/run.d.ts +52 -0
- package/types/commands/cloudrun/base.d.ts +10 -0
- package/types/commands/index.d.ts +1 -0
|
@@ -5,15 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
8
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
10
|
};
|
|
@@ -40,33 +31,31 @@ let SelfUpdateCommand = class SelfUpdateCommand extends common_1.Command {
|
|
|
40
31
|
]
|
|
41
32
|
};
|
|
42
33
|
}
|
|
43
|
-
execute(ctx) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
installerCmd = `${installer}`;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
installerCmd = `bash -c "curl -fsSL ${base}/install | bash"`;
|
|
58
|
-
}
|
|
59
|
-
const env = [
|
|
60
|
-
`DOWNLOAD_BASE=${base}`,
|
|
61
|
-
`CHANNEL=${channel}`,
|
|
62
|
-
`VERSION=${version}`
|
|
63
|
-
].join(' ');
|
|
64
|
-
(0, child_process_1.execSync)(`${env} ${installerCmd}`, { stdio: 'inherit' });
|
|
34
|
+
async execute(ctx) {
|
|
35
|
+
const version = ctx.options.version || 'latest';
|
|
36
|
+
const channel = ctx.options.channel || 'stable';
|
|
37
|
+
const base = ctx.options.downloadBase || process.env.DOWNLOAD_BASE || 'https://static.cloudbase.net/cli';
|
|
38
|
+
const home = os_1.default.homedir();
|
|
39
|
+
const root = path_1.default.join(home, '.local/share/cloudbase-cli');
|
|
40
|
+
const installer = path_1.default.join(root, 'current', 'install.sh');
|
|
41
|
+
let installerCmd;
|
|
42
|
+
try {
|
|
43
|
+
if (fs_1.default.existsSync(installer)) {
|
|
44
|
+
installerCmd = `${installer}`;
|
|
65
45
|
}
|
|
66
|
-
|
|
67
|
-
|
|
46
|
+
else {
|
|
47
|
+
installerCmd = `bash -c "curl -fsSL ${base}/install | bash"`;
|
|
68
48
|
}
|
|
69
|
-
|
|
49
|
+
const env = [
|
|
50
|
+
`DOWNLOAD_BASE=${base}`,
|
|
51
|
+
`CHANNEL=${channel}`,
|
|
52
|
+
`VERSION=${version}`
|
|
53
|
+
].join(' ');
|
|
54
|
+
(0, child_process_1.execSync)(`${env} ${installerCmd}`, { stdio: 'inherit' });
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('自更新失败:{{error}}', { error: (e === null || e === void 0 ? void 0 : e.message) || e }));
|
|
58
|
+
}
|
|
70
59
|
}
|
|
71
60
|
};
|
|
72
61
|
SelfUpdateCommand = __decorate([
|
|
@@ -83,49 +72,47 @@ let RollbackCommand = class RollbackCommand extends common_1.Command {
|
|
|
83
72
|
options: []
|
|
84
73
|
};
|
|
85
74
|
}
|
|
86
|
-
execute() {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const link = path_1.default.join(binDir, name);
|
|
112
|
-
try {
|
|
113
|
-
fs_1.default.unlinkSync(link);
|
|
114
|
-
}
|
|
115
|
-
catch (_) { }
|
|
116
|
-
fs_1.default.symlinkSync(path_1.default.join(targetDir, rel), link);
|
|
117
|
-
}
|
|
75
|
+
async execute() {
|
|
76
|
+
const home = os_1.default.homedir();
|
|
77
|
+
const root = path_1.default.join(home, '.local/share/cloudbase-cli');
|
|
78
|
+
const versionsDir = path_1.default.join(root, 'versions');
|
|
79
|
+
if (!fs_1.default.existsSync(versionsDir)) {
|
|
80
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('未找到已安装版本目录,无法回滚'));
|
|
81
|
+
}
|
|
82
|
+
const entries = fs_1.default.readdirSync(versionsDir)
|
|
83
|
+
.filter((n) => !n.startsWith('.') && fs_1.default.statSync(path_1.default.join(versionsDir, n)).isDirectory())
|
|
84
|
+
.sort();
|
|
85
|
+
if (entries.length < 2) {
|
|
86
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('没有可回滚的历史版本'));
|
|
87
|
+
}
|
|
88
|
+
const target = entries[entries.length - 2];
|
|
89
|
+
const currentLink = path_1.default.join(root, 'current');
|
|
90
|
+
try {
|
|
91
|
+
const binDir = path_1.default.join(os_1.default.homedir(), '.local/bin');
|
|
92
|
+
const targetDir = path_1.default.join(versionsDir, target);
|
|
93
|
+
const map = [
|
|
94
|
+
['cloudbase', 'bin/cloudbase'],
|
|
95
|
+
['tcb', 'bin/tcb'],
|
|
96
|
+
['cloudbase-mcp', 'bin/cloudbase-mcp']
|
|
97
|
+
];
|
|
98
|
+
for (const [name, rel] of map) {
|
|
99
|
+
const link = path_1.default.join(binDir, name);
|
|
118
100
|
try {
|
|
119
|
-
fs_1.default.unlinkSync(
|
|
101
|
+
fs_1.default.unlinkSync(link);
|
|
120
102
|
}
|
|
121
103
|
catch (_) { }
|
|
122
|
-
fs_1.default.symlinkSync(targetDir,
|
|
123
|
-
console.log((0, i18n_1.t)('已回滚到版本: {{version}}', { version: target }));
|
|
104
|
+
fs_1.default.symlinkSync(path_1.default.join(targetDir, rel), link);
|
|
124
105
|
}
|
|
125
|
-
|
|
126
|
-
|
|
106
|
+
try {
|
|
107
|
+
fs_1.default.unlinkSync(currentLink);
|
|
127
108
|
}
|
|
128
|
-
|
|
109
|
+
catch (_) { }
|
|
110
|
+
fs_1.default.symlinkSync(targetDir, currentLink);
|
|
111
|
+
console.log((0, i18n_1.t)('已回滚到版本: {{version}}', { version: target }));
|
|
112
|
+
}
|
|
113
|
+
catch (e) {
|
|
114
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('回滚失败:{{error}}', { error: (e === null || e === void 0 ? void 0 : e.message) || e }));
|
|
115
|
+
}
|
|
129
116
|
}
|
|
130
117
|
};
|
|
131
118
|
RollbackCommand = __decorate([
|
package/lib/commands/smart.js
CHANGED
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
27
|
};
|
|
@@ -48,77 +39,73 @@ const Hosting = __importStar(require("../hosting"));
|
|
|
48
39
|
const Function = __importStar(require("../function"));
|
|
49
40
|
const auth_1 = require("../auth");
|
|
50
41
|
const i18n_1 = require("../i18n");
|
|
51
|
-
function smartDeploy() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
initial: true
|
|
79
|
-
});
|
|
80
|
-
if (!setup) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const config = yield (0, utils_1.getCloudBaseConfig)();
|
|
84
|
-
let envId = config === null || config === void 0 ? void 0 : config.envId;
|
|
85
|
-
if (!(config === null || config === void 0 ? void 0 : config.region) && !region) {
|
|
86
|
-
region = yield (0, utils_1.getSelectRegion)();
|
|
87
|
-
}
|
|
88
|
-
if (!envId) {
|
|
89
|
-
envId = yield (0, utils_1.getSelectedEnv)();
|
|
90
|
-
fs_1.default.writeFileSync(path_1.default.join(process.cwd(), 'cloudbaserc.json'), JSON.stringify({
|
|
91
|
-
envId,
|
|
92
|
-
region,
|
|
93
|
-
version: '2.0',
|
|
94
|
-
$schema: 'https://framework-1258016615.tcloudbaseapp.com/schema/latest.json'
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
97
|
-
const parser = new toolbox_1.ConfigParser();
|
|
98
|
-
parser.update('region', region);
|
|
99
|
-
yield callFramework(envId);
|
|
42
|
+
async function smartDeploy() {
|
|
43
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
44
|
+
loading.start((0, i18n_1.t)('环境检测中'));
|
|
45
|
+
await (0, auth_1.checkLogin)();
|
|
46
|
+
await (0, utils_1.checkTcbService)();
|
|
47
|
+
const files = fs_1.default.readdirSync(process.cwd());
|
|
48
|
+
loading.stop();
|
|
49
|
+
const home = os_1.default.homedir();
|
|
50
|
+
const current = process.cwd();
|
|
51
|
+
let relative = current;
|
|
52
|
+
if (current.indexOf(home) > -1) {
|
|
53
|
+
relative = path_1.default.relative(home, current);
|
|
54
|
+
}
|
|
55
|
+
let region = await (0, toolbox_1.getRegion)(true);
|
|
56
|
+
if (!files.length) {
|
|
57
|
+
utils_1.logger.info((0, i18n_1.t)('当前目录为空,初始化云开发项目\n'));
|
|
58
|
+
region = await (0, utils_1.getSelectRegion)();
|
|
59
|
+
const envId = await (0, utils_1.getSelectedEnv)();
|
|
60
|
+
const projectPath = await (0, utils_1.downloadTemplate)();
|
|
61
|
+
await (0, utils_1.initProjectConfig)(envId, region, projectPath);
|
|
62
|
+
utils_1.logger.success((0, i18n_1.t)('初始化项目成功!\n'));
|
|
63
|
+
}
|
|
64
|
+
const { setup } = await (0, enquirer_1.prompt)({
|
|
65
|
+
type: 'confirm',
|
|
66
|
+
name: 'setup',
|
|
67
|
+
message: (0, i18n_1.t)('是否使用云开发部署当前项目 <{{path}}> ?', { path: chalk_1.default.bold.cyan(relative) }),
|
|
68
|
+
initial: true
|
|
100
69
|
});
|
|
70
|
+
if (!setup) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const config = await (0, utils_1.getCloudBaseConfig)();
|
|
74
|
+
let envId = config === null || config === void 0 ? void 0 : config.envId;
|
|
75
|
+
if (!(config === null || config === void 0 ? void 0 : config.region) && !region) {
|
|
76
|
+
region = await (0, utils_1.getSelectRegion)();
|
|
77
|
+
}
|
|
78
|
+
if (!envId) {
|
|
79
|
+
envId = await (0, utils_1.getSelectedEnv)();
|
|
80
|
+
fs_1.default.writeFileSync(path_1.default.join(process.cwd(), 'cloudbaserc.json'), JSON.stringify({
|
|
81
|
+
envId,
|
|
82
|
+
region,
|
|
83
|
+
version: '2.0',
|
|
84
|
+
$schema: 'https://framework-1258016615.tcloudbaseapp.com/schema/latest.json'
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
const parser = new toolbox_1.ConfigParser();
|
|
88
|
+
parser.update('region', region);
|
|
89
|
+
await callFramework(envId);
|
|
101
90
|
}
|
|
102
91
|
exports.smartDeploy = smartDeploy;
|
|
103
|
-
function callFramework(envId) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}, 'deploy', '');
|
|
123
|
-
});
|
|
92
|
+
async function callFramework(envId) {
|
|
93
|
+
const loginState = await utils_1.authSupevisor.getLoginState();
|
|
94
|
+
const { token, secretId, secretKey } = loginState;
|
|
95
|
+
const config = await (0, utils_1.getCloudBaseConfig)();
|
|
96
|
+
await (0, framework_core_1.run)({
|
|
97
|
+
projectPath: process.cwd(),
|
|
98
|
+
cloudbaseConfig: {
|
|
99
|
+
secretId,
|
|
100
|
+
secretKey,
|
|
101
|
+
token,
|
|
102
|
+
envId
|
|
103
|
+
},
|
|
104
|
+
config,
|
|
105
|
+
logLevel: process.argv.includes('--verbose') ? 'debug' : 'info',
|
|
106
|
+
resourceProviders: {
|
|
107
|
+
hosting: Hosting,
|
|
108
|
+
function: Function
|
|
109
|
+
}
|
|
110
|
+
}, 'deploy', '');
|
|
124
111
|
}
|