Merge branch 'master' into ndelangen/upgrade-react

This commit is contained in:
Filipp Riabchun 2017-09-30 06:21:30 -07:00 committed by GitHub
commit f152c0dcb6
41 changed files with 21507 additions and 277 deletions

View File

@ -6,44 +6,28 @@ defaults: &defaults
version: 2
dependencies:
pre:
- npm install -g npm
- yarn global add npm
jobs:
validate:
<<: *defaults
steps:
- run:
name: "Checking Versions"
command: |
node --version
npm --version
yarn --version
build:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- dependencies-{{ checksum "yarn.lock" }}
- dependencies-
- run:
name: "Install root dependencies"
name: "Install dependencies"
command: |
yarn install
- save_cache:
key: root-dependencies-{{ checksum "package.json" }}
paths:
- node_modules
- restore_cache:
keys:
- package-dependencies-{{ checksum "package.json" }}
- package-dependencies-
- run:
name: "Bootstrapping"
command: |
npm run bootstrap -- --all
yarn bootstrap --core --docs --reactnative --reactnativeapp
- save_cache:
key: package-dependencies-{{ checksum "package.json" }}
key: dependencies-{{ checksum "yarn.lock" }}
paths:
- node_modules
- app/**/node_modules
- docs/**/node_modules
- examples/**/node_modules
@ -54,111 +38,111 @@ jobs:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- dependencies-{{ checksum "yarn.lock" }}
- dependencies-
- run:
name: "Install root dependencies"
name: "Install dependencies"
command: |
yarn install
- run:
name: "Bootstrapping"
command: |
npm run 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:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- dependencies-{{ checksum "yarn.lock" }}
- dependencies-
- run:
name: "Install root dependencies"
name: "Install dependencies"
command: |
yarn install
- run:
name: "Bootstrapping packages"
command: |
npm run 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:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- dependencies-{{ checksum "yarn.lock" }}
- dependencies-
- run:
name: "Install root dependencies"
name: "Install dependencies"
command: |
yarn install
- run:
name: "Bootstrapping"
command: |
npm run bootstrap -- --docs
yarn bootstrap --docs
- run:
name: "Running docs"
command: |
npm run docs:build
yarn docs:build
lint:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- dependencies-{{ checksum "yarn.lock" }}
- dependencies-
- run:
name: "Install root dependencies"
name: "Install dependencies"
command: |
yarn install
- run:
name: "Linting"
command: |
npm run lint
yarn lint
unit-test:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-
- dependencies-{{ checksum "yarn.lock" }}
- dependencies-
- run:
name: "Install root dependencies"
name: "Install dependencies"
command: |
yarn install
- run:
name: "Bootstrapping"
command: |
npm run bootstrap -- --core --reactnative
yarn bootstrap --core --reactnative
- run:
name: "Unit testing"
command: |
npm run test -- --coverage -i
npm run coverage
yarn test --coverage -i
yarn coverage
deploy:
<<: *defaults
steps:
@ -170,7 +154,6 @@ workflows:
version: 2
build_accept_deploy:
jobs:
- validate
- build
- example-kitchen-sinks
- example-react-native

1
.gitignore vendored
View File

@ -12,7 +12,6 @@ coverage/
*.lerna_backup
build
packages/examples/automated-*
yarn.lock
/**/LICENSE
docs/public
packs/*.tgz

View File

@ -4,6 +4,8 @@ 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 repo uses yarn workspaces, so you should `yarn@1.0.0` or higher as package manager. See [installation guide](https://yarnpkg.com/en/docs/install).
## Issues
No software is bug free. So, if you got an issue, follow these steps:
@ -18,25 +20,25 @@ No software is bug free. So, if you got an issue, follow these steps:
### Testing against `master`
To test your project against the current latest version of storybook, you can clone the repository and link it with `npm`. Try following these steps:
To test your project against the current latest version of storybook, you can clone the repository and link it with `yarn`. Try following these steps:
1. Download the latest version of this project, and build it:
```sh
git clone https://github.com/storybooks/storybook.git
cd storybook
npm install
npm run bootstrap -- --core
yarn install
yarn bootstrap --core
```
2. Link `storybook` and any other required dependencies:
```sh
cd app/react
npm link
yarn link
cd <your-project>
npm link @storybook/react
yarn link @storybook/react
# repeat with whichever other parts of the monorepo you are using.
```
@ -51,13 +53,13 @@ A good way to do that is using the example `cra-kitchen-sink` app embedded in th
# Download and build this repository:
git clone https://github.com/storybooks/storybook.git
cd storybook
npm install
npm run bootstrap -- --core
yarn install
yarn bootstrap --core
cd examples/cra-kitchen-sink
# make changes to try and reproduce the problem, such as adding components + stories
npm start storybook
yarn start storybook
# see if you can see the problem, if so, commit it:
git checkout "branch-describing-issue"
@ -71,7 +73,7 @@ git push -u <your-username> master
If you follow that process, you can then link to the github repository in the issue. See <https://github.com/storybooks/storybook/issues/708#issuecomment-290589886> for an example.
**NOTE**: If your issue involves a webpack config, create-react-app will prevent you from modifying the _app's_ webpack config, however you can still modify storybook's to mirror your app's version of storybook. Alternatively, use `npm run eject` in the CRA app to get a modifiable webpack config.
**NOTE**: If your issue involves a webpack config, create-react-app will prevent you from modifying the _app's_ webpack config, however you can still modify storybook's to mirror your app's version of storybook. Alternatively, use `yarn eject` in the CRA app to get a modifiable webpack config.
## Pull Requests (PRs)
@ -82,7 +84,7 @@ We welcome your contributions. There are many ways you can help us. This is few
- Work on [API](https://github.com/storybooks/storybook/labels/enhancement%3A%20api), [Addons](https://github.com/storybooks/storybook/labels/enhancement%3A%20addons), [UI](https://github.com/storybooks/storybook/labels/enhancement%3A%20ui) or [Webpack](https://github.com/storybooks/storybook/labels/enhancement%3A%20webpack) use enhancements and new [features](https://github.com/storybooks/storybook/labels/feature%20request).
- Add more [tests](https://codecov.io/gh/storybooks/storybook/tree/master/packages) (specially for the [UI](https://codecov.io/gh/storybooks/storybook/tree/master/packages/storybook-ui/src)).
Before you submit a new PR, make you to run `npm test`. Do not submit a PR if tests are failing. If you need any help, create an issue and ask.
Before you submit a new PR, make you to run `yarn test`. Do not submit a PR if tests are failing. If you need any help, create an issue and ask.
### Reviewing PRs
@ -136,7 +138,7 @@ This project written in ES2016+ syntax so, we need to transpile it before use.
So run the following command:
```sh
npm run dev
yarn dev
```
This will watch files and transpile in watch mode.
@ -146,14 +148,14 @@ This will watch files and transpile in watch mode.
First of all link this repo with:
```sh
npm link
yarn link
```
In order to test features you add, you may need to link the local copy of this repo.
For that we need a sample project. Let's create it.
```sh
npm install --global create-react-app getstorybook
yarn global add create-react-app getstorybook
create-react-app my-demo-app
cd my-demo-app
getstorybook
@ -165,12 +167,12 @@ getstorybook
Then link storybook inside the sample project with:
```sh
npm link @storybook/react
yarn link @storybook/react
```
### Getting Changes
After you've done any change, you need to run the `npm run storybook` command every time to see those changes.
After you've done any change, you need to run the `yarn storybook` command every time to see those changes.
## Release Guide
@ -212,7 +214,7 @@ yarn bootstrap --reset --core
```sh
# publish and tag the release
npm run publish -- --concurrency 1 --npm-tag=alpha
yarn run publish --concurrency 1 --npm-tag=alpha
# update the release page
open https://github.com/storybooks/storybook/releases
@ -236,7 +238,7 @@ git commit -m "Changelog for vX.Y"
yarn bootstrap --reset --core
# publish and tag the release
npm run publish -- --concurrency 1
yarn run publish --concurrency 1
# update the release page
open https://github.com/storybooks/storybook/releases

View File

@ -92,30 +92,30 @@ We welcome contributions to Storybook!
### Development scripts
#### `npm run bootstrap`
#### `yarn bootstrap`
> Installs package dependencies and links packages together - using lerna
#### `npm run publish`
#### `yarn run publish`
> Push a release to git and npm
> will ask for version in interactive mode - using lerna.
#### `npm run lint`
#### `yarn lint`
> boolean check if code conforms to linting rules - uses remark & eslint
- `npm run lint:js` - will check js
- `npm run lint:md` - will check markdown + code samples
- `yarn lint:js` - will check js
- `yarn lint:md` - will check markdown + code samples
- `npm run lint:js -- --fix` - will automatically fix js
- `yarn lint:js --fix` - will automatically fix js
- `npm run lint:md -- -o` - will automatically fix markdown
#### `npm run test`
#### `yarn test`
> boolean check if unit tests all pass - uses jest
- `npm run test:watch` - will run tests in watch-mode
- `yarn test:watch` - will run tests in watch-mode
### Backers

View File

@ -17,7 +17,7 @@
},
"scripts": {
"deploy-storybook": "storybook-to-ghpages",
"prepublish": "node ../../scripts/prepublish.js",
"prepare": "node ../../scripts/prepare.js",
"storybook": "start-storybook -p 9001"
},
"dependencies": {

View File

@ -6,7 +6,7 @@
"author": "Muhammed Thanish <mnmtanish@gmail.com>",
"main": "dist/index.js",
"scripts": {
"prepublish": "node ../../scripts/prepublish.js"
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"global": "^4.3.2"

View File

@ -16,7 +16,7 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"prepublish": "node ../../scripts/prepublish.js",
"prepare": "node ../../scripts/prepare.js",
"publish-storybook": "bash .scripts/publish_storybook.sh",
"storybook": "start-storybook -p 3006",
"storybook-local": "STORYBOOK_CLOUD_SERVER='http://localhost:3003/graphql' start-storybook -p 9010",

View File

@ -16,7 +16,7 @@
},
"scripts": {
"build-storybook": "build-storybook",
"prepublish": "node ../../scripts/prepublish.js",
"prepare": "node ../../scripts/prepare.js",
"storybook": "start-storybook -p 6006"
},
"dependencies": {

View File

@ -17,7 +17,7 @@
},
"scripts": {
"deploy-storybook": "storybook-to-ghpages",
"prepublish": "node ../../scripts/prepublish.js",
"prepare": "node ../../scripts/prepare.js",
"storybook": "start-storybook -p 9001"
},
"dependencies": {

View File

@ -9,7 +9,7 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"prepublish": "node ../../scripts/prepublish.js",
"prepare": "node ../../scripts/prepare.js",
"publish-storybook": "bash .scripts/publish_storybook.sh",
"storybook": "start-storybook -p 9010"
},

View File

@ -9,9 +9,8 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"prepublish": "node ../../scripts/prepublish.js",
"prepare": "node ../../scripts/prepare.js",
"publish-storybook": "bash .scripts/publish_storybook.sh",
"start": "./example/prepublish.sh",
"storybook": "start-storybook -p 9010"
},
"dependencies": {

View File

@ -17,7 +17,7 @@
},
"scripts": {
"deploy-storybook": "storybook-to-ghpages",
"prepublish": "node ../../scripts/prepublish.js",
"prepare": "node ../../scripts/prepare.js",
"storybook": "start-storybook -p 9001"
},
"dependencies": {

View File

@ -14,7 +14,7 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"prepublish": "node ../../scripts/prepublish.js",
"prepare": "node ../../scripts/prepare.js",
"publish-storybook": "bash .scripts/publish_storybook.sh",
"storybook": "start-storybook -p 9010"
},

View File

@ -16,7 +16,7 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"prepublish": "node ../../scripts/prepublish.js",
"prepare": "node ../../scripts/prepare.js",
"storybook": "start-storybook -p 9001"
},
"dependencies": {

View File

@ -10,7 +10,7 @@
},
"scripts": {
"build-storybook": "build-storybook",
"prepublish": "babel ./src --out-dir ./dist",
"prepare": "babel ./src --out-dir ./dist",
"storybook": "start-storybook -p 6006"
},
"dependencies": {

View File

@ -21,7 +21,7 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"prepublish": "node ../../scripts/prepublish.js"
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@storybook/addon-actions": "^3.2.11",

3
app/react/bin/build.js Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
require('../dist/server/build');

3
app/react/bin/index.js Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
require('../dist/server');

View File

@ -9,17 +9,17 @@
"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'",
"prepublish": "node ../../scripts/prepublish.js"
"dev": "DEV_BUILD=1 nodemon --watch ./src --exec 'yarn prepare'",
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@storybook/addon-actions": "^3.2.11",

View File

@ -1,5 +1,3 @@
#!/usr/bin/env node
import webpack from 'webpack';
import program from 'commander';
import path from 'path';

View File

@ -1,5 +1,3 @@
#!/usr/bin/env node
import express from 'express';
import https from 'https';
import favicon from 'serve-favicon';

3
app/vue/bin/build.js Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
require('../dist/server/build');

3
app/vue/bin/index.js Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
require('../dist/server');

View File

@ -9,17 +9,17 @@
"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'",
"prepublish": "node ../../scripts/prepublish.js"
"dev": "DEV_BUILD=1 nodemon --watch ./src --exec 'yarn prepare'",
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@storybook/addon-actions": "^3.2.11",

View File

@ -1,5 +1,3 @@
#!/usr/bin/env node
import webpack from 'webpack';
import program from 'commander';
import path from 'path';

View File

@ -1,5 +1,3 @@
#!/usr/bin/env node
import express from 'express';
import https from 'https';
import favicon from 'serve-favicon';

View File

@ -5,9 +5,9 @@ This is the source for [storybook.js.org](https://storybook.js.org). It document
### Usage
```sh
npm i
npm run develop
npm run storybook
yarn
yarn develop
yarn storybook
```
### Edit Documentation

8765
docs/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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",
"react-native-vanilla",
"vue-example"
"vue-kitchen-sink"
]
}
},
"packages": [
"addons/*",
"app/*",
"lib/*",
"examples/*"
],
"concurrency": 1,
"version": "3.2.11"
}

View File

@ -16,7 +16,7 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"prepublish": "node ../../scripts/prepublish.js"
"prepare": "node ../../scripts/prepare.js"
},
"devDependencies": {
"shelljs": "^0.7.8"

View File

@ -5,7 +5,7 @@
"license": "MIT",
"main": "dist/index.js",
"scripts": {
"prepublish": "node ../../scripts/prepublish.js"
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@storybook/channels": "^3.2.10",

View File

@ -5,7 +5,7 @@
"license": "MIT",
"main": "dist/index.js",
"scripts": {
"prepublish": "node ../../scripts/prepublish.js"
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"@storybook/channels": "^3.2.10",

View File

@ -5,7 +5,7 @@
"license": "MIT",
"main": "dist/index.js",
"scripts": {
"prepublish": "node ../../scripts/prepublish.js"
"prepare": "node ../../scripts/prepare.js"
},
"devDependencies": {
"shelljs": "^0.7.8"

View File

@ -9,7 +9,7 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"prepublish": "node ../../scripts/prepublish.js"
"prepare": "node ../../scripts/prepare.js"
},
"dependencies": {
"jscodeshift": "^0.3.30"

View File

@ -9,7 +9,7 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"prepublish": "node ../../scripts/prepublish.js",
"prepare": "node ../../scripts/prepare.js",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},

View File

@ -9,7 +9,7 @@
"url": "https://github.com/storybooks/storybook.git"
},
"scripts": {
"prepublish": "node ../../scripts/prepublish.js",
"prepare": "node ../../scripts/prepare.js",
"publish-storybook": "bash ./.scripts/publish_storybook.sh",
"storybook": "start-storybook -p 9010"
},

View File

@ -1,14 +1,21 @@
{
"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: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",
@ -18,12 +25,12 @@
"coverage": "codecov",
"danger": "danger",
"dev": "lerna exec --parallel -- babel src -d dist --ignore tests,__tests__,test.js,stories/,story.jsx --plugins \"transform-runtime\" --copy-files -w",
"docs:build": "cd docs && npm run build",
"docs:deploy:ci": "cd docs && npm run deploy:ci",
"docs:deploy:manual": "cd docs && npm run deploy:manual",
"docs:dev": "cd docs && npm run dev",
"docs:build": "npm --prefix docs run build",
"docs:deploy:ci": "npm --prefix docs run deploy:ci",
"docs:deploy:manual": "npm --prefix docs run deploy:manual",
"docs:dev": "npm --prefix docs 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",
@ -82,7 +89,8 @@
"symlink-dir": "^1.1.0"
},
"engines": {
"node": ">=8.0.0"
"node": ">=8.0.0",
"yarn": ">=1.0.0"
},
"collective": {
"type": "opencollective",
@ -91,11 +99,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": [

25
scripts/bootstrap.js vendored
View File

@ -18,11 +18,17 @@ log.heading = 'storybook';
const prefix = 'bootstrap';
log.addLevel('aborted', 3001, { fg: 'red', bold: true });
const spawn = command => {
const out = childProcess.spawnSync(`${command}`, {
shell: true,
stdio: 'inherit',
});
const spawn = (command, options = {}) => {
const out = childProcess.spawnSync(
`${command}`,
Object.assign(
{
shell: true,
stdio: 'inherit',
},
options
)
);
if (out.status !== 0) {
process.exit(out.status);
@ -56,14 +62,14 @@ const createTask = ({ defaultValue, option, name, check = () => true, command, p
const tasks = {
reset: createTask({
name: `Clean and re-install root dependencies ${chalk.red('(reset)')}`,
name: `Clean and re-install dependencies ${chalk.red('(reset)')}`,
defaultValue: false,
option: '--reset',
command: () => {
log.info(prefix, 'git clean');
spawn('git clean -fdx --exclude=".vscode" --exclude=".idea"');
log.info(prefix, 'yarn install');
spawn('yarn install --no-lockfile');
spawn('yarn install');
},
}),
core: createTask({
@ -71,7 +77,10 @@ const tasks = {
defaultValue: true,
option: '--core',
command: () => {
spawn('yarn bootstrap:core');
log.info(prefix, 'yarn workspace');
spawn('yarn install');
log.info(prefix, 'prepare');
spawn('lerna run prepare -- --silent');
},
}),
docs: createTask({

View File

@ -1,114 +0,0 @@
const path = require('path');
const fs = require('fs-extra');
const fse = require('fs-extra');
const shell = require('shelljs');
const glob = require('glob');
const symlink = require('symlink-dir');
const log = require('npmlog');
const targetPath = path.join(__dirname, '..', 'node_modules', '@storybook');
const prefix = 'hoist-internals';
const cwd = path.join(__dirname, '..');
log.heading = 'lerna+';
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);
const passingLog = fn => i => {
fn(i);
return i;
};
const getPackageOfFolder = sourcePath => fse.readJsonSync(path.join(sourcePath, 'package.json'));
const task = getLernaPackages()
.then(
passingLog(packages => {
log.verbose(prefix, 'working dir paths: %j', cwd);
log.verbose(prefix, 'source paths: %j', packages);
log.verbose(prefix, 'target paths: %j', targetPath);
})
)
.then(packages => `@(${packages.map(s => s.replace('/*', '')).join('|')})/*/`)
.then(
passingLog(pattern => {
log.silly(prefix, 'pattern to look for packages: %j', pattern);
})
)
.then(
pattern =>
new Promise((resolve, reject) => {
glob(pattern, { cwd }, (error, results) => (error ? reject(error) : resolve(results)));
})
)
.then(results =>
Promise.all(
results
.map(sourcePath => path.resolve(fs.realpathSync(sourcePath)))
.reduce((acc, item) => {
if (!acc.includes(item)) {
acc.push(item);
}
return acc;
}, [])
.map(
passingLog(item => {
log.silly(prefix, 'found package path', item);
})
)
.map(sourcePath => ({
sourcePath,
packageJson: getPackageOfFolder(sourcePath),
}))
.filter(({ packageJson }) => !packageJson.private)
.map(({ sourcePath, packageJson }) =>
Promise.resolve(packageJson.name.replace('@storybook/', ''))
.then(packageName => {
log.silly(prefix, 'found package name', packageName);
return path.join(targetPath, packageName);
})
.then(localTargetPath =>
fse
.remove(localTargetPath)
.then(() => symlink(sourcePath, localTargetPath))
.then(
passingLog(() => {
log.silly(prefix, 'symlinked ', [sourcePath, localTargetPath]);
})
)
.then(() => localTargetPath)
.catch(error => {
log.error(prefix, 'symlink', error, [sourcePath, localTargetPath]);
throw new Error('failed symlink');
})
)
)
)
)
.then(locations =>
Promise.all(
locations
.map(location => path.join(location, 'node_modules', '@storybook'))
.map(
passingLog(removePath => {
log.verbose(prefix, 'removing ', removePath);
})
)
.map(removePath => shell.rm('-rf', removePath))
.map(
(item, index) =>
item.code === 0 ? Promise.resolve(locations[index]) : Promise.reject(item)
)
)
);
task
.then(packages => {
log.verbose(prefix, packages.map(dir => dir.replace(cwd, '')).join(',\n'));
log.success(prefix, `Hoisted ${packages.length} packages`);
})
.catch(error => {
log.error(prefix, 'failed', error);
shell.exit(1);
});

View File

@ -1,12 +1,12 @@
const path = require('path');
const shell = require('shelljs');
const chalk = require('chalk');
const log = require('npmlog');
const packageJson = require('../package.json');
const modulePath = path.resolve('./');
// eslint-disable-next-line import/no-dynamic-require
const packageJson = require(path.join(modulePath, 'package.json'));
shell.echo(chalk.bold(`${packageJson.name}@${packageJson.version}`));
shell.echo(chalk.gray('\n=> Clean dist.'));
shell.rm('-rf', 'dist');
const babel = path.join(__dirname, '..', 'node_modules', '.bin', 'babel');
@ -18,16 +18,14 @@ const args = [
].join(' ');
const command = `${babel} ${args}`;
shell.echo(chalk.gray('\n=> Transpiling "src" into ES5 ...\n'));
shell.echo(chalk.gray(command));
shell.echo('');
const code = shell.exec(command).code;
if (code === 0) {
shell.echo(chalk.gray('\n=> Transpiling completed.'));
} else {
const code = shell.exec(command, { silent: true }).code;
if (code !== 0) {
log.error(`FAILED: ${chalk.bold(`${packageJson.name}@${packageJson.version}`)}`);
shell.exit(code);
}
const licence = path.join(__dirname, '..', 'LICENSE');
shell.echo(chalk.gray('\n=> Copy LICENSE.'));
shell.cp(licence, './');
console.log(chalk.gray(`Built: ${chalk.bold(`${packageJson.name}@${packageJson.version}`)}`));

12589
yarn.lock Normal file

File diff suppressed because it is too large Load Diff