Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Fix #626 Improve Create Package output to match orchestrator
Browse files Browse the repository at this point in the history
  • Loading branch information
azlam-abdulsalam committed Aug 27, 2021
1 parent 16728d7 commit 15ff1b0
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 23 deletions.
60 changes: 60 additions & 0 deletions packages/sfpowerscripts-cli/src/PackageCreateCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { COLOR_HEADER, COLOR_KEY_MESSAGE } from "@dxatscale/sfpowerscripts.core/lib/logger/SFPLogger";
import PackageMetadata from "@dxatscale/sfpowerscripts.core/lib/PackageMetadata";
import { EOL } from "os";
import SfpowerscriptsCommand from "./SfpowerscriptsCommand";

export default abstract class PackageCreateCommand extends SfpowerscriptsCommand {

protected printPackageDetails(packageMetadata: PackageMetadata) {
console.log(
COLOR_HEADER(`${EOL}${
packageMetadata.package_name
} package created in ${this.getFormattedTime(
packageMetadata.creation_details.creation_time
)}`
));
console.log(COLOR_HEADER(`-- Package Details:--`));
console.log(
COLOR_HEADER(`-- Package Version Number: `),
COLOR_KEY_MESSAGE(packageMetadata.package_version_number)
);

if (packageMetadata.package_type !== "data") {
if (packageMetadata.package_type == "unlocked") {
console.log(
COLOR_HEADER(`-- Package Version Id: `),
COLOR_KEY_MESSAGE(packageMetadata.package_version_id)
);
console.log(
COLOR_HEADER(`-- Package Test Coverage: `),
COLOR_KEY_MESSAGE(packageMetadata.test_coverage)
);
console.log(
COLOR_HEADER(`-- Package Coverage Check Passed: `),
COLOR_KEY_MESSAGE(packageMetadata.has_passed_coverage_check)
);
}

console.log(
COLOR_HEADER(`-- Apex In Package: `),
COLOR_KEY_MESSAGE(packageMetadata.isApexFound ? "Yes" : "No")
);
console.log(
COLOR_HEADER(`-- Profiles In Package: `),
COLOR_KEY_MESSAGE(packageMetadata.isProfilesFound ? "Yes" : "No")
);
console.log(
COLOR_HEADER(`-- Metadata Count: `),
COLOR_KEY_MESSAGE(packageMetadata.metadataCount)
);
}
}

protected getFormattedTime(milliseconds: number): string {
let date = new Date(0);
date.setSeconds(milliseconds / 1000); // specify value for SECONDS here
let timeString = date.toISOString().substr(11, 8);
return timeString;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import * as fs from "fs-extra";
import path = require("path");
import ProjectConfig from '@dxatscale/sfpowerscripts.core/lib/project/ProjectConfig';
import CreateDataPackageImpl from '@dxatscale/sfpowerscripts.core/lib/sfpcommands/package/CreateDataPackageImpl';
import { ConsoleLogger } from '@dxatscale/sfpowerscripts.core/lib/logger/SFPLogger';
import { COLOR_SUCCESS, ConsoleLogger } from '@dxatscale/sfpowerscripts.core/lib/logger/SFPLogger';
import PackageCreateCommand from '../../../../PackageCreateCommand';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@dxatscale/sfpowerscripts', 'create_data_package');

export default class CreateDataPackage extends SfpowerscriptsCommand {
export default class CreateDataPackage extends PackageCreateCommand {

public static description = messages.getMessage('commandDescription');

Expand Down Expand Up @@ -123,6 +124,10 @@ export default class CreateDataPackage extends SfpowerscriptsCommand {
);
packageMetadata = await createDataPackageImpl.exec();


console.log(COLOR_SUCCESS(`Created data package ${packageMetadata.package_name}`));
this.printPackageDetails(packageMetadata);

if (this.flags.gittag) {
exec(`git config --global user.email "sfpowerscripts@dxscale"`);
exec(`git config --global user.name "sfpowerscripts"`);
Expand All @@ -134,7 +139,7 @@ export default class CreateDataPackage extends SfpowerscriptsCommand {
packageMetadata.tag = tagname;
}

console.log(JSON.stringify(packageMetadata));



//Generate Artifact
Expand All @@ -145,8 +150,7 @@ export default class CreateDataPackage extends SfpowerscriptsCommand {
packageMetadata
);

console.log(`Created data package ${path.basename(artifactFilepath)}`);




console.log("\nOutput variables:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { exec } from "shelljs";
import * as fs from "fs-extra"
import path = require("path");
import CreateSourcePackageImpl from '@dxatscale/sfpowerscripts.core/lib/sfpcommands/package/CreateSourcePackageImpl';
import { ConsoleLogger } from '@dxatscale/sfpowerscripts.core/lib/logger/SFPLogger';
import { COLOR_SUCCESS, ConsoleLogger } from '@dxatscale/sfpowerscripts.core/lib/logger/SFPLogger';
import PackageCreateCommand from '../../../../PackageCreateCommand';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@dxatscale/sfpowerscripts', 'create_source_package');

export default class CreateSourcePackage extends SfpowerscriptsCommand {
export default class CreateSourcePackage extends PackageCreateCommand {

public static description = messages.getMessage('commandDescription');

Expand Down Expand Up @@ -122,6 +123,10 @@ export default class CreateSourcePackage extends SfpowerscriptsCommand {
);
packageMetadata = await createSourcePackageImpl.exec();

console.log(COLOR_SUCCESS(`Created source package ${packageMetadata.package_name}`));
this.printPackageDetails(packageMetadata);


if (this.flags.gittag) {
exec(`git config --global user.email "sfpowerscripts@dxscale"`);
exec(`git config --global user.name "sfpowerscripts"`);
Expand All @@ -132,12 +137,7 @@ export default class CreateSourcePackage extends SfpowerscriptsCommand {
packageMetadata.tag = tagname;
}

console.log(JSON.stringify(packageMetadata, function(key, val) {
if (key !== "payload")
return val;
}));



//Generate Artifact
let artifactFilepath: string = await ArtifactGenerator.generateArtifact(
sfdx_package,
Expand All @@ -146,8 +146,7 @@ export default class CreateSourcePackage extends SfpowerscriptsCommand {
packageMetadata
);

console.log(`Created source package ${path.basename(artifactFilepath)}`);



console.log("\nOutput variables:");
if (refname != null) {
Expand All @@ -168,4 +167,6 @@ export default class CreateSourcePackage extends SfpowerscriptsCommand {
process.exit(1);
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { exec } from "shelljs";
import * as fs from "fs-extra"
import path = require("path");
import CreateUnlockedPackageImpl from "@dxatscale/sfpowerscripts.core/lib/sfpcommands/package/CreateUnlockedPackageImpl";
import { ConsoleLogger } from "@dxatscale/sfpowerscripts.core/lib/logger/SFPLogger";
import { COLOR_HEADER, COLOR_KEY_MESSAGE, COLOR_SUCCESS, ConsoleLogger } from "@dxatscale/sfpowerscripts.core/lib/logger/SFPLogger";
import { EOL } from "os";
import PackageCreateCommand from "../../../../PackageCreateCommand";

// Initialize Messages with the current plugin directory
Messages.importMessagesDirectory(__dirname);
Expand All @@ -20,7 +22,7 @@ const messages = Messages.loadMessages(
"create_unlocked_package"
);

export default class CreateUnlockedPackage extends SfpowerscriptsCommand {
export default class CreateUnlockedPackage extends PackageCreateCommand {
public static description = messages.getMessage("commandDescription");

public static examples = [
Expand Down Expand Up @@ -212,6 +214,10 @@ export default class CreateUnlockedPackage extends SfpowerscriptsCommand {

let result = await createUnlockedPackageImpl.exec();


console.log(COLOR_SUCCESS(`Created unlocked package ${packageMetadata.package_name}`));
this.printPackageDetails(packageMetadata);

if (this.flags.gittag) {
exec(`git config --global user.email "sfpowerscripts@dxscale"`);
exec(`git config --global user.name "sfpowerscripts"`);
Expand All @@ -226,11 +232,7 @@ export default class CreateUnlockedPackage extends SfpowerscriptsCommand {
packageMetadata.tag = tagname;
}

console.log(
JSON.stringify(packageMetadata, function (key, val) {
if (key !== "payload") return val;
})
);


//Generate Artifact
let artifactFilepath: string = await ArtifactGenerator.generateArtifact(
Expand All @@ -240,7 +242,7 @@ export default class CreateUnlockedPackage extends SfpowerscriptsCommand {
packageMetadata
);

console.log(`Created unlocked package ${path.basename(artifactFilepath)}`);


console.log("\nOutput variables:");
if (refname != null) {
Expand Down Expand Up @@ -300,4 +302,6 @@ export default class CreateUnlockedPackage extends SfpowerscriptsCommand {
process.exit(1);
}
}


}

0 comments on commit 15ff1b0

Please sign in to comment.