Skip to content

Commit

Permalink
Merge pull request #1 from KateKate/dev
Browse files Browse the repository at this point in the history
Refactoring slashfile inline with ES6
  • Loading branch information
pablogq committed Sep 9, 2015
2 parents 2f6146a + 50d1e33 commit bbfb3ae
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 137 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ Slush does not contain anything "out of the box", except the ability to locate i

To find out more about Slush, check out the [documentation](https://github.com/slushjs/slush).

## Change log

#### 0.1.0

* Refactoring slushfile in line with ES6.

#### 0.0.0

* The tree project with React+Redux demo project creation.

## Contributing

See the [CONTRIBUTING Guidelines](https://github.com/KateKate/slush-spa/blob/master/CONTRIBUTING.md)
Expand Down
85 changes: 44 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
{
"name": "slush-spa",
"description": "SPA creation",
"version": "0.0.0",
"homepage": "https://github.com/KateKate/slush-spa",
"author": {
"name": "Kate Anishkina",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "git://github.com/KateKate/slush-spa.git"
},
"bugs": {
"url": "https://github.com/KateKate/slush-spa/issues"
},
"licenses": [{
"type": "MIT",
"url": "https://github.com/KateKate/slush-spa/blob/master/LICENSE"
}],
"main": "slushfile.js",
"engines": {
"node": ">= 0.10.26",
"npm": ">=1.4.3"
},
"scripts": {
"test": "echo \"No tests\""
},
"dependencies": {
"slush": ">=1.0.0",
"gulp": "^3.6.2",
"gulp-template": "^0.1.1",
"gulp-install": "^0.1.4",
"gulp-conflict": "^0.1.1",
"gulp-rename": "^1.2.0",
"underscore.string": "^2.3.3",
"inquirer": "^0.8.0",
"iniparser": "^1.0.5"
},
"keywords": [
"slushgenerator"
]
"name": "slush-spa",
"description": "SPA creation",
"version": "0.1.0",
"homepage": "https://github.com/KateKate/slush-spa",
"author": {
"name": "Kate Anishkina",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "git://github.com/KateKate/slush-spa.git"
},
"bugs": {
"url": "https://github.com/KateKate/slush-spa/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/KateKate/slush-spa/blob/master/LICENSE"
}
],
"main": "slushfile.js",
"engines": {
"node": ">= 0.10.26",
"npm": ">=1.4.3"
},
"scripts": {
"test": "echo \"No tests\""
},
"dependencies": {
"babel": "^5.8.23",
"gulp": "^3.6.2",
"gulp-conflict": "^0.1.1",
"gulp-install": "^0.1.4",
"gulp-rename": "^1.2.0",
"gulp-template": "^0.1.1",
"iniparser": "^1.0.5",
"inquirer": "^0.8.0",
"slush": ">=1.0.0",
"underscore.string": "^2.3.3"
},
"keywords": [
"slushgenerator"
]
}
98 changes: 2 additions & 96 deletions slushfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,99 +5,5 @@
* Copyright (c) 2015, Kate Anishkina
* Licensed under the MIT license.
*/

'use strict';

var gulp = require('gulp'),
install = require('gulp-install'),
conflict = require('gulp-conflict'),
template = require('gulp-template'),
rename = require('gulp-rename'),
_ = require('underscore.string'),
inquirer = require('inquirer'),
path = require('path');

function format(string) {
var username = string.toLowerCase();
return username.replace(/\s/g, '');
}

var defaults = (function () {
var workingDirName = path.basename(process.cwd()),
homeDir, osUserName, configFile, user;

if (process.platform === 'win32') {
homeDir = process.env.USERPROFILE;
osUserName = process.env.USERNAME || path.basename(homeDir).toLowerCase();
}
else {
homeDir = process.env.HOME || process.env.HOMEPATH;
osUserName = homeDir && homeDir.split('/').pop() || 'root';
}

configFile = path.join(homeDir, '.gitconfig');
user = {};

if (require('fs').existsSync(configFile)) {
user = require('iniparser').parseSync(configFile).user;
}

return {
appName: workingDirName,
userName: osUserName || format(user.name || ''),
authorName: user.name || '',
authorEmail: user.email || ''
};
})();

gulp.task('default', function (done) {
var prompts = [{
name: 'appName',
message: 'What is the name of your project?',
default: defaults.appName
}, {
name: 'appDescription',
message: 'What is the description?'
}, {
name: 'appVersion',
message: 'What is the version of your project?',
default: '0.1.0'
}, {
name: 'authorName',
message: 'What is the author name?',
default: defaults.authorName
}, {
name: 'authorEmail',
message: 'What is the author email?',
default: defaults.authorEmail
}, {
name: 'userName',
message: 'What is the github username?',
default: defaults.userName
}, {
type: 'confirm',
name: 'moveon',
message: 'Continue?'
}];
//Ask
inquirer.prompt(prompts,
function (answers) {
if (!answers.moveon) {
return done();
}
answers.appNameSlug = _.slugify(answers.appName);
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();
});
});
});
require('babel/register');
require('./slushtasks.js');
94 changes: 94 additions & 0 deletions slushtasks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import gulp from 'gulp';
import install from 'gulp-install';
import conflict from 'gulp-conflict';
import template from 'gulp-template';
import rename from 'gulp-rename';
import inquirer from 'inquirer';
import path from 'path';

const _ = require('underscore.string');

function format(string) {
const username = string.toLowerCase();
return username.replace(/\s/g, '');
}

const defaults = (() => {
const workingDirName = path.basename(process.cwd());

let homeDir, osUserName;
if (process.platform === 'win32') {
homeDir = process.env.USERPROFILE;
osUserName = process.env.USERNAME || path.basename(homeDir).toLowerCase();
}
else {
homeDir = process.env.HOME || process.env.HOMEPATH;
osUserName = homeDir && homeDir.split('/').pop() || 'root';
}

const configFile = path.join(homeDir, '.gitconfig');
let user = {};

if (require('fs').existsSync(configFile)) {
user = require('iniparser').parseSync(configFile).user;
}

return {
appName: workingDirName,
userName: osUserName || format(user.name || ''),
authorName: user.name || '',
authorEmail: user.email || ''
};

})();

gulp.task('default', (done) => {
const prompts = [{
name: 'appName',
message: 'What is the name of your project?',
default: defaults.appName
}, {
name: 'appDescription',
message: 'What is the description?'
}, {
name: 'appVersion',
message: 'What is the version of your project?',
default: '0.1.0'
}, {
name: 'authorName',
message: 'What is the author name?',
default: defaults.authorName
}, {
name: 'authorEmail',
message: 'What is the author email?',
default: defaults.authorEmail
}, {
name: 'userName',
message: 'What is the github username?',
default: defaults.userName
}, {
type: 'confirm',
name: 'moveon',
message: 'Continue?'
}];

inquirer.prompt(prompts, (answers) => {
if (!answers.moveon) {
return done();
}
answers.appNameSlug = _.slugify(answers.appName);
gulp.src(__dirname + '/templates/**')
.pipe(template(answers))
.pipe(rename( (file) => {
if (file.basename[0] === '_') {
file.basename = '.' + file.basename.slice(1);
}
}))
.pipe(conflict('./'))
.pipe(gulp.dest('./'))
.pipe(install())
.on('end', () => {
done();
});
});
});

0 comments on commit bbfb3ae

Please sign in to comment.