I'd like to display the date of a release on my website (together with the release version e.g. 0.3.1).
Option 1
I would prefer to set the date when I bump the version:
npm version patch
--> preferebly adds a data value to the package.json
Option 2
Another approach is to add the date while I build. e.g. npm run deploy:prod
This approach is in particular applicable and accurate, if the latest dependencies are pulled. Though not for me, since I check in my dependencies to have no surprises when I build in production.
QUESTION
How could one add a date to the package.json in both options?
I know how to read:
declare function require(moduleName: string): any;
const { version } = require('../../package.json');
export const envVersion = {
VERSION: version
};