From 4cb6f4678a305c18c9400cdaf77f4619596c9ece Mon Sep 17 00:00:00 2001 From: Qiaoqiao Zhang <55688292+qiaozha@users.noreply.github.com> Date: Thu, 22 Oct 2020 11:50:04 +0800 Subject: [PATCH] split-operation-description-fix (#99) --- azure-pipelines/ci.yml | 2 +- azure-pipelines/release.yml | 2 +- package.json | 2 +- rush.json | 2 +- src/plugins/splitOperation.ts | 22 ++++++++++------------ 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/azure-pipelines/ci.yml b/azure-pipelines/ci.yml index ae7c276..892946c 100644 --- a/azure-pipelines/ci.yml +++ b/azure-pipelines/ci.yml @@ -2,7 +2,7 @@ trigger: - master variables: - NodeVersion: '12.x' + NodeVersion: '12.16.1' jobs: diff --git a/azure-pipelines/release.yml b/azure-pipelines/release.yml index e443b97..92b3550 100644 --- a/azure-pipelines/release.yml +++ b/azure-pipelines/release.yml @@ -13,7 +13,7 @@ schedules: - master variables: - NodeVersion: '12.x' + NodeVersion: '12.16.1' VAR_REPO_URL: $(Build.Repository.Uri) VAR_REPO_BRANCHNAME: $(Build.SourceBranchName) VAR_BUILD_NUMBER: $(Build.BuildNumber) diff --git a/package.json b/package.json index 863578e..53073d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@autorest/clicommon", - "version": "0.5.4", + "version": "0.5.5", "description": "Autorest Azure Cli Common Module", "main": "dist/index.js", "engines": { diff --git a/rush.json b/rush.json index afee8f0..7e6b83e 100644 --- a/rush.json +++ b/rush.json @@ -49,7 +49,7 @@ * Specify a SemVer range to ensure developers use a NodeJS version that is appropriate * for your repo. */ - "nodeSupportedVersionRange": ">=8.9.4 <11.0.0", + "nodeSupportedVersionRange": ">=8.9.4 <14.0.0", "ensureConsistentVersions": true, "projectFolderMinDepth": 1, "projectFolderMaxDepth": 2, diff --git a/src/plugins/splitOperation.ts b/src/plugins/splitOperation.ts index 5ffbaa6..9bd8f58 100644 --- a/src/plugins/splitOperation.ts +++ b/src/plugins/splitOperation.ts @@ -1,5 +1,5 @@ import { Host, Session, startSession } from "@azure-tools/autorest-extension-base"; -import { CodeModel, Operation, codeModelSchema, OperationGroup } from "@azure-tools/codemodel"; +import { CodeModel, Operation, codeModelSchema } from "@azure-tools/codemodel"; import { Helper } from "../helper"; import { CliConst, CliCommonSchema } from "../schema"; import { NodeCliHelper, NodeExtensionHelper } from "../nodeHelper"; @@ -31,7 +31,7 @@ export class SplitOperation{ // Link splitted operation to src opreation NodeExtensionHelper.setSplitOperationOriginalOperation(splittedOperation, operation); - this.updateSplitOperationDescription(splittedOperation, group); + this.updateSplitOperationDescription(splittedOperation); splittedGroupOperations.push(splittedOperation); }); @@ -43,20 +43,18 @@ export class SplitOperation{ } } - private updateSplitOperationDescription(operation: Operation, group: OperationGroup): void { + private updateSplitOperationDescription(operation: Operation): void { const create = 'Create'; const update = 'Update'; const opCliKey = NodeCliHelper.getCliKey(operation, '').toLowerCase(); - const createOrUpdate: string = opCliKey.endsWith('#create') ? create : opCliKey.endsWith('#update') ? update : null; - if (!createOrUpdate) { - return; + + if (opCliKey.endsWith("#create")) { + operation.language.default.description = operation.language.default.description.replace(/[cC]reates?( or |\/)[uU]pdates?|[uU]pdates?( or |\/)[cC]reates?/g, create); + } + + if (opCliKey.endsWith("#update")) { + operation.language.default.description = operation.language.default.description.replace(/[cC]reates?( or |\/)[uU]pdates?|[uU]pdates?( or |\/)[cC]reates?|[cC]reates?/g, update); } - - const groupCliKey = NodeCliHelper.getCliKey(group, ''); - const namingConvention: CliCommonSchema.NamingConvention = { - glossary: [] - }; - operation.language.default.description = createOrUpdate + ' ' + Helper.singularize(namingConvention, groupCliKey); } private async modifier(): Promise {