@cloudbase/cli 2.10.0-beta.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
package/lib/utils/notice.js
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getNotification = void 0;
|
|
13
4
|
const net_1 = require("./net");
|
|
14
5
|
const store_1 = require("./store");
|
|
15
6
|
const url = 'https://tcli.service.tcloudbase.com/notify';
|
|
16
7
|
const ONE_DAY = 86400000;
|
|
17
|
-
function getNotification() {
|
|
18
|
-
return
|
|
8
|
+
async function getNotification() {
|
|
9
|
+
return null;
|
|
10
|
+
const now = Date.now();
|
|
11
|
+
const lastTime = await store_1.commonStore.get('lastNotifyTime');
|
|
12
|
+
const diff = now - Number(lastTime);
|
|
13
|
+
const day = new Date(lastTime).getDay();
|
|
14
|
+
const today = new Date().getDay();
|
|
15
|
+
if (day === today && diff < ONE_DAY)
|
|
19
16
|
return null;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const data = yield (0, net_1.postFetch)(url);
|
|
29
|
-
const uid = (data === null || data === void 0 ? void 0 : data.uid) || 0;
|
|
30
|
-
if (Number(lastUid) >= Number(uid))
|
|
31
|
-
return;
|
|
32
|
-
yield store_1.commonStore.set('readNotificationUid', data.uid);
|
|
33
|
-
yield store_1.commonStore.set('lastNotifyTime', Date.now());
|
|
34
|
-
return data;
|
|
35
|
-
});
|
|
17
|
+
const lastUid = await store_1.commonStore.get('lastNotificationUid');
|
|
18
|
+
const data = await (0, net_1.postFetch)(url);
|
|
19
|
+
const uid = (data === null || data === void 0 ? void 0 : data.uid) || 0;
|
|
20
|
+
if (Number(lastUid) >= Number(uid))
|
|
21
|
+
return;
|
|
22
|
+
await store_1.commonStore.set('readNotificationUid', data.uid);
|
|
23
|
+
await store_1.commonStore.set('lastNotifyTime', Date.now());
|
|
24
|
+
return data;
|
|
36
25
|
}
|
|
37
26
|
exports.getNotification = getNotification;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -48,7 +39,7 @@ const loadingFactory = () => {
|
|
|
48
39
|
return new Loading();
|
|
49
40
|
};
|
|
50
41
|
exports.loadingFactory = loadingFactory;
|
|
51
|
-
const execWithLoading = (task, options = {}) =>
|
|
42
|
+
const execWithLoading = async (task, options = {}) => {
|
|
52
43
|
const { startTip, successTip, failTip } = options;
|
|
53
44
|
const loading = (0, exports.loadingFactory)();
|
|
54
45
|
const flush = (text) => {
|
|
@@ -56,7 +47,7 @@ const execWithLoading = (task, options = {}) => __awaiter(void 0, void 0, void 0
|
|
|
56
47
|
};
|
|
57
48
|
try {
|
|
58
49
|
loading.start(startTip);
|
|
59
|
-
const res =
|
|
50
|
+
const res = await task(flush);
|
|
60
51
|
successTip ? loading.succeed(successTip) : loading.stop();
|
|
61
52
|
return res;
|
|
62
53
|
}
|
|
@@ -64,5 +55,5 @@ const execWithLoading = (task, options = {}) => __awaiter(void 0, void 0, void 0
|
|
|
64
55
|
failTip ? loading.fail(failTip) : loading.stop();
|
|
65
56
|
throw e;
|
|
66
57
|
}
|
|
67
|
-
}
|
|
58
|
+
};
|
|
68
59
|
exports.execWithLoading = execWithLoading;
|
package/lib/utils/parallel.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.AsyncTaskParallelController = void 0;
|
|
13
4
|
class AsyncTaskParallelController {
|
|
@@ -24,41 +15,39 @@ class AsyncTaskParallelController {
|
|
|
24
15
|
this.tasks.push(task);
|
|
25
16
|
this.totalTasks = this.tasks.length;
|
|
26
17
|
}
|
|
27
|
-
run() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
18
|
+
async run() {
|
|
19
|
+
const results = [];
|
|
20
|
+
const taskHasRun = [];
|
|
21
|
+
const taskDone = [];
|
|
22
|
+
let runningTask = 0;
|
|
23
|
+
return new Promise((resolve) => {
|
|
24
|
+
const timer = setInterval(() => {
|
|
25
|
+
const taskDoneLength = taskDone.filter((item) => item).length;
|
|
26
|
+
if (runningTask === 0 && taskDoneLength === this.totalTasks) {
|
|
27
|
+
clearInterval(timer);
|
|
28
|
+
resolve(results);
|
|
29
|
+
}
|
|
30
|
+
if (runningTask >= this.maxParallel) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.tasks.forEach((task, index) => {
|
|
34
|
+
if (!taskHasRun[index] && runningTask < this.maxParallel) {
|
|
35
|
+
runningTask++;
|
|
36
|
+
taskHasRun[index] = 1;
|
|
37
|
+
task()
|
|
38
|
+
.then((res) => {
|
|
39
|
+
results[index] = res;
|
|
40
|
+
})
|
|
41
|
+
.catch((err) => {
|
|
42
|
+
results[index] = err;
|
|
43
|
+
})
|
|
44
|
+
.then(() => {
|
|
45
|
+
runningTask--;
|
|
46
|
+
taskDone[index] = 1;
|
|
47
|
+
});
|
|
39
48
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
this.tasks.forEach((task, index) => {
|
|
44
|
-
if (!taskHasRun[index] && runningTask < this.maxParallel) {
|
|
45
|
-
runningTask++;
|
|
46
|
-
taskHasRun[index] = 1;
|
|
47
|
-
task()
|
|
48
|
-
.then((res) => {
|
|
49
|
-
results[index] = res;
|
|
50
|
-
})
|
|
51
|
-
.catch((err) => {
|
|
52
|
-
results[index] = err;
|
|
53
|
-
})
|
|
54
|
-
.then(() => {
|
|
55
|
-
runningTask--;
|
|
56
|
-
taskDone[index] = 1;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}, this.checkInterval);
|
|
61
|
-
});
|
|
49
|
+
});
|
|
50
|
+
}, this.checkInterval);
|
|
62
51
|
});
|
|
63
52
|
}
|
|
64
53
|
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -27,11 +18,9 @@ function getMacAddress() {
|
|
|
27
18
|
});
|
|
28
19
|
}
|
|
29
20
|
exports.getMacAddress = getMacAddress;
|
|
30
|
-
function getMacAddressMd5() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return macMD5;
|
|
35
|
-
});
|
|
21
|
+
async function getMacAddressMd5() {
|
|
22
|
+
const mac = await getMacAddress();
|
|
23
|
+
const macMD5 = (0, tools_1.md5)(mac);
|
|
24
|
+
return macMD5;
|
|
36
25
|
}
|
|
37
26
|
exports.getMacAddressMd5 = getMacAddressMd5;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -15,12 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
6
|
exports.getPort = void 0;
|
|
16
7
|
const portfinder_1 = __importDefault(require("portfinder"));
|
|
17
8
|
const PORT = 9012;
|
|
18
|
-
function getPort() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
port: PORT
|
|
22
|
-
});
|
|
23
|
-
return port;
|
|
9
|
+
async function getPort() {
|
|
10
|
+
const port = await portfinder_1.default.getPortPromise({
|
|
11
|
+
port: PORT
|
|
24
12
|
});
|
|
13
|
+
return port;
|
|
25
14
|
}
|
|
26
15
|
exports.getPort = getPort;
|
|
@@ -1,31 +1,22 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.pagingSelectPromp = void 0;
|
|
13
4
|
const enquirer_1 = require("enquirer");
|
|
14
5
|
const error_1 = require("../../error");
|
|
15
6
|
const i18n_1 = require("../../i18n");
|
|
16
|
-
const pagingSelectPromp = (type, listFetcher, options, message, filter = _ => true, mapper = item => item) =>
|
|
7
|
+
const pagingSelectPromp = async (type, listFetcher, options, message, filter = _ => true, mapper = item => item) => {
|
|
17
8
|
let res = [];
|
|
18
9
|
let offset = 0;
|
|
19
10
|
let nextRoundList;
|
|
20
11
|
const nextPageText = (0, i18n_1.t)('下一页');
|
|
21
12
|
while (true) {
|
|
22
|
-
const thisRoundList = nextRoundList || (
|
|
13
|
+
const thisRoundList = nextRoundList || (await listFetcher({ ...options, limit: 10, offset: offset })).filter(filter).map(mapper);
|
|
23
14
|
offset += 10;
|
|
24
|
-
nextRoundList = (
|
|
15
|
+
nextRoundList = (await listFetcher({ ...options, limit: 10, offset: offset })).filter(filter).map(mapper);
|
|
25
16
|
if (!thisRoundList || !thisRoundList.length)
|
|
26
17
|
throw new error_1.CloudBaseError((0, i18n_1.t)('列表没有数据'));
|
|
27
18
|
if (type === 'select') {
|
|
28
|
-
let receiver = (
|
|
19
|
+
let receiver = (await (0, enquirer_1.prompt)({
|
|
29
20
|
type: type,
|
|
30
21
|
name: 'receiver',
|
|
31
22
|
message: message,
|
|
@@ -36,7 +27,7 @@ const pagingSelectPromp = (type, listFetcher, options, message, filter = _ => tr
|
|
|
36
27
|
break;
|
|
37
28
|
}
|
|
38
29
|
else {
|
|
39
|
-
let { receiver } =
|
|
30
|
+
let { receiver } = await (0, enquirer_1.prompt)({
|
|
40
31
|
type: type,
|
|
41
32
|
name: 'receiver',
|
|
42
33
|
message: message,
|
|
@@ -50,5 +41,5 @@ const pagingSelectPromp = (type, listFetcher, options, message, filter = _ => tr
|
|
|
50
41
|
}
|
|
51
42
|
}
|
|
52
43
|
return res;
|
|
53
|
-
}
|
|
44
|
+
};
|
|
54
45
|
exports.pagingSelectPromp = pagingSelectPromp;
|
package/lib/utils/report.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -45,34 +36,38 @@ class BeaconAction {
|
|
|
45
36
|
].join('|');
|
|
46
37
|
return crypto_1.default.createHash('sha256').update(deviceInfo).digest('hex').substring(0, 32);
|
|
47
38
|
}
|
|
48
|
-
report(eventCode, eventData = {}) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
39
|
+
async report(eventCode, eventData = {}) {
|
|
40
|
+
const now = Date.now();
|
|
41
|
+
return (0, net_1.postFetch)('https://otheve.beacon.qq.com/analytics/v2_upload', {
|
|
42
|
+
appVersion: '',
|
|
43
|
+
sdkId: 'js',
|
|
44
|
+
sdkVersion: '4.5.14-web',
|
|
45
|
+
mainAppKey: '0WEB0AD0GM4PUUU1',
|
|
46
|
+
platformId: 3,
|
|
47
|
+
common: {
|
|
48
|
+
A2: this.deviceId,
|
|
49
|
+
A101: this.userAgent,
|
|
50
|
+
from: 'tcb-cli',
|
|
51
|
+
xDeployEnv: process.env.NODE_ENV
|
|
52
|
+
},
|
|
53
|
+
events: [
|
|
54
|
+
{
|
|
55
|
+
eventCode,
|
|
56
|
+
eventTime: String(now),
|
|
57
|
+
mapValue: {
|
|
58
|
+
...eventData,
|
|
59
|
+
...this.additionalParams
|
|
68
60
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}).catch((e) => {
|
|
72
64
|
});
|
|
73
65
|
}
|
|
74
66
|
addAdditionalParams(params) {
|
|
75
|
-
this.additionalParams =
|
|
67
|
+
this.additionalParams = {
|
|
68
|
+
...this.additionalParams,
|
|
69
|
+
...params
|
|
70
|
+
};
|
|
76
71
|
}
|
|
77
72
|
}
|
|
78
73
|
exports.beaconAction = new BeaconAction();
|
|
@@ -1,31 +1,20 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.collectAgree = void 0;
|
|
13
4
|
const net_1 = require("../net");
|
|
14
5
|
const platform_1 = require("../platform");
|
|
15
6
|
const store_1 = require("../store");
|
|
16
7
|
const url = 'https://tcli.service.tcloudbase.com/agree-collect';
|
|
17
|
-
function collectAgree(agree) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return (0, net_1.postFetch)(url, data);
|
|
29
|
-
});
|
|
8
|
+
async function collectAgree(agree) {
|
|
9
|
+
const uin = await (0, store_1.getUin)();
|
|
10
|
+
const macMd5 = await (0, platform_1.getMacAddressMd5)();
|
|
11
|
+
const os = await (0, platform_1.getOSInfo)();
|
|
12
|
+
const data = {
|
|
13
|
+
macMd5,
|
|
14
|
+
agree,
|
|
15
|
+
uin,
|
|
16
|
+
os
|
|
17
|
+
};
|
|
18
|
+
return (0, net_1.postFetch)(url, data);
|
|
30
19
|
}
|
|
31
20
|
exports.collectAgree = collectAgree;
|
|
@@ -1,37 +1,26 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.templateDownloadReport = void 0;
|
|
13
4
|
const net_1 = require("../net");
|
|
14
5
|
const platform_1 = require("../platform");
|
|
15
6
|
const store_1 = require("../store");
|
|
16
7
|
const url = 'https://tcli.service.tcloudbase.com/download';
|
|
17
|
-
function templateDownloadReport(templateId, templateName) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
});
|
|
8
|
+
async function templateDownloadReport(templateId, templateName) {
|
|
9
|
+
const uin = await (0, store_1.getUin)();
|
|
10
|
+
const os = await (0, platform_1.getOSInfo)();
|
|
11
|
+
const macMd5 = await (0, platform_1.getMacAddressMd5)();
|
|
12
|
+
const data = {
|
|
13
|
+
os,
|
|
14
|
+
uin,
|
|
15
|
+
macMd5,
|
|
16
|
+
templateId,
|
|
17
|
+
templateName,
|
|
18
|
+
version: process.CLI_VERSION
|
|
19
|
+
};
|
|
20
|
+
try {
|
|
21
|
+
await (0, net_1.postFetch)(url, data);
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
}
|
|
36
25
|
}
|
|
37
26
|
exports.templateDownloadReport = templateDownloadReport;
|
|
@@ -1,32 +1,21 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.collectUsage = void 0;
|
|
13
4
|
const net_1 = require("../net");
|
|
14
5
|
const platform_1 = require("../platform");
|
|
15
6
|
const store_1 = require("../store");
|
|
16
7
|
const url = 'https://tcli.service.tcloudbase.com/usage';
|
|
17
|
-
function collectUsage(command) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return (0, net_1.postFetch)(url, data);
|
|
30
|
-
});
|
|
8
|
+
async function collectUsage(command) {
|
|
9
|
+
const uin = await (0, store_1.getUin)();
|
|
10
|
+
const macMd5 = await (0, platform_1.getMacAddressMd5)();
|
|
11
|
+
const os = await (0, platform_1.getOSInfo)();
|
|
12
|
+
const data = {
|
|
13
|
+
os,
|
|
14
|
+
uin,
|
|
15
|
+
macMd5,
|
|
16
|
+
command,
|
|
17
|
+
version: process.CLI_VERSION
|
|
18
|
+
};
|
|
19
|
+
return (0, net_1.postFetch)(url, data);
|
|
31
20
|
}
|
|
32
21
|
exports.collectUsage = collectUsage;
|
package/lib/utils/store/auth.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -26,23 +17,21 @@ class AuthStore extends db_1.LocalStore {
|
|
|
26
17
|
this.defaults = defaults;
|
|
27
18
|
this.moveOldConfig();
|
|
28
19
|
}
|
|
29
|
-
moveOldConfig() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
fs_1.default.unlinkSync(oldConfigPath);
|
|
43
|
-
}
|
|
20
|
+
async moveOldConfig() {
|
|
21
|
+
const db = await this.getDB();
|
|
22
|
+
const oldConfigPath = path_1.default.resolve(os_1.default.homedir(), '.config', 'configstore', '@cloudbase', 'cli.json');
|
|
23
|
+
if ((0, fs_2.checkFullAccess)(oldConfigPath)) {
|
|
24
|
+
try {
|
|
25
|
+
const content = JSON.parse(fs_1.default.readFileSync(oldConfigPath, 'utf8'));
|
|
26
|
+
const { credential, ssh } = content;
|
|
27
|
+
await db.set(constant_1.ConfigItems.credential, credential).write();
|
|
28
|
+
await db.set(constant_1.ConfigItems.ssh, ssh).write();
|
|
29
|
+
fs_1.default.unlinkSync(oldConfigPath);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
fs_1.default.unlinkSync(oldConfigPath);
|
|
44
33
|
}
|
|
45
|
-
}
|
|
34
|
+
}
|
|
46
35
|
}
|
|
47
36
|
}
|
|
48
37
|
exports.authStore = new AuthStore({
|
|
@@ -50,10 +39,8 @@ exports.authStore = new AuthStore({
|
|
|
50
39
|
[constant_1.ConfigItems.credential]: {},
|
|
51
40
|
[constant_1.ConfigItems.ssh]: {}
|
|
52
41
|
});
|
|
53
|
-
function getUin() {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return (credential === null || credential === void 0 ? void 0 : credential.uin) || (0, i18n_1.t)('无');
|
|
57
|
-
});
|
|
42
|
+
async function getUin() {
|
|
43
|
+
const credential = await exports.authStore.get(constant_1.ConfigItems.credential);
|
|
44
|
+
return (credential === null || credential === void 0 ? void 0 : credential.uin) || (0, i18n_1.t)('无');
|
|
58
45
|
}
|
|
59
46
|
exports.getUin = getUin;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.configStore = void 0;
|
|
13
4
|
const commands_1 = require("../../commands");
|
|
@@ -16,22 +7,17 @@ class ConfigStore extends db_1.LocalStore {
|
|
|
16
7
|
constructor() {
|
|
17
8
|
super({}, 'config');
|
|
18
9
|
}
|
|
19
|
-
get(key) {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (envValue !== undefined)
|
|
31
|
-
return envValue;
|
|
32
|
-
}
|
|
33
|
-
return commands_1.DEFAULT_CONFIGS[key];
|
|
34
|
-
});
|
|
10
|
+
async get(key) {
|
|
11
|
+
const value = await super.get(key);
|
|
12
|
+
if (value !== undefined)
|
|
13
|
+
return value;
|
|
14
|
+
const envKey = commands_1.CONFIGS[key].envKey;
|
|
15
|
+
if (envKey) {
|
|
16
|
+
const envValue = process.env[envKey];
|
|
17
|
+
if (envValue !== undefined)
|
|
18
|
+
return envValue;
|
|
19
|
+
}
|
|
20
|
+
return commands_1.DEFAULT_CONFIGS[key];
|
|
35
21
|
}
|
|
36
22
|
getSync(key) {
|
|
37
23
|
const value = super.getSyncDB().get(key).value();
|