Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Commit

Permalink
Merge pull request #277 from wmonk/react-scripts-1.1.1
Browse files Browse the repository at this point in the history
Merge react scripts 1.1.1
  • Loading branch information
wmonk authored Apr 9, 2018
2 parents 244650d + 00e385e commit 1a27e6a
Show file tree
Hide file tree
Showing 49 changed files with 784 additions and 206 deletions.
3 changes: 3 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
--install.no-lockfile true
--install.check-files true
--add.no-lockfile true
3 changes: 3 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code of Conduct

Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.facebook.com/pages/876921332402685/open-source-code-of-conduct) so that you can understand what actions will and will not be tolerated.
29 changes: 21 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,40 @@ All functionality must be retained (and configuration given to the user) if they

1. Clone the repo with `git clone https://github.com/facebookincubator/create-react-app`

2. Run `npm install` in the root `create-react-app` folder.
2. Run `yarn` in the root `create-react-app` folder.

Once it is done, you can modify any file locally and run `npm start`, `npm test` or `npm run build` just like in a generated project.
Once it is done, you can modify any file locally and run `yarn start`, `yarn test` or `yarn build` just like in a generated project.

If you want to try out the end-to-end flow with the global CLI, you can do this too:

```
npm run create-react-app my-app
yarn create-react-app my-app
cd my-app
```

and then run `npm start` or `npm run build`.

*Note: if you are using yarn, we suggest that you use `yarn install --no-lockfile` instead of the bare `yarn` or `yarn install` because we [intentionally](https://github.com/facebookincubator/create-react-app/pull/2014#issuecomment-300811661) do not ignore or add yarn.lock to our repo.*
and then run `yarn start` or `yarn build`.

## Contributing to E2E (end to end) tests

**TL;DR** use the command `yarn e2e:docker` to run unit and e2e tests.

More detailed information are in the dedicated [README](/packages/react-scripts/fixtures/kitchensink/README.md).

## Tips for contributors using Windows

The scripts in tasks folder and other scripts in `package.json` will not work in Windows out of the box. However, using [Bash on windows](https://msdn.microsoft.com/en-us/commandline/wsl/about) makes it easier to use those scripts without any workarounds. The steps to do so are detailed below:

### Install Bash on Ubuntu on Windows

A good step by step guide can be found [here](https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/)

### Install Node.js and yarn
Even if you have node and yarn installed on your windows, it would not be accessible from the bash shell. You would have to install it again. Installing via [`nvm`](https://github.com/creationix/nvm#install-script) is recommended.

### Line endings

By default git would use `CRLF` line endings which would cause the scripts to fail. You can change it for this repo only by setting `autocrlf` to false by running `git config core.autocrlf false`. You can also enable it for all your repos by using the `--global` flag if you wish to do so.

## Cutting a Release

1. Tag all merged pull requests that go into the release with the relevant milestone. Each merged PR should also be labeled with one of the [labels](https://github.com/facebookincubator/create-react-app/labels) named `tag: ...` to indicate what kind of change it is.
Expand All @@ -104,11 +117,11 @@ More detailed information are in the dedicated [README](/packages/react-scripts/
4. Note that files in `packages/create-react-app` should be modified with extreme caution. Since it’s a global CLI, any version of `create-react-app` (global CLI) including very old ones should work with the latest version of `react-scripts`.
5. Create a change log entry for the release:
* You'll need an [access token for the GitHub API](https://help.github.com/articles/creating-an-access-token-for-command-line-use/). Save it to this environment variable: `export GITHUB_AUTH="..."`
* Run `npm run changelog`. The command will find all the labeled pull requests merged since the last release and group them by the label and affected packages, and create a change log entry with all the changes and links to PRs and their authors. Copy and paste it to `CHANGELOG.md`.
* Run `yarn changelog`. The command will find all the labeled pull requests merged since the last release and group them by the label and affected packages, and create a change log entry with all the changes and links to PRs and their authors. Copy and paste it to `CHANGELOG.md`.
* Add a four-space indented paragraph after each non-trivial list item, explaining what changed and why. For each breaking change also write who it affects and instructions for migrating existing code.
* Maybe add some newlines here and there. Preview the result on GitHub to get a feel for it. Changelog generator output is a bit too terse for my taste, so try to make it visually pleasing and well grouped.
6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them.
7. **Do not run `npm publish`. Instead, run `npm run publish`.**
7. Run `npm run publish`. (It has to be `npm run publish` exactly, not just `npm publish` or `yarn publish`.)
8. Wait for a long time, and it will get published. Don’t worry that it’s stuck. In the end the publish script will prompt for versions before publishing the packages.
9. After publishing, create a GitHub Release with the same text as the changelog entry. See previous Releases for inspiration.

Expand Down
4 changes: 1 addition & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ platform:
- x64

install:
# TODO: Remove after https://github.com/appveyor/ci/issues/1426 is fixed
- set PATH=C:\Program Files\Git\mingw64\bin;%PATH%
- ps: Install-Product node $env:nodejs_version $env:platform

build: off
Expand All @@ -41,4 +39,4 @@ skip_commits:
test_script:
- node --version
- npm --version
- sh tasks/e2e-%test_suite%.sh
- bash tasks/e2e-%test_suite%.sh
9 changes: 4 additions & 5 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"lerna": "2.0.0",
"lerna": "2.6.0",
"npmClient": "yarn",
"useWorkspaces": true,
"version": "independent",
"changelog": {
"repo": "facebookincubator/create-react-app",
Expand All @@ -12,8 +14,5 @@
"tag: internal": ":house: Internal"
},
"cacheDir": ".changelog"
},
"packages": [
"packages/*"
]
}
}
6 changes: 6 additions & 0 deletions packages/babel-preset-react-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ If you want to use this Babel preset in a project not built with Create React Ap

First, [install Babel](https://babeljs.io/docs/setup/).

Then install babel-preset-react-app.

```sh
npm install babel-preset-react-app --save-dev
```

Then create a file named `.babelrc` with following contents in the root folder of your project:

```js
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-preset-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
'use strict';

const plugins = [
// Necessary to include regardless of the environment because
// in practice some other transforms (such as object-rest-spread)
// don't work without it: https://github.com/babel/babel/issues/7215
require.resolve('babel-plugin-transform-es2015-destructuring'),
// class { handleClick = () => { } }
require.resolve('babel-plugin-transform-class-properties'),
// The following two plugins use Object.assign directly, instead of Babel's
Expand Down
3 changes: 2 additions & 1 deletion packages/babel-preset-react-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-preset-react-app",
"version": "3.1.0",
"version": "3.1.1",
"description": "Babel preset used by Create React App",
"repository": "facebookincubator/create-react-app",
"license": "MIT",
Expand All @@ -14,6 +14,7 @@
"babel-plugin-dynamic-import-node": "1.1.0",
"babel-plugin-syntax-dynamic-import": "6.18.0",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-es2015-destructuring": "6.23.0",
"babel-plugin-transform-object-rest-spread": "6.26.0",
"babel-plugin-transform-react-constant-elements": "6.23.0",
"babel-plugin-transform-react-jsx": "6.24.1",
Expand Down
64 changes: 56 additions & 8 deletions packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const tmp = require('tmp');
const unpack = require('tar-pack').unpack;
const url = require('url');
const hyperquest = require('hyperquest');
const envinfo = require('envinfo');

const packageJson = require('./package.json');

Expand All @@ -60,10 +61,12 @@ const program = new commander.Command(packageJson.name)
projectName = name;
})
.option('--verbose', 'print additional logs')
.option('--info', 'print environment debug info')
.option(
'--scripts-version <alternative-package>',
'use a non-standard version of react-scripts'
)
.option('--use-npm')
.allowUnknownOption()
.on('--help', () => {
console.log(` Only ${chalk.green('<project-directory>')} is required.`);
Expand All @@ -78,6 +81,11 @@ const program = new commander.Command(packageJson.name)
console.log(
` - a .tgz archive: ${chalk.green('https://mysite.com/my-react-scripts-0.8.2.tgz')}`
);
console.log(
` - a .tar.gz archive: ${chalk.green(
'https://mysite.com/my-react-scripts-0.8.2.tar.gz'
)}`
);
console.log(
` It is not needed unless you specifically want to use a fork.`
);
Expand All @@ -93,6 +101,14 @@ const program = new commander.Command(packageJson.name)
.parse(process.argv);

if (typeof projectName === 'undefined') {
if (program.info) {
envinfo.print({
packages: ['react', 'react-dom', 'react-scripts'],
noNativeIDE: true,
duplicates: true,
});
process.exit(0);
}
console.error('Please specify the project directory:');
console.log(
` ${chalk.cyan(program.name())} ${chalk.green('<project-directory>')}`
Expand Down Expand Up @@ -127,10 +143,11 @@ createApp(
projectName,
program.verbose,
program.scriptsVersion,
program.useNpm,
hiddenProgram.internalTestingTemplate
);

function createApp(name, verbose, version, template) {
function createApp(name, verbose, version, useNpm, template) {
const root = path.resolve(name);
const appName = path.basename(root);

Expand All @@ -153,7 +170,7 @@ function createApp(name, verbose, version, template) {
JSON.stringify(packageJson, null, 2)
);

const useYarn = shouldUseYarn();
const useYarn = useNpm ? false : shouldUseYarn();
const originalDirectory = process.cwd();
process.chdir(root);
if (!useYarn && !checkThatNpmCanReadCwd()) {
Expand Down Expand Up @@ -260,7 +277,7 @@ function run(
template,
useYarn
) {
const packageToInstall = getInstallPackage(version);
const packageToInstall = getInstallPackage(version, originalDirectory);
const allDependencies = ['react', 'react-dom', packageToInstall];

console.log('Installing packages. This might take a couple of minutes.');
Expand Down Expand Up @@ -351,11 +368,16 @@ function run(
});
}

function getInstallPackage(version) {
function getInstallPackage(version, originalDirectory) {
let packageToInstall = 'react-scripts';
const validSemver = semver.valid(version);
if (validSemver) {
packageToInstall += `@${validSemver}`;
} else if (version && version.match(/^file:/)) {
packageToInstall = `file:${path.resolve(
originalDirectory,
version.match(/^file:(.*)?$/)[1]
)}`;
} else if (version) {
// for tar.gz or alternative paths
packageToInstall = version;
Expand Down Expand Up @@ -403,7 +425,7 @@ function extractStream(stream, dest) {

// Extract package name from tarball url or path.
function getPackageName(installPackage) {
if (installPackage.indexOf('.tgz') > -1) {
if (installPackage.match(/^.+\.(tgz|tar\.gz)$/)) {
return getTemporaryDirectory()
.then(obj => {
let stream;
Expand All @@ -426,7 +448,7 @@ function getPackageName(installPackage) {
`Could not extract the package name from the archive: ${err.message}`
);
const assumedProjectName = installPackage.match(
/^.+\/(.+?)(?:-\d+.+)?\.tgz$/
/^.+\/(.+?)(?:-\d+.+)?\.(tgz|tar\.gz)$/
)[1];
console.log(
`Based on the filename, assuming it is "${chalk.cyan(assumedProjectName)}"`
Expand All @@ -443,6 +465,10 @@ function getPackageName(installPackage) {
return Promise.resolve(
installPackage.charAt(0) + installPackage.substr(1).split('@')[0]
);
} else if (installPackage.match(/^file:/)) {
const installPackagePath = installPackage.match(/^file:(.*)?$/)[1];
const installPackageJson = require(path.join(installPackagePath, 'package.json'));
return Promise.resolve(installPackageJson.name);
}
return Promise.resolve(installPackage);
}
Expand Down Expand Up @@ -571,6 +597,12 @@ function isSafeToCreateProjectIn(root, name) {
'.hg',
'.hgignore',
'.hgcheck',
'.npmignore',
'mkdocs.yml',
'docs',
'.travis.yml',
'.gitlab-ci.yml',
'.gitattributes',
];
console.log();

Expand All @@ -596,6 +628,21 @@ function isSafeToCreateProjectIn(root, name) {
return false;
}

function getProxy() {
if (process.env.https_proxy) {
return process.env.https_proxy;
} else {
try {
// Trying to read https-proxy from .npmrc
let httpsProxy = execSync('npm config get https-proxy')
.toString()
.trim();
return httpsProxy !== 'null' ? httpsProxy : undefined;
} catch (e) {
return;
}
}
}
function checkThatNpmCanReadCwd() {
const cwd = process.cwd();
let childOutput = null;
Expand Down Expand Up @@ -660,10 +707,11 @@ function checkIfOnline(useYarn) {

return new Promise(resolve => {
dns.lookup('registry.yarnpkg.com', err => {
if (err != null && process.env.https_proxy) {
let proxy;
if (err != null && (proxy = getProxy())) {
// If a proxy is defined, we likely can't resolve external hostnames.
// Try to resolve the proxy name as an indication of a connection.
dns.lookup(url.parse(process.env.https_proxy).hostname, proxyErr => {
dns.lookup(url.parse(proxy).hostname, proxyErr => {
resolve(proxyErr == null);
});
} else {
Expand Down
3 changes: 2 additions & 1 deletion packages/create-react-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-react-app",
"version": "1.4.3",
"version": "1.5.2",
"keywords": [
"react"
],
Expand All @@ -24,6 +24,7 @@
"chalk": "^1.1.1",
"commander": "^2.9.0",
"cross-spawn": "^4.0.0",
"envinfo": "3.4.2",
"fs-extra": "^1.0.0",
"hyperquest": "^2.1.2",
"semver": "^5.0.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-react-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The following rules from the [eslint-plugin-jsx-a11y](https://github.com/evcohen
- [aria-role](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-role.md)
- [aria-unsupported-elements](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/aria-unsupported-elements.md)
- [heading-has-content](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md)
- [href-no-hash](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md)
- [href-no-hash](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/v5.1.1/docs/rules/href-no-hash.md)
- [iframe-has-title](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/iframe-has-title.md)
- [img-redundant-alt](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md)
- [no-access-key](https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-access-key.md)
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports = {
'new-parens': 'warn',
'no-array-constructor': 'warn',
'no-caller': 'warn',
'no-cond-assign': ['warn', 'always'],
'no-cond-assign': ['warn', 'except-parens'],
'no-const-assign': 'warn',
'no-control-regex': 'warn',
'no-delete-var': 'warn',
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-react-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-react-app",
"version": "2.0.1",
"version": "2.1.0",
"description": "ESLint configuration used by Create React App",
"repository": "facebookincubator/create-react-app",
"license": "MIT",
Expand Down
Loading

0 comments on commit 1a27e6a

Please sign in to comment.