Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (schema.definitions) {
Object.keys(schema.definitions).forEach((key) => {
removeAdditionalProperties(schema.definitions[key])
enableAll(schema.definitions[key])
})
}
jsf.option({
useExamplesValue: true,
useDefaultValue: false, // do not change this!!
fixedProbabilities: true,
alwaysFakeOptionals: true
})
const values = jsf.generate(schema)
const doc = YAML.parseDocument(YAML.stringify(values))
const comments = [`# ${pathOr(config.projectSlug, ['title'], schema)}`, '']
const description = pathOr('', ['description'], schema)
if (description) {
comments.push(' ' + description)
}
doc.commentBefore = comments.join('\n')
doc.spaceAfter = false
doc.spaceBefore = false
doc.contents.items.forEach(enhance(schema, []))
return Promise.resolve({
// schema,
if(buildDocker){
shell.env.WORDUP_DOCKERFILE_WP_PATH = this.wordupDockerPath('wp')
shell.env.WORDUP_DOCKERFILE_WPCLI_PATH = this.wordupDockerPath('wp-cli')
composerFiles += seperator + this.wordupDockerPath('docker-compose.build.yml')
}
//Legacy support for projects which don't have .wordup/config.yml
this.updateWordupStructure()
if (fs.existsSync(this.getProjectPath('.wordup','config.yml'))) {
try {
this.dotWordupYml = YAML.parseDocument(fs.readFileSync(this.getProjectPath('.wordup','config.yml'), 'utf8'))
this.dotWordupJson = this.dotWordupYml.toJSON()
} catch (err) {
this.error('Could not parse wordup config: '+err, {exit:1})
}
// Create the slug as a name. Because it could be also a path
const slug = this.wPkg('slug')
if(slug){
if (slug.lastIndexOf('/') !== -1) {
dotProp.set(this.dotWordupJson, 'slugName', slug.substring(0, slug.lastIndexOf('/')))
} else {
dotProp.set(this.dotWordupJson, 'slugName', slug)
}
}
// Get config based on the current path
export function deleteValue(values: string, path: string) {
const doc = YAML.parseDocument(values);
const { splittedPath } = parsePathAndValue(doc, path);
(doc as any).deleteIn(splittedPath);
// If the document is empty after the deletion instead of returning {}
// we return an empty line "\n"
return doc.contents && !isEmpty((doc.contents as any).items) ? doc.toString() : "\n";
}
async function duplicateSystemYaml() {
const LCUExePath = await getLCUExecutableFromProcess();
const LCUDir = IS_WIN ? path.dirname(LCUExePath) : `${path.dirname(LCUExePath)}/../../..`;
const originalSystemFile = path.join(LCUDir, 'system.yaml');
const overrideSystemFile = path.join(LCUDir, 'Config', 'rift-explorer', 'system.yaml');
// File doesn't exist, do nothing
if (!(await fs.exists(originalSystemFile))) {
throw new Error('system.yaml not found');
}
const file = await fs.readFile(originalSystemFile, 'utf8');
const fileParsed = yaml.parseDocument(file);
fileParsed.delete('riotclient');
fileParsed.set('enable_swagger', true);
const stringifiedFile = yaml.stringify(fileParsed);
// Rito's file is prefixed with --- newline
await fs.outputFile(overrideSystemFile, `---\n${stringifiedFile}`);
}
export function getValue(values: string, path: string, defaultValue?: any) {
const doc = YAML.parseDocument(values);
const splittedPath = path.split(".");
const value = (doc as any).getIn(splittedPath);
return value === undefined || value === null ? defaultValue : value;
}
File: ['Key', (data, next) => {
if (!file) return next();
let content;
try {
content = fs.readFileSync(path.resolve(file), 'utf8');
} catch (ex) {
console.error('Filed to read the file');
console.log(ex);
return next(true);
}
const packets = YAML.parseDocument(content);
if (Array.isArray(packets.errors) && packets.errors.length > 0) {
packets.errors.forEach(console.error);
return next(true);
}
const rows = packets.toJSON();
Object.keys(rows).forEach(key => {
decodeLine(data.Key, rows[key].replace(/\n/g, ''), false);
});
next();
}],
Line: ['File', (data, next) => {
prepareTextForRendering = () => {
if (this.props.yamlText !== "") {
const yamlObj = yamlParser.parseDocument(this.props.yamlText);
const inputFiles = yamlObj.get("input_files");
if (inputFiles) {
if (Array.isArray(inputFiles.items)) {
inputFiles.items.forEach((inputFileItem) => {
inputFileItem.value = this.encloseFileInTags(inputFileItem.value);
});
} else {
yamlObj.set("input_files", this.encloseFileInTags(inputFiles));
}
}
const properties = yamlObj.get("properties");
if (properties) {
if (Array.isArray(properties.items)) {
properties.items.forEach((property) => {
parse: (d: string) => YAML.parseDocument(d).toJSON()
},
export function setValue(values: string, path: string, newValue: any) {
const doc = YAML.parseDocument(values);
const { splittedPath, value } = parsePathAndValue(doc, path, newValue);
(doc as any).setIn(splittedPath, value);
return doc.toString();
}