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

autotool-plugin-default

v0.5.0

Published

Default executors and validators for autotool

Downloads

38

Readme

autotool-plugin-default

npm ci codacy codecov

This plugin provides the default element executors and some validators. It is always included you don't need to install it separately.

Provided Element Executors

PackageJsonElement

Allows you to add and remove elements from a packageJson file. Will also sort it for you based on a preference. To delete an element, set it to undefined.

Example:

// Add a build script to the package json, and remove another if exists
{
  type: 'packageJson',
  data: {
    scripts: {
      build: 'vite',
      'build-but-legacy': undefined
    }
  }
}

It will also apply prettier formatting with your config on the package json. Which means if you don't have prettier your file will come out using using a simple 2 space formatting straight out of JSON.stringify.

FileCopyElement

Copies a file that has been shipped with your plugin to the target location. It's important that the file that you are copying will be copied from the node_modules folder when it is executed at the user.

If you can't ship the files you need to create, you can use a custom element and create it manually.

Example:

{
  executor: 'fileCopy',
  description: 'Create root prettierrc',
  targetFile: '.prettierrc.cjs',
  packageKind: 'root',
  sourcePluginPackageName: packageJson.name, // import packageJson from '../package.json';
  sourceFile: join('static', 'prettierrc.cjs'), // import { join } from 'node:path';
},

This element will create a .prettierrc.cjs file at your workspace root.

You need to define a sourceFile, that's a relative path from your plugin package and sourcePluginPackageName which has to be your package's name. These two are needed to know where the file will end up at the consumers node_modules folder.

CustomElement

This is the simplest element. You define a function and are given the context all other elements have. The element it's applying (always itself), the target and the options containing data like if it's a dryish run, and the logger.

{
  executor: 'custom',
  description: 'say hello to all public packages!',
  packageJsonFilter: {
    private: false,
  },
  apply: (_e, target, options) =>
    options.logger.info('Hello', target.targetPackage.packageJson.name),
},

Provided Validators

Elements for root should not target inside packages

Use elements that are executing right at that package