esa-cli 0.0.2-beta.8 → 0.0.5
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/dist/commands/commit/index.js +2 -14
- package/dist/commands/common/constant.js +0 -19
- package/dist/commands/deploy/helper.js +9 -24
- package/dist/commands/deploy/index.js +10 -25
- package/dist/commands/deployments/list.js +5 -8
- package/dist/commands/dev/ew2/server.js +14 -13
- package/dist/commands/domain/delete.js +4 -4
- package/dist/commands/domain/list.js +3 -3
- package/dist/commands/init/helper.js +118 -0
- package/dist/commands/init/index.js +121 -189
- package/dist/commands/route/add.js +49 -51
- package/dist/commands/route/delete.js +29 -23
- package/dist/commands/route/helper.js +124 -0
- package/dist/commands/route/list.js +53 -14
- package/dist/commands/utils.js +5 -5
- package/dist/components/mutiLevelSelect.js +44 -55
- package/dist/i18n/locales.json +60 -0
- package/dist/libs/api.js +29 -3
- package/dist/libs/apiService.js +84 -28
- package/dist/libs/templates/index.js +2 -1
- package/dist/utils/checkIsRoutineCreated.js +7 -12
- package/package.json +2 -2
package/dist/libs/apiService.js
CHANGED
|
@@ -12,7 +12,6 @@ import FormData from 'form-data';
|
|
|
12
12
|
import fetch from 'node-fetch';
|
|
13
13
|
import { Environment } from './interface.js';
|
|
14
14
|
import { getApiConfig } from '../utils/fileUtils/index.js';
|
|
15
|
-
import chain from 'lodash';
|
|
16
15
|
import t from '../i18n/index.js';
|
|
17
16
|
export class ApiService {
|
|
18
17
|
constructor(cliConfig) {
|
|
@@ -569,7 +568,7 @@ export class ApiService {
|
|
|
569
568
|
}
|
|
570
569
|
getRoutine(requestParams_1) {
|
|
571
570
|
return __awaiter(this, arguments, void 0, function* (requestParams, isShowError = true) {
|
|
572
|
-
var _a, _b, _c, _d, _e, _f
|
|
571
|
+
var _a, _b, _c, _d, _e, _f;
|
|
573
572
|
try {
|
|
574
573
|
let params = {
|
|
575
574
|
action: 'GetRoutine',
|
|
@@ -602,12 +601,10 @@ export class ApiService {
|
|
|
602
601
|
data: {
|
|
603
602
|
RequestId: (_a = res.body) === null || _a === void 0 ? void 0 : _a.RequestId,
|
|
604
603
|
CodeVersions: ((_b = res.body) === null || _b === void 0 ? void 0 : _b.CodeVersions) || [],
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
RelatedRoutes: ((_g = res.body) === null || _g === void 0 ? void 0 : _g.RelatedRoutes) || [],
|
|
610
|
-
DefaultRelatedRecord: (_h = res.body) === null || _h === void 0 ? void 0 : _h.DefaultRelatedRecord
|
|
604
|
+
Envs: ((_c = res.body) === null || _c === void 0 ? void 0 : _c.Envs) || [],
|
|
605
|
+
CreateTime: (_d = res.body) === null || _d === void 0 ? void 0 : _d.CreateTime,
|
|
606
|
+
Description: (_e = res.body) === null || _e === void 0 ? void 0 : _e.Description,
|
|
607
|
+
DefaultRelatedRecord: (_f = res.body) === null || _f === void 0 ? void 0 : _f.DefaultRelatedRecord
|
|
611
608
|
}
|
|
612
609
|
};
|
|
613
610
|
return routineResponse;
|
|
@@ -640,8 +637,7 @@ export class ApiService {
|
|
|
640
637
|
let request = new $OpenApi.OpenApiRequest({
|
|
641
638
|
query: {
|
|
642
639
|
Name: edgeRoutine.name,
|
|
643
|
-
Description: edgeRoutine.description
|
|
644
|
-
SpecName: edgeRoutine.specName
|
|
640
|
+
Description: edgeRoutine.description
|
|
645
641
|
}
|
|
646
642
|
});
|
|
647
643
|
let runtime = {
|
|
@@ -696,7 +692,7 @@ export class ApiService {
|
|
|
696
692
|
}
|
|
697
693
|
};
|
|
698
694
|
const uploadResult = yield this.client.callApi(params, request, runtime);
|
|
699
|
-
const ossConfig =
|
|
695
|
+
const ossConfig = uploadResult.body.OssPostConfig;
|
|
700
696
|
if (uploadResult.statusCode !== 200 || !ossConfig) {
|
|
701
697
|
return false;
|
|
702
698
|
}
|
|
@@ -709,12 +705,12 @@ export class ApiService {
|
|
|
709
705
|
formData.append('policy', policy);
|
|
710
706
|
formData.append('key', key);
|
|
711
707
|
formData.append('file', edgeRoutine.code);
|
|
712
|
-
// TODO: 检查oss结果;
|
|
713
708
|
const ossRes = yield fetch(Url, {
|
|
714
709
|
method: 'POST',
|
|
715
710
|
body: formData,
|
|
716
711
|
headers: formData.getHeaders()
|
|
717
712
|
});
|
|
713
|
+
// console.log('oss result', oss);
|
|
718
714
|
if (ossRes && ossRes.status === 200) {
|
|
719
715
|
return true;
|
|
720
716
|
}
|
|
@@ -772,11 +768,11 @@ export class ApiService {
|
|
|
772
768
|
return null;
|
|
773
769
|
});
|
|
774
770
|
}
|
|
775
|
-
|
|
771
|
+
createRoutineRelatedRecord(requestParams) {
|
|
776
772
|
return __awaiter(this, void 0, void 0, function* () {
|
|
777
773
|
try {
|
|
778
774
|
let params = {
|
|
779
|
-
action: '
|
|
775
|
+
action: 'CreateRoutineRelatedRecord',
|
|
780
776
|
version: '2024-09-10',
|
|
781
777
|
protocol: 'https',
|
|
782
778
|
method: 'GET',
|
|
@@ -789,7 +785,14 @@ export class ApiService {
|
|
|
789
785
|
return this;
|
|
790
786
|
}
|
|
791
787
|
};
|
|
792
|
-
let request = new $OpenApi.OpenApiRequest(
|
|
788
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
789
|
+
query: {
|
|
790
|
+
RecordName: requestParams.RecordName,
|
|
791
|
+
SiteId: requestParams.SiteId,
|
|
792
|
+
SiteName: requestParams.SiteName,
|
|
793
|
+
Name: requestParams.Name
|
|
794
|
+
}
|
|
795
|
+
});
|
|
793
796
|
let runtime = {
|
|
794
797
|
toMap: function () {
|
|
795
798
|
return this;
|
|
@@ -800,8 +803,8 @@ export class ApiService {
|
|
|
800
803
|
const ret = {
|
|
801
804
|
code: res.statusCode,
|
|
802
805
|
data: {
|
|
803
|
-
|
|
804
|
-
|
|
806
|
+
Status: res.body.Status,
|
|
807
|
+
RequestId: res.body.RequestId
|
|
805
808
|
}
|
|
806
809
|
};
|
|
807
810
|
return ret;
|
|
@@ -813,11 +816,11 @@ export class ApiService {
|
|
|
813
816
|
return null;
|
|
814
817
|
});
|
|
815
818
|
}
|
|
816
|
-
|
|
819
|
+
deleteRoutineRelatedRecord(requestParams) {
|
|
817
820
|
return __awaiter(this, void 0, void 0, function* () {
|
|
818
821
|
try {
|
|
819
822
|
let params = {
|
|
820
|
-
action: '
|
|
823
|
+
action: 'DeleteRoutineRelatedRecord',
|
|
821
824
|
version: '2024-09-10',
|
|
822
825
|
protocol: 'https',
|
|
823
826
|
method: 'GET',
|
|
@@ -835,7 +838,8 @@ export class ApiService {
|
|
|
835
838
|
RecordName: requestParams.RecordName,
|
|
836
839
|
SiteId: requestParams.SiteId,
|
|
837
840
|
SiteName: requestParams.SiteName,
|
|
838
|
-
Name: requestParams.Name
|
|
841
|
+
Name: requestParams.Name,
|
|
842
|
+
RecordId: requestParams.RecordId
|
|
839
843
|
}
|
|
840
844
|
});
|
|
841
845
|
let runtime = {
|
|
@@ -861,11 +865,11 @@ export class ApiService {
|
|
|
861
865
|
return null;
|
|
862
866
|
});
|
|
863
867
|
}
|
|
864
|
-
|
|
868
|
+
listRoutineRelatedRecords(requestParams) {
|
|
865
869
|
return __awaiter(this, void 0, void 0, function* () {
|
|
866
870
|
try {
|
|
867
871
|
let params = {
|
|
868
|
-
action: '
|
|
872
|
+
action: 'ListRoutineRelatedRecords',
|
|
869
873
|
version: '2024-09-10',
|
|
870
874
|
protocol: 'https',
|
|
871
875
|
method: 'GET',
|
|
@@ -880,11 +884,10 @@ export class ApiService {
|
|
|
880
884
|
};
|
|
881
885
|
let request = new $OpenApi.OpenApiRequest({
|
|
882
886
|
query: {
|
|
883
|
-
RecordName: requestParams.RecordName,
|
|
884
|
-
SiteId: requestParams.SiteId,
|
|
885
|
-
SiteName: requestParams.SiteName,
|
|
886
887
|
Name: requestParams.Name,
|
|
887
|
-
|
|
888
|
+
PageNumber: requestParams.PageNumber,
|
|
889
|
+
PageSize: requestParams.PageSize,
|
|
890
|
+
SearchKeyWord: requestParams.SearchKeyWord
|
|
888
891
|
}
|
|
889
892
|
});
|
|
890
893
|
let runtime = {
|
|
@@ -897,8 +900,61 @@ export class ApiService {
|
|
|
897
900
|
const ret = {
|
|
898
901
|
code: res.statusCode,
|
|
899
902
|
data: {
|
|
900
|
-
|
|
901
|
-
|
|
903
|
+
PageNumber: res.body.PageNumber,
|
|
904
|
+
PageSize: res.body.PageSize,
|
|
905
|
+
TotalCount: res.body.TotalCount,
|
|
906
|
+
RelatedRecords: res.body.RelatedRecords
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
return ret;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
catch (error) {
|
|
913
|
+
console.log(error);
|
|
914
|
+
}
|
|
915
|
+
return null;
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
createRoutineRoute(requestParams) {
|
|
919
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
920
|
+
try {
|
|
921
|
+
let params = {
|
|
922
|
+
action: 'CreateRoutineRoute',
|
|
923
|
+
version: '2024-09-10',
|
|
924
|
+
protocol: 'https',
|
|
925
|
+
method: 'POST',
|
|
926
|
+
authType: 'AK',
|
|
927
|
+
bodyType: 'json',
|
|
928
|
+
reqBodyType: 'json',
|
|
929
|
+
style: 'RPC',
|
|
930
|
+
pathname: '/',
|
|
931
|
+
toMap: function () {
|
|
932
|
+
return this;
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
936
|
+
query: {
|
|
937
|
+
SiteId: requestParams.SiteId,
|
|
938
|
+
RoutineName: requestParams.RoutineName,
|
|
939
|
+
RouteName: requestParams.RouteName,
|
|
940
|
+
RouteEnable: 'on',
|
|
941
|
+
Rule: requestParams.Rule,
|
|
942
|
+
Bypass: requestParams.Bypass,
|
|
943
|
+
Mode: 'simple'
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
let runtime = {
|
|
947
|
+
toMap: function () {
|
|
948
|
+
return this;
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
const res = yield this.client.callApi(params, request, runtime);
|
|
952
|
+
if (res.statusCode === 200 && res.body) {
|
|
953
|
+
const ret = {
|
|
954
|
+
code: res.statusCode,
|
|
955
|
+
data: {
|
|
956
|
+
RequestId: res.body.RequestId,
|
|
957
|
+
ConfigId: res.body.ConfigId
|
|
902
958
|
}
|
|
903
959
|
};
|
|
904
960
|
return ret;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getSummary } from '../../commands/common/constant.js';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
+
import logger from '../logger.js';
|
|
3
4
|
export default class Template {
|
|
4
5
|
constructor(path, title) {
|
|
5
6
|
this.path = path;
|
|
@@ -10,7 +11,7 @@ export default class Template {
|
|
|
10
11
|
list.forEach((summary) => {
|
|
11
12
|
const title = chalk.bold(summary.title);
|
|
12
13
|
const command = chalk.green(summary.command);
|
|
13
|
-
|
|
14
|
+
logger.log(`${title}: ${command}`);
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import path from 'path';
|
|
11
11
|
import { createEdgeRoutine } from '../commands/commit/index.js';
|
|
12
|
-
import { displaySelectSpec } from '../commands/deploy/index.js';
|
|
13
12
|
import { ApiService } from '../libs/apiService.js';
|
|
14
13
|
import { readEdgeRoutineFile } from './fileUtils/index.js';
|
|
15
14
|
import logger from '../libs/logger.js';
|
|
@@ -36,26 +35,22 @@ export function validRoutine(name) {
|
|
|
36
35
|
}
|
|
37
36
|
export function checkRoutineExist(name, entry) {
|
|
38
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
var _a, _b;
|
|
40
38
|
const isCreatedRoutine = yield isRoutineExist(name);
|
|
41
39
|
if (!isCreatedRoutine) {
|
|
42
40
|
logger.log(t('first_deploy').d('This is the first time to deploy, we will create a new routine for you.'));
|
|
43
41
|
const entryFile = path.resolve(entry !== null && entry !== void 0 ? entry : '', 'src/index.js');
|
|
44
42
|
yield prodBuild(false, entryFile, entry);
|
|
45
43
|
const code = readEdgeRoutineFile(entry) || '';
|
|
46
|
-
const
|
|
47
|
-
const specList = ((_b = (_a = (yield server.ListRoutineOptionalSpecs())) === null || _a === void 0 ? void 0 : _a.data.Specs) !== null && _b !== void 0 ? _b : []).reduce((acc, item) => {
|
|
48
|
-
if (item.IsAvailable) {
|
|
49
|
-
acc.push(item.SpecName);
|
|
50
|
-
}
|
|
51
|
-
return acc;
|
|
52
|
-
}, []);
|
|
53
|
-
const spec = yield displaySelectSpec(specList);
|
|
54
|
-
yield createEdgeRoutine({
|
|
44
|
+
const res = yield createEdgeRoutine({
|
|
55
45
|
name: name,
|
|
56
|
-
specName: spec,
|
|
57
46
|
code: code
|
|
58
47
|
});
|
|
48
|
+
if (res) {
|
|
49
|
+
logger.success(t('routine_create_success').d('Routine created successfully.'));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
logger.error(t('routine_create_fail').d('Routine created failed.'));
|
|
53
|
+
}
|
|
59
54
|
}
|
|
60
55
|
});
|
|
61
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esa-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "A CLI for operating Alibaba Cloud ESA EdgeRoutine (Edge Functions).",
|
|
5
5
|
"main": "bin/enter.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"vitest": "^2.0.4"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@alicloud/esa20240910": "2.
|
|
70
|
+
"@alicloud/esa20240910": "2.25.0",
|
|
71
71
|
"@alicloud/openapi-client": "^0.4.7",
|
|
72
72
|
"@babel/generator": "^7.26.3",
|
|
73
73
|
"@babel/parser": "^7.24.4",
|