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 9 commits into
base: main
Choose a base branch
from
18 changes: 8 additions & 10 deletions packages/publisher/electron-release-server/src/PublisherERS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ interface ERSVersion {
flavor: ERSFlavor;
}

interface ERSVersionSorted {
total: number;
offset: number;
page: number;
items: ERSVersion[];
}

const fetchAndCheckStatus = async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
const result = await fetch(url, init);
if (result.ok) {
Expand Down Expand Up @@ -93,10 +86,15 @@ 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 existingVersion: ERSVersion = await authFetch(`api/version?name=${packageJSON.version}&flavor=${flavor}`)
.then((res) => res.json())
.then((versions) =>
versions.find((version: ERSVersion) => {
return version.name === packageJSON.version && version.flavor.name === flavor;
})
)
.catch(() => undefined);

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