Skip to content

Commit

Permalink
Export VERSION information (#794)
Browse files Browse the repository at this point in the history
* Export VERSION information

As pointed out by @networkimprov, it is a good practice to tell the
package version by exporting a constant or having a comment to
indicate it. Therefere, the version info is exported now.

Resolves #747.

* Revert "Export VERSION information"

This reverts commit 972e157.

@GillesDebunne and I agreed on a different approach, which is based
on a hardcoded VERSION export, while maintaining a logic to ensure
that the VERSION variable matches the package version.

See #800 (comment).

* Export hardcoded VERSION variable

For a less bold approach, the exported VERSION variable is now
hardcoded. Meanwhile, the `scripts/tag` script was improved to
ensure that all versions match.

See #800 (comment).

Resolves #747 and resolves #799.

* Move version validation to dedicated script

Move the version validation to a dedicated script, so that it can
be called both from release and tag scripts, which are scripts that
should validate the version before proceeding.
  • Loading branch information
pgcalixto committed Nov 9, 2020
1 parent c4b697e commit 343978d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions scripts/release
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
./scripts/version || exit $?

npm run build
npm run docs
npm run site
Expand Down
9 changes: 3 additions & 6 deletions scripts/tag
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/usr/bin/env bash
./scripts/version || exit $?

PACKAGE_VERSION=$(node -p "require('./package.json').version")

if [ $(git tag -l "$PACKAGE_VERSION") ]; then
echo "tag already exists"
else
git tag $PACKAGE_VERSION
git push origin master $PACKAGE_VERSION
fi
git tag $PACKAGE_VERSION
git push origin master $PACKAGE_VERSION
18 changes: 18 additions & 0 deletions scripts/version
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

abort() {
echo "ERROR: $1"
exit 1
}

PACKAGE_VERSION=$(node -p "require('./package.json').version")
PACKAGE_LOCK_VERSION=$(node -p "require('./package-lock.json').version")
EXPORTED_VERSION=$(grep -oP "(?<=const VERSION = \").*(?=\";)" ./src/luxon.js)

if [ $PACKAGE_VERSION != $PACKAGE_LOCK_VERSION ]; then
abort "package-lock.json's version differs from package.json's"
elif [ $PACKAGE_VERSION != $EXPORTED_VERSION ]; then
abort "exported version differs from package.json's"
elif [ $(git tag -l "$PACKAGE_VERSION") ]; then
abort "tag already exists"
fi
3 changes: 3 additions & 0 deletions src/luxon.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import InvalidZone from "./zones/invalidZone.js";
import LocalZone from "./zones/localZone.js";
import Settings from "./settings.js";

const VERSION = "1.25.0";

export {
VERSION,
DateTime,
Duration,
Interval,
Expand Down

0 comments on commit 343978d

Please sign in to comment.