diff --git a/tools/js-sdk-release-tools/src/common/utils.ts b/tools/js-sdk-release-tools/src/common/utils.ts index 0be2cf98329..00945eda7ad 100644 --- a/tools/js-sdk-release-tools/src/common/utils.ts +++ b/tools/js-sdk-release-tools/src/common/utils.ts @@ -5,6 +5,7 @@ import fs from 'fs'; import { SDKType } from './types' import { logger } from "../utils/logger"; import { Project, ScriptTarget, SourceFile } from 'ts-morph'; +import { replaceAll } from '@ts-common/azure-js-dev-tools'; export function getClassicClientParametersPath(packageRoot: string): string { return path.join(packageRoot, 'src', 'models', 'parameters.ts'); @@ -48,4 +49,13 @@ export function getTsSourceFile(filePath: string): SourceFile | undefined { const project = new Project({ compilerOptions }); project.addSourceFileAtPath(filePath); return project.getSourceFile(filePath); +} + +// changelog policy: https://aka.ms/azsdk/guideline/changelogs +export function fixChangelogFormat(content: string) { + content = replaceAll(content, '**Features**', '### Features Added')!; + content = replaceAll(content, '**Breaking Changes**', '### Breaking Changes')!; + content = replaceAll(content, '**Bugs Fixed**', '### Bugs Fixed')!; + content = replaceAll(content, '**Other Changes**', '### Other Changes')!; + return content; } \ No newline at end of file diff --git a/tools/js-sdk-release-tools/src/hlc/utils/automaticGenerateChangeLogAndBumpVersion.ts b/tools/js-sdk-release-tools/src/hlc/utils/automaticGenerateChangeLogAndBumpVersion.ts index 059f4ace921..54af2338a9d 100644 --- a/tools/js-sdk-release-tools/src/hlc/utils/automaticGenerateChangeLogAndBumpVersion.ts +++ b/tools/js-sdk-release-tools/src/hlc/utils/automaticGenerateChangeLogAndBumpVersion.ts @@ -22,7 +22,7 @@ import { execSync } from "child_process"; import { getversionDate } from "../../utils/version"; import { ApiVersionType } from "../../common/types" import { getApiVersionType } from '../../xlc/apiVersion/apiVersionTypeExtractor' -import { getApiReviewPath, getNpmPackageName, getSDKType } from '../../common/utils'; +import { fixChangelogFormat, getApiReviewPath, getNpmPackageName, getSDKType } from '../../common/utils'; export async function generateChangelogAndBumpVersion(packageFolderPath: string) { const jsSdkRepoPath = String(shell.pwd()); @@ -66,7 +66,7 @@ export async function generateChangelogAndBumpVersion(packageFolderPath: string) const oldSDKType = getSDKType(npmPackageRoot); const newSDKType = getSDKType(packageFolderPath); const changelog: Changelog = await extractExportAndGenerateChangelog(apiMdFileNPM, apiMdFileLocal, oldSDKType, newSDKType); - let originalChangeLogContent = fs.readFileSync(path.join(packageFolderPath, 'changelog-temp', 'package', 'CHANGELOG.md'), {encoding: 'utf-8'}); + let originalChangeLogContent = fs.readFileSync(path.join(packageFolderPath, 'changelog-temp', 'package', 'CHANGELOG.md'), { encoding: 'utf-8' }); if(nextVersion){ shell.cd(path.join(packageFolderPath, 'changelog-temp')); shell.mkdir(path.join(packageFolderPath, 'changelog-temp', 'next')); @@ -88,6 +88,7 @@ export async function generateChangelogAndBumpVersion(packageFolderPath: string) if(originalChangeLogContent.includes("https://aka.ms/js-track2-quickstart")){ originalChangeLogContent=originalChangeLogContent.replace("https://aka.ms/js-track2-quickstart","https://aka.ms/azsdk/js/mgmt/quickstart"); } + originalChangeLogContent = fixChangelogFormat(originalChangeLogContent); if (!changelog.hasBreakingChange && !changelog.hasFeature) { logger.logError('Cannot generate changelog because the codes of local and npm may be the same.'); logger.log('Try to bump a fix version'); diff --git a/tools/js-sdk-release-tools/src/hlc/utils/modifyChangelogFileAndBumpVersion.ts b/tools/js-sdk-release-tools/src/hlc/utils/modifyChangelogFileAndBumpVersion.ts index 981ca9b39bb..bc95d1c2438 100644 --- a/tools/js-sdk-release-tools/src/hlc/utils/modifyChangelogFileAndBumpVersion.ts +++ b/tools/js-sdk-release-tools/src/hlc/utils/modifyChangelogFileAndBumpVersion.ts @@ -1,4 +1,5 @@ import {Changelog} from "../../changelog/changelogGenerator"; +import { fixChangelogFormat } from "../../common/utils"; const fs = require('fs'); const path = require('path'); @@ -63,7 +64,7 @@ function changeClientFile(packageFolderPath: string, packageVersion: string) { } export function makeChangesForReleasingTrack2(packageFolderPath: string, packageVersion: string, changeLog: Changelog, originalChangeLogContent: string, comparedVersion:string) { - let pacakgeVersionDetail=`## ${packageVersion} (${date})`; + let pacakgeVersionDetail = `## ${packageVersion} (${date})`; if(packageVersion.includes("beta")){ pacakgeVersionDetail +=`\nCompared with version ${comparedVersion}` } diff --git a/tools/js-sdk-release-tools/src/llc/utils/generateChangelog.ts b/tools/js-sdk-release-tools/src/llc/utils/generateChangelog.ts index f00e61addab..217f1d24ac5 100644 --- a/tools/js-sdk-release-tools/src/llc/utils/generateChangelog.ts +++ b/tools/js-sdk-release-tools/src/llc/utils/generateChangelog.ts @@ -4,7 +4,7 @@ import { NPMScope } from "@ts-common/azure-js-dev-tools"; import { logger } from "../../utils/logger"; import { getLatestStableVersion } from "../../utils/version"; import { extractExportAndGenerateChangelog } from "../../changelog/extractMetaData"; -import { getApiReviewPath, getSDKType } from "../../common/utils"; +import { fixChangelogFormat, getApiReviewPath, getSDKType } from "../../common/utils"; const shell = require('shelljs'); const todayDate = new Date(); @@ -22,7 +22,9 @@ function generateChangelogForFirstRelease(packagePath, version) { } function appendChangelog(packagePath, version, changelog) { - const originalChangeLogContent = fs.readFileSync(path.join(packagePath, 'changelog-temp', 'package', 'CHANGELOG.md'), {encoding: 'utf-8'}); + let originalChangeLogContent: string = fs.readFileSync(path.join(packagePath, 'changelog-temp', 'package', 'CHANGELOG.md'), { encoding: 'utf-8' }); + originalChangeLogContent = fixChangelogFormat(originalChangeLogContent); + const modifiedChangelogContent = `## ${version} (${date}) ${changelog.displayChangeLog()}