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(electron-release-publisher): change api/version endpoint in PublisherERS to use versions/sorted #3431

Merged
merged 4 commits into from
Dec 1, 2023
Merged
Changes from 3 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
12 changes: 10 additions & 2 deletions packages/publisher/electron-release-server/src/PublisherERS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ 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 @@ -86,9 +93,10 @@ export default class PublisherERS extends PublisherBase<PublisherERSConfig> {
const { packageJSON } = makeResult;
const artifacts = makeResult.artifacts.filter((artifactPath) => path.basename(artifactPath).toLowerCase() !== 'releases');

const versions: ERSVersion[] = await (await authFetch('api/version')).json();
const versions: ERSVersionSorted = await (await authFetch('versions/sorted')).json();

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

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