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
Export VERSION information #794
Conversation
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 moment#747.
@networkimprov it was needed to read the version from package.json ( I tried running without it first, but got error messages telling me to install plugin-json. |
This seems fair. |
@GillesDebunne, I retrieved the version from package.json because I've used this procedure to retrieve the package's name and version in some projects I worked in (both little personal projects and some bigger closed source projects for companies). I tried to identify some major libs that also do this, but I had little success. I inspected code from some libs as lodash, moment, axios, request, chalk, fs-extra, etc.
We could think of a way to the same procedure as Moment's: first we would manually write the version export (1.25.0), and for the future releases, we run a task to bump it when. I will try to look for more examples on how to do this and bring some references. |
How is the version bumped on Luxon (such as the commit below)? Is it manual? |
Indeed, updating the version from |
I quite didn't get your suggestion, @GillesDebunne. How do you think we should proceed? |
Vue includes a version in its package.json: vuejs/vue@ec78fc8b which is visible at runtime as EDIT: I'm not familiar with its build process, but found this: https://github.com/vuejs/vue-next/pull/254/commits |
Thank you for the reference, @networkimprov!
React also seems to read the version from |
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 moment#800 (comment).
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 moment#800 (comment). Resolves moment#747 and resolves moment#799.
ffd2952
to
2a14727
Compare
I update the code in this PR to an agreed approach discussed in #800. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about moving this code in a specific script? It does not seems to belong to tag
.
Or maybe check versions at the beginning of release
since the entire process should be stopped in case of version mismatch (which is not the case here)
scripts/tag
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure grep
will work on Windows for instance, but that may not be an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it too, but all these scripts have #!/usr/bin/env bash
in the beginning, reinforcing the idea to run them on Bash, which afaik always has grep, even in Bash for Windows.
(also, the syntax of the scripts have other details that would only allow them to be run on Bash)
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.
I moved it to a dedicated script, and called it in the beginning of both release and tag scripts. |
Thanks! |
This is an attempt to resolve #747 and #799.
Closes #800.
I've read the contribution guide, but I do not know it there is anything to update in the documentation regarding the exports.