@rspack-debug/cli
Advanced tools
+41
-72
@@ -12,68 +12,2 @@ import * as __rspack_external_module from "module"; | ||
| __webpack_require__.add({ | ||
| "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js" (module) { | ||
| let p = process || {}, argv = p.argv || [], env = p.env || {}; | ||
| let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI); | ||
| let formatter = (open, close, replace = open)=>(input)=>{ | ||
| let string = "" + input, index = string.indexOf(close, open.length); | ||
| return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close; | ||
| }; | ||
| let replaceClose = (string, close, replace, index)=>{ | ||
| let result = "", cursor = 0; | ||
| do { | ||
| result += string.substring(cursor, index) + replace; | ||
| cursor = index + close.length; | ||
| index = string.indexOf(close, cursor); | ||
| }while (~index); | ||
| return result + string.substring(cursor); | ||
| }; | ||
| let createColors = (enabled = isColorSupported)=>{ | ||
| let f = enabled ? formatter : ()=>String; | ||
| return { | ||
| isColorSupported: enabled, | ||
| reset: f("\x1b[0m", "\x1b[0m"), | ||
| bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"), | ||
| dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"), | ||
| italic: f("\x1b[3m", "\x1b[23m"), | ||
| underline: f("\x1b[4m", "\x1b[24m"), | ||
| inverse: f("\x1b[7m", "\x1b[27m"), | ||
| hidden: f("\x1b[8m", "\x1b[28m"), | ||
| strikethrough: f("\x1b[9m", "\x1b[29m"), | ||
| black: f("\x1b[30m", "\x1b[39m"), | ||
| red: f("\x1b[31m", "\x1b[39m"), | ||
| green: f("\x1b[32m", "\x1b[39m"), | ||
| yellow: f("\x1b[33m", "\x1b[39m"), | ||
| blue: f("\x1b[34m", "\x1b[39m"), | ||
| magenta: f("\x1b[35m", "\x1b[39m"), | ||
| cyan: f("\x1b[36m", "\x1b[39m"), | ||
| white: f("\x1b[37m", "\x1b[39m"), | ||
| gray: f("\x1b[90m", "\x1b[39m"), | ||
| bgBlack: f("\x1b[40m", "\x1b[49m"), | ||
| bgRed: f("\x1b[41m", "\x1b[49m"), | ||
| bgGreen: f("\x1b[42m", "\x1b[49m"), | ||
| bgYellow: f("\x1b[43m", "\x1b[49m"), | ||
| bgBlue: f("\x1b[44m", "\x1b[49m"), | ||
| bgMagenta: f("\x1b[45m", "\x1b[49m"), | ||
| bgCyan: f("\x1b[46m", "\x1b[49m"), | ||
| bgWhite: f("\x1b[47m", "\x1b[49m"), | ||
| blackBright: f("\x1b[90m", "\x1b[39m"), | ||
| redBright: f("\x1b[91m", "\x1b[39m"), | ||
| greenBright: f("\x1b[92m", "\x1b[39m"), | ||
| yellowBright: f("\x1b[93m", "\x1b[39m"), | ||
| blueBright: f("\x1b[94m", "\x1b[39m"), | ||
| magentaBright: f("\x1b[95m", "\x1b[39m"), | ||
| cyanBright: f("\x1b[96m", "\x1b[39m"), | ||
| whiteBright: f("\x1b[97m", "\x1b[39m"), | ||
| bgBlackBright: f("\x1b[100m", "\x1b[49m"), | ||
| bgRedBright: f("\x1b[101m", "\x1b[49m"), | ||
| bgGreenBright: f("\x1b[102m", "\x1b[49m"), | ||
| bgYellowBright: f("\x1b[103m", "\x1b[49m"), | ||
| bgBlueBright: f("\x1b[104m", "\x1b[49m"), | ||
| bgMagentaBright: f("\x1b[105m", "\x1b[49m"), | ||
| bgCyanBright: f("\x1b[106m", "\x1b[49m"), | ||
| bgWhiteBright: f("\x1b[107m", "\x1b[49m") | ||
| }; | ||
| }; | ||
| module.exports = createColors(); | ||
| module.exports.createColors = createColors; | ||
| }, | ||
| "../../node_modules/.pnpm/pirates@4.0.7/node_modules/pirates/lib/index.js" (module, exports, __webpack_require__) { | ||
@@ -1108,3 +1042,25 @@ module = __webpack_require__.nmd(module); | ||
| } | ||
| const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js"); | ||
| function isEnvColorSupported() { | ||
| if ("u" < typeof process) return false; | ||
| const p = process; | ||
| const argv = p.argv ?? []; | ||
| const env = p.env ?? {}; | ||
| return !('NO_COLOR' in env || argv.includes('--no-color')) && ('FORCE_COLOR' in env || argv.includes('--color') || 'win32' === p.platform || p.stdout?.isTTY && 'dumb' !== env.TERM || 'CI' in env); | ||
| } | ||
| function createAnsiFormatter(open, close, replace = open) { | ||
| const closeLength = close.length; | ||
| return (input)=>{ | ||
| const string = String(input); | ||
| let index = string.indexOf(close, open.length); | ||
| if (-1 === index) return open + string + close; | ||
| let result = ''; | ||
| let cursor = 0; | ||
| do { | ||
| result += string.substring(cursor, index) + replace; | ||
| cursor = index + closeLength; | ||
| index = string.indexOf(close, cursor); | ||
| }while (-1 !== index); | ||
| return open + result + string.substring(cursor) + close; | ||
| }; | ||
| } | ||
| class RspackCLI { | ||
@@ -1118,3 +1074,3 @@ colors; | ||
| program.help(); | ||
| program.version("2.0.0-beta.4"); | ||
| program.version("2.0.0-beta.5"); | ||
| } | ||
@@ -1146,6 +1102,20 @@ async buildCompilerConfig(options, rspackCommand) { | ||
| createColors(useColor) { | ||
| const shouldUseColor = useColor || picocolors.isColorSupported; | ||
| const envSupported = isEnvColorSupported(); | ||
| const enabled = useColor ?? envSupported; | ||
| if (!enabled) { | ||
| const passthrough = (text)=>String(text); | ||
| return { | ||
| isColorSupported: false, | ||
| red: passthrough, | ||
| yellow: passthrough, | ||
| cyan: passthrough, | ||
| green: passthrough | ||
| }; | ||
| } | ||
| return { | ||
| ...(0, picocolors.createColors)(shouldUseColor), | ||
| isColorSupported: shouldUseColor | ||
| isColorSupported: true, | ||
| red: createAnsiFormatter('\x1b[31m', '\x1b[39m'), | ||
| green: createAnsiFormatter('\x1b[32m', '\x1b[39m'), | ||
| yellow: createAnsiFormatter('\x1b[33m', '\x1b[39m'), | ||
| cyan: createAnsiFormatter('\x1b[36m', '\x1b[39m') | ||
| }; | ||
@@ -1219,3 +1189,2 @@ } | ||
| }; | ||
| if (this.colors.isColorSupported && void 0 === item.stats.colors) item.stats.colors = true; | ||
| return item; | ||
@@ -1222,0 +1191,0 @@ }; |
+3
-3
@@ -15,7 +15,7 @@ import type { Compiler, MultiCompiler, MultiRspackOptions, MultiStats, RspackOptions, RspackPluginFunction, RspackPluginInstance, Stats } from '@rspack/core'; | ||
| createCompiler(config: RspackOptions | MultiRspackOptions, callback?: (e: Error | null, res?: Stats | MultiStats) => void): Promise<MultiCompiler | Compiler | null>; | ||
| createColors(useColor?: boolean): RspackCLIColors; | ||
| private createColors; | ||
| getLogger(): RspackCLILogger; | ||
| run(argv: string[]): Promise<void>; | ||
| registerCommands(): Promise<void>; | ||
| buildConfig(item: RspackOptions | MultiRspackOptions, pathMap: WeakMap<RspackOptions, string[]>, options: CommonOptionsForBuildAndServe, command: Command): Promise<RspackOptions | MultiRspackOptions>; | ||
| private registerCommands; | ||
| private buildConfig; | ||
| loadConfig(options: CommonOptions): Promise<{ | ||
@@ -22,0 +22,0 @@ config: RspackOptions | MultiRspackOptions; |
+6
-2
| import type { RspackCLI } from './cli'; | ||
| export type { Configuration } from '@rspack/core'; | ||
| export type LogHandler = (value: any) => void; | ||
| export type RspackCLIColors = { | ||
| export interface RspackCLIColors { | ||
| isColorSupported: boolean; | ||
| } & Omit<typeof import('picocolors'), 'createColors'>; | ||
| red(text: string): string; | ||
| yellow(text: string): string; | ||
| cyan(text: string): string; | ||
| green(text: string): string; | ||
| } | ||
| export interface RspackCLILogger { | ||
@@ -8,0 +12,0 @@ error: LogHandler; |
+3
-4
| { | ||
| "name": "@rspack-debug/cli", | ||
| "version": "2.0.0-beta.4", | ||
| "version": "2.0.0-beta.5", | ||
| "description": "CLI for rspack", | ||
@@ -40,8 +40,7 @@ "homepage": "https://rspack.rs", | ||
| "execa": "^5.1.1", | ||
| "picocolors": "^1.1.1", | ||
| "pirates": "^4.0.7", | ||
| "ts-node": "^10.9.2", | ||
| "typescript": "^5.9.3", | ||
| "@rspack/core": "npm:@rspack-debug/core@2.0.0-beta.4", | ||
| "@rspack/test-tools": "npm:@rspack-debug/test-tools@2.0.0-beta.4" | ||
| "@rspack/core": "npm:@rspack-debug/core@2.0.0-beta.5", | ||
| "@rspack/test-tools": "npm:@rspack-debug/test-tools@2.0.0-beta.5" | ||
| }, | ||
@@ -48,0 +47,0 @@ "peerDependencies": { |
11
-8.33%66206
-3.63%1470
-1.8%