@stacksjs/ts-cloud 0.7.4 → 0.7.6

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 (58) hide show
  1. package/dist/aws/index.js +259 -0
  2. package/dist/bin/cli.js +316 -316
  3. package/dist/chunk-0wxyppza.js +146 -0
  4. package/dist/chunk-3knnr7wh.js +601 -0
  5. package/dist/chunk-3rsfns7x.js +10427 -0
  6. package/dist/chunk-93hjhs78.js +1752 -0
  7. package/dist/chunk-arsh1g5h.js +1749 -0
  8. package/dist/chunk-b82pbxyp.js +1572 -0
  9. package/dist/chunk-c6rgvg1j.js +46124 -0
  10. package/dist/chunk-d2p5n2aq.js +23 -0
  11. package/dist/chunk-d7p84vz5.js +1699 -0
  12. package/dist/chunk-dpkk640m.js +4392 -0
  13. package/dist/chunk-eq08r166.js +8 -0
  14. package/dist/chunk-hsk6fe6x.js +371 -0
  15. package/dist/chunk-mj1tmhte.js +13 -0
  16. package/dist/chunk-p6309384.js +12828 -0
  17. package/dist/chunk-pegd7rmf.js +10 -0
  18. package/dist/chunk-pqfzdg68.js +12 -0
  19. package/dist/chunk-qpj3edwz.js +601 -0
  20. package/dist/chunk-tjjgajbh.js +1032 -0
  21. package/dist/chunk-tnztxpcb.js +630 -0
  22. package/dist/chunk-tt4kxske.js +1788 -0
  23. package/dist/chunk-v0bahtg2.js +4 -0
  24. package/dist/chunk-vd87cpvn.js +1754 -0
  25. package/dist/chunk-zn0nxxa8.js +1779 -0
  26. package/dist/deploy/index.js +87 -0
  27. package/dist/dns/index.js +31 -0
  28. package/dist/drivers/hetzner/provision.d.ts +53 -0
  29. package/dist/drivers/index.d.ts +5 -1
  30. package/dist/drivers/index.js +98 -0
  31. package/dist/drivers/shared/remote-exec.d.ts +47 -0
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +4383 -91358
  34. package/dist/push/index.js +509 -0
  35. package/dist/ui/index.html +3 -3
  36. package/dist/ui/server/actions.html +3 -3
  37. package/dist/ui/server/backups.html +3 -3
  38. package/dist/ui/server/database.html +3 -3
  39. package/dist/ui/server/deployments.html +3 -3
  40. package/dist/ui/server/firewall.html +3 -3
  41. package/dist/ui/server/logs.html +3 -3
  42. package/dist/ui/server/services.html +3 -3
  43. package/dist/ui/server/sites.html +3 -3
  44. package/dist/ui/server/ssh-keys.html +3 -3
  45. package/dist/ui/server/terminal.html +3 -3
  46. package/dist/ui/server/workers.html +3 -3
  47. package/dist/ui/serverless/alarms.html +3 -3
  48. package/dist/ui/serverless/assets.html +3 -3
  49. package/dist/ui/serverless/data.html +3 -3
  50. package/dist/ui/serverless/deployments.html +3 -3
  51. package/dist/ui/serverless/functions.html +3 -3
  52. package/dist/ui/serverless/logs.html +3 -3
  53. package/dist/ui/serverless/queues.html +3 -3
  54. package/dist/ui/serverless/scheduler.html +3 -3
  55. package/dist/ui/serverless/secrets.html +3 -3
  56. package/dist/ui/serverless/traces.html +3 -3
  57. package/dist/ui/serverless.html +3 -3
  58. package/package.json +3 -3
@@ -0,0 +1,146 @@
1
+ import {
2
+ ECRClient
3
+ } from "./chunk-hsk6fe6x.js";
4
+ import {
5
+ collectPhpAppEntries,
6
+ generateAppImageDockerfile,
7
+ packageServerlessApp,
8
+ phpRuntimeLayerAssets,
9
+ runPhpBuildHooks,
10
+ sha256
11
+ } from "./chunk-c6rgvg1j.js";
12
+
13
+ // src/deploy/serverless-image.ts
14
+ import { execFileSync } from "node:child_process";
15
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
16
+ import { tmpdir } from "node:os";
17
+ import { dirname, join } from "node:path";
18
+
19
+ // src/utils/cli.ts
20
+ var colors = {
21
+ reset: "\x1B[0m",
22
+ bright: "\x1B[1m",
23
+ dim: "\x1B[2m",
24
+ red: "\x1B[31m",
25
+ green: "\x1B[32m",
26
+ yellow: "\x1B[33m",
27
+ blue: "\x1B[34m",
28
+ magenta: "\x1B[35m",
29
+ cyan: "\x1B[36m",
30
+ white: "\x1B[37m",
31
+ gray: "\x1B[90m"
32
+ };
33
+ function colorize(text, color) {
34
+ return `${colors[color]}${text}${colors.reset}`;
35
+ }
36
+ function success(message) {
37
+ console.log(`${colors.green}✓${colors.reset} ${message}`);
38
+ }
39
+ function error(message) {
40
+ console.error(`${colors.red}✗${colors.reset} ${message}`);
41
+ }
42
+ function warn(message) {
43
+ console.warn(`${colors.yellow}⚠${colors.reset} ${message}`);
44
+ }
45
+ function info(message) {
46
+ console.log(`${colors.blue}ℹ${colors.reset} ${message}`);
47
+ }
48
+ function step(message) {
49
+ console.log(`${colors.cyan}→${colors.reset} ${message}`);
50
+ }
51
+ function header(message) {
52
+ console.log(`
53
+ ${colors.bright}${colors.cyan}${message}${colors.reset}
54
+ `);
55
+ }
56
+ var isCI = !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.BUILDKITE || process.env.CIRCLECI || process.env.GITLAB_CI);
57
+ function box(message, color = "cyan") {
58
+ const lines = message.split(`
59
+ `);
60
+ const maxLength = Math.max(...lines.map((line) => line.length));
61
+ const border = "─".repeat(maxLength + 2);
62
+ console.log(colorize(`┌${border}┐`, color));
63
+ lines.forEach((line) => {
64
+ console.log(colorize(`│ ${line.padEnd(maxLength)} │`, color));
65
+ });
66
+ console.log(colorize(`└${border}┘`, color));
67
+ }
68
+
69
+ // src/deploy/serverless-image.ts
70
+ function writeEntries(baseDir, entries) {
71
+ for (const e of entries) {
72
+ const dest = join(baseDir, e.name);
73
+ mkdirSync(dirname(dest), { recursive: true });
74
+ writeFileSync(dest, e.data, e.mode ? { mode: e.mode } : undefined);
75
+ }
76
+ }
77
+ async function buildAndPushServerlessImage(opts) {
78
+ const { app, projectRoot, region, repository } = opts;
79
+ const arch = app.architecture ?? "x86_64";
80
+ const platform = arch === "arm64" ? "linux/arm64" : "linux/amd64";
81
+ const isPhp = app.kind === "php";
82
+ const step2 = opts.onStep ?? (() => {});
83
+ const stage = mkdtempSync(join(tmpdir(), "tscloud-img-"));
84
+ try {
85
+ const appDir = join(stage, "app");
86
+ mkdirSync(appDir, { recursive: true });
87
+ let handlers;
88
+ let contentHash;
89
+ if (isPhp) {
90
+ runPhpBuildHooks({ projectRoot, app, skipBuild: opts.skipBuild, onStep: step2 });
91
+ step2("staging application tree");
92
+ const entries = collectPhpAppEntries(projectRoot);
93
+ writeEntries(appDir, entries);
94
+ writeEntries(join(stage, "runtime"), phpRuntimeLayerAssets().map((a) => ({ name: a.path, data: a.contents, mode: a.mode })));
95
+ const handler = app.handlers?.http ?? "public/index.php";
96
+ handlers = { http: handler, queue: app.handlers?.queue ?? handler, cli: app.handlers?.cli ?? handler };
97
+ contentHash = sha256(entries.map((e) => `${e.name}:${e.data.length}`).join("|"));
98
+ } else {
99
+ step2("bundling application");
100
+ const artifact = await packageServerlessApp({ projectRoot, app, skipBuild: opts.skipBuild, onStep: step2 });
101
+ writeFileSync(join(appDir, "index.mjs"), artifact.bundle);
102
+ handlers = artifact.handlers;
103
+ contentHash = artifact.sha256;
104
+ }
105
+ const tag = contentHash.slice(0, 16);
106
+ writeFileSync(join(stage, "Dockerfile"), generateAppImageDockerfile({
107
+ kind: app.kind ?? "node",
108
+ phpVersion: app.phpVersion,
109
+ architecture: arch
110
+ }));
111
+ const ecr = new ECRClient(region);
112
+ let repoUri;
113
+ try {
114
+ const desc = await ecr.describeRepositories({ repositoryNames: [repository] });
115
+ repoUri = desc.repositories?.[0]?.repositoryUri ?? "";
116
+ } catch {
117
+ repoUri = "";
118
+ }
119
+ if (!repoUri) {
120
+ step2(`creating ECR repository ${repository}`);
121
+ const created = await ecr.createRepository({ repositoryName: repository, imageScanningConfiguration: { scanOnPush: true } });
122
+ repoUri = created.repository?.repositoryUri ?? "";
123
+ }
124
+ if (!repoUri)
125
+ throw new Error(`could not resolve ECR repository URI for ${repository}`);
126
+ const imageUri = `${repoUri}:${tag}`;
127
+ step2("docker build");
128
+ execFileSync("docker", ["build", "--platform", platform, "--provenance=false", "--sbom=false", "-t", imageUri, stage], { stdio: "inherit" });
129
+ step2("ecr auth + push");
130
+ const auth = await ecr.getAuthorizationToken();
131
+ const data = auth.authorizationData?.[0];
132
+ if (!data?.authorizationToken || !data.proxyEndpoint)
133
+ throw new Error("failed to get an ECR authorization token");
134
+ const registry = data.proxyEndpoint.replace(/^https?:\/\//, "");
135
+ const dockerConfig = join(stage, ".docker");
136
+ mkdirSync(dockerConfig, { recursive: true });
137
+ writeFileSync(join(dockerConfig, "config.json"), JSON.stringify({ auths: { [registry]: { auth: data.authorizationToken } } }));
138
+ execFileSync("docker", ["push", imageUri], { stdio: "inherit", env: { ...process.env, DOCKER_CONFIG: dockerConfig } });
139
+ info(`Image: ${imageUri}`);
140
+ return { imageUri, tag, handlers };
141
+ } finally {
142
+ rmSync(stage, { recursive: true, force: true });
143
+ }
144
+ }
145
+
146
+ export { success, error, warn, info, step, header, box, buildAndPushServerlessImage };