@intentius/chant-lexicon-gcp 0.15.2 → 0.16.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "algorithm": "sha256",
3
3
  "artifacts": {
4
- "manifest.json": "3c45f5e54db2e865c44d31a6aad4819415ec4eb48fdef24c5caeebd8d5dd9744",
4
+ "manifest.json": "99b71297b50bc2eacdee359a9a2074579841e019ec3da67510a7175f07e0179d",
5
5
  "meta.json": "475f10909854d059a2e2d4fb541c058803422e38b9c64bd4d6858c0623eedb8c",
6
6
  "types/index.d.ts": "5433b54c04b57d6fda8f3d81ef92ed0aca87f7e8e5dd3ea92d8de6e62a3ccfab",
7
7
  "rules/hardcoded-project.ts": "228631d3159e1ffcce2359c66073d4ae59bb0285f378e46e446f416aec50481c",
@@ -37,5 +37,5 @@
37
37
  "skills/chant-gcp-patterns.md": "a7ef31c1eb2f7244d3f73952c300472ef94c1eb09bd7a1003281b89299b6b704",
38
38
  "skills/chant-gcp-gke.md": "be277019da9a722c851e47cd2dfb9c9536668948c3535fb20db7697e934c4e2b"
39
39
  },
40
- "composite": "42fc10bc9384b76a76f820292b930953ad576e8417f95d969d0dfcf84dd4f204"
40
+ "composite": "414193cf3778e11c8cc72849add9573dcbd6059113835f26357ff256bed61b47"
41
41
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcp",
3
- "version": "0.15.2",
3
+ "version": "0.16.0",
4
4
  "chantVersion": ">=0.1.0",
5
5
  "namespace": "GCP",
6
6
  "intrinsics": [],
@@ -14,31 +14,16 @@ export interface FlociGcpDownArgs {
14
14
  /** Container name to remove. Default: `chant-floci-gcp`. */
15
15
  name?: string;
16
16
  }
17
- /** `docker ps -q -f name=<name>` non-empty stdout means the container is running. */
18
- export declare function flociGcpExistsCommand(name: string): string;
19
- /** Build the `docker run` command that boots floci-gcp. */
20
- export declare function flociGcpRunCommand(args: FlociGcpUpArgs): string;
21
- /** Build the `docker rm -f` command. */
22
- export declare function flociGcpRmCommand(name: string): string;
23
- /** The floci-gcp health endpoint URL for a host port. */
24
- export declare function flociGcpHealthUrl(port: number): string;
17
+ export declare const flociGcpExistsCommand: (name: string) => string;
18
+ export declare const flociGcpRmCommand: (name: string) => string;
19
+ export declare const flociGcpHealthUrl: (port: number) => string;
25
20
  /** The GCP endpoint URL (what `gcpApply`'s `endpoint` should point at). */
26
- export declare function flociGcpEndpoint(port: number): string;
27
- /**
28
- * Boot a local floci-gcp (GCP emulator) in Docker and return its endpoint.
29
- *
30
- * Idempotent: reuses a running container of the same name. Waits for the health
31
- * endpoint to answer, then returns `{ endpoint }` for `gcpApply({ endpoint })`.
32
- * The typed twin of the AWS `flociUp` — replaces a raw `docker run` shell step so
33
- * the emulator lifecycle is modeled, not scripted. Uses longInfra profile — 20m
34
- * timeout, heartbeat every poll (the image may pull).
35
- */
36
- export declare function flociGcpUp(args: FlociGcpUpArgs, signal?: AbortSignal): Promise<{
21
+ export declare const flociGcpEndpoint: (port: number) => string;
22
+ export declare const flociGcpRunCommand: (args?: FlociGcpUpArgs) => string;
23
+ /** Boot a local floci-gcp (GCP emulator) in Docker and return its endpoint. */
24
+ export declare const flociGcpUp: (args?: FlociGcpUpArgs, signal?: AbortSignal) => Promise<{
37
25
  endpoint: string;
38
26
  }>;
39
- /**
40
- * Stop and remove the local floci-gcp container. A no-op success when the
41
- * container is already gone. Uses fastIdempotent profile — 5m timeout.
42
- */
43
- export declare function flociGcpDown(args: FlociGcpDownArgs, signal?: AbortSignal): Promise<void>;
27
+ /** Stop and remove the local floci-gcp container (no-op if already gone). */
28
+ export declare const flociGcpDown: (args?: FlociGcpDownArgs, signal?: AbortSignal) => Promise<void>;
44
29
  //# sourceMappingURL=floci-gcp.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"floci-gcp.d.ts","sourceRoot":"","sources":["../../../src/op/activities/floci-gcp.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,cA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AAM,CAAC;IACd,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAWD,eAAO,MAAM,qBAAqB,0BAAoB,CAAC;AACvD,eAAO,MAAM,iBAAiB,0BAAgB,CAAC;AAC/C,eAAO,MAAM,iBAAiB,0BAAgB,CAAC;AAC/C,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,0BAAe,CAAC;AAC7C,eAAO,MAAM,kBAAkB,GAAI,OAAM,cAAmB,KAAG,MAA8B,CAAC;AAE9F,+EAA+E;AAC/E,eAAO,MAAM,UAAU,GAAI,OAAM,cAAmB,EAAE,SAAS,WAAW,KAAG,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CACnF,CAAC;AAEvB,6EAA6E;AAC7E,eAAO,MAAM,YAAY,GAAI,OAAM,gBAAqB,EAAE,SAAS,WAAW,KAAG,OAAO,CAAC,IAAI,CACrE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intentius/chant-lexicon-gcp",
3
- "version": "0.15.2",
3
+ "version": "0.16.0",
4
4
  "description": "Google Cloud lexicon for chant — declarative IaC in TypeScript",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://intentius.io/chant",
@@ -76,6 +76,6 @@
76
76
  "typescript": "^5.9.3"
77
77
  },
78
78
  "peerDependencies": {
79
- "@intentius/chant": "^0.15.2"
79
+ "@intentius/chant": "^0.16.0"
80
80
  }
81
81
  }
@@ -1,12 +1,4 @@
1
- import { exec } from "node:child_process";
2
- import { promisify } from "node:util";
3
- import { safeHeartbeat, sleep } from "@intentius/chant/op";
4
-
5
- const execAsync = promisify(exec);
6
-
7
- const DEFAULT_NAME = "chant-floci-gcp";
8
- const DEFAULT_PORT = 4588;
9
- const DEFAULT_IMAGE = "floci/floci-gcp:latest";
1
+ import { emulatorLifecycle } from "@intentius/chant/op";
10
2
 
11
3
  export interface FlociGcpUpArgs {
12
4
  /** Container name. Default: `chant-floci-gcp`. */
@@ -26,98 +18,26 @@ export interface FlociGcpDownArgs {
26
18
  name?: string;
27
19
  }
28
20
 
29
- /** `docker ps -q -f name=<name>` non-empty stdout means the container is running. */
30
- export function flociGcpExistsCommand(name: string): string {
31
- return `docker ps -q -f name=${name}`;
32
- }
33
-
34
- /** Build the `docker run` command that boots floci-gcp. */
35
- export function flociGcpRunCommand(args: FlociGcpUpArgs): string {
36
- const name = args.name ?? DEFAULT_NAME;
37
- const port = args.port ?? DEFAULT_PORT;
38
- const image = args.image ?? DEFAULT_IMAGE;
39
- return ["docker", "run", "-d", "--rm", "--name", name, "-p", `${port}:4588`, image].join(" ");
40
- }
41
-
42
- /** Build the `docker rm -f` command. */
43
- export function flociGcpRmCommand(name: string): string {
44
- return `docker rm -f ${name}`;
45
- }
46
-
47
- /** The floci-gcp health endpoint URL for a host port. */
48
- export function flociGcpHealthUrl(port: number): string {
49
- return `http://localhost:${port}/_floci-gcp/health`;
50
- }
21
+ // floci-gcp is a bespoke GCP-REST fake (not LocalStack) a plain 200 on its
22
+ // health endpoint means ready. Shared lifecycle: emulatorLifecycle (#746).
23
+ const gcp = emulatorLifecycle({
24
+ name: "chant-floci-gcp",
25
+ image: "floci/floci-gcp:latest",
26
+ containerPort: 4588,
27
+ healthPath: "/_floci-gcp/health",
28
+ });
51
29
 
30
+ export const flociGcpExistsCommand = gcp.existsCommand;
31
+ export const flociGcpRmCommand = gcp.rmCommand;
32
+ export const flociGcpHealthUrl = gcp.healthUrl;
52
33
  /** The GCP endpoint URL (what `gcpApply`'s `endpoint` should point at). */
53
- export function flociGcpEndpoint(port: number): string {
54
- return `http://localhost:${port}`;
55
- }
56
-
57
- /**
58
- * Boot a local floci-gcp (GCP emulator) in Docker and return its endpoint.
59
- *
60
- * Idempotent: reuses a running container of the same name. Waits for the health
61
- * endpoint to answer, then returns `{ endpoint }` for `gcpApply({ endpoint })`.
62
- * The typed twin of the AWS `flociUp` — replaces a raw `docker run` shell step so
63
- * the emulator lifecycle is modeled, not scripted. Uses longInfra profile — 20m
64
- * timeout, heartbeat every poll (the image may pull).
65
- */
66
- export async function flociGcpUp(args: FlociGcpUpArgs, signal?: AbortSignal): Promise<{ endpoint: string }> {
67
- const name = args.name ?? DEFAULT_NAME;
68
- const port = args.port ?? DEFAULT_PORT;
69
- const timeoutMs = args.timeoutMs ?? 60_000;
70
- const intervalMs = args.intervalMs ?? 2_000;
71
-
72
- let running = false;
73
- try {
74
- const { stdout } = await execAsync(flociGcpExistsCommand(name), { signal });
75
- running = Boolean(stdout.trim());
76
- } catch {
77
- // `docker ps` failed — assume not running and try to start it.
78
- }
34
+ export const flociGcpEndpoint = gcp.endpoint;
35
+ export const flociGcpRunCommand = (args: FlociGcpUpArgs = {}): string => gcp.runCommand(args);
79
36
 
80
- if (running) {
81
- console.log(`floci-gcp container "${name}" already running reusing`);
82
- } else {
83
- await execAsync(flociGcpRunCommand({ ...args, name, port }), { signal });
84
- }
37
+ /** Boot a local floci-gcp (GCP emulator) in Docker and return its endpoint. */
38
+ export const flociGcpUp = (args: FlociGcpUpArgs = {}, signal?: AbortSignal): Promise<{ endpoint: string }> =>
39
+ gcp.up(args, signal);
85
40
 
86
- const url = flociGcpHealthUrl(port);
87
- const deadline = Date.now() + timeoutMs;
88
- let ready = false;
89
- while (Date.now() < deadline) {
90
- if (signal?.aborted) throw new Error("flociGcpUp aborted");
91
- safeHeartbeat({ step: "flociGcpUp", container: name });
92
- try {
93
- const res = await fetch(url, { signal });
94
- if (res.ok) {
95
- ready = true;
96
- break;
97
- }
98
- } catch {
99
- // Not up yet (connection refused / non-2xx) — retry.
100
- }
101
- await sleep(intervalMs, signal);
102
- }
103
- if (!ready) {
104
- throw new Error(`floci-gcp "${name}" did not become ready within ${timeoutMs}ms`);
105
- }
106
-
107
- const endpoint = flociGcpEndpoint(port);
108
- console.log(`floci-gcp ready on ${endpoint}`);
109
- return { endpoint };
110
- }
111
-
112
- /**
113
- * Stop and remove the local floci-gcp container. A no-op success when the
114
- * container is already gone. Uses fastIdempotent profile — 5m timeout.
115
- */
116
- export async function flociGcpDown(args: FlociGcpDownArgs, signal?: AbortSignal): Promise<void> {
117
- const name = args.name ?? DEFAULT_NAME;
118
- try {
119
- await execAsync(flociGcpRmCommand(name), { signal });
120
- } catch {
121
- // Already removed (`--rm` on exit, or never started) — treat as success.
122
- }
123
- }
41
+ /** Stop and remove the local floci-gcp container (no-op if already gone). */
42
+ export const flociGcpDown = (args: FlociGcpDownArgs = {}, signal?: AbortSignal): Promise<void> =>
43
+ gcp.down(args, signal);