Skip to content

Commit

Permalink
fix: Show deprecation warning regarding elm.json usage
Browse files Browse the repository at this point in the history
  • Loading branch information
halfzebra committed Oct 9, 2018
1 parent 2d907c8 commit be8c7bf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
const formatElmCompilerErrors = require('./utils/formatElmCompilerErrors');
const warn = require('./utils/warn');

const measureFileSizesBeforeBuild =
FileSizeReporter.measureFileSizesBeforeBuild;
Expand Down Expand Up @@ -72,6 +73,7 @@ measureFileSizesBeforeBuild(paths.appBuild)
console.log('File sizes after gzip:\n');
printFileSizesAfterBuild(stats, previousFileSizes, paths.appBuild);
console.log();
warn(paths.elmJson);
},
err => {
console.error(chalk.red('Failed to compile.\n'));
Expand All @@ -83,6 +85,7 @@ measureFileSizesBeforeBuild(paths.appBuild)
// Create the production build and print the deployment instructions.
function build(previousFileSizes) {
const withDebugger = process.env.ELM_DEBUGGER === 'true' ? true : false;
console.log();
if (withDebugger) {
console.log(
`Creating a ${process.env.NODE_ENV} build with debugger enabled...`
Expand Down
3 changes: 3 additions & 0 deletions scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const openBrowser = require('react-dev-utils/openBrowser');
const createDevServerConfig = require('../config/webpackDevServer.config');
const formatElmCompilerErrors = require('./utils/formatElmCompilerErrors');
const paths = require('../config/paths');
const warn = require('./utils/warn');

if (fs.existsSync('elm.json') === false) {
console.log('Please, run the build script from project root directory');
Expand Down Expand Up @@ -108,8 +109,10 @@ function createCompiler(webpack, config, appName, urls) {
if (isSuccessful) {
console.log(chalk.green('Compiled successfully!'));
}

if (isSuccessful && (isInteractive || isFirstCompile)) {
printInstructions(appName, urls);
warn(paths.elmJson);
}
isFirstCompile = false;

Expand Down
15 changes: 15 additions & 0 deletions scripts/utils/warn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const chalk = require('chalk');

module.exports = function warn(elmJsonPath) {
const elmJson = require(elmJsonPath);
if (elmJson.homepage || elmJson.proxy) {
console.log();
console.log(chalk.yellow('Warning:'));
console.log();
console.log(
' Using elm.json for configuring "homebage" and "proxy" is deprecated.'
);
console.log(' This feature will be removed in the future versions.');
console.log();
}
};

0 comments on commit be8c7bf

Please sign in to comment.