fix: log accurate version by distribution (#1531)

This commit is contained in:
Shawn Erquhart 2018-07-27 14:26:03 -04:00 committed by GitHub
parent 668a53a079
commit 95a76ad790
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 14 deletions

View File

@ -20,7 +20,11 @@ function bootstrap(opts = {}) {
/** /**
* Log the version number. * 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. * Get DOM element where app will mount.

View File

@ -1,4 +1,6 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack');
const pkg = require('./package.json');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin'); const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const { getConfig, rules, plugins } = require('../../scripts/webpack.js'); const { getConfig, rules, plugins } = require('../../scripts/webpack.js');
@ -47,6 +49,10 @@ module.exports = {
...Object.entries(plugins) ...Object.entries(plugins)
.filter(([ key ]) => key !== 'friendlyErrors') .filter(([ key ]) => key !== 'friendlyErrors')
.map(([ _, plugin ]) => plugin()), .map(([ _, plugin ]) => plugin()),
new webpack.DefinePlugin({
NETLIFY_CMS_VERSION: null,
NETLIFY_CMS_CORE_VERSION: JSON.stringify(`${pkg.version}${isProduction ? '' : '-dev'}`),
}),
new FriendlyErrorsWebpackPlugin({ new FriendlyErrorsWebpackPlugin({
compilationSuccessInfo: { compilationSuccessInfo: {
messages: ['Netlify CMS is now running at http://localhost:8080'], messages: ['Netlify CMS is now running at http://localhost:8080'],

View File

@ -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.')

View File

@ -1,26 +1,38 @@
const path = require('path'); const path = require('path');
const webpack = require('webpack');
const pkg = require('./package.json');
const coreWebpackConfig = require('../netlify-cms-core/webpack.config.js'); 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 = [ module.exports = [
{ baseConfig,
...coreWebpackConfig,
context: path.join(__dirname, 'src'),
entry: './index.js',
},
/** /**
* Output the same script a second time, but named `cms.js`, and with a * Output the same script a second time, but named `cms.js`, and with a
* deprecation notice. * deprecation notice.
*/ */
{ {
...coreWebpackConfig, ...baseConfig,
context: path.join(__dirname, 'src'),
entry: [ entry: [
...coreWebpackConfig.entry,
path.join(__dirname, 'scripts/deprecate-old-dist.js'), path.join(__dirname, 'scripts/deprecate-old-dist.js'),
baseConfig.entry,
], ],
output: { output: {
...coreWebpackConfig.output, ...baseConfig.output,
filename: 'dist/cms.js', filename: 'dist/cms.js',
}, },
}, },

View File

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