esa-cli 0.0.5 → 1.0.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/README.md +32 -149
- package/dist/commands/commit/index.js +49 -104
- package/dist/commands/commit/prodBuild.js +2 -3
- package/dist/commands/common/constant.js +4 -4
- package/dist/commands/common/utils.js +419 -0
- package/dist/commands/config.js +2 -2
- package/dist/commands/deploy/helper.js +43 -49
- package/dist/commands/deploy/index.js +51 -174
- package/dist/commands/deployments/delete.js +32 -22
- package/dist/commands/deployments/index.js +4 -4
- package/dist/commands/deployments/list.js +21 -34
- 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 +31 -20
- package/dist/commands/dev/ew2/kvService.js +50 -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 +163 -28
- package/dist/commands/dev/index.js +17 -18
- package/dist/commands/dev/mockWorker/devPack.js +19 -10
- package/dist/commands/dev/mockWorker/server.js +7 -6
- package/dist/commands/domain/add.js +4 -4
- package/dist/commands/domain/delete.js +3 -3
- package/dist/commands/domain/index.js +4 -4
- package/dist/commands/domain/list.js +7 -7
- package/dist/commands/init/helper.js +654 -21
- package/dist/commands/init/index.js +88 -152
- 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 +101 -43
- package/dist/commands/route/delete.js +6 -6
- package/dist/commands/route/helper.js +9 -10
- package/dist/commands/route/index.js +4 -4
- package/dist/commands/route/list.js +4 -4
- package/dist/commands/routine/delete.js +9 -8
- package/dist/commands/routine/index.js +6 -5
- package/dist/commands/routine/list.js +45 -39
- package/dist/commands/site/index.js +3 -3
- package/dist/commands/site/list.js +6 -7
- package/dist/commands/utils.js +61 -25
- package/dist/components/descriptionInput.js +1 -1
- package/dist/components/filterSelector.js +1 -1
- package/dist/components/mutiLevelSelect.js +19 -20
- package/dist/components/mutiSelectTable.js +1 -1
- package/dist/components/routeBuilder.js +68 -0
- package/dist/components/selectInput.js +2 -3
- package/dist/components/selectItem.js +1 -1
- package/dist/docs/Commands_en.md +164 -117
- package/dist/docs/Commands_zh_CN.md +155 -107
- package/dist/docs/Config_en.md +70 -0
- package/dist/docs/Config_zh_CN.md +68 -0
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/locales.json +414 -82
- package/dist/index.js +28 -13
- package/dist/libs/api.js +3 -6
- package/dist/libs/apiService.js +192 -69
- 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 +1 -1
- package/dist/utils/checkAssetsExist.js +80 -0
- package/dist/utils/checkDevPort.js +5 -19
- package/dist/utils/checkEntryFileExist.js +10 -0
- package/dist/utils/checkIsRoutineCreated.js +27 -21
- package/dist/utils/checkVersion.js +119 -1
- package/dist/utils/command.js +149 -0
- package/dist/utils/compress.js +142 -0
- package/dist/utils/download.js +8 -8
- package/dist/utils/fileMd5.js +1 -1
- package/dist/utils/fileUtils/index.js +136 -45
- package/dist/utils/installDeno.js +4 -4
- package/dist/utils/installEw2.js +9 -9
- package/dist/utils/openInBrowser.js +1 -1
- package/dist/utils/prompt.js +97 -0
- package/package.json +23 -12
- package/zh_CN.md +29 -154
package/dist/index.js
CHANGED
|
@@ -7,25 +7,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import chalk from 'chalk';
|
|
10
11
|
import yargs from 'yargs';
|
|
11
12
|
import { hideBin } from 'yargs/helpers';
|
|
12
|
-
import
|
|
13
|
-
import login from './commands/login/index.js';
|
|
13
|
+
import commit from './commands/commit/index.js';
|
|
14
14
|
import config from './commands/config.js';
|
|
15
|
-
import dev from './commands/dev/index.js';
|
|
16
|
-
import init from './commands/init/index.js';
|
|
17
|
-
import routine from './commands/routine/index.js';
|
|
18
15
|
import deploy from './commands/deploy/index.js';
|
|
19
|
-
import commit from './commands/commit/index.js';
|
|
20
16
|
import deployments from './commands/deployments/index.js';
|
|
17
|
+
import dev from './commands/dev/index.js';
|
|
21
18
|
import domainCommand from './commands/domain/index.js';
|
|
22
|
-
import
|
|
23
|
-
import logout from './commands/logout.js';
|
|
19
|
+
import init from './commands/init/index.js';
|
|
24
20
|
import lang from './commands/lang.js';
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
21
|
+
import login from './commands/login/index.js';
|
|
22
|
+
import logout from './commands/logout.js';
|
|
23
|
+
import routeCommand from './commands/route/index.js';
|
|
24
|
+
import routine from './commands/routine/index.js';
|
|
28
25
|
import site from './commands/site/index.js';
|
|
26
|
+
import t from './i18n/index.js';
|
|
27
|
+
import { handleCheckVersion, checkCLIVersion } from './utils/checkVersion.js';
|
|
28
|
+
import { getCliConfig } from './utils/fileUtils/index.js';
|
|
29
29
|
const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
30
|
const argv = hideBin(process.argv);
|
|
31
31
|
const cliConfig = getCliConfig();
|
|
@@ -34,11 +34,21 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
34
34
|
.fail((msg, err) => {
|
|
35
35
|
console.error(msg, err);
|
|
36
36
|
})
|
|
37
|
-
.scriptName('esa')
|
|
37
|
+
.scriptName('esa-cli')
|
|
38
38
|
.locale((cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.lang) || 'en')
|
|
39
39
|
.version(false)
|
|
40
40
|
.wrap(null)
|
|
41
|
-
.help(
|
|
41
|
+
.help()
|
|
42
|
+
.middleware((argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
+
try {
|
|
44
|
+
// Pass current command (first positional) so version check can decide prompting behavior
|
|
45
|
+
yield checkCLIVersion((argv._ && argv._[0] ? String(argv._[0]) : ''));
|
|
46
|
+
}
|
|
47
|
+
catch (e) {
|
|
48
|
+
console.log(e);
|
|
49
|
+
console.log('error');
|
|
50
|
+
}
|
|
51
|
+
}))
|
|
42
52
|
.epilogue(`${t('main_epilogue').d('For more information, visit ESA')}: ${chalk.underline.blue('https://www.aliyun.com/product/esa')}`)
|
|
43
53
|
.options('version', {
|
|
44
54
|
describe: t('main_version_describe').d('Show version'),
|
|
@@ -50,11 +60,16 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
50
60
|
});
|
|
51
61
|
esa.command('*', false, () => { }, (args) => {
|
|
52
62
|
if (args._.length > 0) {
|
|
63
|
+
// Unknown command
|
|
64
|
+
console.error(t('common_sub_command_fail').d('Use esa-cli <command> -h to see help'));
|
|
53
65
|
}
|
|
54
66
|
else {
|
|
55
67
|
if (args.v) {
|
|
56
68
|
handleCheckVersion();
|
|
57
69
|
}
|
|
70
|
+
else if (args.h || args.help) {
|
|
71
|
+
esa.showHelp('log');
|
|
72
|
+
}
|
|
58
73
|
else {
|
|
59
74
|
esa.showHelp('log');
|
|
60
75
|
}
|
package/dist/libs/api.js
CHANGED
|
@@ -103,16 +103,13 @@ class Client {
|
|
|
103
103
|
getMatchSite(params) {
|
|
104
104
|
return this.callOpenApi('getMatchSite', params);
|
|
105
105
|
}
|
|
106
|
-
listRoutineCanaryAreas() {
|
|
107
|
-
return this.callApi(this.client.listRoutineCanaryAreasWithOptions.bind(this.client));
|
|
108
|
-
}
|
|
109
|
-
getRoutineUserInfo() {
|
|
110
|
-
return this.callApi(this.client.getRoutineUserInfoWithOptions.bind(this.client));
|
|
111
|
-
}
|
|
112
106
|
deleteRoutine(params) {
|
|
113
107
|
const request = new $ESA.DeleteRoutineRequest(params);
|
|
114
108
|
return this.callApi(this.client.deleteRoutineWithOptions.bind(this.client), request);
|
|
115
109
|
}
|
|
110
|
+
listUserRoutines(params) {
|
|
111
|
+
return this.callApi(this.client.listUserRoutinesWithOptions.bind(this.client), new $ESA.ListUserRoutinesRequest(params));
|
|
112
|
+
}
|
|
116
113
|
deleteRoutineCodeVersion(params) {
|
|
117
114
|
const request = new $ESA.DeleteRoutineCodeVersionRequest(params);
|
|
118
115
|
return this.callApi(this.client.deleteRoutineCodeVersionWithOptions.bind(this.client), request);
|
package/dist/libs/apiService.js
CHANGED
|
@@ -10,9 +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
13
|
import t from '../i18n/index.js';
|
|
14
|
+
import { getApiConfig } from '../utils/fileUtils/index.js';
|
|
15
|
+
import { Environment } from './interface.js';
|
|
16
16
|
export class ApiService {
|
|
17
17
|
constructor(cliConfig) {
|
|
18
18
|
var _a, _b;
|
|
@@ -48,7 +48,7 @@ export class ApiService {
|
|
|
48
48
|
* - message: (Optional) A string providing additional information in case of failure.
|
|
49
49
|
*/
|
|
50
50
|
checkLogin() {
|
|
51
|
-
return __awaiter(this,
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
52
|
try {
|
|
53
53
|
let params = {
|
|
54
54
|
action: 'GetErService',
|
|
@@ -90,7 +90,6 @@ export class ApiService {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
catch (error) {
|
|
93
|
-
isShowError && console.log(error);
|
|
94
93
|
return {
|
|
95
94
|
success: false,
|
|
96
95
|
message: t('login_failed').d('An error occurred while trying to log in.')
|
|
@@ -101,15 +100,15 @@ export class ApiService {
|
|
|
101
100
|
quickDeployRoutine(edgeRoutine) {
|
|
102
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
102
|
try {
|
|
104
|
-
//
|
|
103
|
+
// Upload code to unstable version
|
|
105
104
|
const stagingRes = yield this.getRoutineStagingCodeUploadInfo(edgeRoutine);
|
|
106
105
|
if (stagingRes) {
|
|
107
|
-
//
|
|
106
|
+
// Production version
|
|
108
107
|
const commitRes = yield this.commitRoutineStagingCode({
|
|
109
108
|
Name: edgeRoutine.name,
|
|
110
109
|
CodeDescription: edgeRoutine.description
|
|
111
110
|
});
|
|
112
|
-
//
|
|
111
|
+
// Deploy to production environment
|
|
113
112
|
if (commitRes) {
|
|
114
113
|
const deployRes = yield this.publishRoutineCodeVersion({
|
|
115
114
|
Name: edgeRoutine.name,
|
|
@@ -129,7 +128,6 @@ export class ApiService {
|
|
|
129
128
|
}
|
|
130
129
|
publishRoutineCodeVersion(requestParams) {
|
|
131
130
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
var _a;
|
|
133
131
|
try {
|
|
134
132
|
let params = {
|
|
135
133
|
action: 'PublishRoutineCodeVersion',
|
|
@@ -145,15 +143,11 @@ export class ApiService {
|
|
|
145
143
|
return this;
|
|
146
144
|
}
|
|
147
145
|
};
|
|
148
|
-
const CanaryAreaList = (_a = requestParams.CanaryAreaList) !== null && _a !== void 0 ? _a : [];
|
|
149
|
-
const CanaryAreaListString = JSON.stringify(CanaryAreaList);
|
|
150
146
|
let request = new $OpenApi.OpenApiRequest({
|
|
151
147
|
query: {
|
|
152
148
|
Env: requestParams.Env,
|
|
153
149
|
Name: requestParams.Name,
|
|
154
|
-
CodeVersion: requestParams.CodeVersion
|
|
155
|
-
CanaryCodeVersion: requestParams.CanaryCodeVersion,
|
|
156
|
-
CanaryAreaList: CanaryAreaListString
|
|
150
|
+
CodeVersion: requestParams.CodeVersion
|
|
157
151
|
}
|
|
158
152
|
});
|
|
159
153
|
let runtime = {
|
|
@@ -224,11 +218,11 @@ export class ApiService {
|
|
|
224
218
|
return null;
|
|
225
219
|
});
|
|
226
220
|
}
|
|
227
|
-
|
|
221
|
+
listUserRoutines(requestParams) {
|
|
228
222
|
return __awaiter(this, void 0, void 0, function* () {
|
|
229
223
|
try {
|
|
230
224
|
let params = {
|
|
231
|
-
action: '
|
|
225
|
+
action: 'ListUserRoutines',
|
|
232
226
|
version: '2024-09-10',
|
|
233
227
|
protocol: 'https',
|
|
234
228
|
method: 'GET',
|
|
@@ -241,44 +235,9 @@ export class ApiService {
|
|
|
241
235
|
return this;
|
|
242
236
|
}
|
|
243
237
|
};
|
|
244
|
-
let request = new $OpenApi.OpenApiRequest(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return this;
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
const res = yield this.client.callApi(params, request, runtime);
|
|
251
|
-
if (res.statusCode === 200 && res.body) {
|
|
252
|
-
const ret = {
|
|
253
|
-
CanaryAreas: res.body.CanaryAreas
|
|
254
|
-
};
|
|
255
|
-
return ret;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
catch (error) {
|
|
259
|
-
console.log(error);
|
|
260
|
-
}
|
|
261
|
-
return null;
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
getRoutineUserInfo() {
|
|
265
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
-
try {
|
|
267
|
-
let params = {
|
|
268
|
-
action: 'GetRoutineUserInfo',
|
|
269
|
-
version: '2024-09-10',
|
|
270
|
-
protocol: 'https',
|
|
271
|
-
method: 'GET',
|
|
272
|
-
authType: 'AK',
|
|
273
|
-
bodyType: 'json',
|
|
274
|
-
reqBodyType: 'json',
|
|
275
|
-
style: 'RPC',
|
|
276
|
-
pathname: '/',
|
|
277
|
-
toMap: function () {
|
|
278
|
-
return this;
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
let request = new $OpenApi.OpenApiRequest();
|
|
238
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
239
|
+
query: requestParams || {}
|
|
240
|
+
});
|
|
282
241
|
let runtime = {
|
|
283
242
|
toMap: function () {
|
|
284
243
|
return this;
|
|
@@ -286,11 +245,7 @@ export class ApiService {
|
|
|
286
245
|
};
|
|
287
246
|
const res = yield this.client.callApi(params, request, runtime);
|
|
288
247
|
if (res.statusCode === 200 && res.body) {
|
|
289
|
-
|
|
290
|
-
Subdomains: res.body.RoutineName,
|
|
291
|
-
Routines: res.body.Routines
|
|
292
|
-
};
|
|
293
|
-
return ret;
|
|
248
|
+
return res;
|
|
294
249
|
}
|
|
295
250
|
}
|
|
296
251
|
catch (error) {
|
|
@@ -568,7 +523,6 @@ export class ApiService {
|
|
|
568
523
|
}
|
|
569
524
|
getRoutine(requestParams_1) {
|
|
570
525
|
return __awaiter(this, arguments, void 0, function* (requestParams, isShowError = true) {
|
|
571
|
-
var _a, _b, _c, _d, _e, _f;
|
|
572
526
|
try {
|
|
573
527
|
let params = {
|
|
574
528
|
action: 'GetRoutine',
|
|
@@ -598,14 +552,7 @@ export class ApiService {
|
|
|
598
552
|
if (res.statusCode === 200 && res.body) {
|
|
599
553
|
const routineResponse = {
|
|
600
554
|
code: res.statusCode,
|
|
601
|
-
data:
|
|
602
|
-
RequestId: (_a = res.body) === null || _a === void 0 ? void 0 : _a.RequestId,
|
|
603
|
-
CodeVersions: ((_b = res.body) === null || _b === void 0 ? void 0 : _b.CodeVersions) || [],
|
|
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
|
|
608
|
-
}
|
|
555
|
+
data: res.body
|
|
609
556
|
};
|
|
610
557
|
return routineResponse;
|
|
611
558
|
}
|
|
@@ -637,7 +584,8 @@ export class ApiService {
|
|
|
637
584
|
let request = new $OpenApi.OpenApiRequest({
|
|
638
585
|
query: {
|
|
639
586
|
Name: edgeRoutine.name,
|
|
640
|
-
Description: edgeRoutine.description
|
|
587
|
+
Description: edgeRoutine.description,
|
|
588
|
+
HasAssets: edgeRoutine.hasAssets
|
|
641
589
|
}
|
|
642
590
|
});
|
|
643
591
|
let runtime = {
|
|
@@ -710,7 +658,6 @@ export class ApiService {
|
|
|
710
658
|
body: formData,
|
|
711
659
|
headers: formData.getHeaders()
|
|
712
660
|
});
|
|
713
|
-
// console.log('oss result', oss);
|
|
714
661
|
if (ossRes && ossRes.status === 200) {
|
|
715
662
|
return true;
|
|
716
663
|
}
|
|
@@ -966,5 +913,181 @@ export class ApiService {
|
|
|
966
913
|
return null;
|
|
967
914
|
});
|
|
968
915
|
}
|
|
916
|
+
/**
|
|
917
|
+
* 调用 CreateRoutineWithAssetsCodeVersion API 获取 OSS 上传配置
|
|
918
|
+
*/
|
|
919
|
+
CreateRoutineWithAssetsCodeVersion(requestParams) {
|
|
920
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
921
|
+
var _a;
|
|
922
|
+
try {
|
|
923
|
+
let params = {
|
|
924
|
+
action: 'CreateRoutineWithAssetsCodeVersion',
|
|
925
|
+
version: '2024-09-10',
|
|
926
|
+
protocol: 'https',
|
|
927
|
+
method: 'POST',
|
|
928
|
+
authType: 'AK',
|
|
929
|
+
bodyType: 'json',
|
|
930
|
+
reqBodyType: 'json',
|
|
931
|
+
style: 'RPC',
|
|
932
|
+
pathname: '/',
|
|
933
|
+
toMap: function () {
|
|
934
|
+
return this;
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
938
|
+
body: {
|
|
939
|
+
Name: requestParams.Name,
|
|
940
|
+
CodeDescription: requestParams.CodeDescription,
|
|
941
|
+
ExtraInfo: requestParams.ExtraInfo,
|
|
942
|
+
ConfOptions: {
|
|
943
|
+
NotFoundStrategy: (_a = requestParams.ConfOptions) === null || _a === void 0 ? void 0 : _a.NotFoundStrategy
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
let runtime = {
|
|
948
|
+
toMap: function () {
|
|
949
|
+
return this;
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
const result = yield this.client.callApi(params, request, runtime);
|
|
953
|
+
if (result.statusCode === 200 && result.body) {
|
|
954
|
+
return {
|
|
955
|
+
code: result.statusCode.toString(),
|
|
956
|
+
data: {
|
|
957
|
+
RequestId: result.body.RequestId,
|
|
958
|
+
CodeVersion: result.body.CodeVersion,
|
|
959
|
+
Status: result.body.Status,
|
|
960
|
+
OssPostConfig: result.body.OssPostConfig
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
return null;
|
|
965
|
+
}
|
|
966
|
+
catch (error) {
|
|
967
|
+
console.error('Error calling CreateRoutineWithAssetsCodeVersion:', error);
|
|
968
|
+
return null;
|
|
969
|
+
}
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* 上传文件到 OSS
|
|
974
|
+
*/
|
|
975
|
+
uploadToOss(ossConfig, zipBuffer) {
|
|
976
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
977
|
+
try {
|
|
978
|
+
const { OSSAccessKeyId, Signature, Url, Key, Policy, XOssSecurityToken } = ossConfig;
|
|
979
|
+
const formData = new FormData();
|
|
980
|
+
formData.append('OSSAccessKeyId', OSSAccessKeyId);
|
|
981
|
+
formData.append('Signature', Signature);
|
|
982
|
+
formData.append('x-oss-security-token', XOssSecurityToken);
|
|
983
|
+
formData.append('policy', Policy);
|
|
984
|
+
formData.append('key', Key);
|
|
985
|
+
formData.append('file', zipBuffer);
|
|
986
|
+
const ossRes = yield fetch(Url, {
|
|
987
|
+
method: 'POST',
|
|
988
|
+
body: formData,
|
|
989
|
+
headers: formData.getHeaders()
|
|
990
|
+
});
|
|
991
|
+
return ossRes && (ossRes.status === 200 || ossRes.status === 204);
|
|
992
|
+
}
|
|
993
|
+
catch (error) {
|
|
994
|
+
console.error('Error uploading to OSS:', error);
|
|
995
|
+
return false;
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
createRoutineCodeDeployment(requestParams) {
|
|
1000
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1001
|
+
try {
|
|
1002
|
+
let params = {
|
|
1003
|
+
action: 'CreateRoutineCodeDeployment',
|
|
1004
|
+
version: '2024-09-10',
|
|
1005
|
+
protocol: 'https',
|
|
1006
|
+
method: 'POST',
|
|
1007
|
+
authType: 'AK',
|
|
1008
|
+
bodyType: 'json',
|
|
1009
|
+
reqBodyType: 'json',
|
|
1010
|
+
style: 'RPC',
|
|
1011
|
+
pathname: '/',
|
|
1012
|
+
toMap: function () {
|
|
1013
|
+
return this;
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
1017
|
+
query: {
|
|
1018
|
+
Name: requestParams.Name,
|
|
1019
|
+
Env: requestParams.Env,
|
|
1020
|
+
Strategy: requestParams.Strategy,
|
|
1021
|
+
CodeVersions: JSON.stringify(requestParams.CodeVersions)
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
let runtime = {
|
|
1025
|
+
toMap: function () {
|
|
1026
|
+
return this;
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
const res = yield this.client.callApi(params, request, runtime);
|
|
1030
|
+
if (res.statusCode === 200 && res.body) {
|
|
1031
|
+
const ret = {
|
|
1032
|
+
code: res.statusCode,
|
|
1033
|
+
data: {
|
|
1034
|
+
RequestId: res.body.RequestId,
|
|
1035
|
+
Strategy: res.body.Strategy,
|
|
1036
|
+
DeploymentId: res.body.DeploymentId,
|
|
1037
|
+
CodeVersions: res.body.CodeVersions
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
return ret;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
catch (error) {
|
|
1044
|
+
console.log(error);
|
|
1045
|
+
}
|
|
1046
|
+
return null;
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
getRoutineCodeVersionInfo(requestParams) {
|
|
1050
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1051
|
+
try {
|
|
1052
|
+
let params = {
|
|
1053
|
+
action: 'GetRoutineCodeVersionInfo',
|
|
1054
|
+
version: '2024-09-10',
|
|
1055
|
+
protocol: 'https',
|
|
1056
|
+
method: 'GET',
|
|
1057
|
+
authType: 'AK',
|
|
1058
|
+
bodyType: 'json',
|
|
1059
|
+
reqBodyType: 'json',
|
|
1060
|
+
style: 'RPC',
|
|
1061
|
+
pathname: '/',
|
|
1062
|
+
toMap: function () {
|
|
1063
|
+
return this;
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
let request = new $OpenApi.OpenApiRequest({
|
|
1067
|
+
query: {
|
|
1068
|
+
Name: requestParams.Name,
|
|
1069
|
+
CodeVersion: requestParams.CodeVersion
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
let runtime = {
|
|
1073
|
+
toMap: function () {
|
|
1074
|
+
return this;
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
const res = yield this.client.callApi(params, request, runtime);
|
|
1078
|
+
if (res.statusCode === 200 && res.body) {
|
|
1079
|
+
const ret = {
|
|
1080
|
+
code: res.statusCode,
|
|
1081
|
+
data: res.body
|
|
1082
|
+
};
|
|
1083
|
+
return ret;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
catch (error) {
|
|
1087
|
+
console.log(error);
|
|
1088
|
+
}
|
|
1089
|
+
return null;
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
969
1092
|
}
|
|
970
1093
|
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