Use node-text-style in script files (#17034)

This commit is contained in:
fisker Cheung authored and GitHub committed 2025-01-23 14:26:54 +08:00
1 parent b238b3f74f
commit 701d2a7136
4 files changed
+20 -11

No files matched your search

+1
View File
@@ -144,6 +144,7 @@
"jest-watch-typeahead": "2.2.2",
"knip": "5.42.2",
"magic-string": "0.30.17",
"node-style-text": "0.0.6",
"npm-run-all2": "7.0.2",
"prettier": "3.4.2",
"pretty-bytes": "6.1.1",
+6 -6
View File
@@ -3,8 +3,8 @@
import fs from "node:fs/promises";
import path from "node:path";
import readline from "node:readline";
import chalk from "chalk";
import createEsmUtils from "esm-utils";
import styleText from "node-style-text";
import prettyBytes from "pretty-bytes";
import { DIST_DIR } from "../utils/index.js";
import files from "./config.js";
@@ -26,7 +26,7 @@ const padStatusText = (text) => {
};
const status = {};
for (const { color, text } of statusConfig) {
status[text] = chalk[color].black(padStatusText(text));
status[text] = styleText[color].black(padStatusText(text));
}
function fitTerminal(input, suffix = "") {
@@ -34,7 +34,7 @@ function fitTerminal(input, suffix = "") {
const WIDTH = columns - maxLength + 1;
if (input.length < WIDTH) {
const repeatCount = Math.max(WIDTH - input.length - 1 - suffix.length, 0);
input += chalk.dim(".").repeat(repeatCount) + suffix;
input += styleText.dim(".").repeat(repeatCount) + suffix;
}
return input;
}
@@ -103,13 +103,13 @@ async function buildFile({ file, files, cliOptions, results }) {
if (stableSize) {
const { size } = await fs.stat(path.join(DIST_DIR, outputFile));
const sizeDiff = size - stableSize;
const message = chalk[sizeDiff > 0 ? "yellow" : "green"](
const message = styleText[sizeDiff > 0 ? "yellow" : "green"](
prettyBytes(sizeDiff),
);
sizeMessages.push(`${message}`);
} else {
sizeMessages.push(chalk.blue("[NEW FILE]"));
sizeMessages.push(styleText.blue("[NEW FILE]"));
}
}
@@ -146,7 +146,7 @@ async function run() {
}
}
console.log(chalk.inverse(" Building packages "));
console.log(styleText.inverse(" Building packages "));
const results = [];
for (const file of files) {
+5 -5
View File
@@ -1,5 +1,5 @@
import fs from "node:fs/promises";
import chalk from "chalk";
import styleText from "node-style-text";
const packageJson = JSON.parse(
await fs.readFile(new URL("../package.json", import.meta.url)),
@@ -9,11 +9,11 @@ validateDependencyObject(packageJson.dependencies);
validateDependencyObject(packageJson.devDependencies);
function validateDependencyObject(object) {
for (const key of Object.keys(object)) {
if (object[key][0] === "^" || object[key][0] === "~") {
for (const [name, version] of Object.entries(object)) {
if (version[0] === "^" || version[0] === "~") {
console.error(
chalk.red("error"),
`Dependency "${chalk.bold.red(key)}" should be pinned.`,
styleText.bgRed.black(" ERROR "),
`Dependency "${styleText.bold.blue(name)}" should be pinned.`,
);
process.exitCode = 1;
}
+8
View File
@@ -6882,6 +6882,13 @@ __metadata:
languageName: node
linkType: hard
"node-style-text@npm:0.0.6":
version: 0.0.6
resolution: "node-style-text@npm:0.0.6"
checksum: 10/9eeb6a054597ed122f16ec1fc404a687f75c857655cc1478b0f8b6ccd14f8badfbaeacc0b9cd5dcf84b8286986e52c5feffbf070ed4568acb7f4eb2f1cb6a5a3
languageName: node
linkType: hard
"nopt@npm:^7.0.0":
version: 7.2.1
resolution: "nopt@npm:7.2.1"
@@ -7564,6 +7571,7 @@ __metadata:
micromatch: "npm:4.0.8"
minimist: "npm:1.2.8"
n-readlines: "npm:1.0.1"
node-style-text: "npm:0.0.6"
npm-run-all2: "npm:7.0.2"
outdent: "npm:0.8.0"
parse-json: "npm:8.1.0"