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

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 (70) hide show
  1. package/dist/commands/commit/index.js +20 -119
  2. package/dist/commands/commit/prodBuild.js +2 -3
  3. package/dist/commands/common/routineUtils.js +276 -0
  4. package/dist/commands/config.js +1 -1
  5. package/dist/commands/deploy/helper.js +31 -36
  6. package/dist/commands/deploy/index.js +78 -165
  7. package/dist/commands/deployments/delete.js +31 -6
  8. package/dist/commands/deployments/index.js +3 -3
  9. package/dist/commands/deployments/list.js +18 -27
  10. package/dist/commands/dev/build.js +3 -3
  11. package/dist/commands/dev/doProcess.js +5 -5
  12. package/dist/commands/dev/ew2/devPack.js +17 -8
  13. package/dist/commands/dev/ew2/mock/kv.js +2 -2
  14. package/dist/commands/dev/ew2/server.js +13 -10
  15. package/dist/commands/dev/index.js +12 -12
  16. package/dist/commands/dev/mockWorker/devPack.js +16 -7
  17. package/dist/commands/dev/mockWorker/server.js +7 -6
  18. package/dist/commands/domain/add.js +3 -3
  19. package/dist/commands/domain/delete.js +3 -3
  20. package/dist/commands/domain/index.js +3 -3
  21. package/dist/commands/domain/list.js +7 -7
  22. package/dist/commands/init/helper.js +59 -9
  23. package/dist/commands/init/index.js +416 -76
  24. package/dist/commands/init/template.jsonc +34 -0
  25. package/dist/commands/lang.js +2 -2
  26. package/dist/commands/login/index.js +9 -5
  27. package/dist/commands/logout.js +6 -6
  28. package/dist/commands/route/add.js +134 -43
  29. package/dist/commands/route/delete.js +6 -6
  30. package/dist/commands/route/index.js +3 -3
  31. package/dist/commands/route/list.js +4 -4
  32. package/dist/commands/routine/delete.js +2 -2
  33. package/dist/commands/routine/index.js +3 -3
  34. package/dist/commands/routine/list.js +5 -16
  35. package/dist/commands/site/index.js +2 -2
  36. package/dist/commands/site/list.js +6 -7
  37. package/dist/commands/utils.js +55 -19
  38. package/dist/components/descriptionInput.js +1 -1
  39. package/dist/components/mutiSelectTable.js +1 -1
  40. package/dist/components/selectInput.js +2 -3
  41. package/dist/components/selectItem.js +1 -1
  42. package/dist/docs/Commands_en.md +12 -16
  43. package/dist/docs/Commands_zh_CN.md +12 -16
  44. package/dist/docs/eslint-config-en.md +1 -0
  45. package/dist/docs/eslint-config.md +73 -0
  46. package/dist/docs/init-command-quick-test.md +208 -0
  47. package/dist/docs/init-command-test-guide.md +598 -0
  48. package/dist/i18n/index.js +2 -2
  49. package/dist/i18n/locales.json +161 -9
  50. package/dist/index.js +11 -11
  51. package/dist/libs/apiService.js +177 -14
  52. package/dist/libs/git/index.js +8 -4
  53. package/dist/libs/logger.js +63 -7
  54. package/dist/libs/service.js +2 -2
  55. package/dist/libs/templates/index.js +1 -1
  56. package/dist/utils/checkAssetsExist.js +80 -0
  57. package/dist/utils/checkDevPort.js +3 -17
  58. package/dist/utils/checkEntryFileExist.js +10 -0
  59. package/dist/utils/checkIsRoutineCreated.js +17 -16
  60. package/dist/utils/checkVersion.js +1 -1
  61. package/dist/utils/compress.js +80 -0
  62. package/dist/utils/download.js +5 -5
  63. package/dist/utils/fileMd5.js +1 -1
  64. package/dist/utils/fileUtils/index.js +71 -22
  65. package/dist/utils/installDeno.js +3 -3
  66. package/dist/utils/installEw2.js +7 -7
  67. package/dist/utils/openInBrowser.js +1 -1
  68. package/package.json +9 -3
  69. package/dist/docs/Dev_en.md +0 -0
  70. package/dist/docs/Dev_zh_CN.md +0 -0
@@ -281,7 +281,7 @@
281
281
  },
282
282
  "init_input_name": {
283
283
  "en": "Enter the name of edgeRoutine:",
284
- "zh_CN": "输入 edgeRoutine 的名称:"
284
+ "zh_CN": "输入 edgeRoutine 的名称"
285
285
  },
286
286
  "init_skip_git": {
287
287
  "en": "Git installation was skipped.",
@@ -359,6 +359,18 @@
359
359
  "en": "The name of route to add",
360
360
  "zh_CN": "要添加的路由名称"
361
361
  },
362
+ "route_add_site_describe": {
363
+ "en": "The site to bind the route to. For example: example.com",
364
+ "zh_CN": "要绑定路由的站点"
365
+ },
366
+ "route_add_route_name_option": {
367
+ "en": "Route name (aliases)",
368
+ "zh_CN": "路由名称(别名)"
369
+ },
370
+ "route_add_route_value_option": {
371
+ "en": "The route value. For example: example.com/*",
372
+ "zh_CN": "路由值"
373
+ },
362
374
  "route_add_invalid": {
363
375
  "en": "The route does not correspond to the domain.",
364
376
  "zh_CN": "该路由与域名不对应。"
@@ -505,7 +517,35 @@
505
517
  },
506
518
  "init_config_file": {
507
519
  "en": "Generate a config file for your project",
508
- "zh_CN": "在您的项目中生成一个esa.toml配置文件"
520
+ "zh_CN": "在您的项目中生成一个配置文件"
521
+ },
522
+ "init_config_format_select": {
523
+ "en": "Select configuration file format:",
524
+ "zh_CN": "选择配置文件格式:"
525
+ },
526
+ "init_config_format_jsonc": {
527
+ "en": "JSONC (.jsonc) - JSON with comments, recommended",
528
+ "zh_CN": "JSONC (.jsonc) - 带注释的JSON,推荐"
529
+ },
530
+ "init_config_format_toml": {
531
+ "en": "TOML (.toml) - Traditional format",
532
+ "zh_CN": "TOML (.toml) - 传统格式"
533
+ },
534
+ "init_language_select": {
535
+ "en": "Select programming language:",
536
+ "zh_CN": "选择编程语言:"
537
+ },
538
+ "init_language_typescript": {
539
+ "en": "TypeScript (.ts) - Type-safe JavaScript, recommended",
540
+ "zh_CN": "TypeScript (.ts) - 类型安全的JavaScript,推荐"
541
+ },
542
+ "init_language_javascript": {
543
+ "en": "JavaScript (.js) - Traditional JavaScript",
544
+ "zh_CN": "JavaScript (.js) - 传统JavaScript"
545
+ },
546
+ "init_language_selected": {
547
+ "en": "Language",
548
+ "zh_CN": "语言"
509
549
  },
510
550
  "init_project_name": {
511
551
  "en": "Project name",
@@ -520,12 +560,12 @@
520
560
  "zh_CN": "未找到模板 \"${templateName}\"。请检查模板名称并重试。"
521
561
  },
522
562
  "generate_config_error": {
523
- "en": "esa.toml already exists",
524
- "zh_CN": "esa.toml 文件已经存在"
563
+ "en": "${path.basename(newFilePath)} already exists",
564
+ "zh_CN": "配置文件已经存在"
525
565
  },
526
566
  "generate_config_success": {
527
- "en": "Generated esa.toml",
528
- "zh_CN": "生成esa.toml成功"
567
+ "en": "Generated ${path.basename(newFilePath)}",
568
+ "zh_CN": "配置文件生成成功"
529
569
  },
530
570
  "commit_option_minify": {
531
571
  "en": "Minify code before committing",
@@ -720,8 +760,8 @@
720
760
  "zh_CN": "无权限:Access Key 或 Secret 错误,或没有必要的权限。"
721
761
  },
722
762
  "init_skip": {
723
- "en": "Skip the project git and deployment initialization",
724
- "zh_CN": "初始化已被跳过。"
763
+ "en": "Answer \"No\" to any prompts for new projects.",
764
+ "zh_CN": "回答 \"否\" 到所有提示。"
725
765
  },
726
766
  "quick_deploy_success": {
727
767
  "en": "Your code has been successfully deployed",
@@ -735,6 +775,18 @@
735
775
  "en": "Quick deploy failed",
736
776
  "zh_CN": "快速部署失败。"
737
777
  },
778
+ "quick_deploy_assets_detected": {
779
+ "en": "Static assets detected, deploying with assets support",
780
+ "zh_CN": "检测到静态资源,正在使用资源支持进行部署"
781
+ },
782
+ "quick_deploy_assets_success": {
783
+ "en": "A new version has been successfully generated",
784
+ "zh_CN": "您的代码和静态资源已成功部署"
785
+ },
786
+ "quick_deploy_assets_failed": {
787
+ "en": "Quick deploy with assets failed",
788
+ "zh_CN": "带静态资源的快速部署失败"
789
+ },
738
790
  "auto_deploy": {
739
791
  "en": "Do you want to deploy your project?",
740
792
  "zh_CN": "您想要部署您的项目吗?"
@@ -968,7 +1020,7 @@
968
1020
  "zh_CN": "边缘函数创建失败"
969
1021
  },
970
1022
  "create_route_route": {
971
- "en": "Enter a Route:",
1023
+ "en": "Enter a Route (e.g., example.com/*):",
972
1024
  "zh_CN": "输入路由:"
973
1025
  },
974
1026
  "route_name_input_required": {
@@ -1026,5 +1078,105 @@
1026
1078
  "login_option_skip_login": {
1027
1079
  "en": "Skip login",
1028
1080
  "zh_CN": "跳过登录"
1081
+ },
1082
+ "check_and_update_package_error": {
1083
+ "en": "Error: An error occurred while checking and updating the package, skipping template update",
1084
+ "zh_CN": "检测和更新包时发生错误,跳过更新模版"
1085
+ },
1086
+ "init_yes": {
1087
+ "en": "Answer \"Yes\" to all prompts.",
1088
+ "zh_CN": "回答 \"是\" 到所有提示。"
1089
+ },
1090
+ "init_no_templates": {
1091
+ "en": "No templates available.",
1092
+ "zh_CN": "没有可用的模版。"
1093
+ },
1094
+ "no_active_sites": {
1095
+ "en": "No active sites found in your account",
1096
+ "zh_CN": "没有找到已激活的站点"
1097
+ },
1098
+ "route_format_invalid": {
1099
+ "en": "Invalid route format",
1100
+ "zh_CN": "无效的路由格式"
1101
+ },
1102
+ "creating_route": {
1103
+ "en": "Creating route...",
1104
+ "zh_CN": "创建路由..."
1105
+ },
1106
+ "site_not_found": {
1107
+ "en": "Site \"${siteName}\" not found in your account",
1108
+ "zh_CN": "站点 \"${siteName}\" 未找到"
1109
+ },
1110
+ "commit_assets_exist": {
1111
+ "en": "This is a routine with assets project",
1112
+ "zh_CN": ""
1113
+ },
1114
+ "commit_routine_with_assets_success": {
1115
+ "en": "Routine with assets code version committed successfully.",
1116
+ "zh_CN": ""
1117
+ },
1118
+ "commit_routine_with_assets_fail": {
1119
+ "en": "An error occurred while trying to commit your routine with assets.",
1120
+ "zh_CN": ""
1121
+ },
1122
+ "commit_option_assets": {
1123
+ "en": "Assets directory",
1124
+ "zh_CN": ""
1125
+ },
1126
+ "commit_option_name": {
1127
+ "en": "Edge Routine name",
1128
+ "zh_CN": ""
1129
+ },
1130
+ "deploy_option_name": {
1131
+ "en": "Name of the routine",
1132
+ "zh_CN": ""
1133
+ },
1134
+ "deploy_option_assets": {
1135
+ "en": "Deploy assets",
1136
+ "zh_CN": ""
1137
+ },
1138
+ "deploy_invalid_environment": {
1139
+ "en": "Invalid environment",
1140
+ "zh_CN": ""
1141
+ },
1142
+ "deploy_success_guide_2": {
1143
+ "en": "Run this command to add routes",
1144
+ "zh_CN": ""
1145
+ },
1146
+ "login_get_from_env": {
1147
+ "en": "Get AccessKey ID and AccessKey Secret from environment variables.",
1148
+ "zh_CN": ""
1149
+ },
1150
+ "deploy_option_description": {
1151
+ "en": "Description of the version",
1152
+ "zh_CN": ""
1153
+ },
1154
+ "deploy_option_minify": {
1155
+ "en": "Minify the code",
1156
+ "zh_CN": ""
1157
+ },
1158
+ "error_reading_project_config_file": {
1159
+ "en": "Error reading project configuration file.",
1160
+ "zh_CN": "读取项目配置文件错误"
1161
+ },
1162
+ "checking_template_update": {
1163
+ "en": "Checking esa-template updates...",
1164
+ "zh_CN": ""
1165
+ },
1166
+ "template_updating": {
1167
+ "en": "Updating templates to latest...",
1168
+ "zh_CN": ""
1169
+ },
1170
+ "template_updated_to_latest": {
1171
+ "en": "Templates updated to latest.",
1172
+ "zh_CN": ""
1173
+ },
1174
+ "checking_esa_template_finished": {
1175
+ "en": "Checking esa-template finished.",
1176
+ "zh_CN": ""
1177
+ },
1178
+ "git_installed_success": {
1179
+ "en": "Git has been installed successfully.",
1180
+ "zh_CN": ""
1029
1181
  }
1030
1182
  }
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 chalk from 'chalk';
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 routeCommand from './commands/route/index.js';
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 { getCliConfig } from './utils/fileUtils/index.js';
26
- import { handleCheckVersion } from './utils/checkVersion.js';
27
- import t from './i18n/index.js';
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 } 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();
@@ -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, arguments, void 0, function* (isShowError = true) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
52
  try {
53
53
  let params = {
54
54
  action: 'GetErService',
@@ -90,7 +90,7 @@ export class ApiService {
90
90
  }
91
91
  }
92
92
  catch (error) {
93
- isShowError && console.log(error);
93
+ console.log('error', error);
94
94
  return {
95
95
  success: false,
96
96
  message: t('login_failed').d('An error occurred while trying to log in.')
@@ -522,7 +522,6 @@ export class ApiService {
522
522
  }
523
523
  getRoutine(requestParams_1) {
524
524
  return __awaiter(this, arguments, void 0, function* (requestParams, isShowError = true) {
525
- var _a, _b, _c, _d, _e, _f;
526
525
  try {
527
526
  let params = {
528
527
  action: 'GetRoutine',
@@ -552,14 +551,7 @@ export class ApiService {
552
551
  if (res.statusCode === 200 && res.body) {
553
552
  const routineResponse = {
554
553
  code: res.statusCode,
555
- data: {
556
- RequestId: (_a = res.body) === null || _a === void 0 ? void 0 : _a.RequestId,
557
- CodeVersions: ((_b = res.body) === null || _b === void 0 ? void 0 : _b.CodeVersions) || [],
558
- Envs: ((_c = res.body) === null || _c === void 0 ? void 0 : _c.Envs) || [],
559
- CreateTime: (_d = res.body) === null || _d === void 0 ? void 0 : _d.CreateTime,
560
- Description: (_e = res.body) === null || _e === void 0 ? void 0 : _e.Description,
561
- DefaultRelatedRecord: (_f = res.body) === null || _f === void 0 ? void 0 : _f.DefaultRelatedRecord
562
- }
554
+ data: res.body
563
555
  };
564
556
  return routineResponse;
565
557
  }
@@ -664,7 +656,6 @@ export class ApiService {
664
656
  body: formData,
665
657
  headers: formData.getHeaders()
666
658
  });
667
- // console.log('oss result', oss);
668
659
  if (ossRes && ossRes.status === 200) {
669
660
  return true;
670
661
  }
@@ -920,5 +911,177 @@ export class ApiService {
920
911
  return null;
921
912
  });
922
913
  }
914
+ /**
915
+ * 调用 CreateRoutineWithAssetsCodeVersion API 获取 OSS 上传配置
916
+ */
917
+ CreateRoutineWithAssetsCodeVersion(requestParams) {
918
+ return __awaiter(this, void 0, void 0, function* () {
919
+ try {
920
+ let params = {
921
+ action: 'CreateRoutineWithAssetsCodeVersion',
922
+ version: '2024-09-10',
923
+ protocol: 'https',
924
+ method: 'POST',
925
+ authType: 'AK',
926
+ bodyType: 'json',
927
+ reqBodyType: 'json',
928
+ style: 'RPC',
929
+ pathname: '/',
930
+ toMap: function () {
931
+ return this;
932
+ }
933
+ };
934
+ let request = new $OpenApi.OpenApiRequest({
935
+ query: {
936
+ Name: requestParams.Name,
937
+ CodeDescription: requestParams.CodeDescription,
938
+ BuildId: requestParams.BuildId
939
+ }
940
+ });
941
+ let runtime = {
942
+ toMap: function () {
943
+ return this;
944
+ }
945
+ };
946
+ const result = yield this.client.callApi(params, request, runtime);
947
+ if (result.statusCode === 200 && result.body) {
948
+ return {
949
+ code: result.statusCode.toString(),
950
+ data: {
951
+ RequestId: result.body.RequestId,
952
+ CodeVersion: result.body.CodeVersion,
953
+ Status: result.body.Status,
954
+ OssPostConfig: result.body.OssPostConfig
955
+ }
956
+ };
957
+ }
958
+ return null;
959
+ }
960
+ catch (error) {
961
+ console.error('Error calling CreateRoutineWithAssetsCodeVersion:', error);
962
+ return null;
963
+ }
964
+ });
965
+ }
966
+ /**
967
+ * 上传文件到 OSS
968
+ */
969
+ uploadToOss(ossConfig, zipBuffer) {
970
+ return __awaiter(this, void 0, void 0, function* () {
971
+ try {
972
+ const { OSSAccessKeyId, Signature, Url, Key, Policy, XOssSecurityToken } = ossConfig;
973
+ const formData = new FormData();
974
+ formData.append('OSSAccessKeyId', OSSAccessKeyId);
975
+ formData.append('Signature', Signature);
976
+ formData.append('x-oss-security-token', XOssSecurityToken);
977
+ formData.append('policy', Policy);
978
+ formData.append('key', Key);
979
+ formData.append('file', zipBuffer);
980
+ const ossRes = yield fetch(Url, {
981
+ method: 'POST',
982
+ body: formData,
983
+ headers: formData.getHeaders()
984
+ });
985
+ return ossRes && (ossRes.status === 200 || ossRes.status === 204);
986
+ }
987
+ catch (error) {
988
+ console.error('Error uploading to OSS:', error);
989
+ return false;
990
+ }
991
+ });
992
+ }
993
+ createRoutineCodeDeployment(requestParams) {
994
+ return __awaiter(this, void 0, void 0, function* () {
995
+ try {
996
+ let params = {
997
+ action: 'CreateRoutineCodeDeployment',
998
+ version: '2024-09-10',
999
+ protocol: 'https',
1000
+ method: 'POST',
1001
+ authType: 'AK',
1002
+ bodyType: 'json',
1003
+ reqBodyType: 'json',
1004
+ style: 'RPC',
1005
+ pathname: '/',
1006
+ toMap: function () {
1007
+ return this;
1008
+ }
1009
+ };
1010
+ let request = new $OpenApi.OpenApiRequest({
1011
+ query: {
1012
+ Name: requestParams.Name,
1013
+ Env: requestParams.Env,
1014
+ Strategy: requestParams.Strategy,
1015
+ CodeVersions: JSON.stringify(requestParams.CodeVersions)
1016
+ }
1017
+ });
1018
+ let runtime = {
1019
+ toMap: function () {
1020
+ return this;
1021
+ }
1022
+ };
1023
+ const res = yield this.client.callApi(params, request, runtime);
1024
+ if (res.statusCode === 200 && res.body) {
1025
+ const ret = {
1026
+ code: res.statusCode,
1027
+ data: {
1028
+ RequestId: res.body.RequestId,
1029
+ Strategy: res.body.Strategy,
1030
+ DeploymentId: res.body.DeploymentId,
1031
+ CodeVersions: res.body.CodeVersions
1032
+ }
1033
+ };
1034
+ return ret;
1035
+ }
1036
+ }
1037
+ catch (error) {
1038
+ console.log(error);
1039
+ }
1040
+ return null;
1041
+ });
1042
+ }
1043
+ getRoutineCodeVersionInfo(requestParams) {
1044
+ return __awaiter(this, void 0, void 0, function* () {
1045
+ try {
1046
+ let params = {
1047
+ action: 'GetRoutineCodeVersionInfo',
1048
+ version: '2024-09-10',
1049
+ protocol: 'https',
1050
+ method: 'GET',
1051
+ authType: 'AK',
1052
+ bodyType: 'json',
1053
+ reqBodyType: 'json',
1054
+ style: 'RPC',
1055
+ pathname: '/',
1056
+ toMap: function () {
1057
+ return this;
1058
+ }
1059
+ };
1060
+ let request = new $OpenApi.OpenApiRequest({
1061
+ query: {
1062
+ Name: requestParams.Name,
1063
+ CodeVersion: requestParams.CodeVersion
1064
+ }
1065
+ });
1066
+ let runtime = {
1067
+ toMap: function () {
1068
+ return this;
1069
+ }
1070
+ };
1071
+ const res = yield this.client.callApi(params, request, runtime);
1072
+ if (res.statusCode === 200 && res.body) {
1073
+ const ret = {
1074
+ code: res.statusCode,
1075
+ data: res.body
1076
+ };
1077
+ return ret;
1078
+ }
1079
+ }
1080
+ catch (error) {
1081
+ console.log(error);
1082
+ }
1083
+ return null;
1084
+ });
1085
+ }
923
1086
  }
924
1087
  ApiService.instance = null;
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { execSync } from 'child_process';
11
11
  import { exit } from 'process';
12
+ import logger from '../../libs/logger.js';
12
13
  export function isInstalledGit() {
13
14
  try {
14
15
  execSync('git --version');
@@ -32,7 +33,7 @@ export function cloneRepository(url, path) {
32
33
  return __awaiter(this, void 0, void 0, function* () {
33
34
  try {
34
35
  execSync(`git clone ${url} ${path}`, { stdio: 'inherit' });
35
- console.log('Repository cloned successfully.');
36
+ logger.log('Repository cloned successfully.');
36
37
  }
37
38
  catch (error) {
38
39
  console.error('Error occurred while cloning the repository:', error);
@@ -40,10 +41,13 @@ export function cloneRepository(url, path) {
40
41
  }
41
42
  });
42
43
  }
43
- export function installGit(path) {
44
+ export function installGit(path, debug = false) {
44
45
  try {
45
- execSync('git init', { stdio: 'inherit', cwd: path });
46
- console.log('Git has been installed successfully.');
46
+ execSync('git init', { stdio: 'ignore', cwd: path });
47
+ if (debug) {
48
+ logger.log('Git has been installed successfully.');
49
+ }
50
+ return true;
47
51
  }
48
52
  catch (error) {
49
53
  console.error('Error occurred during Git installation:', error);
@@ -1,10 +1,10 @@
1
+ import os from 'os';
2
+ import path from 'path';
1
3
  import chalk from 'chalk';
2
- import { format, createLogger } from 'winston';
3
- import DailyRotateFile from 'winston-daily-rotate-file';
4
4
  import Table from 'cli-table3';
5
- import path from 'path';
6
- import os from 'os';
7
5
  import ora from 'ora';
6
+ import { format, createLogger } from 'winston';
7
+ import DailyRotateFile from 'winston-daily-rotate-file';
8
8
  import t from '../i18n/index.js';
9
9
  import { getProjectConfig } from '../utils/fileUtils/index.js';
10
10
  const transport = new DailyRotateFile({
@@ -72,7 +72,7 @@ class Logger {
72
72
  console.log(`\t${message}`);
73
73
  }
74
74
  success(message) {
75
- console.log(`\n🎉 ${chalk.bgGreen(' SUCCESS ')} ${chalk.green(message)}`);
75
+ console.log(`🎉 ${chalk.bgGreen(' SUCCESS ')} ${chalk.green(message)}`);
76
76
  }
77
77
  debug(message) {
78
78
  this.logger.debug(message);
@@ -146,15 +146,71 @@ class Logger {
146
146
  if (messages.length === 0)
147
147
  return;
148
148
  const lines = [];
149
- lines.push(`╭─ ${messages[0]}`);
149
+ lines.push(`╭ ${messages[0]}`);
150
150
  for (let i = 1; i < messages.length - 1; i++) {
151
151
  lines.push(`│ ${messages[i]}`);
152
152
  }
153
153
  if (messages.length > 1) {
154
- lines.push(`╰─ ${messages[messages.length - 1]}`);
154
+ lines.push(`╰ ${messages[messages.length - 1]}`);
155
155
  }
156
156
  console.log(lines.join('\n'));
157
157
  }
158
+ // Cloudflare-like step rendering helpers
159
+ cfStepHeader(title, step, total) {
160
+ console.log(`\n╭ ${title} ${chalk.green(`Step ${step} of ${total}`)}`);
161
+ console.log('│');
162
+ }
163
+ cfStepItem(prompt) {
164
+ console.log(`├ ${prompt}`);
165
+ }
166
+ cfStepKV(key, value) {
167
+ const orange = chalk.hex('#FFA500');
168
+ console.log(`│ ${orange(key)} ${value}`);
169
+ }
170
+ cfStepSpacer() {
171
+ console.log('│');
172
+ }
173
+ cfStepEnd(str) {
174
+ console.log(`╰ ${str || ''}`);
175
+ }
176
+ cfStepEndInline() {
177
+ try {
178
+ process.stdout.write('╰ ');
179
+ }
180
+ catch (_a) {
181
+ console.log('╰');
182
+ }
183
+ }
184
+ divider() {
185
+ console.log(chalk.yellow('--------------------------------------------------------'));
186
+ }
187
+ // Replace the previous single terminal line with new content
188
+ replacePrevLine(content) {
189
+ try {
190
+ // Move cursor up 1 line, clear it, carriage return, print new content
191
+ process.stdout.write('\x1b[1A');
192
+ process.stdout.write('\x1b[2K');
193
+ process.stdout.write('\r');
194
+ console.log(content);
195
+ }
196
+ catch (_a) {
197
+ console.log(content);
198
+ }
199
+ }
200
+ // Replace multiple previous lines with one consolidated line
201
+ replacePrevLines(linesToReplace, content) {
202
+ try {
203
+ for (let i = 0; i < linesToReplace; i++) {
204
+ process.stdout.write('\x1b[1A'); // move up
205
+ process.stdout.write('\x1b[2K'); // clear line
206
+ }
207
+ process.stdout.write('\r');
208
+ console.log(content);
209
+ }
210
+ catch (_a) {
211
+ console.log(content);
212
+ }
213
+ }
158
214
  }
159
215
  const logger = Logger.getInstance();
160
216
  export default logger;
@@ -7,10 +7,10 @@ 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 ora from 'ora';
11
- import chain from 'lodash';
12
10
  import FormData from 'form-data';
11
+ import chain from 'lodash';
13
12
  import fetch from 'node-fetch';
13
+ import ora from 'ora';
14
14
  import t from '../i18n/index.js';
15
15
  import api from './api.js';
16
16
  import { Environment } from './interface.js';
@@ -1,5 +1,5 @@
1
- import { getSummary } from '../../commands/common/constant.js';
2
1
  import chalk from 'chalk';
2
+ import { getSummary } from '../../commands/common/constant.js';
3
3
  import logger from '../logger.js';
4
4
  export default class Template {
5
5
  constructor(path, title) {