Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const configResolver = require('./utils/config-resolver');
const tsLinter = require('./utils/ts-linter');
const skyPagesConfigUtil = require('../config/sky-pages/sky-pages.config');
const pactServers = require('../utils/pact-servers');
let skyPagesConfig = skyPagesConfigUtil.getSkyPagesConfig(command);
let http = require('http');
let httpProxy = require('http-proxy');
argv = argv || process.argv;
argv.command = command;
let pactPortSeries = [];
let consumedPorts = [];
// get a free port for every config entry, plus one for the proxy
if (!skyPagesConfig.skyux.pacts) {
logger.error('skyux pact failed! pacts does not exist on configuration file.');
process.exit();
}
let getAsyncFunction = (callback) => {
// ports are not consumed until karma starts, so need to keep track of future consumed ports
portfinder.getPortPromise(
{ port: consumedPorts.length === 0 ? 8000 : Math.max(consumedPorts) + 1 }
)
.then((port) => {
consumedPorts.push(port);
callback(null, port);
})
.catch((error) => {
callback(error, null);
});
skyPagesConfig.runtime.pactConfig.pactProxyServer = pactServers.getPactProxyServer();
if (skyPagesConfig.skyux.pacts) {
var i = 0;
skyPagesConfig.skyux.pacts.forEach((pact) => {
// set pact settings not specified in config file
pact.log = pact.log || path.resolve(process.cwd(), 'logs', `pact-${pact.provider}.log`);
pact.dir = pact.dir || path.resolve(process.cwd(), 'pacts');
pact.host = pactServers.getPactServer(pact.provider).host;
pact.port = pactServers.getPactServer(pact.provider).port;
pact.pactFileWriteMode = pact.pactFileWriteMode || 'overwrite';
i++;
});
} else {
logger.error('No pact entry in configuration!');
}
config.set({
frameworks: config.frameworks.concat('pact'),
files: config.files.concat(path.resolve(process.cwd(), 'node_modules/@pact-foundation/pact-web',
`pact-web.js`)),
pact: skyPagesConfig.skyux.pacts,
plugins: config.plugins.concat('@pact-foundation/karma-pact'),
webpack: testWebpackConfig.getWebpackConfig(skyPagesConfig, argv)
});
}
.catch((err) => {
cleanAll();
logger.error(err);
process.exit(1);
});
};
.catch(err => {
logger.error(err);
process.exit(1);
});
}
));
let config;
if (external.length > 1) {
logger.warn(`Found multiple external config files.`);
external = external.slice(0, 1);
}
if (external.length === 1) {
logger.info(`Using external config ${external[0]}`);
config = external[0];
} else if (fs.existsSync(internal)) {
logger.info(`Using internal config ${internal}`);
config = internal;
} else {
logger.error('Error locating a config file.');
process.exit(1);
}
return config;
}
.catch(err => {
logger.error(err);
killServers(1);
});
}
lintResult.errors.forEach(error => logger.error(error));
}, 10);
setTimeout(() => {
logger.error('Process failed due to linting errors:');
lintResult.errors.forEach(error => logger.error(error));
}, 10);
}
errors.forEach(error => logger.error(error));
const plural = (errors.length === 1) ? '' : 's';
.filter(tag => tag.match(/wcag\d{3}|^best*/gi))
.join(', ');
const html = violation.nodes
.reduce(
(accumulator, node) => `${accumulator}\n${node.html}\n`,
' Elements:\n'
);
const error = [
`aXe - [Rule: \'${violation.id}\'] ${violation.help} - WCAG: ${wcagTags}`,
` Get help at: ${violation.helpUrl}\n`,
`${html}\n\n`
].join('\n');
logger.error(error);
});
}