@pristine-ts/cli 2.0.16 → 2.0.18

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 (142) hide show
  1. package/dist/lib/cjs/bin.js +0 -0
  2. package/dist/lib/cjs/cli.configuration-keys.js +6 -0
  3. package/dist/lib/cjs/cli.configuration-keys.js.map +1 -1
  4. package/dist/lib/cjs/cli.module.js +13 -0
  5. package/dist/lib/cjs/cli.module.js.map +1 -1
  6. package/dist/lib/cjs/errors/cli-error-code.enum.js +10 -0
  7. package/dist/lib/cjs/errors/cli-error-code.enum.js.map +1 -1
  8. package/dist/lib/cjs/interfaces/command-parameter-choice.interface.js +3 -0
  9. package/dist/lib/cjs/interfaces/command-parameter-choice.interface.js.map +1 -0
  10. package/dist/lib/cjs/interfaces/command-parameter-choices-context.interface.js +3 -0
  11. package/dist/lib/cjs/interfaces/command-parameter-choices-context.interface.js.map +1 -0
  12. package/dist/lib/cjs/interfaces/command-parameter-choices-provider.interface.js +3 -0
  13. package/dist/lib/cjs/interfaces/command-parameter-choices-provider.interface.js.map +1 -0
  14. package/dist/lib/cjs/interfaces/interfaces.js +3 -0
  15. package/dist/lib/cjs/interfaces/interfaces.js.map +1 -1
  16. package/dist/lib/cjs/reporters/cli-error.reporter.js +11 -3
  17. package/dist/lib/cjs/reporters/cli-error.reporter.js.map +1 -1
  18. package/dist/lib/cjs/services/command-argument-error-formatter.js +146 -0
  19. package/dist/lib/cjs/services/command-argument-error-formatter.js.map +1 -0
  20. package/dist/lib/cjs/services/command-argument-resolver.js +1 -1
  21. package/dist/lib/cjs/services/command-argument-resolver.js.map +1 -1
  22. package/dist/lib/cjs/services/command-options-resolver.js +30 -37
  23. package/dist/lib/cjs/services/command-options-resolver.js.map +1 -1
  24. package/dist/lib/cjs/services/command-parameter-prompter.js +118 -38
  25. package/dist/lib/cjs/services/command-parameter-prompter.js.map +1 -1
  26. package/dist/lib/cjs/services/command-usage-renderer.js +81 -0
  27. package/dist/lib/cjs/services/command-usage-renderer.js.map +1 -0
  28. package/dist/lib/cjs/services/program-name-resolver.js +98 -0
  29. package/dist/lib/cjs/services/program-name-resolver.js.map +1 -0
  30. package/dist/lib/cjs/services/services.js +3 -0
  31. package/dist/lib/cjs/services/services.js.map +1 -1
  32. package/dist/lib/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  33. package/dist/lib/cjs/types/command-parameter-choices-list.type.js +3 -0
  34. package/dist/lib/cjs/types/command-parameter-choices-list.type.js.map +1 -0
  35. package/dist/lib/cjs/types/command-parameter-choices-resolver.type.js +3 -0
  36. package/dist/lib/cjs/types/command-parameter-choices-resolver.type.js.map +1 -0
  37. package/dist/lib/cjs/types/command-parameter-choices.type.js +3 -0
  38. package/dist/lib/cjs/types/command-parameter-choices.type.js.map +1 -0
  39. package/dist/lib/cjs/types/types.js +3 -0
  40. package/dist/lib/cjs/types/types.js.map +1 -1
  41. package/dist/lib/esm/cli.configuration-keys.js +6 -0
  42. package/dist/lib/esm/cli.configuration-keys.js.map +1 -1
  43. package/dist/lib/esm/cli.module.js +13 -0
  44. package/dist/lib/esm/cli.module.js.map +1 -1
  45. package/dist/lib/esm/errors/cli-error-code.enum.js +10 -0
  46. package/dist/lib/esm/errors/cli-error-code.enum.js.map +1 -1
  47. package/dist/lib/esm/interfaces/command-parameter-choice.interface.js +2 -0
  48. package/dist/lib/esm/interfaces/command-parameter-choice.interface.js.map +1 -0
  49. package/dist/lib/esm/interfaces/command-parameter-choices-context.interface.js +2 -0
  50. package/dist/lib/esm/interfaces/command-parameter-choices-context.interface.js.map +1 -0
  51. package/dist/lib/esm/interfaces/command-parameter-choices-provider.interface.js +2 -0
  52. package/dist/lib/esm/interfaces/command-parameter-choices-provider.interface.js.map +1 -0
  53. package/dist/lib/esm/interfaces/interfaces.js +3 -0
  54. package/dist/lib/esm/interfaces/interfaces.js.map +1 -1
  55. package/dist/lib/esm/reporters/cli-error.reporter.js +11 -3
  56. package/dist/lib/esm/reporters/cli-error.reporter.js.map +1 -1
  57. package/dist/lib/esm/services/command-argument-error-formatter.js +143 -0
  58. package/dist/lib/esm/services/command-argument-error-formatter.js.map +1 -0
  59. package/dist/lib/esm/services/command-argument-resolver.js +1 -1
  60. package/dist/lib/esm/services/command-argument-resolver.js.map +1 -1
  61. package/dist/lib/esm/services/command-options-resolver.js +31 -38
  62. package/dist/lib/esm/services/command-options-resolver.js.map +1 -1
  63. package/dist/lib/esm/services/command-parameter-prompter.js +120 -40
  64. package/dist/lib/esm/services/command-parameter-prompter.js.map +1 -1
  65. package/dist/lib/esm/services/command-usage-renderer.js +78 -0
  66. package/dist/lib/esm/services/command-usage-renderer.js.map +1 -0
  67. package/dist/lib/esm/services/program-name-resolver.js +62 -0
  68. package/dist/lib/esm/services/program-name-resolver.js.map +1 -0
  69. package/dist/lib/esm/services/services.js +3 -0
  70. package/dist/lib/esm/services/services.js.map +1 -1
  71. package/dist/lib/esm/tsconfig.tsbuildinfo +1 -1
  72. package/dist/lib/esm/types/command-parameter-choices-list.type.js +2 -0
  73. package/dist/lib/esm/types/command-parameter-choices-list.type.js.map +1 -0
  74. package/dist/lib/esm/types/command-parameter-choices-resolver.type.js +2 -0
  75. package/dist/lib/esm/types/command-parameter-choices-resolver.type.js.map +1 -0
  76. package/dist/lib/esm/types/command-parameter-choices.type.js +2 -0
  77. package/dist/lib/esm/types/command-parameter-choices.type.js.map +1 -0
  78. package/dist/lib/esm/types/types.js +3 -0
  79. package/dist/lib/esm/types/types.js.map +1 -1
  80. package/dist/types/cli.configuration-keys.d.ts +7 -0
  81. package/dist/types/errors/cli-error-code.enum.d.ts +10 -0
  82. package/dist/types/interfaces/command-parameter-choice.interface.d.ts +14 -0
  83. package/dist/types/interfaces/command-parameter-choices-context.interface.d.ts +17 -0
  84. package/dist/types/interfaces/command-parameter-choices-provider.interface.d.ts +20 -0
  85. package/dist/types/interfaces/interfaces.d.ts +3 -0
  86. package/dist/types/options/command-parameter.options.d.ts +30 -0
  87. package/dist/types/services/command-argument-error-formatter.d.ts +64 -0
  88. package/dist/types/services/command-options-resolver.d.ts +23 -13
  89. package/dist/types/services/command-parameter-prompter.d.ts +60 -31
  90. package/dist/types/services/command-usage-renderer.d.ts +35 -0
  91. package/dist/types/services/program-name-resolver.d.ts +21 -0
  92. package/dist/types/services/services.d.ts +3 -0
  93. package/dist/types/types/command-parameter-choices-list.type.d.ts +6 -0
  94. package/dist/types/types/command-parameter-choices-resolver.type.d.ts +9 -0
  95. package/dist/types/types/command-parameter-choices.type.d.ts +19 -0
  96. package/dist/types/types/types.d.ts +3 -0
  97. package/package.json +12 -12
  98. package/dist/lib/cjs/bootstrap/app-module-cache.js +0 -71
  99. package/dist/lib/cjs/bootstrap/app-module-cache.js.map +0 -1
  100. package/dist/lib/cjs/bootstrap/app-module-discoverer.js +0 -119
  101. package/dist/lib/cjs/bootstrap/app-module-discoverer.js.map +0 -1
  102. package/dist/lib/cjs/bootstrap/app-module-discovery-candidate.js +0 -21
  103. package/dist/lib/cjs/bootstrap/app-module-discovery-candidate.js.map +0 -1
  104. package/dist/lib/cjs/bootstrap/app-module-discovery-reason.enum.js +0 -15
  105. package/dist/lib/cjs/bootstrap/app-module-discovery-reason.enum.js.map +0 -1
  106. package/dist/lib/cjs/bootstrap/app-module-prompt.js +0 -78
  107. package/dist/lib/cjs/bootstrap/app-module-prompt.js.map +0 -1
  108. package/dist/lib/cjs/commands/config-init.command.js +0 -133
  109. package/dist/lib/cjs/commands/config-init.command.js.map +0 -1
  110. package/dist/lib/cjs/enums/exit-code.enum.js +0 -9
  111. package/dist/lib/cjs/enums/exit-code.enum.js.map +0 -1
  112. package/dist/lib/cjs/managers/console.manager.js +0 -277
  113. package/dist/lib/cjs/managers/console.manager.js.map +0 -1
  114. package/dist/lib/cjs/managers/repl-session.js +0 -251
  115. package/dist/lib/cjs/managers/repl-session.js.map +0 -1
  116. package/dist/lib/esm/bootstrap/app-module-cache.js +0 -65
  117. package/dist/lib/esm/bootstrap/app-module-cache.js.map +0 -1
  118. package/dist/lib/esm/bootstrap/app-module-discoverer.js +0 -113
  119. package/dist/lib/esm/bootstrap/app-module-discoverer.js.map +0 -1
  120. package/dist/lib/esm/bootstrap/app-module-discovery-candidate.js +0 -17
  121. package/dist/lib/esm/bootstrap/app-module-discovery-candidate.js.map +0 -1
  122. package/dist/lib/esm/bootstrap/app-module-discovery-reason.enum.js +0 -12
  123. package/dist/lib/esm/bootstrap/app-module-discovery-reason.enum.js.map +0 -1
  124. package/dist/lib/esm/bootstrap/app-module-prompt.js +0 -75
  125. package/dist/lib/esm/bootstrap/app-module-prompt.js.map +0 -1
  126. package/dist/lib/esm/commands/config-init.command.js +0 -127
  127. package/dist/lib/esm/commands/config-init.command.js.map +0 -1
  128. package/dist/lib/esm/enums/exit-code.enum.js +0 -6
  129. package/dist/lib/esm/enums/exit-code.enum.js.map +0 -1
  130. package/dist/lib/esm/managers/console.manager.js +0 -241
  131. package/dist/lib/esm/managers/console.manager.js.map +0 -1
  132. package/dist/lib/esm/managers/repl-session.js +0 -215
  133. package/dist/lib/esm/managers/repl-session.js.map +0 -1
  134. package/dist/types/bootstrap/app-module-cache.d.ts +0 -15
  135. package/dist/types/bootstrap/app-module-discoverer.d.ts +0 -30
  136. package/dist/types/bootstrap/app-module-discovery-candidate.d.ts +0 -18
  137. package/dist/types/bootstrap/app-module-discovery-reason.enum.d.ts +0 -10
  138. package/dist/types/bootstrap/app-module-prompt.d.ts +0 -20
  139. package/dist/types/commands/config-init.command.d.ts +0 -18
  140. package/dist/types/enums/exit-code.enum.d.ts +0 -4
  141. package/dist/types/managers/console.manager.d.ts +0 -93
  142. package/dist/types/managers/repl-session.d.ts +0 -62
@@ -1,113 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- import { injectable } from "tsyringe";
17
- import fs from "fs";
18
- import path from "path";
19
- import { AppModuleDiscoveryCandidate } from "./app-module-discovery-candidate";
20
- import { AppModuleDiscoveryReasonEnum } from "./app-module-discovery-reason.enum";
21
- /**
22
- * Scans well-known directories for files that look like AppModule definitions. Non-recursive
23
- * (each search root is scanned at depth 1 only) so it stays fast on large repos and predictable
24
- * when users have many nested module files.
25
- *
26
- * A file is a candidate when:
27
- * - its filename matches `*.module.{js,mjs,cjs}` (and is not a test/spec file), AND
28
- * - either the filename literally matches `app.module.{js,mjs,cjs}` (highest confidence,
29
- * scored 0), OR the file's exports include a symbol named `AppModule` (scored 10).
30
- */
31
- let AppModuleDiscoverer = class AppModuleDiscoverer {
32
- constructor() {
33
- /**
34
- * Search roots scanned for candidates, relative to the project root. Order is intentional:
35
- * compiled output first (most likely runtime entry), then build/, then the project root
36
- * itself for trivial single-file demos.
37
- */
38
- this.searchRoots = [
39
- "dist",
40
- "dist/lib/cjs",
41
- "dist/lib/esm",
42
- "build",
43
- ".",
44
- ];
45
- this.moduleFileRegex = /^[A-Za-z0-9._-]+\.module\.(js|mjs|cjs)$/;
46
- this.appModuleNameRegex = /^app\.module\.(js|mjs|cjs)$/i;
47
- }
48
- discover(projectRoot) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const seen = new Set();
51
- const candidates = [];
52
- for (const root of this.searchRoots) {
53
- const dir = path.resolve(projectRoot, root);
54
- if (fs.existsSync(dir) === false || fs.statSync(dir).isDirectory() === false) {
55
- continue;
56
- }
57
- const entries = fs.readdirSync(dir, { withFileTypes: true });
58
- for (const entry of entries) {
59
- if (entry.isFile() === false)
60
- continue;
61
- if (this.moduleFileRegex.test(entry.name) === false)
62
- continue;
63
- if (entry.name.includes(".spec.") || entry.name.includes(".test."))
64
- continue;
65
- const absolutePath = path.resolve(dir, entry.name);
66
- // Same physical file (e.g. dist/app.module.js and dist/lib/cjs/app.module.js pointing
67
- // at duplicated builds) — keep the first occurrence (which respects searchRoots order).
68
- if (seen.has(absolutePath))
69
- continue;
70
- seen.add(absolutePath);
71
- const displayPath = path.relative(projectRoot, absolutePath);
72
- if (this.appModuleNameRegex.test(entry.name)) {
73
- candidates.push(new AppModuleDiscoveryCandidate(absolutePath, displayPath, 0, AppModuleDiscoveryReasonEnum.Named));
74
- continue;
75
- }
76
- if (this.exportsAppModule(absolutePath)) {
77
- candidates.push(new AppModuleDiscoveryCandidate(absolutePath, displayPath, 10, AppModuleDiscoveryReasonEnum.Exports));
78
- }
79
- }
80
- }
81
- candidates.sort((a, b) => {
82
- if (a.score !== b.score)
83
- return a.score - b.score;
84
- return a.displayPath.localeCompare(b.displayPath);
85
- });
86
- return candidates;
87
- });
88
- }
89
- /**
90
- * Synchronous probe: does this file's exports include an `AppModule` symbol? Uses
91
- * `require()` rather than dynamic `import()` because (a) we only accept `.js/.mjs/.cjs`
92
- * whose CJS variants load synchronously, and (b) discarded probes shouldn't hold open
93
- * `import()` promises.
94
- * @private
95
- */
96
- exportsAppModule(absolutePath) {
97
- try {
98
- // eslint-disable-next-line @typescript-eslint/no-var-requires
99
- const loaded = require(absolutePath);
100
- return loaded !== null && typeof loaded === "object" && "AppModule" in loaded;
101
- }
102
- catch (_a) {
103
- // Treat unreadable / unloadable files as non-candidates — the loader couldn't open them
104
- // either, so they cannot be the AppModule.
105
- return false;
106
- }
107
- }
108
- };
109
- AppModuleDiscoverer = __decorate([
110
- injectable()
111
- ], AppModuleDiscoverer);
112
- export { AppModuleDiscoverer };
113
- //# sourceMappingURL=app-module-discoverer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-module-discoverer.js","sourceRoot":"","sources":["../../../../src/bootstrap/app-module-discoverer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AAEhF;;;;;;;;;GASG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAAzB;QACL;;;;WAIG;QACc,gBAAW,GAA0B;YACpD,MAAM;YACN,cAAc;YACd,cAAc;YACd,OAAO;YACP,GAAG;SACJ,CAAC;QAEe,oBAAe,GAAG,yCAAyC,CAAC;QAC5D,uBAAkB,GAAG,8BAA8B,CAAC;IA+DvE,CAAC;IA7DO,QAAQ,CAAC,WAAmB;;YAChC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;YAC/B,MAAM,UAAU,GAAkC,EAAE,CAAC;YAErD,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACpC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAC5C,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK,EAAE,CAAC;oBAC7E,SAAS;gBACX,CAAC;gBA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AED,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACvB,IAAI,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;oBAAE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;gBAClD,OAAO,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;YAEH,OAAO,UAAU,CAAC;QACpB,CAAC;KAAA;IAED;;;;;;OAMG;IACK,gBAAgB,CAAC,YAAoB;QAC3C,IAAI,CAAC;YACH,8DAA8D;YAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;YACrC,OAAO,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,WAAW,IAAI,MAAM,CAAC;QAChF,CAAC;QAAC,WAAM,CAAC;YACP,wFAAwF;YACxF,2CAA2C;YAC3C,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAA;AA9EY,mBAAmB;IAD/B,UAAU,EAAE;GACA,mBAAmB,CA8E/B"}
@@ -1,17 +0,0 @@
1
- /**
2
- * A plausible AppModule found by the convention-based scan. Lower `score` beats higher;
3
- * ties are ambiguous and trigger the disambiguation prompt.
4
- */
5
- export class AppModuleDiscoveryCandidate {
6
- constructor(absolutePath,
7
- /** Path relative to the project root. Used purely for human-facing display. */
8
- displayPath,
9
- /** Lower = better. Files literally named `app.module.*` get 0; AppModule-exporting `*.module.*` files get 10. */
10
- score, reason) {
11
- this.absolutePath = absolutePath;
12
- this.displayPath = displayPath;
13
- this.score = score;
14
- this.reason = reason;
15
- }
16
- }
17
- //# sourceMappingURL=app-module-discovery-candidate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-module-discovery-candidate.js","sourceRoot":"","sources":["../../../../src/bootstrap/app-module-discovery-candidate.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IACtC,YACkB,YAAoB;IACpC,+EAA+E;IAC/D,WAAmB;IACnC,iHAAiH;IACjG,KAAa,EACb,MAAoC;QALpC,iBAAY,GAAZ,YAAY,CAAQ;QAEpB,gBAAW,GAAX,WAAW,CAAQ;QAEnB,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAA8B;IAEtD,CAAC;CACF"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Why a candidate file was considered a possible AppModule. Used by the disambiguation prompt
3
- * so the user sees "(matches app.module.*)" vs "(exports AppModule)" alongside each option.
4
- */
5
- export var AppModuleDiscoveryReasonEnum;
6
- (function (AppModuleDiscoveryReasonEnum) {
7
- /** The filename matches `app.module.{js,mjs,cjs}`. Highest confidence. */
8
- AppModuleDiscoveryReasonEnum["Named"] = "named";
9
- /** The filename is `*.module.{js,mjs,cjs}` and the file's exports include an `AppModule` symbol. */
10
- AppModuleDiscoveryReasonEnum["Exports"] = "exports";
11
- })(AppModuleDiscoveryReasonEnum || (AppModuleDiscoveryReasonEnum = {}));
12
- //# sourceMappingURL=app-module-discovery-reason.enum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-module-discovery-reason.enum.js","sourceRoot":"","sources":["../../../../src/bootstrap/app-module-discovery-reason.enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,4BAKX;AALD,WAAY,4BAA4B;IACtC,0EAA0E;IAC1E,+CAAe,CAAA;IACf,oGAAoG;IACpG,mDAAmB,CAAA;AACrB,CAAC,EALW,4BAA4B,KAA5B,4BAA4B,QAKvC"}
@@ -1,75 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
11
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
12
- return new (P || (P = Promise))(function (resolve, reject) {
13
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
14
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
15
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
16
- step((generator = generator.apply(thisArg, _arguments || [])).next());
17
- });
18
- };
19
- import { injectable } from "tsyringe";
20
- import { AppModuleDiscoveryReasonEnum } from "./app-module-discovery-reason.enum";
21
- import { DynamicImporter } from "./dynamic-importer";
22
- /**
23
- * TTY disambiguation for the AppModule discovery cascade. When multiple equally-ranked
24
- * candidates exist and stdin/stdout are both connected to a real terminal, ask the user
25
- * to pick one. When non-interactive (CI, Docker, redirected stdin), the caller should
26
- * fall back to throwing an actionable error rather than guessing.
27
- *
28
- * `@inquirer/prompts` is dynamic-imported through `DynamicImporter` so the prompt UI
29
- * dependency only loads when actually prompting — keeps non-interactive startup fast and
30
- * avoids paying for inquirer's TTY-detection overhead on every invocation.
31
- */
32
- let AppModulePrompt = class AppModulePrompt {
33
- constructor(dynamicImporter) {
34
- this.dynamicImporter = dynamicImporter;
35
- this.cancelLabel = "Cancel";
36
- }
37
- isInteractive() {
38
- return Boolean(process.stdout.isTTY) && Boolean(process.stdin.isTTY);
39
- }
40
- prompt(candidates) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- const inquirer = yield this.dynamicImporter.import("@inquirer/prompts");
43
- const select = inquirer.select;
44
- try {
45
- const choice = yield select({
46
- message: "Multiple AppModule candidates were found. Which one should pristine load?",
47
- choices: [
48
- ...candidates.map(c => ({
49
- name: `${c.displayPath} ${this.reasonLabel(c.reason)}`,
50
- value: c.absolutePath,
51
- })),
52
- { name: this.cancelLabel, value: null },
53
- ],
54
- });
55
- return choice !== null && choice !== void 0 ? choice : undefined;
56
- }
57
- catch (_a) {
58
- // @inquirer throws on Ctrl+C / SIGINT — treat as a clean abort, not a crash.
59
- return undefined;
60
- }
61
- });
62
- }
63
- reasonLabel(reason) {
64
- switch (reason) {
65
- case AppModuleDiscoveryReasonEnum.Named: return "(matches app.module.*)";
66
- case AppModuleDiscoveryReasonEnum.Exports: return "(exports AppModule)";
67
- }
68
- }
69
- };
70
- AppModulePrompt = __decorate([
71
- injectable(),
72
- __metadata("design:paramtypes", [DynamicImporter])
73
- ], AppModulePrompt);
74
- export { AppModulePrompt };
75
- //# sourceMappingURL=app-module-prompt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"app-module-prompt.js","sourceRoot":"","sources":["../../../../src/bootstrap/app-module-prompt.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AAChF,OAAO,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;;GASG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAG1B,YAA6B,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAF5C,gBAAW,GAAW,QAAQ,CAAC;IAGhD,CAAC;IAED,aAAa;QACX,OAAO,OAAO,CAAE,OAAO,CAAC,MAAc,CAAC,KAAK,CAAC,IAAI,OAAO,CAAE,OAAO,CAAC,KAAa,CAAC,KAAK,CAAC,CAAC;IACzF,CAAC;IAEK,MAAM,CAAC,UAAyC;;YACpD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;YACxE,MAAM,MAAM,GAA4C,QAAQ,CAAC,MAAM,CAAC;YAExE,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC;oBAC1B,OAAO,EAAE,2EAA2E;oBACpF,OAAO,EAAE;wBACP,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;4BACtB,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE;4BACvD,KAAK,EAAE,CAAC,CAAC,YAAY;yBACtB,CAAC,CAAC;wBACH,EAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,EAAC;qBACtC;iBACF,CAAC,CAAC;gBACH,OAAO,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,SAAS,CAAC;YAC7B,CAAC;YAAC,WAAM,CAAC;gBACP,6EAA6E;gBAC7E,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;KAAA;IAEO,WAAW,CAAC,MAAoC;QACtD,QAAQ,MAAM,EAAE,CAAC;YACf,KAAK,4BAA4B,CAAC,KAAK,CAAC,CAAC,OAAO,wBAAwB,CAAC;YACzE,KAAK,4BAA4B,CAAC,OAAO,CAAC,CAAC,OAAO,qBAAqB,CAAC;QAC1E,CAAC;IACH,CAAC;CACF,CAAA;AAtCY,eAAe;IAD3B,UAAU,EAAE;qCAImC,eAAe;GAHlD,eAAe,CAsC3B"}
@@ -1,127 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
11
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
12
- return new (P || (P = Promise))(function (resolve, reject) {
13
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
14
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
15
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
16
- step((generator = generator.apply(thisArg, _arguments || [])).next());
17
- });
18
- };
19
- import fs from "fs";
20
- import path from "path";
21
- import { moduleScoped, ServiceDefinitionTagEnum, tag } from "@pristine-ts/common";
22
- import { injectable } from "tsyringe";
23
- import { ConsoleManager } from "../managers/console.manager";
24
- import { ExitCodeEnum } from "../enums/exit-code.enum";
25
- import { CliModuleKeyname } from "../cli.module.keyname";
26
- /**
27
- * Generates a starter `pristine.config.ts` in the current directory. If the consumer's
28
- * `package.json` already declares `pristine.appModule.path` or `pristine.appModule.cjsPath`,
29
- * the value is migrated into the new config and the user is told to remove the old field.
30
- */
31
- let ConfigInitCommand = class ConfigInitCommand {
32
- constructor(consoleManager) {
33
- this.consoleManager = consoleManager;
34
- this.optionsType = null;
35
- this.name = "p:config:init";
36
- this.description = "Generate a starter pristine.config.ts. Migrates from package.json if present.";
37
- }
38
- run(args) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const projectRoot = process.cwd();
41
- const targetPath = path.resolve(projectRoot, "pristine.config.ts");
42
- if (fs.existsSync(targetPath)) {
43
- this.consoleManager.writeError(`pristine.config.ts already exists at ${targetPath}. Aborting to avoid overwriting.`);
44
- return ExitCodeEnum.Error;
45
- }
46
- const migratedAppModulePath = this.detectExistingAppModulePath(projectRoot);
47
- const body = this.renderConfigTemplate(migratedAppModulePath);
48
- fs.writeFileSync(targetPath, body, "utf8");
49
- this.consoleManager.writeSuccess(`Created ${path.relative(projectRoot, targetPath)}`);
50
- if (migratedAppModulePath !== undefined) {
51
- this.consoleManager.writeInfo(`Migrated 'pristine.appModule' from package.json. ` +
52
- `You can now remove the 'pristine' field from your package.json.`);
53
- }
54
- else {
55
- this.consoleManager.writeInfo("No existing pristine config found in package.json. " +
56
- "Edit pristine.config.ts to point at your AppModule.");
57
- }
58
- return ExitCodeEnum.Success;
59
- });
60
- }
61
- detectExistingAppModulePath(projectRoot) {
62
- var _a;
63
- const packageJson = path.resolve(projectRoot, "package.json");
64
- if (fs.existsSync(packageJson) === false) {
65
- return undefined;
66
- }
67
- let parsed;
68
- try {
69
- parsed = JSON.parse(fs.readFileSync(packageJson, "utf8"));
70
- }
71
- catch (_b) {
72
- return undefined;
73
- }
74
- const appModule = (_a = parsed === null || parsed === void 0 ? void 0 : parsed.pristine) === null || _a === void 0 ? void 0 : _a.appModule;
75
- if ((appModule === null || appModule === void 0 ? void 0 : appModule.path) !== undefined) {
76
- return appModule.path;
77
- }
78
- if ((appModule === null || appModule === void 0 ? void 0 : appModule.cjsPath) !== undefined) {
79
- return appModule.cjsPath;
80
- }
81
- return undefined;
82
- }
83
- renderConfigTemplate(appModulePath) {
84
- const pathLine = appModulePath !== undefined
85
- ? ` path: "${appModulePath}",`
86
- : ` // path: "dist/app.module.js", // <-- point this at your AppModule`;
87
- return `import {defineConfig} from "@pristine-ts/cli";
88
-
89
- /**
90
- * Pristine CLI configuration. See https://github.com/magieno/pristine-ts for the full
91
- * schema reference.
92
- */
93
- export default defineConfig({
94
- appModule: {
95
- ${pathLine}
96
- },
97
-
98
- // build: {
99
- // outDir: "dist",
100
- // tsconfig: "tsconfig.json",
101
- // format: "esm",
102
- // },
103
-
104
- // start: {
105
- // entry: "dist/main.js",
106
- // nodeArgs: ["--enable-source-maps"],
107
- // },
108
-
109
- // plugins: [
110
- // // "@my-org/pristine-cli-extras",
111
- // ],
112
-
113
- // kernelConfiguration: {
114
- // // "pristine.logging.logSeverityLevelConfiguration": 1,
115
- // },
116
- });
117
- `;
118
- }
119
- };
120
- ConfigInitCommand = __decorate([
121
- tag(ServiceDefinitionTagEnum.Command),
122
- moduleScoped(CliModuleKeyname),
123
- injectable(),
124
- __metadata("design:paramtypes", [ConsoleManager])
125
- ], ConfigInitCommand);
126
- export { ConfigInitCommand };
127
- //# sourceMappingURL=config-init.command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-init.command.js","sourceRoot":"","sources":["../../../../src/commands/config-init.command.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,YAAY,EAAE,wBAAwB,EAAE,GAAG,EAAC,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEvD;;;;GAIG;AAII,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAK5B,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAJ3D,gBAAW,GAAG,IAAI,CAAC;QACnB,SAAI,GAAG,eAAe,CAAC;QACvB,gBAAW,GAAG,+EAA+E,CAAC;IAG9F,CAAC;IAEK,GAAG,CAAC,IAAS;;YACjB,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;YAClC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;YAEnE,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE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MAAM,uBAAN,MAAM,CAAE,QAAQ,0CAAE,SAAS,CAAC;QAC9C,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,MAAK,SAAS,EAAE,CAAC;YAClC,OAAO,SAAS,CAAC,IAAI,CAAC;QACxB,CAAC;QACD,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,MAAK,SAAS,EAAE,CAAC;YACrC,OAAO,SAAS,CAAC,OAAO,CAAC;QAC3B,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,oBAAoB,CAAC,aAAiC;QAC5D,MAAM,QAAQ,GAAG,aAAa,KAAK,SAAS;YAC1C,CAAC,CAAC,cAAc,aAAa,IAAI;YACjC,CAAC,CAAC,0EAA0E,CAAC;QAE/E,OAAO;;;;;;;;EAQT,QAAQ;;;;;;;;;;;;;;;;;;;;;;CAsBT,CAAC;IACA,CAAC;CACF,CAAA;AAnGY,iBAAiB;IAH7B,GAAG,CAAC,wBAAwB,CAAC,OAAO,CAAC;IACrC,YAAY,CAAC,gBAAgB,CAAC;IAC9B,UAAU,EAAE;qCAMkC,cAAc;GALhD,iBAAiB,CAmG7B"}
@@ -1,6 +0,0 @@
1
- export var ExitCodeEnum;
2
- (function (ExitCodeEnum) {
3
- ExitCodeEnum[ExitCodeEnum["Success"] = 0] = "Success";
4
- ExitCodeEnum[ExitCodeEnum["Error"] = 1] = "Error";
5
- })(ExitCodeEnum || (ExitCodeEnum = {}));
6
- //# sourceMappingURL=exit-code.enum.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exit-code.enum.js","sourceRoot":"","sources":["../../../../src/enums/exit-code.enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,iDAAS,CAAA;AACX,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB"}
@@ -1,241 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- 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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
8
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
9
- return new (P || (P = Promise))(function (resolve, reject) {
10
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
12
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
13
- step((generator = generator.apply(thisArg, _arguments || [])).next());
14
- });
15
- };
16
- import { injectable } from "tsyringe";
17
- import { moduleScoped } from "@pristine-ts/common";
18
- import { CliModuleKeyname } from "../cli.module.keyname";
19
- import * as readline from 'node:readline/promises';
20
- import { moveCursor, clearLine, cursorTo } from 'node:readline';
21
- import { stdin as input, stdout as output } from 'node:process';
22
- import { ConsoleReadlineOptions } from "../options/console-readline.options";
23
- /**
24
- * ANSI Escape Codes for formatting
25
- */
26
- const Colors = {
27
- Reset: "\x1b[0m",
28
- Bright: "\x1b[1m",
29
- Dim: "\x1b[2m",
30
- Underscore: "\x1b[4m",
31
- Blink: "\x1b[5m",
32
- Reverse: "\x1b[7m",
33
- Hidden: "\x1b[8m",
34
- FgBlack: "\x1b[30m",
35
- FgRed: "\x1b[31m",
36
- FgGreen: "\x1b[32m",
37
- FgYellow: "\x1b[33m",
38
- FgBlue: "\x1b[34m",
39
- FgMagenta: "\x1b[35m",
40
- FgCyan: "\x1b[36m",
41
- FgWhite: "\x1b[37m",
42
- };
43
- let ConsoleManager = class ConsoleManager {
44
- constructor() {
45
- this.spinnerInterval = null;
46
- this.isSpinning = false;
47
- }
48
- /**
49
- * Writes a message to stdout without a newline.
50
- * @param message The message to write.
51
- */
52
- write(message) {
53
- process.stdout.write(message);
54
- }
55
- /**
56
- * Writes a message to stdout with a newline.
57
- * @param message The message to write.
58
- */
59
- writeLine(message) {
60
- this.write(message + "\n");
61
- }
62
- /**
63
- * Writes a table to stdout.
64
- * @param table The array of objects to display as a table.
65
- */
66
- writeTable(table) {
67
- console.table(table);
68
- }
69
- /**
70
- * Writes an error message in red with an 'Error:' prefix.
71
- * @param message The error message to display.
72
- */
73
- writeError(message) {
74
- this.writeLine(`${Colors.FgRed}✖ Error:${Colors.Reset} ${message}`);
75
- }
76
- /**
77
- * Writes a success message in green with a 'Success:' prefix.
78
- * @param message The success message to display.
79
- */
80
- writeSuccess(message) {
81
- this.writeLine(`${Colors.FgGreen}✔ Success:${Colors.Reset} ${message}`);
82
- }
83
- /**
84
- * Writes a warning message in yellow with a 'Warning:' prefix.
85
- * @param message The warning message to display.
86
- */
87
- writeWarning(message) {
88
- this.writeLine(`${Colors.FgYellow}⚠ Warning:${Colors.Reset} ${message}`);
89
- }
90
- /**
91
- * Writes an info message in cyan with an 'Info:' prefix.
92
- * @param message The info message to display.
93
- */
94
- writeInfo(message) {
95
- this.writeLine(`${Colors.FgCyan}ℹ Info:${Colors.Reset} ${message}`);
96
- }
97
- /**
98
- * Starts a loading spinner with a message.
99
- *
100
- * @param message The message to display next to the spinner.
101
- * @remarks
102
- * This method hides the cursor and continuously updates the current line.
103
- * Avoid calling other write methods while the spinner is active as they may conflict with the spinner's line clearing.
104
- */
105
- startSpinner(message) {
106
- if (this.isSpinning)
107
- return;
108
- this.isSpinning = true;
109
- const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
110
- let i = 0;
111
- process.stdout.write('\x1B[?25l'); // Hide cursor
112
- this.spinnerInterval = setInterval(() => {
113
- clearLine(process.stdout, 0);
114
- cursorTo(process.stdout, 0);
115
- const frame = frames[i = (i + 1) % frames.length];
116
- process.stdout.write(`${Colors.FgCyan}${frame}${Colors.Reset} ${message}`);
117
- }, 80);
118
- }
119
- /**
120
- * Stops the loading spinner and optionally prints a completion message.
121
- *
122
- * @param message Optional completion message to display.
123
- * @param success Whether the operation was successful. Defaults to true.
124
- * @remarks
125
- * Stops the spinner, shows the cursor, and prints a final success or error message on the same line.
126
- */
127
- stopSpinner(message, success = true) {
128
- if (!this.isSpinning)
129
- return;
130
- if (this.spinnerInterval) {
131
- clearInterval(this.spinnerInterval);
132
- this.spinnerInterval = null;
133
- }
134
- this.isSpinning = false;
135
- clearLine(process.stdout, 0);
136
- cursorTo(process.stdout, 0);
137
- process.stdout.write('\x1B[?25h'); // Show cursor
138
- if (message) {
139
- if (success) {
140
- this.writeSuccess(message);
141
- }
142
- else {
143
- this.writeError(message);
144
- }
145
- }
146
- }
147
- /**
148
- * Displays or updates a progress bar.
149
- *
150
- * @param current The current progress value.
151
- * @param total The total value to reach (100%).
152
- * @param message Optional message to display next to the bar.
153
- * @param width The visual width of the progress bar in characters. Defaults to 30.
154
- *
155
- * @remarks
156
- * This method clears the *current* line and writes the progress bar.
157
- *
158
- * **Important:** If you call `writeLine()` (or any other method that outputs a newline) between calls to `updateProgressBar()`,
159
- * the next call to `updateProgressBar()` will start on the *new* line, leaving the previous progress bar state on the line above.
160
- *
161
- * **Example of creating artifacts:**
162
- * ```typescript
163
- * manager.updateProgressBar(10, 100); // Draws bar at line N
164
- * manager.writeLine("Log message"); // Moves cursor to line N+1
165
- * manager.updateProgressBar(20, 100); // Draws bar at line N+1 (Line N has the old bar)
166
- * ```
167
- */
168
- updateProgressBar(current, total, message = '', width = 30) {
169
- const percentage = Math.min(Math.max(current / total, 0), 1);
170
- const filledWidth = Math.round(width * percentage);
171
- const emptyWidth = width - filledWidth;
172
- const filledBar = '█'.repeat(filledWidth);
173
- const emptyBar = '░'.repeat(emptyWidth);
174
- clearLine(process.stdout, 0);
175
- cursorTo(process.stdout, 0);
176
- process.stdout.write(`${Colors.FgCyan}[${filledBar}${emptyBar}]${Colors.Reset} ${Math.round(percentage * 100)}% ${message}`);
177
- if (current >= total) {
178
- this.writeLine(''); // New line on completion
179
- }
180
- }
181
- /**
182
- * Reads a string from stdin.
183
- * @returns The raw string read from stdin.
184
- */
185
- read() {
186
- return process.stdin.read();
187
- }
188
- /**
189
- * Reads a line from stdin with a prompt.
190
- *
191
- * @param question The prompt text to display.
192
- * @param options Configuration options for the input (e.g., masking characters).
193
- * @returns A promise resolving to the user's input string.
194
- */
195
- readLine(question_1) {
196
- return __awaiter(this, arguments, void 0, function* (question, options = new ConsoleReadlineOptions()) {
197
- const rl = readline.createInterface({ input, output });
198
- // If we want to hide characters (e.g. for password), we need to handle output manually-ish,
199
- // but readline.question prints the prompt and then echoes input.
200
- // A simple hack for passwords with standard readline is tricky without a dedicated library.
201
- // However, we can use the 'mute' approach or simple overwriting if we accept some limitations.
202
- // For now, adhering to the basic 'question' promise but supporting the 'showCharactersOnTyping' flag logic.
203
- let queryPromise;
204
- if (!options.showCharactersOnTyping) {
205
- // Simple implementation: Ask question, but when user types, we can't easily intercept 'echo' with just createInterface
206
- // unless we use a custom input stream or 'muted-stdout' pattern.
207
- // Given constraint of no external libraries, we will use a basic workaround:
208
- // We will output the question, set stdin to raw mode if possible (for true hiding)
209
- // OR just use the moveCursor trick the previous code had, although that is flaky.
210
- //
211
- // Let's rely on the previous implementation's logic:
212
- // The previous code did `moveCursor(output, 0, -1)` AFTER the answer was received.
213
- // This clears the line AFTER typing. It doesn't hide it WHILE typing.
214
- // Real password masking is complex in Node without libs.
215
- // We will stick to the previous logic but ensure it's robust.
216
- queryPromise = rl.question(question);
217
- }
218
- else {
219
- queryPromise = rl.question(question);
220
- }
221
- const answer = yield queryPromise;
222
- if (!options.showCharactersOnTyping) {
223
- // Move up one line and clear it to hide the password typed
224
- moveCursor(output, 0, -1);
225
- clearLine(output, 0);
226
- // We might want to re-print the question without the answer?
227
- // Or just leave it cleared. The previous code just moved cursor.
228
- // Let's just print a confirmation.
229
- this.writeLine(`${question} [******]`);
230
- }
231
- rl.close();
232
- return answer;
233
- });
234
- }
235
- };
236
- ConsoleManager = __decorate([
237
- injectable(),
238
- moduleScoped(CliModuleKeyname)
239
- ], ConsoleManager);
240
- export { ConsoleManager };
241
- //# sourceMappingURL=console.manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"console.manager.js","sourceRoot":"","sources":["../../../../src/managers/console.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAC,KAAK,IAAI,KAAK,EAAE,MAAM,IAAI,MAAM,EAAC,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;IACjB,GAAG,EAAE,SAAS;IACd,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,SAAS;IAChB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IAEjB,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,UAAU;IACjB,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,UAAU;IAClB,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,UAAU;IAClB,OAAO,EAAE,UAAU;CACpB,CAAC;AAIK,IAAM,cAAc,GAApB,MAAM,c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