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

presetter

v5.0.0

Published

Make project configurations clean with presets

Downloads

59

Readme

Logo

🏄🏻 Setup build settings from a template, quick and right!

•   Quick Start   •   Usage   •   Customization   •

npm build maintainability coverage security dependencies license

Sharing configurations for building tools across projects is painful. How many time you've copied configs for babel, eslint, vitest, typescript or the life cycle scripts in package.json? How many dev dependencies you have to install before you can kick start a project?

What's more, what if you want to update configs for all projects? :man_facepalming:

Presetter is a utility for setting up building tools for your project from a template. This means with just only two dev packages, namely this package and your favorite template preset, all essential development packages, such as typescript, eslint and vitest, together with their configuration files provided by the preset, are automatically setup for you upon the project's initialization.


Quick Start

FULL DOCUMENTATION IS AVAILABLE HERE

  1. Bootstrap your project with a preset (e.g. presetter-preset-esm)
npx presetter use <preset package name>

That's. One command and you're set.

  1. Develop and run life cycle scripts provided by the preset

At this point, all development packages specified in the preset are installed, and now you can try to run some example life cycle scripts (e.g. run prepare) provided by the template.

Demo


Usage

Presetter is shipped with a command line interface, which has 4 commands

⚙ presetter: your preset configurator

Commands:
  presetter use <preset>  adopt the specified preset to the project
  presetter bootstrap     apply the specified preset to the project
  presetter run           run a template script
  presetter unset         remove all artifacts created by the preset

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]

Adopting a Preset

Note: No matter which situation you're in below, you don't need to bootstrap the preset as it's done automatically.

To a Fresh Project

To adopt a preset to an empty project, simple run presetter use <preset> on your project root. By running this command, it will

  • create a .presetterrc file under the root, detailing the preset setting,
  • add a presetter bootstrap command to the prepublish life cycle script in your package.json, and
  • bootstrap the preset at the end of the process.

To an Existing Project

To adopt a preset to an existing project with all the development and life cycle script setup, follow the steps below:

  1. Check if there's anything you want to keep your own version (e.g. eslintrc) instead of the one provided by the preset
  2. Remove any unnecessary dev dependencies, .config files or life cycle scripts
  3. Make sure presetter bootstrap will be executed in the post installation life cycle.
  4. Add your preset via presetter use <preset package name>

Bootstrapping Everything Provided by the Preset

A preset is merely a collection of configuration files and dependency declarations, they have to be installed to the adopting project and it's what presetter bootstrap for.

You would have to run presetter bootstrap manually

Running a Life Cycle Script

You can combine you local life cycle script definition with the template provided by the preset.

Simple run npx presetter run <task> or an equivalent short cut npx run <task>, or if you prefer to run the script in the conventional way, you can set life cycle scripts in package.json to something like

{
  "scripts": {
    "build": "run build",
    "coverage": "run coverage",
    "lint": "run lint",
    "prepare": "run prepare",
    "prepublishOnly": "run prepublishOnly",
    "release": "run release --",
    "test": "run test --",
    "watch": "run watch"
  }
}

When you run the command, presetter will combine the scripts, place them into a temporary package.json and run the task via npm run <task> as usual.

PROTIPS: Install presetter globally via npm install -g presetter and you can ignore the need to call npx all the time.


Customization

Presetter support customization in two ways.

Preset Customization

If your preset support customization, you can supply the customization parameter via the config field in .presetterrc. e.g. For presetter-preset-esm, you can adding an expression to .gitignore with the following in .presetterrc:

{
  "preset": "presetter-preset-esm",
  "config": {
    "gitignore": ["<pattern to ignore>"]
  }
}

Local Configuration

If you prefer your own local configuration than the one provided by the preset, just simply overwrite it. Presetter always respects any local version which is not symlinked to the preset.