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

cogs

v4.8.5

Published

The fast file transform pipeline.

Downloads

622

Readme

Cogs

The fast file transform pipeline.

George Jetson's workweek is typical of his era: an hour a day, two days a week. His boss is Cosmo Spacely, the diminutive yet bombastic owner of Spacely Space Sprockets. Spacely has a competitor, H. G. Cogswell, owner of the rival company Cogswell Cogs (sometimes known as Cogswell's Cosmic Cogs).

Install

npm install cogs

Usage

Cogs leverages a simple command line interface paired with a powerful declarative config file.

Usage: cogs [options]

The fast file transform pipeline.


Options:

  -V, --version             output the version number
  -c, --config-path [path]  load config from [path] (default: cogs.js)
  -d, --debounce [seconds]  trigger a build at most every [seconds] seconds (default: 0.1)
  -w, --watch-paths [path]  rebuild if [path] changes, can be specified multiple times
  -p, --use-polling         use stat polling instead of fsevents when watching
  -s, --silent              do not output build information, only errors
  -h, --help                output usage information

Config

Every good project needs a Cogs config file. This file can be JavaScript or JSON, as long as requireing the file returns the config object. Here's an example in JavaScript:

export default {

  // Define the transformer pipeline here.
  transformers: [
    {
      // This is the name of the transformer to use for this piece of the
      // pipeline. It can be shorthand like this, or the fully-qualified package
      // name like 'cogs-transformer-babel'.
      name: 'babel',

      // The "only" key can be used to define a glob or array of globs, one of
      // which must be matched for the file to go through this transformer.
      only: 'src/**/*.js',

      // "except" is the opposite of only. Paths that match these globs will not
      // go through the transformer.
      except: [
        'src/some/outlier/file.js',
        'src/more/outliers/**/*.js'
      ],

      // "options" will be passed directly to the transformer.
      options: {
        presets: ['stage-0', 'es2015', 'react']
      }
    },

    // Impromptu transformers are as easy as specifying a function.
    {
      fn: ({file: {buffer}, options}) => ({buffer: Buffer.from(`${buffer}!`)),
      only: '**/*.exciting'
    },

    // Some other examples...
    {
      name: 'uglify-js',
      only: '**/*.js',
      except: '**/*+(-|_|.)min.js'
    },
    {
      name: 'sass',
      only: 'src/**/*.scss'
    },
    {
      name: 'clean-css',
      only: '**/*.+(css|scss)'
    }
  ],

  // Define source globs and targets here. This is where you define what to
  // transform and where it should go.
  builds: {
    'src/index.es6': {base: 'src', dir: 'public'},

    'src/public/**/*': {base: 'src/public', dir: 'public'},

    // Save to public dir and rename .es6 files to .js and .scss files to .css
    'src/foo/**/*': {
      base: 'src',
      dir: 'public',
      ext: {
        '.es6': '.js',
        '.scss': '.css'
      }
    }
  }
};

Transformers

Transformers are generally node modules that can be downloaded from npm. Alternatively, you can create your own transformers for your projects and reference them in the transformers array.

Here are some transformers to get you started

Develop

git clone [email protected]:caseywebdev/cogs
cd cogs
npm install
bin/watch-test