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

Support yarn workspace focusing #1084

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ save_default_cache_directories() {

if [[ "$YARN" == "true" ]]; then
if [[ -d "$yarn_cache_dir" ]]; then
if [[ "$YARN_2" == "true" ]] && ! node_modules_enabled "$BUILD_DIR"; then
if [[ "$YARN_2" == "true" ]]; then
cp -RTf "$yarn_cache_dir" "$cache_dir/node/cache/yarn"
else
mv "$yarn_cache_dir" "$cache_dir/node/cache/yarn"
Expand Down
12 changes: 11 additions & 1 deletion lib/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ yarn_2_install() {
echo "Running 'yarn install' with yarn.lock"
cd "$build_dir" || return

monitor "yarn-2-install" yarn install --immutable 2>&1
if [ -n "$YARN2_FOCUS_WORKSPACE" ]; then
echo "Running focused install for workspace $YARN2_FOCUS_WORKSPACE"
monitor "yarn-2-install" yarn workspaces focus "$YARN2_FOCUS_WORKSPACE"
else
monitor "yarn-2-install" yarn install --immutable 2>&1
fi
}

yarn_prune_devdependencies() {
Expand All @@ -172,6 +177,11 @@ yarn_prune_devdependencies() {
meta_set "skipped-prune" "true"
return 0
fi
if [ -n "$YARN2_FOCUS_WORKSPACE" ]; then
echo "Running focused install with --production flag"
monitor "yarn-prune" yarn workspaces focus --production $YARN2_FOCUS_WORKSPACE
return 0
fi
cd "$build_dir" || return
echo "Running 'yarn heroku prune'"
export YARN_PLUGINS="${buildpack_dir}/yarn2-plugins/prune-dev-dependencies/bundles/@yarnpkg/plugin-prune-dev-dependencies.js"
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/yarn-2-workspaces/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.yarn/*
!.yarn/releases
!.yarn/plugins

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions test/fixtures/yarn-2-workspaces/.yarn/releases/yarn-berry.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions test/fixtures/yarn-2-workspaces/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
nodeLinker: "node-modules"

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: ".yarn/releases/yarn-berry.js"
8 changes: 8 additions & 0 deletions test/fixtures/yarn-2-workspaces/apps/server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@sample/server",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"express": "^4.18.2"
}
}
8 changes: 8 additions & 0 deletions test/fixtures/yarn-2-workspaces/apps/web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@sample/web",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"react": "^18.2.0"
}
}
11 changes: 11 additions & 0 deletions test/fixtures/yarn-2-workspaces/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "yarn-2-workspaces",
"version": "1.0.0",
"workspaces": [
"apps/*"
],
"scripts": {
"start": "echo start"
},
"license": "MIT"
}