Skip to content

Commit

Permalink
fix: log accurate version by distribution (decaporg#1531)
Browse files Browse the repository at this point in the history
  • Loading branch information
erquhart authored Jul 27, 2018
1 parent 668a53a commit 95a76ad
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
6 changes: 5 additions & 1 deletion packages/netlify-cms-core/src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ function bootstrap(opts = {}) {
/**
* Log the version number.
*/
console.log(`Netlify CMS version ${NETLIFY_CMS_VERSION}`);
if (NETLIFY_CMS_VERSION) {
console.log(`netlify-cms ${NETLIFY_CMS_VERSION}`);
} else if (NETLIFY_CMS_CORE_VERSION) {
console.log(`netlify-cms-core ${NETLIFY_CMS_CORE_VERSION}`);
}

/**
* Get DOM element where app will mount.
Expand Down
6 changes: 6 additions & 0 deletions packages/netlify-cms-core/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const path = require('path');
const webpack = require('webpack');
const pkg = require('./package.json');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const { getConfig, rules, plugins } = require('../../scripts/webpack.js');

Expand Down Expand Up @@ -47,6 +49,10 @@ module.exports = {
...Object.entries(plugins)
.filter(([ key ]) => key !== 'friendlyErrors')
.map(([ _, plugin ]) => plugin()),
new webpack.DefinePlugin({
NETLIFY_CMS_VERSION: null,
NETLIFY_CMS_CORE_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`),
}),
new FriendlyErrorsWebpackPlugin({
compilationSuccessInfo: {
messages: ['Netlify CMS is now running at http://localhost:8080'],
Expand Down
2 changes: 1 addition & 1 deletion packages/netlify-cms/scripts/deprecate-old-dist.js
Original file line number Diff line number Diff line change
@@ -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.');
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.')
30 changes: 21 additions & 9 deletions packages/netlify-cms/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
const path = require('path');
const webpack = require('webpack');
const pkg = require('./package.json');
const coreWebpackConfig = require('../netlify-cms-core/webpack.config.js');

const isProduction = process.env.NODE_ENV === 'production';

const baseConfig = {
...coreWebpackConfig,
context: path.join(__dirname, 'src'),
entry: './index.js',
plugins: [
...coreWebpackConfig.plugins.filter(plugin => !plugin instanceof webpack.DefinePlugin),
new webpack.DefinePlugin({
NETLIFY_CMS_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`),
NETLIFY_CMS_CORE_VERSION: null,
}),
],
};

module.exports = [
{
...coreWebpackConfig,
context: path.join(__dirname, 'src'),
entry: './index.js',
},
baseConfig,

/**
* Output the same script a second time, but named `cms.js`, and with a
* deprecation notice.
*/
{
...coreWebpackConfig,
context: path.join(__dirname, 'src'),
...baseConfig,
entry: [
...coreWebpackConfig.entry,
path.join(__dirname, 'scripts/deprecate-old-dist.js'),
baseConfig.entry,
],
output: {
...coreWebpackConfig.output,
...baseConfig.output,
filename: 'dist/cms.js',
},
},
Expand Down
3 changes: 0 additions & 3 deletions scripts/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ const rules = () => ({

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

0 comments on commit 95a76ad

Please sign in to comment.