Skip to content

Commit

Permalink
fix(markdown): ensure markdown files have config name when multiple r…
Browse files Browse the repository at this point in the history
…eleases are handled

When multiple release defn is provided, the markdown file should not overwrite, it should provide
the data for both the release defns
  • Loading branch information
azlam-abdulsalam committed Feb 12, 2024
1 parent 5e543c5 commit e201376
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
2 changes: 2 additions & 0 deletions packages/sfp-cli/src/commands/changelog/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export default class GenerateChangelog extends SfpCommand {
this.flags.forcepush,
this.flags.branchname,
this.flags.nopush,
false,
undefined,
null
);

Expand Down
6 changes: 5 additions & 1 deletion packages/sfp-cli/src/impl/changelog/ChangelogImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default class ChangelogImpl {
private branch: string,
private nopush:boolean,
private isDryRun: boolean,
private releaseConfigName:string,
private org?: string
) {
this.org = org?.toLowerCase();
Expand Down Expand Up @@ -145,7 +146,10 @@ export default class ChangelogImpl {
if(this.isDryRun)
{
const outputHandler:FileOutputHandler = FileOutputHandler.getInstance();
outputHandler.writeOutput('release-changelog.md',marked(new ChangelogMarkdownGenerator(releaseChangelog, this.workItemUrl, 1, false,true).generate()));
if(this.releaseConfigName){
outputHandler.appendOutput('release-changelog.md',`# ReleaseConfig: ${this.releaseConfigName}`);
}
outputHandler.appendOutput('release-changelog.md',new ChangelogMarkdownGenerator(releaseChangelog, this.workItemUrl, 1, false,false).generate());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export default class ChangelogMarkdownGenerator {

if (!release.names) {
payload += `\n<a id=${release['name']}></a>\n `; // Create anchor from release hash Id
payload += `# ${release['name']}\n`;
payload += `## ${release['name']}\n`;
} else {
payload += `\n<a id=${release.hashId}></a>\n`; // Create anchor from release hash Id
payload += `# ${release.names.join(`/`)}\n `;
payload += `## ${release.names.join(`/`)}\n `;
payload += `Cumulative Release Number: <b>${release.buildNumber}</b> \n\n`;
if(release.date && !this.isForWorkItemOnlyOutput)
payload += `Matching defintion first created or deployed to an org on: ${release.date}\n `
Expand Down
2 changes: 1 addition & 1 deletion packages/sfp-cli/src/impl/deploy/DeployImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export default class DeployImpl {
}
const table = getMarkdownTable(tableData);
const outputHandler:FileOutputHandler = FileOutputHandler.getInstance();
outputHandler.writeOutput('deployment-breakdown.md',table) ;
outputHandler.appendOutput('deployment-breakdown.md',table) ;
}

function processColoursForAllPackages(pkg) {
Expand Down
7 changes: 7 additions & 0 deletions packages/sfp-cli/src/impl/release/ReleaseImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import SfpPackage from '../../core/package/SfpPackage';
import SfpPackageBuilder from '../../core/package/SfpPackageBuilder';
import SfpPackageInquirer from '../../core/package/SfpPackageInquirer';
import ReleaseDefinitionSorter from './ReleaseDefinitionSorter';
import FileOutputHandler from '../../outputs/FileOutputHandler';

export interface ReleaseProps {
releaseDefinitions: ReleaseDefinition[];
Expand Down Expand Up @@ -72,6 +73,10 @@ export default class ReleaseImpl {
this.props.waitTime
);

//Clear up the deployment output
SFPLogger.log(`Clearing deployment output`, LoggerLevel.TRACE, this.logger);
FileOutputHandler.getInstance().deleteOutputFile(`deployment-breakdown.md`);
FileOutputHandler.getInstance().deleteOutputFile(`release-changelog.md`);

let deploymentResults = await this.deployArtifacts(sortedReleaseDefns);

Expand Down Expand Up @@ -126,6 +131,7 @@ export default class ReleaseImpl {
this.props.branch,
false,
this.props.isDryRun,
releaseDefinition.releaseConfigName,
this.props.targetOrg
);

Expand Down Expand Up @@ -254,6 +260,7 @@ export default class ReleaseImpl {
devhubUserName: this.props.devhubUserName,
};

FileOutputHandler.getInstance().appendOutput(`deployment-breakdown.md`,`## ReleaseConfig: ${releaseDefinition.releaseConfigName?releaseDefinition.releaseConfigName:""}\n`);
let deployImpl: DeployImpl = new DeployImpl(deployProps);

let deploymentResult = await deployImpl.exec();
Expand Down
6 changes: 6 additions & 0 deletions packages/sfp-cli/src/outputs/FileOutputHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ export default class FileOutputHandler {
fs.appendFileSync(path.join(this.containerFolder, fileName), output);
}

public deleteOutputFile(fileName: string) {
if (fs.existsSync(path.join(this.containerFolder, fileName))) {
fs.unlinkSync(path.join(this.containerFolder, fileName));
}
}

}

0 comments on commit e201376

Please sign in to comment.