Skip to content

Commit

Permalink
test: demonstrate dev dependencies between workspace projects
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jan 12, 2025
1 parent 6cf2dc8 commit 1686081
Show file tree
Hide file tree
Showing 22 changed files with 309 additions and 23 deletions.
1 change: 1 addition & 0 deletions e2e/pnpm_lockfiles/.bazelignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
cases/node_modules
projects/a/node_modules
projects/a-types/node_modules
projects/b/node_modules
projects/c/node_modules
projects/d/node_modules
Expand Down
5 changes: 4 additions & 1 deletion e2e/pnpm_lockfiles/lockfile-test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@ WKSP_FILES = {
"repositories.bzl": "@REPO_NAME//:repositories.bzl",
}

def lockfile_test(name = None):
def lockfile_test(npm_link_all_packages, name = None):
"""
Tests for a lockfile and associated targets + files generated by rules_js.
Args:
name: the lockfile version name
npm_link_all_packages: the npm_link_all_packages function
"""

lock_version = name if name else native.package_name()
lock_repo = "lock-%s" % lock_version

npm_link_all_packages(name = "node_modules")

# Copy each test to this lockfile dir
for test in ["patched-dependencies-test.js", "aliases-test.js"]:
copy_file(
Expand Down
10 changes: 10 additions & 0 deletions e2e/pnpm_lockfiles/projects/a-types/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")

js_library(
name = "pkg",
srcs = [
"a.d.ts",
"package.json",
],
visibility = ["//visibility:public"],
)
1 change: 1 addition & 0 deletions e2e/pnpm_lockfiles/projects/a-types/a.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const A: number
7 changes: 7 additions & 0 deletions e2e/pnpm_lockfiles/projects/a-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "a-types",
"private": true,
"dependencies": {
"@types/node": "16.18.11"
}
}
4 changes: 4 additions & 0 deletions e2e/pnpm_lockfiles/projects/b/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
"private": true,
"dependencies": {
"@scoped/a": "workspace:*"
},
"devDependencies": {
"@types/node": "16.18.11",
"a-types": "workspace:*"
}
}
4 changes: 1 addition & 3 deletions e2e/pnpm_lockfiles/v54/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
load("@lock-v54//:defs.bzl", "npm_link_all_packages")
load("//:lockfile-test.bzl", "lockfile_test")

npm_link_all_packages()

lockfile_test()
lockfile_test(npm_link_all_packages = npm_link_all_packages)
12 changes: 11 additions & 1 deletion e2e/pnpm_lockfiles/v54/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 55 additions & 1 deletion e2e/pnpm_lockfiles/v54/snapshots/defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion e2e/pnpm_lockfiles/v54/snapshots/repositories.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions e2e/pnpm_lockfiles/v60/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
load("@lock-v60//:defs.bzl", "npm_link_all_packages")
load("//:lockfile-test.bzl", "lockfile_test")

npm_link_all_packages()

lockfile_test()
lockfile_test(npm_link_all_packages = npm_link_all_packages)
14 changes: 13 additions & 1 deletion e2e/pnpm_lockfiles/v60/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 55 additions & 1 deletion e2e/pnpm_lockfiles/v60/snapshots/defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion e2e/pnpm_lockfiles/v60/snapshots/repositories.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions e2e/pnpm_lockfiles/v61/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
load("@lock-v61//:defs.bzl", "npm_link_all_packages")
load("//:lockfile-test.bzl", "lockfile_test")

npm_link_all_packages()

lockfile_test()
lockfile_test(npm_link_all_packages = npm_link_all_packages)
14 changes: 13 additions & 1 deletion e2e/pnpm_lockfiles/v61/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1686081

Please sign in to comment.