esa-cli 0.0.2-beta.1 → 0.0.2-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/commands/commit/index.js +34 -25
  2. package/dist/commands/common/constant.js +0 -19
  3. package/dist/commands/deploy/helper.js +10 -26
  4. package/dist/commands/deploy/index.js +49 -60
  5. package/dist/commands/deployments/delete.js +1 -16
  6. package/dist/commands/deployments/index.js +1 -1
  7. package/dist/commands/deployments/list.js +8 -15
  8. package/dist/commands/dev/ew2/cacheService.js +33 -0
  9. package/dist/commands/dev/ew2/devEntry.js +2 -1
  10. package/dist/commands/dev/ew2/devPack.js +13 -26
  11. package/dist/commands/dev/ew2/kvService.js +27 -0
  12. package/dist/commands/dev/ew2/mock/cache.js +99 -15
  13. package/dist/commands/dev/ew2/mock/kv.js +142 -21
  14. package/dist/commands/dev/ew2/server.js +152 -19
  15. package/dist/commands/dev/index.js +4 -4
  16. package/dist/commands/dev/mockWorker/devPack.js +16 -14
  17. package/dist/commands/domain/add.js +1 -1
  18. package/dist/commands/domain/delete.js +4 -4
  19. package/dist/commands/domain/index.js +1 -1
  20. package/dist/commands/domain/list.js +3 -3
  21. package/dist/commands/init/helper.js +137 -0
  22. package/dist/commands/init/index.js +183 -187
  23. package/dist/commands/login/index.js +49 -3
  24. package/dist/commands/logout.js +1 -1
  25. package/dist/commands/route/add.js +50 -52
  26. package/dist/commands/route/delete.js +29 -23
  27. package/dist/commands/route/helper.js +124 -0
  28. package/dist/commands/route/index.js +1 -1
  29. package/dist/commands/route/list.js +53 -14
  30. package/dist/commands/routine/index.js +1 -1
  31. package/dist/commands/routine/list.js +4 -5
  32. package/dist/commands/site/index.js +1 -1
  33. package/dist/commands/utils.js +5 -5
  34. package/dist/components/mutiLevelSelect.js +44 -55
  35. package/dist/docs/Commands_en.md +27 -13
  36. package/dist/docs/Commands_zh_CN.md +14 -0
  37. package/dist/docs/Dev_en.md +0 -0
  38. package/dist/docs/Dev_zh_CN.md +0 -0
  39. package/dist/i18n/locales.json +144 -12
  40. package/dist/index.js +6 -9
  41. package/dist/libs/api.js +32 -9
  42. package/dist/libs/apiService.js +88 -78
  43. package/dist/libs/interface.js +0 -1
  44. package/dist/libs/logger.js +1 -1
  45. package/dist/libs/templates/index.js +2 -1
  46. package/dist/utils/checkIsRoutineCreated.js +7 -12
  47. package/dist/utils/checkVersion.js +1 -1
  48. package/dist/utils/download.js +182 -0
  49. package/dist/utils/fileUtils/base.js +1 -1
  50. package/dist/utils/installDeno.js +7 -7
  51. package/package.json +5 -5
@@ -1,9 +1,23 @@
1
1
  # Commands
2
2
 
3
+ - init - Initialize a new project from a template
4
+ - dev - Start a local development server for testing
5
+ - commit - Commit code and create a version
6
+ - deploy - Build and deploy project to the edge routine
7
+ - deployments - Manage deployments
8
+ - routine - Manage edge routine functions
9
+ - site - Manage site settings
10
+ - domain - Configure edge function trigger domain
11
+ - route - Configure edge function trigger routes
12
+ - login - Authenticate via AK/SK to your account
13
+ - logout - Log out current user
14
+ - config - Modify local/global settings
15
+ - lang - Switch CLI interface language
16
+
3
17
  ### init
4
18
 
5
19
  Initialize a routine with a template.
6
-
20
+
7
21
  ```bash
8
22
  $ esa init [OPTIONS]
9
23
  ```
@@ -14,7 +28,7 @@ $ esa init [OPTIONS]
14
28
  ### routine [script]
15
29
 
16
30
  Manage your routine.
17
-
31
+
18
32
  #### delete <routineName>
19
33
 
20
34
  Delete a routine.
@@ -37,7 +51,7 @@ $ esa routine list
37
51
  ### route [script]
38
52
 
39
53
  Manage the routes bound to your routine.
40
-
54
+
41
55
  #### add [route] [site]
42
56
 
43
57
  Bind a Route to a routine.
@@ -68,7 +82,7 @@ $ esa route list
68
82
  ### login
69
83
 
70
84
  Login to the server.
71
-
85
+
72
86
  ```bash
73
87
  $ esa login
74
88
  ```
@@ -76,7 +90,7 @@ $ esa login
76
90
  ### dev [entry]
77
91
 
78
92
  Start a local server for developing your routine.
79
-
93
+
80
94
  ```bash
81
95
  $ esa dev [entry] [OPTIONS]
82
96
  ```
@@ -102,7 +116,7 @@ $ esa dev [entry] [OPTIONS]
102
116
  ### deployments [script]
103
117
 
104
118
  Manage your deployments.
105
-
119
+
106
120
  #### delete <deploymentId>
107
121
 
108
122
  Delete one or more deployment versions.
@@ -125,7 +139,7 @@ $ esa deployments list
125
139
  ### deploy [entry]
126
140
 
127
141
  Deploy your project.
128
-
142
+
129
143
  ```bash
130
144
  $ esa deploy [entry]
131
145
  ```
@@ -136,7 +150,7 @@ $ esa deploy [entry]
136
150
  ### domain [script]
137
151
 
138
152
  Manage the domain names bound to your routine.
139
-
153
+
140
154
  #### add <domain>
141
155
 
142
156
  Bind a domain to a routine.
@@ -170,7 +184,7 @@ $ esa domain list
170
184
  ### commit [entry]
171
185
 
172
186
  Commit your code, save as a new version.
173
-
187
+
174
188
  ```bash
175
189
  $ esa commit [entry] [OPTIONS]
176
190
  ```
@@ -184,7 +198,7 @@ $ esa commit [entry] [OPTIONS]
184
198
  ### logout
185
199
 
186
200
  Logout.
187
-
201
+
188
202
  ```bash
189
203
  $ esa logout
190
204
  ```
@@ -192,7 +206,7 @@ $ esa logout
192
206
  ### config
193
207
 
194
208
  Modify your local or global configuration using -l, -g.
195
-
209
+
196
210
  ```bash
197
211
  $ esa config [OPTIONS]
198
212
  ```
@@ -206,7 +220,7 @@ $ esa config [OPTIONS]
206
220
  ### lang
207
221
 
208
222
  Set the language of the CLI.
209
-
223
+
210
224
  ```bash
211
225
  $ esa lang
212
226
  ```
@@ -214,7 +228,7 @@ $ esa lang
214
228
  ### site [script]
215
229
 
216
230
  Manage your sites.
217
-
231
+
218
232
  #### list
219
233
 
220
234
  List all your sites.
@@ -1,5 +1,19 @@
1
1
  # Commands
2
2
 
3
+ - init - 使用模板初始化新项目
4
+ - dev - 启动本地开发服务器进行调试
5
+ - commit - 提交代码并创建一个新版本
6
+ - deploy - 部署项目到边缘网络
7
+ - deployments - 管理历史部署版本
8
+ - routine - 管理边缘函数
9
+ - site - 管理站点
10
+ - domain - 管理绑定到边缘函数的域名
11
+ - route - 管理绑定到边缘函数的路由
12
+ - login - 通过AK/SK登录到您的账户
13
+ - logout - 注销当前用户
14
+ - config - 修改本地/全局配置
15
+ - lang - 切换CLI界面语言
16
+
3
17
  ### init
4
18
 
5
19
  选择模版初始化项目。
File without changes
File without changes
@@ -75,10 +75,6 @@
75
75
  "en": "Production",
76
76
  "zh_CN": "生产环境"
77
77
  },
78
- "deploy_env_canary": {
79
- "en": "Canary",
80
- "zh_CN": "灰度环境"
81
- },
82
78
  "deploy_description_routine": {
83
79
  "en": "Enter the description of the routine",
84
80
  "zh_CN": "请输入边缘函数的描述"
@@ -103,10 +99,6 @@
103
99
  "en": "Do you want to create a formal version to deploy on production environment?",
104
100
  "zh_CN": "是否创建正式版本以部署到生产环境?"
105
101
  },
106
- "deploy_select_canary": {
107
- "en": "Please select the canary area(s) you want to deploy to",
108
- "zh_CN": "请选择您要部署的灰度区域"
109
- },
110
102
  "deploy_success": {
111
103
  "en": "Your code has been successfully deployed",
112
104
  "zh_CN": "您的代码已成功部署"
@@ -476,8 +468,8 @@
476
468
  "zh_CN": "route不合法"
477
469
  },
478
470
  "install_runtime_explain": {
479
- "en": "Under the beta phase, we are temporarily using Deno as the local development runtime. It needs to be installed first.",
480
- "zh_CN": "在Beta阶段,我们使用了Deno暂时作为本地开发运行时,需要先安装才可以dev。"
471
+ "en": "Our runtime does not yet support this OS. We are temporarily using Deno as the local development runtime, which needs to be installed first.",
472
+ "zh_CN": "我们的Runtime还不支持此操作系统,我们暂时使用Deno作为本地开发runtime,需要先安装。"
481
473
  },
482
474
  "install_runtime_tip": {
483
475
  "en": "🔔 Runtime must be installed to use esa dev. Installing...",
@@ -489,7 +481,7 @@
489
481
  },
490
482
  "route_validate": {
491
483
  "en": "You can add an asterisk (*) as the prefix or suffix to match more URLs, such as \"*.example.com/*\".",
492
- "zh_CN": "您可以通过添加前缀或后缀通配符(*)来匹配更多的URL,例如: “*.example.com/*”。"
484
+ "zh_CN": "您可以通过添加前缀或后缀通配符(*)来匹配更多的URL,例如: \"*.example.com/*\"."
493
485
  },
494
486
  "domain_input": {
495
487
  "en": "Enter the name of domain (Support fuzzy matching on tab press):",
@@ -515,6 +507,18 @@
515
507
  "en": "Generate a config file for your project",
516
508
  "zh_CN": "在您的项目中生成一个esa.toml配置文件"
517
509
  },
510
+ "init_project_name": {
511
+ "en": "Project name",
512
+ "zh_CN": "项目名称"
513
+ },
514
+ "init_template_name": {
515
+ "en": "Template name to use",
516
+ "zh_CN": "要使用的模板名称"
517
+ },
518
+ "init_template_not_found": {
519
+ "en": "Template \"${templateName}\" not found. Please check the template name and try again.",
520
+ "zh_CN": "未找到模板 \"${templateName}\"。请检查模板名称并重试。"
521
+ },
518
522
  "generate_config_error": {
519
523
  "en": "esa.toml already exists",
520
524
  "zh_CN": "esa.toml 文件已经存在"
@@ -527,6 +531,10 @@
527
531
  "en": "Minify code before committing",
528
532
  "zh_CN": "上传前压缩代码"
529
533
  },
534
+ "commit_option_description": {
535
+ "en": "Description for the routine/version (skip interactive input)",
536
+ "zh_CN": "函数/版本的描述(跳过交互式输入)"
537
+ },
530
538
  "dev_entry_describe": {
531
539
  "en": "Entry file of the Routine",
532
540
  "zh_CN": "入口文件路径"
@@ -712,7 +720,7 @@
712
720
  "zh_CN": "无权限:Access Key 或 Secret 错误,或没有必要的权限。"
713
721
  },
714
722
  "init_skip": {
715
- "en": "Initialization was skipped.",
723
+ "en": "Skip the project git and deployment initialization",
716
724
  "zh_CN": "初始化已被跳过。"
717
725
  },
718
726
  "quick_deploy_success": {
@@ -763,6 +771,30 @@
763
771
  "en": "The domain may take some time to take effect, please try again later.",
764
772
  "zh_CN": "域名生效可能需要一段时间,请稍后再试。"
765
773
  },
774
+ "deploy_quick_describe": {
775
+ "en": "Quick deploy the routine to production environment",
776
+ "zh_CN": "快速部署到生产环境"
777
+ },
778
+ "deploy_option_version": {
779
+ "en": "Version to deploy (skip interactive selection)",
780
+ "zh_CN": "要部署的版本(跳过交互式选择)"
781
+ },
782
+ "deploy_option_environment": {
783
+ "en": "Environment to deploy to: staging or production (skip interactive selection)",
784
+ "zh_CN": "部署环境:staging 或 production(跳过交互式选择)"
785
+ },
786
+ "deploy_version_not_found": {
787
+ "en": "Version '${argv.version}' not found",
788
+ "zh_CN": "版本 '${version}' 未找到"
789
+ },
790
+ "deploy_using_version": {
791
+ "en": "Using version",
792
+ "zh_CN": "使用版本"
793
+ },
794
+ "deploy_using_environment": {
795
+ "en": "Using environment",
796
+ "zh_CN": "使用环境"
797
+ },
766
798
  "init_install_dependence": {
767
799
  "en": "⌛️ Installing dependencies...",
768
800
  "zh_CN": "⌛️ 正在安装依赖..."
@@ -894,5 +926,105 @@
894
926
  "dev_url_invalid": {
895
927
  "en": "Invalid URL: ${url}. Please enter a valid URL.",
896
928
  "zh_CN": "不是正确的URL: ${url}. 请输入正确的URL."
929
+ },
930
+ "deno_download_failed": {
931
+ "en": "Download failed",
932
+ "zh_CN": "下载失败"
933
+ },
934
+ "deno_unzip_failed": {
935
+ "en": "Unzip failed",
936
+ "zh_CN": "解压失败"
937
+ },
938
+ "deno_add_path_failed": {
939
+ "en": "Add BinDir to Path failed",
940
+ "zh_CN": "添加环境变量失败"
941
+ },
942
+ "deno_install_success": {
943
+ "en": "Runtime install success!",
944
+ "zh_CN": "Runtime 安装成功!"
945
+ },
946
+ "deno_download_success": {
947
+ "en": "Download success",
948
+ "zh_CN": "下载成功"
949
+ },
950
+ "deno_install_success_tips": {
951
+ "en": "Please run ${dev} again",
952
+ "zh_CN": "请重新运行 ${dev}"
953
+ },
954
+ "no_build_script": {
955
+ "en": "No build script found in package.json, skipping build step.",
956
+ "zh_CN": "在 package.json 中未找到构建脚本,跳过构建步骤。"
957
+ },
958
+ "init_cancel": {
959
+ "en": "User canceled the operation.",
960
+ "zh_CN": "用户取消了操作。"
961
+ },
962
+ "routine_create_success": {
963
+ "en": "Routine created successfully.",
964
+ "zh_CN": "边缘函数创建成功"
965
+ },
966
+ "routine_create_fail": {
967
+ "en": "Routine created failed.",
968
+ "zh_CN": "边缘函数创建失败"
969
+ },
970
+ "create_route_route": {
971
+ "en": "Enter a Route:",
972
+ "zh_CN": "输入路由:"
973
+ },
974
+ "route_name_input_required": {
975
+ "en": "Route name is required",
976
+ "zh_CN": "路由名称是必需的"
977
+ },
978
+ "create_route_mode": {
979
+ "en": "Which mode of route do you want to use?",
980
+ "zh_CN": "您想要使用哪种路由模式?"
981
+ },
982
+ "create_route_site": {
983
+ "en": "Select a site that is active in your account:",
984
+ "zh_CN": "选择您账户中已激活的站点:"
985
+ },
986
+ "route_input_required": {
987
+ "en": "Route is required",
988
+ "zh_CN": "路由是必需的"
989
+ },
990
+ "create_route_rule": {
991
+ "en": "Enter a Rule Expression:",
992
+ "zh_CN": "输入规则表达式:"
993
+ },
994
+ "rule_input_required": {
995
+ "en": "Rule is required",
996
+ "zh_CN": "规则是必需的"
997
+ },
998
+ "route_list_simple_title": {
999
+ "en": "Related simple mode routes",
1000
+ "zh_CN": "相关简单模式路由"
1001
+ },
1002
+ "route_list_custom_title": {
1003
+ "en": "Related custom mode routes",
1004
+ "zh_CN": "相关自定义模式路由"
1005
+ },
1006
+ "create_route_route_name": {
1007
+ "en": "Enter a Route Name (Aliases):",
1008
+ "zh_CN": "输入路由名称(别名):"
1009
+ },
1010
+ "no_route_found": {
1011
+ "en": "No route found! Please check the route name.",
1012
+ "zh_CN": "未找到路由!请检查路由名称。"
1013
+ },
1014
+ "init_template_not_ready": {
1015
+ "en": "Template is not ready. We will install it for you now.",
1016
+ "zh_CN": "模版未准备好,我们为您安装模版。"
1017
+ },
1018
+ "login_option_access_key_id": {
1019
+ "en": "AccessKey ID (AK)",
1020
+ "zh_CN": "AccessKey ID (AK)"
1021
+ },
1022
+ "login_option_access_key_secret": {
1023
+ "en": "AccessKey Secret (SK)",
1024
+ "zh_CN": "AccessKey Secret (SK)"
1025
+ },
1026
+ "login_option_skip_login": {
1027
+ "en": "Skip login",
1028
+ "zh_CN": "跳过登录"
897
1029
  }
898
1030
  }
package/dist/index.js CHANGED
@@ -26,7 +26,6 @@ import { getCliConfig } from './utils/fileUtils/index.js';
26
26
  import { handleCheckVersion } from './utils/checkVersion.js';
27
27
  import t from './i18n/index.js';
28
28
  import site from './commands/site/index.js';
29
- import { quickDeployRoutine } from './libs/service.js';
30
29
  const main = () => __awaiter(void 0, void 0, void 0, function* () {
31
30
  const argv = hideBin(process.argv);
32
31
  const cliConfig = getCliConfig();
@@ -39,7 +38,7 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
39
38
  .locale((cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.lang) || 'en')
40
39
  .version(false)
41
40
  .wrap(null)
42
- .help(false)
41
+ .help()
43
42
  .epilogue(`${t('main_epilogue').d('For more information, visit ESA')}: ${chalk.underline.blue('https://www.aliyun.com/product/esa')}`)
44
43
  .options('version', {
45
44
  describe: t('main_version_describe').d('Show version'),
@@ -51,11 +50,16 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
51
50
  });
52
51
  esa.command('*', false, () => { }, (args) => {
53
52
  if (args._.length > 0) {
53
+ // Unknown command
54
+ console.error(t('common_sub_command_fail').d('Use esa <command> -h to see help'));
54
55
  }
55
56
  else {
56
57
  if (args.v) {
57
58
  handleCheckVersion();
58
59
  }
60
+ else if (args.h || args.help) {
61
+ esa.showHelp('log');
62
+ }
59
63
  else {
60
64
  esa.showHelp('log');
61
65
  }
@@ -74,13 +78,6 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
74
78
  esa.command(logout);
75
79
  esa.command(config);
76
80
  esa.command(lang);
77
- esa.command('t', false, () => { }, (args) => __awaiter(void 0, void 0, void 0, function* () {
78
- const res = yield quickDeployRoutine({
79
- name: 'test',
80
- code: 'test'
81
- });
82
- // console.log(res);
83
- }));
84
81
  esa.group(['help', 'version'], 'Options:');
85
82
  esa.parse();
86
83
  });
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);
@@ -140,9 +137,6 @@ class Client {
140
137
  const request = new $ESA.CreateRoutineRequest(params);
141
138
  return this.callApi(this.client.createRoutineWithOptions.bind(this.client), request);
142
139
  }
143
- listRoutineOptionalSpecs() {
144
- return this.callApi(this.client.listRoutineOptionalSpecsWithOptions.bind(this.client));
145
- }
146
140
  createRoutineRelatedRecord(params) {
147
141
  const request = new $ESA.CreateRoutineRelatedRecordRequest(params);
148
142
  return this.callApi(this.client.createRoutineRelatedRecordWithOptions.bind(this.client), request);
@@ -151,5 +145,34 @@ class Client {
151
145
  const request = new $ESA.DeleteRoutineRelatedRecordRequest(params);
152
146
  return this.callApi(this.client.deleteRoutineRelatedRecordWithOptions.bind(this.client), request);
153
147
  }
148
+ createRoutineRoute(params) {
149
+ const request = new $ESA.CreateRoutineRouteRequest(params);
150
+ const newRequest = Object.assign(request, { mode: 'simple' });
151
+ return this.callApi(this.client.createRoutineRouteWithOptions.bind(this.client), newRequest);
152
+ }
153
+ deleteRoutineRoute(params) {
154
+ const request = new $ESA.DeleteRoutineRouteRequest(params);
155
+ return this.callApi(this.client.deleteRoutineRouteWithOptions.bind(this.client), request);
156
+ }
157
+ getRoutineRoute(params) {
158
+ const request = new $ESA.GetRoutineRouteRequest(params);
159
+ return this.callApi(this.client.getRoutineRouteWithOptions.bind(this.client), request);
160
+ }
161
+ listSiteRoutes(params) {
162
+ const request = new $ESA.ListSiteRoutesRequest(params);
163
+ return this.callApi(this.client.listSiteRoutes.bind(this.client), request);
164
+ }
165
+ listRoutineRoutes(params) {
166
+ const request = new $ESA.ListRoutineRoutesRequest(params);
167
+ return this.callApi(this.client.listRoutineRoutes.bind(this.client), request);
168
+ }
169
+ updateRoutineRoute(params) {
170
+ const request = new $ESA.UpdateRoutineRouteRequest(params);
171
+ return this.callApi(this.client.updateRoutineRoute.bind(this.client), request);
172
+ }
173
+ listRoutineCodeVersions(params) {
174
+ const request = new $ESA.ListRoutineCodeVersionsRequest(params);
175
+ return this.callApi(this.client.listRoutineCodeVersions.bind(this.client), request);
176
+ }
154
177
  }
155
178
  export default new Client();