@@ -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 (),
@@ -691,12 +689,12 @@ def list_patches(name, out = None, include_patterns = ["*.diff", "*.patch"], exc
691689
692690################################################################################
693691def _bootstrap_import (rctx , state ):
694- pnpm_lock_label = state . label_store . label ( " pnpm_lock" )
695- pnpm_lock_path = state . label_store . path ("pnpm_lock" )
692+ pnpm_lock_label = rctx . attr . pnpm_lock
693+ pnpm_lock_path = rctx . path (pnpm_lock_label )
696694
697695 # Check if the pnpm lock file already exists and copy it over if it does.
698696 # When we do this, warn the user that we do.
699- if utils .exists ( rctx , pnpm_lock_path ) :
697+ if pnpm_lock_path .exists :
700698 # buildifier: disable=print
701699 print ("""
702700WARNING: Implicitly using pnpm-lock.yaml file `{pnpm_lock}` that is expected to be the result of running `pnpm import` on the `{lock}` lock file.
@@ -709,7 +707,7 @@ WARNING: Implicitly using pnpm-lock.yaml file `{pnpm_lock}` that is expected to
709707 # because at this point the user has likely not added all package.json and data files that
710708 # pnpm import depends on to `npm_translate_lock`. In order to get a complete initial pnpm lock
711709 # file with all workspace package imports listed we likely need to run in the source tree.
712- bootstrap_working_directory = paths .dirname ( pnpm_lock_path )
710+ bootstrap_working_directory = pnpm_lock_path .dirname
713711
714712 if not rctx .attr .quiet :
715713 # buildifier: disable=print
@@ -727,7 +725,7 @@ INFO: Running initial `pnpm import` in `{wd}` to bootstrap the pnpm-lock.yaml fi
727725 state .label_store .path ("pnpm_entry" ),
728726 "import" ,
729727 ],
730- working_directory = bootstrap_working_directory ,
728+ working_directory = str ( bootstrap_working_directory ) ,
731729 quiet = rctx .attr .quiet ,
732730 )
733731 if result .return_code :
@@ -739,7 +737,7 @@ STDERR:
739737""" .format (status = result .return_code , stdout = result .stdout , stderr = result .stderr )
740738 fail (msg )
741739
742- if not utils .exists ( rctx , pnpm_lock_path ) :
740+ if not pnpm_lock_path .exists :
743741 msg = """
744742
745743ERROR: Running `pnpm import` did not generate the {path} file.
@@ -800,11 +798,10 @@ STDERR:
800798def _update_pnpm_lock (rctx , state ):
801799 _execute_preupdate_scripts (rctx , state )
802800
803- pnpm_lock_label = state .label_store .label ("pnpm_lock" )
804- pnpm_lock_relative_path = state .label_store .relative_path ("pnpm_lock" )
801+ pnpm_lock_relative_path = rctx .path (rctx .attr .pnpm_lock )
805802
806803 update_cmd = ["import" ] if rctx .attr .npm_package_lock or rctx .attr .yarn_lock else ["install" , "--lockfile-only" ]
807- update_working_directory = paths . dirname ( state . label_store . repository_path ( "pnpm_lock" ))
804+ update_working_directory = rctx . workspace_root . get_child ( str ( pnpm_lock_relative_path )). dirname
808805
809806 pnpm_cmd = " " .join (update_cmd )
810807
@@ -831,7 +828,7 @@ INFO: Updating `{pnpm_lock}` file as its inputs have changed since the last upda
831828 # to be specified. This requirement means that if any data file changes then the update command will be
832829 # re-run. For cases where all data files cannot be specified a user can simply turn off auto-updates
833830 # by setting update_pnpm_lock to False and update their pnpm-lock.yaml file manually.
834- working_directory = update_working_directory ,
831+ working_directory = str ( update_working_directory ) ,
835832 quiet = rctx .attr .quiet ,
836833 )
837834 if result .return_code :
@@ -861,15 +858,15 @@ STDERR:
861858
862859 lockfile_changed = False
863860 if state .set_input_hash (
864- state . label_store . relative_path ( "pnpm_lock" ) ,
865- utils .hash (rctx .read (state . label_store . repository_path ( " pnpm_lock" ) )),
861+ pnpm_lock_relative_path ,
862+ utils .hash (rctx .read (rctx . attr . pnpm_lock )),
866863 ):
867864 # The lock file has changed
868865 if not rctx .attr .quiet :
869866 # buildifier: disable=print
870867 print ("""
871868INFO: {} file has changed""" .format (pnpm_lock_relative_path ))
872- utils .reverse_force_copy (rctx , pnpm_lock_label )
869+ utils .reverse_force_copy (rctx , rctx . attr . pnpm_lock )
873870 lockfile_changed = True
874871
875872 state .write_action_cache ()
0 commit comments