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

pfft

v0.22.2

Published

That's how you pronounce it: https://www.youtube.com/watch?v=BhLL8C3OC5M&t=44

Downloads

28

Readme

PFFT

That's how you pronounce it: https://www.youtube.com/watch?v=BhLL8C3OC5M&t=44

Installation

  1. Install yarn
  2. yarn global add pfft

yarn is your friend. npm as well but eh, slow.

Usage

  1. Find the preset you need (right now only react-app is available)
  2. Run pfft react-app myproject/

pfft will create the folder myproject and add the preset pfft-preset-react-app as a dev dependency. Then it will copy the contents of the template folder of the preset to your project and add the scripts listed under the scripts folder as npm scripts in your package.json. Finally it'll initialize the project as a git repo and commit what's inside the folder as initial commit. pfft does not do more than this downloading and copying, all the actual boilerplate logic is stored inside presets.

Why

tl;dr Keep your config and tools in one place to share tech updates between projects.

The JS ecosystem is changing all the time so having your own boilerplate on github to bootstrap your projects with the latest techs is always nice. However, once you clone your boilerplate and start coding something on top of it, you have no way to easily update your build config so you'll have to go through the pain of adding new stuff manually.

When you don't have that many projects, it's not that bad. But when you're trying new experiments all the time, you will eventually add new features to one project and this update will only live there. Then you may add those new parts to your boilerplate and you'll end up starting this whole process all over again.

That's where pfft comes in.

Its main goal is to centralize generic boilerplate code in npm packages so it becomes easier to share and update. It hides away most of the complexity of build config and other helpful tools so you can focus on actually coding. In the meantime, it gives you the ability to update your configs in only one place and share it between many projects so you won't end up maintaining five thousand parallel configs that are actually doing pretty much the same thing.

Building a preset

To build a preset, you'll have to respect a few rules (or else it won't work). I don't like making things mandatory so all of this will probably become optional in a near future.

Naming

Right now, you'll have to prefix your package name with pfft-preset-.

Template

If you want to start your app with some code already available, create a template folder at the root of your project and put your base code inside.

Scripts

A preset needs a scripts folder in its root. You also have to put and init.sh script that contains any commands you want to run when initializing your app. Right now, you can only use .sh scripts there, anything else will be ignored.

Scripts bin

The pfft-utils package has a tool called proxy-script that creates a cli tool that executes sh scripts from the preset module. You'll have to create a js file that uses this function (first arg is the preset name, the other one is always process.argv) and make this file a binary in your package.json. It makes your final app's package.json scripts prettier as you'll only see something like "build": "react-app build" instead of "build": "sh ./node_modules/pfft-preset-react-app/scripts/build.sh". Please look at pfft-preset-react-app/index.js and its package.json for a working example.

Partials

Partials are not mandatory and can have any name you want, they're just npm packages. They can help you share config and scripts between a few presets so you don't have to repeat yourself too much.

The rest

Now you can put anything you want in your preset. The scripts you define inside the script folder should abstract all the features of your preset so the end user doesn't have to know the details. You can eventually make those scripts open to options to give more flexibilty. For example the react-app preset allows you to pass custom webpack config to the build script so you can make configs specific to one project. As the react-app preset is also an npm package, you can require its basic webpack config and extend it as you wish, then pass it to the build script.