esa-cli 0.0.2-beta.10 → 0.0.2-beta.12
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 +34 -24
- package/dist/commands/deploy/helper.js +10 -26
- package/dist/commands/deploy/index.js +49 -60
- package/dist/commands/deployments/delete.js +1 -16
- package/dist/commands/deployments/index.js +1 -1
- package/dist/commands/deployments/list.js +8 -15
- package/dist/commands/dev/ew2/cacheService.js +33 -0
- package/dist/commands/dev/ew2/devEntry.js +2 -1
- package/dist/commands/dev/ew2/devPack.js +5 -3
- package/dist/commands/dev/ew2/kvService.js +27 -0
- package/dist/commands/dev/ew2/mock/cache.js +99 -15
- package/dist/commands/dev/ew2/mock/kv.js +142 -21
- package/dist/commands/dev/ew2/server.js +150 -18
- package/dist/commands/dev/index.js +2 -3
- package/dist/commands/domain/add.js +1 -1
- package/dist/commands/domain/delete.js +4 -4
- package/dist/commands/domain/index.js +1 -1
- package/dist/commands/domain/list.js +3 -3
- package/dist/commands/init/helper.js +28 -4
- package/dist/commands/init/index.js +78 -14
- package/dist/commands/login/index.js +49 -3
- package/dist/commands/logout.js +1 -1
- package/dist/commands/route/add.js +50 -52
- package/dist/commands/route/delete.js +29 -23
- package/dist/commands/route/helper.js +124 -0
- package/dist/commands/route/index.js +1 -1
- package/dist/commands/route/list.js +53 -14
- package/dist/commands/routine/index.js +1 -1
- package/dist/commands/routine/list.js +4 -5
- package/dist/commands/site/index.js +1 -1
- package/dist/commands/utils.js +5 -5
- package/dist/docs/Commands_en.md +27 -13
- package/dist/docs/Commands_zh_CN.md +14 -0
- package/dist/docs/Dev_en.md +0 -0
- package/dist/docs/Dev_zh_CN.md +0 -0
- package/dist/i18n/locales.json +102 -10
- package/dist/index.js +6 -1
- package/dist/libs/api.js +32 -9
- package/dist/libs/apiService.js +88 -78
- package/dist/libs/interface.js +0 -1
- package/dist/utils/checkIsRoutineCreated.js +0 -16
- package/package.json +3 -4
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) {
|
|
@@ -130,7 +129,6 @@ export class ApiService {
|
|
|
130
129
|
}
|
|
131
130
|
publishRoutineCodeVersion(requestParams) {
|
|
132
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
-
var _a;
|
|
134
132
|
try {
|
|
135
133
|
let params = {
|
|
136
134
|
action: 'PublishRoutineCodeVersion',
|
|
@@ -146,15 +144,11 @@ export class ApiService {
|
|
|
146
144
|
return this;
|
|
147
145
|
}
|
|
148
146
|
};
|
|
149
|
-
const CanaryAreaList = (_a = requestParams.CanaryAreaList) !== null && _a !== void 0 ? _a : [];
|
|
150
|
-
const CanaryAreaListString = JSON.stringify(CanaryAreaList);
|
|
151
147
|
let request = new $OpenApi.OpenApiRequest({
|
|
152
148
|
query: {
|
|
153
149
|
Env: requestParams.Env,
|
|
154
150
|
Name: requestParams.Name,
|
|
155
|
-
CodeVersion: requestParams.CodeVersion
|
|
156
|
-
CanaryCodeVersion: requestParams.CanaryCodeVersion,
|
|
157
|
-
CanaryAreaList: CanaryAreaListString
|
|
151
|
+
CodeVersion: requestParams.CodeVersion
|
|
158
152
|
}
|
|
159
153
|
});
|
|
160
154
|
let runtime = {
|
|
@@ -225,48 +219,11 @@ export class ApiService {
|
|
|
225
219
|
return null;
|
|
226
220
|
});
|
|
227
221
|
}
|
|
228
|
-
|
|
229
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
-
try {
|
|
231
|
-
let params = {
|
|
232
|
-
action: 'ListRoutineCanaryAreas',
|
|
233
|
-
version: '2024-09-10',
|
|
234
|
-
protocol: 'https',
|
|
235
|
-
method: 'GET',
|
|
236
|
-
authType: 'AK',
|
|
237
|
-
bodyType: 'json',
|
|
238
|
-
reqBodyType: 'json',
|
|
239
|
-
style: 'RPC',
|
|
240
|
-
pathname: '/',
|
|
241
|
-
toMap: function () {
|
|
242
|
-
return this;
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
let request = new $OpenApi.OpenApiRequest();
|
|
246
|
-
let runtime = {
|
|
247
|
-
toMap: function () {
|
|
248
|
-
return this;
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
const res = yield this.client.callApi(params, request, runtime);
|
|
252
|
-
if (res.statusCode === 200 && res.body) {
|
|
253
|
-
const ret = {
|
|
254
|
-
CanaryAreas: res.body.CanaryAreas
|
|
255
|
-
};
|
|
256
|
-
return ret;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
catch (error) {
|
|
260
|
-
console.log(error);
|
|
261
|
-
}
|
|
262
|
-
return null;
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
getRoutineUserInfo() {
|
|
222
|
+
listUserRoutines() {
|
|
266
223
|
return __awaiter(this, void 0, void 0, function* () {
|
|
267
224
|
try {
|
|
268
225
|
let params = {
|
|
269
|
-
action: '
|
|
226
|
+
action: 'ListUserRoutines',
|
|
270
227
|
version: '2024-09-10',
|
|
271
228
|
protocol: 'https',
|
|
272
229
|
method: 'GET',
|
|
@@ -287,11 +244,7 @@ export class ApiService {
|
|
|
287
244
|
};
|
|
288
245
|
const res = yield this.client.callApi(params, request, runtime);
|
|
289
246
|
if (res.statusCode === 200 && res.body) {
|
|
290
|
-
|
|
291
|
-
Subdomains: res.body.RoutineName,
|
|
292
|
-
Routines: res.body.Routines
|
|
293
|
-
};
|
|
294
|
-
return ret;
|
|
247
|
+
return res;
|
|
295
248
|
}
|
|
296
249
|
}
|
|
297
250
|
catch (error) {
|
|
@@ -569,7 +522,7 @@ export class ApiService {
|
|
|
569
522
|
}
|
|
570
523
|
getRoutine(requestParams_1) {
|
|
571
524
|
return __awaiter(this, arguments, void 0, function* (requestParams, isShowError = true) {
|
|
572
|
-
var _a, _b, _c, _d, _e, _f
|
|
525
|
+
var _a, _b, _c, _d, _e, _f;
|
|
573
526
|
try {
|
|
574
527
|
let params = {
|
|
575
528
|
action: 'GetRoutine',
|
|
@@ -602,12 +555,10 @@ export class ApiService {
|
|
|
602
555
|
data: {
|
|
603
556
|
RequestId: (_a = res.body) === null || _a === void 0 ? void 0 : _a.RequestId,
|
|
604
557
|
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
|
|
558
|
+
Envs: ((_c = res.body) === null || _c === void 0 ? void 0 : _c.Envs) || [],
|
|
559
|
+
CreateTime: (_d = res.body) === null || _d === void 0 ? void 0 : _d.CreateTime,
|
|
560
|
+
Description: (_e = res.body) === null || _e === void 0 ? void 0 : _e.Description,
|
|
561
|
+
DefaultRelatedRecord: (_f = res.body) === null || _f === void 0 ? void 0 : _f.DefaultRelatedRecord
|
|
611
562
|
}
|
|
612
563
|
};
|
|
613
564
|
return routineResponse;
|
|
@@ -640,8 +591,7 @@ export class ApiService {
|
|
|
640
591
|
let request = new $OpenApi.OpenApiRequest({
|
|
641
592
|
query: {
|
|
642
593
|
Name: edgeRoutine.name,
|
|
643
|
-
Description: edgeRoutine.description
|
|
644
|
-
SpecName: edgeRoutine.specName
|
|
594
|
+
Description: edgeRoutine.description
|
|
645
595
|
}
|
|
646
596
|
});
|
|
647
597
|
let runtime = {
|
|
@@ -696,7 +646,7 @@ export class ApiService {
|
|
|
696
646
|
}
|
|
697
647
|
};
|
|
698
648
|
const uploadResult = yield this.client.callApi(params, request, runtime);
|
|
699
|
-
const ossConfig =
|
|
649
|
+
const ossConfig = uploadResult.body.OssPostConfig;
|
|
700
650
|
if (uploadResult.statusCode !== 200 || !ossConfig) {
|
|
701
651
|
return false;
|
|
702
652
|
}
|
|
@@ -709,12 +659,12 @@ export class ApiService {
|
|
|
709
659
|
formData.append('policy', policy);
|
|
710
660
|
formData.append('key', key);
|
|
711
661
|
formData.append('file', edgeRoutine.code);
|
|
712
|
-
// TODO: 检查oss结果;
|
|
713
662
|
const ossRes = yield fetch(Url, {
|
|
714
663
|
method: 'POST',
|
|
715
664
|
body: formData,
|
|
716
665
|
headers: formData.getHeaders()
|
|
717
666
|
});
|
|
667
|
+
// console.log('oss result', oss);
|
|
718
668
|
if (ossRes && ossRes.status === 200) {
|
|
719
669
|
return true;
|
|
720
670
|
}
|
|
@@ -772,11 +722,11 @@ export class ApiService {
|
|
|
772
722
|
return null;
|
|
773
723
|
});
|
|
774
724
|
}
|
|
775
|
-
|
|
725
|
+
createRoutineRelatedRecord(requestParams) {
|
|
776
726
|
return __awaiter(this, void 0, void 0, function* () {
|
|
777
727
|
try {
|
|
778
728
|
let params = {
|
|
779
|
-
action: '
|
|
729
|
+
action: 'CreateRoutineRelatedRecord',
|
|
780
730
|
version: '2024-09-10',
|
|
781
731
|
protocol: 'https',
|
|
782
732
|
method: 'GET',
|
|
@@ -789,7 +739,14 @@ export class ApiService {
|
|
|
789
739
|
return this;
|
|
790
740
|
}
|
|
791
741
|
};
|
|
792
|
-
let request = new $OpenApi.OpenApiRequest(
|
|
742
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
743
|
+
query: {
|
|
744
|
+
RecordName: requestParams.RecordName,
|
|
745
|
+
SiteId: requestParams.SiteId,
|
|
746
|
+
SiteName: requestParams.SiteName,
|
|
747
|
+
Name: requestParams.Name
|
|
748
|
+
}
|
|
749
|
+
});
|
|
793
750
|
let runtime = {
|
|
794
751
|
toMap: function () {
|
|
795
752
|
return this;
|
|
@@ -800,8 +757,8 @@ export class ApiService {
|
|
|
800
757
|
const ret = {
|
|
801
758
|
code: res.statusCode,
|
|
802
759
|
data: {
|
|
803
|
-
|
|
804
|
-
|
|
760
|
+
Status: res.body.Status,
|
|
761
|
+
RequestId: res.body.RequestId
|
|
805
762
|
}
|
|
806
763
|
};
|
|
807
764
|
return ret;
|
|
@@ -813,11 +770,11 @@ export class ApiService {
|
|
|
813
770
|
return null;
|
|
814
771
|
});
|
|
815
772
|
}
|
|
816
|
-
|
|
773
|
+
deleteRoutineRelatedRecord(requestParams) {
|
|
817
774
|
return __awaiter(this, void 0, void 0, function* () {
|
|
818
775
|
try {
|
|
819
776
|
let params = {
|
|
820
|
-
action: '
|
|
777
|
+
action: 'DeleteRoutineRelatedRecord',
|
|
821
778
|
version: '2024-09-10',
|
|
822
779
|
protocol: 'https',
|
|
823
780
|
method: 'GET',
|
|
@@ -835,7 +792,8 @@ export class ApiService {
|
|
|
835
792
|
RecordName: requestParams.RecordName,
|
|
836
793
|
SiteId: requestParams.SiteId,
|
|
837
794
|
SiteName: requestParams.SiteName,
|
|
838
|
-
Name: requestParams.Name
|
|
795
|
+
Name: requestParams.Name,
|
|
796
|
+
RecordId: requestParams.RecordId
|
|
839
797
|
}
|
|
840
798
|
});
|
|
841
799
|
let runtime = {
|
|
@@ -861,11 +819,11 @@ export class ApiService {
|
|
|
861
819
|
return null;
|
|
862
820
|
});
|
|
863
821
|
}
|
|
864
|
-
|
|
822
|
+
listRoutineRelatedRecords(requestParams) {
|
|
865
823
|
return __awaiter(this, void 0, void 0, function* () {
|
|
866
824
|
try {
|
|
867
825
|
let params = {
|
|
868
|
-
action: '
|
|
826
|
+
action: 'ListRoutineRelatedRecords',
|
|
869
827
|
version: '2024-09-10',
|
|
870
828
|
protocol: 'https',
|
|
871
829
|
method: 'GET',
|
|
@@ -880,11 +838,10 @@ export class ApiService {
|
|
|
880
838
|
};
|
|
881
839
|
let request = new $OpenApi.OpenApiRequest({
|
|
882
840
|
query: {
|
|
883
|
-
RecordName: requestParams.RecordName,
|
|
884
|
-
SiteId: requestParams.SiteId,
|
|
885
|
-
SiteName: requestParams.SiteName,
|
|
886
841
|
Name: requestParams.Name,
|
|
887
|
-
|
|
842
|
+
PageNumber: requestParams.PageNumber,
|
|
843
|
+
PageSize: requestParams.PageSize,
|
|
844
|
+
SearchKeyWord: requestParams.SearchKeyWord
|
|
888
845
|
}
|
|
889
846
|
});
|
|
890
847
|
let runtime = {
|
|
@@ -897,8 +854,61 @@ export class ApiService {
|
|
|
897
854
|
const ret = {
|
|
898
855
|
code: res.statusCode,
|
|
899
856
|
data: {
|
|
900
|
-
|
|
901
|
-
|
|
857
|
+
PageNumber: res.body.PageNumber,
|
|
858
|
+
PageSize: res.body.PageSize,
|
|
859
|
+
TotalCount: res.body.TotalCount,
|
|
860
|
+
RelatedRecords: res.body.RelatedRecords
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
return ret;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
catch (error) {
|
|
867
|
+
console.log(error);
|
|
868
|
+
}
|
|
869
|
+
return null;
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
createRoutineRoute(requestParams) {
|
|
873
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
874
|
+
try {
|
|
875
|
+
let params = {
|
|
876
|
+
action: 'CreateRoutineRoute',
|
|
877
|
+
version: '2024-09-10',
|
|
878
|
+
protocol: 'https',
|
|
879
|
+
method: 'POST',
|
|
880
|
+
authType: 'AK',
|
|
881
|
+
bodyType: 'json',
|
|
882
|
+
reqBodyType: 'json',
|
|
883
|
+
style: 'RPC',
|
|
884
|
+
pathname: '/',
|
|
885
|
+
toMap: function () {
|
|
886
|
+
return this;
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
890
|
+
query: {
|
|
891
|
+
SiteId: requestParams.SiteId,
|
|
892
|
+
RoutineName: requestParams.RoutineName,
|
|
893
|
+
RouteName: requestParams.RouteName,
|
|
894
|
+
RouteEnable: 'on',
|
|
895
|
+
Rule: requestParams.Rule,
|
|
896
|
+
Bypass: requestParams.Bypass,
|
|
897
|
+
Mode: 'simple'
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
let runtime = {
|
|
901
|
+
toMap: function () {
|
|
902
|
+
return this;
|
|
903
|
+
}
|
|
904
|
+
};
|
|
905
|
+
const res = yield this.client.callApi(params, request, runtime);
|
|
906
|
+
if (res.statusCode === 200 && res.body) {
|
|
907
|
+
const ret = {
|
|
908
|
+
code: res.statusCode,
|
|
909
|
+
data: {
|
|
910
|
+
RequestId: res.body.RequestId,
|
|
911
|
+
ConfigId: res.body.ConfigId
|
|
902
912
|
}
|
|
903
913
|
};
|
|
904
914
|
return ret;
|
package/dist/libs/interface.js
CHANGED
|
@@ -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,29 +35,14 @@ 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 server = yield ApiService.getInstance();
|
|
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
|
-
console.log({
|
|
55
|
-
name: name,
|
|
56
|
-
specName: spec,
|
|
57
|
-
code: code
|
|
58
|
-
});
|
|
59
44
|
const res = yield createEdgeRoutine({
|
|
60
45
|
name: name,
|
|
61
|
-
specName: spec,
|
|
62
46
|
code: code
|
|
63
47
|
});
|
|
64
48
|
if (res) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esa-cli",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.12",
|
|
4
4
|
"description": "A CLI for operating Alibaba Cloud ESA EdgeRoutine (Edge Functions).",
|
|
5
5
|
"main": "bin/enter.cjs",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"watch": "tsc --watch",
|
|
19
19
|
"eslint": "eslint src/ --ext .js,.jsx,.ts,.tsx",
|
|
20
20
|
"lint-staged": "lint-staged",
|
|
21
|
-
"prepare": "npm run build",
|
|
22
21
|
"test": "FORCE_COLOR=0 npx vitest ",
|
|
23
22
|
"coverage": "vitest --coverage"
|
|
24
23
|
},
|
|
@@ -67,7 +66,7 @@
|
|
|
67
66
|
"vitest": "^2.0.4"
|
|
68
67
|
},
|
|
69
68
|
"dependencies": {
|
|
70
|
-
"@alicloud/esa20240910": "2.
|
|
69
|
+
"@alicloud/esa20240910": "2.25.0",
|
|
71
70
|
"@alicloud/openapi-client": "^0.4.7",
|
|
72
71
|
"@babel/generator": "^7.26.3",
|
|
73
72
|
"@babel/parser": "^7.24.4",
|
|
@@ -80,7 +79,7 @@
|
|
|
80
79
|
"chokidar": "^3.5.3",
|
|
81
80
|
"cli-table3": "^0.6.5",
|
|
82
81
|
"cross-spawn": "^7.0.3",
|
|
83
|
-
"esa-template": "^0.0.
|
|
82
|
+
"esa-template": "^0.0.7",
|
|
84
83
|
"esbuild": "^0.21.1",
|
|
85
84
|
"esbuild-plugin-less": "^1.3.8",
|
|
86
85
|
"form-data": "^4.0.0",
|