Skip to content

Commit

Permalink
Add some missing attributes to bzlmod api (#750)
Browse files Browse the repository at this point in the history
* chore: add pnpm_version to bzlmod api

* chore: add bins to bzlmod api

* chore: support git commits in bzlmod api

* chore: add lifecycle hook env vars to bzlmod api
  • Loading branch information
kormide authored Jan 4, 2023
1 parent c3ed5e0 commit 58bed87
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion npm/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ See https://bazel.build/docs/bzlmod#extension-definition
load("//npm/private:utils.bzl", "utils")
load("//npm/private:npm_translate_lock_generate.bzl", npm_translate_lock_helpers = "helpers")
load("//npm/private:npm_translate_lock.bzl", "npm_translate_lock_lib")
load("//npm/private:npm_import.bzl", npm_import_lib = "npm_import")
load("//npm/private:npm_import.bzl", npm_import_lib = "npm_import", npm_import_links_lib = "npm_import_links")
load("//npm:npm_import.bzl", "npm_import", "npm_translate_lock")
load("//npm/private:transitive_closure.bzl", "translate_to_transitive_closure")
load("//npm/private:versions.bzl", "PNPM_VERSIONS")

LATEST_PNPM_VERSION = PNPM_VERSIONS.keys()[-1]

def _extension_impl(module_ctx):
for mod in module_ctx.modules:
Expand All @@ -17,6 +20,7 @@ def _extension_impl(module_ctx):
npm_translate_lock(
name = attr.name,
pnpm_lock = attr.pnpm_lock,
pnpm_version = attr.pnpm_version,
# TODO: get this working with bzlmod
# update_pnpm_lock = attr.update_pnpm_lock,
)
Expand All @@ -31,10 +35,13 @@ def _extension_impl(module_ctx):
for i in imports:
npm_import(
name = i.name,
bins = i.bins,
commit = i.commit,
custom_postinstall = i.custom_postinstall,
deps = i.deps,
integrity = i.integrity,
lifecycle_hooks = i.lifecycle_hooks,
lifecycle_hooks_env = i.lifecycle_hooks_env,
link_packages = i.link_packages,
npm_translate_lock_repo = attr.name,
package = i.package,
Expand All @@ -49,9 +56,12 @@ def _extension_impl(module_ctx):
for i in mod.tags.npm_import:
npm_import(
name = i.name,
bins = i.bins,
commit = i.commit,
custom_postinstall = i.custom_postinstall,
integrity = i.integrity,
lifecycle_hooks = i.lifecycle_hooks,
lifecycle_hooks_env = i.lifecycle_hooks_env,
link_packages = i.link_packages,
link_workspace = i.link_workspace,
package = i.package,
Expand All @@ -67,11 +77,13 @@ def _npm_translate_lock_attrs():

# Add macro attrs that aren't in the rule attrs.
attrs["name"] = attr.string()
attrs["pnpm_version"] = attr.string(default = LATEST_PNPM_VERSION)

return attrs

def _npm_import_attrs():
attrs = dict(**npm_import_lib.attrs)
attrs.update(**npm_import_links_lib.attrs)

# Add macro attrs that aren't in the rule attrs.
attrs["name"] = attr.string()
Expand Down

0 comments on commit 58bed87

Please sign in to comment.