Skip to content

Commit

Permalink
commit by Serverless devs docs 1-8-2024 11:45:32
Browse files Browse the repository at this point in the history
  • Loading branch information
serverless-devs committed Jan 8, 2024
1 parent dd8e1e1 commit 0da3761
Show file tree
Hide file tree
Showing 16 changed files with 1,142 additions and 814 deletions.
107 changes: 52 additions & 55 deletions content/en/serverless-devs/command/clean.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,68 @@
---
title: Clean command
description: 'Clean command'
position: 7
title: Clean Command
description: 'Clean Command'
position: 3
category: 'Commands'
---

# Clean command

The `clean` command can be used to clean up the cache of Serverless Devs. You can use this command to clean up the environment, dependency packages that are not used, and the cache.

- [Command-description](#Command-description)
- [Parameter description](#Parameter-description)
- [Example](#Example)
- [Precautions](#Precautions)

## Command description

After you execute the `s clean -h` command, we can view the help information:

# Clean Command
The `s clean` command is designated to clear the cache and associated functionalities within Serverless Devs. With this command, you're able to cleanse the environment, eliminate unused dependencies, and remove relevant cached data.
- [Command Overview](#command-overview)
- [Parameters](#parameters)
- [Usage Examples](#usage-examples)
- [Cautions](#cautions)
## Command Overview
To access help information, execute `s clean -h`:
```shell script
$ s clean -h
Usage: s cli [options]

Usage: s clean [options]
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.
Example:
$ s clean --component fc api
$ s clean --all
Tips:
Get all installed component: s component

Example:
$ s clean --component fc-api
$ s clean --all

Tips:
Get all installed component: s component

📖 Document: https://github.com/Serverless-Devs/Serverless-Devs/tree/master/docs/en/command/clean.md

📖 Document: https://serverless.help/t/s/clean
Options:
--all Clean up the environment
--cache [dirName] Delete the <dirName> file in the cache
--component [componentName] Remove component (like: fc, [email protected])
-h, --help Display help for command
--all Clean up the environment
--logs Clean logs
--cache [dirName] Delete the <dirName> file in the cache
--component [componentName] Remove component (like: fc, [email protected])
-h, --help Display help for command
```

### Parameter description

### Parameters
Navigate through the command's options with ease, each tailored for a specific aspect of the clean-up process:
| Parameter | Abbreviation | Required | Description |
|-----|-----|-----|-----|
| all | | No | Cleans the environment. |
| cache | | No | Deletes the <dirName> files in the cache. |
| component | | No | Deletes a component. You can use a component name or [Component name@Version]. |


### Example

If you want to clean a component, you can specify the component name in the `--component` command. For example:

| all | | Optional | Initiates a comprehensive environment clean-up |
| logs | | Optional | Targets log files for cleaning |
| cache | | Optional | Specifies and removes a <dirName> within the cache |
| component | | Optional | Deletes a particular component (e.g., fc, [email protected]) |
### Usage Examples
To purge a specific component, employ the `--component` flag alongside the name of the component:
```shell script
$ s clean --component fc-api
Component [fc-api] has been cleaned up successfully.
$ s clean --component fc api
[2023-******][INFO][s_cli] Component [fc api] has been cleaned up successfully.
```

If you want to clean up the environment, you can use the `--all` parameter. For example:

For cache removal, utilize the `--cache` option as demonstrated below:
```shell script
$ s clean --cache
[2023-******][INFO][s_cli] Cache cleaned up successfully.
```
Log file clean-up can be achieved through the `--logs` parameter:
```shell script
$ s clean --logs
[2023-******][INFO][s_cli] Logs cleaned up successfully.
```
For an all-encompassing clean-up, the `--all` parameter is at your disposal:
```shell script
$ s clean --all
The environment of Serverless Devs has been cleaned up successfully.
[2023-******][INFO][s_cli] Component cleaned up successfully.
[2023-******][INFO][s_cli] Cache cleaned up successfully.
[2023-******][INFO][s_cli] Logs cleaned up successfully.
[2023-******][INFO][s_cli] The environment of Serverless Devs has been cleaned up successfully.
```

## Precautions
When you clean up a component, the system follows the following logic:
1. First, the system checks and cleans the components that meet the condition in the Registry cache.
2. Then, the system checks and cleans the component that meets the condition in the GitHub Registry cache.
## Cautions
Please note the following protocols when executing a component-specific clean-up:
1. The system will first assess if there are any corresponding components within the current Registry cache and proceed to clear them.
2. Following that, the system will purge the ultimate Registry cache, the Github Registry, eradicating any components that match the criteria.
115 changes: 44 additions & 71 deletions content/en/serverless-devs/command/cli.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,44 @@
---
title: Cli command
description: 'Cli command'
title: Cli Command
description: 'Cli Command'
position: 4
category: 'Commands'
---

# Cli command

The `cli` command allows you to directly use Serverless Devs components in CLI mode, instead of the YAML mode.

- [Command description](#Command-description)
- [Common modes](#Common-modes)
- [Support for common components](#Support-for-common-components)
- [Support for specific components](#Support-for-specific-components)

> For more information about the differences between the YAML mode and the CLI mode, see [Compare the YAML mode with the CLI mode](./../yaml_and_cli.md)
## Command description

After you run the `s cli -h` command, the following help information is returned:

# Cli Command
The `cli` command provides a command line interface within Yamlized, allowing direct use of Serverless Devs components via the CLI without the dependence on Yaml files.
- [Command Breakdown](#command-breakdown)
- [Common Usage Patterns](#common-usage-patterns)
- [General Component Support](#general-component-support)
- [Specific Component Support](#specific-component-support)
> For insights into the differences between Yaml mode and Cli mode, as well as their respective use cases, please consult the [Yaml Mode vs. Cli Mode Comparison](./../yaml_and_cli.md) document.
## Command Breakdown
Executing `s cli -h` displays the relevant help information:
```shell script
$ s cli -h
Usage: s cli [component] [method] [options]

Directly use serverless devs to use components, develop and manage applications without yaml configuration.
Usage: s cli [options]
Utilize Serverless Devs components for application development and management without the need for yaml configuration.

Examples:
$ s cli fc api ListServices
$ s cli fc api ListFunctions --path '{"serviceName": "serviceName"}' --body '{"K1": "V1"}'

Example:
$ s cli fc-api listServices
$ s cli fc-api listFunctions --service-name my-service
$ s cli fc-api deploy -p "{/"function/": /"function-name/"}"

📖 Document: https://github.com/Serverless-Devs/Serverless-Devs/tree/master/docs/en/command/cli.md

📖 Documentation: https://serverless.help/t/s/
Options:
-a, --access [aliasName] Specify the access alias name
-p, --props [jsonString] The json string of props
-h, --help Display help for command
-p, --props <jsonString> JSON string of props
-h, --help Display help for command
```

Method:

Typical usage involves:
```shell script
s cli [The component name, such as fc or fc-api.] [The method of the component.] -p/--props [The YAML attribute (JSON string) of the method] -a/--access [The information about the specified key.] [Other settings]
s cli [component name, e.g., fc, fc api, etc.] [component method] -p/--props [Yaml property equivalent for the method (JSON string)] -a/--access [specify key info] [additional settings]
```


## Common modes

### Support for common components

In `cli` mode, you can use the `-p, --props [jsonString]` parameter to configure general support for the component.

For example, you specify the following description in the `s.yaml` of a Serverless Devs application:


## Common Usage Patterns
### General Component Support
In Cli mode, you can support components by using the `-p, --props [jsonString]` parameter.
For instance, a Serverless Devs application might be described like so:
```yaml
edition: 1.0.0
edition: 3.0.0
access: "myaccess"

services:
resources:
website-starter:
component: devsapp/website
props:
Expand All @@ -72,29 +51,23 @@ services:
hosts:
- host: auto
```
You can also use `s website-starter deploy` to deploy `website-starter`.

In this case, if you deploy website-starter in `cli` mode, the preceding YAML file is not required. However, you need to write the complete information about parameters in CLI mode. Example:

This setup's `website-starter` segment can normally be deployed with `s website-starter deploy`.
However, to deploy via `cli` mode, you bypass the Yaml file and directly input complete parameter details on the command line:
```shell script
s cli devsapp/website deploy -p "{\"bucket\":\"testbucket\",\"src\":{\"codeUri\":\"./\",\"publishDir\":\"./build\",\"index\":\"index.html\"},\"region\":\"cn-hangzhou\",\"hosts\":[{\"host\":\"auto\"}]}" -a myaccess
```

### Support for specific components

Among the existing components of Serverless Devs, some excellent components, such as the fc-api component, for CLI mode already exist. You can use this component together with Alibaba Cloud Function Compute API operations to perform specified actions:
- If you want to view functions of a service in Alibaba Cloud Function Compute in a region, run the following command:
```shell script
s cli fc-api listFunctions --service-name my-service --region cn-beijing -a myaccess
```
- You can run the following command in CLI mode to update code for functions:
```shell script
s cli fc-api updateFunction --region cn-hangzhou --serviceName fc-deploy-service --functionName http-trigger-function --code '{"zipFile":"./"}'
```

In addition, many components that use the YAML mode can deliver better performance. Under certain conditions, you can also perform additional optimization for CLI mode. For example, if you want to synchronize the on- and off-premises resources of the `fc` component, you can run the following command:

### Specific Component Support
Serverless Devs offers several well-designed components that are optimized for Cli mode. For example, the `fc api` component is prioritized for command line usage, facilitating quick interactions with certain Aliyun Function Compute (FC) service interfaces, such as:
- Listing functions within a specified service and region:
```shell script
s cli fc api listFunctions --service-name my-service --region cn-beijing -a myaccess
```
- Updating function code via the command line:
```shell script
s cli fc api updateFunction --region cn-hangzhou --serviceName fc-deploy-service --functionName http-trigger-function --code '{"zipFile":"./"}'
```
Furthermore, several components that typically support Yaml mode may also offer an optimized pure command line interface for specific operations. An example is the `fc` component, which provides commands for resource synchronization:
```shell script
s cli fc sync --region cn-shanghai --service-name myService --type config
```
s cli fc sync --region cn-shanghai --service-name myService --type config
```

73 changes: 22 additions & 51 deletions content/en/serverless-devs/command/component.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,51 @@
---
title: Component command
description: 'Component command'
position: 8
category: 'Commands'
title: Component Command
description: 'Component Command'
position: 5
category: 'Command'
---

# Component command

The `component` command is used to obtain the details of components that are installed.
`component` is used to get the details of installed components.

- [Command description](#Command-description)
- [Parameter description](#Parameter-description)
- [Command Parse](#Command-Parse)
- [Parameter](#Parameter)
- [Example](#Example)
- [Precautions](#Precautions)

## Command description
## Command Parse

After you run the `s component -h` command, the following help information is returned:
When we execute `s component -h`, we can get help information:

```shell script
$ s component -h
Usage: s component [options]

Get details of installed components.

Example:
$ s component

Example:
$ s component
$ s component --component fc-api

📖 Document: https://github.com/Serverless-Devs/Serverless-Devs/tree/master/docs/en/command/component.md
📖 Document: https://serverless.help/t/s/component

Options:
--component <componentName> Gets the specified component information (like: fc, [email protected])
-h, --help Display help for command
-h, --help Display help for command.
```

### Parameter description
### Parameter

| Parameter | Abbreviation | Required | Description |
|-----|-----|-----|-----|
| name | | No | You can obtain the specified component information, such as the component name or [Component name @Version number] |
No parameters are required.

### Example

If you want to obtain the information about a component, you can use the `--component` parameter. Example:

```shell script
$ s component --component fc-api
Component: fc
Registry: serverless registry [http://registry.devsapp.cn/simple]
Version: 0.1.27
Size: 100 MB
Description: 阿里云函数计算基础组件
Path: ~/.s/components/fc
Hompage: https://github.com/devsapp/fc

🙋 Delete the component, please use the command [s clean --component [email protected]]
```
We can execute `s component` to get all installed components, for example:

If you want to obtain the information about all installed components, run the `s component` command. Example:
```shell script
$ s component

🔎 serverless registry [http://registry.devsapp.cn/simple]
Component Description Size Version
fc 阿里云函数计算基础组件 100 MB 0.1.27
devsapp/fc 阿里云函数计算基础组件 100 MB 0.1.27
fc-api 函数计算api操作组件 100 MB 0.0.44

🔎 github registry [https://api.github.com/repos]
Component Description Size Version
fc 阿里云函数计算基础组件 100 MB 0.1.27
devsapp/fc 阿里云函数计算基础组件 100 MB 0.1.27

🔎 serverless registry [https://registry.serverless-devs.com]
Component Version Size Description
fc 0.1.27 100 MB Aliyun Function Compute Base Component
devsapp/fc 0.1.27 100 MB Aliyun Function Compute Base Component
fc api 0.0.44 100 MB Function Compute api operation component
```


## Precautions
When you query a component, the system displays the information about the current registry and the default GitHub registry. If you need to view other registries, run the `s set registry` command to switch registries.
Loading

0 comments on commit 0da3761

Please sign in to comment.