@stacksjs/ts-cloud 0.7.26 → 0.7.28

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.
@@ -55,7 +55,7 @@ function buildPantryBootstrapScript(options = {}) {
55
55
  versionLine,
56
56
  "command -v curl >/dev/null 2>&1 || (apt-get update -y && apt-get install -y curl ca-certificates)",
57
57
  "command -v unzip >/dev/null 2>&1 || (apt-get update -y && apt-get install -y unzip)",
58
- "command -v pantry >/dev/null 2>&1 || curl -fsSL https://pantry.dev | bash",
58
+ `command -v pantry >/dev/null 2>&1 || { ` + `OS=$(uname -s | tr '[:upper:]' '[:lower:]'); ARCH=$(uname -m); ` + `case "$ARCH" in x86_64|amd64) ARCH=x64 ;; arm64|aarch64) ARCH=arm64 ;; esac; ` + `ZIP="pantry-\${OS}-\${ARCH}.zip"; ` + `if [ "\${PANTRY_VERSION:-latest}" = latest ]; then REL='latest/download'; else REL="download/v\${PANTRY_VERSION}"; fi; ` + `TMP=$(mktemp -d); ` + `curl -fsSL -o "\${TMP}/\${ZIP}" "https://github.com/home-lang/pantry/releases/\${REL}/\${ZIP}"; ` + `unzip -o "\${TMP}/\${ZIP}" -d ${PANTRY_INSTALL_DIR}; ` + `chmod +x ${PANTRY_INSTALL_DIR}/pantry; rm -rf "\${TMP}"; }`,
59
59
  `export PATH="${PANTRY_INSTALL_DIR}:$PATH"`,
60
60
  `mkdir -p ${PANTRY_PROJECT_DIR}`
61
61
  ];
@@ -841,7 +841,13 @@ let files = []
841
841
  try { files = readdirSync(dir).filter(n => n.endsWith('.json')).sort() } catch {}
842
842
  for (const f of files) {
843
843
  let frag
844
- try { frag = JSON.parse(readFileSync(dir + '/' + f, 'utf8')) } catch { continue }
844
+ // Fragments are written atomically (temp + rename by ts-cloud), so a parse
845
+ // failure here means a genuinely corrupt fragment, not a mid-write read. Log
846
+ // it LOUD — a silent skip drops that app's whole host from the routing table,
847
+ // which then answers 404 until someone notices. We still continue so one bad
848
+ // fragment can't take every other app down, but the drop is now visible.
849
+ try { frag = JSON.parse(readFileSync(dir + '/' + f, 'utf8')) }
850
+ catch (err) { console.error('[rpx-assembler] SKIPPING malformed fragment ' + f + ' — its host(s) will 404 until fixed: ' + err); continue }
845
851
  for (const p of frag.proxies ?? []) {
846
852
  const key = p.id || (p.to + (p.path ?? ''))
847
853
  if (seen.has(key)) continue
@@ -873,9 +879,12 @@ await startProxies(config)
873
879
  }
874
880
  function writeFileHeredoc(path, content, delimiter) {
875
881
  return [
876
- `cat > ${path} <<'${delimiter}'`,
882
+ `__tsc_tmp="$(mktemp "${path}.XXXXXX")"`,
883
+ `cat > "$__tsc_tmp" <<'${delimiter}'`,
877
884
  content,
878
- delimiter
885
+ delimiter,
886
+ `mv -f "$__tsc_tmp" ${path}`,
887
+ `chmod 0644 ${path}`
879
888
  ];
880
889
  }
881
890
  function certDomainsForConfig(config) {
@@ -1604,7 +1613,7 @@ function resolveAwsImageId(config) {
1604
1613
  // src/drivers/aws/driver.ts
1605
1614
  function readPinnedInstanceId(stackName) {
1606
1615
  try {
1607
- const raw = readFileSync(join(process.cwd(), ".ts-cloud/state", `${stackName}.json`), "utf8");
1616
+ const raw = readFileSync(join(process.cwd(), "storage/cloud/state", `${stackName}.json`), "utf8");
1608
1617
  const state = JSON.parse(raw);
1609
1618
  return typeof state.instanceId === "string" && state.instanceId.length > 0 ? state.instanceId : null;
1610
1619
  } catch {
@@ -2267,7 +2276,7 @@ function matchesTsCloudLabels(labels, slug, environment, role = "app") {
2267
2276
  // src/drivers/hetzner/state.ts
2268
2277
  import { mkdir, readFile, writeFile } from "node:fs/promises";
2269
2278
  import { join as join3 } from "node:path";
2270
- var STATE_DIR = ".ts-cloud/state";
2279
+ var STATE_DIR = "storage/cloud/state";
2271
2280
  function driverStatePath(stackName) {
2272
2281
  return join3(process.cwd(), STATE_DIR, `${stackName}.json`);
2273
2282
  }
@@ -4577,7 +4586,7 @@ async function deploySiteRelease(driver, options, logger = noopLogger2) {
4577
4586
  stackName
4578
4587
  });
4579
4588
  if (targets.length === 0) {
4580
- const hint = driver.name === "aws" ? `Stack '${stackName}' has no EC2 instances tagged Project=${slug} Environment=${environment} Role=app, and .ts-cloud/state/${stackName}.json pins no live instance. For a shared box, record its instanceId there.` : `No Hetzner servers labeled ts-cloud/project=${slug} ts-cloud/environment=${environment} ts-cloud/role=app, and .ts-cloud/state/${stackName}.json pins no live server. For a shared box, record its serverId there.`;
4589
+ const hint = driver.name === "aws" ? `Stack '${stackName}' has no EC2 instances tagged Project=${slug} Environment=${environment} Role=app, and storage/cloud/state/${stackName}.json pins no live instance. For a shared box, record its instanceId there.` : `No Hetzner servers labeled ts-cloud/project=${slug} ts-cloud/environment=${environment} ts-cloud/role=app, and storage/cloud/state/${stackName}.json pins no live server. For a shared box, record its serverId there.`;
4581
4590
  return { success: false, error: hint };
4582
4591
  }
4583
4592
  if (isPhpSite(site)) {
@@ -28,7 +28,7 @@ import {
28
28
  resolveSiteKind,
29
29
  resolveUiSource,
30
30
  siteInstallBase
31
- } from "./chunk-q75x5tw6.js";
31
+ } from "./chunk-5m8y0gx1.js";
32
32
  import {
33
33
  artifactKey,
34
34
  composeServerlessAppTemplate,
@@ -10224,7 +10224,7 @@ function configuredRegion(config6) {
10224
10224
  return config6.project.region ?? "us-east-1";
10225
10225
  }
10226
10226
  function loadLocalState(config6, environment) {
10227
- const statePath = join9(process.cwd(), ".ts-cloud", "state", `${config6.project.slug}-${environment}.json`);
10227
+ const statePath = join9(process.cwd(), "storage", "cloud", "state", `${config6.project.slug}-${environment}.json`);
10228
10228
  if (!existsSync14(statePath))
10229
10229
  return null;
10230
10230
  try {
@@ -12,7 +12,7 @@ import {
12
12
  sanitizeCloudConfig,
13
13
  setMaintenance,
14
14
  startLocalDashboardServer
15
- } from "../chunk-zz10yhec.js";
15
+ } from "../chunk-a71qr72q.js";
16
16
  import {
17
17
  buildAndPushServerlessImage
18
18
  } from "../chunk-zcx1x2bf.js";
@@ -30,7 +30,7 @@ import {
30
30
  resolveUiSource,
31
31
  siteInstallBase,
32
32
  validateDeploymentConfig
33
- } from "../chunk-q75x5tw6.js";
33
+ } from "../chunk-5m8y0gx1.js";
34
34
  import"../chunk-haw9g3zk.js";
35
35
  import"../chunk-93hjhs78.js";
36
36
  import {
@@ -5,7 +5,7 @@ export interface AwsDriverOptions {
5
5
  /**
6
6
  * Local-state pin (parity with the Hetzner driver's shared-box support): a
7
7
  * project riding an instance whose tags belong to another project records
8
- * `{ "instanceId": "i-..." }` in `.ts-cloud/state/<stack>.json`, and target
8
+ * `{ "instanceId": "i-..." }` in `storage/cloud/state/<stack>.json`, and target
9
9
  * lookups trust that record when the tag scan finds nothing. Exported for
10
10
  * tests.
11
11
  */
@@ -22,6 +22,7 @@ export interface HetznerDriverState {
22
22
  lbServerId?: number;
23
23
  appServerIds?: number[];
24
24
  }
25
+ export declare const STATE_DIR = "storage/cloud/state";
25
26
  export declare function driverStatePath(stackName: string): string;
26
27
  export declare function readDriverState(stackName: string): Promise<HetznerDriverState | null>;
27
28
  export declare function writeDriverState(stackName: string, state: HetznerDriverState): Promise<void>;
@@ -48,7 +48,7 @@ import {
48
48
  waitForCloudInit,
49
49
  waitForSsh,
50
50
  wrapCloudInitUserData
51
- } from "../chunk-q75x5tw6.js";
51
+ } from "../chunk-5m8y0gx1.js";
52
52
  import"../chunk-haw9g3zk.js";
53
53
  import"../chunk-93hjhs78.js";
54
54
  import"../chunk-qpj3edwz.js";
package/dist/index.js CHANGED
@@ -55,7 +55,7 @@ import {
55
55
  sanitizeCloudConfig,
56
56
  setMaintenance,
57
57
  startLocalDashboardServer
58
- } from "./chunk-zz10yhec.js";
58
+ } from "./chunk-a71qr72q.js";
59
59
  import {
60
60
  buildAndPushServerlessImage
61
61
  } from "./chunk-zcx1x2bf.js";
@@ -105,7 +105,7 @@ import {
105
105
  waitForCloudInit,
106
106
  waitForSsh,
107
107
  wrapCloudInitUserData
108
- } from "./chunk-q75x5tw6.js";
108
+ } from "./chunk-5m8y0gx1.js";
109
109
  import {
110
110
  ABTestManager,
111
111
  AI,