@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.
Files changed (76) hide show
  1. package/lib/clean/index.js +1 -1
  2. package/lib/cli/index.js +1 -1
  3. package/lib/component/index.js +1 -1
  4. package/lib/config/add/index.js +1 -1
  5. package/lib/config/delete/index.js +1 -1
  6. package/lib/config/get/index.js +1 -1
  7. package/lib/config/index.js +1 -1
  8. package/lib/index.js +1 -1
  9. package/lib/init/index.js +1 -1
  10. package/lib/set/analysis/index.js +1 -1
  11. package/lib/set/index.js +1 -1
  12. package/lib/set/locale/index.js +1 -1
  13. package/lib/set/registry/index.js +1 -1
  14. package/lib/set/workspace/index.js +1 -1
  15. package/lib/update-notifier/index.js +1 -1
  16. package/package.json +2 -2
  17. package/CODE_OF_CONDUCT.md +0 -5
  18. package/CONTRIBUTING.md +0 -189
  19. package/CONTRIBUTORS.md +0 -148
  20. package/docs/readme.md +0 -100
  21. package/docs/zh/awesome.md +0 -20
  22. package/docs/zh/cicd.md +0 -231
  23. package/docs/zh/cli_design.md +0 -100
  24. package/docs/zh/command/clean.md +0 -63
  25. package/docs/zh/command/cli.md +0 -92
  26. package/docs/zh/command/component.md +0 -75
  27. package/docs/zh/command/config.md +0 -274
  28. package/docs/zh/command/custom.md +0 -73
  29. package/docs/zh/command/init.md +0 -149
  30. package/docs/zh/command/readme.md +0 -76
  31. package/docs/zh/command/set.md +0 -195
  32. package/docs/zh/default_provider_config/alibabacloud.md +0 -82
  33. package/docs/zh/default_provider_config/aws.md +0 -12
  34. package/docs/zh/default_provider_config/azure.md +0 -9
  35. package/docs/zh/default_provider_config/baiducloud.md +0 -8
  36. package/docs/zh/default_provider_config/gcp.md +0 -21
  37. package/docs/zh/default_provider_config/huaweicloud.md +0 -52
  38. package/docs/zh/default_provider_config/readme.md +0 -9
  39. package/docs/zh/default_provider_config/tencentcloud.md +0 -41
  40. package/docs/zh/install.md +0 -52
  41. package/docs/zh/package_dev.md +0 -142
  42. package/docs/zh/quick_start.md +0 -297
  43. package/docs/zh/readme.md +0 -92
  44. package/docs/zh/tool.md +0 -101
  45. package/docs/zh/yaml.md +0 -207
  46. package/docs/zh/yaml_and_cli.md +0 -67
  47. package/jest.setup.ts +0 -37
  48. package/spec/readme.md +0 -59
  49. package/spec/zh/0.0.1/readme.md +0 -47
  50. package/spec/zh/0.0.1/serverless_package_model/1.purpose_and_goals.md +0 -3
  51. package/spec/zh/0.0.1/serverless_package_model/2.overview_and_terminology.md +0 -14
  52. package/spec/zh/0.0.1/serverless_package_model/3.package_model.md +0 -434
  53. package/spec/zh/0.0.1/serverless_package_model/4.application_scopes.md +0 -3
  54. package/spec/zh/0.0.1/serverless_package_model/5.design_principles.md +0 -3
  55. package/spec/zh/0.0.1/serverless_package_model/readme.md +0 -12
  56. package/spec/zh/0.0.1/serverless_registry_model/1.purpose_and_goals.md +0 -18
  57. package/spec/zh/0.0.1/serverless_registry_model/2.overview_and_terminology.md +0 -18
  58. package/spec/zh/0.0.1/serverless_registry_model/3.registry_model.md +0 -61
  59. package/spec/zh/0.0.1/serverless_registry_model/4.application_scopes.md +0 -6
  60. package/spec/zh/0.0.1/serverless_registry_model/5.design_principles.md +0 -3
  61. package/spec/zh/0.0.1/serverless_registry_model/readme.md +0 -12
  62. package/spec/zh/0.0.1/serverless_user_model/1.purpose_and_goals.md +0 -3
  63. package/spec/zh/0.0.1/serverless_user_model/2.overview_and_terminology.md +0 -16
  64. package/spec/zh/0.0.1/serverless_user_model/3.user_model.md +0 -218
  65. package/spec/zh/0.0.1/serverless_user_model/4.application_scopes.md +0 -4
  66. package/spec/zh/0.0.1/serverless_user_model/5.design_principles.md +0 -3
  67. package/spec/zh/0.0.1/serverless_user_model/readme.md +0 -12
  68. package/test/ci.sh +0 -33
  69. package/test/cli/cli-manager.test.ts +0 -64
  70. package/test/config/get.test.ts +0 -12
  71. package/test/helloworld.test.ts +0 -7
  72. package/test/start-fc-http-nodejs12/code/index.js +0 -47
  73. package/test/start-fc-http-nodejs12/s.yaml +0 -38
  74. package/test/utils/index.test.ts +0 -8
  75. package/test/utils/storage.test.ts +0 -19
  76. package/tsconfig.json +0 -37
package/docs/readme.md DELETED
@@ -1,100 +0,0 @@
1
- <div align=center> <img src="https://images.devsapp.cn/devs-github/logo.jpg" width="100%"/> </div>
2
- <br>
3
- <p align="center">
4
- <a href="https://www.npmjs.com/package/@serverless-devs/s">
5
- <img src="https://img.shields.io/npm/v/@serverless-devs/s" alt="npm version">
6
- </a>
7
- <a href="https://www.npmjs.com/package/@serverless-devs/s">
8
- <img src="https://img.shields.io/npm/dy/@serverless-devs/s" alt="npm download">
9
- </a>
10
- <a href="https://nodejs.org/en/">
11
- <img src="https://img.shields.io/badge/node-%3E%3D%2010.8.0-brightgreen" alt="node.js version">
12
- </a>
13
- <a href="https://github.com/Serverless-Devs/Serverless-Devs/blob/master/LICENSE">
14
- <img src="https://img.shields.io/badge/License-MIT-green" alt="license">
15
- </a>
16
- <a href="https://github.com/Serverless-Devs/Serverless-Devs/issues">
17
- <img src="https://img.shields.io/github/issues/serverless-devs/serverless-devs" alt="issues">
18
- </a>
19
- <a href="https://github.com/Serverless-Devs/Serverless-Devs/discussions">
20
- <img src="https://img.shields.io/github/discussions/serverless-devs/serverless-devs" alt="discussions">
21
- </a>
22
- </p>
23
-
24
- <p align="center">
25
- <span><b>Serverless 应用全生命周期管理工具</b></span><br>
26
- </p>
27
-
28
- **Serverless Devs** 是一个开源开放的 Serverless 开发者平台,致力于为开发者提供强大的工具链体系。通过该平台,开发者不仅可以一键体验多云 Serverless 产品,极速部署 Serverless 项目,还可以在 Serverless 应用全生命周期进行项目的管理,并且非常简单快速的将 Serverless Devs 与其他工具/平台进行结合,进一步提升研发、运维效能。
29
-
30
- ![图片alt](https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635319587379_20211027072627561648.png)
31
-
32
- > 更多关于 Serverless Devs 的介绍可以参考[项目介绍文档](./zh/readme.md)
33
-
34
- # 快速上手
35
-
36
- ❶ 安装 Node.js(>=10.8.0) 与 NPM 包管理工具;
37
- ❷ 安装 Serverless Devs 开发者工具;
38
- ```shell script
39
- $ npm install @serverless-devs/s -g
40
- ```
41
- ❸ 在命令行中执行命令`s`,并按回车,开启你的 Serverless 之旅;
42
-
43
- > 更多详细信息可以参考[Serverless Devs 安装文档](./zh/install.md)和[快速入门指南](./zh/quick_start.md)
44
-
45
- # 帮助文档
46
-
47
- - [安装文档](zh/install.md)
48
- - [命令行操作](zh/command/readme.md)
49
- - [Yaml规范](zh/yaml.md)
50
- - [CI/CD平台集成](zh/cicd.md)
51
-
52
- > 如果您想为 Serverless Devs 贡献 Package(包括组件和应用),您可以参考 [Package开发文档](zh/package_dev.md)
53
-
54
- > Serverless Devs 天然支持 Yaml 模式与 Cli 模式,关于两者的区别和试用场景,可以参考文档[ **Yaml 模式 Cli 模式对比**](./zh/yaml_and_cli.md);关于[**Exit Code 定义**](./zh/tool.md#exit-code-定义)、[**Yaml 文件优先级规范**](./zh/tool.md#yaml-文件优先级规范)、[**密钥使用顺序与规范**](./zh/tool.md#密钥使用顺序与规范)、[**通过环境变量设置密钥**](./zh/tool.md#通过环境变量设置密钥)更多关于项目设计的一些细节可以参考[**开发者工具设计文档**](./zh/tool.md)
55
-
56
- # 相关资源
57
-
58
- 目前 Serverless Devs 项目已经支持的 FaaS 平台/产品:
59
-
60
- - 阿里云函数计算(FC): [项目仓库](https://github.com/devsapp/fc)
61
- - AWS Lambda: [项目仓库](https://github.com/devscomp/lambda)
62
- - 百度智能云函数计算(CFC): [项目仓库](https://github.com/xinwuyun/cfc)
63
- - 华为云函数工作流(FG): [项目仓库](https://github.com/xinwuyun/fg)
64
- - 腾讯云云函数(SCF): [项目仓库](https://github.com/devscomp/scf)
65
-
66
- > 尽管以上 FaaS 平台/产品已经有人贡献或在持续维护中,但是我们仍然非常欢迎大家可以参与贡献/维护,除此之外,其他的 FaaS 平台/产品(例如 Google Cloud Platform Functions、Azure Functions等),我们也非常期望社区的小伙伴们可以参与开发和贡献。
67
-
68
- > 🚀 除此之外 Serverless Devs 项目还拥有很多优秀的组件和应用,可以参考[Awesome](./zh/awesome.md)
69
-
70
- # 项目期望
71
-
72
- - Serverless Devs 希望可以为 Serverless 开发者们提供一款可以无厂商锁定的,可以在 Serverless 应用全生命周期发挥作用的 Serverless 开发者工具;
73
- - Serverless Registry 希望可以为 Serverless 生态提供一套完整的包管理规范,与 Python 中的 pypi, Nodejs 中的 npm 等类似,将以此来开放和分享 Serverless Package,建设 Serverless 生态;
74
- - Serverless Developer Meetup 希望可以打造最符合 Serverless 开发者的社区活动,通过这个活动,我们希望更多人可以一起和我们交流、学习 Serverless 相关的产品;
75
-
76
- # 项目贡献
77
-
78
- 我们非常希望您可以和我们一起贡献这个项目。贡献内容包括不限于代码的维护、应用/组件的贡献、文档的完善等,更多详情可以参考[ 🏆 贡献指南](../CONTRIBUTING.md)。
79
-
80
- 与此同时,我们也非常感谢所有[ 👬 参与贡献的小伙伴](../CONTRIBUTORS.md),为 Serverless Devs 项目贡献的努力和汗水。
81
-
82
- # 开源许可
83
-
84
- Serverless Devs 遵循 [MIT License](../LICENSE) 开源许可。
85
-
86
- 位于`node_modules`和外部目录中的所有文件都是本软件使用的外部维护库,具有自己的许可证;我们建议您阅读它们,因为它们的条款可能与[MIT License](../LICENSE)的条款不同。
87
-
88
- # 交流社区
89
-
90
- <p align="center">
91
-
92
- | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407298906_20211028074819117230.png" width="200px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407044136_20211028074404326599.png" width="200px" > | <img src="https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635407252200_20211028074732517533.png" width="200px" > |
93
- |--- | --- | --- |
94
- | <center>关注微信公众号:`serverless`</center> | <center>联系微信小助手:`xiaojiangwh`</center> | <center>加入钉钉交流群:`33947367`</center> |
95
-
96
- </p>
97
-
98
- -----------
99
-
100
- > Serverless Devs 开发者工具遵循 [Serverless Devs Model](../spec/readme.md),更多模型/规范信息可以参考 [Serverless Registry Model](../spec/zh/0.0.1/serverless_registry_model/readme.md),[Serverless User Model](../spec/zh/0.0.1/serverless_user_model/readme.md) 以及 [Serverless Package Model](../spec/zh/0.0.1/serverless_pacakge_model/readme.md);
@@ -1,20 +0,0 @@
1
- # Awesome
2
-
3
- ## 组件集合
4
-
5
- - [阿里云函数计算(FC)](https://github.com/devsapp/fc)
6
- - [阿里云Serverless应用引擎(FC)](https://github.com/devsapp/sae)
7
- - [AWS Lambda](https://github.com/devscomp/lambda)
8
- - [百度智能云函数计算(CFC)](https://github.com/xinwuyun/cfc)
9
- - [华为云函数工作流(FG)](https://github.com/xinwuyun/fg)
10
- - [腾讯云云函数(SCF)](https://github.com/devscomp/scf)
11
-
12
- ## 应用集合
13
-
14
- - [阿里云相关应用合集](https://github.com/devsapp/awesome)
15
- - [AWS Lambda](https://github.com/devscomp/start-lambda)
16
- - [百度智能云函数计算(CFC)](https://github.com/xinwuyun/start-cfc)
17
- - [华为云函数工作流(FG)](https://github.com/xinwuyun/start-fg)
18
- - [腾讯云云函数(SCF)](https://github.com/devscomp/start-scf)
19
-
20
- > 如果您有相关的案例,欢迎您提PR到本文件。
package/docs/zh/cicd.md DELETED
@@ -1,231 +0,0 @@
1
- # 与 CI/CD 平台/工具集成
2
-
3
- - [与 Github Action 的集成](#与-github-action-的集成)
4
- - [与 Gitee Go 的集成](#与-gitee-go-的集成)
5
- - [与 Jenkins 的集成](#与-jenkins-的集成)
6
- - [与云效的集成](#与云效的集成)
7
- - [注意事项](#注意事项)
8
-
9
- ## 与 Github Action 的集成
10
-
11
- 在 Github Action 的 Yaml 文件中,可以增加 Serverless Devs 的相关下载、配置以及命令执行相关能力。
12
-
13
- 例如,在仓库中可以创建该文件`.github/workflows/publish.yml`,文件内容:
14
-
15
- ```yaml
16
- name: Serverless Devs Project CI/CD
17
-
18
- on:
19
- push:
20
- branches: [ master ]
21
-
22
- jobs:
23
- serverless-devs-cd:
24
- runs-on: ubuntu-latest
25
- steps:
26
- - uses: actions/checkout@v2
27
- - uses: actions/setup-node@v2
28
- with:
29
- node-version: 12
30
- registry-url: https://registry.npmjs.org/
31
- - run: npm install
32
- - run: npm install -g @serverless-devs/s
33
- - run: s config add --AccountID ${{secrets.AccountID}} --AccessKeyID ${{secrets.AccessKeyID}} --AccessKeySecret ${{secrets.AccessKeySecret}} -a default
34
- - run: s deploy
35
- ```
36
-
37
- 主要包括几个部分的内容:
38
- - `run: npm install -g @serverless-devs/s`:
39
- 通过NPM安装最新版本的 Serverless Devs 开发者工具;
40
- - `run: s config add --AccountID ${{secrets.AccountID}} --AccessKeyID ${{secrets.AccessKeyID}} --AccessKeySecret ${{secrets.AccessKeySecret}} -a default`
41
- 通过`config`命令进行密钥等信息的配置;
42
- - `run: s deploy`
43
- 执行某些命令,例如通过`deploy`进行项目的部署,或者`build`等命令进行构建等;
44
-
45
- 关于密钥的配置:密钥信息的获取是通过`${{secrets.*}}`进行获取的,所以此时,需要将所需要的密钥和对应的`Key`配置到 Github Secrets 中,例如在上面的案例中,需要`AccountID`,`AccessKeyID`,`AccessKeySecret`等三个密钥的 Key ,我们就可以配置相关的内容:
46
-
47
- 1. 将密钥信息配置到Github Secrets中
48
- ![](https://user-images.githubusercontent.com/21079031/120761131-71f28080-c547-11eb-9bb8-e08dafabb4ee.png)
49
-
50
- 2. 我们创建多对密钥信息:
51
- ![](https://user-images.githubusercontent.com/21079031/120761249-93ec0300-c547-11eb-9c0d-904fb85b4201.png)
52
- 例如,我此处配置了三对密钥:
53
- ![](https://user-images.githubusercontent.com/21079031/120761347-ae25e100-c547-11eb-9bcd-4fc742671bc5.png)
54
-
55
- > 关于密钥配置的部分注意内容,可以参考文末的[注意事项](#注意事项)
56
-
57
- ## 与 Gitee Go 的集成
58
-
59
- 在开启 Gitee Go 的服务之后,在流水线的 Yaml 文件中,可以增加 Serverless Devs 的相关下载、配置以及命令执行相关能力。
60
-
61
- 例如,在仓库中可以创建该文件`.github/workflows/publish.yml`,文件内容:
62
-
63
- ```yaml
64
- name: serverless-devs
65
- displayName: 'Serverless Devs Project CI/CD'
66
- triggers: # 流水线触发器配置
67
- push: # 设置 master 分支 在产生代码 push 时精确触发(PRECISE)构建
68
- - matchType: PRECISE
69
- branch: master
70
- commitMessage: '' # 通过匹配当前提交的 CommitMessage 决定是否执行流水线
71
- stages: # 构建阶段配置
72
- - stage: # 定义一个 ID 标识为 deploy-stage ,名为「 Deploy Stage 」的阶段
73
- name: deploy-stage
74
- displayName: 'Deploy Stage'
75
- failFast: false # 允许快速失败,即当 Stage 中有任务失败时,直接结束整个 Stage
76
-
77
- steps: # 构建步骤配置
78
- - step: npmbuild@1 # 采用 npm 编译环境
79
- name: deploy-step # 定义一个 ID 标识为 deploy-step ,名为「 Deploy Step 」的阶段
80
- displayName: 'Deploy Step'
81
- inputs: # 构建输入参数设定
82
- nodeVersion: 14.15 # 指定 node 环境版本为 14.15
83
- goals: | # 安装依赖,配置相关主题、部署参数并发布部署
84
- node -v
85
- npm -v
86
- npm install -g @serverless-devs/s
87
- s config add --AccountID $ACCOUNTID --AccessKeyID $ACCESSKEYID --AccessKeySecret $ACCESSKEYSECRET -a default
88
- s deploy
89
- ```
90
-
91
- 主要包括几个部分的内容:
92
- - `npm install -g @serverless-devs/s`:
93
- 通过NPM安装最新版本的 Serverless Devs 开发者工具;
94
- - `s config add --AccountID $ACCOUNTID --AccessKeyID $ACCESSKEYID --AccessKeySecret $ACCESSKEYSECRET -a default`
95
- 通过`config`命令进行密钥等信息的配置;
96
- - `s deploy`
97
- 执行某些命令,例如通过`deploy`进行项目的部署,或者`build`等命令进行构建等;
98
-
99
- 关于密钥的配置:密钥信息的获取是通过`$*`进行获取的,所以此时,需要将所需要的密钥和对应的`Key`配置到 Gitee 的环境变量管理即可,例如在上面的案例中,需要`ACCOUNTID`,`ACCESSKEYID`,`ACCESSKEYSECRET`等三个密钥的 Key ,我们就可以配置相关的内容:
100
-
101
- 1. 找到 Gitee 的环境变量管理
102
- ![](https://user-images.githubusercontent.com/21079031/124716639-e5b4ee00-df36-11eb-9dc8-cf2d8eb30e51.png)
103
-
104
- 2. 我们创建多对密钥信息:
105
- ![](https://user-images.githubusercontent.com/21079031/124719394-aa67ee80-df39-11eb-84ad-944ccf0486ba.png)
106
- 例如,我此处配置了三对密钥:
107
- ![](https://user-images.githubusercontent.com/21079031/124719496-c9ff1700-df39-11eb-8ef6-4ccae28caefc.png)
108
-
109
- > 关于密钥配置的部分注意内容,可以参考文末的[注意事项](#注意事项)
110
-
111
-
112
- ## 与 Jenkins 的集成
113
-
114
- 在准备将 Serverless Devs 集成到 Jenkins 之前,需要先基于 [Jenkins 官网](https://www.jenkins.io/zh/doc/pipeline/tour/getting-started/) 安装并运行 Jenkins。
115
-
116
- 本地启动 Jenkins 后,通过浏览器进入链接 `http://localhost:8080` 配置完成基础设置后,需要新增 Credentials 设置,如下图所示:
117
-
118
- ![](https://img.alicdn.com/imgextra/i2/O1CN01tSgoo71Ne62AMGxqh_!!6000000001594-2-tps-3582-1048.png)
119
-
120
- 此时可以根据需要,增加密钥信息,以阿里云为例,新增三个全局凭据:
121
-
122
- ```
123
- jenkins-alicloud-account-id : 阿里云 accountId
124
-
125
- jenkins-alicloud-access-key-id : 阿里云 accessKeyId
126
-
127
- jenkins-alicloud-access-key-secret : 阿里云 accessKeySecret
128
- ```
129
-
130
- > 新增 Credentials 的教程可以参考[这里](https://www.jenkins.io/zh/doc/book/using/using-credentials/)。
131
-
132
- 此时,可以对自身的 Serverless Devs 项目进行完善:
133
-
134
- - 创建文件`Jenkinsfile`
135
- ```
136
- pipeline {
137
- agent {
138
- docker {
139
- image 'maven:3.3-jdk-8'
140
- }
141
- }
142
-
143
- environment {
144
- ALICLOUD_ACCESS = 'default'
145
- ALICLOUD_ACCOUNT_ID = credentials('jenkins-alicloud-account-id')
146
- ALICLOUD_ACCESS_KEY_ID = credentials('jenkins-alicloud-access-key-id')
147
- ALICLOUD_ACCESS_KEY_SECRET = credentials('jenkins-alicloud-access-key-secret')
148
- }
149
-
150
- stages {
151
- stage('Setup') {
152
- steps {
153
- sh 'scripts/setup.sh'
154
- }
155
- }
156
- }
157
- }
158
- ```
159
- 主要的内容包括两个部分:
160
- - environment 部分,主要是根据上面步骤配置的密钥信息,进行密钥的处理;
161
- - stages 部分,这里面会有一个部分是`sh 'scripts/setup.sh'`,即运行`scripts/setup.sh`文件,进行相关内容的准备和配置;
162
- - 准备`scripts/setup.sh`文件,只需要在项目下,创建该文件即可:
163
- ```shell script
164
- #!/usr/bin/env bash
165
-
166
- echo $(pwd)
167
- curl -o- -L http://cli.so/install.sh | bash
168
-
169
- source ~/.bashrc
170
-
171
- echo $ALICLOUD_ACCOUNT_ID
172
- s config add --AccountID $ALICLOUD_ACCOUNT_ID --AccessKeyID $ALICLOUD_ACCESS_KEY_ID --AccessKeySecret $ALICLOUD_ACCESS_KEY_SECRET -a $ALICLOUD_ACCESS
173
-
174
- (cd code && mvn package && echo $(pwd))
175
-
176
- s deploy -y --use-local --access $ALICLOUD_ACCESS
177
- ```
178
- 在该文件中,主要包括了几个部分:
179
- - `curl -o- -L http://cli.so/install.sh | bash`
180
- 下载并安装 Serverless Devs 开发者工具
181
- - `s config add --AccountID $ALICLOUD_ACCOUNT_ID --AccessKeyID $ALICLOUD_ACCESS_KEY_ID --AccessKeySecret $ALICLOUD_ACCESS_KEY_SECRET -a $ALICLOUD_ACCESS`
182
- 配置密钥信息等内容
183
- - `s deploy -y --use-local --access $ALICLOUD_ACCESS`
184
- 执行某些命令,例如通过`deploy`进行项目的部署,或者`build`等命令进行构建等;
185
-
186
-
187
- 完成密钥配置之后,可以创建一个 Jenkins 流水线,该流水线的源是目标 github 地址。接下来,就可以开始运行 Jenkins 流水线,运行结束后,就可以得到相关的内容结果。
188
-
189
- > 关于密钥配置的部分注意内容,可以参考文末的[注意事项](#注意事项)
190
-
191
-
192
- ## 与云效的集成
193
-
194
- 在云效中,可以直接选择Serverless Devs开发者工具,并在自定义命令中,输入以下内容即可:
195
-
196
- ```
197
- # input your command here
198
- npm install -g @serverless-devs/s
199
- s config add --AccountID ${ACCOUNTID} --AccessKeyID ${ACCESSKEYID} --AccessKeySecret ${ACCESSKEYSECRET} -a default
200
- s deploy
201
- ```
202
-
203
- 这里主要包括三个部分:
204
-
205
- - `npm install -g @serverless-devs/s`:
206
- 通过NPM安装最新版本的 Serverless Devs 开发者工具(虽然云效中已经拥有了相关版本的Serverless Devs,但是实际上,这个版本可能比较老旧,所以可以通过该命令安装最新版本);
207
- - `s config add --AccountID ${ACCOUNTID} --AccessKeyID ${ACCESSKEYID} --AccessKeySecret ${ACCESSKEYSECRET} -a default`
208
- 通过`config`命令进行密钥等信息的配置;
209
- - `s deploy`
210
- 执行某些命令,例如通过`deploy`进行项目的部署,或者`build`等命令进行构建等;
211
-
212
- 效果如下:
213
-
214
- ![image](https://user-images.githubusercontent.com/21079031/144697943-2ce9ea56-7af8-4c3b-945b-6897e6d744b5.png)
215
-
216
- 由于在命令中,引用了三个重要的环境变量:`ACCOUNTID`, `ACCESSKEYID`, `ACCESSKEYSECRET`,所以还需要在环境变量中,增加类似的内容:
217
-
218
- ![image](https://user-images.githubusercontent.com/21079031/144699074-3dad63d7-835f-4eb8-bd95-662de683dbbc.png)
219
-
220
-
221
-
222
- ## 注意事项
223
-
224
- - 在配置密钥的时候,使用了`s config add`命令,此时在最后有一个参数是`-a default`,代表的是给该密钥一个叫`default`的别名,这个别名要和项目所设定的使用密钥保持一致,例如在`s.yaml`中的`access`字段;
225
- - 如果在当前应用在,涉及到了配置部署到不同的平台或者账号下,可能会涉及到配置多个密钥信息,此时需要给不同的密钥不同的别名,并且在`s.yaml`中进行使用;
226
- - 如果想要配置更为灵活的密钥信息,可以考虑通过`-il`和`-kl`参数获取,例如同时配置两对密钥,并且使用自定义 Key :
227
- ```yaml
228
- s config add -kl tempToken1,tempToken2 -il tempValue1,tempValue2 -a website_access
229
- s config add -kl tempToken3,tempToken4 -il tempValue3,tempValue4 -a fc_access
230
- ```
231
-
@@ -1,100 +0,0 @@
1
- # 命令行设计规范
2
-
3
- Serverless Devs 作为 Serverless 领域的开发者工具,其输出的标准化和规范化会在一定程度上对用户体验有比较明显的影响。
4
-
5
- 本文档将会通过一些文字和案例,对Serverless Devs的命令行工具输出,进行规范化升级。
6
-
7
- ## 规范详情
8
-
9
- 输出格式的规范目标是:
10
-
11
- - 更清晰
12
- - 更简约
13
- - 不影响功能实用
14
-
15
- 基于以上三个原则,我们可以通过正常输出的形式、异常输出的形式等分别进行举例说明
16
-
17
- ### 基本输出
18
-
19
- 基本输出的形式,整体上包括两个部分:
20
-
21
- 1. 项目执行阶段
22
-
23
- 项目执行阶段主要包括一个基本格式:
24
-
25
- ```
26
- ⌛ Steps for process
27
- ====================
28
- ```
29
-
30
- 采用重写机制,不断的更新输出内容,每个项目执行完成可以输出相对应的结果,示例:
31
-
32
- ```
33
- ⌛ Steps for process
34
- ====================
35
- ✔ Pre-action completed (10s)
36
- ```
37
-
38
- 2. 结果输出阶段
39
-
40
- 项目执行阶段主要包括一个基本格式:
41
-
42
- ```
43
- 🚀 Result for process
44
- ====================
45
- ```
46
-
47
- 具体的项目输出采用`Yaml`的格式进行输出,输出时,项目名称要加下划线,如果没有输出则直接结束项目,示例:
48
-
49
- ```
50
- 🚀 Result for process
51
- ====================
52
- ✔ MyProject deployed (11s)
53
- fc-deploy-test:
54
- region: cn-hangzhou
55
- service:
56
- name: fc-deploy-service
57
- memorySize: 128
58
- ```
59
-
60
- #### 单项目输出示例
61
-
62
- ![render1629447409205](https://user-images.githubusercontent.com/21079031/130204631-174a5af5-5550-4e7f-bc3b-d6d23681ce61.gif)
63
-
64
-
65
- #### 多项目输出示例
66
-
67
- ![render1629448703505](https://user-images.githubusercontent.com/21079031/130206222-8674550e-2ecf-4e19-9dac-d81a8ab11b02.gif)
68
-
69
-
70
- ### 调试模式
71
-
72
- 当用户使用`--debug`进入到调试模式,则会打印非常详细的信息在控制台,但是这些信息将会以灰色形式打印出来,以保持整体的层次感:
73
-
74
- ![render1629448900851](https://user-images.githubusercontent.com/21079031/130206327-b25c444f-d336-4dc3-8dfe-39a5329e4b13.gif)
75
-
76
-
77
-
78
- ### 错误输出
79
-
80
- 当执行出现错误时,Serverless Devs要做到感知并输出相对应的内容:
81
-
82
- ```
83
- ⌛ Steps for process
84
- ====================
85
- ✔ MyProject pre-action completed (10s)
86
- ✖ MyProject failed to deploy:
87
-
88
- Error Message:
89
- t[r] is not a function
90
-
91
- Env: darwin, node v15.14.0
92
- Docs: https://github.com/serverless-devs/docs
93
- Bugs: https://github.com/Serverless-Devs/Serverless-Devs/issues
94
- Logs: ~/demo/demo/demo/s.log
95
- ```
96
-
97
- 动态效果为:
98
-
99
- ![render1629447327225](https://user-images.githubusercontent.com/21079031/130204744-be670d4b-0c1a-4128-aafe-3e8871b3ef58.gif)
100
-
@@ -1,63 +0,0 @@
1
- # Clean 命令
2
-
3
- `clean`命令是清理 Serverless Devs 的缓存相关功能,可以通过该命令清理环境、不用的依赖包以及相关的缓存内容。
4
-
5
- - [命令解析](#命令解析)
6
- - [参数解析](#参数解析)
7
- - [操作案例](#操作案例)
8
-
9
- ## 命令解析
10
-
11
- 当我们执行`s clean -h`之后,可以进行相关帮助信息的查看:
12
-
13
- ```shell script
14
- $ s clean -h
15
- Usage: s cli [options]
16
-
17
- Clean up the cache related functions of serverless devs. You can clean up the environment, unused dependent packages and related cache contents through this command.
18
-
19
- Example:
20
- $ s clean --component fc-api
21
- $ s clean --all
22
-
23
- Tips:
24
- Get all installed component: s component
25
-
26
- 📖 Document: https://github.com/Serverless-Devs/Serverless-Devs/tree/master/docs/zh/command/clean.md
27
-
28
- Options:
29
- --all Clean up the environment
30
- --cache [dirName] Delete the <dirName> file in the cache
31
- --component [componentName] Remove component (like: fc, fc@0.0.1)
32
- -h, --help Display help for command
33
- ```
34
-
35
- ### 参数解析
36
-
37
- | 参数全称 | 参数缩写 | 是否必填 | 参数含义 |
38
- |-----|-----|-----|-----|
39
- | all | | 选填 | 清理环境 |
40
- | cache | | 选填 | 删除缓存里的的<dirName>文件 |
41
- | component | | 选填 | 删除指定的组件,可以是组件名,也可以是[组件名@版本号] |
42
-
43
- ### 操作案例
44
-
45
- 如果想要清理掉某个组件,可以通过`--component`参数与具体的组件名进行清理,例如:
46
-
47
- ```shell script
48
- $ s clean --component fc-api
49
- Component [fc-api] has been cleaned up successfully.
50
- ```
51
-
52
- 如果想要清理整体环境,可以直接通过`--all`参数进行,例如:
53
-
54
- ```shell script
55
- $ s clean --all
56
- The environment of Serverless Devs has been cleaned up successfully.
57
- ```
58
-
59
- ## 注意事项
60
-
61
- 在进行指定组件的清理时,系统会按照指定的逻辑进行组件的清理:
62
- 1. 系统先会确定当前设置的 Registry 缓存中,存在的符合条件的组件,并进行清理;
63
- 2. 系统将会对系统的最终 Registry 缓存中(Github Registry),存在的符合条件的组件,并进行清理;
@@ -1,92 +0,0 @@
1
- # Cli 命令
2
-
3
- `cli`命令是去Yaml化的命令行模式,即可以通过命令行直接使用 Serverless Devs 的组件,而不需要依赖Yaml文件。
4
-
5
- - [命令解析](#命令解析)
6
- - [常见模式](#常见模式)
7
- - [通用组件的支持](#通用组件的支持)
8
- - [特定组件的支持](#特定组件的支持)
9
-
10
- > Yaml 模式与 Cli 模式的区别和试用场景,可以参考文档[Yaml 模式 Cli 模式对比](./../yaml_and_cli.md)
11
-
12
- ## 命令解析
13
-
14
- 当我们执行`s cli -h`之后,可以进行相关帮助信息的查看:
15
-
16
- ```shell script
17
- $ s cli -h
18
- Usage: s cli [component] [method] [options]
19
-
20
- Directly use serverless devs to use components, develop and manage applications without yaml configuration.
21
-
22
- Example:
23
- $ s cli fc-api listServices
24
- $ s cli fc-api listFunctions --service-name my-service
25
- $ s cli fc-api deploy -p "{/"function/": /"function-name/"}"
26
-
27
- 📖 Document: https://github.com/Serverless-Devs/Serverless-Devs/tree/master/docs/zh/command/cli.md
28
-
29
- Options:
30
- -a, --access [aliasName] Specify the access alias name
31
- -p, --props [jsonString] The json string of props
32
- -h, --help Display help for command
33
- ```
34
-
35
- 使用方法主要是:
36
-
37
- ```shell script
38
- s cli [组件名称,例如fc,fc-api等] [组件的方法] -p/--props [该方法对应的Yaml属性(JSON字符串)] -a/--access [指定密钥信息] [其他设定]
39
- ```
40
-
41
-
42
- ## 常见模式
43
-
44
- ### 通用组件的支持
45
-
46
- 在`cli`模式下,可以通过`-p, --props [jsonString]`参数对组件进行通用的支持。
47
-
48
- 例如,某Serverless Devs应用可以通过以下`s.yaml`描述:
49
-
50
- ```yaml
51
- edition: 1.0.0
52
- access: "myaccess"
53
-
54
- services:
55
- website-starter:
56
- component: devsapp/website
57
- props:
58
- bucket: testbucket
59
- src:
60
- codeUri: ./
61
- publishDir: ./build
62
- index: index.html
63
- region: cn-hangzhou
64
- hosts:
65
- - host: auto
66
- ```
67
-
68
- 并且,可以通过`s website-starter deploy`,将`website-starter`部分进行部署。
69
-
70
- 此时,如果通过`cli`模式进行部署,可以不需要依赖上述Yaml,但是需要在命令行中,写上完整的参数信息:
71
-
72
- ```shell script
73
- s cli devsapp/website deploy -p "{\"bucket\":\"testbucket\",\"src\":{\"codeUri\":\"./\",\"publishDir\":\"./build\",\"index\":\"index.html\"},\"region\":\"cn-hangzhou\",\"hosts\":[{\"host\":\"auto\"}]}" -a myaccess
74
- ```
75
-
76
- ### 特定组件的支持
77
-
78
- 在 Serverless Devs 目前已经存在的组件中,已经有一些比较优秀且针对 Cli 模式设计的组件,例如`fc-api`组件,就是一款命令行模式优先的组件,通过该组件,可以快速的使用阿里云函数计算的一些接口,进行操作,例如:
79
-
80
- - 查看阿里云函数计算的某个地区下某个服务下的函数列表:
81
- ```shell script
82
- s cli fc-api listFunctions --service-name my-service --region cn-beijing -a myaccess
83
- ```
84
- - 通过纯命令行形式,对函数进行代码更新:
85
- ```shell script
86
- s cli fc-api updateFunction --region cn-hangzhou --serviceName fc-deploy-service --functionName http-trigger-function --code '{"zipFile":"./"}'
87
- ```
88
-
89
- 除此之外,很多组件可以即对 Yaml 模式有比较好的支持,也会在某些情况下对 纯命令行模式,进行额外优化设计,例如 `fc` 组件的线上线下资源同步操作:
90
- ```shell script
91
- s cli fc sync --region cn-shanghai --service-name myService --type config
92
- ```