Skip to content

Commit

Permalink
Bump chalk from 3.0.0 to 5.4.1 (#571)
Browse files Browse the repository at this point in the history
* Bump chalk from 3.0.0 to 5.4.1

Bumps [chalk](https://github.com/chalk/chalk) from 3.0.0 to 5.4.1.
- [Release notes](https://github.com/chalk/chalk/releases)
- [Commits](chalk/chalk@v3.0.0...v5.4.1)

---
updated-dependencies:
- dependency-name: chalk
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(test): use esm chalk

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kevin Eady <[email protected]>
  • Loading branch information
dependabot[bot] and KevinEady authored Feb 26, 2025
1 parent 2624fcd commit bd39695
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 60 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
]
},
"dependencies": {
"chalk": "^3.0.0",
"chalk": "^5.4.1",
"clang-format": "^1.4.0",
"cmake-js": "^7.1.1",
"semver": "^7.1.3"
Expand Down
125 changes: 66 additions & 59 deletions test_all.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const fs = require("fs");
const path = require("path");
const { execSync } = require("child_process");
const chalk = require("chalk");
const semver = require("semver");

const examplesFolder = path.join(__dirname, "src");
Expand All @@ -21,70 +20,78 @@ function getAllExamples(pathToCheck) {
return directoriesToTest;
}

const passed = [];
const failedInstalls = [];
const noTest = [];
const failedTests = [];
for (directoryToTest of getAllExamples(examplesFolder)) {
console.log(chalk.green(`testing: ${directoryToTest}`));
const pkgJson = require(path.join(directoryToTest, "package.json"));
if (pkgJson.engines && pkgJson.engines.node) {
const currentNodeVersion = process.versions.node;
const range = pkgJson.engines.node;
const engineOk = semver.satisfies(currentNodeVersion, range);
if (!engineOk) {
console.warn(
chalk.yellow(
`${directoryToTest} require Node.js ${range}, current is ${currentNodeVersion}, skipping`
)
);
const main = async () => {
const { default: chalk } = await import("chalk");
const passed = [];
const failedInstalls = [];
const noTest = [];
const failedTests = [];
for (directoryToTest of getAllExamples(examplesFolder)) {
console.log(chalk.green(`testing: ${directoryToTest}`));
const pkgJson = require(path.join(directoryToTest, "package.json"));
if (pkgJson.engines && pkgJson.engines.node) {
const currentNodeVersion = process.versions.node;
const range = pkgJson.engines.node;
const engineOk = semver.satisfies(currentNodeVersion, range);
if (!engineOk) {
console.warn(
chalk.yellow(
`${directoryToTest} require Node.js ${range}, current is ${currentNodeVersion}, skipping`
)
);
continue;
}
}

try {
const stdout = execSync("npm install", { cwd: directoryToTest });
console.log(stdout.toString());
} catch (err) {
console.log(err);
failedInstalls.push(directoryToTest);
continue;
}
}

try {
const stdout = execSync("npm install", { cwd: directoryToTest });
console.log(stdout.toString());
} catch (err) {
console.log(err);
failedInstalls.push(directoryToTest);
continue;
}
let testCommand;
if ("scripts" in pkgJson && "start" in pkgJson.scripts) {
testCommand = "npm start";
} else if ("scripts" in pkgJson && "test" in pkgJson.scripts) {
testCommand = "npm test";
} else if ("main" in pkgJson) {
testCommand = `node ${pkgJson.main}`
} else {
noTest.push(directoryToTest);
continue;
}

let testCommand;
if ("scripts" in pkgJson && "start" in pkgJson.scripts) {
testCommand = "npm start";
} else if ("scripts" in pkgJson && "test" in pkgJson.scripts) {
testCommand = "npm test";
} else if ("main" in pkgJson) {
testCommand = `node ${pkgJson.main}`
} else {
noTest.push(directoryToTest);
continue;
try {
const stdout = execSync(testCommand, { cwd: directoryToTest });
console.log(stdout.toString());
passed.push(directoryToTest);
} catch (err) {
console.log(err);
failedTests.push(directoryToTest);
}
}

try {
const stdout = execSync(testCommand, { cwd: directoryToTest });
console.log(stdout.toString());
passed.push(directoryToTest);
} catch (err) {
console.log(err);
failedTests.push(directoryToTest);
}
}
passed.map((dir) => console.log(chalk.green(`passed: ${dir}`)));

passed.map((dir) => console.log(chalk.green(`passed: ${dir}`)));
if (noTest.length > 0) {
console.warn(chalk.yellow("no test found:"));
noTest.map((dir) => console.warn(chalk.yellow(` ${dir}`)));
}

if (noTest.length > 0) {
console.warn(chalk.yellow("no test found:"));
noTest.map((dir) => console.warn(chalk.yellow(` ${dir}`)));
}
if (failedInstalls.length > 0) {
console.error(chalk.red("failed to install:"));
failedInstalls.map((dir) => console.warn(chalk.red(` ${dir}`)));
}
if (failedTests.length > 0) {
console.error(chalk.red("failed tests:"));
failedTests.map((dir) => console.warn(chalk.red(` ${dir}`)));
}
};

if (failedInstalls.length > 0) {
console.error(chalk.red("failed to install:"));
failedInstalls.map((dir) => console.warn(chalk.red(` ${dir}`)));
}
if (failedTests.length > 0) {
console.error(chalk.red("failed tests:"));
failedTests.map((dir) => console.warn(chalk.red(` ${dir}`)));
}
main().catch(e => {
console.error(e);
process.exitCode = 1;
});

0 comments on commit bd39695

Please sign in to comment.