Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function scrubConfig(config, utils) {
if (config.meteor) {
delete config.meteor;
}
if (config.app) {
// eslint-disable-next-line
config.app = traverse(config.app).map(function () {
const path = this.path.join('.');
switch (path) {
case 'name':
return this.update('my-app');
case 'buildOptions.server':
return this.update(utils.scrubUrl(this.node));
case 'env.ROOT_URL':
return this.update(utils.scrubUrl(this.node));
case 'env.MONGO_URL':
if (config.mongo) {
const url = this.node.split('/');
url.pop();
url.push('my-app');
const invertDoc = function (obj) {
const invertedDoc = {}
// take a plain old JSON object and parse out all of the leaf-nodes
trav(obj).forEach(function (node) {
if (typeof node === 'undefined') return
const self = this
let searchable = true
this.path.forEach(item => {
// denotes that a field is indexable
if (item === '_id') searchable = false
if (item.substring(0, 1) === '!') searchable = false
})
if (searchable && this.isLeaf) {
invertedDoc[self.path.filter(item => { // eslint-disable-line
return isNaN(item)
}).join('.')] = (self.node + '').split(' ')
}
})
return invertedDoc
}
export function scrubConfig(config) {
if (config.servers) {
// eslint-disable-next-line
config.servers = traverse(config.servers).map(function() {
if (this.path.length !== 2) {
// eslint-disable-next-line
return;
}
switch (this.key) {
case 'host':
return this.update('1.2.3.4');
case 'password':
return this.update('password');
case 'pem':
return this.update('~/.ssh/pem');
// no default
}
});
function compareToSnapshot (snapshot, data) {
traverse(data).forEach(function (node) {
if (Array.isArray(node) || (typeof node === 'object' && node !== null)) return
const path = this.path.join('.')
const compareTo = objectPath.get(snapshot, path)
const t = typeof node
const ct = typeof compareTo
if (t === 'undefined' || node === null) {
log(`bad-value(${path}): is ${t === null ? 'null' : 'undefined'}`)
}
if (t !== ct) {
log(`type-diverged(${path}): ${t} !== ${ct}`)
}
if (node !== compareTo) {
export const getIsolatedQuery = (querySource, fieldName, typeName) => {
const query = getQuery(querySource);
const updatedQuery = cloneDeep(query);
const updatedRoot = updatedQuery.definitions[0].selectionSet.selections
.find(selection => selection.name && selection.name.kind === 'Name' && selection.name.value === fieldName);
if (updatedRoot) {
updatedQuery.definitions[0].selectionSet.selections = updatedRoot.selectionSet.selections;
} else if (fieldName) {
console.warn('Failed to update query root');
return;
}
traverse(updatedQuery).forEach(function (x) {
if (this.isLeaf && this.parent && this.parent.key === 'name') {
if (this.parent.parent && this.parent.parent.node.kind === 'NamedType') {
if (typeof x === 'string' && x.indexOf(`${typeName}_`) === 0) {
this.update(x.substr(typeName.length + 1));
}
}
}
});
return updatedQuery;
}
export const convertLayout = (configStr, toReact) => {
const config = JSON.parse(configStr)
const omit = ['isClosable', 'reorderEnabled', 'activeItemIndex', 'header']
return traverse(config).map(function(el) {
if (this.key === 'componentName') {
this.update(toReact ? 'lm-react-component' : this.parent.node.component)
}
if (omit.includes(this.key)) {
this.remove()
}
})
}
errors: _parseValidatorErrors(validator.errors, {
title: schema.title,
debug: options.debug
})
};
}
if (validatedData && options.filterReadonly) {
const readonlyProperties = traverse(schemaObj).reduce(function (memo, value) {
if (this.key === 'readonly' && value === true) {
memo.push(this.parent.key);
}
return memo;
}, []);
traverse(data).forEach(function () {
if (readonlyProperties.indexOf(this.key) !== -1) {
this.remove();
}
});
}
return {
valid: true
};
}
const stripSharp = (query: any) => {
return traverse(query).map(function(x) {
if (
typeof x === 'object' &&
x.kind == 'Name' &&
this.parent &&
this.parent.node.kind === 'Field' &&
x.value.match(/Sharp$/)
) {
this.parent.delete();
}
});
};
const _traversalMerge = (staticData, previewData, key) => {
const { data: previewDocData, id: previewId } = previewData[key]
function handleNode(node) {
if (node && typeof node === 'object' && node.id === previewId) {
this.update(mergeWith(node, { data: previewDocData }, mergeCopyArrays))
}
}
return traverse(staticData).map(handleNode)
}