@@ -137,12 +137,12 @@ See the section on stamping in the [README](stamping)
137
137
),
138
138
"_npm_script_generator" : attr .label (
139
139
default = Label ("//internal/pkg_npm:npm_script_generator" ),
140
- cfg = "host " ,
140
+ cfg = "exec " ,
141
141
executable = True ,
142
142
),
143
143
"_packager" : attr .label (
144
144
default = Label ("//internal/pkg_npm:packager" ),
145
- cfg = "host " ,
145
+ cfg = "exec " ,
146
146
executable = True ,
147
147
),
148
148
"_run_npm_bat_template" : attr .label (
@@ -206,7 +206,7 @@ def create_package(ctx, deps_files, nested_packages):
206
206
# that single directory and there is no work to do
207
207
package_dir = all_files [0 ]
208
208
209
- _create_npm_scripts (ctx , package_dir )
209
+ _create_npm_scripts (ctx )
210
210
211
211
return package_dir
212
212
@@ -260,15 +260,14 @@ def create_package(ctx, deps_files, nested_packages):
260
260
arguments = [args ],
261
261
)
262
262
263
- _create_npm_scripts (ctx , package_dir )
263
+ _create_npm_scripts (ctx )
264
264
265
265
return package_dir
266
266
267
- def _create_npm_scripts (ctx , package_dir ):
267
+ def _create_npm_scripts (ctx ):
268
268
args = ctx .actions .args ()
269
269
270
270
args .add_all ([
271
- package_dir .path ,
272
271
ctx .outputs .pack_sh .path ,
273
272
ctx .outputs .publish_sh .path ,
274
273
ctx .file ._run_npm_template .path ,
@@ -281,13 +280,16 @@ def _create_npm_scripts(ctx, package_dir):
281
280
progress_message = "Generating npm pack & publish scripts" ,
282
281
mnemonic = "GenerateNpmScripts" ,
283
282
executable = ctx .executable ._npm_script_generator ,
284
- inputs = [ctx .file ._run_npm_template , ctx .file ._run_npm_bat_template , package_dir ],
283
+ inputs = [ctx .file ._run_npm_template , ctx .file ._run_npm_bat_template ],
285
284
outputs = [ctx .outputs .pack_sh , ctx .outputs .publish_sh , ctx .outputs .pack_bat , ctx .outputs .publish_bat ],
286
285
arguments = [args ],
287
- # Must be run local (no sandbox) so that the pwd is the actual execroot
288
- # in the script which is used to generate the path in the pack & publish
289
- # scripts.
290
- execution_requirements = {"local" : "1" },
286
+ # Cannot be built remotely (template contains absolute path to npm executable).
287
+ # Cannot be built with sandboxing (references files outside sandbox).
288
+ # Can be cached, because absolute path is a standard input from a repo rule.
289
+ execution_requirements = {
290
+ "no-remote-exec" : "" ,
291
+ "no-sandbox" : "" ,
292
+ },
291
293
)
292
294
293
295
def _pkg_npm (ctx ):
@@ -326,7 +328,6 @@ def _pkg_npm(ctx):
326
328
result = [
327
329
DefaultInfo (
328
330
files = package_dir_depset ,
329
- runfiles = ctx .runfiles ([package_dir ]),
330
331
),
331
332
]
332
333
@@ -385,15 +386,18 @@ def pkg_npm_macro(name, tgz = None, **kwargs):
385
386
outs = [tgz ],
386
387
# NOTE(mattem): on windows, it seems to output a buch of other stuff on stdout when piping, so pipe to tail
387
388
# and grab the last line
388
- cmd = "$(location :%s.pack) 2>/dev/null | tail -1 | xargs -I {} cp {} $@" % name ,
389
+ # pass in package path
390
+ cmd = "$(location :%s.pack) $(location :%s) | tail -1 | xargs -I {} cp {} $@" % (name , name ),
389
391
srcs = [
390
392
name ,
391
393
],
392
394
tools = [
393
395
":%s.pack" % name ,
394
396
],
395
397
tags = [
396
- "local" ,
398
+ # Inherits limitations of %s.pack (due to absolute path to npm)
399
+ "no-remote-exec" ,
400
+ "no-sandbox" ,
397
401
],
398
402
visibility = kwargs .get ("visibility" ),
399
403
)
0 commit comments