esa-cli 1.0.4-beta.1 → 1.0.4-beta.2

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.
@@ -13,7 +13,6 @@ import chalk from 'chalk';
13
13
  import t from '../../i18n/index.js';
14
14
  import logger from '../../libs/logger.js';
15
15
  import promptParameter from '../../utils/prompt.js';
16
- import { checkAndCleanupVersions } from '../utils.js';
17
16
  import { validateAndInitializeProject, generateCodeVersion } from '../common/utils.js';
18
17
  const commit = {
19
18
  command: 'commit [entry]',
@@ -45,10 +44,6 @@ const commit = {
45
44
  describe: 'Bundle with esbuild (use --no-bundle to skip)',
46
45
  type: 'boolean',
47
46
  default: true
48
- })
49
- .option('version-limit', {
50
- describe: t('commit_option_version_limit').d('Maximum number of versions to keep. Oldest unreleased versions will be deleted if exceeded.'),
51
- type: 'number'
52
47
  });
53
48
  },
54
49
  handler: (argv) => __awaiter(void 0, void 0, void 0, function* () {
@@ -64,12 +59,7 @@ export function handleCommit(argv) {
64
59
  const projectInfo = yield validateAndInitializeProject(argv === null || argv === void 0 ? void 0 : argv.name);
65
60
  if (!projectInfo)
66
61
  return;
67
- const { projectName, projectConfig } = projectInfo;
68
- // Cleanup old versions if limit is specified
69
- const limit = argv['version-limit'] || (projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.versionLimit);
70
- if (limit) {
71
- yield checkAndCleanupVersions(projectName, limit, true);
72
- }
62
+ const { projectName } = projectInfo;
73
63
  let description;
74
64
  if (argv.description) {
75
65
  description = argv.description;
@@ -15,7 +15,7 @@ import { ensureRoutineExists } from '../../utils/checkIsRoutineCreated.js';
15
15
  import compress from '../../utils/compress.js';
16
16
  import { getProjectConfig } from '../../utils/fileUtils/index.js';
17
17
  import sleep from '../../utils/sleep.js';
18
- import { checkAndCleanupVersions, checkIsLoginSuccess } from '../utils.js';
18
+ import { checkIsLoginSuccess } from '../utils.js';
19
19
  function normalizeNotFoundStrategy(value) {
20
20
  if (!value)
21
21
  return undefined;
@@ -260,26 +260,21 @@ export function deployToEnvironments(name, codeVersion, env) {
260
260
  * 结合了压缩、提交和部署的完整流程
261
261
  */
262
262
  export function commitAndDeployVersion(projectName_1, scriptEntry_1, assets_1) {
263
- return __awaiter(this, arguments, void 0, function* (projectName, scriptEntry, assets, description = '', projectPath, env = 'production', minify = false, version, noBundle = false, versionLimit) {
263
+ return __awaiter(this, arguments, void 0, function* (projectName, scriptEntry, assets, description = '', projectPath, env = 'production', minify = false, version, noBundle = false) {
264
264
  var _a, _b, _c;
265
265
  const projectInfo = yield validateAndInitializeProject(projectName, projectPath);
266
266
  if (!projectInfo) {
267
267
  return false;
268
268
  }
269
- const { projectConfig, projectName: resolvedProjectName } = projectInfo;
270
- // Cleanup old versions if limit is specified
271
- const limit = versionLimit || (projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.versionLimit);
272
- if (limit) {
273
- yield checkAndCleanupVersions(resolvedProjectName, limit, !version);
274
- }
269
+ const { projectConfig } = projectInfo;
275
270
  // 2) Use existing version or generate a new one
276
271
  if (version) {
277
272
  logger.startSubStep(`Using existing version ${version}`);
278
- const deployed = yield deployToEnvironments(resolvedProjectName, version, env);
273
+ const deployed = yield deployToEnvironments(projectInfo.projectName, version, env);
279
274
  logger.endSubStep(deployed ? 'Deploy finished' : 'Deploy failed');
280
275
  return deployed;
281
276
  }
282
- const res = yield generateCodeVersion(resolvedProjectName, description, scriptEntry || (projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.entry), assets || ((_a = projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.assets) === null || _a === void 0 ? void 0 : _a.directory), minify || (projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.minify), projectPath, noBundle);
277
+ const res = yield generateCodeVersion(projectInfo.projectName, description, scriptEntry || (projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.entry), assets || ((_a = projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.assets) === null || _a === void 0 ? void 0 : _a.directory), minify || (projectConfig === null || projectConfig === void 0 ? void 0 : projectConfig.minify), projectPath, noBundle);
283
278
  const isCommitSuccess = res === null || res === void 0 ? void 0 : res.isSuccess;
284
279
  if (!isCommitSuccess) {
285
280
  logger.endSubStep('Generate version failed');
@@ -61,10 +61,6 @@ const deploy = {
61
61
  .option('versions', {
62
62
  describe: 'Deploy two versions with percentages, format: v1:80,v2:20 or repeat --versions v1:80 --versions v2:20',
63
63
  type: 'array'
64
- })
65
- .option('version-limit', {
66
- describe: t('deploy_option_version_limit').d('Maximum number of versions to keep. Oldest unreleased versions will be deleted if exceeded.'),
67
- type: 'number'
68
64
  });
69
65
  },
70
66
  describe: `🚀 ${t('deploy_describe').d('Deploy your project')}`,
@@ -86,7 +82,7 @@ export function handleDeploy(argv) {
86
82
  outro(ok ? 'Deploy finished' : 'Deploy failed');
87
83
  exit(ok ? 0 : 1);
88
84
  }
89
- const success = yield commitAndDeployVersion(argv.name || undefined, entry, assets, argv.description || '', getRoot(), argv.environment || 'all', argv.minify, argv.version, (argv.bundle === false), argv['version-limit']);
85
+ const success = yield commitAndDeployVersion(argv.name || undefined, entry, assets, argv.description || '', getRoot(), argv.environment || 'all', argv.minify, argv.version, (argv.bundle === false));
90
86
  outro(success ? 'Deploy finished' : 'Deploy failed');
91
87
  if (success) {
92
88
  const projectConfig = getProjectConfig(getRoot());
@@ -21,8 +21,13 @@ const renameMock = {
21
21
  });
22
22
  traverse(ast, {
23
23
  Identifier(path) {
24
+ var _a;
24
25
  const name = path.node.name;
25
- if (replacements.hasOwnProperty(name)) {
26
+ if (!replacements.hasOwnProperty(name)) {
27
+ return;
28
+ }
29
+ if (((_a = path.parentPath) === null || _a === void 0 ? void 0 : _a.type) === 'MemberExpression' &&
30
+ path.key === 'object') {
26
31
  path.node.name = replacements[name];
27
32
  }
28
33
  }
@@ -17,7 +17,7 @@ import Haikunator from 'haikunator';
17
17
  import t from '../../i18n/index.js';
18
18
  import logger from '../../libs/logger.js';
19
19
  import Template from '../../libs/templates/index.js';
20
- import { execCommand, execWithLoginShell } from '../../utils/command.js';
20
+ import { execCommand } from '../../utils/command.js';
21
21
  import { getDirName } from '../../utils/fileUtils/base.js';
22
22
  import { generateConfigFile, getCliConfig, getProjectConfig, getTemplatesConfig, templateHubPath, updateProjectConfigFile } from '../../utils/fileUtils/index.js';
23
23
  import promptParameter from '../../utils/prompt.js';
@@ -382,7 +382,7 @@ export const createProject = (initParams) => __awaiter(void 0, void 0, void 0, f
382
382
  const templateFlag = ((_a = frameworkConfig.language) === null || _a === void 0 ? void 0 : _a[initParams.language || 'typescript']) || '';
383
383
  const extraParams = frameworkConfig.params || '';
384
384
  const full = `${command} ${initParams.name} ${templateFlag} ${extraParams}`.trim();
385
- const res = yield execWithLoginShell(full, {
385
+ const res = yield execCommand(['sh', '-lc', full], {
386
386
  interactive: true,
387
387
  startText: `Starting to execute framework command ${chalk.gray(full)}`,
388
388
  doneText: `Framework command executed ${chalk.gray(full)}`
@@ -93,13 +93,6 @@ export function checkIsLoginSuccess() {
93
93
  },
94
94
  endpoint: result.endpoint
95
95
  });
96
- api.updateConfig({
97
- auth: {
98
- accessKeyId,
99
- accessKeySecret
100
- },
101
- endpoint: result.endpoint
102
- });
103
96
  return true;
104
97
  }
105
98
  }
@@ -153,61 +146,3 @@ export const getRoutineCodeVersions = (projectName) => __awaiter(void 0, void 0,
153
146
  const productionVersions = ((_m = (_l = (_k = (_j = (_h = routineDetail === null || routineDetail === void 0 ? void 0 : routineDetail.data) === null || _h === void 0 ? void 0 : _h.Envs) === null || _j === void 0 ? void 0 : _j.find((item) => item.Env === 'production')) === null || _k === void 0 ? void 0 : _k.CodeDeploy) === null || _l === void 0 ? void 0 : _l.CodeVersions) === null || _m === void 0 ? void 0 : _m.map((item) => item.CodeVersion)) || [];
154
147
  return { allVersions, stagingVersions, productionVersions };
155
148
  });
156
- /**
157
- * Check the total number of versions and delete the oldest unreleased ones if they exceed the limit.
158
- * @param projectName Name of the project
159
- * @param limit The maximum number of versions to keep
160
- * @param isCreatingNewVersion Whether a new version will be created after cleanup
161
- */
162
- export function checkAndCleanupVersions(projectName_1, limit_1) {
163
- return __awaiter(this, arguments, void 0, function* (projectName, limit, isCreatingNewVersion = true) {
164
- if (limit <= 0)
165
- return;
166
- const { allVersions, stagingVersions, productionVersions } = yield getRoutineCodeVersions(projectName);
167
- const currentCount = allVersions.length;
168
- const targetCount = isCreatingNewVersion ? limit - 1 : limit;
169
- if (currentCount <= targetCount) {
170
- return;
171
- }
172
- const deployedVersions = new Set([...stagingVersions, ...productionVersions]);
173
- // Filter versions that are not currently deployed
174
- const undeployedVersions = allVersions.filter((v) => v.codeVersion && !deployedVersions.has(v.codeVersion));
175
- // Sort by createTime (oldest first)
176
- undeployedVersions.sort((a, b) => {
177
- const timeA = a.createTime ? new Date(a.createTime).getTime() : 0;
178
- const timeB = b.createTime ? new Date(b.createTime).getTime() : 0;
179
- return timeA - timeB;
180
- });
181
- const numToDelete = currentCount - targetCount;
182
- const toDelete = undeployedVersions.slice(0, numToDelete);
183
- if (toDelete.length > 0) {
184
- logger.info(t('cleanup_versions_start', {
185
- count: toDelete.length.toString(),
186
- limit: limit.toString()
187
- }).d(`Cleaning up ${toDelete.length} oldest unreleased versions (limit: ${limit})...`));
188
- const server = yield ApiService.getInstance();
189
- for (const version of toDelete) {
190
- if (!version.codeVersion)
191
- continue;
192
- try {
193
- const res = yield server.deleteRoutineCodeVersion({
194
- Name: projectName,
195
- CodeVersion: version.codeVersion
196
- });
197
- if ((res === null || res === void 0 ? void 0 : res.Status) === 'OK') {
198
- logger.success(t('deployments_delete_success').d('Delete success') +
199
- `: ${version.codeVersion}`);
200
- }
201
- else {
202
- logger.warn(t('deployments_delete_failed').d('Delete failed') +
203
- `: ${version.codeVersion}`);
204
- }
205
- }
206
- catch (error) {
207
- logger.warn(t('deployments_delete_failed').d('Delete failed') +
208
- `: ${version.codeVersion}`);
209
- }
210
- }
211
- }
212
- });
213
- }
@@ -143,9 +143,6 @@ Description for Functions & Pages/version (skip interactive input)
143
143
  **--name, -n** _optional_
144
144
  Functions & Pages name
145
145
 
146
- **--version-limit** _optional_
147
- Maximum number of versions to keep. Oldest unreleased versions (not in staging or production) will be deleted if exceeded.
148
-
149
146
  ---
150
147
 
151
148
  ## deploy
@@ -177,9 +174,6 @@ Description of the version
177
174
  **--minify, -m** _optional_
178
175
  Whether to minify the code
179
176
 
180
- **--version-limit** _optional_
181
- Maximum number of versions to keep. Oldest unreleased versions (not in staging or production) will be deleted if exceeded.
182
-
183
177
  ---
184
178
 
185
179
  ## deployments
@@ -351,11 +345,15 @@ AccessKey ID (AK)
351
345
  **--access-key-secret, --sk** _optional_
352
346
  AccessKey Secret (SK)
353
347
 
348
+ **--endpoint, -e** _optional_
349
+ API endpoint URL Example: esa.cn-hangzhou.aliyuncs.com
350
+
354
351
  **Environment Variables**
355
352
  Read from environment variables:
356
353
 
357
354
  - **ESA_ACCESS_KEY_ID**
358
355
  - **ESA_ACCESS_KEY_SECRET**
356
+ - **ESA_ENDPOINT**
359
357
 
360
358
  ---
361
359
 
@@ -2,31 +2,13 @@
2
2
 
3
3
  **ESA CLI 提供多种命令来管理您的阿里云 ESA Functions & Pages。**
4
4
 
5
- **init** - 从各种 Web 框架和模板创建新项目。
6
-
7
- **dev** - 启动本地开发服务器。
8
-
9
- **commit** - 提交代码并保存为新版本。
10
-
11
- **deploy** - 将您的 Functions & Pages 部署到阿里云。
12
-
13
- **deployments** - 管理您的部署和版本。
14
-
15
- **project** - 管理您的 Functions & Pages 项目。
16
-
17
- **site** - 列出您已激活的站点。
18
-
19
- **domain** - 管理您的 Functions & Pages 的域名绑定。
20
-
21
- **route** - 管理您的 Functions & Pages 的路由绑定。
22
-
23
- **login** - 使用您的阿里云账户授权 ESA CLI。
24
-
25
- **logout** - 移除 ESA CLI 访问您账户的授权。
26
-
27
- **config** - 修改您的本地或全局配置。
28
-
29
- **lang** - 设置 CLI 的语言。
5
+ **init** - 从各种 Web 框架和模板创建新项目。**
6
+ \*\***dev** - 启动本地开发服务器。** \***\*commit** - 提交代码并保存为新版本。**
7
+ \*\***deploy** - 将您的 Functions & Pages 部署到阿里云。** \***\*deployments** - 管理您的部署和版本。**
8
+ \*\***project** - 管理您的 Functions & Pages 项目。** \***\*site** - 列出您已激活的站点。**
9
+ \*\***domain** - 管理您的 Functions & Pages 的域名绑定。** \***\*route** - 管理您的 Functions & Pages 的路由绑定。**
10
+ \*\***login** - 使用您的阿里云账户授权 ESA CLI。** \***\*logout** - 移除 ESA CLI 访问您账户的授权。**
11
+ \*\***config** - 修改您的本地或全局配置。** \***\*lang** - 设置 CLI 的语言。
30
12
 
31
13
  ### 如何运行 ESA CLI 命令
32
14
 
@@ -56,12 +38,12 @@ npx esa-cli <COMMAND> <SUBCOMMAND> [PARAMETERS] [OPTIONS]
56
38
 
57
39
  ```
58
40
  {
59
- ...
60
- "scripts": {
61
- "deploy": "esa-cli deploy",
62
- "dev": "esa-cli dev"
41
+  ...
42
+  "scripts": {
43
+    "deploy": "esa-cli deploy",
44
+    "dev": "esa-cli dev"
63
45
  }
64
- ...
46
+  ...
65
47
  }
66
48
  ```
67
49
 
@@ -81,25 +63,25 @@ npm run deploy
81
63
  esa-cli init [<NAME>] [OPTIONS]
82
64
  ```
83
65
 
84
- **NAME** _可选(默认:工作目录名称)_
66
+ **NAME\***可选(默认:工作目录名称)\*
85
67
  **Functions & Pages 项目的名称。这既是目录名称,也是生成的 ESA CLI 配置中的 name 属性。**
86
68
 
87
- **--framework, -f** _可选_
69
+ **--framework, -f\***可选\*
88
70
  **选择前端框架(react/vue/nextjs...)**
89
71
 
90
- **--language, -l** _可选_
72
+ **--language, -l\***可选\*
91
73
  **选择编程语言(typescript/javascript)。可选:typescript | javascript**
92
74
 
93
- **--template, -t** _可选_
75
+ **--template, -t\***可选\*
94
76
  **指定模板名称**
95
77
 
96
- **--yes, -y** _可选_
78
+ **--yes, -y\***可选\*
97
79
  **对所有交互询问选择"是"(默认 false),模版采用helloworld**
98
80
 
99
- **--git** _可选_
81
+ **--git\***可选\*
100
82
  **在项目中初始化 git**
101
83
 
102
- **--deploy** _可选_
84
+ **--deploy\***可选\*
103
85
  **初始化完成后自动部署**
104
86
 
105
87
  ---
@@ -112,22 +94,22 @@ esa-cli init [<NAME>] [OPTIONS]
112
94
  esa-cli dev [<ENTRY>] [OPTIONS]
113
95
  ```
114
96
 
115
- **ENTRY** _可选_
97
+ **ENTRY\***可选\*
116
98
  **函数和Pages入口文件**
117
99
 
118
- **--port, -p** _可选_
100
+ **--port, -p\***可选\*
119
101
  **监听端口**
120
102
 
121
- **--minify, -m** _可选_
103
+ **--minify, -m\***可选\*
122
104
  **开发模式下压缩代码(默认 false)**
123
105
 
124
- **--refresh-command** _可选_
106
+ **--refresh-command\***可选\*
125
107
  **保存自动刷新前执行的命令**
126
108
 
127
- **--local-upstream** _可选_
109
+ **--local-upstream\***可选\*
128
110
  **在本地开发中作为源站的主机**
129
111
 
130
- **--debug** _可选_
112
+ **--debug\***可选\*
131
113
  **输出调试日志(默认 false)**
132
114
 
133
115
  ---
@@ -140,24 +122,21 @@ esa-cli dev [<ENTRY>] [OPTIONS]
140
122
  esa-cli commit [<ENTRY>] [OPTIONS]
141
123
  ```
142
124
 
143
- **ENTRY** _可选_
125
+ **ENTRY\***可选\*
144
126
  **函数和Pages入口文件**
145
127
 
146
- **--minify, -m** _可选_
128
+ **--minify, -m\***可选\*
147
129
  **提交前压缩代码(默认 false)**
148
130
 
149
- **--assets, -a** _可选_
131
+ **--assets, -a\***可选\*
150
132
  **静态资源目录**
151
133
 
152
- **--description, -d** _可选_
134
+ **--description, -d\***可选\*
153
135
  **版本/例程描述(跳过交互输入)**
154
136
 
155
- **--name, -n** _可选_
137
+ **--name, -n\***可选\*
156
138
  **函数和Pages名称**
157
139
 
158
- **--version-limit** _可选_
159
- **保持的最大版本数量。如果超过此限制,将删除最旧的未发布版本(不处于仿真环境或线上环境的版本)。**
160
-
161
140
  ---
162
141
 
163
142
  ## deploy
@@ -168,30 +147,27 @@ esa-cli commit [<ENTRY>] [OPTIONS]
168
147
  esa-cli deploy [<ENTRY>] [OPTIONS]
169
148
  ```
170
149
 
171
- **ENTRY** _可选_
172
- **函数和Pages入口文件,默认以 `esa.jsonc`中entry配置为准**
150
+ **ENTRY\***可选\*
151
+ **函数和Pages入口文件,默认以 **`esa.jsonc`中entry配置为准
173
152
 
174
- **--version, -v** _可选_
153
+ **--version, -v\***可选\*
175
154
  **指定要部署的版本(跳过交互选择)**
176
155
 
177
- **--environment, -e** _可选_
156
+ **--environment, -e\***可选\*
178
157
  **部署环境。可选:staging | production**
179
158
 
180
- **--name, -n** _可选_
159
+ **--name, -n\***可选\*
181
160
  **函数和Pages名称**
182
161
 
183
- **--assets, -a** _可选_
162
+ **--assets, -a\***可选\*
184
163
  **静态资源目录(例如:./dist)**
185
164
 
186
- **--description, -d** _可选_
165
+ **--description, -d\***可选\*
187
166
  **版本描述**
188
167
 
189
- **--minify, -m** _可选_
168
+ **--minify, -m\***可选\*
190
169
  **是否压缩代码**
191
170
 
192
- **--version-limit** _可选_
193
- **保持的最大版本数量。如果超过此限制,将删除最旧的未发布版本(不处于仿真环境或线上环境的版本)。**
194
-
195
171
  ---
196
172
 
197
173
  ## deployments
@@ -214,7 +190,7 @@ esa-cli deployments list
214
190
  esa-cli deployments delete [<DEPLOYMENT_ID>...] [OPTIONS]
215
191
  ```
216
192
 
217
- **DEPLOYMENT_ID** _必需_
193
+ **DEPLOYMENT_ID\***必需\*
218
194
  **要删除的部署版本ID(可一次传多个)**
219
195
 
220
196
  ---
@@ -239,7 +215,7 @@ esa-cli project list
239
215
  esa-cli project delete <PROJECT_NAME> [OPTIONS]
240
216
  ```
241
217
 
242
- **PROJECT_NAME** _必需_
218
+ **PROJECT_NAME\***必需\*
243
219
  **要删除的函数或Pages名称**
244
220
 
245
221
  ---
@@ -272,7 +248,7 @@ esa-cli domain add <DOMAIN> [OPTIONS]
272
248
 
273
249
  **只有在该账号下激活的站点才能绑定**
274
250
 
275
- **DOMAIN** _必需_
251
+ **DOMAIN\***必需\*
276
252
  **要绑定的域名(在该账号站点下已激活)**
277
253
 
278
254
  ### domain list
@@ -291,7 +267,7 @@ esa-cli domain list
291
267
  esa-cli domain delete <DOMAIN> [OPTIONS]
292
268
  ```
293
269
 
294
- **DOMAIN** _必需_
270
+ **DOMAIN\***必需\*
295
271
  **要删除绑定的域名**
296
272
 
297
273
  ---
@@ -308,24 +284,23 @@ esa-cli domain delete <DOMAIN> [OPTIONS]
308
284
  esa-cli route add [<ROUTE>] [<SITE>] [OPTIONS]
309
285
  ```
310
286
 
311
- **ROUTE** _可选_
287
+ **ROUTE\***可选\*
312
288
  **路由值,例如:example.com/_ 或 _.example.com/\***
313
289
 
314
- **SITE** _可选_
290
+ **SITE\***可选\*
315
291
  **站点名称,例如:example.com**
316
292
 
317
293
  **只有在该账号下激活的站点才能绑定**
318
294
 
319
- **--route, -r** _可选_
320
- **路由值,例如:example.com/\***
295
+ **--route, -r\***可选*路由值,例如:example.com/*
321
296
 
322
- - **主机名支持以 `*` 开头表示后缀匹配(如:`*.example.com`)**
323
- - **路径支持以 `*` 结尾表示前缀匹配(如:`/api/*`)**
297
+ - **主机名支持以 **`*` 开头表示后缀匹配(如:`*.example.com`)
298
+ - **路径支持以 **`*` 结尾表示前缀匹配(如:`/api/*`)
324
299
 
325
- **--site, -s** _可选_
300
+ **--site, -s\***可选\*
326
301
  **站点名称(需为账户下已激活站点)**
327
302
 
328
- **--alias, -a** _可选_
303
+ **--alias, -a\***可选\*
329
304
  **路由名称(别名)例如:apple、orange等**
330
305
 
331
306
  ### route list
@@ -344,7 +319,7 @@ esa-cli route list
344
319
  esa-cli route delete <ROUTE_NAME> [OPTIONS]
345
320
  ```
346
321
 
347
- **ROUTE_NAME** _必需_
322
+ **ROUTE_NAME\***必需\*
348
323
  **要删除的路由名称**
349
324
 
350
325
  ---
@@ -357,16 +332,20 @@ esa-cli route delete <ROUTE_NAME> [OPTIONS]
357
332
  esa-cli login [OPTIONS]
358
333
  ```
359
334
 
360
- **--access-key-id, --ak** _可选_
335
+ **--access-key-id, --ak\***可选\*
361
336
  **AccessKey ID (AK)**
362
337
 
363
- **--access-key-secret, --sk** _可选_
338
+ **--access-key-secret, --sk\***可选\*
364
339
  **AccessKey Secret (SK)**
365
340
 
366
- **环境变量** _从环境变量中读取:_
341
+ **--endpoint, -e\***可选\*
342
+ **API 端点 URL 例子: esa.cn-hangzhou.aliyuncs.com**
343
+
344
+ **环境变量**从环境变量中读取:
367
345
 
368
346
  - **ESA_ACCESS_KEY_ID**
369
347
  - **ESA_ACCESS_KEY_SECRET**
348
+ - **ESA_ENDPOINT**
370
349
 
371
350
  ---
372
351
 
@@ -388,10 +367,10 @@ esa-cli logout
388
367
  esa-cli config [OPTIONS]
389
368
  ```
390
369
 
391
- **--local, -l** _可选_
370
+ **--local, -l\***可选\*
392
371
  **编辑本地配置文件(默认 false)**
393
372
 
394
- **--global, -g** _可选_
373
+ **--global, -g\***可选\*
395
374
  **编辑全局配置文件(默认 false)**
396
375
 
397
376
  ---
@@ -1322,17 +1322,5 @@
1322
1322
  "login_get_credentials_from_environment_variables": {
1323
1323
  "en": "Get credentials from environment variables",
1324
1324
  "zh_CN": ""
1325
- },
1326
- "commit_option_version_limit": {
1327
- "en": "Maximum number of versions to keep. Oldest unreleased versions will be deleted if exceeded.",
1328
- "zh_CN": "保留的最大版本数量。如果超过此限制,最旧的未发布版本将被删除。"
1329
- },
1330
- "deploy_option_version_limit": {
1331
- "en": "Maximum number of versions to keep. Oldest unreleased versions will be deleted if exceeded.",
1332
- "zh_CN": "保留的最大版本数量。如果超过此限制,最旧的未发布版本将被删除。"
1333
- },
1334
- "cleanup_versions_start": {
1335
- "en": "Cleaning up ${toDelete.length} oldest unreleased versions (limit: ${limit})...",
1336
- "zh_CN": "正在清理 ${count} 个最旧的未发布版本(限制数量:${limit})..."
1337
1325
  }
1338
1326
  }
package/dist/index.js CHANGED
@@ -24,7 +24,6 @@ import routeCommand from './commands/route/index.js';
24
24
  import routine from './commands/routine/index.js';
25
25
  import site from './commands/site/index.js';
26
26
  import t from './i18n/index.js';
27
- import logger from './libs/logger.js';
28
27
  import { handleCheckVersion, checkCLIVersion } from './utils/checkVersion.js';
29
28
  import { getCliConfig } from './utils/fileUtils/index.js';
30
29
  const main = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -41,9 +40,6 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
41
40
  .wrap(null)
42
41
  .help()
43
42
  .middleware((argv) => __awaiter(void 0, void 0, void 0, function* () {
44
- if (argv.debug) {
45
- logger.setLogLevel('debug');
46
- }
47
43
  try {
48
44
  // Pass current command (first positional) so version check can decide prompting behavior
49
45
  yield checkCLIVersion((argv._ && argv._[0] ? String(argv._[0]) : ''));
@@ -61,11 +57,6 @@ const main = () => __awaiter(void 0, void 0, void 0, function* () {
61
57
  .options('help', {
62
58
  describe: t('main_help_describe').d('Show help'),
63
59
  alias: 'h'
64
- })
65
- .options('debug', {
66
- describe: t('dev_option_debugger').d('Output debug logs'),
67
- type: 'boolean',
68
- default: false
69
60
  });
70
61
  esa.command('*', false, () => { }, (args) => {
71
62
  if (args._.length > 0) {
package/dist/libs/api.js CHANGED
@@ -11,7 +11,6 @@ import ESA, * as $ESA from '@alicloud/esa20240910';
11
11
  import * as $OpenApi from '@alicloud/openapi-client';
12
12
  import * as $Util from '@alicloud/tea-util';
13
13
  import { getApiConfig } from '../utils/fileUtils/index.js';
14
- import { CLI_USER_AGENT } from './constants.js';
15
14
  import logger from './logger.js';
16
15
  class Client {
17
16
  constructor() {
@@ -78,8 +77,7 @@ class Client {
78
77
  const apiConfig = new $OpenApi.Config({
79
78
  accessKeyId: (_a = config.auth) === null || _a === void 0 ? void 0 : _a.accessKeyId,
80
79
  accessKeySecret: (_b = config.auth) === null || _b === void 0 ? void 0 : _b.accessKeySecret,
81
- endpoint: config.endpoint,
82
- userAgent: CLI_USER_AGENT
80
+ endpoint: config.endpoint
83
81
  });
84
82
  return new ESA.default(apiConfig);
85
83
  }
@@ -12,7 +12,6 @@ import FormData from 'form-data';
12
12
  import fetch from 'node-fetch';
13
13
  import t from '../i18n/index.js';
14
14
  import { getApiConfig } from '../utils/fileUtils/index.js';
15
- import { CLI_USER_AGENT } from './constants.js';
16
15
  import { Environment } from './interface.js';
17
16
  export class ApiService {
18
17
  constructor(cliConfig) {
@@ -20,8 +19,7 @@ export class ApiService {
20
19
  let apiConfig = new $OpenApi.Config({
21
20
  accessKeyId: (_a = cliConfig.auth) === null || _a === void 0 ? void 0 : _a.accessKeyId,
22
21
  accessKeySecret: (_b = cliConfig.auth) === null || _b === void 0 ? void 0 : _b.accessKeySecret,
23
- endpoint: cliConfig.endpoint,
24
- userAgent: CLI_USER_AGENT
22
+ endpoint: cliConfig.endpoint
25
23
  });
26
24
  this.client = new $OpenApi.default.default(apiConfig);
27
25
  }
@@ -39,8 +37,7 @@ export class ApiService {
39
37
  let apiConfig = new $OpenApi.Config({
40
38
  accessKeyId: (_a = newConfig.auth) === null || _a === void 0 ? void 0 : _a.accessKeyId,
41
39
  accessKeySecret: (_b = newConfig.auth) === null || _b === void 0 ? void 0 : _b.accessKeySecret,
42
- endpoint: newConfig.endpoint,
43
- userAgent: CLI_USER_AGENT
40
+ endpoint: newConfig.endpoint
44
41
  });
45
42
  this.client = new $OpenApi.default.default(apiConfig);
46
43
  }
@@ -8,15 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { spawn } from 'child_process';
11
- import { platform } from 'os';
12
11
  import { cancel, spinner } from '@clack/prompts';
13
12
  import chalk from 'chalk';
14
- export const isWindows = platform() === 'win32';
15
13
  /**
16
14
  * Execute a shell command with rich options (spinner, capture, env, cwd).
17
15
  */
18
16
  export const execCommand = (command_1, ...args_1) => __awaiter(void 0, [command_1, ...args_1], void 0, function* (command, options = {}) {
19
- const { startText, doneText, silent = false, captureOutput = false, useSpinner = true, realtimeOutput = false, interactive = false, env, cwd, transformOutput, fallbackOutput, errorMessage, shell = false } = options;
17
+ const { startText, doneText, silent = false, captureOutput = false, useSpinner = true, realtimeOutput = false, interactive = false, env, cwd, transformOutput, fallbackOutput, errorMessage } = options;
20
18
  // Determine stdio mode based on options
21
19
  // If realtimeOutput is true, we need to pipe to capture and display output in real-time
22
20
  // If spinner is used without realtimeOutput, pipe to avoid TTY contention
@@ -57,7 +55,7 @@ export const execCommand = (command_1, ...args_1) => __awaiter(void 0, [command_
57
55
  stdio,
58
56
  cwd,
59
57
  env: Object.assign(Object.assign({}, process.env), env),
60
- shell
58
+ shell: false
61
59
  });
62
60
  if (stdio === 'pipe') {
63
61
  (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (chunk) => {
@@ -148,21 +146,4 @@ export const execCommand = (command_1, ...args_1) => __awaiter(void 0, [command_
148
146
  return { success: false, stdout, stderr };
149
147
  }
150
148
  });
151
- /**
152
- * Execute a command with login shell on Unix (to load ~/.profile, ~/.zshrc etc.)
153
- * On Windows, directly execute the command since login shell is not typically needed.
154
- *
155
- * @param commandStr - The full command string to execute
156
- * @param options - ExecCommandOptions
157
- */
158
- export const execWithLoginShell = (commandStr_1, ...args_1) => __awaiter(void 0, [commandStr_1, ...args_1], void 0, function* (commandStr, options = {}) {
159
- if (isWindows) {
160
- // Windows: use cmd /c to execute the command
161
- return execCommand(['cmd', '/c', commandStr], options);
162
- }
163
- else {
164
- // Unix: use login shell to ensure PATH is properly set (nvm, fnm, etc.)
165
- return execCommand(['sh', '-lc', commandStr], options);
166
- }
167
- });
168
149
  export default execCommand;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esa-cli",
3
- "version": "1.0.4-beta.1",
3
+ "version": "1.0.4-beta.2",
4
4
  "description": "A CLI for operating Alibaba Cloud ESA Functions and Pages.",
5
5
  "main": "bin/enter.cjs",
6
6
  "type": "module",
@@ -1,13 +0,0 @@
1
- import { createRequire } from 'module';
2
- const require = createRequire(import.meta.url);
3
- const packageJson = require('../../package.json');
4
- /**
5
- * CLI User-Agent string for API requests
6
- * Format: esa-cli/{version}
7
- * This helps identify requests originating from the CLI
8
- */
9
- export const CLI_USER_AGENT = `esa-cli/${packageJson.version}`;
10
- /**
11
- * CLI version from package.json
12
- */
13
- export const CLI_VERSION = packageJson.version;