UNPKG

apeman-proto-app

Version:
162 lines (152 loc) 3.79 kB
/** * Configuration file for apeman projects. * @see https://github.com/apeman-labo/apeman */ 'use strict' module.exports = { /** * Current working directory path */ get $cwd () { return __dirname }, /** Package data. */ get $pkg () { return require('./package.json') }, /** Prototype projects */ get $proto () { return [ require('apeman-proto-abstract'), require('apeman-proto-wtch'), require('apeman-proto-mocha') ] }, /** * apeman tmpl configurations. * @see https://github.com/apeman-cmd-labo/apeman-tmpl */ get $tmpls () { const robots = require('apeman-tmpl-robots') const humans = require('apeman-tmpl-humans') const route = require('apeman-tmpl-route') const constants = require('apeman-tmpl-constants') const middleware = require('apeman-tmpl-middleware') const bud = require('apeman-tmpl-bud') const settings = require('apeman-tmpl-settings') let $ctx = this.$ctx || {} let $vars = this.$vars || {} let testDir = $ctx.testDir || $vars.TEST_DEFAULT_DIR return { 'constants/index.js': constants({}), 'constants/.constants.js.bud': bud({ type: 'consts', suffix: 'constants' }), 'errors/.html.bud': bud({ type: 'error' }), 'middlewares/index.js': middleware({}), 'public/robots.txt': robots({ disallow: [ 'errors', 'tmp', 'downloads' ] }), 'public/humans.txt': humans({}), 'routes/index.js': route({}), 'settings/index.js': settings({}), 'test/.test.js.bud': undefined, [`${testDir}/.test.js.bud`]: bud({ type: 'route-test', runner: 'mocha', src: '../routes/*_route.js' }) } }, /** * apeman task configurations. * @see https://github.com/apeman-cmd-labo/apeman-task */ get $tasks () { const mocha = require('apeman-task-mocha') const mkdir = require('apeman-task-mkdir') const coz = require('apeman-task-coz') const fmtjson = require('apeman-task-fmtjson') let $ctx = this.$ctx || {} let $vars = this.$vars || {} let testDir = $ctx.testDir || $vars.TEST_DEFAULT_DIR return { 'app:fmt': fmtjson('settings/*.json', { sort: $vars.APP_FMT_SORT, indent: $vars.APP_FMT_INDENT }), 'app:mkdir': mkdir([ 'constants', 'errors', 'public', 'routes', `${testDir}`, 'settings' ]), 'app:render': coz([ $vars.APP_RENDER_PATTERN ]), 'app:test': [ 'mocha:run' ], 'mocha:run': mocha([ `${testDir}/**/+(*_test.js|*Test.js)` ], { timeout: 60 * 1000 }) } }, /** * apeman watch configurations. * @see https://github.com/apeman-cmd-labo/apeman-wtch */ get $wtchs () { let $vars = this.$vars return { 'app:render': { pattern: $vars.APP_RENDER_PATTERN, action: (ev, filename) => { require('coz').render(filename) } } } }, /** * Note about properties */ get $notes () { return { '$tasks.app:mkdir': 'Generate directories for app.', '$tasks.app:render': 'Render bud files.', '$wtchs.app:render': 'Watch bud files to render.' } }, /** * Commands which need to be installed in advance */ get $needs () { return {} }, /** * Project variables */ get $vars () { return { TEST_DEFAULT_DIR: 'tests', APP_FMT_SORT: true, APP_FMT_INDENT: 2, APP_RENDER_PATTERN: '+(errors|constants|public|routes|tests|settings)/**/.*.bud' } } } if (!module.parent) { // Execute this file as apeman bin. require('apeman').cli(process.argv) }