From cc4f8980980809927e61a00cf7b8d727618ea067 Mon Sep 17 00:00:00 2001 From: yo mama Date: Tue, 2 Dec 2014 21:31:51 -0800 Subject: first --- .editorconfig | 12 +++++ .gitattributes | 1 + .gitignore | 1 + .jshintrc | 21 ++++++++ .travis.yml | 7 +++ .yo-rc.json | 3 ++ README.md | 47 ++++++++++++++++++ RESET_CMD | 3 ++ app/index.js | 93 +++++++++++++++++++++++++++++++++++ app/templates/_bower.json | 7 +++ app/templates/_package.json | 6 +++ app/templates/jshintrc | 21 ++++++++ app/templates/templates/Gruntfile.js | 85 ++++++++++++++++++++++++++++++++ app/templates/templates/_bower.json | 9 ++++ app/templates/templates/_package.json | 15 ++++++ app/templates/templates/app.amd.js | 9 ++++ app/templates/templates/app.css | 0 app/templates/templates/app.js | 11 +++++ app/templates/templates/app.styl | 3 ++ app/templates/templates/config.js | 6 +++ app/templates/templates/gitignore | 4 ++ app/templates/templates/index.html | 35 +++++++++++++ app/templates/templates/jshintrc | 65 ++++++++++++++++++++++++ app/templates/vimproject.config | 0 ascii_art.js | 5 ++ package.json | 36 ++++++++++++++ test/test-app.js | 28 +++++++++++ 27 files changed, 533 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 .travis.yml create mode 100644 .yo-rc.json create mode 100644 README.md create mode 100755 RESET_CMD create mode 100644 app/index.js create mode 100644 app/templates/_bower.json create mode 100644 app/templates/_package.json create mode 100644 app/templates/jshintrc create mode 100644 app/templates/templates/Gruntfile.js create mode 100644 app/templates/templates/_bower.json create mode 100644 app/templates/templates/_package.json create mode 100644 app/templates/templates/app.amd.js create mode 100644 app/templates/templates/app.css create mode 100644 app/templates/templates/app.js create mode 100644 app/templates/templates/app.styl create mode 100644 app/templates/templates/config.js create mode 100644 app/templates/templates/gitignore create mode 100644 app/templates/templates/index.html create mode 100644 app/templates/templates/jshintrc create mode 100644 app/templates/vimproject.config create mode 100755 ascii_art.js create mode 100644 package.json create mode 100644 test/test-app.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5760be5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..0cd291c --- /dev/null +++ b/.jshintrc @@ -0,0 +1,21 @@ +{ + "node": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 2, + "latedef": true, + "newcap": true, + "noarg": true, + "quotmark": "single", + "regexp": true, + "undef": true, + "unused": true, + "strict": true, + "trailing": true, + "smarttabs": true, + "white": true +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..32a70eb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: node_js +node_js: + - '0.10' +before_install: + - currentfolder=${PWD##*/} + - if [ "$currentfolder" != 'generator-unsemantic-express' ]; then cd .. && eval "mv $currentfolder generator-unsemantic-express" && cd generator-unsemantic-express; fi + diff --git a/.yo-rc.json b/.yo-rc.json new file mode 100644 index 0000000..01d1070 --- /dev/null +++ b/.yo-rc.json @@ -0,0 +1,3 @@ +{ + "generator-generator": {} +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..188d012 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# generator-unsemantic-express [![Build Status](https://secure.travis-ci.org/pepperpepperpepper/generator-unsemantic-express.png?branch=master)](https://travis-ci.org/pepperpepperpepper/generator-unsemantic-express) + +> [Yeoman](http://yeoman.io) generator + + +## Getting Started + +### What is Yeoman? + +Trick question. It's not a thing. It's this guy: + +![](http://i.imgur.com/JHaAlBJ.png) + +Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create. + +Not every new computer comes with a Yeoman pre-installed. He lives in the [npm](https://npmjs.org) package repository. You only have to ask for him once, then he packs up and moves into your hard drive. *Make sure you clean up, he likes new and shiny things.* + +```bash +npm install -g yo +``` + +### Yeoman Generators + +Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. You get to choose what type of application you wish to create, such as a Backbone application or even a Chrome extension. + +To install generator-unsemantic-express from npm, run: + +```bash +npm install -g generator-unsemantic-express +``` + +Finally, initiate the generator: + +```bash +yo unsemantic-express +``` + +### Getting To Know Yeoman + +Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced. + +If you'd like to get to know Yeoman better and meet some of his friends, [Grunt](http://gruntjs.com) and [Bower](http://bower.io), check out the complete [Getting Started Guide](https://github.com/yeoman/yeoman/wiki/Getting-Started). + + +## License + +MIT diff --git a/RESET_CMD b/RESET_CMD new file mode 100755 index 0000000..d2ec2a5 --- /dev/null +++ b/RESET_CMD @@ -0,0 +1,3 @@ +#!/bin/bash +reset(){ ls | grep -v node_modules | grep -v reset | while read a; do rm -rf "$a"; done; find node_modules -maxdepth 1 -mindepth 1 -type d | grep -v '\.bin' | grep -v 'generator' | while read a; do rm -rf "$a"; done; } +reset diff --git a/app/index.js b/app/index.js new file mode 100644 index 0000000..d9074fe --- /dev/null +++ b/app/index.js @@ -0,0 +1,93 @@ +'use strict'; +var util = require('util'); +var path = require('path'); +var yeoman = require('yeoman-generator'); +var yosay = require('yosay'); + +var UnsemanticExpressGenerator = yeoman.generators.Base.extend({ + initializing: function () { + this.pkg = require('../package.json'); + this.ascii_art = require('../ascii_art'); + }, + + prompting: function () { + var done = this.async(); + var prompts = [{ + name: 'siteName', + message: 'What is the title of this Web site?', + default: '' + }, { + name: 'siteDescription', + message: 'What is the description of this Web site?', + default: '' + }, { + type: 'confirm', + name: 'vim', + message: 'Are you using vim?', + default: true + }, { + name: 'features', + message: 'What frameworks will it use?', + type: 'checkbox', + choices: [{ + name: 'jQuery', + value: 'jquery', + checked: false + }, { + name: 'Stylus CSS preprocessor', + value: 'preprocess', + checked: false + }, { + name: 'AMD via Require.js', + value: 'amd', + checked: false + }] + }]; + + // Have Yeoman greet the user. + this.ascii_art(); + this.log(yosay( + 'Welcome to the prime UnsemanticExpress generator!' + )); + + this.prompt(prompts, function (props) { + this.jQuery = props.jQuery; + this.vim = props.vim; + this.siteName = props.siteName; + this.siteDescription = props.siteDescription; + done(); + }.bind(this)); + }, + + writing: { + app: function () { + this.dest.mkdir('app'); + this.dest.mkdir('app/templates'); + + this.template('_package.json', 'package.json'); + this.template('_bower.json', 'bower.json'); + }, + + projectfiles: function () { + this.src.copy('vimproject.config', 'vimproject.config'); + this.src.copy('jshintrc', '.jshintrc'); + } + }, + installingExpress: function() { + if (this.jQuery){ +// var done = this.async(); + this.npmInstall(['express'], { 'saveDev': true }); +// this.npmInstall(['express'], { 'saveDev': true }, done); + } + }, + installingUnsemantic: function() { + if (! this.jQuery){ + this.bowerInstall(['unsemantic'], { 'saveDev': true }); + } + }, + end: function () { + this.installDependencies(); + } +}); + +module.exports = UnsemanticExpressGenerator; diff --git a/app/templates/_bower.json b/app/templates/_bower.json new file mode 100644 index 0000000..a39de3e --- /dev/null +++ b/app/templates/_bower.json @@ -0,0 +1,7 @@ +{ + "name": "<%= _.slugify(siteName) %>", + "description": "<%= siteDescription %>", + "version": "0.0.0", + "dependencies": { + } +} diff --git a/app/templates/_package.json b/app/templates/_package.json new file mode 100644 index 0000000..ea68338 --- /dev/null +++ b/app/templates/_package.json @@ -0,0 +1,6 @@ +{ + "name": "<%= _.slugify(siteName) %>", + "description": "<%= siteDescription %>", + "private": true, + "devDependencies": {} +} diff --git a/app/templates/jshintrc b/app/templates/jshintrc new file mode 100644 index 0000000..0cd291c --- /dev/null +++ b/app/templates/jshintrc @@ -0,0 +1,21 @@ +{ + "node": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 2, + "latedef": true, + "newcap": true, + "noarg": true, + "quotmark": "single", + "regexp": true, + "undef": true, + "unused": true, + "strict": true, + "trailing": true, + "smarttabs": true, + "white": true +} diff --git a/app/templates/templates/Gruntfile.js b/app/templates/templates/Gruntfile.js new file mode 100644 index 0000000..56db414 --- /dev/null +++ b/app/templates/templates/Gruntfile.js @@ -0,0 +1,85 @@ +module.exports = function(grunt) { + grunt.initConfig({<% if (amd) { %> + requirejs: { + compile: { + options: { + baseUrl: '.', + name: 'app', + mainConfigFile: 'js/config.js', + out: 'js/app.min.js' + } + } + },<% } else { %> + concat: { + js: { + src: [<% if (jquery) { %> + 'bower_components/jquery/jquery.js',<% } %> + 'js/app.js' + ], + dest: 'js/app.concat.js' + } + }, + uglify: { + build: { + src: 'js/app.concat.js', + dest: 'js/app.min.js' + } + },<% } %><% if (preprocess) { %> + stylus: { + compile: { + files: { + 'css/app.min.css': 'css/app.styl' + } + } + },<% } else { %> + cssmin: { + minify: { + files: { + 'css/app.min.css': 'css/app.css' + } + } + },<% } %> + watch: { + js: { + files: [ + 'bower_components/**/*.js', + 'js/**/!(app.min|app.concat).js' + ], + tasks: ['javascript'] + }, + css: {<% if (preprocess) { %> + files: [ + 'css/**/*.styl' + ],<% } else { %> + files: [ + 'css/**/!(app.min).css' + ], + <% } %> + tasks: ['stylesheets'] + } + } + }); + <% if (amd) { %> + grunt.loadNpmTasks('grunt-contrib-requirejs');<% } else { %> + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify');<% } %><% if (preprocess) { %> + grunt.loadNpmTasks('grunt-contrib-stylus');<% } else { %> + grunt.loadNpmTasks('grunt-contrib-cssmin');<% } %> + grunt.loadNpmTasks('grunt-contrib-watch'); + <% if (amd) { %> + grunt.registerTask('javascript', [ + 'requirejs' + ]);<% } else { %> + grunt.registerTask('javascript', [ + 'concat:js', + 'uglify' + ]);<% } %><% if (preprocess) { %> + grunt.registerTask('stylesheets', [ + 'stylus' + ]);<% } else { %> + grunt.registerTask('stylesheets', [ + 'cssmin' + ]);<% } %> + + grunt.registerTask('default', ['javascript', 'stylesheets', 'watch']); +}; \ No newline at end of file diff --git a/app/templates/templates/_bower.json b/app/templates/templates/_bower.json new file mode 100644 index 0000000..020d0b8 --- /dev/null +++ b/app/templates/templates/_bower.json @@ -0,0 +1,9 @@ +{ + "name": "<%= _.slugify(siteName) %>", + "description": "<%= siteDescription %>", + "version": "0.0.0", + "dependencies": {<% if (jquery) { %> + "jquery": "~2.0.3"<% if (amd) { %>,<% } %><% } %><% if (amd) { %> + "requirejs": "~2.1.9"<% } %> + } +} \ No newline at end of file diff --git a/app/templates/templates/_package.json b/app/templates/templates/_package.json new file mode 100644 index 0000000..90f5f05 --- /dev/null +++ b/app/templates/templates/_package.json @@ -0,0 +1,15 @@ +{ + "name": "<%= _.slugify(siteName) %>", + "description": "<%= siteDescription %>", + "private": true, + "devDependencies": {<% if (preprocess) { %> + "grunt-contrib-stylus": "*", + "nib": "*",<% } else { %> + "grunt-contrib-cssmin": "*",<% } %><% if (amd) { %> + "grunt-contrib-requirejs": "*",<% } %> + "grunt-contrib-concat": "*", + "grunt-contrib-uglify": "*", + "grunt-contrib-watch": "*", + "grunt": "*" + } +} \ No newline at end of file diff --git a/app/templates/templates/app.amd.js b/app/templates/templates/app.amd.js new file mode 100644 index 0000000..045610d --- /dev/null +++ b/app/templates/templates/app.amd.js @@ -0,0 +1,9 @@ +define([], function () { + var app = { + init: function () { + + } + }; + + app.init(); +}); \ No newline at end of file diff --git a/app/templates/templates/app.css b/app/templates/templates/app.css new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/templates/app.js b/app/templates/templates/app.js new file mode 100644 index 0000000..439a2f5 --- /dev/null +++ b/app/templates/templates/app.js @@ -0,0 +1,11 @@ +/* globals $:false */ + +<% if (jquery) { %>$<% } %>(function () { + var app = { + init: function () { + + } + }; + + app.init(); +})<% if (!jquery) { %>()<% } %>; \ No newline at end of file diff --git a/app/templates/templates/app.styl b/app/templates/templates/app.styl new file mode 100644 index 0000000..0237647 --- /dev/null +++ b/app/templates/templates/app.styl @@ -0,0 +1,3 @@ +@import '../node_modules/nib' + +global-reset() \ No newline at end of file diff --git a/app/templates/templates/config.js b/app/templates/templates/config.js new file mode 100644 index 0000000..b680be7 --- /dev/null +++ b/app/templates/templates/config.js @@ -0,0 +1,6 @@ +require.config({ + paths: { + app: 'js/app'<% if (jquery) { %>, + jquery: 'bower_components/jquery/jquery'<% } %> + } +}); \ No newline at end of file diff --git a/app/templates/templates/gitignore b/app/templates/templates/gitignore new file mode 100644 index 0000000..4a3b993 --- /dev/null +++ b/app/templates/templates/gitignore @@ -0,0 +1,4 @@ +node_modules +bower_components +.DS_Store +npm-debug.log \ No newline at end of file diff --git a/app/templates/templates/index.html b/app/templates/templates/index.html new file mode 100644 index 0000000..89794cb --- /dev/null +++ b/app/templates/templates/index.html @@ -0,0 +1,35 @@ + + + + <%= siteName %> + + + + + + + + + + + + + + + + + + + + + + + <% if (amd) { %> + + <% } %> + <% if (amd) { %> + <% } %> + + \ No newline at end of file diff --git a/app/templates/templates/jshintrc b/app/templates/templates/jshintrc new file mode 100644 index 0000000..f51da24 --- /dev/null +++ b/app/templates/templates/jshintrc @@ -0,0 +1,65 @@ +{ + "asi": false, + "bitwise": false, + "boss": false, + "browser": true, + "camelcase": true, + "couch": false, + "curly": true, + "debug": false, + "devel": true, + "dojo": false, + "eqeqeq": true, + "eqnull": true, + "esnext": false, + "evil": false, + "expr": true, + "forin": false, + "funcscope": true, + "globalstrict": false, + "immed": true, + "iterator": false, + "jquery": false, + "lastsemic": false, + "latedef": false, + "laxbreak": true, + "laxcomma": false, + "loopfunc": true, + "mootools": false, + "multistr": false, + "newcap": true, + "noarg": true, + "node": false, + "noempty": false, + "nonew": true, + "nonstandard": false, + "nomen": false, + "onecase": false, + "onevar": false, + "passfail": false, + "plusplus": false, + "proto": false, + "prototypejs": false, + "regexdash": true, + "regexp": false, + "rhino": false, + "undef": true, + "unused": true, + "scripturl": true, + "shadow": false, + "smarttabs": true, + "strict": false, + "sub": false, + "supernew": false, + "trailing": true, + "validthis": true, + "withstmt": false, + "white": true, + "worker": false, + "wsh": false, + "yui": false, + "indent": 4, + "predef": [ "require", "define" ], + "quotmark": "single", + "maxcomplexity": 10 +} \ No newline at end of file diff --git a/app/templates/vimproject.config b/app/templates/vimproject.config new file mode 100644 index 0000000..e69de29 diff --git a/ascii_art.js b/ascii_art.js new file mode 100755 index 0000000..3987995 --- /dev/null +++ b/ascii_art.js @@ -0,0 +1,5 @@ +module.exports = function(){ +process.stdout.write("\u001B[2J\u001B[0;0f"); +//exec -out printf "\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\x030,11 \x03\n \x0311,1Y\x03\x037,1O\x03\x037,1 \x03\x0313,1Y\x03\x0313,1O\x03\x0313,1 \x03\x036,1Y\x03\x036,1O\x03\x036,1!\x03\x036,1!\x03\x036,1!\x03\x036,1!\x03\n \x030,11 \x03\x030,11 \x03\x030,11 \x03\n \x030,11 \x03\x030,11 \x03\x030,11 \x03 \x030,11 \x03 \x030,11 \x03\n \x030,11 \x03\n \x030,12 \x03 \x030,12 \x03\n \x030,10 \x03\n \x030,10 \x03\x030,10 \x03 \x030,12 \x03\n \x030,12 \x03\x030,12 \x03\x030,12 \x03\n \x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\x030,12 \x03\n \x030,4 \x03\x030,4 \x03\x030,4 \x03\x030,4 \x03\x030,4 \x03\x030,4 \x03\x030,4 \x03\n \x030,4 \x03\x030,4 \x03\x030,4 \x03 \x030,4 \x03\x030,4 \x03\x030,4 \x03\n \x030,4 \x03\x030,4 \x03\x030,4 \x03\n" +process.stdout.write( "\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\n \033[311m1Y\x03\033[37m1O\x03\033[37m1 \x03\033[313m1Y\x03\033[313m1O\x03\033[313m1 \x03\033[36m1Y\x03\033[36m1O\x03\033[36m1!\x03\033[36m1!\x03\033[36m1!\x03\033[36m1!\x03\n \033[30m11 \x03\033[30m11 \x03\033[30m11 \x03\n \033[30m11 \x03\033[30m11 \x03\033[30m11 \x03 \033[30m11 \x03 \033[30m11 \x03\n \033[30m11 \x03\n \033[30m12 \x03 \033[30m12 \x03\n \033[30m10 \x03\n \033[30m10 \x03\033[30m10 \x03 \033[30m12 \x03\n \033[30m12 \x03\033[30m12 \x03\033[30m12 \x03\n \033[30m12 \x03\033[30m12 \x03\033[30m12 \x03\033[30m12 \x03\033[30m12 \x03\033[30m12 \x03\033[30m12 \x03\033[30m12 \x03\033[30m12 \x03\033[30m12 \x03\033[30m12 \x03\033[30m12 \x03\n \033[30m4 \x03\033[30m4 \x03\033[30m4 \x03\033[30m4 \x03\033[30m4 \x03\033[30m4 \x03\033[30m4 \x03\n \033[30m4 \x03\033[30m4 \x03\033[30m4 \x03 \033[30m4 \x03\033[30m4 \x03\033[30m4 \x03\n \033[30m4 \x03\033[30m4 \x03\033[30m4 \x03\n"); +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..22ccf79 --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "generator-unsemantic-express", + "version": "0.0.0", + "description": "Yeoman generator", + "license": "MIT", + "main": "app/index.js", + "repository": "pepperpepperpepper/generator-unsemantic-express", + "author": { + "name": "", + "email": "", + "url": "https://github.com/pepperpepperpepper" + }, + "engines": { + "node": ">=0.10.0" + }, + "scripts": { + "test": "mocha" + }, + "files": [ + "app" + ], + "keywords": [ + "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..38e3583 --- /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('unsemantic-express: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' + ]); + }); +}); -- cgit v1.2.3-70-g09d2