Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/publisher/github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"main": "dist/PublisherGithub.js",
"typings": "dist/PublisherGithub.d.ts",
"devDependencies": {
"@types/cli-progress": "^3.11.6",
"vitest": "^3.0.3"
},
"engines": {
Expand All @@ -22,6 +23,7 @@
"@octokit/rest": "^18.0.11",
"@octokit/types": "^6.1.2",
"chalk": "^4.0.0",
"cli-progress": "^3.12.0",
"debug": "^4.3.1",
"fs-extra": "^10.0.0",
"log-symbols": "^4.0.0",
Expand Down
23 changes: 16 additions & 7 deletions packages/publisher/github/src/PublisherGithub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ForgeMakeResult } from '@electron-forge/shared-types';
import { RequestError } from '@octokit/request-error';
import { GetResponseDataTypeFromEndpointMethod } from '@octokit/types';
import chalk from 'chalk';
import cliProgress from 'cli-progress';
import fs from 'fs-extra';
import logSymbols from 'log-symbols';
import mime from 'mime-types';
Expand Down Expand Up @@ -90,19 +91,26 @@ export default class PublisherGithub extends PublisherBase<PublisherGitHubConfig
}
}

let uploaded = 0;
const updateUploadStatus = () => {
setStatusLine(`Uploading distributable (${uploaded}/${artifacts.length} to ${releaseName})`);
};
updateUploadStatus();
const totalArtifacts = artifacts.flatMap((artifact) => artifact.artifacts).length;

const progressBar = new cliProgress.SingleBar(
{
format: `Uploading to ${releaseName} | {bar} | {percentage}% ({value}/{total})`,
barCompleteChar: '#',
barIncompleteChar: '.',
hideCursor: true,
},
cliProgress.Presets.shades_classic
);

progressBar.start(totalArtifacts, 0);

await Promise.all(
artifacts
.flatMap((artifact) => artifact.artifacts)
.map(async (artifactPath) => {
const done = () => {
uploaded += 1;
updateUploadStatus();
progressBar.increment();
};
const artifactName = path.basename(artifactPath);
const sanitizedArtifactName = GitHub.sanitizeName(artifactName);
Expand Down Expand Up @@ -152,6 +160,7 @@ export default class PublisherGithub extends PublisherBase<PublisherGitHubConfig
return done();
})
);
progressBar.stop();
}
}
}
Expand Down
Loading