Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// If dotnet-runtime is checked-out and we can find a local repository, add it to the list.
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports,import/no-extraneous-dependencies
const jsiiDotNetRuntime = require('@jsii/dotnet-runtime');
localRepos.push(jsiiDotNetRuntime.repository);
} catch {
// Couldn't locate @jsii/dotnet-runtime, which is owkay!
}
// Filter out nonexistant directories, .NET will be unhappy if paths don't exist
const existingLocalRepos = await filterAsync(localRepos, fs.pathExists);
logging.debug('local NuGet repos:', existingLocalRepos);
// Construct XML content.
const configuration = xmlbuilder.create('configuration', { encoding: 'UTF-8' });
const packageSources = configuration.ele('packageSources');
const nugetOrgAdd = packageSources.ele('add');
nugetOrgAdd.att('key', 'nuget.org');
nugetOrgAdd.att('value', 'https://api.nuget.org/v3/index.json');
nugetOrgAdd.att('protocolVersion', '3');
existingLocalRepos.forEach((repo, index) => {
const add = packageSources.ele('add');
add.att('key', `local-${index}`);
add.att('value', path.join(repo));
});
const xml = configuration.end({ pretty: true });
// Write XML content to NuGet.config.
function parseInput(input, root, reservedWords, replaceFields) {
// inject a root node
let xml = builder.create(root),
// parse the xml input
$ = cheerio.load(input, OPTIONS);
const children = _.filter($.root()[0].children, (c) => {
return c.type === 'tag';
});
_.forEach(children, (elem) => {
if (elem.children && elem.children.length > 0 &&
_.indexOf(reservedWords, elem.name.toLowerCase()) > -1 && elem.type === 'tag') {
const elementName = replaceFields ? replaceFields[elem.name] : elem.name,
parent = xml.ele(elementName, elem.attribs, getElemData(elem));
doChildren(elem, parent, replaceFields);
}
else if (_.indexOf(reservedWords, elem.name.toLowerCase()) > -1) {
const elementName = replaceFields ? replaceFields[elem.name] : elem.name;
xml.ele(elementName, elem.attribs, getElemData(elem));
}
function makeFeed(makeEntries) {
var xml = xmlbuilder.create('feed').att('xmlns', Constants.ATOM_NAMESPACE);
xml.ele('title', { type: 'text'}, 'Test feed');
makeEntries(xml);
return xml;
}
ToGraphML.prototype.create = function(callback) {
for (var i = 0; i < this.jsonGraph.nodes.length; i++) {
if( (i+1) % 1000 == 0) {console.log('Node: ' + (i+1))};
var tmp = {node: this.addNode(this.jsonGraph.nodes[i])};
var nodeGraphml = (builder.create(tmp)).end({pretty: true});
nodeGraphml = nodeGraphml.split(/\r?\n/);
nodeGraphml.splice(0, 1);
nodeGraphml = nodeGraphml.join('\n');
fs.appendFileSync(this.filePath, nodeGraphml + '\r\n');
}
for (var i = 0; i < this.jsonGraph.edges.length; i++) {
if( (i+1) % 1000 == 0) {console.log('Edge: ' + (i+1))};
var tmp = {edge: this.addEdge(this.jsonGraph.edges[i])};
var edgeGraphml = (builder.create(tmp)).end({pretty: true});
edgeGraphml = edgeGraphml.split(/\r?\n/);
edgeGraphml.splice(0, 1);
edgeGraphml = edgeGraphml.join('\n');
fs.appendFileSync(this.filePath, edgeGraphml +'\r\n');
}
fs.appendFileSync(this.filePath, '' + '\r\n' + '');
callback(this.filePath)
}
private createChangeset(metadata: object): any {
console.log('LOG (overpass s.)', metadata['source'], metadata['comment']);
const changeset = create('osm')
.ele('changeset')
.ele('tag', { k: 'created_by', v: ConfService.appName })
.up()
.ele('tag', { k: 'source', v: metadata['source'] })
.up()
.ele('tag', { k: 'comment', v: metadata['comment'] })
.end({ pretty: true });
console.log('LOG (overpass s.)', changeset);
return changeset;
}
private projectXmlForPreview(): string {
this.tail = XmlBuilder.create("Project");
this.addProjectInfo();
return this.makeString();
}
self.CreateXml = function(jsObj) {
var copy = JSON.parse(JSON.stringify(jsObj));
var doc = xmlBuilder.create(jsObj.resourceType);
doc.att('xmlns', 'http://hl7.org/fhir');
delete copy.resourceType;
buildObject(doc, copy, jsObj.resourceType);
var xml = doc.end({ pretty: true });
return xml;
};
};
function createNuSpecXml(manifest) {
var root = xmlbuilder.create('package', {version: '1.0', encoding: 'utf-8'});
var metadata = root.ele('metadata');
metadata.ele('id', util.format('%s.%s', manifest.namespace, manifest.id));
metadata.ele('version', manifest.version);
metadata.ele('authors', manifest.author);
metadata.ele('description', manifest.summary);
if (manifest.title) {
metadata.ele('title', manifest.title);
}
if (manifest.license && manifest.license.url) {
metadata.ele('licenseUrl', manifest.license.url);
}
var requireAcceptance = !!(manifest.license && manifest.license.requireAcceptance);
metadata.ele('requireLicenseAcceptance', requireAcceptance.toString());
if (manifest.copyright) {
metadata.ele('copyright', manifest.copyright);
}
function createCorePropertiesXml(manifest) {
var nsCore = 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties';
var nsXsi = 'http://www.w3.org/2011/XMLSchema-instance';
var nsDc = 'http://purl.org/dc/elements/1.1/';
var nsDcTerms = 'http://purl.org/dc/terms/';
var root = xmlbuilder.create('coreProperties', { version: '1.0', encoding: 'utf-8'})
.att('xmlns:dc', nsDc)
.att('xmlns:dcterms', nsDcTerms)
.att('xmlns:xsi', nsXsi)
.att('xmlns', nsCore);
root.ele('dc:creator', manifest.author);
root.ele('dc:description', manifest.summary);
root.ele('dc:identifier', manifest.namespace + '.' + manifest.id);
root.ele('version', manifest.version);
root.ele('dc:language', '');
root.ele('keywords', (manifest.tags || []).join(','));
root.ele('dc:title', manifest.title);
return root.end({pretty: true});
}
toXML (callback) {
var xml = builder.create('osm', {'encoding':'UTF-8'});
xml.att('generator', 'osrm-test')
.att('version', '0.6');
this.nodes.forEach((n) => {
var node = xml.ele('node', {
id: n.id,
version: 1,
uid: n.OSM_UID,
user: n.OSM_USER,
timestamp: n.OSM_TIMESTAMP,
lon: ensureDecimal(n.lon),
lat: ensureDecimal(n.lat)
});
for (var k in n.tags) {
node.ele('tag')