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 15 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: 26 additions & 20 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 @@ -57,25 +63,25 @@ jobs:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- run:
name: "Install root dependencies"
name: "Install yarn 1.0.0-prerelease"
command: |
yarn install
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly
- 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 @@ -85,23 +91,23 @@ jobs:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- run:
name: "Install root dependencies"
name: "Install yarn 1.0.0-prerelease"
command: |
yarn install
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly
- 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 +116,10 @@ jobs:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- 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 +132,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 @@ -147,17 +153,17 @@ jobs:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- run:
name: "Install root dependencies"
name: "Install yarn 1.0.0-prerelease"
command: |
yarn install
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly
- 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
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Thanks for your interest in improving Storybook! We are a community-driven proje

Please review this document to help to streamline the process and save everyone's precious time.

This guide assumes you're using `yarn` as package manager. You may have some success using `npm` as well, but there are chances you'll get wrong versions of root dependencies in that case (we only commit `yarn.lock` to the repo).
This repo uses yarn workspaces, so you should `yarn@1.0.0` or higher as package manager. See [installation guide](<>).

## Issues

Expand Down Expand Up @@ -35,7 +35,7 @@ The bootstrap command will ask which sections of the codebase you want to bootst

You can also pick directly from CLI:

yarn bootstrap -- --core
yarn bootstrap --core

#### 2a. Run unit tests

Expand All @@ -52,7 +52,7 @@ _Note that in order to run the tests fro ReactNative, you must have bootstrapped
You can also pick suites from CLI:

```sh
yarn test -- --core
yarn test --core
```

In order to run ALL unit tests, you must have bootstrapped the react-native
Expand Down Expand Up @@ -224,7 +224,7 @@ git status

# clean out extra files & build all the packages
# WARNING: destructive if you have extra files lying around!
yarn bootstrap -- --reset --all
yarn bootstrap --reset --all
```

From here there are different procedures for prerelease (e.g. alpha/beta/rc) and proper release.
Expand All @@ -235,7 +235,7 @@ From here there are different procedures for prerelease (e.g. alpha/beta/rc) and

```sh
# publish and tag the release
yarn run publish -- --concurrency 1 --npm-tag=alpha
yarn run publish --concurrency 1 --npm-tag=alpha

# push the tags
git push --tags
Expand All @@ -245,7 +245,7 @@ git push --tags

```sh
# publish but don't commit to git
yarn publish -- --concurrency 1 --skip-git
yarn run publish --concurrency 1 --skip-git

# Update `CHANGELOG.md`
# - Edit PR titles/labels on github until output is good
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ We welcome contributions to Storybook!
- `yarn lint:js` - will check js
- `yarn lint:md` - will check markdown + code samples

- `yarn lint:js -- --fix` - will automatically fix js
- `yarn lint:md -- -o` - will automatically fix markdown
- `yarn lint:js --fix` - will automatically fix js
- `yarn lint:md -o` - will automatically fix markdown

#### `yarn test`

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 @@ b64@2.x.x:
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"
"vue-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
Loading