Top Related Projects
A toolkit to automate & enhance your workflow
CLI tool for running Yeoman generators
:fork_and_knife: Web applications made easy. Since 2011.
Full-featured Node.js framework, with no complexity. 🚀 Simple and easy to use, TypeScript-based and well-documented.
⚔ Futuristic scaffolding tool
Quick Overview
Slush is a scaffolding tool for Node.js projects, similar to Yeoman. It uses Gulp under the hood, allowing developers to leverage the power of Gulp's streaming build system for generating project structures and files. Slush aims to provide a flexible and efficient way to kickstart new projects or add components to existing ones.
Pros
- Utilizes Gulp's streaming build system, making it fast and efficient
- Highly customizable and extensible through plugins (called generators)
- Easy to create custom generators using familiar Gulp tasks
- Simpler and more lightweight compared to some alternatives like Yeoman
Cons
- Smaller community and ecosystem compared to more popular scaffolding tools
- Less actively maintained in recent years
- Limited documentation and examples for creating complex generators
- Requires knowledge of Gulp for creating custom generators
Code Examples
- Installing a Slush generator:
npm install -g slush-angular
This installs the Slush generator for Angular projects globally.
- Using a Slush generator to scaffold a project:
mkdir my-angular-project
cd my-angular-project
slush angular
This creates a new Angular project using the installed generator.
- Creating a custom Slush generator:
var gulp = require('gulp');
var install = require('gulp-install');
var conflict = require('gulp-conflict');
var template = require('gulp-template');
var rename = require('gulp-rename');
gulp.task('default', function (done) {
gulp.src(__dirname + '/templates/**')
.pipe(template(answers))
.pipe(rename(function (file) {
if (file.basename[0] === '_') {
file.basename = '.' + file.basename.slice(1);
}
}))
.pipe(conflict('./'))
.pipe(gulp.dest('./'))
.pipe(install())
.on('end', function () {
done();
});
});
This is a basic structure for a custom Slush generator using Gulp tasks.
Getting Started
To get started with Slush, follow these steps:
-
Install Slush globally:
npm install -g slush
-
Install a Slush generator (e.g., for Angular):
npm install -g slush-angular
-
Create a new project directory and navigate to it:
mkdir my-project && cd my-project
-
Run the generator:
slush angular
-
Follow the prompts to configure your project.
-
Start developing your project with the scaffolded structure!
Competitor Comparisons
A toolkit to automate & enhance your workflow
Pros of gulp
- Larger community and ecosystem with more plugins and resources
- Better performance for complex build tasks due to streaming architecture
- More flexible and customizable for advanced build processes
Cons of gulp
- Steeper learning curve, especially for beginners
- Requires more configuration and setup for basic tasks
- May be overkill for simple projects with minimal build requirements
Code comparison
gulp:
const gulp = require('gulp');
const sass = require('gulp-sass');
gulp.task('sass', function() {
return gulp.src('src/scss/*.scss')
.pipe(sass())
.pipe(gulp.dest('dist/css'));
});
slush:
var gulp = require('gulp');
var install = require('gulp-install');
gulp.task('default', function() {
gulp.src(__dirname + '/templates/**')
.pipe(gulp.dest('./'))
.pipe(install());
});
Key differences
- gulp focuses on build automation and task running
- slush is primarily a scaffolding tool for project generation
- gulp uses a streaming-based approach for file processing
- slush leverages gulp internally but provides a higher-level abstraction for project templates
Use cases
- Choose gulp for complex build processes and task automation
- Opt for slush when quickly scaffolding new projects or generating boilerplate code
Both tools have their strengths, and the choice depends on specific project requirements and developer preferences.
CLI tool for running Yeoman generators
Pros of yo
- Larger ecosystem with more generators available
- Better documentation and community support
- Cross-platform compatibility (Windows, macOS, Linux)
Cons of yo
- Steeper learning curve for creating custom generators
- Slower execution compared to Slush
- Requires more dependencies and setup
Code Comparison
yo:
const Generator = require('yeoman-generator');
module.exports = class extends Generator {
writing() {
this.fs.copyTpl(
this.templatePath('index.html'),
this.destinationPath('index.html'),
{ title: 'My New Project' }
);
}
};
Slush:
const gulp = require('gulp');
const template = require('gulp-template');
gulp.task('default', function() {
return gulp.src(__dirname + '/templates/**')
.pipe(template({ title: 'My New Project' }))
.pipe(gulp.dest('./'));
});
Both yo and Slush are scaffolding tools for web development, but they differ in their approach and ecosystem. yo is built on top of Yeoman and offers a more comprehensive solution with a larger variety of generators. It provides better cross-platform support and has a more active community.
Slush, on the other hand, is built on Gulp and offers a simpler, more lightweight approach. It's faster in execution and easier to create custom generators, but has a smaller ecosystem and less documentation compared to yo.
The code comparison shows that yo uses a class-based approach with Yeoman's built-in file system methods, while Slush relies on Gulp's streaming architecture for file manipulation.
:fork_and_knife: Web applications made easy. Since 2011.
Pros of Brunch
- More active development and larger community support
- Built-in optimization and minification features
- Faster build times for large projects
Cons of Brunch
- Steeper learning curve for beginners
- Less flexibility in customizing build processes
- Limited plugin ecosystem compared to some alternatives
Code Comparison
Brunch configuration (brunch-config.js):
module.exports = {
files: {
javascripts: {joinTo: 'app.js'},
stylesheets: {joinTo: 'app.css'}
}
};
Slush configuration (slushfile.js):
var gulp = require('gulp');
var install = require('gulp-install');
gulp.task('default', function() {
return gulp.src(__dirname + '/templates/**')
.pipe(gulp.dest('./'))
.pipe(install());
});
Brunch focuses on a declarative configuration approach, while Slush uses a more imperative style based on Gulp tasks. Brunch's configuration is typically more concise and easier to understand at a glance, but Slush offers more granular control over the build process.
Both tools aim to simplify project scaffolding and build processes, but they cater to different preferences in terms of configuration style and project structure. Brunch is better suited for projects that align with its conventions, while Slush provides more flexibility for custom workflows.
Full-featured Node.js framework, with no complexity. 🚀 Simple and easy to use, TypeScript-based and well-documented.
Pros of Foal
- Built specifically for TypeScript, offering strong typing and modern language features
- Comprehensive framework with built-in security features and database integration
- Active development and regular updates
Cons of Foal
- Steeper learning curve due to its opinionated structure and TypeScript focus
- Less flexibility compared to Slush's generator-based approach
- Smaller community and ecosystem compared to more established frameworks
Code Comparison
Foal (Controller example):
import { Context, Get, HttpResponseOK } from '@foal/core';
export class AppController {
@Get('/')
index(ctx: Context) {
return new HttpResponseOK('Hello World!');
}
}
Slush (Generator example):
module.exports = function(gulp, install, conflict, template, rename, _, inflections, inquirer) {
gulp.task('default', function(done) {
// Implement generator logic here
});
};
Summary
Foal is a TypeScript-focused web framework with built-in features and strong typing, while Slush is a scaffolding system for creating project templates. Foal offers a more structured approach to web development, whereas Slush provides flexibility in generating custom project structures. The choice between them depends on project requirements, team expertise, and desired level of customization.
⚔ Futuristic scaffolding tool
Pros of sao
- More modern and actively maintained project
- Supports both CLI and programmatic usage
- Offers a plugin system for extending functionality
Cons of sao
- Smaller community and ecosystem compared to Slush
- Less documentation and examples available
- Steeper learning curve for beginners
Code Comparison
sao:
module.exports = {
prompts() {
return [
{
name: 'name',
message: 'What is the name of your project?'
}
]
},
actions: [
{
type: 'add',
files: '**'
}
]
}
Slush:
gulp.task('default', function (done) {
inquirer.prompt([
{
type: 'input',
name: 'name',
message: 'What is the name of your project?'
}
]).then(function (answers) {
gulp.src(__dirname + '/templates/**')
.pipe(template(answers))
.pipe(gulp.dest('./'));
done();
});
});
Both sao and Slush are scaffolding tools for generating project structures. sao is a more modern alternative with a focus on flexibility and extensibility. It offers a plugin system and supports both CLI and programmatic usage. However, Slush has a larger community and more extensive documentation, making it potentially easier for beginners to get started. The code comparison shows that sao uses a more declarative approach with a configuration object, while Slush relies on Gulp tasks and uses a more imperative style.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
slush
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 thedefault
task in the slushfile is run<args>
: any other given arguments (not prefixed with "--" or "-") can be accessed via thegulp.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.
Find slush generators
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
When using Slush globally:
- Install
slush
globally - Install slush generators globally
When using Slush locally:
- Install
slush
locally - Install slush generators locally
- Preferably add
"slush": "slush"
to the"scripts"
section in yourpackage.json
and run slush like so:npm run slush
(see @majgis comment for more info)
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!
Top Related Projects
A toolkit to automate & enhance your workflow
CLI tool for running Yeoman generators
:fork_and_knife: Web applications made easy. Since 2011.
Full-featured Node.js framework, with no complexity. 🚀 Simple and easy to use, TypeScript-based and well-documented.
⚔ Futuristic scaffolding tool
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot