@creact-labs/creact 0.1.7 → 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 +72 -21
  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 -27
  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,164 +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
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.PlanCommand = void 0;
33
- /**
34
- * Plan Command - shows diff between current and previous CloudDOM
35
- */
36
- const BaseCommand_1 = require("../core/BaseCommand");
37
- const CLIContext_1 = require("../core/CLIContext");
38
- const Output_1 = require("../../utils/Output");
39
- const Reconciler_1 = require("../../core/Reconciler");
40
- const Logger_1 = require("../../utils/Logger");
41
- const logger = Logger_1.LoggerFactory.getLogger('cli');
42
- class PlanCommand extends BaseCommand_1.BaseCommand {
43
- getName() {
44
- return 'plan';
45
- }
46
- getDescription() {
47
- return 'Show diff between current and previous CloudDOM';
48
- }
49
- async execute() {
50
- const output = (0, Output_1.createOutputManager)({
51
- json: this.json,
52
- quiet: !!this.context.flags.quiet,
53
- verbose: this.verbose,
54
- });
55
- try {
56
- // Find entry file
57
- logger.debug('PlanCommand: Starting execution');
58
- let entryPath;
59
- try {
60
- entryPath = CLIContext_1.CLIContextManager.findEntryFile(this.context.flags.entry);
61
- logger.debug(`PlanCommand: Entry file resolved to ${entryPath}`);
62
- }
63
- catch (error) {
64
- output.showError('Entry file resolution failed', {
65
- cause: error.message,
66
- stackTrace: this.verbose ? error.stack : undefined,
67
- });
68
- return { exitCode: 1 };
69
- }
70
- // Load entry file and create CLI instance
71
- output.showInfo('Loading entry file and configuring providers...');
72
- let result;
73
- try {
74
- result = await CLIContext_1.CLIContextManager.createCLIInstance(entryPath, this.verbose);
75
- logger.debug(`PlanCommand: Current CloudDOM built with ${result.cloudDOM.length} resources`);
76
- }
77
- catch (error) {
78
- output.showError('Failed to load entry file and configure providers', {
79
- cause: error.message,
80
- stackTrace: this.verbose ? error.stack : undefined,
81
- });
82
- return { exitCode: 1 };
83
- }
84
- output.showSuccess('Entry file loaded and providers configured');
85
- // Load previous CloudDOM from backend
86
- output.showInfo('Loading previous state...');
87
- let previousCloudDOM = [];
88
- try {
89
- const previousState = await result.instance.getBackendProvider().getState(result.stackName);
90
- if (previousState && previousState.cloudDOM) {
91
- previousCloudDOM = previousState.cloudDOM;
92
- logger.debug(`PlanCommand: Previous CloudDOM loaded with ${previousCloudDOM.length} resources`);
93
- }
94
- else {
95
- logger.debug('PlanCommand: No previous state found (first deployment)');
96
- }
97
- }
98
- catch (stateError) {
99
- logger.debug(`PlanCommand: Could not load previous state: ${stateError.message}`);
100
- // Continue with empty previous state
101
- }
102
- output.showSuccess('Previous state loaded');
103
- // Compute diff using Reconciler
104
- output.showInfo('Computing changes...');
105
- const reconciler = new Reconciler_1.Reconciler();
106
- const changeSet = reconciler.reconcile(previousCloudDOM, result.cloudDOM);
107
- logger.debug(`PlanCommand: Changes computed: ${changeSet.creates.length} creates, ${changeSet.updates.length} updates, ${changeSet.deletes.length} deletes, ${changeSet.replacements.length} replacements`);
108
- output.showSuccess('Changes computed');
109
- // Check if there are any changes
110
- const hasChanges = changeSet.creates.length > 0 ||
111
- changeSet.updates.length > 0 ||
112
- changeSet.deletes.length > 0 ||
113
- changeSet.replacements.length > 0 ||
114
- changeSet.moves.length > 0;
115
- // Display plan
116
- output.showPlanHeader(result.stackName);
117
- output.showPlanChanges(changeSet);
118
- output.showPlanSummary(changeSet);
119
- if (this.verbose && !this.json) {
120
- this.printVerboseOutput(changeSet);
121
- }
122
- if (!hasChanges) {
123
- return { exitCode: 0 };
124
- }
125
- // Output results
126
- const totalChanges = changeSet.creates.length +
127
- changeSet.updates.length +
128
- changeSet.deletes.length +
129
- changeSet.replacements.length +
130
- changeSet.moves.length;
131
- if (this.json) {
132
- const diffVisualization = reconciler.generateDiffVisualization(changeSet);
133
- console.log(JSON.stringify({
134
- status: 'success',
135
- message: `Plan complete: ${totalChanges} changes`,
136
- summary: diffVisualization.summary,
137
- changes: diffVisualization.changes,
138
- deployment: diffVisualization.deployment,
139
- }, null, 2));
140
- }
141
- return { exitCode: 0 };
142
- }
143
- catch (error) {
144
- output.showError('Plan failed', {
145
- cause: error.message,
146
- stackTrace: this.verbose ? error.stack : undefined,
147
- });
148
- return { exitCode: 1 };
149
- }
150
- }
151
- printVerboseOutput(changeSet) {
152
- console.log('\nDeployment Order:');
153
- changeSet.deploymentOrder.forEach((nodeId, index) => {
154
- console.log(` ${String(index + 1).padStart(2)}. ${nodeId}`);
155
- });
156
- if (changeSet.parallelBatches.length > 1) {
157
- console.log('\nParallel Batches:');
158
- changeSet.parallelBatches.forEach((batch, index) => {
159
- console.log(` Batch ${index + 1}: ${batch.join(', ')}`);
160
- });
161
- }
162
- }
163
- }
164
- exports.PlanCommand = PlanCommand;
@@ -1,36 +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
- * Command exports - centralized command registration
32
- */
33
- export { BuildCommand } from './BuildCommand';
34
- export { PlanCommand } from './PlanCommand';
35
- export { DeployCommand } from './DeployCommand';
36
- export { DevCommand } from './DevCommand';
@@ -1,43 +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
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.DevCommand = exports.DeployCommand = exports.PlanCommand = exports.BuildCommand = void 0;
33
- /**
34
- * Command exports - centralized command registration
35
- */
36
- var BuildCommand_1 = require("./BuildCommand");
37
- Object.defineProperty(exports, "BuildCommand", { enumerable: true, get: function () { return BuildCommand_1.BuildCommand; } });
38
- var PlanCommand_1 = require("./PlanCommand");
39
- Object.defineProperty(exports, "PlanCommand", { enumerable: true, get: function () { return PlanCommand_1.PlanCommand; } });
40
- var DeployCommand_1 = require("./DeployCommand");
41
- Object.defineProperty(exports, "DeployCommand", { enumerable: true, get: function () { return DeployCommand_1.DeployCommand; } });
42
- var DevCommand_1 = require("./DevCommand");
43
- Object.defineProperty(exports, "DevCommand", { enumerable: true, get: function () { return DevCommand_1.DevCommand; } });
@@ -1,46 +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
- * Argument Parser - parses CLI arguments and flags
32
- */
33
- import { CLIContext } from './CLIContext';
34
- /**
35
- * Simple argument parser for CLI commands
36
- */
37
- export declare class ArgumentParser {
38
- /**
39
- * Parse command line arguments into context
40
- */
41
- static parse(argv: string[]): CLIContext;
42
- /**
43
- * Show help message
44
- */
45
- static showHelp(): void;
46
- }
@@ -1,127 +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
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.ArgumentParser = void 0;
33
- const Logger_1 = require("../../utils/Logger");
34
- const logger = Logger_1.LoggerFactory.getLogger('cli');
35
- /**
36
- * Simple argument parser for CLI commands
37
- */
38
- class ArgumentParser {
39
- /**
40
- * Parse command line arguments into context
41
- */
42
- static parse(argv) {
43
- // Remove node and script path
44
- const args = argv.slice(2);
45
- if (args.length === 0) {
46
- throw new Error('No command specified');
47
- }
48
- const command = args[0];
49
- const remainingArgs = args.slice(1);
50
- const flags = {};
51
- const positionalArgs = [];
52
- for (let i = 0; i < remainingArgs.length; i++) {
53
- const arg = remainingArgs[i];
54
- if (arg.startsWith('--')) {
55
- // Long flag
56
- const flagName = arg.slice(2);
57
- if (flagName.includes('=')) {
58
- // --flag=value
59
- const [name, value] = flagName.split('=', 2);
60
- flags[name] = value;
61
- }
62
- else {
63
- // --flag or --flag value
64
- const nextArg = remainingArgs[i + 1];
65
- if (nextArg && !nextArg.startsWith('-')) {
66
- // --flag value
67
- flags[flagName] = nextArg;
68
- i++; // Skip next arg
69
- }
70
- else {
71
- // --flag (boolean)
72
- flags[flagName] = true;
73
- }
74
- }
75
- }
76
- else if (arg.startsWith('-') && arg.length > 1) {
77
- // Short flag(s)
78
- const shortFlags = arg.slice(1);
79
- for (const flag of shortFlags) {
80
- flags[flag] = true;
81
- }
82
- }
83
- else {
84
- // Positional argument
85
- positionalArgs.push(arg);
86
- }
87
- }
88
- return {
89
- args: [command, ...positionalArgs],
90
- flags,
91
- };
92
- }
93
- /**
94
- * Show help message
95
- */
96
- static showHelp() {
97
- logger.info(`
98
- CReact CLI - Infrastructure as Code with JSX
99
-
100
- Usage:
101
- creact <command> [options]
102
-
103
- Commands:
104
- build Build CloudDOM from entry file
105
- plan Show diff between current and previous CloudDOM
106
- deploy Deploy CloudDOM to cloud provider
107
- dev Hot reload development mode
108
-
109
- Options:
110
- --entry <file> Entry file path (default: index.ts)
111
- --verbose, -v Verbose output
112
- --json JSON output format
113
- --dry-run Simulate deployment without applying changes
114
- --auto-approve Auto-approve changes in dev mode (alias: --auto)
115
- --help, -h Show help
116
-
117
- Examples:
118
- creact build
119
- creact build --entry app.ts --verbose
120
- creact plan --json
121
- creact deploy --dry-run
122
- creact dev
123
- creact dev --auto-approve
124
- `);
125
- }
126
- }
127
- exports.ArgumentParser = ArgumentParser;
@@ -1,75 +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
- * Base Command - abstract base class for all CLI commands
32
- */
33
- import { CLIContext } from './CLIContext';
34
- export interface CommandResult {
35
- exitCode: number;
36
- message?: string;
37
- data?: any;
38
- }
39
- /**
40
- * Abstract base class for CLI commands
41
- */
42
- export declare abstract class BaseCommand {
43
- protected context: CLIContext;
44
- protected verbose: boolean;
45
- protected json: boolean;
46
- constructor(context: CLIContext);
47
- /**
48
- * Execute the command
49
- */
50
- abstract execute(): Promise<CommandResult>;
51
- /**
52
- * Get command name for help/error messages
53
- */
54
- abstract getName(): string;
55
- /**
56
- * Get command description for help
57
- */
58
- abstract getDescription(): string;
59
- /**
60
- * Log verbose message
61
- */
62
- protected logVerbose(message: string): void;
63
- /**
64
- * Output JSON if json flag is set, otherwise return false
65
- */
66
- protected outputJson(data: any): boolean;
67
- /**
68
- * Handle errors consistently
69
- */
70
- protected handleError(error: Error, context?: string): CommandResult;
71
- /**
72
- * Handle success consistently
73
- */
74
- protected handleSuccess(message: string, data?: any): CommandResult;
75
- }
@@ -1,95 +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
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.BaseCommand = void 0;
33
- const Logger_1 = require("../../utils/Logger");
34
- const logger = Logger_1.LoggerFactory.getLogger('cli');
35
- /**
36
- * Abstract base class for CLI commands
37
- */
38
- class BaseCommand {
39
- constructor(context) {
40
- this.context = context;
41
- this.verbose = !!context.flags.verbose;
42
- this.json = !!context.flags.json;
43
- }
44
- /**
45
- * Log verbose message
46
- */
47
- logVerbose(message) {
48
- if (this.verbose) {
49
- logger.debug(`[${this.getName()}] ${message}`);
50
- }
51
- }
52
- /**
53
- * Output JSON if json flag is set, otherwise return false
54
- */
55
- outputJson(data) {
56
- if (this.json) {
57
- logger.info(JSON.stringify(data, null, 2));
58
- return true;
59
- }
60
- return false;
61
- }
62
- /**
63
- * Handle errors consistently
64
- */
65
- handleError(error, context) {
66
- const message = context ? `${context}: ${error.message}` : error.message;
67
- if (this.outputJson({
68
- status: 'error',
69
- error: error.message,
70
- stack: this.verbose ? error.stack : undefined,
71
- })) {
72
- return { exitCode: 1 };
73
- }
74
- logger.error(`Error: ${message}`);
75
- if (this.verbose && error.stack) {
76
- logger.error(error.stack);
77
- }
78
- return { exitCode: 1, message };
79
- }
80
- /**
81
- * Handle success consistently
82
- */
83
- handleSuccess(message, data) {
84
- if (this.outputJson({
85
- status: 'success',
86
- message,
87
- ...data,
88
- })) {
89
- return { exitCode: 0 };
90
- }
91
- logger.info(message);
92
- return { exitCode: 0, message, data };
93
- }
94
- }
95
- exports.BaseCommand = BaseCommand;
@@ -1,68 +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
- import { CReact } from '../../core/CReact';
31
- import { CloudDOMNode } from '../../core/types';
32
- export interface CLIFlags {
33
- entry?: string;
34
- verbose?: boolean;
35
- json?: boolean;
36
- 'dry-run'?: boolean;
37
- 'auto-approve'?: boolean;
38
- auto?: boolean;
39
- help?: boolean;
40
- h?: boolean;
41
- version?: boolean;
42
- V?: boolean;
43
- [key: string]: string | boolean | undefined;
44
- }
45
- export interface CLIContext {
46
- args: string[];
47
- flags: CLIFlags;
48
- }
49
- export interface CLIResult {
50
- instance: CReact;
51
- stackName: string;
52
- cloudDOM: CloudDOMNode[];
53
- entryPath: string;
54
- }
55
- /**
56
- * CLI Context Manager - handles entry file loading and instance creation
57
- */
58
- export declare class CLIContextManager {
59
- /**
60
- * Find entry file with fallback logic
61
- */
62
- static findEntryFile(specifiedPath?: string): string;
63
- /**
64
- * Load entry file and create CReact instance using configured providers
65
- * This is the React way - load configuration, then create instances as needed
66
- */
67
- static createCLIInstance(entryPath: string, verbose?: boolean): Promise<CLIResult>;
68
- }