Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: centralize version number on package #342

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions scripts/check_version
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
#!/bin/bash

SRC_VERSION=`grep "const VERSION " ./src/constants.js | cut -d"'" -f2`
set -e # Exit on any command failure.
set -u # Exit on unset variables.

PACKAGE_VERSION=`grep '"version":' ./package.json | cut -d '"' -f4`
PACKAGE_LOCK_VERSION=`node -p "require('./package-lock.json').version"`
PACKAGE_LOCK_VERSION_2=`node -p "require('./package-lock.json').packages[''].version"`

# For debugging:
# echo x${SRC_VERSION}x
# echo x${PACKAGE_VERSION}x
# echo x${PACKAGE_LOCK_VERSION}x
# echo x${PACKAGE_LOCK_VERSION_2}x

EXITCODE=0

if [[ x${PACKAGE_VERSION}x != x${SRC_VERSION}x ]]; then
echo Version different in package.json and src/constants.js
if [[ x${PACKAGE_VERSION}x != x${PACKAGE_LOCK_VERSION}x ]]; then
echo Version different in package.json and package-lock.json
EXITCODE=-1
fi

if [[ x${PACKAGE_VERSION}x != x${PACKAGE_LOCK_VERSION_2}x ]]; then
echo Version different in package.json and the packages property in package-lock.json
EXITCODE=-1
fi

exit $EXITCODE
exit $EXITCODE
3 changes: 2 additions & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { version } from '../package.json';

export const BASE_URL =
process.env.REACT_APP_BASE_URL || 'https://node.explorer.hathor.network/v1a/';
Expand Down Expand Up @@ -57,7 +58,7 @@ export const TESTNET_GENESIS_TX = [
'00975897028ceb037307327c953f5e7ad4d3f42402d71bd3d11ecb63ac39f01a',
];

export const VERSION = '0.20.6';
export const VERSION = version;

export const MIN_API_VERSION = '0.33.0';

Expand Down