Skip to content

Commit

Permalink
Update all dependencies to latest versions
Browse files Browse the repository at this point in the history
Except for v8-to-istanbul. Something about the latest version causes
code coverage for the browser to always show 100% after integrating the
new API. Don’t have time to figure it out right now.
  • Loading branch information
ccampbell committed Apr 25, 2021
1 parent a7a2857 commit 3d23a82
Show file tree
Hide file tree
Showing 4 changed files with 4,228 additions and 1,114 deletions.
74 changes: 40 additions & 34 deletions bin/luna.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
/* Luna v1.6.1 */
'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var chalk = require('chalk');
var ProgressBar = require('progress');

var chalk = _interopDefault(require('chalk'));
var ProgressBar = _interopDefault(require('progress'));
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
var ProgressBar__default = /*#__PURE__*/_interopDefaultLegacy(ProgressBar);

const constant = /\b(\d+|true|false)\b/g;
const operator = /\+|\!|\-|&|>|<|\||\*|\=/g;
Expand Down Expand Up @@ -268,8 +271,8 @@ function assert() {
}

const express = require('express');
const fs = require('fs');
const path = require('path');
const fs$2 = require('fs');
const path$1 = require('path');
const rollup = require('rollup');
const buble = require('rollup-plugin-buble');
const replace = require('rollup-plugin-replace');
Expand All @@ -286,7 +289,7 @@ async function getBundle(filePath, options) {
// straight string replacement any path that has \test\something in
// it will end up rendering the \t as a tab characters. We have to
// make sure that any \ are replaced with \\
const fullTestPath = path.join(process.cwd(), filePath).replace(/\\/g, '\\\\');
const fullTestPath = path$1.join(process.cwd(), filePath).replace(/\\/g, '\\\\');
const plugins = [
replace({
TEST_FILE_PATH: fullTestPath,
Expand All @@ -311,13 +314,16 @@ async function getBundle(filePath, options) {
if (options.svelte) {
plugins.unshift(svelte({
include: options.svelte,
dev: true,
css: true
emitCss: false,
compilerOptions: {
css: true,
dev: true
}
}));
}

const bundle = await rollup.rollup({
input: path.resolve(`${__dirname}/../src`, options.node ? 'run-node.js' : 'run-browser.js'),
input: path$1.resolve(`${__dirname}/../src`, options.node ? 'run-node.js' : 'run-browser.js'),
external: ['chalk'],
treeshake: true,
plugins
Expand All @@ -344,7 +350,7 @@ async function getBundle(filePath, options) {
async function bundleHandler(req, res) {
const filePath = req.params[0];

const exists = fs.existsSync(filePath);
const exists = fs$2.existsSync(filePath);
if (!exists) {
res.status(404).send('File does not exist');
return;
Expand Down Expand Up @@ -385,7 +391,7 @@ async function startServer(options) {

return app.listen(options.port, () => {
if (options.verbose) {
console.log(`🔌 Server started at ${chalk.bold(`http://localhost:${options.port}`)}…`);
console.log(`🔌 Server started at ${chalk__default['default'].bold(`http://localhost:${options.port}`)}…`);
}
});
}
Expand All @@ -395,7 +401,7 @@ function syntaxHighlight(code) {
const stringMap = {};

if (code === undefined) {
return chalk.yellow('undefined');
return chalk__default['default'].yellow('undefined');
}

code = code.replace(string, (match) => {
Expand All @@ -405,11 +411,11 @@ function syntaxHighlight(code) {
return stringName;
});

code = code.replace(operator, (match) => chalk.magenta(match));
code = code.replace(constant, (match) => chalk.yellow(match));
code = code.replace(operator, (match) => chalk__default['default'].magenta(match));
code = code.replace(constant, (match) => chalk__default['default'].yellow(match));

for (const stringName of strings) {
code = code.replace(stringName, chalk.green(stringMap[stringName]));
code = code.replace(stringName, chalk__default['default'].green(stringMap[stringName]));
}

return code;
Expand Down Expand Up @@ -884,7 +890,7 @@ function handleMessage(message, testPath, options) {

const messageBits = message.split(' ');
const failures = parseInt(messageBits[2], 10);
console.log(`${failures === 0 ? chalk.green.bold('✔︎') : chalk.red.bold('𝗫')} ${chalk.gray(`[${testPath}]`)}`, messageBits[1]);
console.log(`${failures === 0 ? chalk__default['default'].green.bold('✔︎') : chalk__default['default'].red.bold('𝗫')} ${chalk__default['default'].gray(`[${testPath}]`)}`, messageBits[1]);
return false;
}

Expand Down Expand Up @@ -1043,7 +1049,7 @@ async function runTestBrowser(browser, testPath, options) {

function killWithError(message) {
if (message) {
console.log(`⚠️ ${chalk.bold(message)}`);
console.log(`⚠️ ${chalk__default['default'].bold(message)}`);
}
process.exit(1);
}
Expand All @@ -1053,8 +1059,8 @@ function logAssertion(testData) {
const lineWidth = (lineNumber + 2).toString().length;

const indent = spaces(4);
console.log(`\n${chalk.yellow(formatLine(lineNumber - 1, lineWidth))}`);
console.log(`${chalk.yellow(formatLine(lineNumber, lineWidth))} ${indent}${syntaxHighlight(testData.source.code)}`);
console.log(`\n${chalk__default['default'].yellow(formatLine(lineNumber - 1, lineWidth))}`);
console.log(`${chalk__default['default'].yellow(formatLine(lineNumber, lineWidth))} ${indent}${syntaxHighlight(testData.source.code)}`);
let leftIndex = testData.left.range[0];

// Move it to after the last dot
Expand All @@ -1073,21 +1079,21 @@ function logAssertion(testData) {
}

if (leftIndex > -1) {
console.log(`${chalk.yellow(formatLine(lineNumber + 1, lineWidth))} ${indent}${spaces(leftIndex)}${chalk.gray('|')}${rightIndex > -1 ? spaces(rightIndex - leftIndex - 1) + chalk.gray('|') : ''}`);
console.log(`${chalk__default['default'].yellow(formatLine(lineNumber + 1, lineWidth))} ${indent}${spaces(leftIndex)}${chalk__default['default'].gray('|')}${rightIndex > -1 ? spaces(rightIndex - leftIndex - 1) + chalk__default['default'].gray('|') : ''}`);
if (rightIndex > -1) {
console.log(`${spaces(lineWidth)} ${indent}${spaces(leftIndex)}${chalk.gray('|')}${rightIndex > -1 ? spaces(rightIndex - leftIndex - 1) + syntaxHighlight(JSON.stringify(testData.right.value)) : ''}`);
console.log(`${spaces(lineWidth)} ${indent}${spaces(leftIndex)}${chalk__default['default'].gray('|')}${rightIndex > -1 ? spaces(rightIndex - leftIndex - 1) + syntaxHighlight(JSON.stringify(testData.right.value)) : ''}`);
}
console.log(`${spaces(lineWidth)} ${indent}${spaces(leftIndex)}${syntaxHighlight(JSON.stringify(testData.left.value))}\n`);
}
}

function logError(error, options) {
console.log(`\n${chalk.bold.underline(error.name)}\n`);
console.log(`\n${chalk__default['default'].bold.underline(error.name)}\n`);
if (error.type === 'taskerror') {
console.log(`⚠️ ${chalk.red(error.data)}\n`);
console.log(`⚠️ ${chalk__default['default'].red(error.data)}\n`);

if (!options.node) {
console.log(`❓ Perhaps you meant to run your tests in node using the ${chalk.bold('--node')} flag\n`);
console.log(`❓ Perhaps you meant to run your tests in node using the ${chalk__default['default'].bold('--node')} flag\n`);
}
return;
}
Expand All @@ -1097,7 +1103,7 @@ function logError(error, options) {
continue;
}

console.log(`❌ ${chalk.red.bold(test.name)}`);
console.log(`❌ ${chalk__default['default'].red.bold(test.name)}`);
if (test.data) {
logAssertion(test.data);
continue;
Expand Down Expand Up @@ -1159,7 +1165,7 @@ function logLogs(exitCode) {
console.log('');
}

console.log(chalk.bold.underline.blue('Console Logs\n'));
console.log(chalk__default['default'].bold.underline.blue('Console Logs\n'));
for (const log of logs) {
if (typeof log === 'object' && log.constructor.name === 'Array' && log[0] === puppeteerObjectText) {
console.log(log[1], log[2]);
Expand Down Expand Up @@ -1211,7 +1217,7 @@ function logCoverage(options) {
reporter.addAll(reportersToUse);
reporter.write(map);

console.log(`\n💾 HTML coverage report available at ${chalk.bold.underline('coverage/lcov-report/index.html')}`);
console.log(`\n💾 HTML coverage report available at ${chalk__default['default'].bold.underline('coverage/lcov-report/index.html')}`);
}

async function runTests(options) {
Expand Down Expand Up @@ -1240,7 +1246,7 @@ async function runTests(options) {

console.log('🌙 Running tests…');
if (!options.verbose) {
bar = new ProgressBar('⏳ [:bar] :percent (:current/:total)', {
bar = new ProgressBar__default['default']('⏳ [:bar] :percent (:current/:total)', {
total: totalTests,
width: 50,
renderThrottle: 0,
Expand Down Expand Up @@ -1338,10 +1344,10 @@ async function runTests(options) {
q.start();
}

const fs$2 = require('fs');
const fs = require('fs');
const yargs = require('yargs');
const os = require('os');
const path$1 = require('path');
const path = require('path');
const version = require('./../package.json').version;
const ci = require('ci-info');

Expand All @@ -1368,7 +1374,7 @@ function showUsage(message) {
console.log('--version Show version');

if (message) {
console.log(`\n⚠️ ${chalk.bold(message)}`);
console.log(`\n⚠️ ${chalk__default['default'].bold(message)}`);
}
}

Expand Down Expand Up @@ -1399,7 +1405,7 @@ if (argv._.length < 1) {

const paths = [];
for (let i = 0; i < argv._.length; i++) {
if (fs$2.existsSync(argv._[i])) {
if (fs.existsSync(argv._[i])) {
paths.push(argv._[i]);
}
}
Expand Down Expand Up @@ -1448,15 +1454,15 @@ if (ci.isCI) {
let fileName;
const hasCoverage = options.coverage;
if (hasCoverage) {
fileName = path$1.join(os.tmpdir(), `coverage-${process.pid}.json`);
fileName = path.join(os.tmpdir(), `coverage-${process.pid}.json`);
console.log(PREFIX.coverage, fileName);
}

await singleRun(options);

/* global __coverage__ */
if (hasCoverage && typeof __coverage__ !== 'undefined') {
fs$2.writeFileSync(fileName, JSON.stringify(__coverage__));
fs.writeFileSync(fileName, JSON.stringify(__coverage__));
}
process.exit(0);
return;
Expand Down
Loading

0 comments on commit 3d23a82

Please sign in to comment.