Skip to content

Commit

Permalink
Update chalk 4.1.2 → 5.3.0 (major) (#101)
Browse files Browse the repository at this point in the history
* Update chalk to version 5.3.0

* Turned cli package ESM

---------

Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
Co-authored-by: Kræn Hansen <[email protected]>
  • Loading branch information
depfu[bot] and kraenhansen authored Mar 19, 2024
1 parent fccd677 commit e550cd4
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 49 deletions.
60 changes: 46 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions packages/cli/bin/mocha-remote

This file was deleted.

4 changes: 4 additions & 0 deletions packages/cli/mocha-remote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node

import { run } from "./dist/index.js";
run();
14 changes: 10 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "mocha-remote-cli",
"version": "1.8.0",
"description": "Run Mocha tests somewhere - get reporting elsewhere",
"type": "module",
"main": "dist/index.js",
"scripts": {
"build": "tsc -p tsconfig.build.json",
Expand All @@ -19,7 +20,7 @@
}
},
"bin": {
"mocha-remote": "./bin/mocha-remote"
"mocha-remote": "./mocha-remote.js"
},
"author": {
"name": "Kræn Hansen",
Expand All @@ -37,19 +38,24 @@
"bugs": "https://github.com/kraenhansen/mocha-remote/issues",
"license": "ISC",
"dependencies": {
"chalk": "^4.1.0",
"chalk": "^5.3.0",
"debug": "^4.3.1",
"mocha-remote-server": "1.8.0",
"yargs": "^16.2.0"
"yargs": "^17.7.2"
},
"engines": {
"node": "^20"
},
"devDependencies": {
"@types/commander": "^2.12.2",
"@types/debug": "^4.1.5",
"@types/node": "^10",
"@types/yargs": "^17.0.32",
"mocha-remote-client": "1.8.0"
},
"eslintConfig": {
"parserOptions": {
"sourceType": "module"
},
"env": {
"node": true
},
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { run } from "./index.js";
run();
10 changes: 5 additions & 5 deletions packages/cli/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import cp from "child_process";
import path from "path";
import { expect } from "chai";
import { it } from "mocha";
import { URL } from "url";

const cliPath = path.resolve(__dirname, "./index.ts");
const cliPath = new URL("./cli.ts", import.meta.url).pathname;

function cli(...args: string[]) {
return cp.spawnSync(
process.execPath,
["--require", "tsx/cjs", cliPath, ...args],
["--import", "tsx", cliPath, ...args],
{ encoding: 'utf8', env: { ...process.env, FORCE_COLOR: "false" }, timeout: 4_000 },
);
}
Expand Down Expand Up @@ -111,8 +111,8 @@ describe("Mocha Remote CLI", () => {

it("exits on error when asked", () => {
const output = cli("--port", "0", "--exit-on-error", "--", "tsx", "src/test/throwing-client.ts");
//expect(output.stderr).contains("ERROR b00m!");
//expect(output.status).equals(1);
expect(output.stderr).contains("ERROR b00m!");
expect(output.status).equals(1);
});

it("exits unclean if client dies early", () => {
Expand Down
15 changes: 6 additions & 9 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import fs from "fs";
import path from "path";
import yargs from "yargs/yargs";
import { hideBin } from "yargs/helpers";
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import cp from "child_process";
import chalk from "chalk";
import { inspect } from "util";

const packageJsonPath = path.join(__dirname, "..", "package.json");
const packageJsonPath = new URL("../package.json", import.meta.url);
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));

import { Server, ReporterOptions, CustomContext, WebSocket, ClientError } from "mocha-remote-server";
Expand Down Expand Up @@ -254,15 +254,16 @@ export function run(args = hideBin(process.argv)): void {
alias: 'e',
default: process.env.MOCHA_REMOTE_EXIT_ON_ERROR === "true",
})
.command('$0 [command...]', 'Start the Mocha Remote Server', ({ argv }) => {
.command('$0 [command...]', 'Start the Mocha Remote Server', () => {}, (argv) => {
function log(...args: unknown[]) {
if (!argv.silent) {
/* eslint-disable-next-line no-console */
console.log(...args);
}
}

const logo = chalk.dim(fs.readFileSync(path.resolve(__dirname, '../logo.txt')));
const logoUrl = new URL('../logo.txt', import.meta.url);
const logo = chalk.dim(fs.readFileSync(logoUrl));
log(logo);

log(chalk.dim("reporter:"), argv.reporter);
Expand Down Expand Up @@ -321,7 +322,3 @@ export function run(args = hideBin(process.argv)): void {
.alias('h', 'help')
.argv
}

if (module.parent === null) {
run();
}
18 changes: 18 additions & 0 deletions packages/cli/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "es2022",
"module": "NodeNext",
"lib": ["es2022"],
"types": [
"node",
"yargs",
"yargs/helpers"
],
"moduleResolution": "NodeNext",
"outDir": "dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
7 changes: 5 additions & 2 deletions packages/cli/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"extends": "./tsconfig.json",
"extends": "./tsconfig.base.json",
"include": [
"src/**/*.ts"
],
"exclude": [
"**/*.test.ts",
"src/**/*.test.ts",
"src/test/"
]
}
16 changes: 5 additions & 11 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"lib": ["es2019"],
"moduleResolution": "node",
"outDir": "dist",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
"files": [],
"references": [
{ "path": "./tsconfig.build.json" },
{ "path": "./tsconfig.test.json" }
]
}
10 changes: 10 additions & 0 deletions packages/cli/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"types": ["node", "mocha", "chai"],
},
"include": [
"src/**/*.test.ts",
"src/test/"
]
}

0 comments on commit e550cd4

Please sign in to comment.