UNPKG

4.16 kBJavaScriptView Raw
1/**
2 * Configuration file for apeman projects.
3 * @see https://github.com/apeman-labo/apeman
4 */
5
6"use strict";
7
8module.exports = {
9 /**
10 * Current working directory path
11 */
12 get $cwd() {
13 return __dirname;
14 },
15 /** Package data. */
16 get $pkg() {
17 return require('./package.json');
18 },
19 /** Prototype apps */
20 get $proto() {
21 return [
22 require('apeman-proto-abstract'),
23 require('apeman-proto-wtch'),
24 require('apeman-proto-mocha')
25 ];
26 },
27 /**
28 * apeman tmpl configurations.
29 * @see https://github.com/apeman-labo/apeman-tmpl
30 */
31 get $tmpls() {
32 const robots = require('apeman-tmpl-robots'),
33 humans = require('apeman-tmpl-humans'),
34 route = require('apeman-tmpl-route'),
35 middleware = require('apeman-tmpl-middleware'),
36 bud = require('apeman-tmpl-bud'),
37 settings = require('apeman-tmpl-settings');
38
39 let $ctx = this.$ctx || {},
40 $vars = this.$vars || {};
41
42 let testDir = $ctx.testDir || $vars.TEST_DEFAULT_DIR;
43
44 return {
45 'errors/.html.bud': bud({
46 type: 'error'
47 }),
48 'middlewares/index.js': middleware({}),
49 'public/robots.txt': robots({
50 disallow: [
51 'errors',
52 'tmp',
53 'downloads'
54 ]
55 }),
56 'public/humans.txt': humans({}),
57 'routes/index.js': route({}),
58 'settings/index.js': settings({}),
59 'test/.test.js.bud': undefined,
60 [`${testDir}/.test.js.bud`]: bud({
61 type: 'route-test',
62 runner: 'mocha',
63 src: '../routes/*_route.js'
64 })
65 }
66 },
67 /**
68 * apeman task configurations.
69 * @see https://github.com/apeman-labo/apeman-task
70 */
71 get $tasks() {
72 const mocha = require('apeman-task-mocha'),
73 mkdir = require('apeman-task-mkdir'),
74 coz = require('apeman-task-coz'),
75 fmtjson = require('apeman-task-fmtjson');
76
77 let $ctx = this.$ctx || {},
78 $vars = this.$vars || {};
79
80 let testDir = $ctx.testDir || $vars.TEST_DEFAULT_DIR;
81
82 return {
83 'app:fmt': fmtjson('settings/*.json', {
84 sort: $vars.APP_FMT_SORT,
85 indent: $vars.APP_FMT_INDENT
86 }),
87 'app:mkdir': mkdir([
88 'errors',
89 'public',
90 'routes',
91 `${testDir}`,
92 'settings'
93 ]),
94 'app:render': coz([
95 $vars.APP_RENDER_PATTERN
96 ]),
97 'app:test': [
98 'mocha:run'
99 ],
100 'mocha:run': mocha([
101 `${testDir}/**/+(*_test.js|*Test.js)`
102 ], {
103 timeout: 8000
104 })
105 }
106 },
107 /**
108 * apeman watch configurations.
109 * @see https://github.com/apeman-labo/apeman-wtch
110 */
111 get $wtchs() {
112 let $vars = this.$vars;
113 return {
114 'app:render': {
115 pattern: $vars.APP_RENDER_PATTERN,
116 action: (ev, filename) => {
117 require('coz').render(filename);
118 }
119 }
120 }
121 },
122 /**
123 * Note about properties
124 */
125 get $notes() {
126 return {
127 '$tasks.app:mkdir': "Generate directories for app.",
128 '$tasks.app:render': "Render bud files.",
129 '$wtchs.app:render': "Watch bud files to render."
130 }
131 },
132 /**
133 * Commands which need to be installed in advance
134 */
135 get $needs() {
136 return {}
137 },
138 /**
139 * Project variables
140 */
141 get $vars() {
142
143 return {
144 TEST_DEFAULT_DIR: 'tests',
145 APP_FMT_SORT: true,
146 APP_FMT_INDENT: 2,
147 APP_RENDER_PATTERN: `+(errors|public|routes|tests|settings)/**/.*.bud`
148 }
149 }
150};
151
152
153if (!module.parent) {
154 // Execute this file as apeman bin.
155 require('apeman').cli(process.argv);
156}