Skip to content

Commit 95a76ad

Browse files
authored
fix: log accurate version by distribution (#1531)
1 parent 668a53a commit 95a76ad

File tree

5 files changed

+33
-14
lines changed

5 files changed

+33
-14
lines changed

packages/netlify-cms-core/src/bootstrap.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ function bootstrap(opts = {}) {
2020
/**
2121
* Log the version number.
2222
*/
23-
console.log(`Netlify CMS version ${NETLIFY_CMS_VERSION}`);
23+
if (NETLIFY_CMS_VERSION) {
24+
console.log(`netlify-cms ${NETLIFY_CMS_VERSION}`);
25+
} else if (NETLIFY_CMS_CORE_VERSION) {
26+
console.log(`netlify-cms-core ${NETLIFY_CMS_CORE_VERSION}`);
27+
}
2428

2529
/**
2630
* Get DOM element where app will mount.

packages/netlify-cms-core/webpack.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const path = require('path');
2+
const webpack = require('webpack');
3+
const pkg = require('./package.json');
24
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
35
const { getConfig, rules, plugins } = require('../../scripts/webpack.js');
46

@@ -47,6 +49,10 @@ module.exports = {
4749
...Object.entries(plugins)
4850
.filter(([ key ]) => key !== 'friendlyErrors')
4951
.map(([ _, plugin ]) => plugin()),
52+
new webpack.DefinePlugin({
53+
NETLIFY_CMS_VERSION: null,
54+
NETLIFY_CMS_CORE_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`),
55+
}),
5056
new FriendlyErrorsWebpackPlugin({
5157
compilationSuccessInfo: {
5258
messages: ['Netlify CMS is now running at http://localhost:8080'],
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
console.warn('The `cms.js` file is deprecated and will be removed in the next major release. Please use `netlify-cms.js` instead.');
1+
console.warn('You seem to be loading Netlify CMS by fetching `dist/cms.js` from a CDN. That file is deprecated and will be removed in the next major release. Please use `dist/netlify-cms.js` instead.')

packages/netlify-cms/webpack.config.js

+21-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
const path = require('path');
2+
const webpack = require('webpack');
3+
const pkg = require('./package.json');
24
const coreWebpackConfig = require('../netlify-cms-core/webpack.config.js');
35

6+
const isProduction = process.env.NODE_ENV === 'production';
7+
8+
const baseConfig = {
9+
...coreWebpackConfig,
10+
context: path.join(__dirname, 'src'),
11+
entry: './index.js',
12+
plugins: [
13+
...coreWebpackConfig.plugins.filter(plugin => !plugin instanceof webpack.DefinePlugin),
14+
new webpack.DefinePlugin({
15+
NETLIFY_CMS_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`),
16+
NETLIFY_CMS_CORE_VERSION: null,
17+
}),
18+
],
19+
};
20+
421
module.exports = [
5-
{
6-
...coreWebpackConfig,
7-
context: path.join(__dirname, 'src'),
8-
entry: './index.js',
9-
},
22+
baseConfig,
1023

1124
/**
1225
* Output the same script a second time, but named `cms.js`, and with a
1326
* deprecation notice.
1427
*/
1528
{
16-
...coreWebpackConfig,
17-
context: path.join(__dirname, 'src'),
29+
...baseConfig,
1830
entry: [
19-
...coreWebpackConfig.entry,
2031
path.join(__dirname, 'scripts/deprecate-old-dist.js'),
32+
baseConfig.entry,
2133
],
2234
output: {
23-
...coreWebpackConfig.output,
35+
...baseConfig.output,
2436
filename: 'dist/cms.js',
2537
},
2638
},

scripts/webpack.js

-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ const rules = () => ({
2525

2626
const plugins = () => {
2727
return {
28-
define: () => new webpack.DefinePlugin({
29-
NETLIFY_CMS_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`),
30-
}),
3128
ignoreEsprima: () => new webpack.IgnorePlugin(/^esprima$/, /js-yaml/),
3229
ignoreMomentOptionalDeps: () => new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
3330
friendlyErrors: () => new FriendlyErrorsWebpackPlugin(),

0 commit comments

Comments
 (0)