@creact-labs/creact 0.1.8 → 0.2.0

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 (146) hide show
  1. package/README.md +73 -22
  2. package/dist/cli.d.ts +11 -0
  3. package/dist/cli.js +88 -0
  4. package/dist/index.d.ts +19 -44
  5. package/dist/index.js +20 -68
  6. package/dist/jsx/index.d.ts +2 -0
  7. package/dist/jsx/index.js +1 -0
  8. package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
  9. package/dist/jsx/jsx-dev-runtime.js +4 -0
  10. package/dist/jsx/jsx-runtime.d.ts +38 -0
  11. package/dist/jsx/jsx-runtime.js +38 -0
  12. package/dist/jsx/types.d.ts +12 -0
  13. package/dist/jsx/types.js +4 -0
  14. package/dist/primitives/context.d.ts +34 -0
  15. package/dist/primitives/context.js +63 -0
  16. package/dist/primitives/index.d.ts +3 -0
  17. package/dist/primitives/index.js +3 -0
  18. package/dist/primitives/instance.d.ts +72 -0
  19. package/dist/primitives/instance.js +235 -0
  20. package/dist/primitives/store.d.ts +22 -0
  21. package/dist/primitives/store.js +97 -0
  22. package/dist/provider/backend.d.ts +110 -0
  23. package/dist/provider/backend.js +37 -0
  24. package/dist/provider/interface.d.ts +48 -0
  25. package/dist/provider/interface.js +39 -0
  26. package/dist/reactive/effect.d.ts +11 -0
  27. package/dist/reactive/effect.js +42 -0
  28. package/dist/reactive/index.d.ts +3 -0
  29. package/dist/reactive/index.js +3 -0
  30. package/dist/reactive/signal.d.ts +32 -0
  31. package/dist/reactive/signal.js +60 -0
  32. package/dist/reactive/tracking.d.ts +41 -0
  33. package/dist/reactive/tracking.js +161 -0
  34. package/dist/runtime/fiber.d.ts +21 -0
  35. package/dist/runtime/fiber.js +16 -0
  36. package/dist/runtime/index.d.ts +4 -0
  37. package/dist/runtime/index.js +4 -0
  38. package/dist/runtime/reconcile.d.ts +66 -0
  39. package/dist/runtime/reconcile.js +210 -0
  40. package/dist/runtime/render.d.ts +42 -0
  41. package/dist/runtime/render.js +231 -0
  42. package/dist/runtime/run.d.ts +119 -0
  43. package/dist/runtime/run.js +334 -0
  44. package/dist/runtime/state-machine.d.ts +95 -0
  45. package/dist/runtime/state-machine.js +209 -0
  46. package/dist/types.d.ts +13 -0
  47. package/dist/types.js +4 -0
  48. package/package.json +11 -24
  49. package/dist/cli/commands/BuildCommand.d.ts +0 -40
  50. package/dist/cli/commands/BuildCommand.js +0 -151
  51. package/dist/cli/commands/DeployCommand.d.ts +0 -38
  52. package/dist/cli/commands/DeployCommand.js +0 -194
  53. package/dist/cli/commands/DevCommand.d.ts +0 -52
  54. package/dist/cli/commands/DevCommand.js +0 -394
  55. package/dist/cli/commands/PlanCommand.d.ts +0 -39
  56. package/dist/cli/commands/PlanCommand.js +0 -164
  57. package/dist/cli/commands/index.d.ts +0 -36
  58. package/dist/cli/commands/index.js +0 -43
  59. package/dist/cli/core/ArgumentParser.d.ts +0 -46
  60. package/dist/cli/core/ArgumentParser.js +0 -127
  61. package/dist/cli/core/BaseCommand.d.ts +0 -75
  62. package/dist/cli/core/BaseCommand.js +0 -95
  63. package/dist/cli/core/CLIContext.d.ts +0 -68
  64. package/dist/cli/core/CLIContext.js +0 -183
  65. package/dist/cli/core/CommandRegistry.d.ts +0 -64
  66. package/dist/cli/core/CommandRegistry.js +0 -89
  67. package/dist/cli/core/index.d.ts +0 -36
  68. package/dist/cli/core/index.js +0 -43
  69. package/dist/cli/index.d.ts +0 -35
  70. package/dist/cli/index.js +0 -100
  71. package/dist/cli/output.d.ts +0 -204
  72. package/dist/cli/output.js +0 -437
  73. package/dist/cli/utils.d.ts +0 -59
  74. package/dist/cli/utils.js +0 -76
  75. package/dist/context/createContext.d.ts +0 -90
  76. package/dist/context/createContext.js +0 -113
  77. package/dist/context/index.d.ts +0 -30
  78. package/dist/context/index.js +0 -35
  79. package/dist/core/CReact.d.ts +0 -409
  80. package/dist/core/CReact.js +0 -1151
  81. package/dist/core/CloudDOMBuilder.d.ts +0 -447
  82. package/dist/core/CloudDOMBuilder.js +0 -1234
  83. package/dist/core/ContextDependencyTracker.d.ts +0 -165
  84. package/dist/core/ContextDependencyTracker.js +0 -448
  85. package/dist/core/ErrorRecoveryManager.d.ts +0 -145
  86. package/dist/core/ErrorRecoveryManager.js +0 -443
  87. package/dist/core/EventBus.d.ts +0 -91
  88. package/dist/core/EventBus.js +0 -185
  89. package/dist/core/ProviderOutputTracker.d.ts +0 -211
  90. package/dist/core/ProviderOutputTracker.js +0 -476
  91. package/dist/core/ReactiveUpdateQueue.d.ts +0 -76
  92. package/dist/core/ReactiveUpdateQueue.js +0 -121
  93. package/dist/core/Reconciler.d.ts +0 -415
  94. package/dist/core/Reconciler.js +0 -1044
  95. package/dist/core/RenderScheduler.d.ts +0 -153
  96. package/dist/core/RenderScheduler.js +0 -519
  97. package/dist/core/Renderer.d.ts +0 -336
  98. package/dist/core/Renderer.js +0 -944
  99. package/dist/core/Runtime.d.ts +0 -246
  100. package/dist/core/Runtime.js +0 -640
  101. package/dist/core/StateBindingManager.d.ts +0 -121
  102. package/dist/core/StateBindingManager.js +0 -309
  103. package/dist/core/StateMachine.d.ts +0 -441
  104. package/dist/core/StateMachine.js +0 -883
  105. package/dist/core/StructuralChangeDetector.d.ts +0 -140
  106. package/dist/core/StructuralChangeDetector.js +0 -363
  107. package/dist/core/Validator.d.ts +0 -127
  108. package/dist/core/Validator.js +0 -279
  109. package/dist/core/errors.d.ts +0 -153
  110. package/dist/core/errors.js +0 -202
  111. package/dist/core/index.d.ts +0 -38
  112. package/dist/core/index.js +0 -64
  113. package/dist/core/types.d.ts +0 -265
  114. package/dist/core/types.js +0 -48
  115. package/dist/hooks/context.d.ts +0 -147
  116. package/dist/hooks/context.js +0 -334
  117. package/dist/hooks/useContext.d.ts +0 -113
  118. package/dist/hooks/useContext.js +0 -169
  119. package/dist/hooks/useEffect.d.ts +0 -105
  120. package/dist/hooks/useEffect.js +0 -540
  121. package/dist/hooks/useInstance.d.ts +0 -139
  122. package/dist/hooks/useInstance.js +0 -455
  123. package/dist/hooks/useState.d.ts +0 -120
  124. package/dist/hooks/useState.js +0 -298
  125. package/dist/jsx.d.ts +0 -143
  126. package/dist/jsx.js +0 -76
  127. package/dist/providers/DummyBackendProvider.d.ts +0 -193
  128. package/dist/providers/DummyBackendProvider.js +0 -189
  129. package/dist/providers/DummyCloudProvider.d.ts +0 -128
  130. package/dist/providers/DummyCloudProvider.js +0 -157
  131. package/dist/providers/IBackendProvider.d.ts +0 -177
  132. package/dist/providers/IBackendProvider.js +0 -31
  133. package/dist/providers/ICloudProvider.d.ts +0 -230
  134. package/dist/providers/ICloudProvider.js +0 -31
  135. package/dist/providers/index.d.ts +0 -31
  136. package/dist/providers/index.js +0 -31
  137. package/dist/test-event-callbacks.d.ts +0 -0
  138. package/dist/test-event-callbacks.js +0 -1
  139. package/dist/utils/Logger.d.ts +0 -144
  140. package/dist/utils/Logger.js +0 -220
  141. package/dist/utils/Output.d.ts +0 -161
  142. package/dist/utils/Output.js +0 -401
  143. package/dist/utils/deepEqual.d.ts +0 -71
  144. package/dist/utils/deepEqual.js +0 -276
  145. package/dist/utils/naming.d.ts +0 -241
  146. package/dist/utils/naming.js +0 -376
@@ -1,204 +0,0 @@
1
- /**
2
-
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
-
5
- * you may not use this file except in compliance with the License.
6
-
7
- * You may obtain a copy of the License at
8
-
9
- *
10
-
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
-
13
- *
14
-
15
- * Unless required by applicable law or agreed to in writing, software
16
-
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
-
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
-
21
- * See the License for the specific language governing permissions and
22
-
23
- * limitations under the License.
24
-
25
- *
26
-
27
- * Copyright 2025 Daniel Coutinho Ribeiro
28
-
29
- */
30
- /**
31
- * CLI Output Utilities
32
- *
33
- * DEPRECATED: Most functions in this file are deprecated in favor of OutputManager.
34
- * Use OutputManager (src/utils/Output.ts) for user-facing output instead.
35
- *
36
- * This file now only contains:
37
- * - Color utilities (colors object)
38
- * - Spinner, ProgressBar, MultiProgressBar classes (for backward compatibility)
39
- *
40
- * Deprecated functions (use OutputManager instead):
41
- * - printSuccess() -> output.showSuccess()
42
- * - printError() -> output.showError()
43
- * - printInfo() -> output.showInfo()
44
- * - printWarning() -> output.showWarning()
45
- * - formatDiff() -> output.showPlanChanges()
46
- */
47
- import chalk from 'chalk';
48
- /**
49
- * Color utilities for consistent CLI output
50
- */
51
- export declare const colors: {
52
- success: chalk.Chalk;
53
- error: chalk.Chalk;
54
- warning: chalk.Chalk;
55
- info: chalk.Chalk;
56
- create: chalk.Chalk;
57
- update: chalk.Chalk;
58
- delete: chalk.Chalk;
59
- move: chalk.Chalk;
60
- primary: chalk.Chalk;
61
- secondary: chalk.Chalk;
62
- highlight: chalk.Chalk;
63
- dim: chalk.Chalk;
64
- resource: chalk.Chalk;
65
- output: chalk.Chalk;
66
- checkmark: string;
67
- cross: string;
68
- arrow: string;
69
- bullet: string;
70
- };
71
- /**
72
- * Spinner manager for long-running operations
73
- */
74
- export declare class Spinner {
75
- private spinner;
76
- private isJsonMode;
77
- constructor(isJsonMode?: boolean);
78
- /**
79
- * Start spinner with message
80
- */
81
- start(message: string): void;
82
- /**
83
- * Update spinner text
84
- */
85
- update(message: string): void;
86
- /**
87
- * Mark spinner as successful
88
- */
89
- succeed(message?: string): void;
90
- /**
91
- * Mark spinner as failed
92
- */
93
- fail(message?: string): void;
94
- /**
95
- * Mark spinner as warning
96
- */
97
- warn(message?: string): void;
98
- /**
99
- * Stop spinner without status
100
- */
101
- stop(): void;
102
- }
103
- /**
104
- * Progress bar for batch operations
105
- */
106
- export declare class ProgressBar {
107
- private bar;
108
- private isJsonMode;
109
- private total;
110
- private current;
111
- constructor(isJsonMode?: boolean);
112
- /**
113
- * Start progress bar
114
- */
115
- start(total: number, startValue?: number, message?: string): void;
116
- /**
117
- * Update progress
118
- */
119
- update(value: number, status?: string): void;
120
- /**
121
- * Increment progress by 1
122
- */
123
- increment(status?: string): void;
124
- /**
125
- * Stop progress bar
126
- */
127
- stop(): void;
128
- }
129
- /**
130
- * Multi-bar progress for parallel operations
131
- */
132
- export declare class MultiProgressBar {
133
- private multibar;
134
- private bars;
135
- private isJsonMode;
136
- constructor(isJsonMode?: boolean);
137
- /**
138
- * Add a new progress bar
139
- */
140
- add(name: string, total: number, startValue?: number): void;
141
- /**
142
- * Update a specific progress bar
143
- */
144
- update(name: string, value: number): void;
145
- /**
146
- * Increment a specific progress bar
147
- */
148
- increment(name: string): void;
149
- /**
150
- * Stop all progress bars
151
- */
152
- stop(): void;
153
- }
154
- /**
155
- * Format diff output with colors
156
- * @deprecated Use OutputManager.showPlanChanges() and showPlanSummary() instead
157
- */
158
- export declare function formatDiff(changeSet: {
159
- creates: any[];
160
- updates: any[];
161
- deletes: any[];
162
- moves?: Array<{
163
- from: string;
164
- to: string;
165
- }>;
166
- }): string;
167
- /**
168
- * Format deployment status with colors
169
- */
170
- export declare function formatDeploymentStatus(status: string): string;
171
- /**
172
- * Format resource output
173
- */
174
- export declare function formatResource(construct: string, id: string, status?: string): string;
175
- /**
176
- * Print success message
177
- * @deprecated Use OutputManager.showSuccess() instead
178
- */
179
- export declare function printSuccess(message: string): void;
180
- /**
181
- * Print error message
182
- * @deprecated Use OutputManager.showError() instead
183
- */
184
- export declare function printError(message: string): void;
185
- /**
186
- * Print warning message
187
- * @deprecated Use OutputManager.showWarning() instead
188
- */
189
- export declare function printWarning(message: string): void;
190
- /**
191
- * Print info message
192
- * @deprecated Use OutputManager.showInfo() instead
193
- */
194
- export declare function printInfo(message: string): void;
195
- /**
196
- * Print section header
197
- * @deprecated Use OutputManager methods instead
198
- */
199
- export declare function printHeader(message: string): void;
200
- /**
201
- * Print table
202
- * @deprecated Use OutputManager methods instead
203
- */
204
- export declare function printTable(headers: string[], rows: string[][]): void;
@@ -1,437 +0,0 @@
1
- "use strict";
2
- /**
3
-
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
-
6
- * you may not use this file except in compliance with the License.
7
-
8
- * You may obtain a copy of the License at
9
-
10
- *
11
-
12
- * http://www.apache.org/licenses/LICENSE-2.0
13
-
14
- *
15
-
16
- * Unless required by applicable law or agreed to in writing, software
17
-
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
-
20
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
-
22
- * See the License for the specific language governing permissions and
23
-
24
- * limitations under the License.
25
-
26
- *
27
-
28
- * Copyright 2025 Daniel Coutinho Ribeiro
29
-
30
- */
31
- var __importDefault = (this && this.__importDefault) || function (mod) {
32
- return (mod && mod.__esModule) ? mod : { "default": mod };
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.MultiProgressBar = exports.ProgressBar = exports.Spinner = exports.colors = void 0;
36
- exports.formatDiff = formatDiff;
37
- exports.formatDeploymentStatus = formatDeploymentStatus;
38
- exports.formatResource = formatResource;
39
- exports.printSuccess = printSuccess;
40
- exports.printError = printError;
41
- exports.printWarning = printWarning;
42
- exports.printInfo = printInfo;
43
- exports.printHeader = printHeader;
44
- exports.printTable = printTable;
45
- /**
46
- * CLI Output Utilities
47
- *
48
- * DEPRECATED: Most functions in this file are deprecated in favor of OutputManager.
49
- * Use OutputManager (src/utils/Output.ts) for user-facing output instead.
50
- *
51
- * This file now only contains:
52
- * - Color utilities (colors object)
53
- * - Spinner, ProgressBar, MultiProgressBar classes (for backward compatibility)
54
- *
55
- * Deprecated functions (use OutputManager instead):
56
- * - printSuccess() -> output.showSuccess()
57
- * - printError() -> output.showError()
58
- * - printInfo() -> output.showInfo()
59
- * - printWarning() -> output.showWarning()
60
- * - formatDiff() -> output.showPlanChanges()
61
- */
62
- const chalk_1 = __importDefault(require("chalk"));
63
- const ora_1 = __importDefault(require("ora"));
64
- const cli_progress_1 = __importDefault(require("cli-progress"));
65
- const Logger_1 = require("../utils/Logger");
66
- const logger = Logger_1.LoggerFactory.getLogger('cli');
67
- /**
68
- * Color utilities for consistent CLI output
69
- */
70
- exports.colors = {
71
- // Status colors
72
- success: chalk_1.default.green,
73
- error: chalk_1.default.red,
74
- warning: chalk_1.default.yellow,
75
- info: chalk_1.default.blue,
76
- // Diff colors (for plan command)
77
- create: chalk_1.default.green,
78
- update: chalk_1.default.yellow,
79
- delete: chalk_1.default.red,
80
- move: chalk_1.default.cyan,
81
- // Semantic colors
82
- primary: chalk_1.default.cyan,
83
- secondary: chalk_1.default.gray,
84
- highlight: chalk_1.default.bold.white,
85
- dim: chalk_1.default.dim,
86
- // Resource types
87
- resource: chalk_1.default.magenta,
88
- output: chalk_1.default.blue,
89
- // Symbols
90
- checkmark: chalk_1.default.green('✓'),
91
- cross: chalk_1.default.red('✗'),
92
- arrow: chalk_1.default.cyan('→'),
93
- bullet: chalk_1.default.gray('•'),
94
- };
95
- /**
96
- * Spinner manager for long-running operations
97
- */
98
- class Spinner {
99
- constructor(isJsonMode = false) {
100
- this.spinner = null;
101
- this.isJsonMode = false;
102
- this.isJsonMode = isJsonMode;
103
- }
104
- /**
105
- * Start spinner with message
106
- */
107
- start(message) {
108
- if (this.isJsonMode) {
109
- // In JSON mode, just log without spinner
110
- logger.info(`[info] ${message}`);
111
- return;
112
- }
113
- this.spinner = (0, ora_1.default)({
114
- text: message,
115
- color: 'cyan',
116
- }).start();
117
- }
118
- /**
119
- * Update spinner text
120
- */
121
- update(message) {
122
- if (this.isJsonMode) {
123
- logger.info(`[info] ${message}`);
124
- return;
125
- }
126
- if (this.spinner) {
127
- this.spinner.text = message;
128
- }
129
- }
130
- /**
131
- * Mark spinner as successful
132
- */
133
- succeed(message) {
134
- if (this.isJsonMode) {
135
- logger.info(`[success] ${message || 'Done'}`);
136
- return;
137
- }
138
- if (this.spinner) {
139
- this.spinner.succeed(message);
140
- this.spinner = null;
141
- }
142
- }
143
- /**
144
- * Mark spinner as failed
145
- */
146
- fail(message) {
147
- if (this.isJsonMode) {
148
- logger.error(`[error] ${message || 'Failed'}`);
149
- return;
150
- }
151
- if (this.spinner) {
152
- this.spinner.fail(message);
153
- this.spinner = null;
154
- }
155
- }
156
- /**
157
- * Mark spinner as warning
158
- */
159
- warn(message) {
160
- if (this.isJsonMode) {
161
- logger.warn(`[warning] ${message || 'Warning'}`);
162
- return;
163
- }
164
- if (this.spinner) {
165
- this.spinner.warn(message);
166
- this.spinner = null;
167
- }
168
- }
169
- /**
170
- * Stop spinner without status
171
- */
172
- stop() {
173
- if (this.spinner) {
174
- this.spinner.stop();
175
- this.spinner = null;
176
- }
177
- }
178
- }
179
- exports.Spinner = Spinner;
180
- /**
181
- * Progress bar for batch operations
182
- */
183
- class ProgressBar {
184
- constructor(isJsonMode = false) {
185
- this.bar = null;
186
- this.isJsonMode = false;
187
- this.total = 0;
188
- this.current = 0;
189
- this.isJsonMode = isJsonMode;
190
- }
191
- /**
192
- * Start progress bar
193
- */
194
- start(total, startValue = 0, message) {
195
- this.total = total;
196
- this.current = startValue;
197
- if (this.isJsonMode) {
198
- logger.info(`[progress] ${message || 'Starting'} (0/${total})`);
199
- return;
200
- }
201
- this.bar = new cli_progress_1.default.SingleBar({
202
- format: `${message || 'Progress'} |${chalk_1.default.cyan('{bar}')}| {percentage}% | {value}/{total} | {status}`,
203
- barCompleteChar: '\u2588',
204
- barIncompleteChar: '\u2591',
205
- hideCursor: true,
206
- });
207
- this.bar.start(total, startValue, { status: '' });
208
- }
209
- /**
210
- * Update progress
211
- */
212
- update(value, status) {
213
- this.current = value;
214
- if (this.isJsonMode) {
215
- logger.info(`[progress] ${status || 'Processing'} (${value}/${this.total})`);
216
- return;
217
- }
218
- if (this.bar) {
219
- this.bar.update(value, { status: status || '' });
220
- }
221
- }
222
- /**
223
- * Increment progress by 1
224
- */
225
- increment(status) {
226
- this.update(this.current + 1, status);
227
- }
228
- /**
229
- * Stop progress bar
230
- */
231
- stop() {
232
- if (this.bar) {
233
- this.bar.stop();
234
- this.bar = null;
235
- }
236
- }
237
- }
238
- exports.ProgressBar = ProgressBar;
239
- /**
240
- * Multi-bar progress for parallel operations
241
- */
242
- class MultiProgressBar {
243
- constructor(isJsonMode = false) {
244
- this.multibar = null;
245
- this.bars = new Map();
246
- this.isJsonMode = false;
247
- this.isJsonMode = isJsonMode;
248
- if (!isJsonMode) {
249
- this.multibar = new cli_progress_1.default.MultiBar({
250
- clearOnComplete: false,
251
- hideCursor: true,
252
- format: '{name} |{bar}| {percentage}% | {value}/{total}',
253
- }, cli_progress_1.default.Presets.shades_classic);
254
- }
255
- }
256
- /**
257
- * Add a new progress bar
258
- */
259
- add(name, total, startValue = 0) {
260
- if (this.isJsonMode) {
261
- logger.info(`[progress] ${name}: 0/${total}`);
262
- return;
263
- }
264
- if (this.multibar) {
265
- const bar = this.multibar.create(total, startValue, { name });
266
- this.bars.set(name, bar);
267
- }
268
- }
269
- /**
270
- * Update a specific progress bar
271
- */
272
- update(name, value) {
273
- if (this.isJsonMode) {
274
- return;
275
- }
276
- const bar = this.bars.get(name);
277
- if (bar) {
278
- bar.update(value);
279
- }
280
- }
281
- /**
282
- * Increment a specific progress bar
283
- */
284
- increment(name) {
285
- if (this.isJsonMode) {
286
- return;
287
- }
288
- const bar = this.bars.get(name);
289
- if (bar) {
290
- bar.increment();
291
- }
292
- }
293
- /**
294
- * Stop all progress bars
295
- */
296
- stop() {
297
- if (this.multibar) {
298
- this.multibar.stop();
299
- this.multibar = null;
300
- this.bars.clear();
301
- }
302
- }
303
- }
304
- exports.MultiProgressBar = MultiProgressBar;
305
- /**
306
- * Format diff output with colors
307
- * @deprecated Use OutputManager.showPlanChanges() and showPlanSummary() instead
308
- */
309
- function formatDiff(changeSet) {
310
- const lines = [];
311
- // Header
312
- lines.push(chalk_1.default.bold('\nPlanned Changes:\n'));
313
- // Creates
314
- if (changeSet.creates.length > 0) {
315
- lines.push(exports.colors.create(` + ${changeSet.creates.length} to create`));
316
- changeSet.creates.forEach((node) => {
317
- lines.push(exports.colors.create(` + ${node.construct?.name || 'Unknown'}.${node.id}`));
318
- });
319
- lines.push('');
320
- }
321
- // Updates
322
- if (changeSet.updates.length > 0) {
323
- lines.push(exports.colors.update(` ~ ${changeSet.updates.length} to update`));
324
- changeSet.updates.forEach((node) => {
325
- lines.push(exports.colors.update(` ~ ${node.construct?.name || 'Unknown'}.${node.id}`));
326
- });
327
- lines.push('');
328
- }
329
- // Deletes
330
- if (changeSet.deletes.length > 0) {
331
- lines.push(exports.colors.delete(` - ${changeSet.deletes.length} to delete`));
332
- changeSet.deletes.forEach((node) => {
333
- lines.push(exports.colors.delete(` - ${node.construct?.name || 'Unknown'}.${node.id}`));
334
- });
335
- lines.push('');
336
- }
337
- // Moves
338
- if (changeSet.moves && changeSet.moves.length > 0) {
339
- lines.push(exports.colors.move(` → ${changeSet.moves.length} to move`));
340
- changeSet.moves.forEach((move) => {
341
- lines.push(exports.colors.move(` → ${move.from} → ${move.to}`));
342
- });
343
- lines.push('');
344
- }
345
- // Summary
346
- const total = changeSet.creates.length +
347
- changeSet.updates.length +
348
- changeSet.deletes.length +
349
- (changeSet.moves?.length || 0);
350
- lines.push(chalk_1.default.bold(`Total: ${total} changes\n`));
351
- return lines.join('\n');
352
- }
353
- /**
354
- * Format deployment status with colors
355
- */
356
- function formatDeploymentStatus(status) {
357
- switch (status.toUpperCase()) {
358
- case 'PENDING':
359
- return exports.colors.info('PENDING');
360
- case 'APPLYING':
361
- return exports.colors.warning('APPLYING');
362
- case 'DEPLOYED':
363
- return exports.colors.success('DEPLOYED');
364
- case 'FAILED':
365
- return exports.colors.error('FAILED');
366
- case 'ROLLED_BACK':
367
- return exports.colors.warning('ROLLED_BACK');
368
- default:
369
- return exports.colors.dim(status);
370
- }
371
- }
372
- /**
373
- * Format resource output
374
- */
375
- function formatResource(construct, id, status) {
376
- const resourceStr = `${exports.colors.resource(construct)}.${exports.colors.highlight(id)}`;
377
- if (status) {
378
- return `${resourceStr} ${exports.colors.dim('→')} ${formatDeploymentStatus(status)}`;
379
- }
380
- return resourceStr;
381
- }
382
- /**
383
- * Print success message
384
- * @deprecated Use OutputManager.showSuccess() instead
385
- */
386
- function printSuccess(message) {
387
- console.log(`${exports.colors.checkmark} ${exports.colors.success(message)}`);
388
- }
389
- /**
390
- * Print error message
391
- * @deprecated Use OutputManager.showError() instead
392
- */
393
- function printError(message) {
394
- console.error(`${exports.colors.cross} ${exports.colors.error(message)}`);
395
- }
396
- /**
397
- * Print warning message
398
- * @deprecated Use OutputManager.showWarning() instead
399
- */
400
- function printWarning(message) {
401
- console.log(`${exports.colors.warning('⚠')} ${exports.colors.warning(message)}`);
402
- }
403
- /**
404
- * Print info message
405
- * @deprecated Use OutputManager.showInfo() instead
406
- */
407
- function printInfo(message) {
408
- console.log(`${exports.colors.info('ℹ')} ${exports.colors.info(message)}`);
409
- }
410
- /**
411
- * Print section header
412
- * @deprecated Use OutputManager methods instead
413
- */
414
- function printHeader(message) {
415
- console.log(`\n${exports.colors.highlight(message)}`);
416
- console.log(exports.colors.dim('─'.repeat(message.length)));
417
- }
418
- /**
419
- * Print table
420
- * @deprecated Use OutputManager methods instead
421
- */
422
- function printTable(headers, rows) {
423
- // Calculate column widths
424
- const widths = headers.map((header, i) => {
425
- const maxRowWidth = Math.max(...rows.map((row) => (row[i] || '').length));
426
- return Math.max(header.length, maxRowWidth);
427
- });
428
- // Print header
429
- const headerRow = headers.map((header, i) => header.padEnd(widths[i])).join(' ');
430
- console.log(exports.colors.highlight(headerRow));
431
- console.log(exports.colors.dim('─'.repeat(headerRow.length)));
432
- // Print rows
433
- rows.forEach((row) => {
434
- const rowStr = row.map((cell, i) => (cell || '').padEnd(widths[i])).join(' ');
435
- console.log(rowStr);
436
- });
437
- }
@@ -1,59 +0,0 @@
1
- /**
2
-
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
-
5
- * you may not use this file except in compliance with the License.
6
-
7
- * You may obtain a copy of the License at
8
-
9
- *
10
-
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
-
13
- *
14
-
15
- * Unless required by applicable law or agreed to in writing, software
16
-
17
- * distributed under the License is distributed on an "AS IS" BASIS,
18
-
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
-
21
- * See the License for the specific language governing permissions and
22
-
23
- * limitations under the License.
24
-
25
- *
26
-
27
- * Copyright 2025 Daniel Coutinho Ribeiro
28
-
29
- */
30
- /**
31
- * CLI utility functions
32
- *
33
- * Shared utilities for CLI commands including config loading,
34
- * logging, and error handling.
35
- */
36
- import type { CLIContext } from './core/CLIContext';
37
- /**
38
- * Log message if verbose mode is enabled
39
- *
40
- * @param message - Message to log
41
- * @param verbose - Whether verbose mode is enabled
42
- */
43
- export declare function logVerbose(message: string, verbose?: boolean): void;
44
- /**
45
- * Format error for CLI output
46
- *
47
- * @param error - Error to format
48
- * @param verbose - Whether to include stack trace
49
- * @returns Formatted error message
50
- */
51
- export declare function formatError(error: Error, verbose?: boolean): string;
52
- /**
53
- * Output data in JSON format if --json flag is set
54
- *
55
- * @param data - Data to output
56
- * @param ctx - Command context
57
- * @returns true if JSON output was used, false otherwise
58
- */
59
- export declare function outputJson(data: any, ctx: CLIContext): boolean;