+ oputil.js config cat

* Many updates to config gen
y
This commit is contained in:
Bryan Ashby 2018-11-10 23:59:26 -07:00
parent 82cfdc978f
commit c24695e998
5 changed files with 337 additions and 254 deletions

View File

@ -19,6 +19,9 @@ This document attempts to track **major** changes and additions in ENiGMA½. For
* Any module may now register for a system startup intiialization via the `initializeModules(initInfo, cb)` export. * Any module may now register for a system startup intiialization via the `initializeModules(initInfo, cb)` export.
* User event log is now functional. Various events a user performs will be persisted to the `system.db` `user_event_log` table for up to 90 days. An example usage can be found in the updated `last_callers` module where events are turned into Ami/X style actions. Please see `UPGRADE.md`! * User event log is now functional. Various events a user performs will be persisted to the `system.db` `user_event_log` table for up to 90 days. An example usage can be found in the updated `last_callers` module where events are turned into Ami/X style actions. Please see `UPGRADE.md`!
* New MCI codes including general purpose movement codes. See [MCI codes](docs/art/mci.md) * New MCI codes including general purpose movement codes. See [MCI codes](docs/art/mci.md)
* `install.sh` will now attempt to use NPM's `--build-from-source` option when ARM is detected.
* `oputil.js config new` will now generate a much more complete configuration file with comments, examples, etc. `oputil.js config cat` dumps your current config to stdout.
## 0.0.8-alpha ## 0.0.8-alpha

View File

@ -346,6 +346,19 @@ function getDefaultConfig() {
certPem : paths.join(__dirname, './../config/https_cert.pem'), certPem : paths.join(__dirname, './../config/https_cert.pem'),
keyPem : paths.join(__dirname, './../config/https_cert_key.pem'), keyPem : paths.join(__dirname, './../config/https_cert_key.pem'),
} }
},
gopher : {
enabled : false,
port : 8070,
publicHostname : 'another-fine-enigma-bbs.org',
publicPort : 8080, // adjust if behind NAT/etc.
bannerFile : 'gopher_banner.asc',
//
// Set messageConferences{} to maps of confTag -> [ areaTag1, areaTag2, ... ]
// to export message confs/areas
//
} }
}, },

View File

@ -4,12 +4,14 @@
// ENiGMA½ // ENiGMA½
const resolvePath = require('../../core/misc_util.js').resolvePath; const resolvePath = require('../../core/misc_util.js').resolvePath;
const printUsageAndSetExitCode = require('./oputil_common.js').printUsageAndSetExitCode; const {
const ExitCodes = require('./oputil_common.js').ExitCodes; printUsageAndSetExitCode,
const argv = require('./oputil_common.js').argv; getConfigPath,
const getConfigPath = require('./oputil_common.js').getConfigPath; argv,
ExitCodes,
initConfigAndDatabases
} = require('./oputil_common.js');
const getHelpFor = require('./oputil_help.js').getHelpFor; const getHelpFor = require('./oputil_help.js').getHelpFor;
const initConfigAndDatabases = require('./oputil_common.js').initConfigAndDatabases;
const Errors = require('../../core/enig_error.js').Errors; const Errors = require('../../core/enig_error.js').Errors;
// deps // deps
@ -21,6 +23,8 @@ const hjson = require('hjson');
const paths = require('path'); const paths = require('path');
const _ = require('lodash'); const _ = require('lodash');
const packageJson = require('../../package.json');
exports.handleConfigCommand = handleConfigCommand; exports.handleConfigCommand = handleConfigCommand;
@ -37,6 +41,15 @@ const ConfigIncludeKeys = [
'fileBase.areaStoragePrefix', 'fileBase.areaStoragePrefix',
]; ];
const HJSONStringifyComonOpts = {
emitRootBraces : true,
bracesSameLine : true,
space : 4,
keepWsc : true,
quotes : 'min',
eol : '\n',
};
const QUESTIONS = { const QUESTIONS = {
Intro : [ Intro : [
{ {
@ -214,7 +227,10 @@ function askNewConfigQuestions(cb) {
} }
function writeConfig(config, path) { function writeConfig(config, path) {
config = hjson.stringify(config, { bracesSameLine : true, space : '\t', keepWsc : true, quotes : 'strings' } ); config = hjson.stringify(config, HJSONStringifyComonOpts)
.replace(/%ENIG_VERSION%/g, packageJson.version)
.replace(/%HJSON_VERSION%/g, hjson.version)
;
try { try {
fs.writeFileSync(path, config, 'utf8'); fs.writeFileSync(path, config, 'utf8');
@ -522,6 +538,24 @@ function getImportEntries(importType, importData) {
return importEntries; return importEntries;
} }
function catCurrentConfig() {
try {
const config = hjson.rt.parse(fs.readFileSync(getConfigPath(), 'utf8'));
const hjsonOpts = Object.assign({}, HJSONStringifyComonOpts, {
colors : false === argv.colors ? false : true,
keepWsc : false === argv.comments ? false : true,
});
console.log(hjson.stringify(config, hjsonOpts));
} catch(e) {
if('ENOENT' == e.code) {
console.error(`File not found: ${getConfigPath()}`);
} else {
console.error(e);
}
}
}
function handleConfigCommand() { function handleConfigCommand() {
if(true === argv.help) { if(true === argv.help) {
return printUsageAndSetExitCode(getHelpFor('Config'), ExitCodes.ERROR); return printUsageAndSetExitCode(getHelpFor('Config'), ExitCodes.ERROR);
@ -532,6 +566,7 @@ function handleConfigCommand() {
switch(action) { switch(action) {
case 'new' : return buildNewConfig(); case 'new' : return buildNewConfig();
case 'import-areas' : return importAreas(); case 'import-areas' : return importAreas();
case 'cat' : return catCurrentConfig();
default : return printUsageAndSetExitCode(getHelpFor('Config'), ExitCodes.ERROR); default : return printUsageAndSetExitCode(getHelpFor('Config'), ExitCodes.ERROR);
} }

View File

@ -39,12 +39,17 @@ actions:
actions: actions:
new generate a new/initial configuration new generate a new/initial configuration
import-areas PATH import areas using fidonet *.NA or AREAS.BBS file from PATH import-areas PATH import areas using fidonet *.NA or AREAS.BBS file from PATH
cat cat current configuration to stdout
import-areas args: import-areas args:
--conf CONF_TAG specify conference tag in which to import areas --conf CONF_TAG specify conference tag in which to import areas
--network NETWORK specify network name/key to associate FTN areas --network NETWORK specify network name/key to associate FTN areas
--uplinks UL1,UL2,... specify one or more comma separated uplinks --uplinks UL1,UL2,... specify one or more comma separated uplinks
--type TYPE specifies area import type. valid options are "bbs" and "na" --type TYPE specifies area import type. valid options are "bbs" and "na"
cat args:
--no-color disable color
--no-comments strip any comments
`, `,
FileBase : FileBase :
`usage: oputil.js fb <action> [<args>] `usage: oputil.js fb <action> [<args>]

View File

@ -10,28 +10,41 @@
/__ _\ /__ _\
<*> ENiGMA½ // HTTPS://GITHUB.COM/NUSKOOLER/ENIGMA-BBS <*> /__/ <*> ENiGMA½ // HTTPS://GITHUB.COM/NUSKOOLER/ENIGMA-BBS <*> /__/
------------------------------------------------------------------------------- *-----------------------------------------------------------------------------*
Generated by ENiGMA½ v%ENIG_VERSION% / hjson v%HJSON_VERSION%
*-----------------------------------------------------------------------------*
------------------------------- -- - -
General Information General Information
------------------------------- ------------------------------- - -
This configuration is in HJSON (http://hjson.org/) format. Strict to-spec This configuration is in HJSON (http://hjson.org/) format. Strict to-spec
JSON is also perfectly valid. Use 'hjson' from npm to convert to/from JSON. JSON is also perfectly valid. Use 'hjson' from npm to convert to/from JSON.
See http://hjson.org/ for more information and syntax. See http://hjson.org/ for more information and syntax.
Various editors and IDEs have plugins for the HJSON format which can be Various editors and IDEs such as Sublime Text 3, Visual Studio Code, and so
very useful. on have syntax highlighting for the HJSON format which are highly recommended.
Available Configuration
-------------------------------
ENiGMA½ is highly configurable! By default, this file contains common
configuration elements, examples, etc. To see a full list of settings
available to this file, don't be afraid to open up core/config.js and
look around. Do not make changes there however, you may override any
of the configuration from within this file!
See the documentation for more information, and don't be shy to ask ------------------------------- -- - -
for help! Configuration
------------------------------- - -
ENiGMA½ is *highly* configurable, and thus can be overwhelming at first!
By default, this file contains common configuration elements, examples, etc.
To see a more complete view of settings available to the system, don't be
afraid to open up core/config.js and look around. Do not make changes there
however! All system configuration can be extended and defaults overridden
via this file!
Please see RTFM ...er, uh... see the documentation for more information, and
don't be shy to ask for help:
BBS : Xibalba @ xibalba.l33t.codes
FTN : BBS Discussion on fsxNet
IRC : #enigma-bbs / FreeNode
Email : bryan@leet.codes
*/ */
general: { general: {
@ -54,7 +67,6 @@
theme: { theme: {
// Default theme applied to new users. "*" indicates random. // Default theme applied to new users. "*" indicates random.
default: XXXXX default: XXXXX
// Theme applied before a user has logged in. "*" indicates random. // Theme applied before a user has logged in. "*" indicates random.
preLogin: XXXXX preLogin: XXXXX
@ -146,6 +158,21 @@
// Set to your public FQDN // Set to your public FQDN
domain: XXXXX domain: XXXXX
} }
// Ladies and gentlemen, a Gopher server!
gopher: {
port: XXXXX
enabled: false
//
// The Gopher Content Server can export message base
// conferences and areas via the "messageConferences" key.
//
// Example:
// messageConferences: {
// some_conf: [ "area_tag1", "area_tag2" ]
// }
}
} }
// //