├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── bin ├── commands.js ├── trek ├── trek-console ├── trek-generate ├── trek-new ├── trek-server └── trek.txt ├── lib └── utils.js ├── package.json └── templates └── app ├── .babelrc ├── .editorconfig ├── .eslintrc ├── .travis.yml ├── Dockerfile ├── Procfile ├── README.md ├── app ├── controllers │ ├── users.js │ └── welcome.js ├── models │ └── user.js ├── services │ └── .gitkeep └── views │ └── .gitkeep ├── config ├── .env.development ├── .env.production ├── .env.test ├── app.development.toml ├── app.production.toml ├── app.test.toml ├── app.toml ├── database.toml ├── locales │ └── .gitkeep ├── middleware.js ├── routes.js └── secrets.js ├── docker-compose.yml ├── gitattributes ├── gitignore ├── gulpfile.js ├── log └── .gitkeep ├── package.json ├── public ├── fonts │ └── .gitkeep ├── humans.txt ├── images │ └── .gitkeep ├── robots.txt ├── scripts │ └── .gitkeep └── styles │ └── .gitkeep ├── server.js └── test └── .gitkeep /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | trekapp/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # For more information about the configurations used 2 | # in this file, please see the Travis CI documentation: 3 | # http://docs.travis-ci.com 4 | 5 | sudo: false 6 | 7 | language: node_js 8 | 9 | node_js: 10 | - '4' 11 | - '5' 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2015 fundon <cfddream@gmail.com< 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # trek-cli 2 | 3 | Command line tool for Trek's application. 4 | 5 | [![NPM version][npm-img]][npm-url] 6 | [![Build status][travis-img]][travis-url] 7 | [![Test coverage][coveralls-img]][coveralls-url] 8 | [![License][license-img]][license-url] 9 | [![Dependency status][david-img]][david-url] 10 | 11 | ### Usage 12 | 13 | ```bash 14 | $ trek -h 15 | $ trek new trekapp 16 | $ cd trekapp 17 | $ npm i 18 | $ npm start 19 | ``` 20 | 21 | ```bash 22 | 23 | Usage: trek [options] 24 | 25 | Command line tool for Trek's application 26 | 27 | Options: 28 | 29 | -h, --help output usage information 30 | -V, --version output the version number 31 | 32 | Commands: 33 | 34 | generate|g generate new code 35 | new|n create a new Trek application 36 | server|s start the Trek server 37 | console|c start the Trek console(REPL) 38 | 39 | _____ ____ _____ _ ___ 40 | /____//__ \ /____//_X__/ 41 | __ ___) / ____ ___ 42 | / / / _/ / __/ / _ \ 43 | / / / /\ \ / /__ / / \ \ 44 | /_/ /_/ /_//____//_/ \_\ 45 | 46 | 47 | ``` 48 | 49 | ## Directory Structure 50 | 51 | ```bash 52 | treek -a trekapp 53 | . 54 | ├── .babelrc 55 | ├── .editorconfig 56 | ├── .eslintrc 57 | ├── .gitattributes 58 | ├── .gitignore 59 | ├── .travis.yml 60 | ├── app 61 | │   ├── controllers 62 | │   │   ├── users.js 63 | │   │   └── welcome.js 64 | │   ├── models 65 | │   │   └── user.js 66 | │   ├── services 67 | │   │   └── .gitkeep 68 | │   └── views 69 | │   └── .gitkeep 70 | ├── config 71 | │   ├── .env.development 72 | │   ├── .env.production 73 | │   ├── .env.test 74 | │   ├── app.development.toml 75 | │   ├── app.production.toml 76 | │   ├── app.test.toml 77 | │   ├── app.toml 78 | │   ├── database.toml 79 | │   ├── locales 80 | │   │   └── .gitkeep 81 | │   ├── middleware.js 82 | │   └── routes.js 83 | │   └── secrets.toml 84 | │   └── session.js 85 | ├── docker-compose.yml 86 | ├── log 87 | │   └── .gitkeep 88 | ├── package.json 89 | ├── public 90 | │   ├── fonts 91 | │   │   └── .gitkeep 92 | │   ├── humans.txt 93 | │   ├── images 94 | │   │   └── .gitkeep 95 | │   ├── robots.txt 96 | │   ├── scripts 97 | │   │   └── .gitkeep 98 | │   └── styles 99 | │   └── .gitkeep 100 | ├── server.js 101 | └── test 102 | └── .gitkeep 103 | ``` 104 | 105 | ## LICENSE 106 | 107 | [MIT](LICENSE) 108 | 109 | [npm-img]: https://img.shields.io/npm/v/trek-cli.svg?style=flat-square 110 | [npm-url]: https://npmjs.org/package/trek-cli 111 | [travis-img]: https://img.shields.io/travis/trekjs/cli.svg?style=flat-square 112 | [travis-url]: https://travis-ci.org/trekjs/cli 113 | [coveralls-img]: https://img.shields.io/coveralls/trekjs/cli.svg?style=flat-square 114 | [coveralls-url]: https://coveralls.io/r/trekjs/cli?branch=master 115 | [license-img]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square 116 | [david-img]: https://img.shields.io/david/trekjs/cli.svg?style=flat-square 117 | [david-url]: https://david-dm.org/trekjs/cli 118 | [license-url]: LICENSE 119 | -------------------------------------------------------------------------------- /bin/commands.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = [ 4 | { 5 | name: 'generate' 6 | , alias: 'g' 7 | , description: 'generate new code' 8 | }, 9 | { 10 | name: 'new' 11 | , alias: 'n' 12 | , description: 'create a new Trek application' 13 | }, 14 | { 15 | name: 'server' 16 | , alias: 's' 17 | , description: 'start the Trek server' 18 | }, 19 | { 20 | name: 'console' 21 | , alias: 'c' 22 | , description: 'start the Trek console(REPL)' 23 | } 24 | ] 25 | -------------------------------------------------------------------------------- /bin/trek: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict' 4 | 5 | const path = require('path') 6 | const spawn = require('win-fork') 7 | const fs = require('fs') 8 | const join = path.join 9 | const resolve = path.resolve 10 | const stat = fs.statSync 11 | const exists = fs.existsSync 12 | const abbrev = require('abbrev') 13 | const program = require('commander') 14 | const chalk = require('chalk') 15 | const utils = require('../lib/utils') 16 | const pad = utils.pad 17 | const deref = utils.deref 18 | 19 | const pkg = require(path.join(__dirname, '../package')) 20 | const title = process.title = 'trek' 21 | const cmdList = require('./commands') 22 | const aliasNames = cmdList.filter((c) => !!c.alias).map((c) => c.alias) 23 | const fullList = cmdList.map((c) => c.name).concat(aliasNames) 24 | const abbrevs = abbrev(fullList) 25 | 26 | program 27 | .version(pkg.version) 28 | .description(chalk.green(pkg.description)) 29 | .usage(' [options]') 30 | 31 | program.on('--help', () => { 32 | console.log(' Commands:') 33 | console.log() 34 | cmdList.forEach((c) => { 35 | const alias = c.alias ? `|${chalk.bold.blue(c.alias)}` : '' 36 | const name = `${chalk.blue(c.name)}${alias}` 37 | console.log(' ' + pad(name, 44) + (c.description || '')) 38 | }) 39 | console.log() 40 | // http://the.sunnyspot.org/asciiart/gallery/startrek.html 41 | console.log(chalk.bold.green(fs.readFileSync(__dirname + '/trek.txt', 'utf8'))) 42 | console.log() 43 | 44 | process.exit() 45 | }) 46 | 47 | program.parse(process.argv) 48 | 49 | // args void of cmd 50 | 51 | var args = process.argv.slice(3) 52 | 53 | // command 54 | 55 | var cmd = program.args[0] 56 | 57 | // display help 58 | 59 | if (!cmd) program.help() 60 | 61 | // alias 62 | 63 | cmd = deref(cmd, abbrevs, cmdList) || cmd 64 | 65 | // executable 66 | 67 | var bin = title + '-' + cmd 68 | 69 | // local or resolve to absolute executable path 70 | 71 | var local = join(__dirname, bin) 72 | 73 | if (exists(local)) { 74 | bin = local 75 | } else { 76 | bin = process.env.PATH 77 | .split(path.delimiter) 78 | .reduce((binary, p) => { 79 | p = resolve(p, bin) 80 | return exists(p) && stat(p).isFile() ? p : binary 81 | }, bin) 82 | } 83 | 84 | // display help if bin does not exist 85 | 86 | if (!exists(bin)) { 87 | console.error('\n %s(1) does not exist', chalk.bold.red(bin)) 88 | program.help() 89 | } 90 | 91 | // spawn 92 | 93 | var proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] }) 94 | 95 | proc.on('close', (code) => { 96 | process.exit(code) 97 | }) 98 | -------------------------------------------------------------------------------- /bin/trek-console: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict' 4 | 5 | const chalk = require('chalk') 6 | const fs = require('fs') 7 | const repl = require('repl') 8 | const program = require('commander') 9 | 10 | // options 11 | 12 | program 13 | .usage('') 14 | .parse(process.argv) 15 | 16 | // CLI 17 | 18 | before(program, 'outputHelp', () => { 19 | program.allowUnknownOption() 20 | }) 21 | 22 | process.on('exit', () => { 23 | console.log() 24 | }) 25 | 26 | main() 27 | 28 | /** 29 | * Install a before function; AOP. 30 | */ 31 | 32 | function before(obj, method, fn) { 33 | var old = obj[method] 34 | 35 | obj[method] = function () { 36 | fn.call(this) 37 | old.apply(this, arguments) 38 | } 39 | } 40 | 41 | /** 42 | * Main program. 43 | */ 44 | 45 | function main() { 46 | 47 | let Trek 48 | try { 49 | let d = require('trek') 50 | Trek = d.default || d 51 | } catch (e) { 52 | const msg = `you need install the ${chalk.yellow('trek')} module.` 53 | throw new Error(msg) 54 | } 55 | 56 | const input = Trek.env === 'test' 57 | ? fs.createWriteStream('/dev/null') 58 | : process.stdin 59 | 60 | const output = Trek.env === 'test' 61 | ? fs.createReadStream('/dev/null') 62 | : process.stdout 63 | 64 | const useColors = true 65 | const prompt = `${chalk.yellow('Trek')}~${chalk.black(Trek.version)} > ` 66 | 67 | const r = repl.start({ 68 | prompt, 69 | useColors, 70 | input, 71 | output 72 | }) 73 | 74 | r.context.Trek = Trek 75 | 76 | return r 77 | } 78 | -------------------------------------------------------------------------------- /bin/trek-generate: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict' 4 | -------------------------------------------------------------------------------- /bin/trek-new: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | 'use strict' 4 | 5 | const chalk = require('chalk') 6 | const fs = require('fs-extra') 7 | const path = require('path') 8 | const mkdirp = require('mkdirp') 9 | const readline = require('readline') 10 | const templatly = require('templatly') 11 | const program = require('commander') 12 | 13 | // options 14 | 15 | program 16 | .usage('[options] [dir]') 17 | .option('-o, --orm ', 'selecte an ORM. Default: ' 18 | + chalk.cyan('sequelize') 19 | + ' (options: bookshelf/sequelize/waterline/mongoose)', 'sequelize') 20 | .option('-d, --database ', 'selecte a database. Default: ' 21 | + chalk.cyan('postgresql') 22 | +' (options: mongodb/mariadb/mysql/postgresql/sqlite3)', 'postgresql') 23 | .option('-E, --skip-env', 'don\'t create .env.{development,production,test}') 24 | .option('-G, --skip-git', 'don\'t create .gitignore file') 25 | .option('-b, --babel', 'use ES6+ with babel') 26 | .option('-l, --lint', 'use linter for project', 'eslint') 27 | .option('-f, --force', 'force on non-empty directory') 28 | .parse(process.argv) 29 | 30 | // CLI 31 | 32 | before(program, 'outputHelp', () => { 33 | program.allowUnknownOption() 34 | }) 35 | 36 | program.on('--help', () => { 37 | console.log(' Examples:') 38 | console.log() 39 | console.log(chalk.gray(' # create app')) 40 | console.log(chalk.bold.blue(' $ trek new')) 41 | console.log() 42 | console.log(chalk.gray(' # create app, selected an orm and a dabatase')) 43 | console.log(chalk.bold.blue(' $ trek new -o sequelize -d mariadb')) 44 | console.log() 45 | console.log() 46 | process.exit() 47 | }) 48 | 49 | process.on('exit', () => { 50 | console.log() 51 | }) 52 | 53 | main() 54 | 55 | /** 56 | * Install a before function; AOP. 57 | */ 58 | 59 | function before(obj, method, fn) { 60 | var old = obj[method] 61 | 62 | obj[method] = function () { 63 | fn.call(this) 64 | old.apply(this, arguments) 65 | } 66 | } 67 | 68 | /** 69 | * Prompt for confirmation on STDOUT/STDIN 70 | */ 71 | 72 | function confirm(msg, callback) { 73 | var rl = readline.createInterface({ 74 | input: process.stdin, 75 | output: process.stdout 76 | }) 77 | 78 | rl.question(msg, (input) => { 79 | rl.close() 80 | callback(/^y|yes|ok|true$/i.test(input)) 81 | }) 82 | } 83 | 84 | /** 85 | * Create application at the given directory `path`. 86 | * 87 | * @param {String} path 88 | */ 89 | 90 | function createApplication(appName, appPath) { 91 | const wait = 5 92 | 93 | // app template path 94 | const APP_TEMPLATE_PATH = path.join(__dirname, '..', 'templates', 'app') 95 | 96 | // copy files 97 | copy('app') 98 | copy('config') 99 | copy('log') 100 | copy('public') 101 | copy('test') 102 | copy('server.js') 103 | copy('.babelrc') 104 | copy('.editorconfig') 105 | copy('.eslintrc') 106 | copy('.travis.yml') 107 | copy('gitignore', true) 108 | copy('gitattributes', true) 109 | copy('docker-compose.yml') 110 | write('package.json', { name: appName }) 111 | write('README.md', { name: appName }) 112 | 113 | // copy files 114 | function copy(src, dot) { 115 | const dest = path.join(appPath, (dot ? '.' : '') + src) 116 | src = path.join(APP_TEMPLATE_PATH, src) 117 | console.log(' * %s', chalk.green(dest)) 118 | fs.copySync.call(null, src, dest) 119 | } 120 | 121 | // template, render and write file 122 | function write(src, data) { 123 | const content = fs.readFileSync(path.join(APP_TEMPLATE_PATH, src)) 124 | const pkg = templatly(content, data || {}) 125 | const dest = path.join(appPath, src) 126 | console.log(' * %s', chalk.green(dest)) 127 | fs.writeFileSync(dest, pkg) 128 | } 129 | 130 | function mkdir(dir) { 131 | dir = path.join(appPath, dir) 132 | return mkdirp.sync(dir) 133 | } 134 | } 135 | 136 | /** 137 | * Check if the given directory `path` is empty. 138 | * 139 | * @param {String} path 140 | * @param {Function} fn 141 | */ 142 | 143 | function emptyDirectory(path, fn) { 144 | fs.readdir(path, (err, files) => { 145 | if (err && 'ENOENT' != err.code) throw err 146 | fn(!files || !files.length) 147 | }) 148 | } 149 | 150 | /** 151 | * Main program. 152 | */ 153 | 154 | function main() { 155 | 156 | // Path 157 | const destinationPath = program.args.shift() || '.' 158 | 159 | // App name 160 | const appName = path.basename(path.resolve(destinationPath)) 161 | 162 | // Generate application 163 | emptyDirectory(destinationPath, (empty) => { 164 | if (empty || program.force) { 165 | createApplication(appName, destinationPath) 166 | } else { 167 | confirm('destination is not empty, continue? [y/N] ', (ok) => { 168 | if (ok) { 169 | process.stdin.destroy() 170 | createApplication(appName, destinationPath) 171 | } else { 172 | console.error('aborting') 173 | process.exit(1) 174 | } 175 | }) 176 | } 177 | }) 178 | } 179 | -------------------------------------------------------------------------------- /bin/trek-server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | -------------------------------------------------------------------------------- /bin/trek.txt: -------------------------------------------------------------------------------- 1 | _____ ____ _____ _ ___ 2 | /____//__ \ /____//_X__/ 3 | __ ___) / ____ ___ 4 | / / / _/ / __/ / _ \ 5 | / / / /\ \ / /__ / / \ \ 6 | /_/ /_/ /_//____//_/ \_\ 7 | -------------------------------------------------------------------------------- /lib/utils.js: -------------------------------------------------------------------------------- 1 | 2 | exports.pad = function pad (str, width) { 3 | var len = Math.max(0, width - str.length) 4 | return str + Array(len + 1).join(' ') 5 | } 6 | 7 | exports.deref = function deref (c, abbrevs, cmdList) { 8 | if (!c) return '' 9 | if (c.match(/[A-Z]/)) c = c.replace(/([A-Z])/g, function (m) { 10 | return "-" + m.toLowerCase() 11 | }) 12 | var a = abbrevs[c] 13 | var cmd = cmdList.filter(function (c) { 14 | return c.alias === a 15 | })[0] 16 | if (cmd) a = cmd.name 17 | return a 18 | } 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "trek-cli", 3 | "version": "0.1.7", 4 | "description": "Command line tool for Trek's application", 5 | "author": "Fangdun Cai ", 6 | "preferGlobal": true, 7 | "repository": "trekjs/trek-cli", 8 | "bin": { 9 | "trek": "./bin/trek", 10 | "trek-generate": "./bin/trek-generate", 11 | "trek-new": "./bin/trek-new", 12 | "trek-server": "./bin/trek-server", 13 | "trek-console": "./bin/trek-console" 14 | }, 15 | "keywords": [ 16 | "trek.js", 17 | "trek", 18 | "cli", 19 | "generator", 20 | "trek-generator", 21 | "app", 22 | "kit", 23 | "app-kit", 24 | "trek-app-kit" 25 | ], 26 | "license": "MIT", 27 | "dependencies": { 28 | "abbrev": "1", 29 | "chalk": "1", 30 | "commander": "2", 31 | "fs-extra": "0.30.0", 32 | "mkdirp": "0", 33 | "templatly": "0", 34 | "win-fork": "1" 35 | }, 36 | "files": [ 37 | "LICENSE", 38 | "bin/", 39 | "lib/", 40 | "templates/" 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /templates/app/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"] 3 | } 4 | -------------------------------------------------------------------------------- /templates/app/.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | indent_size = 2 8 | end_of_line = lf 9 | indent_style = space 10 | insert_final_newline = true 11 | trim_trailing_whitespace = true 12 | 13 | [{*.md,*.jade}] 14 | trim_trailing_whitespace = false 15 | 16 | [*.svg] 17 | insert_final_newline = false 18 | -------------------------------------------------------------------------------- /templates/app/.eslintrc: -------------------------------------------------------------------------------- 1 | env: 2 | node: true 3 | mocha: true 4 | 5 | parser: babel-eslint 6 | 7 | plugins: [ 8 | "babel" 9 | ] 10 | 11 | # enable ECMAScript features 12 | ecmaFeatures: 13 | arrowFunctions: true 14 | binaryLiterals: true 15 | blockBindings: true 16 | classes: true 17 | forOf: true 18 | generators: true 19 | objectLiteralShorthandMethods: true 20 | objectLiteralShorthandProperties: true 21 | octalLiterals: true 22 | templateStrings: true 23 | 24 | rules: 25 | # Possible Errors 26 | # list: https://github.com/eslint/eslint/tree/master/docs/rules#possible-errors 27 | ## check debugger sentence 28 | no-debugger: 2 29 | ## check duplicate arguments 30 | no-dupe-args: 2 31 | ## check duplicate object keys 32 | no-dupe-keys: 2 33 | ## check duplicate switch-case 34 | no-duplicate-case: 2 35 | ## disallow assignment of exceptional params 36 | no-ex-assign: 2 37 | ## disallow unreachable code 38 | no-unreachable: 2 39 | ## require valid typeof compared string like typeof foo === 'strnig' 40 | valid-typeof: 2 41 | 42 | # Best Practices 43 | # list: https://github.com/eslint/eslint/tree/master/docs/rules#best-practices 44 | ## require falls through comment on switch-case 45 | no-fallthrough: 2 46 | 47 | # Stylistic Issues 48 | # list: https://github.com/eslint/eslint/tree/master/docs/rules#stylistic-issues 49 | ## use single quote, we can use double quote when escape chars 50 | quotes: [2, "single", "avoid-escape"] 51 | ## 2 space indentation 52 | indent: [2, 2] 53 | ## add space after comma 54 | comma-spacing: 2 55 | ## put semi-colon 56 | semi: [2, "never"] 57 | ## require spaces operator like var sum = 1 + 1; 58 | space-infix-ops: 2 59 | ## require spaces return, throw, case 60 | space-return-throw-case: 2 61 | ## no space before function, eg. 'function()' 62 | space-before-function-paren: [2, "never"] 63 | ## require space before blocks, eg 'function() {' 64 | space-before-blocks: [2, "always"] 65 | ## require parens for Constructor 66 | new-parens: 2 67 | ## max 80 length 68 | max-len: [2, 80, 2] 69 | ## max 2 consecutive empty lines 70 | no-multiple-empty-lines: [2, {max: 2}] 71 | ## require newline at end of files 72 | eol-last: 2 73 | ## no trailing spaces 74 | no-trailing-spaces: 2 75 | # require space after keywords, eg 'for (..)' 76 | space-after-keywords: 2 77 | 78 | # ECMAScript 6 79 | # list: http://eslint.org/docs/rules/#ecmascript-6 80 | ## Suggest using 'const' wherever possible 81 | prefer-const: 2 82 | 83 | # Strict Mode 84 | # list: https://github.com/eslint/eslint/tree/master/docs/rules#strict-mode 85 | ## 'use strict' on top 86 | strict: [2, "global"] 87 | 88 | # Variables 89 | # list: https://github.com/eslint/eslint/tree/master/docs/rules#variables 90 | ## disallow use of undefined variables (globals) 91 | no-undef: 2 92 | 93 | # Global scoped method and vars 94 | globals: 95 | Trek : true 96 | escape : false 97 | unescape : false 98 | -------------------------------------------------------------------------------- /templates/app/.travis.yml: -------------------------------------------------------------------------------- 1 | # For more information about the configurations used 2 | # in this file, please see the Travis CI documentation: 3 | # http://docs.travis-ci.com 4 | 5 | sudo: false 6 | 7 | language: node_js 8 | 9 | node_js: 10 | - '4' 11 | - '5' 12 | -------------------------------------------------------------------------------- /templates/app/Dockerfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/Dockerfile -------------------------------------------------------------------------------- /templates/app/Procfile: -------------------------------------------------------------------------------- 1 | web: npm start -------------------------------------------------------------------------------- /templates/app/README.md: -------------------------------------------------------------------------------- 1 | # ${ name } 2 | 3 | Made with ♥ by [Trek.js](https://github.com/trekjs). -------------------------------------------------------------------------------- /templates/app/app/controllers/users.js: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | 4 | * index(next) {}, 5 | 6 | * show(next) {} 7 | 8 | } 9 | -------------------------------------------------------------------------------- /templates/app/app/controllers/welcome.js: -------------------------------------------------------------------------------- 1 | 2 | export default { 3 | 4 | * index(next) { 5 | this.body = 'Hello Trek.js!'; 6 | } 7 | 8 | }; -------------------------------------------------------------------------------- /templates/app/app/models/user.js: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /templates/app/app/services/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/app/services/.gitkeep -------------------------------------------------------------------------------- /templates/app/app/views/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/app/views/.gitkeep -------------------------------------------------------------------------------- /templates/app/config/.env.development: -------------------------------------------------------------------------------- 1 | # development environment variables 2 | -------------------------------------------------------------------------------- /templates/app/config/.env.production: -------------------------------------------------------------------------------- 1 | # production environment variables 2 | -------------------------------------------------------------------------------- /templates/app/config/.env.test: -------------------------------------------------------------------------------- 1 | # test environment variables 2 | -------------------------------------------------------------------------------- /templates/app/config/app.development.toml: -------------------------------------------------------------------------------- 1 | # development 2 | 3 | -------------------------------------------------------------------------------- /templates/app/config/app.production.toml: -------------------------------------------------------------------------------- 1 | # production 2 | 3 | -------------------------------------------------------------------------------- /templates/app/config/app.test.toml: -------------------------------------------------------------------------------- 1 | # test 2 | 3 | -------------------------------------------------------------------------------- /templates/app/config/app.toml: -------------------------------------------------------------------------------- 1 | # Application defults config 2 | 3 | [site] 4 | protocol = "http" 5 | host = "127.0.0.1" 6 | port = 3000 7 | 8 | [views] 9 | root = "" 10 | -------------------------------------------------------------------------------- /templates/app/config/database.toml: -------------------------------------------------------------------------------- 1 | # Deveopment 2 | 3 | [development] 4 | username = "trek" 5 | password = "star trek" 6 | database = "trek" 7 | host = "192.168.59.103" 8 | port = "5432" 9 | dialect = "postgres" 10 | native = true 11 | timezone = "+00:00" 12 | 13 | [development.query] 14 | pool = true 15 | debug = true 16 | logging = true 17 | 18 | [development.define] 19 | timestamps = true 20 | underscored = true 21 | charset = "utf8" 22 | 23 | 24 | # Test 25 | 26 | [test] 27 | username = "root" 28 | password = "" 29 | database = "database_test" 30 | host = "127.0.0.1" 31 | dialect = "postgres" 32 | 33 | 34 | # Production 35 | 36 | [production] 37 | username = "${env.DATABASE_USERNAME}" 38 | password = "${env.DATABASE_PASSWORD}" 39 | database = "${env.DATABASE_DATABASE}" 40 | host = "${env.DATABASE_HOST}" 41 | port = "${env.DATABASE_PORT}" 42 | dialect = "postgres" -------------------------------------------------------------------------------- /templates/app/config/locales/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/config/locales/.gitkeep -------------------------------------------------------------------------------- /templates/app/config/middleware.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Middleware 3 | */ 4 | export default (app, config) => { 5 | 6 | const middlewareConfig = config.get('middleware') || Object.create(null) 7 | 8 | 9 | // Development logger for query 10 | if (Trek.isDevelopment) { 11 | app.use(require('koa-logger')()) 12 | } 13 | 14 | 15 | // bodyparser 16 | app.use(require('koa-bodyparser')(middlewareConfig.bodyparser)) 17 | 18 | 19 | // method-override 20 | const methodOverride = middlewareConfig.methodoverride 21 | if (methodOverride) { 22 | app.use(require('koa-methodoverride')(methodOverride.getter, methodOverride.options)) 23 | } 24 | 25 | 26 | // session 27 | let session = { 28 | key: 'trek.sid', 29 | prefix: 'trek:sess:' 30 | } 31 | let store = middlewareConfig.session && middlewareConfig.session.store 32 | Object.assign( 33 | session, 34 | middlewareConfig.session, 35 | { 36 | store: Trek.isProduction && require('koa-redis')(store) 37 | } 38 | ) 39 | app.use(require('koa-generic-session')(session)) 40 | 41 | 42 | // compress 43 | const compress = config.get('middleware.compress') 44 | if (compress) { 45 | app.use(require('koa-compress')(compress)) 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /templates/app/config/routes.js: -------------------------------------------------------------------------------- 1 | 2 | get('/', { to: 'welcome#index' }) 3 | -------------------------------------------------------------------------------- /templates/app/config/secrets.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/config/secrets.js -------------------------------------------------------------------------------- /templates/app/docker-compose.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/docker-compose.yml -------------------------------------------------------------------------------- /templates/app/gitattributes: -------------------------------------------------------------------------------- 1 | # Automatically normalize line endings for all text-based files 2 | # http://git-scm.com/docs/gitattributes#_end_of_line_conversion 3 | * text=auto 4 | 5 | # For the following file types, normalize line endings to LF on 6 | # checkin and prevent conversion to CRLF when they are checked out 7 | # (this is required in order to prevent newline related issues like, 8 | # for example, after the build script is run) 9 | .* text eol=lf 10 | *.css text eol=lf 11 | *.html text eol=lf 12 | *.js text eol=lf 13 | *.json text eol=lf 14 | *.md text eol=lf 15 | *.sh text eol=lf 16 | *.txt text eol=lf 17 | *.xml text eol=lf -------------------------------------------------------------------------------- /templates/app/gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | node_modules 4 | bower_components 5 | npm-debug.log 6 | coverage 7 | 8 | dist 9 | test/tmp 10 | .tmp 11 | 12 | # .env* files 13 | config/.env* 14 | !.env.example 15 | !.env.sample 16 | -------------------------------------------------------------------------------- /templates/app/gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var $ = require('gulp-load-plugins')(); 3 | var browserSync = require('browser-sync'); 4 | var reload = browserSync.reload; 5 | 6 | gulp.task('browser-sync', function() { 7 | browserSync({ 8 | proxy: { 9 | target: '127.0.0.1:3000' 10 | }, 11 | logLevel: 'debug', 12 | logConnections: true 13 | }); 14 | }); 15 | 16 | gulp.task('scss', function() { 17 | return buildSCSS(); 18 | }); 19 | 20 | gulp.task('watch:scss', function() { 21 | return buildSCSS(true) 22 | .on('data', function(file) { 23 | //console.log(file); 24 | }) 25 | .pipe(reload({ 26 | stream: true 27 | })); 28 | }); 29 | 30 | gulp.task('watch:html', function() { 31 | gulp.watch('app/views/**/*.html').on('change', reload); 32 | }); 33 | 34 | gulp.task('watch', ['browser-sync', 'watch:scss', 'watch:html']); 35 | 36 | function buildSCSS(watching) { 37 | var pattern = 'public/scss/*.scss'; 38 | var task = gulp.src(pattern); 39 | 40 | if (watching) { 41 | task = $.watch(pattern, { 42 | emit: 'all', 43 | verbose: true 44 | }) 45 | } 46 | 47 | return task 48 | .pipe($.sass()) 49 | .pipe(gulp.dest('public/styles')); 50 | } 51 | -------------------------------------------------------------------------------- /templates/app/log/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/log/.gitkeep -------------------------------------------------------------------------------- /templates/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "${ name }", 3 | "version": "0.0.0", 4 | "private": true, 5 | "description": "Powered by Trek.js", 6 | "scripts": { 7 | "start": "babel-node server.js" 8 | }, 9 | "dependencies": { 10 | "babel-core": "6", 11 | "trek": "trekjs/trek", 12 | "trek-cli": "trekjs/cli", 13 | "koa-bodyparser": "^3.x", 14 | "koa-compress": "^1.x", 15 | "koa-methodoverride": "^2.x", 16 | "koa-morgan": "^1.x", 17 | "koa-redis": "^1.x", 18 | "koa-generic-session": "^1.x", 19 | "koa-logger": "^1.x" 20 | }, 21 | "devDependencies": { 22 | "babel-cli": "6", 23 | "babel-eslint": "4", 24 | "babel-preset-es2015": "6", 25 | "browser-sync": "2", 26 | "eslint": "1", 27 | "eslint-plugin-babel": "3", 28 | "gulp": "3", 29 | "gulp-load-plugins": "1", 30 | "gulp-watch": "4", 31 | "mocha": "2" 32 | }, 33 | "engines": { 34 | "node": ">= 4" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /templates/app/public/fonts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/public/fonts/.gitkeep -------------------------------------------------------------------------------- /templates/app/public/humans.txt: -------------------------------------------------------------------------------- 1 | # humanstxt.org/ 2 | # The humans responsible & technology colophon 3 | 4 | # TEAM 5 | 6 | -- -- 7 | 8 | # THANKS 9 | 10 | 11 | 12 | # TECHNOLOGY COLOPHON 13 | 14 | HTML5, CSS3, io.js, Node.js, trek.js, babel.js, koa.js -------------------------------------------------------------------------------- /templates/app/public/images/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/public/images/.gitkeep -------------------------------------------------------------------------------- /templates/app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # www.robotstxt.org/ 2 | 3 | # Allow crawling of all content 4 | User-agent: * 5 | Disallow: -------------------------------------------------------------------------------- /templates/app/public/scripts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/public/scripts/.gitkeep -------------------------------------------------------------------------------- /templates/app/public/styles/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/public/styles/.gitkeep -------------------------------------------------------------------------------- /templates/app/server.js: -------------------------------------------------------------------------------- 1 | import Trek from 'trek'; 2 | 3 | const app = new Trek(__dirname); 4 | 5 | app.get('/', function* (next) { 6 | this.body = 'Hello Trek.js!'; 7 | }); 8 | 9 | app.on('error', function (err, context) { 10 | app.logger.error(err); 11 | }); 12 | 13 | app.run(); 14 | -------------------------------------------------------------------------------- /templates/app/test/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trekjs/cli/1014623dcad244b3ca5133eba9a2621efe360175/templates/app/test/.gitkeep --------------------------------------------------------------------------------