Skip to content

Commit

Permalink
test: add pnpm file: archive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Oct 17, 2024
1 parent 0f15704 commit d8f63d9
Show file tree
Hide file tree
Showing 25 changed files with 403 additions and 180 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**/pnpm-lock.yaml
docs/*_*.md
e2e/**/*-docs.md
e2e/pnpm_lockfiles/cases/*.yaml
examples/**/*-docs.md
js/private/coverage/coverage.js
js/private/node-patches/fs.cjs
Expand Down
9 changes: 8 additions & 1 deletion e2e/pnpm_lockfiles/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ PNPM_LOCK_TEST_CASES = [
"isaacs-cliui-v90.yaml",
"docusaurus-direct-peer-v6.yaml",
"docusaurus-direct-peer-v9.yaml",
"vendored-files-v6.yaml",
"vendored-files-v9.yaml",
]

bazel_dep(name = "aspect_bazel_lib", version = "2.7.7")
Expand Down Expand Up @@ -81,7 +83,7 @@ npm = use_extension(
# Deep with many peers
"lock-%s__at_rollup_plugin-typescript__8.2.1_%s" % (
version,
"ommloj5qql5ba6x5wuiluawhoi" if version == "v54" else "1662662592" if version == "v90" else "1813138439",
"7f3ueovs674nryaiv3k7rfzidm" if version == "v54" else "217335199" if version == "v90" else "1813138439",
),

# Dep with patch
Expand All @@ -93,6 +95,11 @@ npm = use_extension(
[
npm.npm_translate_lock(
name = lockfile.replace(".yaml", ""),
data = [
"//vendored:lodash-4.17.19.tgz",
"//vendored:lodash-4.17.20.tgz",
"//vendored:lodash-4.17.21.tgz",
],
pnpm_lock = "//cases:%s" % lockfile,
verify_node_modules_ignored = "//:.bazelignore",
)
Expand Down
13 changes: 13 additions & 0 deletions e2e/pnpm_lockfiles/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ PNPM_LOCK_TEST_CASES = [
"isaacs-cliui-v90.yaml",
"docusaurus-direct-peer-v6.yaml",
"docusaurus-direct-peer-v9.yaml",
"vendored-files-v6.yaml",
"vendored-files-v9.yaml",
]

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
Expand Down Expand Up @@ -59,6 +61,11 @@ npm_repositories_v90()
[
npm_translate_lock(
name = lockfile.replace(".yaml", ""),
data = [
"//vendored:lodash-4.17.19.tgz",
"//vendored:lodash-4.17.20.tgz",
"//vendored:lodash-4.17.21.tgz",
],
pnpm_lock = "//cases:%s" % lockfile,
verify_node_modules_ignored = "//:.bazelignore",
)
Expand All @@ -70,6 +77,8 @@ load("@docusaurus-direct-peer-v9//:repositories.bzl", npm_repositories_direct_wi
load("@isaacs-cliui-v90//:repositories.bzl", npm_repositories_isaacs_cliui_v90 = "npm_repositories")
load("@override-with-alias-url-v9//:repositories.bzl", npm_repositories_override_with_alias_v90 = "npm_repositories")
load("@tarball-no-url-v54//:repositories.bzl", npm_repositories_tarball_no_url_v54 = "npm_repositories")
load("@vendored-files-v6//:repositories.bzl", npm_repositories_vendored_files_v6 = "npm_repositories")
load("@vendored-files-v9//:repositories.bzl", npm_repositories_vendored_files_v9 = "npm_repositories")

npm_repositories_tarball_no_url_v54()

Expand All @@ -80,3 +89,7 @@ npm_repositories_isaacs_cliui_v90()
npm_repositories_direct_with_peers_v6()

npm_repositories_direct_with_peers_v9()

npm_repositories_vendored_files_v6()

npm_repositories_vendored_files_v9()
1 change: 1 addition & 0 deletions e2e/pnpm_lockfiles/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"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",
"jquery-git-ssh-e61fccb": "git+ssh://[email protected]/jquery/jquery.git#e61fccb9d736235b4b011f89cba6866bc0b8997d",
"lodash": "file:../vendored/lodash-4.17.21.tgz",
"rollup": "2.14.0",
"rollup3": "npm:[email protected]",
"rollup-plugin-with-peers": "npm:@rollup/[email protected]",
Expand Down
28 changes: 28 additions & 0 deletions e2e/pnpm_lockfiles/cases/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ load("@docusaurus-direct-peer-v9//:defs.bzl", docusaurus_direct_with_peers_v9_li
load("@isaacs-cliui-v90//:defs.bzl", isaacs_cliui_v90_link_all = "npm_link_all_packages")
load("@override-with-alias-url-v9//:defs.bzl", override_with_alias_link_all = "npm_link_all_packages")
load("@tarball-no-url-v54//:defs.bzl", tarball_no_url_link_all = "npm_link_all_packages")
load("@vendored-files-v6//:defs.bzl", vendored_files_v6_link_all = "npm_link_all_packages")
load("@vendored-files-v9//:defs.bzl", vendored_files_v9_link_all = "npm_link_all_packages")

exports_files(glob(["*.yaml"]))

Expand Down Expand Up @@ -52,3 +54,29 @@ build_test(
# ":docusaurus_direct_with_peers_v6-modules/@docusaurus/module-type-aliases",
],
)

vendored_files_v6_link_all(name = "vendored-files-v6-modules")

build_test(
name = "vendored-files-v6",
targets = [
":vendored-files-v6-modules",
":vendored-files-v6-modules/lodash",
":vendored-files-v6-modules/is-number",
":.aspect_rules_js/vendored-files-v6-modules/[email protected]",
":.aspect_rules_js/vendored-files-v6-modules/[email protected]",
],
)

vendored_files_v9_link_all(name = "vendored-files-v9-modules")

build_test(
name = "vendored-files-v9",
targets = [
":vendored-files-v9-modules",
":vendored-files-v9-modules/lodash",
":vendored-files-v9-modules/is-number",
":.aspect_rules_js/vendored-files-v9-modules/[email protected]",
":.aspect_rules_js/vendored-files-v9-modules/[email protected]",
],
)
31 changes: 31 additions & 0 deletions e2e/pnpm_lockfiles/cases/vendored-files-v6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
lockfileVersion: '6.0'

settings:
autoInstallPeers: true
excludeLinksFromLockfile: false

onlyBuiltDependencies: []

importers:

.:
dependencies:
is-number:
specifier: file:../vendored/is-number
version: file:../vendored/is-number
lodash:
specifier: file:../vendored/lodash-4.17.19.tgz
version: file:../vendored/lodash-4.17.19.tgz

packages:

file:../vendored/is-number:
resolution: {directory: ../vendored/is-number, type: directory}
name: is-number
dev: false

file:../vendored/lodash-4.17.19.tgz:
resolution: {integrity: sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==, tarball: file:../vendored/lodash-4.17.19.tgz}
name: lodash
version: 4.17.19
dev: false
31 changes: 31 additions & 0 deletions e2e/pnpm_lockfiles/cases/vendored-files-v9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
lockfileVersion: '9.0'

settings:
autoInstallPeers: true
excludeLinksFromLockfile: false

importers:

.:
dependencies:
is-number:
specifier: file:../vendored/is-number
version: file:../vendored/is-number
lodash:
specifier: file:../vendored/lodash-4.17.20.tgz
version: file:../vendored/lodash-4.17.20.tgz

packages:

is-number@file:../vendored/is-number:
resolution: {directory: ../vendored/is-number, type: directory}

lodash@file:../vendored/lodash-4.17.20.tgz:
resolution: {integrity: sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==, tarball: file:../vendored/lodash-4.17.20.tgz}
version: 4.17.20

snapshots:

is-number@file:../vendored/is-number: {}

lodash@file:../vendored/lodash-4.17.20.tgz: {}
8 changes: 6 additions & 2 deletions e2e/pnpm_lockfiles/lockfile-test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,26 @@ def lockfile_test(name = None):
# npm: alias to a package that has many peers
":node_modules/rollup-plugin-with-peers",
# underlying repo for the many-peers package
"@%s__at_rollup_plugin-typescript__8.2.1_%s//:pkg" % (lock_repo, "ommloj5qql5ba6x5wuiluawhoi" if lock_version == "v54" else "1662662592" if lock_version == "v90" else "1813138439"),
"@%s__at_rollup_plugin-typescript__8.2.1_%s//:pkg" % (lock_repo, "7f3ueovs674nryaiv3k7rfzidm" if lock_version == "v54" else "217335199" if lock_version == "v90" else "1813138439"),

# uuv 'hasBin'
":node_modules/uvu",

# a package with various `npm:` cases
":node_modules/@isaacs/cliui",

# link:, workspace:, file:, ./rel/path
# link:, workspace:, file:dir, ./rel/path
":node_modules/@scoped", # target for the scope
":node_modules/@scoped/a",
":node_modules/@scoped/b",
":node_modules/@scoped/c",
":node_modules/@scoped/d",
":node_modules/scoped/bad",

# file:tarball
":node_modules/lodash",
":.aspect_rules_js/node_modules/[email protected]",

# Packages involving overrides
":node_modules/is-odd",
":.aspect_rules_js/node_modules/[email protected]",
Expand Down
32 changes: 20 additions & 12 deletions e2e/pnpm_lockfiles/v54/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 d8f63d9

Please sign in to comment.