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 1 commit
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
34 changes: 12 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,36 @@ dependencies:
pre:
- yarn global add npm
jobs:
validate:
<<: *defaults
steps:
- run:
name: "Checking Versions"
command: |
node --version
npm --version
yarn --version
Copy link
Member Author

Choose a reason for hiding this comment

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

why?

Copy link
Member

Choose a reason for hiding this comment

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

yarn version won't print the correct version anymore, This script isn't providing value really.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe comment it instead? To reenable once docker image gets updated

Copy link
Member

Choose a reason for hiding this comment

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

Meh, it's really not useful the info is in the logs anyway.

build:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-{{ checksum "yarn.lock" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
command: |
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly
curl -o- -L https://yarnpkg.com/install.sh | bash -s
- run:
name: "Install root dependencies"
command: |
yarn install
- save_cache:
key: root-dependencies-{{ checksum "package.json" }}
key: root-dependencies-{{ checksum "yarn.lock" }}
paths:
- node_modules
- restore_cache:
keys:
- package-dependencies-{{ checksum "package.json" }}
- package-dependencies-{{ checksum "yarn.lock" }}
- package-dependencies-
- run:
name: "Bootstrapping"
command: |
yarn bootstrap --all
yarn bootstrap --core --docs --reactnative --reactnativeapp
Copy link
Member Author

@Hypnosphi Hypnosphi Sep 29, 2017

Choose a reason for hiding this comment

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

What was wrong with --all?
Oh I see, the reset step would remove the cache

- save_cache:
key: package-dependencies-{{ checksum "package.json" }}
key: package-dependencies-{{ checksum "yarn.lock" }}
paths:
- app/**/node_modules
- docs/**/node_modules
Expand All @@ -60,7 +51,7 @@ jobs:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-{{ checksum "yarn.lock" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
Expand Down Expand Up @@ -88,7 +79,7 @@ jobs:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-{{ checksum "yarn.lock" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
Expand All @@ -114,7 +105,7 @@ jobs:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-{{ checksum "yarn.lock" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
Expand All @@ -134,7 +125,7 @@ jobs:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-{{ checksum "yarn.lock" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
Expand All @@ -154,7 +145,7 @@ jobs:
- checkout
- restore_cache:
keys:
- root-dependencies-{{ checksum "package.json" }}
- root-dependencies-{{ checksum "yarn.lock" }}
- root-dependencies-
- run:
name: "Install yarn 1.0.0-prerelease"
Expand All @@ -180,7 +171,6 @@ workflows:
version: 2
build_accept_deploy:
jobs:
- validate
- build
- example-kitchen-sinks
- example-react-native
Expand All @@ -192,4 +182,4 @@ workflows:
# requires:
# - lint
# - unit-test
# - docs
# - docs
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"scripts": {
"bootstrap": "./scripts/bootstrap.js",
"bootstrap:core": "yarn install && lerna run prepublish && node ./scripts/hoist-internals.js",
"bootstrap:core": "lerna bootstrap -–use-workspaces",
"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",
Expand Down Expand Up @@ -126,4 +126,4 @@
"other": "Other"
}
}
}
}
19 changes: 14 additions & 5 deletions scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -71,6 +77,9 @@ const tasks = {
defaultValue: true,
option: '--core',
command: () => {
log.info(prefix, 'prepublish');
spawn('lerna run prepublish -- --silent');
Copy link
Member Author

Choose a reason for hiding this comment

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

this won't work without global lerna installed

Copy link
Member Author

Choose a reason for hiding this comment

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

and without some package deps like babel as well

Copy link
Member

Choose a reason for hiding this comment

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

isn't lerna a local dependency?

Copy link
Member Author

@Hypnosphi Hypnosphi Sep 7, 2017

Choose a reason for hiding this comment

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

Hmm, yes, didn't know you can run local deps with spawn. The problem is that we effectively yarn install two times in this setup. Why not just once?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, you can't run bootstrap script without root dependencies anyway

log.info(prefix, 'yarn workspace');
spawn('yarn bootstrap:core');
},
}),
Expand Down
22 changes: 10 additions & 12 deletions scripts/prepublish.js
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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}`)}`));
Loading