esa-cli 0.0.5 → 1.0.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.
Files changed (85) hide show
  1. package/README.md +34 -145
  2. package/dist/commands/commit/index.js +49 -104
  3. package/dist/commands/commit/prodBuild.js +2 -3
  4. package/dist/commands/common/constant.js +4 -4
  5. package/dist/commands/common/utils.js +419 -0
  6. package/dist/commands/config.js +2 -2
  7. package/dist/commands/deploy/helper.js +43 -49
  8. package/dist/commands/deploy/index.js +51 -174
  9. package/dist/commands/deployments/delete.js +32 -22
  10. package/dist/commands/deployments/index.js +4 -4
  11. package/dist/commands/deployments/list.js +21 -34
  12. package/dist/commands/dev/build.js +3 -3
  13. package/dist/commands/dev/doProcess.js +5 -5
  14. package/dist/commands/dev/ew2/cacheService.js +33 -0
  15. package/dist/commands/dev/ew2/devEntry.js +2 -1
  16. package/dist/commands/dev/ew2/devPack.js +31 -20
  17. package/dist/commands/dev/ew2/kvService.js +50 -0
  18. package/dist/commands/dev/ew2/mock/cache.js +99 -15
  19. package/dist/commands/dev/ew2/mock/kv.js +142 -21
  20. package/dist/commands/dev/ew2/server.js +163 -28
  21. package/dist/commands/dev/index.js +17 -18
  22. package/dist/commands/dev/mockWorker/devPack.js +19 -10
  23. package/dist/commands/dev/mockWorker/server.js +7 -6
  24. package/dist/commands/domain/add.js +4 -4
  25. package/dist/commands/domain/delete.js +3 -3
  26. package/dist/commands/domain/index.js +4 -4
  27. package/dist/commands/domain/list.js +7 -7
  28. package/dist/commands/init/helper.js +654 -21
  29. package/dist/commands/init/index.js +88 -152
  30. package/dist/commands/init/snippets/nextjs/next.config.mjs +6 -0
  31. package/dist/commands/init/snippets/nextjs/next.config.ts +7 -0
  32. package/dist/commands/init/snippets/react-router/react-router.config.ts +7 -0
  33. package/dist/commands/init/template.jsonc +84 -0
  34. package/dist/commands/init/types.js +1 -0
  35. package/dist/commands/lang.js +2 -2
  36. package/dist/commands/login/index.js +74 -34
  37. package/dist/commands/logout.js +6 -6
  38. package/dist/commands/route/add.js +101 -43
  39. package/dist/commands/route/delete.js +6 -6
  40. package/dist/commands/route/helper.js +9 -10
  41. package/dist/commands/route/index.js +4 -4
  42. package/dist/commands/route/list.js +4 -4
  43. package/dist/commands/routine/delete.js +9 -8
  44. package/dist/commands/routine/index.js +6 -5
  45. package/dist/commands/routine/list.js +45 -39
  46. package/dist/commands/site/index.js +3 -3
  47. package/dist/commands/site/list.js +6 -7
  48. package/dist/commands/utils.js +61 -25
  49. package/dist/components/descriptionInput.js +1 -1
  50. package/dist/components/filterSelector.js +1 -1
  51. package/dist/components/mutiLevelSelect.js +19 -20
  52. package/dist/components/mutiSelectTable.js +1 -1
  53. package/dist/components/routeBuilder.js +68 -0
  54. package/dist/components/selectInput.js +2 -3
  55. package/dist/components/selectItem.js +1 -1
  56. package/dist/docs/Commands_en.md +164 -117
  57. package/dist/docs/Commands_zh_CN.md +155 -107
  58. package/dist/docs/Config_en.md +70 -0
  59. package/dist/docs/Config_zh_CN.md +68 -0
  60. package/dist/i18n/index.js +2 -2
  61. package/dist/i18n/locales.json +418 -82
  62. package/dist/index.js +28 -13
  63. package/dist/libs/api.js +3 -6
  64. package/dist/libs/apiService.js +201 -70
  65. package/dist/libs/git/index.js +86 -9
  66. package/dist/libs/interface.js +0 -1
  67. package/dist/libs/logger.js +162 -10
  68. package/dist/libs/service.js +2 -2
  69. package/dist/libs/templates/index.js +1 -1
  70. package/dist/utils/checkAssetsExist.js +80 -0
  71. package/dist/utils/checkDevPort.js +5 -19
  72. package/dist/utils/checkEntryFileExist.js +10 -0
  73. package/dist/utils/checkIsRoutineCreated.js +27 -21
  74. package/dist/utils/checkVersion.js +119 -1
  75. package/dist/utils/command.js +149 -0
  76. package/dist/utils/compress.js +142 -0
  77. package/dist/utils/download.js +8 -8
  78. package/dist/utils/fileMd5.js +1 -1
  79. package/dist/utils/fileUtils/index.js +136 -45
  80. package/dist/utils/installDeno.js +4 -4
  81. package/dist/utils/installEw2.js +9 -9
  82. package/dist/utils/openInBrowser.js +1 -1
  83. package/dist/utils/prompt.js +97 -0
  84. package/package.json +23 -12
  85. package/zh_CN.md +31 -150
@@ -7,19 +7,36 @@ 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 logger from '../../libs/logger.js';
11
- import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
12
- import { getProjectConfig } from '../../utils/fileUtils/index.js';
13
- import { ApiService } from '../../libs/apiService.js';
10
+ import inquirer from 'inquirer';
11
+ import { routeBuilder } from '../../components/routeBuilder.js';
14
12
  import t from '../../i18n/index.js';
13
+ import { ApiService } from '../../libs/apiService.js';
14
+ import logger from '../../libs/logger.js';
15
15
  import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
16
- import inquirer from 'inquirer';
16
+ import { getProjectConfig } from '../../utils/fileUtils/index.js';
17
+ import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
17
18
  import { transferRouteToRuleString } from './helper.js';
18
19
  const addRoute = {
19
20
  command: 'add [route] [site]',
20
- describe: `📥 ${t('route_add_describe').d('Bind a Route to a routine')}`,
21
+ describe: `🚄 ${t('route_add_describe').d('Bind a Route to a project')}`,
21
22
  builder: (yargs) => {
22
- return yargs.fail((msg, err, yargsIns) => {
23
+ return yargs
24
+ .option('route', {
25
+ describe: t('route_add_route_value_option').d('The route value. For example: example.com/*'),
26
+ alias: 'r',
27
+ type: 'string'
28
+ })
29
+ .option('site', {
30
+ describe: t('route_add_site_describe').d('The site to bind the route to. For example: example.com'),
31
+ alias: 's',
32
+ type: 'string'
33
+ })
34
+ .option('alias', {
35
+ alias: 'a',
36
+ describe: t('route_add_route_name_option').d('Route name (aliases)'),
37
+ type: 'string'
38
+ })
39
+ .fail((msg, err, yargsIns) => {
23
40
  if (err)
24
41
  throw err;
25
42
  if (msg) {
@@ -35,6 +52,7 @@ const addRoute = {
35
52
  };
36
53
  export function handlerAddRoute(argv) {
37
54
  return __awaiter(this, void 0, void 0, function* () {
55
+ var _a;
38
56
  if (!checkDirectory()) {
39
57
  return;
40
58
  }
@@ -53,60 +71,100 @@ export function handlerAddRoute(argv) {
53
71
  };
54
72
  const server = yield ApiService.getInstance();
55
73
  const ListSitesRes = yield server.listSites(listSitesReq);
56
- const siteList = ((ListSitesRes === null || ListSitesRes === void 0 ? void 0 : ListSitesRes.data.Sites) || []).map((i) => ({
74
+ if (!((_a = ListSitesRes === null || ListSitesRes === void 0 ? void 0 : ListSitesRes.data) === null || _a === void 0 ? void 0 : _a.Sites) || ListSitesRes.data.Sites.length === 0) {
75
+ logger.error(t('no_active_sites').d('No active sites found in your account'));
76
+ return;
77
+ }
78
+ const siteList = ListSitesRes.data.Sites.map((i) => ({
57
79
  name: i.SiteName,
58
80
  value: i.SiteId
59
81
  }));
60
- const { routeName } = yield inquirer.prompt([
61
- {
62
- type: 'input',
63
- name: 'routeName',
64
- message: t('create_route_route_name').d('Enter a Route Name (Aliases):'),
65
- validate: (input) => {
66
- if (!input) {
67
- return t('route_name_input_required').d('Route name is required');
82
+ let routeName = argv.alias;
83
+ if (!routeName) {
84
+ const response = yield inquirer.prompt([
85
+ {
86
+ type: 'input',
87
+ name: 'routeName',
88
+ message: t('create_route_route_name').d('Enter a Route Name (Aliases):'),
89
+ validate: (input) => {
90
+ if (!input) {
91
+ return t('route_name_input_required').d('Route name is required');
92
+ }
93
+ return true;
68
94
  }
69
- return true;
70
95
  }
96
+ ]);
97
+ routeName = response.routeName;
98
+ }
99
+ let siteName = argv.site;
100
+ let siteId;
101
+ if (!siteName) {
102
+ const response = yield inquirer.prompt([
103
+ {
104
+ type: 'list',
105
+ name: 'routeSite',
106
+ message: t('create_route_site').d('Select a site that is active in your account:'),
107
+ choices: siteList
108
+ }
109
+ ]);
110
+ siteId = response.routeSite;
111
+ }
112
+ else {
113
+ // Find corresponding site ID by site name
114
+ const matchedSite = siteList.find((site) => site.name === siteName);
115
+ if (matchedSite) {
116
+ siteId = matchedSite.value;
71
117
  }
72
- ]);
73
- const { routeSite } = yield inquirer.prompt([
74
- {
75
- type: 'list',
76
- name: 'routeSite',
77
- message: t('create_route_site').d('Select a site that is active in your account:'),
78
- choices: siteList
118
+ else {
119
+ logger.error(t('site_not_found').d(`Site "${siteName}" not found in your account`));
120
+ return;
79
121
  }
80
- ]);
81
- const { inputRoute } = yield inquirer.prompt([
82
- {
83
- type: 'input',
84
- name: 'inputRoute',
85
- message: t('create_route_route').d('Enter a Route:'),
86
- validate: (input) => {
87
- if (!input) {
88
- return t('route_input_required').d('Route is required');
89
- }
90
- return true;
91
- }
122
+ }
123
+ let inputRoute = argv.route;
124
+ if (!inputRoute) {
125
+ // Get selected site name for route building
126
+ const selectedSite = siteList.find((site) => site.value === siteId);
127
+ const displaySiteName = selectedSite ? selectedSite.name : siteName;
128
+ // Use route builder
129
+ const builtRoute = yield routeBuilder(displaySiteName);
130
+ if (!builtRoute) {
131
+ logger.info(t('route_build_cancelled').d('Route building cancelled'));
132
+ return;
92
133
  }
93
- ]);
134
+ inputRoute = builtRoute;
135
+ }
94
136
  const rule = transferRouteToRuleString(inputRoute);
137
+ if (!rule) {
138
+ logger.error(t('route_format_invalid').d('Invalid route format'));
139
+ return;
140
+ }
141
+ const selectedSite = siteList.find((site) => site.value === siteId);
142
+ const displaySiteName = selectedSite ? selectedSite.name : siteName;
95
143
  const req = {
96
144
  RoutineName: projectConfig.name,
97
145
  RouteName: routeName,
98
- SiteId: routeSite,
146
+ SiteId: siteId,
99
147
  RouteEnable: 'on',
100
148
  Bypass: 'off',
101
149
  Rule: rule
102
150
  };
103
- const res = yield server.createRoutineRoute(req);
104
- const addSuccess = (res === null || res === void 0 ? void 0 : res.code) === 200;
105
- if (addSuccess) {
106
- logger.success(t('route_add_success').d('Add route success!'));
151
+ try {
152
+ logger.info(t('creating_route').d('Creating route...'));
153
+ const res = yield server.createRoutineRoute(req);
154
+ const addSuccess = (res === null || res === void 0 ? void 0 : res.code) === 200;
155
+ if (addSuccess) {
156
+ logger.success(t('route_add_success').d('Add route success!'));
157
+ logger.info(`Route "${routeName}" has been successfully added to routine "${projectConfig.name}" for site "${displaySiteName}"`);
158
+ }
159
+ else {
160
+ logger.error(t('route_add_fail').d('Add route fail!'));
161
+ }
107
162
  }
108
- else {
163
+ catch (error) {
109
164
  logger.error(t('route_add_fail').d('Add route fail!'));
165
+ if (error instanceof Error) {
166
+ logger.error(`Error: ${error.message}`);
167
+ }
110
168
  }
111
169
  });
112
170
  }
@@ -7,18 +7,18 @@ 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 { getProjectConfig } from '../../utils/fileUtils/index.js';
11
- import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
12
- import logger from '../../libs/logger.js';
13
10
  import t from '../../i18n/index.js';
14
- import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
15
11
  import api from '../../libs/api.js';
12
+ import logger from '../../libs/logger.js';
13
+ import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
14
+ import { getProjectConfig } from '../../utils/fileUtils/index.js';
15
+ import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
16
16
  const deleteRoute = {
17
- command: 'delete <route>',
17
+ command: 'delete <routeName>',
18
18
  describe: `🗑 ${t('route_delete_describe').d('Delete a related route')}`,
19
19
  builder: (yargs) => {
20
20
  return yargs
21
- .positional('route', {
21
+ .positional('routeName', {
22
22
  describe: t('route_delete_positional_describe').d('The name of the routes to delete'),
23
23
  type: 'string',
24
24
  demandOption: true
@@ -72,8 +72,7 @@ export const transferRouteToRuleString = (routePath) => {
72
72
  export const transferRuleStringToRoute = (ruleStr) => {
73
73
  if (!ruleStr) {
74
74
  return '';
75
- }
76
- // 去掉外层括号并按 " and " 分割
75
+ } // Remove outer brackets and split by " and "
77
76
  const cleanedRule = ruleStr.replace(/^\(|\)$/g, '');
78
77
  const parts = cleanedRule.split(' and ');
79
78
  if (parts.length !== 2) {
@@ -81,36 +80,36 @@ export const transferRuleStringToRoute = (ruleStr) => {
81
80
  }
82
81
  let host = '';
83
82
  let uriPath = '';
84
- // 处理host部分
83
+ // Process host part
85
84
  const hostPart = parts[0].trim();
86
85
  if (hostPart.startsWith(`${RuleMatchOperatorEndsWith}(${RuleMatchTypeHost},`)) {
87
- // host匹配eq时的逻辑
86
+ // Logic when host matches eq
88
87
  // ends_with(http.host, "value")
89
88
  const match = hostPart.match(/ends_with\(http\.host,\s*"([^"]+)"\)/);
90
89
  if (match) {
91
- host = `*${match[1]}`; // 加前缀 *
90
+ host = `*${match[1]}`; // Add prefix *
92
91
  }
93
92
  }
94
93
  else if (hostPart.startsWith(`${RuleMatchTypeHost} ${RuleMatchOperatorEq}`)) {
95
- // host匹配eq时的逻辑
94
+ // Logic when host matches eq
96
95
  // http.host eq "value"
97
96
  const match = hostPart.match(/http\.host eq "([^"]+)"/);
98
97
  if (match) {
99
98
  host = match[1];
100
99
  }
101
100
  }
102
- // 处理uriPath 部分
101
+ // Process uriPath part
103
102
  const uriPathPart = parts[1].trim();
104
103
  if (uriPathPart.startsWith(`${RuleMatchOperatorStartsWith}(${RuleMatchTypeUriPath},`)) {
105
- // uriPath匹配startsWith时的逻辑
104
+ // Logic when uriPath matches startsWith
106
105
  // starts_with(http.request.uri.path, "value")
107
106
  const match = uriPathPart.match(/starts_with\(http\.request\.uri\.path,\s*"([^"]+)"\)/);
108
107
  if (match) {
109
- uriPath = `${match[1]}*`; // 加后缀 *
108
+ uriPath = `${match[1]}*`; // Add suffix *
110
109
  }
111
110
  }
112
111
  else if (uriPathPart.startsWith(`${RuleMatchTypeUriPath} ${RuleMatchOperatorEq}`)) {
113
- // uriPath匹配eq时的逻辑
112
+ // Logic when uriPath matches eq
114
113
  // http.request.uri.path eq "value"
115
114
  const match = uriPathPart.match(/http\.request\.uri\.path eq "([^"]+)"/);
116
115
  if (match) {
@@ -1,11 +1,11 @@
1
+ import t from '../../i18n/index.js';
2
+ import addRoute from './add.js';
1
3
  import deleteRoute from './delete.js';
2
4
  import listRoute from './list.js';
3
- import addRoute from './add.js';
4
- import t from '../../i18n/index.js';
5
5
  let yargsIns;
6
6
  const routeCommand = {
7
7
  command: 'route [script]',
8
- describe: `🚀 ${t('route_describe').d('Manage the routes bound to your routine')}`,
8
+ describe: `🚄 ${t('route_describe').d('Manage the routes bound to your project')}`,
9
9
  builder: (yargs) => {
10
10
  yargsIns = yargs;
11
11
  return yargs
@@ -18,7 +18,7 @@ const routeCommand = {
18
18
  type: 'boolean',
19
19
  default: false
20
20
  })
21
- .usage(`${t('common_usage').d('Usage')}: esa route <add | list | delete>`);
21
+ .usage(`${t('common_usage').d('Usage')}: esa-cli route <add | list | delete>`);
22
22
  },
23
23
  handler: (argv) => {
24
24
  if (yargsIns && (argv.help || argv._.length < 2)) {
@@ -7,13 +7,13 @@ 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 { getProjectConfig } from '../../utils/fileUtils/index.js';
11
10
  import Table from 'cli-table3';
12
- import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
13
- import logger from '../../libs/logger.js';
14
11
  import t from '../../i18n/index.js';
15
- import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
16
12
  import api from '../../libs/api.js';
13
+ import logger from '../../libs/logger.js';
14
+ import { validRoutine } from '../../utils/checkIsRoutineCreated.js';
15
+ import { getProjectConfig } from '../../utils/fileUtils/index.js';
16
+ import { checkDirectory, checkIsLoginSuccess } from '../utils.js';
17
17
  import { transferRuleStringToRoute } from './helper.js';
18
18
  const listRoute = {
19
19
  command: 'list',
@@ -7,22 +7,23 @@ 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 { checkIsLoginSuccess } from '../utils.js';
11
- import { ApiService } from '../../libs/apiService.js';
12
10
  import t from '../../i18n/index.js';
11
+ import { ApiService } from '../../libs/apiService.js';
13
12
  import logger from '../../libs/logger.js';
13
+ import { checkIsLoginSuccess } from '../utils.js';
14
14
  const deleteCommand = {
15
- command: 'delete <routineName>',
16
- describe: `🗑 ${t('delete_describe').d('Delete a routine')}`,
15
+ command: 'delete <projectName>',
16
+ aliases: ['delete <routineName>'],
17
+ describe: `🗑 ${t('delete_describe').d('Delete a project')}`,
17
18
  builder: (yargs) => {
18
19
  return yargs
19
- .positional('routineName', {
20
- describe: t('delete_routineName_positional_describe').d('The name of the routine to delete'),
20
+ .positional('projectName', {
21
+ describe: t('delete_routineName_positional_describe').d('The name of the project to delete'),
21
22
  type: 'string',
22
23
  array: true,
23
24
  demandOption: true
24
25
  })
25
- .usage(`${t('common_usage').d('Usage')}: $0 delete <routineName>`);
26
+ .usage(`${t('common_usage').d('Usage')}: $0 delete <projectName>`);
26
27
  },
27
28
  handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
28
29
  handleDelete(argv);
@@ -34,7 +35,7 @@ export function handleDelete(argv) {
34
35
  const isSuccess = yield checkIsLoginSuccess();
35
36
  if (!isSuccess)
36
37
  return;
37
- const routineName = argv.routineName;
38
+ const routineName = argv.projectName || argv.routineName;
38
39
  const req = { Name: routineName };
39
40
  return yield deleteRoutineFromUserAccount(req);
40
41
  });
@@ -1,10 +1,11 @@
1
- import routineList from './list.js';
2
- import routineDelete from './delete.js';
3
1
  import t from '../../i18n/index.js';
2
+ import routineDelete from './delete.js';
3
+ import routineList from './list.js';
4
4
  let yargsIns;
5
5
  const routineCommand = {
6
- command: 'routine [script]',
7
- describe: `🚀 ${t('routine_describe').d('Manage your routine')}`,
6
+ command: 'project [script]',
7
+ aliases: ['routine'],
8
+ describe: `🧭 ${t('routine_describe').d('Manage your project')}`,
8
9
  builder: (yargs) => {
9
10
  yargsIns = yargs;
10
11
  return yargs
@@ -16,7 +17,7 @@ const routineCommand = {
16
17
  type: 'boolean',
17
18
  default: false
18
19
  })
19
- .usage(`${t('common_usage').d('Usage')}: esa routine [list | delete]`);
20
+ .usage(`${t('common_usage').d('Usage')}: esa-cli project [list | delete]`);
20
21
  },
21
22
  handler: (argv) => {
22
23
  if (yargsIns && (argv.help || argv._.length < 2)) {
@@ -7,62 +7,68 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
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
- };
10
+ import chalk from 'chalk';
21
11
  import Table from 'cli-table3';
12
+ import moment from 'moment';
13
+ import t from '../../i18n/index.js';
14
+ import { ApiService } from '../../libs/apiService.js';
22
15
  import logger from '../../libs/logger.js';
23
- import { Base64 } from 'js-base64';
24
16
  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
- import moment from 'moment';
29
17
  const list = {
30
18
  command: 'list',
31
- describe: `📋 ${t('list_describe').d('List all your routines')}`,
19
+ describe: `📋 ${t('list_describe').d('List all your projects')}`,
32
20
  builder: (yargs) => {
33
- return yargs.usage(`${t('common_usage').d('Usage')}: \$0 list []`);
21
+ return yargs
22
+ .option('keyword', {
23
+ alias: 'k',
24
+ describe: t('deploy_option_keyword').d('Keyword to search for projects'),
25
+ type: 'string'
26
+ })
27
+ .usage(`${t('common_usage').d('Usage')}: \$0 list [--keyword <keyword>]`);
34
28
  },
35
29
  handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
36
30
  handleList(argv);
37
31
  })
38
32
  };
39
33
  export default list;
40
- export function handleList(argv) {
34
+ export function getAllRoutines(options) {
41
35
  return __awaiter(this, void 0, void 0, function* () {
42
36
  var _a;
43
- const { site } = argv, args = __rest(argv, ["site"]);
37
+ const server = yield ApiService.getInstance();
38
+ const allRoutines = [];
39
+ let pageNumber = 1;
40
+ const pageSize = (options === null || options === void 0 ? void 0 : options.PageSize) || 50;
41
+ while (true) {
42
+ const res = yield server.listUserRoutines({
43
+ RegionId: options === null || options === void 0 ? void 0 : options.RegionId,
44
+ PageNumber: pageNumber,
45
+ PageSize: pageSize,
46
+ SearchKeyWord: options === null || options === void 0 ? void 0 : options.SearchKeyWord
47
+ });
48
+ if (!((_a = res === null || res === void 0 ? void 0 : res.body) === null || _a === void 0 ? void 0 : _a.Routines)) {
49
+ break;
50
+ }
51
+ allRoutines.push(...res.body.Routines);
52
+ const totalCount = res.body.TotalCount;
53
+ const currentCount = allRoutines.length;
54
+ if (currentCount >= totalCount) {
55
+ break;
56
+ }
57
+ pageNumber++;
58
+ }
59
+ return allRoutines;
60
+ });
61
+ }
62
+ export function handleList(argv) {
63
+ return __awaiter(this, void 0, void 0, function* () {
44
64
  const isSuccess = yield checkIsLoginSuccess();
45
65
  if (!isSuccess)
46
66
  return;
47
- const server = yield ApiService.getInstance();
48
- if (site) {
49
- const req = {
50
- SiteSearchType: 'fuzzy',
51
- Status: 'active',
52
- PageNumber: 1,
53
- PageSize: 50
54
- };
55
- const res = yield server.listSites(req);
56
- const siteList = (_a = res === null || res === void 0 ? void 0 : res.data.Sites) !== null && _a !== void 0 ? _a : [];
57
- const siteNameList = siteList === null || siteList === void 0 ? void 0 : siteList.map((item) => item.SiteName);
58
- logger.log(chalk.bold.bgGray(`📃 ${t('list_site_name_title').d('List all of site names')}:`));
59
- logger.tree(siteNameList);
60
- return;
61
- }
62
- const res = yield server.getRoutineUserInfo();
63
- const routineList = res === null || res === void 0 ? void 0 : res.Routines;
67
+ const routineList = yield getAllRoutines({
68
+ SearchKeyWord: argv.keyword
69
+ });
64
70
  if (routineList) {
65
- logger.log(chalk.bold.bgGray(`📃 ${t('list_routine_name_title').d('List all of routine')}:`));
71
+ logger.log(chalk.bold.bgGray(`📃 ${t('list_routine_name_title').d('List all of Functions and Pages')}:`));
66
72
  displayRoutineList(routineList);
67
73
  }
68
74
  });
@@ -77,7 +83,7 @@ export function displayRoutineList(versionList) {
77
83
  table.push([
78
84
  version.RoutineName,
79
85
  moment(version.CreateTime).format('YYYY/MM/DD HH:mm:ss'),
80
- Base64.decode(version.Description)
86
+ version.Description
81
87
  ]);
82
88
  });
83
89
  console.table(table.toString());
@@ -1,9 +1,9 @@
1
- import siteList from './list.js';
2
1
  import t from '../../i18n/index.js';
2
+ import siteList from './list.js';
3
3
  let yargsIns;
4
4
  const siteCommand = {
5
5
  command: 'site [script]',
6
- describe: `🚀 ${t('site_describe').d('Manage your sites')}`,
6
+ describe: `📈 ${t('site_describe').d('Manage your sites')}`,
7
7
  builder: (yargs) => {
8
8
  yargsIns = yargs;
9
9
  return yargs
@@ -14,7 +14,7 @@ const siteCommand = {
14
14
  type: 'boolean',
15
15
  default: false
16
16
  })
17
- .usage(`${t('common_usage').d('Usage')}: esa site [list]`);
17
+ .usage(`${t('common_usage').d('Usage')}: esa-cli site [list]`);
18
18
  },
19
19
  handler: (argv) => {
20
20
  if (yargsIns && (argv.help || argv._.length < 2)) {
@@ -7,25 +7,24 @@ 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 logger from '../../libs/logger.js';
11
- import { checkIsLoginSuccess } from '../utils.js';
12
10
  import chalk from 'chalk';
13
- import { ApiService } from '../../libs/apiService.js';
14
11
  import t from '../../i18n/index.js';
12
+ import { ApiService } from '../../libs/apiService.js';
13
+ import logger from '../../libs/logger.js';
14
+ import { checkIsLoginSuccess } from '../utils.js';
15
15
  const list = {
16
16
  command: 'list',
17
17
  describe: `📋 ${t('site_describe_list').d('List all your sites')}`,
18
18
  builder: (yargs) => {
19
19
  return yargs.usage(`${t('common_usage').d('Usage')}: \$0 list []`);
20
20
  },
21
- handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
22
- handleList(argv);
21
+ handler: () => __awaiter(void 0, void 0, void 0, function* () {
22
+ handleList();
23
23
  })
24
24
  };
25
25
  export default list;
26
- export function handleList(argv) {
26
+ export function handleList() {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
- // const { site, ...args } = argv;
29
28
  var _a;
30
29
  const isSuccess = yield checkIsLoginSuccess();
31
30
  if (!isSuccess)