@serverless-devs/s 2.0.92 → 2.0.93-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CONTRIBUTORS.md +2 -0
  2. package/bin/s-component +2 -0
  3. package/bin/s-set-workspace +2 -0
  4. package/docs/readme.md +94 -0
  5. package/docs/zh/awesome.md +296 -0
  6. package/docs/zh/cicd.md +200 -0
  7. package/docs/zh/cli_design.md +100 -0
  8. package/docs/zh/command/clean.md +63 -0
  9. package/docs/zh/command/cli.md +92 -0
  10. package/docs/zh/command/component.md +76 -0
  11. package/docs/zh/command/config.md +278 -0
  12. package/docs/zh/command/custom.md +73 -0
  13. package/docs/zh/command/init.md +148 -0
  14. package/docs/zh/command/readme.md +76 -0
  15. package/docs/zh/command/set.md +195 -0
  16. package/docs/zh/default_provider_config/alibabacloud.md +82 -0
  17. package/docs/zh/default_provider_config/aws.md +12 -0
  18. package/docs/zh/default_provider_config/azure.md +9 -0
  19. package/docs/zh/default_provider_config/baiducloud.md +8 -0
  20. package/docs/zh/default_provider_config/gcp.md +21 -0
  21. package/docs/zh/default_provider_config/huaweicloud.md +52 -0
  22. package/docs/zh/default_provider_config/readme.md +9 -0
  23. package/docs/zh/default_provider_config/tencentcloud.md +41 -0
  24. package/docs/zh/install.md +52 -0
  25. package/docs/zh/package_dev.md +142 -0
  26. package/docs/zh/quick_start.md +297 -0
  27. package/docs/zh/readme.md +90 -0
  28. package/docs/zh/tool.md +80 -0
  29. package/docs/zh/yaml.md +203 -0
  30. package/docs/zh/yaml_and_cli.md +67 -0
  31. package/lib/clean/index.js +43 -35
  32. package/lib/cli/cli-manager.js +33 -22
  33. package/lib/cli/index.js +60 -62
  34. package/lib/component/index.d.ts +1 -0
  35. package/lib/component/index.js +161 -0
  36. package/lib/config/add/index.js +39 -39
  37. package/lib/config/delete/index.js +49 -59
  38. package/lib/config/get/index.d.ts +0 -1
  39. package/lib/config/get/index.js +46 -51
  40. package/lib/config/index.js +36 -35
  41. package/lib/constants/index.d.ts +0 -1
  42. package/lib/constants/index.js +1 -5
  43. package/lib/core/command/command-manager.js +36 -43
  44. package/lib/core/component/index.d.ts +14 -7
  45. package/lib/core/component/index.js +78 -52
  46. package/lib/core/plugin/index.js +4 -3
  47. package/lib/daemon/template.js +2 -4
  48. package/lib/error/human-error.d.ts +12 -2
  49. package/lib/error/human-error.js +63 -28
  50. package/lib/error/human-warning.d.ts +8 -0
  51. package/lib/error/human-warning.js +19 -0
  52. package/lib/error/index.d.ts +10 -1
  53. package/lib/error/index.js +74 -27
  54. package/lib/index.js +89 -94
  55. package/lib/init/index.js +76 -79
  56. package/lib/init/init-config.js +3 -5
  57. package/lib/init/init-manager.js +3 -4
  58. package/lib/init/update-template.js +3 -5
  59. package/lib/onboarding/index.js +5 -5
  60. package/lib/set/analysis/index.js +41 -37
  61. package/lib/set/index.js +34 -33
  62. package/lib/set/locale/index.js +54 -53
  63. package/lib/set/registry/index.js +52 -52
  64. package/lib/set/workspace/index.d.ts +1 -0
  65. package/lib/set/workspace/index.js +61 -0
  66. package/lib/specification/parse.js +9 -6
  67. package/lib/update-notifier/index.js +10 -10
  68. package/lib/utils/command-util.d.ts +0 -2
  69. package/lib/utils/command-util.js +2 -42
  70. package/lib/utils/common.d.ts +1 -0
  71. package/lib/utils/common.js +100 -20
  72. package/lib/utils/core.js +3 -3
  73. package/lib/utils/handler-set-config.d.ts +1 -1
  74. package/lib/utils/handler-set-config.js +6 -7
  75. package/lib/utils/i18n/en.js +4 -4
  76. package/lib/utils/i18n/index.js +3 -3
  77. package/lib/utils/i18n/zh.js +3 -3
  78. package/lib/utils/storage.js +3 -4
  79. package/package.json +2 -2
  80. package/readme.md +64 -38
  81. package/shell/postbuild.sh +2 -0
  82. package/spec/readme.md +59 -0
  83. package/spec/zh/0.0.1/readme.md +47 -0
  84. package/spec/zh/0.0.1/serverless_pacakge_model/1.purpose_and_goals.md +3 -0
  85. package/spec/zh/0.0.1/serverless_pacakge_model/2.overview_and_terminology.md +14 -0
  86. package/spec/zh/0.0.1/serverless_pacakge_model/3.package_model.md +434 -0
  87. package/spec/zh/0.0.1/serverless_pacakge_model/4.application_scopes.md +3 -0
  88. package/spec/zh/0.0.1/serverless_pacakge_model/5.design_principles.md +3 -0
  89. package/spec/zh/0.0.1/serverless_pacakge_model/readme.md +12 -0
  90. package/spec/zh/0.0.1/serverless_registry_model/1.purpose_and_goals.md +18 -0
  91. package/spec/zh/0.0.1/serverless_registry_model/2.overview_and_terminology.md +18 -0
  92. package/spec/zh/0.0.1/serverless_registry_model/3.registry_model.md +61 -0
  93. package/spec/zh/0.0.1/serverless_registry_model/4.application_scopes.md +6 -0
  94. package/spec/zh/0.0.1/serverless_registry_model/5.design_principles.md +3 -0
  95. package/spec/zh/0.0.1/serverless_registry_model/readme.md +12 -0
  96. package/spec/zh/0.0.1/serverless_user_model/1.purpose_and_goals.md +3 -0
  97. package/spec/zh/0.0.1/serverless_user_model/2.overview_and_terminology.md +16 -0
  98. package/spec/zh/0.0.1/serverless_user_model/3.user_model.md +218 -0
  99. package/spec/zh/0.0.1/serverless_user_model/4.application_scopes.md +4 -0
  100. package/spec/zh/0.0.1/serverless_user_model/5.design_principles.md +3 -0
  101. package/spec/zh/0.0.1/serverless_user_model/readme.md +12 -0
  102. package/bin/s-set-locale +0 -2
  103. package/readme_zh.md +0 -72
@@ -0,0 +1,218 @@
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
+
@@ -0,0 +1,4 @@
1
+ # 适用范围
2
+
3
+ 以上规范适用于条件仅限于 Serverless Devs 开发者工具 所支持、所识别的Serverless应用。Serverless应用开发者,可以通过上述的规范,快速通过Serverless Devs开发者工具,进行Serverless应用的创建、开发、运维等全生命周期的管理。
4
+
@@ -0,0 +1,3 @@
1
+ # 设计原则
2
+
3
+ 为了给Serverless开发者更加规范和科学的Serverless应用开发流程,可以让Serverless开发者更好的通过Serverless Devs开发者工具对Serverless Devs应用进行全生命周期的管理,Serverless User Model从开发者角度出发,提出Serverless Application规范以及Serverless Package Component规范,可以帮助开发者快速管理和操作Serverless应用。
@@ -0,0 +1,12 @@
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/bin/s-set-locale DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- require('../lib/set/locale');
package/readme_zh.md DELETED
@@ -1,72 +0,0 @@
1
- # Serverless Devs 帮助文档
2
-
3
- <div align=center> <img src="https://images.devsapp.cn/devs-github/logo.jpg" width="100%"/> </div>
4
-
5
- <p align="center">
6
- <a href="https://www.npmjs.com/package/@serverless-devs/s">
7
- <img src="https://img.shields.io/npm/v/@serverless-devs/s" alt="npm version">
8
- </a>
9
- <a href="https://github.com/Serverless-Devs/Serverless-Devs/blob/master/LICENSE">
10
- <img src="https://img.shields.io/badge/License-MIT-green" alt="license">
11
- </a>
12
- </p>
13
-
14
-
15
-
16
- <p align="center">
17
- <span>像使用手机一样使用Serverless</span><br>
18
- <span>中文文档 |<a href="./readme.md">English</a> </span>
19
- </p>
20
-
21
- ## 项目简介
22
-
23
- ```text
24
- _________ .__ ________
25
- / _____/ ______________ __ ___________| | ____ ______ ______ \______ \ _______ ________
26
- \_____ \_/ __ \_ __ \ \/ // __ \_ __ \ | _/ __ \ / ___// ___/ | | \_/ __ \ \/ / ___/
27
- / \ ___/| | \/\ /\ ___/| | \/ |_\ ___/ \___ \ \___ \ | ` \ ___/\ /\___ \
28
- /_______ /\___ >__| \_/ \___ >__| |____/\___ >____ >____ > /_______ /\___ >\_//____ >
29
- \/ \/ \/ \/ \/ \/ \/ \/ \/
30
- ```
31
-
32
- Serverless Devs 是一个开源开放的 Serverless 开发者平台,致力于为开发者提供强大的工具链体系。通过该平台,开发者可以一键体验多云 Serverless 产品,极速部署 Serverless 项目。
33
-
34
-
35
-
36
- ### 可支持主流 Serverless 服务/框架
37
-
38
- Serverless Devs 是一个组件化与插件化的 Serverless 开发者平台,在该平台中,每个使用者都可以可插拔式的使用不同 Serverless 的服务和框架,同时每个使用者都可以参与开发组件和插件。在 Serverless Devs 中无论是工业级的 Serverless 服务,还是各类开源的 Serverless 框架,都可以得到非常友好的支持。开发者无需对市面上每一款 Serverless 工具进行研究和学习,只需通过 Serverless Devs ,就可以简单、快捷的“上手”主流 Serverless 服务和框架;
39
-
40
- ### 灵活与开放的使用方法
41
-
42
- 与绝大部分的开发者工具不同的是,Serverless Devs 在进行项目描述时不仅仅可以对函数计算、API 网关、对象存储等资源进行描述,也可以通过 Serverless Devs 提供的插件以及 Hook 进行Install, Build, Publish等行为描述。与此同时 Serverless Devs 不会对每个组件的命令进行限制,而是鼓励开发者针对不同的组件,开发不同的能力来应对更多、更复杂的场景,例如阿里云函数计算组件,不仅仅支持函数的部署和移除这样的传统能力,还支持日志查询,指标查询,本地构建,依赖安装,调试等更多定制化的能力。Serverless Devs 的这种灵活与开放的使用方法,可以在自动化部署、运维等领域发挥非常大的作用,将Serverless Devs与项目全生命周期进行有机融合,可使得 Serverless 项目的开发运维效能提升 90%。
43
-
44
-
45
- ## 帮助文档
46
-
47
- - [安装文档](https://github.com/Serverless-Devs/docs/blob/master/zh/install.md)
48
- - [命令行指令文档](https://github.com/Serverless-Devs/docs/blob/master/zh/command.md)
49
- - [Yaml规范文档](https://github.com/Serverless-Devs/docs/blob/master/zh/yaml.md)
50
- - [Package开发者文档](https://github.com/Serverless-Devs/docs/blob/master/zh/dev.md)
51
- - [源文档](https://github.com/Serverless-Devs/docs/blob/master/zh/registry.md)
52
-
53
- ## 相关资源
54
-
55
- [组件/应用Awesome](https://github.com/Serverless-Devs/package-awesome/blob/main/README_zh.md)
56
-
57
- ## 快速体验
58
-
59
- ### 零基础部署一个博客系统
60
-
61
- - 下载命令行工具:npm install -g @serverless-devs/s
62
- - 初始化一个模版项目:s init devsapp/start-zblog
63
- - 进入项目后部署项目:cd start-zblog && s deploy
64
-
65
- ### 零基础部署一个企业官网
66
-
67
- - 下载命令行工具:npm install -g @serverless-devs/s
68
- - 初始化一个模版项目:s init devsapp/start-metinfo
69
- - 进入项目后部署项目:cd start-metinfo && s deploy
70
-
71
- 更多案例: `s init`
72
-