+ oputil.js config cat
* Many updates to config gen y
This commit is contained in:
@@ -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
|
||||
//
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>]
|
||||
|
||||
Reference in New Issue
Block a user