Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getPackageConfig(filepath = path.join(process.cwd(), configFileName)) {
const file = fs.readFileSync(filepath);
const packageConfig = toml.parse(file);
return {
title: packageConfig.title,
description: packageConfig.description,
version: packageConfig.version,
license: packageConfig.license,
main: packageConfig.main,
authors: packageConfig.authors,
keywords: packageConfig.keywords,
// eslint-disable-next-line camelcase
git_repository: packageConfig.git_repository,
documentation: packageConfig.documentation,
scripts: packageConfig.scripts,
dependencies: Object.entries(packageConfig.dependencies).map(dep => {
return { name: dep[0], version: dep[1] };
async function load(dir) {
do {
try {
const src = await fs.readFile(path.join(dir, 'Package.toml'), 'utf8');
return { location: dir, content: toml.parse(src) };
} catch (err) {
if (err.code !== 'ENOENT') {
throw err;
}
}
const newDir = path.resolve(dir, '..');
if (newDir === dir) {
throw new Error('Could not find Package.toml.');
}
dir = newDir;
} while (true); // eslint-disable-line no-constant-condition
}
.then(data => {
this.config = TOML.parse(data);
// Each internal polyfill needs to target all supported browsers at all versions.
if (this.path.relative.startsWith('_')) {
const supportedBrowsers = Object.keys(UA.getBaselines()).sort((a, b) => a.localeCompare(b));
if (!supportedBrowsers.every(browser => this.config.browsers[browser] === "*")){
const browserSupport = {};
supportedBrowsers.forEach(browser => browserSupport[browser] = "*");
throw new Error("Internal polyfill called " + this.name + " is not targeting all supported browsers correctly. It should be: \n" + TOML.stringify(browserSupport));
}
}
this.config.detectSource = '';
this.config.baseDir = this.path.relative;
if ('licence' in this.config) {
throw new Error(`Incorrect spelling of license property in ${this.name}`);
}
this.config.hasTests = fs.existsSync(path.join(this.path.absolute, 'tests.js'));
this.config.isTestable = !('test' in this.config && 'ci' in this.config.test && this.config.test.ci === false);
this.config.isPublic = this.name.indexOf('_') !== 0;
if (fs.existsSync(this.detectPath)) {
this.config.detectSource = fs.readFileSync(this.detectPath, 'utf8').replace(/\s*$/, '') || '';
tagsCount++;
}
// build tree
const progressBar = new ProgressBar('building tree :percent [:bar] :rate/s :etas', { total: tagsCount });
for (const prefix in tagsByPrefix) {
const tags = tagsByPrefix[prefix];
for (const tag in tags) {
const tagData = {
...tags[tag],
handle: null
};
const toml = TOML.stringify(sortKeys(tagData, { deep: true }));
const blob = await tree.writeChild(`${prefix}/${tag}.toml`, toml);
progressBar.tick();
}
}
// write tree
return await tree.write();
}
.on('end', async () => {
// build tree
const progressBar = new ProgressBar('building tree :percent [:bar] :rate/s :etas', { total: tags.length });
for (const tagData of tags) {
const category = tagData.category
.replace(/\s+/, '-')
.replace(/\(s\)/, 's')
.toLowerCase();
const toml = TOML.stringify(sortKeys({
...tagData,
category: null,
canonical_name: null,
parent: tagData.parent || null,
subcategory: tagData.subcategory || null,
caption: tagData.caption || null
}, { deep: true }));
const blob = await tree.writeChild(`${category}/${tagData.canonical_name}.toml`, toml);
progressBar.tick();
}
tree.write()
.then(resolve)
.catch(reject);
automateClient.getBrowsers(function(error, browsers) {
console.log("Updated the browser list for automated testing via BrowserStack.");
fs.writeFileSync(path.join(__dirname, "browserstackBrowsers.toml"), TOML.stringify({browsers}));
fs.writeFileSync(
path.join(__dirname, "browsers.toml"),
TOML.stringify({
browsers: Array.from(new Set(browsers.map(b => (b.browser_version ? `${b.browser}/${b.browser_version}` : `${b.os}/${b.os_version}`)))).sort()
})
);
});
const thirdPartyDependenciesForFeature = filesRequiredByFeature.filter(file => file.endsWith('/config.toml')).map(file => {
const config = TOML.parse(fs.readFileSync(path.join(__dirname, '../../', file), 'utf-8'));
return config.install && config.install.module;
}).filter(thirdPartyPolyfills => thirdPartyPolyfills !== undefined);
readConfigForService(service: Service) {
return TOML.parse(fs.readFileSync(
path.join(
configFolderPath,
service.moduleName + '.' + service.id + '.toml',
),
'utf8',
) as string)
}
function parse(contents) {
let object
try {
object = TOML.parse(contents)
} catch (e) {
throw new Error(e)
}
return object
}
async function tomlMetadata(fs: FileSystem, modidTree: ModidTree, manifest: any) {
const existed = await fs.existsFile("META-INF/mods.toml");
if (existed) {
const str = await fs.readFile("META-INF/mods.toml", "utf-8");
const map = parseToml(str);
if (map.mods instanceof Array) {
for (const mod of map.mods) {
const tomlMod = mod as any;
const modObject: Partial = {
modid: tomlMod.modId,
authorList: typeof map.authors === "string" ? [map.authors] : [],
version: tomlMod.version === "${file.jarVersion}"
? manifest?.["Implementation-Version"] : tomlMod.version,
name: typeof tomlMod.displayName === "string" ? tomlMod.displayName : "",
displayName: tomlMod.displayName,
description: tomlMod.description,
loaderVersion: map.loaderVersion as string,
url: typeof map.displayURL === "string" ? map.displayURL : undefined,
}
if (typeof modObject.modid === "string") {
if (modObject.modid in modidTree) {