Skip to content

Commit 4dea24f

Browse files
committed
re-incorporate changes for spring-boot
1 parent 86ad43c commit 4dea24f

File tree

11 files changed

+91
-50
lines changed

11 files changed

+91
-50
lines changed

packages/create-react-app/createReactApp.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ function run(
343343
}
344344

345345
function getInstallPackage(version) {
346-
let packageToInstall = 'react-scripts';
346+
let packageToInstall = '@jwbennet/spring-boot-react-scripts';
347347
const validSemver = semver.valid(version);
348348
if (validSemver) {
349349
packageToInstall += `@${validSemver}`;
@@ -492,7 +492,7 @@ function checkAppName(appName) {
492492

493493
// TODO: there should be a single place that holds the dependencies
494494
const dependencies = ['react', 'react-dom'];
495-
const devDependencies = ['react-scripts'];
495+
const devDependencies = ['@jwbennet/spring-boot-react-scripts'];
496496
const allDependencies = dependencies.concat(devDependencies).sort();
497497
if (allDependencies.indexOf(appName) >= 0) {
498498
console.error(
@@ -565,12 +565,19 @@ function isSafeToCreateProjectIn(root) {
565565
'.idea',
566566
'README.md',
567567
'LICENSE',
568-
'web.iml',
569568
'.hg',
570569
'.hgignore',
571570
'.hgcheck',
571+
'.mvn',
572+
'mvnw',
573+
'mvnw.cmd',
574+
'pom.xml',
575+
'src',
572576
];
573-
return fs.readdirSync(root).every(file => validFiles.indexOf(file) >= 0);
577+
return fs
578+
.readdirSync(root)
579+
.filter(file => !file.endsWith('.iml'))
580+
.every(file => validFiles.indexOf(file) >= 0);
574581
}
575582

576583
function checkIfOnline(useYarn) {

packages/create-react-app/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
{
2-
"name": "create-react-app",
3-
"version": "1.3.1",
2+
"name": "@jwbennet/spring-boot-create-react-app",
3+
"version": "1.3.2",
44
"keywords": [
55
"react"
66
],
77
"description": "Create React apps with no build configuration.",
8-
"repository": "facebookincubator/create-react-app",
8+
"repository": "jwbennet/create-react-app",
99
"license": "BSD-3-Clause",
1010
"engines": {
1111
"node": ">=4"
1212
},
1313
"bugs": {
14-
"url": "https://github.com/facebookincubator/create-react-app/issues"
14+
"url": "https://github.com/jwbennet/create-react-app/issues"
1515
},
1616
"files": [
1717
"index.js",
1818
"createReactApp.js"
1919
],
2020
"bin": {
21-
"create-react-app": "./index.js"
21+
"spring-boot-create-react-app": "./index.js"
2222
},
2323
"dependencies": {
2424
"chalk": "^1.1.1",

packages/react-scripts/config/paths.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ function getServedPath(appPackageJson) {
5151
// config after eject: we're in ./config/
5252
module.exports = {
5353
dotenv: resolveApp('.env'),
54-
appBuild: resolveApp('build'),
55-
appPublic: resolveApp('public'),
56-
appHtml: resolveApp('public/index.html'),
57-
appIndexJs: resolveApp('src/index.js'),
54+
appBuild: resolveApp('target/classes/static'),
55+
appPublic: resolveApp('src/main/resources/static'),
56+
appHtml: resolveApp('src/main/resources/index.html'),
57+
appIndexJs: resolveApp('src/main/js/index.js'),
5858
appPackageJson: resolveApp('package.json'),
59-
appSrc: resolveApp('src'),
59+
appSrc: resolveApp('src/main/js'),
60+
appTest: resolveApp('src/test/js'),
6061
yarnLockFile: resolveApp('yarn.lock'),
61-
testsSetup: resolveApp('src/setupTests.js'),
62+
testsSetup: resolveApp('src/test/js/setupTests.js'),
6263
appNodeModules: resolveApp('node_modules'),
6364
publicUrl: getPublicUrl(resolveApp('package.json')),
6465
servedPath: getServedPath(resolveApp('package.json')),

packages/react-scripts/config/webpack.config.dev.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ module.exports = {
7272
// This does not produce a real file. It's just the virtual path that is
7373
// served by WebpackDevServer in development. This is the JS bundle
7474
// containing code from all our entry points, and the Webpack runtime.
75-
filename: 'static/js/bundle.js',
75+
filename: 'js/bundle.js',
7676
// There are also additional JS chunk files if you use code splitting.
7777
chunkFilename: 'static/js/[name].chunk.js',
7878
// This is the URL that app is served from. We use "/" in development.
@@ -175,7 +175,7 @@ module.exports = {
175175
],
176176
loader: require.resolve('file-loader'),
177177
options: {
178-
name: 'static/media/[name].[hash:8].[ext]',
178+
name: 'media/[name].[hash:8].[ext]',
179179
},
180180
},
181181
// "url" loader works like "file" loader except that it embeds assets
@@ -186,7 +186,7 @@ module.exports = {
186186
loader: require.resolve('url-loader'),
187187
options: {
188188
limit: 10000,
189-
name: 'static/media/[name].[hash:8].[ext]',
189+
name: 'media/[name].[hash:8].[ext]',
190190
},
191191
},
192192
// Process JS with Babel.

packages/react-scripts/config/webpack.config.prod.js

+5-17
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,6 @@ const eslintFormatter = require('react-dev-utils/eslintFormatter');
2222
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
2323
const paths = require('./paths');
2424
const getClientEnvironment = require('./env');
25-
var autoprefixer = require('autoprefixer');
26-
var webpack = require('webpack');
27-
var HtmlWebpackPlugin = require('html-webpack-plugin');
28-
var ExtractTextPlugin = require('extract-text-webpack-plugin');
29-
var ManifestPlugin = require('webpack-manifest-plugin');
30-
var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
31-
var paths = require('./paths');
32-
var getClientEnvironment = require('./env');
33-
34-
// @remove-on-eject-begin
35-
// `path` is not used after eject - see https://github.com/facebookincubator/create-react-app/issues/1174
36-
var path = require('path');
37-
// @remove-on-eject-end
3825

3926
// Webpack uses `publicPath` to determine where the app is being served from.
4027
// It requires a trailing slash, or the file assets will get an incorrect path.
@@ -56,7 +43,7 @@ if (env.stringified['process.env'].NODE_ENV !== '"production"') {
5643
}
5744

5845
// Note: defined here because it will be used more than once.
59-
const cssFilename = 'static/css/[name].[contenthash:8].css';
46+
const cssFilename = 'css/[name].[contenthash:8].css';
6047

6148
// ExtractTextPlugin expects the build output to be flat.
6249
// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
@@ -84,7 +71,7 @@ module.exports = {
8471
// Generated JS file names (with nested folders).
8572
// There will be one main bundle, and one file per asynchronous chunk.
8673
// We don't currently advertise code splitting but Webpack supports it.
87-
filename: 'static/js/[name].[chunkhash:8].js',
74+
filename: 'js/[name].[chunkhash:8].js',
8875
chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
8976
// We inferred the "public path" (such as / or /my-project) from homepage.
9077
publicPath: publicPath,
@@ -181,7 +168,7 @@ module.exports = {
181168
],
182169
loader: require.resolve('file-loader'),
183170
options: {
184-
name: 'static/media/[name].[hash:8].[ext]',
171+
name: 'media/[name].[hash:8].[ext]',
185172
},
186173
},
187174
// "url" loader works just like "file" loader but it also embeds
@@ -191,7 +178,7 @@ module.exports = {
191178
loader: require.resolve('url-loader'),
192179
options: {
193180
limit: 10000,
194-
name: 'static/media/[name].[hash:8].[ext]',
181+
name: 'media/[name].[hash:8].[ext]',
195182
},
196183
},
197184
// Process JS with Babel.
@@ -273,6 +260,7 @@ module.exports = {
273260
new HtmlWebpackPlugin({
274261
inject: true,
275262
template: paths.appHtml,
263+
filename: '../templates/index.html',
276264
minify: {
277265
removeComments: true,
278266
collapseWhitespace: true,

packages/react-scripts/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "react-scripts",
3-
"version": "1.0.6",
2+
"name": "@jwbennet/spring-boot-react-scripts",
3+
"version": "1.0.7",
44
"description": "Configuration and scripts for Create React App.",
55
"repository": "jwbennet/create-react-app",
66
"license": "BSD-3-Clause",
@@ -44,6 +44,7 @@
4444
"fs-extra": "3.0.1",
4545
"html-webpack-plugin": "2.28.0",
4646
"jest": "20.0.3",
47+
"nunjucks": "3.0.0",
4748
"object-assign": "4.1.1",
4849
"postcss-flexbugs-fixes": "3.0.0",
4950
"postcss-loader": "2.0.5",

packages/react-scripts/scripts/build.js

+33
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,44 @@ measureFileSizesBeforeBuild(paths.appBuild)
9797
}
9898
);
9999

100+
// Print out errors
101+
function printErrors(summary, errors) {
102+
console.log(chalk.red(summary));
103+
console.log();
104+
errors.forEach(err => {
105+
console.log(err.message || err);
106+
console.log();
107+
});
108+
}
109+
100110
// Create the production build and print the deployment instructions.
101111
function build(previousFileSizes) {
102112
console.log('Creating an optimized production build...');
113+
const compilationCallback = (err, stats) => {
114+
if (err) {
115+
printErrors('Failed to compile.', [err]);
116+
process.exit(1);
117+
}
103118

119+
if (stats.compilation.errors.length) {
120+
printErrors('Failed to compile.', stats.compilation.errors);
121+
process.exit(1);
122+
}
123+
124+
if (process.env.CI && stats.compilation.warnings.length) {
125+
printErrors(
126+
'Failed to compile. When process.env.CI = true, warnings are treated as failures. Most CI servers set this automatically.',
127+
stats.compilation.warnings
128+
);
129+
process.exit(1);
130+
}
131+
};
104132
let compiler = webpack(config);
133+
if (process.argv.includes('--watch')) {
134+
webpack(config).watch({}, compilationCallback);
135+
} else {
136+
webpack(config).run(compilationCallback);
137+
}
105138
return new Promise((resolve, reject) => {
106139
compiler.run((err, stats) => {
107140
if (err) {

packages/react-scripts/scripts/init.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ const path = require('path');
2121
const chalk = require('chalk');
2222
const spawn = require('react-dev-utils/crossSpawn');
2323

24+
const addDependencies = require('../utils/addDependencies');
25+
const copyTemplates = require('../utils/copyTemplates');
26+
2427
module.exports = function(
2528
appPath,
2629
appName,
@@ -37,8 +40,19 @@ module.exports = function(
3740
const appPackage = require(path.join(appPath, 'package.json'));
3841
const useYarn = fs.existsSync(path.join(appPath, 'yarn.lock'));
3942

43+
const activeModules = {
44+
bootstrap: true,
45+
fontawesome: true,
46+
form: true,
47+
redux: true,
48+
router: true,
49+
};
50+
4051
// Copy over some of the devDependencies
41-
appPackage.dependencies = appPackage.dependencies || {};
52+
appPackage.dependencies = addDependencies(
53+
appPackage.dependencies,
54+
activeModules
55+
);
4256
appPackage.devDependencies = appPackage.devDependencies || {};
4357

4458
// Setup the script rules
@@ -47,6 +61,7 @@ module.exports = function(
4761
build: 'react-scripts build',
4862
test: 'react-scripts test --env=jsdom',
4963
eject: 'react-scripts eject',
64+
watch: 'react-scripts build --watch',
5065
};
5166

5267
fs.writeFileSync(
@@ -67,7 +82,7 @@ module.exports = function(
6782
? path.resolve(originalDirectory, template)
6883
: path.join(ownPath, 'template');
6984
if (fs.existsSync(templatePath)) {
70-
fs.copySync(templatePath, appPath);
85+
copyTemplates(appName, appPath, templatePath, activeModules);
7186
} else {
7287
console.error(
7388
`Could not locate supplied template: ${chalk.green(templatePath)}`

packages/react-scripts/scripts/start.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
4949

5050
// Tools like Cloud9 rely on this.
5151
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
52-
const HOST = process.env.HOST || '0.0.0.0';
52+
const HOST = process.env.HOST || 'localhost';
5353

5454
// We attempt to use the default port but if it is busy, we offer the user to
5555
// run on a different port. `detect()` Promise resolves to the next free port.

packages/react-scripts/scripts/utils/createJestConfig.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,24 @@
1010
'use strict';
1111

1212
const fs = require('fs');
13+
const path = require('path');
1314
const chalk = require('chalk');
1415
const paths = require('../../config/paths');
1516

1617
module.exports = (resolve, rootDir, isEjecting) => {
1718
// Use this instead of `paths.testsSetup` to avoid putting
1819
// an absolute filename into configuration after ejecting.
1920
const setupTestsFile = fs.existsSync(paths.testsSetup)
20-
? '<rootDir>/src/setupTests.js'
21+
? '<rootDir>/src/test/js/setupTests.js'
2122
: undefined;
2223

2324
// TODO: I don't know if it's safe or not to just use / as path separator
2425
// in Jest configs. We need help from somebody with Windows to determine this.
2526
const config = {
26-
collectCoverageFrom: ['src/**/*.{js,jsx}'],
27+
collectCoverageFrom: [
28+
path.relative(rootDir, paths.appSrc) + '/**/*.{js,jsx}',
29+
],
30+
roots: [paths.appSrc, paths.appTest],
2731
setupFiles: [resolve('config/polyfills.js')],
2832
setupTestFrameworkScriptFile: setupTestsFile,
2933
testMatch: [

packages/react-scripts/template/src/index.js

-8
This file was deleted.

0 commit comments

Comments
 (0)