Skip to content

Commit 51de4e0

Browse files
KrauseStefanalexeagle
authored andcommitted
feat(node_repositories): Added auth option for downloading nodejs and yarn
1 parent 9663b85 commit 51de4e0

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

internal/node/node_repositories.bzl

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ Note that the dependency installation scripts will run in each subpackage indica
141141

142142
# TODO(kgreenek): Add arm64 versions for all of these.
143143
_ATTRS = {
144+
"node_download_auth": attr.string_dict(
145+
default = {},
146+
doc = """auth to use for all url requests
147+
Example: {\"type\": \"basic\", \"login\": \"<UserName>\", \"password\": \"<Password>\" }
148+
""",
149+
),
144150
"node_repositories": attr.string_list_dict(
145151
doc = """Custom list of node repositories to use
146152
@@ -194,6 +200,12 @@ If set then also set node_version to the version that of node that is vendored."
194200
allow_single_file = True,
195201
doc = "the local path to a pre-installed yarn tool",
196202
),
203+
"yarn_download_auth": attr.string_dict(
204+
default = {},
205+
doc = """auth to use for all url requests
206+
Example: {\"type\": \"basic\", \"login\": \"<UserName>\", \"password\": \"<Password>\" }
207+
""",
208+
),
197209
"yarn_repositories": attr.string_list_dict(
198210
doc = """Custom list of yarn repositories to use.
199211
@@ -275,8 +287,14 @@ def _download_node(repository_ctx):
275287
fail("Unknown NodeJS version-host %s" % version_host_os)
276288
filename, strip_prefix, sha256 = node_repositories[version_host_os]
277289

290+
urls = [url.format(version = node_version, filename = filename) for url in node_urls]
291+
auth = {}
292+
for url in urls:
293+
auth[url] = repository_ctx.attr.node_download_auth
294+
278295
repository_ctx.download_and_extract(
279-
url = [url.format(version = node_version, filename = filename) for url in node_urls],
296+
auth = auth,
297+
url = urls,
280298
output = NODE_EXTRACT_DIR,
281299
stripPrefix = strip_prefix,
282300
sha256 = sha256,
@@ -317,8 +335,15 @@ def _download_yarn(repository_ctx):
317335
else:
318336
fail("Unknown Yarn version %s" % yarn_version)
319337

338+
urls = [url.format(version = yarn_version, filename = filename) for url in yarn_urls]
339+
340+
auth = {}
341+
for url in urls:
342+
auth[url] = repository_ctx.attr.yarn_download_auth
343+
320344
repository_ctx.download_and_extract(
321-
url = [url.format(version = yarn_version, filename = filename) for url in yarn_urls],
345+
auth = auth,
346+
url = urls,
322347
output = YARN_EXTRACT_DIR,
323348
stripPrefix = strip_prefix,
324349
sha256 = sha256,

0 commit comments

Comments
 (0)