@pristine-ts/cli 2.0.5 → 2.0.7

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.
Files changed (85) hide show
  1. package/dist/lib/cjs/bootstrap/build-runner.js +1 -1
  2. package/dist/lib/cjs/cli.module.js +12 -7
  3. package/dist/lib/cjs/cli.module.js.map +1 -1
  4. package/dist/lib/cjs/commands/build.command.js +15 -14
  5. package/dist/lib/cjs/commands/build.command.js.map +1 -1
  6. package/dist/lib/cjs/commands/config-print.command.js +16 -11
  7. package/dist/lib/cjs/commands/config-print.command.js.map +1 -1
  8. package/dist/lib/cjs/commands/help.command.js +17 -17
  9. package/dist/lib/cjs/commands/help.command.js.map +1 -1
  10. package/dist/lib/cjs/commands/info.command.js +26 -21
  11. package/dist/lib/cjs/commands/info.command.js.map +1 -1
  12. package/dist/lib/cjs/commands/init.command.js +22 -21
  13. package/dist/lib/cjs/commands/init.command.js.map +1 -1
  14. package/dist/lib/cjs/commands/list.command.js +6 -6
  15. package/dist/lib/cjs/commands/list.command.js.map +1 -1
  16. package/dist/lib/cjs/commands/start.command.js +12 -13
  17. package/dist/lib/cjs/commands/start.command.js.map +1 -1
  18. package/dist/lib/cjs/event-handlers/cli.event-handler.js +9 -7
  19. package/dist/lib/cjs/event-handlers/cli.event-handler.js.map +1 -1
  20. package/dist/lib/cjs/managers/cli-output.manager.js +45 -0
  21. package/dist/lib/cjs/managers/cli-output.manager.js.map +1 -0
  22. package/dist/lib/cjs/managers/cli-progress-bar.manager.js +49 -0
  23. package/dist/lib/cjs/managers/cli-progress-bar.manager.js.map +1 -0
  24. package/dist/lib/cjs/managers/cli-prompt.manager.js +99 -0
  25. package/dist/lib/cjs/managers/cli-prompt.manager.js.map +1 -0
  26. package/dist/lib/cjs/managers/cli-spinner.manager.js +93 -0
  27. package/dist/lib/cjs/managers/cli-spinner.manager.js.map +1 -0
  28. package/dist/lib/cjs/managers/managers.js +4 -1
  29. package/dist/lib/cjs/managers/managers.js.map +1 -1
  30. package/dist/lib/cjs/managers/shell.manager.js +25 -20
  31. package/dist/lib/cjs/managers/shell.manager.js.map +1 -1
  32. package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  33. package/dist/lib/esm/bootstrap/build-runner.js +1 -1
  34. package/dist/lib/esm/cli.module.js +12 -7
  35. package/dist/lib/esm/cli.module.js.map +1 -1
  36. package/dist/lib/esm/commands/build.command.js +16 -15
  37. package/dist/lib/esm/commands/build.command.js.map +1 -1
  38. package/dist/lib/esm/commands/config-print.command.js +16 -11
  39. package/dist/lib/esm/commands/config-print.command.js.map +1 -1
  40. package/dist/lib/esm/commands/help.command.js +17 -17
  41. package/dist/lib/esm/commands/help.command.js.map +1 -1
  42. package/dist/lib/esm/commands/info.command.js +27 -22
  43. package/dist/lib/esm/commands/info.command.js.map +1 -1
  44. package/dist/lib/esm/commands/init.command.js +23 -22
  45. package/dist/lib/esm/commands/init.command.js.map +1 -1
  46. package/dist/lib/esm/commands/list.command.js +6 -6
  47. package/dist/lib/esm/commands/list.command.js.map +1 -1
  48. package/dist/lib/esm/commands/start.command.js +13 -14
  49. package/dist/lib/esm/commands/start.command.js.map +1 -1
  50. package/dist/lib/esm/event-handlers/cli.event-handler.js +9 -7
  51. package/dist/lib/esm/event-handlers/cli.event-handler.js.map +1 -1
  52. package/dist/lib/esm/managers/cli-output.manager.js +42 -0
  53. package/dist/lib/esm/managers/cli-output.manager.js.map +1 -0
  54. package/dist/lib/esm/managers/cli-progress-bar.manager.js +46 -0
  55. package/dist/lib/esm/managers/cli-progress-bar.manager.js.map +1 -0
  56. package/dist/lib/esm/managers/cli-prompt.manager.js +63 -0
  57. package/dist/lib/esm/managers/cli-prompt.manager.js.map +1 -0
  58. package/dist/lib/esm/managers/cli-spinner.manager.js +90 -0
  59. package/dist/lib/esm/managers/cli-spinner.manager.js.map +1 -0
  60. package/dist/lib/esm/managers/managers.js +4 -1
  61. package/dist/lib/esm/managers/managers.js.map +1 -1
  62. package/dist/lib/esm/managers/shell.manager.js +26 -21
  63. package/dist/lib/esm/managers/shell.manager.js.map +1 -1
  64. package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
  65. package/dist/types/bootstrap/build-runner.d.ts +1 -1
  66. package/dist/types/commands/build.command.d.ts +3 -3
  67. package/dist/types/commands/config-print.command.d.ts +8 -3
  68. package/dist/types/commands/help.command.d.ts +3 -3
  69. package/dist/types/commands/info.command.d.ts +5 -3
  70. package/dist/types/commands/init.command.d.ts +3 -3
  71. package/dist/types/commands/list.command.d.ts +3 -3
  72. package/dist/types/commands/start.command.d.ts +3 -3
  73. package/dist/types/event-handlers/cli.event-handler.d.ts +1 -3
  74. package/dist/types/managers/cli-output.manager.d.ts +21 -0
  75. package/dist/types/managers/cli-progress-bar.manager.d.ts +17 -0
  76. package/dist/types/managers/cli-prompt.manager.d.ts +22 -0
  77. package/dist/types/managers/cli-spinner.manager.d.ts +34 -0
  78. package/dist/types/managers/managers.d.ts +4 -1
  79. package/dist/types/managers/shell.manager.d.ts +3 -3
  80. package/package.json +9 -9
  81. package/dist/lib/cjs/managers/console.manager.js +0 -277
  82. package/dist/lib/cjs/managers/console.manager.js.map +0 -1
  83. package/dist/lib/esm/managers/console.manager.js +0 -241
  84. package/dist/lib/esm/managers/console.manager.js.map +0 -1
  85. package/dist/types/managers/console.manager.d.ts +0 -93
@@ -4,7 +4,7 @@
4
4
  * inline avoids the awkward "exit, ask the user to type a command, re-enter" loop.
5
5
  *
6
6
  * Spawning rather than dispatching to `BuildCommand` directly keeps `AppModuleLoader` free
7
- * of the build pipeline's dependency graph (ConsoleManager, ShellManager, etc.) which only
7
+ * of the build pipeline's dependency graph (LogHandler, ShellManager, CliOutput, etc.) which only
8
8
  * exists in the kernel container — and the kernel hasn't booted yet at the point this is
9
9
  * called. The subprocess re-bootstraps the kernel cleanly with all of those services.
10
10
  *
@@ -1,6 +1,6 @@
1
1
  import { ExitCode } from "@pristine-ts/common";
2
+ import { LogHandlerInterface } from "@pristine-ts/logging";
2
3
  import { CommandInterface } from "../interfaces/command.interface";
3
- import { ConsoleManager } from "../managers/console.manager";
4
4
  import { ShellManager } from "../managers/shell.manager";
5
5
  import { ConfigLoader } from "../config/config-loader";
6
6
  import { BuildManifestWriter } from "../bootstrap/build-manifest-writer";
@@ -24,7 +24,7 @@ import { BuildManifestWriter } from "../bootstrap/build-manifest-writer";
24
24
  * - clean: false (set true to wipe outDir before building)
25
25
  */
26
26
  export declare class BuildCommand implements CommandInterface<null> {
27
- private readonly consoleManager;
27
+ private readonly logHandler;
28
28
  private readonly shellManager;
29
29
  private readonly configLoader;
30
30
  private readonly buildManifestWriter;
@@ -33,7 +33,7 @@ export declare class BuildCommand implements CommandInterface<null> {
33
33
  description: string;
34
34
  private readonly defaultTsconfig;
35
35
  private readonly defaultFormat;
36
- constructor(consoleManager: ConsoleManager, shellManager: ShellManager, configLoader: ConfigLoader, buildManifestWriter: BuildManifestWriter);
36
+ constructor(logHandler: LogHandlerInterface, shellManager: ShellManager, configLoader: ConfigLoader, buildManifestWriter: BuildManifestWriter);
37
37
  run(args: any): Promise<ExitCode | number>;
38
38
  private writeManifestIfConfigured;
39
39
  /**
@@ -1,18 +1,23 @@
1
1
  import { ExitCode } from "@pristine-ts/common";
2
2
  import { CommandInterface } from "../interfaces/command.interface";
3
- import { ConsoleManager } from "../managers/console.manager";
3
+ import { CliOutput } from "../managers/cli-output.manager";
4
4
  import { ConfigLoader } from "../config/config-loader";
5
5
  /**
6
6
  * Prints the resolved Pristine configuration plus where it was loaded from. Useful for
7
7
  * debugging discovery — when `pristine` is doing something unexpected, the first question is
8
8
  * always "which config file did it actually pick up?"
9
+ *
10
+ * This is a report command: its entire output is the report. It goes through `CliOutput`
11
+ * exclusively (not `LogHandler`) so the dump pipes/redirects cleanly — `pristine
12
+ * p:config:print > config.json` must produce a usable file, with no severity gating, no
13
+ * per-line timestamp/icon decoration, and no fan-out to file/Sentry transports.
9
14
  */
10
15
  export declare class ConfigPrintCommand implements CommandInterface<null> {
11
- private readonly consoleManager;
16
+ private readonly cliOutput;
12
17
  private readonly configLoader;
13
18
  optionsType: null;
14
19
  name: string;
15
20
  description: string;
16
- constructor(consoleManager: ConsoleManager, configLoader: ConfigLoader);
21
+ constructor(cliOutput: CliOutput, configLoader: ConfigLoader);
17
22
  run(args: any): Promise<ExitCode | number>;
18
23
  }
@@ -1,7 +1,7 @@
1
1
  import { DependencyContainer } from "tsyringe";
2
2
  import { ExitCode } from "@pristine-ts/common";
3
3
  import { CommandInterface } from "../interfaces/command.interface";
4
- import { ConsoleManager } from "../managers/console.manager";
4
+ import { CliOutput } from "../managers/cli-output.manager";
5
5
  /**
6
6
  * Prints a usage banner plus a one-line summary for every registered command. The output is
7
7
  * generated from the actual `CommandInterface[]` resolved from the current DI container, so
@@ -18,11 +18,11 @@ import { ConsoleManager } from "../managers/console.manager";
18
18
  * by which point every Command-tagged class is fully constructed and cached.
19
19
  */
20
20
  export declare class HelpCommand implements CommandInterface<null> {
21
- private readonly consoleManager;
21
+ private readonly cliOutput;
22
22
  private readonly container;
23
23
  optionsType: null;
24
24
  name: string;
25
25
  description: string;
26
- constructor(consoleManager: ConsoleManager, container: DependencyContainer);
26
+ constructor(cliOutput: CliOutput, container: DependencyContainer);
27
27
  run(args: any): Promise<ExitCode | number>;
28
28
  }
@@ -1,6 +1,7 @@
1
1
  import { ExitCode } from "@pristine-ts/common";
2
+ import { LogHandlerInterface } from "@pristine-ts/logging";
2
3
  import { CommandInterface } from "../interfaces/command.interface";
3
- import { ConsoleManager } from "../managers/console.manager";
4
+ import { CliOutput } from "../managers/cli-output.manager";
4
5
  import { ConfigLoader } from "../config/config-loader";
5
6
  import { AppModuleLoader } from "../bootstrap/app-module-loader";
6
7
  /**
@@ -14,7 +15,8 @@ import { AppModuleLoader } from "../bootstrap/app-module-loader";
14
15
  * prevents `kernel.start()`.
15
16
  */
16
17
  export declare class InfoCommand implements CommandInterface<null> {
17
- private readonly consoleManager;
18
+ private readonly logHandler;
19
+ private readonly cliOutput;
18
20
  private readonly configLoader;
19
21
  private readonly appModuleLoader;
20
22
  optionsType: null;
@@ -26,7 +28,7 @@ export declare class InfoCommand implements CommandInterface<null> {
26
28
  * package.json sits four levels up from dist/lib/cjs/commands/.
27
29
  */
28
30
  private readonly cliPackageJsonPath;
29
- constructor(consoleManager: ConsoleManager, configLoader: ConfigLoader, appModuleLoader: AppModuleLoader);
31
+ constructor(logHandler: LogHandlerInterface, cliOutput: CliOutput, configLoader: ConfigLoader, appModuleLoader: AppModuleLoader);
30
32
  run(args: any): Promise<ExitCode | number>;
31
33
  private printRuntimeBanner;
32
34
  private printConfigSection;
@@ -1,6 +1,6 @@
1
1
  import { ExitCode } from "@pristine-ts/common";
2
+ import { LogHandlerInterface } from "@pristine-ts/logging";
2
3
  import { CommandInterface } from "../interfaces/command.interface";
3
- import { ConsoleManager } from "../managers/console.manager";
4
4
  import { InitCommandOptions } from "./init.command-options";
5
5
  import { InitPrompt } from "../bootstrap/init-prompt";
6
6
  /**
@@ -19,14 +19,14 @@ import { InitPrompt } from "../bootstrap/init-prompt";
19
19
  * Refuses to overwrite an existing `pristine.config.ts` so re-running init is safe.
20
20
  */
21
21
  export declare class InitCommand implements CommandInterface<InitCommandOptions> {
22
- private readonly consoleManager;
22
+ private readonly logHandler;
23
23
  private readonly initPrompt;
24
24
  optionsType: typeof InitCommandOptions;
25
25
  name: string;
26
26
  description: string;
27
27
  private readonly configFileName;
28
28
  private readonly gitignoreEntry;
29
- constructor(consoleManager: ConsoleManager, initPrompt: InitPrompt);
29
+ constructor(logHandler: LogHandlerInterface, initPrompt: InitPrompt);
30
30
  run(args: InitCommandOptions): Promise<ExitCode | number>;
31
31
  /**
32
32
  * Fills in answers from CLI flags first, then prompts (in TTY) for whatever's missing.
@@ -1,18 +1,18 @@
1
1
  import { ExitCode } from "@pristine-ts/common";
2
2
  import { DependencyContainer } from "tsyringe";
3
3
  import { CommandInterface } from "../interfaces/command.interface";
4
- import { ConsoleManager } from "../managers/console.manager";
4
+ import { CliOutput } from "../managers/cli-output.manager";
5
5
  /**
6
6
  * Lists every registered command's name. Like `HelpCommand`, this resolves the command set
7
7
  * lazily inside `run()` via the injected child container to avoid the self-referential cycle
8
8
  * that constructor-time `@injectAll(Command)` would create — see `HelpCommand` for details.
9
9
  */
10
10
  export declare class ListCommand implements CommandInterface<null> {
11
- private readonly consoleManager;
11
+ private readonly cliOutput;
12
12
  private readonly container;
13
13
  optionsType: null;
14
14
  name: string;
15
15
  description: string;
16
- constructor(consoleManager: ConsoleManager, container: DependencyContainer);
16
+ constructor(cliOutput: CliOutput, container: DependencyContainer);
17
17
  run(args: any): Promise<ExitCode | number>;
18
18
  }
@@ -1,7 +1,7 @@
1
1
  import { ExitCode } from "@pristine-ts/common";
2
2
  import { Kernel, RuntimeServerInterface } from "@pristine-ts/core";
3
+ import { LogHandlerInterface } from "@pristine-ts/logging";
3
4
  import { CommandInterface } from "../interfaces/command.interface";
4
- import { ConsoleManager } from "../managers/console.manager";
5
5
  import { StartCommandOptions } from "./start.command-options";
6
6
  /**
7
7
  * Boots the AppModule, starts every registered `RuntimeServerInterface` (HTTP server, gRPC
@@ -34,7 +34,7 @@ import { StartCommandOptions } from "./start.command-options";
34
34
  * `nodemon` or `tsx --watch`.
35
35
  */
36
36
  export declare class StartCommand implements CommandInterface<StartCommandOptions> {
37
- private readonly consoleManager;
37
+ private readonly logHandler;
38
38
  private readonly kernel;
39
39
  private readonly servers;
40
40
  optionsType: typeof StartCommandOptions;
@@ -42,6 +42,6 @@ export declare class StartCommand implements CommandInterface<StartCommandOption
42
42
  description: string;
43
43
  private static readonly HARD_EXIT_TIMEOUT_MS;
44
44
  private readonly defaultRuntimeServerName;
45
- constructor(consoleManager: ConsoleManager, kernel: Kernel, servers: RuntimeServerInterface[]);
45
+ constructor(logHandler: LogHandlerInterface, kernel: Kernel, servers: RuntimeServerInterface[]);
46
46
  run(args: StartCommandOptions): Promise<ExitCode | number>;
47
47
  }
@@ -4,13 +4,11 @@ import { CommandEventResponse } from "../types/command-event-response.type";
4
4
  import { CommandInterface } from "../interfaces/command.interface";
5
5
  import { LogHandlerInterface } from "@pristine-ts/logging";
6
6
  import { Validator } from "@pristine-ts/class-validator";
7
- import { ConsoleManager } from "../managers/console.manager";
8
7
  export declare class CliEventHandler implements EventHandlerInterface<any, any> {
9
8
  private readonly logHandler;
10
9
  private readonly validator;
11
- private readonly consoleManager;
12
10
  private readonly commands;
13
- constructor(logHandler: LogHandlerInterface, validator: Validator, consoleManager: ConsoleManager, commands: CommandInterface<any>[]);
11
+ constructor(logHandler: LogHandlerInterface, validator: Validator, commands: CommandInterface<any>[]);
14
12
  handle(event: CommandEvent): Promise<CommandEventResponse>;
15
13
  /**
16
14
  * Maps `rawArgs` (the parsed argv shape produced by `CommandEventMapper`) into a typed
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Pipe-friendly stdout primitives for the CLI. Use this when you need to emit text that
3
+ * a user might redirect or pipe — help banners, command tables, JSON dumps — and the
4
+ * `LogHandler` pipeline would be wrong because it can be severity-gated, routed to
5
+ * stderr per-severity, or fanned out to file/Sentry transports. For event narration
6
+ * ("Compiling X", "Server started"), use `LogHandler` instead.
7
+ */
8
+ export declare class CliOutput {
9
+ /**
10
+ * Writes a message to stdout without a newline.
11
+ */
12
+ write(message: string): void;
13
+ /**
14
+ * Writes a message to stdout with a newline.
15
+ */
16
+ writeLine(message: string): void;
17
+ /**
18
+ * Renders an array of objects as a table using Node's `console.table`.
19
+ */
20
+ writeTable(rows: any[]): void;
21
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Inline progress bar rendered on the current TTY line. Each call clears and redraws
3
+ * the line, so callers must not interleave other output (LogHandler narration, raw
4
+ * CliOutput writes, etc.) between updates or the previous bar will be left behind on
5
+ * the line above.
6
+ */
7
+ export declare class CliProgressBar {
8
+ private static readonly FILLED;
9
+ private static readonly EMPTY;
10
+ private static readonly CYAN;
11
+ private static readonly RESET;
12
+ /**
13
+ * Renders the progress bar at the current line. When `current >= total` the cursor
14
+ * is advanced to the next line so subsequent output doesn't overwrite the finished bar.
15
+ */
16
+ update(current: number, total: number, message?: string, width?: number): void;
17
+ }
@@ -0,0 +1,22 @@
1
+ import { ConsoleReadlineOptions } from "../options/console-readline.options";
2
+ /**
3
+ * Interactive stdin reader for CLI commands. Wraps Node's `readline/promises` and offers
4
+ * a single `readLine` method with optional masking after input is received.
5
+ */
6
+ export declare class CliPrompt {
7
+ /**
8
+ * Reads a string from stdin synchronously. Returns whatever `process.stdin.read()`
9
+ * gives back (which may be `null` when no data is buffered).
10
+ */
11
+ read(): string;
12
+ /**
13
+ * Reads a line from stdin after displaying a prompt. When
14
+ * `options.showCharactersOnTyping` is false, the answered line is cleared and replaced
15
+ * with a masked echo so the typed value isn't left visible on screen.
16
+ *
17
+ * Note: this is not a true keystroke-suppressing password input — Node's stock
18
+ * `readline` does not support that without raw-mode handling. The current behavior is
19
+ * a post-input clear, sufficient for most CLI prompts.
20
+ */
21
+ readLine(question: string, options?: ConsoleReadlineOptions): Promise<string>;
22
+ }
@@ -0,0 +1,34 @@
1
+ import { LogHandlerInterface } from "@pristine-ts/logging";
2
+ /**
3
+ * Animated spinner for indicating long-running work in a TTY. Hides the cursor while
4
+ * spinning, redraws the current line every 80ms, and routes the completion message
5
+ * through the injected `LogHandler` so success/failure rendering matches the rest of
6
+ * the framework.
7
+ *
8
+ * Avoid emitting other output (especially LogHandler narration) while the spinner is
9
+ * active — concurrent writes will fight the spinner's line clearing and produce visual
10
+ * artifacts.
11
+ */
12
+ export declare class CliSpinner {
13
+ private readonly logHandler;
14
+ private spinnerInterval;
15
+ private isSpinning;
16
+ private static readonly FRAMES;
17
+ private static readonly FRAME_INTERVAL_MS;
18
+ private static readonly CYAN;
19
+ private static readonly RESET;
20
+ private static readonly HIDE_CURSOR;
21
+ private static readonly SHOW_CURSOR;
22
+ constructor(logHandler: LogHandlerInterface);
23
+ /**
24
+ * Starts the spinner with the given label. Subsequent calls are no-ops until `stop()`
25
+ * is invoked.
26
+ */
27
+ start(message: string): void;
28
+ /**
29
+ * Stops the spinner, restores the cursor, and optionally emits a final completion
30
+ * message. `success` controls whether the message is rendered as a success log
31
+ * (`logHandler.success`) or an error log (`logHandler.error`).
32
+ */
33
+ stop(message?: string, success?: boolean): void;
34
+ }
@@ -1,2 +1,5 @@
1
- export * from "./console.manager";
1
+ export * from "./cli-output.manager";
2
+ export * from "./cli-progress-bar.manager";
3
+ export * from "./cli-prompt.manager";
4
+ export * from "./cli-spinner.manager";
2
5
  export * from "./shell.manager";
@@ -1,12 +1,12 @@
1
1
  import { ChildProcessWithoutNullStreams } from "child_process";
2
- import { ConsoleManager } from "./console.manager";
3
2
  import { PathManager } from "@pristine-ts/core";
4
3
  import { DateUtil } from "@pristine-ts/common";
4
+ import { LogHandlerInterface } from "@pristine-ts/logging";
5
5
  export declare class ShellManager {
6
- private readonly consoleManager;
6
+ private readonly logHandler;
7
7
  private readonly pathManager;
8
8
  private readonly dateUtil;
9
- constructor(consoleManager: ConsoleManager, pathManager: PathManager, dateUtil: DateUtil);
9
+ constructor(logHandler: LogHandlerInterface, pathManager: PathManager, dateUtil: DateUtil);
10
10
  execute(command: string, options?: {
11
11
  directory?: string;
12
12
  streamStdout?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pristine-ts/cli",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "",
5
5
  "module": "dist/lib/esm/cli.module.js",
6
6
  "main": "dist/lib/cjs/cli.module.js",
@@ -25,13 +25,13 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@inquirer/prompts": "^7.2.0",
28
- "@pristine-ts/common": "^2.0.5",
29
- "@pristine-ts/core": "^2.0.5",
30
- "@pristine-ts/data-mapping": "^2.0.5",
31
- "@pristine-ts/data-mapping-common": "^2.0.5",
32
- "@pristine-ts/file": "^2.0.5",
33
- "@pristine-ts/logging": "^2.0.5",
34
- "@pristine-ts/validation": "^2.0.5",
28
+ "@pristine-ts/common": "^2.0.7",
29
+ "@pristine-ts/core": "^2.0.7",
30
+ "@pristine-ts/data-mapping": "^2.0.7",
31
+ "@pristine-ts/data-mapping-common": "^2.0.7",
32
+ "@pristine-ts/file": "^2.0.7",
33
+ "@pristine-ts/logging": "^2.0.7",
34
+ "@pristine-ts/validation": "^2.0.7",
35
35
  "jiti": "^2.4.0",
36
36
  "uuid": "^9.0.1"
37
37
  },
@@ -72,7 +72,7 @@
72
72
  "src/*.{js,ts}"
73
73
  ]
74
74
  },
75
- "gitHead": "9a960b330ee1961bb9a6151ce50257c4d8ccd48d",
75
+ "gitHead": "8788c711f72b7ebdcec76bc8f6a56d51af143087",
76
76
  "repository": {
77
77
  "type": "git",
78
78
  "url": "https://github.com/magieno/pristine-ts.git",
@@ -1,277 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
42
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
43
- return new (P || (P = Promise))(function (resolve, reject) {
44
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
45
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
46
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
47
- step((generator = generator.apply(thisArg, _arguments || [])).next());
48
- });
49
- };
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.ConsoleManager = void 0;
52
- const tsyringe_1 = require("tsyringe");
53
- const common_1 = require("@pristine-ts/common");
54
- const cli_module_keyname_1 = require("../cli.module.keyname");
55
- const readline = __importStar(require("node:readline/promises"));
56
- const node_readline_1 = require("node:readline");
57
- const node_process_1 = require("node:process");
58
- const console_readline_options_1 = require("../options/console-readline.options");
59
- /**
60
- * ANSI Escape Codes for formatting
61
- */
62
- const Colors = {
63
- Reset: "\x1b[0m",
64
- Bright: "\x1b[1m",
65
- Dim: "\x1b[2m",
66
- Underscore: "\x1b[4m",
67
- Blink: "\x1b[5m",
68
- Reverse: "\x1b[7m",
69
- Hidden: "\x1b[8m",
70
- FgBlack: "\x1b[30m",
71
- FgRed: "\x1b[31m",
72
- FgGreen: "\x1b[32m",
73
- FgYellow: "\x1b[33m",
74
- FgBlue: "\x1b[34m",
75
- FgMagenta: "\x1b[35m",
76
- FgCyan: "\x1b[36m",
77
- FgWhite: "\x1b[37m",
78
- };
79
- let ConsoleManager = class ConsoleManager {
80
- constructor() {
81
- this.spinnerInterval = null;
82
- this.isSpinning = false;
83
- }
84
- /**
85
- * Writes a message to stdout without a newline.
86
- * @param message The message to write.
87
- */
88
- write(message) {
89
- process.stdout.write(message);
90
- }
91
- /**
92
- * Writes a message to stdout with a newline.
93
- * @param message The message to write.
94
- */
95
- writeLine(message) {
96
- this.write(message + "\n");
97
- }
98
- /**
99
- * Writes a table to stdout.
100
- * @param table The array of objects to display as a table.
101
- */
102
- writeTable(table) {
103
- console.table(table);
104
- }
105
- /**
106
- * Writes an error message in red with an 'Error:' prefix.
107
- * @param message The error message to display.
108
- */
109
- writeError(message) {
110
- this.writeLine(`${Colors.FgRed}✖ Error:${Colors.Reset} ${message}`);
111
- }
112
- /**
113
- * Writes a success message in green with a 'Success:' prefix.
114
- * @param message The success message to display.
115
- */
116
- writeSuccess(message) {
117
- this.writeLine(`${Colors.FgGreen}✔ Success:${Colors.Reset} ${message}`);
118
- }
119
- /**
120
- * Writes a warning message in yellow with a 'Warning:' prefix.
121
- * @param message The warning message to display.
122
- */
123
- writeWarning(message) {
124
- this.writeLine(`${Colors.FgYellow}⚠ Warning:${Colors.Reset} ${message}`);
125
- }
126
- /**
127
- * Writes an info message in cyan with an 'Info:' prefix.
128
- * @param message The info message to display.
129
- */
130
- writeInfo(message) {
131
- this.writeLine(`${Colors.FgCyan}ℹ Info:${Colors.Reset} ${message}`);
132
- }
133
- /**
134
- * Starts a loading spinner with a message.
135
- *
136
- * @param message The message to display next to the spinner.
137
- * @remarks
138
- * This method hides the cursor and continuously updates the current line.
139
- * Avoid calling other write methods while the spinner is active as they may conflict with the spinner's line clearing.
140
- */
141
- startSpinner(message) {
142
- if (this.isSpinning)
143
- return;
144
- this.isSpinning = true;
145
- const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
146
- let i = 0;
147
- process.stdout.write('\x1B[?25l'); // Hide cursor
148
- this.spinnerInterval = setInterval(() => {
149
- (0, node_readline_1.clearLine)(process.stdout, 0);
150
- (0, node_readline_1.cursorTo)(process.stdout, 0);
151
- const frame = frames[i = (i + 1) % frames.length];
152
- process.stdout.write(`${Colors.FgCyan}${frame}${Colors.Reset} ${message}`);
153
- }, 80);
154
- }
155
- /**
156
- * Stops the loading spinner and optionally prints a completion message.
157
- *
158
- * @param message Optional completion message to display.
159
- * @param success Whether the operation was successful. Defaults to true.
160
- * @remarks
161
- * Stops the spinner, shows the cursor, and prints a final success or error message on the same line.
162
- */
163
- stopSpinner(message, success = true) {
164
- if (!this.isSpinning)
165
- return;
166
- if (this.spinnerInterval) {
167
- clearInterval(this.spinnerInterval);
168
- this.spinnerInterval = null;
169
- }
170
- this.isSpinning = false;
171
- (0, node_readline_1.clearLine)(process.stdout, 0);
172
- (0, node_readline_1.cursorTo)(process.stdout, 0);
173
- process.stdout.write('\x1B[?25h'); // Show cursor
174
- if (message) {
175
- if (success) {
176
- this.writeSuccess(message);
177
- }
178
- else {
179
- this.writeError(message);
180
- }
181
- }
182
- }
183
- /**
184
- * Displays or updates a progress bar.
185
- *
186
- * @param current The current progress value.
187
- * @param total The total value to reach (100%).
188
- * @param message Optional message to display next to the bar.
189
- * @param width The visual width of the progress bar in characters. Defaults to 30.
190
- *
191
- * @remarks
192
- * This method clears the *current* line and writes the progress bar.
193
- *
194
- * **Important:** If you call `writeLine()` (or any other method that outputs a newline) between calls to `updateProgressBar()`,
195
- * the next call to `updateProgressBar()` will start on the *new* line, leaving the previous progress bar state on the line above.
196
- *
197
- * **Example of creating artifacts:**
198
- * ```typescript
199
- * manager.updateProgressBar(10, 100); // Draws bar at line N
200
- * manager.writeLine("Log message"); // Moves cursor to line N+1
201
- * manager.updateProgressBar(20, 100); // Draws bar at line N+1 (Line N has the old bar)
202
- * ```
203
- */
204
- updateProgressBar(current, total, message = '', width = 30) {
205
- const percentage = Math.min(Math.max(current / total, 0), 1);
206
- const filledWidth = Math.round(width * percentage);
207
- const emptyWidth = width - filledWidth;
208
- const filledBar = '█'.repeat(filledWidth);
209
- const emptyBar = '░'.repeat(emptyWidth);
210
- (0, node_readline_1.clearLine)(process.stdout, 0);
211
- (0, node_readline_1.cursorTo)(process.stdout, 0);
212
- process.stdout.write(`${Colors.FgCyan}[${filledBar}${emptyBar}]${Colors.Reset} ${Math.round(percentage * 100)}% ${message}`);
213
- if (current >= total) {
214
- this.writeLine(''); // New line on completion
215
- }
216
- }
217
- /**
218
- * Reads a string from stdin.
219
- * @returns The raw string read from stdin.
220
- */
221
- read() {
222
- return process.stdin.read();
223
- }
224
- /**
225
- * Reads a line from stdin with a prompt.
226
- *
227
- * @param question The prompt text to display.
228
- * @param options Configuration options for the input (e.g., masking characters).
229
- * @returns A promise resolving to the user's input string.
230
- */
231
- readLine(question_1) {
232
- return __awaiter(this, arguments, void 0, function* (question, options = new console_readline_options_1.ConsoleReadlineOptions()) {
233
- const rl = readline.createInterface({ input: node_process_1.stdin, output: node_process_1.stdout });
234
- // If we want to hide characters (e.g. for password), we need to handle output manually-ish,
235
- // but readline.question prints the prompt and then echoes input.
236
- // A simple hack for passwords with standard readline is tricky without a dedicated library.
237
- // However, we can use the 'mute' approach or simple overwriting if we accept some limitations.
238
- // For now, adhering to the basic 'question' promise but supporting the 'showCharactersOnTyping' flag logic.
239
- let queryPromise;
240
- if (!options.showCharactersOnTyping) {
241
- // Simple implementation: Ask question, but when user types, we can't easily intercept 'echo' with just createInterface
242
- // unless we use a custom input stream or 'muted-stdout' pattern.
243
- // Given constraint of no external libraries, we will use a basic workaround:
244
- // We will output the question, set stdin to raw mode if possible (for true hiding)
245
- // OR just use the moveCursor trick the previous code had, although that is flaky.
246
- //
247
- // Let's rely on the previous implementation's logic:
248
- // The previous code did `moveCursor(output, 0, -1)` AFTER the answer was received.
249
- // This clears the line AFTER typing. It doesn't hide it WHILE typing.
250
- // Real password masking is complex in Node without libs.
251
- // We will stick to the previous logic but ensure it's robust.
252
- queryPromise = rl.question(question);
253
- }
254
- else {
255
- queryPromise = rl.question(question);
256
- }
257
- const answer = yield queryPromise;
258
- if (!options.showCharactersOnTyping) {
259
- // Move up one line and clear it to hide the password typed
260
- (0, node_readline_1.moveCursor)(node_process_1.stdout, 0, -1);
261
- (0, node_readline_1.clearLine)(node_process_1.stdout, 0);
262
- // We might want to re-print the question without the answer?
263
- // Or just leave it cleared. The previous code just moved cursor.
264
- // Let's just print a confirmation.
265
- this.writeLine(`${question} [******]`);
266
- }
267
- rl.close();
268
- return answer;
269
- });
270
- }
271
- };
272
- exports.ConsoleManager = ConsoleManager;
273
- exports.ConsoleManager = ConsoleManager = __decorate([
274
- (0, tsyringe_1.injectable)(),
275
- (0, common_1.moduleScoped)(cli_module_keyname_1.CliModuleKeyname)
276
- ], ConsoleManager);
277
- //# sourceMappingURL=console.manager.js.map