Skip to content

Commit

Permalink
fix(envvar): revert env var to use SFPOWERSCRIPTS nomenclature for ba…
Browse files Browse the repository at this point in the history
…ckward compatibility
  • Loading branch information
sfopsbot committed Dec 19, 2023
1 parent 8b7cd6a commit 028a179
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 78 deletions.
2 changes: 1 addition & 1 deletion packages/sfp-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@flxblio/sfp",
"description": "Flxbl Toolkit",
"version": "30.0.3",
"version": "30.0.4",
"license": "MIT",
"author": "flxblio",
"release": "January 24",
Expand Down
26 changes: 13 additions & 13 deletions packages/sfp-cli/src/SfpCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default abstract class sfpCommand extends Command {
*/
async run(): Promise<any> {
//Always enable color by default
if (process.env.sfp_NOCOLOR) SFPLogger.disableColor();
if (process.env.SFPOWERSCRIPTS_NOCOLOR) SFPLogger.disableColor();
else SFPLogger.enableColor();


Expand Down Expand Up @@ -121,32 +121,32 @@ export default abstract class sfpCommand extends Command {


private initializeStatsD() {
if (process.env.sfp_STATSD) {
if (process.env.SFPOWERSCRIPTS_STATSD) {
SFPStatsSender.initialize(
process.env.sfp_STATSD_PORT,
process.env.sfp_STATSD_HOST,
process.env.sfp_STATSD_PROTOCOL
process.env.SFPOWERSCRIPTS_STATSD_PORT,
process.env.SFPOWERSCRIPTS_STATSD_HOST,
process.env.SFPOWERSCRIPTS_STATSD_PROTOCOL
);
}
if (process.env.sfp_DATADOG) {
if (process.env.SFPOWERSCRIPTS_DATADOG) {
SFPStatsSender.initializeNativeMetrics(
'DataDog',
process.env.sfp_DATADOG_HOST,
process.env.sfp_DATADOG_API_KEY,
process.env.SFPOWERSCRIPTS_DATADOG_HOST,
process.env.SFPOWERSCRIPTS_DATADOG_API_KEY,
new ConsoleLogger()
);
} else if (process.env.sfp_NEWRELIC) {
} else if (process.env.SFPOWERSCRIPTS_NEWRELIC) {
SFPStatsSender.initializeNativeMetrics(
'NewRelic',
null,
process.env.sfp_NEWRELIC_API_KEY,
process.env.SFPOWERSCRIPTS_NEWRELIC_API_KEY,
new ConsoleLogger()
);
} else if (process.env.sfp_SPLUNK) {
} else if (process.env.SFPOWERSCRIPTS_SPLUNK) {
SFPStatsSender.initializeNativeMetrics(
'Splunk',
process.env.sfp_SPLUNK_HOST,
process.env.sfp_SPLUNK_API_KEY,
process.env.SFPOWERSCRIPTS_SPLUNK_HOST,
process.env.SFPOWERSCRIPTS_SPLUNK_API_KEY,
new ConsoleLogger()
);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/sfp-cli/src/commands/metrics/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ export default class Report extends sfpCommand {
private validateEnvVars() {
if (
!(
process.env.sfp_STATSD ||
process.env.sfp_DATADOG ||
process.env.sfp_NEWRELIC ||
process.env.sfp_SPLUNK
process.env.SFPOWERSCRIPTS_STATSD ||
process.env.SFPOWERSCRIPTS_STATSD_DATADOG ||
process.env.SFPOWERSCRIPTS_STATSD_NEWRELIC ||
process.env.SFPOWERSCRIPTS_STATSD_SPLUNK
)
) {
throw new Error('Environment variable not set for metrics. No metrics will be published.');
Expand Down
4 changes: 2 additions & 2 deletions packages/sfp-cli/src/commands/orchestrator/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default class Promote extends sfpCommand {
let artifactFilePaths = ArtifactFetcher.fetchArtifacts(this.flags.artifactdir);

// Pattern captures two named groups, the "package" name and "version" number
let pattern = new RegExp('(?<package>^.*)(?:_sfp_artifact_)(?<version>.*)(?:\\.zip)');
let pattern = new RegExp('(?<package>^.*)(?:_sfpowerscripts_artifact_)(?<version>.*)(?:\\.zip)');
for (let artifact of artifacts) {
let packageName: string;
let packageVersionNumber: string;
Expand Down Expand Up @@ -261,7 +261,7 @@ export default class Promote extends sfpCommand {
let artifactRootDirectory = path.dirname(sfpPackage.sourceDir);

// NPM does not accept packages with uppercase characters
let name: string = sfpPackage.packageName.toLowerCase() + '_sfp_artifact';
let name: string = sfpPackage.packageName.toLowerCase() + '_sfpowerscriptsartifact';

//Check whether the user has already passed in @

Expand Down
8 changes: 4 additions & 4 deletions packages/sfp-cli/src/commands/package/source/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,19 @@ export default class InstallSourcePackage extends InstallPackageCommand {
if (this.flags.refname) {
fs.writeFileSync(
'.env',
`${this.flags.refname}_sfp_installsourcepackage_deployment_id=${result.deploy_id}\n`,
`${this.flags.refname}_sfpowerscripts_installsourcepackage_deployment_id=${result.deploy_id}\n`,
{ flag: 'a' }
);
console.log(
`${this.flags.refname}_sfp_installsourcepackage_deployment_id=${result.deploy_id}`
`${this.flags.refname}_sfpowerscripts_installsourcepackage_deployment_id=${result.deploy_id}`
);
} else {
fs.writeFileSync(
'.env',
`sfp_installsourcepackage_deployment_id=${result.deploy_id}\n`,
`sfpowerscripts_installsourcepackage_deployment_id=${result.deploy_id}\n`,
{ flag: 'a' }
);
console.log(`sfp_installsourcepackage_deployment_id=${result.deploy_id}`);
console.log(`sfpowerscripts_installsourcepackage_deployment_id=${result.deploy_id}`);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/sfp-cli/src/commands/pool/metrics/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ export default class Publish extends sfpCommand {
private validateEnvVars() {
if (
!(
process.env.sfp_STATSD ||
process.env.sfp_DATADOG ||
process.env.sfp_NEWRELIC ||
process.env.sfp_SPLUNK
process.env.SFPOWERSCRIPTS_STATSD ||
process.env.SFPOWERSCRIPTS_DATADOG ||
process.env.SFPOWERSCRIPTS_NEWRELIC ||
process.env.SFPOWERSCRIPTS_SPLUNK
)
) {
throw new Error('Environment variable not set for metrics. No metrics will be published.');
Expand Down
14 changes: 7 additions & 7 deletions packages/sfp-cli/src/core/artifacts/ArtifactFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class ArtifactFetcher {
// Overwrite existing files
zip.extractAllTo(unzippedArtifactsDirectory, true);

let artifactName: string = path.basename(artifact).match(/.*sfp_artifact/)?.[0];
let artifactName: string = path.basename(artifact).match(/.*sfpowerscripts_artifact/)?.[0];
if (artifactName == null) {
throw new Error(`Failed to fetch artifact file paths for ${artifact}`);
}
Expand Down Expand Up @@ -128,16 +128,16 @@ export default class ArtifactFetcher {
/**
* Find zip and tarball artifacts
* Artifact format/s:
* sfp_artifact_<version>.zip,
* [sfdx_package]_sfp_artifact_[version].zip,
* [sfdx_package]_sfp_artifact_[version].tgz
* sfpowerscripts_artifact_<version>.zip,
* [sfdx_package]_sfpowerscripts_artifact_[version].zip,
* [sfdx_package]_sfpowerscripts_artifact_[version].tgz
*/
public static findArtifacts(artifactDirectory: string, sfdx_package?: string): string[] {
let pattern: string;
if (sfdx_package) {
pattern = `**/*${sfdx_package}_sfp_artifact*.@(zip|tgz)`;
pattern = `**/*${sfdx_package}_sfpowerscripts_artifact*.@(zip|tgz)`;
} else {
pattern = `**/*sfp_artifact*.@(zip|tgz)`;
pattern = `**/*sfpowerscripts_artifact*.@(zip|tgz)`;
}

let artifacts: string[] = globSync(pattern, {
Expand All @@ -164,7 +164,7 @@ export default class ArtifactFetcher {
return ext === '.zip' || ext === '.tgz';
});

let pattern = new RegExp('(?:^.*)(?:_sfp_artifact[_-])(?<version>.*)(?:\\.zip|\\.tgz)$');
let pattern = new RegExp('(?:^.*)(?:_sfpowerscripts_artifact[_-])(?<version>.*)(?:\\.zip|\\.tgz)$');
let versions: string[] = artifacts.map((artifact) => {
let match: RegExpMatchArray = path.basename(artifact).match(pattern);
let version = match?.groups.version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class ArtifactGenerator {
): Promise<string> {
try {
// Artifact folder consisting of artifact metadata, changelog & source
let artifactFolder: string = `${sfpPackage.packageName}_sfp_artifact`;
let artifactFolder: string = `${sfpPackage.packageName}_sfpowerscripts_artifact`;

// Absolute filepath of artifact
let artifactFilepath: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/sfp-cli/src/core/git/Git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ export default class Git {
async pushToRemote(branch: string, isForce: boolean) {
if (!branch) branch = (await this._git.branch()).current;
SFPLogger.log(`Pushing ${branch}`, LoggerLevel.INFO, this.logger);
if (process.env.sfp_OVERRIDE_ORIGIN_URL) {
if (process.env.SFPOWERSCRIPTS_OVERRIDE_ORIGIN_URL) {
await this._git.removeRemote('origin');
await this._git.addRemote('origin', process.env.sfp_OVERRIDE_ORIGIN_URL);
await this._git.addRemote('origin', process.env.SFPOWERSCRIPTS_OVERRIDE_ORIGIN_URL);
}

if (isForce) {
Expand Down
8 changes: 4 additions & 4 deletions packages/sfp-cli/src/core/git/GitIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default class GitIdentity {
private async setUsername(): Promise<void> {
let username: string;

if (process.env.sfp_GIT_USERNAME) {
username = process.env.sfp_GIT_USERNAME;
if (process.env.SFPOWERSCRIPTS_GIT_USERNAME) {
username = process.env.SFPOWERSCRIPTS_GIT_USERNAME;
} else {
username = 'sfp';
}
Expand All @@ -23,8 +23,8 @@ export default class GitIdentity {
private async setEmail(): Promise<void> {
let email: string;

if (process.env.sfp_GIT_EMAIL) {
email = process.env.sfp_GIT_EMAIL;
if (process.env.SFPOWERSCRIPTS_GIT_EMAIL) {
email = process.env.SFPOWERSCRIPTS_GIT_EMAIL;
} else {
email = '[email protected]';
}
Expand Down
12 changes: 6 additions & 6 deletions packages/sfp-cli/src/core/stats/SFPStatsSender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class SFPStatsSender {
host: host,
port: port == null ? 8125 : Number(port),
protocol: protocol == 'tcp' ? 'tcp' : 'udp',
prefix: 'sfp.',
prefix: 'sfpowerscripts.',
};
SFPStatsSender.client = new StatsDClient(options);
}
Expand Down Expand Up @@ -46,8 +46,8 @@ export default class SFPStatsSender {

static initializeLogBasedMetrics() {
try {
fs.mkdirpSync('.sfp/logs');
SFPStatsSender.metricsLogger = `.sfp/logs/metrics.log`;
fs.mkdirpSync('.sfpowerscripts/logs');
SFPStatsSender.metricsLogger = `.sfpowerscripts/logs/metrics.log`;
} catch (error) {
console.log('Unable to initiate Log based metrics', error);
}
Expand All @@ -62,7 +62,7 @@ export default class SFPStatsSender {
}

let metrics = {
metric: `sfp.${metric}`,
metric: `sfpowerscripts.${metric}`,
type: `timers`,
value: elapsedMilliSeconds,
timestamp: Date.now(),
Expand All @@ -80,7 +80,7 @@ export default class SFPStatsSender {
}

let metrics = {
metric: `sfp.${metric}`,
metric: `sfpowerscripts.${metric}`,
type: `guage`,
value: value,
timestamp: Date.now(),
Expand All @@ -98,7 +98,7 @@ export default class SFPStatsSender {
}

let metrics = {
metric: `sfp.${metric}`,
metric: `sfpowerscripts.${metric}`,
type: `count`,
timestamp: Date.now(),
tags: tags,
Expand Down
8 changes: 4 additions & 4 deletions packages/sfp-cli/src/core/utils/DefaultShell.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const sfp_DEFAULT_SHELL = `sh`;
const SFPOWERSCRIPTS_DEFAULT_SHELL = `sh`;

export default function defaultShell(): string {
return process.env.sfp_DEFAULT_SHELL
? process.env.sfp_DEFAULT_SHELL
: sfp_DEFAULT_SHELL;
return process.env.SFPOWERSCRIPTS_DEFAULT_SHELL
? process.env.SFPOWERSCRIPTS_DEFAULT_SHELL
: SFPOWERSCRIPTS_DEFAULT_SHELL;
}
4 changes: 2 additions & 2 deletions packages/sfp-cli/src/impl/artifacts/FetchAnArtifactFromNPM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export class FetchAnArtifactFromNPM implements FetchAnArtifact {
packageName = packageName.toLowerCase();

let cmd: string;
if (this.scope) cmd = `npm pack @${this.scope.toLowerCase()}/${packageName}_sfp_artifact`;
else cmd = `npm pack ${packageName}_sfp_artifact`;
if (this.scope) cmd = `npm pack @${this.scope.toLowerCase()}/${packageName}_sfpowerscripts_artifact`;
else cmd = `npm pack ${packageName}_sfpowerscripts_artifact`;

cmd += `@${version}`;

Expand Down
14 changes: 7 additions & 7 deletions packages/sfp-cli/src/impl/prepare/PrepareOrgJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import ProjectConfig from '../../core/project/ProjectConfig';
import { FileLogger } from '@flxblio/sfp-logger';
const fs = require('fs-extra');

const sfp_ARTIFACT_PACKAGE = '04t1P000000ka9mQAA';
const SFPOWERSCRIPTS_ARTIFACT_PACKAGE = '04t1P000000ka9mQAA';
export default class PrepareOrgJob extends PoolJobExecutor implements PreDeployHook {
public constructor(
protected pool: PoolConfig,
Expand Down Expand Up @@ -145,22 +145,22 @@ export default class PrepareOrgJob extends PoolJobExecutor implements PreDeployH
logger: Logger,
packageCollectionInstaller: InstallUnlockedPackageCollection
) {
SFPLogger.log(`Installing sfp_artifact package to the ${scratchOrg.alias}`, null, logger);
SFPLogger.log(`Installing sfpowerscripts_artifact package to the ${scratchOrg.alias}`, null, logger);

//Install sfp artifact package
await packageCollectionInstaller.install(
[
{
name: 'sfp_artifact2',
subscriberPackageVersionId: process.env.sfp_ARTIFACT_PACKAGE
? process.env.sfp_ARTIFACT_PACKAGE
: sfp_ARTIFACT_PACKAGE,
name: 'SFPOWERSCRIPTS_artifact2',
subscriberPackageVersionId: process.env.SFPOWERSCRIPTS_ARTIFACT_PACKAGE
? process.env.SFPOWERSCRIPTS_ARTIFACT_PACKAGE
: SFPOWERSCRIPTS_ARTIFACT_PACKAGE,
},
],
true
);

SFPLogger.log(`Suscessfully Installed sfp_artifact package to the ${scratchOrg.alias}`, null, logger);
SFPLogger.log(`Suscessfully Installed SFPOWERSCRIPTS_artifact package to the ${scratchOrg.alias}`, null, logger);
}

private async invokeDeployImpl(
Expand Down
4 changes: 2 additions & 2 deletions packages/sfp-cli/src/impl/validate/ValidateImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ export default class ValidateImpl implements PostDeployHook, PreDeployHook {
} else if (
this.props.validateAgainst === ValidateAgainst.PRECREATED_POOL
) {
if (process.env.sfp_DEBUG_PREFETCHED_SCRATCHORG)
if (process.env.SFPOWERSCRIPTS_DEBUG_PREFETCHED_SCRATCHORG)
scratchOrgUsername =
process.env.sfp_DEBUG_PREFETCHED_SCRATCHORG;
process.env.SFPOWERSCRIPTS_DEBUG_PREFETCHED_SCRATCHORG;
else
scratchOrgUsername = await this.fetchScratchOrgFromPool(
this.props.pools,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,46 @@ describe('Provided a path to the artifacts folder containing sfp artifact', () =

jest.spyOn(globSync, 'globSync').mockImplementationOnce((pattern: string | string[], options: any) => {
return [
'/path/to/core_sfp_artifact_1.0.0-2.zip',
'/path/to/core2_sfp_artifact_1.0.0-2.zip',
'/path/to/core3_sfp_artifact_1.0.0-3.zip',
'/path/to/my-package_sfp_artifact_3.30.53-NEXT.tgz'
'/path/to/core_sfpowerscripts_artifact_1.0.0-2.zip',
'/path/to/core2_sfpowerscripts_artifact_1.0.0-2.zip',
'/path/to/core3_sfpowerscripts_artifact_1.0.0-3.zip',
'/path/to/my-package_sfpowerscripts_artifact_3.30.53-NEXT.tgz'
];
});


let artifacts = ArtifactFetcher.findArtifacts('artifacts');
expect(artifacts).toEqual(
[
'/path/to/core_sfp_artifact_1.0.0-2.zip',
'/path/to/core2_sfp_artifact_1.0.0-2.zip',
'/path/to/core3_sfp_artifact_1.0.0-3.zip',
'/path/to/my-package_sfp_artifact_3.30.53-NEXT.tgz'
'/path/to/core_sfpowerscripts_artifact_1.0.0-2.zip',
'/path/to/core2_sfpowerscripts_artifact_1.0.0-2.zip',
'/path/to/core3_sfpowerscripts_artifact_1.0.0-3.zip',
'/path/to/my-package_sfpowerscripts_artifact_3.30.53-NEXT.tgz'
]
);
});

it('provided only one artifact exists for a package and a package name is provided, it should just return the one artifact', () => {

jest.spyOn(globSync, 'globSync').mockImplementationOnce((pattern: string | string[], options: any) => {
return new Array('/path/to/core_sfp_artifact_1.0.0-2.zip');
return new Array('/path/to/core_sfpowerscripts_artifact_1.0.0-2.zip');
});

let artifacts = ArtifactFetcher.findArtifacts('artifacts', 'core');
expect(artifacts).toEqual(new Array('/path/to/core_sfp_artifact_1.0.0-2.zip'));
expect(artifacts).toEqual(new Array('/path/to/core_sfpowerscripts_artifact_1.0.0-2.zip'));
});

it('provided multiple artifacts of the same package exists and a package name is provied, it should return the latest', () => {

jest.spyOn(globSync, 'globSync').mockImplementationOnce((pattern: string | string[], options: any) => {
return [
'/path/to/core_sfp_artifact_1.0.0-2.zip',
'/path/to/core_sfp_artifact_1.0.0-3.zip',
'/path/to/core_sfp_artifact_1.0.0-4.zip',
'/path/to/core_sfp_artifact_1.0.0-5.tgz'
'/path/to/core_sfpowerscripts_artifact_1.0.0-2.zip',
'/path/to/core_sfpowerscripts_artifact_1.0.0-3.zip',
'/path/to/core_sfpowerscripts_artifact_1.0.0-4.zip',
'/path/to/core_sfpowerscripts_artifact_1.0.0-5.tgz'
];
});
let artifacts = ArtifactFetcher.findArtifacts('artifacts', 'core');
expect(artifacts).toEqual(new Array('/path/to/core_sfp_artifact_1.0.0-5.tgz'));
expect(artifacts).toEqual(new Array('/path/to/core_sfpowerscripts_artifact_1.0.0-5.tgz'));
});
});

0 comments on commit 028a179

Please sign in to comment.