mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-09-17 10:17:09 +03:00
add and call a rule to make a node_modules
This commit is contained in:
parent
cbe8944b74
commit
0dca027c8e
7
BUCK
7
BUCK
@ -1,5 +1,6 @@
|
||||
# A list of available rules and their signatures can be found here: https://buck2.build/docs/api/rules/
|
||||
load("@prelude-nri//:elm.bzl", "elm_docs")
|
||||
load("@prelude-nri//:node.bzl", "node_modules")
|
||||
|
||||
elm_docs(
|
||||
name = "docs.json",
|
||||
@ -12,3 +13,9 @@ filegroup(
|
||||
srcs = glob(["src/**/*.elm"]),
|
||||
visibility = ["//component-catalog:app"]
|
||||
)
|
||||
|
||||
node_modules(
|
||||
name = "node_modules",
|
||||
package = "package.json",
|
||||
package_lock = "package-lock.json",
|
||||
)
|
||||
|
34
prelude-nri/node.bzl
Normal file
34
prelude-nri/node.bzl
Normal file
@ -0,0 +1,34 @@
|
||||
load("//node:toolchain.bzl", "NodeToolchainInfo")
|
||||
load("@prelude//python:toolchain.bzl", "PythonToolchainInfo")
|
||||
|
||||
def _node_modules_impl(ctx: "context") -> [DefaultInfo.type]:
|
||||
out = ctx.actions.declare_output("node_modules")
|
||||
|
||||
ctx.actions.run(
|
||||
[
|
||||
ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter,
|
||||
ctx.attrs._node_toolchain[NodeToolchainInfo].build_node_modules[DefaultInfo].default_outputs,
|
||||
out.as_output(),
|
||||
"--package", ctx.attrs.package,
|
||||
"--package-lock", ctx.attrs.package_lock,
|
||||
],
|
||||
category = "npm",
|
||||
)
|
||||
|
||||
return [DefaultInfo(default_output = out)]
|
||||
|
||||
node_modules = rule(
|
||||
impl = _node_modules_impl,
|
||||
attrs = {
|
||||
"package": attrs.source(),
|
||||
"package_lock": attrs.source(),
|
||||
"_node_toolchain": attrs.toolchain_dep(
|
||||
default="toolchains//:node",
|
||||
providers=[NodeToolchainInfo]
|
||||
),
|
||||
"_python_toolchain": attrs.toolchain_dep(
|
||||
default="toolchains//:python",
|
||||
providers=[PythonToolchainInfo]
|
||||
),
|
||||
}
|
||||
)
|
Loading…
Reference in New Issue
Block a user