Skip to content

Commit

Permalink
refactor: remove deprecated run_lifecycle_hooks from npm_import (#1572)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmagolan committed Apr 19, 2024
1 parent 6019cc5 commit d83e99b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
5 changes: 2 additions & 3 deletions docs/npm_import.md

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

5 changes: 2 additions & 3 deletions npm/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ WARNING: Cannot determine home directory in order to load home `.npmrc` file in
dev = i.dev,
integrity = i.integrity,
generate_bzl_library_targets = attr.generate_bzl_library_targets,
lifecycle_hooks = i.run_lifecycle_hooks if i.run_lifecycle_hooks and i.lifecycle_hooks else [],
lifecycle_hooks_env = i.lifecycle_hooks_env if i.run_lifecycle_hooks and i.lifecycle_hooks_env else {},
lifecycle_hooks = i.lifecycle_hooks if i.run_lifecycle_hooks else [],
lifecycle_hooks_env = i.lifecycle_hooks_env if i.run_lifecycle_hooks else {},
lifecycle_hooks_execution_requirements = i.lifecycle_hooks_execution_requirements if i.run_lifecycle_hooks else [],
lifecycle_hooks_use_default_shell_env = i.lifecycle_hooks_use_default_shell_env,
link_packages = i.link_packages,
Expand Down Expand Up @@ -220,7 +220,6 @@ def _npm_import_bzlmod(i):
patches = i.patches,
replace_package = i.replace_package,
root_package = i.root_package,
run_lifecycle_hooks = i.run_lifecycle_hooks,
transitive_closure = i.transitive_closure,
url = i.url,
version = i.version,
Expand Down
17 changes: 3 additions & 14 deletions npm/private/npm_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,6 @@ def npm_import(
dev = False,
register_copy_directory_toolchains = True,
register_copy_to_directory_toolchains = True,
# TODO(2.0): remove run_lifecycle_hooks from npm_import
run_lifecycle_hooks = None,
# TODO(2.0): remove lifecycle_hooks_no_sandbox from npm_import
lifecycle_hooks_no_sandbox = None,
**kwargs):
Expand Down Expand Up @@ -1130,8 +1128,9 @@ def npm_import(
patches: Patch files to apply onto the downloaded npm package.
custom_postinstall: Custom string postinstall script to run on the installed npm package. Runs after any
existing lifecycle hooks if `run_lifecycle_hooks` is True.
custom_postinstall: Custom string postinstall script to run on the installed npm package.
Runs after any existing lifecycle hooks if any are enabled.
npm_auth: Auth token to authenticate with npm. When using Bearer authentication.
Expand Down Expand Up @@ -1171,11 +1170,6 @@ def npm_import(
register_copy_to_directory_toolchains: if True, `@aspect_bazel_lib//lib:repositories.bzl` `register_copy_to_directory_toolchains()` is called if the toolchain is not already registered
run_lifecycle_hooks: If True, runs `preinstall`, `install`, `postinstall` and 'prepare' lifecycle hooks declared
in this package.
Deprecated. Use `lifecycle_hooks` instead.
lifecycle_hooks_no_sandbox: If True, adds "no-sandbox" to `lifecycle_hooks_execution_requirements`.
Deprecated. Add "no-sandbox" to `lifecycle_hooks_execution_requirements` instead.
Expand All @@ -1195,11 +1189,6 @@ def npm_import(
msg = "Invalid npm_import parameter '{}'".format(kwargs.keys()[0])
fail(msg)

if lifecycle_hooks and run_lifecycle_hooks:
fail("Expected only one of lifecycle_hooks or run_lifecycle_hooks")
if run_lifecycle_hooks:
lifecycle_hooks = ["preinstall", "install", "postinstall"]

# By convention, the `{name}` repository contains the actual npm
# package sources downloaded from the registry and extracted
npm_import_rule(
Expand Down

0 comments on commit d83e99b

Please sign in to comment.