Skip to content

Commit

Permalink
feature!: sfp-cli: Reorganize commands and topics
Browse files Browse the repository at this point in the history
- Rename `deploy` command to `install`
- Move `prepare` command to `pool` topic
- Move `promote` command to `artifacts` topic

and messaging changes to be consistent with sfp topology
  • Loading branch information
azlam-abdulsalam committed Feb 29, 2024
1 parent 554f61a commit 71bdcde
Show file tree
Hide file tree
Showing 24 changed files with 101 additions and 115 deletions.
2 changes: 1 addition & 1 deletion packages/sfp-cli/messages/build.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commandDescription": "Build artifacts of your packages in the current project",
"commandDescription": "Build artifact(s) of your packages in the current project",
"devhubAliasFlagDescription": "Provide the alias of the devhub previously authenticated, default value is HubOrg if using the Authenticate Devhub task",
"diffCheckFlagDescription": "Only build the packages which have changed by analyzing previous tags",
"repoUrlFlagDescription": "Custom source repository URL to use in artifact metadata, overrides origin URL defined in git config",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commandDescription": "Deploy artifacts from a given directory to a target org",
"commandDescription": "Installs artifact(s) from a given directory to a target org",
"targetOrgFlagDescription": "Alias/User Name of the target environment",
"artifactDirectoryFlagDescription": "The directory containing artifacts to be deployed",
"waitTimeFlagDescription": "Wait time for command to finish in minutes",
Expand Down
8 changes: 0 additions & 8 deletions packages/sfp-cli/messages/install_data_package.json

This file was deleted.

14 changes: 0 additions & 14 deletions packages/sfp-cli/messages/install_package.json

This file was deleted.

6 changes: 0 additions & 6 deletions packages/sfp-cli/messages/install_package_command.json

This file was deleted.

12 changes: 0 additions & 12 deletions packages/sfp-cli/messages/install_source_package.json

This file was deleted.

16 changes: 0 additions & 16 deletions packages/sfp-cli/messages/install_unlocked_package.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/sfp-cli/messages/quickbuild.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commandDescription": "Build artifacts of your packages in the current project without dependency validation for unlocked packages",
"commandDescription": "Build artifact(s) of your packages in the current project without dependency validation for unlocked packages",
"devhubAliasFlagDescription": "Provide the alias of the devhub previously authenticated, default value is HubOrg if using the Authenticate Devhub task",
"diffCheckFlagDescription": "Only build the packages which have changed by analyzing previous tags",
"gitTagFlagDescription": "Tag the current commit ID with an annotated tag containing the package name and version - does not push tag",
Expand Down
2 changes: 1 addition & 1 deletion packages/sfp-cli/messages/release.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commandDescription": "Deploy a release definition to a target org",
"commandDescription": "Release a set of artifact(s) as defined by a release definition into a target org",
"releaseDefinitionFlagDescription": "Path to release definiton yaml, Multiple paths can be seperated by commas",
"targetOrgFlagDescription": "Alias/User Name of the target environment",
"scriptPathFlagDescription": "(Optional: no-NPM) Path to script that authenticates and downloads artifacts from the registry",
Expand Down
29 changes: 18 additions & 11 deletions packages/sfp-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flxblio/sfp",
"description": "Flxbl Toolkit",
"description": "sfp is a CLI tool to help you manage your Salesforce projects in an artifact centric model",
"version": "36.0.7",
"license": "MIT",
"author": "flxblio",
Expand Down Expand Up @@ -106,33 +106,40 @@
"topicSeparator": " ",
"topics": {
"releasedefinition": {
"description": "Commands around release definition"
"description": "Commands around managing release defintion"
},
"pool": {
"description": "Manage the pooled orgs created by the sfp orchestrator in prepare stage"
"description": "Build and manage scratch org or sandbox pools"
},
"changelog": {
"description": "Track your artifacts & user stories as they progress through different environments, with release changelogs"
},
"impact": {
"description": "Figures out the impact of a change to various components of your project",
"artifacts": {
"description": "Manage artifacts for a project",
"external": true
},
"analyze": {
"description": "Analyze your projects using static analysis tools such as PMD",
"impact": {
"description": "Utilities to help you understand the impact of various components in sfp",
"external": true
},
"metrics": {
"description": "Report metrics to sfp supported metric providers",
"external": false
},
"apextests": {
"description": "Trigger Apex Tests and validate apex tests in a package"
"description": "Manage apex tests in a package or a org"
},
"repo": {
"description": "Commands to help with maintaing repository"
"description": "Manage your project repository"
},
"flow": {
"description": "Commands to help with management of flows"
"description": "Manage flows in your org"
},
"profile": {
"description": "Commands to manage profiles in your project or org"
},
"dependency": {
"description": "Commands to help with dependency management of a project",
"description": "Manage the dependencies of a project",
"subtopics": {
"expand": {
"description": "Expand the dependency list in sfdx-project.json file for each package, fix the gap of dependencies from its dependent packages"
Expand Down
11 changes: 11 additions & 0 deletions packages/sfp-cli/resources/schemas/sfdx-project.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@
"skipDeployOnOrgs": {
"$ref": "#/definitions/packageDirectory.skipDeployOnOrgs"
},
"skipInstallOnOrgs": {
"$ref": "#/definitions/packageDirectory.skipInstallOnOrgs"
},
"skipTesting": {
"$ref": "#/definitions/packageDirectory.skipTesting"
},
Expand Down Expand Up @@ -530,6 +533,14 @@
"type": "string"
}
},
"packageDirectory.skipInstallOnOrgs": {
"type": "array",
"title": "Skip installation of an artifact",
"description": "Skip installation of an artifact on a particular org or org(s). Take an array of aliases as the input",
"items": {
"type": "string"
}
},
"packageDirectory.skipTesting": {
"type": "boolean",
"title": "Skip Unit testing",
Expand Down
6 changes: 3 additions & 3 deletions packages/sfp-cli/src/BuildBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export default abstract class BuildBase extends SfpCommand {
SFPLogger.printHeaderLine('', COLOR_HEADER, LoggerLevel.INFO);
SFPLogger.log(
COLOR_SUCCESS(
`${buildExecResult.generatedPackages.length} packages created in ${COLOR_TIME(
`${buildExecResult.generatedPackages.length} artifacts created in ${COLOR_TIME(
getFormattedTime(totalElapsedTime)
)} minutes with ${COLOR_ERROR(buildExecResult.failedPackages.length)} errors`
)
Expand Down Expand Up @@ -271,7 +271,7 @@ export default abstract class BuildBase extends SfpCommand {
return buildProps;
function printIncludeOnlyPackages(includeOnlyPackages: string[]) {
SFPLogger.log(
COLOR_KEY_MESSAGE(`Build will include the below packages release configs (domain(s))(domain)`),
COLOR_KEY_MESSAGE(`Build will include the below packages as per the given release configs domain(s)`),
LoggerLevel.INFO
);
SFPLogger.log(COLOR_KEY_VALUE(`${includeOnlyPackages.toString()}`), LoggerLevel.INFO);
Expand All @@ -296,7 +296,7 @@ export default abstract class BuildBase extends SfpCommand {

function printIncludeOnlyPackages(includeOnlyPackages: string[]) {
SFPLogger.log(
COLOR_KEY_MESSAGE(`Build will include the below packages release configs (domain(s))(domain)`),
COLOR_KEY_MESSAGE(`Build will include the below packages as per the given release configs(domain(s))`),
LoggerLevel.INFO
);
SFPLogger.log(COLOR_KEY_VALUE(`${includeOnlyPackages.toString()}`), LoggerLevel.INFO);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import SfpCommand from '../SfpCommand';
import SfpCommand from '../../SfpCommand';
import { Messages } from '@salesforce/core';
import PromoteUnlockedPackageImpl from '../core/package/promote/PromoteUnlockedPackageImpl'
import ArtifactFetcher from '../core/artifacts/ArtifactFetcher';
import PromoteUnlockedPackageImpl from '../../core/package/promote/PromoteUnlockedPackageImpl'
import ArtifactFetcher from '../../core/artifacts/ArtifactFetcher';
import { ConsoleLogger } from '@flxblio/sfp-logger';
import SfpPackageBuilder from '../core/package/SfpPackageBuilder';
import { PackageType } from '../core/package/SfpPackage';
import SfpPackageBuilder from '../../core/package/SfpPackageBuilder';
import { PackageType } from '../../core/package/SfpPackage';
import { Flags, ux } from '@oclif/core';
import { loglevel, targetdevhubusername } from '../flags/sfdxflags';
import { loglevel, targetdevhubusername } from '../../flags/sfdxflags';
import { LoggerLevel } from '@flxblio/sfp-logger';
import { COLOR_HEADER } from '@flxblio/sfp-logger';
import SFPLogger from '@flxblio/sfp-logger';
Expand All @@ -16,6 +16,8 @@ const messages = Messages.loadMessages('@flxblio/sfp', 'promote');

export default class Promote extends SfpCommand {
public static description = messages.getMessage('commandDescription');
static aliases = ['orchestrator:promote']


public static examples = [`$ sfp promote -d path/to/artifacts -v <org>`];

Expand Down
1 change: 1 addition & 0 deletions packages/sfp-cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const messages = Messages.loadMessages('@flxblio/sfp', 'build');

export default class Build extends BuildBase {
public static description = messages.getMessage('commandDescription');
static aliases = ['orchestrator:build']

getStage() {
return Stage.BUILD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ Messages.importMessagesDirectory(__dirname);

// Load the specific messages for this file. Messages from @salesforce/command, @salesforce/core,
// or any library that is using the messages framework can also be loaded this way.
const messages = Messages.loadMessages('@flxblio/sfp', 'deploy');
const messages = Messages.loadMessages('@flxblio/sfp', 'install');

export default class Deploy extends SfpCommand {
export default class Install extends SfpCommand {
public static description = messages.getMessage('commandDescription');
static aliases = ['orchestrator:deploy',]

public static examples = [`$ sfp deploy -u <username>`];
public static examples = [`$ sfp install -u <username>`];

protected static requiresUsername = false;
protected static requiresDevhubUsername = false;
Expand Down Expand Up @@ -80,8 +81,8 @@ export default class Deploy extends SfpCommand {
public async execute() {
let executionStartTime = Date.now();

SFPLogger.log(COLOR_HEADER(`command: ${COLOR_KEY_MESSAGE(`deploy`)}`));
SFPLogger.log(COLOR_HEADER(`Skip Packages If Already Installed: ${this.flags.skipifalreadyinstalled}`));
SFPLogger.log(COLOR_HEADER(`command: ${COLOR_KEY_MESSAGE(`install`)}`));
SFPLogger.log(COLOR_HEADER(`Skip artifacts if already installed: ${this.flags.skipifalreadyinstalled}`));
SFPLogger.log(COLOR_HEADER(`Artifact Directory: ${this.flags.artifactdir}`));
SFPLogger.log(COLOR_HEADER(`Target Environment: ${this.flags.targetorg}`));
if(this.flags.releaseconfig) SFPLogger.log(COLOR_HEADER(`Filter according to: ${this.flags.releaseconfig}`));
Expand Down Expand Up @@ -131,7 +132,7 @@ export default class Deploy extends SfpCommand {
SFPLogger.printHeaderLine('',COLOR_HEADER,LoggerLevel.INFO);
SFPLogger.log(
COLOR_SUCCESS(
`${deploymentResult.deployed.length} packages deployed in ${COLOR_TIME(
`${deploymentResult.deployed.length} artifacts installed in ${COLOR_TIME(
getFormattedTime(totalElapsedTime)
)} with {${deploymentResult.failed.length}} errors`
)
Expand All @@ -140,7 +141,7 @@ export default class Deploy extends SfpCommand {
if (deploymentResult.failed.length > 0) {
SFPLogger.log(
COLOR_ERROR(
`\nPackages Failed to Deploy`,
`\nArtifacts failed to install:`,
deploymentResult.failed.map((packageInfo) => packageInfo.sfpPackage.packageName)
)
);
Expand All @@ -149,19 +150,28 @@ export default class Deploy extends SfpCommand {


SFPStatsSender.logCount('deploy.scheduled', tags);
SFPStatsSender.logCount('install.scheduled', tags);

SFPStatsSender.logGauge('deploy.packages.scheduled', deploymentResult.scheduled, tags);
SFPStatsSender.logGauge('install.packages.scheduled', deploymentResult.scheduled, tags);

SFPStatsSender.logGauge('deploy.duration', totalElapsedTime, tags);
SFPStatsSender.logGauge('install.duration', totalElapsedTime, tags);

SFPStatsSender.logGauge('deploy.succeeded.packages', deploymentResult.deployed.length, tags);
SFPStatsSender.logGauge('install.succeeded.packages', deploymentResult.deployed.length, tags);


SFPStatsSender.logGauge('deploy.failed.packages', deploymentResult.failed.length, tags);
SFPStatsSender.logGauge('install.failed.packages', deploymentResult.failed.length, tags);


if (deploymentResult.failed.length > 0) {
SFPStatsSender.logCount('deploy.failed', tags);
SFPStatsSender.logCount('install.failed', tags);
} else {
SFPStatsSender.logCount('deploy.succeeded', tags);
SFPStatsSender.logCount('install.succeeded', tags);
}
}
}
Expand Down
Loading

0 comments on commit 71bdcde

Please sign in to comment.