Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dropAssetic: function () {
if (!this._hasAssetic()) {
return;
}
// Remove assetic from config_dev.yml
const confDev = YAML.load('app/config/config_dev.yml');
delete confDev.assetic;
const newConfDev = YAML.stringify(confDev, 2, 4);
fs.writeFileSync('app/config/config_dev.yml', newConfDev);
// Remove assetic from config.yml
const conf = YAML.load('app/config/config.yml');
delete conf.assetic;
const newConf = YAML.stringify(conf, 2, 4);
fs.writeFileSync('app/config/config.yml', newConf);
// Remove assetic from app kernel
const appKernel = read('app/AppKernel.php').replace('new Symfony\\Bundle\\AsseticBundle\\AsseticBundle(),', '');
fs.writeFileSync('app/AppKernel.php', appKernel);
return this._composer(['remove', 'symfony/assetic-bundle']);
},
Dltbuilder.WriteFiles = function(title, dc, arr , path, name){
var aliasHead = Dltbuilder.BuildAlias(name)
var arrFinal = aliasHead.concat(arr)
var peersStr = Dltbuilder.BuildHead(title, '\r\n') + YAML.stringify(dc, 6, 2)
var shfunc=fs.readFileSync("lib/bashfunc.sh", "utf8");
var aliasStr = Dltbuilder.BuildHead(title, '\r\n') + shfunc + '\n' + arrFinal.join('\n')
fs.writeFileSync(`${path}/peers${name}.yml`, peersStr)
var shfile = `${path}/alias${name}.sh`
fs.writeFileSync(shfile, aliasStr)
}
private async registerService() {
const key = `service__${this.self.name}__${this.self.address}__${this.self.port}`;
const ttl = get(this.options, 'healthCheck.ttl', 20);
while (true) {
try {
const lease = this.client.namespace(this.namespace).lease(ttl);
await lease.put(key).value(YAML.stringify(this.self));
lease.on('lost', async () => {
lease.removeAllListeners('lost');
await sleep(5000);
await this.registerService();
});
this.logger.log('ServiceModule initialized');
break;
} catch (e) {
this.logger.error(`Unable to initial ServiceModule, retrying...`, e);
await sleep(this.options.retryInterval || 5000);
}
}
}
CloudConfig.prototype.toYAML = function () {
debug( 'stringifying to YAML' );
var yaml = YAML.stringify( this.toJSON(), Infinity, 4 );
debug( 'yaml generated' );
return "#cloud-config" + "\n" + yaml;
};
return function(req, res, next) {
if(!req.user.admin)
return next(new HTTPError('Forbidden', 403))
res.locals.config = config
res.locals.ymlConfig = yaml.stringify(config, 2, 4)
return next()
}
}
containersSocketCluster[index].env = containersSocketCluster[index].env.filter((envObject) => {
return envObject.name != 'SOCKETCLUSTER_WORKERS' && envObject.name != 'SOCKETCLUSTER_BROKERS';
});
containersSocketCluster[index].env.push({
name: 'SOCKETCLUSTER_WORKERS',
value: String(configSocketCluster.workers || defaultWorkerCount)
});
containersSocketCluster[index].env.push({
name: 'SOCKETCLUSTER_BROKERS',
value: String(configSocketCluster.brokers || defaultBrokerCount)
});
}
}
});
var formattedYAMLStringSocketCluster = sanitizeYAML(YAML.stringify(deploymentConfSocketCluster, Infinity, 2));
fs.writeFileSync(kubeConfSocketCluster, formattedYAMLStringSocketCluster);
var kubeConfSCCBroker = getSCCBrokerDeploymentDefPath(kubernetesDirPath);
var kubeConfContentSCCBroker = fs.readFileSync(kubeConfSCCBroker, {encoding: 'utf8'});
var deploymentConfSCCBroker = YAML.parse(kubeConfContentSCCBroker);
var configSCCBroker = baasilConfig.sccBroker || {};
var containersSCCBroker = deploymentConfSCCBroker.spec.template.spec.containers;
containersSCCBroker.forEach((value, index) => {
if (value) {
if (value.name == 'scc-broker') {
if (!containersSCCBroker[index].env) {
containersSCCBroker[index].env = [];
}
async set(path: string, value: any) {
this.store.update(path, value);
const yamlString = YAML.stringify(this.store.data);
try {
await this.consul.kv.set(this.key, yamlString);
} catch (e) {
throw new ConfigSyncException(e.message, e.stack);
}
}
function processLine(line) {
var targetObj = resolveFields(extractFields(line));
if (yaml) {
return YAML.stringify(targetObj, 256);
} else {
return pretty ? JSON.stringify(targetObj, undefined, 2) : JSON.stringify(targetObj)
}
}
buildServiceYML(service_id, functions, stage) {
let yamlString = YAML.stringify(this.getYAMLObject(this.serverless.service, service_id, functions, stage), 6, 2);
return write(`./.services/${service_id}/serverless.yml`, yamlString);
}
let spec: Swagger.Spec;
if (swaggerConfig.specVersion && swaggerConfig.specVersion === 3) {
spec = new SpecGenerator3(metadata, swaggerConfig).GetSpec();
} else {
spec = new SpecGenerator2(metadata, swaggerConfig).GetSpec();
}
const exists = await fsExists(swaggerConfig.outputDirectory);
if (!exists) {
await fsMkDir(swaggerConfig.outputDirectory);
}
let data = JSON.stringify(spec, null, '\t');
if (swaggerConfig.yaml) {
data = YAML.stringify(JSON.parse(data), 10);
}
const ext = swaggerConfig.yaml ? 'yaml' : 'json';
await fsWriteFile(`${swaggerConfig.outputDirectory}/swagger.${ext}`, data, { encoding: 'utf8' });
return metadata;
};