esa-cli 0.0.2-beta.9 → 1.0.0

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 +32 -149
  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 +51 -54
  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 +165 -29
  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 +7 -7
  26. package/dist/commands/domain/index.js +4 -4
  27. package/dist/commands/domain/list.js +10 -10
  28. package/dist/commands/init/helper.js +654 -20
  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 +105 -49
  39. package/dist/commands/route/delete.js +33 -27
  40. package/dist/commands/route/helper.js +123 -0
  41. package/dist/commands/route/index.js +4 -4
  42. package/dist/commands/route/list.js +56 -17
  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 +447 -71
  62. package/dist/index.js +28 -13
  63. package/dist/libs/api.js +32 -9
  64. package/dist/libs/apiService.js +294 -73
  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 +24 -13
  85. package/zh_CN.md +29 -154
@@ -7,19 +7,40 @@ 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';
18
- const projectConfigFile = 'esa.toml';
15
+ import logger from '../../libs/logger.js';
16
+ import { getDirName, getRoot } from './base.js';
19
17
  const __dirname = getDirName(import.meta.url);
20
18
  const root = getRoot();
21
- export const projectConfigPath = path.join(root, projectConfigFile);
19
+ // Function to get the actual project config file path (supports both .jsonc and .toml)
20
+ export const getProjectConfigPath = (filePath = root) => {
21
+ const configFormats = ['esa.jsonc', 'esa.toml'];
22
+ for (const format of configFormats) {
23
+ const configPath = path.join(filePath, format);
24
+ if (fs.existsSync(configPath)) {
25
+ return configPath;
26
+ }
27
+ }
28
+ // Default to .jsonc if no config file exists
29
+ return path.join(filePath, 'esa.jsonc');
30
+ };
31
+ export const projectConfigPath = getProjectConfigPath();
22
32
  export const cliConfigPath = path.join(os.homedir(), '.esa/config/default.toml');
33
+ // Function to get the actual config file path (supports both .toml and .jsonc)
34
+ export const getCliConfigPath = () => {
35
+ const configDir = path.join(os.homedir(), '.esa/config');
36
+ const jsoncPath = path.join(configDir, 'default.jsonc');
37
+ const tomlPath = path.join(configDir, 'default.toml');
38
+ // Check if JSONC file exists first, then fallback to TOML
39
+ if (fs.existsSync(jsoncPath)) {
40
+ return jsoncPath;
41
+ }
42
+ return tomlPath;
43
+ };
23
44
  export const hiddenConfigDir = path.join(os.homedir(), '.esa/config');
24
45
  export const generateHiddenConfigDir = () => {
25
46
  if (!fs.existsSync(hiddenConfigDir)) {
@@ -29,7 +50,7 @@ export const generateHiddenConfigDir = () => {
29
50
  export const generateToml = (path) => {
30
51
  if (!fs.existsSync(path)) {
31
52
  fs.writeFileSync(path, '', 'utf-8');
32
- // 添加默认的endpoint
53
+ // Add default endpoint
33
54
  const defaultConfig = {
34
55
  endpoint: 'esa.cn-hangzhou.aliyuncs.com'
35
56
  };
@@ -38,20 +59,34 @@ export const generateToml = (path) => {
38
59
  };
39
60
  export const generateDefaultConfig = () => {
40
61
  generateHiddenConfigDir();
41
- generateToml(cliConfigPath);
62
+ const configPath = getCliConfigPath();
63
+ generateToml(configPath);
42
64
  };
43
65
  export function updateProjectConfigFile(configUpdate_1) {
44
66
  return __awaiter(this, arguments, void 0, function* (configUpdate, filePath = root) {
45
- const configPath = path.join(filePath, projectConfigFile);
67
+ const configPath = getProjectConfigPath(filePath);
46
68
  try {
47
69
  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);
70
+ let config;
71
+ let updatedConfigString;
72
+ // Detect file format based on file extension
73
+ if (configPath.endsWith('.jsonc') || configPath.endsWith('.json')) {
74
+ // Handle JSONC format
75
+ const jsonContent = configFileContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
76
+ config = JSON.parse(jsonContent);
77
+ config = Object.assign(Object.assign({}, config), configUpdate);
78
+ updatedConfigString = JSON.stringify(config, null, 2) + '\n';
79
+ }
80
+ else {
81
+ // Handle TOML format (default)
82
+ config = toml.parse(configFileContent);
83
+ config = Object.assign(Object.assign({}, config), configUpdate);
84
+ updatedConfigString = toml.stringify(config);
85
+ }
51
86
  yield fsPromises.writeFile(configPath, updatedConfigString);
52
87
  }
53
88
  catch (error) {
54
- logger.error(`Error updating TOML file: ${error}`);
89
+ logger.error(`Error updating config file: ${error}`);
55
90
  logger.pathEacces(__dirname);
56
91
  }
57
92
  });
@@ -59,16 +94,30 @@ export function updateProjectConfigFile(configUpdate_1) {
59
94
  export function updateCliConfigFile(configUpdate) {
60
95
  return __awaiter(this, void 0, void 0, function* () {
61
96
  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);
97
+ const configPath = getCliConfigPath();
98
+ let configFileContent = yield fsPromises.readFile(configPath, 'utf8');
99
+ let config;
100
+ let updatedConfigString;
101
+ // Detect file format based on file extension
102
+ if (configPath.endsWith('.jsonc') || configPath.endsWith('.json')) {
103
+ // Handle JSONC format
104
+ const jsonContent = configFileContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
105
+ config = JSON.parse(jsonContent);
106
+ config = Object.assign(Object.assign({}, config), configUpdate);
107
+ updatedConfigString = JSON.stringify(config, null, 2) + '\n';
108
+ }
109
+ else {
110
+ // Handle TOML format (default)
111
+ config = toml.parse(configFileContent);
112
+ config = Object.assign(Object.assign({}, config), configUpdate);
113
+ updatedConfigString = toml.stringify(config);
114
+ }
115
+ yield fsPromises.writeFile(configPath, updatedConfigString);
67
116
  }
68
117
  catch (error) {
69
- logger.error(`Error updating TOML file: ${error}`);
118
+ logger.error(`Error updating config file: ${error}`);
70
119
  logger.pathEacces(__dirname);
71
- throw new Error('Login error');
120
+ throw new Error('Config update error');
72
121
  }
73
122
  });
74
123
  }
@@ -76,35 +125,46 @@ export function readConfigFile(configPath) {
76
125
  if (fs.existsSync(configPath)) {
77
126
  const configFileContent = fs.readFileSync(configPath, 'utf-8');
78
127
  try {
79
- const config = toml.parse(configFileContent);
80
- return config;
128
+ if (configPath.endsWith('.jsonc') || configPath.endsWith('.json')) {
129
+ // Remove comments for JSON parsing
130
+ const jsonContent = configFileContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
131
+ const config = JSON.parse(jsonContent);
132
+ return config;
133
+ }
134
+ else {
135
+ // TOML format
136
+ const config = toml.parse(configFileContent);
137
+ return config;
138
+ }
81
139
  }
82
140
  catch (error) {
83
- logger.error(`Error parsing TOML file: ${error}`);
141
+ logger.error(`Error parsing config file: ${error}`);
84
142
  return null;
85
143
  }
86
144
  }
87
145
  return null;
88
146
  }
89
147
  export function getCliConfig() {
90
- const res = readConfigFile(cliConfigPath);
148
+ const configPath = getCliConfigPath();
149
+ const res = readConfigFile(configPath);
91
150
  if (!res) {
92
151
  return null;
93
152
  }
94
153
  return res;
95
154
  }
96
155
  export function getProjectConfig(filePath = root) {
97
- const res = readConfigFile(path.join(filePath, projectConfigFile));
98
- if (!res) {
99
- return null;
156
+ // Try to find config file in order of preference: .jsonc, .toml
157
+ const configFormats = ['esa.jsonc', 'esa.toml'];
158
+ for (const format of configFormats) {
159
+ const configPath = path.join(filePath, format);
160
+ const config = readConfigFile(configPath);
161
+ if (config) {
162
+ return config;
163
+ }
100
164
  }
101
- return res;
165
+ return null;
102
166
  }
103
167
  export function readEdgeRoutineFile(projectPath = root) {
104
- const projectConfig = getProjectConfig(projectPath);
105
- if (!projectConfig) {
106
- return null;
107
- }
108
168
  const pubFilePath = `.dev/pub.js`;
109
169
  const edgeRoutinePath = path.join(projectPath, pubFilePath);
110
170
  if (fs.existsSync(edgeRoutinePath)) {
@@ -122,26 +182,57 @@ export function getConfigurations() {
122
182
  return [null, null];
123
183
  }
124
184
  }
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';
185
+ export function generateConfigFile(projectName_1, initConfigs_1, targetDir_1) {
186
+ return __awaiter(this, arguments, void 0, function* (projectName, initConfigs, targetDir, configFormat = 'jsonc', notFoundStrategy) {
187
+ var _a, _b;
188
+ const outputDir = targetDir !== null && targetDir !== void 0 ? targetDir : process.cwd();
189
+ const currentDirName = path.basename(outputDir);
190
+ const entry = (_a = initConfigs === null || initConfigs === void 0 ? void 0 : initConfigs.dev) === null || _a === void 0 ? void 0 : _a.entry;
131
191
  const port = (initConfigs === null || initConfigs === void 0 ? void 0 : initConfigs.port) || 18080;
132
192
  const name = projectName || currentDirName;
193
+ const assetsDirectory = (_b = initConfigs === null || initConfigs === void 0 ? void 0 : initConfigs.assets) === null || _b === void 0 ? void 0 : _b.directory;
194
+ let newFilePath;
195
+ let genConfig;
196
+ if (configFormat === 'jsonc') {
197
+ newFilePath = path.join(outputDir, 'esa.jsonc');
198
+ const configObj = { name };
199
+ if (entry)
200
+ configObj.entry = entry;
201
+ if (assetsDirectory) {
202
+ configObj.assets = { directory: assetsDirectory };
203
+ if (notFoundStrategy) {
204
+ configObj.assets.notFoundStrategy =
205
+ notFoundStrategy;
206
+ }
207
+ }
208
+ configObj.dev = { port };
209
+ genConfig = JSON.stringify(configObj, null, 2) + '\n';
210
+ }
211
+ else {
212
+ // Default to TOML format
213
+ newFilePath = path.join(outputDir, 'esa.toml');
214
+ const configObj = {
215
+ name,
216
+ dev: { port }
217
+ };
218
+ if (entry)
219
+ configObj.entry = entry;
220
+ if (assetsDirectory) {
221
+ configObj.assets = { directory: assetsDirectory };
222
+ if (notFoundStrategy) {
223
+ configObj.assets.notFoundStrategy =
224
+ notFoundStrategy;
225
+ }
226
+ }
227
+ genConfig = toml.stringify(configObj);
228
+ }
133
229
  if (fs.existsSync(newFilePath)) {
134
- logger.error(t('generate_config_error').d('esa.toml already exists'));
230
+ logger.error(`${path.basename(newFilePath)}` +
231
+ t('generate_config_error').d('already exists'));
135
232
  return;
136
233
  }
137
234
  else {
138
- const genConfig = `name = "${name}"
139
- entry = "${entry}"
140
- [dev]
141
- port = ${port}
142
- `;
143
235
  yield fsPromises.writeFile(newFilePath, genConfig, 'utf-8');
144
- logger.success(t('generate_config_success').d('Generated esa.toml'));
145
236
  }
146
237
  });
147
238
  }
@@ -10,10 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { exec, execSync } from 'child_process';
11
11
  import os from 'os';
12
12
  import path from 'path';
13
+ import t from '../i18n/index.js';
13
14
  import logger from '../libs/logger.js';
14
- import { getDirName } from './fileUtils/base.js';
15
15
  import { downloadRuntimeAndUnzipForWindows } from './download.js';
16
- import t from '../i18n/index.js';
16
+ import { getDirName } from './fileUtils/base.js';
17
17
  export function preCheckDeno() {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
19
  const command = yield checkDenoInstalled();
@@ -45,7 +45,7 @@ export function checkDenoInstalled() {
45
45
  .then((res) => {
46
46
  resolve(res);
47
47
  })
48
- .catch((err) => {
48
+ .catch(() => {
49
49
  resolve(false);
50
50
  });
51
51
  });
@@ -66,7 +66,7 @@ export function installDeno() {
66
66
  default:
67
67
  installCommand = `sh ${p}/install.sh`;
68
68
  }
69
- logger.warn(t('install_runtime_tip').d(`🔔 Runtime must be installed to use esa dev. Installing...`));
69
+ logger.warn(t('install_runtime_tip').d(`🔔 Runtime must be installed to use esa-cli dev. Installing...`));
70
70
  try {
71
71
  execSync(installCommand, { stdio: 'inherit' });
72
72
  logger.success(t('install_runtime_success').d(`Runtime installed.`));
@@ -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);
@@ -43,7 +43,7 @@ export function preCheckEw2() {
43
43
  try {
44
44
  yield fsAccess(EW2BinPath, fs.constants.X_OK);
45
45
  if (!manifestRes.isLatest) {
46
- logger.warn(t('install_runtime_update_tip').d(`🔔 Runtime must be update to use esa dev. Installing...`));
46
+ logger.warn(t('install_runtime_update_tip').d(`🔔 Runtime must be update to use esa-cli dev. Installing...`));
47
47
  return yield installVersion(manifestRes.remoteManifest);
48
48
  }
49
49
  return true;
@@ -55,7 +55,7 @@ export function preCheckEw2() {
55
55
  return false;
56
56
  }
57
57
  if (err.code === 'ENOENT' || err.code === 'EPERM') {
58
- logger.warn(t('install_runtime_tip').d(`🔔 Runtime must be installed to use esa dev. Installing...`));
58
+ logger.warn(t('install_runtime_tip').d(`🔔 Runtime must be installed to use esa-cli dev. Installing...`));
59
59
  return yield installVersion(manifestRes.remoteManifest);
60
60
  }
61
61
  logger.error(err.message);
@@ -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,11 +1,12 @@
1
1
  {
2
2
  "name": "esa-cli",
3
- "version": "0.0.2-beta.9",
4
- "description": "A CLI for operating Alibaba Cloud ESA EdgeRoutine (Edge Functions).",
3
+ "version": "1.0.0",
4
+ "description": "A CLI for operating Alibaba Cloud ESA Functions and Pages.",
5
5
  "main": "bin/enter.cjs",
6
6
  "type": "module",
7
7
  "bin": {
8
- "esa": "bin/enter.cjs"
8
+ "esa": "bin/enter.cjs",
9
+ "esa-cli": "bin/enter.cjs"
9
10
  },
10
11
  "files": [
11
12
  "bin",
@@ -15,12 +16,14 @@
15
16
  ],
16
17
  "scripts": {
17
18
  "build": "rm -rf ./dist && rm -rf ./build && node ./genLocale.cjs && tsc && node ./copy.cjs",
18
- "watch": "tsc --watch",
19
+ "dev": "tsc --watch",
19
20
  "eslint": "eslint src/ --ext .js,.jsx,.ts,.tsx",
21
+ "prepare": "husky install",
20
22
  "lint-staged": "lint-staged",
21
- "prepare": "npm run build",
22
- "test": "FORCE_COLOR=0 npx vitest ",
23
- "coverage": "vitest --coverage"
23
+ "test": "vitest --coverage",
24
+ "coverage": "vitest --coverage",
25
+ "lint": "eslint src/",
26
+ "lint:fix": "eslint src/ --fix"
24
27
  },
25
28
  "keywords": [
26
29
  "cli",
@@ -50,11 +53,12 @@
50
53
  "@types/portscanner": "^2.1.4",
51
54
  "@types/react": "^18.2.47",
52
55
  "@types/yargs": "^17.0.32",
56
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
53
57
  "@typescript-eslint/parser": "^6.9.1",
54
- "eslint": "^8.52.0",
55
- "eslint-config-prettier": "^9.0.0",
56
- "eslint-plugin-react": "^7.33.2",
57
- "eslint-plugin-react-hooks": "^4.6.0",
58
+ "eslint": "^8.57.0",
59
+ "eslint-plugin-import": "^2.32.0",
60
+ "eslint-plugin-react": "latest",
61
+ "eslint-plugin-react-hooks": "^5.2.0",
58
62
  "husky": "^8.0.3",
59
63
  "jsdom": "^25.0.1",
60
64
  "lint-staged": "^15.0.2",
@@ -67,11 +71,12 @@
67
71
  "vitest": "^2.0.4"
68
72
  },
69
73
  "dependencies": {
70
- "@alicloud/esa20240910": "2.8.1",
74
+ "@alicloud/esa20240910": "2.25.0",
71
75
  "@alicloud/openapi-client": "^0.4.7",
72
76
  "@babel/generator": "^7.26.3",
73
77
  "@babel/parser": "^7.24.4",
74
78
  "@babel/traverse": "^7.24.1",
79
+ "@clack/prompts": "1.0.0-alpha.4",
75
80
  "@iarna/toml": "^2.2.5",
76
81
  "@types/inquirer": "^9.0.7",
77
82
  "@vitest/coverage-istanbul": "^2.0.4",
@@ -80,11 +85,12 @@
80
85
  "chokidar": "^3.5.3",
81
86
  "cli-table3": "^0.6.5",
82
87
  "cross-spawn": "^7.0.3",
83
- "esa-template": "0.0.4-beta.1",
88
+ "esa-template": "^0.0.9",
84
89
  "esbuild": "^0.21.1",
85
90
  "esbuild-plugin-less": "^1.3.8",
86
91
  "form-data": "^4.0.0",
87
92
  "fs-extra": "^11.2.0",
93
+ "haikunator": "^2.1.2",
88
94
  "http-proxy-agent": "^7.0.2",
89
95
  "ink": "^5.0.1",
90
96
  "ink-select-input": "^6.0.0",
@@ -101,6 +107,11 @@
101
107
  "winston-daily-rotate-file": "^5.0.0",
102
108
  "yargs": "^17.7.2"
103
109
  },
110
+ "lint-staged": {
111
+ "src/**/*.{ts,tsx,js,jsx}": [
112
+ "eslint --fix"
113
+ ]
114
+ },
104
115
  "repository": {
105
116
  "type": "git",
106
117
  "url": "git+ssh://git@github.com/aliyun/alibabacloud-esa-cli.git"