puls-dev 0.3.5 → 0.3.7
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/README.md +165 -54
- package/dist/bin/install-shell.js +5 -6
- package/dist/bin/puls.js +10 -3
- package/dist/core/config.d.ts +4 -0
- package/dist/core/decorators.d.ts +4 -0
- package/dist/core/decorators.js +2 -0
- package/dist/core/parallel.test.js +4 -3
- package/dist/core/resource.d.ts +2 -1
- package/dist/core/resource.js +4 -2
- package/dist/core/stack.d.ts +4 -0
- package/dist/core/stack.js +8 -8
- package/dist/providers/aws/acm.test.d.ts +1 -0
- package/dist/providers/aws/acm.test.js +167 -0
- package/dist/providers/aws/cloudfront.test.d.ts +1 -0
- package/dist/providers/aws/cloudfront.test.js +170 -0
- package/dist/providers/aws/fargate.test.d.ts +1 -0
- package/dist/providers/aws/fargate.test.js +244 -0
- package/dist/providers/aws/rds.test.d.ts +1 -0
- package/dist/providers/aws/rds.test.js +219 -0
- package/dist/providers/aws/sqs.test.d.ts +1 -0
- package/dist/providers/aws/sqs.test.js +181 -0
- package/dist/providers/cloudflare/api.d.ts +15 -0
- package/dist/providers/cloudflare/api.js +199 -0
- package/dist/providers/cloudflare/index.d.ts +14 -0
- package/dist/providers/cloudflare/index.js +19 -0
- package/dist/providers/cloudflare/kv.d.ts +20 -0
- package/dist/providers/cloudflare/kv.js +69 -0
- package/dist/providers/cloudflare/kv.test.d.ts +1 -0
- package/dist/providers/cloudflare/kv.test.js +134 -0
- package/dist/providers/cloudflare/r2.d.ts +14 -0
- package/dist/providers/cloudflare/r2.js +57 -0
- package/dist/providers/cloudflare/r2.test.d.ts +1 -0
- package/dist/providers/cloudflare/r2.test.js +132 -0
- package/dist/providers/cloudflare/worker.d.ts +28 -0
- package/dist/providers/cloudflare/worker.js +172 -0
- package/dist/providers/cloudflare/worker.test.d.ts +1 -0
- package/dist/providers/cloudflare/worker.test.js +220 -0
- package/dist/providers/cloudflare/zone.d.ts +42 -0
- package/dist/providers/cloudflare/zone.js +280 -0
- package/dist/providers/cloudflare/zone.test.d.ts +1 -0
- package/dist/providers/cloudflare/zone.test.js +284 -0
- package/dist/providers/firebase/auth.test.d.ts +1 -0
- package/dist/providers/firebase/auth.test.js +145 -0
- package/dist/providers/firebase/hosting.test.js +7 -6
- package/dist/providers/firebase/storage.test.d.ts +1 -0
- package/dist/providers/firebase/storage.test.js +148 -0
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
# Pulsdev.io
|
|
2
2
|
|
|
3
|
-
**Intent-driven infrastructure-as-code. Describe what you want
|
|
3
|
+
**Intent-driven infrastructure-as-code. Describe what you want- Puls figures out create, update, or skip.**
|
|
4
4
|
|
|
5
|
-
[Live Documentation](https://pulsdev.io/) | Matrix|Gitter: **pulsdev.io** ([Join](https://matrix.to/#/#pulsdevio:gitter.im))
|
|
5
|
+
[Live Documentation](https://pulsdev.io/) | [GitHub Actions](docs/github-actions.md) | Matrix|Gitter: **pulsdev.io** ([Join](https://matrix.to/#/#pulsdevio:gitter.im))
|
|
6
6
|
|
|
7
7
|
> [!IMPORTANT]
|
|
8
8
|
> **Active Pre-1.0 Development**
|
|
9
|
-
> `pulsdev.io` is
|
|
10
|
-
> We are aggressively rolling out new resources and provider integrations. We welcome your feedback, bug reports, and contributions!
|
|
9
|
+
> `pulsdev.io` is under active development. APIs and features are evolving- we welcome feedback, bug reports, and contributions!
|
|
11
10
|
|
|
12
11
|
```typescript
|
|
13
12
|
@Deploy({ proxmox: CONFIG.STAGING })
|
|
14
13
|
class GameInfra extends Stack {
|
|
15
|
-
server = Proxmox.VM("
|
|
14
|
+
server = Proxmox.VM("ix-app01")
|
|
16
15
|
.image(OS.UBUNTU_24_04)
|
|
17
16
|
.cores(4).memory(8192)
|
|
18
|
-
.ip("
|
|
17
|
+
.ip("10.8.10.51").vlan(2010)
|
|
19
18
|
.sshKey(KEYS)
|
|
20
19
|
.provision("config/default.yaml");
|
|
21
20
|
}
|
|
22
21
|
```
|
|
23
22
|
|
|
24
|
-
No state files. No plan step. Runs against real APIs
|
|
23
|
+
No state files. No plan step. Runs against real APIs- idempotent by default.
|
|
25
24
|
|
|
26
25
|
---
|
|
27
26
|
|
|
@@ -35,20 +34,52 @@ Declare resource → Discovery fires immediately (async)
|
|
|
35
34
|
→ deploy() awaits discovery, diffs, acts
|
|
36
35
|
```
|
|
37
36
|
|
|
38
|
-
Running the same stack twice is always safe
|
|
37
|
+
Running the same stack twice is always safe- existing resources are detected and skipped or updated in place.
|
|
39
38
|
|
|
40
39
|
---
|
|
41
40
|
|
|
42
|
-
##
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm install puls-dev
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**One-time shell setup**- so you never have to type `npx puls` again:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx puls install-shell
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
This adds a `puls` launcher to `~/.puls/bin` and wires it into your shell config (`~/.zshrc`, `~/.bashrc`, or Fish). Open a new terminal and `puls` works everywhere.
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## CLI
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
puls plan infra/stack.ts # dry-run- prints what would change, no API writes
|
|
61
|
+
puls deploy infra/stack.ts # apply the stack
|
|
62
|
+
puls destroy infra/stack.ts # tear down the stack
|
|
63
|
+
puls diff infra/stack.ts # compare declared intent vs live cloud state
|
|
64
|
+
puls diff infra/stack.ts --fail-on-drift # exit 1 if anything has drifted
|
|
65
|
+
|
|
66
|
+
puls install-shell # one-time shell setup
|
|
67
|
+
puls uninstall-shell # remove shell integration
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Always run `plan` before `deploy`- it activates dry-run mode automatically.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Providers
|
|
51
75
|
|
|
76
|
+
| Provider | Resources |
|
|
77
|
+
|----------|-----------|
|
|
78
|
+
| **AWS** | EC2, RDS, Lambda, ECS/Fargate, API Gateway, S3, CloudFront, Route53, ACM, SQS, SNS, IAM, CloudWatch, SecretsManager |
|
|
79
|
+
| **DigitalOcean** | Droplet, Domain (full DNS), Firewall, Certificate, LoadBalancer, Database, App Platform, VPC, Spaces |
|
|
80
|
+
| **GCP** | Compute VM, Cloud Run, Cloud SQL, Secret Manager, Pub/Sub, Cloud DNS, IAM |
|
|
81
|
+
| **Firebase** | Hosting, Functions, Firestore, Storage, Auth, RemoteConfig, App Check |
|
|
82
|
+
| **Proxmox** | VM (clone, cloud-init, provision, cluster-aware scheduling), Templates (golden images) |
|
|
52
83
|
|
|
53
84
|
---
|
|
54
85
|
|
|
@@ -57,11 +88,13 @@ Running the same stack twice is always safe - existing resources are detected an
|
|
|
57
88
|
### DigitalOcean
|
|
58
89
|
|
|
59
90
|
```typescript
|
|
91
|
+
import "dotenv/config";
|
|
60
92
|
import { Stack, Deploy } from "puls-dev";
|
|
61
93
|
import { DO, SIZE, REGION } from "puls-dev/do";
|
|
62
94
|
|
|
63
95
|
@Deploy({ token: process.env.DO_TOKEN! })
|
|
64
96
|
class Production extends Stack {
|
|
97
|
+
db = DO.Database("prod-db").engine("pg").size("db-s-2vcpu-2gb").nodes(2);
|
|
65
98
|
web = DO.Droplet("prod-web").size(SIZE.MEDIUM).region(REGION.FRA).allowPublicWeb();
|
|
66
99
|
dns = DO.Domain("example.com").pointer("@", this.web).withSSL();
|
|
67
100
|
}
|
|
@@ -70,47 +103,132 @@ class Production extends Stack {
|
|
|
70
103
|
### AWS
|
|
71
104
|
|
|
72
105
|
```typescript
|
|
106
|
+
import "dotenv/config";
|
|
73
107
|
import { Stack, Deploy } from "puls-dev";
|
|
74
|
-
import { AWS,
|
|
108
|
+
import { AWS, REGION, RUNTIME, DB } from "puls-dev/aws";
|
|
75
109
|
|
|
76
|
-
@Deploy({ region: REGION.
|
|
77
|
-
class
|
|
78
|
-
|
|
110
|
+
@Deploy({ region: REGION.EU_CENTRAL_1 })
|
|
111
|
+
class AppStack extends Stack {
|
|
112
|
+
db = AWS.RDS("app-db").engine(DB.POSTGRES_16).size("db.t3.micro");
|
|
113
|
+
api = AWS.Lambda("app-api").code("./functions/api").runtime(RUNTIME.NODEJS_20);
|
|
114
|
+
cdn = AWS.S3("app-assets").staticSite().allowFrom(this.api);
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### GCP
|
|
79
119
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
120
|
+
```typescript
|
|
121
|
+
import "dotenv/config";
|
|
122
|
+
import { Stack, Deploy } from "puls-dev";
|
|
123
|
+
import { GCP } from "puls-dev/gcp";
|
|
83
124
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
125
|
+
@Deploy({})
|
|
126
|
+
class CloudStack extends Stack {
|
|
127
|
+
secret = GCP.Secret("db-password").value(process.env.DB_PASS!);
|
|
128
|
+
api = GCP.CloudRun("app-api").image("gcr.io/my-project/api:latest").port(8080).public();
|
|
129
|
+
db = GCP.CloudSQL("app-db").engine("postgres").version("16").tier("db-f1-micro");
|
|
87
130
|
}
|
|
88
131
|
```
|
|
89
132
|
|
|
90
133
|
### Proxmox
|
|
91
134
|
|
|
92
135
|
```typescript
|
|
136
|
+
import "dotenv/config";
|
|
93
137
|
import { Stack, Deploy, Protected } from "puls-dev";
|
|
94
138
|
import { Proxmox, CONFIG, OS, KEYS } from "puls-dev/proxmox";
|
|
95
139
|
|
|
96
140
|
@Deploy({ proxmox: CONFIG.STAGING })
|
|
97
141
|
class StagingInfra extends Stack {
|
|
98
142
|
@Protected
|
|
99
|
-
db = Proxmox.VM("ix-
|
|
100
|
-
|
|
101
|
-
.cores(2).memory(4096)
|
|
102
|
-
.ip("1.1.1.1").vlan(2010)
|
|
103
|
-
.sshKey(KEYS);
|
|
143
|
+
db = Proxmox.VM("ix-db01").image(OS.UBUNTU_24_04).cores(2).memory(4096)
|
|
144
|
+
.ip("10.8.10.50").vlan(2010).sshKey(KEYS);
|
|
104
145
|
|
|
105
|
-
app = Proxmox.VM("ix-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
146
|
+
app = Proxmox.VM("ix-app01").image(OS.UBUNTU_24_04).cores(4).memory(8192)
|
|
147
|
+
.ip("10.8.10.51").vlan(2010).sshKey(KEYS)
|
|
148
|
+
.provision("config/default.yaml");
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Key features
|
|
155
|
+
|
|
156
|
+
### Drift detection
|
|
157
|
+
|
|
158
|
+
`Stack.diff()` compares every declared resource against its live cloud state- no API writes, structured output:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
puls diff infra/production.ts
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
🔍 Diff: Production
|
|
166
|
+
|
|
167
|
+
db prod-db ⚠️ drift
|
|
168
|
+
└─ size db-s-1vcpu-1gb → db-s-2vcpu-2gb
|
|
169
|
+
└─ nodes 1 → 2
|
|
170
|
+
web prod-web ✅ in-sync
|
|
171
|
+
dns example.com ✅ in-sync
|
|
172
|
+
|
|
173
|
+
⚠️ 1 drifted out of 3 resources.
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Resource adoption
|
|
177
|
+
|
|
178
|
+
Bring existing cloud infrastructure under Puls management without recreating it:
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
db = DO.Database("prod-db")
|
|
182
|
+
.adoptId("existing-cluster-uuid")
|
|
183
|
+
.adoptOutput("host", "db.internal.example.com")
|
|
184
|
+
.adoptOutput("uri", "postgres://...");
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### GitHub Actions integration
|
|
188
|
+
|
|
189
|
+
Post plan output as a PR comment automatically. Add to your repo:
|
|
190
|
+
|
|
191
|
+
```yaml
|
|
192
|
+
# .github/workflows/puls-plan.yml
|
|
193
|
+
- uses: puls-dev/puls-dev@v1
|
|
194
|
+
with:
|
|
195
|
+
command: plan
|
|
196
|
+
stack-file: infra/production.ts
|
|
197
|
+
env:
|
|
198
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
199
|
+
DO_TOKEN: ${{ secrets.DO_TOKEN }}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Every PR that touches infra files gets a comment showing exactly what would change. See [docs/github-actions.md](docs/github-actions.md) for deploy and drift-check workflows.
|
|
203
|
+
|
|
204
|
+
### Stack outputs & cross-stack wiring
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
@Deploy({ proxmox: CONFIG.STAGING, token: process.env.DO_TOKEN })
|
|
208
|
+
class Infra extends Stack {
|
|
209
|
+
vm = Proxmox.VM("ix-app01").cores(4).memory(8192).ip("10.8.10.51").vlan(2010);
|
|
210
|
+
dns = DO.Domain("example.com").pointer("app", this.vm.out.ip); // Output<string>
|
|
111
211
|
}
|
|
112
212
|
```
|
|
113
213
|
|
|
214
|
+
Outputs resolve lazily- downstream resources unblock the moment their dependency finishes deploying.
|
|
215
|
+
|
|
216
|
+
### Dry run / plan
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
@Deploy({ dryRun: true, proxmox: CONFIG.STAGING })
|
|
220
|
+
class MyStack extends Stack { ... }
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Or via the CLI: `puls plan infra/stack.ts`- no config change required.
|
|
224
|
+
|
|
225
|
+
### Protected resources
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
@Protected
|
|
229
|
+
db = Proxmox.VM("ix-db01")...; // Puls will refuse to modify or destroy this
|
|
230
|
+
```
|
|
231
|
+
|
|
114
232
|
---
|
|
115
233
|
|
|
116
234
|
## Decorators
|
|
@@ -120,29 +238,19 @@ class StagingInfra extends Stack {
|
|
|
120
238
|
| `@Deploy({ ... })` | Deploy all resources in the stack |
|
|
121
239
|
| `@Deploy({ dryRun: true })` | Print plan without making changes |
|
|
122
240
|
| `@Destroy` | Tear down all resources in the stack |
|
|
123
|
-
| `@Destroy({ proxmox: CONFIG.STAGING })` | Tear down with provider credentials |
|
|
124
241
|
| `@DryRun` | Shorthand for `@Deploy({ dryRun: true })` |
|
|
125
|
-
| `@Protected`
|
|
126
|
-
|
|
127
|
-
See [docs/decorators.md](docs/decorators.md) for full reference.
|
|
242
|
+
| `@Protected` | Block changes/destruction of that resource |
|
|
243
|
+
| `@Check` | Inventory query- lists all live resources across providers |
|
|
128
244
|
|
|
129
245
|
---
|
|
130
246
|
|
|
131
|
-
##
|
|
247
|
+
## .env
|
|
132
248
|
|
|
133
249
|
```bash
|
|
134
|
-
npm install puls-dev
|
|
135
|
-
npx tsx your-stack.ts
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
Requires Node 20+.
|
|
139
|
-
|
|
140
|
-
**.env**
|
|
141
|
-
```
|
|
142
250
|
# DigitalOcean
|
|
143
251
|
DO_TOKEN=
|
|
144
252
|
|
|
145
|
-
# AWS
|
|
253
|
+
# AWS
|
|
146
254
|
AWS_ACCESS_KEY_ID=
|
|
147
255
|
AWS_SECRET_ACCESS_KEY=
|
|
148
256
|
AWS_REGION=us-east-1
|
|
@@ -151,8 +259,11 @@ AWS_REGION=us-east-1
|
|
|
151
259
|
PROXMOX_URL=https://pve.example.com:8006
|
|
152
260
|
PROXMOX_USER=root@pam
|
|
153
261
|
PROXMOX_TOKEN_NAME=puls
|
|
154
|
-
PROXMOX_TOKEN_SECRET=
|
|
262
|
+
PROXMOX_TOKEN_SECRET=
|
|
155
263
|
PROXMOX_NODES=pve1,pve2
|
|
156
|
-
|
|
157
|
-
|
|
264
|
+
|
|
265
|
+
# GCP / Firebase
|
|
266
|
+
GCP_SA=./service-account.json
|
|
158
267
|
```
|
|
268
|
+
|
|
269
|
+
Requires Node 20+.
|
|
@@ -95,11 +95,11 @@ export function uninstallShell() {
|
|
|
95
95
|
fs.rmdirSync(path.join(home, ".puls"));
|
|
96
96
|
}
|
|
97
97
|
catch {
|
|
98
|
-
// Non-empty dirs left behind (user may have other files)
|
|
98
|
+
// Non-empty dirs left behind (user may have other files)- that's fine
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
else {
|
|
102
|
-
console.log(` Launcher not found at ${launcherPath}
|
|
102
|
+
console.log(` Launcher not found at ${launcherPath}- nothing to remove.`);
|
|
103
103
|
}
|
|
104
104
|
// 2. Remove PATH line from shell config
|
|
105
105
|
const detected = detectShellConfig();
|
|
@@ -109,12 +109,12 @@ export function uninstallShell() {
|
|
|
109
109
|
}
|
|
110
110
|
const { configFile } = detected;
|
|
111
111
|
if (!fs.existsSync(configFile)) {
|
|
112
|
-
console.log(` Shell config not found at ${configFile}
|
|
112
|
+
console.log(` Shell config not found at ${configFile}- nothing to clean up.`);
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
const content = fs.readFileSync(configFile, "utf8");
|
|
116
116
|
if (!content.includes(MARKER)) {
|
|
117
|
-
console.log(` Shell config at ${configFile} has no puls entry
|
|
117
|
+
console.log(` Shell config at ${configFile} has no puls entry- nothing to remove.`);
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
// Remove the marker line and the PATH line that follows it
|
|
@@ -127,8 +127,7 @@ export function uninstallShell() {
|
|
|
127
127
|
return { out: acc.out, skip: false }; // skip the PATH line
|
|
128
128
|
return { out: [...acc.out, line], skip: false };
|
|
129
129
|
}, { out: [], skip: false })
|
|
130
|
-
.out
|
|
131
|
-
.join("\n")
|
|
130
|
+
.out.join("\n")
|
|
132
131
|
.replace(/\n{3,}/g, "\n\n"); // collapse triple+ blank lines
|
|
133
132
|
fs.writeFileSync(configFile, cleaned, "utf8");
|
|
134
133
|
console.log(`✅ Removed puls PATH entry from ${configFile}`);
|
package/dist/bin/puls.js
CHANGED
|
@@ -48,7 +48,7 @@ Options:
|
|
|
48
48
|
--help Print this help and exit
|
|
49
49
|
|
|
50
50
|
Examples:
|
|
51
|
-
npx puls install-shell # one-time setup
|
|
51
|
+
npx puls install-shell # one-time setup- then just use "puls" directly
|
|
52
52
|
puls plan infra/staging.ts
|
|
53
53
|
puls deploy infra/staging.ts --parallel
|
|
54
54
|
puls destroy infra/staging.ts
|
|
@@ -84,12 +84,19 @@ if (values.help || positionals.length === 0) {
|
|
|
84
84
|
process.exit(0);
|
|
85
85
|
}
|
|
86
86
|
const [command, userFile] = positionals;
|
|
87
|
-
const COMMANDS = [
|
|
87
|
+
const COMMANDS = [
|
|
88
|
+
"plan",
|
|
89
|
+
"deploy",
|
|
90
|
+
"destroy",
|
|
91
|
+
"diff",
|
|
92
|
+
"install-shell",
|
|
93
|
+
"uninstall-shell",
|
|
94
|
+
];
|
|
88
95
|
if (!COMMANDS.includes(command)) {
|
|
89
96
|
console.error(`Error: Unknown command "${command}". Run "puls --help" for usage.`);
|
|
90
97
|
process.exit(1);
|
|
91
98
|
}
|
|
92
|
-
// Shell management commands run directly
|
|
99
|
+
// Shell management commands run directly- no stack file needed
|
|
93
100
|
if (command === "install-shell") {
|
|
94
101
|
installShell();
|
|
95
102
|
process.exit(0);
|
package/dist/core/config.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ type ProviderOpts = {
|
|
|
19
19
|
verifySsl?: boolean;
|
|
20
20
|
sshUser?: string;
|
|
21
21
|
};
|
|
22
|
+
cloudflare?: {
|
|
23
|
+
token: string;
|
|
24
|
+
accountId?: string;
|
|
25
|
+
};
|
|
22
26
|
};
|
|
23
27
|
export declare function Protected(target: any, propertyKey: string): void;
|
|
24
28
|
export declare function ForceConfigCheck(target: any, propertyKey: string): void;
|
package/dist/core/decorators.js
CHANGED
|
@@ -15,6 +15,8 @@ function applyConfig(opts) {
|
|
|
15
15
|
Config.set({ providers: { aws: { region: opts.region } } });
|
|
16
16
|
if (opts.proxmox)
|
|
17
17
|
Config.set({ providers: { proxmox: opts.proxmox } });
|
|
18
|
+
if (opts.cloudflare)
|
|
19
|
+
Config.set({ providers: { cloudflare: opts.cloudflare } });
|
|
18
20
|
if (opts.firebase) {
|
|
19
21
|
const sa = JSON.parse(readFileSync(opts.firebase, "utf8"));
|
|
20
22
|
Config.set({
|
|
@@ -201,15 +201,16 @@ describe("Parallel Resource Deployment Unit Tests", () => {
|
|
|
201
201
|
assert.strictEqual(logs.includes("start:r2"), false);
|
|
202
202
|
});
|
|
203
203
|
test("decorator option propagation sets configuration values", async () => {
|
|
204
|
-
// Clear parallel flag
|
|
205
204
|
Config.set({ parallel: false });
|
|
206
|
-
// We define a decorated simple stack
|
|
207
205
|
let SimpleDecoStack = class SimpleDecoStack extends Stack {
|
|
208
206
|
};
|
|
209
207
|
SimpleDecoStack = __decorate([
|
|
210
208
|
Deploy({ parallel: true })
|
|
211
209
|
], SimpleDecoStack);
|
|
212
|
-
// Verify decorator correctly updated global configuration to true
|
|
213
210
|
assert.strictEqual(Config.isParallelActive(), true);
|
|
211
|
+
// @Deploy fires an async stack.deploy() that escapes this test's scope.
|
|
212
|
+
// Waiting here lets it complete before the test runner serializes results,
|
|
213
|
+
// preventing IPC stream corruption on the way back to the parent process.
|
|
214
|
+
await new Promise(resolve => setTimeout(resolve, 50));
|
|
214
215
|
});
|
|
215
216
|
});
|
package/dist/core/resource.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare abstract class BaseBuilder {
|
|
|
29
29
|
* naming convention).
|
|
30
30
|
*
|
|
31
31
|
* Outputs that depend on live API response fields (e.g. `out.host`) won't be
|
|
32
|
-
* resolved automatically
|
|
32
|
+
* resolved automatically- chain `.adoptOutput(key, value)` for each one you
|
|
33
33
|
* need for cross-stack wiring.
|
|
34
34
|
*/
|
|
35
35
|
adoptId(id: string): this;
|
|
@@ -51,6 +51,7 @@ export declare abstract class BaseBuilder {
|
|
|
51
51
|
* (no field-level diff available).
|
|
52
52
|
*/
|
|
53
53
|
getDiff(_existing: any): FieldDiff[];
|
|
54
|
+
forceConfigCheck?(): void;
|
|
54
55
|
adoptOutput(key: string, value: any): this;
|
|
55
56
|
dryRun(enabled?: boolean): this;
|
|
56
57
|
beforeDeploy(callback: () => Promise<void> | void): this;
|
package/dist/core/resource.js
CHANGED
|
@@ -39,7 +39,7 @@ export class BaseBuilder {
|
|
|
39
39
|
* naming convention).
|
|
40
40
|
*
|
|
41
41
|
* Outputs that depend on live API response fields (e.g. `out.host`) won't be
|
|
42
|
-
* resolved automatically
|
|
42
|
+
* resolved automatically- chain `.adoptOutput(key, value)` for each one you
|
|
43
43
|
* need for cross-stack wiring.
|
|
44
44
|
*/
|
|
45
45
|
adoptId(id) {
|
|
@@ -178,7 +178,9 @@ export class BaseBuilder {
|
|
|
178
178
|
}
|
|
179
179
|
async destroy() {
|
|
180
180
|
const dryRun = this.isDryRunActive();
|
|
181
|
-
const adoptedSuffix = this._adoptedId
|
|
181
|
+
const adoptedSuffix = this._adoptedId
|
|
182
|
+
? ` [adopted id=${this._adoptedId}]`
|
|
183
|
+
: "";
|
|
182
184
|
console.log(`\n🗑️ Destroying "${this.name}"${adoptedSuffix}...`);
|
|
183
185
|
console.log(` ✅ [${dryRun ? "PLAN" : "OK"}] Resource "${this.name}" marked for destruction.`);
|
|
184
186
|
await this.destroySidecars();
|
package/dist/core/stack.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export declare abstract class Stack {
|
|
|
17
17
|
* }
|
|
18
18
|
*/
|
|
19
19
|
static from<T extends Stack>(cls: new (...args: any[]) => T, region?: string): T;
|
|
20
|
+
beforeDeploy?(): Promise<void> | void;
|
|
21
|
+
afterDeploy?(outputs: Record<string, any>): Promise<void> | void;
|
|
22
|
+
beforeDestroy?(): Promise<void> | void;
|
|
23
|
+
afterDestroy?(outputs: Record<string, any>): Promise<void> | void;
|
|
20
24
|
/**
|
|
21
25
|
* Compares every declared resource against its live cloud state without
|
|
22
26
|
* making any API writes. Returns a structured `StackDiff` and prints a
|
package/dist/core/stack.js
CHANGED
|
@@ -237,7 +237,7 @@ export class Stack {
|
|
|
237
237
|
return withRedactedConsole(secrets, async () => {
|
|
238
238
|
console.log(`\n🏗️ Deploying Stack: ${this.constructor.name}`);
|
|
239
239
|
// Stack-level beforeDeploy hook
|
|
240
|
-
if (
|
|
240
|
+
if (this.beforeDeploy) {
|
|
241
241
|
console.log(` ⚡ Running Stack-level beforeDeploy hook...`);
|
|
242
242
|
await this.beforeDeploy();
|
|
243
243
|
}
|
|
@@ -255,8 +255,8 @@ export class Stack {
|
|
|
255
255
|
if (isProtected)
|
|
256
256
|
val.protect();
|
|
257
257
|
const forceConfigCheck = Reflect.getMetadata("forceConfigCheck", this, prop);
|
|
258
|
-
if (forceConfigCheck
|
|
259
|
-
val.forceConfigCheck();
|
|
258
|
+
if (forceConfigCheck) {
|
|
259
|
+
val.forceConfigCheck?.();
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
else if (Array.isArray(val)) {
|
|
@@ -267,8 +267,8 @@ export class Stack {
|
|
|
267
267
|
resources.push({ prop, resource: item });
|
|
268
268
|
if (isProtected)
|
|
269
269
|
item.protect();
|
|
270
|
-
if (forceConfigCheck
|
|
271
|
-
item.forceConfigCheck();
|
|
270
|
+
if (forceConfigCheck) {
|
|
271
|
+
item.forceConfigCheck?.();
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
}
|
|
@@ -373,7 +373,7 @@ export class Stack {
|
|
|
373
373
|
}
|
|
374
374
|
printOutputs(this.constructor.name, outputs);
|
|
375
375
|
// Stack-level afterDeploy hook
|
|
376
|
-
if (
|
|
376
|
+
if (this.afterDeploy) {
|
|
377
377
|
console.log(` ⚡ Running Stack-level afterDeploy hook...`);
|
|
378
378
|
await this.afterDeploy(outputs);
|
|
379
379
|
}
|
|
@@ -395,7 +395,7 @@ export class Stack {
|
|
|
395
395
|
return withRedactedConsole(secrets, async () => {
|
|
396
396
|
console.log(`\n💥 Tearing down Stack: ${this.constructor.name}`);
|
|
397
397
|
// Stack-level beforeDestroy hook
|
|
398
|
-
if (
|
|
398
|
+
if (this.beforeDestroy) {
|
|
399
399
|
console.log(` ⚡ Running Stack-level beforeDestroy hook...`);
|
|
400
400
|
await this.beforeDestroy();
|
|
401
401
|
}
|
|
@@ -507,7 +507,7 @@ export class Stack {
|
|
|
507
507
|
}
|
|
508
508
|
printOutputs(this.constructor.name, outputs);
|
|
509
509
|
// Stack-level afterDestroy hook
|
|
510
|
-
if (
|
|
510
|
+
if (this.afterDestroy) {
|
|
511
511
|
console.log(` ⚡ Running Stack-level afterDestroy hook...`);
|
|
512
512
|
await this.afterDestroy(outputs);
|
|
513
513
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|