Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions docs/zh/command/version.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ category: '发布&配置'

当执行命令`version -h`/`version --help`时,可以获取帮助文档。


在该命令中,包括了两个子命令:

- [list:查看版本列表](#version-list-命令)
Expand All @@ -37,11 +36,11 @@ category: '发布&配置'

### 参数解析

| 参数全称 | 参数缩写 | Yaml模式下必填 | Cli模式下必填 | 参数含义 |
| ------------ | -------- | -------------- | ------------- | ------------------------------------------------------------ |
| region | - | 选填 | 必填 | 地区,取值范围:`cn-hangzhou, cn-beijing, cn-beijing, cn-hangzhou, cn-shanghai, cn-qingdao, cn-zhangjiakou, cn-huhehaote, cn-shenzhen, cn-chengdu, cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1, eu-west-1, us-west-1, us-east-1, ap-south-1` |
| service-name | - | 选填 | 必填 | 服务名 |
| table | - | 选填 | 选填 | 是否以表格形式输出 |
| 参数全称 | 参数缩写 | Yaml 模式下必填 | Cli 模式下必填 | 参数含义 |
| ------------ | -------- | --------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| region | - | 选填 | 必填 | 地区,取值范围:`cn-hangzhou, cn-beijing, cn-beijing, cn-hangzhou, cn-shanghai, cn-qingdao, cn-zhangjiakou, cn-huhehaote, cn-shenzhen, cn-chengdu, cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1, eu-west-1, us-west-1, us-east-1, ap-south-1` |
| service-name | - | 选填 | 必填 | 服务名 |
| table | - | 选填 | 选填 | 是否以表格形式输出 |

> 当前命令还支持部分全局参数(例如`-a/--access`, `--debug`等),详情可参考 [Serverless Devs 全局参数文档](https://serverless-devs.com/serverless-devs/command/readme#全局参数)

Expand All @@ -53,8 +52,8 @@ category: '发布&配置'
上述命令的执行结果示例:

```text
fc-deploy-test:
-
fc-deploy-test:
-
versionId: 1
description: test publish version
createdTime: 2021-11-08T06:07:00Z
Expand All @@ -71,7 +70,6 @@ fc-deploy-test:
└───────────┴──────────────────────┴──────────────────────┴──────────────────────┘
```


## version publish 命令

`version publish` 命令,是用于发布版本的命令。
Expand All @@ -80,11 +78,12 @@ fc-deploy-test:

### 参数解析

| 参数全称 | 参数缩写 | Yaml模式下必填 | Cli模式下必填 | 参数含义 |
| ------------ | -------- | -------------- | ------------- | ------------------------------------------------------------ |
| region | - | 选填 | 必填 | 地区,取值范围:`cn-hangzhou, cn-beijing, cn-beijing, cn-hangzhou, cn-shanghai, cn-qingdao, cn-zhangjiakou, cn-huhehaote, cn-shenzhen, cn-chengdu, cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1, eu-west-1, us-west-1, us-east-1, ap-south-1` |
| service-name | - | 选填 | 必填 | 服务名 |
| description | - | 选填 | 选填 | 版本描述 |
| 参数全称 | 参数缩写 | Yaml 模式下必填 | Cli 模式下必填 | 参数含义 |
| --------------------- | -------- | --------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| region | - | 选填 | 必填 | 地区,取值范围:`cn-hangzhou, cn-beijing, cn-beijing, cn-hangzhou, cn-shanghai, cn-qingdao, cn-zhangjiakou, cn-huhehaote, cn-shenzhen, cn-chengdu, cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1, eu-west-1, us-west-1, us-east-1, ap-south-1` |
| service-name | - | 选填 | 必填 | 服务名 |
| description | - | 选填 | 选填 | 版本描述 |
| ignore-no-chang-error | - | 选填 | 选填 | 忽略发布版本 `No changes were made since last publish`异常 |

> 当前命令还支持部分全局参数(例如`-a/--access`, `--debug`等),详情可参考 [Serverless Devs 全局参数文档](https://serverless-devs.com/serverless-devs/command/readme#全局参数)

Expand All @@ -96,7 +95,7 @@ fc-deploy-test:
上述命令的执行结果示例:

```text
fc-deploy-test:
fc-deploy-test:
versionId: 1
description: test publish version
createdTime: 2021-11-08T06:07:00Z
Expand All @@ -111,13 +110,14 @@ fc-deploy-test:

```yaml
{
"Version": "1",
"Statement": [
{
"Action": "fc:PublishServiceVersion",
"Effect": "Allow",
"Resource": "acs:fc:<region>:<account-id>:services/<serviceName>/versions"
}
]
'Version': '1',
'Statement':
[
{
'Action': 'fc:PublishServiceVersion',
'Effect': 'Allow',
'Resource': 'acs:fc:<region>:<account-id>:services/<serviceName>/versions',
},
],
}
```
10 changes: 7 additions & 3 deletions src/lib/component/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ interface IProps {
description?: string;
versionId?: string;
assumeYes?: boolean;
ignoreNoChangError?: boolean;
}
interface Publish {
serviceName: string;
description?: string;
ignoreNoChangError?: boolean;
}
interface Remove {
serviceName: string;
Expand All @@ -38,7 +40,7 @@ export default class Version {
logger.debug(`inputs.props: ${JSON.stringify(inputs.props)}`);

const parsedArgs: { [key: string]: any } = core.commandParse(inputs, {
boolean: ['help', 'table', 'y'],
boolean: ['help', 'table', 'y', 'ignore-no-chang-error'],
string: ['region', 'service-name', 'description', 'id'],
alias: { help: 'h', 'version-id': 'id', 'assume-yes': 'y' },
});
Expand Down Expand Up @@ -70,6 +72,7 @@ export default class Version {
description: parsedData.description,
versionId: parsedData.id,
assumeYes: parsedData.y,
ignoreNoChangError: parsedData['ignore-no-chang-error'],
};

if (!endProps.region) {
Expand Down Expand Up @@ -107,9 +110,10 @@ export default class Version {
}
}

async publish({ serviceName, description }: Publish) {
async publish({ serviceName, description, ignoreNoChangError }: Publish) {
logger.info(`Creating service version: ${serviceName}`);
const { data } = await Client.fcClient.publishVersion(serviceName, description);
const headers = ignoreNoChangError ? { 'x-fc-ignore-version-publish-error': 'true' } : {};
const { data } = await Client.fcClient.publishVersion(serviceName, description, headers);
logger.debug(`publish version: ${JSON.stringify(data)}`);
return data;
}
Expand Down
5 changes: 5 additions & 0 deletions src/lib/help/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ export const VERSION_PUBLISH = [
description: '[Optional] Specify the alias description',
type: String,
},
{
name: 'ignore-no-chang-error',
description: '[Optional] Ignore no changes were made since last publish',
type: String,
},
],
},
{ ...globalParams },
Expand Down