Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(builtin): renamed pkg_npm rename_build_files to hide_build_files #1470

Merged
merged 1 commit into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pkg_npm(
],
# Don't rename BUILD files as this package is not published to npm
# but is compressed in "release" below and published as a .tar.gz to GitHub
rename_build_files = False,
hide_build_files = False,
# Don't replace the default 0.0.0-PLACEHOLDER for this pkg_npm since
# we are packaging up the packager itself and this replacement will break it
replace_with_version = "",
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg_npm/packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function main(args) {
args = fs.readFileSync(args[0], {encoding: 'utf-8'}).split('\n').map(unquoteArgs);
const
[outDir, baseDir, srcsArg, binDir, genDir, depsArg, packagesArg, substitutionsArg, packPath,
publishPath, replaceWithVersion, stampFile, vendorExternalArg, renameBuildFilesArg,
publishPath, replaceWithVersion, stampFile, vendorExternalArg, hideBuildFilesArg,
runNpmTemplatePath] = args;
const renameBuildFiles = parseInt(renameBuildFilesArg);
const renameBuildFiles = parseInt(hideBuildFilesArg);

const substitutions = [
// Strip content between BEGIN-INTERNAL / END-INTERNAL comments
Expand Down
18 changes: 11 additions & 7 deletions internal/pkg_npm/pkg_npm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def create_package(ctx, deps_sources, nested_packages):
args.add(ctx.attr.replace_with_version)
args.add(ctx.version_file.path if stamp else "")
args.add_joined(ctx.attr.vendor_external, join_with = ",", omit_if_empty = False)
args.add("1" if ctx.attr.rename_build_files else "0")
args.add("1" if ctx.attr.hide_build_files else "0")

# require.resolve expects the path to start with the workspace name and not "external"
run_npm_template_path = strip_external(ctx.file._run_npm_template.path)
Expand Down Expand Up @@ -123,6 +123,16 @@ PKG_NPM_ATTRS = {
doc = """Files inside this directory which are simply copied into the package.""",
allow_files = True,
),
"hide_build_files": attr.bool(
doc = """If set BUILD and BUILD.bazel files are prefixed with `_` in the npm package.
The default is True since npm packages that contain BUILD files don't work with
`yarn_install` and `npm_install` without a post-install step that deletes or renames them.

NB: Bazel has a change in https://github.com/bazelbuild/bazel/pull/10261
(expected in version 2.1) that adds .bazelignore
support for external repositories, which will make this attribute obsolete.""",
default = True,
),
"nested_packages": attr.label_list(
doc = """Other pkg_npm rules whose content is copied into this package.""",
allow_files = True,
Expand All @@ -132,12 +142,6 @@ PKG_NPM_ATTRS = {
providers = [NodeContextInfo],
doc = "Internal use only",
),
"rename_build_files": attr.bool(
doc = """If set BUILD and BUILD.bazel files are prefixed with `_` in the npm package.
The default is True since npm packages that contain BUILD files don't work with
`yarn_install` and `npm_install` without a post-install step that deletes or renames them.""",
default = True,
),
"replace_with_version": attr.string(
doc = """If set this value is replaced with the version stamp data.
See the section on stamping in the README.""",
Expand Down