@serverless-devs/s 2.0.96 → 2.0.97-beta.6
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/Makefile +26 -0
- package/lib/clean/index.js +34 -31
- package/lib/cli/cli-manager.js +10 -10
- package/lib/cli/index.js +52 -52
- package/lib/component/index.js +51 -144
- package/lib/config/add/index.js +36 -33
- package/lib/config/delete/index.js +47 -47
- package/lib/config/get/index.js +40 -37
- package/lib/config/index.js +35 -32
- package/lib/core/command/command-manager.js +5 -5
- package/lib/core/component/hook.js +4 -4
- package/lib/core/component/index.js +9 -9
- package/lib/error/human-error.js +5 -5
- package/lib/error/human-warning.js +4 -4
- package/lib/error/index.js +19 -14
- package/lib/index.js +109 -120
- package/lib/init/index.js +97 -97
- package/lib/init/init-manager.js +11 -11
- package/lib/onboarding/index.js +5 -5
- package/lib/set/analysis/index.js +37 -34
- package/lib/set/index.js +35 -32
- package/lib/set/locale/index.js +49 -49
- package/lib/set/registry/index.js +49 -49
- package/lib/set/workspace/index.js +38 -35
- package/lib/specification/parse.js +10 -10
- package/lib/update-notifier/index.js +17 -17
- package/lib/utils/command-util.js +74 -57
- package/lib/utils/common.js +40 -13
- package/lib/utils/index.js +3 -3
- package/package.json +5 -4
- package/.eslintrc.json +0 -112
- package/.prettierrc.json +0 -11
- package/CODE_OF_CONDUCT.md +0 -5
- package/CONTRIBUTING.md +0 -189
- package/CONTRIBUTORS.md +0 -148
- package/docs/readme.md +0 -100
- package/docs/zh/awesome.md +0 -20
- package/docs/zh/cicd.md +0 -231
- package/docs/zh/cli_design.md +0 -100
- package/docs/zh/command/clean.md +0 -63
- package/docs/zh/command/cli.md +0 -92
- package/docs/zh/command/component.md +0 -75
- package/docs/zh/command/config.md +0 -274
- package/docs/zh/command/custom.md +0 -73
- package/docs/zh/command/init.md +0 -149
- package/docs/zh/command/readme.md +0 -76
- package/docs/zh/command/set.md +0 -195
- package/docs/zh/default_provider_config/alibabacloud.md +0 -82
- package/docs/zh/default_provider_config/aws.md +0 -12
- package/docs/zh/default_provider_config/azure.md +0 -9
- package/docs/zh/default_provider_config/baiducloud.md +0 -8
- package/docs/zh/default_provider_config/gcp.md +0 -21
- package/docs/zh/default_provider_config/huaweicloud.md +0 -52
- package/docs/zh/default_provider_config/readme.md +0 -9
- package/docs/zh/default_provider_config/tencentcloud.md +0 -41
- package/docs/zh/install.md +0 -52
- package/docs/zh/package_dev.md +0 -142
- package/docs/zh/quick_start.md +0 -297
- package/docs/zh/readme.md +0 -92
- package/docs/zh/tool.md +0 -101
- package/docs/zh/yaml.md +0 -207
- package/docs/zh/yaml_and_cli.md +0 -67
- package/jest.setup.ts +0 -37
- package/lib/clean/index.d.ts +0 -1
- package/lib/cli/cli-manager.d.ts +0 -13
- package/lib/cli/index.d.ts +0 -2
- package/lib/component/index.d.ts +0 -1
- package/lib/config/add/index.d.ts +0 -1
- package/lib/config/common/common.d.ts +0 -46
- package/lib/config/delete/index.d.ts +0 -2
- package/lib/config/get/index.d.ts +0 -1
- package/lib/config/index.d.ts +0 -2
- package/lib/constants/index.d.ts +0 -0
- package/lib/constants/static-variable.d.ts +0 -4
- package/lib/core/command/command-manager.d.ts +0 -12
- package/lib/core/component/hook.d.ts +0 -17
- package/lib/core/component/index.d.ts +0 -53
- package/lib/core/index.d.ts +0 -2
- package/lib/core/plugin/index.d.ts +0 -13
- package/lib/entiry/cli.d.ts +0 -27
- package/lib/entiry/index.d.ts +0 -2
- package/lib/error/command-error.d.ts +0 -5
- package/lib/error/config-delete-error.d.ts +0 -5
- package/lib/error/config-error.d.ts +0 -5
- package/lib/error/config-get-error.d.ts +0 -5
- package/lib/error/human-error.d.ts +0 -13
- package/lib/error/human-warning.d.ts +0 -8
- package/lib/error/index.d.ts +0 -17
- package/lib/error/init-error.d.ts +0 -5
- package/lib/error/serverless-error.d.ts +0 -4
- package/lib/execDaemon.d.ts +0 -6
- package/lib/index.d.ts +0 -2
- package/lib/init/index.d.ts +0 -2
- package/lib/init/init-config.d.ts +0 -43
- package/lib/init/init-manager.d.ts +0 -17
- package/lib/onboarding/index.d.ts +0 -2
- package/lib/set/analysis/index.d.ts +0 -1
- package/lib/set/index.d.ts +0 -1
- package/lib/set/locale/index.d.ts +0 -1
- package/lib/set/registry/index.d.ts +0 -10
- package/lib/set/workspace/index.d.ts +0 -1
- package/lib/specification/analysis.d.ts +0 -12
- package/lib/specification/index.d.ts +0 -4
- package/lib/specification/parse.d.ts +0 -24
- package/lib/specification/version.d.ts +0 -35
- package/lib/update-notifier/index.d.ts +0 -10
- package/lib/utils/command-util.d.ts +0 -18
- package/lib/utils/common.d.ts +0 -28
- package/lib/utils/core.d.ts +0 -3
- package/lib/utils/handler-set-config.d.ts +0 -19
- package/lib/utils/i18n/en.d.ts +0 -44
- package/lib/utils/i18n/index.d.ts +0 -2
- package/lib/utils/i18n/zh.d.ts +0 -44
- package/lib/utils/index.d.ts +0 -9
- package/lib/utils/logger.d.ts +0 -11
- package/lib/utils/storage.d.ts +0 -8
- package/lib/utils/url-parser.d.ts +0 -15
- package/spec/readme.md +0 -59
- package/spec/zh/0.0.1/readme.md +0 -47
- package/spec/zh/0.0.1/serverless_package_model/1.purpose_and_goals.md +0 -3
- package/spec/zh/0.0.1/serverless_package_model/2.overview_and_terminology.md +0 -14
- package/spec/zh/0.0.1/serverless_package_model/3.package_model.md +0 -434
- package/spec/zh/0.0.1/serverless_package_model/4.application_scopes.md +0 -3
- package/spec/zh/0.0.1/serverless_package_model/5.design_principles.md +0 -3
- package/spec/zh/0.0.1/serverless_package_model/readme.md +0 -12
- package/spec/zh/0.0.1/serverless_registry_model/1.purpose_and_goals.md +0 -18
- package/spec/zh/0.0.1/serverless_registry_model/2.overview_and_terminology.md +0 -18
- package/spec/zh/0.0.1/serverless_registry_model/3.registry_model.md +0 -61
- package/spec/zh/0.0.1/serverless_registry_model/4.application_scopes.md +0 -6
- package/spec/zh/0.0.1/serverless_registry_model/5.design_principles.md +0 -3
- package/spec/zh/0.0.1/serverless_registry_model/readme.md +0 -12
- package/spec/zh/0.0.1/serverless_user_model/1.purpose_and_goals.md +0 -3
- package/spec/zh/0.0.1/serverless_user_model/2.overview_and_terminology.md +0 -16
- package/spec/zh/0.0.1/serverless_user_model/3.user_model.md +0 -218
- package/spec/zh/0.0.1/serverless_user_model/4.application_scopes.md +0 -4
- package/spec/zh/0.0.1/serverless_user_model/5.design_principles.md +0 -3
- package/spec/zh/0.0.1/serverless_user_model/readme.md +0 -12
- package/test/ci.sh +0 -33
- package/test/cli/cli-manager.test.ts +0 -64
- package/test/config/get.test.ts +0 -12
- package/test/helloworld.test.ts +0 -7
- package/test/start-fc-http-nodejs12/code/index.js +0 -47
- package/test/start-fc-http-nodejs12/s.yaml +0 -38
- package/test/utils/index.test.ts +0 -8
- package/test/utils/storage.test.ts +0 -19
- package/tsconfig.json +0 -37
package/docs/zh/yaml.md
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
# 描述文件(Yaml)规范
|
|
2
|
-
|
|
3
|
-
> 当前文档遵循 [Serverless User Model](../../spec/zh/0.0.1/serverless_user_model/readme.md) 和相关规范。
|
|
4
|
-
|
|
5
|
-
- [描述文件简介](#描述文件简介)
|
|
6
|
-
- [描述文件格式/规范](#描述文件格式规范)
|
|
7
|
-
- [元数据](#元数据)
|
|
8
|
-
- [变量赋值](#变量赋值)
|
|
9
|
-
- [服务顺序](#服务顺序)
|
|
10
|
-
- [行为描述](#行为描述)
|
|
11
|
-
|
|
12
|
-
## 描述文件简介
|
|
13
|
-
|
|
14
|
-
在非`cli`模式下,进行应用的操作、组件的使用,需要按照 Serverless Devs 的规范,提供相对应的资源/行为描述文件,且该文件还需要符合以下条件:
|
|
15
|
-
|
|
16
|
-
- 拓展名可以是`.yaml`或`.yml`
|
|
17
|
-
- 格式必须符合[Yaml规范](https://yaml.org/spec/1.2.2/)
|
|
18
|
-
|
|
19
|
-
> 👉 对于需要通过描述文件进行环境隔离的项目,建议将文件命名为 `s-${ENV}.yaml` 或 `s-${ENV}.yml` 格式。 例如:`s-prod.yaml`。
|
|
20
|
-
|
|
21
|
-
在默认情况下,Serverless Devs 开发者工具会默认该描述文件的名称为`s.yaml`或`s.yml`,且`s.yaml`的优先级大于`s.yml`, 即在一个 Serverless 应用下,同时出现`s.yaml`与`s.yml`时,系统会优先识别和使用`s.yaml`。
|
|
22
|
-
|
|
23
|
-
当然,开发者也可以通过`-t, --template [templatePath]`进行指定,例如,在某应用在生产环境下的描述文件名为`s-prod.yml`,则可以在执行相关命令时,增加参数`-t s-prod.yml`或者`--template s-prod.yml`。
|
|
24
|
-
|
|
25
|
-
## 描述文件格式/规范
|
|
26
|
-
|
|
27
|
-
关于 Serverless Devs 所支持的资源/行为描述文件基本格式为:
|
|
28
|
-
|
|
29
|
-
```yaml
|
|
30
|
-
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范
|
|
31
|
-
name: applicationName # 应用名称
|
|
32
|
-
access: xxx-account1 # 秘钥别名
|
|
33
|
-
|
|
34
|
-
vars: # [全局变量,提供给各个服务使用]
|
|
35
|
-
Key: Value
|
|
36
|
-
|
|
37
|
-
Service: # 可以包括多个服务
|
|
38
|
-
ServiceName: # 服务名称
|
|
39
|
-
access: xxx-account1 # 秘钥别名,如果和项目的access相同,可省略
|
|
40
|
-
component: componentName # 组件名称
|
|
41
|
-
props: serviceProp # 组件的属性值
|
|
42
|
-
actions: serviceActions # 自定义执行逻辑
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
例如,一个相对完整的 Yaml 案例可以是:
|
|
46
|
-
|
|
47
|
-
```yaml
|
|
48
|
-
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范
|
|
49
|
-
name: FullStack # 项目名称
|
|
50
|
-
access: xxx-account1 # 秘钥别名
|
|
51
|
-
|
|
52
|
-
vars: # [全局变量,提供给各个服务使用]
|
|
53
|
-
logo: https://image.aliyun.com/xxxx.png
|
|
54
|
-
|
|
55
|
-
services:
|
|
56
|
-
nextjs-portal: # 服务名称
|
|
57
|
-
access: xxx-account1 # 秘钥别名,如果和项目的access相同,可省略
|
|
58
|
-
component: vue-component # 组件名称
|
|
59
|
-
props: # 组件的属性值
|
|
60
|
-
src: ./frontend_src
|
|
61
|
-
url: url
|
|
62
|
-
actions: # 自定义执行逻辑
|
|
63
|
-
pre-deploy: # 在deploy之前运行
|
|
64
|
-
- run: s exec -- publish # 要运行的命令行
|
|
65
|
-
path: ./backend_src # 命令行运行的路径
|
|
66
|
-
- run: s build # 要运行的命令行
|
|
67
|
-
path: ./backend_src # 命令行运行的路径
|
|
68
|
-
post-deploy: # 在deploy之后运行
|
|
69
|
-
- run: s clean
|
|
70
|
-
path: ./frontend_src
|
|
71
|
-
|
|
72
|
-
assets:
|
|
73
|
-
component: static
|
|
74
|
-
props:
|
|
75
|
-
cache-control: "public, max-age=604800, immutable"
|
|
76
|
-
www: "./public"
|
|
77
|
-
|
|
78
|
-
express-blog:
|
|
79
|
-
component: express
|
|
80
|
-
props:
|
|
81
|
-
app: ./express-blog
|
|
82
|
-
url: ${vars.domain}
|
|
83
|
-
actions:
|
|
84
|
-
pre-deploy:
|
|
85
|
-
- run: npm run build
|
|
86
|
-
path: ./express-blog
|
|
87
|
-
|
|
88
|
-
gateway:
|
|
89
|
-
component: serverless-gateway # 路由组件:HTTP URL和服务之间的映射规则
|
|
90
|
-
props:
|
|
91
|
-
routes:
|
|
92
|
-
- route: /~assets
|
|
93
|
-
value: ${assets.output.url}
|
|
94
|
-
- route: /
|
|
95
|
-
value: ${nextjs-portal.output.url}
|
|
96
|
-
index: index.html
|
|
97
|
-
- route: /~portal
|
|
98
|
-
value: ${nextjs-portal.output.url}
|
|
99
|
-
inex: index.html
|
|
100
|
-
- route: /~blog
|
|
101
|
-
value: ${express-blog.output.url}
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### 元数据
|
|
105
|
-
|
|
106
|
-
在该格式中:
|
|
107
|
-
|
|
108
|
-
| 参数名 | 代表含义 |
|
|
109
|
-
| ---- | ---- |
|
|
110
|
-
| edition | 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范 |
|
|
111
|
-
| name | 应用名称 |
|
|
112
|
-
| access | 秘钥别名,可以使用通过[config命令](./command/config.md#config-add-命令)配置的密钥信息,以及[配置到环境变量的密钥信息](./command/config.md#通过环境变量配置密钥信息) |
|
|
113
|
-
| vars | 全局变量,提供给各个服务使用,是一个Key-Value的形式 |
|
|
114
|
-
| Service | 应用所包含的服务,是一个Key-Value的形式 |
|
|
115
|
-
|
|
116
|
-
关于Service参数:
|
|
117
|
-
|
|
118
|
-
| 参数名 | 代表含义 |
|
|
119
|
-
| ---- | ---- |
|
|
120
|
-
| access | 秘钥别名,如果和项目的access相同,可省略 |
|
|
121
|
-
| component | 组件名称 |
|
|
122
|
-
| actions | 自定义执行逻辑 |
|
|
123
|
-
| props | 组件的属性值 |
|
|
124
|
-
|
|
125
|
-
### 变量赋值
|
|
126
|
-
|
|
127
|
-
Serverless Application模型对应的Yaml文件支持多种变量格式:
|
|
128
|
-
|
|
129
|
-
- 获取当前机器中的环境变量:${env(环境变量)},例如${env(secretId)}
|
|
130
|
-
- 获取外部文档的变量:${file(路径)},例如${file(./path)}
|
|
131
|
-
- 获取全局变量:${vars.*}
|
|
132
|
-
- 获取其他项目的变量:${projectName.props.*}
|
|
133
|
-
- 获取Yaml中其他项目的结果变量:${projectName.output.*}
|
|
134
|
-
|
|
135
|
-
### 服务顺序
|
|
136
|
-
|
|
137
|
-
如果一个Serverless Application模型对应的Yaml文件中有过多的服务,系统会默认分析部署顺序,该部署顺序分为两个步骤:
|
|
138
|
-
|
|
139
|
-
1. 分析项目中的依赖关系
|
|
140
|
-
2. 有依赖关系的按照依赖关系从前到后部署,无依赖关系的按Yaml配置的从上到下部署
|
|
141
|
-
|
|
142
|
-
### 行为描述
|
|
143
|
-
|
|
144
|
-
在Serverless Application模型对应的Yaml文件中,可以针对服务,提供对应的行为操作,其基本格式是:
|
|
145
|
-
|
|
146
|
-
```yaml
|
|
147
|
-
actions: # 自定义执行逻辑
|
|
148
|
-
pre-命令: # 在命令之前运行
|
|
149
|
-
- run: command # 要运行的操作
|
|
150
|
-
path: ./path # 运行操作的路径
|
|
151
|
-
post-命令: # 在命令之后运行
|
|
152
|
-
- run: command # 要运行的操作
|
|
153
|
-
path: ./path # 运行操作的路径
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
例如:
|
|
157
|
-
|
|
158
|
-
```yaml
|
|
159
|
-
actions: # 自定义执行逻辑
|
|
160
|
-
pre-deploy: # 在deploy之前运行
|
|
161
|
-
- run: s exec -- publish # 要运行的命令行
|
|
162
|
-
path: ./backend_src # 命令行运行的路径
|
|
163
|
-
- run: s build # 要运行的命令行
|
|
164
|
-
path: ./backend_src # 命令行运行的路径
|
|
165
|
-
post-deploy: # 在deploy之后运行
|
|
166
|
-
- run: s clean
|
|
167
|
-
path: ./frontend_src
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
当Serverless Devs开发者工具执行到该服务时,会在进行相关的命令之行之前,优先按照顺序执行`pre-命令`的操作,所有内容完成执行之后,再执行`post-命令`的操作。
|
|
171
|
-
|
|
172
|
-
以下面的Yaml为例:
|
|
173
|
-
|
|
174
|
-
```yaml
|
|
175
|
-
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范
|
|
176
|
-
name: FullStack # 项目名称
|
|
177
|
-
|
|
178
|
-
services:
|
|
179
|
-
nextjs-portal: # 服务名称
|
|
180
|
-
access: xxx-account1 # 秘钥别名,如果和项目的access相同,可省略
|
|
181
|
-
component: vue-component # 组件名称
|
|
182
|
-
props: # 组件的属性值
|
|
183
|
-
src: ./frontend_src
|
|
184
|
-
url: url
|
|
185
|
-
actions: # 自定义执行逻辑
|
|
186
|
-
pre-deploy: # 在deploy之前运行
|
|
187
|
-
- run: s exec -- publish # 要运行的命令行
|
|
188
|
-
path: ./backend_src # 命令行运行的路径
|
|
189
|
-
- run: s build # 要运行的命令行
|
|
190
|
-
path: ./backend_src # 命令行运行的路径
|
|
191
|
-
post-deploy: # 在deploy之后运行
|
|
192
|
-
- run: s clean
|
|
193
|
-
path: ./frontend_src
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
当开发者在当前应用下执行了`deploy`命令,系统将会按照以下顺序进行操作:
|
|
197
|
-
1. 在`./backend_src`目录下执行`s exec -- publish`
|
|
198
|
-
2. 在`./backend_src`目录下执行`s build`
|
|
199
|
-
3. 调用组件`vue-component`的`deploy`方法,并将`props`和项目的基本信息传入到组件`vue-component`的`deploy`方法中
|
|
200
|
-
4. 在`./frontend_src`目录下执行`s clean`
|
|
201
|
-
|
|
202
|
-
以上顺序仅适用于整个流程没有出错的前提下,如果流程出现错误,系统将会进行报错,并终止后续流程的执行。
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
-----------
|
|
206
|
-
|
|
207
|
-
> 在一个应用下,如何一键部署整个应用?又或者如何只部署应用中的某个Service?可以参考[自定义命令使用指南](./command/custom.md)
|
package/docs/zh/yaml_and_cli.md
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# Yaml 模式 Cli 模式对比
|
|
2
|
-
|
|
3
|
-
Serverless Devs 开发者工具从根本上提供了两种使用方法。
|
|
4
|
-
- Yaml模式:需要依赖资源描述文档进行操作的模式
|
|
5
|
-
- Cli模式:可以在任何目录下直接执行,而不需要依赖资源描述文档;
|
|
6
|
-
|
|
7
|
-
这两者的核心区别是:
|
|
8
|
-
|
|
9
|
-
1. 如果想要使用 Yaml 模式,在当前目录下,必须要有`s.yaml`/`s.yml`文件,或通过`-t`/`--template`指定的资源部描述文件;
|
|
10
|
-
2. 如果想要试用 Cli 模式,则必须是 `s cli 组件名 方法 参数`的格式进行,此时不需要 Yaml 文件;
|
|
11
|
-
|
|
12
|
-
举一个非常简单的例子,如果有一个应用的资源描述文件`s.yaml`如下:
|
|
13
|
-
|
|
14
|
-
```yaml
|
|
15
|
-
name: myApp
|
|
16
|
-
edition: 1.0.0
|
|
17
|
-
access: "myaccess"
|
|
18
|
-
|
|
19
|
-
services:
|
|
20
|
-
website-starter:
|
|
21
|
-
component: devsapp/website
|
|
22
|
-
props:
|
|
23
|
-
bucket: testbucket
|
|
24
|
-
backend-starter:
|
|
25
|
-
component: devsapp/demo
|
|
26
|
-
props:
|
|
27
|
-
service:
|
|
28
|
-
name: serviceName
|
|
29
|
-
function:
|
|
30
|
-
name: functionName
|
|
31
|
-
region: cn-hangzhou
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
此时,可以执行`s deploy`进行`myApp`应用部署,如果执行`s backend-starter deploy`则可以进行`myApp`应用下的`backend-starter`项目/服务部署。
|
|
35
|
-
|
|
36
|
-
此时,部署过程中,所需要的相关参数,可以通过该 Yaml 文件进行读取。
|
|
37
|
-
|
|
38
|
-
但是,在某些情况下,并不方便直接使用 Serverless Devs 规范的 Yaml 文件(例如,将线上资源同步到本地,或者要将 Funcraft 的 Yaml 转换成为 Serverless Devs 的 Yaml),此时可以选择纯命令行形式,即`s cli`模式。
|
|
39
|
-
|
|
40
|
-
在 `s cli` 模式下,由于不会读取 Yaml 等资源描述文件,所以很多参数都需要自行填写,这时的填写方法有两种:
|
|
41
|
-
|
|
42
|
-
1. 通过 `s cli` 天然支持的 `-p`/`--prop` 参数,进行相关 Yaml 参数的赋值,例如上述案例的`s backend-starter deploy`,此时可以改写成:
|
|
43
|
-
```shell script
|
|
44
|
-
s cli devsapp/demo -p "{\"service\":{\"name\":\"serviceName\"},\"function\":{\"name\":\"functionName\"},\"region\":\"cn-hangzhou\"}"
|
|
45
|
-
```
|
|
46
|
-
2. 通过 demo 组件本身所支持的一些参数,例如通过`s cli devsapp/demo -h`,可以得到帮助信息,部分内容如下:
|
|
47
|
-
```shell script
|
|
48
|
-
--region [region] [C-Required] Specify the fc region, value: cn-hangzhou/cn-beijing/cn-beijing/cn-hangzhou/cn-shanghai/cn-qingdao/cn-zhangjiakou/cn-huhehaote/cn-shenzhen/cn-chengdu/cn-hongkong/ap-southeast-1/ap-southeast-2/ap-southeast-3/ap-southeast-5/ap-northeast-1/eu-central-1/eu-west-1/us-west-1/us-east-1/ap-south-1
|
|
49
|
-
--service-name [serviceName] [C-Required] Specify the fc service name
|
|
50
|
-
--function-name [functionName] [Optional] Specify the fc function name
|
|
51
|
-
```
|
|
52
|
-
此时,就可与通过下面的命令实现上述功能:
|
|
53
|
-
```shell script
|
|
54
|
-
s cli devsapp/demo --region cn-hangzhou --service-name serviceName --function-name functionName
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## 特点对比
|
|
58
|
-
|
|
59
|
-
| 模式 | 使用方法 | 优势 | 劣势 | 适用场景 |
|
|
60
|
-
| --- | --- | --- | --- | --- |
|
|
61
|
-
| Yaml模式 | 在具有符合Serverless Devs规范,且存在资源/行为描述的Yaml文件的应用目录下,执行组件对应的命令,即可直接使用,例如`s deploy`,`s servicename build`等 | 可以一键部署一个完整的应用(例如,某个应用中规定了多个Service,可以通过该命令一键部署);同时,通过资源/行为描述文档,可以更佳简单,清晰的对应用进行描述; | 需要学习Yaml的规范,且在某些时候与一些自动化流程进行结合,会比较复杂; | 部署、运维等操作,尤其是批量操作时更为合适; |
|
|
62
|
-
| 纯Cli模式 | 在任何目录下,通过子命令`cli`进行触发,同样适用全部组件,例如`s cli deploy -p "{/"function/": /"function-name/"}"`,`s cli fc-api listFunctions --service-name my-service` | 相对来说可以更加简单,快速上手工具,并且可以非常简单的与自动化流程进行结合,降低了Yaml格式/规范的学习难度 | 对于一些复杂项目而言,需要在命令行中写过多的参数,出错的概率会比较高; | 更适合项目的管理,源自化操作 |
|
|
63
|
-
|
|
64
|
-
## 设计思路
|
|
65
|
-
|
|
66
|
-
> ❓ 为什么要同时存在 Yaml 模式和 Cli 模式?
|
|
67
|
-
> 💬 因为在长期的实践过程中,我们发现通过 Yaml 进行资源描述会相对来说更简单和方便,例如 K8S 等也都是通过 Yaml 进行资源描述的;但是,在某些情况下,Yaml 文件也可能成为一种负担,例如想要查看某个服务下的函数列表,查看某个地区下的服务列表,因为这样一个简单的事情要额外的去完成一个 Yaml 文件,就显得过于臃肿,所以,在 Serverless Devs 项目中,同时保留了两种使用方法。
|
package/jest.setup.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import core from './src/utils/core';
|
|
5
|
-
const { fse: fs, jsyaml: yaml } = core;
|
|
6
|
-
import logger from './src/utils/logger';
|
|
7
|
-
|
|
8
|
-
jestBeforeDetection();
|
|
9
|
-
|
|
10
|
-
function jestBeforeDetection() {
|
|
11
|
-
if (!detectioIsExist('.s/access.yaml')) {
|
|
12
|
-
logger.error(`Failed to execute:\n
|
|
13
|
-
❌ Message: Please install S component
|
|
14
|
-
😈 If you have questions, please tell us: https://github.com/Serverless-Devs/Serverless-Devs/issues\n`);
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
if (Object.keys(getAccessFile()).length === 0) {
|
|
18
|
-
logger.error(`Failed to execute:\n
|
|
19
|
-
❌ Message: Please configure your Secret
|
|
20
|
-
😈 If you have questions, please tell us: https://github.com/Serverless-Devs/Serverless-Devs/issues\n`);
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function detectioIsExist(road) {
|
|
26
|
-
return fs.existsSync(getPath(road));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function getAccessFile() {
|
|
30
|
-
const accessFile = getPath('.s/access.yaml');
|
|
31
|
-
const accessFileInfo = yaml.load(fs.readFileSync(accessFile, 'utf-8') || '{}');
|
|
32
|
-
return accessFileInfo;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function getPath(road) {
|
|
36
|
-
return path.join(os.homedir(), road);
|
|
37
|
-
}
|
package/lib/clean/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/cli/cli-manager.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
export interface CliParams {
|
|
3
|
-
component: string;
|
|
4
|
-
command: string;
|
|
5
|
-
access: string;
|
|
6
|
-
props: string;
|
|
7
|
-
}
|
|
8
|
-
export default class CliManager {
|
|
9
|
-
protected inputs: CliParams;
|
|
10
|
-
constructor(inputs: CliParams);
|
|
11
|
-
getTempCommandStr(commands: string, length: number): string;
|
|
12
|
-
init(): Promise<any>;
|
|
13
|
-
}
|
package/lib/cli/index.d.ts
DELETED
package/lib/component/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
export declare type ProviderName = 'alibaba' | 'baidu' | 'huawei' | 'aws' | 'azure' | 'google' | 'tencent';
|
|
3
|
-
export declare enum ProviderObject {
|
|
4
|
-
alibaba = "Alibaba Cloud (alibaba)",
|
|
5
|
-
baidu = "Baidu Cloud (baidu)",
|
|
6
|
-
huawei = "Huawei Cloud (huawei)",
|
|
7
|
-
aws = "AWS (aws)",
|
|
8
|
-
azure = "Azure (azure)",
|
|
9
|
-
google = "Google Cloud (google)",
|
|
10
|
-
tencent = "Tencent Cloud (tencent)"
|
|
11
|
-
}
|
|
12
|
-
export declare const providerArray: ProviderName[];
|
|
13
|
-
export declare type ProviderCollectionConfig = {
|
|
14
|
-
[k in ProviderName]: {
|
|
15
|
-
type: string;
|
|
16
|
-
message: string;
|
|
17
|
-
name: string;
|
|
18
|
-
default: string;
|
|
19
|
-
}[];
|
|
20
|
-
};
|
|
21
|
-
export declare const providerCollection: ProviderCollectionConfig;
|
|
22
|
-
export interface AccessFormat {
|
|
23
|
-
AccountID?: string;
|
|
24
|
-
AccessKeyID?: string;
|
|
25
|
-
AccessKeySecret?: string;
|
|
26
|
-
SecretAccessKey?: string;
|
|
27
|
-
KeyVaultName?: string;
|
|
28
|
-
TenantID?: string;
|
|
29
|
-
ClientID?: string;
|
|
30
|
-
ClientSecret?: string;
|
|
31
|
-
SecretID?: string;
|
|
32
|
-
PrivateKeyData?: string;
|
|
33
|
-
}
|
|
34
|
-
export declare const providerAccessFormat: {
|
|
35
|
-
[k in ProviderName]: (keyof AccessFormat)[];
|
|
36
|
-
};
|
|
37
|
-
export declare const checkProviderList: {
|
|
38
|
-
type: string;
|
|
39
|
-
name: string;
|
|
40
|
-
message: string;
|
|
41
|
-
choices: {
|
|
42
|
-
name: ProviderObject;
|
|
43
|
-
value: ProviderName;
|
|
44
|
-
}[];
|
|
45
|
-
}[];
|
|
46
|
-
export declare function getInputData(program: AccessFormat): AccessFormat;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/config/index.d.ts
DELETED
package/lib/constants/index.d.ts
DELETED
|
File without changes
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Parse } from '../../specification';
|
|
2
|
-
import { ComponentConfig } from '../component';
|
|
3
|
-
export declare class CommandManager {
|
|
4
|
-
protected templateFile: string;
|
|
5
|
-
protected method: string;
|
|
6
|
-
protected customerCommandName?: string;
|
|
7
|
-
protected deployParams: any;
|
|
8
|
-
constructor(templateFile: string, method: string, customerCommandName?: string, params?: any);
|
|
9
|
-
assemblyProjectConfig(parse: Parse, projectName: string, parsedObj: any): Promise<ComponentConfig>;
|
|
10
|
-
warnEnvironmentVariables(realVariables: any): Promise<void>;
|
|
11
|
-
init(): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
export interface HookConfig {
|
|
3
|
-
Pre: boolean;
|
|
4
|
-
Plugin?: string;
|
|
5
|
-
Hook?: string;
|
|
6
|
-
Path?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class Hook {
|
|
9
|
-
preHooks: HookConfig[];
|
|
10
|
-
afterHooks: HookConfig[];
|
|
11
|
-
constructor(extendsParams?: HookConfig[]);
|
|
12
|
-
executePreHook(): Promise<void>;
|
|
13
|
-
executeAfterHook(): Promise<void>;
|
|
14
|
-
commandExecute(command: string, executePath: string | undefined): Promise<void>;
|
|
15
|
-
pluginExecute(name: string): Promise<void>;
|
|
16
|
-
executeByConfig(hookConfig: HookConfig): Promise<void>;
|
|
17
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { PackageType } from '../../entiry';
|
|
3
|
-
import { Parse } from '../../specification';
|
|
4
|
-
import { Hook } from './hook';
|
|
5
|
-
export interface ComponentConfig {
|
|
6
|
-
component: string;
|
|
7
|
-
provider: string;
|
|
8
|
-
Access?: string;
|
|
9
|
-
access?: string;
|
|
10
|
-
Extends: any;
|
|
11
|
-
props: {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
14
|
-
Params: any;
|
|
15
|
-
ProjectName: string;
|
|
16
|
-
}
|
|
17
|
-
export interface VersionCheckParams {
|
|
18
|
-
name: string;
|
|
19
|
-
type: PackageType;
|
|
20
|
-
provider: string;
|
|
21
|
-
}
|
|
22
|
-
export interface GenerateComponentExeParams {
|
|
23
|
-
list: string[];
|
|
24
|
-
parse: Parse;
|
|
25
|
-
parsedObj: any;
|
|
26
|
-
method: string;
|
|
27
|
-
params: string;
|
|
28
|
-
}
|
|
29
|
-
export declare function synchronizeExecuteComponentList(list?: any, index?: any, initData?: any): Promise<any>;
|
|
30
|
-
export declare function generateSynchronizeComponentExeList({ list, parse, parsedObj, method, params }: GenerateComponentExeParams, equipment: (parse: Parse, projectName: string, parsedObj: any) => Promise<ComponentConfig>): any[];
|
|
31
|
-
interface IComponentExeCute {
|
|
32
|
-
componentConfig: ComponentConfig;
|
|
33
|
-
method: string;
|
|
34
|
-
version: string;
|
|
35
|
-
customerCommandName?: string;
|
|
36
|
-
}
|
|
37
|
-
export declare class ComponentExeCute {
|
|
38
|
-
private credentials;
|
|
39
|
-
private componentConfig;
|
|
40
|
-
private method;
|
|
41
|
-
private version;
|
|
42
|
-
private customerCommandName;
|
|
43
|
-
constructor(config: IComponentExeCute);
|
|
44
|
-
init(): Promise<any>;
|
|
45
|
-
getCredentials(): Promise<any>;
|
|
46
|
-
private loadExtends;
|
|
47
|
-
loadPreExtends(extend: Hook | null): Promise<void>;
|
|
48
|
-
loadAfterExtend(extend: Hook | null): Promise<void>;
|
|
49
|
-
invokeMethod(componentInstance: any, method: string, data: any): Promise<any>;
|
|
50
|
-
executeCommand(): Promise<any>;
|
|
51
|
-
startExecute(): Promise<any>;
|
|
52
|
-
}
|
|
53
|
-
export {};
|
package/lib/core/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
export interface PluginConifg {
|
|
3
|
-
name: string;
|
|
4
|
-
}
|
|
5
|
-
export declare class PluginExeCute {
|
|
6
|
-
protected pluginConfig: PluginConifg;
|
|
7
|
-
protected pluginPath: string;
|
|
8
|
-
constructor(pluginConfig: PluginConifg);
|
|
9
|
-
init(): Promise<void>;
|
|
10
|
-
pluginExist(): boolean;
|
|
11
|
-
downLoadPlugin(name: string): Promise<void>;
|
|
12
|
-
loadPlugin(): Promise<any>;
|
|
13
|
-
}
|
package/lib/entiry/cli.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
export declare enum PackageType {
|
|
3
|
-
application = 0,
|
|
4
|
-
component = 1,
|
|
5
|
-
plugin = 2
|
|
6
|
-
}
|
|
7
|
-
export interface CommandType {
|
|
8
|
-
type: string;
|
|
9
|
-
message: string;
|
|
10
|
-
name: string;
|
|
11
|
-
default?: string;
|
|
12
|
-
choices?: any;
|
|
13
|
-
}
|
|
14
|
-
export interface InquirerCommand {
|
|
15
|
-
[key: string]: CommandType;
|
|
16
|
-
}
|
|
17
|
-
export interface RepoTemplate {
|
|
18
|
-
zipFile: string;
|
|
19
|
-
subPath?: string;
|
|
20
|
-
hasSubPath: boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface GitRepoTemplate extends RepoTemplate {
|
|
23
|
-
host: string | null;
|
|
24
|
-
ownerName: string;
|
|
25
|
-
branch: string;
|
|
26
|
-
repoName: string;
|
|
27
|
-
}
|
package/lib/entiry/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
interface IConfigs {
|
|
2
|
-
errorMessage: string;
|
|
3
|
-
tips?: string;
|
|
4
|
-
}
|
|
5
|
-
interface IReport {
|
|
6
|
-
error: Error;
|
|
7
|
-
}
|
|
8
|
-
export declare class HumanError {
|
|
9
|
-
private errorMessage;
|
|
10
|
-
constructor(configs: IConfigs);
|
|
11
|
-
report(configs: IReport): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
export {};
|
package/lib/error/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export { CommandError } from './command-error';
|
|
2
|
-
export { ConfigDeleteError } from './config-delete-error';
|
|
3
|
-
export { ConfigError } from './config-error';
|
|
4
|
-
export { ConfigGetError } from './config-get-error';
|
|
5
|
-
export { InitError } from './init-error';
|
|
6
|
-
export { ServerlessError } from './serverless-error';
|
|
7
|
-
export { HumanError } from './human-error';
|
|
8
|
-
export { HumanWarning } from './human-warning';
|
|
9
|
-
interface IConfigs {
|
|
10
|
-
error: Error;
|
|
11
|
-
prefix?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare class HandleError {
|
|
14
|
-
private traceId;
|
|
15
|
-
constructor(configs: IConfigs);
|
|
16
|
-
report(error: Error): Promise<void>;
|
|
17
|
-
}
|
package/lib/execDaemon.d.ts
DELETED
package/lib/index.d.ts
DELETED
package/lib/init/index.d.ts
DELETED