esa-cli 0.0.2-beta.2 → 0.0.2-beta.21
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 +45 -117
- package/dist/commands/commit/prodBuild.js +2 -3
- package/dist/commands/common/constant.js +0 -19
- package/dist/commands/common/utils.js +419 -0
- package/dist/commands/config.js +1 -1
- package/dist/commands/deploy/helper.js +51 -72
- package/dist/commands/deploy/index.js +48 -187
- package/dist/commands/deployments/delete.js +32 -22
- package/dist/commands/deployments/index.js +3 -3
- package/dist/commands/deployments/list.js +22 -38
- package/dist/commands/dev/build.js +3 -3
- package/dist/commands/dev/doProcess.js +5 -5
- 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 +30 -34
- package/dist/commands/dev/ew2/kvService.js +46 -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 +165 -28
- package/dist/commands/dev/index.js +16 -16
- package/dist/commands/dev/mockWorker/devPack.js +32 -21
- package/dist/commands/dev/mockWorker/server.js +7 -6
- package/dist/commands/domain/add.js +3 -3
- package/dist/commands/domain/delete.js +7 -7
- package/dist/commands/domain/index.js +3 -3
- package/dist/commands/domain/list.js +10 -10
- package/dist/commands/init/helper.js +761 -0
- package/dist/commands/init/index.js +88 -220
- package/dist/commands/init/snippets/nextjs/next.config.mjs +6 -0
- package/dist/commands/init/snippets/nextjs/next.config.ts +7 -0
- package/dist/commands/init/snippets/react-router/react-router.config.ts +7 -0
- package/dist/commands/init/template.jsonc +84 -0
- package/dist/commands/init/types.js +1 -0
- package/dist/commands/lang.js +2 -2
- package/dist/commands/login/index.js +74 -34
- package/dist/commands/logout.js +6 -6
- package/dist/commands/route/add.js +138 -49
- package/dist/commands/route/delete.js +33 -27
- package/dist/commands/route/helper.js +124 -0
- package/dist/commands/route/index.js +3 -3
- package/dist/commands/route/list.js +56 -17
- package/dist/commands/routine/delete.js +2 -2
- package/dist/commands/routine/index.js +3 -3
- package/dist/commands/routine/list.js +9 -21
- package/dist/commands/site/index.js +2 -2
- package/dist/commands/site/list.js +6 -7
- package/dist/commands/utils.js +55 -19
- package/dist/components/descriptionInput.js +1 -1
- package/dist/components/mutiLevelSelect.js +43 -55
- package/dist/components/mutiSelectTable.js +1 -1
- package/dist/components/selectInput.js +2 -3
- package/dist/components/selectItem.js +1 -1
- package/dist/docs/Commands_en.md +142 -131
- package/dist/docs/Commands_zh_CN.md +139 -127
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/locales.json +401 -21
- package/dist/index.js +27 -20
- package/dist/libs/api.js +32 -9
- package/dist/libs/apiService.js +262 -84
- package/dist/libs/git/index.js +86 -9
- package/dist/libs/interface.js +0 -1
- package/dist/libs/logger.js +162 -10
- package/dist/libs/service.js +2 -2
- package/dist/libs/templates/index.js +3 -2
- package/dist/utils/checkAssetsExist.js +80 -0
- package/dist/utils/checkDevPort.js +3 -17
- package/dist/utils/checkEntryFileExist.js +10 -0
- package/dist/utils/checkIsRoutineCreated.js +27 -26
- package/dist/utils/checkVersion.js +119 -1
- package/dist/utils/command.js +149 -0
- package/dist/utils/compress.js +136 -0
- package/dist/utils/download.js +182 -0
- package/dist/utils/fileMd5.js +1 -1
- package/dist/utils/fileUtils/base.js +1 -1
- package/dist/utils/fileUtils/index.js +69 -28
- package/dist/utils/installDeno.js +8 -8
- package/dist/utils/installEw2.js +7 -7
- package/dist/utils/openInBrowser.js +1 -1
- package/dist/utils/prompt.js +97 -0
- package/package.json +20 -12
package/dist/libs/apiService.js
CHANGED
|
@@ -10,10 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import * as $OpenApi from '@alicloud/openapi-client';
|
|
11
11
|
import FormData from 'form-data';
|
|
12
12
|
import fetch from 'node-fetch';
|
|
13
|
-
import { Environment } from './interface.js';
|
|
14
|
-
import { getApiConfig } from '../utils/fileUtils/index.js';
|
|
15
|
-
import chain from 'lodash';
|
|
16
13
|
import t from '../i18n/index.js';
|
|
14
|
+
import { getApiConfig } from '../utils/fileUtils/index.js';
|
|
15
|
+
import { Environment } from './interface.js';
|
|
17
16
|
export class ApiService {
|
|
18
17
|
constructor(cliConfig) {
|
|
19
18
|
var _a, _b;
|
|
@@ -49,7 +48,7 @@ export class ApiService {
|
|
|
49
48
|
* - message: (Optional) A string providing additional information in case of failure.
|
|
50
49
|
*/
|
|
51
50
|
checkLogin() {
|
|
52
|
-
return __awaiter(this,
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
52
|
try {
|
|
54
53
|
let params = {
|
|
55
54
|
action: 'GetErService',
|
|
@@ -91,7 +90,7 @@ export class ApiService {
|
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
92
|
catch (error) {
|
|
94
|
-
|
|
93
|
+
console.log('error', error);
|
|
95
94
|
return {
|
|
96
95
|
success: false,
|
|
97
96
|
message: t('login_failed').d('An error occurred while trying to log in.')
|
|
@@ -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,11 +219,11 @@ export class ApiService {
|
|
|
225
219
|
return null;
|
|
226
220
|
});
|
|
227
221
|
}
|
|
228
|
-
|
|
222
|
+
listUserRoutines() {
|
|
229
223
|
return __awaiter(this, void 0, void 0, function* () {
|
|
230
224
|
try {
|
|
231
225
|
let params = {
|
|
232
|
-
action: '
|
|
226
|
+
action: 'ListUserRoutines',
|
|
233
227
|
version: '2024-09-10',
|
|
234
228
|
protocol: 'https',
|
|
235
229
|
method: 'GET',
|
|
@@ -250,48 +244,7 @@ export class ApiService {
|
|
|
250
244
|
};
|
|
251
245
|
const res = yield this.client.callApi(params, request, runtime);
|
|
252
246
|
if (res.statusCode === 200 && res.body) {
|
|
253
|
-
|
|
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() {
|
|
266
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
-
try {
|
|
268
|
-
let params = {
|
|
269
|
-
action: 'GetRoutineUserInfo',
|
|
270
|
-
version: '2024-09-10',
|
|
271
|
-
protocol: 'https',
|
|
272
|
-
method: 'GET',
|
|
273
|
-
authType: 'AK',
|
|
274
|
-
bodyType: 'json',
|
|
275
|
-
reqBodyType: 'json',
|
|
276
|
-
style: 'RPC',
|
|
277
|
-
pathname: '/',
|
|
278
|
-
toMap: function () {
|
|
279
|
-
return this;
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
let request = new $OpenApi.OpenApiRequest();
|
|
283
|
-
let runtime = {
|
|
284
|
-
toMap: function () {
|
|
285
|
-
return this;
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
const res = yield this.client.callApi(params, request, runtime);
|
|
289
|
-
if (res.statusCode === 200 && res.body) {
|
|
290
|
-
const ret = {
|
|
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,6 @@ 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, _g, _h;
|
|
573
525
|
try {
|
|
574
526
|
let params = {
|
|
575
527
|
action: 'GetRoutine',
|
|
@@ -599,16 +551,7 @@ export class ApiService {
|
|
|
599
551
|
if (res.statusCode === 200 && res.body) {
|
|
600
552
|
const routineResponse = {
|
|
601
553
|
code: res.statusCode,
|
|
602
|
-
data:
|
|
603
|
-
RequestId: (_a = res.body) === null || _a === void 0 ? void 0 : _a.RequestId,
|
|
604
|
-
CodeVersions: ((_b = res.body) === null || _b === void 0 ? void 0 : _b.CodeVersions) || [],
|
|
605
|
-
RelatedRecords: ((_c = res.body) === null || _c === void 0 ? void 0 : _c.RelatedRecords) || [],
|
|
606
|
-
Envs: ((_d = res.body) === null || _d === void 0 ? void 0 : _d.Envs) || [],
|
|
607
|
-
CreateTime: (_e = res.body) === null || _e === void 0 ? void 0 : _e.CreateTime,
|
|
608
|
-
Description: (_f = res.body) === null || _f === void 0 ? void 0 : _f.Description,
|
|
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
|
|
611
|
-
}
|
|
554
|
+
data: res.body
|
|
612
555
|
};
|
|
613
556
|
return routineResponse;
|
|
614
557
|
}
|
|
@@ -641,7 +584,7 @@ export class ApiService {
|
|
|
641
584
|
query: {
|
|
642
585
|
Name: edgeRoutine.name,
|
|
643
586
|
Description: edgeRoutine.description,
|
|
644
|
-
|
|
587
|
+
HasAssets: edgeRoutine.hasAssets
|
|
645
588
|
}
|
|
646
589
|
});
|
|
647
590
|
let runtime = {
|
|
@@ -696,7 +639,7 @@ export class ApiService {
|
|
|
696
639
|
}
|
|
697
640
|
};
|
|
698
641
|
const uploadResult = yield this.client.callApi(params, request, runtime);
|
|
699
|
-
const ossConfig =
|
|
642
|
+
const ossConfig = uploadResult.body.OssPostConfig;
|
|
700
643
|
if (uploadResult.statusCode !== 200 || !ossConfig) {
|
|
701
644
|
return false;
|
|
702
645
|
}
|
|
@@ -709,7 +652,6 @@ export class ApiService {
|
|
|
709
652
|
formData.append('policy', policy);
|
|
710
653
|
formData.append('key', key);
|
|
711
654
|
formData.append('file', edgeRoutine.code);
|
|
712
|
-
// TODO: 检查oss结果;
|
|
713
655
|
const ossRes = yield fetch(Url, {
|
|
714
656
|
method: 'POST',
|
|
715
657
|
body: formData,
|
|
@@ -772,11 +714,11 @@ export class ApiService {
|
|
|
772
714
|
return null;
|
|
773
715
|
});
|
|
774
716
|
}
|
|
775
|
-
|
|
717
|
+
createRoutineRelatedRecord(requestParams) {
|
|
776
718
|
return __awaiter(this, void 0, void 0, function* () {
|
|
777
719
|
try {
|
|
778
720
|
let params = {
|
|
779
|
-
action: '
|
|
721
|
+
action: 'CreateRoutineRelatedRecord',
|
|
780
722
|
version: '2024-09-10',
|
|
781
723
|
protocol: 'https',
|
|
782
724
|
method: 'GET',
|
|
@@ -789,7 +731,14 @@ export class ApiService {
|
|
|
789
731
|
return this;
|
|
790
732
|
}
|
|
791
733
|
};
|
|
792
|
-
let request = new $OpenApi.OpenApiRequest(
|
|
734
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
735
|
+
query: {
|
|
736
|
+
RecordName: requestParams.RecordName,
|
|
737
|
+
SiteId: requestParams.SiteId,
|
|
738
|
+
SiteName: requestParams.SiteName,
|
|
739
|
+
Name: requestParams.Name
|
|
740
|
+
}
|
|
741
|
+
});
|
|
793
742
|
let runtime = {
|
|
794
743
|
toMap: function () {
|
|
795
744
|
return this;
|
|
@@ -800,8 +749,8 @@ export class ApiService {
|
|
|
800
749
|
const ret = {
|
|
801
750
|
code: res.statusCode,
|
|
802
751
|
data: {
|
|
803
|
-
|
|
804
|
-
|
|
752
|
+
Status: res.body.Status,
|
|
753
|
+
RequestId: res.body.RequestId
|
|
805
754
|
}
|
|
806
755
|
};
|
|
807
756
|
return ret;
|
|
@@ -813,11 +762,11 @@ export class ApiService {
|
|
|
813
762
|
return null;
|
|
814
763
|
});
|
|
815
764
|
}
|
|
816
|
-
|
|
765
|
+
deleteRoutineRelatedRecord(requestParams) {
|
|
817
766
|
return __awaiter(this, void 0, void 0, function* () {
|
|
818
767
|
try {
|
|
819
768
|
let params = {
|
|
820
|
-
action: '
|
|
769
|
+
action: 'DeleteRoutineRelatedRecord',
|
|
821
770
|
version: '2024-09-10',
|
|
822
771
|
protocol: 'https',
|
|
823
772
|
method: 'GET',
|
|
@@ -835,7 +784,8 @@ export class ApiService {
|
|
|
835
784
|
RecordName: requestParams.RecordName,
|
|
836
785
|
SiteId: requestParams.SiteId,
|
|
837
786
|
SiteName: requestParams.SiteName,
|
|
838
|
-
Name: requestParams.Name
|
|
787
|
+
Name: requestParams.Name,
|
|
788
|
+
RecordId: requestParams.RecordId
|
|
839
789
|
}
|
|
840
790
|
});
|
|
841
791
|
let runtime = {
|
|
@@ -861,11 +811,11 @@ export class ApiService {
|
|
|
861
811
|
return null;
|
|
862
812
|
});
|
|
863
813
|
}
|
|
864
|
-
|
|
814
|
+
listRoutineRelatedRecords(requestParams) {
|
|
865
815
|
return __awaiter(this, void 0, void 0, function* () {
|
|
866
816
|
try {
|
|
867
817
|
let params = {
|
|
868
|
-
action: '
|
|
818
|
+
action: 'ListRoutineRelatedRecords',
|
|
869
819
|
version: '2024-09-10',
|
|
870
820
|
protocol: 'https',
|
|
871
821
|
method: 'GET',
|
|
@@ -880,11 +830,194 @@ export class ApiService {
|
|
|
880
830
|
};
|
|
881
831
|
let request = new $OpenApi.OpenApiRequest({
|
|
882
832
|
query: {
|
|
883
|
-
|
|
833
|
+
Name: requestParams.Name,
|
|
834
|
+
PageNumber: requestParams.PageNumber,
|
|
835
|
+
PageSize: requestParams.PageSize,
|
|
836
|
+
SearchKeyWord: requestParams.SearchKeyWord
|
|
837
|
+
}
|
|
838
|
+
});
|
|
839
|
+
let runtime = {
|
|
840
|
+
toMap: function () {
|
|
841
|
+
return this;
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
const res = yield this.client.callApi(params, request, runtime);
|
|
845
|
+
if (res.statusCode === 200 && res.body) {
|
|
846
|
+
const ret = {
|
|
847
|
+
code: res.statusCode,
|
|
848
|
+
data: {
|
|
849
|
+
PageNumber: res.body.PageNumber,
|
|
850
|
+
PageSize: res.body.PageSize,
|
|
851
|
+
TotalCount: res.body.TotalCount,
|
|
852
|
+
RelatedRecords: res.body.RelatedRecords
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
return ret;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
catch (error) {
|
|
859
|
+
console.log(error);
|
|
860
|
+
}
|
|
861
|
+
return null;
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
createRoutineRoute(requestParams) {
|
|
865
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
866
|
+
try {
|
|
867
|
+
let params = {
|
|
868
|
+
action: 'CreateRoutineRoute',
|
|
869
|
+
version: '2024-09-10',
|
|
870
|
+
protocol: 'https',
|
|
871
|
+
method: 'POST',
|
|
872
|
+
authType: 'AK',
|
|
873
|
+
bodyType: 'json',
|
|
874
|
+
reqBodyType: 'json',
|
|
875
|
+
style: 'RPC',
|
|
876
|
+
pathname: '/',
|
|
877
|
+
toMap: function () {
|
|
878
|
+
return this;
|
|
879
|
+
}
|
|
880
|
+
};
|
|
881
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
882
|
+
query: {
|
|
884
883
|
SiteId: requestParams.SiteId,
|
|
885
|
-
|
|
884
|
+
RoutineName: requestParams.RoutineName,
|
|
885
|
+
RouteName: requestParams.RouteName,
|
|
886
|
+
RouteEnable: 'on',
|
|
887
|
+
Rule: requestParams.Rule,
|
|
888
|
+
Bypass: requestParams.Bypass,
|
|
889
|
+
Mode: 'simple'
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
let runtime = {
|
|
893
|
+
toMap: function () {
|
|
894
|
+
return this;
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
const res = yield this.client.callApi(params, request, runtime);
|
|
898
|
+
if (res.statusCode === 200 && res.body) {
|
|
899
|
+
const ret = {
|
|
900
|
+
code: res.statusCode,
|
|
901
|
+
data: {
|
|
902
|
+
RequestId: res.body.RequestId,
|
|
903
|
+
ConfigId: res.body.ConfigId
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
return ret;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
catch (error) {
|
|
910
|
+
console.log(error);
|
|
911
|
+
}
|
|
912
|
+
return null;
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* 调用 CreateRoutineWithAssetsCodeVersion API 获取 OSS 上传配置
|
|
917
|
+
*/
|
|
918
|
+
CreateRoutineWithAssetsCodeVersion(requestParams) {
|
|
919
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
920
|
+
var _a;
|
|
921
|
+
try {
|
|
922
|
+
let params = {
|
|
923
|
+
action: 'CreateRoutineWithAssetsCodeVersion',
|
|
924
|
+
version: '2024-09-10',
|
|
925
|
+
protocol: 'https',
|
|
926
|
+
method: 'POST',
|
|
927
|
+
authType: 'AK',
|
|
928
|
+
bodyType: 'json',
|
|
929
|
+
reqBodyType: 'json',
|
|
930
|
+
style: 'RPC',
|
|
931
|
+
pathname: '/',
|
|
932
|
+
toMap: function () {
|
|
933
|
+
return this;
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
937
|
+
body: {
|
|
886
938
|
Name: requestParams.Name,
|
|
887
|
-
|
|
939
|
+
CodeDescription: requestParams.CodeDescription,
|
|
940
|
+
ExtraInfo: requestParams.ExtraInfo,
|
|
941
|
+
ConfOptions: {
|
|
942
|
+
NotFoundStrategy: (_a = requestParams.ConfOptions) === null || _a === void 0 ? void 0 : _a.NotFoundStrategy
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
let runtime = {
|
|
947
|
+
toMap: function () {
|
|
948
|
+
return this;
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
const result = yield this.client.callApi(params, request, runtime);
|
|
952
|
+
if (result.statusCode === 200 && result.body) {
|
|
953
|
+
return {
|
|
954
|
+
code: result.statusCode.toString(),
|
|
955
|
+
data: {
|
|
956
|
+
RequestId: result.body.RequestId,
|
|
957
|
+
CodeVersion: result.body.CodeVersion,
|
|
958
|
+
Status: result.body.Status,
|
|
959
|
+
OssPostConfig: result.body.OssPostConfig
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
return null;
|
|
964
|
+
}
|
|
965
|
+
catch (error) {
|
|
966
|
+
console.error('Error calling CreateRoutineWithAssetsCodeVersion:', error);
|
|
967
|
+
return null;
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* 上传文件到 OSS
|
|
973
|
+
*/
|
|
974
|
+
uploadToOss(ossConfig, zipBuffer) {
|
|
975
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
976
|
+
try {
|
|
977
|
+
const { OSSAccessKeyId, Signature, Url, Key, Policy, XOssSecurityToken } = ossConfig;
|
|
978
|
+
const formData = new FormData();
|
|
979
|
+
formData.append('OSSAccessKeyId', OSSAccessKeyId);
|
|
980
|
+
formData.append('Signature', Signature);
|
|
981
|
+
formData.append('x-oss-security-token', XOssSecurityToken);
|
|
982
|
+
formData.append('policy', Policy);
|
|
983
|
+
formData.append('key', Key);
|
|
984
|
+
formData.append('file', zipBuffer);
|
|
985
|
+
const ossRes = yield fetch(Url, {
|
|
986
|
+
method: 'POST',
|
|
987
|
+
body: formData,
|
|
988
|
+
headers: formData.getHeaders()
|
|
989
|
+
});
|
|
990
|
+
return ossRes && (ossRes.status === 200 || ossRes.status === 204);
|
|
991
|
+
}
|
|
992
|
+
catch (error) {
|
|
993
|
+
console.error('Error uploading to OSS:', error);
|
|
994
|
+
return false;
|
|
995
|
+
}
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
createRoutineCodeDeployment(requestParams) {
|
|
999
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1000
|
+
try {
|
|
1001
|
+
let params = {
|
|
1002
|
+
action: 'CreateRoutineCodeDeployment',
|
|
1003
|
+
version: '2024-09-10',
|
|
1004
|
+
protocol: 'https',
|
|
1005
|
+
method: 'POST',
|
|
1006
|
+
authType: 'AK',
|
|
1007
|
+
bodyType: 'json',
|
|
1008
|
+
reqBodyType: 'json',
|
|
1009
|
+
style: 'RPC',
|
|
1010
|
+
pathname: '/',
|
|
1011
|
+
toMap: function () {
|
|
1012
|
+
return this;
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
1016
|
+
query: {
|
|
1017
|
+
Name: requestParams.Name,
|
|
1018
|
+
Env: requestParams.Env,
|
|
1019
|
+
Strategy: requestParams.Strategy,
|
|
1020
|
+
CodeVersions: JSON.stringify(requestParams.CodeVersions)
|
|
888
1021
|
}
|
|
889
1022
|
});
|
|
890
1023
|
let runtime = {
|
|
@@ -897,8 +1030,10 @@ export class ApiService {
|
|
|
897
1030
|
const ret = {
|
|
898
1031
|
code: res.statusCode,
|
|
899
1032
|
data: {
|
|
900
|
-
|
|
901
|
-
|
|
1033
|
+
RequestId: res.body.RequestId,
|
|
1034
|
+
Strategy: res.body.Strategy,
|
|
1035
|
+
DeploymentId: res.body.DeploymentId,
|
|
1036
|
+
CodeVersions: res.body.CodeVersions
|
|
902
1037
|
}
|
|
903
1038
|
};
|
|
904
1039
|
return ret;
|
|
@@ -910,5 +1045,48 @@ export class ApiService {
|
|
|
910
1045
|
return null;
|
|
911
1046
|
});
|
|
912
1047
|
}
|
|
1048
|
+
getRoutineCodeVersionInfo(requestParams) {
|
|
1049
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1050
|
+
try {
|
|
1051
|
+
let params = {
|
|
1052
|
+
action: 'GetRoutineCodeVersionInfo',
|
|
1053
|
+
version: '2024-09-10',
|
|
1054
|
+
protocol: 'https',
|
|
1055
|
+
method: 'GET',
|
|
1056
|
+
authType: 'AK',
|
|
1057
|
+
bodyType: 'json',
|
|
1058
|
+
reqBodyType: 'json',
|
|
1059
|
+
style: 'RPC',
|
|
1060
|
+
pathname: '/',
|
|
1061
|
+
toMap: function () {
|
|
1062
|
+
return this;
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
1066
|
+
query: {
|
|
1067
|
+
Name: requestParams.Name,
|
|
1068
|
+
CodeVersion: requestParams.CodeVersion
|
|
1069
|
+
}
|
|
1070
|
+
});
|
|
1071
|
+
let runtime = {
|
|
1072
|
+
toMap: function () {
|
|
1073
|
+
return this;
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
const res = yield this.client.callApi(params, request, runtime);
|
|
1077
|
+
if (res.statusCode === 200 && res.body) {
|
|
1078
|
+
const ret = {
|
|
1079
|
+
code: res.statusCode,
|
|
1080
|
+
data: res.body
|
|
1081
|
+
};
|
|
1082
|
+
return ret;
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
catch (error) {
|
|
1086
|
+
console.log(error);
|
|
1087
|
+
}
|
|
1088
|
+
return null;
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
913
1091
|
}
|
|
914
1092
|
ApiService.instance = null;
|
package/dist/libs/git/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { execSync } from 'child_process';
|
|
11
|
-
import
|
|
11
|
+
import logger from '../../libs/logger.js';
|
|
12
12
|
export function isInstalledGit() {
|
|
13
13
|
try {
|
|
14
14
|
execSync('git --version');
|
|
@@ -30,23 +30,100 @@ export function isGitConfigured() {
|
|
|
30
30
|
}
|
|
31
31
|
export function cloneRepository(url, path) {
|
|
32
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
if (!isInstalledGit()) {
|
|
34
|
+
logger.error('Git is not installed on your system.');
|
|
35
|
+
logger.info('Please install Git first:');
|
|
36
|
+
logger.info(' • macOS: brew install git');
|
|
37
|
+
logger.info(' • Ubuntu/Debian: sudo apt-get install git');
|
|
38
|
+
logger.info(' • Windows: Download from https://git-scm.com/');
|
|
39
|
+
logger.info(' • Or visit: https://git-scm.com/downloads');
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
33
42
|
try {
|
|
34
43
|
execSync(`git clone ${url} ${path}`, { stdio: 'inherit' });
|
|
35
|
-
|
|
44
|
+
logger.log('Repository cloned successfully.');
|
|
45
|
+
return true;
|
|
36
46
|
}
|
|
37
47
|
catch (error) {
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
logger.error(`Error occurred while cloning the repository: ${error}`);
|
|
49
|
+
return false;
|
|
40
50
|
}
|
|
41
51
|
});
|
|
42
52
|
}
|
|
43
|
-
export function installGit(path) {
|
|
53
|
+
export function installGit(path, debug = false, autoInstall = false) {
|
|
54
|
+
if (!isInstalledGit()) {
|
|
55
|
+
if (autoInstall) {
|
|
56
|
+
logger.info('Git not found. Attempting to auto-install...');
|
|
57
|
+
if (autoInstallGit()) {
|
|
58
|
+
logger.info('Git installed successfully! Now initializing repository...');
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
logger.error('Failed to auto-install Git.');
|
|
62
|
+
logger.info('Please install Git manually:');
|
|
63
|
+
logger.info(' • macOS: brew install git');
|
|
64
|
+
logger.info(' • Ubuntu/Debian: sudo apt-get install git');
|
|
65
|
+
logger.info(' • Windows: Download from https://git-scm.com/');
|
|
66
|
+
logger.info(' • Or visit: https://git-scm.com/downloads');
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
logger.error('Git is not installed on your system.');
|
|
72
|
+
logger.info('Please install Git first:');
|
|
73
|
+
logger.info(' • macOS: brew install git');
|
|
74
|
+
logger.info(' • Ubuntu/Debian: sudo apt-get install git');
|
|
75
|
+
logger.info(' • Windows: Download from https://git-scm.com/');
|
|
76
|
+
logger.info(' • Or visit: https://git-scm.com/downloads');
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
execSync('git init', { stdio: 'ignore', cwd: path });
|
|
82
|
+
if (debug) {
|
|
83
|
+
logger.log('Git repository initialized successfully.');
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
logger.error(`Error occurred while initializing Git repository: ${error}`);
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Attempt to automatically install Git on supported platforms
|
|
94
|
+
* @returns true if installation was successful, false otherwise
|
|
95
|
+
*/
|
|
96
|
+
export function autoInstallGit() {
|
|
44
97
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
98
|
+
const platform = process.platform;
|
|
99
|
+
if (platform === 'darwin') {
|
|
100
|
+
// macOS - try using Homebrew
|
|
101
|
+
logger.info('Attempting to install Git using Homebrew...');
|
|
102
|
+
execSync('brew install git', { stdio: 'inherit' });
|
|
103
|
+
logger.success('Git installed successfully via Homebrew!');
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
else if (platform === 'linux') {
|
|
107
|
+
// Linux - try using apt-get (Ubuntu/Debian)
|
|
108
|
+
logger.info('Attempting to install Git using apt-get...');
|
|
109
|
+
execSync('sudo apt-get update && sudo apt-get install -y git', {
|
|
110
|
+
stdio: 'inherit'
|
|
111
|
+
});
|
|
112
|
+
logger.success('Git installed successfully via apt-get!');
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
logger.warn('Auto-installation is not supported on this platform.');
|
|
117
|
+
logger.info('Please install Git manually from: https://git-scm.com/downloads');
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
47
120
|
}
|
|
48
121
|
catch (error) {
|
|
49
|
-
|
|
50
|
-
|
|
122
|
+
logger.error(`Failed to auto-install Git: ${error}`);
|
|
123
|
+
logger.info('Please install Git manually:');
|
|
124
|
+
logger.info(' • macOS: brew install git');
|
|
125
|
+
logger.info(' • Ubuntu/Debian: sudo apt-get install git');
|
|
126
|
+
logger.info(' • Windows: Download from https://git-scm.com/');
|
|
127
|
+
return false;
|
|
51
128
|
}
|
|
52
129
|
}
|
package/dist/libs/interface.js
CHANGED