-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #327 from WatWowMap/addl-version-checking
Additional Version Error Checking
- Loading branch information
Showing
14 changed files
with
105 additions
and
64 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
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,13 +1,13 @@ | ||
version: '3.1' | ||
services: | ||
reactmap: | ||
image: ghcr.io/watwowmap/reactmap:main #pr-10 | ||
image: ghcr.io/watwowmap/reactmap:main | ||
container_name: reactmap | ||
command: sh -c "yarn migrate:latest && yarn start" | ||
command: sh -c "yarn start" | ||
restart: unless-stopped | ||
volumes: | ||
- ./server/src/configs/areas.json:/home/node/server/src/configs/areas.json | ||
- ./server/src/configs/local.json:/home/node/server/src/local/config.json | ||
- ./server/src/configs/local.json:/home/node/server/src/configs/local.json | ||
- ./example.env:/home/node/.env | ||
ports: | ||
- "9090:8080" |
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
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,32 +1,52 @@ | ||
/* eslint-disable no-console */ | ||
const { exec } = require('child_process') | ||
const fs = require('fs') | ||
|
||
const { version: currentVersion } = require('../../../package.json') | ||
const Fetch = require('./Fetch') | ||
try { | ||
exec('git branch --show-current', async (err, stdout) => { | ||
try { | ||
const gitRef = fs.readFileSync('.gitref', 'utf8') | ||
|
||
exec('git branch --show-current', async (err, stdout) => { | ||
try { | ||
if (err || typeof stdout !== 'string') { | ||
throw new Error('Unable to get current branch', err.message) | ||
} | ||
const { version } = await Fetch.json(`https://raw.githubusercontent.com/WatWowMap/ReactMap/${stdout.trim()}/package.json`) | ||
if (!gitRef && (err || typeof stdout !== 'string' || !stdout.trim())) { | ||
throw new Error('Unable to get current branch', err) | ||
} | ||
const branch = typeof gitRef === 'string' && gitRef.trim() | ||
? gitRef.split('/')[2].trim() | ||
: stdout.trim() | ||
|
||
if (!version) { | ||
throw new Error('Unable to fetch latest version') | ||
} | ||
exec('git rev-parse HEAD', async (err2, stdout2) => { | ||
try { | ||
const gitSha = fs.readFileSync('.gitsha', 'utf8') | ||
|
||
const [majorC, minorC, patchC] = currentVersion.split('.').map(x => parseInt(x)) | ||
const [majorN, minorN, patchN] = version.split('.').map(x => parseInt(x)) | ||
if (!gitSha && (err2 || typeof stdout2 !== 'string' || !stdout2.trim())) { | ||
throw new Error('Unable to get current sha', err) | ||
} | ||
const sha = typeof gitSha === 'string' && gitSha.trim() | ||
? gitSha.trim() | ||
: stdout2.trim() | ||
|
||
if (stdout.trim() === 'main') { | ||
console.info('You are on the main branch, there may be additional features available on the "develop" branch. Type "git checkout develop" in the console if you would like the latest features.') | ||
} | ||
if (majorC < majorN | ||
|| (majorC === majorN && minorC < minorN) | ||
|| (majorC === majorN && minorC === minorN && patchC < patchN)) { | ||
console.info(`[${stdout.trim().toUpperCase()}] New version available: ${version} (Current: ${currentVersion})`) | ||
exec(`git ls-remote https://github.com/WatWowMap/ReactMap/ refs/heads/${branch}`, (err3, stdout3) => { | ||
try { | ||
if (err3 || typeof stdout3 !== 'string' || !stdout3?.split('\t')?.[0]) { | ||
throw new Error('Unable to get remote sha', err3) | ||
} | ||
const remoteSha = stdout3.split('\t')[0] | ||
|
||
if (remoteSha !== sha) { | ||
console.log('There is a new version available:', remoteSha) | ||
} | ||
} catch (e) { | ||
console.warn('Unable to get remote SHA', e.message, 'Branch:', branch, 'Local SHA:', sha) | ||
} | ||
}) | ||
} catch (e) { | ||
console.warn('Unable to get current SHA', e.message, 'Branch:', branch) | ||
} | ||
}) | ||
} catch (e) { | ||
console.warn('Unable to get current branch', e.message) | ||
} | ||
} catch (e) { | ||
console.error(e.message) | ||
} | ||
}) | ||
}) | ||
} catch (e) { | ||
console.log(e.message) | ||
} |
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
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
Oops, something went wrong.