Skip to content

Latest commit

 

History

History
224 lines (168 loc) · 13.5 KB

package_dev.md

File metadata and controls

224 lines (168 loc) · 13.5 KB
title description position category
Package development
Serverless Devs Package development documentation
6
Overview

Package development documentation

Note:

  • By default, templates for developing Serverless Devs components and applications are integrated into Serverless Devs developer tools. Package developers can directly use the templates.
  • The development of Package must follow Serverless Package Model and conform to relevant specifications. This way, the developers can use Serverless Registry and Serverless Devs to work for future development.
  • For the best practices in developing Serverless Devs applications and components, refer to :

Component development instructions

The development of Serverless Devs components is strictly in line with the component model specification in Serverless Package Model. In the component model specification, the instructions on component model metadata and component model code specification are described.

🐵 Note: When you develop Serverless Devs components, you need the following capabilities when you develop Serverless Devs components. The capabilities include but not limited to:

The component development cases of Serverless Devs are integrated into the Serverless Devs CLI tool. You can use the CLI tool to initialize a component project that is not developed. Developers only need to run the s init command, and the following command output is returned:

🚀 Serverless Awesome: https://github.com/Serverless-Devs/package-awesome

? Hello Serverless for Cloud Vendors (Use arrow keys or type to search)
❯ Alibaba Cloud Serverless 
  AWS Cloud Serverless 
  Tencent Cloud Serverless 
  Baidu Cloud Serverless 
  Dev Template for Serverless Devs 

Select the last line Dev Template for Serverless Devs and press the Enter key. The following command output is returned:

$ s init

🚀 Serverless Awesome: https://github.com/Serverless-Devs/package-awesome

? Hello Serverless for Cloud Vendors Dev Template for Serverless Devs
? Please select an Serverless-Devs Application (Use arrow keys or type to search)
❯ Application Scaffolding 
  Component Scaffolding 

Select Component Scaffolding and press the Enter key. The project of a Serverless Devs component is initialized. You can run the following command to view the file tree:

$ find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
.
|____LICENSE
|____.signore
|____example
| |____s.yaml
|____readme.md
|____publish.yaml
|____.gitignore
|____package.json
|____tsconfig.json
|____src
| |____common
| | |____entity.ts
| | |____logger.ts
| |____index.ts

The following table describes the directories in the file tree.

Directory Description
LICENSE The default license for the project. The default license follows the Massachusetts Institute of Technology (Apache 2.0) open source protocol. We recommend that you use the default license.
.signore The file that can be ignored in your package when you publish a project. The .signore file is similar to the .npmignore file that you can use to keep the ignored file out of your package when you publish npm packages.
example The test application of the component.
publish.yaml The file that is required for the project. The file is identifiable for developers of the Serverless Devs Package.
.gitignore The file that can be ignored when the project is committed to GitHub.
package.json The package.json file of the Node.js runtime environment. The detailed position of the component handler is described in the file.
tsconfig.json The tsconfig.json file of a TypeScript project, which describes the information that is required to compile the TypeScript project.
src The directory that is used to store the source code files of users.
readme.md The description of the project version, such as the updates of the current version.

Developers can use the code in the src directory for development. By default, the initialization project is a TypeScript project. This way, developers need to run the npm run build command to compile the code into JavaScript. After the code of the project is compiled into JavaScript, developers also need to write the publish.yaml file. After the preceding operations are complete, you can commit the project to different sources. For example, if you want to commit the project to GitHub Registry, you can create a repository named Public in GitHub, store the compiled code into the repository, and then publish a version. In this case, the application is available on Serverless Devs clients.

Application development instructions

The development of Serverless Devs applications must strictly conform to the application model specification in Serverless Package Model. In the application model specification, the instructions on application model metadata are described.

The component development cases of Serverless Devs are integrated into the Serverless Devs CLI tool. You can use the CLI tool to initialize an application project that is not developed. Developers only need to run the s init command, and the following command output is returned:

🚀 Serverless Awesome: https://github.com/Serverless-Devs/package-awesome

? Hello Serverless for Cloud Vendors (Use arrow keys or type to search)
❯ Alibaba Cloud Serverless 
  AWS Cloud Serverless 
  Tencent Cloud Serverless 
  Baidu Cloud Serverless 
  Dev Template for Serverless Devs 

Select the last line Dev Template for Serverless Devs and press the Enter key. The following command output is returned:

$ s init

🚀 Serverless Awesome: https://github.com/Serverless-Devs/package-awesome

? Hello Serverless for Cloud Vendors Dev Template for Serverless Devs
? Please select an Serverless-Devs Application (Use arrow keys or type to search)
❯ Application Scaffolding 
  Component Scaffolding 

Select the Application Scaffolding and press the Enter key. The project of a Serverless Devs application is initialized. You can view the file tree by using the following command:

$ find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
.
|____readme.md
|____version.md
|____publish.yaml
|____src
| |____s.yaml
| |____index.js

The following table describes the directories in the file tree:

Directory Description
readme.md Description of the component, or help documentations.
version.md The description of the project version, such as the updates of the current version.
publish.yaml The file that is a required for the project. The file is identifiable for developers of Serverless Devs Package.
src The directory where the application is located, which needs to include s.yaml and related application code.

Developers can develop applications by using the code stored in the src directory and write the publish.yaml file for the project. After the preceding operations are complete, you can commit the project to different sources. For example, if you want to commit the project to GitHub Registry, you can create a repository named Public in GitHub, store the compiled code into the repository, and then publish a version. In this case, the application is available on Serverless Devs clients.

Plugin development instructions

The development of Serverless Devs plugin is strictly in line with the plugin model specification in Serverless Package Model. In the plugin model specification, the instructions on plugin model metadata and plugin model code specification are described.

The component development cases of Serverless Devs are integrated into the Serverless Devs CLI tool. You can use the CLI tool to initialize a plugin project that is not developed. Developers only need to run the s init command, and the following command output is returned:

🚀 Serverless Awesome: https://github.com/Serverless-Devs/package-awesome

? Hello Serverless for Cloud Vendors (Use arrow keys or type to search)
❯ Alibaba Cloud Serverless 
  AWS Cloud Serverless 
  Tencent Cloud Serverless 
  Baidu Cloud Serverless 
  Dev Template for Serverless Devs 

Select the last line Dev Template for Serverless Devs and press the Enter key. The following command output is returned:

$ s init

🚀 Serverless Awesome: https://github.com/Serverless-Devs/package-awesome

? Hello Serverless for Cloud Vendors Dev Template for Serverless Devs
? Please select an Serverless-Devs Application (Use arrow keys or type to search)
❯ Application Scaffolding 
  Component Scaffolding 
  Plugin Scaffolding 

Select Plugin Scaffolding and press the Enter key. The project of a Serverless Devs component is initialized. You can run the following command to view the file tree:

$ find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
.
|____LICENSE
|____.signore
|____example
| |____s.yaml
|____readme.md
|____publish.yaml
|____.gitignore
|____package.json
|____src
| |____common
| | |____entity.ts
| | |____logger.ts
| |____index.ts

The following table describes the directories in the file tree.

Directory Description
LICENSE The default license for the project. The default license follows the Massachusetts Institute of Technology (Apache 2.0) open source protocol. We recommend that you use the default license.
.signore The file that can be ignored in your package when you publish a project. The .signore file is similar to the .npmignore file that you can use to keep the ignored file out of your package when you publish npm packages.
example The test application of the component.
publish.yaml The file that is required for the project. The file is identifiable for developers of the Serverless Devs Package.
.gitignore The file that can be ignored when the project is committed to GitHub.
package.json The package.json file of the Node.js runtime environment. The detailed position of the plugin handler is described in the file.
src The directory that is used to store the source code files of users.
readme.md The description of the project version, such as the updates of the current version.

Developers can use the code in the src directory for development. By default, the initialization project is a TypeScript project. This way, developers need to run the npm run build command to compile the code into JavaScript. After the code of the project is compiled into JavaScript, developers also need to write the publish.yaml file. After the preceding operations are complete, you can commit the project to different sources. For example, if you want to commit the project to GitHub Registry, you can create a repository named Public in GitHub, store the compiled code into the repository, and then publish a version. In this case, the application is available on Serverless Devs clients.