Code Monkey home page Code Monkey logo

slush's Introduction

slush NPM version Build Status Dependency Status

The streaming scaffolding system - Gulp as a replacement for Yeoman

Use Gulp instead of Yeoman

Slush is a tool to be able to use Gulp for project scaffolding.

Slush does not contain anything "out of the box", except the ability to locate installed slush generators and to run them with liftoff.

To be able to provide functionality like Yeoman, see: Yeoman like behavior below.

Install

Install slush globally with:

npm install -g slush

Usage

slush <generator>[:<tasks>] [<args>]
  • <tasks>: a colon (":") separated list of a task or tasks to run. If not provided the default task in the slushfile is run
  • <args>: any other given arguments (not prefixed with "--" or "-") can be accessed via the gulp.args property from within a slushfile

Example:

slush angular:component myNewComponent

Which will run task component in generator slush-angular and gulp.args will be set to ["myNewComponent"].

List available generators

If run without any arguments, slush will list all installed generators.

slush

List available tasks in generator

To list available tasks within a generator, use the generator name in conjunction with the --tasks parameter.

slush <generator> --tasks

Print version(s)

As usual you can use -v or --version to get the current slush version:

slush -v

It can also be used together with a generator name:

slush <generator> -v

You'll then get the version for slush, the gulp version installed in the generator and the version number of the given generator.

Creating a generator

A Slush generator is an npm package following the naming convention slush-* and containing a slushfile.js.

Add slushgenerator as a keyword in your package.json.

As when building gulp plugins all slush generators need to have gulp installed as a local dependency.

All slush-* packages should be installed globally (for now) to be found by the slush executable.

Note remember to add gulp plugins (and gulp itself) as ordinary dependencies, instead of devDependencies, when building a slush generator.

Documentation

Things to remember

  • Install slush globally
  • Install slush generators globally
  • When creating slush generators:
    • name them slush-<name>
    • add slushgenerator as package keyword
    • create a slushfile.js
    • Install gulp and used gulp plugins for your generator as ordinary dependencies

Slush uses gulp

Slush is just the global excutable to trigger slush generators, under the hood it's still gulp that is run using each slushfile as config file.

Needing help writing slush generators? Check out Gulp's documentation!

The slushfile

A slushfile is basically a gulpfile, but meant to be used to scaffold project structures.

Why not name it "gulpfile" then?

Because a Slush generator may want to use gulp locally for linting, testing and other purposes, in which case it will need to have a gulpfile.

Sample slushfile

Given a slush generator project structure with a web app project template inside ./templates/app/, a slushfile could be designed like this:

var gulp = require('gulp'),
    install = require('gulp-install'),
    conflict = require('gulp-conflict'),
    template = require('gulp-template'),
    inquirer = require('inquirer');

gulp.task('default', function (done) {
  inquirer.prompt([
    {type: 'input', name: 'name', message: 'Give your app a name', default: gulp.args.join(' ')}, // Get app name from arguments by default
    {type: 'confirm', name: 'moveon', message: 'Continue?'}
  ],
  function (answers) {
    if (!answers.moveon) {
      return done();
    }
    gulp.src(__dirname + '/templates/app/**')  // Note use of __dirname to be relative to generator
      .pipe(template(answers))                 // Lodash template support
      .pipe(conflict('./'))                    // Confirms overwrites on file conflicts
      .pipe(gulp.dest('./'))                   // Without __dirname here = relative to cwd
      .pipe(install())                         // Run `bower install` and/or `npm install` if necessary
      .on('end', function () {
        done();                                // Finished!
      })
      .resume();
  });
});

Yeoman like behavior

Use these packages/plugins:

  • inquirer - To prompt the user for input
  • gulp-install - To install npm and bower packages after scaffolding
  • gulp-conflict - To prompt before overwriting files on regeneration

Want to contribute?

Anyone can help make this project better!

slush's People

Contributors

ajoslin avatar azweb76 avatar bitdeli-chef avatar callumlocke avatar darsain avatar dashed avatar ezhilvendhan avatar floatdrop avatar funkytek avatar hughsk avatar jakeboone02 avatar jamescrowley avatar jednano avatar jgable avatar joakimbeng avatar johnhaldson avatar johnheroy avatar kimjoar avatar koistya avatar lazd avatar minibikini avatar phated avatar plaxdan avatar robrich avatar simianhacker avatar sindresorhus avatar stryju avatar subhaze avatar t3chnoboy avatar yocontra avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.