@serverless-devs/s 2.0.96 → 2.0.97-beta.1
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/lib/clean/index.js +1 -1
- package/lib/cli/index.js +1 -1
- package/lib/component/index.js +1 -1
- package/lib/config/add/index.js +1 -1
- package/lib/config/delete/index.js +1 -1
- package/lib/config/get/index.js +1 -1
- package/lib/config/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/init/index.js +1 -1
- package/lib/set/analysis/index.js +1 -1
- package/lib/set/index.js +1 -1
- package/lib/set/locale/index.js +1 -1
- package/lib/set/registry/index.js +1 -1
- package/lib/set/workspace/index.js +1 -1
- package/lib/update-notifier/index.js +1 -1
- package/package.json +2 -2
- 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/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
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
# 开发者模型
|
|
2
|
-
|
|
3
|
-
Serverless User Model 部分介绍了 Serverless Application 规范以 Serverless Package Component 使用规范。
|
|
4
|
-
|
|
5
|
-
- [Serverless Application 模型](#serverless-application-模型)
|
|
6
|
-
- [元数据](#元数据)
|
|
7
|
-
- [变量赋值](#变量赋值)
|
|
8
|
-
- [服务顺序](#服务顺序)
|
|
9
|
-
- [行为描述](#行为描述)
|
|
10
|
-
- [Serverless Package Component 使用规范](#serverless-package-component-使用规范)
|
|
11
|
-
|
|
12
|
-
## Serverless Application 模型
|
|
13
|
-
|
|
14
|
-
Serverless Application 模型的定义,基于Serverless Devs开发者工具可识别的资源/行为描述文件。该文件仅支持`.yaml`和`.yml`两种格式,且需要符合Yaml的标准规范。与此同时,Serverless Application 模型规定,一个Serverless Devs开发者工具可识别的资源/行为描述文件表示一个Serverless应用。
|
|
15
|
-
|
|
16
|
-
同时,需要注意的是,Serverless Application模型对应的Yaml格式文件默认名称为`s.yaml`与`s.yml`,且`s.yaml`的优先级大于`s.yml`,即在一个Serverless应用下,同时出现`s.yaml`与`s.yml`时,系统会优先识别和使用`s.yaml`,除非用户在使用时指定了其他Yaml格式的文件,作为默认文件。
|
|
17
|
-
|
|
18
|
-
关于Serverless Application模型对应的Yaml文件格式,也是有着比较严格的要求,其格式为:
|
|
19
|
-
|
|
20
|
-
```yaml
|
|
21
|
-
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范
|
|
22
|
-
name: applicationName # 应用名称
|
|
23
|
-
access: xxx-account1 # 秘钥别名
|
|
24
|
-
|
|
25
|
-
vars: # [全局变量,提供给各个服务使用]
|
|
26
|
-
Key: Value
|
|
27
|
-
|
|
28
|
-
Service:
|
|
29
|
-
ServiceName: # 服务名称
|
|
30
|
-
access: xxx-account1 # 秘钥别名,如果和项目的access相同,可省略
|
|
31
|
-
component: componentName # 组件名称
|
|
32
|
-
props: serviceProp # 组件的属性值
|
|
33
|
-
actions: serviceActions # 自定义执行逻辑
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
一个完整的符合Serverless Application模型
|
|
37
|
-
|
|
38
|
-
```yaml
|
|
39
|
-
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范
|
|
40
|
-
name: FullStack # 项目名称
|
|
41
|
-
access: xxx-account1 # 秘钥别名
|
|
42
|
-
|
|
43
|
-
vars: # [全局变量,提供给各个服务使用]
|
|
44
|
-
logo: https://image.aliyun.com/xxxx.png
|
|
45
|
-
|
|
46
|
-
services:
|
|
47
|
-
nextjs-portal: # 服务名称
|
|
48
|
-
access: xxx-account1 # 秘钥别名,如果和项目的access相同,可省略
|
|
49
|
-
component: vue-component # 组件名称
|
|
50
|
-
props: # 组件的属性值
|
|
51
|
-
src: ./frontend_src
|
|
52
|
-
url: url
|
|
53
|
-
actions: # 自定义执行逻辑
|
|
54
|
-
pre-deploy: # 在deploy之前运行
|
|
55
|
-
- run: s exec -- publish # 要运行的命令行
|
|
56
|
-
path: ./backend_src # 命令行运行的路径
|
|
57
|
-
- run: s build # 要运行的命令行
|
|
58
|
-
path: ./backend_src # 命令行运行的路径
|
|
59
|
-
post-deploy: # 在deploy之后运行
|
|
60
|
-
- run: s clean
|
|
61
|
-
path: ./frontend_src
|
|
62
|
-
|
|
63
|
-
assets:
|
|
64
|
-
component: static
|
|
65
|
-
props:
|
|
66
|
-
cache-control: "public, max-age=604800, immutable"
|
|
67
|
-
www: "./public"
|
|
68
|
-
|
|
69
|
-
express-blog:
|
|
70
|
-
component: express
|
|
71
|
-
props:
|
|
72
|
-
app: ./express-blog
|
|
73
|
-
url: ${vars.domain}
|
|
74
|
-
actions:
|
|
75
|
-
pre-deploy:
|
|
76
|
-
- run: npm run build
|
|
77
|
-
path: ./express-blog
|
|
78
|
-
|
|
79
|
-
gateway:
|
|
80
|
-
component: serverless-gateway # 路由组件:HTTP URL和服务之间的映射规则
|
|
81
|
-
props:
|
|
82
|
-
routes:
|
|
83
|
-
- route: /~assets
|
|
84
|
-
value: ${assets.output.url}
|
|
85
|
-
- route: /
|
|
86
|
-
value: ${nextjs-portal.output.url}
|
|
87
|
-
index: index.html
|
|
88
|
-
- route: /~portal
|
|
89
|
-
value: ${nextjs-portal.output.url}
|
|
90
|
-
inex: index.html
|
|
91
|
-
- route: /~blog
|
|
92
|
-
value: ${express-blog.output.url}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### 元数据
|
|
96
|
-
|
|
97
|
-
在该格式中:
|
|
98
|
-
|
|
99
|
-
| 参数名 | 代表含义 |
|
|
100
|
-
| ---- | ---- |
|
|
101
|
-
| edition | 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范 |
|
|
102
|
-
| name | 应用名称 |
|
|
103
|
-
| access | 秘钥别名 |
|
|
104
|
-
| vars | 全局变量,提供给各个服务使用,是一个Key-Value的形式 |
|
|
105
|
-
| Service | 应用所包含的服务,是一个Key-Value的形式 |
|
|
106
|
-
|
|
107
|
-
关于Service参数:
|
|
108
|
-
|
|
109
|
-
| 参数名 | 代表含义 |
|
|
110
|
-
| ---- | ---- |
|
|
111
|
-
| access | 秘钥别名,如果和项目的access相同,可省略 |
|
|
112
|
-
| component | 组件名称 |
|
|
113
|
-
| actions | 自定义执行逻辑 |
|
|
114
|
-
| props | 组件的属性值 |
|
|
115
|
-
|
|
116
|
-
### 变量赋值
|
|
117
|
-
|
|
118
|
-
Serverless Application模型对应的Yaml文件支持多种变量格式:
|
|
119
|
-
|
|
120
|
-
- 获取当前机器中的环境变量:${env(环境变量)},例如${env(secretId)}
|
|
121
|
-
- 获取外部文档的变量:${file(路径)},例如${file(./path)}
|
|
122
|
-
- 获取全局变量:${vars.*}
|
|
123
|
-
- 获取其他项目的变量:${projectName.props.*}
|
|
124
|
-
- 获取Yaml中其他项目的结果变量:${projectName.output.*}
|
|
125
|
-
|
|
126
|
-
### 服务顺序
|
|
127
|
-
|
|
128
|
-
如果一个Serverless Application模型对应的Yaml文件中有过多的服务,系统会默认分析部署顺序,该部署顺序分为两个步骤:
|
|
129
|
-
|
|
130
|
-
1. 分析项目中的依赖关系
|
|
131
|
-
2. 有依赖关系的按照依赖关系从前到后部署,无依赖关系的按Yaml配置的从上到下部署
|
|
132
|
-
|
|
133
|
-
### 行为描述
|
|
134
|
-
|
|
135
|
-
在Serverless Application模型对应的Yaml文件中,可以针对服务,提供对应的行为操作,其基本格式是:
|
|
136
|
-
|
|
137
|
-
```yaml
|
|
138
|
-
actions: # 自定义执行逻辑
|
|
139
|
-
pre-命令: # 在命令之前运行
|
|
140
|
-
- run: command # 要运行的操作
|
|
141
|
-
path: ./path # 运行操作的路径
|
|
142
|
-
post-命令: # 在命令之后运行
|
|
143
|
-
- run: command # 要运行的操作
|
|
144
|
-
path: ./path # 运行操作的路径
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
例如:
|
|
148
|
-
|
|
149
|
-
```yaml
|
|
150
|
-
actions: # 自定义执行逻辑
|
|
151
|
-
pre-deploy: # 在deploy之前运行
|
|
152
|
-
- run: s exec -- publish # 要运行的命令行
|
|
153
|
-
path: ./backend_src # 命令行运行的路径
|
|
154
|
-
- run: s build # 要运行的命令行
|
|
155
|
-
path: ./backend_src # 命令行运行的路径
|
|
156
|
-
post-deploy: # 在deploy之后运行
|
|
157
|
-
- run: s clean
|
|
158
|
-
path: ./frontend_src
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
当Serverless Devs开发者工具执行到该服务时,会在进行相关的命令之行之前,优先按照顺序执行`pre-命令`的操作,所有内容完成执行之后,再执行`post-命令`的操作。
|
|
162
|
-
|
|
163
|
-
以下面的Yaml为例:
|
|
164
|
-
|
|
165
|
-
```yaml
|
|
166
|
-
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范
|
|
167
|
-
name: FullStack # 项目名称
|
|
168
|
-
|
|
169
|
-
services:
|
|
170
|
-
nextjs-portal: # 服务名称
|
|
171
|
-
access: xxx-account1 # 秘钥别名,如果和项目的access相同,可省略
|
|
172
|
-
component: vue-component # 组件名称
|
|
173
|
-
props: # 组件的属性值
|
|
174
|
-
src: ./frontend_src
|
|
175
|
-
url: url
|
|
176
|
-
actions: # 自定义执行逻辑
|
|
177
|
-
pre-deploy: # 在deploy之前运行
|
|
178
|
-
- run: s exec -- publish # 要运行的命令行
|
|
179
|
-
path: ./backend_src # 命令行运行的路径
|
|
180
|
-
- run: s build # 要运行的命令行
|
|
181
|
-
path: ./backend_src # 命令行运行的路径
|
|
182
|
-
post-deploy: # 在deploy之后运行
|
|
183
|
-
- run: s clean
|
|
184
|
-
path: ./frontend_src
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
当开发者在当前应用下执行了`deploy`命令,系统将会按照以下顺序进行操作:
|
|
188
|
-
1. 在`./backend_src`目录下执行`s exec -- publish`
|
|
189
|
-
2. 在`./backend_src`目录下执行`s build`
|
|
190
|
-
3. 调用组件`vue-component`的`deploy`方法,并将`props`和项目的基本信息传入到组件`vue-component`的`deploy`方法中
|
|
191
|
-
4. 在`./frontend_src`目录下执行`s clean`
|
|
192
|
-
|
|
193
|
-
以上顺序仅适用于整个流程没有出错的前提下,如果流程出现错误,系统将会进行报错,并终止后续流程的执行。
|
|
194
|
-
|
|
195
|
-
## Serverless Package Component 使用规范
|
|
196
|
-
|
|
197
|
-
Serverless 开发者模型,规定了Serverless Package Component的使用规范。对于一个符合Serverless Application模型的Yaml文件:
|
|
198
|
-
|
|
199
|
-
```yaml
|
|
200
|
-
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范
|
|
201
|
-
name: applicationName # 应用名称
|
|
202
|
-
access: xxx-account1 # 秘钥别名
|
|
203
|
-
|
|
204
|
-
vars: # [全局变量,提供给各个服务使用]
|
|
205
|
-
Key: Value
|
|
206
|
-
|
|
207
|
-
Service:
|
|
208
|
-
ServiceName: # 服务名称
|
|
209
|
-
access: xxx-account1 # 秘钥别名,如果和项目的access相同,可省略
|
|
210
|
-
component: componentName # 组件名称
|
|
211
|
-
props: serviceProp # 组件的属性值
|
|
212
|
-
actions: serviceActions # 自定义执行逻辑
|
|
213
|
-
```
|
|
214
|
-
在规范中,不同的Service都需要明确需要使用的component。此时的component格式将会分为几种:
|
|
215
|
-
- 一个存在与指定registry的组件,例如`fc`组件等;
|
|
216
|
-
- 一个存在Github的仓库,且按照规Serverless Package Component规范发布了Release,例如`devsapp/fc`
|
|
217
|
-
- 一个本地的且符合Serverless Package Component规范的组件路径,例如`./../start-component/`
|
|
218
|
-
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# 用户模型
|
|
2
|
-
|
|
3
|
-
一个关于 Serverless 应用的开发规范,也是Serverless开发者规范。Serverless developer 需要遵循该规范进行应用开发,通过法规范,可以快速使用Serverless Devs开发者工具,进行相关业务功能的实现。。
|
|
4
|
-
|
|
5
|
-
- [目的和目标](1.purpose_and_goals.md)
|
|
6
|
-
- [概述和术语](2.overview_and_terminology.md)
|
|
7
|
-
- [模型概述](2.overview_and_terminology.md#模型概述)
|
|
8
|
-
- [User 模型](./3.user_model.md)
|
|
9
|
-
- [Serverless Application 模型](./3.user_model.md#serverless-application-模型)
|
|
10
|
-
- [Serverless Package Component 使用规范](./3.user_model.md##serverless-package-component-使用规范)
|
|
11
|
-
- [适用范围](4.application_scopes.md)
|
|
12
|
-
- [设计原则](5.design_principles.md)
|
package/test/ci.sh
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
echo './bin/s -v'
|
|
3
|
-
./bin/s -v
|
|
4
|
-
|
|
5
|
-
echo './bin/s -h'
|
|
6
|
-
./bin/s -h
|
|
7
|
-
|
|
8
|
-
echo './bin/s config add --AccountID 12345 --AccessKeyID 12345 --AccessKeySecret 12345 -a test -f'
|
|
9
|
-
./bin/s config add --AccountID 12345 --AccessKeyID 12345 --AccessKeySecret 12345 -a test -f
|
|
10
|
-
|
|
11
|
-
echo './bin/s config get'
|
|
12
|
-
./bin/s config get
|
|
13
|
-
|
|
14
|
-
echo './bin/s config delete -a test'
|
|
15
|
-
./bin/s config delete -a test
|
|
16
|
-
|
|
17
|
-
echo './bin/s cli fc-api listServices'
|
|
18
|
-
./bin/s cli fc-api
|
|
19
|
-
|
|
20
|
-
echo './bin/s component'
|
|
21
|
-
./bin/s component
|
|
22
|
-
|
|
23
|
-
echo './bin/s component --component fc-api'
|
|
24
|
-
./bin/s component --component fc-api
|
|
25
|
-
|
|
26
|
-
echo './bin/s clean --component fc-api'
|
|
27
|
-
./bin/s clean --component fc-api
|
|
28
|
-
|
|
29
|
-
echo './bin/s clean --cache'
|
|
30
|
-
./bin/s clean --cache
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
|
|
3
|
-
import CliManager, { CliParams } from '../../src/cli/cli-manager';
|
|
4
|
-
|
|
5
|
-
describe('init cli', () => {
|
|
6
|
-
it('Verify CliManager class initialization', () => {
|
|
7
|
-
const input: CliParams = {
|
|
8
|
-
component: 'string',
|
|
9
|
-
command: 'string',
|
|
10
|
-
access: 'string',
|
|
11
|
-
props: 'string',
|
|
12
|
-
};
|
|
13
|
-
class myClass extends CliManager {
|
|
14
|
-
public values: any;
|
|
15
|
-
constructor(data) {
|
|
16
|
-
super(data);
|
|
17
|
-
this.values = this.inputs;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const v = new myClass(input);
|
|
21
|
-
expect(v.values).toEqual(input)
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('test component inner inputs', async () => {
|
|
25
|
-
try {
|
|
26
|
-
const input: CliParams = {
|
|
27
|
-
component: 's-demo',
|
|
28
|
-
command: 'test',
|
|
29
|
-
access: 'default',
|
|
30
|
-
props: undefined,
|
|
31
|
-
};
|
|
32
|
-
const cli = new CliManager(input);
|
|
33
|
-
let access = process.env['serverless_devs_temp_access'] ? process.env['serverless_devs_temp_access'] : input.access;
|
|
34
|
-
input.access = access;
|
|
35
|
-
const result = await cli.init();
|
|
36
|
-
expect(result).toHaveProperty('props'); // 判断输入到组件的参数是否包含props
|
|
37
|
-
expect(result).toHaveProperty('credentials'); // 判断输入到组件的参数是否包含credentials
|
|
38
|
-
expect(result).toHaveProperty('project'); // 判断输入到组件的参数是否包含project
|
|
39
|
-
expect(result).toHaveProperty('appName'); // 判断输入到组件的参数是否包含appName
|
|
40
|
-
} catch (e) {
|
|
41
|
-
expect(e).toMatch('error');
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
it('test params as input', async () => {
|
|
45
|
-
try {
|
|
46
|
-
const input: CliParams = {
|
|
47
|
-
component: 's-demo',
|
|
48
|
-
command: 'test',
|
|
49
|
-
access: 'default',
|
|
50
|
-
props: '{"hello":"serverless devs"}',
|
|
51
|
-
};
|
|
52
|
-
let access = process.env['serverless_devs_temp_access'] ? process.env['serverless_devs_temp_access'] : input.access;
|
|
53
|
-
input.access = access;
|
|
54
|
-
const cli = new CliManager(input);
|
|
55
|
-
|
|
56
|
-
const result = await cli.init();
|
|
57
|
-
expect(result).toHaveProperty('props')
|
|
58
|
-
expect(result.props).toHaveProperty('hello');
|
|
59
|
-
expect(result.props).toMatchObject({ hello: 'serverless devs' }); // 判断经过入参转换后是否为对象
|
|
60
|
-
} catch (e) {
|
|
61
|
-
expect(e).toMatch('error');
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
package/test/config/get.test.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** @format */
|
|
2
|
-
import { spawnSync } from 'child_process'
|
|
3
|
-
|
|
4
|
-
describe('module config', () => {
|
|
5
|
-
it('s config -l', () => {
|
|
6
|
-
const ls = spawnSync('s', ['config', 'get', '-l'])
|
|
7
|
-
const v = Buffer.from(ls.stdout)
|
|
8
|
-
expect(v.toString()).toContain('AccountID')
|
|
9
|
-
expect(v.toString()).toContain('AccessKeySecret')
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
})
|
package/test/helloworld.test.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
var getRawBody = require('raw-body');
|
|
2
|
-
var getFormBody = require('body/form');
|
|
3
|
-
var body = require('body');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
To enable the initializer feature (https://help.aliyun.com/document_detail/156876.html)
|
|
8
|
-
please implement the initializer function as below:
|
|
9
|
-
exports.initializer = (context, callback) => {
|
|
10
|
-
console.log('initializing');
|
|
11
|
-
callback(null, '');
|
|
12
|
-
};
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
exports.handler = (req, resp, context) => {
|
|
16
|
-
console.log('hello world');
|
|
17
|
-
|
|
18
|
-
var params = {
|
|
19
|
-
path: req.path,
|
|
20
|
-
queries: req.queries,
|
|
21
|
-
headers: req.headers,
|
|
22
|
-
method : req.method,
|
|
23
|
-
requestURI : req.url,
|
|
24
|
-
clientIP : req.clientIP,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getRawBody(req, function(err, body) {
|
|
28
|
-
for (var key in req.queries) {
|
|
29
|
-
var value = req.queries[key];
|
|
30
|
-
resp.setHeader(key, value);
|
|
31
|
-
}
|
|
32
|
-
params.body = body.toString();
|
|
33
|
-
resp.send(JSON.stringify(params, null, ' '));
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
/*
|
|
37
|
-
getFormBody(req, function(err, formBody) {
|
|
38
|
-
for (var key in req.queries) {
|
|
39
|
-
var value = req.queries[key];
|
|
40
|
-
resp.setHeader(key, value);
|
|
41
|
-
}
|
|
42
|
-
params.body = formBody;
|
|
43
|
-
console.log(formBody);
|
|
44
|
-
resp.send(JSON.stringify(params));
|
|
45
|
-
});
|
|
46
|
-
*/
|
|
47
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范
|
|
2
|
-
name: fcDeployApp # 项目名称
|
|
3
|
-
access: "default" # 秘钥别名
|
|
4
|
-
|
|
5
|
-
services:
|
|
6
|
-
fc-deploy-test: # 服务名称
|
|
7
|
-
component: devsapp/fc # 组件名称
|
|
8
|
-
props: # 组件的属性值
|
|
9
|
-
region: cn-hangzhou
|
|
10
|
-
service:
|
|
11
|
-
name: fc-deploy-service
|
|
12
|
-
description: 'demo for fc-deploy component'
|
|
13
|
-
internetAccess: true
|
|
14
|
-
function:
|
|
15
|
-
name: http-trigger-nodejs12
|
|
16
|
-
description: this is a test
|
|
17
|
-
runtime: nodejs12
|
|
18
|
-
codeUri: ./code
|
|
19
|
-
# ossBucket:
|
|
20
|
-
# ossKey: # conflict with codeUri
|
|
21
|
-
handler: index.handler
|
|
22
|
-
memorySize: 128
|
|
23
|
-
timeout: 60
|
|
24
|
-
triggers:
|
|
25
|
-
- name: httpTrigger
|
|
26
|
-
type: http
|
|
27
|
-
config:
|
|
28
|
-
authType: anonymous
|
|
29
|
-
methods:
|
|
30
|
-
- GET
|
|
31
|
-
customDomains:
|
|
32
|
-
- domainName: auto
|
|
33
|
-
protocol: HTTP
|
|
34
|
-
routeConfigs:
|
|
35
|
-
- path: /*
|
|
36
|
-
methods:
|
|
37
|
-
- GET
|
|
38
|
-
# 函数计算FC组件文档参考地址:https://github.com/devsapp/fc
|
package/test/utils/index.test.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import core from '../../src/utils/core';
|
|
2
|
-
const { fse: fs } = core;
|
|
3
|
-
import os from 'os';
|
|
4
|
-
import { getHomeDir, getHistoryFile } from '../../src/utils/storage';
|
|
5
|
-
|
|
6
|
-
describe('module storage', () => {
|
|
7
|
-
it('test getHomeDir methods', () => {
|
|
8
|
-
const path = getHomeDir();
|
|
9
|
-
expect(path).toContain('.s');
|
|
10
|
-
const v = fs.existsSync(`${os.homedir()}/.s`);
|
|
11
|
-
expect(v).toBeTruthy();
|
|
12
|
-
});
|
|
13
|
-
it('test getHistoryFile methods', () => {
|
|
14
|
-
const path = getHistoryFile();
|
|
15
|
-
expect(path).toContain('history');
|
|
16
|
-
const v = fs.existsSync(`${os.homedir()}/.s/history`);
|
|
17
|
-
expect(v).toBeTruthy();
|
|
18
|
-
});
|
|
19
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compileOnSave": true,
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"esModuleInterop": true,
|
|
5
|
-
"lib": [
|
|
6
|
-
"es2015",
|
|
7
|
-
"dom",
|
|
8
|
-
"es6"
|
|
9
|
-
],
|
|
10
|
-
"target": "es5",
|
|
11
|
-
"module": "commonjs",
|
|
12
|
-
"moduleResolution": "node",
|
|
13
|
-
"experimentalDecorators": true,
|
|
14
|
-
"emitDecoratorMetadata": true,
|
|
15
|
-
"inlineSourceMap": true,
|
|
16
|
-
"noImplicitThis": true,
|
|
17
|
-
"noUnusedLocals": true,
|
|
18
|
-
"stripInternal": true,
|
|
19
|
-
"pretty": false,
|
|
20
|
-
"declaration": true,
|
|
21
|
-
"typeRoots": [
|
|
22
|
-
"./typings",
|
|
23
|
-
"./node_modules/@types"
|
|
24
|
-
],
|
|
25
|
-
"rootDir": "src",
|
|
26
|
-
"outDir": "lib"
|
|
27
|
-
},
|
|
28
|
-
"exclude": [
|
|
29
|
-
"node_modules",
|
|
30
|
-
"dist",
|
|
31
|
-
"test"
|
|
32
|
-
],
|
|
33
|
-
"include": [
|
|
34
|
-
"./src/**/*.ts",
|
|
35
|
-
"src/**/*.json"
|
|
36
|
-
]
|
|
37
|
-
}
|