-
Notifications
You must be signed in to change notification settings - Fork 2
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 #20 from hyperskill/master
Upgrade dependencies
- Loading branch information
Showing
12 changed files
with
3,313 additions
and
9,945 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,51 @@ | ||
import packageJson from "../../package.json"; | ||
|
||
/** | ||
* CheckerLibraryVersion is a class responsible for comparing the local library | ||
* version with the remote version available on GitHub. | ||
* | ||
* It helps to ensure that the user is using the latest version of the library. | ||
*/ | ||
class CheckerLibraryVersion { | ||
|
||
constructor() {} | ||
|
||
/** | ||
* Compares the local library version with the remote version on GitHub. | ||
* | ||
* If the versions are different, an error message will be logged to the console, | ||
* or an Error will be thrown if the throwError flag is set to true. | ||
* | ||
* @param throwError {boolean} - Optional flag to indicate if an Error should be | ||
* thrown when versions are different. Default is false. | ||
* @returns {Promise<void>} - A promise that resolves when the check is complete. | ||
*/ | ||
async checkLibraryVersion(throwError = false): Promise<void> { | ||
|
||
const libraryVersionUrl = "https://github.com/hyperskill/hs-test-web/blob/master/package.json"; | ||
try { | ||
const response = await fetch(libraryVersionUrl); | ||
const packageRemoteJson = await response.json(); | ||
const remoteVersion = packageRemoteJson.version; | ||
const localVersion = packageJson.version; | ||
if (remoteVersion !== localVersion) { | ||
const errorMsg = `The version of the local library (${localVersion}) is different from the version on GitHub (${remoteVersion}). | ||
Please update your local version. | ||
You can download the new version of the library at the link: https://github.com/hyperskill/hs-test-web/archive/release.tar.gz | ||
To upgrade, install the new version using the command: npm install /path/to/your/archive/hs-test-web-release.tar.gz`; | ||
if (throwError) { | ||
throw new Error(errorMsg); | ||
} else { | ||
console.error(errorMsg); | ||
} | ||
} | ||
} catch (error) { | ||
console.error("Error while checking library version:\n", error); | ||
if (throwError) { | ||
throw error; | ||
} | ||
} | ||
} | ||
} | ||
|
||
export default CheckerLibraryVersion; |
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.