@@ -27,7 +27,6 @@ Advanced users may want to directly fetch a package from npm rather than start f
2727
2828load ("@aspect_bazel_lib//lib:utils.bzl" , bazel_lib_utils = "utils" )
2929load ("@aspect_bazel_lib//lib:write_source_files.bzl" , "write_source_file" )
30- load ("@bazel_skylib//lib:paths.bzl" , "paths" )
3130load (":exclude_package_contents_default.bzl" , "exclude_package_contents_default" )
3231load (":list_sources.bzl" , "list_sources" )
3332load (":npm_translate_lock_generate.bzl" , "generate_repository_files" )
@@ -139,7 +138,7 @@ def _npm_translate_lock_impl(rctx):
139138INFO: {} file updated. Please run your build again.
140139
141140See https://github.com/aspect-build/rules_js/issues/1445
142- """ .format (state . label_store . relative_path ( " pnpm_lock" ))
141+ """ .format (rctx . path ( rctx . attr . pnpm_lock ))
143142 fail (msg )
144143
145144 helpers .verify_node_modules_ignored (rctx , state .importers (), state .root_package ())
@@ -148,7 +147,7 @@ See https://github.com/aspect-build/rules_js/issues/1445
148147
149148 helpers .verify_lifecycle_hooks_specified (rctx , state )
150149
151- rctx .report_progress ("Translating {}" . format ( state . label_store . relative_path ( " pnpm_lock" )))
150+ rctx .report_progress ("Translating %s" % str ( rctx . path ( rctx . attr . pnpm_lock )))
152151
153152 importers , packages = translate_to_transitive_closure (
154153 state .importers (),
@@ -162,7 +161,6 @@ See https://github.com/aspect-build/rules_js/issues/1445
162161
163162 generate_repository_files (
164163 rctx ,
165- state .label_store .label ("pnpm_lock" ),
166164 importers ,
167165 packages ,
168166 state .patched_dependencies (),
@@ -693,12 +691,12 @@ def list_patches(name, out = None, include_patterns = ["*.diff", "*.patch"], exc
693691
694692################################################################################
695693def _bootstrap_import (rctx , state ):
696- pnpm_lock_label = state . label_store . label ( " pnpm_lock" )
697- pnpm_lock_path = state . label_store . path ("pnpm_lock" )
694+ pnpm_lock_label = rctx . attr . pnpm_lock
695+ pnpm_lock_path = rctx . path (pnpm_lock_label )
698696
699697 # Check if the pnpm lock file already exists and copy it over if it does.
700698 # When we do this, warn the user that we do.
701- if utils .exists ( rctx , pnpm_lock_path ) :
699+ if pnpm_lock_path .exists :
702700 # buildifier: disable=print
703701 print ("""
704702WARNING: Implicitly using pnpm-lock.yaml file `{pnpm_lock}` that is expected to be the result of running `pnpm import` on the `{lock}` lock file.
@@ -711,7 +709,7 @@ WARNING: Implicitly using pnpm-lock.yaml file `{pnpm_lock}` that is expected to
711709 # because at this point the user has likely not added all package.json and data files that
712710 # pnpm import depends on to `npm_translate_lock`. In order to get a complete initial pnpm lock
713711 # file with all workspace package imports listed we likely need to run in the source tree.
714- bootstrap_working_directory = paths .dirname ( pnpm_lock_path )
712+ bootstrap_working_directory = pnpm_lock_path .dirname
715713
716714 if not rctx .attr .quiet :
717715 # buildifier: disable=print
@@ -729,7 +727,7 @@ INFO: Running initial `pnpm import` in `{wd}` to bootstrap the pnpm-lock.yaml fi
729727 state .label_store .path ("pnpm_entry" ),
730728 "import" ,
731729 ],
732- working_directory = bootstrap_working_directory ,
730+ working_directory = str ( bootstrap_working_directory ) ,
733731 quiet = rctx .attr .quiet ,
734732 )
735733 if result .return_code :
@@ -741,7 +739,7 @@ STDERR:
741739""" .format (status = result .return_code , stdout = result .stdout , stderr = result .stderr )
742740 fail (msg )
743741
744- if not utils .exists ( rctx , pnpm_lock_path ) :
742+ if not pnpm_lock_path .exists :
745743 msg = """
746744
747745ERROR: Running `pnpm import` did not generate the {path} file.
@@ -802,11 +800,10 @@ STDERR:
802800def _update_pnpm_lock (rctx , state ):
803801 _execute_preupdate_scripts (rctx , state )
804802
805- pnpm_lock_label = state .label_store .label ("pnpm_lock" )
806- pnpm_lock_relative_path = state .label_store .relative_path ("pnpm_lock" )
803+ pnpm_lock_relative_path = str (rctx .path (rctx .attr .pnpm_lock ))
807804
808805 update_cmd = ["import" ] if rctx .attr .npm_package_lock or rctx .attr .yarn_lock else ["install" , "--lockfile-only" ]
809- update_working_directory = paths . dirname ( state . label_store . repository_path ( "pnpm_lock" ))
806+ update_working_directory = rctx . workspace_root . get_child ( pnpm_lock_relative_path ). dirname
810807
811808 pnpm_cmd = " " .join (update_cmd )
812809
@@ -833,7 +830,7 @@ INFO: Updating `{pnpm_lock}` file as its inputs have changed since the last upda
833830 # to be specified. This requirement means that if any data file changes then the update command will be
834831 # re-run. For cases where all data files cannot be specified a user can simply turn off auto-updates
835832 # by setting update_pnpm_lock to False and update their pnpm-lock.yaml file manually.
836- working_directory = update_working_directory ,
833+ working_directory = str ( update_working_directory ) ,
837834 quiet = rctx .attr .quiet ,
838835 )
839836 if result .return_code :
@@ -863,15 +860,15 @@ STDERR:
863860
864861 lockfile_changed = False
865862 if state .set_input_hash (
866- state . label_store . relative_path ( "pnpm_lock" ) ,
867- utils .hash (rctx .read (state . label_store . repository_path ( " pnpm_lock" ) )),
863+ pnpm_lock_relative_path ,
864+ utils .hash (rctx .read (rctx . attr . pnpm_lock )),
868865 ):
869866 # The lock file has changed
870867 if not rctx .attr .quiet :
871868 # buildifier: disable=print
872869 print ("""
873- INFO: {} file has changed""" . format ( pnpm_lock_relative_path ) )
874- utils .reverse_force_copy (rctx , pnpm_lock_label )
870+ INFO: %s file has changed""" % pnpm_lock_relative_path )
871+ utils .reverse_force_copy (rctx , rctx . attr . pnpm_lock )
875872 lockfile_changed = True
876873
877874 state .write_action_cache ()
@@ -893,7 +890,7 @@ ERROR: `{action_cache}` is out of date. `{pnpm_lock}` may require an update. To
893890
894891""" .format (
895892 action_cache = state .label_store .relative_path ("action_cache" ),
896- pnpm_lock = state . label_store . relative_path ( " pnpm_lock" ),
893+ pnpm_lock = str ( rctx . path ( rctx . attr . pnpm_lock ) ),
897894 repo_reference_symbol = repo_reference_symbol ,
898895 rctx_name = rctx .name ,
899896 ))
0 commit comments