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

yui-configger

v0.5.1

Published

Extract meta-data from a folder of YUI modules & generate a Loader config

Downloads

219

Readme

yui-configger

Build Status NPM version Dependency Status devDependency Status

Extract meta-data from a folder of YUI modules/CSS files & generate a Loader config object. Writing out a config file by hand sucks, so let's automate the process!

Example

Let's say you have a folder of files (mostly YUI modules), something like

/app
|-- main
|   |-- a.js
|   |-- b.js
|   `-- c.js
|
|-- shared
|   |-- d.js
|   |-- e.js
|   `-- f.js
|
|-- test
|   |-- g.js
|   `-- h.js
|
`-- _config-template.js

Where each module looks something like

YUI.add("a.js", function(Y) {
    ...
}, "@VERSION@", {
    requires : [
        "event",
        "io"
    ]
});

Running configger in the /app dir will generate this config:

var config = {
    groups : {
        "main" : {
            base : "/main",
            modules : {
                "a" : {
                    path : "a.js",
                    requires : [
                        "event",
                        "io"
                    ]
                },
                "b" : { ... },
                "c" : { ... }
            }
        },
        "shared" : { ... },
        "test" : { ... }
    }
};

You can also optionally provide a list of search dirs to look for modules in, all paths will be relative to the root value. This pairs well with the --css flag, which will generate minimal metadata to allow the YUI Loader to load css files as modules for you.

So running configger --css --root=/app /app/js /app/css on directories laid out like

/app
|-- js
|   |-- main
|   |   |-- a.js
|   |   |-- b.js
|   |   `-- c.js
|   |
|   |-- shared
|   |   |-- d.js
|   |   |-- e.js
|   |   `-- f.js
|   |
|   `-- _config-template.js
|
`-- css
    |-- a.js
    `-- b.js

will generate this config

var config = {
    groups : {
        "/js/main" : {
            base : "/js/main",
            modules : {
                "a" : { ... },
                "b" : { ... },
                "c" : { ... }
            }
        },

        "/js/shared" : { ... },

        "/css" : {
            base : "/css",
            modules : {
                "css-a" : {
                    type : "css",
                    path : "a.css"
                },
                "css-b" : { ... }
            }
        }
    }
};

Install

npm -g install yui-configger

Usage

CLI

Generate a YUI config.
Usage: yui-configger --root=[dir] [dir],..,[dirN]

Options:
  --cssextensions  CSS file extensions (comma-separated)                  [default: "css"]
  --css, -f        Generate config values for CSS modules                 [default: false]
  --filter, -f     File-name filter (glob)                                [string]  [default: undefined]
  --jsextensions   JavaScript file extensions (comma-separated)           [default: "js"]
  --output, -o     Output file for generated config (defaults to stdout)
  --prefix, -p     Prefix for group names                                 [default: ""]
  --root, -r       Root path that files will be loaded relative to        [default: "."]
  --tmpl, -t       YUI config file template                               [default: "**/_config-template.js"]
  --verbose, -v                                                           [default: false]
  --silent                                                                [default: false]
  --loglevel                                                              [default: "info"]

Programmatic

var Configger = require("configger"),
    configger = new Configer({
        root : "."
    }),
    config;

config = configger.run();

From the programmatic API you may also define a nameFn that will be invoked to determine the name of all non-YUI modules. The default nameFn will do the following for CSS files.

fooga.css will have a module name of css-fooga.

The default implementation provides a good overview of the arguments passed.

// Default naming function for modules
_nameFn : function(file, type) {
    var name = path.basename(file, path.extname(file));

    if(type !== "css") {
        return name;
    }

    return "css-" + name;
},

Development

To install from a clone of the source:

git clone git://github.com/tivac/yui-configger.git
cd yui-configger
npm link