From ae4e8e8f8498ff6d0d4c95e1d28aa130a9012867 Mon Sep 17 00:00:00 2001 From: Ricky Pai Date: Thu, 28 Feb 2019 10:55:47 -0800 Subject: [PATCH 1/4] use native.package_name() instead of PACKAGE_NAME --- node/internal/mocha_test.bzl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/node/internal/mocha_test.bzl b/node/internal/mocha_test.bzl index 13f5e6f..60a772b 100644 --- a/node/internal/mocha_test.bzl +++ b/node/internal/mocha_test.bzl @@ -26,7 +26,7 @@ def mocha_test( executable with the name of the testable entrypoint module. """ - + node_module( name = name + "_module", main = main, @@ -45,12 +45,12 @@ def mocha_test( "%s_modules" % name, "node_modules" ] - - if PACKAGE_NAME: - entrypoint.insert(0, PACKAGE_NAME) - entrypoint.append(PACKAGE_NAME) + + if native.package_name(): + entrypoint.insert(0, native.package_name()) + entrypoint.append(native.package_name()) entrypoint.append("%s_module" % name) - + native.sh_test( name = name, srcs = [script], From 6d25158a96e68fc11543ee8dd9542b47fb1fc9c0 Mon Sep 17 00:00:00 2001 From: Ricky Pai Date: Thu, 28 Feb 2019 10:55:58 -0800 Subject: [PATCH 2/4] remove cfg = "data" no-op --- node/internal/node_module.bzl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/node/internal/node_module.bzl b/node/internal/node_module.bzl index b73aa62..30cee04 100644 --- a/node/internal/node_module.bzl +++ b/node/internal/node_module.bzl @@ -13,13 +13,13 @@ def _relname(ctx, root_file, file): rel = file.path[len(root_file.dirname):] return rel - + if not file.short_path.startswith(ctx.label.package): fail("_relname failed: %s must start with %s" % (file.short_path, ctx.label.package)) # All others, shave off the package label from the file's short # path. - rel = file.short_path[len(ctx.label.package):] + rel = file.short_path[len(ctx.label.package):] if rel.startswith('/'): rel = rel[1:] @@ -65,7 +65,7 @@ def _create_package_json(ctx, name, files, executables): if executables: json["bin"] = executables - + if ctx.attr.main: json["main"] = ctx.file.main.basename @@ -132,7 +132,7 @@ def _node_module_impl(ctx): files.append(ctx.file.main) executables = ctx.attr.executables - + package_json = ctx.file.package_json # The presence of an index file suppresses creation of the @@ -234,7 +234,6 @@ node_module = rule( # excluded from the package.json 'files' attribute. "data": attr.label_list( allow_files = True, - cfg = "data", ), # Module dependencies. From 4e1d1c624339c820408aa307b0be7d2bf6097814 Mon Sep 17 00:00:00 2001 From: Ricky Pai Date: Thu, 28 Mar 2019 11:12:40 -0700 Subject: [PATCH 3/4] test latest bazels --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 30ce8e5..842ecc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,11 @@ os: - osx env: - - V=0.7.0 - - V=0.6.1 - - V=0.5.4 - - V=0.5.3 + - V=0.20.0 + - V=0.21.0 + - V=0.22.0 + - V=0.23.2 + - V=0.24.0 before_install: - OS=linux From e13a08b1be68f02f4456f639c81bfa1a41919b58 Mon Sep 17 00:00:00 2001 From: Ricky Pai Date: Thu, 28 Mar 2019 11:26:26 -0700 Subject: [PATCH 4/4] stop using FileType for Bazel 0.24.0 --- node/internal/node_module.bzl | 4 ++-- node/internal/yarn_modules.bzl | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/node/internal/node_module.bzl b/node/internal/node_module.bzl index 30cee04..232f3f1 100644 --- a/node/internal/node_module.bzl +++ b/node/internal/node_module.bzl @@ -1,4 +1,4 @@ -_node_filetype = FileType([".js", ".node"]) +_node_filetype = [".js", ".node"] def _relname(ctx, root_file, file): @@ -226,7 +226,7 @@ node_module = rule( # the module. If not present, one will be generated UNLESS an # index file is provided. "package_json": attr.label( - allow_files = FileType(["package.json"]), + allow_files = ["package.json"], single_file = True, ), diff --git a/node/internal/yarn_modules.bzl b/node/internal/yarn_modules.bzl index 491d10f..01c32c0 100644 --- a/node/internal/yarn_modules.bzl +++ b/node/internal/yarn_modules.bzl @@ -43,7 +43,7 @@ def _yarn_modules_impl(ctx): sha256 = "472add7ad141c75811f93dca421e2b7456045504afacec814b0565f092156250", stripPrefix = "package", ) - + # Copy over or create the package.json file if ctx.attr.package_json: package_json_file = ctx.path(ctx.attr.package_json) @@ -51,7 +51,7 @@ def _yarn_modules_impl(ctx): else: ctx.file("package.json", _create_package_json_content(ctx).to_json()) - + # Copy the parse_yarn_lock script and yarn.js over here. execute(ctx, ["cp", parse_yarn_lock_js, "internal/parse_yarn_lock.js"]) execute(ctx, ["cp", clean_node_modules_js, "internal/clean_node_modules.js"]) @@ -64,7 +64,7 @@ def _yarn_modules_impl(ctx): fail("Required install tool '%s' is not in the PATH" % tool, "install_tools") install_path.append(tool_path.dirname) install_path.append("$PATH") - + # Build node_modules via 'yarn install' execute(ctx, [node, yarn_js, "install"], quiet = True, environment = { "PATH": ":".join(install_path), @@ -73,7 +73,7 @@ def _yarn_modules_impl(ctx): # Sadly, pre-existing BUILD.bazel files located in npm modules can # screw up package boudaries. Remove these. execute(ctx, [node, "internal/clean_node_modules.js"], quiet = True) - + # Run the script and save the stdout to our BUILD file(s) parse_args = ["--resolve=%s:%s" % (k, v) for k, v in ctx.attr.resolutions.items()] result = execute(ctx, [node, "internal/parse_yarn_lock.js"] + parse_args, quiet = True) @@ -130,11 +130,11 @@ yarn_modules = repository_rule( single_file = True, ), # If specififed, augment the PATH environment variable with these - # tools during 'yarn install'. + # tools during 'yarn install'. "install_tools": attr.string_list(), "package_json": attr.label( mandatory = False, - allow_files = FileType(["package.json"]), + allow_files = ["package.json"], ), "post_install": attr.string_list(), "deps": attr.string_dict(mandatory = False),