Skip to content

Commit 9e1703c

Browse files
authored
Read Recharts version from npm (#288)
* Read Recharts latest version from npm API * Fetch npm API as part of build job
1 parent e8736c4 commit 9e1703c

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

.github/workflows/deploy-website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Install dependencies
3636
run: npm install
3737
- name: Build with npm
38-
run: npm run build
38+
run: RECHARTS_LATEST_VERSION=`curl -X GET "https://registry.npmjs.org/recharts/latest" | jq --raw-output '.version'` npm run build
3939
- name: Setup Pages
4040
uses: actions/configure-pages@v3
4141
- name: Upload artifact

src/views/IndexView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { getLocaleType, localeGet } from '../utils/LocaleUtils';
66
import './IndexView.scss';
77
import 'simple-line-icons/scss/simple-line-icons.scss';
88
import users from '../docs/users/users';
9-
import rechartsPackageJson from 'recharts/package.json';
109

1110
const data = [
1211
{
@@ -69,8 +68,9 @@ class IndexView extends PureComponent {
6968
<p>
7069
<Link to={`/${locale}/guide/installation`} className="button install-btn">
7170
<i className="icon-energy" />
71+
&nbsp;
7272
{localeGet(locale, 'home', 'install')}
73-
&nbsp;v{rechartsPackageJson.version}
73+
{process.env.RECHARTS_LATEST_VERSION ? ` v${process.env.RECHARTS_LATEST_VERSION}` : undefined}
7474
</Link>
7575
</p>
7676
<iframe

webpack.config.prod.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ module.exports = {
7777
},
7878
plugins: [
7979
new webpack.DefinePlugin({
80-
'process.env.NODE_ENV': JSON.stringify('production'),
80+
'process.env': {
81+
NODE_ENV: JSON.stringify('production'),
82+
RECHARTS_LATEST_VERSION: JSON.stringify(process.env.RECHARTS_LATEST_VERSION),
83+
},
8184
__DEV__: false,
8285
__DEVTOOLS__: false,
8386
}),

0 commit comments

Comments
 (0)