tfts 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 +21 -0
- package/README.md +171 -0
- package/dist/bin/tfts.d.ts +3 -0
- package/dist/bin/tfts.d.ts.map +1 -0
- package/dist/bin/tfts.js +5 -0
- package/dist/bin/tfts.js.map +1 -0
- package/dist/src/cli/config.d.ts +43 -0
- package/dist/src/cli/config.d.ts.map +1 -0
- package/dist/src/cli/config.js +63 -0
- package/dist/src/cli/config.js.map +1 -0
- package/dist/src/cli/diff.d.ts +25 -0
- package/dist/src/cli/diff.d.ts.map +1 -0
- package/dist/src/cli/diff.js +105 -0
- package/dist/src/cli/diff.js.map +1 -0
- package/dist/src/cli/get.d.ts +24 -0
- package/dist/src/cli/get.d.ts.map +1 -0
- package/dist/src/cli/get.js +41 -0
- package/dist/src/cli/get.js.map +1 -0
- package/dist/src/cli/index.d.ts +2 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +157 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/cli/synth.d.ts +32 -0
- package/dist/src/cli/synth.d.ts.map +1 -0
- package/dist/src/cli/synth.js +52 -0
- package/dist/src/cli/synth.js.map +1 -0
- package/dist/src/codegen/__tests__/generator.spec.d.ts +2 -0
- package/dist/src/codegen/__tests__/generator.spec.d.ts.map +1 -0
- package/dist/src/codegen/__tests__/generator.spec.js +22 -0
- package/dist/src/codegen/__tests__/generator.spec.js.map +1 -0
- package/dist/src/codegen/generator.d.ts +7 -0
- package/dist/src/codegen/generator.d.ts.map +1 -0
- package/dist/src/codegen/generator.js +160 -0
- package/dist/src/codegen/generator.js.map +1 -0
- package/dist/src/codegen/schema.d.ts +46 -0
- package/dist/src/codegen/schema.d.ts.map +1 -0
- package/dist/src/codegen/schema.js +141 -0
- package/dist/src/codegen/schema.js.map +1 -0
- package/dist/src/codegen/templates.d.ts +14 -0
- package/dist/src/codegen/templates.d.ts.map +1 -0
- package/dist/src/codegen/templates.js +74 -0
- package/dist/src/codegen/templates.js.map +1 -0
- package/dist/src/core/backend.d.ts +5 -0
- package/dist/src/core/backend.d.ts.map +1 -0
- package/dist/src/core/backend.js +2 -0
- package/dist/src/core/backend.js.map +1 -0
- package/dist/src/core/construct.d.ts +42 -0
- package/dist/src/core/construct.d.ts.map +1 -0
- package/dist/src/core/construct.js +2 -0
- package/dist/src/core/construct.js.map +1 -0
- package/dist/src/core/datasource.d.ts +8 -0
- package/dist/src/core/datasource.d.ts.map +1 -0
- package/dist/src/core/datasource.js +2 -0
- package/dist/src/core/datasource.js.map +1 -0
- package/dist/src/core/errors.d.ts +29 -0
- package/dist/src/core/errors.d.ts.map +1 -0
- package/dist/src/core/errors.js +2 -0
- package/dist/src/core/errors.js.map +1 -0
- package/dist/src/core/local.d.ts +4 -0
- package/dist/src/core/local.d.ts.map +1 -0
- package/dist/src/core/local.js +2 -0
- package/dist/src/core/local.js.map +1 -0
- package/dist/src/core/logical-id.d.ts +3 -0
- package/dist/src/core/logical-id.d.ts.map +1 -0
- package/dist/src/core/logical-id.js +48 -0
- package/dist/src/core/logical-id.js.map +1 -0
- package/dist/src/core/output.d.ts +8 -0
- package/dist/src/core/output.d.ts.map +1 -0
- package/dist/src/core/output.js +2 -0
- package/dist/src/core/output.js.map +1 -0
- package/dist/src/core/provider.d.ts +7 -0
- package/dist/src/core/provider.d.ts.map +1 -0
- package/dist/src/core/provider.js +2 -0
- package/dist/src/core/provider.js.map +1 -0
- package/dist/src/core/resource.d.ts +30 -0
- package/dist/src/core/resource.d.ts.map +1 -0
- package/dist/src/core/resource.js +2 -0
- package/dist/src/core/resource.js.map +1 -0
- package/dist/src/core/synthesize.d.ts +78 -0
- package/dist/src/core/synthesize.d.ts.map +1 -0
- package/dist/src/core/synthesize.js +293 -0
- package/dist/src/core/synthesize.js.map +1 -0
- package/dist/src/core/synthesize.spec.d.ts +2 -0
- package/dist/src/core/synthesize.spec.d.ts.map +1 -0
- package/dist/src/core/synthesize.spec.js +506 -0
- package/dist/src/core/synthesize.spec.js.map +1 -0
- package/dist/src/core/terraform-json.d.ts +36 -0
- package/dist/src/core/terraform-json.d.ts.map +1 -0
- package/dist/src/core/terraform-json.js +2 -0
- package/dist/src/core/terraform-json.js.map +1 -0
- package/dist/src/core/tokens.d.ts +55 -0
- package/dist/src/core/tokens.d.ts.map +1 -0
- package/dist/src/core/tokens.js +98 -0
- package/dist/src/core/tokens.js.map +1 -0
- package/dist/src/core/tokens.spec.d.ts +2 -0
- package/dist/src/core/tokens.spec.d.ts.map +1 -0
- package/dist/src/core/tokens.spec.js +119 -0
- package/dist/src/core/tokens.spec.js.map +1 -0
- package/dist/src/core/tree.d.ts +6 -0
- package/dist/src/core/tree.d.ts.map +1 -0
- package/dist/src/core/tree.js +52 -0
- package/dist/src/core/tree.js.map +1 -0
- package/dist/src/core/tree.spec.d.ts +2 -0
- package/dist/src/core/tree.spec.d.ts.map +1 -0
- package/dist/src/core/tree.spec.js +138 -0
- package/dist/src/core/tree.spec.js.map +1 -0
- package/dist/src/core/validate.d.ts +5 -0
- package/dist/src/core/validate.d.ts.map +1 -0
- package/dist/src/core/validate.js +94 -0
- package/dist/src/core/validate.js.map +1 -0
- package/dist/src/core/validate.spec.d.ts +2 -0
- package/dist/src/core/validate.spec.d.ts.map +1 -0
- package/dist/src/core/validate.spec.js +69 -0
- package/dist/src/core/validate.spec.js.map +1 -0
- package/dist/src/core/variable.d.ts +14 -0
- package/dist/src/core/variable.d.ts.map +1 -0
- package/dist/src/core/variable.js +2 -0
- package/dist/src/core/variable.js.map +1 -0
- package/dist/src/facade/app.d.ts +23 -0
- package/dist/src/facade/app.d.ts.map +1 -0
- package/dist/src/facade/app.js +55 -0
- package/dist/src/facade/app.js.map +1 -0
- package/dist/src/facade/backends/backend.d.ts +7 -0
- package/dist/src/facade/backends/backend.d.ts.map +1 -0
- package/dist/src/facade/backends/backend.js +15 -0
- package/dist/src/facade/backends/backend.js.map +1 -0
- package/dist/src/facade/backends/gcs.d.ts +18 -0
- package/dist/src/facade/backends/gcs.d.ts.map +1 -0
- package/dist/src/facade/backends/gcs.js +28 -0
- package/dist/src/facade/backends/gcs.js.map +1 -0
- package/dist/src/facade/backends/index.d.ts +6 -0
- package/dist/src/facade/backends/index.d.ts.map +1 -0
- package/dist/src/facade/backends/index.js +6 -0
- package/dist/src/facade/backends/index.js.map +1 -0
- package/dist/src/facade/backends/local.d.ts +12 -0
- package/dist/src/facade/backends/local.d.ts.map +1 -0
- package/dist/src/facade/backends/local.js +16 -0
- package/dist/src/facade/backends/local.js.map +1 -0
- package/dist/src/facade/backends/remote.d.ts +22 -0
- package/dist/src/facade/backends/remote.d.ts.map +1 -0
- package/dist/src/facade/backends/remote.js +23 -0
- package/dist/src/facade/backends/remote.js.map +1 -0
- package/dist/src/facade/backends/s3.d.ts +24 -0
- package/dist/src/facade/backends/s3.d.ts.map +1 -0
- package/dist/src/facade/backends/s3.js +39 -0
- package/dist/src/facade/backends/s3.js.map +1 -0
- package/dist/src/facade/construct.d.ts +9 -0
- package/dist/src/facade/construct.d.ts.map +1 -0
- package/dist/src/facade/construct.js +32 -0
- package/dist/src/facade/construct.js.map +1 -0
- package/dist/src/facade/datasource.d.ts +20 -0
- package/dist/src/facade/datasource.d.ts.map +1 -0
- package/dist/src/facade/datasource.js +33 -0
- package/dist/src/facade/datasource.js.map +1 -0
- package/dist/src/facade/facade.spec.d.ts +2 -0
- package/dist/src/facade/facade.spec.d.ts.map +1 -0
- package/dist/src/facade/facade.spec.js +434 -0
- package/dist/src/facade/facade.spec.js.map +1 -0
- package/dist/src/facade/local.d.ts +15 -0
- package/dist/src/facade/local.d.ts.map +1 -0
- package/dist/src/facade/local.js +27 -0
- package/dist/src/facade/local.js.map +1 -0
- package/dist/src/facade/output.d.ts +18 -0
- package/dist/src/facade/output.d.ts.map +1 -0
- package/dist/src/facade/output.js +29 -0
- package/dist/src/facade/output.js.map +1 -0
- package/dist/src/facade/provider.d.ts +14 -0
- package/dist/src/facade/provider.d.ts.map +1 -0
- package/dist/src/facade/provider.js +25 -0
- package/dist/src/facade/provider.js.map +1 -0
- package/dist/src/facade/resource.d.ts +32 -0
- package/dist/src/facade/resource.d.ts.map +1 -0
- package/dist/src/facade/resource.js +49 -0
- package/dist/src/facade/resource.js.map +1 -0
- package/dist/src/facade/stack.d.ts +12 -0
- package/dist/src/facade/stack.d.ts.map +1 -0
- package/dist/src/facade/stack.js +26 -0
- package/dist/src/facade/stack.js.map +1 -0
- package/dist/src/facade/variable.d.ts +27 -0
- package/dist/src/facade/variable.d.ts.map +1 -0
- package/dist/src/facade/variable.js +45 -0
- package/dist/src/facade/variable.js.map +1 -0
- package/dist/src/index.d.ts +34 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +22 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# tfts
|
|
2
|
+
|
|
3
|
+
TypeScript-first infrastructure as code for Terraform. A lightweight, type-safe alternative to CDKTF.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
tfts lets you define Terraform infrastructure using TypeScript with full type safety. It generates Terraform JSON that you can apply with the standard Terraform CLI.
|
|
8
|
+
|
|
9
|
+
Key differences from CDKTF:
|
|
10
|
+
|
|
11
|
+
- **Type-safe attribute references** - Computed attributes return `TokenString` instead of `string`, preventing invalid operations like `.toUpperCase()` at compile time
|
|
12
|
+
- **Lightweight** - No JSII, no complex runtime, just TypeScript
|
|
13
|
+
|
|
14
|
+
## Getting Started
|
|
15
|
+
|
|
16
|
+
### Prerequisites
|
|
17
|
+
|
|
18
|
+
- [Bun](https://bun.sh) or Node.js
|
|
19
|
+
- [Terraform CLI](https://developer.hashicorp.com/terraform/downloads)
|
|
20
|
+
|
|
21
|
+
### Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bun add tfts
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Project Setup
|
|
28
|
+
|
|
29
|
+
Create `cdktf.json`:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"language": "typescript",
|
|
34
|
+
"app": "bun main.ts",
|
|
35
|
+
"output": "cdktf.out",
|
|
36
|
+
"codeMakerOutput": ".gen",
|
|
37
|
+
"terraformProviders": [
|
|
38
|
+
{
|
|
39
|
+
"name": "google",
|
|
40
|
+
"source": "hashicorp/google",
|
|
41
|
+
"version": "5.0.0"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Generate provider bindings:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
bunx tfts get
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Write Infrastructure
|
|
54
|
+
|
|
55
|
+
Create `main.ts`:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { App, TerraformStack, TerraformOutput } from "tfts";
|
|
59
|
+
import { GoogleProvider, GoogleComputeNetwork } from "./.gen/providers/google/index.js";
|
|
60
|
+
|
|
61
|
+
const app = new App();
|
|
62
|
+
const stack = new TerraformStack(app, "my-stack");
|
|
63
|
+
|
|
64
|
+
new GoogleProvider(stack, "google", {
|
|
65
|
+
project: "my-project",
|
|
66
|
+
region: "us-central1",
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const network = new GoogleComputeNetwork(stack, "network", {
|
|
70
|
+
name: "my-network",
|
|
71
|
+
autoCreateSubnetworks: true,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
new TerraformOutput(stack, "network_id", {
|
|
75
|
+
value: network.id,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
app.synth();
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Deploy
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Synthesize to Terraform JSON
|
|
85
|
+
bun main.ts
|
|
86
|
+
|
|
87
|
+
# Apply with Terraform
|
|
88
|
+
cd cdktf.out/stacks/my-stack
|
|
89
|
+
terraform init
|
|
90
|
+
terraform apply
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Migration from CDKTF
|
|
94
|
+
|
|
95
|
+
### Type-Safe Attributes
|
|
96
|
+
|
|
97
|
+
The main difference: computed attributes return `TokenString` instead of `string`.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
// CDKTF - compiles but broken at runtime
|
|
101
|
+
network.id.toUpperCase();
|
|
102
|
+
|
|
103
|
+
// tfts - compile error (TokenString has no .toUpperCase())
|
|
104
|
+
network.id.toUpperCase(); // Error!
|
|
105
|
+
|
|
106
|
+
// tfts - template literals work via toString()
|
|
107
|
+
`prefix-${network.id}`;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Custom Constructs
|
|
111
|
+
|
|
112
|
+
If your CDKTF code has custom constructs with string config properties:
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
// CDKTF
|
|
116
|
+
interface MyDatabaseConfig {
|
|
117
|
+
name: string;
|
|
118
|
+
vpcId: string; // Often passed a token like vpc.id
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
class MyDatabase extends Construct {
|
|
122
|
+
constructor(scope: Construct, id: string, config: MyDatabaseConfig) {
|
|
123
|
+
// ...
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
new MyDatabase(stack, "db", {
|
|
128
|
+
name: "mydb",
|
|
129
|
+
vpcId: vpc.id, // Works in CDKTF because vpc.id is typed as string
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
In tfts, update config properties that accept tokens to use `TfString`:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import { TfString } from "tfts";
|
|
137
|
+
|
|
138
|
+
// tfts
|
|
139
|
+
interface MyDatabaseConfig {
|
|
140
|
+
name: string; // Literal only - keep as string
|
|
141
|
+
vpcId: TfString; // Accepts tokens - use TfString
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Import Changes
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
// CDKTF
|
|
149
|
+
import { App, TerraformStack } from "cdktf";
|
|
150
|
+
|
|
151
|
+
// tfts
|
|
152
|
+
import { App, TerraformStack } from "tfts";
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Supported Constructs
|
|
156
|
+
|
|
157
|
+
| Construct | Status |
|
|
158
|
+
|-----------|--------|
|
|
159
|
+
| TerraformResource | Supported |
|
|
160
|
+
| TerraformDataSource | Supported |
|
|
161
|
+
| TerraformProvider | Supported |
|
|
162
|
+
| TerraformVariable | Supported |
|
|
163
|
+
| TerraformOutput | Supported |
|
|
164
|
+
| TerraformLocal | Supported |
|
|
165
|
+
| Backends (S3, GCS, Remote, Local) | Supported |
|
|
166
|
+
| TerraformModule | Not yet |
|
|
167
|
+
| TerraformIterator | Not yet |
|
|
168
|
+
|
|
169
|
+
## License
|
|
170
|
+
|
|
171
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tfts.d.ts","sourceRoot":"","sources":["../../bin/tfts.ts"],"names":[],"mappings":""}
|
package/dist/bin/tfts.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tfts.js","sourceRoot":"","sources":["../../bin/tfts.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type Result } from "neverthrow";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
declare const ProviderConstraintSchema: z.ZodObject<{
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
source: z.ZodString;
|
|
6
|
+
version: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
declare const ModuleConstraintSchema: z.ZodObject<{
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
source: z.ZodString;
|
|
11
|
+
version: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
declare const CdktfConfigSchema: z.ZodObject<{
|
|
14
|
+
language: z.ZodLiteral<"typescript">;
|
|
15
|
+
app: z.ZodString;
|
|
16
|
+
output: z.ZodString;
|
|
17
|
+
terraformProviders: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
source: z.ZodString;
|
|
20
|
+
version: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>>>;
|
|
22
|
+
terraformModules: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
source: z.ZodString;
|
|
25
|
+
version: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>>>;
|
|
27
|
+
codeMakerOutput: z.ZodOptional<z.ZodString>;
|
|
28
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
29
|
+
sendCrashReports: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type CdktfConfig = z.infer<typeof CdktfConfigSchema>;
|
|
32
|
+
export type ProviderConstraint = z.infer<typeof ProviderConstraintSchema>;
|
|
33
|
+
export type ModuleConstraint = z.infer<typeof ModuleConstraintSchema>;
|
|
34
|
+
export type ConfigError = {
|
|
35
|
+
readonly field: string;
|
|
36
|
+
readonly message: string;
|
|
37
|
+
};
|
|
38
|
+
export declare const readConfig: (path: string) => Promise<Result<CdktfConfig, ConfigError>>;
|
|
39
|
+
export declare const parseConfig: (parsed: unknown) => Result<CdktfConfig, ConfigError>;
|
|
40
|
+
export declare const parseProviderConstraint: (spec: string) => ProviderConstraint;
|
|
41
|
+
export declare const validateConfig: (config: unknown) => readonly ConfigError[];
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/cli/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,wBAAwB;;;;iBAI5B,CAAC;AAEH,QAAA,MAAM,sBAAsB;;;;iBAI1B,CAAC;AAEH,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;iBASrB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,UAAU,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,CAWvF,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,QAAQ,OAAO,KAAG,MAAM,CAAC,WAAW,EAAE,WAAW,CAU5E,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,KAAG,kBAatD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,QAAQ,OAAO,KAAG,SAAS,WAAW,EAMpE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ok, err } from "neverthrow";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const ProviderConstraintSchema = z.object({
|
|
4
|
+
name: z.string(),
|
|
5
|
+
source: z.string(),
|
|
6
|
+
version: z.string().optional(),
|
|
7
|
+
});
|
|
8
|
+
const ModuleConstraintSchema = z.object({
|
|
9
|
+
name: z.string(),
|
|
10
|
+
source: z.string(),
|
|
11
|
+
version: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
const CdktfConfigSchema = z.object({
|
|
14
|
+
language: z.literal("typescript"),
|
|
15
|
+
app: z.string().min(1),
|
|
16
|
+
output: z.string().min(1),
|
|
17
|
+
terraformProviders: z.array(ProviderConstraintSchema).optional(),
|
|
18
|
+
terraformModules: z.array(ModuleConstraintSchema).optional(),
|
|
19
|
+
codeMakerOutput: z.string().optional(),
|
|
20
|
+
projectId: z.string().optional(),
|
|
21
|
+
sendCrashReports: z.boolean().optional(),
|
|
22
|
+
});
|
|
23
|
+
export const readConfig = async (path) => {
|
|
24
|
+
const file = Bun.file(path);
|
|
25
|
+
const exists = await file.exists();
|
|
26
|
+
if (!exists) {
|
|
27
|
+
return err({ field: "path", message: `Config file not found: ${path}` });
|
|
28
|
+
}
|
|
29
|
+
const text = await file.text();
|
|
30
|
+
const parsed = JSON.parse(text);
|
|
31
|
+
return parseConfig(parsed);
|
|
32
|
+
};
|
|
33
|
+
export const parseConfig = (parsed) => {
|
|
34
|
+
const result = CdktfConfigSchema.safeParse(parsed);
|
|
35
|
+
if (!result.success) {
|
|
36
|
+
const issue = result.error.issues[0];
|
|
37
|
+
if (issue !== undefined) {
|
|
38
|
+
return err({ field: issue.path.join(".") || "root", message: issue.message });
|
|
39
|
+
}
|
|
40
|
+
return err({ field: "root", message: "Invalid config" });
|
|
41
|
+
}
|
|
42
|
+
return ok(result.data);
|
|
43
|
+
};
|
|
44
|
+
export const parseProviderConstraint = (spec) => {
|
|
45
|
+
const parts = spec.split("@");
|
|
46
|
+
const sourceAndName = parts[0] ?? spec;
|
|
47
|
+
const version = parts[1];
|
|
48
|
+
const sourceParts = sourceAndName.split("/");
|
|
49
|
+
const name = sourceParts[sourceParts.length - 1] ?? sourceAndName;
|
|
50
|
+
return {
|
|
51
|
+
name,
|
|
52
|
+
source: sourceAndName,
|
|
53
|
+
version,
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export const validateConfig = (config) => {
|
|
57
|
+
const result = parseConfig(config);
|
|
58
|
+
if (result.isErr()) {
|
|
59
|
+
return [result.error];
|
|
60
|
+
}
|
|
61
|
+
return [];
|
|
62
|
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CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAsB,EAAE;IAC1E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;IACvC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAEzB,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,aAAa,CAAC;IAElE,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,aAAa;QACrB,OAAO;KACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAe,EAA0B,EAAE;IACxE,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QACnB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Result } from "neverthrow";
|
|
2
|
+
import { type ConfigError } from "./config.js";
|
|
3
|
+
export type DiffOptions = {
|
|
4
|
+
readonly configPath?: string;
|
|
5
|
+
readonly output?: string;
|
|
6
|
+
readonly app?: string;
|
|
7
|
+
readonly stack?: string;
|
|
8
|
+
readonly refreshOnly?: boolean;
|
|
9
|
+
readonly skipSynth?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type DiffError = {
|
|
12
|
+
readonly kind: "config";
|
|
13
|
+
readonly error: ConfigError;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "exec";
|
|
16
|
+
readonly message: string;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "io";
|
|
19
|
+
readonly message: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "terraform";
|
|
22
|
+
readonly message: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const runDiff: (options: DiffOptions) => Promise<Result<void, DiffError>>;
|
|
25
|
+
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/cli/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAgB3D,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,eAAO,MAAM,OAAO,GAAU,SAAS,WAAW,KAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CA8EnF,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ok, err } from "neverthrow";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { readConfig } from "./config.js";
|
|
4
|
+
import { executeApp } from "./synth.js";
|
|
5
|
+
const ManifestStackSchema = z.object({
|
|
6
|
+
name: z.string(),
|
|
7
|
+
synthesizedStackPath: z.string(),
|
|
8
|
+
workingDirectory: z.string(),
|
|
9
|
+
});
|
|
10
|
+
const ManifestSchema = z.object({
|
|
11
|
+
version: z.string(),
|
|
12
|
+
stacks: z.record(z.string(), ManifestStackSchema),
|
|
13
|
+
});
|
|
14
|
+
export const runDiff = async (options) => {
|
|
15
|
+
const configPath = options.configPath ?? "cdktf.json";
|
|
16
|
+
const configResult = await readConfig(configPath);
|
|
17
|
+
if (configResult.isErr()) {
|
|
18
|
+
return err({ kind: "config", error: configResult.error });
|
|
19
|
+
}
|
|
20
|
+
const config = configResult.value;
|
|
21
|
+
const appCommand = options.app ?? config.app;
|
|
22
|
+
const outdir = options.output ?? config.output;
|
|
23
|
+
// Step 1: Synthesize (unless skipped)
|
|
24
|
+
if (options.skipSynth !== true) {
|
|
25
|
+
console.log("Synthesizing...");
|
|
26
|
+
const synthResult = await executeApp(appCommand, outdir);
|
|
27
|
+
if (synthResult.isErr()) {
|
|
28
|
+
const synthError = synthResult.error;
|
|
29
|
+
const message = synthError.kind === "exec" ? synthError.message : "Synth failed";
|
|
30
|
+
return err({ kind: "exec", message });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Step 2: Read manifest to get stacks
|
|
34
|
+
const manifestPath = `${outdir}/manifest.json`;
|
|
35
|
+
const manifestFile = Bun.file(manifestPath);
|
|
36
|
+
const manifestExists = await manifestFile.exists();
|
|
37
|
+
if (!manifestExists) {
|
|
38
|
+
return err({ kind: "io", message: `Manifest not found: ${manifestPath}` });
|
|
39
|
+
}
|
|
40
|
+
const manifestText = await manifestFile.text();
|
|
41
|
+
const manifestJson = JSON.parse(manifestText);
|
|
42
|
+
const manifestResult = ManifestSchema.safeParse(manifestJson);
|
|
43
|
+
if (!manifestResult.success) {
|
|
44
|
+
return err({ kind: "io", message: "Invalid manifest.json format" });
|
|
45
|
+
}
|
|
46
|
+
const manifest = manifestResult.data;
|
|
47
|
+
const stackNames = Object.keys(manifest.stacks);
|
|
48
|
+
if (stackNames.length === 0) {
|
|
49
|
+
console.log("No stacks found.");
|
|
50
|
+
return ok(undefined);
|
|
51
|
+
}
|
|
52
|
+
// Filter to specific stack if provided
|
|
53
|
+
const targetStacks = options.stack !== undefined ? stackNames.filter((name) => name === options.stack) : stackNames;
|
|
54
|
+
if (targetStacks.length === 0) {
|
|
55
|
+
return err({ kind: "io", message: `Stack not found: ${options.stack}` });
|
|
56
|
+
}
|
|
57
|
+
// Step 3: Run terraform init and plan for each stack
|
|
58
|
+
for (const stackName of targetStacks) {
|
|
59
|
+
const stackInfo = manifest.stacks[stackName];
|
|
60
|
+
if (stackInfo === undefined)
|
|
61
|
+
continue;
|
|
62
|
+
const stackDir = `${outdir}/${stackInfo.workingDirectory}`;
|
|
63
|
+
console.log(`\n--- Stack: ${stackName} ---\n`);
|
|
64
|
+
// terraform init
|
|
65
|
+
const initResult = await runTerraformInit(stackDir);
|
|
66
|
+
if (initResult.isErr()) {
|
|
67
|
+
return initResult;
|
|
68
|
+
}
|
|
69
|
+
// terraform plan
|
|
70
|
+
const planResult = await runTerraformPlan(stackDir, options.refreshOnly ?? false);
|
|
71
|
+
if (planResult.isErr()) {
|
|
72
|
+
return planResult;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return ok(undefined);
|
|
76
|
+
};
|
|
77
|
+
const runTerraformInit = async (workingDir) => {
|
|
78
|
+
const proc = Bun.spawn(["terraform", "init", "-input=false"], {
|
|
79
|
+
cwd: workingDir,
|
|
80
|
+
stdout: "inherit",
|
|
81
|
+
stderr: "inherit",
|
|
82
|
+
});
|
|
83
|
+
const exitCode = await proc.exited;
|
|
84
|
+
if (exitCode !== 0) {
|
|
85
|
+
return err({ kind: "terraform", message: `terraform init failed with exit code ${exitCode}` });
|
|
86
|
+
}
|
|
87
|
+
return ok(undefined);
|
|
88
|
+
};
|
|
89
|
+
const runTerraformPlan = async (workingDir, refreshOnly) => {
|
|
90
|
+
const args = ["terraform", "plan", "-input=false"];
|
|
91
|
+
if (refreshOnly) {
|
|
92
|
+
args.push("-refresh-only");
|
|
93
|
+
}
|
|
94
|
+
const proc = Bun.spawn(args, {
|
|
95
|
+
cwd: workingDir,
|
|
96
|
+
stdout: "inherit",
|
|
97
|
+
stderr: "inherit",
|
|
98
|
+
});
|
|
99
|
+
const exitCode = await proc.exited;
|
|
100
|
+
if (exitCode !== 0) {
|
|
101
|
+
return err({ kind: "terraform", message: `terraform plan failed with exit code ${exitCode}` });
|
|
102
|
+
}
|
|
103
|
+
return ok(undefined);
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/cli/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAe,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAoB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE;IAChC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;CAC7B,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,OAAO,EAAE,CAAC,CAAC,MAAM,E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EAAE,wCAAwC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,KAAK,EAC5B,UAAkB,EAClB,WAAoB,EACc,EAAE;IACpC,MAAM,IAAI,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;IACnD,IAAI,WAAW,EAAE,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE;QAC3B,GAAG,EAAE,UAAU;QACf,MAAM,EAAE,SAAS;QACjB,MAAM,EAAE,SAAS;KAClB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC;IACnC,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,wCAAwC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACjG,CAAC;IAED,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;AACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type Result } from "neverthrow";
|
|
2
|
+
import { type ConfigError } from "./config.js";
|
|
3
|
+
import { type SchemaError } from "../codegen/schema.js";
|
|
4
|
+
export type GetOptions = {
|
|
5
|
+
readonly configPath?: string;
|
|
6
|
+
readonly output?: string;
|
|
7
|
+
};
|
|
8
|
+
export type GetError = {
|
|
9
|
+
readonly kind: "config";
|
|
10
|
+
readonly error: ConfigError;
|
|
11
|
+
} | {
|
|
12
|
+
readonly kind: "schema";
|
|
13
|
+
readonly error: SchemaError;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "io";
|
|
16
|
+
readonly message: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const runGet: (options: GetOptions) => Promise<Result<void, GetError>>;
|
|
19
|
+
export declare const generateBindings: (providers: readonly {
|
|
20
|
+
name: string;
|
|
21
|
+
source: string;
|
|
22
|
+
version?: string;
|
|
23
|
+
}[], outdir: string) => Promise<Result<void, GetError>>;
|
|
24
|
+
//# sourceMappingURL=get.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/cli/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE7E,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD,eAAO,MAAM,MAAM,GAAU,SAAS,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CA6BhF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,WAAW,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACxE,QAAQ,MAAM,KACb,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAiBhC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ok, err } from "neverthrow";
|
|
2
|
+
import { readConfig } from "./config.js";
|
|
3
|
+
import { generateProvider } from "../codegen/generator.js";
|
|
4
|
+
import { fetchProviderSchema } from "../codegen/schema.js";
|
|
5
|
+
export const runGet = async (options) => {
|
|
6
|
+
const configPath = options.configPath ?? "cdktf.json";
|
|
7
|
+
const configResult = await readConfig(configPath);
|
|
8
|
+
if (configResult.isErr()) {
|
|
9
|
+
return err({ kind: "config", error: configResult.error });
|
|
10
|
+
}
|
|
11
|
+
const config = configResult.value;
|
|
12
|
+
const outdir = options.output ?? config.codeMakerOutput ?? ".gen";
|
|
13
|
+
const providers = config.terraformProviders ?? [];
|
|
14
|
+
for (const provider of providers) {
|
|
15
|
+
const version = provider.version ?? "latest";
|
|
16
|
+
const schemaResult = await fetchProviderSchema(provider.source, version);
|
|
17
|
+
if (schemaResult.isErr()) {
|
|
18
|
+
return err({ kind: "schema", error: schemaResult.error });
|
|
19
|
+
}
|
|
20
|
+
const code = generateProvider(provider.name, schemaResult.value);
|
|
21
|
+
const providerDir = `${outdir}/providers/${provider.name}`;
|
|
22
|
+
await Bun.$ `mkdir -p ${providerDir}`;
|
|
23
|
+
await Bun.write(`${providerDir}/index.ts`, code);
|
|
24
|
+
}
|
|
25
|
+
return ok(undefined);
|
|
26
|
+
};
|
|
27
|
+
export const generateBindings = async (providers, outdir) => {
|
|
28
|
+
for (const provider of providers) {
|
|
29
|
+
const version = provider.version ?? "latest";
|
|
30
|
+
const schemaResult = await fetchProviderSchema(provider.source, version);
|
|
31
|
+
if (schemaResult.isErr()) {
|
|
32
|
+
return err({ kind: "schema", error: schemaResult.error });
|
|
33
|
+
}
|
|
34
|
+
const code = generateProvider(provider.name, schemaResult.value);
|
|
35
|
+
const providerDir = `${outdir}/providers/${provider.name}`;
|
|
36
|
+
await Bun.$ `mkdir -p ${providerDir}`;
|
|
37
|
+
await Bun.write(`${providerDir}/index.ts`, code);
|
|
38
|
+
}
|
|
39
|
+
return ok(undefined);
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/cli/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,GAAG,EAAe,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,UAAU,EAAoB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAoB,MAAM,sBAAsB,CAAC;AAY7E,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,OAAmB,EAAmC,EAAE;IACnF,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,YAAY,CAAC;IACtD,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC;IAElD,IAAI,YAAY,CAAC,KAAK,EAAE,EAAE,CAAC;QACzB,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC;IAClC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC;IAElE,MAAM,SAAS,GAAG,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC;IAElD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC;QAC7C,MAAM,YAAY,GAAG,MAAM,mBAAmB,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAEzE,IAAI,YAA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