+ 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.
* 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)
* `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

View File

@ -346,6 +346,19 @@ function getDefaultConfig() {
certPem : paths.join(__dirname, './../config/https_cert.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½
const resolvePath = require('../../core/misc_util.js').resolvePath;
const printUsageAndSetExitCode = require('./oputil_common.js').printUsageAndSetExitCode;
const ExitCodes = require('./oputil_common.js').ExitCodes;
const argv = require('./oputil_common.js').argv;
const getConfigPath = require('./oputil_common.js').getConfigPath;
const {
printUsageAndSetExitCode,
getConfigPath,
argv,
ExitCodes,
initConfigAndDatabases
} = require('./oputil_common.js');
const getHelpFor = require('./oputil_help.js').getHelpFor;
const initConfigAndDatabases = require('./oputil_common.js').initConfigAndDatabases;
const Errors = require('../../core/enig_error.js').Errors;
// deps
@ -21,6 +23,8 @@ const hjson = require('hjson');
const paths = require('path');
const _ = require('lodash');
const packageJson = require('../../package.json');
exports.handleConfigCommand = handleConfigCommand;
@ -37,6 +41,15 @@ const ConfigIncludeKeys = [
'fileBase.areaStoragePrefix',
];
const HJSONStringifyComonOpts = {
emitRootBraces : true,
bracesSameLine : true,
space : 4,
keepWsc : true,
quotes : 'min',
eol : '\n',
};
const QUESTIONS = {
Intro : [
{
@ -214,7 +227,10 @@ function askNewConfigQuestions(cb) {
}
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 {
fs.writeFileSync(path, config, 'utf8');
@ -522,6 +538,24 @@ function getImportEntries(importType, importData) {
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() {
if(true === argv.help) {
return printUsageAndSetExitCode(getHelpFor('Config'), ExitCodes.ERROR);
@ -532,6 +566,7 @@ function handleConfigCommand() {
switch(action) {
case 'new' : return buildNewConfig();
case 'import-areas' : return importAreas();
case 'cat' : return catCurrentConfig();
default : return printUsageAndSetExitCode(getHelpFor('Config'), ExitCodes.ERROR);
}

View File

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

View File

@ -10,28 +10,41 @@
/__ _\
<*> ENiGMA½ // HTTPS://GITHUB.COM/NUSKOOLER/ENIGMA-BBS <*> /__/
-------------------------------------------------------------------------------
*-----------------------------------------------------------------------------*
Generated by ENiGMA½ v%ENIG_VERSION% / hjson v%HJSON_VERSION%
*-----------------------------------------------------------------------------*
------------------------------- -- - -
General Information
-------------------------------
------------------------------- - -
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.
See http://hjson.org/ for more information and syntax.
Various editors and IDEs have plugins for the HJSON format which can be
very useful.
Various editors and IDEs such as Sublime Text 3, Visual Studio Code, and so
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: {
@ -54,7 +67,6 @@
theme: {
// Default theme applied to new users. "*" indicates random.
default: XXXXX
// Theme applied before a user has logged in. "*" indicates random.
preLogin: XXXXX
@ -146,6 +158,21 @@
// Set to your public FQDN
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" ]
// }
}
}
//