Skip to content

Commit

Permalink
Read Recharts version from npm (#288)
Browse files Browse the repository at this point in the history
* Read Recharts latest version from npm API

* Fetch npm API as part of build job
charpeni authored Nov 28, 2023
1 parent e8736c4 commit 9e1703c
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ jobs:
- name: Install dependencies
run: npm install
- name: Build with npm
run: npm run build
run: RECHARTS_LATEST_VERSION=`curl -X GET "https://registry.npmjs.org/recharts/latest" | jq --raw-output '.version'` npm run build
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
4 changes: 2 additions & 2 deletions src/views/IndexView.js
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ import { getLocaleType, localeGet } from '../utils/LocaleUtils';
import './IndexView.scss';
import 'simple-line-icons/scss/simple-line-icons.scss';
import users from '../docs/users/users';
import rechartsPackageJson from 'recharts/package.json';

const data = [
{
@@ -69,8 +68,9 @@ class IndexView extends PureComponent {
<p>
<Link to={`/${locale}/guide/installation`} className="button install-btn">
<i className="icon-energy" />
&nbsp;
{localeGet(locale, 'home', 'install')}
&nbsp;v{rechartsPackageJson.version}
{process.env.RECHARTS_LATEST_VERSION ? ` v${process.env.RECHARTS_LATEST_VERSION}` : undefined}
</Link>
</p>
<iframe
5 changes: 4 additions & 1 deletion webpack.config.prod.js
Original file line number Diff line number Diff line change
@@ -77,7 +77,10 @@ module.exports = {
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env': {
NODE_ENV: JSON.stringify('production'),
RECHARTS_LATEST_VERSION: JSON.stringify(process.env.RECHARTS_LATEST_VERSION),
},
__DEV__: false,
__DEVTOOLS__: false,
}),

0 comments on commit 9e1703c

Please sign in to comment.