Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

Commit

Permalink
Merge branch 'feature/generator-dependency-upgrade' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ffffranklin committed Aug 29, 2014
2 parents f1de54d + e14dc24 commit f5fc005
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 214 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions .yo-rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"generator-generator": {}
}
20 changes: 0 additions & 20 deletions LICENSE

This file was deleted.

183 changes: 87 additions & 96 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -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');
};
2 changes: 1 addition & 1 deletion app/templates/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
};
10 changes: 5 additions & 5 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
1 change: 0 additions & 1 deletion app/templates/editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
74 changes: 34 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
28 changes: 28 additions & 0 deletions test/test-app.js
Original file line number Diff line number Diff line change
@@ -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'
]);
});
});
Loading

0 comments on commit f5fc005

Please sign in to comment.