@conloca/cloud-astro 0.2.4 → 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.
- package/README.md +69 -22
- package/dist/.build-inputs.json +36 -23
- package/dist/src/constants.d.ts +4 -4
- package/dist/src/constants.js +4 -4
- package/dist/src/d3-build.d.ts +6 -2
- package/dist/src/d3-build.d.ts.map +1 -1
- package/dist/src/d3-build.js +15 -11
- package/dist/src/d3-build.js.map +1 -1
- package/dist/src/d8-adapters.d.ts +10 -0
- package/dist/src/d8-adapters.d.ts.map +1 -0
- package/dist/src/d8-adapters.js +19 -0
- package/dist/src/d8-adapters.js.map +1 -0
- package/dist/src/d8-build.d.ts +99 -0
- package/dist/src/d8-build.d.ts.map +1 -0
- package/dist/src/d8-build.js +265 -0
- package/dist/src/d8-build.js.map +1 -0
- package/dist/src/d8-guards.d.ts +29 -0
- package/dist/src/d8-guards.d.ts.map +1 -0
- package/dist/src/d8-guards.js +145 -0
- package/dist/src/d8-guards.js.map +1 -0
- package/dist/src/d8-middleware.d.ts +7 -0
- package/dist/src/d8-middleware.d.ts.map +1 -0
- package/dist/src/d8-middleware.js +15 -0
- package/dist/src/d8-middleware.js.map +1 -0
- package/dist/src/d8-render.d.ts +9 -0
- package/dist/src/d8-render.d.ts.map +1 -0
- package/dist/src/d8-render.js +52 -0
- package/dist/src/d8-render.js.map +1 -0
- package/dist/src/doctor/checks-d8.d.ts +7 -0
- package/dist/src/doctor/checks-d8.d.ts.map +1 -0
- package/dist/src/doctor/checks-d8.js +240 -0
- package/dist/src/doctor/checks-d8.js.map +1 -0
- package/dist/src/doctor/checks-live.d.ts.map +1 -1
- package/dist/src/doctor/checks-live.js +3 -5
- package/dist/src/doctor/checks-live.js.map +1 -1
- package/dist/src/doctor/checks-offline.d.ts +2 -0
- package/dist/src/doctor/checks-offline.d.ts.map +1 -1
- package/dist/src/doctor/checks-offline.js +17 -8
- package/dist/src/doctor/checks-offline.js.map +1 -1
- package/dist/src/doctor/checks-preview-live.d.ts +7 -2
- package/dist/src/doctor/checks-preview-live.d.ts.map +1 -1
- package/dist/src/doctor/checks-preview-live.js +107 -7
- package/dist/src/doctor/checks-preview-live.js.map +1 -1
- package/dist/src/doctor/checks-preview.d.ts.map +1 -1
- package/dist/src/doctor/checks-preview.js +9 -4
- package/dist/src/doctor/checks-preview.js.map +1 -1
- package/dist/src/doctor/config-scan.d.ts +24 -6
- package/dist/src/doctor/config-scan.d.ts.map +1 -1
- package/dist/src/doctor/config-scan.js +89 -18
- package/dist/src/doctor/config-scan.js.map +1 -1
- package/dist/src/doctor/run.d.ts.map +1 -1
- package/dist/src/doctor/run.js +2 -0
- package/dist/src/doctor/run.js.map +1 -1
- package/dist/src/doctor/types.d.ts +7 -0
- package/dist/src/doctor/types.d.ts.map +1 -1
- package/dist/src/doctor/types.js +7 -0
- package/dist/src/doctor/types.js.map +1 -1
- package/dist/src/editor-page/emit.d.ts +4 -3
- package/dist/src/editor-page/emit.d.ts.map +1 -1
- package/dist/src/editor-page/emit.js +9 -9
- package/dist/src/editor-page/emit.js.map +1 -1
- package/dist/src/integration.d.ts.map +1 -1
- package/dist/src/integration.js +228 -124
- package/dist/src/integration.js.map +1 -1
- package/dist/src/node.d.ts +2 -0
- package/dist/src/node.d.ts.map +1 -1
- package/dist/src/node.js +4 -0
- package/dist/src/node.js.map +1 -1
- package/dist/src/preview/_resolve-opts.d.ts +26 -1
- package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
- package/dist/src/preview/_resolve-opts.js.map +1 -1
- package/dist/src/preview/content-api.d.ts +15 -0
- package/dist/src/preview/content-api.d.ts.map +1 -1
- package/dist/src/preview/content-api.js +57 -6
- package/dist/src/preview/content-api.js.map +1 -1
- package/dist/src/preview/d8-middleware.d.ts +25 -0
- package/dist/src/preview/d8-middleware.d.ts.map +1 -0
- package/dist/src/preview/d8-middleware.js +94 -0
- package/dist/src/preview/d8-middleware.js.map +1 -0
- package/dist/src/preview/dispatcher.d.ts +3 -16
- package/dist/src/preview/dispatcher.d.ts.map +1 -1
- package/dist/src/preview/dispatcher.js +46 -134
- package/dist/src/preview/dispatcher.js.map +1 -1
- package/dist/src/preview/headers.d.ts +3 -0
- package/dist/src/preview/headers.d.ts.map +1 -1
- package/dist/src/preview/headers.js +10 -1
- package/dist/src/preview/headers.js.map +1 -1
- package/dist/src/preview/links.d.ts +23 -0
- package/dist/src/preview/links.d.ts.map +1 -0
- package/dist/src/preview/links.js +168 -0
- package/dist/src/preview/links.js.map +1 -0
- package/dist/src/preview/middleware.d.ts +9 -3
- package/dist/src/preview/middleware.d.ts.map +1 -1
- package/dist/src/preview/middleware.js +36 -16
- package/dist/src/preview/middleware.js.map +1 -1
- package/dist/src/preview/prefix-router.d.ts +67 -0
- package/dist/src/preview/prefix-router.d.ts.map +1 -0
- package/dist/src/preview/prefix-router.js +153 -0
- package/dist/src/preview/prefix-router.js.map +1 -0
- package/dist/src/preview/preview-path.d.ts +8 -3
- package/dist/src/preview/preview-path.d.ts.map +1 -1
- package/dist/src/preview/preview-path.js +16 -4
- package/dist/src/preview/preview-path.js.map +1 -1
- package/dist/src/preview/site-middleware.d.ts +8 -2
- package/dist/src/preview/site-middleware.d.ts.map +1 -1
- package/dist/src/preview/site-middleware.js +90 -31
- package/dist/src/preview/site-middleware.js.map +1 -1
- package/dist/src/preview/site-page-sources.d.ts +21 -0
- package/dist/src/preview/site-page-sources.d.ts.map +1 -0
- package/dist/src/preview/site-page-sources.js +129 -0
- package/dist/src/preview/site-page-sources.js.map +1 -0
- package/dist/src/preview/site-pages.d.ts +18 -0
- package/dist/src/preview/site-pages.d.ts.map +1 -0
- package/dist/src/preview/site-pages.js +7 -0
- package/dist/src/preview/site-pages.js.map +1 -0
- package/dist/src/preview-build.d.ts +17 -16
- package/dist/src/preview-build.d.ts.map +1 -1
- package/dist/src/preview-build.js +37 -40
- package/dist/src/preview-build.js.map +1 -1
- package/dist/src/preview-image-endpoint.d.ts +8 -0
- package/dist/src/preview-image-endpoint.d.ts.map +1 -0
- package/dist/src/preview-image-endpoint.js +34 -0
- package/dist/src/preview-image-endpoint.js.map +1 -0
- package/dist/src/preview-render-seams.d.ts +7 -0
- package/dist/src/preview-render-seams.d.ts.map +1 -0
- package/dist/src/preview-render-seams.js +27 -0
- package/dist/src/preview-render-seams.js.map +1 -0
- package/dist/src/site-middleware.d.ts +2 -4
- package/dist/src/site-middleware.d.ts.map +1 -1
- package/dist/src/site-middleware.js +6 -22
- package/dist/src/site-middleware.js.map +1 -1
- package/dist/src/types.d.ts +15 -16
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +138 -6
- package/src/constants.ts +4 -4
- package/src/d3-build.ts +20 -14
- package/src/d8-adapters.ts +19 -0
- package/src/d8-build.ts +356 -0
- package/src/d8-guards.ts +177 -0
- package/src/d8-middleware.ts +17 -0
- package/src/d8-render.ts +61 -0
- package/src/doctor/checks-d8.ts +256 -0
- package/src/doctor/checks-live.ts +3 -4
- package/src/doctor/checks-offline.ts +21 -8
- package/src/doctor/checks-preview-live.ts +114 -8
- package/src/doctor/checks-preview.ts +9 -4
- package/src/doctor/config-scan.ts +86 -15
- package/src/doctor/run.ts +2 -0
- package/src/doctor/types.ts +8 -0
- package/src/editor-page/emit.ts +23 -14
- package/src/integration.ts +274 -135
- package/src/node.ts +4 -0
- package/src/preview/_resolve-opts.ts +17 -1
- package/src/preview/content-api.ts +60 -5
- package/src/preview/d8-middleware.ts +124 -0
- package/src/preview/dispatcher.ts +55 -150
- package/src/preview/headers.ts +10 -1
- package/src/preview/links.ts +175 -0
- package/src/preview/middleware.ts +41 -19
- package/src/preview/prefix-router.ts +197 -0
- package/src/preview/preview-path.ts +24 -6
- package/src/preview/site-middleware.ts +109 -38
- package/src/preview/site-page-sources.ts +146 -0
- package/src/preview/site-pages.ts +22 -0
- package/src/preview-build.ts +43 -42
- package/src/preview-image-endpoint.ts +35 -0
- package/src/preview-render-seams.ts +31 -0
- package/src/site-middleware.ts +6 -24
- package/src/skill/SKILL.md +19 -1
- package/src/types.ts +15 -16
- package/src/virtual-modules.d.ts +17 -2
package/src/d8-render.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The d8 draft render, loaded by the front (`./d8-middleware.ts`) only for a navigation that holds a pass: it pulls in
|
|
3
|
+
* `astro:content` and the routing config, which a request off the preview route must never pay for.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import baked from 'virtual:conloca-preview-opts';
|
|
7
|
+
import { resolveFromBaked } from './preview/_resolve-opts.js';
|
|
8
|
+
import type { D8Context } from './preview/d8-middleware.js';
|
|
9
|
+
import type { PreviewMiddlewareOptions } from './preview/middleware.js';
|
|
10
|
+
import { createPreviewSiteMiddleware } from './preview/site-middleware.js';
|
|
11
|
+
import { assetsSitePages, diskSitePages, functionSitePages, serverDirOf } from './preview/site-page-sources.js';
|
|
12
|
+
import { NO_SITE_PAGES, type SitePageSource } from './preview/site-pages.js';
|
|
13
|
+
import { previewRenderSeams } from './preview-render-seams.js';
|
|
14
|
+
|
|
15
|
+
// Always d8: a missing bake must not fall back to the D2 rules.
|
|
16
|
+
export function d8Opts(): PreviewMiddlewareOptions {
|
|
17
|
+
return { ...resolveFromBaked(baked, (name) => process.env[name]), mode: 'd8' };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// One source per process: each reads its list once.
|
|
21
|
+
let sitePagesPromise: Promise<SitePageSource> | undefined;
|
|
22
|
+
async function sitePageSource(): Promise<SitePageSource> {
|
|
23
|
+
const where = baked.sitePages;
|
|
24
|
+
const base = baked.base || '/';
|
|
25
|
+
switch (where?.kind) {
|
|
26
|
+
case 'disk':
|
|
27
|
+
return diskSitePages(await serverDirOf(import.meta.url, where.serverEntry), base);
|
|
28
|
+
case 'function':
|
|
29
|
+
return functionSitePages(await serverDirOf(import.meta.url, where.serverEntry), where.origin, fetch);
|
|
30
|
+
case 'assets': {
|
|
31
|
+
// Dynamic: only workerd has this module.
|
|
32
|
+
const { env } = await import(/* @vite-ignore */ 'cloudflare:workers');
|
|
33
|
+
const assets = env.ASSETS;
|
|
34
|
+
return typeof assets === 'object' && assets !== null && 'fetch' in assets && typeof assets.fetch === 'function'
|
|
35
|
+
? // SAFETY: the Cloudflare adapter binds ASSETS to the static assets Fetcher, checked callable just above.
|
|
36
|
+
// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- same reason as the SAFETY note.
|
|
37
|
+
assetsSitePages(assets as { fetch(request: Request): Promise<Response> }, base)
|
|
38
|
+
: NO_SITE_PAGES;
|
|
39
|
+
}
|
|
40
|
+
default:
|
|
41
|
+
return NO_SITE_PAGES;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function render(
|
|
46
|
+
context: D8Context,
|
|
47
|
+
next: () => Promise<Response>,
|
|
48
|
+
slug: string | undefined,
|
|
49
|
+
): Promise<Response> {
|
|
50
|
+
sitePagesPromise ??= sitePageSource().catch((error: unknown) => {
|
|
51
|
+
// Without the list, site pages fall to the CMS route; the draft render itself still works.
|
|
52
|
+
console.warn(`[@conloca/cloud-astro] preview can't read the site's own pages: ${String(error)}`);
|
|
53
|
+
return NO_SITE_PAGES;
|
|
54
|
+
});
|
|
55
|
+
const handler = createPreviewSiteMiddleware(d8Opts, {
|
|
56
|
+
...(await previewRenderSeams()),
|
|
57
|
+
baked,
|
|
58
|
+
sitePages: await sitePagesPromise,
|
|
59
|
+
});
|
|
60
|
+
return handler(context, next, slug);
|
|
61
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { basename, dirname, join } from 'node:path';
|
|
2
|
+
import { isRecord } from '@conloca/content-api/component-vocabulary';
|
|
3
|
+
import { REFUSED_PREVIEW_ADAPTERS } from '../constants.js';
|
|
4
|
+
import { D8_TESTED_ADAPTERS, d8RateLimitLines } from '../d8-adapters.js';
|
|
5
|
+
import { D8_EDGE_REFUSAL, d8ConfigRefusal, d8EdgeRefusal } from '../d8-guards.js';
|
|
6
|
+
import { parseWranglerConfig } from '../preview/cloudflare-adapter.js';
|
|
7
|
+
import { previewRoutePrefix } from '../preview/preview-path.js';
|
|
8
|
+
import { separateRefusal } from '../preview-build.js';
|
|
9
|
+
import { INTEGRATION_NOT_CALLED, PREVIEW_BUILD_ADAPTER } from './checks-offline.js';
|
|
10
|
+
import {
|
|
11
|
+
type ConfigScan,
|
|
12
|
+
previewBuildSetting,
|
|
13
|
+
previewBuildText,
|
|
14
|
+
previewServeSetting,
|
|
15
|
+
type ReadScan,
|
|
16
|
+
separateRefused,
|
|
17
|
+
siteAdapter,
|
|
18
|
+
} from './config-scan.js';
|
|
19
|
+
import { type CheckId, type CheckOutcome, type DoctorDeps, outcomeOf, skipped } from './types.js';
|
|
20
|
+
|
|
21
|
+
type D8Deps = Pick<DoctorDeps, 'exists' | 'readFile'>;
|
|
22
|
+
const IDS: readonly CheckId[] = ['CC25', 'CC26', 'CC27', 'CC28'];
|
|
23
|
+
|
|
24
|
+
type Official = keyof typeof D8_TESTED_ADAPTERS;
|
|
25
|
+
const isOfficial = (name: string): name is Official => Object.hasOwn(D8_TESTED_ADAPTERS, name);
|
|
26
|
+
/** The page files Astro builds a `src/pages/404` route from. */
|
|
27
|
+
const NOT_FOUND_PAGES = ['astro', 'md', 'mdx', 'html', 'js', 'ts'].map((extension) => `404.${extension}`);
|
|
28
|
+
|
|
29
|
+
/** previewBuild options the site's own build ignores. */
|
|
30
|
+
const NO_EFFECT = ['config', 'outDir', 'required'] as const;
|
|
31
|
+
const UPDATE = '— run `conloca connect --update --yes`';
|
|
32
|
+
const UNREADABLE_MODE =
|
|
33
|
+
"doctor can't read middlewareMode from astro.config; the build reads it from the adapter and turns preview off if it is edge";
|
|
34
|
+
const NO_SITE =
|
|
35
|
+
'your own (non-CMS) pages open the published page instead of staying in the preview: set site in astro.config (on Vercel and Netlify, conloca connect proposes it from sites.json or --site-url and writes it only on your yes in a terminal, never under --yes, since site also changes canonical, sitemap, RSS and Open Graph URLs on your live pages)';
|
|
36
|
+
|
|
37
|
+
function read(deps: D8Deps, path: string): string | undefined {
|
|
38
|
+
try {
|
|
39
|
+
return deps.readFile(path);
|
|
40
|
+
} catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A JSON file's object, or undefined; the return type is `isRecord`'s narrowing. */
|
|
46
|
+
function jsonRecord(deps: D8Deps, path: string) {
|
|
47
|
+
const text = read(deps, path);
|
|
48
|
+
if (text === undefined) return undefined;
|
|
49
|
+
try {
|
|
50
|
+
const value: unknown = JSON.parse(text);
|
|
51
|
+
return isRecord(value) ? value : undefined;
|
|
52
|
+
} catch {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** A package's manifest as the project installs it: the nearest node_modules from the project up, as Node resolves it. */
|
|
58
|
+
function installedManifest(deps: D8Deps, projectDir: string, name: string) {
|
|
59
|
+
for (let dir = projectDir; ; dir = dirname(dir)) {
|
|
60
|
+
const found = jsonRecord(deps, join(dir, 'node_modules', name, 'package.json'));
|
|
61
|
+
if (found !== undefined || dir === dirname(dir)) return found;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** `[major, minor, patch]` of a version or range floor; undefined when it names none. */
|
|
66
|
+
function versionParts(text: string): [number, number, number] | undefined {
|
|
67
|
+
const match = /(\d+)\.(\d+)\.(\d+)/u.exec(text);
|
|
68
|
+
return match === null ? undefined : [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function below(a: [number, number, number], b: [number, number, number]): boolean {
|
|
72
|
+
for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return (a[i] ?? 0) < (b[i] ?? 0);
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** CC25: an official adapter, in the release range draft preview is tested with, on an astro it accepts. */
|
|
77
|
+
function adapterCheck(name: string | null, deps: D8Deps, projectDir: string): CheckOutcome {
|
|
78
|
+
const outcome = outcomeOf('CC25');
|
|
79
|
+
const warn = (message: string) => outcome.problems.push({ check: 'CC25', level: 'warn', message });
|
|
80
|
+
if (name === null) {
|
|
81
|
+
warn("doctor can't tell which adapter astro.config uses: import it by default and call it in adapter");
|
|
82
|
+
return outcome;
|
|
83
|
+
}
|
|
84
|
+
if (!isOfficial(name)) {
|
|
85
|
+
warn(`unsupported adapter ${name}: draft preview may work, Conloca doesn't test it`);
|
|
86
|
+
return outcome;
|
|
87
|
+
}
|
|
88
|
+
const manifest = installedManifest(deps, projectDir, name);
|
|
89
|
+
const version = typeof manifest?.version === 'string' ? manifest.version : undefined;
|
|
90
|
+
if (version === undefined) {
|
|
91
|
+
warn(`${name} is not installed: install the site's packages, then run doctor again`);
|
|
92
|
+
return outcome;
|
|
93
|
+
}
|
|
94
|
+
const tested = D8_TESTED_ADAPTERS[name];
|
|
95
|
+
const have = versionParts(version);
|
|
96
|
+
const want = versionParts(tested);
|
|
97
|
+
if (have === undefined || want === undefined || have[0] !== want[0] || below(have, want)) {
|
|
98
|
+
warn(`${name} ${version} is outside the range Conloca tests draft preview with (^${tested})`);
|
|
99
|
+
}
|
|
100
|
+
const peers = isRecord(manifest?.peerDependencies) ? manifest.peerDependencies : {};
|
|
101
|
+
const floor = typeof peers.astro === 'string' ? versionParts(peers.astro) : undefined;
|
|
102
|
+
const astroManifest = installedManifest(deps, projectDir, 'astro');
|
|
103
|
+
const astro = typeof astroManifest?.version === 'string' ? astroManifest.version : undefined;
|
|
104
|
+
const astroParts = astro === undefined ? undefined : versionParts(astro);
|
|
105
|
+
if (floor !== undefined && astro !== undefined && astroParts !== undefined && below(astroParts, floor)) {
|
|
106
|
+
outcome.problems.push({
|
|
107
|
+
check: 'CC25',
|
|
108
|
+
level: 'error',
|
|
109
|
+
message: `${name} ${version} needs astro ${floor.join('.')} or later; this site has ${astro}`,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
outcome.detail = `${name} ${version}`;
|
|
113
|
+
return outcome;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** CC26: what the build turns preview off for. */
|
|
117
|
+
function guardCheck(scan: ReadScan, name: string | null | undefined, base: string): CheckOutcome {
|
|
118
|
+
const outcome = outcomeOf('CC26');
|
|
119
|
+
const add = (level: 'error' | 'warn', message: string) => outcome.problems.push({ check: 'CC26', level, message });
|
|
120
|
+
if (previewBuildSetting(scan) === 'adapter') {
|
|
121
|
+
add('error', PREVIEW_BUILD_ADAPTER);
|
|
122
|
+
return outcome;
|
|
123
|
+
}
|
|
124
|
+
const options = previewBuildText(scan) ?? '';
|
|
125
|
+
if (name && REFUSED_PREVIEW_ADAPTERS.includes(name) && /\bseparate\s*:\s*true\b/u.test(options)) {
|
|
126
|
+
add('error', separateRefusal(name));
|
|
127
|
+
return outcome;
|
|
128
|
+
}
|
|
129
|
+
if (name) {
|
|
130
|
+
const { text } = scan.config;
|
|
131
|
+
const refusal = d8ConfigRefusal(text, name, base);
|
|
132
|
+
if (refusal !== null) add('error', refusal);
|
|
133
|
+
else {
|
|
134
|
+
const edge = d8EdgeRefusal(undefined, text, name);
|
|
135
|
+
if (edge === D8_EDGE_REFUSAL) add('error', edge);
|
|
136
|
+
else if (edge !== null) add('warn', UNREADABLE_MODE);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
for (const key of NO_EFFECT) {
|
|
140
|
+
if (new RegExp(`\\b${key}\\s*:`, 'u').test(options)) {
|
|
141
|
+
add('warn', `previewBuild.${key} has no effect: drafts render in the site's own build`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return outcome;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** CC27: how the host routes the preview route and the site's misses. Notes go in `detail`, the doctor's info. */
|
|
148
|
+
function routingCheck(scan: ReadScan, name: Official, deps: D8Deps, projectDir: string, base: string): CheckOutcome {
|
|
149
|
+
const outcome = outcomeOf('CC27');
|
|
150
|
+
const warn = (message: string) => outcome.problems.push({ check: 'CC27', level: 'warn', message });
|
|
151
|
+
const notes: string[] = [];
|
|
152
|
+
const prefix = previewRoutePrefix(base);
|
|
153
|
+
const { site, text } = scan.config;
|
|
154
|
+
const isStatic = site.output === 'static';
|
|
155
|
+
if (name === '@astrojs/vercel') {
|
|
156
|
+
if (/\bformat\s*:\s*['"]file['"]/u.test(text)) {
|
|
157
|
+
warn("@astrojs/vercel builds build.format 'file' as 'directory', so page addresses lose their .html");
|
|
158
|
+
}
|
|
159
|
+
const pages = join(projectDir, 'src', 'pages');
|
|
160
|
+
if (isStatic && !NOT_FOUND_PAGES.some((file) => deps.exists(join(pages, file)))) {
|
|
161
|
+
notes.push(
|
|
162
|
+
'misses run the preview function unless the build can restore the static 404 route; add src/pages/404.astro',
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
notes.push(...d8RateLimitLines(name, prefix));
|
|
166
|
+
}
|
|
167
|
+
if (name === '@astrojs/netlify') {
|
|
168
|
+
notes.push("every missing URL, images included, runs your site's function");
|
|
169
|
+
notes.push(...d8RateLimitLines(name, prefix));
|
|
170
|
+
}
|
|
171
|
+
// A computed site (null) may well be set at build time; only an absent one is certain.
|
|
172
|
+
if ((name === '@astrojs/vercel' || name === '@astrojs/netlify') && site.url === undefined) warn(NO_SITE);
|
|
173
|
+
if (name === '@astrojs/cloudflare' && isStatic) {
|
|
174
|
+
// The build's list is the truth: it leaves out `<base>_image` once the image endpoint moved under the prefix.
|
|
175
|
+
const reported = jsonStrings(deps, join(projectDir, '.conloca', 'dispatcher', 'run_worker_first.json'));
|
|
176
|
+
const wanted = reported ?? [prefix, `${prefix}/*`];
|
|
177
|
+
const path = ['wrangler.jsonc', 'wrangler.json'].map((file) => join(projectDir, file)).find((p) => deps.exists(p));
|
|
178
|
+
if (path === undefined && deps.exists(join(projectDir, 'wrangler.toml'))) {
|
|
179
|
+
warn('convert wrangler.toml to wrangler.jsonc, then run conloca connect --update --yes');
|
|
180
|
+
if (notes.length > 0) outcome.detail = notes.join('; ');
|
|
181
|
+
return outcome;
|
|
182
|
+
}
|
|
183
|
+
const config = path === undefined ? undefined : parseWranglerConfig(read(deps, path) ?? '');
|
|
184
|
+
const assets = isRecord(config?.assets) ? config.assets : {};
|
|
185
|
+
const listed: unknown[] = Array.isArray(assets.run_worker_first) ? assets.run_worker_first : [];
|
|
186
|
+
const missing = assets.run_worker_first === true ? [] : wanted.filter((entry) => !listed.includes(entry));
|
|
187
|
+
if (missing.length > 0 || (assets.not_found_handling !== '404-page' && assets.not_found_handling !== 'none')) {
|
|
188
|
+
warn(
|
|
189
|
+
`${path === undefined ? 'wrangler.jsonc' : basename(path)} does not route the preview to the Cloudflare Worker: add ${(missing.length > 0 ? missing : wanted).join(', ')} to assets.run_worker_first and set assets.not_found_handling to "404-page" ${UPDATE}`,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (notes.length > 0) outcome.detail = notes.join('; ');
|
|
194
|
+
return outcome;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** A JSON file's array of strings, or undefined. */
|
|
198
|
+
function jsonStrings(deps: D8Deps, path: string): string[] | undefined {
|
|
199
|
+
const text = read(deps, path);
|
|
200
|
+
if (text === undefined) return undefined;
|
|
201
|
+
try {
|
|
202
|
+
const value: unknown = JSON.parse(text);
|
|
203
|
+
return Array.isArray(value) && value.every((item) => typeof item === 'string') ? value : undefined;
|
|
204
|
+
} catch {
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/** CC28: Node checks the forwarded host against `security.allowedDomains`, so a TLS proxy needs the site's domains there. */
|
|
210
|
+
function nodeCheck(scan: ReadScan): CheckOutcome {
|
|
211
|
+
const outcome = outcomeOf('CC28');
|
|
212
|
+
const { text } = scan.config;
|
|
213
|
+
if (!/\ballowedDomains\s*:/u.test(text)) {
|
|
214
|
+
outcome.problems.push({
|
|
215
|
+
check: 'CC28',
|
|
216
|
+
level: 'error',
|
|
217
|
+
message:
|
|
218
|
+
'add security.allowedDomains with your domains (connect writes it): without it every preview entry fails behind a TLS proxy',
|
|
219
|
+
});
|
|
220
|
+
} else if (/\ballowedDomains\s*:\s*\[\s*\]/u.test(text)) {
|
|
221
|
+
outcome.problems.push({
|
|
222
|
+
check: 'CC28',
|
|
223
|
+
level: 'warn',
|
|
224
|
+
message: 'security.allowedDomains is empty: add your domains, or every preview entry fails behind a TLS proxy',
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return outcome;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** CC25–CC28: what drafts rendered in the site's own build (d8) need from its adapter and host. Never networks. */
|
|
231
|
+
export function runD8Checks(scan: ConfigScan, projectDir: string, deps: D8Deps): CheckOutcome[] {
|
|
232
|
+
const mode = previewServeSetting(scan);
|
|
233
|
+
const misplaced = previewBuildSetting(scan) === 'adapter';
|
|
234
|
+
const refusedSeparate = separateRefused(scan) !== undefined;
|
|
235
|
+
if (scan.kind !== 'read' || (mode !== 'd8' && !misplaced && !refusedSeparate)) {
|
|
236
|
+
const reason =
|
|
237
|
+
scan.kind === 'read' && scan.config.conlocaCloud === 'absent'
|
|
238
|
+
? INTEGRATION_NOT_CALLED
|
|
239
|
+
: "only drafts rendered in the site's own build, through its adapter (d8), need these";
|
|
240
|
+
return IDS.map((id) => skipped(id, reason));
|
|
241
|
+
}
|
|
242
|
+
const name = siteAdapter(scan);
|
|
243
|
+
const base = scan.config.site.base ?? '/';
|
|
244
|
+
const guards = guardCheck(scan, name, base);
|
|
245
|
+
if (mode !== 'd8') {
|
|
246
|
+
return [skipped('CC25', 'no d8 build'), guards, skipped('CC27', 'no d8 build'), skipped('CC28', 'no d8 build')];
|
|
247
|
+
}
|
|
248
|
+
return [
|
|
249
|
+
adapterCheck(name ?? null, deps, projectDir),
|
|
250
|
+
guards,
|
|
251
|
+
name && isOfficial(name)
|
|
252
|
+
? routingCheck(scan, name, deps, projectDir, base)
|
|
253
|
+
: skipped('CC27', 'not an adapter Conloca knows the routing of'),
|
|
254
|
+
name === '@astrojs/node' ? nodeCheck(scan) : skipped('CC28', 'not @astrojs/node'),
|
|
255
|
+
];
|
|
256
|
+
}
|
|
@@ -19,13 +19,12 @@ import {
|
|
|
19
19
|
type CloudDoctorContext,
|
|
20
20
|
type DoctorDeps,
|
|
21
21
|
outcomeOf,
|
|
22
|
+
REQUEST_TIMEOUT_MS,
|
|
22
23
|
skipped,
|
|
23
24
|
} from './types.js';
|
|
24
25
|
|
|
25
|
-
const LIVE_CHECK_IDS: readonly CheckId[] = ['CC11', 'CC12', 'CC13', 'CC24'];
|
|
26
|
+
const LIVE_CHECK_IDS: readonly CheckId[] = ['CC11', 'CC12', 'CC13', 'CC24', 'CC29'];
|
|
26
27
|
|
|
27
|
-
/** Every doctor request is bounded: a hanging host must never hang `conloca doctor` (the CLI seam has no timer of its own). */
|
|
28
|
-
const REQUEST_TIMEOUT_MS = 10_000;
|
|
29
28
|
/** The server probe's conloca.json cap; a longer answer reads as `invalid` here as there. */
|
|
30
29
|
const CONLOCA_JSON_CAP_BYTES = 16 * 1024;
|
|
31
30
|
/** CC11 judges everything but the protocol; CC13 holds that against the range the editor publishes. */
|
|
@@ -313,6 +312,6 @@ export async function runLiveChecks(input: LiveInput): Promise<CheckOutcome[]> {
|
|
|
313
312
|
page.outcome,
|
|
314
313
|
frame,
|
|
315
314
|
await checkProtocol(page.info, origin, deps.fetch),
|
|
316
|
-
...(await runPreviewLiveChecks({ context, deps, scan, info: page.info })),
|
|
315
|
+
...(await runPreviewLiveChecks({ context, deps, scan, info: page.info, address })),
|
|
317
316
|
];
|
|
318
317
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
import { separateRefusal } from '../preview-build.js';
|
|
1
2
|
import type { RepositoryEnvironment } from '../repository.js';
|
|
2
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
type ConfigScan,
|
|
5
|
+
hasOption,
|
|
6
|
+
optionLiteral,
|
|
7
|
+
previewBuildSetting,
|
|
8
|
+
previewServeSetting,
|
|
9
|
+
separateRefused,
|
|
10
|
+
} from './config-scan.js';
|
|
3
11
|
import { type CheckOutcome, outcomeOf, skipped } from './types.js';
|
|
4
12
|
|
|
5
13
|
/** Doctor-only override for an endpoint the config computes (e.g. from an env var). */
|
|
@@ -54,12 +62,15 @@ export function checkWiring(scan: ConfigScan, repoUri: string | undefined): Chec
|
|
|
54
62
|
}
|
|
55
63
|
|
|
56
64
|
const SERVE_DETAIL = {
|
|
57
|
-
|
|
65
|
+
d8: "drafts render in the site's own build, through its adapter (d8)",
|
|
58
66
|
d3: 'the preview server runs next to the static site on Cloudflare Workers (D3)',
|
|
59
67
|
d4: "a separate preview deploy (D4): its address goes in sites.json's previewUrl",
|
|
60
68
|
unknown: 'not verified — doctor cannot read previewBuild, output or the adapter from the config text',
|
|
61
69
|
} as const;
|
|
62
70
|
|
|
71
|
+
/** The build turns preview off for previewBuild.adapter; CC8 and CC26 name it. */
|
|
72
|
+
export const PREVIEW_BUILD_ADAPTER = 'remove previewBuild.adapter; put the adapter in astro.config';
|
|
73
|
+
|
|
63
74
|
/** CC8 — how the preview build serves drafts, read from the config text. */
|
|
64
75
|
export function checkPreviewBuildAdapter(scan: ConfigScan): CheckOutcome {
|
|
65
76
|
if (scan.kind !== 'read') {
|
|
@@ -68,11 +79,13 @@ export function checkPreviewBuildAdapter(scan: ConfigScan): CheckOutcome {
|
|
|
68
79
|
if (scan.config.conlocaCloud === 'absent') return skipped('CC8', INTEGRATION_NOT_CALLED);
|
|
69
80
|
const outcome = outcomeOf('CC8');
|
|
70
81
|
const mode = previewServeSetting(scan);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
const refused = separateRefused(scan);
|
|
83
|
+
if (mode === 'off') {
|
|
84
|
+
outcome.detail = hasOption(scan, 'previewBuild')
|
|
85
|
+
? 'previewBuild: false — no preview build runs'
|
|
86
|
+
: 'previewBuild is not set — no preview build runs';
|
|
87
|
+
} else if (previewBuildSetting(scan) === 'adapter') outcome.detail = PREVIEW_BUILD_ADAPTER;
|
|
88
|
+
else if (refused !== undefined) outcome.detail = separateRefusal(refused);
|
|
89
|
+
else outcome.detail = SERVE_DETAIL[mode];
|
|
77
90
|
return outcome;
|
|
78
91
|
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
import { isRecord } from '@conloca/content-api/component-vocabulary';
|
|
3
|
-
import type
|
|
4
|
-
import {
|
|
5
|
-
import { type
|
|
3
|
+
import { type EditorPageInfo, hostOf } from '@conloca/content-api/editor-host';
|
|
4
|
+
import { PREVIEW_LABEL_HEADER, PREVIEW_MODE_HEADER, previewRoutePrefix } from '../preview/preview-path.js';
|
|
5
|
+
import { type ConfigScan, previewServeSetting, siteAdapter } from './config-scan.js';
|
|
6
|
+
import {
|
|
7
|
+
type CheckOutcome,
|
|
8
|
+
type CloudDoctorContext,
|
|
9
|
+
type DoctorDeps,
|
|
10
|
+
outcomeOf,
|
|
11
|
+
REQUEST_TIMEOUT_MS,
|
|
12
|
+
skipped,
|
|
13
|
+
} from './types.js';
|
|
6
14
|
|
|
7
15
|
interface Input {
|
|
8
16
|
context: CloudDoctorContext;
|
|
@@ -10,6 +18,97 @@ interface Input {
|
|
|
10
18
|
scan: ConfigScan;
|
|
11
19
|
/** The deployed site's conloca.json, when CC11 read it. */
|
|
12
20
|
info: EditorPageInfo | undefined;
|
|
21
|
+
/** The production address with its base, ending in `/` (CC9). */
|
|
22
|
+
address: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Where each host shows the logs of the code that serves the preview route. */
|
|
26
|
+
const LOGS = {
|
|
27
|
+
vercel: 'Project → Logs',
|
|
28
|
+
netlify: 'Logs → Functions',
|
|
29
|
+
cloudflare: 'the Cloudflare dashboard → your site → Observability → Logs',
|
|
30
|
+
node: "your server's own log output",
|
|
31
|
+
} as const;
|
|
32
|
+
|
|
33
|
+
/** The host whose logs to name: the one the production build recorded, else the adapter's, else D3's Cloudflare. */
|
|
34
|
+
function logsOf(input: Input, mode: 'd3' | 'd8'): string {
|
|
35
|
+
const recorded = input.info === undefined ? undefined : hostOf(input.info);
|
|
36
|
+
if (recorded === 'vercel' || recorded === 'netlify' || recorded === 'cloudflare') return LOGS[recorded];
|
|
37
|
+
if (mode === 'd3') return LOGS.cloudflare;
|
|
38
|
+
const adapter = input.scan.kind === 'read' ? siteAdapter(input.scan) : undefined;
|
|
39
|
+
if (adapter === '@astrojs/vercel') return LOGS.vercel;
|
|
40
|
+
if (adapter === '@astrojs/netlify') return LOGS.netlify;
|
|
41
|
+
if (adapter === '@astrojs/cloudflare') return LOGS.cloudflare;
|
|
42
|
+
return LOGS.node;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** What is wrong with one exit answer, or null; `mode` is what the config text says the build serves. */
|
|
46
|
+
function exitProblem(answer: Response, url: string, mode: 'd3' | 'd8', prefix: string): string | null {
|
|
47
|
+
const { status, headers } = answer;
|
|
48
|
+
const location = headers.get('location');
|
|
49
|
+
const elsewhere =
|
|
50
|
+
location !== null && status >= 300 && status < 400 && new URL(location, url).host !== new URL(url).host;
|
|
51
|
+
if ([401, 403, 429].includes(status) || headers.has('cf-mitigated') || elsewhere) {
|
|
52
|
+
return `answered ${status}: something in front of the site answered (auth, firewall or bot challenge): let ${prefix}/* through`;
|
|
53
|
+
}
|
|
54
|
+
if (status !== 302 || headers.get(PREVIEW_LABEL_HEADER) === null) {
|
|
55
|
+
const label = headers.get(PREVIEW_LABEL_HEADER) === null ? ' without the conloca-preview label' : '';
|
|
56
|
+
return `answered ${status} (location: ${location ?? 'none'})${label}, not the preview route's 302`;
|
|
57
|
+
}
|
|
58
|
+
const served = headers.get(PREVIEW_MODE_HEADER);
|
|
59
|
+
if (served !== mode) return `serves preview mode ${served ?? 'none'}, but astro.config builds ${mode}`;
|
|
60
|
+
const hit = (name: string) =>
|
|
61
|
+
headers.get(name)?.toUpperCase().includes('HIT') ? `${name}: ${headers.get(name)}` : null;
|
|
62
|
+
const cached = [
|
|
63
|
+
Number(headers.get('age') ?? 0) > 0 ? `age: ${headers.get('age')}` : null,
|
|
64
|
+
hit('cf-cache-status'),
|
|
65
|
+
hit('x-cache'),
|
|
66
|
+
hit('x-vercel-cache'),
|
|
67
|
+
/;\s*hit\b/iu.test(headers.get('cache-status') ?? '') ? `cache-status: ${headers.get('cache-status')}` : null,
|
|
68
|
+
].filter((item) => item !== null);
|
|
69
|
+
if (cached.length > 0) {
|
|
70
|
+
return `a CDN caches the preview route (${cached.join(', ')}): bypass the cache for ${prefix}/*`;
|
|
71
|
+
}
|
|
72
|
+
if (!/\bno-store\b/iu.test(headers.get('cache-control') ?? '') || !/\bcookie\b/iu.test(headers.get('vary') ?? '')) {
|
|
73
|
+
return 'answers without cache-control: no-store and Vary: Cookie, so a CDN may cache drafts';
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** CC29, under --live only: the site's preview route answers its exit as the configured mode, uncached, twice. */
|
|
79
|
+
async function checkPreviewExit(input: Input): Promise<CheckOutcome> {
|
|
80
|
+
const { scan, deps, address } = input;
|
|
81
|
+
const mode = previewServeSetting(scan);
|
|
82
|
+
if (mode !== 'd3' && mode !== 'd8') return skipped('CC29', 'only D3 and d8 serve the preview route on the site');
|
|
83
|
+
const base = (scan.kind === 'read' ? (scan.config.site.base ?? '/') : '/').replace(/\/?$/u, '/');
|
|
84
|
+
const url = `${address}_conloca/preview/__exit?to=${base}`;
|
|
85
|
+
const outcome = outcomeOf('CC29');
|
|
86
|
+
const logs = logsOf(input, mode);
|
|
87
|
+
const probe = async () => {
|
|
88
|
+
const started = Date.now();
|
|
89
|
+
try {
|
|
90
|
+
const answer = await deps.fetch(url, {
|
|
91
|
+
redirect: 'manual',
|
|
92
|
+
credentials: 'omit',
|
|
93
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
94
|
+
});
|
|
95
|
+
return { problem: exitProblem(answer, url, mode, previewRoutePrefix(base)), ms: Date.now() - started };
|
|
96
|
+
} catch (error) {
|
|
97
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
98
|
+
return { problem: `could not be reached (${reason})`, ms: Date.now() - started };
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
// Twice, one after the other: a CDN that caches the route answers the second from its cache.
|
|
102
|
+
const first = await probe();
|
|
103
|
+
const second = await probe();
|
|
104
|
+
const problem = first.problem ?? second.problem;
|
|
105
|
+
if (problem !== null) {
|
|
106
|
+
const timing = `(${first.ms} ms, ${second.ms} ms)`;
|
|
107
|
+
outcome.problems.push({ check: 'CC29', level: 'error', message: `${url} ${problem} ${timing} — logs: ${logs}` });
|
|
108
|
+
} else {
|
|
109
|
+
outcome.detail = `302 in ${first.ms} ms and ${second.ms} ms`;
|
|
110
|
+
}
|
|
111
|
+
return outcome;
|
|
13
112
|
}
|
|
14
113
|
|
|
15
114
|
/** sites.json's previewUrl for the default site's default locale, when it names one. */
|
|
@@ -28,10 +127,17 @@ function declaredPreviewUrl(contentRoot: string, deps: DoctorDeps): string | und
|
|
|
28
127
|
return typeof value === 'string' ? value : undefined;
|
|
29
128
|
}
|
|
30
129
|
|
|
31
|
-
/**
|
|
32
|
-
|
|
130
|
+
/**
|
|
131
|
+
* CC24 and CC29, under --live only: the separate preview deploy answers its own conloca.json as D4, on the site's
|
|
132
|
+
* release; the site's own preview route answers its exit.
|
|
133
|
+
*/
|
|
134
|
+
export function runPreviewLiveChecks(input: Input): Promise<CheckOutcome[]> {
|
|
135
|
+
return Promise.all([checkSeparateDeploy(input), checkPreviewExit(input)]);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function checkSeparateDeploy(input: Input): Promise<CheckOutcome> {
|
|
33
139
|
const { context, deps, scan } = input;
|
|
34
|
-
if (previewServeSetting(scan) !== 'd4') return
|
|
140
|
+
if (previewServeSetting(scan) !== 'd4') return skipped('CC24', 'no separate preview deploy (D4)');
|
|
35
141
|
const base = scan.kind === 'read' ? (scan.config.site.base ?? '/') : '/';
|
|
36
142
|
const release = outcomeOf('CC24');
|
|
37
143
|
const previewUrl = declaredPreviewUrl(context.contentRoot, deps);
|
|
@@ -42,7 +148,7 @@ export async function runPreviewLiveChecks(input: Input): Promise<CheckOutcome[]
|
|
|
42
148
|
message:
|
|
43
149
|
"sites.json names no previewUrl for the default locale: add the separate preview deploy's https:// address",
|
|
44
150
|
});
|
|
45
|
-
return
|
|
151
|
+
return release;
|
|
46
152
|
}
|
|
47
153
|
// A base written without its trailing slash (`/docs`) still needs one before `_conloca`.
|
|
48
154
|
const url = `${previewUrl.replace(/\/+$/u, '')}${base.replace(/\/?$/u, '/')}_conloca/editor/conloca.json`;
|
|
@@ -73,5 +179,5 @@ export async function runPreviewLiveChecks(input: Input): Promise<CheckOutcome[]
|
|
|
73
179
|
} else {
|
|
74
180
|
release.detail = 'the preview deploy answers as D4';
|
|
75
181
|
}
|
|
76
|
-
return
|
|
182
|
+
return release;
|
|
77
183
|
}
|
|
@@ -3,7 +3,7 @@ import { isRecord } from '@conloca/content-api/component-vocabulary';
|
|
|
3
3
|
import { parseWranglerConfig } from '../preview/cloudflare-adapter.js';
|
|
4
4
|
import { previewOwnEntries, previewRoutePrefix } from '../preview/preview-path.js';
|
|
5
5
|
import { INTEGRATION_NOT_CALLED } from './checks-offline.js';
|
|
6
|
-
import { type ConfigScan, previewServeSetting } from './config-scan.js';
|
|
6
|
+
import { type ConfigScan, previewServeSetting, separateRefused } from './config-scan.js';
|
|
7
7
|
import { type CheckId, type CheckOutcome, type DoctorDeps, outcomeOf, skipped } from './types.js';
|
|
8
8
|
|
|
9
9
|
type PreviewDeps = Pick<DoctorDeps, 'exists' | 'readFile' | 'git'>;
|
|
@@ -64,12 +64,17 @@ const onlyD3 = (id: CheckId) => skipped(id, 'a separate preview deploy (D4) runs
|
|
|
64
64
|
export function runPreviewChecks(scan: ConfigScan, projectDir: string, deps: PreviewDeps): CheckOutcome[] {
|
|
65
65
|
const mode = previewServeSetting(scan);
|
|
66
66
|
if (mode !== 'd3' && mode !== 'd4') {
|
|
67
|
+
const refused = separateRefused(scan);
|
|
67
68
|
const reason =
|
|
68
69
|
scan.kind === 'read' && scan.config.conlocaCloud === 'absent'
|
|
69
70
|
? INTEGRATION_NOT_CALLED
|
|
70
|
-
:
|
|
71
|
-
?
|
|
72
|
-
:
|
|
71
|
+
: refused !== undefined
|
|
72
|
+
? `the build refuses separate: true under ${refused} (see CC26)`
|
|
73
|
+
: mode === 'unknown'
|
|
74
|
+
? 'doctor cannot read previewBuild from the config text'
|
|
75
|
+
: mode === 'd8'
|
|
76
|
+
? "drafts render in the site's own build (d8): CC25–CC28 check its adapter and host"
|
|
77
|
+
: 'only a static site previewing next to itself (D3) or on a separate deploy (D4) needs these';
|
|
73
78
|
return IDS.map((id) => skipped(id, reason));
|
|
74
79
|
}
|
|
75
80
|
const base = scan.kind === 'read' ? (scan.config.site.base ?? '/') : '/';
|