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

Commit

Permalink
fix/download-links (#54)
Browse files Browse the repository at this point in the history
* fix/download-page (#37) (#48)

* Fix/change download links (#53)

* 🚑 fix download links
  • Loading branch information
mehdilouraoui authored Jun 7, 2022
1 parent 79ec2a2 commit 85c9420
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
7 changes: 7 additions & 0 deletions utils/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,12 @@ export const REVALIDATE_TIME = 60 * 60; // 1 hour to avoid github spam
export const EXE_EXTENSION = '.exe';
export const DMG_EXTENSION = '.dmg';
export const APP_IMAGE_EXTENSION = '.AppImage';
export const EXE_EXTENSION_MAILS_FIX = '-win-setup.exe';
export const DMG_EXTENSION_MAILS_FIX = '-mac.dmg';
export const APP_IMAGE_EXTENSION_MAILS_FIX = '-linux.AppImage';

export const EXE_EXTENSION_DOCS_FIX = '-win-setup.exe';
export const DMG_EXTENSION_DOCS_FIX = '-mac-x64.dmg';
export const APP_IMAGE_EXTENSION_DOCS_FIX = '-linux-x86_64.AppImage';

export const ARCHIFILTRE_MAIL_ADDRESS = 'contact@archifiltre.fr';
34 changes: 29 additions & 5 deletions utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { Endpoints } from '@octokit/types';
import { UAParser } from 'ua-parser-js';
import { APP_IMAGE_EXTENSION, DMG_EXTENSION, EXE_EXTENSION } from './constant';
import {
DMG_EXTENSION_MAILS_FIX,
APP_IMAGE_EXTENSION_MAILS_FIX,
EXE_EXTENSION_MAILS_FIX,
APP_IMAGE_EXTENSION_DOCS_FIX,
DMG_EXTENSION_DOCS_FIX,
EXE_EXTENSION_DOCS_FIX,
} from './constant';

export const HAS_WINDOW = typeof window !== 'undefined';

Expand Down Expand Up @@ -77,10 +84,27 @@ export const getDownloadLink = (
const name = product.url.includes('archifiltre-docs')
? 'docs'
: 'mails';
const url = `https://github.com/SocialGouv/archifiltre-${name}/releases/download/v${version}/archifiltre-${name}-${version}`;

if (os === 'Mac OS') return url + DMG_EXTENSION;
if (os === 'Linux') return url + APP_IMAGE_EXTENSION;
if (os?.startsWith('Windows')) return url + EXE_EXTENSION;
// TODO: clean download util

const baseUrl = `https://github.com/SocialGouv/archifiltre-${name}/releases/download/v${version}/archifiltre-${name}`;

if (name === 'mails') {
if (os === 'Mac OS') return baseUrl + DMG_EXTENSION_MAILS_FIX;
if (os === 'Linux') return baseUrl + APP_IMAGE_EXTENSION_MAILS_FIX;
if (os?.startsWith('Windows'))
return baseUrl + EXE_EXTENSION_MAILS_FIX;
} else {
if (os === 'Mac OS') return baseUrl + DMG_EXTENSION_DOCS_FIX;
if (os === 'Linux') return baseUrl + APP_IMAGE_EXTENSION_DOCS_FIX;
if (os?.startsWith('Windows'))
return baseUrl + EXE_EXTENSION_DOCS_FIX;
}

// const url = `https://github.com/SocialGouv/archifiltre-${name}/releases/download/v${version}/archifiltre-${name}-${version}`;

// if (os === 'Mac OS') return url + DMG_EXTENSION;
// if (os === 'Linux') return url + APP_IMAGE_EXTENSION;
// if (os?.startsWith('Windows')) return url + EXE_EXTENSION;
}
};

1 comment on commit 85c9420

@vercel
Copy link

@vercel vercel bot commented on 85c9420 Jun 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.