Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
40 changes: 38 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
node_modules/
temp/
# Numerous always-ignore extensions
.ruby-version
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.zip
*.vi
*~

# OS or Editor folders
*.esproj
*.sublime-project
*.sublime-workspace
._*
.cache
.DS_Store
.idea
.project
.settings
.tmproj
nbproject
Thumbs.db

# Komodo
*.komodoproject
.komodotools

# grunt-html-validation
validation-status.json
validation-report.json

# Folders to ignore
tmp
temp
node_modules
bower_components
22 changes: 22 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"esnext": true,
"boss": true,
"curly": true,
"eqeqeq": true,
"eqnull": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"node": true,
"sub": true,
"undef": true,
"unused": true,
"globals": {
"define": true,
"before": true,
"after": true,
"describe": true,
"it": true
}
}
8 changes: 3 additions & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.npmignore
.editorconfig
.travis.yml
.jshintrc
.gitattributes
test
src/
.jshintrc
.npmignore
.travis.yml
test
23 changes: 23 additions & 0 deletions _lib/mixins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var path = require('path');
var _ = require('lodash');

var prefixes = [
'assemble',
'assemble-contrib',
'assemble-plugin',
'filter',
'generator',
'grunt',
'gulp',
'handlebars-helper',
'helper',
'mixin',
'plugin',
'verb'
];

exports.safename = function (name, patterns) {
var remove = _.unique(_.flatten(_.union([], prefixes, patterns || [])));
var re = new RegExp('^(?:' + remove.join('|') + ')[-_]?');
return name.replace(re, '').replace(/[\W_]+/g, '_').replace(/^(\d)/, '$1');
};
7 changes: 7 additions & 0 deletions _lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var path = require('path');
var _ = require('lodash');


exports.app = function(filepath) {
return path.join('../../app/templates', filepath);
};
194 changes: 194 additions & 0 deletions app/_index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
'use strict';

var util = require('util');
var path = require('path');
var spawn = require('child_process').spawn;
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var log = require('verbalize');

/**
* Module exports Assemble Generator constructor
* Extend Yeoman base generator
*/

var AssembleGenerator = module.exports = function Assemblegenerator(args, options, config) {
yeoman.generators.Base.apply(this, arguments);

// setup the test-framework property, Gruntfile template will need this
this.testFramework = options['test-framework'] || 'mocha';
this.coffee = options.coffee;

// for hooks to resolve on mocha by default
options['test-framework'] = this.testFramework;

// resolved to mocha by default (could be switched to jasmine for instance)
this.hookFor('test-framework', {
as: 'app',
options: {
options: {
'skip-install': options['skip-install-message'],
'skip-message': options['skip-install']
}
}
});

this.options = options;

this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};

util.inherits(AssembleGenerator, yeoman.generators.Base);


AssembleGenerator.prototype.askFor = function askFor() {
var done = this.async();

if (!this.options['skip-welcome-message']) {
console.log(this.yeoman);
}

var questions = [];

questions.push({
type : "confirm",
name : "installPlugin",
message : "Do you want to install Assemble plugins?",
default : this.config.get("installPlugin")
});

// for first time/re-init, make new list of defaultPlugins
if(!this.config.get("installPlugin")) {
var plugins = this.config.get("plugins");
// if we have previous plugin choice
if (this._.isArray(plugins)) {
var defaultPlugins = {};
// convert it to object and assign checked
plugins.forEach(function(plugin) {
defaultPlugins[plugin] = true;
});
// concat with defautPlugins
for (var key in defaultPlugins) {
this.defaultPlugins[key] = defaultPlugins[key];
}
}
}

var choices = [];
var pluginObj = this.defaultPlugins;

// make choice more dynamic and checked from previous choice
// TODO: fetch from npm with "assembleplugin" keyword
for (var plugin in pluginObj) {
if(pluginObj.hasOwnProperty(plugin)){
choices.push({ name: plugin, checked: pluginObj[plugin] });
}
}

questions.push({
name : "plugins",
type : "checkbox",
message : "Which plugins would you like to include?",
choices : choices,
when: function( answers ) {
return answers.installPlugin;
}
});

this.prompt(questions, function (answers) {
this.plugins = answers.plugins;
done();
}.bind(this));
};


AssembleGenerator.prototype.gruntfile = function gruntfile() {
this.template('Gruntfile.js');
};

AssembleGenerator.prototype.packageJSON = function packageJSON() {
this.template('_package.json', 'package.json');
};

AssembleGenerator.prototype.license = function license() {
this.template('LICENSE-MIT');
};

AssembleGenerator.prototype.config = function config() {
this.copy('assemblerc.yml', '.assemblerc.yml');
this.copy('verbrc.yml', '.verbrc.yml');
};

AssembleGenerator.prototype.git = function git() {
this.copy('gitignore', '.gitignore');
this.copy('gitattributes', '.gitattributes');
};

AssembleGenerator.prototype.github = function githut() {
this.copy('nojekyll', '.nojekyll');
};

AssembleGenerator.prototype.bower = function bower() {
this.copy('bowerrc', '.bowerrc');
this.copy('_bower.json', 'bower.json');
};

AssembleGenerator.prototype.jshint = function jshint() {
this.copy('jshintrc', '.jshintrc');
};

AssembleGenerator.prototype.editorConfig = function editorConfig() {
this.copy('editorconfig', '.editorconfig');
};

AssembleGenerator.prototype.readme = function readme() {
this.template('README.md');
this.copy('_README.tmpl.md', 'docs/README.tmpl.md');
};

AssembleGenerator.prototype.templates = function templates() {
this.copy('blog.hbs', 'templates/pages/blog.hbs');
this.copy('index.hbs', 'templates/pages/index.hbs');
this.copy('layout.hbs', 'templates/layouts/default.hbs');
this.copy('navbar.hbs', 'templates/includes/navbar.hbs');
};

AssembleGenerator.prototype.app = function app() {
this.mkdir('_gh_pages');
this.mkdir('assets');
this.mkdir('content');
this.mkdir('data');
this.mkdir('styles');
this.mkdir('templates/pages');
this.mkdir('templates/layouts');
this.mkdir('templates/includes');

this.mkdir('assets');
this.mkdir('assets/images');
this.mkdir('scripts');
this.mkdir('styles');
// this.write('app/index.html', this.indexFile);

if (this.coffee) {
this.write(
'scripts/index.coffee',
'console.log "foo"'
);
}
else {
this.write('scripts/index.js', 'console.log("bar");');
}
};

AssembleGenerator.prototype.install = function () {
if (this.options['skip-install']) {
return;
}

var done = this.async();
this.installDependencies({
skipMessage: this.options['skip-install-message'],
skipInstall: this.options['skip-install'],
callback: done
});
};
Loading