esa-cli 0.0.5 → 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.
- package/README.md +32 -149
- package/dist/commands/commit/index.js +49 -104
- package/dist/commands/commit/prodBuild.js +2 -3
- package/dist/commands/common/constant.js +4 -4
- package/dist/commands/common/utils.js +419 -0
- package/dist/commands/config.js +2 -2
- package/dist/commands/deploy/helper.js +43 -49
- package/dist/commands/deploy/index.js +51 -174
- package/dist/commands/deployments/delete.js +32 -22
- package/dist/commands/deployments/index.js +4 -4
- package/dist/commands/deployments/list.js +21 -34
- package/dist/commands/dev/build.js +3 -3
- package/dist/commands/dev/doProcess.js +5 -5
- package/dist/commands/dev/ew2/cacheService.js +33 -0
- package/dist/commands/dev/ew2/devEntry.js +2 -1
- package/dist/commands/dev/ew2/devPack.js +31 -20
- package/dist/commands/dev/ew2/kvService.js +50 -0
- package/dist/commands/dev/ew2/mock/cache.js +99 -15
- package/dist/commands/dev/ew2/mock/kv.js +142 -21
- package/dist/commands/dev/ew2/server.js +163 -28
- package/dist/commands/dev/index.js +17 -18
- package/dist/commands/dev/mockWorker/devPack.js +19 -10
- package/dist/commands/dev/mockWorker/server.js +7 -6
- package/dist/commands/domain/add.js +4 -4
- package/dist/commands/domain/delete.js +3 -3
- package/dist/commands/domain/index.js +4 -4
- package/dist/commands/domain/list.js +7 -7
- package/dist/commands/init/helper.js +654 -21
- package/dist/commands/init/index.js +88 -152
- package/dist/commands/init/snippets/nextjs/next.config.mjs +6 -0
- package/dist/commands/init/snippets/nextjs/next.config.ts +7 -0
- package/dist/commands/init/snippets/react-router/react-router.config.ts +7 -0
- package/dist/commands/init/template.jsonc +84 -0
- package/dist/commands/init/types.js +1 -0
- package/dist/commands/lang.js +2 -2
- package/dist/commands/login/index.js +74 -34
- package/dist/commands/logout.js +6 -6
- package/dist/commands/route/add.js +101 -43
- package/dist/commands/route/delete.js +6 -6
- package/dist/commands/route/helper.js +9 -10
- package/dist/commands/route/index.js +4 -4
- package/dist/commands/route/list.js +4 -4
- package/dist/commands/routine/delete.js +9 -8
- package/dist/commands/routine/index.js +6 -5
- package/dist/commands/routine/list.js +45 -39
- package/dist/commands/site/index.js +3 -3
- package/dist/commands/site/list.js +6 -7
- package/dist/commands/utils.js +61 -25
- package/dist/components/descriptionInput.js +1 -1
- package/dist/components/filterSelector.js +1 -1
- package/dist/components/mutiLevelSelect.js +19 -20
- package/dist/components/mutiSelectTable.js +1 -1
- package/dist/components/routeBuilder.js +68 -0
- package/dist/components/selectInput.js +2 -3
- package/dist/components/selectItem.js +1 -1
- package/dist/docs/Commands_en.md +164 -117
- package/dist/docs/Commands_zh_CN.md +155 -107
- package/dist/docs/Config_en.md +70 -0
- package/dist/docs/Config_zh_CN.md +68 -0
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/locales.json +414 -82
- package/dist/index.js +28 -13
- package/dist/libs/api.js +3 -6
- package/dist/libs/apiService.js +192 -69
- package/dist/libs/git/index.js +86 -9
- package/dist/libs/interface.js +0 -1
- package/dist/libs/logger.js +162 -10
- package/dist/libs/service.js +2 -2
- package/dist/libs/templates/index.js +1 -1
- package/dist/utils/checkAssetsExist.js +80 -0
- package/dist/utils/checkDevPort.js +5 -19
- package/dist/utils/checkEntryFileExist.js +10 -0
- package/dist/utils/checkIsRoutineCreated.js +27 -21
- package/dist/utils/checkVersion.js +119 -1
- package/dist/utils/command.js +149 -0
- package/dist/utils/compress.js +142 -0
- package/dist/utils/download.js +8 -8
- package/dist/utils/fileMd5.js +1 -1
- package/dist/utils/fileUtils/index.js +136 -45
- package/dist/utils/installDeno.js +4 -4
- package/dist/utils/installEw2.js +9 -9
- package/dist/utils/openInBrowser.js +1 -1
- package/dist/utils/prompt.js +97 -0
- package/package.json +23 -12
- package/zh_CN.md +29 -154
package/dist/utils/installEw2.js
CHANGED
|
@@ -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
|
|
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
|
|
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', (
|
|
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
|
|
4
|
-
"description": "A CLI for operating Alibaba Cloud ESA
|
|
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
|
-
"
|
|
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
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
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.
|
|
55
|
-
"eslint-
|
|
56
|
-
"eslint-plugin-react": "
|
|
57
|
-
"eslint-plugin-react-hooks": "^
|
|
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",
|
|
@@ -72,6 +76,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.
|
|
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"
|
package/zh_CN.md
CHANGED
|
@@ -1,176 +1,51 @@
|
|
|
1
|
-
# ESA CLI
|
|
1
|
+
# 安装/更新 ESA CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ESA CLI 是用于构建阿里云 ESA Functions 与 Pages 的命令行工具。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://discord.gg/xygV6MYx">
|
|
7
|
+
<img alt="Discord 中文" src="https://img.shields.io/badge/Discord-中文-5865F2?logo=discord&logoColor=white" />
|
|
8
|
+
</a>
|
|
9
|
+
<a href="https://discord.gg/YeFg4yUA" style="margin-left:8px;">
|
|
10
|
+
<img alt="Discord English" src="https://img.shields.io/badge/Discord-English-5865F2?logo=discord&logoColor=white" />
|
|
11
|
+
</a>
|
|
12
|
+
</p>
|
|
6
13
|
|
|
7
|
-
|
|
14
|
+
## 安装 ESA CLI
|
|
8
15
|
|
|
9
|
-
|
|
10
|
-
- [边缘函数概述](https://help.aliyun.com/document_detail/2710021.html)
|
|
16
|
+
### 前置条件
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
我们正在积极改进,并欢迎任何反馈。感谢您的理解与支持!
|
|
18
|
+
- Node.js:18.x 或更高(支持 18.x、20.x、22.x)
|
|
19
|
+
- 操作系统:macOS (Apple Silicon)、Linux
|
|
20
|
+
- 推荐使用 Volta 或 nvm 等 Node 版本管理工具,避免权限问题并便于切换版本
|
|
16
21
|
|
|
17
22
|
## 安装
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
$ npm install esa-cli -g # 全局安装
|
|
23
|
-
$ esa -v # 查看版本
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## 使用指南
|
|
27
|
-
|
|
28
|
-
### 1. 初始化Routine项目
|
|
24
|
+
为确保团队协作的一致性,建议在项目中将 `esa-cli` 安装为开发依赖,以便团队成员使用相同版本。
|
|
29
25
|
|
|
30
|
-
```bash
|
|
31
|
-
& esa init
|
|
32
26
|
```
|
|
33
|
-
|
|
34
|
-
初始化命令有完整的流程引导,根据提示输入项目名称、选择模板即可。
|
|
35
|
-
|
|
36
|
-
### 2. 开始本地调试
|
|
37
|
-
|
|
38
|
-
本地调试功能是 CLI 的核心,提供了比阿里云 ESA 控制台更便捷的调试体验。
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
& cd <Project Name>
|
|
42
|
-
& esa dev [options]
|
|
27
|
+
npm i -D esa-cli@latest
|
|
43
28
|
```
|
|
44
29
|
|
|
45
|
-
|
|
30
|
+
当尚未安装 `esa-cli` 时,`npx` 会从注册表拉取并运行最新版本。
|
|
46
31
|
|
|
47
|
-
|
|
32
|
+
## 查看 ESA CLI 版本
|
|
48
33
|
|
|
49
|
-
```javascript
|
|
50
|
-
const html = `<!DOCTYPE html>
|
|
51
|
-
<body>
|
|
52
|
-
<h1>Hello World!</h1>
|
|
53
|
-
</body>`;
|
|
54
|
-
|
|
55
|
-
async function handleRequest(request) {
|
|
56
|
-
return new Response(html, {
|
|
57
|
-
headers: {
|
|
58
|
-
'content-type': 'text/html;charset=UTF-8'
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export default {
|
|
64
|
-
async fetch(event) {
|
|
65
|
-
return event.respondWith(handleRequest(event));
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
34
|
```
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
#### 本地调试
|
|
73
|
-
|
|
74
|
-
执行 `esa dev` 后,会自动打包入口文件,并启动本地调试服务,界面样式如下:
|
|
75
|
-
|
|
76
|
-

|
|
77
|
-
|
|
78
|
-
- 在界面上按 `b` 即可在浏览器中打开调试页面。
|
|
79
|
-
- 在界面上按 `c` 可以清空面板。
|
|
80
|
-
- 在界面上按 `x` 可以退出调试。
|
|
81
|
-
- 可以用 `esa dev --port <port>` 临时指定端口,也可以使用 `esa config -l` 按照项目配置端口。
|
|
82
|
-
|
|
83
|
-
### 3. 登录阿里云账号
|
|
84
|
-
|
|
85
|
-
需要先登录阿里云账号,才能进行远程管理操作。
|
|
86
|
-
|
|
87
|
-
首先请访问[阿里云RAM控制台](https://ram.console.aliyun.com/manage/ak)获取您的AccessKey ID和AccessKey Secret,再执行`esa login`根据提示输入。
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
& esa login # 登录
|
|
91
|
-
& esa logout # 登出
|
|
35
|
+
npx esa-cli --version
|
|
36
|
+
# 或
|
|
37
|
+
npx esa-cli -v
|
|
92
38
|
```
|
|
93
39
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
当本地调试完成后,需要生成一个代码版本用于部署。
|
|
40
|
+
## 更新 ESA CLI
|
|
97
41
|
|
|
98
|
-
```bash
|
|
99
|
-
& esa commit # 生成版本
|
|
100
42
|
```
|
|
101
|
-
|
|
102
|
-
### 5. 部署到环境 & 管理版本与部署
|
|
103
|
-
|
|
104
|
-
当代码版本生成后,需要部署到边缘节点。
|
|
105
|
-
|
|
106
|
-
通过`esa deployments [script]`命令可以管理版本与部署情况。
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
& esa deploy # 根据提示选择版本、目标环境即可部署
|
|
110
|
-
& esa deployments list # 查看部署情况
|
|
111
|
-
& esa deployments delete <versionId> # 删除版本
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
_注意:已经被部署的版本无法删除。_
|
|
115
|
-
|
|
116
|
-
### 6. 管理触发器
|
|
117
|
-
|
|
118
|
-
当被部署到节点后,您可以配置触发器,通过触发器可以访问您的边缘函数。触发器有两种:
|
|
119
|
-
|
|
120
|
-
- 域名:为您的函数绑定域名,该域名必须是您ESA站点的子域名,您可以通过域名直接访问到该函数,此时边缘函数将作为该域名的源站。
|
|
121
|
-
- 路由:为您的ESA站点绑定函数路由,访问该路由可触发边缘函数执行,此时边缘函数可以和站点的源站进行通信。
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
# 域名
|
|
125
|
-
& esa domain list
|
|
126
|
-
& esa domain add <domainName> # 需要是您的已备案域名
|
|
127
|
-
& esa domain delete <domainName>
|
|
128
|
-
|
|
129
|
-
# 路由
|
|
130
|
-
& esa route list
|
|
131
|
-
& esa route add [route] [site]
|
|
132
|
-
& esa route delete <route>
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### 7. 管理函数
|
|
136
|
-
|
|
137
|
-
可以通过CLI查看、删除Routine函数。
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
& esa routine list # 查看函数
|
|
141
|
-
& esa routine delete <routineName> # 删除函数
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## 命令
|
|
145
|
-
|
|
146
|
-
查看[命令](./docs/Commands.md)
|
|
147
|
-
|
|
148
|
-
## 配置文件
|
|
149
|
-
|
|
150
|
-
### 全局配置
|
|
151
|
-
|
|
152
|
-
```toml
|
|
153
|
-
endpoint = "" # ESA API Endpoint
|
|
154
|
-
lang = "zh_CN" # 语言
|
|
155
|
-
|
|
156
|
-
[auth]
|
|
157
|
-
accessKeyId = "" # AccessKey ID
|
|
158
|
-
accessKeySecret = "" # AccessKey Secret
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### 项目配置
|
|
162
|
-
|
|
163
|
-
```toml
|
|
164
|
-
name = "Hello World" # 项目名称
|
|
165
|
-
description = "Hello World" # 项目描述
|
|
166
|
-
entry = "src/index.js" # 入口文件
|
|
167
|
-
codeVersions = [ ] # 代码版本
|
|
168
|
-
|
|
169
|
-
[dev]
|
|
170
|
-
port = 18080 # 调试端口
|
|
171
|
-
localUpstream = '' # 本地调试上游源站,会替换掉回源时当前的origin
|
|
43
|
+
npm i -D esa-cli@latest
|
|
172
44
|
```
|
|
173
45
|
|
|
174
|
-
##
|
|
46
|
+
## 相关文档
|
|
175
47
|
|
|
176
|
-
[
|
|
48
|
+
- [esa-cli 命令](./docs/Commands_zh_CN.md)
|
|
49
|
+
- [ESA 配置文件说明](./docs/Config_zh_CN.md)
|
|
50
|
+
- [阿里云 ESA 文档](https://help.aliyun.com/document_detail/2710021.html)
|
|
51
|
+
- [Functions 和 Pages API 参考](https://help.aliyun.com/document_detail/2710024.html)
|