puls-dev 0.1.0 → 0.1.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import { test, describe } from "node:test";
2
+ import assert from "node:assert";
3
+ import { Config } from "./config.js";
4
+ describe("ConfigManager", () => {
5
+ test("sets and gets config correctly", () => {
6
+ Config.set({ dryRun: true });
7
+ assert.strictEqual(Config.get().dryRun, true);
8
+ assert.strictEqual(Config.isGlobalDryRun(), true);
9
+ Config.set({ dryRun: false });
10
+ assert.strictEqual(Config.get().dryRun, false);
11
+ assert.strictEqual(Config.isGlobalDryRun(), false);
12
+ });
13
+ test("merges provider config correctly", () => {
14
+ Config.set({
15
+ providers: {
16
+ aws: { region: "us-east-1" }
17
+ }
18
+ });
19
+ assert.strictEqual(Config.get().providers.aws?.region, "us-east-1");
20
+ });
21
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { test, describe } from "node:test";
2
+ import assert from "node:assert";
3
+ import { Output } from "./output.js";
4
+ describe("Output", () => {
5
+ test("resolves a value correctly", async () => {
6
+ const out = new Output();
7
+ out.resolve("success");
8
+ const val = await out.get();
9
+ assert.strictEqual(val, "success");
10
+ });
11
+ test("applies transformations via .apply()", async () => {
12
+ const out = new Output();
13
+ const doubled = out.apply(n => n * 2);
14
+ out.resolve(10);
15
+ const result = await doubled.get();
16
+ assert.strictEqual(result, 20);
17
+ });
18
+ });
@@ -24,7 +24,7 @@ export declare class VMBuilder extends BaseBuilder {
24
24
  image(os: OSImage): this;
25
25
  cores(n: number): this;
26
26
  memory(mb: number): this;
27
- provision(playbookPath: string): this;
27
+ provision(playbookPath: string | string[]): this;
28
28
  replace(oldVmName: string): this;
29
29
  node(n: string): this;
30
30
  storage(pool: string): this;
@@ -106,8 +106,12 @@ export class VMBuilder extends BaseBuilder {
106
106
  console.log(` └─ Cores: ${this._cores} Memory: ${this._memory} MB`);
107
107
  if (this._vlan)
108
108
  console.log(` └─ VLAN: ${this._vlan}`);
109
- if (this._provision)
110
- console.log(` └─ Provision: ${this._provision}`);
109
+ if (this._provision) {
110
+ const p = Array.isArray(this._provision)
111
+ ? this._provision.join(", ")
112
+ : this._provision;
113
+ console.log(` └─ Provision: ${p}`);
114
+ }
111
115
  if (this._replace)
112
116
  console.log(` └─ Replace: "${this._replace}" after creation`);
113
117
  this.out.vmid.resolve(-1);
@@ -240,7 +244,10 @@ export class VMBuilder extends BaseBuilder {
240
244
  if (this._provision) {
241
245
  await this.waitFor(`SSH on ${this.resolvedIp} to be ready`, () => this.checkPort(this.resolvedIp, 22), { intervalMs: 10_000, timeoutMs: 300_000 });
242
246
  await this.waitFor(`cloud-init to finish on ${this.resolvedIp}`, () => this.checkCloudInit(this.resolvedIp), { intervalMs: 15_000, timeoutMs: 300_000 });
243
- await this.runProvisioner(this.resolvedIp, this._provision);
247
+ const scripts = Array.isArray(this._provision) ? this._provision : [this._provision];
248
+ for (const script of scripts) {
249
+ await this.runProvisioner(this.resolvedIp, script);
250
+ }
244
251
  }
245
252
  if (this._replace) {
246
253
  await this.destroyVmByName(this._replace, pm);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "puls-dev",
3
- "version": "0.1.0",
3
+ "version": "0.1.7",
4
4
  "description": "Intent-driven infrastructure-as-code with eager discovery and no state files.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -14,7 +14,7 @@
14
14
  "scripts": {
15
15
  "build": "tsc",
16
16
  "prepublishOnly": "npm run build",
17
- "test": "echo \"Error: no test specified\" && exit 1"
17
+ "test": "tsx --test src/**/*.test.ts"
18
18
  },
19
19
  "keywords": [
20
20
  "iac",