Skip to content

Commit

Permalink
feat(node_repositories): Added auth option for downloading nodejs and…
Browse files Browse the repository at this point in the history
… yarn
  • Loading branch information
KrauseStefan authored and Alex Eagle committed Nov 10, 2020
1 parent 5d70997 commit c89ff38
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions internal/node/node_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ Note that the dependency installation scripts will run in each subpackage indica

# TODO(kgreenek): Add arm64 versions for all of these.
_ATTRS = {
"node_download_auth": attr.string_dict(
default = {},
doc = """auth to use for all url requests
Example: {\"type\": \"basic\", \"login\": \"<UserName>\", \"password\": \"<Password>\" }
""",
),
"node_repositories": attr.string_list_dict(
doc = """Custom list of node repositories to use
Expand Down Expand Up @@ -194,6 +200,12 @@ If set then also set node_version to the version that of node that is vendored."
allow_single_file = True,
doc = "the local path to a pre-installed yarn tool",
),
"yarn_download_auth": attr.string_dict(
default = {},
doc = """auth to use for all url requests
Example: {\"type\": \"basic\", \"login\": \"<UserName>\", \"password\": \"<Password>\" }
""",
),
"yarn_repositories": attr.string_list_dict(
doc = """Custom list of yarn repositories to use.
Expand Down Expand Up @@ -275,8 +287,14 @@ def _download_node(repository_ctx):
fail("Unknown NodeJS version-host %s" % version_host_os)
filename, strip_prefix, sha256 = node_repositories[version_host_os]

urls = [url.format(version = node_version, filename = filename) for url in node_urls]
auth = {}
for url in urls:
auth[url] = repository_ctx.attr.node_download_auth

repository_ctx.download_and_extract(
url = [url.format(version = node_version, filename = filename) for url in node_urls],
auth = auth,
url = urls,
output = NODE_EXTRACT_DIR,
stripPrefix = strip_prefix,
sha256 = sha256,
Expand Down Expand Up @@ -317,8 +335,15 @@ def _download_yarn(repository_ctx):
else:
fail("Unknown Yarn version %s" % yarn_version)

urls = [url.format(version = yarn_version, filename = filename) for url in yarn_urls]

auth = {}
for url in urls:
auth[url] = repository_ctx.attr.yarn_download_auth

repository_ctx.download_and_extract(
url = [url.format(version = yarn_version, filename = filename) for url in yarn_urls],
auth = auth,
url = urls,
output = YARN_EXTRACT_DIR,
stripPrefix = strip_prefix,
sha256 = sha256,
Expand Down

0 comments on commit c89ff38

Please sign in to comment.