From 9bcd766ba9e21b34a53bc05753f4ae42e73c140d Mon Sep 17 00:00:00 2001 From: Greg Magolan Date: Tue, 2 Apr 2024 19:25:47 -0400 Subject: [PATCH] refactor: remove deprecated run_lifecycle_hooks from npm_import (#1572) --- docs/npm_import.md | 5 ++--- npm/extensions.bzl | 1 - npm/private/npm_import.bzl | 17 +++-------------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/docs/npm_import.md b/docs/npm_import.md index 851ef87f5..260956f96 100644 --- a/docs/npm_import.md +++ b/docs/npm_import.md @@ -30,7 +30,7 @@ npm_import(name, pa replace_package, package_visibility, patch_args, patches, custom_postinstall, npm_auth, npm_auth_basic, npm_auth_username, npm_auth_password, bins, dev, register_copy_directory_toolchains, register_copy_to_directory_toolchains, - run_lifecycle_hooks, lifecycle_hooks_no_sandbox, kwargs) + lifecycle_hooks_no_sandbox, kwargs) Import a single npm package into Bazel. @@ -155,7 +155,7 @@ Read more about the downloader config: <https://blog.aspect.dev/configuring-b | package_visibility | Visibility of generated node_module link targets. | ["//visibility:public"] | | patch_args | Arguments to pass to the patch tool.

-p1 will usually be needed for patches generated by git. | ["-p0"] | | 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. | "" | | npm_auth_basic | Auth token to authenticate with npm. When using Basic authentication.

This is typically the base64 encoded string "username:password". | "" | | npm_auth_username | Auth username to authenticate with npm. When using Basic authentication. | "" | @@ -164,7 +164,6 @@ Read more about the downloader config: <https://blog.aspect.dev/configuring-b | dev | Whether this npm package is a dev dependency | False | | register_copy_directory_toolchains | if True, @aspect_bazel_lib//lib:repositories.bzl register_copy_directory_toolchains() is called if the toolchain is not already registered | True | | 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 | True | -| run_lifecycle_hooks | If True, runs preinstall, install, postinstall and 'prepare' lifecycle hooks declared in this package.

Deprecated. Use lifecycle_hooks instead. | None | | lifecycle_hooks_no_sandbox | If True, adds "no-sandbox" to lifecycle_hooks_execution_requirements.

Deprecated. Add "no-sandbox" to lifecycle_hooks_execution_requirements instead. | None | | kwargs | Internal use only | none | diff --git a/npm/extensions.bzl b/npm/extensions.bzl index 73135c041..1424d4a05 100644 --- a/npm/extensions.bzl +++ b/npm/extensions.bzl @@ -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, diff --git a/npm/private/npm_import.bzl b/npm/private/npm_import.bzl index 33dd60875..192f23cd4 100644 --- a/npm/private/npm_import.bzl +++ b/npm/private/npm_import.bzl @@ -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): @@ -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. @@ -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. @@ -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(