|
| 1 | +path = require 'path' |
| 2 | +yeoman = require 'yeoman-generator' |
| 3 | +fs = require 'fs' |
| 4 | + |
| 5 | +module.exports = class ComboGenerator extends yeoman.generators.Base |
| 6 | + constructor: (args, options, config) -> |
| 7 | + yeoman.generators.Base.apply this, arguments |
| 8 | + @on 'end', -> |
| 9 | + @installDependencies skipInstall: options['skip-install'] |
| 10 | + |
| 11 | + @pkg = JSON.parse @readFileAsString path.join __dirname, '../package.json' |
| 12 | + |
| 13 | + unless @env.options.coffee? |
| 14 | + @option('coffee') |
| 15 | + |
| 16 | + # attempt to detect if user is using CS or not |
| 17 | + # if cml arg provided, use that; else look for the existence of cs |
| 18 | + if (!@options.coffee && @expandFiles('/src/**/*.coffee', {}).length > 0) |
| 19 | + @options.coffee = true |
| 20 | + |
| 21 | + @env.options.coffee = @options.coffee |
| 22 | + |
| 23 | + |
| 24 | + if @env.options.coffee |
| 25 | + @sourceRoot path.join __dirname, '/templates/coffeescript' |
| 26 | + @ext = '.coffee' |
| 27 | + else |
| 28 | + @sourceRoot path.join __dirname, '/templates/javascript' |
| 29 | + @ext = '.js' |
| 30 | + |
| 31 | + @combo = """ _____ _____ ___ _________ _____ |
| 32 | + / __ \\| _ || \\/ || ___ \\| _ | |
| 33 | + | / \\/| | | || . . || |_/ /| | | | |
| 34 | + | | | | | || |\\/| || ___ \\| | | | |
| 35 | + | \\__/\\\\ \\_/ /| | | || |_/ /\\ \\_/ / |
| 36 | + \\____/ \\___/ \\_| |_/\\____/ \\___/ |
| 37 | +
|
| 38 | + """ |
| 39 | + |
| 40 | + askFor: -> |
| 41 | + cb = @async() |
| 42 | + |
| 43 | + # have Yeoman greet the user. |
| 44 | + console.log @combo |
| 45 | + |
| 46 | + prompts = [ |
| 47 | + name: 'gameName' |
| 48 | + message: 'What do you want to call your game?' |
| 49 | + default: 'Combo Game' |
| 50 | + ] |
| 51 | + |
| 52 | + @prompt prompts, (props) => |
| 53 | + @gameName = props.gameName |
| 54 | + cb() |
| 55 | + |
| 56 | + app: -> |
| 57 | + @template '_Gruntfile'+@ext, 'Gruntfile'+@ext |
| 58 | + |
| 59 | + @mkdir 'src' |
| 60 | + @mkdir 'src/assets' |
| 61 | + |
| 62 | + @template 'src/_Game'+@ext, 'src/' + @_.camelize(@gameName)+@ext |
| 63 | + @template 'src/_main'+@ext, 'src/main'+@ext |
| 64 | + @template '../common/src/_index.html', 'src/index.html' |
| 65 | + @copy 'src/mainWrapper.js', 'src/mainWrapper.js' |
| 66 | + |
| 67 | + # package configs/dotfiles |
| 68 | + @template '../common/_package.json', 'package.json' |
| 69 | + @template '../common/_bower.json', 'bower.json' |
| 70 | + @copy '../common/bowerrc', '.bowerrc' |
| 71 | + @copy '../common/editorconfig', '.editorconfig' |
| 72 | + @copy '../common/gitignore', '.gitignore' |
| 73 | + |
| 74 | + # fs.symlinkSync path.join(@destinationRoot(), '../support/combo'), path.join(@destinationRoot(), 'src/combo/src'), 'dir' |
0 commit comments