Skip to content

Commit

Permalink
Make it super easy to run pnpm from bazel, and remove old scripts fro…
Browse files Browse the repository at this point in the history
…m package.json
  • Loading branch information
Zemnmez committed Dec 26, 2024
1 parent b4233b2 commit e053bb6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ alias(
alias(
name = "pnpm",
# bazel run -- //:pnpm --dir $PWD
actual = "@pnpm//:pnpm",
actual = "//sh/bin:pnpm",
)

alias(
Expand Down
13 changes: 0 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,6 @@
"uuid": "11.0.3",
"yarn": "1.22.22"
},
"scripts": {
"lint": "eslint --fix",
"bazel": "npm run -- bazelisk",
"bazelisk": "npx --yes @bazel/bazelisk",
"ibazel": "npx --yes @bazel/ibazel",
"build": "npm run bazel build //...",
"test": "npm run bazel run //bzl:affected_files",
"fix": "npm run bazel run //:fix",
"dev": "npm run ibazel --run_output --run_output_interactive=false test",
"pr": "gh pr create -f; gh pr merge -md --auto",
"repin": "CARGO_BAZEL_REPIN=1 npm run -- bazel sync --only=cargo",
"pnpm": "npm run -- bazel run -- @pnpm//:pnpm --dir $PWD"
},
"dependencies": {
"@commander-js/extra-typings": "12.1.0",
"@eslint/compat": "1.2.4",
Expand Down
2 changes: 1 addition & 1 deletion sh/bin/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ alias(

alias(
name = "pnpm",
actual = "//:pnpm",
actual = "//sh/pnpm",
)

alias(
Expand Down
20 changes: 20 additions & 0 deletions sh/pnpm/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("//bzl:rules.bzl", "bazel_lint")

sh_binary(
name = "pnpm",
srcs = [
"pnpm_bazel.sh",
],
data = [
"@pnpm",
],
env = {
"PNPM_BINARY": "$(rootpath @pnpm)",
},
visibility = ["//sh:__subpackages__"],
)

bazel_lint(
name = "bazel_lint",
srcs = ["BUILD.bazel"],
)
7 changes: 7 additions & 0 deletions sh/pnpm/pnpm_bazel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
#
# Attaches bazel's workspace directory to pnpm so it can be run directly
# under bazel and it will change the workspace correctly.
#

$PNPM_BINARY --dir "$BUILD_WORKSPACE_DIRECTORY" $@

0 comments on commit e053bb6

Please sign in to comment.