@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
@@ -0,0 +1,95 @@
1
+ /**
2
+ * StateMachine - Resource lifecycle tracking and deployment orchestration
3
+ *
4
+ * Tracks:
5
+ * - Individual resource states (pending → applying → deployed)
6
+ * - Deployment lifecycle (start → checkpoint → complete/fail)
7
+ * - Resume capability from crash
8
+ */
9
+ import type { Backend, DeploymentState, ResourceState, SerializedNode } from '../provider/backend';
10
+ export interface StateMachineOptions {
11
+ user?: string;
12
+ enableAuditLog?: boolean;
13
+ }
14
+ /**
15
+ * StateMachine manages deployment lifecycle and resource states
16
+ */
17
+ export declare class StateMachine {
18
+ private backend;
19
+ private resourceStates;
20
+ private options;
21
+ constructor(backend: Backend, options?: StateMachineOptions);
22
+ /**
23
+ * Get the current state of a resource
24
+ */
25
+ getResourceState(nodeId: string): ResourceState;
26
+ /**
27
+ * Set the state of a resource
28
+ */
29
+ setResourceState(nodeId: string, state: ResourceState): void;
30
+ /**
31
+ * Restore resource states from persisted nodes
32
+ */
33
+ restoreResourceStates(nodes: SerializedNode[]): void;
34
+ /**
35
+ * Clear all resource states
36
+ */
37
+ clearResourceStates(): void;
38
+ /**
39
+ * Start a new deployment
40
+ */
41
+ startDeployment(stackName: string, nodes: SerializedNode[], changeStats?: {
42
+ creates: number;
43
+ updates: number;
44
+ deletes: number;
45
+ }): Promise<void>;
46
+ /**
47
+ * Update a node's outputs in persisted state (for crash recovery)
48
+ * This is the real checkpoint - nodes with outputs are considered deployed
49
+ */
50
+ updateNodeOutputs(stackName: string, nodeId: string, outputs: Record<string, any>): Promise<void>;
51
+ /**
52
+ * Mark a node as currently being applied (for crash recovery)
53
+ */
54
+ markApplying(stackName: string, nodeId: string): Promise<void>;
55
+ /**
56
+ * Clear the applying marker after successful apply
57
+ */
58
+ clearApplying(stackName: string): Promise<void>;
59
+ /**
60
+ * Record a resource being applied
61
+ */
62
+ recordResourceApplied(stackName: string, nodeId: string, outputs: Record<string, any>): Promise<void>;
63
+ /**
64
+ * Record a resource being destroyed
65
+ */
66
+ recordResourceDestroyed(stackName: string, nodeId: string): Promise<void>;
67
+ /**
68
+ * Complete a successful deployment
69
+ */
70
+ completeDeployment(stackName: string, nodes: SerializedNode[]): Promise<void>;
71
+ /**
72
+ * Record a failed deployment
73
+ */
74
+ failDeployment(stackName: string, error: Error): Promise<void>;
75
+ /**
76
+ * Check if a deployment can be resumed
77
+ */
78
+ canResume(stackName: string): Promise<boolean>;
79
+ /**
80
+ * Get the node that was being applied when crash occurred
81
+ */
82
+ getInterruptedNodeId(stackName: string): Promise<string | null>;
83
+ /**
84
+ * Get previous deployment state
85
+ */
86
+ getPreviousState(stackName: string): Promise<DeploymentState | null>;
87
+ /**
88
+ * Acquire deployment lock (if backend supports it)
89
+ */
90
+ acquireLock(stackName: string, holder: string, ttlSeconds?: number): Promise<boolean>;
91
+ /**
92
+ * Release deployment lock (if backend supports it)
93
+ */
94
+ releaseLock(stackName: string): Promise<void>;
95
+ }
@@ -0,0 +1,209 @@
1
+ /**
2
+ * StateMachine - Resource lifecycle tracking and deployment orchestration
3
+ *
4
+ * Tracks:
5
+ * - Individual resource states (pending → applying → deployed)
6
+ * - Deployment lifecycle (start → checkpoint → complete/fail)
7
+ * - Resume capability from crash
8
+ */
9
+ /**
10
+ * StateMachine manages deployment lifecycle and resource states
11
+ */
12
+ export class StateMachine {
13
+ backend;
14
+ resourceStates = new Map();
15
+ options;
16
+ constructor(backend, options = {}) {
17
+ this.backend = backend;
18
+ this.options = options;
19
+ }
20
+ /**
21
+ * Get the current state of a resource
22
+ */
23
+ getResourceState(nodeId) {
24
+ return this.resourceStates.get(nodeId) ?? 'pending';
25
+ }
26
+ /**
27
+ * Set the state of a resource
28
+ */
29
+ setResourceState(nodeId, state) {
30
+ this.resourceStates.set(nodeId, state);
31
+ }
32
+ /**
33
+ * Restore resource states from persisted nodes
34
+ */
35
+ restoreResourceStates(nodes) {
36
+ this.resourceStates.clear();
37
+ for (const node of nodes) {
38
+ // If node has outputs, it was previously deployed
39
+ const state = node.state ?? (node.outputs ? 'deployed' : 'pending');
40
+ this.resourceStates.set(node.id, state);
41
+ }
42
+ }
43
+ /**
44
+ * Clear all resource states
45
+ */
46
+ clearResourceStates() {
47
+ this.resourceStates.clear();
48
+ }
49
+ /**
50
+ * Start a new deployment
51
+ */
52
+ async startDeployment(stackName, nodes, changeStats) {
53
+ const state = {
54
+ nodes,
55
+ status: 'applying',
56
+ stackName,
57
+ lastDeployedAt: Date.now(),
58
+ user: this.options.user,
59
+ };
60
+ await this.backend.saveState(stackName, state);
61
+ if (this.options.enableAuditLog && this.backend.appendAuditLog) {
62
+ await this.backend.appendAuditLog(stackName, {
63
+ timestamp: Date.now(),
64
+ action: 'deploy_start',
65
+ user: this.options.user,
66
+ details: changeStats,
67
+ });
68
+ }
69
+ }
70
+ /**
71
+ * Update a node's outputs in persisted state (for crash recovery)
72
+ * This is the real checkpoint - nodes with outputs are considered deployed
73
+ */
74
+ async updateNodeOutputs(stackName, nodeId, outputs) {
75
+ const state = await this.backend.getState(stackName);
76
+ if (state) {
77
+ const node = state.nodes.find((n) => n.id === nodeId);
78
+ if (node) {
79
+ node.outputs = outputs;
80
+ await this.backend.saveState(stackName, state);
81
+ }
82
+ }
83
+ }
84
+ /**
85
+ * Mark a node as currently being applied (for crash recovery)
86
+ */
87
+ async markApplying(stackName, nodeId) {
88
+ const state = await this.backend.getState(stackName);
89
+ if (state) {
90
+ state.applyingNodeId = nodeId;
91
+ await this.backend.saveState(stackName, state);
92
+ }
93
+ }
94
+ /**
95
+ * Clear the applying marker after successful apply
96
+ */
97
+ async clearApplying(stackName) {
98
+ const state = await this.backend.getState(stackName);
99
+ if (state) {
100
+ state.applyingNodeId = undefined;
101
+ await this.backend.saveState(stackName, state);
102
+ }
103
+ }
104
+ /**
105
+ * Record a resource being applied
106
+ */
107
+ async recordResourceApplied(stackName, nodeId, outputs) {
108
+ this.setResourceState(nodeId, 'deployed');
109
+ if (this.options.enableAuditLog && this.backend.appendAuditLog) {
110
+ await this.backend.appendAuditLog(stackName, {
111
+ timestamp: Date.now(),
112
+ action: 'resource_applied',
113
+ nodeId,
114
+ user: this.options.user,
115
+ details: { outputKeys: Object.keys(outputs) },
116
+ });
117
+ }
118
+ }
119
+ /**
120
+ * Record a resource being destroyed
121
+ */
122
+ async recordResourceDestroyed(stackName, nodeId) {
123
+ this.resourceStates.delete(nodeId);
124
+ if (this.options.enableAuditLog && this.backend.appendAuditLog) {
125
+ await this.backend.appendAuditLog(stackName, {
126
+ timestamp: Date.now(),
127
+ action: 'resource_destroyed',
128
+ nodeId,
129
+ user: this.options.user,
130
+ });
131
+ }
132
+ }
133
+ /**
134
+ * Complete a successful deployment
135
+ */
136
+ async completeDeployment(stackName, nodes) {
137
+ const state = {
138
+ nodes,
139
+ status: 'deployed',
140
+ stackName,
141
+ lastDeployedAt: Date.now(),
142
+ user: this.options.user,
143
+ };
144
+ await this.backend.saveState(stackName, state);
145
+ if (this.options.enableAuditLog && this.backend.appendAuditLog) {
146
+ await this.backend.appendAuditLog(stackName, {
147
+ timestamp: Date.now(),
148
+ action: 'deploy_complete',
149
+ user: this.options.user,
150
+ details: { nodeCount: nodes.length },
151
+ });
152
+ }
153
+ }
154
+ /**
155
+ * Record a failed deployment
156
+ */
157
+ async failDeployment(stackName, error) {
158
+ const state = await this.backend.getState(stackName);
159
+ if (state) {
160
+ state.status = 'failed';
161
+ await this.backend.saveState(stackName, state);
162
+ }
163
+ if (this.options.enableAuditLog && this.backend.appendAuditLog) {
164
+ await this.backend.appendAuditLog(stackName, {
165
+ timestamp: Date.now(),
166
+ action: 'deploy_failed',
167
+ user: this.options.user,
168
+ details: { error: error.message },
169
+ });
170
+ }
171
+ }
172
+ /**
173
+ * Check if a deployment can be resumed
174
+ */
175
+ async canResume(stackName) {
176
+ const state = await this.backend.getState(stackName);
177
+ return state?.status === 'applying';
178
+ }
179
+ /**
180
+ * Get the node that was being applied when crash occurred
181
+ */
182
+ async getInterruptedNodeId(stackName) {
183
+ const state = await this.backend.getState(stackName);
184
+ return state?.applyingNodeId ?? null;
185
+ }
186
+ /**
187
+ * Get previous deployment state
188
+ */
189
+ async getPreviousState(stackName) {
190
+ return this.backend.getState(stackName);
191
+ }
192
+ /**
193
+ * Acquire deployment lock (if backend supports it)
194
+ */
195
+ async acquireLock(stackName, holder, ttlSeconds = 300) {
196
+ if (this.backend.acquireLock) {
197
+ return this.backend.acquireLock(stackName, holder, ttlSeconds);
198
+ }
199
+ return true; // No locking support, allow
200
+ }
201
+ /**
202
+ * Release deployment lock (if backend supports it)
203
+ */
204
+ async releaseLock(stackName) {
205
+ if (this.backend.releaseLock) {
206
+ await this.backend.releaseLock(stackName);
207
+ }
208
+ }
209
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Shared types
3
+ */
4
+ export type { JSXElement } from './jsx/jsx-runtime';
5
+ export type { Context } from './primitives/context';
6
+ export type { InstanceNode, OutputAccessors } from './primitives/instance';
7
+ export type { SetStoreFunction } from './primitives/store';
8
+ export type { AuditLogEntry, Backend, DeploymentState, DeploymentStatus, ResourceState, SerializedNode, } from './provider/backend';
9
+ export type { Provider } from './provider/interface';
10
+ export type { Accessor, Computation, Setter, Signal } from './reactive/signal';
11
+ export type { Fiber } from './runtime/fiber';
12
+ export type { ChangeSet, DependencyGraph } from './runtime/reconcile';
13
+ export type { StateMachineOptions } from './runtime/state-machine';
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Shared types
3
+ */
4
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@creact-labs/creact",
3
- "version": "0.1.7",
4
- "description": "CReact - React for Infrastructure. Render JSX to CloudDOM.",
3
+ "version": "0.2.0",
4
+ "description": "Declarative universal reactive runtime",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "typesVersions": {
@@ -26,26 +26,20 @@
26
26
  "prepublishOnly": "npm run build"
27
27
  },
28
28
  "keywords": [
29
- "infrastructure",
30
- "infrastructure-as-code",
31
- "iac",
29
+ "reactive",
30
+ "declarative",
31
+ "runtime",
32
32
  "jsx",
33
- "react",
33
+ "ai-agents",
34
+ "automation",
35
+ "orchestration",
36
+ "workflow",
37
+ "infrastructure-as-code",
34
38
  "cloud",
35
- "terraform",
36
- "aws",
37
- "kubernetes",
38
39
  "devops",
39
40
  "deployment",
40
- "orchestration",
41
- "clouddom",
42
41
  "reconciler",
43
- "reactive",
44
- "pulumi",
45
- "cdk",
46
- "helm",
47
- "multi-cloud",
48
- "declarative"
42
+ "multi-cloud"
49
43
  ],
50
44
  "author": "Daniel Coutinho Ribeiro <dcoutinho.96@gmail.com>",
51
45
  "license": "Apache-2.0",
@@ -67,28 +61,18 @@
67
61
  ],
68
62
  "devDependencies": {
69
63
  "@eslint/js": "^9.37.0",
70
- "@types/better-sqlite3": "^7.6.13",
71
- "@types/cli-progress": "^3.11.6",
72
64
  "@types/node": "^20.0.0",
73
65
  "@typescript-eslint/eslint-plugin": "^8.45.0",
74
66
  "@typescript-eslint/parser": "^8.45.0",
75
- "better-sqlite3": "^12.4.1",
76
67
  "eslint": "^9.37.0",
77
68
  "eslint-config-prettier": "^10.1.8",
78
69
  "eslint-plugin-prettier": "^5.5.4",
79
70
  "prettier": "^3.6.2",
80
- "ts-node": "^10.9.2",
81
71
  "typescript": "^5.0.0",
82
72
  "typescript-eslint": "^8.45.0",
83
73
  "vitest": "^3.2.4"
84
74
  },
85
- "peerDependencies": {
86
- "react": "^18.0.0"
87
- },
88
75
  "dependencies": {
89
- "chalk": "^4.1.2",
90
- "cli-progress": "^3.12.0",
91
- "ora": "^5.4.1",
92
76
  "tsx": "^4.20.6"
93
77
  }
94
78
  }
@@ -1,40 +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
- * Build Command - builds CloudDOM from entry file
32
- */
33
- import { BaseCommand, CommandResult } from '../core/BaseCommand';
34
- export declare class BuildCommand extends BaseCommand {
35
- getName(): string;
36
- getDescription(): string;
37
- execute(): Promise<CommandResult>;
38
- private printVerboseOutput;
39
- private countResources;
40
- }
@@ -1,151 +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.BuildCommand = void 0;
33
- /**
34
- * Build Command - builds CloudDOM from entry file
35
- */
36
- const BaseCommand_1 = require("../core/BaseCommand");
37
- const CLIContext_1 = require("../core/CLIContext");
38
- const Output_1 = require("../../utils/Output");
39
- const Logger_1 = require("../../utils/Logger");
40
- const logger = Logger_1.LoggerFactory.getLogger('cli');
41
- class BuildCommand extends BaseCommand_1.BaseCommand {
42
- getName() {
43
- return 'build';
44
- }
45
- getDescription() {
46
- return 'Build CloudDOM from entry file';
47
- }
48
- async execute() {
49
- const output = (0, Output_1.createOutputManager)({
50
- json: this.json,
51
- quiet: !!this.context.flags.quiet,
52
- verbose: this.verbose,
53
- });
54
- try {
55
- // Find entry file
56
- logger.debug('BuildCommand: Starting execution');
57
- let entryPath;
58
- try {
59
- entryPath = CLIContext_1.CLIContextManager.findEntryFile(this.context.flags.entry);
60
- logger.debug(`BuildCommand: Entry file resolved to ${entryPath}`);
61
- }
62
- catch (error) {
63
- output.showError('Entry file resolution failed', {
64
- cause: error.message,
65
- stackTrace: this.verbose ? error.stack : undefined,
66
- });
67
- return { exitCode: 1 };
68
- }
69
- // Load entry file and create CLI instance
70
- output.showInfo('Loading entry file and configuring providers...');
71
- let result;
72
- try {
73
- result = await CLIContext_1.CLIContextManager.createCLIInstance(entryPath, this.verbose);
74
- logger.debug(`BuildCommand: CloudDOM built with ${result.cloudDOM.length} resources`);
75
- }
76
- catch (error) {
77
- output.showError('Failed to load entry file and configure providers', {
78
- cause: error.message,
79
- stackTrace: this.verbose ? error.stack : undefined,
80
- });
81
- return { exitCode: 1 };
82
- }
83
- output.showSuccess('Entry file loaded and providers configured');
84
- // Success output
85
- const message = `Build complete: ${result.cloudDOM.length} resources`;
86
- if (this.verbose && !this.json) {
87
- this.printVerboseOutput(result, output);
88
- }
89
- output.showSuccess(message);
90
- if (this.json) {
91
- console.log(JSON.stringify({
92
- status: 'success',
93
- resourceCount: result.cloudDOM.length,
94
- entryFile: entryPath,
95
- stackName: result.stackName,
96
- resources: result.cloudDOM.map((node) => ({
97
- id: node.id,
98
- type: node.construct?.name || 'Unknown',
99
- path: node.path,
100
- })),
101
- }, null, 2));
102
- }
103
- return { exitCode: 0 };
104
- }
105
- catch (error) {
106
- output.showError('Build failed', {
107
- cause: error.message,
108
- stackTrace: this.verbose ? error.stack : undefined,
109
- });
110
- return { exitCode: 1 };
111
- }
112
- }
113
- printVerboseOutput(result, output) {
114
- console.log('\nCloudDOM Summary:');
115
- const resourceCounts = this.countResources(result.cloudDOM);
116
- if (Object.keys(resourceCounts).length === 0) {
117
- console.log(' No resources found');
118
- }
119
- else {
120
- for (const [type, count] of Object.entries(resourceCounts)) {
121
- console.log(` ${type}: ${count}`);
122
- }
123
- }
124
- // Show first few resource IDs for debugging
125
- if (result.cloudDOM.length > 0) {
126
- console.log('\nResource IDs:');
127
- const sampleIds = result.cloudDOM.slice(0, 5).map((node) => node.id);
128
- sampleIds.forEach((id) => {
129
- console.log(` • ${id}`);
130
- });
131
- if (result.cloudDOM.length > 5) {
132
- console.log(` ... and ${result.cloudDOM.length - 5} more`);
133
- }
134
- }
135
- }
136
- countResources(cloudDOM) {
137
- const counts = {};
138
- const walk = (nodes) => {
139
- for (const node of nodes) {
140
- const type = node.construct?.name || 'Unknown';
141
- counts[type] = (counts[type] || 0) + 1;
142
- if (node.children && node.children.length > 0) {
143
- walk(node.children);
144
- }
145
- }
146
- };
147
- walk(cloudDOM);
148
- return counts;
149
- }
150
- }
151
- exports.BuildCommand = BuildCommand;
@@ -1,38 +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
- * Deploy Command - deploys CloudDOM to cloud provider
32
- */
33
- import { BaseCommand, CommandResult } from '../core/BaseCommand';
34
- export declare class DeployCommand extends BaseCommand {
35
- getName(): string;
36
- getDescription(): string;
37
- execute(): Promise<CommandResult>;
38
- }