Skip to content

Commit

Permalink
refactor: remove support for pnpm v6 (#1696)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard authored and gregmagolan committed May 7, 2024
1 parent c7c13c2 commit f9b2e35
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 158 deletions.
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ If your code works with pnpm, then you should expect it works under Bazel as wel
This means that if your issue can be reproduced outside of Bazel, using a reproduction with only pnpm,
then we ask that you fix the issue there, and will close such issues filed on rules_js.

Supported pnpm versions are 7-8 (lockfile versions 5.4-6.1) with pnpm 9 (lockfile 9) support in progress (see [1652](https://github.com/aspect-build/rules_js/issues/1652)).

The typical usage is to import an entire `pnpm-lock.yaml` file.
Create such a file if you don't have one. You could install pnpm on your machine, or use `npx` to run it.
We recommend this command, which creates a lockfile with minimal installation needed,
Expand Down
4 changes: 0 additions & 4 deletions e2e/pnpm_lockfiles/.bazelignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
node_modules/
v53/node_modules/
v54/node_modules/
v60/node_modules/
v61/node_modules/
v53/projects/a/node_modules
v53/projects/b/node_modules
v53/projects/c/node_modules
v54/projects/a/node_modules
v54/projects/b/node_modules
v54/projects/c/node_modules
Expand Down
2 changes: 0 additions & 2 deletions e2e/pnpm_lockfiles/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ npm = use_extension(
verify_node_modules_ignored = "//:.bazelignore",
)
for version in [
"v53",
"v54",
"v60",
"v61",
Expand All @@ -53,7 +52,6 @@ npm = use_extension(
"lock-%s" % version,
)
for version in [
"v53",
"v54",
"v60",
"v61",
Expand Down
4 changes: 0 additions & 4 deletions e2e/pnpm_lockfiles/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,16 @@ load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")
verify_node_modules_ignored = "//:.bazelignore",
)
for version in [
"v53",
"v54",
"v60",
"v61",
]
]

load("@lock-v53//:repositories.bzl", npm_repositories_v53 = "npm_repositories")
load("@lock-v54//:repositories.bzl", npm_repositories_v54 = "npm_repositories")
load("@lock-v60//:repositories.bzl", npm_repositories_v60 = "npm_repositories")
load("@lock-v61//:repositories.bzl", npm_repositories_v61 = "npm_repositories")

npm_repositories_v53()

npm_repositories_v54()

npm_repositories_v60()
Expand Down
2 changes: 0 additions & 2 deletions e2e/pnpm_lockfiles/setup.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/usr/bin/env bash

# 5.3 - pnpm v6.x.x
# 5.4 - pnpm v7.0.0 bumped the lockfile version to 5.4
# 6.0 - pnpm v8.0.0 bumped the lockfile version to 6.0; this included breaking changes
# 6.1 - pnpm v8.6.0 bumped the lockfile version to 6.1

mv v53/pnpm-lock.yaml . && npx pnpm@^6.0 install --lockfile-only && mv pnpm-lock.yaml v53/
mv v54/pnpm-lock.yaml . && npx pnpm@^7.0 install --lockfile-only && mv pnpm-lock.yaml v54/

# pnpm v8.0.0 bumped the lockfile version to 6.0, 8.6.0 bumped it to 6.1 which was then reverted to 6.0
Expand Down
6 changes: 0 additions & 6 deletions e2e/pnpm_lockfiles/v53/BUILD.bazel

This file was deleted.

1 change: 0 additions & 1 deletion e2e/pnpm_lockfiles/v53/patches

This file was deleted.

133 changes: 0 additions & 133 deletions e2e/pnpm_lockfiles/v53/pnpm-lock.yaml

This file was deleted.

13 changes: 10 additions & 3 deletions npm/private/test/utils_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@ def test_package_store_name(ctx):
# buildifier: disable=function-docstring
def test_version_supported(ctx):
env = unittest.begin(ctx)
utils.assert_lockfile_version(5.3)
utils.assert_lockfile_version(5.4)

# Unsupported versions + msgs
msg = utils.assert_lockfile_version(5.3, testonly = True)
asserts.equals(env, "npm_translate_lock requires lock_version at least 5.4, but found 5.3. Please upgrade to pnpm v7 or greater.", msg)
msg = utils.assert_lockfile_version(1.2, testonly = True)
asserts.equals(env, "npm_translate_lock requires lock_version at least 5.3, but found 1.2. Please upgrade to pnpm v6 or greater.", msg)
asserts.equals(env, "npm_translate_lock requires lock_version at least 5.4, but found 1.2. Please upgrade to pnpm v7 or greater.", msg)
msg = utils.assert_lockfile_version(99.99, testonly = True)
asserts.equals(env, "npm_translate_lock currently supports a maximum lock_version of 6.1, but found 99.99. Please file an issue on rules_js", msg)

# supported versions
utils.assert_lockfile_version(5.4)
utils.assert_lockfile_version(6.1)

return unittest.end(env)

# buildifier: disable=function-docstring
Expand Down
5 changes: 2 additions & 3 deletions npm/private/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,15 @@ def _assert_lockfile_version(version, testonly = False):
fail("version should be passed as a float")

# Restrict the supported lock file versions to what this code has been tested with:
# 5.3 - pnpm v6.x.x
# 5.4 - pnpm v7.0.0 bumped the lockfile version to 5.4
# 6.0 - pnpm v8.0.0 bumped the lockfile version to 6.0; this included breaking changes
# 6.1 - pnpm v8.6.0 bumped the lockfile version to 6.1
min_lock_version = 5.3
min_lock_version = 5.4
max_lock_version = 6.1
msg = None

if version < min_lock_version:
msg = "npm_translate_lock requires lock_version at least {min}, but found {actual}. Please upgrade to pnpm v6 or greater.".format(
msg = "npm_translate_lock requires lock_version at least {min}, but found {actual}. Please upgrade to pnpm v7 or greater.".format(
min = min_lock_version,
actual = version,
)
Expand Down

0 comments on commit f9b2e35

Please sign in to comment.