@conloca/cloud-astro 0.0.0-stage → 0.2.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.
- package/README.md +327 -2
- package/dist/src/build-commit.d.ts +19 -0
- package/dist/src/build-commit.d.ts.map +1 -0
- package/dist/src/build-commit.js +6 -0
- package/dist/src/build-commit.js.map +1 -0
- package/dist/src/bundle.d.ts +173 -0
- package/dist/src/bundle.d.ts.map +1 -0
- package/dist/src/bundle.js +413 -0
- package/dist/src/bundle.js.map +1 -0
- package/dist/src/component-manifest.d.ts +29 -0
- package/dist/src/component-manifest.d.ts.map +1 -0
- package/dist/src/component-manifest.js +53 -0
- package/dist/src/component-manifest.js.map +1 -0
- package/dist/src/constants.d.ts +26 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +26 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/descriptors.d.ts +25 -0
- package/dist/src/descriptors.d.ts.map +1 -0
- package/dist/src/descriptors.js +65 -0
- package/dist/src/descriptors.js.map +1 -0
- package/dist/src/discovery.d.ts +58 -0
- package/dist/src/discovery.d.ts.map +1 -0
- package/dist/src/discovery.js +133 -0
- package/dist/src/discovery.js.map +1 -0
- package/dist/src/doctor/checks-live.d.ts +15 -0
- package/dist/src/doctor/checks-live.d.ts.map +1 -0
- package/dist/src/doctor/checks-live.js +229 -0
- package/dist/src/doctor/checks-live.js.map +1 -0
- package/dist/src/doctor/checks-offline.d.ts +36 -0
- package/dist/src/doctor/checks-offline.d.ts.map +1 -0
- package/dist/src/doctor/checks-offline.js +301 -0
- package/dist/src/doctor/checks-offline.js.map +1 -0
- package/dist/src/doctor/config-scan.d.ts +55 -0
- package/dist/src/doctor/config-scan.d.ts.map +1 -0
- package/dist/src/doctor/config-scan.js +178 -0
- package/dist/src/doctor/config-scan.js.map +1 -0
- package/dist/src/doctor/run.d.ts +4 -0
- package/dist/src/doctor/run.d.ts.map +1 -0
- package/dist/src/doctor/run.js +29 -0
- package/dist/src/doctor/run.js.map +1 -0
- package/dist/src/doctor/types.d.ts +60 -0
- package/dist/src/doctor/types.d.ts.map +1 -0
- package/dist/src/doctor/types.js +18 -0
- package/dist/src/doctor/types.js.map +1 -0
- package/dist/src/doctor.d.ts +9 -0
- package/dist/src/doctor.d.ts.map +1 -0
- package/dist/src/doctor.js +12 -0
- package/dist/src/doctor.js.map +1 -0
- package/dist/src/git.d.ts +38 -0
- package/dist/src/git.d.ts.map +1 -0
- package/dist/src/git.js +43 -0
- package/dist/src/git.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/integration.d.ts +6 -0
- package/dist/src/integration.d.ts.map +1 -0
- package/dist/src/integration.js +532 -0
- package/dist/src/integration.js.map +1 -0
- package/dist/src/message-of.d.ts +3 -0
- package/dist/src/message-of.d.ts.map +1 -0
- package/dist/src/message-of.js +5 -0
- package/dist/src/message-of.js.map +1 -0
- package/dist/src/node.d.ts +3 -0
- package/dist/src/node.d.ts.map +1 -0
- package/dist/src/node.js +4 -0
- package/dist/src/node.js.map +1 -0
- package/dist/src/package-version.d.ts +7 -0
- package/dist/src/package-version.d.ts.map +1 -0
- package/dist/src/package-version.js +17 -0
- package/dist/src/package-version.js.map +1 -0
- package/dist/src/preview/_dispatch.d.ts +52 -0
- package/dist/src/preview/_dispatch.d.ts.map +1 -0
- package/dist/src/preview/_dispatch.js +70 -0
- package/dist/src/preview/_dispatch.js.map +1 -0
- package/dist/src/preview/_resolve-opts.d.ts +28 -0
- package/dist/src/preview/_resolve-opts.d.ts.map +1 -0
- package/dist/src/preview/_resolve-opts.js +70 -0
- package/dist/src/preview/_resolve-opts.js.map +1 -0
- package/dist/src/preview/banner.d.ts +29 -0
- package/dist/src/preview/banner.d.ts.map +1 -0
- package/dist/src/preview/banner.js +94 -0
- package/dist/src/preview/banner.js.map +1 -0
- package/dist/src/preview/content-api.d.ts +110 -0
- package/dist/src/preview/content-api.d.ts.map +1 -0
- package/dist/src/preview/content-api.js +216 -0
- package/dist/src/preview/content-api.js.map +1 -0
- package/dist/src/preview/cookie.d.ts +36 -0
- package/dist/src/preview/cookie.d.ts.map +1 -0
- package/dist/src/preview/cookie.js +59 -0
- package/dist/src/preview/cookie.js.map +1 -0
- package/dist/src/preview/headers.d.ts +25 -0
- package/dist/src/preview/headers.d.ts.map +1 -0
- package/dist/src/preview/headers.js +31 -0
- package/dist/src/preview/headers.js.map +1 -0
- package/dist/src/preview/landing.d.ts +22 -0
- package/dist/src/preview/landing.d.ts.map +1 -0
- package/dist/src/preview/landing.js +70 -0
- package/dist/src/preview/landing.js.map +1 -0
- package/dist/src/preview/middleware.d.ts +112 -0
- package/dist/src/preview/middleware.d.ts.map +1 -0
- package/dist/src/preview/middleware.js +197 -0
- package/dist/src/preview/middleware.js.map +1 -0
- package/dist/src/preview/preview-path.d.ts +21 -0
- package/dist/src/preview/preview-path.d.ts.map +1 -0
- package/dist/src/preview/preview-path.js +29 -0
- package/dist/src/preview/preview-path.js.map +1 -0
- package/dist/src/preview/satteri-workerd.d.ts +17 -0
- package/dist/src/preview/satteri-workerd.d.ts.map +1 -0
- package/dist/src/preview/satteri-workerd.js +18 -0
- package/dist/src/preview/satteri-workerd.js.map +1 -0
- package/dist/src/preview/site-middleware.d.ts +69 -0
- package/dist/src/preview/site-middleware.d.ts.map +1 -0
- package/dist/src/preview/site-middleware.js +159 -0
- package/dist/src/preview/site-middleware.js.map +1 -0
- package/dist/src/preview/workerd-shim.d.ts +19 -0
- package/dist/src/preview/workerd-shim.d.ts.map +1 -0
- package/dist/src/preview/workerd-shim.js +33 -0
- package/dist/src/preview/workerd-shim.js.map +1 -0
- package/dist/src/preview-build.d.ts +71 -0
- package/dist/src/preview-build.d.ts.map +1 -0
- package/dist/src/preview-build.js +115 -0
- package/dist/src/preview-build.js.map +1 -0
- package/dist/src/preview.d.ts +6 -0
- package/dist/src/preview.d.ts.map +1 -0
- package/dist/src/preview.js +12 -0
- package/dist/src/preview.js.map +1 -0
- package/dist/src/register.d.ts +98 -0
- package/dist/src/register.d.ts.map +1 -0
- package/dist/src/register.js +103 -0
- package/dist/src/register.js.map +1 -0
- package/dist/src/repository.d.ts +18 -0
- package/dist/src/repository.d.ts.map +1 -0
- package/dist/src/repository.js +46 -0
- package/dist/src/repository.js.map +1 -0
- package/dist/src/site-id.d.ts +18 -0
- package/dist/src/site-id.d.ts.map +1 -0
- package/dist/src/site-id.js +70 -0
- package/dist/src/site-id.js.map +1 -0
- package/dist/src/site-middleware.d.ts +18 -0
- package/dist/src/site-middleware.d.ts.map +1 -0
- package/dist/src/site-middleware.js +47 -0
- package/dist/src/site-middleware.js.map +1 -0
- package/dist/src/skill.d.ts +26 -0
- package/dist/src/skill.d.ts.map +1 -0
- package/dist/src/skill.js +67 -0
- package/dist/src/skill.js.map +1 -0
- package/dist/src/types.d.ts +125 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +177 -4
- package/src/build-commit.ts +22 -0
- package/src/bundle.ts +563 -0
- package/src/component-manifest.ts +75 -0
- package/src/constants.ts +28 -0
- package/src/descriptors.ts +92 -0
- package/src/discovery.ts +183 -0
- package/src/doctor/checks-live.ts +324 -0
- package/src/doctor/checks-offline.ts +325 -0
- package/src/doctor/config-scan.ts +205 -0
- package/src/doctor/run.ts +39 -0
- package/src/doctor/types.ts +71 -0
- package/src/doctor.ts +14 -0
- package/src/git.ts +66 -0
- package/src/index.ts +8 -0
- package/src/integration.ts +595 -0
- package/src/message-of.ts +4 -0
- package/src/node.ts +5 -0
- package/src/package-version.ts +16 -0
- package/src/preview/_dispatch.ts +101 -0
- package/src/preview/_resolve-opts.ts +84 -0
- package/src/preview/banner.ts +96 -0
- package/src/preview/content-api.ts +293 -0
- package/src/preview/cookie.ts +54 -0
- package/src/preview/headers.ts +30 -0
- package/src/preview/landing.ts +73 -0
- package/src/preview/middleware.ts +303 -0
- package/src/preview/preview-path.ts +28 -0
- package/src/preview/satteri-workerd.ts +24 -0
- package/src/preview/site-middleware.ts +209 -0
- package/src/preview/workerd-shim.ts +31 -0
- package/src/preview-build.ts +147 -0
- package/src/preview-handler.astro +55 -0
- package/src/preview-handler.d.ts +6 -0
- package/src/preview.ts +22 -0
- package/src/register.ts +180 -0
- package/src/repository.ts +54 -0
- package/src/site-id.ts +86 -0
- package/src/site-middleware.ts +55 -0
- package/src/skill/SKILL.md +69 -0
- package/src/skill.ts +66 -0
- package/src/types.ts +127 -0
- package/src/virtual-modules.d.ts +51 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { discoverMdxComponents, EDITOR_DESCRIPTORS_ENV_VAR, readEditorDescriptors, toPortableImports, } from '@conloca/astro-cms/node';
|
|
2
|
+
/**
|
|
3
|
+
* Runs conlocaCMS's own registry scan and makes its local-component import
|
|
4
|
+
* specifiers portable — the descriptors are serialized into the site's
|
|
5
|
+
* MDX files on save, where a build agent's absolute path would be a
|
|
6
|
+
* committed dead link.
|
|
7
|
+
*/
|
|
8
|
+
const scanMdxDescriptors = async (options) => {
|
|
9
|
+
// Resolved ONCE and handed to both calls: the scan and the portability
|
|
10
|
+
// rewrite must agree on the root, or a drift in either default would
|
|
11
|
+
// produce non-portable paths with no failing test.
|
|
12
|
+
const projectRoot = options.projectRoot ?? process.cwd();
|
|
13
|
+
return toPortableImports(await discoverMdxComponents({ ...options, projectRoot }), projectRoot);
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Resolves the editor descriptors for this build from the channel conlocaCMS
|
|
17
|
+
* published — the bundle's third leg, next to the puck config and the styles.
|
|
18
|
+
*
|
|
19
|
+
* The editor at the endpoint has no dev server to serve `/api/registry` from,
|
|
20
|
+
* so the scan runs HERE and its output is compiled into the bundle. Fail-soft throughout: a
|
|
21
|
+
* scan failure costs the auto-discovered half and warns; an absent channel (a
|
|
22
|
+
* CMS-less build) is simply a build with no descriptors; a PRESENT but
|
|
23
|
+
* unreadable channel warns — that is version drift between this package and
|
|
24
|
+
* `@conloca/astro-cms`, not a CMS-less build, and silence would strip every
|
|
25
|
+
* schema from the editor at the endpoint with no diagnostic. The bundle itself stays
|
|
26
|
+
* fail-hard, unchanged.
|
|
27
|
+
*/
|
|
28
|
+
export async function resolveEditorDescriptors(logger, env = process.env, scan = scanMdxDescriptors) {
|
|
29
|
+
const channel = readEditorDescriptors(env);
|
|
30
|
+
if (channel === undefined) {
|
|
31
|
+
if (env[EDITOR_DESCRIPTORS_ENV_VAR] !== undefined && env[EDITOR_DESCRIPTORS_ENV_VAR] !== '') {
|
|
32
|
+
logger.warn(`${EDITOR_DESCRIPTORS_ENV_VAR} is set but unreadable — @conloca/astro-cms and @conloca/cloud-astro ` +
|
|
33
|
+
'versions may have drifted; the editor at the endpoint gets no schemas or MDX descriptors from this build, ' +
|
|
34
|
+
'and agents get no component manifest');
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
let discovered = [];
|
|
39
|
+
try {
|
|
40
|
+
discovered = await scan(channel.registry);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
logger.warn('MDX component discovery failed — the editor at the endpoint gets the site-authored descriptors only ' +
|
|
44
|
+
`(${error instanceof Error ? error.message : String(error)})`);
|
|
45
|
+
}
|
|
46
|
+
const templateCount = Object.keys(channel.templates ?? {}).length;
|
|
47
|
+
const { dataBindings } = channel;
|
|
48
|
+
if (channel.schemasPath === undefined &&
|
|
49
|
+
discovered.length === 0 &&
|
|
50
|
+
templateCount === 0 &&
|
|
51
|
+
dataBindings === undefined) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
logger.info(`editor descriptors: ${discovered.length} auto-discovered MDX component(s)` +
|
|
55
|
+
(channel.schemasPath ? ` plus the host schemas module (${channel.schemasPath})` : '') +
|
|
56
|
+
(templateCount > 0 ? ` plus ${templateCount} page template(s)` : '') +
|
|
57
|
+
(dataBindings ? ` plus the data bindings of ${Object.keys(dataBindings.routes).length} page collection(s)` : ''));
|
|
58
|
+
return {
|
|
59
|
+
...(channel.schemasPath === undefined ? {} : { schemasPath: channel.schemasPath }),
|
|
60
|
+
...(discovered.length === 0 ? {} : { discoveredMdxComponents: discovered }),
|
|
61
|
+
...(templateCount === 0 ? {} : { templates: channel.templates }),
|
|
62
|
+
...(dataBindings === undefined ? {} : { dataBindings }),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=descriptors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptors.js","sourceRoot":"","sources":["../../src/descriptors.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AASjC;;;;;GAKG;AACH,MAAM,kBAAkB,GAAsB,KAAK,EAAE,OAAO,EAAE,EAAE;IAC9D,uEAAuE;IACvE,qEAAqE;IACrE,mDAAmD;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACzD,OAAO,iBAAiB,CAAC,MAAM,qBAAqB,CAAC,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;AAClG,CAAC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,MAAoE,EACpE,GAAG,GAAuC,OAAO,CAAC,GAAG,EACrD,IAAI,GAAsB,kBAAkB;IAE5C,MAAM,OAAO,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,IAAI,GAAG,CAAC,0BAA0B,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,0BAA0B,CAAC,KAAK,EAAE,EAAE,CAAC;YAC5F,MAA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QACL,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;QAClF,GAAG,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,uBAAuB,EAAE,UAAU,EAAE,CAAC;QAC3E,GAAG,CAAC,aAAa,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;QAChE,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC;KACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { DiscoveredWrappers } from '@conloca/astro-cms/node';
|
|
2
|
+
/**
|
|
3
|
+
* Build-time style discovery. The editor at the endpoint cannot run the
|
|
4
|
+
* discovery flow conlocaCMS runs on the site's dev server — no Vite graph to
|
|
5
|
+
* ask for a route's CSS, and cross-origin computed styles are browser-blocked
|
|
6
|
+
* — but every mechanism only produces plain data, and the build is the moment
|
|
7
|
+
* this pipeline stands inside the site. So: read the discovery route's
|
|
8
|
+
* rendered page, collect its stylesheets, run the SAME wrapper heuristic the
|
|
9
|
+
* dev server runs (`findContentWrapper`, imported — not duplicated), and hand
|
|
10
|
+
* the results to registration.
|
|
11
|
+
*
|
|
12
|
+
* Where the rendered page comes from, in order:
|
|
13
|
+
* 1. a prerendered file in the client dir (static routes);
|
|
14
|
+
* 2. the built server entry, booted for one request (the node adapter's
|
|
15
|
+
* `dist/server/entry.mjs` honors HOST/PORT) — covers `output: 'server'`
|
|
16
|
+
* sites, which is what real CMS deployments are;
|
|
17
|
+
* 3. nothing → warn and skip; registration proceeds without the artifacts
|
|
18
|
+
* (fail-soft, like every other optional registration input).
|
|
19
|
+
*
|
|
20
|
+
* ponytail: only the node adapter's entry is bootable in v1 — a
|
|
21
|
+
* workerd-targeted build (Cloudflare adapter) skips discovery with the
|
|
22
|
+
* warning. A site whose prose is `.conloca-prose`-scoped is already covered
|
|
23
|
+
* by the derived tier; boot-via-wrangler is the upgrade path if a
|
|
24
|
+
* workerd-targeted site ever needs heuristic discovery.
|
|
25
|
+
*/
|
|
26
|
+
export interface DiscoveredStyleContext {
|
|
27
|
+
hostWrappers: DiscoveredWrappers;
|
|
28
|
+
/** The route's stylesheets concatenated in document order (links + inline). */
|
|
29
|
+
routeCss: string;
|
|
30
|
+
}
|
|
31
|
+
export type CssRef = {
|
|
32
|
+
kind: 'link';
|
|
33
|
+
href: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: 'inline';
|
|
36
|
+
css: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Stylesheet references of a rendered page in document order. Regex-level on
|
|
40
|
+
* purpose: build-output HTML is machine-generated, and the only shapes that
|
|
41
|
+
* matter are `<link rel="stylesheet">` and `<style>` blocks.
|
|
42
|
+
*/
|
|
43
|
+
export declare function extractRouteCssRefs(html: string): CssRef[];
|
|
44
|
+
interface DiscoverInput {
|
|
45
|
+
/** The build's client output dir (where `_conloca/` also lands). */
|
|
46
|
+
clientDir: string;
|
|
47
|
+
/** The built SSR entry, when the adapter produces a bootable one. */
|
|
48
|
+
serverEntry?: string;
|
|
49
|
+
/** The representative content route (the shared `fragmentPreviewRoute`). */
|
|
50
|
+
route: string;
|
|
51
|
+
logger: {
|
|
52
|
+
info(message: string): void;
|
|
53
|
+
warn(message: string): void;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export declare function discoverStyleContext(input: DiscoverInput): Promise<DiscoveredStyleContext | undefined>;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/discovery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAGlE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,kBAAkB,CAAC;IACjC,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtF;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAkB1D;AAED,UAAU,aAAa;IACrB,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE;QAAE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;CACtE;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAsB5G"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { findContentWrapper } from '@conloca/astro-cms/node';
|
|
4
|
+
/**
|
|
5
|
+
* Stylesheet references of a rendered page in document order. Regex-level on
|
|
6
|
+
* purpose: build-output HTML is machine-generated, and the only shapes that
|
|
7
|
+
* matter are `<link rel="stylesheet">` and `<style>` blocks.
|
|
8
|
+
*/
|
|
9
|
+
export function extractRouteCssRefs(html) {
|
|
10
|
+
const refs = [];
|
|
11
|
+
const linkRe = /<link\b[^>]*>/gi;
|
|
12
|
+
for (const match of html.matchAll(linkRe)) {
|
|
13
|
+
const tag = match[0];
|
|
14
|
+
if (!/rel\s*=\s*["']?stylesheet["']?/i.test(tag))
|
|
15
|
+
continue;
|
|
16
|
+
const href = tag.match(/href\s*=\s*["']([^"']+)["']/i)?.[1];
|
|
17
|
+
if (href)
|
|
18
|
+
refs.push({ index: match.index ?? 0, ref: { kind: 'link', href } });
|
|
19
|
+
}
|
|
20
|
+
const styleRe = /<style\b[^>]*>([\s\S]*?)<\/style>/gi;
|
|
21
|
+
for (const match of html.matchAll(styleRe)) {
|
|
22
|
+
const css = match[1].trim();
|
|
23
|
+
if (css)
|
|
24
|
+
refs.push({ index: match.index ?? 0, ref: { kind: 'inline', css } });
|
|
25
|
+
}
|
|
26
|
+
return refs.sort((a, b) => a.index - b.index).map((entry) => entry.ref);
|
|
27
|
+
}
|
|
28
|
+
export async function discoverStyleContext(input) {
|
|
29
|
+
const fromFile = await readPrerenderedPage(input);
|
|
30
|
+
if (fromFile)
|
|
31
|
+
return fromFile;
|
|
32
|
+
if (input.serverEntry) {
|
|
33
|
+
try {
|
|
34
|
+
return await bootAndDiscover(input);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
input.logger.warn(`style discovery: booting the server entry failed — skipping (${error instanceof Error ? error.message : String(error)})`);
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
input.logger.warn(`style discovery: no built page for ${input.route} and no bootable server entry — ` +
|
|
42
|
+
'skipping; the editor falls back to the prose-safe tier.');
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
/** Try `<route>/index.html` then `<route>.html` under the client dir. */
|
|
46
|
+
async function readPrerenderedPage(input) {
|
|
47
|
+
const slug = input.route.replace(/^\/+|\/+$/g, '');
|
|
48
|
+
for (const candidate of [`${slug}/index.html`, `${slug}.html`]) {
|
|
49
|
+
let html;
|
|
50
|
+
try {
|
|
51
|
+
html = await readFile(join2(input.clientDir, candidate), 'utf8');
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const routeCss = await assembleCss(extractRouteCssRefs(html), async (href) => {
|
|
57
|
+
try {
|
|
58
|
+
return await readFile(join2(input.clientDir, href.replace(/^\/+/, '')), 'utf8');
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
input.logger.warn(`style discovery: stylesheet ${href} not found in the client dir — skipped.`);
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return { hostWrappers: findContentWrapper(html), routeCss };
|
|
66
|
+
}
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
/** Boot the built entry on a loopback port, fetch the route + its CSS, kill. */
|
|
70
|
+
async function bootAndDiscover(input) {
|
|
71
|
+
if (!input.serverEntry)
|
|
72
|
+
return undefined;
|
|
73
|
+
const port = 41000 + Math.floor(Math.random() * 20000);
|
|
74
|
+
const origin = `http://127.0.0.1:${port}`;
|
|
75
|
+
const child = spawn(process.execPath, [input.serverEntry], {
|
|
76
|
+
env: { ...process.env, HOST: '127.0.0.1', PORT: String(port) },
|
|
77
|
+
stdio: 'ignore',
|
|
78
|
+
});
|
|
79
|
+
try {
|
|
80
|
+
await waitForServer(origin);
|
|
81
|
+
const page = await fetch(`${origin}${input.route}`);
|
|
82
|
+
if (!page.ok) {
|
|
83
|
+
input.logger.warn(`style discovery: ${input.route} answered ${page.status} on the booted entry — skipping.`);
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const html = await page.text();
|
|
87
|
+
const routeCss = await assembleCss(extractRouteCssRefs(html), async (href) => {
|
|
88
|
+
const res = await fetch(new URL(href, origin));
|
|
89
|
+
if (!res.ok) {
|
|
90
|
+
input.logger.warn(`style discovery: stylesheet ${href} answered ${res.status} — skipped.`);
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
return res.text();
|
|
94
|
+
});
|
|
95
|
+
return { hostWrappers: findContentWrapper(html), routeCss };
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
child.kill('SIGTERM');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async function assembleCss(refs, loadHref) {
|
|
102
|
+
const parts = [];
|
|
103
|
+
for (const ref of refs) {
|
|
104
|
+
if (ref.kind === 'inline') {
|
|
105
|
+
parts.push(ref.css);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const css = await loadHref(ref.href);
|
|
109
|
+
if (css)
|
|
110
|
+
parts.push(css);
|
|
111
|
+
}
|
|
112
|
+
return parts.join('\n');
|
|
113
|
+
}
|
|
114
|
+
async function waitForServer(origin) {
|
|
115
|
+
// A design-time boot of the SSR entry; on a saturated CI runner the first
|
|
116
|
+
// answer took >15s while a full parallel gate ran beside it.
|
|
117
|
+
const deadline = Date.now() + 60_000;
|
|
118
|
+
while (Date.now() < deadline) {
|
|
119
|
+
try {
|
|
120
|
+
await fetch(origin, { method: 'HEAD' });
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
throw new Error('server entry did not answer within 60s');
|
|
128
|
+
}
|
|
129
|
+
/** node:path join without importing path twice under bundling edge cases. */
|
|
130
|
+
function join2(base, rel) {
|
|
131
|
+
return `${base.replace(/\/+$/, '')}/${rel}`;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5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IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,MAAc;IACzC,0EAA0E;IAC1E,6DAA6D;IAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC;IACrC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YACxC,OAAO;QACT,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;AAC5D,CAAC;AAED,6EAA6E;AAC7E,SAAS,KAAK,CAAC,IAAY,EAAE,GAAW;IACtC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ConfigScan } from './config-scan.js';
|
|
2
|
+
import { type CheckOutcome, type CloudDoctorContext, type DoctorDeps } from './types.js';
|
|
3
|
+
interface LiveInput {
|
|
4
|
+
context: CloudDoctorContext;
|
|
5
|
+
deps: DoctorDeps;
|
|
6
|
+
scan: ConfigScan;
|
|
7
|
+
/** CC2's verdict: the token once it parses; undefined when missing or malformed. */
|
|
8
|
+
token: string | undefined;
|
|
9
|
+
/** CC3's verdict: the endpoint once it parses as a URL. */
|
|
10
|
+
endpoint: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
/** CC5–CC7. Networks only under --live, and the token goes ONLY to the configured endpoint. */
|
|
13
|
+
export declare function runLiveChecks(input: LiveInput): Promise<CheckOutcome[]>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=checks-live.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks-live.d.ts","sourceRoot":"","sources":["../../../src/doctor/checks-live.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAiB,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,UAAU,EAGhB,MAAM,YAAY,CAAC;AAmCpB,UAAU,SAAS;IACjB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,oFAAoF;IACpF,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAuND,+FAA+F;AAC/F,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAmD7E"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { PACKAGE_NAME } from '../constants.js';
|
|
2
|
+
import { resolveBuildRef, resolveRepositoryUri } from '../git.js';
|
|
3
|
+
import { messageOf } from '../message-of.js';
|
|
4
|
+
import { resolveBuildSiteId } from '../site-id.js';
|
|
5
|
+
import { ENDPOINT_ENV_VAR, INTEGRATION_NOT_CALLED, suppliedBuildToken, suppliedEndpoint } from './checks-offline.js';
|
|
6
|
+
import { optionLiteral } from './config-scan.js';
|
|
7
|
+
import { outcomeOf, skipped, } from './types.js';
|
|
8
|
+
const LIVE_CHECK_IDS = ['CC5', 'CC6', 'CC7'];
|
|
9
|
+
/** Every doctor request is bounded: a hanging host must never hang `conloca doctor` (the CLI seam has no timer of its own). */
|
|
10
|
+
const REQUEST_TIMEOUT_MS = 10_000;
|
|
11
|
+
/** Version strings come from whatever build registered; only a value shaped like a version reaches the terminal. */
|
|
12
|
+
const VERSION_SHAPE = /^[0-9A-Za-z.+-]{1,64}$/;
|
|
13
|
+
function builtWithNote(value) {
|
|
14
|
+
return typeof value === 'string' && VERSION_SHAPE.test(value) ? ` (built with ${PACKAGE_NAME} ${value})` : '';
|
|
15
|
+
}
|
|
16
|
+
const skipAll = (reason) => LIVE_CHECK_IDS.map((id) => skipped(id, reason));
|
|
17
|
+
function isStatusRegistration(value) {
|
|
18
|
+
if (typeof value !== 'object' || value === null)
|
|
19
|
+
return false;
|
|
20
|
+
const row = value;
|
|
21
|
+
return (typeof row.branch === 'string' &&
|
|
22
|
+
typeof row.gitSha === 'string' &&
|
|
23
|
+
typeof row.editorBundleUrl === 'string' &&
|
|
24
|
+
typeof row.registeredAt === 'number' &&
|
|
25
|
+
(row.siteId === null || typeof row.siteId === 'string') &&
|
|
26
|
+
(row.parked === undefined || typeof row.parked === 'boolean') &&
|
|
27
|
+
(row.clientVersion === undefined || row.clientVersion === null || typeof row.clientVersion === 'string'));
|
|
28
|
+
}
|
|
29
|
+
/** Every field the checks read, so an endpoint drift fails CC5 loudly instead of surfacing as a broken CC6/CC7. */
|
|
30
|
+
function isStatusResponse(value) {
|
|
31
|
+
if (typeof value !== 'object' || value === null)
|
|
32
|
+
return false;
|
|
33
|
+
const body = value;
|
|
34
|
+
return ((body.defaultBranch === null || typeof body.defaultBranch === 'string') &&
|
|
35
|
+
Array.isArray(body.registrations) &&
|
|
36
|
+
body.registrations.every(isStatusRegistration));
|
|
37
|
+
}
|
|
38
|
+
function statusFailed(outcome, message, skipReason) {
|
|
39
|
+
outcome.problems.push({ check: 'CC5', level: 'error', message });
|
|
40
|
+
return { outcome, skipReason };
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* CC5 — GET the status route with the token, joining the path exactly as the
|
|
44
|
+
* build does (register.ts) so --live reproduces the build's own request. 200
|
|
45
|
+
* and 401 both prove reachability; only 200 yields rows.
|
|
46
|
+
*/
|
|
47
|
+
async function probeStatus(fetchFn, target) {
|
|
48
|
+
const outcome = outcomeOf('CC5');
|
|
49
|
+
const url = `${target.endpoint}/api/v1/registrations/status?repoUri=${encodeURIComponent(target.repoUri)}`;
|
|
50
|
+
let response;
|
|
51
|
+
try {
|
|
52
|
+
response = await fetchFn(url, {
|
|
53
|
+
headers: { authorization: `Bearer ${target.token}` },
|
|
54
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
return statusFailed(outcome, `endpoint ${target.endpoint} is unreachable (${messageOf(error)}) — check the endpoint option and network access from this machine`, 'the endpoint is unreachable');
|
|
59
|
+
}
|
|
60
|
+
if (response.status === 401) {
|
|
61
|
+
return statusFailed(outcome, 'the build token is rejected by the endpoint — most likely rotated (a new token invalidates the old one); create a new token and update the CI secret — or the endpoint predates the registration status route, in which case update the endpoint first', 'the endpoint rejected the build token');
|
|
62
|
+
}
|
|
63
|
+
if (response.status === 403) {
|
|
64
|
+
return statusFailed(outcome, `the token does not cover ${target.repoUri} — give the endpoint access to that repository or fix repoUri`, 'the repository is not covered by the token');
|
|
65
|
+
}
|
|
66
|
+
if (!response.ok) {
|
|
67
|
+
return statusFailed(outcome, `endpoint answered HTTP ${response.status} for the registration status — the endpoint may predate this check; update it or retry`, `the status route answered HTTP ${response.status}`);
|
|
68
|
+
}
|
|
69
|
+
let body;
|
|
70
|
+
try {
|
|
71
|
+
body = await response.json();
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return statusFailed(outcome, 'the endpoint answered 200 but not with JSON — does endpoint point at the site itself instead of the editor endpoint?', 'the endpoint did not answer with JSON');
|
|
75
|
+
}
|
|
76
|
+
if (!isStatusResponse(body)) {
|
|
77
|
+
return statusFailed(outcome, 'the registration status response has an unexpected shape — update the endpoint or this package', 'the status response was unreadable');
|
|
78
|
+
}
|
|
79
|
+
outcome.detail = `${target.endpoint} reachable — ${body.registrations.length} registration(s) for ${target.repoUri}`;
|
|
80
|
+
return { outcome, body };
|
|
81
|
+
}
|
|
82
|
+
/** CC6 — own row → probe; default-branch row → warn + probe; neither → error. Returns the row the editor would load. */
|
|
83
|
+
function diagnoseRegistrations(body, branch, siteId) {
|
|
84
|
+
const outcome = outcomeOf('CC6');
|
|
85
|
+
if (!branch) {
|
|
86
|
+
outcome.problems.push({
|
|
87
|
+
check: 'CC6',
|
|
88
|
+
level: 'warn',
|
|
89
|
+
message: 'could not determine the current branch (detached HEAD?) — set CF_PAGES_BRANCH or GITHUB_REF_NAME, or check out a branch',
|
|
90
|
+
});
|
|
91
|
+
return { outcome, row: undefined };
|
|
92
|
+
}
|
|
93
|
+
// Newest first, whatever order the route returned: the editor loads the newest row.
|
|
94
|
+
const live = body.registrations.filter((row) => row.parked !== true).sort((a, b) => b.registeredAt - a.registeredAt);
|
|
95
|
+
// Activation is branch-scoped, so only rows parked for THIS branch say anything about it. They carry no siteId:
|
|
96
|
+
// the site stays undetermined until the editor's next open reads the branch's tree.
|
|
97
|
+
const parkedHere = body.registrations.filter((row) => row.parked === true && row.branch === branch);
|
|
98
|
+
// A branch without its own row is served by the default branch's row for that site — the editor's own lookup
|
|
99
|
+
// rule, which reads an empty default branch as none (the route relays the repository record as is).
|
|
100
|
+
const defaultBranch = body.defaultBranch === '' ? null : body.defaultBranch;
|
|
101
|
+
const inheritable = defaultBranch !== null && defaultBranch !== branch;
|
|
102
|
+
const own = live.find((row) => row.branch === branch && row.siteId === siteId);
|
|
103
|
+
const inherited = own === undefined && inheritable
|
|
104
|
+
? live.find((row) => row.branch === defaultBranch && row.siteId === siteId)
|
|
105
|
+
: undefined;
|
|
106
|
+
const details = [];
|
|
107
|
+
if (own) {
|
|
108
|
+
details.push(`site "${siteId}": own registration ${own.gitSha}${builtWithNote(own.clientVersion)}`);
|
|
109
|
+
}
|
|
110
|
+
else if (inherited) {
|
|
111
|
+
outcome.problems.push({
|
|
112
|
+
check: 'CC6',
|
|
113
|
+
level: 'warn',
|
|
114
|
+
message: `site "${siteId}": no registration for branch ${branch} — the editor inherits the default branch's (${defaultBranch}) registration; it works, preview is degraded. Build ${branch} with the token to register it`,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else if (parkedHere.length > 0) {
|
|
118
|
+
// The next editor open activates these rows, so the editor does load. It only fails when the branch has since
|
|
119
|
+
// grown a second site, which the doctor cannot foresee: resolveBuildSiteId answers with one id, never a count.
|
|
120
|
+
outcome.problems.push({
|
|
121
|
+
check: 'CC6',
|
|
122
|
+
level: 'warn',
|
|
123
|
+
message: `site "${siteId}": no active registration serves branch ${branch} — ${parkedHere.length} older registration(s) for it become active the next time the editor opens, unless this branch now declares more than one site (the editor answers 409 then). Build ${branch} with CONLOCA_BUILD_TOKEN set to replace them`,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const fallback = inheritable ? ` (nor the default branch ${defaultBranch})` : '';
|
|
128
|
+
outcome.problems.push({
|
|
129
|
+
check: 'CC6',
|
|
130
|
+
level: 'error',
|
|
131
|
+
message: `site "${siteId}": no registration serves branch ${branch}${fallback} — the editor will not load; build ${branch} with CONLOCA_BUILD_TOKEN set`,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// Only a footnote when something already serves the branch; the parked-only warning above carries the count itself.
|
|
135
|
+
if (parkedHere.length > 0 && (own ?? inherited)) {
|
|
136
|
+
details.push(`${parkedHere.length} older registration(s) not active yet — they become active the next time the editor opens`);
|
|
137
|
+
}
|
|
138
|
+
if (details.length > 0)
|
|
139
|
+
outcome.detail = details.join('; ');
|
|
140
|
+
return { outcome, row: own ?? inherited };
|
|
141
|
+
}
|
|
142
|
+
/** HEAD the URL; a host that refuses HEAD (405/501) gets a GET. */
|
|
143
|
+
async function reachable(fetchFn, url) {
|
|
144
|
+
try {
|
|
145
|
+
let response = await fetchFn(url, { method: 'HEAD', signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
|
|
146
|
+
if (response.status === 405 || response.status === 501) {
|
|
147
|
+
// A one-byte range keeps the probe from downloading the whole bundle; the 206 it earns is `ok`.
|
|
148
|
+
response = await fetchFn(url, {
|
|
149
|
+
method: 'GET',
|
|
150
|
+
headers: { range: 'bytes=0-0' },
|
|
151
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return response.ok ? { ok: true } : { ok: false, answer: `HTTP ${response.status}` };
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
return { ok: false, answer: `unreachable (${messageOf(error)})` };
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** CC7 — the bundle a registration names must still be deployed: the row serving this branch needs its bytes. */
|
|
161
|
+
async function probeBundle(siteId, row, localSha, fetchFn) {
|
|
162
|
+
if (row === undefined)
|
|
163
|
+
return skipped('CC7', 'no registration to probe');
|
|
164
|
+
const outcome = outcomeOf('CC7');
|
|
165
|
+
const result = await reachable(fetchFn, row.editorBundleUrl);
|
|
166
|
+
if (!result.ok) {
|
|
167
|
+
outcome.problems.push({
|
|
168
|
+
check: 'CC7',
|
|
169
|
+
level: 'error',
|
|
170
|
+
message: `site "${siteId}": the registration for ${row.branch} points at deleted editor assets — ${row.editorBundleUrl} answers ${result.answer} (a later deploy replaced them); rebuild and deploy from ${row.branch}`,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
else if (localSha && localSha !== row.gitSha) {
|
|
174
|
+
outcome.detail = `site "${siteId}": registered ${row.gitSha.slice(0, 7)}, local HEAD ${localSha.slice(0, 7)} — the editor at the endpoint lags this checkout`;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
outcome.detail = `site "${siteId}": ${row.editorBundleUrl} reachable`;
|
|
178
|
+
}
|
|
179
|
+
return outcome;
|
|
180
|
+
}
|
|
181
|
+
/** CC5–CC7. Networks only under --live, and the token goes ONLY to the configured endpoint. */
|
|
182
|
+
export async function runLiveChecks(input) {
|
|
183
|
+
const { context, deps, scan, token, endpoint } = input;
|
|
184
|
+
if (!context.live)
|
|
185
|
+
return skipAll('live checks run only with --live');
|
|
186
|
+
// The live trio diagnoses this integration: an unwired one is the reason, exactly as CC2/CC3 say.
|
|
187
|
+
if (scan.kind === 'read' && scan.config.conlocaCloud === 'absent')
|
|
188
|
+
return skipAll(INTEGRATION_NOT_CALLED);
|
|
189
|
+
if (token === undefined) {
|
|
190
|
+
// CC2 already said why a supplied token is unusable; only a missing one gets the how-to here.
|
|
191
|
+
return skipAll(suppliedBuildToken(scan, deps.env) === undefined
|
|
192
|
+
? 'no build token — set CONLOCA_BUILD_TOKEN'
|
|
193
|
+
: 'no usable build token (see CC2)');
|
|
194
|
+
}
|
|
195
|
+
if (endpoint === undefined) {
|
|
196
|
+
// Likewise CC3 already said why a supplied endpoint is unusable.
|
|
197
|
+
return skipAll(suppliedEndpoint(scan, deps.env) === undefined
|
|
198
|
+
? `endpoint could not be determined — set ${ENDPOINT_ENV_VAR}`
|
|
199
|
+
: 'no usable endpoint (see CC3)');
|
|
200
|
+
}
|
|
201
|
+
// The doctor diagnoses the project it was handed, not whatever checkout the CLI happens to be standing in:
|
|
202
|
+
// `conloca doctor ./site` from a wrapper repo would otherwise read that repo's branch and call the site broken.
|
|
203
|
+
const git = (args) => deps.git(args, context.projectDir);
|
|
204
|
+
const repoUri = resolveRepositoryUri(optionLiteral(scan, 'repoUri'), deps.env, git);
|
|
205
|
+
if (repoUri === undefined) {
|
|
206
|
+
return skipAll('repository identity could not be determined — build in a CI environment or Git checkout, or set repoUri');
|
|
207
|
+
}
|
|
208
|
+
const status = await probeStatus(deps.fetch, { token, endpoint, repoUri });
|
|
209
|
+
if (!('body' in status)) {
|
|
210
|
+
return [status.outcome, skipped('CC6', status.skipReason), skipped('CC7', status.skipReason)];
|
|
211
|
+
}
|
|
212
|
+
let siteId;
|
|
213
|
+
try {
|
|
214
|
+
siteId = resolveBuildSiteId({
|
|
215
|
+
contentRoot: context.contentRoot,
|
|
216
|
+
override: optionLiteral(scan, 'siteId'),
|
|
217
|
+
readFile: deps.readFile,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
const outcome = outcomeOf('CC6');
|
|
222
|
+
outcome.problems.push({ check: 'CC6', level: 'error', message: messageOf(error) });
|
|
223
|
+
return [status.outcome, outcome, skipped('CC7', 'the site id could not be resolved')];
|
|
224
|
+
}
|
|
225
|
+
const ref = resolveBuildRef(deps.env, git);
|
|
226
|
+
const diagnosis = diagnoseRegistrations(status.body, ref.branch, siteId);
|
|
227
|
+
return [status.outcome, diagnosis.outcome, await probeBundle(siteId, diagnosis.row, ref.gitSha, deps.fetch)];
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=checks-live.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks-live.js","sourceRoot":"","sources":["../../../src/doctor/checks-live.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACrH,OAAO,EAAmB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAKL,SAAS,EACT,OAAO,GACR,MAAM,YAAY,CAAC;AAEpB,MAAM,cAAc,GAAuB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAEjE,+HAA+H;AAC/H,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC,oHAAoH;AACpH,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAE/C,SAAS,aAAa,CAAC,KAAgC;IAC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,QAAQ,CAAC;YACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACnF,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,mCAAmC,CAAC,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,qBAAqB,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO,EAAE,MAAM,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/G,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { RepositoryEnvironment } from '../repository.js';
|
|
2
|
+
import { type ConfigScan } from './config-scan.js';
|
|
3
|
+
import { type CheckOutcome } from './types.js';
|
|
4
|
+
/** Doctor-only override for an endpoint the config computes (e.g. from an env var). */
|
|
5
|
+
export declare const ENDPOINT_ENV_VAR = "CONLOCA_ENDPOINT";
|
|
6
|
+
/** Why CC2, CC3 and the live trio skip when the integration is not wired. */
|
|
7
|
+
export declare const INTEGRATION_NOT_CALLED = "conlocaCloud(...) is not called in the astro config";
|
|
8
|
+
/** The build token as supplied — env first, then the config literal. CC2 judges its shape; CC5 only asks whether one exists. */
|
|
9
|
+
export declare function suppliedBuildToken(scan: ConfigScan, env: RepositoryEnvironment): string | undefined;
|
|
10
|
+
/** The endpoint as supplied — config literal first, then CONLOCA_ENDPOINT. CC3 judges its shape; CC5 only asks whether one exists. */
|
|
11
|
+
export declare function suppliedEndpoint(scan: ConfigScan, env: RepositoryEnvironment): string | undefined;
|
|
12
|
+
/** CC1 — three states for the conlocaCloud call, and the both-integrations rule for conlocaCMS. */
|
|
13
|
+
export declare function checkWiring(scan: ConfigScan): CheckOutcome;
|
|
14
|
+
/**
|
|
15
|
+
* CC2 — severity by context: under CI a missing token is an error, locally an
|
|
16
|
+
* info. A token literal in the config is always a warning, even when the env
|
|
17
|
+
* var also carries one: the committed secret is the finding.
|
|
18
|
+
*/
|
|
19
|
+
export declare function checkBuildToken(scan: ConfigScan, env: RepositoryEnvironment): {
|
|
20
|
+
outcome: CheckOutcome;
|
|
21
|
+
token?: string;
|
|
22
|
+
};
|
|
23
|
+
/** CC3 — the endpoint and the public base URL, each in its own helper; skipped when there is nothing to read. */
|
|
24
|
+
export declare function checkEndpoints(scan: ConfigScan, env: RepositoryEnvironment): {
|
|
25
|
+
outcome: CheckOutcome;
|
|
26
|
+
endpoint?: string;
|
|
27
|
+
};
|
|
28
|
+
/** CC4 — each option the endpoint's editor ignores, warned when set. */
|
|
29
|
+
export declare function checkInertCmsOptions(scan: ConfigScan): CheckOutcome;
|
|
30
|
+
/**
|
|
31
|
+
* CC8 — unless previewBuild is false, every build that registers also runs the preview build, which needs an SSR
|
|
32
|
+
* adapter: the project's own or previewBuild.adapter. A static project with neither stays green until its first
|
|
33
|
+
* registering build, which then fails. Only what the config text shows is judged.
|
|
34
|
+
*/
|
|
35
|
+
export declare function checkPreviewBuildAdapter(scan: ConfigScan): CheckOutcome;
|
|
36
|
+
//# sourceMappingURL=checks-offline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks-offline.d.ts","sourceRoot":"","sources":["../../../src/doctor/checks-offline.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