esa-cli 0.0.1-beta.1
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/LICENSE +21 -0
- package/README.md +175 -0
- package/bin/enter.cjs +52 -0
- package/dist/README.md +175 -0
- package/dist/bin/enter.cjs +52 -0
- package/dist/cliconfig.toml +6 -0
- package/dist/commands/commit/index.js +147 -0
- package/dist/commands/commit/prodBuild.js +50 -0
- package/dist/commands/common/constant.js +54 -0
- package/dist/commands/config.js +51 -0
- package/dist/commands/deploy/helper.js +108 -0
- package/dist/commands/deploy/index.js +217 -0
- package/dist/commands/deployments/delete.js +92 -0
- package/dist/commands/deployments/index.js +27 -0
- package/dist/commands/deployments/list.js +89 -0
- package/dist/commands/dev/config/devBuild.js +26 -0
- package/dist/commands/dev/config/devEntry.js +71 -0
- package/dist/commands/dev/config/mock/cache.js +31 -0
- package/dist/commands/dev/config/mock/kv.js +87 -0
- package/dist/commands/dev/devPack.js +113 -0
- package/dist/commands/dev/doProcess.js +73 -0
- package/dist/commands/dev/index.js +240 -0
- package/dist/commands/dev/server.js +100 -0
- package/dist/commands/domain/add.js +72 -0
- package/dist/commands/domain/delete.js +74 -0
- package/dist/commands/domain/index.js +29 -0
- package/dist/commands/domain/list.js +51 -0
- package/dist/commands/init/index.js +149 -0
- package/dist/commands/lang.js +32 -0
- package/dist/commands/login/index.js +108 -0
- package/dist/commands/logout.js +44 -0
- package/dist/commands/route/add.js +115 -0
- package/dist/commands/route/delete.js +74 -0
- package/dist/commands/route/index.js +29 -0
- package/dist/commands/route/list.js +63 -0
- package/dist/commands/routine/delete.js +54 -0
- package/dist/commands/routine/index.js +27 -0
- package/dist/commands/routine/list.js +101 -0
- package/dist/commands/site/index.js +25 -0
- package/dist/commands/site/list.js +47 -0
- package/dist/commands/utils.js +139 -0
- package/dist/components/descriptionInput.js +38 -0
- package/dist/components/filterSelector.js +132 -0
- package/dist/components/mutiSelectTable.js +95 -0
- package/dist/components/selectInput.js +17 -0
- package/dist/components/selectItem.js +6 -0
- package/dist/components/yesNoPrompt.js +9 -0
- package/dist/docs/Commands_en.md +224 -0
- package/dist/docs/Commands_zh_CN.md +224 -0
- package/dist/docs/dev.png +0 -0
- package/dist/i18n/index.js +27 -0
- package/dist/i18n/locales.json +766 -0
- package/dist/index.js +80 -0
- package/dist/libs/apiService.js +914 -0
- package/dist/libs/git/index.js +52 -0
- package/dist/libs/interface.js +21 -0
- package/dist/libs/logger.js +149 -0
- package/dist/libs/request.js +98 -0
- package/dist/libs/templates/index.js +16 -0
- package/dist/package.json +93 -0
- package/dist/utils/checkDevPort.js +113 -0
- package/dist/utils/checkIsRoutineCreated.js +56 -0
- package/dist/utils/checkVersion.js +26 -0
- package/dist/utils/debounce.js +18 -0
- package/dist/utils/fileUtils/index.js +219 -0
- package/dist/utils/fileUtils/interface.js +1 -0
- package/dist/utils/install/install.ps1 +33 -0
- package/dist/utils/install/install.sh +53 -0
- package/dist/utils/installRuntime.js +80 -0
- package/dist/utils/openInBrowser.js +24 -0
- package/dist/utils/sleep.js +6 -0
- package/dist/zh_CN.md +177 -0
- package/package.json +93 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
import logger from '../../libs/logger.js';
|
|
12
|
+
import { checkDirectory, checkIsLoginSuccess, isValidRouteForDomain } from '../utils.js';
|
|
13
|
+
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
14
|
+
import { ApiService } from '../../libs/apiService.js';
|
|
15
|
+
import t from '../../i18n/index.js';
|
|
16
|
+
import { descriptionInput } from '../../components/descriptionInput.js';
|
|
17
|
+
import { promptFilterSelector } from '../../components/filterSelector.js';
|
|
18
|
+
import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
|
|
19
|
+
const addRoute = {
|
|
20
|
+
command: 'add [route] [site]',
|
|
21
|
+
describe: `📥 ${t('route_add_describe').d('Bind a Route to a routine')}`,
|
|
22
|
+
builder: (yargs) => {
|
|
23
|
+
return yargs.fail((msg, err, yargsIns) => {
|
|
24
|
+
if (err)
|
|
25
|
+
throw err;
|
|
26
|
+
if (msg) {
|
|
27
|
+
console.error(msg);
|
|
28
|
+
yargsIns.showHelp('log');
|
|
29
|
+
}
|
|
30
|
+
process.exit(1);
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
handlerAddRoute(argv);
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
export function handlerAddRoute(argv) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
var _a, _b, _c;
|
|
40
|
+
if (!checkDirectory()) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const projectConfig = getProjectConfig();
|
|
44
|
+
if (!projectConfig)
|
|
45
|
+
return logger.notInProject();
|
|
46
|
+
const isSuccess = yield checkIsLoginSuccess();
|
|
47
|
+
if (!isSuccess)
|
|
48
|
+
return;
|
|
49
|
+
yield validRoutine(projectConfig.name);
|
|
50
|
+
// input route and site
|
|
51
|
+
const { route, site } = argv;
|
|
52
|
+
const listSitesReq = {
|
|
53
|
+
SiteSearchType: 'fuzzy',
|
|
54
|
+
Status: 'active',
|
|
55
|
+
PageNumber: 1,
|
|
56
|
+
PageSize: 500
|
|
57
|
+
};
|
|
58
|
+
const server = yield ApiService.getInstance();
|
|
59
|
+
const ListSitesRes = yield server.listSites(listSitesReq);
|
|
60
|
+
const siteList = ((ListSitesRes === null || ListSitesRes === void 0 ? void 0 : ListSitesRes.data.Sites) || []).map((i) => ({
|
|
61
|
+
label: i.SiteName,
|
|
62
|
+
value: i.SiteId
|
|
63
|
+
}));
|
|
64
|
+
if (route && site) {
|
|
65
|
+
const siteId = (_a = siteList.find((item) => item.label === site)) === null || _a === void 0 ? void 0 : _a.value;
|
|
66
|
+
const req = {
|
|
67
|
+
Name: projectConfig.name,
|
|
68
|
+
SiteId: Number(siteId),
|
|
69
|
+
SiteName: String(site),
|
|
70
|
+
Route: String(route)
|
|
71
|
+
};
|
|
72
|
+
const res = yield server.createRoutineRelatedRoute(req);
|
|
73
|
+
const addSuccess = ((_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.Status) === 'OK';
|
|
74
|
+
if (addSuccess) {
|
|
75
|
+
logger.success(t('route_add_success').d('Add route success!'));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
logger.error(t('route_add_fail').d('Add route fail!'));
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
logger.warn(t('interactive_mode').d('Interactive mode'));
|
|
83
|
+
// not input route and site, enter interactive mode
|
|
84
|
+
logger.log(`🖊️ ${t('domain_input').d('Enter the name of domain (Support fuzzy matching on tab press):')}`);
|
|
85
|
+
const domain = yield promptFilterSelector(siteList);
|
|
86
|
+
const inputRoute = yield descriptionInput(`🖊️ ${t('route_input').d('Enter a Route:')} (${chalk.green(t('route_validate').d('You can add an asterisk (*) as the prefix or suffix to match more URLs, such as "*.example.com/*".'))})`, true);
|
|
87
|
+
const ROUTE_PATTERN = /^(?:\*\.)?([a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,})(\/\*|\/[^?#]*)?$/;
|
|
88
|
+
if (!ROUTE_PATTERN.test(inputRoute)) {
|
|
89
|
+
return logger.error(t('route_add_invalid_route').d('Invalid route'));
|
|
90
|
+
}
|
|
91
|
+
if (!isValidRouteForDomain(inputRoute, domain.label)) {
|
|
92
|
+
return logger.error(t('route_site_not_match').d('The route does not correspond to the domain.'));
|
|
93
|
+
}
|
|
94
|
+
if (domain.value !== '') {
|
|
95
|
+
const req = {
|
|
96
|
+
Name: projectConfig.name,
|
|
97
|
+
SiteId: Number(domain.value),
|
|
98
|
+
SiteName: domain.label,
|
|
99
|
+
Route: inputRoute
|
|
100
|
+
};
|
|
101
|
+
const res = yield server.createRoutineRelatedRoute(req);
|
|
102
|
+
const addSuccess = ((_c = res === null || res === void 0 ? void 0 : res.data) === null || _c === void 0 ? void 0 : _c.Status) === 'OK';
|
|
103
|
+
if (addSuccess) {
|
|
104
|
+
logger.success(t('route_add_success').d('Add route success!'));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
logger.error(t('route_add_fail').d('Add route fail!'));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
logger.error(t('invalid_domain').d('Input domain is invalid'));
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
export default addRoute;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
11
|
+
import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
|
|
12
|
+
import { ApiService } from '../../libs/apiService.js';
|
|
13
|
+
import logger from '../../libs/logger.js';
|
|
14
|
+
import t from '../../i18n/index.js';
|
|
15
|
+
import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
|
|
16
|
+
const deleteRoute = {
|
|
17
|
+
command: 'delete <route>',
|
|
18
|
+
describe: `🗑 ${t('route_delete_describe').d('Delete a related route')}`,
|
|
19
|
+
builder: (yargs) => {
|
|
20
|
+
return yargs.positional('route', {
|
|
21
|
+
describe: t('route_delete_positional_describe').d('The name of the routes to delete'),
|
|
22
|
+
type: 'string',
|
|
23
|
+
demandOption: true
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
handleDeleteRoute(argv);
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
export default deleteRoute;
|
|
31
|
+
export function handleDeleteRoute(argv) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
var _a, _b;
|
|
34
|
+
if (!checkDirectory()) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const projectConfig = getProjectConfig();
|
|
38
|
+
if (!projectConfig)
|
|
39
|
+
return logger.notInProject();
|
|
40
|
+
const isSuccess = yield checkIsLoginSuccess();
|
|
41
|
+
if (!isSuccess)
|
|
42
|
+
return;
|
|
43
|
+
yield validRoutine(projectConfig.name);
|
|
44
|
+
const server = yield ApiService.getInstance();
|
|
45
|
+
const req = { Name: projectConfig.name };
|
|
46
|
+
const routineDetail = yield server.getRoutine(req);
|
|
47
|
+
if (!routineDetail)
|
|
48
|
+
return;
|
|
49
|
+
const relatedRoutes = (_b = (_a = routineDetail.data) === null || _a === void 0 ? void 0 : _a.RelatedRoutes) !== null && _b !== void 0 ? _b : [];
|
|
50
|
+
const deleteDomain = argv.route;
|
|
51
|
+
const matchedSite = relatedRoutes.find((item) => {
|
|
52
|
+
return String(item.Route) === deleteDomain;
|
|
53
|
+
});
|
|
54
|
+
if (matchedSite === undefined) {
|
|
55
|
+
logger.error(t('route_not_exist').d('Route not exist!'));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const request = {
|
|
59
|
+
Name: projectConfig.name,
|
|
60
|
+
SiteId: matchedSite.SiteId,
|
|
61
|
+
SiteName: matchedSite.SiteName,
|
|
62
|
+
Route: matchedSite.Route,
|
|
63
|
+
RouteId: matchedSite.RouteId
|
|
64
|
+
};
|
|
65
|
+
const res = yield server.deleteRoutineRelatedRoute(request);
|
|
66
|
+
const isDeleteSuccess = (res === null || res === void 0 ? void 0 : res.data.Status) === 'OK';
|
|
67
|
+
if (isDeleteSuccess) {
|
|
68
|
+
logger.success(t('route_delete_success').d('Delete route success!'));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
logger.error(t('route_delete_fail').d('Delete route fail!'));
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import deleteRoute from './delete.js';
|
|
2
|
+
import listRoute from './list.js';
|
|
3
|
+
import addRoute from './add.js';
|
|
4
|
+
import t from '../../i18n/index.js';
|
|
5
|
+
let yargsIns;
|
|
6
|
+
const routeCommand = {
|
|
7
|
+
command: 'route [script]',
|
|
8
|
+
describe: `🚀 ${t('route_describe').d('Manage the routes bound to your routine')}`,
|
|
9
|
+
builder: (yargs) => {
|
|
10
|
+
yargsIns = yargs;
|
|
11
|
+
return yargs
|
|
12
|
+
.command(addRoute)
|
|
13
|
+
.command(deleteRoute)
|
|
14
|
+
.command(listRoute)
|
|
15
|
+
.option('help', {
|
|
16
|
+
alias: 'h',
|
|
17
|
+
describe: t('common_help').d('Help'),
|
|
18
|
+
type: 'boolean',
|
|
19
|
+
default: false
|
|
20
|
+
})
|
|
21
|
+
.usage(`${t('common_usage').d('Usage')}: esa route <add | list | delete>`);
|
|
22
|
+
},
|
|
23
|
+
handler: (argv) => {
|
|
24
|
+
if (yargsIns && (argv.help || argv._.length < 2)) {
|
|
25
|
+
yargsIns.showHelp('log');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export default routeCommand;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { getProjectConfig } from '../../utils/fileUtils/index.js';
|
|
11
|
+
import Table from 'cli-table3';
|
|
12
|
+
import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
|
|
13
|
+
import { ApiService } from '../../libs/apiService.js';
|
|
14
|
+
import logger from '../../libs/logger.js';
|
|
15
|
+
import t from '../../i18n/index.js';
|
|
16
|
+
import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
|
|
17
|
+
const listRoute = {
|
|
18
|
+
command: 'list',
|
|
19
|
+
describe: `🔍 ${t('route_list_describe').d('List all related routes')}`,
|
|
20
|
+
handler: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
handleListRoutes();
|
|
22
|
+
})
|
|
23
|
+
};
|
|
24
|
+
export default listRoute;
|
|
25
|
+
export function handleListRoutes() {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
if (!checkDirectory()) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const projectConfig = getProjectConfig();
|
|
32
|
+
if (!projectConfig)
|
|
33
|
+
return logger.notInProject();
|
|
34
|
+
const isSuccess = yield checkIsLoginSuccess();
|
|
35
|
+
if (!isSuccess)
|
|
36
|
+
return;
|
|
37
|
+
yield validRoutine(projectConfig.name);
|
|
38
|
+
const server = yield ApiService.getInstance();
|
|
39
|
+
const req = { Name: projectConfig.name };
|
|
40
|
+
const routineDetail = yield server.getRoutine(req);
|
|
41
|
+
if (!routineDetail)
|
|
42
|
+
return;
|
|
43
|
+
const relatedRoutes = (_b = (_a = routineDetail.data) === null || _a === void 0 ? void 0 : _a.RelatedRoutes) !== null && _b !== void 0 ? _b : [];
|
|
44
|
+
if (relatedRoutes.length === 0) {
|
|
45
|
+
logger.warn(`🙅 ${t('route_list_empty').d('No related routes found')}`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
logger.log(`📃 ${t('route_list_title').d('Related routes')}:`);
|
|
49
|
+
displayRelatedRouteList(relatedRoutes);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function displayRelatedRouteList(routeList) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const table = new Table({
|
|
55
|
+
head: ['Route', 'Site']
|
|
56
|
+
});
|
|
57
|
+
for (let i = 0; i < routeList.length; i++) {
|
|
58
|
+
const route = routeList[i];
|
|
59
|
+
table.push([route.Route, route.SiteName]);
|
|
60
|
+
}
|
|
61
|
+
console.log(table.toString());
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { checkIsLoginSuccess } from '../utils.js';
|
|
11
|
+
import { ApiService } from '../../libs/apiService.js';
|
|
12
|
+
import t from '../../i18n/index.js';
|
|
13
|
+
import logger from '../../libs/logger.js';
|
|
14
|
+
const deleteCommand = {
|
|
15
|
+
command: 'delete <routineName>',
|
|
16
|
+
describe: `🗑 ${t('delete_describe').d('Delete a routine')}`,
|
|
17
|
+
builder: (yargs) => {
|
|
18
|
+
return yargs
|
|
19
|
+
.positional('routineName', {
|
|
20
|
+
describe: t('delete_routineName_positional_describe').d('The name of the routine to delete'),
|
|
21
|
+
type: 'string',
|
|
22
|
+
array: true,
|
|
23
|
+
demandOption: true
|
|
24
|
+
})
|
|
25
|
+
.usage(`${t('common_usage').d('Usage')}: $0 delete <routineName>`);
|
|
26
|
+
},
|
|
27
|
+
handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
handleDelete(argv);
|
|
29
|
+
})
|
|
30
|
+
};
|
|
31
|
+
export default deleteCommand;
|
|
32
|
+
export function handleDelete(argv) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const isSuccess = yield checkIsLoginSuccess();
|
|
35
|
+
if (!isSuccess)
|
|
36
|
+
return;
|
|
37
|
+
const routineName = argv.routineName;
|
|
38
|
+
const req = { Name: routineName };
|
|
39
|
+
console.log(2);
|
|
40
|
+
return yield deleteRoutineFromUserAccount(req);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function deleteRoutineFromUserAccount(req) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const server = yield ApiService.getInstance();
|
|
46
|
+
const res = yield server.deleteRoutine(req);
|
|
47
|
+
if ((res === null || res === void 0 ? void 0 : res.Status) === 'OK') {
|
|
48
|
+
logger.success(t('delete_success').d('Delete success!'));
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
logger.error(t('delete_error').d('Delete error!'));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import routineList from './list.js';
|
|
2
|
+
import routineDelete from './delete.js';
|
|
3
|
+
import t from '../../i18n/index.js';
|
|
4
|
+
let yargsIns;
|
|
5
|
+
const routineCommand = {
|
|
6
|
+
command: 'routine [script]',
|
|
7
|
+
describe: `🚀 ${t('routine_describe').d('Manage your routine')}`,
|
|
8
|
+
builder: (yargs) => {
|
|
9
|
+
yargsIns = yargs;
|
|
10
|
+
return yargs
|
|
11
|
+
.command(routineList)
|
|
12
|
+
.command(routineDelete)
|
|
13
|
+
.option('help', {
|
|
14
|
+
alias: 'h',
|
|
15
|
+
describe: t('common_help').d('Help'),
|
|
16
|
+
type: 'boolean',
|
|
17
|
+
default: false
|
|
18
|
+
})
|
|
19
|
+
.usage(`${t('common_usage').d('Usage')}: esa routine [list | delete]`);
|
|
20
|
+
},
|
|
21
|
+
handler: (argv) => {
|
|
22
|
+
if (yargsIns && (argv.help || argv._.length < 2)) {
|
|
23
|
+
yargsIns.showHelp('log');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export default routineCommand;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import Table from 'cli-table3';
|
|
22
|
+
import logger from '../../libs/logger.js';
|
|
23
|
+
import { Base64 } from 'js-base64';
|
|
24
|
+
import { checkIsLoginSuccess } from '../utils.js';
|
|
25
|
+
import chalk from 'chalk';
|
|
26
|
+
import { ApiService } from '../../libs/apiService.js';
|
|
27
|
+
import t from '../../i18n/index.js';
|
|
28
|
+
const list = {
|
|
29
|
+
command: 'list',
|
|
30
|
+
describe: `📋 ${t('list_describe').d('List all your routines')}`,
|
|
31
|
+
builder: (yargs) => {
|
|
32
|
+
return (yargs
|
|
33
|
+
// .positional('deployment', {
|
|
34
|
+
// type: 'string',
|
|
35
|
+
// description: t('list_deployment_positional_describe').d(
|
|
36
|
+
// '(Optional) ID or URL of the deployment to tail. Specify by environment if deployment ID is unknown.'
|
|
37
|
+
// ),
|
|
38
|
+
// demandOption: true
|
|
39
|
+
// })
|
|
40
|
+
// .option('site', {
|
|
41
|
+
// alias: 's',
|
|
42
|
+
// describe: t('list_site_option_describe').d(
|
|
43
|
+
// 'List all site names of your account'
|
|
44
|
+
// ),
|
|
45
|
+
// type: 'boolean',
|
|
46
|
+
// default: false
|
|
47
|
+
// })
|
|
48
|
+
.usage(`${t('common_usage').d('Usage')}: \$0 list []`));
|
|
49
|
+
},
|
|
50
|
+
handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
+
handleList(argv);
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
export default list;
|
|
55
|
+
export function handleList(argv) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a;
|
|
58
|
+
const { site } = argv, args = __rest(argv, ["site"]);
|
|
59
|
+
const isSuccess = yield checkIsLoginSuccess();
|
|
60
|
+
if (!isSuccess)
|
|
61
|
+
return;
|
|
62
|
+
const server = yield ApiService.getInstance();
|
|
63
|
+
if (site) {
|
|
64
|
+
const req = {
|
|
65
|
+
SiteSearchType: 'fuzzy',
|
|
66
|
+
Status: 'active',
|
|
67
|
+
PageNumber: 1,
|
|
68
|
+
PageSize: 50
|
|
69
|
+
};
|
|
70
|
+
const res = yield server.listSites(req);
|
|
71
|
+
const siteList = (_a = res === null || res === void 0 ? void 0 : res.data.Sites) !== null && _a !== void 0 ? _a : [];
|
|
72
|
+
const siteNameList = siteList === null || siteList === void 0 ? void 0 : siteList.map((item) => item.SiteName);
|
|
73
|
+
logger.log(chalk.bold.bgGray(`📃 ${t('list_site_name_title').d('List all of site names')}:`));
|
|
74
|
+
logger.tree(siteNameList);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const res = yield server.getRoutineUserInfo();
|
|
78
|
+
const routineList = res === null || res === void 0 ? void 0 : res.Routines;
|
|
79
|
+
if (routineList) {
|
|
80
|
+
console.log(chalk.bold.bgGray(`📃 ${t('list_routine_name_title').d('List all of routine')}:`));
|
|
81
|
+
displayRoutineList(routineList);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
export function displayRoutineList(versionList) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
const table = new Table({
|
|
88
|
+
head: ['Name', 'Created', 'Description', 'Specification']
|
|
89
|
+
});
|
|
90
|
+
versionList.forEach((version) => {
|
|
91
|
+
var _a;
|
|
92
|
+
table.push([
|
|
93
|
+
version.RoutineName,
|
|
94
|
+
new Date(version.CreateTime).toLocaleString(),
|
|
95
|
+
Base64.decode(version.Description),
|
|
96
|
+
(_a = version.SpecName) !== null && _a !== void 0 ? _a : ' '
|
|
97
|
+
]);
|
|
98
|
+
});
|
|
99
|
+
console.log(table.toString());
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import siteList from './list.js';
|
|
2
|
+
import t from '../../i18n/index.js';
|
|
3
|
+
let yargsIns;
|
|
4
|
+
const siteCommand = {
|
|
5
|
+
command: 'site [script]',
|
|
6
|
+
describe: `🚀 ${t('site_describe').d('Manage your sites')}`,
|
|
7
|
+
builder: (yargs) => {
|
|
8
|
+
yargsIns = yargs;
|
|
9
|
+
return yargs
|
|
10
|
+
.command(siteList)
|
|
11
|
+
.option('help', {
|
|
12
|
+
alias: 'h',
|
|
13
|
+
describe: t('common_help').d('Help'),
|
|
14
|
+
type: 'boolean',
|
|
15
|
+
default: false
|
|
16
|
+
})
|
|
17
|
+
.usage(`${t('common_usage').d('Usage')}: esa site [list]`);
|
|
18
|
+
},
|
|
19
|
+
handler: (argv) => {
|
|
20
|
+
if (yargsIns && (argv.help || argv._.length < 2)) {
|
|
21
|
+
yargsIns.showHelp('log');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export default siteCommand;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import logger from '../../libs/logger.js';
|
|
11
|
+
import { checkIsLoginSuccess } from '../utils.js';
|
|
12
|
+
import chalk from 'chalk';
|
|
13
|
+
import { ApiService } from '../../libs/apiService.js';
|
|
14
|
+
import t from '../../i18n/index.js';
|
|
15
|
+
const list = {
|
|
16
|
+
command: 'list',
|
|
17
|
+
describe: `📋 ${t('site_describe_list').d('List all your sites')}`,
|
|
18
|
+
builder: (yargs) => {
|
|
19
|
+
return yargs.usage(`${t('common_usage').d('Usage')}: \$0 list []`);
|
|
20
|
+
},
|
|
21
|
+
handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
handleList(argv);
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
export default list;
|
|
26
|
+
export function handleList(argv) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
// const { site, ...args } = argv;
|
|
29
|
+
var _a;
|
|
30
|
+
const isSuccess = yield checkIsLoginSuccess();
|
|
31
|
+
if (!isSuccess)
|
|
32
|
+
return;
|
|
33
|
+
const server = yield ApiService.getInstance();
|
|
34
|
+
const req = {
|
|
35
|
+
SiteSearchType: 'fuzzy',
|
|
36
|
+
Status: 'active',
|
|
37
|
+
PageNumber: 1,
|
|
38
|
+
PageSize: 50
|
|
39
|
+
};
|
|
40
|
+
const res = yield server.listSites(req);
|
|
41
|
+
const siteList = (_a = res === null || res === void 0 ? void 0 : res.data.Sites) !== null && _a !== void 0 ? _a : [];
|
|
42
|
+
const siteNameList = siteList === null || siteList === void 0 ? void 0 : siteList.map((item) => item.SiteName);
|
|
43
|
+
logger.log(chalk.bold.bgGray(`📃 ${t('list_site_name_title').d('List all of site names')}:`));
|
|
44
|
+
logger.tree(siteNameList);
|
|
45
|
+
return;
|
|
46
|
+
});
|
|
47
|
+
}
|