Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 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,10 @@ export function getTsSourceFile(filePath: string): SourceFile | undefined {
const project = new Project({ compilerOptions });
project.addSourceFileAtPath(filePath);
return project.getSourceFile(filePath);
}

export function fixChangelogFormat(content: string) {
content = replaceAll(content, '**Features**', '### Features')!;
content = replaceAll(content, '**Breaking Changes**', '### Breaking 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
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