@alagoni97/cli 0.72.1

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 (244) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +336 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/dev.mjs +3 -0
  5. package/bin/run.cmd +3 -0
  6. package/bin/run.mjs +4 -0
  7. package/dist/LoggingInterface.d.ts +123 -0
  8. package/dist/LoggingInterface.js +300 -0
  9. package/dist/PersistedConfig.d.ts +46 -0
  10. package/dist/PersistedConfig.js +94 -0
  11. package/dist/browser/adapters/output.d.ts +69 -0
  12. package/dist/browser/adapters/output.js +91 -0
  13. package/dist/browser/config.d.ts +18 -0
  14. package/dist/browser/config.js +59 -0
  15. package/dist/browser/generate.d.ts +20 -0
  16. package/dist/browser/generate.js +129 -0
  17. package/dist/browser/index.d.ts +17 -0
  18. package/dist/browser/index.js +26 -0
  19. package/dist/browser/parser.d.ts +9 -0
  20. package/dist/browser/parser.js +61 -0
  21. package/dist/browser/shims/asyncapi-parser.d.ts +30 -0
  22. package/dist/browser/shims/asyncapi-parser.js +52 -0
  23. package/dist/browser/shims/fs.d.ts +190 -0
  24. package/dist/browser/shims/fs.js +188 -0
  25. package/dist/browser/shims/json-schema-ref-parser.d.ts +73 -0
  26. package/dist/browser/shims/json-schema-ref-parser.js +246 -0
  27. package/dist/browser/shims/swagger-parser.d.ts +20 -0
  28. package/dist/browser/shims/swagger-parser.js +40 -0
  29. package/dist/codegen/configurationSchemaBuilder.d.ts +15 -0
  30. package/dist/codegen/configurationSchemaBuilder.js +48 -0
  31. package/dist/codegen/configurations.d.ts +29 -0
  32. package/dist/codegen/configurations.js +260 -0
  33. package/dist/codegen/detection.d.ts +19 -0
  34. package/dist/codegen/detection.js +174 -0
  35. package/dist/codegen/errors.d.ts +111 -0
  36. package/dist/codegen/errors.js +352 -0
  37. package/dist/codegen/generators/generic/custom.d.ts +75 -0
  38. package/dist/codegen/generators/generic/custom.js +66 -0
  39. package/dist/codegen/generators/index.d.ts +14 -0
  40. package/dist/codegen/generators/index.js +42 -0
  41. package/dist/codegen/generators/typescript/channels/asyncapi.d.ts +10 -0
  42. package/dist/codegen/generators/typescript/channels/asyncapi.js +131 -0
  43. package/dist/codegen/generators/typescript/channels/index.d.ts +8 -0
  44. package/dist/codegen/generators/typescript/channels/index.js +142 -0
  45. package/dist/codegen/generators/typescript/channels/openapi.d.ts +9 -0
  46. package/dist/codegen/generators/typescript/channels/openapi.js +168 -0
  47. package/dist/codegen/generators/typescript/channels/protocols/amqp/index.d.ts +7 -0
  48. package/dist/codegen/generators/typescript/channels/protocols/amqp/index.js +149 -0
  49. package/dist/codegen/generators/typescript/channels/protocols/amqp/publishExchange.d.ts +5 -0
  50. package/dist/codegen/generators/typescript/channels/protocols/amqp/publishExchange.js +106 -0
  51. package/dist/codegen/generators/typescript/channels/protocols/amqp/publishQueue.d.ts +3 -0
  52. package/dist/codegen/generators/typescript/channels/protocols/amqp/publishQueue.js +102 -0
  53. package/dist/codegen/generators/typescript/channels/protocols/amqp/subscribeQueue.d.ts +3 -0
  54. package/dist/codegen/generators/typescript/channels/protocols/amqp/subscribeQueue.js +133 -0
  55. package/dist/codegen/generators/typescript/channels/protocols/eventsource/express.d.ts +3 -0
  56. package/dist/codegen/generators/typescript/channels/protocols/eventsource/express.js +100 -0
  57. package/dist/codegen/generators/typescript/channels/protocols/eventsource/fetch.d.ts +5 -0
  58. package/dist/codegen/generators/typescript/channels/protocols/eventsource/fetch.js +144 -0
  59. package/dist/codegen/generators/typescript/channels/protocols/eventsource/index.d.ts +6 -0
  60. package/dist/codegen/generators/typescript/channels/protocols/eventsource/index.js +132 -0
  61. package/dist/codegen/generators/typescript/channels/protocols/http/client.d.ts +10 -0
  62. package/dist/codegen/generators/typescript/channels/protocols/http/client.js +224 -0
  63. package/dist/codegen/generators/typescript/channels/protocols/http/common-types.d.ts +14 -0
  64. package/dist/codegen/generators/typescript/channels/protocols/http/common-types.js +800 -0
  65. package/dist/codegen/generators/typescript/channels/protocols/http/index.d.ts +8 -0
  66. package/dist/codegen/generators/typescript/channels/protocols/http/index.js +96 -0
  67. package/dist/codegen/generators/typescript/channels/protocols/http/security.d.ts +48 -0
  68. package/dist/codegen/generators/typescript/channels/protocols/http/security.js +491 -0
  69. package/dist/codegen/generators/typescript/channels/protocols/kafka/index.d.ts +6 -0
  70. package/dist/codegen/generators/typescript/channels/protocols/kafka/index.js +127 -0
  71. package/dist/codegen/generators/typescript/channels/protocols/kafka/publish.d.ts +3 -0
  72. package/dist/codegen/generators/typescript/channels/protocols/kafka/publish.js +108 -0
  73. package/dist/codegen/generators/typescript/channels/protocols/kafka/subscribe.d.ts +3 -0
  74. package/dist/codegen/generators/typescript/channels/protocols/kafka/subscribe.js +154 -0
  75. package/dist/codegen/generators/typescript/channels/protocols/kafka/utils.d.ts +11 -0
  76. package/dist/codegen/generators/typescript/channels/protocols/kafka/utils.js +58 -0
  77. package/dist/codegen/generators/typescript/channels/protocols/mqtt/index.d.ts +6 -0
  78. package/dist/codegen/generators/typescript/channels/protocols/mqtt/index.js +113 -0
  79. package/dist/codegen/generators/typescript/channels/protocols/mqtt/publish.d.ts +3 -0
  80. package/dist/codegen/generators/typescript/channels/protocols/mqtt/publish.js +99 -0
  81. package/dist/codegen/generators/typescript/channels/protocols/mqtt/subscribe.d.ts +3 -0
  82. package/dist/codegen/generators/typescript/channels/protocols/mqtt/subscribe.js +186 -0
  83. package/dist/codegen/generators/typescript/channels/protocols/nats/corePublish.d.ts +3 -0
  84. package/dist/codegen/generators/typescript/channels/protocols/nats/corePublish.js +90 -0
  85. package/dist/codegen/generators/typescript/channels/protocols/nats/coreReply.d.ts +3 -0
  86. package/dist/codegen/generators/typescript/channels/protocols/nats/coreReply.js +142 -0
  87. package/dist/codegen/generators/typescript/channels/protocols/nats/coreRequest.d.ts +3 -0
  88. package/dist/codegen/generators/typescript/channels/protocols/nats/coreRequest.js +100 -0
  89. package/dist/codegen/generators/typescript/channels/protocols/nats/coreSubscribe.d.ts +3 -0
  90. package/dist/codegen/generators/typescript/channels/protocols/nats/coreSubscribe.js +143 -0
  91. package/dist/codegen/generators/typescript/channels/protocols/nats/index.d.ts +11 -0
  92. package/dist/codegen/generators/typescript/channels/protocols/nats/index.js +224 -0
  93. package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPublish.d.ts +3 -0
  94. package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPublish.js +89 -0
  95. package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPullSubscribe.d.ts +3 -0
  96. package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPullSubscribe.js +146 -0
  97. package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPushSubscription.d.ts +3 -0
  98. package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPushSubscription.js +149 -0
  99. package/dist/codegen/generators/typescript/channels/protocols/nats/utils.d.ts +35 -0
  100. package/dist/codegen/generators/typescript/channels/protocols/nats/utils.js +120 -0
  101. package/dist/codegen/generators/typescript/channels/protocols/websocket/index.d.ts +7 -0
  102. package/dist/codegen/generators/typescript/channels/protocols/websocket/index.js +152 -0
  103. package/dist/codegen/generators/typescript/channels/protocols/websocket/publish.d.ts +3 -0
  104. package/dist/codegen/generators/typescript/channels/protocols/websocket/publish.js +64 -0
  105. package/dist/codegen/generators/typescript/channels/protocols/websocket/register.d.ts +3 -0
  106. package/dist/codegen/generators/typescript/channels/protocols/websocket/register.js +115 -0
  107. package/dist/codegen/generators/typescript/channels/protocols/websocket/subscribe.d.ts +3 -0
  108. package/dist/codegen/generators/typescript/channels/protocols/websocket/subscribe.js +151 -0
  109. package/dist/codegen/generators/typescript/channels/types.d.ts +181 -0
  110. package/dist/codegen/generators/typescript/channels/types.js +131 -0
  111. package/dist/codegen/generators/typescript/channels/utils.d.ts +64 -0
  112. package/dist/codegen/generators/typescript/channels/utils.js +163 -0
  113. package/dist/codegen/generators/typescript/client/index.d.ts +8 -0
  114. package/dist/codegen/generators/typescript/client/index.js +61 -0
  115. package/dist/codegen/generators/typescript/client/protocols/nats/corePublish.d.ts +6 -0
  116. package/dist/codegen/generators/typescript/client/protocols/nats/corePublish.js +53 -0
  117. package/dist/codegen/generators/typescript/client/protocols/nats/coreSubscribe.d.ts +6 -0
  118. package/dist/codegen/generators/typescript/client/protocols/nats/coreSubscribe.js +90 -0
  119. package/dist/codegen/generators/typescript/client/protocols/nats/jetStreamPullSubscription.d.ts +6 -0
  120. package/dist/codegen/generators/typescript/client/protocols/nats/jetStreamPullSubscription.js +83 -0
  121. package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPublish.d.ts +6 -0
  122. package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPublish.js +54 -0
  123. package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPushSubscription.d.ts +6 -0
  124. package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPushSubscription.js +82 -0
  125. package/dist/codegen/generators/typescript/client/protocols/nats.d.ts +2 -0
  126. package/dist/codegen/generators/typescript/client/protocols/nats.js +182 -0
  127. package/dist/codegen/generators/typescript/client/types.d.ts +49 -0
  128. package/dist/codegen/generators/typescript/client/types.js +37 -0
  129. package/dist/codegen/generators/typescript/headers.d.ts +54 -0
  130. package/dist/codegen/generators/typescript/headers.js +138 -0
  131. package/dist/codegen/generators/typescript/index.d.ts +7 -0
  132. package/dist/codegen/generators/typescript/index.js +38 -0
  133. package/dist/codegen/generators/typescript/models.d.ts +21761 -0
  134. package/dist/codegen/generators/typescript/models.js +64 -0
  135. package/dist/codegen/generators/typescript/parameters.d.ts +37 -0
  136. package/dist/codegen/generators/typescript/parameters.js +101 -0
  137. package/dist/codegen/generators/typescript/payloads.d.ts +73 -0
  138. package/dist/codegen/generators/typescript/payloads.js +250 -0
  139. package/dist/codegen/generators/typescript/types.d.ts +34 -0
  140. package/dist/codegen/generators/typescript/types.js +70 -0
  141. package/dist/codegen/generators/typescript/utils.d.ts +38 -0
  142. package/dist/codegen/generators/typescript/utils.js +195 -0
  143. package/dist/codegen/index.d.ts +7 -0
  144. package/dist/codegen/index.js +38 -0
  145. package/dist/codegen/inputs/asyncapi/generators/headers.d.ts +3 -0
  146. package/dist/codegen/inputs/asyncapi/generators/headers.js +41 -0
  147. package/dist/codegen/inputs/asyncapi/generators/parameters.d.ts +14 -0
  148. package/dist/codegen/inputs/asyncapi/generators/parameters.js +120 -0
  149. package/dist/codegen/inputs/asyncapi/generators/payloads.d.ts +16 -0
  150. package/dist/codegen/inputs/asyncapi/generators/payloads.js +124 -0
  151. package/dist/codegen/inputs/asyncapi/generators/types.d.ts +9 -0
  152. package/dist/codegen/inputs/asyncapi/generators/types.js +61 -0
  153. package/dist/codegen/inputs/asyncapi/index.d.ts +1 -0
  154. package/dist/codegen/inputs/asyncapi/index.js +7 -0
  155. package/dist/codegen/inputs/asyncapi/parser.d.ts +4 -0
  156. package/dist/codegen/inputs/asyncapi/parser.js +90 -0
  157. package/dist/codegen/inputs/index.d.ts +3 -0
  158. package/dist/codegen/inputs/index.js +19 -0
  159. package/dist/codegen/inputs/jsonschema/generators/index.d.ts +1 -0
  160. package/dist/codegen/inputs/jsonschema/generators/index.js +5 -0
  161. package/dist/codegen/inputs/jsonschema/generators/models.d.ts +7 -0
  162. package/dist/codegen/inputs/jsonschema/generators/models.js +26 -0
  163. package/dist/codegen/inputs/jsonschema/index.d.ts +1 -0
  164. package/dist/codegen/inputs/jsonschema/index.js +7 -0
  165. package/dist/codegen/inputs/jsonschema/parser.d.ts +31 -0
  166. package/dist/codegen/inputs/jsonschema/parser.js +128 -0
  167. package/dist/codegen/inputs/openapi/generators/headers.d.ts +3 -0
  168. package/dist/codegen/inputs/openapi/generators/headers.js +101 -0
  169. package/dist/codegen/inputs/openapi/generators/parameters.d.ts +10 -0
  170. package/dist/codegen/inputs/openapi/generators/parameters.js +852 -0
  171. package/dist/codegen/inputs/openapi/generators/payloads.d.ts +3 -0
  172. package/dist/codegen/inputs/openapi/generators/payloads.js +231 -0
  173. package/dist/codegen/inputs/openapi/generators/types.d.ts +9 -0
  174. package/dist/codegen/inputs/openapi/generators/types.js +86 -0
  175. package/dist/codegen/inputs/openapi/index.d.ts +2 -0
  176. package/dist/codegen/inputs/openapi/index.js +8 -0
  177. package/dist/codegen/inputs/openapi/parser.d.ts +4 -0
  178. package/dist/codegen/inputs/openapi/parser.js +115 -0
  179. package/dist/codegen/inputs/openapi/security.d.ts +56 -0
  180. package/dist/codegen/inputs/openapi/security.js +193 -0
  181. package/dist/codegen/modelina/index.d.ts +2 -0
  182. package/dist/codegen/modelina/index.js +20 -0
  183. package/dist/codegen/modelina/presets/index.d.ts +3 -0
  184. package/dist/codegen/modelina/presets/index.js +14 -0
  185. package/dist/codegen/modelina/presets/primitives.d.ts +34 -0
  186. package/dist/codegen/modelina/presets/primitives.js +211 -0
  187. package/dist/codegen/modelina/presets/union.d.ts +33 -0
  188. package/dist/codegen/modelina/presets/union.js +197 -0
  189. package/dist/codegen/modelina/presets/validation.d.ts +66 -0
  190. package/dist/codegen/modelina/presets/validation.js +183 -0
  191. package/dist/codegen/modelina/types.d.ts +61845 -0
  192. package/dist/codegen/modelina/types.js +412 -0
  193. package/dist/codegen/output/filesystem.d.ts +30 -0
  194. package/dist/codegen/output/filesystem.js +61 -0
  195. package/dist/codegen/output/index.d.ts +16 -0
  196. package/dist/codegen/output/index.js +57 -0
  197. package/dist/codegen/output/memory.d.ts +54 -0
  198. package/dist/codegen/output/memory.js +81 -0
  199. package/dist/codegen/output/modelina.d.ts +30 -0
  200. package/dist/codegen/output/modelina.js +30 -0
  201. package/dist/codegen/output/types.d.ts +47 -0
  202. package/dist/codegen/output/types.js +6 -0
  203. package/dist/codegen/renderer.d.ts +13 -0
  204. package/dist/codegen/renderer.js +309 -0
  205. package/dist/codegen/schemaPostProcess.d.ts +25 -0
  206. package/dist/codegen/schemaPostProcess.js +38 -0
  207. package/dist/codegen/types.d.ts +285187 -0
  208. package/dist/codegen/types.js +177 -0
  209. package/dist/codegen/utils.d.ts +126 -0
  210. package/dist/codegen/utils.js +373 -0
  211. package/dist/commands/base.d.ts +18 -0
  212. package/dist/commands/base.js +59 -0
  213. package/dist/commands/generate.d.ts +46 -0
  214. package/dist/commands/generate.js +305 -0
  215. package/dist/commands/init.d.ts +55 -0
  216. package/dist/commands/init.js +544 -0
  217. package/dist/commands/telemetry.d.ts +25 -0
  218. package/dist/commands/telemetry.js +115 -0
  219. package/dist/index.d.ts +29 -0
  220. package/dist/index.js +35 -0
  221. package/dist/telemetry/anonymize.d.ts +19 -0
  222. package/dist/telemetry/anonymize.js +73 -0
  223. package/dist/telemetry/collector.d.ts +26 -0
  224. package/dist/telemetry/collector.js +57 -0
  225. package/dist/telemetry/config.d.ts +32 -0
  226. package/dist/telemetry/config.js +97 -0
  227. package/dist/telemetry/events.d.ts +72 -0
  228. package/dist/telemetry/events.js +5 -0
  229. package/dist/telemetry/index.d.ts +46 -0
  230. package/dist/telemetry/index.js +91 -0
  231. package/dist/telemetry/notice.d.ts +8 -0
  232. package/dist/telemetry/notice.js +50 -0
  233. package/dist/telemetry/sender.d.ts +14 -0
  234. package/dist/telemetry/sender.js +125 -0
  235. package/dist/utils/gitignore.d.ts +66 -0
  236. package/dist/utils/gitignore.js +111 -0
  237. package/dist/utils/inputSource.d.ts +3 -0
  238. package/dist/utils/inputSource.js +26 -0
  239. package/dist/utils/refResolvers.d.ts +29 -0
  240. package/dist/utils/refResolvers.js +83 -0
  241. package/dist/utils/remoteFetch.d.ts +18 -0
  242. package/dist/utils/remoteFetch.js +64 -0
  243. package/oclif.manifest.json +510 -0
  244. package/package.json +155 -0
@@ -0,0 +1,123 @@
1
+ export type LogLevel = 'silent' | 'error' | 'warn' | 'info' | 'verbose' | 'debug';
2
+ /**
3
+ * Logging interface for the model generation library
4
+ */
5
+ export interface LoggingInterface {
6
+ debug(message?: unknown, ...optionalParams: unknown[]): void;
7
+ info(message?: unknown, ...optionalParams: unknown[]): void;
8
+ warn(message?: unknown, ...optionalParams: unknown[]): void;
9
+ error(message?: unknown, ...optionalParams: unknown[]): void;
10
+ }
11
+ /**
12
+ * Extended logging interface with additional capabilities
13
+ */
14
+ export interface ExtendedLoggingInterface extends LoggingInterface {
15
+ verbose(message?: unknown, ...optionalParams: unknown[]): void;
16
+ startSpinner(text: string): void;
17
+ updateSpinner(text: string): void;
18
+ succeedSpinner(text?: string): void;
19
+ failSpinner(text?: string): void;
20
+ stopSpinner(): void;
21
+ json(data: unknown): void;
22
+ setLevel(level: LogLevel): void;
23
+ setJsonMode(enabled: boolean): void;
24
+ setColors(enabled: boolean): void;
25
+ getLevel(): LogLevel;
26
+ isJsonMode(): boolean;
27
+ }
28
+ /**
29
+ * Logger class with enhanced capabilities
30
+ *
31
+ * Supports log levels, colors, spinners, and JSON output mode.
32
+ * Acts as a forefront for any external loggers.
33
+ */
34
+ export declare class LoggerClass implements ExtendedLoggingInterface {
35
+ private logger?;
36
+ private level;
37
+ private jsonMode;
38
+ private colorsEnabled;
39
+ private spinner;
40
+ /**
41
+ * Check if a message at the given level should be logged
42
+ */
43
+ private shouldLog;
44
+ /**
45
+ * Format a message with optional color
46
+ */
47
+ private formatMessage;
48
+ /**
49
+ * Stop spinner before logging to prevent output overlap
50
+ */
51
+ private pauseSpinner;
52
+ /**
53
+ * Resume spinner after logging
54
+ */
55
+ private resumeSpinner;
56
+ /**
57
+ * Render the spinner
58
+ */
59
+ private renderSpinner;
60
+ debug(message?: unknown, ...optionalParams: unknown[]): void;
61
+ verbose(message?: unknown, ...optionalParams: unknown[]): void;
62
+ info(message?: unknown, ...optionalParams: unknown[]): void;
63
+ warn(message?: unknown, ...optionalParams: unknown[]): void;
64
+ error(message?: unknown, ...optionalParams: unknown[]): void;
65
+ /**
66
+ * Start a spinner with the given text
67
+ */
68
+ startSpinner(text: string): void;
69
+ /**
70
+ * Update the spinner text
71
+ */
72
+ updateSpinner(text: string): void;
73
+ /**
74
+ * Stop the spinner with a success message
75
+ */
76
+ succeedSpinner(text?: string): void;
77
+ /**
78
+ * Stop the spinner with a failure message
79
+ */
80
+ failSpinner(text?: string): void;
81
+ /**
82
+ * Stop the spinner without a message
83
+ */
84
+ stopSpinner(): void;
85
+ /**
86
+ * Output structured JSON data
87
+ * Only outputs in JSON mode or when explicitly called
88
+ */
89
+ json(data: unknown): void;
90
+ /**
91
+ * Set the log level
92
+ */
93
+ setLevel(level: LogLevel): void;
94
+ /**
95
+ * Enable or disable JSON mode
96
+ * In JSON mode, only json() output is shown
97
+ */
98
+ setJsonMode(enabled: boolean): void;
99
+ /**
100
+ * Enable or disable colored output
101
+ */
102
+ setColors(enabled: boolean): void;
103
+ /**
104
+ * Get the current log level
105
+ */
106
+ getLevel(): LogLevel;
107
+ /**
108
+ * Check if JSON mode is enabled
109
+ */
110
+ isJsonMode(): boolean;
111
+ /**
112
+ * Sets the logger to use for the model generation library
113
+ *
114
+ * @param logger to add
115
+ */
116
+ setLogger(logger?: LoggingInterface): void;
117
+ /**
118
+ * Reset the logger to default state.
119
+ * Useful for testing or when re-initializing the logger.
120
+ */
121
+ reset(): void;
122
+ }
123
+ export declare const Logger: LoggerClass;
@@ -0,0 +1,300 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Logger = exports.LoggerClass = void 0;
7
+ /* eslint-disable no-undef, no-console, security/detect-object-injection */
8
+ /**
9
+ * Enhanced logging interface with levels, colors, and spinners
10
+ */
11
+ const picocolors_1 = __importDefault(require("picocolors"));
12
+ const LOG_LEVEL_PRIORITY = {
13
+ silent: 0,
14
+ error: 1,
15
+ warn: 2,
16
+ info: 3,
17
+ verbose: 4,
18
+ debug: 5
19
+ };
20
+ // Simple spinner implementation using console
21
+ const SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
22
+ /**
23
+ * Logger class with enhanced capabilities
24
+ *
25
+ * Supports log levels, colors, spinners, and JSON output mode.
26
+ * Acts as a forefront for any external loggers.
27
+ */
28
+ class LoggerClass {
29
+ logger = undefined;
30
+ level = 'info';
31
+ jsonMode = false;
32
+ colorsEnabled = true;
33
+ spinner = null;
34
+ /**
35
+ * Check if a message at the given level should be logged
36
+ */
37
+ shouldLog(messageLevel) {
38
+ return (LOG_LEVEL_PRIORITY[messageLevel] <= LOG_LEVEL_PRIORITY[this.level] &&
39
+ !this.jsonMode);
40
+ }
41
+ /**
42
+ * Format a message with optional color
43
+ */
44
+ formatMessage(message, colorFn) {
45
+ const msg = String(message);
46
+ if (this.colorsEnabled && colorFn) {
47
+ return colorFn(msg);
48
+ }
49
+ return msg;
50
+ }
51
+ /**
52
+ * Stop spinner before logging to prevent output overlap
53
+ */
54
+ pauseSpinner() {
55
+ if (this.spinner?.interval) {
56
+ clearInterval(this.spinner.interval);
57
+ this.spinner.interval = null;
58
+ // Clear the current line
59
+ if (process.stdout.isTTY) {
60
+ process.stdout.clearLine(0);
61
+ process.stdout.cursorTo(0);
62
+ }
63
+ }
64
+ }
65
+ /**
66
+ * Resume spinner after logging
67
+ */
68
+ resumeSpinner() {
69
+ if (this.spinner && !this.spinner.interval) {
70
+ this.renderSpinner();
71
+ }
72
+ }
73
+ /**
74
+ * Render the spinner
75
+ */
76
+ renderSpinner() {
77
+ if (!this.spinner || !process.stdout.isTTY) {
78
+ return;
79
+ }
80
+ this.spinner.interval = setInterval(() => {
81
+ if (!this.spinner) {
82
+ return;
83
+ }
84
+ const frame = this.colorsEnabled
85
+ ? picocolors_1.default.cyan(SPINNER_FRAMES[this.spinner.frameIndex])
86
+ : SPINNER_FRAMES[this.spinner.frameIndex];
87
+ process.stdout.clearLine(0);
88
+ process.stdout.cursorTo(0);
89
+ process.stdout.write(`${frame} ${this.spinner.text}`);
90
+ this.spinner.frameIndex =
91
+ (this.spinner.frameIndex + 1) % SPINNER_FRAMES.length;
92
+ }, 80);
93
+ }
94
+ debug(message, ...optionalParams) {
95
+ if (!this.shouldLog('debug')) {
96
+ return;
97
+ }
98
+ this.pauseSpinner();
99
+ const prefix = this.formatMessage('[DEBUG] ', picocolors_1.default.gray);
100
+ const formattedMessage = this.formatMessage(message, picocolors_1.default.gray);
101
+ if (this.logger) {
102
+ this.logger.debug(prefix + formattedMessage, ...optionalParams);
103
+ }
104
+ else {
105
+ console.debug(prefix + formattedMessage, ...optionalParams);
106
+ }
107
+ this.resumeSpinner();
108
+ }
109
+ verbose(message, ...optionalParams) {
110
+ if (!this.shouldLog('verbose')) {
111
+ return;
112
+ }
113
+ this.pauseSpinner();
114
+ const formattedMessage = this.formatMessage(message, picocolors_1.default.dim);
115
+ if (this.logger) {
116
+ this.logger.info(formattedMessage, ...optionalParams);
117
+ }
118
+ else {
119
+ console.log(formattedMessage, ...optionalParams);
120
+ }
121
+ this.resumeSpinner();
122
+ }
123
+ info(message, ...optionalParams) {
124
+ if (!this.shouldLog('info')) {
125
+ return;
126
+ }
127
+ this.pauseSpinner();
128
+ const msg = String(message);
129
+ if (this.logger) {
130
+ this.logger.info(msg, ...optionalParams);
131
+ }
132
+ else {
133
+ // Use process.stdout.write for better capture by oclif test utilities
134
+ const fullMsg = optionalParams.length > 0
135
+ ? `${msg} ${optionalParams.join(' ')}\n`
136
+ : `${msg}\n`;
137
+ process.stdout.write(fullMsg);
138
+ }
139
+ this.resumeSpinner();
140
+ }
141
+ warn(message, ...optionalParams) {
142
+ if (!this.shouldLog('warn')) {
143
+ return;
144
+ }
145
+ this.pauseSpinner();
146
+ const formattedMessage = this.formatMessage(message, picocolors_1.default.yellow);
147
+ if (this.logger) {
148
+ this.logger.warn(formattedMessage, ...optionalParams);
149
+ }
150
+ else {
151
+ console.warn(formattedMessage, ...optionalParams);
152
+ }
153
+ this.resumeSpinner();
154
+ }
155
+ error(message, ...optionalParams) {
156
+ if (!this.shouldLog('error')) {
157
+ return;
158
+ }
159
+ this.pauseSpinner();
160
+ const formattedMessage = this.formatMessage(message, picocolors_1.default.red);
161
+ if (this.logger) {
162
+ this.logger.error(formattedMessage, ...optionalParams);
163
+ }
164
+ else {
165
+ console.error(formattedMessage, ...optionalParams);
166
+ }
167
+ this.resumeSpinner();
168
+ }
169
+ /**
170
+ * Start a spinner with the given text
171
+ */
172
+ startSpinner(text) {
173
+ if (this.jsonMode) {
174
+ return;
175
+ }
176
+ this.stopSpinner();
177
+ this.spinner = {
178
+ text,
179
+ interval: null,
180
+ frameIndex: 0
181
+ };
182
+ if (process.stdout.isTTY) {
183
+ this.renderSpinner();
184
+ }
185
+ else {
186
+ // In non-TTY mode, just print the text
187
+ console.log(text);
188
+ }
189
+ }
190
+ /**
191
+ * Update the spinner text
192
+ */
193
+ updateSpinner(text) {
194
+ if (this.spinner) {
195
+ this.spinner.text = text;
196
+ }
197
+ }
198
+ /**
199
+ * Stop the spinner with a success message
200
+ */
201
+ succeedSpinner(text) {
202
+ const spinnerText = this.spinner?.text;
203
+ this.stopSpinner();
204
+ const displayText = text || spinnerText || '';
205
+ if (displayText && this.shouldLog('info')) {
206
+ const symbol = this.colorsEnabled ? picocolors_1.default.green('✓') : '[OK]';
207
+ console.log(`${symbol} ${displayText}`);
208
+ }
209
+ }
210
+ /**
211
+ * Stop the spinner with a failure message
212
+ */
213
+ failSpinner(text) {
214
+ const spinnerText = this.spinner?.text;
215
+ this.stopSpinner();
216
+ const displayText = text || spinnerText || '';
217
+ if (displayText && this.shouldLog('error')) {
218
+ const symbol = this.colorsEnabled ? picocolors_1.default.red('✗') : '[FAIL]';
219
+ console.log(`${symbol} ${displayText}`);
220
+ }
221
+ }
222
+ /**
223
+ * Stop the spinner without a message
224
+ */
225
+ stopSpinner() {
226
+ if (this.spinner) {
227
+ if (this.spinner.interval) {
228
+ clearInterval(this.spinner.interval);
229
+ }
230
+ if (process.stdout.isTTY) {
231
+ process.stdout.clearLine(0);
232
+ process.stdout.cursorTo(0);
233
+ }
234
+ this.spinner = null;
235
+ }
236
+ }
237
+ /**
238
+ * Output structured JSON data
239
+ * Only outputs in JSON mode or when explicitly called
240
+ */
241
+ json(data) {
242
+ this.stopSpinner();
243
+ console.log(JSON.stringify(data, null, 2));
244
+ }
245
+ /**
246
+ * Set the log level
247
+ */
248
+ setLevel(level) {
249
+ this.level = level;
250
+ }
251
+ /**
252
+ * Enable or disable JSON mode
253
+ * In JSON mode, only json() output is shown
254
+ */
255
+ setJsonMode(enabled) {
256
+ this.jsonMode = enabled;
257
+ if (enabled) {
258
+ this.stopSpinner();
259
+ }
260
+ }
261
+ /**
262
+ * Enable or disable colored output
263
+ */
264
+ setColors(enabled) {
265
+ this.colorsEnabled = enabled;
266
+ }
267
+ /**
268
+ * Get the current log level
269
+ */
270
+ getLevel() {
271
+ return this.level;
272
+ }
273
+ /**
274
+ * Check if JSON mode is enabled
275
+ */
276
+ isJsonMode() {
277
+ return this.jsonMode;
278
+ }
279
+ /**
280
+ * Sets the logger to use for the model generation library
281
+ *
282
+ * @param logger to add
283
+ */
284
+ setLogger(logger) {
285
+ this.logger = logger;
286
+ }
287
+ /**
288
+ * Reset the logger to default state.
289
+ * Useful for testing or when re-initializing the logger.
290
+ */
291
+ reset() {
292
+ this.stopSpinner();
293
+ this.level = 'info';
294
+ this.jsonMode = false;
295
+ this.colorsEnabled = true;
296
+ this.logger = undefined;
297
+ }
298
+ }
299
+ exports.LoggerClass = LoggerClass;
300
+ exports.Logger = new LoggerClass();
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Global configuration interface stored in ~/.the-codegen-project/config.json
3
+ * This configuration persists across all projects and CLI sessions.
4
+ */
5
+ export interface GlobalConfig {
6
+ version: string;
7
+ telemetry: TelemetryConfig;
8
+ hasShownTelemetryNotice: boolean;
9
+ lastUpdated?: string;
10
+ }
11
+ /**
12
+ * Telemetry configuration interface
13
+ */
14
+ export interface TelemetryConfig {
15
+ enabled: boolean;
16
+ anonymousId: string;
17
+ endpoint: string;
18
+ trackingId: string;
19
+ apiSecret: string;
20
+ }
21
+ /**
22
+ * Get global configuration.
23
+ * Creates default config if it doesn't exist.
24
+ * This function never throws - returns default config on any error.
25
+ */
26
+ export declare function getGlobalConfig(): Promise<GlobalConfig>;
27
+ /**
28
+ * Update global configuration.
29
+ * Creates config directory if it doesn't exist.
30
+ * This function never throws - fails silently on errors.
31
+ */
32
+ export declare function updateGlobalConfig(config: GlobalConfig): Promise<void>;
33
+ /**
34
+ * Check if the global config file exists.
35
+ */
36
+ export declare function configFileExists(): Promise<boolean>;
37
+ /**
38
+ * Get the path to the global config file.
39
+ * Useful for debugging and testing.
40
+ */
41
+ export declare function getConfigFilePath(): string;
42
+ /**
43
+ * Get the path to the config directory.
44
+ * Useful for debugging and testing.
45
+ */
46
+ export declare function getConfigDirectoryPath(): string;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getConfigDirectoryPath = exports.getConfigFilePath = exports.configFileExists = exports.updateGlobalConfig = exports.getGlobalConfig = void 0;
7
+ const os_1 = __importDefault(require("os"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const promises_1 = __importDefault(require("fs/promises"));
10
+ const uuid_1 = require("uuid");
11
+ const CONFIG_DIR = path_1.default.join(os_1.default.homedir(), '.the-codegen-project');
12
+ const CONFIG_FILE = path_1.default.join(CONFIG_DIR, 'config.json');
13
+ /**
14
+ * Get global configuration.
15
+ * Creates default config if it doesn't exist.
16
+ * This function never throws - returns default config on any error.
17
+ */
18
+ async function getGlobalConfig() {
19
+ try {
20
+ const data = await promises_1.default.readFile(CONFIG_FILE, 'utf-8');
21
+ return JSON.parse(data);
22
+ }
23
+ catch {
24
+ // Config doesn't exist or is invalid, create default
25
+ return await createDefaultGlobalConfig();
26
+ }
27
+ }
28
+ exports.getGlobalConfig = getGlobalConfig;
29
+ /**
30
+ * Update global configuration.
31
+ * Creates config directory if it doesn't exist.
32
+ * This function never throws - fails silently on errors.
33
+ */
34
+ async function updateGlobalConfig(config) {
35
+ try {
36
+ await promises_1.default.mkdir(CONFIG_DIR, { recursive: true });
37
+ config.lastUpdated = new Date().toISOString();
38
+ await promises_1.default.writeFile(CONFIG_FILE, JSON.stringify(config, null, 2));
39
+ }
40
+ catch {
41
+ // Fail silently - config update is not critical
42
+ // Debug logging intentionally omitted to avoid dependencies
43
+ }
44
+ }
45
+ exports.updateGlobalConfig = updateGlobalConfig;
46
+ /**
47
+ * Create default global configuration with telemetry enabled.
48
+ * Uses GA4 Measurement Protocol as the default endpoint.
49
+ */
50
+ async function createDefaultGlobalConfig() {
51
+ const globalConfig = {
52
+ version: '1.0.0',
53
+ telemetry: {
54
+ enabled: true,
55
+ anonymousId: (0, uuid_1.v4)(),
56
+ endpoint: 'https://www.google-analytics.com/mp/collect',
57
+ trackingId: 'G-45KZ589PCT',
58
+ apiSecret: 'emUAvwyZRDqCKYbmvWUM9g' // NOTE: is OKAY to be committed as its a public API secret
59
+ },
60
+ hasShownTelemetryNotice: false,
61
+ lastUpdated: new Date().toISOString()
62
+ };
63
+ await updateGlobalConfig(globalConfig);
64
+ return globalConfig;
65
+ }
66
+ /**
67
+ * Check if the global config file exists.
68
+ */
69
+ async function configFileExists() {
70
+ try {
71
+ await promises_1.default.access(CONFIG_FILE);
72
+ return true;
73
+ }
74
+ catch {
75
+ return false;
76
+ }
77
+ }
78
+ exports.configFileExists = configFileExists;
79
+ /**
80
+ * Get the path to the global config file.
81
+ * Useful for debugging and testing.
82
+ */
83
+ function getConfigFilePath() {
84
+ return CONFIG_FILE;
85
+ }
86
+ exports.getConfigFilePath = getConfigFilePath;
87
+ /**
88
+ * Get the path to the config directory.
89
+ * Useful for debugging and testing.
90
+ */
91
+ function getConfigDirectoryPath() {
92
+ return CONFIG_DIR;
93
+ }
94
+ exports.getConfigDirectoryPath = getConfigDirectoryPath;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * In-memory file output adapter for browser environments.
3
+ * Replaces filesystem writes with Map<string, string> storage.
4
+ * Implements OutputAdapter interface for compatibility with shared generators.
5
+ */
6
+ import { OutputAdapter } from '../../codegen/output/types';
7
+ export declare class BrowserOutput implements OutputAdapter {
8
+ private files;
9
+ /**
10
+ * Write a file to memory.
11
+ * @param path - The file path (e.g., 'src/models/User.ts')
12
+ * @param content - The file content
13
+ */
14
+ write(path: string, content: string): Promise<void>;
15
+ /**
16
+ * No-op for browser - directories are virtual.
17
+ */
18
+ mkdir(_dirPath: string, _options?: {
19
+ recursive?: boolean;
20
+ }): Promise<void>;
21
+ /**
22
+ * Get all file paths that were written.
23
+ * Implements OutputAdapter interface.
24
+ */
25
+ getWrittenFiles(): string[];
26
+ /**
27
+ * Get all files with their content.
28
+ * Implements OutputAdapter interface.
29
+ */
30
+ getAllFiles(): Record<string, string>;
31
+ /**
32
+ * Read a file from memory.
33
+ * @param path - The file path
34
+ * @returns The file content, or undefined if not found
35
+ */
36
+ read(path: string): string | undefined;
37
+ /**
38
+ * Get all files as a Record.
39
+ * @deprecated Use getAllFiles() instead for OutputAdapter compatibility
40
+ * @returns A copy of all files as Record<path, content>
41
+ */
42
+ getAll(): Record<string, string>;
43
+ /**
44
+ * Clear all files from memory.
45
+ */
46
+ clear(): void;
47
+ /**
48
+ * Check if a file exists.
49
+ * @param path - The file path
50
+ * @returns True if the file exists
51
+ */
52
+ has(path: string): boolean;
53
+ /**
54
+ * Delete a specific file.
55
+ * @param path - The file path
56
+ * @returns True if the file was deleted, false if it didn't exist
57
+ */
58
+ delete(path: string): boolean;
59
+ /**
60
+ * Get all file paths.
61
+ * @deprecated Use getWrittenFiles() instead for OutputAdapter compatibility
62
+ * @returns Array of file paths
63
+ */
64
+ getPaths(): string[];
65
+ /**
66
+ * Get the number of files.
67
+ */
68
+ get size(): number;
69
+ }