From 90ef8f790340626dc90f5786e8a8d6239d4d2cef Mon Sep 17 00:00:00 2001 From: Kate Anishkina Date: Tue, 8 Sep 2015 18:28:03 +0300 Subject: [PATCH 1/4] Add babel and 2 spaces indent --- package.json | 85 +++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index da0e46e..b00e508 100644 --- a/package.json +++ b/package.json @@ -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": "anishkina@gmail.com" - }, - "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.0.0", + "homepage": "https://github.com/KateKate/slush-spa", + "author": { + "name": "Kate Anishkina", + "email": "anishkina@gmail.com" + }, + "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" + ] } From 1f863d20827b7b648fa6e31f68e228e276283037 Mon Sep 17 00:00:00 2001 From: Kate Anishkina Date: Tue, 8 Sep 2015 18:29:23 +0300 Subject: [PATCH 2/4] Refactoring slashfile inline with ES6 --- slushfile.js | 98 ++------------------------------------------------- slushtasks.js | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 96 deletions(-) create mode 100644 slushtasks.js diff --git a/slushfile.js b/slushfile.js index 29acf28..72d2461 100644 --- a/slushfile.js +++ b/slushfile.js @@ -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'); diff --git a/slushtasks.js b/slushtasks.js new file mode 100644 index 0000000..adadaca --- /dev/null +++ b/slushtasks.js @@ -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(); + }); + }); +}); From 7e3096445d78de0696d0260178a5ee45d3712625 Mon Sep 17 00:00:00 2001 From: Ekaterina Anishkina Date: Wed, 9 Sep 2015 15:42:19 +0300 Subject: [PATCH 3/4] Update readme --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 264fbf2..f2030ae 100644 --- a/README.md +++ b/README.md @@ -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) From 50d1e33f998f49724ce1e035b9b2210e521bff6d Mon Sep 17 00:00:00 2001 From: Ekaterina Anishkina Date: Wed, 9 Sep 2015 15:42:53 +0300 Subject: [PATCH 4/4] Update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b00e508..76d276b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "slush-spa", "description": "SPA creation", - "version": "0.0.0", + "version": "0.1.0", "homepage": "https://github.com/KateKate/slush-spa", "author": { "name": "Kate Anishkina",