|
8 | 8 | */ |
9 | 9 |
|
10 | 10 | import { JsonValue, json, logging, schema, strings, tags, workspaces } from '@angular-devkit/core'; |
11 | | -import { NodeJsSyncHost, createConsoleLogger } from '@angular-devkit/core/node'; |
| 11 | +import { NodeJsSyncHost } from '@angular-devkit/core/node'; |
12 | 12 | import { existsSync } from 'node:fs'; |
13 | 13 | import * as path from 'node:path'; |
14 | 14 | import { parseArgs, styleText } from 'node:util'; |
@@ -217,12 +217,35 @@ async function main(args: string[]): Promise<number> { |
217 | 217 | const { positionals, cliOptions, builderOptions } = parseOptions(args); |
218 | 218 |
|
219 | 219 | /** Create the DevKit Logger used through the CLI. */ |
220 | | - const logger = createConsoleLogger(!!cliOptions['verbose'], process.stdout, process.stderr, { |
| 220 | + const logger = new logging.IndentLogger('architect'); |
| 221 | + const colorLevels: Record<string, (message: string) => string> = { |
221 | 222 | info: (s) => s, |
222 | 223 | debug: (s) => s, |
223 | | - warn: (s) => styleText(['yellow', 'bold'], s), |
224 | | - error: (s) => styleText(['red', 'bold'], s), |
225 | | - fatal: (s) => styleText(['red', 'bold'], s), |
| 224 | + warn: (s) => styleText(['yellow', 'bold'], s, { stream: process.stderr }), |
| 225 | + error: (s) => styleText(['red', 'bold'], s, { stream: process.stderr }), |
| 226 | + fatal: (s) => styleText(['red', 'bold'], s, { stream: process.stderr }), |
| 227 | + }; |
| 228 | + |
| 229 | + logger.subscribe((entry) => { |
| 230 | + if (entry.level === 'debug' && !cliOptions['verbose']) { |
| 231 | + return; |
| 232 | + } |
| 233 | + |
| 234 | + const color = colorLevels[entry.level]; |
| 235 | + const message = color ? color(entry.message) : entry.message; |
| 236 | + |
| 237 | + switch (entry.level) { |
| 238 | + case 'warn': |
| 239 | + case 'fatal': |
| 240 | + case 'error': |
| 241 | + // eslint-disable-next-line no-console |
| 242 | + console.error(message); |
| 243 | + break; |
| 244 | + default: |
| 245 | + // eslint-disable-next-line no-console |
| 246 | + console.log(message); |
| 247 | + break; |
| 248 | + } |
226 | 249 | }); |
227 | 250 |
|
228 | 251 | // Check the target. |
|
0 commit comments