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

chore: add 1p linked deps to e2e/js_image_oci #1710

Merged
merged 1 commit into from
May 7, 2024
Merged
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
2 changes: 2 additions & 0 deletions e2e/js_image_oci/.bazelignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
pkg/a/node_modules
pkg/b/node_modules
repo
14 changes: 3 additions & 11 deletions e2e/js_image_oci/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,15 @@ bazel_dep(name = "platforms", version = "0.0.10", dev_dependency = True)
bazel_dep(name = "rules_nodejs", version = "5.8.2", dev_dependency = True)
bazel_dep(name = "rules_oci", version = "1.7.5", dev_dependency = True)

npm = use_extension(
"@aspect_rules_js//npm:extensions.bzl",
"npm",
dev_dependency = True,
)
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")

oci = use_extension("@rules_oci//oci:extensions.bzl", "oci")
oci = use_extension("@rules_oci//oci:extensions.bzl", "oci", dev_dependency = True)
oci.pull(
name = "debian",
digest = "sha256:3d868b5eb908155f3784317b3dda2941df87bbbbaa4608f84881de66d9bb297b",
Expand All @@ -40,9 +36,5 @@ oci.pull(
)
use_repo(oci, "debian")

node = use_extension(
"@rules_nodejs//nodejs:extensions.bzl",
"node",
dev_dependency = True,
)
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
use_repo(node, "nodejs_toolchains")
5 changes: 4 additions & 1 deletion e2e/js_image_oci/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "image",
"dependencies": {
"chalk": "^4.0.0"
"acorn": "8.7.1",
"chalk": "^4.0.0",
"@mycorp/pkg-a": "workspace:*",
"@mycorp/pkg-b": "workspace:*"
}
}
16 changes: 16 additions & 0 deletions e2e/js_image_oci/pkg/a/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")

npm_package(
name = "pkg",
srcs = [
"index.js",
"package.json",
],
data = [
":node_modules",
],
visibility = ["//visibility:public"],
)
17 changes: 17 additions & 0 deletions e2e/js_image_oci/pkg/a/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @fileoverview minimal test program that requires third-party packages from npm
*/
const acorn = require('acorn')

function getAcornVersion() {
return acorn.version
}

function getUuidVersion() {
return require('uuid/package.json').version
}

module.exports = {
getAcornVersion,
getUuidVersion,
}
10 changes: 10 additions & 0 deletions e2e/js_image_oci/pkg/a/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@mycorp/pkg-a",
"private": true,
"dependencies": {
"uuid": "9.0.1"
},
"peerDependencies": {
"acorn": "8.x.x"
}
}
19 changes: 19 additions & 0 deletions e2e/js_image_oci/pkg/b/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(name = "node_modules")

js_library(
name = "pkg",
srcs = [
"index.js",
"package.json",
],
visibility = ["//visibility:public"],
# because we're linking this js_library, we must explictly add our npm dependendies to `deps` so
# they are picked up my the linker. npm dependendies in `data` are not propogated through the
# linker when linking a js_libary.
deps = [
":node_modules",
],
)
17 changes: 17 additions & 0 deletions e2e/js_image_oci/pkg/b/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @fileoverview minimal test program that requires third-party packages from npm
*/
const acorn = require('acorn')

function getAcornVersion() {
return acorn.version
}

function getUuidVersion() {
return require('uuid/package.json').version
}

module.exports = {
getAcornVersion,
getUuidVersion,
}
10 changes: 10 additions & 0 deletions e2e/js_image_oci/pkg/b/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@mycorp/pkg-b",
"private": true,
"dependencies": {
"uuid": "8.3.2"
},
"peerDependencies": {
"acorn": "8.x.x"
}
}
62 changes: 57 additions & 5 deletions e2e/js_image_oci/pnpm-lock.yaml

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

3 changes: 2 additions & 1 deletion e2e/js_image_oci/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
packages:
- '.'
- 'pkg/a'
- 'pkg/b'
1 change: 1 addition & 0 deletions e2e/js_image_oci/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ js_binary(
data = [
"ascii.art",
":proto",
"//:node_modules/@mycorp/pkg-a",
"//:node_modules/chalk",
"@repo//:dir",
"@repo//:source_txt",
Expand Down
8 changes: 5 additions & 3 deletions e2e/js_image_oci/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ console.log(
)
console.log('')

const pkgA = require('@mycorp/pkg-a')
console.log(`@mycorp/pkg-a acorn@${pkgA.getAcornVersion()}`)
console.log(`@mycorp/pkg-a uuid@${pkgA.getUuidVersion()}`)
console.log('')

console.log(
chalk.bold.bgYellow(' SOURCE CHECK '),
space,
Expand All @@ -48,7 +53,6 @@ console.log(
)
)
)

console.log(
chalk.bold.bgMagenta(' DIRECTORY CHECK '),
space,
Expand All @@ -58,7 +62,6 @@ console.log(
)
)
)

console.log(
chalk.bold.bgMagenta(' SOURCE DIRECTORY CHECK '),
space,
Expand All @@ -68,7 +71,6 @@ console.log(
)
)
)

console.log(
chalk.bold.bgWhite(' PROTO CHECK '),
space,
Expand Down
4 changes: 4 additions & 0 deletions e2e/js_image_oci/src/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ commandTests:
' TARGET //src:bin',
' CWD /app/src/bin.runfiles/',
' JS_BINARY__RUNFILES /app/src/bin.runfiles',
'@mycorp/pkg-a acorn@7.4.0',
'@mycorp/pkg-a uuid@9.0.1',
' SOURCE CHECK true',
' DIRECTORY CHECK true',
' PROTO CHECK true',
Expand All @@ -27,6 +29,8 @@ commandTests:
' TARGET //src:bin',
' CWD /app/src/bin.runfiles/',
' JS_BINARY__RUNFILES /app/src/bin.runfiles',
'@mycorp/pkg-a acorn@7.4.0',
'@mycorp/pkg-a uuid@9.0.1',
' SOURCE CHECK true',
' DIRECTORY CHECK true',
' PROTO CHECK true',
Expand Down
Loading