UNPKG

1.1 kBJavaScriptView Raw
1/**
2 * Dependencies
3 */
4
5var pkg = require('./package.json')
6 , fs = require('fs')
7 , path = require('path')
8 , nash = require('nash')
9 , cli = nash()
10 ;
11
12
13/**
14 * Settings
15 */
16
17cli.set({
18 pkg:
19 pkg,
20 logo:
21 fs.readFileSync(
22 path.join(__dirname, 'lib', 'logo.txt'), 'ascii'
23 ),
24 website:
25 'http://anvil.io',
26 description:
27 'A modern authorization server built to\n' +
28 'authenticate your users and protect your APIs.',
29});
30
31
32/**
33 * Initialize
34 * Requires and registers a directory of plugins.
35 */
36
37cli.initialize = function (directory) {
38 var plugins = []
39 , modules = fs.readdirSync(directory)
40 ;
41
42 modules.forEach(function (mod) {
43 if (path.extname(mod) === '.js' && path.basename(mod) !== 'index.js') {
44 plugins.push({
45 register: require(path.join(directory, mod))
46 });
47 }
48 });
49
50 cli.register(plugins, function (err) {});
51}
52
53
54/**
55 * Register Commands and Plugins
56 */
57
58cli.initialize(path.join(__dirname, 'lib', 'commands'));
59cli.initialize(path.join(__dirname, 'lib', 'plugins'));
60
61
62/**
63 * Exports
64 */
65
66module.exports = cli;