Files
cloudron-box/src/custom.js
T

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-05-07 09:34:23 -07:00
'use strict';
let debug = require('debug')('box:features'),
2019-05-10 11:19:13 -07:00
lodash = require('lodash'),
2019-05-07 09:34:23 -07:00
paths = require('./paths.js'),
safe = require('safetydance'),
yaml = require('js-yaml');
exports = module.exports = {
2019-05-10 11:19:13 -07:00
uiSpec: uiSpec,
2019-05-10 15:53:34 -07:00
spec: spec
2019-05-07 09:34:23 -07:00
};
2019-05-10 15:53:34 -07:00
const DEFAULT_SPEC = {
backups: {
configurable: true
},
domains: {
dynamicDns: true
},
subscription: {
configurable: true
2019-05-10 11:19:13 -07:00
},
support: {
2019-05-10 15:53:34 -07:00
email: 'support@cloudron.io',
remoteSupport: true
2019-05-10 11:19:13 -07:00
},
alerts: {
email: '',
notifyCloudronAdmins: false
}
};
2019-05-10 15:53:34 -07:00
const gSpec = (function () {
2019-05-07 09:34:23 -07:00
try {
2019-05-10 15:53:34 -07:00
if (!safe.fs.existsSync(paths.CUSTOM_FILE)) return DEFAULT_SPEC;
2019-05-10 11:19:13 -07:00
const c = yaml.safeLoad(safe.fs.readFileSync(paths.CUSTOM_FILE, 'utf8'));
2019-05-10 15:53:34 -07:00
return lodash.merge({}, DEFAULT_SPEC, c);
2019-05-07 09:34:23 -07:00
} catch (e) {
debug(`Error loading features file from ${paths.CUSTOM_FILE} : ${e.message}`);
2019-05-10 15:53:34 -07:00
return DEFAULT_SPEC;
2019-05-07 09:34:23 -07:00
}
})();
2019-05-10 15:53:34 -07:00
// flags sent to the UI. this is separate because we have values that are secret to the backend
2019-05-10 11:19:13 -07:00
function uiSpec() {
2019-05-10 15:53:34 -07:00
return gSpec;
2019-05-07 09:34:23 -07:00
}
2019-05-07 11:30:12 -07:00
2019-05-10 15:53:34 -07:00
function spec() {
return gSpec;
}