Skip to content

Commit

Permalink
Update old changelog format (#8490)
Browse files Browse the repository at this point in the history
* Update old changelog format

* Update tools/js-sdk-release-tools/src/common/utils.ts

Co-authored-by: ZiWei Chen <[email protected]>

* fix

* add one more

* add link

---------

Co-authored-by: Wanpeng Li <[email protected]>
Co-authored-by: ZiWei Chen <[email protected]>
  • Loading branch information
3 people authored Jun 21, 2024
1 parent ef7f191 commit 6064947
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
10 changes: 10 additions & 0 deletions tools/js-sdk-release-tools/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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'));
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Changelog} from "../../changelog/changelogGenerator";
import { fixChangelogFormat } from "../../common/utils";

const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -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}`
}
Expand Down
6 changes: 4 additions & 2 deletions tools/js-sdk-release-tools/src/llc/utils/generateChangelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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()}
Expand Down

0 comments on commit 6064947

Please sign in to comment.