Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn workspaces #1810

Merged
merged 27 commits into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4d10a55
Introduce yarn workspaces
Hypnosphi Sep 6, 2017
adb20c6
Add export PATH
Hypnosphi Sep 6, 2017
dc0bd90
Merge remote-tracking branch 'upstream/release/3.3' into yarn-workspaces
Hypnosphi Sep 6, 2017
2486947
update lockfile
Hypnosphi Sep 6, 2017
b4d9ee0
add BASH_ENV
Hypnosphi Sep 6, 2017
d22f209
add BASH_ENV
Hypnosphi Sep 6, 2017
cd7472a
CI: Temporarily disable all steps but lint
Hypnosphi Sep 6, 2017
51363c2
Enable all the steps back, extract environment into defaults
Hypnosphi Sep 6, 2017
78a42a8
Use --cwd flag for bootstrapping docs
Hypnosphi Sep 6, 2017
2308e98
Use yarn scripts where possible, omitting extra `--` because now we can
Hypnosphi Sep 6, 2017
fee27b5
Update documentation
Hypnosphi Sep 6, 2017
6d37521
Fix lerna.json
Hypnosphi Sep 6, 2017
d846b0c
Merge branch 'release/3.3' into yarn-workspaces
Hypnosphi Sep 6, 2017
5d8e07e
CI: Remove "Install root dependencies" phase where possible, as it's …
Hypnosphi Sep 6, 2017
75b0076
Merge branch 'release/3.3' into yarn-workspaces
Hypnosphi Sep 6, 2017
181878d
CI: use yarn nightly in docs task
Hypnosphi Sep 6, 2017
cc9ab25
Merge branch 'release/3.3' into yarn-workspaces
Hypnosphi Sep 7, 2017
5382fcb
IMPROVE yarn workspaces setup
ndelangen Sep 7, 2017
8df6f4d
CHANGE package.json.engines
ndelangen Sep 7, 2017
fe9ee4e
CI: use latest yarn instead of nightly. Cache all the dependencies to…
Hypnosphi Sep 7, 2017
38011e8
CI: bring back install phase, as it's needed for bootstrap script
Hypnosphi Sep 8, 2017
f343861
bootstrap: use `yarn install` directly
Hypnosphi Sep 8, 2017
f3046d5
CI: bootstrap --core isn't needed for react-native examples, `npm pac…
Hypnosphi Sep 8, 2017
824bbd6
Replace the deprecated `prepublish` script with `prepare`
Hypnosphi Sep 8, 2017
11298bf
Revert "CI: bootstrap --core isn't needed for react-native examples, …
Hypnosphi Sep 8, 2017
088c5f8
Merge branch 'release/3.3' into yarn-workspaces
Hypnosphi Sep 8, 2017
bd31e8b
Merge remote-tracking branch 'upstream/release/3.3' into yarn-workspaces
Hypnosphi Sep 8, 2017
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
46 changes: 36 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defaults: &defaults
working_directory: /tmp/storybook
docker:
- image: node:8
environment:
BASH_ENV: ~/.bashrc

version: 2
dependencies:
Expand All @@ -25,6 +27,10 @@ jobs:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
command: |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly
- run:
name: "Install root dependencies"
command: |
Expand All @@ -40,7 +46,7 @@ jobs:
- run:
name: "Bootstrapping"
command: |
yarn bootstrap -- --all
yarn bootstrap --all
- save_cache:
key: package-dependencies-{{ checksum "package.json" }}
paths:
Expand All @@ -56,26 +62,30 @@ jobs:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
command: |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly
- run:
name: "Install root dependencies"
command: |
yarn install
- run:
name: "Bootstrapping"
command: |
yarn bootstrap -- --core
yarn bootstrap --core
- run:
name: "Build react kitchen-sink"
command: |
cd examples/cra-kitchen-sink
yarn build-storybook
yarn storybook -- --smoke-test
yarn storybook --smoke-test
- run:
name: "Build vue kitchen-sink"
command: |
cd examples/vue-kitchen-sink
yarn build-storybook
yarn storybook -- --smoke-test
yarn storybook --smoke-test
example-react-native:
<<: *defaults
steps:
Expand All @@ -84,24 +94,28 @@ jobs:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
command: |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly
- run:
name: "Install root dependencies"
command: |
yarn install
- run:
name: "Bootstrapping packages"
command: |
yarn bootstrap -- --core --reactnative --reactnativeapp
yarn bootstrap --core --reactnative --reactnativeapp
- run:
name: "Running React-Native example"
command: |
cd examples/react-native-vanilla
yarn storybook -- --smoke-test
yarn storybook --smoke-test
- run:
name: "Running React-Native-App example"
command: |
cd examples/crna-kitchen-sink
yarn storybook -- --smoke-test
yarn storybook --smoke-test
docs:
<<: *defaults
steps:
Expand All @@ -110,14 +124,18 @@ jobs:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
command: |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly
- run:
name: "Install root dependencies"
command: |
yarn install
- run:
name: "Bootstrapping"
command: |
yarn bootstrap -- --docs
yarn bootstrap --docs
- run:
name: "Running docs"
command: |
Expand All @@ -130,6 +148,10 @@ jobs:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
command: |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly
- run:
name: "Install root dependencies"
command: |
Expand All @@ -146,18 +168,22 @@ jobs:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
command: |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly
- run:
name: "Install root dependencies"
command: |
yarn install
- run:
name: "Bootstrapping"
command: |
yarn bootstrap -- --core --reactnative
yarn bootstrap --core --reactnative
- run:
name: "Unit testing"
command: |
yarn test -- --all --coverage --runInBand
yarn test --all --coverage --runInBand
yarn coverage
deploy:
<<: *defaults
Expand Down
3 changes: 3 additions & 0 deletions app/react/bin/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../dist/server/build');
3 changes: 3 additions & 0 deletions app/react/bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../dist/server');
8 changes: 4 additions & 4 deletions app/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"license": "MIT",
"main": "dist/client/index.js",
"bin": {
"build-storybook": "./dist/server/build.js",
"start-storybook": "./dist/server/index.js",
"storybook-server": "./dist/server/index.js"
"build-storybook": "./bin/build.js",
"start-storybook": "./bin/index.js",
"storybook-server": "./bin/index.js"
},
"repository": {
"type": "git",
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"dev": "DEV_BUILD=1 nodemon --watch ./src --exec 'npm run prepublish'",
"dev": "DEV_BUILD=1 nodemon --watch ./src --exec 'yarn prepublish'",
"prepublish": "node ../../scripts/prepublish.js"
},
"dependencies": {
Expand Down
2 changes: 0 additions & 2 deletions app/react/src/server/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

import webpack from 'webpack';
import program from 'commander';
import path from 'path';
Expand Down
2 changes: 0 additions & 2 deletions app/react/src/server/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

import express from 'express';
import https from 'https';
import favicon from 'serve-favicon';
Expand Down
3 changes: 3 additions & 0 deletions app/vue/bin/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../dist/server/build');
3 changes: 3 additions & 0 deletions app/vue/bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../dist/server');
8 changes: 4 additions & 4 deletions app/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"license": "MIT",
"main": "dist/client/index.js",
"bin": {
"build-storybook": "./dist/server/build.js",
"start-storybook": "./dist/server/index.js",
"storybook-server": "./dist/server/index.js"
"build-storybook": "./bin/build.js",
"start-storybook": "bin/index.js",
"storybook-server": "bin/index.js"
Copy link
Member Author

@Hypnosphi Hypnosphi Sep 6, 2017

Choose a reason for hiding this comment

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

This change is needed because yarn needs some files to link as binaries, see https://github.com/storybooks/storybook/pull/1810/files#r137413061

},
"repository": {
"type": "git",
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"dev": "DEV_BUILD=1 nodemon --watch ./src --exec 'npm run prepublish'",
"dev": "DEV_BUILD=1 nodemon --watch ./src --exec 'yarn prepublish'",
"prepublish": "node ../../scripts/prepublish.js"
},
"dependencies": {
Expand Down
2 changes: 0 additions & 2 deletions app/vue/src/server/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

import webpack from 'webpack';
import program from 'commander';
import path from 'path';
Expand Down
2 changes: 0 additions & 2 deletions app/vue/src/server/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

import express from 'express';
import https from 'https';
import favicon from 'serve-favicon';
Expand Down
4 changes: 2 additions & 2 deletions docs/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ [email protected]:
dependencies:
hoek "2.x.x"

babel-cli@^6.24.1:
babel-cli@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.26.0.tgz#502ab54874d7db88ad00b887a06383ce03d002f1"
dependencies:
Expand Down Expand Up @@ -1266,7 +1266,7 @@ babel-plugin-transform-undefined-to-void@^6.8.3:
version "6.8.3"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-undefined-to-void/-/babel-plugin-transform-undefined-to-void-6.8.3.tgz#fc52707f6ee1ddc71bb91b0d314fbefdeef9beb4"

babel-polyfill@^6.23.0, babel-polyfill@^6.26.0:
babel-polyfill@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153"
dependencies:
Expand Down
18 changes: 3 additions & 15 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
{
"lerna": "2.0.0",
"npmClient": "yarn",
"useWorkspaces": true,
"commands": {
"bootstrap": {
"ignore": [
"crna-kitchen-sink",
"react-native-vanilla"
]
},
"publish": {
"ignore": [
"cra-kitchen-sink",
"crna-kitchen-sink",
Copy link
Member

Choose a reason for hiding this comment

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

@Hypnosphi we don't need these because ... "private: true" in package.json?

Copy link
Member Author

@Hypnosphi Hypnosphi Sep 6, 2017

Choose a reason for hiding this comment

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

"react-native-vanilla",
"vue-example"
"crna-kitchen-sink"
]
}
},
"packages": [
Copy link
Member

Choose a reason for hiding this comment

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

@Hypnosphi why don't we need this anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

https://github.com/lerna/lerna#--use-workspaces

If --use-workspaces is true then packages will be overridden by the value from package.json/workspaces.

"addons/*",
"app/*",
"lib/*",
"examples/*"
],
"concurrency": 1,
"version": "3.3.0-alpha.0"
}
21 changes: 15 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
{
"private": true,
"name": "storybook",
"version": "3.0.0",
"repository": {
"type": "git",
"url": "https://github.com/storybooks/storybook.git"
},
"workspaces": [
"addons/*",
"app/*",
"lib/*",
"examples/cra-kitchen-sink",
"examples/vue-kitchen-sink"
],
"scripts": {
"bootstrap": "./scripts/bootstrap.js",
"bootstrap:core": "lerna bootstrap --concurrency 1 --npm-client=\"yarn\" --hoist && node ./scripts/hoist-internals.js",
"bootstrap:docs": "cd docs && yarn install",
"bootstrap:core": "yarn install && lerna run prepublish && node ./scripts/hoist-internals.js",
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, at the moment yarn doesn't run lifecycle hooks when bootstrapping workspaces: yarnpkg/yarn#3911
That's why we need lerna run prepublish here

Copy link
Member Author

Choose a reason for hiding this comment

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

We can probably now remove yarn install step from yarn bootstrap --reset task, as it runs anyway as part of yarn bootstrap --core

"bootstrap:docs": "yarn install --cwd docs",
"bootstrap:react-native-vanilla": "npm --prefix examples/react-native-vanilla install",
"bootstrap:crna-kitchen-sink": "npm --prefix examples/crna-kitchen-sink install",
"build-packs": "lerna exec --scope '@storybook/*' --parallel -- ../../scripts/build-pack.sh ../../packs",
Expand All @@ -23,7 +31,7 @@
"docs:deploy:manual": "cd docs && npm run deploy:manual",
"docs:dev": "cd docs && npm run dev",
"github-release": "github-release-from-changelog",
"lint": "npm run lint:js . && npm run lint:md .",
"lint": "yarn lint:js . && yarn lint:md .",
"lint:js": "eslint --cache --cache-location=.cache/eslint --ext .js,.jsx,.json",
"lint:md": "remark",
"publish": "lerna publish",
Expand Down Expand Up @@ -80,7 +88,8 @@
"symlink-dir": "^1.1.0"
},
"engines": {
"node": "node"
"node": "^8.0.0",
Copy link
Member Author

@Hypnosphi Hypnosphi Sep 6, 2017

Choose a reason for hiding this comment

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

This just states the limitation we have de facto

"yarn": "^1.0.0-0"
},
"collective": {
"type": "opencollective",
Expand All @@ -89,11 +98,11 @@
"lint-staged": {
"linters": {
"*.js": [
"npm run lint:js -- --fix",
"yarn lint:js --fix",
"git add"
],
"*.json": [
"npm run lint:js -- --fix",
"yarn lint:js --fix",
"git add"
],
"*.md": [
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately when I try to use yarn for *.md tasks, yarn precommit hangs

Copy link
Member

Choose a reason for hiding this comment

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

Expand Down
2 changes: 1 addition & 1 deletion scripts/hoist-internals.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ log.addLevel('success', 3001, { fg: 'green', bold: true });
log.info(prefix, 'Hoisting internal packages');

const getLernaPackages = () =>
fse.readJson(path.join(__dirname, '..', 'lerna.json')).then(json => json.packages);
fse.readJson(path.join(__dirname, '..', 'package.json')).then(json => json.workspaces);
Copy link
Member Author

Choose a reason for hiding this comment

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

I've noticed that this script always yields Hoisted 0 packages. So either something is broken, or yarn does what's needed. @ndelangen can you please check?

Copy link
Member

Choose a reason for hiding this comment

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

I think yarn workspaces already hoists everything?

Copy link
Member Author

@Hypnosphi Hypnosphi Sep 6, 2017

Choose a reason for hiding this comment

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

Looks like that, I just want to be sure about this

Copy link
Member

Choose a reason for hiding this comment

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

This entire script can be removed if this PR comes thru

const passingLog = fn => i => {
fn(i);
return i;
Expand Down
8 changes: 7 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
version "16.0.5"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.0.5.tgz#d713cf67cc211dea20463d2a0b66005c22070c4b"

"@types/react@^15.0.21", "@types/react@^15.0.22":
"@types/react@^15.0.21", "@types/react@^15.0.22", "@types/react@^15.0.24":
version "15.6.2"
resolved "https://registry.yarnpkg.com/@types/react/-/react-15.6.2.tgz#2c8495aa853cb37591d0046e9afe544fb837c612"

Expand Down Expand Up @@ -6613,6 +6613,12 @@ [email protected]:
dependencies:
jest-cli "^20.0.3"

jest@^20.0.4:
version "20.0.4"
resolved "https://registry.yarnpkg.com/jest/-/jest-20.0.4.tgz#3dd260c2989d6dad678b1e9cc4d91944f6d602ac"
dependencies:
jest-cli "^20.0.4"

jest@^21.0.1:
version "21.0.1"
resolved "https://registry.yarnpkg.com/jest/-/jest-21.0.1.tgz#746cddc89477beaea5b208e7017ca26652bfdb38"
Expand Down