Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"lint-staged": {
"*.{js,md,css,html}": [
"prettier --trailing-comma es5 --single-quote --write",
"prettier --print-width 100 es5 --single-quote --write",
"git add"
],
"yarn.lock": [
Expand Down
8 changes: 7 additions & 1 deletion packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,13 @@ module.exports = function(webpackEnv) {
eslintPath: require.resolve('eslint'),
// @remove-on-eject-begin
baseConfig: {
extends: [require.resolve('eslint-config-react-app')],
extends: [
//in order to keep backwards compatability for people currently using eslint-config-frontier
//with their old polymer projects, we have to point to the recommended file instead of index.js
require
.resolve('eslint-config-frontier')
.replace('index.js', 'recommended.js'),
],
settings: { react: { version: '999.999.999' } },
},
ignore: false,
Expand Down
6 changes: 0 additions & 6 deletions packages/react-scripts/gitTagForkedStyle.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"engines": {
"node": ">=6"
},
"scripts": {
"postversion": "node gitTagForkedStyle.js"
},
"bugs": {
"url": "https://github.com/fs-webdev/create-react-app/issues"
},
Expand Down
90 changes: 37 additions & 53 deletions packages/react-scripts/scripts/utils/frontierInit.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) {
if (additionalFeatures.includes('polymer')) {
configurePolymer(appPath, useYarn);
}
if (additionalFeatures.includes('redux')) {
configureRedux(appPath, useYarn, ownPath);
}
if (additionalFeatures.includes('electric-flow')) {
configureEF(appPath, useYarn, ownPath);
}
Expand All @@ -60,59 +57,59 @@ function installFrontierDependencies(appPath, answers, useYarn, ownPath) {
];

const defaultDevModules = [
'eslint@5.6.0',
'fs-webdev/eslint-config-frontier#settingUpRecommendedReactConfig',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start putting eslint-config-frontier into artifactory, and then update that usage here

'react-styleguidist@9.0.0-beta4',
'webpack@4.19.1',
];

installModulesSync(defaultModules, useYarn);
installModulesSync(defaultDevModules, useYarn, true);
addStyleguidistScriptsToPackageJson(appPath);
}

function addStyleguidistScriptsToPackageJson(appPath) {
//we read the package.json using fs instead of require() because require() uses the
//cached result from earlier, even though the package.json has been updated previously.
const appPackage = JSON.parse(
alterPackageJsonFile(appPath, appPackage => {
const packageJson = { ...appPackage };
const additionalScripts = {
styleguide: 'styleguidist server --open',
'styleguide:build': 'styleguidist build',
lint: 'eslint src/',
'lint:fix': 'eslint src/ --fix',
};
packageJson.scripts = { ...packageJson.scripts, ...additionalScripts };
packageJson.eslintConfig = {
extends: ['frontier/recommended'],
};
return packageJson;
});
}
function alterPackageJsonFile(appPath, extendFunction) {
let appPackage = JSON.parse(
fs.readFileSync(path.join(appPath, 'package.json'), 'UTF8')
);

appPackage.scripts.styleguide = 'styleguidist server --open';
appPackage.scripts['styleguide:build'] = 'styleguidist build';

appPackage = extendFunction(appPackage);
fs.writeFileSync(
path.join(appPath, 'package.json'),
JSON.stringify(appPackage, null, 2) + os.EOL
);
}

function configurePolymer(appPath, useYarn) {
//we read the package.json using fs instead of require() because require() uses the
//cached result from earlier, even though the package.json has been updated previously.
const appPackage = JSON.parse(
fs.readFileSync(path.join(appPath, 'package.json'), 'UTF8')
);
appPackage.vendorCopy = [
{
from:
'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js',
to: 'public/vendor/custom-elements-es5-adapter.js',
},
{
from:
'node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js',
to: 'public/vendor/webcomponents-bundle.js',
},
];

const { postinstall } = appPackage.scripts;
appPackage.scripts.postinstall = postinstall
? `${postinstall} && `
: '' + 'vendor-copy';

fs.writeFileSync(
path.join(appPath, 'package.json'),
JSON.stringify(appPackage, null, 2) + os.EOL
);
alterPackageJsonFile(appPath, appPackage => {
const packageJson = { ...appPackage };
packageJson.vendorCopy = [
{
from:
'node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js',
to: 'public/vendor/custom-elements-es5-adapter.js',
},
{
from:
'node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js',
to: 'public/vendor/webcomponents-bundle.js',
},
];
packageJson.scripts.postinstall = 'vendor-copy';
return packageJson;
});

const polymerModules = [
'vendor-copy@2.0.0',
Expand All @@ -137,19 +134,6 @@ function injectPolymerCode(appPath) {
fs.writeFileSync(indexPath, indexHtml);
}

function configureRedux(appPath, useYarn, ownPath) {
const reduxModules = [
'redux@4.0.0',
'react-redux@5.0.7',
'redux-logger@3.0.6',
'redux-thunk@2.3.0',
];
installModulesSync(reduxModules, useYarn);

const templatePath = path.join(ownPath, 'template-redux');
fs.copySync(templatePath, appPath, { overwrite: true });
}

function configureEF(appPath, useYarn, ownPath) {
// TODO - modify package.json to make sure name is correct for blueprint
// TODO - use blueprint.yml as a template
Expand Down
2 changes: 2 additions & 0 deletions packages/react-scripts/template/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#dont worry about using newer versions of libraries than react-scripts
SKIP_PREFLIGHT_CHECK=true
6 changes: 2 additions & 4 deletions packages/react-scripts/template/src/components/App.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { Component } from 'react';
import React from 'react';
import logo from './logo.svg';
import styles from './App.module.css';

class App extends Component {
render() {
function App() {
return (
<div className={styles.app}>
<header className={styles.appHeader}>
Expand All @@ -22,7 +21,6 @@ class App extends Component {
</header>
</div>
);
}
}

export default App;
2 changes: 1 addition & 1 deletion packages/react-scripts/template/src/components/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import App from './App';

export { App };
export default App;
1 change: 1 addition & 0 deletions packages/react-scripts/template/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import './index.css';
import App from './components/App';
import * as serviceWorker from './serviceWorker';

// eslint-disable-next-line react/jsx-filename-extension
ReactDOM.render(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
Expand Down
8 changes: 2 additions & 6 deletions packages/react-scripts/template/src/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ const isLocalhost = Boolean(
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
);

export function register(config) {
Expand Down Expand Up @@ -120,9 +118,7 @@ function checkValidServiceWorker(swUrl, config) {
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
console.log('No internet connection found. App is running in offline mode.');
});
}

Expand Down