Skip to content

Commit 9670be6

Browse files
Merge branch 'next' into mono-cra
2 parents 3dab136 + 2c34d5b commit 9670be6

21 files changed

+250
-50
lines changed

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
## 1.1.1 (February 2, 2018)
2+
3+
#### :bug: Bug Fix
4+
* `react-scripts`
5+
* [#4000](https://github.com/facebook/create-react-app/pull/4000) Fix escaping `$` in environment variables. ([@iansu](https://github.com/iansu))
6+
7+
#### :nail_care: Enhancement
8+
* `react-scripts`
9+
* [#4006](https://github.com/facebook/create-react-app/pull/4006) Add Node 9 compatibility for `fsevents`. ([@gaearon](https://github.com/gaearon))
10+
11+
#### :memo: Documentation
12+
* `react-scripts`
13+
* [#3971](https://github.com/facebook/create-react-app/pull/3971) Update instructions for continuous delivery with Netlify. ([@hubgit](https://github.com/hubgit))
14+
* [#3894](https://github.com/facebook/create-react-app/pull/3894) Include `{json,css}` files in prettier command. ([@reyronald](https://github.com/reyronald))
15+
16+
#### :house: Internal
17+
* `create-react-app`
18+
* [#3853](https://github.com/facebook/create-react-app/pull/3853) pin envinfo version to 3.4.2. ([@bondz](https://github.com/bondz))
19+
20+
#### Committers: 6
21+
- Alf Eaton ([hubgit](https://github.com/hubgit))
22+
- Bond ([bondz](https://github.com/bondz))
23+
- Dan Abramov ([gaearon](https://github.com/gaearon))
24+
- Ian Sutherland ([iansu](https://github.com/iansu))
25+
- Ronald Rey ([reyronald](https://github.com/reyronald))
26+
27+
### Migrating from 1.1.0 to 1.1.1
28+
29+
Inside any created project that has not been ejected, run:
30+
31+
```
32+
npm install --save --save-exact [email protected]
33+
```
34+
35+
or
36+
37+
```
38+
yarn add --exact [email protected]
39+
```
40+
141
## 1.1.0 (January 15, 2018)
242

343
#### :rocket: New Feature

packages/create-react-app/createReactApp.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const hyperquest = require('hyperquest');
5050
const envinfo = require('envinfo');
5151
const os = require('os');
5252
const resolveFrom = require('resolve-from');
53-
53+
const findMonorepo = require('react-dev-utils/workspaceUtils').findMonorepo;
5454
const packageJson = require('./package.json');
5555

5656
// These files should be allowed to remain on a failed install,
@@ -186,7 +186,7 @@ function createApp(name, verbose, version, useNpm, template) {
186186
JSON.stringify(packageJson, null, 2) + os.EOL
187187
);
188188

189-
const useYarn = useNpm ? false : shouldUseYarn();
189+
const useYarn = useNpm ? false : shouldUseYarn(root);
190190
const originalDirectory = process.cwd();
191191
process.chdir(root);
192192
if (!useYarn && !checkThatNpmCanReadCwd()) {
@@ -222,7 +222,7 @@ function createApp(name, verbose, version, useNpm, template) {
222222
run(root, appName, version, verbose, originalDirectory, template, useYarn);
223223
}
224224

225-
function shouldUseYarn() {
225+
function isYarnAvailable() {
226226
try {
227227
execSync('yarnpkg --version', { stdio: 'ignore' });
228228
return true;
@@ -231,6 +231,11 @@ function shouldUseYarn() {
231231
}
232232
}
233233

234+
function shouldUseYarn(appDir) {
235+
const mono = findMonorepo(appDir);
236+
return (mono.isYarnWs && mono.isAppIncluded) || isYarnAvailable();
237+
}
238+
234239
function install(root, useYarn, dependencies, verbose, isOnline) {
235240
return new Promise((resolve, reject) => {
236241
let command;

packages/create-react-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"envinfo": "3.4.2",
2828
"fs-extra": "^5.0.0",
2929
"hyperquest": "^2.1.2",
30+
"react-dev-utils": "^5.0.0",
3031
"resolve-from": "^4.0.0",
3132
"semver": "^5.0.3",
3233
"tar-pack": "^3.4.0",

packages/react-dev-utils/launchEditor.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ const COMMON_EDITORS_OSX = {
5757
'/Applications/WebStorm.app/Contents/MacOS/webstorm':
5858
'/Applications/WebStorm.app/Contents/MacOS/webstorm',
5959
'/Applications/MacVim.app/Contents/MacOS/MacVim': 'mvim',
60+
'/Applications/GoLand.app/Contents/MacOS/goland':
61+
'/Applications/GoLand.app/Contents/MacOS/goland',
6062
};
6163

6264
const COMMON_EDITORS_LINUX = {
@@ -72,6 +74,7 @@ const COMMON_EDITORS_LINUX = {
7274
sublime_text: 'sublime_text',
7375
vim: 'vim',
7476
'webstorm.sh': 'webstorm',
77+
'goland.sh': 'goland',
7578
};
7679

7780
const COMMON_EDITORS_WIN = [
@@ -93,6 +96,8 @@ const COMMON_EDITORS_WIN = [
9396
'rubymine64.exe',
9497
'webstorm.exe',
9598
'webstorm64.exe',
99+
'goland.exe',
100+
'goland64.exe',
96101
];
97102

98103
function addWorkspaceToArgumentsIfExists(args, workspace) {
@@ -155,6 +160,8 @@ function getArgumentsForLineNumber(
155160
case 'rubymine64':
156161
case 'webstorm':
157162
case 'webstorm64':
163+
case 'goland':
164+
case 'goland64':
158165
return addWorkspaceToArgumentsIfExists(
159166
['--line', lineNumber, fileName],
160167
workspace

packages/react-dev-utils/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"printHostingInstructions.js",
3535
"WatchMissingNodeModulesPlugin.js",
3636
"WebpackDevServerUtils.js",
37-
"webpackHotDevClient.js"
37+
"webpackHotDevClient.js",
38+
"workspaceUtils.js"
3839
],
3940
"dependencies": {
4041
"@babel/code-frame": "7.0.0-beta.38",
@@ -45,7 +46,9 @@
4546
"detect-port-alt": "1.1.5",
4647
"escape-string-regexp": "1.0.5",
4748
"filesize": "3.5.11",
49+
"find-pkg": "1.0.0",
4850
"global-modules": "1.0.0",
51+
"globby": "7.1.1",
4952
"gzip-size": "4.1.0",
5053
"inquirer": "5.0.0",
5154
"is-root": "1.0.0",
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Copyright (c) 2018-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
const fs = require('fs');
10+
const path = require('path');
11+
const findPkg = require('find-pkg');
12+
const globby = require('globby');
13+
14+
const findPkgs = (rootPath, globPatterns) => {
15+
if (!globPatterns) {
16+
return [];
17+
}
18+
const globOpts = {
19+
cwd: rootPath,
20+
strict: true,
21+
absolute: true,
22+
};
23+
return globPatterns
24+
.reduce(
25+
(pkgs, pattern) =>
26+
pkgs.concat(globby.sync(path.join(pattern, 'package.json'), globOpts)),
27+
[]
28+
)
29+
.map(f => path.dirname(path.normalize(f)));
30+
};
31+
32+
const findMonorepo = appDir => {
33+
const monoPkgPath = findPkg.sync(path.resolve(appDir, '..'));
34+
const monoPkg = monoPkgPath && require(monoPkgPath);
35+
const patterns = monoPkg && monoPkg.workspaces;
36+
const isYarnWs = Boolean(patterns);
37+
const allPkgs = patterns && findPkgs(path.dirname(monoPkgPath), patterns);
38+
const isIncluded = dir => allPkgs && allPkgs.indexOf(dir) !== -1;
39+
const isAppIncluded = isIncluded(appDir);
40+
const pkgs = allPkgs
41+
? allPkgs.filter(f => fs.realpathSync(f) !== appDir)
42+
: [];
43+
44+
return {
45+
isAppIncluded,
46+
isYarnWs,
47+
pkgs,
48+
};
49+
};
50+
51+
module.exports = {
52+
findMonorepo,
53+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// @remove-on-eject-begin
2+
/**
3+
* Copyright (c) 2018-present, Facebook, Inc.
4+
* Copyright (c) 2016 Remind
5+
*
6+
* This source code is licensed under the MIT license found in the
7+
* LICENSE file in the root directory of this source tree.
8+
*/
9+
// @remove-on-eject-end
10+
'use strict';
11+
12+
const loader = require('graphql-tag/loader');
13+
14+
module.exports = {
15+
process(src) {
16+
return loader.call({ cacheable() {} }, src);
17+
},
18+
};

packages/react-scripts/config/paths.js

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
const path = require('path');
1212
const fs = require('fs');
1313
const url = require('url');
14-
const findPkg = require('find-pkg');
15-
const globby = require('globby');
14+
const findMonorepo = require('react-dev-utils/workspaceUtils').findMonorepo;
1615

1716
// Make sure any symlinks in the project folder are resolved:
1817
// https://github.com/facebook/create-react-app/issues/637
@@ -58,7 +57,6 @@ module.exports = {
5857
appIndexJs: resolveApp('src/index.js'),
5958
appPackageJson: resolveApp('package.json'),
6059
appSrc: resolveApp('src'),
61-
yarnLockFile: resolveApp('yarn.lock'),
6260
testsSetup: resolveApp('src/setupTests.js'),
6361
appNodeModules: resolveApp('node_modules'),
6462
publicUrl: getPublicUrl(resolveApp('package.json')),
@@ -80,7 +78,6 @@ module.exports = {
8078
appIndexJs: resolveApp('src/index.js'),
8179
appPackageJson: resolveApp('package.json'),
8280
appSrc: resolveApp('src'),
83-
yarnLockFile: resolveApp('yarn.lock'),
8481
testsSetup: resolveApp('src/setupTests.js'),
8582
appNodeModules: resolveApp('node_modules'),
8683
publicUrl: getPublicUrl(resolveApp('package.json')),
@@ -106,7 +103,6 @@ if (useTemplate) {
106103
appIndexJs: resolveOwn('template/src/index.js'),
107104
appPackageJson: resolveOwn('package.json'),
108105
appSrc: resolveOwn('template/src'),
109-
yarnLockFile: resolveOwn('template/yarn.lock'),
110106
testsSetup: resolveOwn('template/src/setupTests.js'),
111107
appNodeModules: resolveOwn('node_modules'),
112108
publicUrl: getPublicUrl(resolveOwn('package.json')),
@@ -120,37 +116,16 @@ if (useTemplate) {
120116

121117
module.exports.srcPaths = [module.exports.appSrc];
122118

123-
const findPkgs = (rootPath, globPatterns) => {
124-
const globOpts = {
125-
cwd: rootPath,
126-
strict: true,
127-
absolute: true,
128-
};
129-
return globPatterns
130-
.reduce(
131-
(pkgs, pattern) =>
132-
pkgs.concat(globby.sync(path.join(pattern, 'package.json'), globOpts)),
133-
[]
134-
)
135-
.map(f => path.dirname(path.normalize(f)));
136-
};
137-
138-
const getMonorepoPkgPaths = () => {
139-
const monoPkgPath = findPkg.sync(path.resolve(appDirectory, '..'));
140-
if (monoPkgPath) {
141-
// get monorepo config from yarn workspace
142-
const pkgPatterns = require(monoPkgPath).workspaces;
143-
const pkgPaths = findPkgs(path.dirname(monoPkgPath), pkgPatterns);
144-
// only include monorepo pkgs if app itself is included in monorepo
145-
if (pkgPaths.indexOf(appDirectory) !== -1) {
146-
return pkgPaths.filter(f => fs.realpathSync(f) !== appDirectory);
147-
}
148-
}
149-
return [];
150-
};
119+
module.exports.useYarn = fs.existsSync(
120+
path.join(module.exports.appPath, 'yarn.lock')
121+
);
151122

152123
if (checkForMonorepo) {
153124
// if app is in a monorepo (lerna or yarn workspace), treat other packages in
154125
// the monorepo as if they are app source
155-
Array.prototype.push.apply(module.exports.srcPaths, getMonorepoPkgPaths());
126+
const mono = findMonorepo(appDirectory);
127+
if (mono.isAppIncluded) {
128+
Array.prototype.push.apply(module.exports.srcPaths, mono.pkgs);
129+
}
130+
module.exports.useYarn = module.exports.useYarn || mono.isYarnWs;
156131
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ module.exports = {
278278
},
279279
],
280280
},
281+
// The GraphQL loader preprocesses GraphQL queries in .graphql files.
282+
{
283+
test: /\.(graphql)$/,
284+
loader: 'graphql-tag/loader',
285+
},
281286
// "file" loader makes sure those assets get served by WebpackDevServer.
282287
// When you `import` an asset, you get its (virtual) filename.
283288
// In production, they would get copied to the `build` folder.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@ module.exports = {
320320
),
321321
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
322322
},
323+
// The GraphQL loader preprocesses GraphQL queries in .graphql files.
324+
{
325+
test: /\.(graphql)$/,
326+
loader: 'graphql-tag/loader',
327+
},
323328
// "file" loader makes sure assets end up in the `build` folder.
324329
// When you `import` an asset, you get its filename.
325330
// This loader doesn't use a "test" so it will catch all modules
@@ -408,6 +413,7 @@ module.exports = {
408413
// having to parse `index.html`.
409414
new ManifestPlugin({
410415
fileName: 'asset-manifest.json',
416+
publicPath: publicPath
411417
}),
412418
// Generate a service worker script that will precache, and keep up to date,
413419
// the HTML & assets that are part of the Webpack build.

packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ describe('Integration', () => {
3131
);
3232
});
3333

34+
it('graphql files inclusion', async () => {
35+
const doc = await initDOM('graphql-inclusion');
36+
const children = doc.getElementById('graphql-inclusion').children;
37+
38+
// .graphql
39+
expect(children[0].textContent.replace(/\s/g, '')).to.equal(
40+
'{"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","variableDefinitions":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"test"},"value":{"kind":"StringValue","value":"test","block":false}}],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[],"directives":[]}]}}]}}],"loc":{"start":0,"end":40,"source":{"body":"{\\ntest(test:\\"test\\"){\\ntest\\n}\\n}\\n","name":"GraphQLrequest","locationOffset":{"line":1,"column":1}}}}'
41+
);
42+
});
43+
3444
it('image inclusion', async () => {
3545
const doc = await initDOM('image-inclusion');
3646

packages/react-scripts/fixtures/kitchensink/src/App.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ class App extends Component {
111111
this.setFeature(f.default)
112112
);
113113
break;
114+
case 'graphql-inclusion':
115+
import('./features/webpack/GraphQLInclusion').then(f =>
116+
this.setFeature(f.default)
117+
);
118+
break;
114119
case 'image-inclusion':
115120
import('./features/webpack/ImageInclusion').then(f =>
116121
this.setFeature(f.default)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright (c) 2018-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React from 'react';
9+
import A from './assets/graphql.graphql';
10+
11+
export default () => (
12+
<p id="graphql-inclusion">
13+
<span>{JSON.stringify(A)}</span>
14+
</p>
15+
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright (c) 2018-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import React from 'react';
9+
import ReactDOM from 'react-dom';
10+
import GraphQLInclusion from './GraphQLInclusion';
11+
12+
describe('graphql files inclusion', () => {
13+
it('renders without crashing', () => {
14+
const div = document.createElement('div');
15+
ReactDOM.render(<GraphQLInclusion />, div);
16+
});
17+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
test(test: "test") {
3+
test
4+
}
5+
}

0 commit comments

Comments
 (0)