Skip to content

Commit

Permalink
chore: migrate repository from npm to "yarn workspaces" (aws#4588)
Browse files Browse the repository at this point in the history
This brings speed and reliability improvements with respects to the
installation of dependencies.
  • Loading branch information
RomainMuller authored Oct 29, 2019
1 parent 0b3c3d2 commit 24a6416
Show file tree
Hide file tree
Showing 303 changed files with 9,335 additions and 186,980 deletions.
2 changes: 1 addition & 1 deletion .dependabot/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ update_configs:
- match:
# Don't suggest upgrading @types/node to versions >= 9
dependency_name: '@types/node'
version_requirement: '>= 9'
version_requirement: '>= 11'
version_requirement_updates: increase_versions
default_labels: []
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Helps with using npm package-locally, while in a yarn workflow (avoids coupling scripts to yarn).
# This is needed because yarn goes out of it's way to ensure it controls what `node` binary is used (for good!)
scripts-prepend-node-path=auto
4 changes: 4 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This is required as the *current* CodeBuild image has node8, but we "require" node 10.
# The whole file can be dropped once the new Docker image is released.
--install.ignore-engines true
--run.ignore-engines true
25 changes: 12 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ and let us know if it's not up-to-date (even better, submit a PR with your corr
## Getting Started

For day-to-day development and normal contributions, [Node.js ≥ 10.3.0](https://nodejs.org/download/release/latest-v10.x/)
should be sufficient.
with [Yarn >= 1.19.1](https://yarnpkg.com/lang/en/docs/install) should be sufficient.

```console
$ git clone git@github.com:aws/aws-cdk.git
Expand Down Expand Up @@ -193,8 +193,7 @@ fixed for you by hitting `Ctrl-.` when your cursor is on a red underline.

The build process is divided into stages, so you can invoke them as needed:

- __`install.sh`__: installs all external dependencies and symlinks internal dependencies (using `lerna link`).
- __`build.sh`__: runs `npm build` and `npm test` in all modules (in topological order).
- __`build.sh`__: runs `yarn build` and `yarn test` in all modules (in topological order).
- __`pack.sh`__: packages all modules to all supported languages and produces a `dist/` directory with all the outputs
(running this script requires that you installed the [toolchains](#Toolchains) for all target languages on your
system).
Expand All @@ -214,11 +213,11 @@ You can also add a few useful aliases to your shell profile:
# runs an npm script via lerna for a the current module
alias lr='lerna run --stream --scope $(node -p "require(\"./package.json\").name")'

# runs "npm run build" (build + test) for the current module
# runs "yarn build" (build + test) for the current module
alias lb='lr build'
alias lt='lr test'

# runs "npm run watch" for the current module (recommended to run in a separate terminal session):
# runs "yarn watch" for the current module (recommended to run in a separate terminal session):
alias lw='lr watch'
```

Expand Down Expand Up @@ -254,9 +253,9 @@ the [guidelines](./design/aws-guidelines.md).

Here are a few useful commands:

* `npm run awslint` in every module will run __awslint__ for that module.
* `npm run awslint list` prints all rules (details and rationale in the guidelines doc)
* `scripts/foreach.sh npm run awslint` will start linting the entire repo, progressively. Rerun `scripts/foreach.sh` after fixing to continue.
* `yarn awslint` in every module will run __awslint__ for that module.
* `yarn awslint list` prints all rules (details and rationale in the guidelines doc)
* `scripts/foreach.sh yarn awslint` will start linting the entire repo, progressively. Rerun `scripts/foreach.sh` after fixing to continue.
* `lerna run awslint --no-bail --stream 2> awslint.txt` will run __awslint__ in all modules and collect all results into awslint.txt
* `lerna run awslint -- -i <RULE>` will run awslint throughout the repo and
evaluate only the rule specified [awslint README](./tools/awslint/README.md)
Expand All @@ -275,7 +274,7 @@ between those.

Each module also has an npm script called `cfn2ts`:

* `npm run cfn2ts`: generates L1 for a specific module
* `yarn cfn2ts`: generates L1 for a specific module
* `lerna run cfn2ts`: generates L1 for the entire repo

### scripts/foreach.sh
Expand Down Expand Up @@ -409,7 +408,7 @@ One can use the `postinstall` script to symlink this repo:
```

This assumes this repo is a sibling of the target repo and will install the CDK as a linked dependency during
__npm install__.
__yarn install__.

### Running integration tests in parallel

Expand Down Expand Up @@ -437,8 +436,8 @@ $ cdk -a some.app.js synth | $awscdk/scripts/template-deps-to-dot | dot -Tpng >
The root [package.json](./package.json) includes global devDependencies (see
[lerna docs](https://github.com/lerna/lerna#common-devdependencies)) on the topic.

* To add a global dependency, run `npm i --save-dev <dep>` at the root.
* To add a dependency for a specific module, run `npm i <dep>` inside the module's directory.
* To add a global dependency, run `yarn add <dep> --dev` at the root.
* To add a dependency for a specific module, run `yarn add <dep>` inside the module's directory.

Guidelines:

Expand Down Expand Up @@ -557,7 +556,7 @@ $ CDK_TEST_BUILD=false lr test
To debug your CDK application along with the CDK repository,

1. Clone the CDK repository locally and build the repository. See [Workflows](#workflows) section for the different build options.
2. Build the CDK application using the appropriate npm script (typically, `npm run build`) and then run the `link-all.sh` script as so -
2. Build the CDK application using the appropriate npm script (typically, `yarn build`) and then run the `link-all.sh` script as so -

```
cd /path/to/cdk/app
Expand Down
12 changes: 6 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ while [[ "${1:-}" != "" ]]; do
shift
done

if [ ! -d node_modules ]; then
/bin/bash ./install.sh
fi
export PATH=$(npm bin):$PATH
export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}"

echo "============================================================================================="
echo "installing..."
yarn install

fail() {
echo "❌ Last command failed. Scroll up to see errors in log (search for '!!!!!!!!')."
Expand All @@ -43,9 +46,6 @@ fail() {
BUILD_INDICATOR=".BUILD_COMPLETED"
rm -rf $BUILD_INDICATOR

export PATH=$(npm bin):$PATH
export NODE_OPTIONS="--max-old-space-size=4096 ${NODE_OPTIONS:-}"

# Speed up build by reusing calculated tree hashes
# On dev machine, this speeds up the TypeScript part of the build by ~30%.
export MERKLE_BUILD_CACHE=$(mktemp -d)
Expand Down
4 changes: 3 additions & 1 deletion buildspec-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ version: 0.2
phases:
install:
commands:
- /bin/bash ./install.sh
# Install yarn if it wasn't already present in the image
- yarn --version || npm -g install yarn
- yarn install --frozen-lockfile
build:
commands:
- /bin/bash ./build.sh && git diff-index --exit-code --ignore-space-at-eol --stat HEAD
4 changes: 3 additions & 1 deletion buildspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ version: 0.2
phases:
install:
commands:
- /bin/bash ./install.sh
# Install yarn if it wasn't already present in the image
- yarn --version || npm -g install yarn
- yarn install --frozen-lockfile
pre_build:
commands:
- /bin/bash ./fetch-dotnet-snk.sh
Expand Down
25 changes: 0 additions & 25 deletions install.sh

This file was deleted.

2 changes: 2 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"lerna": "3.15.0",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*",
"packages/@aws-cdk/*",
Expand Down
Loading

0 comments on commit 24a6416

Please sign in to comment.