@creact-labs/creact 0.1.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.
- package/LICENSE +212 -0
- package/README.md +379 -0
- package/dist/cli/commands/BuildCommand.d.ts +40 -0
- package/dist/cli/commands/BuildCommand.js +151 -0
- package/dist/cli/commands/DeployCommand.d.ts +38 -0
- package/dist/cli/commands/DeployCommand.js +194 -0
- package/dist/cli/commands/DevCommand.d.ts +52 -0
- package/dist/cli/commands/DevCommand.js +385 -0
- package/dist/cli/commands/PlanCommand.d.ts +39 -0
- package/dist/cli/commands/PlanCommand.js +164 -0
- package/dist/cli/commands/index.d.ts +36 -0
- package/dist/cli/commands/index.js +43 -0
- package/dist/cli/core/ArgumentParser.d.ts +46 -0
- package/dist/cli/core/ArgumentParser.js +127 -0
- package/dist/cli/core/BaseCommand.d.ts +75 -0
- package/dist/cli/core/BaseCommand.js +95 -0
- package/dist/cli/core/CLIContext.d.ts +68 -0
- package/dist/cli/core/CLIContext.js +183 -0
- package/dist/cli/core/CommandRegistry.d.ts +64 -0
- package/dist/cli/core/CommandRegistry.js +89 -0
- package/dist/cli/core/index.d.ts +36 -0
- package/dist/cli/core/index.js +43 -0
- package/dist/cli/index.d.ts +35 -0
- package/dist/cli/index.js +100 -0
- package/dist/cli/output.d.ts +204 -0
- package/dist/cli/output.js +437 -0
- package/dist/cli/utils.d.ts +59 -0
- package/dist/cli/utils.js +76 -0
- package/dist/context/createContext.d.ts +90 -0
- package/dist/context/createContext.js +113 -0
- package/dist/context/index.d.ts +30 -0
- package/dist/context/index.js +35 -0
- package/dist/core/CReact.d.ts +409 -0
- package/dist/core/CReact.js +1127 -0
- package/dist/core/CloudDOMBuilder.d.ts +429 -0
- package/dist/core/CloudDOMBuilder.js +1198 -0
- package/dist/core/ContextDependencyTracker.d.ts +165 -0
- package/dist/core/ContextDependencyTracker.js +448 -0
- package/dist/core/ErrorRecoveryManager.d.ts +145 -0
- package/dist/core/ErrorRecoveryManager.js +443 -0
- package/dist/core/EventBus.d.ts +91 -0
- package/dist/core/EventBus.js +185 -0
- package/dist/core/ProviderOutputTracker.d.ts +211 -0
- package/dist/core/ProviderOutputTracker.js +476 -0
- package/dist/core/ReactiveUpdateQueue.d.ts +76 -0
- package/dist/core/ReactiveUpdateQueue.js +121 -0
- package/dist/core/Reconciler.d.ts +415 -0
- package/dist/core/Reconciler.js +1037 -0
- package/dist/core/RenderScheduler.d.ts +153 -0
- package/dist/core/RenderScheduler.js +519 -0
- package/dist/core/Renderer.d.ts +276 -0
- package/dist/core/Renderer.js +791 -0
- package/dist/core/Runtime.d.ts +246 -0
- package/dist/core/Runtime.js +640 -0
- package/dist/core/StateBindingManager.d.ts +121 -0
- package/dist/core/StateBindingManager.js +309 -0
- package/dist/core/StateMachine.d.ts +424 -0
- package/dist/core/StateMachine.js +787 -0
- package/dist/core/StructuralChangeDetector.d.ts +140 -0
- package/dist/core/StructuralChangeDetector.js +363 -0
- package/dist/core/Validator.d.ts +127 -0
- package/dist/core/Validator.js +279 -0
- package/dist/core/errors.d.ts +153 -0
- package/dist/core/errors.js +202 -0
- package/dist/core/index.d.ts +38 -0
- package/dist/core/index.js +64 -0
- package/dist/core/types.d.ts +263 -0
- package/dist/core/types.js +48 -0
- package/dist/hooks/context.d.ts +147 -0
- package/dist/hooks/context.js +334 -0
- package/dist/hooks/useContext.d.ts +113 -0
- package/dist/hooks/useContext.js +169 -0
- package/dist/hooks/useEffect.d.ts +105 -0
- package/dist/hooks/useEffect.js +540 -0
- package/dist/hooks/useInstance.d.ts +139 -0
- package/dist/hooks/useInstance.js +441 -0
- package/dist/hooks/useState.d.ts +120 -0
- package/dist/hooks/useState.js +298 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +70 -0
- package/dist/jsx.d.ts +64 -0
- package/dist/jsx.js +76 -0
- package/dist/providers/DummyBackendProvider.d.ts +193 -0
- package/dist/providers/DummyBackendProvider.js +189 -0
- package/dist/providers/DummyCloudProvider.d.ts +128 -0
- package/dist/providers/DummyCloudProvider.js +157 -0
- package/dist/providers/IBackendProvider.d.ts +177 -0
- package/dist/providers/IBackendProvider.js +31 -0
- package/dist/providers/ICloudProvider.d.ts +146 -0
- package/dist/providers/ICloudProvider.js +31 -0
- package/dist/providers/index.d.ts +31 -0
- package/dist/providers/index.js +31 -0
- package/dist/test-event-callbacks.d.ts +0 -0
- package/dist/test-event-callbacks.js +1 -0
- package/dist/utils/Logger.d.ts +144 -0
- package/dist/utils/Logger.js +220 -0
- package/dist/utils/Output.d.ts +161 -0
- package/dist/utils/Output.js +401 -0
- package/dist/utils/deepEqual.d.ts +71 -0
- package/dist/utils/deepEqual.js +276 -0
- package/dist/utils/naming.d.ts +241 -0
- package/dist/utils/naming.js +376 -0
- package/package.json +87 -0
|
@@ -0,0 +1,437 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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;
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.logVerbose = logVerbose;
|
|
33
|
+
exports.formatError = formatError;
|
|
34
|
+
exports.outputJson = outputJson;
|
|
35
|
+
const output_1 = require("./output");
|
|
36
|
+
const Logger_1 = require("../utils/Logger");
|
|
37
|
+
const logger = Logger_1.LoggerFactory.getLogger('cli');
|
|
38
|
+
/**
|
|
39
|
+
* Log message if verbose mode is enabled
|
|
40
|
+
*
|
|
41
|
+
* @param message - Message to log
|
|
42
|
+
* @param verbose - Whether verbose mode is enabled
|
|
43
|
+
*/
|
|
44
|
+
function logVerbose(message, verbose = false) {
|
|
45
|
+
if (verbose || process.env.CREACT_VERBOSE === 'true') {
|
|
46
|
+
logger.debug(output_1.colors.dim(`[verbose] ${message}`));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Format error for CLI output
|
|
51
|
+
*
|
|
52
|
+
* @param error - Error to format
|
|
53
|
+
* @param verbose - Whether to include stack trace
|
|
54
|
+
* @returns Formatted error message
|
|
55
|
+
*/
|
|
56
|
+
function formatError(error, verbose = false) {
|
|
57
|
+
let message = output_1.colors.error(`Error: ${error.message}`);
|
|
58
|
+
if (verbose && error.stack) {
|
|
59
|
+
message += `\n\n${output_1.colors.dim('Stack trace:')}\n${output_1.colors.dim(error.stack)}`;
|
|
60
|
+
}
|
|
61
|
+
return message;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Output data in JSON format if --json flag is set
|
|
65
|
+
*
|
|
66
|
+
* @param data - Data to output
|
|
67
|
+
* @param ctx - Command context
|
|
68
|
+
* @returns true if JSON output was used, false otherwise
|
|
69
|
+
*/
|
|
70
|
+
function outputJson(data, ctx) {
|
|
71
|
+
if (ctx.flags.json) {
|
|
72
|
+
logger.info(JSON.stringify(data, null, 2));
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
* Context object returned by createContext
|
|
32
|
+
* Contains Provider and Consumer components for sharing values down the component tree
|
|
33
|
+
*/
|
|
34
|
+
export interface Context<T> {
|
|
35
|
+
/** Unique symbol to identify this context */
|
|
36
|
+
_contextId: symbol;
|
|
37
|
+
/** Default value when no Provider is found */
|
|
38
|
+
defaultValue?: T;
|
|
39
|
+
/** Provider component to supply context value */
|
|
40
|
+
Provider: (props: {
|
|
41
|
+
value: T;
|
|
42
|
+
children?: any;
|
|
43
|
+
}) => any;
|
|
44
|
+
/** Consumer component to consume context value (alternative to useContext) */
|
|
45
|
+
Consumer: (props: {
|
|
46
|
+
children: (value: T) => any;
|
|
47
|
+
}) => any;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a typed context object (like React.createContext)
|
|
51
|
+
*
|
|
52
|
+
* Returns a context object with Provider and Consumer components.
|
|
53
|
+
* Use with useContext hook to access values from the nearest Provider.
|
|
54
|
+
*
|
|
55
|
+
* REQ-02: Stack Context (declarative outputs)
|
|
56
|
+
*
|
|
57
|
+
* @param defaultValue - Optional default value when no Provider exists
|
|
58
|
+
* @returns Context object with Provider and Consumer
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```tsx
|
|
62
|
+
* // Create a typed context
|
|
63
|
+
* interface RegistryOutputs {
|
|
64
|
+
* repositoryUrl?: string;
|
|
65
|
+
* repositoryArn?: string;
|
|
66
|
+
* }
|
|
67
|
+
*
|
|
68
|
+
* const RegistryContext = createContext<RegistryOutputs>({});
|
|
69
|
+
*
|
|
70
|
+
* // Provider component
|
|
71
|
+
* function RegistryStack({ children }) {
|
|
72
|
+
* const repo = useInstance(EcrRepository, { key: 'repo', name: 'my-app' });
|
|
73
|
+
* const [repositoryUrl, setRepositoryUrl] = useState();
|
|
74
|
+
* const [repositoryArn, setRepositoryArn] = useState();
|
|
75
|
+
*
|
|
76
|
+
* const outputs = { repositoryUrl, repositoryArn };
|
|
77
|
+
* return <RegistryContext.Provider value={outputs}>{children}</RegistryContext.Provider>;
|
|
78
|
+
* }
|
|
79
|
+
*
|
|
80
|
+
* // Consumer component
|
|
81
|
+
* function Service() {
|
|
82
|
+
* const { repositoryUrl } = useContext(RegistryContext);
|
|
83
|
+
* const service = useInstance(AppRunnerService, {
|
|
84
|
+
* image: `${repositoryUrl}:latest`
|
|
85
|
+
* });
|
|
86
|
+
* return <></>;
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function createContext<T>(defaultValue?: T): Context<T>;
|