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

Commit

Permalink
fix(publish): add ability to push bigger artifacts using environment …
Browse files Browse the repository at this point in the history
…vars

Using ENV VAR SFPOWERSCRIPTS_PROCESS_MAX_BUFFER, add support to push artifacts bigger than 5 MB

fixes #1149
  • Loading branch information
azlam-abdulsalam committed Dec 6, 2022
1 parent f901fcf commit 3d22a20
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
4 changes: 2 additions & 2 deletions packages/sfpowerscripts-cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/sfpowerscripts-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@dxatscale/sfpowerscripts",
"description": "DX@Scale Toolkit",
"version": "20.2.3",
"version": "20.2.4",
"author": "dxatscale",
"release": "November 22",
"bin": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Messages } from '@salesforce/core';
import * as fs from 'fs-extra';
import path = require('path');
import ArtifactFetcher, { Artifact } from '@dxatscale/sfpowerscripts.core/lib/artifacts/ArtifactFetcher';
import child_process = require('child_process');
import SFPStatsSender from '@dxatscale/sfpowerscripts.core/lib/stats/SFPStatsSender';
import SFPLogger, {
COLOR_ERROR,
Expand All @@ -18,11 +17,12 @@ import defaultShell from '@dxatscale/sfpowerscripts.core/lib/utils/DefaultShell'
import SfpPackage, { PackageType } from '@dxatscale/sfpowerscripts.core/lib/package/SfpPackage';
import { ConsoleLogger } from '@dxatscale/sfp-logger';
import SfpPackageBuilder from '@dxatscale/sfpowerscripts.core/lib/package/SfpPackageBuilder';
import Git from "@dxatscale/sfpowerscripts.core/lib/git/Git"
import Git from '@dxatscale/sfpowerscripts.core/lib/git/Git';
import GroupConsoleLogs from '../../../ui/GroupConsoleLogs';
import PackageVersionLister from "@dxatscale/sfpowerscripts.core/lib/package/version/PackageVersionLister"
import PackageVersionLister from '@dxatscale/sfpowerscripts.core/lib/package/version/PackageVersionLister';
import SFPOrg from '@dxatscale/sfpowerscripts.core/lib/org/SFPOrg';

import ExecuteCommand from '@dxatscale/sfpowerscripts.core/lib/command/commandExecutor/ExecuteCommand';
import { LoggerLevel } from '@dxatscale/sfp-logger';

Messages.importMessagesDirectory(__dirname);
const messages = Messages.loadMessages('@dxatscale/sfpowerscripts', 'publish');
Expand Down Expand Up @@ -79,15 +79,15 @@ export default class Promote extends SfpowerscriptsCommand {
scope: flags.string({
description: messages.getMessage('scopeFlagDescription'),
dependsOn: ['npm'],
parse: async (scope) => scope.replace(/@/g, '').toLowerCase()
parse: async (scope) => scope.replace(/@/g, '').toLowerCase(),
}),
npmtag: flags.string({
description: messages.getMessage('npmTagFlagDescription'),
dependsOn: ['npm'],
required: false,
deprecated: {
message:
'--npmtag is deprecated, sfpowerscripts will automatically tag the artifact with the branch name',
'--npmtag is deprecated, sfpowerscripts will automatically tag the artifact with the branch name',
messageOverride:
'--npmtag is deprecated, sfpowerscripts will automatically tag the artifact with the branch name',
},
Expand Down Expand Up @@ -152,10 +152,9 @@ export default class Promote extends SfpowerscriptsCommand {
);
let packageVersionList: any;
if (this.flags.publishpromotedonly) {
let hubOrg = await SFPOrg.create({aliasOrUsername:this.flags.devhubalias})
let packageVersionLister:PackageVersionLister = new PackageVersionLister(hubOrg);
packageVersionList = await packageVersionLister.listAllReleasedVersions(process.cwd())

let hubOrg = await SFPOrg.create({ aliasOrUsername: this.flags.devhubalias });
let packageVersionLister: PackageVersionLister = new PackageVersionLister(hubOrg);
packageVersionList = await packageVersionLister.listAllReleasedVersions(process.cwd());
}

let artifacts = ArtifactFetcher.findArtifacts(this.flags.artifactdir);
Expand Down Expand Up @@ -197,9 +196,9 @@ export default class Promote extends SfpowerscriptsCommand {

try {
if (this.flags.npm) {
this.publishUsingNpm(sfpPackage, packageVersionNumber, npmrcFilesToCleanup);
await this.publishUsingNpm(sfpPackage, packageVersionNumber, npmrcFilesToCleanup);
} else {
this.publishUsingScript(packageName, packageVersionNumber, artifact);
await this.publishUsingScript(packageName, packageVersionNumber, artifact);
}

succesfullyPublishedPackageNamesForTagging.push({
Expand Down Expand Up @@ -275,7 +274,7 @@ export default class Promote extends SfpowerscriptsCommand {
}
}

private publishUsingNpm(sfpPackage: SfpPackage, packageVersionNumber: string, npmrcFilesToCleanup: string[]) {
private async publishUsingNpm(sfpPackage: SfpPackage, packageVersionNumber: string, npmrcFilesToCleanup: string[]) {
let publishGroupSection = new GroupConsoleLogs(`Publishing ${sfpPackage.packageName}`).begin();
let artifactRootDirectory = path.dirname(sfpPackage.sourceDir);

Expand Down Expand Up @@ -310,14 +309,14 @@ export default class Promote extends SfpowerscriptsCommand {
);
}

let npmPublishExecutor: ExecuteCommand = new ExecuteCommand(new ConsoleLogger(), LoggerLevel.INFO, true);
await npmPublishExecutor.execCommand(cmd, artifactRootDirectory);

child_process.execSync(cmd, {
cwd: artifactRootDirectory,
});
publishGroupSection.end();
}

private publishUsingScript(packageName: string, packageVersionNumber: string, artifact: string) {
private async publishUsingScript(packageName: string, packageVersionNumber: string, artifact: string) {
let publishGroupSection = new GroupConsoleLogs(`Publishing ${packageName}`).begin();
let cmd: string;
if (process.platform !== 'win32') {
cmd = `${defaultShell()} -e ${this.flags.scriptpath} ${packageName} ${packageVersionNumber} ${artifact} ${
Expand All @@ -331,10 +330,9 @@ export default class Promote extends SfpowerscriptsCommand {

SFPLogger.log(COLOR_KEY_MESSAGE(`Publishing ${packageName} Version ${packageVersionNumber}...`));

child_process.execSync(cmd, {
cwd: process.cwd(),
stdio: ['ignore', 'inherit', 'inherit'],
});
let scriptExecutor: ExecuteCommand = new ExecuteCommand(new ConsoleLogger(), LoggerLevel.INFO, true);
await scriptExecutor.execCommand(cmd, process.cwd());
publishGroupSection.end();
}

protected validateFlags() {
Expand All @@ -350,7 +348,7 @@ export default class Promote extends SfpowerscriptsCommand {
private async pushGitTags() {
SFPLogger.log(COLOR_KEY_MESSAGE('Pushing Git Tags to Repo'));
if (this.flags.pushgittag) {
await this.git.pushTags();
await this.git.pushTags();
}
}

Expand Down Expand Up @@ -402,6 +400,4 @@ export default class Promote extends SfpowerscriptsCommand {
`Unable to find artifact metadata for ${packageName} Version ${packageVersionNumber.replace('-', '.')}`
);
}


}

0 comments on commit 3d22a20

Please sign in to comment.