diff --git a/.eslintrc.js b/.eslintrc.js index 0f8fb047066..1a0ff4648a0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,4 @@ -const clientESLintConfig = require('./config/eslint'); +const clientESLintConfig = require('./packages/react-scripts/config/eslint'); module.exports = Object.assign({}, clientESLintConfig, { env: Object.assign({}, clientESLintConfig.env, { diff --git a/.gitignore b/.gitignore index f19abba4284..1900a2f2cf9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ build *.tgz my-app* template/src/__tests__/__snapshots__/ +lerna-debug.log +npm-debug.log diff --git a/.travis.yml b/.travis.yml index 3ed7097635b..75383b87806 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ node_js: - 6 cache: directories: - - global-cli/node_modules - node_modules + - packages/create-react-app/node_modules + - packages/react-scripts/node_modules script: tasks/e2e.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7eab19b19df..bc0f7aa0030 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,7 @@ Please also provide a **test plan**, i.e. specify how you verified that your add 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 **and** the `create-react-app/global-cli` folder +2. Run `npm install` 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. @@ -62,16 +62,15 @@ and then run `npm start` or `npm run build`. 1. Tag all merged PRs that go into the release with the relevant milestone. 2. Close the milestone. -3. In most releases, only `react-scripts` needs to be released. If you don’t have any changes to the `global-cli` folder, you don’t need to bump its version or publish it. -4. Note that files in `global-cli` 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`. +3. In most releases, only `react-scripts` needs to be released. If you don’t have any changes to the `packages/create-react-app` folder, you don’t need to bump its version or publish it (the publish script will publish only changed packages). +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. Add an entry to `CHANGELOG.md` detailing what has changed with links to PRs and their authors. Use previous entries for inspiration. Group changes to `react-scripts` and `create-react-app` separately in the notes, for example like in `0.2.0` release notes. 6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them. 7. After merging the changelog update, create a GitHub Release with the same text. See previous Releases for inspiration. -8. If you are releasing updates to the `create-react-app` CLI (likely not), go to `global-cli`, bump the version in `package.json` and run `npm publish` in that folder. -9. If you are releasing updates to `react-scripts` (most likely!), bump the version in `package.json`. **Do not run `npm publish`. Instead, run `sh tasks/release.sh`.** -10. Wait for a long time, and it will get published. Don’t worry that it’s stuck. It will bundle dependencies into a single tarball before publishing for faster installs. +8. **Do not run `npm publish`. Instead, run `npm run publish`.** +9. Wait for a long time, and it will get published. Don’t worry that it’s stuck. It will bundle dependencies into a single tarball before publishing for faster installs. In the end the publish script will prompt for versions before publishing the packages. -Make sure to test the released version! If you want to be extra careful, you can publish a prerelease by running `sh tasks/release.sh --tag next` instead of `sh tasks/release.sh`. +Make sure to test the released version! If you want to be extra careful, you can publish a prerelease by running `npm run publish -- --tag next` instead of `npm run publish`. ------------ diff --git a/lerna.json b/lerna.json new file mode 100644 index 00000000000..75db3193146 --- /dev/null +++ b/lerna.json @@ -0,0 +1,4 @@ +{ + "lerna": "2.0.0-beta.28", + "version": "independent" +} diff --git a/package.json b/package.json index 5718e9fa71e..b57e050bd93 100644 --- a/package.json +++ b/package.json @@ -1,89 +1,20 @@ { - "name": "react-scripts", - "version": "0.4.3", - "description": "Configuration and scripts for Create React App.", - "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", - "engines": { - "node": ">=4" - }, - "bugs": { - "url": "https://github.com/facebookincubator/create-react-app/issues" - }, + "private": true, "scripts": { - "build": "node scripts/build.js", + "build": "node packages/react-scripts/scripts/build.js", "create-react-app": "tasks/cra.sh", "e2e": "tasks/e2e.sh", - "start": "node scripts/start.js", - "test": "node scripts/test.js --env=jsdom" + "postinstall": "lerna bootstrap", + "publish": "tasks/release.sh", + "start": "node packages/react-scripts/scripts/start.js", + "test": "node packages/react-scripts/scripts/test.js --env=jsdom" }, - "files": [ - "PATENTS", - "bin", - "config", - "scripts", - "template" - ], - "bin": { - "react-scripts": "./bin/react-scripts.js" - }, - "dependencies": { - "autoprefixer": "6.4.1", - "babel-core": "6.14.0", - "babel-eslint": "6.1.2", - "babel-jest": "15.0.0", - "babel-loader": "6.2.5", - "babel-plugin-transform-class-properties": "6.11.5", - "babel-plugin-transform-object-rest-spread": "6.8.0", - "babel-plugin-transform-react-constant-elements": "6.9.1", - "babel-plugin-transform-regenerator": "6.14.0", - "babel-plugin-transform-runtime": "6.15.0", - "babel-preset-latest": "6.14.0", - "babel-preset-react": "6.11.1", - "babel-runtime": "6.11.6", - "case-sensitive-paths-webpack-plugin": "1.1.4", - "chalk": "1.1.3", - "connect-history-api-fallback": "1.3.0", - "cross-spawn": "4.0.0", - "css-loader": "0.24.0", - "detect-port": "1.0.0", + "devDependencies": { "eslint": "3.5.0", - "eslint-loader": "1.5.0", "eslint-plugin-flowtype": "2.18.1", "eslint-plugin-import": "1.12.0", "eslint-plugin-jsx-a11y": "2.2.2", "eslint-plugin-react": "5.2.2", - "extract-text-webpack-plugin": "1.0.1", - "file-loader": "0.9.0", - "filesize": "3.3.0", - "find-cache-dir": "0.1.1", - "fs-extra": "0.30.0", - "gzip-size": "3.0.0", - "html-loader": "0.4.3", - "html-webpack-plugin": "2.22.0", - "http-proxy-middleware": "0.17.1", - "jest": "15.1.1", - "json-loader": "0.5.4", - "object-assign": "4.1.0", - "opn": "4.0.2", - "path-exists": "3.0.0", - "postcss-loader": "0.13.0", - "promise": "7.1.1", - "recursive-readdir": "2.0.0", - "rimraf": "2.5.4", - "strip-ansi": "3.0.1", - "style-loader": "0.13.1", - "url-loader": "0.5.7", - "webpack": "1.13.2", - "webpack-dev-server": "1.16.1", - "whatwg-fetch": "1.0.0" - }, - "devDependencies": { - "bundle-deps": "1.0.0", - "react": "^15.3.0", - "react-dom": "^15.3.0" - }, - "optionalDependencies": { - "fsevents": "1.0.14" + "lerna": "2.0.0-beta.28" } } diff --git a/global-cli/index.js b/packages/create-react-app/index.js similarity index 100% rename from global-cli/index.js rename to packages/create-react-app/index.js diff --git a/global-cli/package.json b/packages/create-react-app/package.json similarity index 100% rename from global-cli/package.json rename to packages/create-react-app/package.json diff --git a/bin/react-scripts.js b/packages/react-scripts/bin/react-scripts.js similarity index 100% rename from bin/react-scripts.js rename to packages/react-scripts/bin/react-scripts.js diff --git a/config/babel.dev.js b/packages/react-scripts/config/babel.dev.js similarity index 100% rename from config/babel.dev.js rename to packages/react-scripts/config/babel.dev.js diff --git a/config/babel.prod.js b/packages/react-scripts/config/babel.prod.js similarity index 100% rename from config/babel.prod.js rename to packages/react-scripts/config/babel.prod.js diff --git a/config/env.js b/packages/react-scripts/config/env.js similarity index 100% rename from config/env.js rename to packages/react-scripts/config/env.js diff --git a/config/eslint.js b/packages/react-scripts/config/eslint.js similarity index 100% rename from config/eslint.js rename to packages/react-scripts/config/eslint.js diff --git a/config/flow/css.js.flow b/packages/react-scripts/config/flow/css.js.flow similarity index 100% rename from config/flow/css.js.flow rename to packages/react-scripts/config/flow/css.js.flow diff --git a/config/flow/file.js.flow b/packages/react-scripts/config/flow/file.js.flow similarity index 100% rename from config/flow/file.js.flow rename to packages/react-scripts/config/flow/file.js.flow diff --git a/config/jest/CSSStub.js b/packages/react-scripts/config/jest/CSSStub.js similarity index 100% rename from config/jest/CSSStub.js rename to packages/react-scripts/config/jest/CSSStub.js diff --git a/config/jest/FileStub.js b/packages/react-scripts/config/jest/FileStub.js similarity index 100% rename from config/jest/FileStub.js rename to packages/react-scripts/config/jest/FileStub.js diff --git a/config/jest/transform.js b/packages/react-scripts/config/jest/transform.js similarity index 100% rename from config/jest/transform.js rename to packages/react-scripts/config/jest/transform.js diff --git a/config/paths.js b/packages/react-scripts/config/paths.js similarity index 98% rename from config/paths.js rename to packages/react-scripts/config/paths.js index c3594e14519..314bcc2051f 100644 --- a/config/paths.js +++ b/packages/react-scripts/config/paths.js @@ -70,7 +70,7 @@ module.exports = { // @remove-on-publish-begin module.exports = { - appBuild: resolveOwn('../build'), + appBuild: resolveOwn('../../../build'), appHtml: resolveOwn('../template/index.html'), appIndexJs: resolveOwn('../template/src/index.js'), appPackageJson: resolveOwn('../package.json'), diff --git a/config/polyfills.js b/packages/react-scripts/config/polyfills.js similarity index 100% rename from config/polyfills.js rename to packages/react-scripts/config/polyfills.js diff --git a/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js similarity index 100% rename from config/webpack.config.dev.js rename to packages/react-scripts/config/webpack.config.dev.js diff --git a/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js similarity index 100% rename from config/webpack.config.prod.js rename to packages/react-scripts/config/webpack.config.prod.js diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json new file mode 100644 index 00000000000..c9c5b34f611 --- /dev/null +++ b/packages/react-scripts/package.json @@ -0,0 +1,81 @@ +{ + "name": "react-scripts", + "version": "0.4.3", + "description": "Configuration and scripts for Create React App.", + "repository": "facebookincubator/create-react-app", + "license": "BSD-3-Clause", + "engines": { + "node": ">=4" + }, + "bugs": { + "url": "https://github.com/facebookincubator/create-react-app/issues" + }, + "files": [ + "bin", + "config", + "scripts", + "template" + ], + "bin": { + "react-scripts": "./bin/react-scripts.js" + }, + "dependencies": { + "autoprefixer": "6.4.1", + "babel-core": "6.14.0", + "babel-eslint": "6.1.2", + "babel-jest": "15.0.0", + "babel-loader": "6.2.5", + "babel-plugin-transform-class-properties": "6.11.5", + "babel-plugin-transform-object-rest-spread": "6.8.0", + "babel-plugin-transform-react-constant-elements": "6.9.1", + "babel-plugin-transform-regenerator": "6.14.0", + "babel-plugin-transform-runtime": "6.15.0", + "babel-preset-latest": "6.14.0", + "babel-preset-react": "6.11.1", + "babel-runtime": "6.11.6", + "case-sensitive-paths-webpack-plugin": "1.1.4", + "chalk": "1.1.3", + "connect-history-api-fallback": "1.3.0", + "cross-spawn": "4.0.0", + "css-loader": "0.24.0", + "detect-port": "1.0.0", + "eslint": "3.5.0", + "eslint-loader": "1.5.0", + "eslint-plugin-flowtype": "2.18.1", + "eslint-plugin-import": "1.12.0", + "eslint-plugin-jsx-a11y": "2.2.2", + "eslint-plugin-react": "5.2.2", + "extract-text-webpack-plugin": "1.0.1", + "file-loader": "0.9.0", + "filesize": "3.3.0", + "find-cache-dir": "0.1.1", + "fs-extra": "0.30.0", + "gzip-size": "3.0.0", + "html-loader": "0.4.3", + "html-webpack-plugin": "2.22.0", + "http-proxy-middleware": "0.17.1", + "jest": "15.1.1", + "json-loader": "0.5.4", + "object-assign": "4.1.0", + "opn": "4.0.2", + "path-exists": "3.0.0", + "postcss-loader": "0.13.0", + "promise": "7.1.1", + "recursive-readdir": "2.0.0", + "rimraf": "2.5.4", + "strip-ansi": "3.0.1", + "style-loader": "0.13.1", + "url-loader": "0.5.7", + "webpack": "1.13.2", + "webpack-dev-server": "1.16.1", + "whatwg-fetch": "1.0.0" + }, + "devDependencies": { + "bundle-deps": "1.0.0", + "react": "^15.3.0", + "react-dom": "^15.3.0" + }, + "optionalDependencies": { + "fsevents": "1.0.14" + } +} diff --git a/scripts/build.js b/packages/react-scripts/scripts/build.js similarity index 100% rename from scripts/build.js rename to packages/react-scripts/scripts/build.js diff --git a/scripts/eject.js b/packages/react-scripts/scripts/eject.js similarity index 100% rename from scripts/eject.js rename to packages/react-scripts/scripts/eject.js diff --git a/scripts/init.js b/packages/react-scripts/scripts/init.js similarity index 100% rename from scripts/init.js rename to packages/react-scripts/scripts/init.js diff --git a/scripts/start.js b/packages/react-scripts/scripts/start.js similarity index 100% rename from scripts/start.js rename to packages/react-scripts/scripts/start.js diff --git a/scripts/test.js b/packages/react-scripts/scripts/test.js similarity index 100% rename from scripts/test.js rename to packages/react-scripts/scripts/test.js diff --git a/scripts/utils/WatchMissingNodeModulesPlugin.js b/packages/react-scripts/scripts/utils/WatchMissingNodeModulesPlugin.js similarity index 100% rename from scripts/utils/WatchMissingNodeModulesPlugin.js rename to packages/react-scripts/scripts/utils/WatchMissingNodeModulesPlugin.js diff --git a/scripts/utils/checkRequiredFiles.js b/packages/react-scripts/scripts/utils/checkRequiredFiles.js similarity index 100% rename from scripts/utils/checkRequiredFiles.js rename to packages/react-scripts/scripts/utils/checkRequiredFiles.js diff --git a/scripts/utils/chrome.applescript b/packages/react-scripts/scripts/utils/chrome.applescript similarity index 100% rename from scripts/utils/chrome.applescript rename to packages/react-scripts/scripts/utils/chrome.applescript diff --git a/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js similarity index 100% rename from scripts/utils/createJestConfig.js rename to packages/react-scripts/scripts/utils/createJestConfig.js diff --git a/scripts/utils/prompt.js b/packages/react-scripts/scripts/utils/prompt.js similarity index 100% rename from scripts/utils/prompt.js rename to packages/react-scripts/scripts/utils/prompt.js diff --git a/template/README.md b/packages/react-scripts/template/README.md similarity index 100% rename from template/README.md rename to packages/react-scripts/template/README.md diff --git a/template/gitignore b/packages/react-scripts/template/gitignore similarity index 100% rename from template/gitignore rename to packages/react-scripts/template/gitignore diff --git a/template/index.html b/packages/react-scripts/template/index.html similarity index 100% rename from template/index.html rename to packages/react-scripts/template/index.html diff --git a/template/src/App.css b/packages/react-scripts/template/src/App.css similarity index 100% rename from template/src/App.css rename to packages/react-scripts/template/src/App.css diff --git a/template/src/App.js b/packages/react-scripts/template/src/App.js similarity index 100% rename from template/src/App.js rename to packages/react-scripts/template/src/App.js diff --git a/template/src/App.test.js b/packages/react-scripts/template/src/App.test.js similarity index 100% rename from template/src/App.test.js rename to packages/react-scripts/template/src/App.test.js diff --git a/template/src/favicon.ico b/packages/react-scripts/template/src/favicon.ico similarity index 100% rename from template/src/favicon.ico rename to packages/react-scripts/template/src/favicon.ico diff --git a/template/src/index.css b/packages/react-scripts/template/src/index.css similarity index 100% rename from template/src/index.css rename to packages/react-scripts/template/src/index.css diff --git a/template/src/index.js b/packages/react-scripts/template/src/index.js similarity index 100% rename from template/src/index.js rename to packages/react-scripts/template/src/index.js diff --git a/template/src/logo.svg b/packages/react-scripts/template/src/logo.svg similarity index 100% rename from template/src/logo.svg rename to packages/react-scripts/template/src/logo.svg diff --git a/tasks/cra.sh b/tasks/cra.sh index 726c6de8499..1fd60f6a221 100755 --- a/tasks/cra.sh +++ b/tasks/cra.sh @@ -85,7 +85,7 @@ scripts_path=$clean_path/`npm pack` # Go back to the root directory and run the command from here cd $root_path -node global-cli/index.js --scripts-version=$scripts_path "$@" +node packages/create-react-app/index.js --scripts-version=$scripts_path "$@" # Cleanup cleanup diff --git a/tasks/e2e.sh b/tasks/e2e.sh index 0cd92b0d25e..4d6e70b4fe3 100755 --- a/tasks/e2e.sh +++ b/tasks/e2e.sh @@ -18,7 +18,7 @@ function cleanup { echo 'Cleaning up.' cd $root_path # Uncomment when snapshot testing is enabled by default: - # rm ./template/src/__snapshots__/App.test.js.snap + # rm ./packages/react-scripts/template/src/__snapshots__/App.test.js.snap rm -rf $temp_cli_path $temp_app_path $clean_path } @@ -81,8 +81,7 @@ npm start -- --smoke-test # ****************************************************************************** # Pack CLI (it doesn't need cleaning) -cd global-cli -npm install +cd packages/create-react-app cli_path=$PWD/`npm pack` # Packing react-scripts takes more work because we want to clean it up first. diff --git a/tasks/release.sh b/tasks/release.sh index 83c9fefada0..8177688c4c0 100755 --- a/tasks/release.sh +++ b/tasks/release.sh @@ -46,7 +46,7 @@ clean_path=`mktemp -d 2>/dev/null || mktemp -d -t 'clean_path'` # Copy some of the project files to the temporary folder. # Exclude folders that definitely won’t be part of the package from processing. # We will strip the dev-only code there, and publish from it. -rsync -av --exclude='.git' --exclude=$clean_path\ +rsync -av --exclude=$clean_path\ --exclude='node_modules' --exclude='build'\ './' $clean_path >/dev/null cd $clean_path @@ -64,6 +64,7 @@ rm -rf ~/.npm npm cache clear npm install +cd packages/react-scripts # Force dedupe npm dedupe @@ -72,10 +73,12 @@ npm dedupe rm -rf node_modules/fsevents # This modifies $clean_path/package.json to copy all dependencies to bundledDependencies -node $root_path/node_modules/.bin/bundle-deps +node ./node_modules/.bin/bundle-deps + +cd $clean_path # Go! -npm publish "$@" +./node_modules/.bin/lerna publish --independent "$@" # cleanup cd ..