@caelo-cms/provisioning 0.1.1 → 0.2.3

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.
Files changed (65) hide show
  1. package/dist/cli.js +92 -7
  2. package/dist/cli.js.map +1 -1
  3. package/dist/compose.d.ts +7 -0
  4. package/dist/compose.d.ts.map +1 -1
  5. package/dist/compose.js +10 -9
  6. package/dist/compose.js.map +1 -1
  7. package/dist/dns/cloudflare.d.ts +9 -0
  8. package/dist/dns/cloudflare.d.ts.map +1 -0
  9. package/dist/dns/cloudflare.js +160 -0
  10. package/dist/dns/cloudflare.js.map +1 -0
  11. package/dist/dns/index.d.ts +12 -0
  12. package/dist/dns/index.d.ts.map +1 -0
  13. package/dist/dns/index.js +42 -0
  14. package/dist/dns/index.js.map +1 -0
  15. package/dist/dns/manual.d.ts +5 -0
  16. package/dist/dns/manual.d.ts.map +1 -0
  17. package/dist/dns/manual.js +96 -0
  18. package/dist/dns/manual.js.map +1 -0
  19. package/dist/dns/types.d.ts +23 -0
  20. package/dist/dns/types.d.ts.map +1 -0
  21. package/dist/dns/types.js +3 -0
  22. package/dist/dns/types.js.map +1 -0
  23. package/dist/gcloud.d.ts +42 -0
  24. package/dist/gcloud.d.ts.map +1 -0
  25. package/dist/gcloud.js +187 -0
  26. package/dist/gcloud.js.map +1 -0
  27. package/dist/install-state.d.ts +54 -0
  28. package/dist/install-state.d.ts.map +1 -0
  29. package/dist/install-state.js +118 -0
  30. package/dist/install-state.js.map +1 -0
  31. package/dist/lifecycle.d.ts +19 -0
  32. package/dist/lifecycle.d.ts.map +1 -0
  33. package/dist/lifecycle.js +588 -0
  34. package/dist/lifecycle.js.map +1 -0
  35. package/dist/migration-runner.d.ts +15 -0
  36. package/dist/migration-runner.d.ts.map +1 -0
  37. package/dist/migration-runner.js +174 -0
  38. package/dist/migration-runner.js.map +1 -0
  39. package/dist/redirects-emit.d.ts.map +1 -1
  40. package/dist/redirects-emit.js +4 -1
  41. package/dist/redirects-emit.js.map +1 -1
  42. package/dist/wizard.d.ts +35 -0
  43. package/dist/wizard.d.ts.map +1 -0
  44. package/dist/wizard.js +160 -0
  45. package/dist/wizard.js.map +1 -0
  46. package/dist/wizards/gcp-cost.d.ts +27 -0
  47. package/dist/wizards/gcp-cost.d.ts.map +1 -0
  48. package/dist/wizards/gcp-cost.js +77 -0
  49. package/dist/wizards/gcp-cost.js.map +1 -0
  50. package/dist/wizards/gcp-pulumi.d.ts +37 -0
  51. package/dist/wizards/gcp-pulumi.d.ts.map +1 -0
  52. package/dist/wizards/gcp-pulumi.js +100 -0
  53. package/dist/wizards/gcp-pulumi.js.map +1 -0
  54. package/dist/wizards/gcp.d.ts +9 -0
  55. package/dist/wizards/gcp.d.ts.map +1 -0
  56. package/dist/wizards/gcp.js +895 -0
  57. package/dist/wizards/gcp.js.map +1 -0
  58. package/package.json +13 -2
  59. package/stacks/aws/index.ts +6 -7
  60. package/stacks/azure/index.ts +11 -11
  61. package/stacks/gcp/Pulumi.production.yaml +16 -0
  62. package/stacks/gcp/Pulumi.yaml +52 -6
  63. package/stacks/gcp/index.ts +569 -188
  64. package/stacks/self-hosted/index.ts +3 -3
  65. package/static/welcome.html +155 -0
@@ -0,0 +1,100 @@
1
+ // SPDX-License-Identifier: MPL-2.0
2
+ /**
3
+ * Pulumi Automation SDK wrapper for the GCP wizard. Replaces the
4
+ * shell-out `pulumi up` flow with a programmatic equivalent that
5
+ * streams progress events into the wizard's UI.
6
+ *
7
+ * Per CLAUDE.md §11.C: end-users never see `pulumi` directly. The
8
+ * wizard handles passphrase + state location + config + up; failures
9
+ * surface inline with provider errors.
10
+ */
11
+ import { join, resolve as resolvePath } from "node:path";
12
+ import * as pulumi from "@pulumi/pulumi/automation";
13
+ /**
14
+ * Resolve the GCP stack workdir relative to the installed package.
15
+ * Works whether the CLI runs from source (apps/admin/scripts/...)
16
+ * or from the published npm tarball (node_modules/@caelo-cms/...).
17
+ */
18
+ function gcpStackWorkDir() {
19
+ // The Pulumi.yaml + stacks/gcp/index.ts ship in the npm tarball
20
+ // under `stacks/gcp/`. From this file's location at runtime
21
+ // (dist/wizards/gcp-pulumi.js), the stack dir is two levels up
22
+ // + into stacks/gcp/.
23
+ return resolvePath(import.meta.dir, "../../stacks/gcp");
24
+ }
25
+ /**
26
+ * Run `pulumi up` against the GCP stack via the Automation SDK.
27
+ * Streams resource-create events to the supplied onEvent callback so
28
+ * the wizard can render a live progress bar.
29
+ */
30
+ export async function pulumiUpGcp(inputs, onEvent) {
31
+ // Pulumi's local backend reads the passphrase from
32
+ // PULUMI_CONFIG_PASSPHRASE; we set it for this process scope only.
33
+ // Same for the GOOGLE_APPLICATION_CREDENTIALS pointing at the SA key.
34
+ const env = {
35
+ ...process.env,
36
+ PULUMI_CONFIG_PASSPHRASE: inputs.pulumiPassphrase,
37
+ GOOGLE_APPLICATION_CREDENTIALS: inputs.saKeyPath,
38
+ // Pulumi local-backend state lives under the install's state dir.
39
+ PULUMI_BACKEND_URL: `file://${join(inputs.installRoot, "state")}`,
40
+ };
41
+ const stackName = "production";
42
+ const workDir = gcpStackWorkDir();
43
+ const stack = await pulumi.LocalWorkspace.createOrSelectStack({
44
+ stackName,
45
+ workDir,
46
+ }, {
47
+ envVars: env,
48
+ });
49
+ // Set every config value the stack reads. Secrets via setConfig with
50
+ // {value, secret: true}; Pulumi encrypts them in state.
51
+ await stack.setAllConfig({
52
+ "caelo-gcp:project": { value: inputs.projectId },
53
+ "caelo-gcp:domain": { value: inputs.domain },
54
+ "caelo-gcp:ownerEmail": { value: inputs.ownerEmail },
55
+ "caelo-gcp:region": { value: inputs.region },
56
+ "caelo-gcp:cloudSqlTier": { value: inputs.cloudSqlTier },
57
+ "caelo-gcp:cloudSqlHa": { value: String(inputs.cloudSqlHa) },
58
+ "caelo-gcp:adminMinInstances": { value: String(inputs.adminMinInstances) },
59
+ "caelo-gcp:gatewayMinInstances": { value: String(inputs.gatewayMinInstances) },
60
+ "caelo-gcp:wafAdaptiveProtection": { value: String(inputs.wafAdaptiveProtection) },
61
+ "caelo-gcp:iapAllowlist": { value: inputs.iapAllowlist.join(",") },
62
+ "caelo-gcp:anthropicApiKey": { value: inputs.anthropicApiKey, secret: true },
63
+ ...Object.fromEntries(Object.entries(inputs.imageDigests).map(([service, digest]) => [
64
+ `caelo-gcp:image-digest-${service}`,
65
+ { value: digest },
66
+ ])),
67
+ });
68
+ // Refresh state first to detect drift from any out-of-band changes.
69
+ await stack.refresh({ onOutput: (msg) => onEvent("log", msg) });
70
+ // Run `up`. The onEvent callback receives the same JSON-RPC events
71
+ // Pulumi prints to stdout in --json mode.
72
+ const result = await stack.up({
73
+ onOutput: (msg) => onEvent("log", msg),
74
+ onEvent: (event) => {
75
+ // We only care about resource start/finish events for the
76
+ // progress UI — diagnostics surface via onOutput already.
77
+ if (event.resOpFailedEvent) {
78
+ onEvent("error", `${event.resOpFailedEvent.metadata.urn}: ${event.resOpFailedEvent.status}`);
79
+ }
80
+ else if (event.resOutputsEvent) {
81
+ onEvent("resource", event.resOutputsEvent.metadata.urn);
82
+ }
83
+ },
84
+ });
85
+ const summary = result.summary;
86
+ const changes = summary.resourceChanges ?? {};
87
+ const outputs = {};
88
+ for (const [k, v] of Object.entries(result.outputs)) {
89
+ outputs[k] = v.value;
90
+ }
91
+ return {
92
+ outputs,
93
+ resourceCount: {
94
+ created: changes.create ?? 0,
95
+ updated: changes.update ?? 0,
96
+ deleted: changes.delete ?? 0,
97
+ },
98
+ };
99
+ }
100
+ //# sourceMappingURL=gcp-pulumi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gcp-pulumi.js","sourceRoot":"","sources":["../../src/wizards/gcp-pulumi.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAC;AA8BpD;;;;GAIG;AACH,SA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E,CAC3E,CAAC;YACJ,CAAC;iBAAM,IAAI,KAAK,CAAC,eAAe,EAAE,CAAC;gBACjC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;IAC9C,MAAM,OAAO,GAA4B,EAAE,CAAC;IAC5C,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;IACvB,CAAC;IAED,OAAO;QACL,OAAO;QACP,aAAa,EAAE;YACb,OAAO,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC;YAC5B,OAAO,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC;YAC5B,OAAO,EAAE,OAAO,CAAC,MAAM,IAAI,CAAC;SAC7B;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ export interface GcpWizardOpts {
2
+ installId: string;
3
+ domain: string;
4
+ ownerEmail: string;
5
+ projectId: string | null;
6
+ nonInteractive: boolean;
7
+ }
8
+ export declare function runGcpWizard(opts: GcpWizardOpts): Promise<void>;
9
+ //# sourceMappingURL=gcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gcp.d.ts","sourceRoot":"","sources":["../../src/wizards/gcp.ts"],"names":[],"mappings":"AAqEA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CA2JrE"}