Set up a monorepo with Lerna

This commit is contained in:
Ville Immonen
2016-09-19 02:12:19 +03:00
committed by Dan Abramov
parent 36d68680c1
commit 26464096d5
46 changed files with 114 additions and 94 deletions

View File

@@ -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, {

2
.gitignore vendored
View File

@@ -4,3 +4,5 @@ build
*.tgz
my-app*
template/src/__tests__/__snapshots__/
lerna-debug.log
npm-debug.log

View File

@@ -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

View File

@@ -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 dont have any changes to the `global-cli` folder, you dont need to bump its version or publish it.
4. Note that files in `global-cli` should be modified with extreme caution. Since its 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 dont have any changes to the `packages/create-react-app` folder, you dont 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 its 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. Dont worry that its 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. Dont worry that its 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`.
------------

4
lerna.json Normal file
View File

@@ -0,0 +1,4 @@
{
"lerna": "2.0.0-beta.28",
"version": "independent"
}

View File

@@ -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"
}
}

View File

@@ -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'),

View File

@@ -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"
}
}

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -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

View File

@@ -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
}
@@ -85,8 +85,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.

View File

@@ -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 wont 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 ..