gt 2.26.9 → 2.26.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 2.26.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2526](https://github.com/generaltranslation/gt/pull/2526) [`9e9b6d8`](https://github.com/generaltranslation/gt/commit/9e9b6d866cae109f7ec13f5b1d1182ccfb87d947) Thanks [@brian-lou](https://github.com/brian-lou)! - Add `GT_LOG_FORMAT=agent`, which prints plain `[time] LEVEL: msg` lines, and use it by default in CI or when stdout is not a TTY. Set `GT_LOG_FORMAT=default` to keep the interactive output. The ASCII banner no longer prints when `GT_LOG_FORMAT` is `json` or `agent`.
8
+
3
9
  ## 2.26.9
4
10
 
5
11
  ### Patch Changes
@@ -1,11 +1,13 @@
1
1
  import type { SpinnerResult, ProgressResult } from '@clack/prompts';
2
- export type LogFormat = 'default' | 'json';
2
+ export type LogFormat = 'default' | 'json' | 'agent';
3
3
  export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
4
4
  export type ConsoleOutput = 'stdout' | 'stderr';
5
5
  /**
6
- * GT_LOG_FORMAT: default | json.
6
+ * GT_LOG_FORMAT: default | json | agent. If unset, defaults to agent in CI
7
+ * or when stdout is not a TTY, and to default otherwise.
7
8
  * - If default, logs will be pretty-printed using @clack/prompts.
8
9
  * - If json, logs will be written in JSON format to the console.
10
+ * - If agent, logs will be written as plain `[time] LEVEL: msg` lines.
9
11
  * GT_LOG_FILE: If specified, logs will be written to the file.
10
12
  * GT_LOG_LEVEL: The level of logs to write. If not specified, defaults to 'info'.
11
13
  * - Valid levels: debug, info, warn, error.
@@ -23,6 +25,7 @@ declare class Logger {
23
25
  private clackOutput;
24
26
  private constructor();
25
27
  private createPinoLogger;
28
+ private createConsoleLogger;
26
29
  static getInstance(): Logger;
27
30
  /**
28
31
  * Route console output (Clack chatter and the JSON console logger) to
@@ -48,6 +51,7 @@ declare class Logger {
48
51
  */
49
52
  setAnimatedProgress(animated: boolean): boolean;
50
53
  isQuiet(): boolean;
54
+ getLogFormat(): LogFormat;
51
55
  trace(message: string): void;
52
56
  debug(message: string): void;
53
57
  info(message: string): void;
@@ -1,7 +1,9 @@
1
1
  import { intro, log, outro, progress, spinner } from "@clack/prompts";
2
2
  import chalk from "chalk";
3
3
  import { randomUUID } from "node:crypto";
4
+ import { stripVTControlCharacters } from "node:util";
4
5
  import { destination, pino } from "pino";
6
+ import { build } from "pino-pretty";
5
7
  //#region src/console/logger.ts
6
8
  const LOG_LEVEL_RANK = {
7
9
  debug: 10,
@@ -10,6 +12,10 @@ const LOG_LEVEL_RANK = {
10
12
  error: 40
11
13
  };
12
14
  const QUIET_FLOOR_LEVEL = "warn";
15
+ function getDefaultLogFormat() {
16
+ const ci = process.env.CI;
17
+ return !!ci && ci !== "false" && ci !== "0" || !process.stdout.isTTY ? "agent" : "default";
18
+ }
13
19
  var MockSpinner = class {
14
20
  currentMessage = "";
15
21
  logger;
@@ -73,10 +79,10 @@ const logger = class Logger {
73
79
  consoleLoggers = {};
74
80
  clackOutput;
75
81
  constructor() {
76
- const format = (process.env.GT_LOG_FORMAT || "default").toLowerCase();
82
+ const format = (process.env.GT_LOG_FORMAT || getDefaultLogFormat()).toLowerCase();
77
83
  const logFile = process.env.GT_LOG_FILE;
78
84
  const logLevel = process.env.GT_LOG_LEVEL || "info";
79
- if (format !== "default" && format !== "json") {
85
+ if (format !== "default" && format !== "json" && format !== "agent") {
80
86
  console.error("Invalid log format");
81
87
  process.exit(1);
82
88
  }
@@ -86,8 +92,8 @@ const logger = class Logger {
86
92
  }
87
93
  this.logFormat = format;
88
94
  this.logLevel = logLevel;
89
- if (format === "json") {
90
- this.pinoLogger = this.createPinoLogger(process.stdout.fd, logLevel);
95
+ if (format !== "default") {
96
+ this.pinoLogger = this.createConsoleLogger(process.stdout.fd, logLevel);
91
97
  this.consoleLoggers.stdout = this.pinoLogger;
92
98
  }
93
99
  if (logFile) this.fileLogger = this.createPinoLogger(logFile, logLevel);
@@ -98,6 +104,17 @@ const logger = class Logger {
98
104
  mixin: () => ({ logId: randomUUID() })
99
105
  }, destination(dest));
100
106
  }
107
+ createConsoleLogger(fd, level) {
108
+ if (this.logFormat === "json") return this.createPinoLogger(fd, level);
109
+ return pino({ level }, build({
110
+ destination: fd,
111
+ sync: true,
112
+ colorize: false,
113
+ translateTime: "SYS:yyyy-mm-dd HH:MM:ss",
114
+ ignore: "pid,hostname",
115
+ messageFormat: (log, messageKey) => stripVTControlCharacters(String(log[messageKey]))
116
+ }));
117
+ }
101
118
  static getInstance() {
102
119
  if (!Logger.instance) Logger.instance = new Logger();
103
120
  return Logger.instance;
@@ -115,7 +132,7 @@ const logger = class Logger {
115
132
  this.clackOutput = output === "stderr" ? { output: process.stderr } : void 0;
116
133
  if (this.pinoLogger) {
117
134
  this.pinoLogger.flush();
118
- const next = this.consoleLoggers[output] ?? this.createPinoLogger(process[output].fd, this.pinoLogger.level);
135
+ const next = this.consoleLoggers[output] ?? this.createConsoleLogger(process[output].fd, this.pinoLogger.level);
119
136
  next.level = this.pinoLogger.level;
120
137
  this.consoleLoggers[output] = next;
121
138
  this.pinoLogger = next;
@@ -146,6 +163,9 @@ const logger = class Logger {
146
163
  isQuiet() {
147
164
  return this.quiet;
148
165
  }
166
+ getLogFormat() {
167
+ return this.logFormat;
168
+ }
149
169
  trace(message) {
150
170
  if (!this.quiet) if (this.logFormat === "default") log.message(message, {
151
171
  symbol: chalk.dim("•"),
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","names":[],"sources":["../../src/console/logger.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { randomUUID } from 'node:crypto';\nimport { pino, destination } from 'pino';\nimport {\n log as clackLog,\n spinner,\n progress,\n intro,\n outro,\n} from '@clack/prompts';\nimport type { Logger as PinoLogger } from 'pino';\nimport type { SpinnerResult, ProgressResult } from '@clack/prompts';\nimport type { Writable } from 'node:stream';\n\nexport type LogFormat = 'default' | 'json';\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\nexport type ConsoleOutput = 'stdout' | 'stderr';\n\n// Numeric ordering used to decide the quiet floor without lowering an\n// already-more-restrictive level chosen via GT_LOG_LEVEL.\nconst LOG_LEVEL_RANK: Record<LogLevel, number> = {\n debug: 10,\n info: 20,\n warn: 30,\n error: 40,\n};\n\n// Under --quiet, informational output is suppressed but warnings and errors\n// still print, so the console never drops below this level.\nconst QUIET_FLOOR_LEVEL: LogLevel = 'warn';\n\n// Mock spinner that logs to console instead of updating terminal UI\nclass MockSpinner implements SpinnerResult {\n private currentMessage: string = '';\n private logger: Logger;\n isCancelled: boolean = false;\n\n constructor(logger: Logger) {\n this.logger = logger;\n }\n\n start(message?: string): void {\n if (message) {\n this.currentMessage = message;\n this.logger.info(`[Spinner] ${message}`);\n }\n }\n\n stop(message?: string): void {\n const msg = message || this.currentMessage;\n if (msg) {\n this.logger.info(`[Spinner] ${msg}`);\n }\n this.currentMessage = '';\n }\n\n message(message?: string): void {\n if (message) {\n this.currentMessage = message;\n this.logger.info(`[Spinner] ${message}`);\n }\n }\n}\n\n// Mock progress bar that logs to console instead of updating terminal UI\nclass MockProgress implements ProgressResult {\n private max: number;\n private current: number = 0;\n private logger: Logger;\n isCancelled: boolean = false;\n\n constructor(max: number, logger: Logger) {\n this.max = max;\n this.logger = logger;\n }\n\n start(message?: string): void {\n const msg = message || 'Starting progress';\n this.logger.info(`[Progress] ${msg} (0/${this.max})`);\n }\n\n stop(message?: string): void {\n const msg = message || 'Complete';\n this.logger.info(`[Progress] ${msg} (${this.current}/${this.max})`);\n }\n\n message(message?: string): void {\n if (message) {\n this.logger.info(`[Progress] ${message} (${this.current}/${this.max})`);\n }\n }\n\n advance(amount: number, message?: string): void {\n this.current += amount;\n const msg = message || 'Progress';\n this.logger.info(`[Progress] ${msg} (${this.current}/${this.max})`);\n }\n}\n\n/**\n * GT_LOG_FORMAT: default | json.\n * - If default, logs will be pretty-printed using @clack/prompts.\n * - If json, logs will be written in JSON format to the console.\n * GT_LOG_FILE: If specified, logs will be written to the file.\n * GT_LOG_LEVEL: The level of logs to write. If not specified, defaults to 'info'.\n * - Valid levels: debug, info, warn, error.\n */\nclass Logger {\n private static instance: Logger;\n private pinoLogger: PinoLogger | null = null;\n private fileLogger: PinoLogger | null = null;\n private logFormat: LogFormat;\n private logLevel: LogLevel;\n private quiet = false;\n private animatedProgress = true;\n private consoleOutput: ConsoleOutput = 'stdout';\n // One JSON console logger per stream so switching direction within a\n // process reuses the existing SonicBoom instead of recreating it.\n private consoleLoggers: Partial<Record<ConsoleOutput, PinoLogger>> = {};\n // Clack writes to stdout unless told otherwise; unset keeps its default so\n // ordinary commands are untouched while stderr routing redirects it.\n private clackOutput: { output: Writable } | undefined;\n\n private constructor() {\n // Read configuration from environment variables\n const format = (\n process.env.GT_LOG_FORMAT || 'default'\n ).toLowerCase() as LogFormat;\n const logFile = process.env.GT_LOG_FILE;\n const logLevel = process.env.GT_LOG_LEVEL || 'info';\n\n if (format !== 'default' && format !== 'json') {\n console.error('Invalid log format');\n process.exit(1);\n }\n if (\n logLevel !== 'debug' &&\n logLevel !== 'info' &&\n logLevel !== 'warn' &&\n logLevel !== 'error'\n ) {\n console.error('Invalid log level');\n process.exit(1);\n }\n\n this.logFormat = format;\n this.logLevel = logLevel as LogLevel;\n\n // Console output (stdout) - only for JSON format\n // For 'default' format, we use @clack/prompts directly\n if (format === 'json') {\n this.pinoLogger = this.createPinoLogger(process.stdout.fd, logLevel);\n this.consoleLoggers.stdout = this.pinoLogger;\n }\n\n // File output (if specified) - always JSON format\n if (logFile) {\n this.fileLogger = this.createPinoLogger(logFile, logLevel);\n }\n }\n\n private createPinoLogger(dest: number | string, level: string): PinoLogger {\n return pino(\n {\n level,\n mixin: () => ({\n logId: randomUUID(),\n }),\n },\n destination(dest)\n );\n }\n\n static getInstance(): Logger {\n if (!Logger.instance) {\n Logger.instance = new Logger();\n }\n return Logger.instance;\n }\n\n /**\n * Route console output (Clack chatter and the JSON console logger) to\n * stdout (the historical default) or stderr, so a command whose stdout is\n * machine-readable can keep diagnostics off it. Reversible per invocation;\n * a no-op when the direction is unchanged. The JSON logger keeps its\n * current level and is flushed before switching. File logging is unaffected.\n */\n setConsoleOutput(output: ConsoleOutput): void {\n if (output === this.consoleOutput) return;\n this.consoleOutput = output;\n this.clackOutput =\n output === 'stderr' ? { output: process.stderr } : undefined;\n if (this.pinoLogger) {\n this.pinoLogger.flush();\n const next =\n this.consoleLoggers[output] ??\n this.createPinoLogger(process[output].fd, this.pinoLogger.level);\n next.level = this.pinoLogger.level;\n this.consoleLoggers[output] = next;\n this.pinoLogger = next;\n }\n }\n\n /**\n * Enable or disable quiet mode. When quiet, informational chatter\n * (info/step/success/message/debug/trace, spinners, progress bars, and\n * command intro/outro markers) is suppressed on the console, while warnings\n * and errors still print. Quiet wins over GT_LOG_LEVEL but never lowers an\n * already-more-restrictive level. File logging is unaffected so an explicit\n * GT_LOG_FILE still captures everything.\n */\n setQuiet(quiet: boolean): void {\n this.quiet = quiet;\n if (this.pinoLogger) {\n this.pinoLogger.level = quiet\n ? LOG_LEVEL_RANK[this.logLevel] > LOG_LEVEL_RANK[QUIET_FLOOR_LEVEL]\n ? this.logLevel\n : QUIET_FLOOR_LEVEL\n : this.logLevel;\n }\n }\n\n /**\n * Noninteractive setup reports progress as plain log lines instead of\n * redrawing spinners and progress bars on the console. Returns the previous\n * mode so a run can restore it.\n */\n setAnimatedProgress(animated: boolean): boolean {\n const previous = this.animatedProgress;\n this.animatedProgress = animated;\n return previous;\n }\n\n isQuiet(): boolean {\n return this.quiet;\n }\n\n // Standard logging methods\n trace(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n // @clack/prompts doesn't have trace, use message\n clackLog.message(message, {\n symbol: chalk.dim('•'),\n ...this.clackOutput,\n });\n } else {\n this.pinoLogger?.trace(message);\n }\n }\n this.fileLogger?.trace(message);\n }\n\n debug(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n // @clack/prompts doesn't have debug, use message\n clackLog.message(message, {\n symbol: chalk.dim('◆'),\n ...this.clackOutput,\n });\n } else {\n this.pinoLogger?.debug(message);\n }\n }\n this.fileLogger?.debug(message);\n }\n\n info(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n clackLog.info(message, this.clackOutput);\n } else {\n this.pinoLogger?.info(message);\n }\n }\n this.fileLogger?.info(message);\n }\n\n warn(message: string): void {\n if (this.logFormat === 'default') {\n clackLog.warn(message, this.clackOutput);\n } else {\n this.pinoLogger?.warn(message);\n }\n this.fileLogger?.warn(message);\n }\n\n error(message: string): void {\n if (this.logFormat === 'default') {\n clackLog.error(message, this.clackOutput);\n } else {\n this.pinoLogger?.error(message);\n }\n this.fileLogger?.error(message);\n }\n\n fatal(message: string): void {\n if (this.logFormat === 'default') {\n // @clack/prompts doesn't have fatal, use error\n clackLog.error(message, this.clackOutput);\n } else {\n this.pinoLogger?.fatal(message);\n }\n this.fileLogger?.fatal(message);\n }\n\n silent(message: string): void {\n // Silent doesn't log to console, only to file\n this.fileLogger?.silent(message);\n }\n\n // @clack/prompts specific methods (for 'default' format)\n success(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n clackLog.success(message, this.clackOutput);\n } else {\n this.pinoLogger?.info(message); // Map to info for non-default formats\n }\n }\n this.fileLogger?.info(message);\n }\n\n step(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n clackLog.step(message, this.clackOutput);\n } else {\n this.pinoLogger?.info(message); // Map to info for non-default formats\n }\n }\n this.fileLogger?.info(message);\n }\n\n message(message: string, symbol?: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n clackLog.message(\n message,\n symbol ? { symbol, ...this.clackOutput } : this.clackOutput\n );\n } else {\n this.pinoLogger?.info(message); // Map to info for non-default formats\n }\n }\n this.fileLogger?.info(message);\n }\n\n // Spinner functionality\n createSpinner(indicator: 'dots' | 'timer' = 'timer'): SpinnerResult {\n // Quiet mode suppresses spinner UI; the mock routes through the gated\n // info() so nothing reaches the console while file logging is preserved.\n if (this.quiet || !this.animatedProgress) {\n return new MockSpinner(this);\n }\n if (this.logFormat === 'default') {\n return spinner({ indicator, ...this.clackOutput });\n } else {\n return new MockSpinner(this);\n }\n }\n\n // Progress bar functionality\n createProgressBar(total: number): ProgressResult {\n if (this.quiet || !this.animatedProgress) {\n return new MockProgress(total, this);\n }\n if (this.logFormat === 'default') {\n return progress({ max: total, ...this.clackOutput });\n } else {\n return new MockProgress(total, this);\n }\n }\n\n // Command start/end markers\n startCommand(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n intro(chalk.cyan(message), this.clackOutput);\n } else {\n this.info(`╭─ ${message}`);\n }\n }\n this.fileLogger?.info(`[START] ${message}`);\n }\n\n endCommand(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n outro(chalk.cyan(message), this.clackOutput);\n } else {\n this.info(`╰─ ${message}`);\n }\n }\n this.fileLogger?.info(`[END] ${message}`);\n }\n\n // Flush logs to ensure they're written before process exit\n flush(): void {\n this.pinoLogger?.flush();\n this.fileLogger?.flush();\n }\n}\n\nexport const logger = Logger.getInstance();\n"],"mappings":";;;;;AAoBA,MAAM,iBAA2C;CAC/C,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACR;AAID,MAAM,oBAA8B;AAGpC,IAAM,cAAN,MAA2C;CACzC,iBAAiC;CACjC;CACA,cAAuB;CAEvB,YAAY,QAAgB;AAC1B,OAAK,SAAS;;CAGhB,MAAM,SAAwB;AAC5B,MAAI,SAAS;AACX,QAAK,iBAAiB;AACtB,QAAK,OAAO,KAAK,aAAa,UAAU;;;CAI5C,KAAK,SAAwB;EAC3B,MAAM,MAAM,WAAW,KAAK;AAC5B,MAAI,IACF,MAAK,OAAO,KAAK,aAAa,MAAM;AAEtC,OAAK,iBAAiB;;CAGxB,QAAQ,SAAwB;AAC9B,MAA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CAGhC,QAAQ,SAAiB,QAAuB;AAC9C,MAAI,CAAC,KAAK,MACR,KAAI,KAAK,cAAc,UACrB,KAAS,QACP,SACA,SAAS;GAAE;GAAQ,GAAG,KAAK;GAAa,GAAG,KAAK,YACjD;MAED,MAAK,YAAY,KAAK,QAAQ;AAGlC,OAAK,YAAY,KAAK,QAAQ;;CAIhC,cAAc,YAA8B,SAAwB;AAGlE,MAAI,KAAK,SAAS,CAAC,KAAK,iBACtB,QAAO,IAAI,YAAY,KAAK;AAE9B,MAAI,KAAK,cAAc,UACrB,QAAO,QAAQ;GAAE;GAAW,GAAG,KAAK;GAAa,CAAC;MAElD,QAAO,IAAI,YAAY,KAAK;;CAKhC,kBAAkB,OAA+B;AAC/C,MAAI,KAAK,SAAS,CAAC,KAAK,iBACtB,QAAO,IAAI,aAAa,OAAO,KAAK;AAEtC,MAAI,KAAK,cAAc,UACrB,QAAO,SAAS;GAAE,KAAK;GAAO,GAAG,KAAK;GAAa,CAAC;MAEpD,QAAO,IAAI,aAAa,OAAO,KAAK;;CAKxC,aAAa,SAAuB;AAClC,MAAI,CAAC,KAAK,MACR,KAAI,KAAK,cAAc,UACrB,OAAM,MAAM,KAAK,QAAQ,EAAE,KAAK,YAAY;MAE5C,MAAK,KAAK,MAAM,UAAU;AAG9B,OAAK,YAAY,KAAK,WAAW,UAAU;;CAG7C,WAAW,SAAuB;AAChC,MAAI,CAAC,KAAK,MACR,KAAI,KAAK,cAAc,UACrB,OAAM,MAAM,KAAK,QAAQ,EAAE,KAAK,YAAY;MAE5C,MAAK,KAAK,MAAM,UAAU;AAG9B,OAAK,YAAY,KAAK,SAAS,UAAU;;CAI3C,QAAc;AACZ,OAAK,YAAY,OAAO;AACxB,OAAK,YAAY,OAAO;;EAIC,aAAa"}
1
+ {"version":3,"file":"logger.js","names":["pinoPretty"],"sources":["../../src/console/logger.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { randomUUID } from 'node:crypto';\nimport { stripVTControlCharacters } from 'node:util';\nimport { pino, destination } from 'pino';\nimport { build as pinoPretty } from 'pino-pretty';\nimport {\n log as clackLog,\n spinner,\n progress,\n intro,\n outro,\n} from '@clack/prompts';\nimport type { Logger as PinoLogger } from 'pino';\nimport type { SpinnerResult, ProgressResult } from '@clack/prompts';\nimport type { Writable } from 'node:stream';\n\nexport type LogFormat = 'default' | 'json' | 'agent';\nexport type LogLevel = 'debug' | 'info' | 'warn' | 'error';\nexport type ConsoleOutput = 'stdout' | 'stderr';\n\n// Numeric ordering used to decide the quiet floor without lowering an\n// already-more-restrictive level chosen via GT_LOG_LEVEL.\nconst LOG_LEVEL_RANK: Record<LogLevel, number> = {\n debug: 10,\n info: 20,\n warn: 30,\n error: 40,\n};\n\n// Under --quiet, informational output is suppressed but warnings and errors\n// still print, so the console never drops below this level.\nconst QUIET_FLOOR_LEVEL: LogLevel = 'warn';\n\n// Without an explicit GT_LOG_FORMAT, CI and non-TTY output get plain agent\n// lines instead of Clack's interactive rendering.\nfunction getDefaultLogFormat(): LogFormat {\n const ci = process.env.CI;\n const isCI = !!ci && ci !== 'false' && ci !== '0';\n return isCI || !process.stdout.isTTY ? 'agent' : 'default';\n}\n\n// Mock spinner that logs to console instead of updating terminal UI\nclass MockSpinner implements SpinnerResult {\n private currentMessage: string = '';\n private logger: Logger;\n isCancelled: boolean = false;\n\n constructor(logger: Logger) {\n this.logger = logger;\n }\n\n start(message?: string): void {\n if (message) {\n this.currentMessage = message;\n this.logger.info(`[Spinner] ${message}`);\n }\n }\n\n stop(message?: string): void {\n const msg = message || this.currentMessage;\n if (msg) {\n this.logger.info(`[Spinner] ${msg}`);\n }\n this.currentMessage = '';\n }\n\n message(message?: string): void {\n if (message) {\n this.currentMessage = message;\n this.logger.info(`[Spinner] ${message}`);\n }\n }\n}\n\n// Mock progress bar that logs to console instead of updating terminal UI\nclass MockProgress implements ProgressResult {\n private max: number;\n private current: number = 0;\n private logger: Logger;\n isCancelled: boolean = false;\n\n constructor(max: number, logger: Logger) {\n this.max = max;\n this.logger = logger;\n }\n\n start(message?: string): void {\n const msg = message || 'Starting progress';\n this.logger.info(`[Progress] ${msg} (0/${this.max})`);\n }\n\n stop(message?: string): void {\n const msg = message || 'Complete';\n this.logger.info(`[Progress] ${msg} (${this.current}/${this.max})`);\n }\n\n message(message?: string): void {\n if (message) {\n this.logger.info(`[Progress] ${message} (${this.current}/${this.max})`);\n }\n }\n\n advance(amount: number, message?: string): void {\n this.current += amount;\n const msg = message || 'Progress';\n this.logger.info(`[Progress] ${msg} (${this.current}/${this.max})`);\n }\n}\n\n/**\n * GT_LOG_FORMAT: default | json | agent. If unset, defaults to agent in CI\n * or when stdout is not a TTY, and to default otherwise.\n * - If default, logs will be pretty-printed using @clack/prompts.\n * - If json, logs will be written in JSON format to the console.\n * - If agent, logs will be written as plain `[time] LEVEL: msg` lines.\n * GT_LOG_FILE: If specified, logs will be written to the file.\n * GT_LOG_LEVEL: The level of logs to write. If not specified, defaults to 'info'.\n * - Valid levels: debug, info, warn, error.\n */\nclass Logger {\n private static instance: Logger;\n private pinoLogger: PinoLogger | null = null;\n private fileLogger: PinoLogger | null = null;\n private logFormat: LogFormat;\n private logLevel: LogLevel;\n private quiet = false;\n private animatedProgress = true;\n private consoleOutput: ConsoleOutput = 'stdout';\n // One JSON console logger per stream so switching direction within a\n // process reuses the existing SonicBoom instead of recreating it.\n private consoleLoggers: Partial<Record<ConsoleOutput, PinoLogger>> = {};\n // Clack writes to stdout unless told otherwise; unset keeps its default so\n // ordinary commands are untouched while stderr routing redirects it.\n private clackOutput: { output: Writable } | undefined;\n\n private constructor() {\n // Read configuration from environment variables\n const format = (\n process.env.GT_LOG_FORMAT || getDefaultLogFormat()\n ).toLowerCase() as LogFormat;\n const logFile = process.env.GT_LOG_FILE;\n const logLevel = process.env.GT_LOG_LEVEL || 'info';\n\n if (format !== 'default' && format !== 'json' && format !== 'agent') {\n console.error('Invalid log format');\n process.exit(1);\n }\n if (\n logLevel !== 'debug' &&\n logLevel !== 'info' &&\n logLevel !== 'warn' &&\n logLevel !== 'error'\n ) {\n console.error('Invalid log level');\n process.exit(1);\n }\n\n this.logFormat = format;\n this.logLevel = logLevel as LogLevel;\n\n // Console output (stdout) - only for JSON and agent formats\n // For 'default' format, we use @clack/prompts directly\n if (format !== 'default') {\n this.pinoLogger = this.createConsoleLogger(process.stdout.fd, logLevel);\n this.consoleLoggers.stdout = this.pinoLogger;\n }\n\n // File output (if specified) - always JSON format\n if (logFile) {\n this.fileLogger = this.createPinoLogger(logFile, logLevel);\n }\n }\n\n private createPinoLogger(dest: number | string, level: string): PinoLogger {\n return pino(\n {\n level,\n mixin: () => ({\n logId: randomUUID(),\n }),\n },\n destination(dest)\n );\n }\n\n private createConsoleLogger(fd: number, level: string): PinoLogger {\n if (this.logFormat === 'json') {\n return this.createPinoLogger(fd, level);\n }\n // Synchronous, in-thread pretty printing so lines are not lost when the\n // CLI exits via process.exit().\n return pino(\n { level },\n pinoPretty({\n destination: fd,\n sync: true,\n colorize: false,\n translateTime: 'SYS:yyyy-mm-dd HH:MM:ss',\n ignore: 'pid,hostname',\n messageFormat: (log, messageKey) =>\n stripVTControlCharacters(String(log[messageKey])),\n })\n );\n }\n\n static getInstance(): Logger {\n if (!Logger.instance) {\n Logger.instance = new Logger();\n }\n return Logger.instance;\n }\n\n /**\n * Route console output (Clack chatter and the JSON console logger) to\n * stdout (the historical default) or stderr, so a command whose stdout is\n * machine-readable can keep diagnostics off it. Reversible per invocation;\n * a no-op when the direction is unchanged. The JSON logger keeps its\n * current level and is flushed before switching. File logging is unaffected.\n */\n setConsoleOutput(output: ConsoleOutput): void {\n if (output === this.consoleOutput) return;\n this.consoleOutput = output;\n this.clackOutput =\n output === 'stderr' ? { output: process.stderr } : undefined;\n if (this.pinoLogger) {\n this.pinoLogger.flush();\n const next =\n this.consoleLoggers[output] ??\n this.createConsoleLogger(process[output].fd, this.pinoLogger.level);\n next.level = this.pinoLogger.level;\n this.consoleLoggers[output] = next;\n this.pinoLogger = next;\n }\n }\n\n /**\n * Enable or disable quiet mode. When quiet, informational chatter\n * (info/step/success/message/debug/trace, spinners, progress bars, and\n * command intro/outro markers) is suppressed on the console, while warnings\n * and errors still print. Quiet wins over GT_LOG_LEVEL but never lowers an\n * already-more-restrictive level. File logging is unaffected so an explicit\n * GT_LOG_FILE still captures everything.\n */\n setQuiet(quiet: boolean): void {\n this.quiet = quiet;\n if (this.pinoLogger) {\n this.pinoLogger.level = quiet\n ? LOG_LEVEL_RANK[this.logLevel] > LOG_LEVEL_RANK[QUIET_FLOOR_LEVEL]\n ? this.logLevel\n : QUIET_FLOOR_LEVEL\n : this.logLevel;\n }\n }\n\n /**\n * Noninteractive setup reports progress as plain log lines instead of\n * redrawing spinners and progress bars on the console. Returns the previous\n * mode so a run can restore it.\n */\n setAnimatedProgress(animated: boolean): boolean {\n const previous = this.animatedProgress;\n this.animatedProgress = animated;\n return previous;\n }\n\n isQuiet(): boolean {\n return this.quiet;\n }\n\n getLogFormat(): LogFormat {\n return this.logFormat;\n }\n\n // Standard logging methods\n trace(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n // @clack/prompts doesn't have trace, use message\n clackLog.message(message, {\n symbol: chalk.dim('•'),\n ...this.clackOutput,\n });\n } else {\n this.pinoLogger?.trace(message);\n }\n }\n this.fileLogger?.trace(message);\n }\n\n debug(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n // @clack/prompts doesn't have debug, use message\n clackLog.message(message, {\n symbol: chalk.dim('◆'),\n ...this.clackOutput,\n });\n } else {\n this.pinoLogger?.debug(message);\n }\n }\n this.fileLogger?.debug(message);\n }\n\n info(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n clackLog.info(message, this.clackOutput);\n } else {\n this.pinoLogger?.info(message);\n }\n }\n this.fileLogger?.info(message);\n }\n\n warn(message: string): void {\n if (this.logFormat === 'default') {\n clackLog.warn(message, this.clackOutput);\n } else {\n this.pinoLogger?.warn(message);\n }\n this.fileLogger?.warn(message);\n }\n\n error(message: string): void {\n if (this.logFormat === 'default') {\n clackLog.error(message, this.clackOutput);\n } else {\n this.pinoLogger?.error(message);\n }\n this.fileLogger?.error(message);\n }\n\n fatal(message: string): void {\n if (this.logFormat === 'default') {\n // @clack/prompts doesn't have fatal, use error\n clackLog.error(message, this.clackOutput);\n } else {\n this.pinoLogger?.fatal(message);\n }\n this.fileLogger?.fatal(message);\n }\n\n silent(message: string): void {\n // Silent doesn't log to console, only to file\n this.fileLogger?.silent(message);\n }\n\n // @clack/prompts specific methods (for 'default' format)\n success(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n clackLog.success(message, this.clackOutput);\n } else {\n this.pinoLogger?.info(message); // Map to info for non-default formats\n }\n }\n this.fileLogger?.info(message);\n }\n\n step(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n clackLog.step(message, this.clackOutput);\n } else {\n this.pinoLogger?.info(message); // Map to info for non-default formats\n }\n }\n this.fileLogger?.info(message);\n }\n\n message(message: string, symbol?: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n clackLog.message(\n message,\n symbol ? { symbol, ...this.clackOutput } : this.clackOutput\n );\n } else {\n this.pinoLogger?.info(message); // Map to info for non-default formats\n }\n }\n this.fileLogger?.info(message);\n }\n\n // Spinner functionality\n createSpinner(indicator: 'dots' | 'timer' = 'timer'): SpinnerResult {\n // Quiet mode suppresses spinner UI; the mock routes through the gated\n // info() so nothing reaches the console while file logging is preserved.\n if (this.quiet || !this.animatedProgress) {\n return new MockSpinner(this);\n }\n if (this.logFormat === 'default') {\n return spinner({ indicator, ...this.clackOutput });\n } else {\n return new MockSpinner(this);\n }\n }\n\n // Progress bar functionality\n createProgressBar(total: number): ProgressResult {\n if (this.quiet || !this.animatedProgress) {\n return new MockProgress(total, this);\n }\n if (this.logFormat === 'default') {\n return progress({ max: total, ...this.clackOutput });\n } else {\n return new MockProgress(total, this);\n }\n }\n\n // Command start/end markers\n startCommand(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n intro(chalk.cyan(message), this.clackOutput);\n } else {\n this.info(`╭─ ${message}`);\n }\n }\n this.fileLogger?.info(`[START] ${message}`);\n }\n\n endCommand(message: string): void {\n if (!this.quiet) {\n if (this.logFormat === 'default') {\n outro(chalk.cyan(message), this.clackOutput);\n } else {\n this.info(`╰─ ${message}`);\n }\n }\n this.fileLogger?.info(`[END] ${message}`);\n }\n\n // Flush logs to ensure they're written before process exit\n flush(): void {\n this.pinoLogger?.flush();\n this.fileLogger?.flush();\n }\n}\n\nexport const logger = Logger.getInstance();\n"],"mappings":";;;;;;;AAsBA,MAAM,iBAA2C;CAC/C,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACR;AAID,MAAM,oBAA8B;AAIpC,SAAS,sBAAiC;CACxC,MAAM,KAAK,QAAQ,IAAI;AAEvB,QADa,CAAC,CAAC,MAAM,OAAO,WAAW,OAAO,OAC/B,CAAC,QAAQ,OAAO,QAAQ,UAAU;;AAInD,IAAM,cAAN,MAA2C;CACzC,iBAAiC;CACjC;CACA,cAAuB;CAEvB,YAAY,QAAgB;AAC1B,OAAK,SAAS;;CAGhB,MAAM,SAAwB;AAC5B,MAAI,SAAS;AACX,QAAK,iBAAiB;AACtB,QAAK,OAAO,KAAK,aAAa,UAAU;;;CAI5C,KAAK,SAAwB;EAC3B,MAAM,MAAM,WAAW,KAAK;AAC5B,MAAI,IACF,MAAK,OAAO,KAAK,aAAa,MAAM;AAEtC,OAAK,iBAAiB;;CAGxB,QAAQ,SAAwB;AAC9B,MAAI,SAAS;AACX,QAAK,iBAAiB;AACtB,QAAK,OAAO,KAAK,aAAa,UAAU;;;;AAM9C,IAAM,eAAN,MAA6C;CAC3C;CACA,UAA0B;CAC1B;CACA,cAAuB;CAEvB,YAAY,KAAa,QAAgB;AACvC,OAAK,MAAM;AACX,OAAK,SAAS;;CAGhB,MAAM,SAAwB;EAC5B,MAAM,MAAM,WAAW;AACvB,OAAK,OAAO,KAAK,cAAc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()) {
39
+ if (!logger.isQuiet() && logger.getLogFormat() === "default") {
40
40
  displayAsciiTitle();
41
41
  displayInitializingText();
42
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"logging.js","names":[],"sources":["../../src/console/logging.ts"],"sourcesContent":["import {\n text,\n select,\n confirm,\n isCancel,\n cancel,\n multiselect,\n autocomplete,\n autocompleteMultiselect,\n} from '@clack/prompts';\nimport type { Option } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { getCLIVersion } from '../utils/packageJson.js';\nimport { logger } from './logger.js';\nimport { TEMPLATE_FILE_NAME } from '../utils/constants.js';\nimport type { CustomMapping, FileToUpload } from 'generaltranslation/types';\nimport { parseTypedLocale } from './promptParsing.js';\nimport { getFilteredLocaleOptions } from './localeOptions.js';\nimport {\n getInlineElementsLabel,\n type InlineLibrary,\n} from '../types/libraries.js';\n\nfunction exitIfCancelled<T>(\n result: T | symbol,\n message = 'Operation cancelled'\n): T {\n if (isCancel(result)) {\n cancel(message);\n return exitSync(0);\n }\n return result as T;\n}\n\n/**\n * Strip ANSI escape codes from a string (e.g., chalk color codes)\n */\nexport function stripAnsi(str: string): string {\n // eslint-disable-next-line no-control-regex, no-useless-escape\n return str.replace(/\\x1B\\[[0-9;]*m/g, '');\n}\n\nlet lastExitError: string | undefined;\n\n/** The message of the last logErrorAndExit call, for exit-time reporting. */\nexport function getLastExitError(): string | undefined {\n return lastExitError;\n}\n\nexport function logErrorAndExit(message: string): never {\n lastExitError = message;\n logger.error(message);\n return exitSync(1);\n}\n\nexport function exitSync(code: number): never {\n // Flush logs before exit\n logger.flush();\n process.exit(code);\n}\n\n// GT specific logging\nexport function displayHeader(introString?: string) {\n // The ASCII banner is pure chatter and writes to console directly, bypassing\n // the logger, so gate it here to honor --quiet. startCommand stays outside\n // the gate: it is quiet-aware itself and must still run so the file log\n // gets its [START] marker.\n if (!logger.isQuiet()) {\n displayAsciiTitle();\n displayInitializingText();\n }\n\n if (introString) {\n logger.startCommand(introString);\n }\n}\n\nfunction displayAsciiTitle() {\n // eslint-disable-next-line no-console\n console.log(\n chalk.cyan(\n `\\n @@@@@@@@@@@@@@@@@@@@@@\n @@ @@@@@@@@@@@@ @@@@@@@\n @@ @@@ @ @\n@@ @@ @ @\n@@ @ @@@@@ @ @\n@@ @@ @@@ @ @ @\n @@ @@ @ @ @ @\n @@ @@@@@@@ @ @ @\n @@@@@@@@@ @ @`\n )\n );\n}\n\nfunction displayInitializingText() {\n const version = getCLIVersion();\n // eslint-disable-next-line no-console\n console.log(\n `\\n${chalk.bold.blue('General Translation, Inc.')}\n${chalk.dim('https://generaltranslation.com/docs')}\n${chalk.dim(`CLI Version: ${version}\\n`)}`\n );\n}\n\nexport function displayProjectId(projectId: string) {\n logger.message(\n chalk.dim(`Project ID: ${chalk.bold(projectId)}`),\n chalk.cyan('~')\n );\n}\n\nexport function displayResolvedPaths(resolvedPaths: [string, string][]) {\n const paths = resolvedPaths.map(([key, resolvedPath]) => {\n return chalk.dim(`'${chalk.white(key)}' → '${chalk.green(resolvedPath)}'`);\n });\n logger.step(`Resolved path aliases:\\n${paths.join('\\n')}`);\n}\n\nexport function displayCreatedConfigFile(configFilepath: string) {\n logger.step(`Created config file ${chalk.cyan(configFilepath)}`);\n}\n\nexport function displayUpdatedConfigFile(configFilepath: string) {\n logger.success(`Updated config file ${chalk.cyan(configFilepath)}`);\n}\n\nexport function displayUpdatedVersionsFile(versionFilepath: string) {\n logger.success(`Updated versions file ${chalk.cyan(versionFilepath)}`);\n}\n\n// Input prompts\nexport async function promptText({\n message,\n defaultValue,\n validate,\n}: {\n message: string;\n defaultValue?: string;\n validate?: (value: string) => boolean | string;\n}) {\n const result = await text({\n message,\n placeholder: defaultValue,\n defaultValue,\n validate: validate\n ? (value) => {\n // Clack applies defaultValue after validation; check what Enter returns.\n const validation = validate(value || defaultValue || '');\n return validation === true ? undefined : validation.toString();\n }\n : undefined,\n });\n return exitIfCancelled(result);\n}\n\ntype LocalePromptContext = {\n userInput: string;\n selectedValues: string[];\n focusedValue?: string;\n};\n\n/**\n * Clack keeps the focused option while it still matches a new search, so\n * typing `fr` could leave `af` (Afrikaans) focused. Refocus the top-ranked\n * option whenever the search changes.\n */\nfunction searchableLocaleOptions(\n getOptions: (query: string, selected: string[]) => Option<string>[]\n) {\n let lastQuery = '';\n return function (this: LocalePromptContext) {\n const query = this.userInput ?? '';\n if (query !== lastQuery) {\n lastQuery = query;\n this.focusedValue = undefined;\n }\n return getOptions(query, this.selectedValues ?? []);\n };\n}\n\n/**\n * Searchable locale options: supported locales ranked by the query, the\n * configured customMapping aliases, and any other valid locale typed or\n * already selected, so aliases and custom tags stay selectable.\n */\nexport function getLocalePromptOptions(\n query: string,\n selected: string[] = [],\n customMapping?: CustomMapping\n): Option<string>[] {\n const normalizedQuery = query.trim().toLowerCase();\n const supported = getFilteredLocaleOptions(query).map((option) => ({\n value: option.code,\n label: option.label,\n }));\n const known = new Set(supported.map((option) => option.value));\n const aliases = Object.keys(customMapping ?? {})\n .filter((alias) => alias.toLowerCase().includes(normalizedQuery))\n .map((alias) => ({ value: alias, label: alias, hint: 'custom mapping' }));\n const typed = parseTypedLocale(query, customMapping);\n const extras = [...selected, ...(typed ? [typed] : [])]\n .filter(\n (locale) =>\n !known.has(locale) && !aliases.some((alias) => alias.value === locale)\n )\n .map((locale) => ({ value: locale, label: locale }));\n return [\n ...new Map(\n [...aliases, ...extras, ...supported].map((option) => [\n option.value,\n option,\n ])\n ).values(),\n ].sort(\n (a, b) =>\n Number(b.value.toLowerCase() === normalizedQuery) -\n Number(a.value.toLowerCase() === normalizedQuery)\n );\n}\n\n// Body-only: Clack shows it inline under the prompt.\nconst noLocaleSelectedError = createDiagnosticMessage({\n whatHappened: 'No locale matches the search',\n fix: 'Change the search and select a locale from the list',\n});\n\nexport async function promptLocale({\n message,\n defaultValue,\n customMapping,\n}: {\n message: string;\n defaultValue?: string;\n customMapping?: CustomMapping;\n}) {\n const result = await autocomplete<string>({\n message,\n placeholder: 'Type to search locales',\n initialValue: defaultValue,\n options: searchableLocaleOptions((query) =>\n getLocalePromptOptions(query, [], customMapping)\n ),\n // Enter with no matching option submits nothing; keep asking.\n validate: (value) => (value ? undefined : noLocaleSelectedError),\n });\n return exitIfCancelled(result);\n}\n\nexport async function promptLocaleList({\n message,\n defaultValue,\n required = true,\n customMapping,\n}: {\n message: string;\n defaultValue?: string[];\n required?: boolean;\n customMapping?: CustomMapping;\n}) {\n const result = await autocompleteMultiselect<string>({\n message,\n placeholder: 'Type to search, Tab or Space to select',\n initialValues: defaultValue,\n required,\n // Clack only preselects defaults present in the first options list, so\n // keep custom default tags listed even before they are selected.\n options: searchableLocaleOptions((query, selected) =>\n getLocalePromptOptions(\n query,\n [...(defaultValue ?? []), ...selected],\n customMapping\n )\n ),\n });\n return exitIfCancelled(result);\n}\n\nexport async function promptGlobPatterns(options: {\n label: string;\n message: string;\n defaultValue?: string;\n validate?: (value: string) => boolean | string;\n}) {\n return promptText(options);\n}\n\nexport async function promptSelect<T>({\n message,\n options,\n defaultValue,\n}: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n defaultValue?: T;\n}) {\n const result = await select({\n message,\n options: options as Option<T>[],\n initialValue: defaultValue,\n });\n return exitIfCancelled(result);\n}\n\nexport async function promptMultiSelect<T extends string>({\n message,\n options,\n required = true,\n}: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n required?: boolean;\n}) {\n const result = await multiselect({\n message,\n options: options as Option<T>[],\n required,\n });\n return exitIfCancelled(result);\n}\n\nexport async function promptConfirm({\n message,\n defaultValue = true,\n cancelMessage = 'Operation cancelled',\n}: {\n message: string;\n defaultValue?: boolean;\n cancelMessage?: string;\n}) {\n const result = await confirm({\n message,\n initialValue: defaultValue,\n });\n return exitIfCancelled(result, cancelMessage);\n}\n\n// Warning display functions\nexport function warnApiKeyInConfig(optionsFilepath: string) {\n logger.warn(\n `Found ${chalk.cyan('apiKey')} in \"${chalk.green(optionsFilepath)}\". ` +\n chalk.white(\n 'Your API key is exposed! Remove it from the file and include it as an environment variable.'\n )\n );\n}\n\nexport function warnVariableProp(\n file: string,\n attrName: string,\n value: string\n) {\n logger.warn(\n `Found ${chalk.green('<T>')} component in ${chalk.cyan(file)} with variable ${attrName}: \"${chalk.white(value)}\". ` +\n `Change \"${attrName}\" to ensure this content is translated.`\n );\n}\n\nexport function warnNoId(file: string) {\n logger.warn(\n `Found ${chalk.green('<T>')} component in ${chalk.cyan(file)} with no id. ` +\n chalk.white('Add an id to ensure the content is translated.')\n );\n}\n\nexport function warnHasUnwrappedExpression(\n file: string,\n id: string,\n unwrappedExpressions: string[]\n) {\n logger.warn(\n `${chalk.green('<T>')} with id \"${id}\" in ${chalk.cyan(file)} has children: ${unwrappedExpressions.join(', ')} that could change at runtime. ` +\n chalk.white('Use a variable component like ') +\n chalk.green('<Var>') +\n chalk.white(' (') +\n chalk.blue('https://generaltranslation.com/docs') +\n chalk.white(') to translate this properly.')\n );\n}\n\nexport function warnTemplateLiteral(file: string, value: string) {\n logger.warn(\n `Found template literal with quasis (${value}) in ${chalk.cyan(file)}. ` +\n chalk.white(\n 'Change the template literal to a string to ensure this content is translated.'\n )\n );\n}\n\nexport function warnTernary(file: string) {\n logger.warn(\n `Found ternary expression in ${chalk.cyan(file)}. ` +\n chalk.white('A Branch component may be more appropriate here.')\n );\n}\n\nexport function warnDeprecatedField(\n deprecatedField: string,\n replacement: string\n) {\n logger.warn(\n `${chalk.green(deprecatedField)} is deprecated. ` +\n chalk.white(`Use ${chalk.green(replacement)} instead.`)\n );\n}\n\n/**\n * Helper: Log all collected files\n */\nexport function logCollectedFiles(\n files: Pick<FileToUpload, 'fileName'>[],\n inlineComponents?: number,\n inlineLibrary?: InlineLibrary\n): void {\n const elementLabel = getInlineElementsLabel(inlineLibrary);\n logger.message(\n chalk.cyan('Files found in project:') +\n '\\n' +\n files\n .map((file) => {\n if (file.fileName === TEMPLATE_FILE_NAME) {\n return `- <${elementLabel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ACL,GAAG,MAAM,MAAM,gBAAgB,CAAC,oBAC9B,MAAM,MAAM,OAAO,MAAM,MAAM,YAAY,CAAC,WAAW,CAC1D;;;;;AAMH,SAAgB,kBACd,OACA,kBACA,eACM;CACN,MAAM,eAAe,uBAAuB,cAAc;AAC1D,QAAO,QACL,MAAM,KAAK,0BAA0B,GACnC,OACA,MACG,KAAK,SAAS;AACb,MAAI,KAAK,aAAA,gCACP,QAAO,MAAM,aAAa,GAAG,mBAAmB,KAAK,iBAAiB,KAAK;AAE7E,SAAO,KAAK,KAAK;GACjB,CACD,KAAK,KAAK,CAChB"}
1
+ {"version":3,"file":"logging.js","names":[],"sources":["../../src/console/logging.ts"],"sourcesContent":["import {\n text,\n select,\n confirm,\n isCancel,\n cancel,\n multiselect,\n autocomplete,\n autocompleteMultiselect,\n} from '@clack/prompts';\nimport type { Option } from '@clack/prompts';\nimport chalk from 'chalk';\nimport { createDiagnosticMessage } from 'generaltranslation/internal';\nimport { getCLIVersion } from '../utils/packageJson.js';\nimport { logger } from './logger.js';\nimport { TEMPLATE_FILE_NAME } from '../utils/constants.js';\nimport type { CustomMapping, FileToUpload } from 'generaltranslation/types';\nimport { parseTypedLocale } from './promptParsing.js';\nimport { getFilteredLocaleOptions } from './localeOptions.js';\nimport {\n getInlineElementsLabel,\n type InlineLibrary,\n} from '../types/libraries.js';\n\nfunction exitIfCancelled<T>(\n result: T | symbol,\n message = 'Operation cancelled'\n): T {\n if (isCancel(result)) {\n cancel(message);\n return exitSync(0);\n }\n return result as T;\n}\n\n/**\n * Strip ANSI escape codes from a string (e.g., chalk color codes)\n */\nexport function stripAnsi(str: string): string {\n // eslint-disable-next-line no-control-regex, no-useless-escape\n return str.replace(/\\x1B\\[[0-9;]*m/g, '');\n}\n\nlet lastExitError: string | undefined;\n\n/** The message of the last logErrorAndExit call, for exit-time reporting. */\nexport function getLastExitError(): string | undefined {\n return lastExitError;\n}\n\nexport function logErrorAndExit(message: string): never {\n lastExitError = message;\n logger.error(message);\n return exitSync(1);\n}\n\nexport function exitSync(code: number): never {\n // Flush logs before exit\n logger.flush();\n process.exit(code);\n}\n\n// GT specific logging\nexport function displayHeader(introString?: string) {\n // The ASCII banner is pure chatter and writes to console directly, bypassing\n // the logger, so gate it here to honor --quiet and to keep json/agent output\n // free of decoration. startCommand stays outside the gate: it is\n // quiet-aware itself and must still run so the file log gets its [START]\n // marker.\n if (!logger.isQuiet() && logger.getLogFormat() === 'default') {\n displayAsciiTitle();\n displayInitializingText();\n }\n\n if (introString) {\n logger.startCommand(introString);\n }\n}\n\nfunction displayAsciiTitle() {\n // eslint-disable-next-line no-console\n console.log(\n chalk.cyan(\n `\\n @@@@@@@@@@@@@@@@@@@@@@\n @@ @@@@@@@@@@@@ @@@@@@@\n @@ @@@ @ @\n@@ @@ @ @\n@@ @ @@@@@ @ @\n@@ @@ @@@ @ @ @\n @@ @@ @ @ @ @\n @@ @@@@@@@ @ @ @\n @@@@@@@@@ @ @`\n )\n );\n}\n\nfunction displayInitializingText() {\n const version = getCLIVersion();\n // eslint-disable-next-line no-console\n console.log(\n `\\n${chalk.bold.blue('General Translation, Inc.')}\n${chalk.dim('https://generaltranslation.com/docs')}\n${chalk.dim(`CLI Version: ${version}\\n`)}`\n );\n}\n\nexport function displayProjectId(projectId: string) {\n logger.message(\n chalk.dim(`Project ID: ${chalk.bold(projectId)}`),\n chalk.cyan('~')\n );\n}\n\nexport function displayResolvedPaths(resolvedPaths: [string, string][]) {\n const paths = resolvedPaths.map(([key, resolvedPath]) => {\n return chalk.dim(`'${chalk.white(key)}' → '${chalk.green(resolvedPath)}'`);\n });\n logger.step(`Resolved path aliases:\\n${paths.join('\\n')}`);\n}\n\nexport function displayCreatedConfigFile(configFilepath: string) {\n logger.step(`Created config file ${chalk.cyan(configFilepath)}`);\n}\n\nexport function displayUpdatedConfigFile(configFilepath: string) {\n logger.success(`Updated config file ${chalk.cyan(configFilepath)}`);\n}\n\nexport function displayUpdatedVersionsFile(versionFilepath: string) {\n logger.success(`Updated versions file ${chalk.cyan(versionFilepath)}`);\n}\n\n// Input prompts\nexport async function promptText({\n message,\n defaultValue,\n validate,\n}: {\n message: string;\n defaultValue?: string;\n validate?: (value: string) => boolean | string;\n}) {\n const result = await text({\n message,\n placeholder: defaultValue,\n defaultValue,\n validate: validate\n ? (value) => {\n // Clack applies defaultValue after validation; check what Enter returns.\n const validation = validate(value || defaultValue || '');\n return validation === true ? undefined : validation.toString();\n }\n : undefined,\n });\n return exitIfCancelled(result);\n}\n\ntype LocalePromptContext = {\n userInput: string;\n selectedValues: string[];\n focusedValue?: string;\n};\n\n/**\n * Clack keeps the focused option while it still matches a new search, so\n * typing `fr` could leave `af` (Afrikaans) focused. Refocus the top-ranked\n * option whenever the search changes.\n */\nfunction searchableLocaleOptions(\n getOptions: (query: string, selected: string[]) => Option<string>[]\n) {\n let lastQuery = '';\n return function (this: LocalePromptContext) {\n const query = this.userInput ?? '';\n if (query !== lastQuery) {\n lastQuery = query;\n this.focusedValue = undefined;\n }\n return getOptions(query, this.selectedValues ?? []);\n };\n}\n\n/**\n * Searchable locale options: supported locales ranked by the query, the\n * configured customMapping aliases, and any other valid locale typed or\n * already selected, so aliases and custom tags stay selectable.\n */\nexport function getLocalePromptOptions(\n query: string,\n selected: string[] = [],\n customMapping?: CustomMapping\n): Option<string>[] {\n const normalizedQuery = query.trim().toLowerCase();\n const supported = getFilteredLocaleOptions(query).map((option) => ({\n value: option.code,\n label: option.label,\n }));\n const known = new Set(supported.map((option) => option.value));\n const aliases = Object.keys(customMapping ?? {})\n .filter((alias) => alias.toLowerCase().includes(normalizedQuery))\n .map((alias) => ({ value: alias, label: alias, hint: 'custom mapping' }));\n const typed = parseTypedLocale(query, customMapping);\n const extras = [...selected, ...(typed ? [typed] : [])]\n .filter(\n (locale) =>\n !known.has(locale) && !aliases.some((alias) => alias.value === locale)\n )\n .map((locale) => ({ value: locale, label: locale }));\n return [\n ...new Map(\n [...aliases, ...extras, ...supported].map((option) => [\n option.value,\n option,\n ])\n ).values(),\n ].sort(\n (a, b) =>\n Number(b.value.toLowerCase() === normalizedQuery) -\n Number(a.value.toLowerCase() === normalizedQuery)\n );\n}\n\n// Body-only: Clack shows it inline under the prompt.\nconst noLocaleSelectedError = createDiagnosticMessage({\n whatHappened: 'No locale matches the search',\n fix: 'Change the search and select a locale from the list',\n});\n\nexport async function promptLocale({\n message,\n defaultValue,\n customMapping,\n}: {\n message: string;\n defaultValue?: string;\n customMapping?: CustomMapping;\n}) {\n const result = await autocomplete<string>({\n message,\n placeholder: 'Type to search locales',\n initialValue: defaultValue,\n options: searchableLocaleOptions((query) =>\n getLocalePromptOptions(query, [], customMapping)\n ),\n // Enter with no matching option submits nothing; keep asking.\n validate: (value) => (value ? undefined : noLocaleSelectedError),\n });\n return exitIfCancelled(result);\n}\n\nexport async function promptLocaleList({\n message,\n defaultValue,\n required = true,\n customMapping,\n}: {\n message: string;\n defaultValue?: string[];\n required?: boolean;\n customMapping?: CustomMapping;\n}) {\n const result = await autocompleteMultiselect<string>({\n message,\n placeholder: 'Type to search, Tab or Space to select',\n initialValues: defaultValue,\n required,\n // Clack only preselects defaults present in the first options list, so\n // keep custom default tags listed even before they are selected.\n options: searchableLocaleOptions((query, selected) =>\n getLocalePromptOptions(\n query,\n [...(defaultValue ?? []), ...selected],\n customMapping\n )\n ),\n });\n return exitIfCancelled(result);\n}\n\nexport async function promptGlobPatterns(options: {\n label: string;\n message: string;\n defaultValue?: string;\n validate?: (value: string) => boolean | string;\n}) {\n return promptText(options);\n}\n\nexport async function promptSelect<T>({\n message,\n options,\n defaultValue,\n}: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n defaultValue?: T;\n}) {\n const result = await select({\n message,\n options: options as Option<T>[],\n initialValue: defaultValue,\n });\n return exitIfCancelled(result);\n}\n\nexport async function promptMultiSelect<T extends string>({\n message,\n options,\n required = true,\n}: {\n message: string;\n options: Array<{ value: T; label: string; hint?: string }>;\n required?: boolean;\n}) {\n const result = await multiselect({\n message,\n options: options as Option<T>[],\n required,\n });\n return exitIfCancelled(result);\n}\n\nexport async function promptConfirm({\n message,\n defaultValue = true,\n cancelMessage = 'Operation cancelled',\n}: {\n message: string;\n defaultValue?: boolean;\n cancelMessage?: string;\n}) {\n const result = await confirm({\n message,\n initialValue: defaultValue,\n });\n return exitIfCancelled(result, cancelMessage);\n}\n\n// Warning display functions\nexport function warnApiKeyInConfig(optionsFilepath: string) {\n logger.warn(\n `Found ${chalk.cyan('apiKey')} in \"${chalk.green(optionsFilepath)}\". ` +\n chalk.white(\n 'Your API key is exposed! Remove it from the file and include it as an environment variable.'\n )\n );\n}\n\nexport function warnVariableProp(\n file: string,\n attrName: string,\n value: string\n) {\n logger.warn(\n `Found ${chalk.green('<T>')} component in ${chalk.cyan(file)} with variable ${attrName}: \"${chalk.white(value)}\". ` +\n `Change \"${attrName}\" to ensure this content is translated.`\n );\n}\n\nexport function warnNoId(file: string) {\n logger.warn(\n `Found ${chalk.green('<T>')} component in ${chalk.cyan(file)} with no id. ` +\n chalk.white('Add an id to ensure the content is translated.')\n );\n}\n\nexport function warnHasUnwrappedExpression(\n file: string,\n id: string,\n unwrappedExpressions: string[]\n) {\n logger.warn(\n `${chalk.green('<T>')} with id \"${id}\" in ${chalk.cyan(file)} has children: ${unwrappedExpressions.join(', ')} that could change at runtime. ` +\n chalk.white('Use a variable component like ') +\n chalk.green('<Var>') +\n chalk.white(' (') +\n chalk.blue('https://generaltranslation.com/docs') +\n chalk.white(') to translate this properly.')\n );\n}\n\nexport function warnTemplateLiteral(file: string, value: string) {\n logger.warn(\n `Found template literal with quasis (${value}) in ${chalk.cyan(file)}. ` +\n chalk.white(\n 'Change the template literal to a string to ensure this content is translated.'\n )\n );\n}\n\nexport function warnTernary(file: string) {\n logger.warn(\n `Found ternary expression in ${chalk.cyan(file)}. ` +\n chalk.white('A Branch component may be more appropriate here.')\n );\n}\n\nexport function warnDeprecatedField(\n deprecatedField: string,\n replacement: string\n) {\n logger.warn(\n `${chalk.green(deprecatedField)} is deprecated. ` +\n chalk.white(`Use ${chalk.green(replacement)} instead.`)\n );\n}\n\n/**\n * Helper: Log all collected files\n */\nexport function logCollectedFiles(\n files: Pick<FileToUpload, 'fileName'>[],\n inlineComponents?: number,\n inlineLibrary?: InlineLibrary\n): void {\n const elementLabel = getInlineElementsLabel(inlineLibrary);\n logger.message(\n chalk.cyan('Files found in project:') +\n '\\n' +\n files\n .map((file) => {\n if (file.fileName === TEMPLATE_FILE_NAME) {\n return `- <${elementLabel}>${inlineComponents ? ` (${inlineComponents})` : ''}`;\n }\n return `- ${file.fileName}`;\n })\n .join('\\n')\n );\n}\n"],"mappings":";;;;;;;;;;AAwBA,SAAS,gBACP,QACA,UAAU,uBACP;AACH,KAAI,SAAS,OAAO,EAAE;AACpB,SAAO,QAAQ;AACf,SAAO,SAAS,EAAE;;AAEpB,QAAO;;;;;AAMT,SAAgB,UAAU,KAAqB;AAE7C,QAAO,IAAI,QAAQ,mBAAmB,GAAG;;AAG3C,IAAI;;AAGJ,SAAgB,mBAAuC;AACrD,QAAO;;AAGT,SAAgB,gBAAgB,SAAwB;AACtD,iBAAgB;AAChB,QAAO,MAAM,QAAQ;AACrB,QAAO,SAAS,EAAE;;AAGpB,SAAgB,SAAS,MAAqB;AAE5C,QAAO,OAAO;AACd,SAAQ,KAAK,KAAK;;AAIpB,SAAgB,cAAc,aAAsB;AAMlD,KAAI,CAAC,OAAO,SAAS,IAAI,OAAO,cAAc,KAAK,WAAW;AAC5D,qBAAmB;AACnB,2BAAyB;;AAG3B,KAAI,YACF,QAAO,aAAa,YAAY;;AAIpC,SAAS,oBAAoB;AAE3B,SAAQ,IACN,MAAM,KACJ;;;;;;;;sBASD,CACF;;AAGH,SAAS,0BAA0B;CACjC,MAAM,UAAU,eAAe;AAE/B,SAAQ,IACN,KAAK,MAAM,KAAK,KAAK,4BAA4B,CAAC;EACpD,MAAM,IAAI,sCAAsC,CAAC;EACjD,MAAM,IAAI,gBAAgB,QAAQ,IAAI,GAC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B,MAAM,KAAK,sCAAsC,GACjD,MAAM,MAAM,gCAAgC,CAC/C;;AAGH,SAAgB,oBAAoB,MAAc,OAAe;AAC/D,QAAO,KACL,uCAAuC,MAAM,OAAO,MAAM,KAAK,KAAK,CAAC,MACnE,MAAM,MACJ,gFACD,CACJ;;AAGH,SAAgB,YAAY,MAAc;AACxC,QAAO,KACL,+BAA+B,MAAM,KAAK,KAAK,CAAC,MAC9C,MAAM,MAAM,mDAAmD,CAClE;;AAGH,SAAgB,oBACd,iBACA,aACA;AACA,QAAO,KACL,GAAG,MAAM,MAAM,gBAAgB,CAAC,oBAC9B,MAAM,MAAM,OAAO,MAAM,MAAM,YAAY,CAAC,WAAW,CAC1D;;;;;AAMH,SAAgB,kBACd,OACA,kBACA,eACM;CACN,MAAM,eAAe,uBAAuB,cAAc;AAC1D,QAAO,QACL,MAAM,KAAK,0BAA0B,GACnC,OACA,MACG,KAAK,SAAS;AACb,MAAI,KAAK,aAAA,gCACP,QAAO,MAAM,aAAa,GAAG,mBAAmB,KAAK,iBAAiB,KAAK;AAE7E,SAAO,KAAK,KAAK;GACjB,CACD,KAAK,KAAK,CAChB"}
@@ -1,8 +1,8 @@
1
1
  import { GT_CONFIG_SCHEMA_URL } from "../../utils/constants.js";
2
2
  import { displayCreatedConfigFile, displayUpdatedConfigFile } from "../../console/logging.js";
3
3
  import { createDiagnosticMessage, formatDiagnosticErrorDetails } from "generaltranslation/internal";
4
- import fs from "node:fs";
5
4
  import { isDeepStrictEqual } from "node:util";
5
+ import fs from "node:fs";
6
6
  //#region src/fs/config/setupConfig.ts
7
7
  function asObject(value) {
8
8
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "2.26.9";
1
+ export declare const PACKAGE_VERSION = "2.26.10";
@@ -1,5 +1,5 @@
1
1
  //#region src/generated/version.ts
2
- const PACKAGE_VERSION = "2.26.9";
2
+ const PACKAGE_VERSION = "2.26.10";
3
3
  //#endregion
4
4
  export { PACKAGE_VERSION };
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.26.9';\n"],"mappings":";AACA,MAAa,kBAAkB"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../src/generated/version.ts"],"sourcesContent":["// This file is auto-generated. Do not edit manually.\nexport const PACKAGE_VERSION = '2.26.10';\n"],"mappings":";AACA,MAAa,kBAAkB"}
@@ -1,9 +1,9 @@
1
1
  import updateConfig from "../fs/config/updateConfig.js";
2
+ import { promisify } from "node:util";
2
3
  import path from "node:path";
3
4
  import fs from "node:fs";
4
5
  import { createDiagnosticMessage } from "generaltranslation/diagnostics";
5
6
  import { execFile } from "node:child_process";
6
- import { promisify } from "node:util";
7
7
  //#region src/git/setupMergeDrivers.ts
8
8
  const execFileAsync = promisify(execFile);
9
9
  const GT_LOCK_DRIVER = "merge=gt-lock";
@@ -1,9 +1,9 @@
1
1
  import { createDiagnosticMessage, formatDiagnosticErrorDetails } from "generaltranslation/internal";
2
2
  import { randomUUID } from "node:crypto";
3
+ import { promisify } from "node:util";
3
4
  import path from "node:path";
4
5
  import fs from "node:fs";
5
6
  import { execFile } from "node:child_process";
6
- import { promisify } from "node:util";
7
7
  import dotenv from "dotenv";
8
8
  //#region src/utils/credentials.ts
9
9
  const execFileAsync = promisify(execFile);
@@ -1,5 +1,5 @@
1
- import { execFile } from "node:child_process";
2
1
  import { promisify } from "node:util";
2
+ import { execFile } from "node:child_process";
3
3
  //#region src/utils/gitDiff.ts
4
4
  const execFileAsync = promisify(execFile);
5
5
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gt",
3
- "version": "2.26.9",
3
+ "version": "2.26.10",
4
4
  "main": "dist/index.js",
5
5
  "bin": "bin/main.js",
6
6
  "files": [
@@ -104,6 +104,7 @@
104
104
  "openid-client": "6.8.8",
105
105
  "package-manager-detector": "^1.8.0",
106
106
  "pino": "^10.1.0",
107
+ "pino-pretty": "^13.2.0",
107
108
  "remark-frontmatter": "^5.0.0",
108
109
  "remark-mdx": "^3.1.0",
109
110
  "remark-parse": "^11.0.0",
@@ -115,13 +116,13 @@
115
116
  "unified": "^11.0.5",
116
117
  "unist-util-visit": "^5.0.0",
117
118
  "yaml": "^2.8.0",
118
- "@generaltranslation/format": "0.1.9",
119
119
  "@generaltranslation/icu": "0.1.2",
120
120
  "@generaltranslation/python-extractor": "0.2.63",
121
121
  "@generaltranslation/supported-locales": "2.1.44",
122
122
  "@generaltranslation/vue-extractor": "0.1.22",
123
123
  "generaltranslation": "9.5.8",
124
- "gt-remark": "1.0.12"
124
+ "gt-remark": "1.0.12",
125
+ "@generaltranslation/format": "0.1.9"
125
126
  },
126
127
  "devDependencies": {
127
128
  "@types/babel__generator": "^7.27.0",