Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.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()
})
);
});
export function writeTomlConfig(fileName: string): void {
const content = stringify(generateTomlConfig(defaults, BeaconNodeOptions));
try {
ensureDirectoryExistence(fileName);
fs.writeFileSync(fileName, content);
} catch {
throw new CliError(`Could not write to ${fileName}`);
}
}
function dump(object) {
let toml
try {
toml = TOML.stringify(object)
} catch (e) {
throw new Error(e)
}
return toml
}
const service = new Service()
service.configured = true
service.enabled = true
service.primaryMode = false
service.instanceName = newInstanceName
service.moduleName = serviceModule.moduleName
await serviceRepository.save(service)
fs.writeFileSync(
path.join(
configFolderPath,
service.moduleName + '.' + service.id + '.toml',
),
TOML.stringify(configuration),
)
this.context.coreLogger.info(
`Created and configured instance ${newInstanceName} of service ${serviceName}`,
)
}
const schema = nativeRequire(serviceModule.modulePath).Config
const fieldList = Reflect.getMetadata(
fieldListMetadataKey,
new schema(),
) as string[]
if (!fieldList.every(el => configuration[el] !== undefined)) {
throw new BadRequestError('Config does not match schema')
}
fs.writeFileSync(
path.join(
configFolderPath,
service.moduleName + '.' + service.id + '.toml',
),
TOML.stringify(configuration),
)
if (!serviceModule) {
throw new NotFoundError('Service with given name does not exist')
}
service.configured = true
await this.servicesRepository.save(service)
if (!this.context.serviceManager.getServiceForId(service.id)) {
await this.context.serviceManager.loadService(service)
}
const serviceModules = await this.context.serviceManager.getAvailableServices()
service['serviceModule'] = serviceModules.find(
sm => sm.moduleName === service.moduleName,
}
const wizard = new CLIConfigWizard()
const confSchema = nativeRequire(serviceModule.modulePath).Config
this.context.coreLogger.info(
`Reconfiguring instance ${newInstanceName} of service ${serviceName}`,
)
const configuration: { [x: string]: any } = await wizard.promptForConfig(
confSchema,
)
fs.writeFileSync(
path.join(
configFolderPath,
serviceName + '.' + newInstanceName + '.toml',
),
TOML.stringify(configuration),
)
this.context.coreLogger.info('New configuration saved.')
}