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

fix(pnpm): url and git package specifiers #1754

Closed
wants to merge 2 commits into from
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/pnpm_lockfiles/.bazelignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
cases/node_modules
projects/a/node_modules
projects/b/node_modules
projects/c/node_modules
Expand Down
23 changes: 23 additions & 0 deletions e2e/pnpm_lockfiles/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ local_path_override(
path = "../..",
)

# The same primary lockfile across all versions
PNPM_LOCK_VERSIONS = [
"v54",
"v60",
"v61",
"v90",
]

# Lockfiles with unique test cases
PNPM_LOCK_TEST_CASES = [
"tarball-no-url-v54.yaml",
]

bazel_dep(name = "aspect_bazel_lib", version = "2.7.6")

bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)
Expand Down Expand Up @@ -62,3 +68,20 @@ npm = use_extension(
)
for version in PNPM_LOCK_VERSIONS
]

[
npm.npm_translate_lock(
name = lockfile.replace(".yaml", ""),
pnpm_lock = "//cases:%s" % lockfile,
verify_node_modules_ignored = "//:.bazelignore",
)
for lockfile in PNPM_LOCK_TEST_CASES
]

[
use_repo(
npm,
lockfile.replace(".yaml", ""),
)
for lockfile in PNPM_LOCK_TEST_CASES
]
14 changes: 6 additions & 8 deletions e2e/pnpm_lockfiles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

TODO:

- http references: `"hello": "https://gitpkg.vercel.app/EqualMa/gitpkg-hello/packages/hello"`

Has inconsistencies across pnpm lockfile versions, issues with pnpm9

- file references: `"@scoped/c": "file:../projects/c"`

Has inconsistencies across pnpm lockfile versions, issues with pnpm9

- npm: references: `@aspect-test/a2": "npm:@aspect-test/a"`

No :node_modules/\* targets are generated for aliases to npm packages.

Note: _sometimes_ fails to install with pnpm9

## pnpm lockfile edge cases

Unique test cases hard to cover with normal pnpm workspaces + package.json. Each
test case is a pnpm-lock.yaml with a unique filename, see cases/BUILD for how the test
cases run on each of those lockfiles.
19 changes: 19 additions & 0 deletions e2e/pnpm_lockfiles/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ local_repository(
path = "../..",
)

# The same primary lockfile across all versions
PNPM_LOCK_VERSIONS = [
"v54",
"v60",
"v61",
"v90",
]

# Lockfiles with unique test cases
PNPM_LOCK_TEST_CASES = [
"tarball-no-url-v54.yaml",
]

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()
Expand Down Expand Up @@ -45,3 +51,16 @@ npm_repositories_v60()
npm_repositories_v61()

npm_repositories_v90()

[
npm_translate_lock(
name = lockfile.replace(".yaml", ""),
pnpm_lock = "//cases:%s" % lockfile,
verify_node_modules_ignored = "//:.bazelignore",
)
for lockfile in PNPM_LOCK_TEST_CASES
]

load("@tarball-no-url-v54//:repositories.bzl", npm_repositories_tarball_no_url_v54 = "npm_repositories")

npm_repositories_tarball_no_url_v54()
3 changes: 3 additions & 0 deletions e2e/pnpm_lockfiles/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"private": true,
"dependencies": {
"@aspect-test/a": "^5.0.2",
"debug": "ngokevin/debug#9742c5f383a6f8046241920156236ade8ec30d53",
"hello": "https://gitpkg.vercel.app/EqualMa/gitpkg-hello/packages/hello",
"jsonify": "https://github.com/aspect-build/test-packages/releases/download/0.0.0/@foo-jsonify-0.0.0.tgz",
Copy link
Member

Choose a reason for hiding this comment

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

Are there more from npm/private/test/package.json that should be pulled into e2e/pnpm_lockfiles?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah there probably are. I need to get this PR actually working before I add much more though.

The debug and hello ones are unique cases (odd git syntax, https syntax). The jsonify one is also plain http but has a more interesting URL which requires escaping.

"rollup": "3.2.5",
"meaning-of-life": "1.0.0",
"uvu": "0.5.6",
Expand Down
14 changes: 14 additions & 0 deletions e2e/pnpm_lockfiles/cases/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@tarball-no-url-v54//:defs.bzl", tarball_no_url_link_all = "npm_link_all_packages")

tarball_no_url_link_all(name = "tarball-no-url-v54-modules")

build_test(
name = "tarball-no-url-v54",
targets = [
":tarball-no-url-v54-modules",
":tarball-no-url-v54-modules/@aspect-build/a",
],
)

exports_files(glob(["*.yaml"]))
1 change: 1 addition & 0 deletions e2e/pnpm_lockfiles/cases/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 2 additions & 0 deletions e2e/pnpm_lockfiles/cases/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages:
- '.'
19 changes: 19 additions & 0 deletions e2e/pnpm_lockfiles/cases/tarball-no-url-v54.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
lockfileVersion: 5.4

importers:
.:
specifiers:
'@aspect-build/a': 1.0.0
dependencies:
'@aspect-build/a': 1.0.0

packages:
# This was found in https://github.com/aspect-build/rules_js/blob/795138561e878c09f0b62a25572358d64960d732/e2e/npm_translate_lock_auth/pnpm-lock.yaml
/@aspect-build/a/1.0.0:
resolution:
{
integrity: sha512-MYeL/yqAPYJXOnnSEOAdtQSu/8tiifFtKN6Jg/rgpKRqxKL8NVsQXrX9H2dlJ4mS23pu7VS0+i9mZNiRoCUYwg==,
tarball: '@aspect-test/a/-/a-1.0.0.tgz',
}
hasBin: true
dev: false
16 changes: 15 additions & 1 deletion e2e/pnpm_lockfiles/lockfile-test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,23 @@ def lockfile_test(name = None):
# link:, workspace:, file:, ./rel/path
":node_modules/@scoped/a",
":node_modules/@scoped/b",
# ":node_modules/@scoped/c", TODO: see README
":node_modules/@scoped/c",
":node_modules/@scoped/d",

# http:
":node_modules/debug",
# TODO: differs across lockfile versions
":.aspect_rules_js/node_modules/{}".format("[email protected]+ngokevin+debug+tar.gz+9742c5f383a6f8046241920156236ade8ec30d53" if lock_version == "v90" else "[email protected]+ngokevin+debug+9742c5f383a6f8046241920156236ade8ec30d53"),

# http: with some '@'s in the name + url/version
":node_modules/jsonify",

# repo#hash
# (no protocol, assumed to be github repo + hash):
":node_modules/hello",
# TODO: differs across lockfile versions
":.aspect_rules_js/node_modules/{}".format("[email protected]+EqualMa+gitpkg-hello+packages+hello" if lock_version == "v90" else "@gitpkg.vercel.app+EqualMa+gitpkg-hello+packages+hello"),

# npm:
# ":node_modules/@aspect-test/c2",

Expand Down
39 changes: 38 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.

48 changes: 30 additions & 18 deletions e2e/pnpm_lockfiles/v54/snapshots/defs.bzl

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

Loading
Loading