Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Provide a full BIRD3 object that can be included by submodules.
var _root = require("find-root")(),
path = require("path"),
YAML = require("yamljs");
var BIRD3 = module.exports = {
// The root of the app, one level above .../app
root: _root,
// NPM, Bower and Composer
package: require(path.join(_root, "package.json")),
composer: require(path.join(_root, "composer.json")),
bower: require(path.join(_root, "bower.json")),
// Loading the global BIRD3 config.
config: YAML.parseFile(path.join(_root, "config/BIRD3.yml")),
// Logger
log: require("../Backend/Log"),
// The key to share WebPack data on
WebPackKey: "BIRD3.WebPack",
// The session key-prefix used to track sessions
sessionKey: "BIRD3.Session.",
// The prefix used to retrive the hprose port.
hprosePortKey: "BIRD3.hprosePort",
// Max workers...
maxWorkers: require("os").cpus().length
};
function validateSyntax(fileName) {
try {
if (fileName.endsWith(".json")) {
require('jsonlint').parse(fs.readFileSync(fileName, {
encoding: 'utf-8'
}));
console.log("Validated successfully");
} else if (fileName.endsWith(".yaml") || fileName.endsWith(".yml")) {
require('yamljs').parseFile(fileName);
console.log("Validated successfully");
}else if(fileName.endsWith(".xml")){
var result = require('fast-xml-parser').validate(fs.readFileSync(fileName, {
encoding: 'utf-8'
}));
if(result === true) {
console.log("Validated successfully");
}else{
console.log("Validation failed");
}
}else {
console.log("Unsupported file");
}
} catch (e) {
console.log("Validation failed");
console.log(color(e, 'red'));
buildMappings(mappingFiles, allMappings){
var fileLevelMappings;
allMappings = allMappings || [];
//defaultConfig = config.mappings.default || defaultConfig;
defaultConfig = deepAssign({},defaultConfig, this.options.mappings.default);
for(var fileName in mappingFiles){
var req_mapping = mappingFiles[fileName];
try{
fileLevelMappings = YAML.parseFile(req_mapping);
if(!fileLevelMappings || fileLevelMappings.length === 0){
logger.info(req_mapping + " is an empty file.");
}else{
logger.info("Loading "+ fileLevelMappings.length +" mappings from " + req_mapping);
let fileLevelMappingIndex = -1;
for(var i=0;i
gulp.task('changelog', cb => {
const YAML = require('yamljs');
const reduce = require('lodash/reduce');
const sortBy = require('lodash/sortBy');
let parsed = YAML.parseFile('./CHANGELOG.yml');
Object.keys(parsed)
.sort()
.reverse()
.reduce(
(acc, version) => {
acc[version] = parsed[version];
return acc;
},
{}
);
const versions = Object.keys(parsed);
const numVersions = versions.length;
RoutesManager.prototype.readRoutesFromFile = function(filepath){
let routes;
try{
routes = YAML.parseFile(filepath);
}catch(e){
logger.log.error( filepath + " is an invalid Yaml file or have syntax issues.");
logger.log.error( e);
}
logger.log.info("reading "+ (routes && routes.length) +" routes from file " + filepath);
routes && this.addRoutes(routes);
}