-
-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/extensions
- Loading branch information
Showing
39 changed files
with
3,360 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ko_fi: kimlimjustin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Please see https://xplorer.vercel.app/docs/Community/Contributing/ | ||
Please see https://xplorer.space/docs/Community/Contributing/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Home for Xplorer API. | ||
|
||
# /api/updater | ||
|
||
An API to check if there is an update available and to download it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
|
||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## This is Xplorer's automatic updater API. | ||
|
||
Nothing much here, just an [API](https://updater.xplorer.space) to check if there is an update available and to download it. | ||
Go back to the [Xplorer website](https://xplorer.space) for Xplorer's docs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/image-types/global" /> | ||
|
||
// NOTE: This file should not be edited | ||
// see https://nextjs.org/docs/basic-features/typescript for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** @type {import('next').NextConfig} */ | ||
module.exports = { | ||
reactStrictMode: true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "updater", | ||
"private": true, | ||
"scripts": { | ||
"dev": "next dev", | ||
"build": "next build", | ||
"start": "next start", | ||
"lint": "next lint" | ||
}, | ||
"dependencies": { | ||
"next": "12.0.7", | ||
"react": "17.0.2", | ||
"react-dom": "17.0.2", | ||
"semver": "^7.3.5" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "17.0.2", | ||
"@types/react": "17.0.37", | ||
"@types/semver": "^7.3.9", | ||
"eslint": "8.5.0", | ||
"eslint-config-next": "12.0.7", | ||
"typescript": "4.5.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import '../styles/globals.css' | ||
import type { AppProps } from 'next/app' | ||
|
||
function MyApp({ Component, pageProps }: AppProps) { | ||
return <Component {...pageProps} /> | ||
} | ||
|
||
export default MyApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { AVAILABLE_PLATFORMS, validatePlatform } from '../../util/platform'; | ||
import semver from 'semver'; | ||
import { GITHUB_TOKEN } from '../../util/constant'; | ||
|
||
export default async function handler(req: any, res: any) { | ||
const { slug } = req.query; | ||
const platform = slug[0]; | ||
const version = slug[1]; | ||
|
||
if (!platform || !validatePlatform(platform)) { | ||
res.status(400).send('Invalid platform'); | ||
return; | ||
} | ||
|
||
if (!version || !semver.valid(version)) { | ||
res.status(400).send('Invalid version'); | ||
return; | ||
} | ||
const reqUrl = new URL(`https://api.github.com/repos/kimlimjustin/xplorer/releases`); | ||
// Headers | ||
const headers: HeadersInit = { Accept: 'application/vnd.github.preview' }; | ||
if (GITHUB_TOKEN && GITHUB_TOKEN.length > 0) { | ||
headers.Authorization = `token ${GITHUB_TOKEN}`; | ||
} | ||
const release = await (await fetch(reqUrl.toString(), { method: 'GET', headers })).json(); | ||
|
||
// Get the latest release but only the ones that is not draft | ||
let index = 0; | ||
let latest_release = release[index]; | ||
while (latest_release.draft) { | ||
index++; | ||
latest_release = release[index]; | ||
} | ||
const latest_version = sanitizeVersion(latest_release.tag_name); | ||
const should_update = semver.gt(latest_version, version); | ||
if (!should_update) { | ||
res.status(204).send(''); | ||
return; | ||
} | ||
for (const asset of latest_release.assets) { | ||
const { name, browser_download_url } = asset; | ||
const findPlatform = checkPlatform(platform, name); | ||
if (!findPlatform) continue; | ||
|
||
res.status(200).json({ | ||
name: latest_release.tag_name, | ||
notes: `Please visit ${latest_release.html_url} to see the detailed changelog.`, | ||
pub_date: latest_release.published_at, | ||
signature: '', | ||
url: browser_download_url, | ||
}); | ||
return; | ||
} | ||
res.status(204).send(''); | ||
} | ||
|
||
function sanitizeVersion(version: string): string { | ||
// if it start with v1.0.0 remove the `v` | ||
if (version.charAt(0) === 'v') { | ||
return version.substring(1); | ||
} | ||
|
||
return version; | ||
} | ||
|
||
function extname(filename: string) { | ||
return filename.split('.').pop() || ''; | ||
} | ||
|
||
function checkPlatform(platform: string, fileName: string) { | ||
const extension = extname(fileName); | ||
|
||
// OSX we should have our .app tar.gz | ||
if ( | ||
(fileName.includes('.app') || fileName.includes('darwin') || fileName.includes('osx')) && | ||
extension === 'gz' && | ||
platform === AVAILABLE_PLATFORMS.MacOS | ||
) { | ||
return 'darwin'; | ||
} | ||
|
||
// Windows 64 bits | ||
if ((fileName.includes('x64') || fileName.includes('win64')) && extension === 'zip' && platform === AVAILABLE_PLATFORMS.Win64) { | ||
return 'win64'; | ||
} | ||
|
||
// Windows 32 bits | ||
if ((fileName.includes('x32') || fileName.includes('win32')) && extension === 'zip' && platform === AVAILABLE_PLATFORMS.Win32) { | ||
return 'win32'; | ||
} | ||
|
||
// Linux app image | ||
if (fileName.includes('AppImage') && extension === 'gz' && platform === AVAILABLE_PLATFORMS.Linux) { | ||
return 'linux'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { NextPage } from 'next'; | ||
import Head from 'next/head'; | ||
import styles from '../styles/Home.module.css'; | ||
|
||
const Home: NextPage = () => { | ||
return ( | ||
<div className={styles.container}> | ||
<Head> | ||
<title>Create Next App</title> | ||
<meta name="description" content="Generated by create next app" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
</Head> | ||
|
||
<main className={styles.main}> | ||
<h1 className={styles.title}>Hello World.</h1> | ||
|
||
<p className={styles.description}>Actually there{"'"}s nothing here, just an auto updater API for Xplorer. </p> | ||
|
||
<div className={styles.grid}> | ||
<a href="https://xplorer.space" className={styles.card}> | ||
<h2>Xplorer Documentation →</h2> | ||
<p>Go to Xplorer home page instead</p> | ||
</a> | ||
</div> | ||
</main> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Home; |
Binary file not shown.
Oops, something went wrong.