component-api

API for creating, building, and installing components

component-api

API for creating, building, and installing components. If you're looking for a command line interface, see component(1)

$ npm install component-api
var api = require('component-api');

Build a component in the given directory. It returns an event emitter so you can view progress.

directory string path for the directory containing the component you wish to build options dev True to include development dependencies standalone If present, indicates that a standalone build should be created which exports the global with name `standalone` out

The output directory for built files, defaults to `./build`.

You can alternatively pass an object of the form: `{js: Stream, css: Stream}`

name The base name for the output files - defaults to `build` prefix prefix css asset urls with `prefix` callback(err, duration) Gets passed how long the build took in milliseconds. `writing to` Gets called with `{js, css}` containing the streams being written to. Use `js.path` to get the path of the JavaScript file being written. `writing` Gets called with `{js, css}` containing the number of bytes being written to each file.

Convert a text file into require'able JavaScript

file Path to the file as a string callback(err) Called once the converted file is written to disk

Download a repo into a folder and return the component.json file as parsed json. N.B. This doesn't download dependencies, you'll need to use install for that.

api.fetch('component/emitter', '*', './', {}, function (err) {
  if (err) throw err;
  api.install('./', [], {}, function (err) {
    if (err) throw err;
    api.build('./', {standalone: 'EventEmitter'}, function (err) {
      if (err) throw err;
      console.log('built standalone event emitter');
    })
  });
})
packageName `:user/:repo` the package name to download version The version of the package to download. destination The directory to download the package to. options remote The remote to fetch from (defaults to `https://raw.github.com`) OR remotes The remotes to fetch from. Takes precedence over remote if both are present. Each remote in the array will be tried until one of them returns JavaScript or there are no more left to try. And force re-install modules even if they aren't out of date. ignore An object hash of any modules you want to ignore, used internally. auth `{user, pass}`

Install a module including dependencies.

directory string path for the directory containing the component you wish to install pkgs Array of package names to install (and save into component.json) options destination Sub-folder to put dependencies in (defaults to `components`) dev Include development dependencies force re-install modules even if they aren't out of date. callback(err) Called once the module's been installed

List the dependency of a component.