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

zlibrarybuilder

v1.2.0

Published

A Node.js module that makes building BetterDiscord plugins based off rauenzi's ZLibrary easy!

Downloads

1

Readme

ZLibraryBuilder

A Node.js module that makes building BetterDiscord plugins based off rauenzi's ZLibrary easy!

abstract

BDPluginLibrary AKA ZLibrary AKA Zere's Plugin Library AKA 0PluginLibrary is an extremely common tool for creating plugins for BetterDiscord, making life so much easier. However, the process to "build" a plugin is annoying to say the least. This project breaks away just the build scripts and adapts them to work neatly as a CLI node module!

improvements over BDPluginLibrary's build.js

install

zlibrarybuilder is available on npm

npm i zlibrarybuilder --save-dev

or you can install it from the github repo

npm i https://github.com/HexCodeFFF/ZLibraryBuilder --save-dev

example usage

default build

zlibrarybuilder

builds the single plugin contained inside the plugins folder, outputs to the release folder

build one plugin

zlibrarybuilder --pluginFolder ./plugin -ci

builds the plugin contained inside the plugin folder, adds the install script (-i) and copies it to BetterDiscord (-c)

backwards compatibility/build multiple plugins

zlibrarybuilder --pluginFolder ./plugins -cimo

the -m argument makes it build all plugins inside the folder, like the default ZLibrary build.js script does.

the -o argument is for backwards compatability, as this library changes some compilation behavior.

JSON

package.json

{
  "name": "myplugin",
  "dependencies": {
    "zlibrarybuilder": "^1.0.0",
    // ... (other dependencies)
  },
  // ... (other package.json stuff)
  "buildConfig": {
    "pluginFolder": "./plugin",
    "copyToBD": true,
    "addInstallScript": true
  }
}
zlibrarybuilder

this example has the same end behavior as the "build one plugin" example above

config

how

there are several ways to specify config options to enable both ease of use and backwards compatibility. all options are the same, just specified differently. options are found in this order, first ones take priority:

  • options specified via CLI
  • buildConfig field in your package.json
  • config.json file at the root of your project
  • defaultConfig field in your package.json
  • default options

options

options are listed via their CLI usage, use the long name as a key in either JSON file to specify it from there.

-p, --pluginFolder <folder>

default: ./plugins

Absolute or relative path to the folder containing the plugin(s) that build scripts can build automatically.

-r, --releaseFolder <folder>

default: ./release

Absolute or relative path to the folder where plugins that are built should be placed.

-c, --copyToBD

default: false

Boolean to determine if the built plugin should also be automatically copied over to your BD plugins directory. Very convenient for development.

-i, --addInstallScript

default: false

Boolean to determine if the plugin should include the Windows Host Script install script. This means that users on Windows that double click the plugin will be prompted to automatically install the plugin.

-p, --packLib

default: false

Boolean to include all lib functions into the plugin file.

-m, --multiPlugin

default: false

Boolean to re-enable the default behavior of ZLibrary, which is trying to build all plugins in the pluginFolder. If disabled, will assume pluginFolder is the path to one plugin.

-o, --oldHeader

default: false

Boolean to re-enable the normal ZLibrary plugin header generation. The existing generation was strange and limited, and this option only exists for backwards compatability. Leave disabled for the improved behavior, passing all plugin config.info keys as JSDoc entries. View the official BetterDiscord docs for more info about these.

keep in mind that the ZLibrary authors field overwrites the author and authorId properties. ZLibraryBuilder (when oldHeader is off) attempts to convert these into the correct ZLibrary config options if authors is unspecified, but it is better to just work with ZLibrary.

-h, --help

display help for command. won't do anything if specified via JSON.

dynamic node module embed

ZLibraryBuilder has the ability to automatically compile and embed external node.js modules into your plugin for you in 2 easy steps

  1. make sure the module in question is installed in your node_modules
  2. add a comment so ZLibraryBuilder knows to replace the require()
// this statement will remain unmodified
require('ts-leaky-bucket');
// zlibrarybuilder will replace this with the entire library code for you!
require('ts-leaky-bucket' /* zlibrarybuilder embed */);

the reason that not all require calls are replaced by default is that discord itself is a node app and it is highly recommended to properly require() from discord's modules when possible

note: ZLibraryBuilder naively replaces all (properly commented) require() calls with library embeds. if you require the module twice, it'll be in your plugin twice. please require it once to a variable and reuse the variable.