@cloudhal/cli 0.10.0 → 0.10.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.
@@ -14,18 +14,18 @@
14
14
  "astro": "astro"
15
15
  },
16
16
  "dependencies": {
17
- "@cloudhal/astro-renderer": "0.10.0",
18
- "@cloudhal/core-ts": "0.10.0",
17
+ "@cloudhal/astro-renderer": "0.10.1",
18
+ "@cloudhal/core-ts": "0.10.1",
19
19
  "@tailwindcss/vite": "^4.3.3",
20
20
  "astro": "7.4.7",
21
21
  "better-sqlite3": "13.0.3",
22
22
  "tailwindcss": "^4.3.3",
23
23
  "@astrojs/cloudflare": "14.4.6",
24
- "@cloudhal/cli": "0.10.0"
24
+ "@cloudhal/cli": "0.10.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "wrangler": "^4.158.0",
28
- "@cloudhal/cloudflare": "0.10.0"
28
+ "@cloudhal/cloudflare": "0.10.1"
29
29
  },
30
30
  "trustedDependencies": [
31
31
  "better-sqlite3",
@@ -69,21 +69,39 @@ async function target(options ) {
69
69
  return { cfg, url, token, fetch: f };
70
70
  }
71
71
 
72
+ /**
73
+ * `ifAbsent`: whether the deployment already has the site. Only a 200 (it has it) and a 404 (it
74
+ * does not) are answers. A 401 throws an error `whileTokenPropagates` retries: right after a
75
+ * Workers Builds deploy the edge can still check the new token against the previous admin
76
+ * Worker, and pushing then would hit the site the deployment does have. Anything else throws
77
+ * too, and nothing is pushed.
78
+ */
79
+ async function deploymentHasSite(f , url , auth ) {
80
+ const probe = await f(url, { headers: auth });
81
+ if (probe.status === 200) return true;
82
+ if (probe.status === 404) return false;
83
+ throw new Error(
84
+ `checking whether the deployment has the site failed (${probe.status}): ${brief(await probe.text())}; nothing was pushed`,
85
+ );
86
+ }
87
+
88
+ /** A bootstrap PUT refused because the deployment already has this site (SyncConflictError). */
89
+ const alreadyHasSite = (status , body ) =>
90
+ status === 409 && body.includes('"error":"conflict"') && body.includes("already has site");
91
+
72
92
  export async function pushSite(
73
93
  options ,
74
94
  ) {
75
95
  const log = options.log ?? (() => {});
76
96
  const { cfg, url, token, fetch: f } = await target(options);
77
97
  const auth = { authorization: `Bearer ${token}` };
78
- if (options.ifAbsent) {
79
- const probe = await f(url, { headers: auth });
80
- if (probe.status === 200) {
81
- log(
82
- "the deployment already has this site; leaving it as the source of truth (use `cloudhal pull`)",
83
- );
84
- return { pushed: false, message: "already deployed" };
85
- }
86
- }
98
+ const keepDeployed = () => {
99
+ log(
100
+ "the deployment already has this site; leaving it as the source of truth (use `cloudhal pull`)",
101
+ );
102
+ return { pushed: false, message: "already deployed" };
103
+ };
104
+ if (options.ifAbsent && (await deploymentHasSite(f, url, auth))) return keepDeployed();
87
105
  const local = await openLocalStore(path.join(options.projectDir, cfg.dataDir));
88
106
  let bundle ;
89
107
  try {
@@ -118,6 +136,9 @@ export async function pushSite(
118
136
  body: JSON.stringify(bundle),
119
137
  });
120
138
  const body = await res.text();
139
+ // The probe said absent, yet the site is there (it arrived between the two): same outcome.
140
+ if (options.ifAbsent && !options.replace && alreadyHasSite(res.status, body))
141
+ return keepDeployed();
121
142
  if (res.status === 409 && /"error":"schedules_(pending|running)"/.test(body)) {
122
143
  const parsed = JSON.parse(body)
123
144
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudhal/cli",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "cloudhal — create, run and build Cloudhal sites locally",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://cloudhal.dev",
@@ -27,19 +27,19 @@
27
27
  "README.md"
28
28
  ],
29
29
  "dependencies": {
30
- "@cloudhal/agent-runtime": "0.10.0",
31
- "@cloudhal/analytics": "0.10.0",
32
- "@cloudhal/api": "0.10.0",
33
- "@cloudhal/astro-renderer": "0.10.0",
34
- "@cloudhal/cloudflare": "0.10.0",
35
- "@cloudhal/comments": "0.10.0",
36
- "@cloudhal/core-contracts": "0.10.0",
37
- "@cloudhal/core-ts": "0.10.0",
38
- "@cloudhal/mcp-server": "0.10.0",
39
- "@cloudhal/release-verify": "0.10.0",
40
- "@cloudhal/schedules": "0.10.0",
41
- "@cloudhal/storage": "0.10.0",
42
- "@hono/node-server": "^2.1.4",
30
+ "@cloudhal/agent-runtime": "0.10.1",
31
+ "@cloudhal/analytics": "0.10.1",
32
+ "@cloudhal/api": "0.10.1",
33
+ "@cloudhal/astro-renderer": "0.10.1",
34
+ "@cloudhal/cloudflare": "0.10.1",
35
+ "@cloudhal/comments": "0.10.1",
36
+ "@cloudhal/core-contracts": "0.10.1",
37
+ "@cloudhal/core-ts": "0.10.1",
38
+ "@cloudhal/mcp-server": "0.10.1",
39
+ "@cloudhal/release-verify": "0.10.1",
40
+ "@cloudhal/schedules": "0.10.1",
41
+ "@cloudhal/storage": "0.10.1",
42
+ "@hono/node-server": "^2.1.6",
43
43
  "better-sqlite3": "13.0.3"
44
44
  },
45
45
  "peerDependencies": {