Skip to content

Commit

Permalink
feat(release): add a markdown deployment breakdown during dryun
Browse files Browse the repository at this point in the history
  • Loading branch information
azlam-abdulsalam committed Aug 11, 2023
1 parent b25ab3e commit 0f7057f
Show file tree
Hide file tree
Showing 3 changed files with 12,108 additions and 16,416 deletions.
1 change: 1 addition & 0 deletions packages/sfpowerscripts-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"jsforce": "2.0.0-beta.19",
"lodash": "^4.17.21",
"markdown-table": "^2.0.0",
"markdown-table-ts": "^1.0.3",
"marked": "4.0.16",
"marked-terminal": "5.1.1",
"neverthrow": "4.2.1",
Expand Down
49 changes: 48 additions & 1 deletion packages/sfpowerscripts-cli/src/impl/deploy/DeployImpl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ArtifactFetcher, { Artifact } from '@dxatscale/sfpowerscripts.core/lib/artifacts/ArtifactFetcher';
import SFPLogger, { COLOR_ERROR, COLOR_SUCCESS, Logger, LoggerLevel } from '@dxatscale/sfp-logger';
import SFPLogger, { COLOR_ERROR, COLOR_SUCCESS, FileLogger, Logger, LoggerLevel } from '@dxatscale/sfp-logger';
import { EOL } from 'os';
import { Stage } from '../Stage';
import ProjectConfig from '@dxatscale/sfpowerscripts.core/lib/project/ProjectConfig';
Expand All @@ -24,6 +24,8 @@ import GroupConsoleLogs from '../../ui/GroupConsoleLogs';
import { ZERO_BORDER_TABLE } from '../../ui/TableConstants';
import convertBuildNumDotDelimToHyphen from '@dxatscale/sfpowerscripts.core/lib/utils/VersionNumberConverter';
import ReleaseConfig from '../release/ReleaseConfig';
import fs from 'fs-extra';
import { Align, getMarkdownTable } from 'markdown-table-ts';


const Table = require('cli-table');
Expand Down Expand Up @@ -452,10 +454,21 @@ export default class DeployImpl {
});

queue.forEach((pkg) => {

maxTable.push(processColoursForAllPackages(pkg));
});

SFPLogger.log(maxTable.toString(), LoggerLevel.INFO, this.props.logger);


//Insane Hack
//TODO: Export the value to the caller
if(this.props.isDryRun)
{
printDeploymentBreakDownInMarkdown();
}


groupSection.end();

groupSection = new GroupConsoleLogs(`Packages to be deployed`, this.props.logger).begin();
Expand Down Expand Up @@ -483,6 +496,28 @@ export default class DeployImpl {



function printDeploymentBreakDownInMarkdown() {
let tableData = {
table: {
head: [
'Package',
'Incoming Version',
isBaselinOrgModeActivated ? 'Version in baseline org' : 'Version in org',
'To be installed?',
],
body: []
},
alignment: [Align.Left, Align.Left, Align.Left,Align.Right],
};
for (const pkg of queue) {
tableData.table.body.push(getRowForMarkdownTable(pkg));
}
const table = getMarkdownTable(tableData);
const pathToDeploymentBreakDownFile = `.sfpowerscripts/logs/deployment-breakdown.md`;
fs.createFileSync(pathToDeploymentBreakDownFile);
fs.writeFileSync(pathToDeploymentBreakDownFile, table);
}

function processColoursForAllPackages(pkg) {
const pkgInfo = packagesToPackageInfo[pkg.packageName];

Expand All @@ -508,6 +543,18 @@ export default class DeployImpl {

return [packageName, versionNumber, versionInstalledInOrg, isPackageInstalled];
}


function getRowForMarkdownTable(pkg) {
const pkgInfo = packagesToPackageInfo[pkg.packageName];

let packageName = pkg.packageName;
let versionNumber = pkg.versionNumber;
let versionInstalledInOrg = pkgInfo.versionInstalledInOrg ? pkgInfo.versionInstalledInOrg : 'N/A';
let isPackageInstalled = pkgInfo.isPackageInstalled ? 'No' : 'Yes';

return [packageName, versionNumber, versionInstalledInOrg, isPackageInstalled];
}
}

private printArtifactVersions(queue: SfpPackage[], packagesToPackageInfo: { [p: string]: PackageInfo }) {
Expand Down
Loading

0 comments on commit 0f7057f

Please sign in to comment.