Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: limit items on response from ERS #3699

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 10 additions & 4 deletions packages/publisher/electron-release-server/src/PublisherERS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface ERSVersion {
interface ERSVersionSorted {
total: number;
offset: number;
page: number;
page: string | number;
items: ERSVersion[];
}

Expand Down Expand Up @@ -93,10 +93,16 @@ export default class PublisherERS extends PublisherBase<PublisherERSConfig> {
const { packageJSON } = makeResult;
const artifacts = makeResult.artifacts.filter((artifactPath) => path.basename(artifactPath).toLowerCase() !== 'releases');

const versions: ERSVersionSorted = await (await authFetch('versions/sorted')).json();

// Find the version with the same name and flavor
const existingVersion = versions['items'].find((version) => version.name === packageJSON.version && version.flavor.name === flavor);
const findVersion = (versions: ERSVersion[]) => versions.find((version) => version.name === packageJSON.version && version.flavor.name === flavor);

let versions: ERSVersionSorted = await (await authFetch('versions/sorted')).json();
let existingVersion: ERSVersion | undefined = findVersion(versions.items);

while (!existingVersion && versions.offset + versions.items.length < versions.total) {
versions = await (await authFetch(`versions/sorted?page=${Number(versions.page) + 1}`)).json();
existingVersion = findVersion(versions.items);
}

let channel = 'stable';
if (config.channel) {
Expand Down