Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {Schema} from "js-yaml";
import failsafe from "js-yaml/lib/js-yaml/schema/failsafe";
// @ts-ignore
import nullType from "js-yaml/lib/js-yaml/type/null";
// @ts-ignore
import boolType from "js-yaml/lib/js-yaml/type/bool";
// @ts-ignore
import floatType from "js-yaml/lib/js-yaml/type/float";
import {intType} from "./int";
export const schema = new Schema({
include: [
failsafe
],
implicit: [
nullType,
boolType,
intType,
floatType
],
explicit: [
]
});
const ImageType = new yaml.Type('image', {
kind: 'scalar',
instanceOf: AssetProxy,
represent(value) {
return `${ value.path }`;
},
resolve(value) {
if (value === null) return false;
if (value instanceof AssetProxy) return true;
return false;
},
});
const OutputSchema = new yaml.Schema({
include: yaml.DEFAULT_SAFE_SCHEMA.include,
implicit: [MomentType, ImageType].concat(yaml.DEFAULT_SAFE_SCHEMA.implicit),
explicit: yaml.DEFAULT_SAFE_SCHEMA.explicit,
});
export default {
fromFile(content) {
return yaml.safeLoad(content);
},
toFile(data, sortedKeys = []) {
return yaml.safeDump(data, { schema: OutputSchema, sortKeys: sortKeys(sortedKeys) });
}
}
const request = require('request')
const openpgp = require('openpgp')
const username = require('username')
const readline = require('readline')
const split = require('split')
const semver = require('semver')
/**
* Setup Custom YAML Parsing
*/
const yaml = require('js-yaml')
const PythonUnicodeType = new yaml.Type('tag:yaml.org,2002:python/unicode', {
kind: 'scalar',
construct: (data) => { return data !== null ? data : ''; }
})
const PYTHON_SCHEMA = new yaml.Schema({
include: [yaml.DEFAULT_SAFE_SCHEMA],
explicit: [PythonUnicodeType]
})
const currentUser = process.env.SUDO_USER || username.sync()
const doc = `
Usage:
sift [options] list-upgrades [--pre-release]
sift [options] install [--pre-release] [--version=] [--mode=] [--user=]
sift [options] update
sift [options] upgrade [--pre-release]
sift [options] self-upgrade [--pre-release]
sift [options] version
sift [options] debug
sift -h | --help | -v
module.exports = function(yamlTags) {
let yamlTypes = yamlTags.map(tagToType);
let schema = new yaml.Schema({
include: [yaml.DEFAULT_SAFE_SCHEMA],
explicit: yamlTypes
});
return function(file) {
let content = fs.readFileSync(file, 'utf8');
return yaml.load(content, { schema });
};
};
schema() {
if (this._schema) return this._schema
let plugins = this._pluginM.list()
this._schema = new yaml.Schema({
include: [yaml.DEFAULT_SAFE_SCHEMA],
explicit: plugins
})
return this._schema
}
}
});
const ImageType = new yaml.Type('image', {
kind: 'scalar',
instanceOf: AssetProxy,
represent(value) {
return `${value.path}`;
},
resolve(value) {
if (value === null) return false;
if (value instanceof AssetProxy) return true;
return false;
},
});
const OutputSchema = new yaml.Schema({
include: yaml.DEFAULT_SAFE_SCHEMA.include,
implicit: [MomentType, ImageType].concat(yaml.DEFAULT_SAFE_SCHEMA.implicit),
explicit: yaml.DEFAULT_SAFE_SCHEMA.explicit,
});
export default {
fromFile(content) {
return yaml.safeLoad(content);
},
toFile(data, sortedKeys = []) {
return yaml.safeDump(data, { schema: OutputSchema, sortKeys: sortKeys(sortedKeys) });
},
};
'Fn::Equals',
'Fn::If',
'Fn::Not',
'Fn::Or',
];
let allTagTypes = [];
for (let name of supportedFunctions) {
allTagTypes.push(...makeTagTypes(name));
}
/**
* The actual js-yaml schema, extending the DEFAULT_SAFE_SCHEMA.
*/
const schema = new jsYaml.Schema({
include: [ jsYaml.CORE_SCHEMA ],
implicit: [],
explicit: allTagTypes,
});
exports.schema = schema;
/**
* Convenience function to parse the given yaml input.
*/
function yamlParse(input) {
return jsYaml.safeLoad(input, { schema: schema });
}
exports.yamlParse = yamlParse;