@crewhaus/crewhaus-cloud 0.4.2 → 0.5.1

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/dist/index.d.ts CHANGED
@@ -31,7 +31,6 @@ export declare const PROVIDERS: readonly ["aws", "gcp", "azure", "aws-localstack
31
31
  export type CloudProvider = (typeof PROVIDERS)[number];
32
32
  export declare const TIERS: readonly ["dev", "default", "production"];
33
33
  export type Tier = (typeof TIERS)[number];
34
- export declare function recipesRoot(): string;
35
34
  export type CloudConfig = {
36
35
  readonly provider: CloudProvider;
37
36
  readonly region: string;
@@ -58,7 +57,10 @@ export type CloudRunner = (argv: readonly string[], cwd: string) => Promise<{
58
57
  }>;
59
58
  export type DeployCloudOptions = {
60
59
  readonly config: CloudConfig;
61
- /** Working directory to write generated artefacts into; defaults to a temp dir. */
60
+ /**
61
+ * Working directory to write generated artefacts into; defaults to
62
+ * `.crewhaus/cloud/<clusterName>` under the current working directory.
63
+ */
62
64
  readonly workingDir?: string;
63
65
  /** Override the terraform binary path; defaults to env TF_BIN or "terraform". */
64
66
  readonly tfBin?: string;
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
3
- import { dirname, join, resolve } from "node:path";
4
- import { fileURLToPath } from "node:url";
3
+ import { join } from "node:path";
5
4
  import { isTargetShape } from "@crewhaus/docker-images";
6
5
  /**
7
6
  * Section 32 — `@crewhaus/crewhaus-cloud`
@@ -36,11 +35,6 @@ export class CrewhausCloudError extends CrewhausError {
36
35
  }
37
36
  export const PROVIDERS = ["aws", "gcp", "azure", "aws-localstack"];
38
37
  export const TIERS = ["dev", "default", "production"];
39
- const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
40
- const RECIPES_ROOT = join(PACKAGE_ROOT, "recipes");
41
- export function recipesRoot() {
42
- return RECIPES_ROOT;
43
- }
44
38
  export function defaultCloudConfig(provider, region) {
45
39
  if (!PROVIDERS.includes(provider)) {
46
40
  throw new CrewhausCloudError(`unknown provider: ${provider}`);
@@ -324,9 +318,22 @@ output "cluster_fqdn" {
324
318
  }
325
319
  `;
326
320
  }
321
+ /**
322
+ * Where generated Terraform/Kustomize lands when the caller passes no
323
+ * `workingDir`. Rooted at the *invocation* directory, never at the package
324
+ * directory: under an npm install the package dir may be read-only and is
325
+ * wiped on reinstall, and in a source checkout it turns every deploy into
326
+ * untracked files in `git status`. `.crewhaus/` is the repo-wide convention
327
+ * for runtime artefacts (`.crewhaus/sessions`, `.crewhaus/compliance`, …) and
328
+ * is gitignored. The path also has to be *stable* rather than a fresh temp
329
+ * dir, because `teardownCloud` has to find what `deployCloud` wrote.
330
+ */
331
+ function defaultWorkingDir(clusterName) {
332
+ return join(process.cwd(), ".crewhaus", "cloud", clusterName);
333
+ }
327
334
  export async function deployCloud(opts) {
328
335
  const { config } = opts;
329
- const workingDir = opts.workingDir ?? join(RECIPES_ROOT, ".out", config.clusterName);
336
+ const workingDir = opts.workingDir ?? defaultWorkingDir(config.clusterName);
330
337
  mkdirSync(join(workingDir, "terraform"), { recursive: true });
331
338
  mkdirSync(join(workingDir, "kustomize"), { recursive: true });
332
339
  // 1. Render the Terraform module + Kustomize overlay onto disk.
@@ -381,7 +388,7 @@ export async function deployCloud(opts) {
381
388
  }
382
389
  export async function teardownCloud(opts) {
383
390
  const tfBin = opts.tfBin ?? process.env["TF_BIN"] ?? "terraform";
384
- const workingDir = opts.workingDir ?? join(RECIPES_ROOT, ".out", opts.config.clusterName);
391
+ const workingDir = opts.workingDir ?? defaultWorkingDir(opts.config.clusterName);
385
392
  if (!existsSync(workingDir)) {
386
393
  throw new CrewhausCloudError(`no working directory at ${workingDir} (was deployCloud ever run?)`);
387
394
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crewhaus/crewhaus-cloud",
3
- "version": "0.4.2",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "Managed-as-a-service composite recipe: target-managed + helm-chart Kustomize overlay + Terraform module for GKE/EKS/AKS provisioning (Section 32)",
6
6
  "main": "dist/index.js",
@@ -15,9 +15,9 @@
15
15
  "test": "bun test src"
16
16
  },
17
17
  "dependencies": {
18
- "@crewhaus/docker-images": "0.4.2",
19
- "@crewhaus/errors": "0.4.2",
20
- "@crewhaus/helm-chart": "0.4.2"
18
+ "@crewhaus/docker-images": "0.5.1",
19
+ "@crewhaus/errors": "0.5.1",
20
+ "@crewhaus/helm-chart": "0.5.1"
21
21
  },
22
22
  "license": "Apache-2.0",
23
23
  "author": {