-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: option to check for adrift updates on build
- Loading branch information
Showing
3 changed files
with
44 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// @ts-nocheck | ||
|
||
/** | ||
* Internal adrift version. | ||
*/ | ||
const adriftVersion = "0.10.439"; | ||
|
||
/** | ||
* Checks with latest GitHub release to see if there is an update. | ||
*/ | ||
async function isAdriftUpdateAvailable() { | ||
try { | ||
const url = 'https://raw.githubusercontent.com/hmerritt/adrift/master/scripts/bootstrap/version.cjs'; | ||
const rawGithubText = await (await fetch(url)).text(); | ||
|
||
const versionRegex = /adriftVersion\s*=\s*"([^"]+)"/; | ||
const match = rawGithubText.match(versionRegex)[1].trim(); | ||
|
||
if (!match || !match.match(/\d+\.\d+\.\d+/gi)) { | ||
throw new Error("No version found"); | ||
} | ||
|
||
if (adriftVersion !== match) { | ||
return match; | ||
} | ||
} catch (error) { } | ||
|
||
return false; | ||
} | ||
|
||
module.exports = { adriftVersion, isAdriftUpdateAvailable }; |