npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@evertz/bzlgen

v0.5.1

Published

Bazel Buildozer command file generator written in Typescript

Downloads

623

Readme

Bazel BUILD file generator

Tool to generate Bazel build files for a number of different rule sets and languages. Generation is done via buildozer commands for a given rule and source file or directory.

The generator can create rules for the following and can be extended to provide more

  • sass_library
  • sass_binary
  • ng_module
  • ts_library
  • nodejs_binary
  • container_layer
  • filegroup
  • bzl_library

The generator is somewhat flexible in the source structure, but does make a number of assumptions in certain cases. It will try and 'best guess' labels from other packages. It's currently not expected to generate a 100% correct and working build file, but will (in most cases) generate a ~80-90% best effort and reduce the boilerplate needed.

Running the generator

bzlgen can be installed from npm

npm i -g @evertz/bzlgen

Then run the generator, passing the type to generate and the path or file to generate for (not all generators support single files or directories)

bzlgen ng ./home

There are many option other flags that can be set to customize the output of the generator, see --help for more

The generator can also be run from source if needed:

bazel run //src:bin -- --help

Mapping rules to load statements

By default, the generator will load rules from the workspace. However this can be changed by setting load_mapping flags This tells the generator where to load a given rule from.

This will load sass_library from //tools/defaults.bzl. This allows those with marcos overriding rule definitions to specify the correct load site

--load_mapping=sass_library=//tools/defaults.bzl

Mapping sources to labels

Label mappings can be added to either override or augment the mapping between a source file and its label. Labels mappings are always the relative path from the root of the workspace (or in the case of node_modules, simply the module name)

--label_mapping path/to/src/component.ts=//some/other:label

Mappings can also contain glob patterns, allowing many paths or subpaths to be mapped to a specific label. The example below will map all files in the path/to subdirectory to the label //:foo

--label_mapping path/to/**/*=//:foo

Imports can be ignored by setting the path to a blank label

Bazel Query

The generator has experimental use of bazel query to attempt to resolve source files to labels. This can be useful if BUILD files have already been generated in the repo. Mappings added via the --label_mapping flag will have priority over any query results or best guess label generation.

The --use_bazel_query can be set to opt-in to this behaviour

.bzlgenrc

As bzlgen has a large number of flags, it can read them from a .bzlgenrc file in the root of the repo when to command is run.

Each line should contain one flag, all lines are processed, except those starting with #

# load mappings
--load_mapping=sass_library=//tools/defaults.bzl
--load_mapping=sass_binary=//tools/defaults.bzl

# label mappings
--label_mapping=rxjs/operators=@npm//rxjs