diff --git a/.editorconfig b/.editorconfig index c308ed0..2536d66 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,7 +4,6 @@ root = true [*] indent_style = space indent_size = 4 -end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true diff --git a/.travis.yml b/.travis.yml index d8baa03..3823917 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: node_js node_js: - '0.10' - - '0.11' before_install: - currentfolder=${PWD##*/} - if [ "$currentfolder" != 'generator-tumblr-theme' ]; then cd .. && eval "mv $currentfolder generator-tumblr-theme" && cd generator-tumblr-theme; fi diff --git a/.yo-rc.json b/.yo-rc.json new file mode 100644 index 0000000..ae75bcc --- /dev/null +++ b/.yo-rc.json @@ -0,0 +1,3 @@ +{ + "generator-generator": {} +} \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 43a6fb4..0000000 --- a/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright 2013 - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/app/index.js b/app/index.js index a41799f..649e2ff 100644 --- a/app/index.js +++ b/app/index.js @@ -1,112 +1,103 @@ - 'use strict'; var util = require('util'); var path = require('path'); var yeoman = require('yeoman-generator'); +var yosay = require('yosay'); + +var TumblrThemeGenerator = yeoman.generators.Base.extend({ + + initializing: function () { + this.pkg = require('../package.json'); + }, + + prompting: function () { + var done = this.async(); + + // Have Yeoman greet the user. + this.log(yosay( + 'Welcome to the cool Tumblr Theme generator!' + )); + + var prompts = [{ + type: 'confirm', + name: 'customContent', + message: 'Would you like to use custom content? [No]', + default: false + },{ + // todo: should test url to make sure it's properly configured + when: function (answers) { + return answers && answers.customContent; + }, + name: 'contentURL', + message: 'What is the URL of the content source for this theme? http://' + }]; + + this.prompt(prompts, function (props) { + this.contentURL= props.contentURL; + + done(); + }.bind(this)); + }, + + writing: { + + app: function () { + this.dest.mkdir('app'); + this.dest.mkdir('app/themr'); + this.dest.mkdir('app/themr/javascripts'); + this.dest.mkdir('app/theme'); + this.dest.mkdir('app/theme/styles'); + this.dest.mkdir('app/theme/scripts'); + this.src.copy('_package.json', 'package.json'); + this.src.copy('_bower.json', 'bower.json'); + }, + createconfig: function () { -var TumblrGenerator = module.exports = function TumblrGenerator(args, options, config) { - - yeoman.generators.Base.apply(this, arguments); + var url = 'tumblrthemr.tumblr.com'; + var userURL = this.contentURL; - this.on('end', function () { - this.installDependencies({ skipInstall: options['skip-install'] }); - }); + if (typeof userURL === 'string') { + url = userURL; + } - this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json'))); -}; + this.write( + 'app/themr/javascripts/tumblr-themr-1.0.config.js', + 'var themrConf = { url: \'' + url + '\', theme: \'theme\' };' + ); + }, -util.inherits(TumblrGenerator, yeoman.generators.Base); + gruntfile: function () { + this.template('Gruntfile.js'); + }, -TumblrGenerator.prototype.askFor = function askFor() { + projectfiles: function () { + this.src.copy('editorconfig', '.editorconfig'); + this.src.copy('jshintrc', '.jshintrc'); + }, - var cb = this.async(); + createthemr: function () { + this.src.copy('index.html', 'app/index.html'); + this.src.copy('spinner.gif', 'app/themr/images/spinner.gif'); + this.src.copy('tumblr-themr-1.0.js', 'app/themr/javascripts/tumblr-themr-1.0.js'); + this.src.copy('jquery-1.6.4.min.js', 'app/themr/javascripts/jquery-1.6.4.min.js'); + this.src.copy('sammy.js', 'app/themr/javascripts/sammy.js'); + this.src.copy('sammy.handlebars.js', 'app/themr/javascripts/sammy.handlebars.js'); + }, - // have Yeoman greet the user. - console.log(this.yeoman); + demotheme: function () { + this.src.copy('theme.tumblr', 'app/theme.tumblr'); + this.src.copy('jquery-1.6.4.min.js', 'app/theme/scripts/jquery-1.6.4.min.js'); + this.src.copy('theme.scss', 'app/theme/styles/main.scss'); + this.src.copy('theme.js', 'app/theme/scripts/main.js'); + } + }, - var prompts = [{ - type: 'confirm', - name: 'customContent', - message: 'Would you like to use custom content? [No]', - default: false - },{ - // todo: should test url to make sure it's properly configured - when: function (answers) { - return answers && answers.customContent; - }, - name: 'contentURL', - message: 'What is the URL of the content source for this theme? http://' - }/*,{ - name: 'themeName', - message: 'What is your tumblr name?' - },{ - type: 'confirm', - name: 'agree', - message: 'Would you like to proceed?' - }*/]; - - this.prompt(prompts, function (props) { - //this.themeID = this.sanitizeName(props.themeName); - //this.themeName = props.themeName; - this.contentURL= props.contentURL; - cb(); - }.bind(this)); - -}; - -/** - * TODO: add find and replace to sanitize - */ -TumblrGenerator.prototype.sanitizeName = function sanitizeName(name) { - return this._.slugify(name); -}; - -TumblrGenerator.prototype.app = function app() { - this.mkdir('app'); - this.mkdir('app/themr'); - this.mkdir('app/themr/javascripts'); - this.mkdir('app/theme'); - this.mkdir('app/theme/styles'); - this.mkdir('app/theme/scripts'); - this.copy('_package.json', 'package.json'); - this.copy('_bower.json', 'bower.json'); -}; - -TumblrGenerator.prototype.createConfig= function createConfig() { - - var url = 'tumblrthemr.tumblr.com'; - var userURL = this.contentURL; - - if (typeof userURL === 'string') { - url = userURL; + end: function () { + this.installDependencies(); } +}); + +module.exports = TumblrThemeGenerator; - this.write( - 'app/themr/javascripts/tumblr-themr-1.0.config.js', - 'var themrConf = { url: \'' + url + '\', theme: \'theme\' };' - ); -}; -TumblrGenerator.prototype.gruntfile = function gruntfile() { - this.template('Gruntfile.js'); -}; -TumblrGenerator.prototype.projectfiles = function projectfiles() { - this.copy('editorconfig', '.editorconfig'); - this.copy('jshintrc', '.jshintrc'); -}; - -TumblrGenerator.prototype.createThemr = function createthemr() { - this.copy('index.html', 'app/index.html'); - this.copy('spinner.gif', 'app/themr/images/spinner.gif'); - this.copy('tumblr-themr-1.0.js', 'app/themr/javascripts/tumblr-themr-1.0.js'); - this.copy('jquery-1.6.4.min.js', 'app/themr/javascripts/jquery-1.6.4.min.js'); - this.copy('sammy.js', 'app/themr/javascripts/sammy.js'); - this.copy('sammy.handlebars.js', 'app/themr/javascripts/sammy.handlebars.js'); -}; -TumblrGenerator.prototype.demoTheme = function demotheme() { - this.copy('theme.tumblr', 'app/theme.tumblr'); - this.copy('jquery-1.6.4.min.js', 'app/theme/scripts/jquery-1.6.4.min.js'); - this.copy('theme.scss', 'app/theme/styles/main.scss'); - this.copy('theme.js', 'app/theme/scripts/main.js'); -}; diff --git a/app/templates/Gruntfile.js b/app/templates/Gruntfile.js index 3c34325..de21756 100644 --- a/app/templates/Gruntfile.js +++ b/app/templates/Gruntfile.js @@ -49,6 +49,6 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-sass'); grunt.loadNpmTasks('grunt-open'); - grunt.registerTask('default', ['server']); + grunt.registerTask('default', ['serve']); grunt.registerTask('server', ['sass', 'connect', 'open', 'watch']); }; diff --git a/app/templates/_package.json b/app/templates/_package.json index 8c5f525..5e96f82 100644 --- a/app/templates/_package.json +++ b/app/templates/_package.json @@ -3,10 +3,10 @@ "version": "0.0.0", "dependencies": {}, "devDependencies": { - "grunt-contrib-sass": "^0.7.4", - "grunt-contrib-watch": "~0.5.3", - "grunt": "~0.4.2", - "grunt-contrib-connect": "~0.5.0", - "grunt-open": "~0.2.2" + "grunt-contrib-sass": "^0.8.1", + "grunt-contrib-watch": "~0.6.1", + "grunt": "~0.4.5", + "grunt-contrib-connect": "~0.8.0", + "grunt-open": "~0.2.3" } } diff --git a/app/templates/editorconfig b/app/templates/editorconfig index c308ed0..2536d66 100644 --- a/app/templates/editorconfig +++ b/app/templates/editorconfig @@ -4,7 +4,6 @@ root = true [*] indent_style = space indent_size = 4 -end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true diff --git a/package.json b/package.json index 58fb84a..5bdffcf 100644 --- a/package.json +++ b/package.json @@ -1,43 +1,37 @@ { - "name": "generator-tumblr-theme", - "version": "0.2.1", - "description": "A tumblr theme generator for Yeoman", - "keywords": [ - "tumblr", - "theme", - "yeoman-generator" - ], - "homepage": "https://github.com/ffffranklin/generator-tumblr-theme", - "bugs": "https://github.com/ffffranklin/generator-tumblr-theme/issues", - "author": { - "name": "Franklin Clark", - "email": "", - "url": "https://github.com/ffffranklin" - }, - "main": "app/index.js", - "repository": { - "type": "git", - "url": "git://github.com/ffffranklin/generator-tumblr-theme.git" - }, - "scripts": { - "test": "mocha" - }, - "dependencies": { - "yeoman-generator": "~0.14.0" - }, - "devDependencies": { - "mocha": "~1.14.0" - }, - "peerDependencies": { - "yo": ">=1.0.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">=1.2.14" - }, - "licenses": [ - { - "type": "MIT" + "name": "generator-tumblr-theme", + "version": "0.2.3", + "description": "A tumblr theme generator for Yeoman", + "homepage": "https://github.com/ffffranklin/generator-tumblr-theme", + "bugs": "https://github.com/ffffranklin/generator-tumblr-theme/issues", + "license": "BSD", + "main": "app/index.js", + "repository": "ffffranklin/generator-tumblr-theme", + "author": { + "name": "Franklin Clark", + "email": "", + "url": "https://github.com/ffffranklin" + }, + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha" + }, + "keywords": [ + "tumblr", + "theme", + "yeoman-generator" + ], + "dependencies": { + "yeoman-generator": "^0.17.0", + "chalk": "^0.5.0", + "yosay": "^0.3.0" + }, + "devDependencies": { + "mocha": "*" + }, + "peerDependencies": { + "yo": ">=1.0.0" } - ] } diff --git a/test/test-app.js b/test/test-app.js new file mode 100644 index 0000000..9349244 --- /dev/null +++ b/test/test-app.js @@ -0,0 +1,28 @@ +/*global describe, beforeEach, it*/ +'use strict'; + +var path = require('path'); +var assert = require('yeoman-generator').assert; +var helpers = require('yeoman-generator').test; +var os = require('os'); + +describe('tumblr-theme:app', function () { + before(function (done) { + helpers.run(path.join(__dirname, '../app')) + .inDir(path.join(os.tmpdir(), './temp-test')) + .withOptions({ 'skip-install': true }) + .withPrompt({ + someOption: true + }) + .on('end', done); + }); + + it('creates files', function () { + assert.file([ + 'bower.json', + 'package.json', + '.editorconfig', + '.jshintrc' + ]); + }); +}); diff --git a/test/test-creation.js b/test/test-creation.js deleted file mode 100644 index 8c47ebf..0000000 --- a/test/test-creation.js +++ /dev/null @@ -1,38 +0,0 @@ -/*global describe, beforeEach, it*/ -'use strict'; - -var path = require('path'); -var helpers = require('yeoman-generator').test; - - -describe('tumblr-theme generator', function () { - beforeEach(function (done) { - helpers.testDirectory(path.join(__dirname, 'temp'), function (err) { - if (err) { - return done(err); - } - - this.app = helpers.createGenerator('tumblr-theme:app', [ - '../../app' - ]); - done(); - }.bind(this)); - }); - - it('creates expected files', function (done) { - var expected = [ - // add files you expect to exist here. - '.jshintrc', - '.editorconfig' - ]; - - helpers.mockPrompt(this.app, { - 'someOption': true - }); - this.app.options['skip-install'] = true; - this.app.run({}, function () { - helpers.assertFiles(expected); - done(); - }); - }); -}); diff --git a/test/test-load.js b/test/test-load.js deleted file mode 100644 index 7d6a420..0000000 --- a/test/test-load.js +++ /dev/null @@ -1,11 +0,0 @@ -/*global describe, beforeEach, it*/ -'use strict'; - -var assert = require('assert'); - -describe('tumblr-theme generator', function () { - it('can be imported without blowing up', function () { - var app = require('../app'); - assert(app !== undefined); - }); -});