esa-cli 0.0.2-beta.2 → 0.0.2-beta.20

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 (82) hide show
  1. package/dist/commands/commit/index.js +48 -115
  2. package/dist/commands/commit/prodBuild.js +2 -3
  3. package/dist/commands/common/constant.js +0 -19
  4. package/dist/commands/common/utils.js +416 -0
  5. package/dist/commands/config.js +1 -1
  6. package/dist/commands/deploy/helper.js +51 -72
  7. package/dist/commands/deploy/index.js +50 -188
  8. package/dist/commands/deployments/delete.js +32 -22
  9. package/dist/commands/deployments/index.js +2 -2
  10. package/dist/commands/deployments/list.js +22 -38
  11. package/dist/commands/dev/build.js +3 -3
  12. package/dist/commands/dev/doProcess.js +5 -5
  13. package/dist/commands/dev/ew2/cacheService.js +33 -0
  14. package/dist/commands/dev/ew2/devEntry.js +2 -1
  15. package/dist/commands/dev/ew2/devPack.js +39 -43
  16. package/dist/commands/dev/ew2/kvService.js +27 -0
  17. package/dist/commands/dev/ew2/mock/cache.js +99 -15
  18. package/dist/commands/dev/ew2/mock/kv.js +142 -21
  19. package/dist/commands/dev/ew2/server.js +165 -29
  20. package/dist/commands/dev/index.js +17 -17
  21. package/dist/commands/dev/mockWorker/devPack.js +35 -24
  22. package/dist/commands/dev/mockWorker/server.js +7 -6
  23. package/dist/commands/domain/add.js +2 -2
  24. package/dist/commands/domain/delete.js +7 -7
  25. package/dist/commands/domain/index.js +2 -2
  26. package/dist/commands/domain/list.js +10 -10
  27. package/dist/commands/init/helper.js +759 -0
  28. package/dist/commands/init/index.js +88 -220
  29. package/dist/commands/init/snippets/nextjs/next.config.mjs +6 -0
  30. package/dist/commands/init/snippets/nextjs/next.config.ts +7 -0
  31. package/dist/commands/init/snippets/react-router/react-router.config.ts +7 -0
  32. package/dist/commands/init/template.jsonc +84 -0
  33. package/dist/commands/init/types.js +1 -0
  34. package/dist/commands/lang.js +2 -2
  35. package/dist/commands/login/index.js +74 -34
  36. package/dist/commands/logout.js +5 -5
  37. package/dist/commands/route/add.js +105 -49
  38. package/dist/commands/route/delete.js +33 -27
  39. package/dist/commands/route/helper.js +123 -0
  40. package/dist/commands/route/index.js +2 -2
  41. package/dist/commands/route/list.js +56 -17
  42. package/dist/commands/routine/delete.js +2 -2
  43. package/dist/commands/routine/index.js +2 -2
  44. package/dist/commands/routine/list.js +43 -37
  45. package/dist/commands/site/index.js +1 -1
  46. package/dist/commands/site/list.js +6 -7
  47. package/dist/commands/utils.js +59 -23
  48. package/dist/components/descriptionInput.js +1 -1
  49. package/dist/components/filterSelector.js +1 -1
  50. package/dist/components/mutiLevelSelect.js +43 -55
  51. package/dist/components/mutiSelectTable.js +1 -1
  52. package/dist/components/routeBuilder.js +68 -0
  53. package/dist/components/selectInput.js +2 -3
  54. package/dist/components/selectItem.js +1 -1
  55. package/dist/docs/Commands_en.md +142 -131
  56. package/dist/docs/Commands_zh_CN.md +139 -127
  57. package/dist/i18n/index.js +2 -2
  58. package/dist/i18n/locales.json +435 -23
  59. package/dist/index.js +27 -20
  60. package/dist/libs/api.js +32 -9
  61. package/dist/libs/apiService.js +267 -88
  62. package/dist/libs/git/index.js +86 -9
  63. package/dist/libs/interface.js +0 -1
  64. package/dist/libs/logger.js +162 -10
  65. package/dist/libs/service.js +2 -2
  66. package/dist/libs/templates/index.js +3 -2
  67. package/dist/utils/checkAssetsExist.js +80 -0
  68. package/dist/utils/checkDevPort.js +3 -17
  69. package/dist/utils/checkEntryFileExist.js +10 -0
  70. package/dist/utils/checkIsRoutineCreated.js +28 -27
  71. package/dist/utils/checkVersion.js +119 -1
  72. package/dist/utils/command.js +149 -0
  73. package/dist/utils/compress.js +136 -0
  74. package/dist/utils/download.js +182 -0
  75. package/dist/utils/fileMd5.js +1 -1
  76. package/dist/utils/fileUtils/base.js +1 -1
  77. package/dist/utils/fileUtils/index.js +136 -44
  78. package/dist/utils/installDeno.js +8 -8
  79. package/dist/utils/installEw2.js +7 -7
  80. package/dist/utils/openInBrowser.js +1 -1
  81. package/dist/utils/prompt.js +97 -0
  82. package/package.json +19 -12
@@ -7,19 +7,41 @@ 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 fs from 'fs';
10
+ import fs, { promises as fsPromises } from 'fs';
11
11
  import os from 'os';
12
12
  import path from 'path';
13
13
  import toml from '@iarna/toml';
14
- import { promises as fsPromises } from 'fs';
15
- import { getDirName, getRoot } from './base.js';
16
- import logger from '../../libs/logger.js';
17
14
  import t from '../../i18n/index.js';
15
+ import logger from '../../libs/logger.js';
16
+ import { getDirName, getRoot } from './base.js';
18
17
  const projectConfigFile = 'esa.toml';
19
18
  const __dirname = getDirName(import.meta.url);
20
19
  const root = getRoot();
21
- export const projectConfigPath = path.join(root, projectConfigFile);
20
+ // Function to get the actual project config file path (supports both .jsonc and .toml)
21
+ export const getProjectConfigPath = (filePath = root) => {
22
+ const configFormats = ['esa.jsonc', 'esa.toml'];
23
+ for (const format of configFormats) {
24
+ const configPath = path.join(filePath, format);
25
+ if (fs.existsSync(configPath)) {
26
+ return configPath;
27
+ }
28
+ }
29
+ // Default to .jsonc if no config file exists
30
+ return path.join(filePath, 'esa.jsonc');
31
+ };
32
+ export const projectConfigPath = getProjectConfigPath();
22
33
  export const cliConfigPath = path.join(os.homedir(), '.esa/config/default.toml');
34
+ // Function to get the actual config file path (supports both .toml and .jsonc)
35
+ export const getCliConfigPath = () => {
36
+ const configDir = path.join(os.homedir(), '.esa/config');
37
+ const jsoncPath = path.join(configDir, 'default.jsonc');
38
+ const tomlPath = path.join(configDir, 'default.toml');
39
+ // Check if JSONC file exists first, then fallback to TOML
40
+ if (fs.existsSync(jsoncPath)) {
41
+ return jsoncPath;
42
+ }
43
+ return tomlPath;
44
+ };
23
45
  export const hiddenConfigDir = path.join(os.homedir(), '.esa/config');
24
46
  export const generateHiddenConfigDir = () => {
25
47
  if (!fs.existsSync(hiddenConfigDir)) {
@@ -29,7 +51,7 @@ export const generateHiddenConfigDir = () => {
29
51
  export const generateToml = (path) => {
30
52
  if (!fs.existsSync(path)) {
31
53
  fs.writeFileSync(path, '', 'utf-8');
32
- // 添加默认的endpoint
54
+ // Add default endpoint
33
55
  const defaultConfig = {
34
56
  endpoint: 'esa.cn-hangzhou.aliyuncs.com'
35
57
  };
@@ -38,20 +60,34 @@ export const generateToml = (path) => {
38
60
  };
39
61
  export const generateDefaultConfig = () => {
40
62
  generateHiddenConfigDir();
41
- generateToml(cliConfigPath);
63
+ const configPath = getCliConfigPath();
64
+ generateToml(configPath);
42
65
  };
43
66
  export function updateProjectConfigFile(configUpdate_1) {
44
67
  return __awaiter(this, arguments, void 0, function* (configUpdate, filePath = root) {
45
- const configPath = path.join(filePath, projectConfigFile);
68
+ const configPath = getProjectConfigPath(filePath);
46
69
  try {
47
70
  let configFileContent = yield fsPromises.readFile(configPath, 'utf8');
48
- let config = toml.parse(configFileContent);
49
- config = Object.assign(Object.assign({}, config), configUpdate);
50
- const updatedConfigString = toml.stringify(config);
71
+ let config;
72
+ let updatedConfigString;
73
+ // Detect file format based on file extension
74
+ if (configPath.endsWith('.jsonc') || configPath.endsWith('.json')) {
75
+ // Handle JSONC format
76
+ const jsonContent = configFileContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
77
+ config = JSON.parse(jsonContent);
78
+ config = Object.assign(Object.assign({}, config), configUpdate);
79
+ updatedConfigString = JSON.stringify(config, null, 2) + '\n';
80
+ }
81
+ else {
82
+ // Handle TOML format (default)
83
+ config = toml.parse(configFileContent);
84
+ config = Object.assign(Object.assign({}, config), configUpdate);
85
+ updatedConfigString = toml.stringify(config);
86
+ }
51
87
  yield fsPromises.writeFile(configPath, updatedConfigString);
52
88
  }
53
89
  catch (error) {
54
- logger.error(`Error updating TOML file: ${error}`);
90
+ logger.error(`Error updating config file: ${error}`);
55
91
  logger.pathEacces(__dirname);
56
92
  }
57
93
  });
@@ -59,16 +95,30 @@ export function updateProjectConfigFile(configUpdate_1) {
59
95
  export function updateCliConfigFile(configUpdate) {
60
96
  return __awaiter(this, void 0, void 0, function* () {
61
97
  try {
62
- let configFileContent = yield fsPromises.readFile(cliConfigPath, 'utf8');
63
- let config = toml.parse(configFileContent);
64
- config = Object.assign(Object.assign({}, config), configUpdate);
65
- const updatedConfigString = toml.stringify(config);
66
- yield fsPromises.writeFile(cliConfigPath, updatedConfigString);
98
+ const configPath = getCliConfigPath();
99
+ let configFileContent = yield fsPromises.readFile(configPath, 'utf8');
100
+ let config;
101
+ let updatedConfigString;
102
+ // Detect file format based on file extension
103
+ if (configPath.endsWith('.jsonc') || configPath.endsWith('.json')) {
104
+ // Handle JSONC format
105
+ const jsonContent = configFileContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
106
+ config = JSON.parse(jsonContent);
107
+ config = Object.assign(Object.assign({}, config), configUpdate);
108
+ updatedConfigString = JSON.stringify(config, null, 2) + '\n';
109
+ }
110
+ else {
111
+ // Handle TOML format (default)
112
+ config = toml.parse(configFileContent);
113
+ config = Object.assign(Object.assign({}, config), configUpdate);
114
+ updatedConfigString = toml.stringify(config);
115
+ }
116
+ yield fsPromises.writeFile(configPath, updatedConfigString);
67
117
  }
68
118
  catch (error) {
69
- logger.error(`Error updating TOML file: ${error}`);
119
+ logger.error(`Error updating config file: ${error}`);
70
120
  logger.pathEacces(__dirname);
71
- throw new Error('Login error');
121
+ throw new Error('Config update error');
72
122
  }
73
123
  });
74
124
  }
@@ -76,35 +126,46 @@ export function readConfigFile(configPath) {
76
126
  if (fs.existsSync(configPath)) {
77
127
  const configFileContent = fs.readFileSync(configPath, 'utf-8');
78
128
  try {
79
- const config = toml.parse(configFileContent);
80
- return config;
129
+ if (configPath.endsWith('.jsonc') || configPath.endsWith('.json')) {
130
+ // Remove comments for JSON parsing
131
+ const jsonContent = configFileContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
132
+ const config = JSON.parse(jsonContent);
133
+ return config;
134
+ }
135
+ else {
136
+ // TOML format
137
+ const config = toml.parse(configFileContent);
138
+ return config;
139
+ }
81
140
  }
82
141
  catch (error) {
83
- logger.error(`Error parsing TOML file: ${error}`);
142
+ logger.error(`Error parsing config file: ${error}`);
84
143
  return null;
85
144
  }
86
145
  }
87
146
  return null;
88
147
  }
89
148
  export function getCliConfig() {
90
- const res = readConfigFile(cliConfigPath);
149
+ const configPath = getCliConfigPath();
150
+ const res = readConfigFile(configPath);
91
151
  if (!res) {
92
152
  return null;
93
153
  }
94
154
  return res;
95
155
  }
96
156
  export function getProjectConfig(filePath = root) {
97
- const res = readConfigFile(path.join(filePath, projectConfigFile));
98
- if (!res) {
99
- return null;
157
+ // Try to find config file in order of preference: .jsonc, .toml
158
+ const configFormats = ['esa.jsonc', 'esa.toml'];
159
+ for (const format of configFormats) {
160
+ const configPath = path.join(filePath, format);
161
+ const config = readConfigFile(configPath);
162
+ if (config) {
163
+ return config;
164
+ }
100
165
  }
101
- return res;
166
+ return null;
102
167
  }
103
168
  export function readEdgeRoutineFile(projectPath = root) {
104
- const projectConfig = getProjectConfig(projectPath);
105
- if (!projectConfig) {
106
- return null;
107
- }
108
169
  const pubFilePath = `.dev/pub.js`;
109
170
  const edgeRoutinePath = path.join(projectPath, pubFilePath);
110
171
  if (fs.existsSync(edgeRoutinePath)) {
@@ -122,26 +183,57 @@ export function getConfigurations() {
122
183
  return [null, null];
123
184
  }
124
185
  }
125
- export function generateConfigFile(projectName, initConfigs) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- var _a;
128
- const newFilePath = path.join(process.cwd(), 'esa.toml');
129
- const currentDirName = path.basename(process.cwd());
130
- const entry = ((_a = initConfigs === null || initConfigs === void 0 ? void 0 : initConfigs.dev) === null || _a === void 0 ? void 0 : _a.entry) || 'src/index.js';
186
+ export function generateConfigFile(projectName_1, initConfigs_1, targetDir_1) {
187
+ return __awaiter(this, arguments, void 0, function* (projectName, initConfigs, targetDir, configFormat = 'jsonc', notFoundStrategy) {
188
+ var _a, _b;
189
+ const outputDir = targetDir !== null && targetDir !== void 0 ? targetDir : process.cwd();
190
+ const currentDirName = path.basename(outputDir);
191
+ const entry = (_a = initConfigs === null || initConfigs === void 0 ? void 0 : initConfigs.dev) === null || _a === void 0 ? void 0 : _a.entry;
131
192
  const port = (initConfigs === null || initConfigs === void 0 ? void 0 : initConfigs.port) || 18080;
132
193
  const name = projectName || currentDirName;
194
+ const assetsDirectory = (_b = initConfigs === null || initConfigs === void 0 ? void 0 : initConfigs.assets) === null || _b === void 0 ? void 0 : _b.directory;
195
+ let newFilePath;
196
+ let genConfig;
197
+ if (configFormat === 'jsonc') {
198
+ newFilePath = path.join(outputDir, 'esa.jsonc');
199
+ const configObj = { name };
200
+ if (entry)
201
+ configObj.entry = entry;
202
+ if (assetsDirectory) {
203
+ configObj.assets = { directory: assetsDirectory };
204
+ if (notFoundStrategy) {
205
+ configObj.assets.notFoundStrategy =
206
+ notFoundStrategy;
207
+ }
208
+ }
209
+ configObj.dev = { port };
210
+ genConfig = JSON.stringify(configObj, null, 2) + '\n';
211
+ }
212
+ else {
213
+ // Default to TOML format
214
+ newFilePath = path.join(outputDir, 'esa.toml');
215
+ const configObj = {
216
+ name,
217
+ dev: { port }
218
+ };
219
+ if (entry)
220
+ configObj.entry = entry;
221
+ if (assetsDirectory) {
222
+ configObj.assets = { directory: assetsDirectory };
223
+ if (notFoundStrategy) {
224
+ configObj.assets.notFoundStrategy =
225
+ notFoundStrategy;
226
+ }
227
+ }
228
+ genConfig = toml.stringify(configObj);
229
+ }
133
230
  if (fs.existsSync(newFilePath)) {
134
- logger.error(t('generate_config_error').d('esa.toml already exists'));
231
+ logger.error(`${path.basename(newFilePath)}` +
232
+ t('generate_config_error').d('already exists'));
135
233
  return;
136
234
  }
137
235
  else {
138
- const genConfig = `name = "${name}"
139
- entry = "${entry}"
140
- [dev]
141
- port = ${port}
142
- `;
143
236
  yield fsPromises.writeFile(newFilePath, genConfig, 'utf-8');
144
- logger.success(t('generate_config_success').d('Generated esa.toml'));
145
237
  }
146
238
  });
147
239
  }
@@ -9,16 +9,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { exec, execSync } from 'child_process';
11
11
  import os from 'os';
12
- import { getDirName } from './fileUtils/base.js';
13
- import logger from '../libs/logger.js';
14
12
  import path from 'path';
15
13
  import t from '../i18n/index.js';
14
+ import logger from '../libs/logger.js';
15
+ import { downloadRuntimeAndUnzipForWindows } from './download.js';
16
+ import { getDirName } from './fileUtils/base.js';
16
17
  export function preCheckDeno() {
17
18
  return __awaiter(this, void 0, void 0, function* () {
18
19
  const command = yield checkDenoInstalled();
19
20
  if (!command) {
20
- logger.error(t('install_runtime_explain').d('Under the beta phase, we are temporarily using Deno as the local development runtime. It needs to be installed first.'));
21
- installDeno();
21
+ logger.error(t('install_runtime_explain').d('Our runtime does not yet support this OS. We are temporarily using Deno as the local development runtime, which needs to be installed first.'));
22
+ yield installDeno();
22
23
  return false;
23
24
  }
24
25
  return command;
@@ -44,8 +45,7 @@ export function checkDenoInstalled() {
44
45
  .then((res) => {
45
46
  resolve(res);
46
47
  })
47
- .catch((err) => {
48
- console.log(err);
48
+ .catch(() => {
49
49
  resolve(false);
50
50
  });
51
51
  });
@@ -57,8 +57,8 @@ export function installDeno() {
57
57
  const p = path.join(__dirname, './install');
58
58
  switch (os.platform()) {
59
59
  case 'win32':
60
- installCommand = `powershell.exe -Command "Get-Content '${p}/install.ps1' | iex"`;
61
- break;
60
+ yield downloadRuntimeAndUnzipForWindows();
61
+ return true;
62
62
  case 'darwin':
63
63
  case 'linux':
64
64
  installCommand = `sh ${p}/install.sh`;
@@ -7,17 +7,17 @@ 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 { execSync } from 'child_process';
11
+ import https from 'https';
10
12
  import os from 'os';
11
- import fs from 'fs-extra';
12
13
  import path from 'path';
13
14
  import util from 'util';
14
- import https from 'https';
15
- import { execSync } from 'child_process';
16
- import logger from '../libs/logger.js';
17
- import { getDirName } from './fileUtils/base.js';
15
+ import fs from 'fs-extra';
18
16
  import t from '../i18n/index.js';
19
- import { calculateFileMD5 } from './fileMd5.js';
17
+ import logger from '../libs/logger.js';
20
18
  import { checkOS } from './checkOS.js';
19
+ import { calculateFileMD5 } from './fileMd5.js';
20
+ import { getDirName } from './fileUtils/base.js';
21
21
  export const EW2DirName = '.ew2';
22
22
  export const EW2BinName = 'edgeworker2';
23
23
  export const EW2Path = path.join(os.homedir(), EW2DirName);
@@ -79,7 +79,7 @@ export function fetchRemoteManifest() {
79
79
  }
80
80
  });
81
81
  })
82
- .on('error', (err) => reject);
82
+ .on('error', () => reject);
83
83
  });
84
84
  }
85
85
  export function checkManifest() {
@@ -8,8 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import open from 'open';
11
- import logger from '../libs/logger.js';
12
11
  import t from '../i18n/index.js';
12
+ import logger from '../libs/logger.js';
13
13
  /**
14
14
  * Open url in browser
15
15
  * @param {string} url
@@ -0,0 +1,97 @@
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 { confirm as clackConfirm, isCancel, multiselect as clackMultiselect, select as clackSelect, text as clackText, cancel as clackCancel } from '@clack/prompts';
11
+ import multiLevelSelect from '../components/mutiLevelSelect.js';
12
+ function normalizeChoices(choices) {
13
+ if (!choices)
14
+ return undefined;
15
+ return choices.map((c) => {
16
+ if (typeof c === 'string')
17
+ return { label: c, value: c };
18
+ return { label: c.name, value: String(c.value), hint: c.hint };
19
+ });
20
+ }
21
+ export function promptParameter(param) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ var _a;
24
+ const { type, question, defaultValue, validate } = param;
25
+ let value = '';
26
+ const msg = question;
27
+ if (type === 'text') {
28
+ const v = yield clackText({
29
+ message: msg,
30
+ placeholder: typeof defaultValue === 'string' ? defaultValue : undefined,
31
+ initialValue: typeof defaultValue === 'string' ? defaultValue : undefined,
32
+ validate: validate
33
+ ? (val) => {
34
+ if (val === undefined)
35
+ return 'Value is required';
36
+ const res = validate(val);
37
+ return res === true ? undefined : res;
38
+ }
39
+ : undefined
40
+ });
41
+ if (isCancel(v)) {
42
+ clackCancel('Operation cancelled.');
43
+ process.exit(130);
44
+ }
45
+ value = v;
46
+ }
47
+ else if (type === 'confirm') {
48
+ const v = yield clackConfirm({
49
+ message: msg,
50
+ initialValue: (_a = defaultValue) !== null && _a !== void 0 ? _a : false
51
+ });
52
+ if (isCancel(v)) {
53
+ clackCancel('Operation cancelled.');
54
+ process.exit(130);
55
+ }
56
+ value = v;
57
+ }
58
+ else if (type === 'select') {
59
+ const options = normalizeChoices(param.choices) || [];
60
+ const v = yield clackSelect({
61
+ message: msg,
62
+ options,
63
+ initialValue: defaultValue || undefined
64
+ });
65
+ if (isCancel(v)) {
66
+ clackCancel('Operation cancelled.');
67
+ process.exit(130);
68
+ }
69
+ value = v;
70
+ }
71
+ else if (type === 'multiselect') {
72
+ const options = normalizeChoices(param.choices) || [];
73
+ const initialValues = (defaultValue || []).map((v) => String(v));
74
+ const v = yield clackMultiselect({
75
+ message: msg,
76
+ options,
77
+ initialValues
78
+ });
79
+ if (isCancel(v)) {
80
+ clackCancel('Operation cancelled.');
81
+ process.exit(130);
82
+ }
83
+ value = v;
84
+ }
85
+ else if (type === 'multiLevelSelect') {
86
+ const items = (param.treeItems || []);
87
+ const v = yield multiLevelSelect(items, msg);
88
+ if (v === null) {
89
+ clackCancel('Operation cancelled.');
90
+ process.exit(130);
91
+ }
92
+ value = v;
93
+ }
94
+ return value;
95
+ });
96
+ }
97
+ export default promptParameter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esa-cli",
3
- "version": "0.0.2-beta.2",
3
+ "version": "0.0.2-beta.20",
4
4
  "description": "A CLI for operating Alibaba Cloud ESA EdgeRoutine (Edge Functions).",
5
5
  "main": "bin/enter.cjs",
6
6
  "type": "module",
@@ -15,12 +15,14 @@
15
15
  ],
16
16
  "scripts": {
17
17
  "build": "rm -rf ./dist && rm -rf ./build && node ./genLocale.cjs && tsc && node ./copy.cjs",
18
- "watch": "tsc --watch",
18
+ "dev": "tsc --watch",
19
19
  "eslint": "eslint src/ --ext .js,.jsx,.ts,.tsx",
20
+ "prepare": "husky install",
20
21
  "lint-staged": "lint-staged",
21
- "prepare": "npm run build",
22
- "test": "FORCE_COLOR=0 npx vitest ",
23
- "coverage": "vitest --coverage"
22
+ "test": "vitest --coverage",
23
+ "coverage": "vitest --coverage",
24
+ "lint": "eslint src/",
25
+ "lint:fix": "eslint src/ --fix"
24
26
  },
25
27
  "keywords": [
26
28
  "cli",
@@ -37,6 +39,7 @@
37
39
  "@testing-library/dom": "^10.4.0",
38
40
  "@testing-library/jest-dom": "^6.5.0",
39
41
  "@testing-library/react": "^16.0.1",
42
+ "@types/adm-zip": "^0.5.7",
40
43
  "@types/babel__generator": "^7.6.8",
41
44
  "@types/babel__traverse": "^7.20.6",
42
45
  "@types/cli-table": "^0.3.4",
@@ -49,11 +52,8 @@
49
52
  "@types/portscanner": "^2.1.4",
50
53
  "@types/react": "^18.2.47",
51
54
  "@types/yargs": "^17.0.32",
55
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
52
56
  "@typescript-eslint/parser": "^6.9.1",
53
- "eslint": "^8.52.0",
54
- "eslint-config-prettier": "^9.0.0",
55
- "eslint-plugin-react": "^7.33.2",
56
- "eslint-plugin-react-hooks": "^4.6.0",
57
57
  "husky": "^8.0.3",
58
58
  "jsdom": "^25.0.1",
59
59
  "lint-staged": "^15.0.2",
@@ -66,24 +66,26 @@
66
66
  "vitest": "^2.0.4"
67
67
  },
68
68
  "dependencies": {
69
- "@alicloud/esa20240910": "2.8.1",
69
+ "@alicloud/esa20240910": "2.25.0",
70
70
  "@alicloud/openapi-client": "^0.4.7",
71
71
  "@babel/generator": "^7.26.3",
72
72
  "@babel/parser": "^7.24.4",
73
73
  "@babel/traverse": "^7.24.1",
74
+ "@clack/prompts": "1.0.0-alpha.4",
74
75
  "@iarna/toml": "^2.2.5",
75
76
  "@types/inquirer": "^9.0.7",
76
77
  "@vitest/coverage-istanbul": "^2.0.4",
77
- "axios": "^1.7.7",
78
+ "adm-zip": "^0.5.16",
78
79
  "chalk": "^5.3.0",
79
80
  "chokidar": "^3.5.3",
80
81
  "cli-table3": "^0.6.5",
81
82
  "cross-spawn": "^7.0.3",
82
- "esa-template": "^0.0.3",
83
+ "esa-template": "0.0.9",
83
84
  "esbuild": "^0.21.1",
84
85
  "esbuild-plugin-less": "^1.3.8",
85
86
  "form-data": "^4.0.0",
86
87
  "fs-extra": "^11.2.0",
88
+ "haikunator": "^2.1.2",
87
89
  "http-proxy-agent": "^7.0.2",
88
90
  "ink": "^5.0.1",
89
91
  "ink-select-input": "^6.0.0",
@@ -100,6 +102,11 @@
100
102
  "winston-daily-rotate-file": "^5.0.0",
101
103
  "yargs": "^17.7.2"
102
104
  },
105
+ "lint-staged": {
106
+ "src/**/*.{ts,tsx,js,jsx}": [
107
+ "eslint --fix"
108
+ ]
109
+ },
103
110
  "repository": {
104
111
  "type": "git",
105
112
  "url": "git+ssh://git@github.com/aliyun/alibabacloud-esa-cli.git"