@conloca/cloud-astro 0.2.5 → 0.2.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 (171) hide show
  1. package/README.md +69 -22
  2. package/dist/.build-inputs.json +36 -23
  3. package/dist/src/constants.d.ts +4 -4
  4. package/dist/src/constants.js +4 -4
  5. package/dist/src/d3-build.d.ts +6 -2
  6. package/dist/src/d3-build.d.ts.map +1 -1
  7. package/dist/src/d3-build.js +15 -11
  8. package/dist/src/d3-build.js.map +1 -1
  9. package/dist/src/d8-adapters.d.ts +10 -0
  10. package/dist/src/d8-adapters.d.ts.map +1 -0
  11. package/dist/src/d8-adapters.js +19 -0
  12. package/dist/src/d8-adapters.js.map +1 -0
  13. package/dist/src/d8-build.d.ts +99 -0
  14. package/dist/src/d8-build.d.ts.map +1 -0
  15. package/dist/src/d8-build.js +265 -0
  16. package/dist/src/d8-build.js.map +1 -0
  17. package/dist/src/d8-guards.d.ts +29 -0
  18. package/dist/src/d8-guards.d.ts.map +1 -0
  19. package/dist/src/d8-guards.js +145 -0
  20. package/dist/src/d8-guards.js.map +1 -0
  21. package/dist/src/d8-middleware.d.ts +7 -0
  22. package/dist/src/d8-middleware.d.ts.map +1 -0
  23. package/dist/src/d8-middleware.js +15 -0
  24. package/dist/src/d8-middleware.js.map +1 -0
  25. package/dist/src/d8-render.d.ts +9 -0
  26. package/dist/src/d8-render.d.ts.map +1 -0
  27. package/dist/src/d8-render.js +52 -0
  28. package/dist/src/d8-render.js.map +1 -0
  29. package/dist/src/doctor/checks-d8.d.ts +7 -0
  30. package/dist/src/doctor/checks-d8.d.ts.map +1 -0
  31. package/dist/src/doctor/checks-d8.js +240 -0
  32. package/dist/src/doctor/checks-d8.js.map +1 -0
  33. package/dist/src/doctor/checks-live.d.ts.map +1 -1
  34. package/dist/src/doctor/checks-live.js +3 -5
  35. package/dist/src/doctor/checks-live.js.map +1 -1
  36. package/dist/src/doctor/checks-offline.d.ts +2 -0
  37. package/dist/src/doctor/checks-offline.d.ts.map +1 -1
  38. package/dist/src/doctor/checks-offline.js +17 -8
  39. package/dist/src/doctor/checks-offline.js.map +1 -1
  40. package/dist/src/doctor/checks-preview-live.d.ts +7 -2
  41. package/dist/src/doctor/checks-preview-live.d.ts.map +1 -1
  42. package/dist/src/doctor/checks-preview-live.js +107 -7
  43. package/dist/src/doctor/checks-preview-live.js.map +1 -1
  44. package/dist/src/doctor/checks-preview.d.ts.map +1 -1
  45. package/dist/src/doctor/checks-preview.js +9 -4
  46. package/dist/src/doctor/checks-preview.js.map +1 -1
  47. package/dist/src/doctor/config-scan.d.ts +24 -6
  48. package/dist/src/doctor/config-scan.d.ts.map +1 -1
  49. package/dist/src/doctor/config-scan.js +89 -18
  50. package/dist/src/doctor/config-scan.js.map +1 -1
  51. package/dist/src/doctor/run.d.ts.map +1 -1
  52. package/dist/src/doctor/run.js +2 -0
  53. package/dist/src/doctor/run.js.map +1 -1
  54. package/dist/src/doctor/types.d.ts +7 -0
  55. package/dist/src/doctor/types.d.ts.map +1 -1
  56. package/dist/src/doctor/types.js +7 -0
  57. package/dist/src/doctor/types.js.map +1 -1
  58. package/dist/src/editor-page/emit.d.ts +4 -3
  59. package/dist/src/editor-page/emit.d.ts.map +1 -1
  60. package/dist/src/editor-page/emit.js +9 -9
  61. package/dist/src/editor-page/emit.js.map +1 -1
  62. package/dist/src/integration.d.ts.map +1 -1
  63. package/dist/src/integration.js +228 -124
  64. package/dist/src/integration.js.map +1 -1
  65. package/dist/src/node.d.ts +2 -0
  66. package/dist/src/node.d.ts.map +1 -1
  67. package/dist/src/node.js +4 -0
  68. package/dist/src/node.js.map +1 -1
  69. package/dist/src/preview/_resolve-opts.d.ts +26 -1
  70. package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
  71. package/dist/src/preview/_resolve-opts.js.map +1 -1
  72. package/dist/src/preview/content-api.d.ts +15 -0
  73. package/dist/src/preview/content-api.d.ts.map +1 -1
  74. package/dist/src/preview/content-api.js +57 -6
  75. package/dist/src/preview/content-api.js.map +1 -1
  76. package/dist/src/preview/d8-middleware.d.ts +25 -0
  77. package/dist/src/preview/d8-middleware.d.ts.map +1 -0
  78. package/dist/src/preview/d8-middleware.js +94 -0
  79. package/dist/src/preview/d8-middleware.js.map +1 -0
  80. package/dist/src/preview/dispatcher.d.ts +3 -16
  81. package/dist/src/preview/dispatcher.d.ts.map +1 -1
  82. package/dist/src/preview/dispatcher.js +46 -134
  83. package/dist/src/preview/dispatcher.js.map +1 -1
  84. package/dist/src/preview/headers.d.ts +3 -0
  85. package/dist/src/preview/headers.d.ts.map +1 -1
  86. package/dist/src/preview/headers.js +10 -1
  87. package/dist/src/preview/headers.js.map +1 -1
  88. package/dist/src/preview/links.d.ts +23 -0
  89. package/dist/src/preview/links.d.ts.map +1 -0
  90. package/dist/src/preview/links.js +168 -0
  91. package/dist/src/preview/links.js.map +1 -0
  92. package/dist/src/preview/middleware.d.ts +9 -3
  93. package/dist/src/preview/middleware.d.ts.map +1 -1
  94. package/dist/src/preview/middleware.js +36 -16
  95. package/dist/src/preview/middleware.js.map +1 -1
  96. package/dist/src/preview/prefix-router.d.ts +67 -0
  97. package/dist/src/preview/prefix-router.d.ts.map +1 -0
  98. package/dist/src/preview/prefix-router.js +153 -0
  99. package/dist/src/preview/prefix-router.js.map +1 -0
  100. package/dist/src/preview/preview-path.d.ts +8 -3
  101. package/dist/src/preview/preview-path.d.ts.map +1 -1
  102. package/dist/src/preview/preview-path.js +16 -4
  103. package/dist/src/preview/preview-path.js.map +1 -1
  104. package/dist/src/preview/site-middleware.d.ts +8 -2
  105. package/dist/src/preview/site-middleware.d.ts.map +1 -1
  106. package/dist/src/preview/site-middleware.js +90 -31
  107. package/dist/src/preview/site-middleware.js.map +1 -1
  108. package/dist/src/preview/site-page-sources.d.ts +21 -0
  109. package/dist/src/preview/site-page-sources.d.ts.map +1 -0
  110. package/dist/src/preview/site-page-sources.js +129 -0
  111. package/dist/src/preview/site-page-sources.js.map +1 -0
  112. package/dist/src/preview/site-pages.d.ts +18 -0
  113. package/dist/src/preview/site-pages.d.ts.map +1 -0
  114. package/dist/src/preview/site-pages.js +7 -0
  115. package/dist/src/preview/site-pages.js.map +1 -0
  116. package/dist/src/preview-build.d.ts +17 -16
  117. package/dist/src/preview-build.d.ts.map +1 -1
  118. package/dist/src/preview-build.js +37 -40
  119. package/dist/src/preview-build.js.map +1 -1
  120. package/dist/src/preview-image-endpoint.d.ts +8 -0
  121. package/dist/src/preview-image-endpoint.d.ts.map +1 -0
  122. package/dist/src/preview-image-endpoint.js +34 -0
  123. package/dist/src/preview-image-endpoint.js.map +1 -0
  124. package/dist/src/preview-render-seams.d.ts +7 -0
  125. package/dist/src/preview-render-seams.d.ts.map +1 -0
  126. package/dist/src/preview-render-seams.js +27 -0
  127. package/dist/src/preview-render-seams.js.map +1 -0
  128. package/dist/src/site-middleware.d.ts +2 -4
  129. package/dist/src/site-middleware.d.ts.map +1 -1
  130. package/dist/src/site-middleware.js +6 -22
  131. package/dist/src/site-middleware.js.map +1 -1
  132. package/dist/src/types.d.ts +15 -16
  133. package/dist/src/types.d.ts.map +1 -1
  134. package/package.json +138 -6
  135. package/src/constants.ts +4 -4
  136. package/src/d3-build.ts +20 -14
  137. package/src/d8-adapters.ts +19 -0
  138. package/src/d8-build.ts +356 -0
  139. package/src/d8-guards.ts +177 -0
  140. package/src/d8-middleware.ts +17 -0
  141. package/src/d8-render.ts +61 -0
  142. package/src/doctor/checks-d8.ts +256 -0
  143. package/src/doctor/checks-live.ts +3 -4
  144. package/src/doctor/checks-offline.ts +21 -8
  145. package/src/doctor/checks-preview-live.ts +114 -8
  146. package/src/doctor/checks-preview.ts +9 -4
  147. package/src/doctor/config-scan.ts +86 -15
  148. package/src/doctor/run.ts +2 -0
  149. package/src/doctor/types.ts +8 -0
  150. package/src/editor-page/emit.ts +23 -14
  151. package/src/integration.ts +274 -135
  152. package/src/node.ts +4 -0
  153. package/src/preview/_resolve-opts.ts +17 -1
  154. package/src/preview/content-api.ts +60 -5
  155. package/src/preview/d8-middleware.ts +124 -0
  156. package/src/preview/dispatcher.ts +55 -150
  157. package/src/preview/headers.ts +10 -1
  158. package/src/preview/links.ts +175 -0
  159. package/src/preview/middleware.ts +41 -19
  160. package/src/preview/prefix-router.ts +197 -0
  161. package/src/preview/preview-path.ts +24 -6
  162. package/src/preview/site-middleware.ts +109 -38
  163. package/src/preview/site-page-sources.ts +146 -0
  164. package/src/preview/site-pages.ts +22 -0
  165. package/src/preview-build.ts +43 -42
  166. package/src/preview-image-endpoint.ts +35 -0
  167. package/src/preview-render-seams.ts +31 -0
  168. package/src/site-middleware.ts +6 -24
  169. package/src/skill/SKILL.md +19 -1
  170. package/src/types.ts +15 -16
  171. package/src/virtual-modules.d.ts +17 -2
@@ -1,4 +1,5 @@
1
1
  import { join } from 'node:path';
2
+ import { REFUSED_PREVIEW_ADAPTERS } from '../constants.js';
2
3
  import type { DoctorDeps } from './types.js';
3
4
 
4
5
  const ASTRO_CONFIG_NAMES = ['astro.config.mjs', 'astro.config.ts', 'astro.config.js'] as const;
@@ -23,7 +24,7 @@ function skipString(text: string, index: number): number {
23
24
  }
24
25
 
25
26
  /** Blank out comments, keeping strings and offsets intact, so a commented-out option never counts as set. */
26
- function stripComments(source: string): string {
27
+ export function stripComments(source: string): string {
27
28
  const chars = source.split('');
28
29
  let i = 0;
29
30
  while (i < chars.length) {
@@ -49,7 +50,7 @@ function stripComments(source: string): string {
49
50
  }
50
51
 
51
52
  /** The balanced bracket slice starting at openIndex, or null when it never closes. */
52
- function balancedSlice(text: string, openIndex: number): string | null {
53
+ export function balancedSlice(text: string, openIndex: number): string | null {
53
54
  const closer = OPENERS[text[openIndex]];
54
55
  let depth = 0;
55
56
  let i = openIndex;
@@ -71,7 +72,7 @@ function balancedSlice(text: string, openIndex: number): string | null {
71
72
  }
72
73
 
73
74
  /** True when `needle` appears in the text outside string literals. */
74
- function containsOutsideStrings(text: string, needle: string): boolean {
75
+ export function containsOutsideStrings(text: string, needle: string): boolean {
75
76
  let i = 0;
76
77
  while (i < text.length) {
77
78
  if (QUOTES.has(text[i])) {
@@ -139,6 +140,8 @@ interface ScannedConfig {
139
140
  conlocaCloud: CallArgs;
140
141
  conlocaCMS: CallArgs;
141
142
  site: SiteSettings;
143
+ /** The whole config, comments blanked. */
144
+ text: string;
142
145
  }
143
146
 
144
147
  /** Astro's own settings, read without conlocaCloud's options: their previewBuild.adapter is not the site's. */
@@ -185,7 +188,13 @@ export function scanAstroConfig(projectDir: string, fs: ScanFs): ConfigScan {
185
188
  const conlocaCloud = callArgs(text, 'conlocaCloud');
186
189
  return {
187
190
  kind: 'read',
188
- config: { path, conlocaCloud, conlocaCMS: callArgs(text, 'conlocaCMS'), site: siteSettings(text, conlocaCloud) },
191
+ config: {
192
+ path,
193
+ conlocaCloud,
194
+ conlocaCMS: callArgs(text, 'conlocaCMS'),
195
+ site: siteSettings(text, conlocaCloud),
196
+ text,
197
+ },
189
198
  };
190
199
  }
191
200
 
@@ -203,8 +212,9 @@ export function hasOption(scan: ConfigScan, key: string): boolean {
203
212
 
204
213
  /**
205
214
  * conlocaCloud's previewBuild as the text shows it: 'off' when absent or written as false (the preview build is
206
- * opt-in), 'adapter' when the options name an adapter (previewBuild.adapter, written out or as shorthand), 'on' for
207
- * an options object without one, and 'unknown' when computed or when a spread could set it.
215
+ * opt-in), 'adapter' when previewBuild's own object names an adapter (written out or as shorthand; one nested in
216
+ * `config` is not previewBuild's), 'on' for an options object without one, and 'unknown' when computed or when a
217
+ * spread could set it.
208
218
  */
209
219
  export function previewBuildSetting(scan: ConfigScan): 'off' | 'adapter' | 'on' | 'unknown' {
210
220
  if (scan.kind !== 'read' || typeof scan.config.conlocaCloud === 'string') return 'unknown';
@@ -212,20 +222,81 @@ export function previewBuildSetting(scan: ConfigScan): 'off' | 'adapter' | 'on'
212
222
  const value = /\bpreviewBuild\s*:\s*(false\b|\{)?/.exec(text);
213
223
  if (value === null) return spread || containsOutsideStrings(text, 'previewBuild') ? 'unknown' : 'off';
214
224
  if (value[1] === 'false') return 'off';
215
- if (containsOutsideStrings(text, 'adapter')) return 'adapter';
216
- return value[1] === '{' ? 'on' : 'unknown';
225
+ if (value[1] !== '{') return 'unknown';
226
+ const options = balancedSlice(text, value.index + value[0].length - 1);
227
+ if (options === null) return 'unknown';
228
+ return hasTopLevelKey(options, 'adapter') ? 'adapter' : 'on';
229
+ }
230
+
231
+ /** Whether the object literal `objectText` has `key` at its own top level, written out or as shorthand. */
232
+ function hasTopLevelKey(objectText: string, key: string): boolean {
233
+ let depth = 0;
234
+ let i = 0;
235
+ while (i < objectText.length) {
236
+ const ch = objectText[i];
237
+ if (QUOTES.has(ch)) {
238
+ i = skipString(objectText, i);
239
+ continue;
240
+ }
241
+ if (OPENERS[ch]) depth += 1;
242
+ else if (CLOSERS.has(ch)) depth -= 1;
243
+ else if (
244
+ depth === 1 &&
245
+ objectText.startsWith(key, i) &&
246
+ /[{,]\s*$/u.test(objectText.slice(0, i)) &&
247
+ /^\s*[:,}]/u.test(objectText.slice(i + key.length))
248
+ ) {
249
+ return true;
250
+ }
251
+ i += 1;
252
+ }
253
+ return false;
217
254
  }
218
255
 
219
256
  /**
220
- * How the preview build serves, as the config text shows it (the rule of `previewBuildMode`): `separate: true` is D4,
221
- * an adapter named anywhere (the site's or previewBuild's) is D2, a static site is D3; 'unknown' when the text cannot
222
- * tell.
257
+ * How the preview build serves, as the config text shows it (the rule of `previewBuildMode`): previewBuild.adapter
258
+ * turns preview off ('unknown' here, CC26 names it), `separate: true` is D4, the site's own adapter is d8, a static
259
+ * site is D3; 'unknown' when the text cannot tell.
223
260
  */
224
- export function previewServeSetting(scan: ConfigScan): 'off' | 'd2' | 'd3' | 'd4' | 'unknown' {
261
+ export function previewServeSetting(scan: ConfigScan): 'off' | 'd3' | 'd4' | 'd8' | 'unknown' {
225
262
  const setting = previewBuildSetting(scan);
226
- if (setting === 'off' || setting === 'unknown') return setting;
263
+ if (setting === 'off') return 'off';
264
+ if (setting !== 'on') return 'unknown';
227
265
  if (scan.kind !== 'read' || typeof scan.config.conlocaCloud === 'string') return 'unknown';
228
- if (/\bseparate\s*:\s*true\b/u.test(scan.config.conlocaCloud.text)) return 'd4';
229
- if (setting === 'adapter' || scan.config.site.adapter) return 'd2';
266
+ // The build refuses separate: true under an adapter that deploys from the project root, so no D4 runs.
267
+ if (/\bseparate\s*:\s*true\b/u.test(scan.config.conlocaCloud.text)) {
268
+ return separateRefused(scan) === undefined ? 'd4' : 'unknown';
269
+ }
270
+ if (scan.config.site.adapter) return 'd8';
230
271
  return scan.config.site.output === 'unknown' ? 'unknown' : 'd3';
231
272
  }
273
+
274
+ /** The site's adapter when previewBuild asks for `separate: true` under one the build refuses it for; else undefined. */
275
+ export function separateRefused(scan: ConfigScan): string | undefined {
276
+ if (scan.kind !== 'read' || typeof scan.config.conlocaCloud === 'string') return undefined;
277
+ if (!/\bseparate\s*:\s*true\b/u.test(scan.config.conlocaCloud.text)) return undefined;
278
+ const adapter = siteAdapter(scan);
279
+ return adapter && REFUSED_PREVIEW_ADAPTERS.includes(adapter) ? adapter : undefined;
280
+ }
281
+
282
+ /**
283
+ * The package of the site's adapter, from `adapter: <name>(...)` and the default import of `<name>`; null when the
284
+ * text names an adapter it does not show that way (a variable, a named import), undefined when there is none.
285
+ */
286
+ export function siteAdapter(scan: ReadScan): string | null | undefined {
287
+ if (!scan.config.site.adapter) return undefined;
288
+ const { text, conlocaCloud } = scan.config;
289
+ const own = typeof conlocaCloud === 'string' ? text : text.replace(conlocaCloud.text, '');
290
+ const call = /\badapter\s*:\s*([$A-Za-z_][$\w]*)\s*\(/u.exec(own)?.[1];
291
+ if (call === undefined) return null;
292
+ const from = new RegExp(`\\bimport\\s+${call.replaceAll('$', '\\$')}\\s+from\\s+['"]([^'"]+)['"]`, 'u').exec(text);
293
+ return from?.[1] ?? null;
294
+ }
295
+
296
+ /** previewBuild's object literal as written, or undefined when it is absent or not an object. */
297
+ export function previewBuildText(scan: ReadScan): string | undefined {
298
+ const { conlocaCloud } = scan.config;
299
+ if (typeof conlocaCloud === 'string') return undefined;
300
+ const key = /\bpreviewBuild\s*:\s*\{/u.exec(conlocaCloud.text);
301
+ return key === null ? undefined : (balancedSlice(conlocaCloud.text, key.index + key[0].length - 1) ?? undefined);
302
+ }
package/src/doctor/run.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { gitOutput, resolveRepositoryUri } from '../git.js';
3
3
  import { checkFramingHeaders, checkKeyLeftovers, checkSiteAddress } from './checks-address.js';
4
+ import { runD8Checks } from './checks-d8.js';
4
5
  import { runLiveChecks } from './checks-live.js';
5
6
  import { checkPreviewBuildAdapter, checkWiring, suppliedEndpoint } from './checks-offline.js';
6
7
  import { runPreviewChecks } from './checks-preview.js';
@@ -35,6 +36,7 @@ export async function runDoctor(
35
36
  checkPreviewBuildAdapter(scan),
36
37
  ...runPreviewChecks(scan, context.projectDir, deps),
37
38
  ...runPreviewLimitChecks(scan, context.projectDir, deps),
39
+ ...runD8Checks(scan, context.projectDir, deps),
38
40
  ...(await runLiveChecks({ context, deps, scan, address: site.address, repoUri })),
39
41
  ];
40
42
  return { contractVersion: 1, checks };
@@ -63,15 +63,23 @@ const CHECK_LABELS = {
63
63
  CC21: 'no tag manager runs on draft pages',
64
64
  CC22: "the preview route's rate limit fits the plan",
65
65
  CC23: 'the recorded Cloudflare plan fits draft previews',
66
+ CC25: 'the adapter is one draft preview supports',
67
+ CC26: 'nothing in astro.config turns draft preview off',
68
+ CC27: 'the host routes the preview as d8 needs',
69
+ CC28: 'the Node server allows the site domains',
66
70
  CC11: 'the deployed editor page answers',
67
71
  CC12: 'the deployed editor page may be framed',
68
72
  CC13: "the editor speaks this page's protocol",
69
73
  CC24: 'the separate preview deploy runs this release',
74
+ CC29: "the site's preview route answers, uncached",
70
75
  } as const;
71
76
 
72
77
  /** A typo in a check id fails tsc here; the CLI would otherwise drop a label-less outcome silently. */
73
78
  export type CheckId = keyof typeof CHECK_LABELS;
74
79
 
80
+ /** Every doctor request is bounded: a hanging host must never hang `conloca doctor` (the CLI seam has no timer of its own). */
81
+ export const REQUEST_TIMEOUT_MS = 10_000;
82
+
75
83
  export function outcomeOf(id: CheckId): CheckOutcome {
76
84
  return { id, label: CHECK_LABELS[id], problems: [] };
77
85
  }
@@ -1,6 +1,6 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { existsSync } from 'node:fs';
3
- import { cp, mkdir, writeFile } from 'node:fs/promises';
3
+ import { mkdir, writeFile } from 'node:fs/promises';
4
4
  import { isAbsolute, join, relative, sep } from 'node:path';
5
5
  import {
6
6
  type AstroI18nLocales,
@@ -15,6 +15,8 @@ import {
15
15
  branchDeploysOf,
16
16
  CONLOCA_JSON_MAX_BYTES,
17
17
  contentPathsOf,
18
+ type DeployHost,
19
+ deployHostFromEnv,
18
20
  EDITOR_HOST_PROTOCOL,
19
21
  EDITOR_PAGE_INFO_FORMATS,
20
22
  type EditorMedia,
@@ -160,13 +162,16 @@ export async function emitEditorPage(input: EmitEditorPageInput): Promise<void>
160
162
  }
161
163
  const branchDeploys = branchDeploysFromEnv(process.env);
162
164
  const preview: PreviewSignal = { mode: input.previewMode, protocol: PREVIEW_PROTOCOL };
163
- const written: WrittenConlocaJson = {
164
- ...info,
165
- preview,
166
- ...(branchDeploys === undefined ? {} : { branchDeploys }),
167
- ...(contentPaths === undefined ? {} : { contentPaths }),
168
- ...(media === undefined ? {} : { media }),
169
- };
165
+ const written = withDeployHost(
166
+ {
167
+ ...info,
168
+ preview,
169
+ ...(branchDeploys === undefined ? {} : { branchDeploys }),
170
+ ...(contentPaths === undefined ? {} : { contentPaths }),
171
+ ...(media === undefined ? {} : { media }),
172
+ },
173
+ process.env,
174
+ );
170
175
  const collected = await collectStaticPageRoutes({
171
176
  pagesDir: input.pagesDir,
172
177
  serverOutput: input.serverOutput,
@@ -198,12 +203,6 @@ export async function emitEditorPage(input: EmitEditorPageInput): Promise<void>
198
203
  logger.info(`editor page written: ${base}${EDITOR_DIR}/`);
199
204
  }
200
205
 
201
- /** Copies <from>/_conloca/editor into <to>, for a preview child whose client folder serves the site. */
202
- export async function mirrorEditorPage(fromDir: string, toDir: string): Promise<void> {
203
- await mkdir(join(toDir, '_conloca'), { recursive: true });
204
- await cp(join(fromDir, EDITOR_DIR), join(toDir, EDITOR_DIR), { recursive: true });
205
- }
206
-
207
206
  /**
208
207
  * A separate preview deploy (D4) serves no editor page, but it answers its own conloca.json: its release, protocol
209
208
  * and mode, read next to the site's to tell when the two deploys run different releases.
@@ -242,6 +241,15 @@ export function branchDeploysFromEnv(env: Record<string, string | undefined>): B
242
241
  return project === undefined ? undefined : branchDeploysOf({ branchDeploys: { host: 'cloudflare-pages', project } });
243
242
  }
244
243
 
244
+ /** `written` with the host whose CI runs this build, so a local build writes no `host`. */
245
+ export function withDeployHost(
246
+ written: WrittenConlocaJson,
247
+ env: Record<string, string | undefined>,
248
+ ): WrittenConlocaJson {
249
+ const host = deployHostFromEnv(env);
250
+ return host === undefined ? written : { ...written, host };
251
+ }
252
+
245
253
  /** Each content path under the repository root, written from that root ('' for the root itself); others are dropped. */
246
254
  export function contentPathsFromBuild(paths: readonly string[], repoRoot: string | undefined): string[] | undefined {
247
255
  if (repoRoot === undefined) return undefined;
@@ -258,6 +266,7 @@ export function contentPathsFromBuild(paths: readonly string[], repoRoot: string
258
266
  export interface WrittenConlocaJson extends EditorPageInfo {
259
267
  preview: PreviewSignal;
260
268
  branchDeploys?: BranchDeploys;
269
+ host?: DeployHost;
261
270
  contentPaths?: string[];
262
271
  media?: EditorMedia;
263
272
  }