@conloca/cloud-astro 0.2.3 → 0.2.4
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 +155 -37
- package/dist/.build-inputs.json +32 -23
- package/dist/src/constants.d.ts +12 -3
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +12 -3
- package/dist/src/constants.js.map +1 -1
- package/dist/src/d3-build.d.ts +70 -0
- package/dist/src/d3-build.d.ts.map +1 -0
- package/dist/src/d3-build.js +272 -0
- package/dist/src/d3-build.js.map +1 -0
- package/dist/src/descriptors.d.ts.map +1 -1
- package/dist/src/descriptors.js +4 -2
- package/dist/src/descriptors.js.map +1 -1
- package/dist/src/doctor/checks-live.d.ts +2 -2
- package/dist/src/doctor/checks-live.d.ts.map +1 -1
- package/dist/src/doctor/checks-live.js +10 -4
- package/dist/src/doctor/checks-live.js.map +1 -1
- package/dist/src/doctor/checks-offline.d.ts +1 -5
- package/dist/src/doctor/checks-offline.d.ts.map +1 -1
- package/dist/src/doctor/checks-offline.js +15 -27
- package/dist/src/doctor/checks-offline.js.map +1 -1
- package/dist/src/doctor/checks-preview-limits.d.ts +11 -0
- package/dist/src/doctor/checks-preview-limits.d.ts.map +1 -0
- package/dist/src/doctor/checks-preview-limits.js +133 -0
- package/dist/src/doctor/checks-preview-limits.js.map +1 -0
- package/dist/src/doctor/checks-preview-live.d.ts +14 -0
- package/dist/src/doctor/checks-preview-live.d.ts.map +1 -0
- package/dist/src/doctor/checks-preview-live.js +72 -0
- package/dist/src/doctor/checks-preview-live.js.map +1 -0
- package/dist/src/doctor/checks-preview.d.ts +7 -0
- package/dist/src/doctor/checks-preview.d.ts.map +1 -0
- package/dist/src/doctor/checks-preview.js +287 -0
- package/dist/src/doctor/checks-preview.js.map +1 -0
- package/dist/src/doctor/config-scan.d.ts +6 -0
- package/dist/src/doctor/config-scan.d.ts.map +1 -1
- package/dist/src/doctor/config-scan.js +17 -0
- 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 +4 -0
- package/dist/src/doctor/run.js.map +1 -1
- package/dist/src/doctor/types.d.ts +11 -1
- package/dist/src/doctor/types.d.ts.map +1 -1
- package/dist/src/doctor/types.js +11 -1
- package/dist/src/doctor/types.js.map +1 -1
- package/dist/src/editor-page/bundle.d.ts +2 -0
- package/dist/src/editor-page/bundle.d.ts.map +1 -1
- package/dist/src/editor-page/bundle.js +3 -0
- package/dist/src/editor-page/bundle.js.map +1 -1
- package/dist/src/editor-page/data-schemas.d.ts +16 -0
- package/dist/src/editor-page/data-schemas.d.ts.map +1 -0
- package/dist/src/editor-page/data-schemas.js +39 -0
- package/dist/src/editor-page/data-schemas.js.map +1 -0
- package/dist/src/editor-page/emit.d.ts +37 -1
- package/dist/src/editor-page/emit.d.ts.map +1 -1
- package/dist/src/editor-page/emit.js +75 -4
- package/dist/src/editor-page/emit.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/integration.d.ts.map +1 -1
- package/dist/src/integration.js +165 -41
- package/dist/src/integration.js.map +1 -1
- package/dist/src/preview/_dispatch.d.ts +12 -0
- package/dist/src/preview/_dispatch.d.ts.map +1 -1
- package/dist/src/preview/_dispatch.js +31 -0
- package/dist/src/preview/_dispatch.js.map +1 -1
- package/dist/src/preview/_resolve-opts.d.ts +3 -0
- package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
- package/dist/src/preview/_resolve-opts.js +3 -1
- package/dist/src/preview/_resolve-opts.js.map +1 -1
- package/dist/src/preview/banner.d.ts +12 -9
- package/dist/src/preview/banner.d.ts.map +1 -1
- package/dist/src/preview/banner.js +46 -41
- package/dist/src/preview/banner.js.map +1 -1
- package/dist/src/preview/cloudflare-adapter.d.ts +35 -0
- package/dist/src/preview/cloudflare-adapter.d.ts.map +1 -0
- package/dist/src/preview/cloudflare-adapter.js +92 -0
- package/dist/src/preview/cloudflare-adapter.js.map +1 -0
- package/dist/src/preview/cookie.d.ts +9 -13
- package/dist/src/preview/cookie.d.ts.map +1 -1
- package/dist/src/preview/cookie.js +15 -25
- package/dist/src/preview/cookie.js.map +1 -1
- package/dist/src/preview/dispatcher.d.ts +73 -0
- package/dist/src/preview/dispatcher.d.ts.map +1 -0
- package/dist/src/preview/dispatcher.js +329 -0
- package/dist/src/preview/dispatcher.js.map +1 -0
- package/dist/src/preview/entry-code.d.ts +33 -0
- package/dist/src/preview/entry-code.d.ts.map +1 -0
- package/dist/src/preview/entry-code.js +33 -0
- package/dist/src/preview/entry-code.js.map +1 -0
- package/dist/src/preview/headers.d.ts +24 -4
- package/dist/src/preview/headers.d.ts.map +1 -1
- package/dist/src/preview/headers.js +35 -7
- package/dist/src/preview/headers.js.map +1 -1
- package/dist/src/preview/landing.d.ts +21 -0
- package/dist/src/preview/landing.d.ts.map +1 -1
- package/dist/src/preview/landing.js +103 -35
- package/dist/src/preview/landing.js.map +1 -1
- package/dist/src/preview/middleware.d.ts +29 -7
- package/dist/src/preview/middleware.d.ts.map +1 -1
- package/dist/src/preview/middleware.js +238 -84
- package/dist/src/preview/middleware.js.map +1 -1
- package/dist/src/preview/preview-path.d.ts +29 -0
- package/dist/src/preview/preview-path.d.ts.map +1 -1
- package/dist/src/preview/preview-path.js +41 -0
- package/dist/src/preview/preview-path.js.map +1 -1
- package/dist/src/preview/redeem-url.d.ts +7 -0
- package/dist/src/preview/redeem-url.d.ts.map +1 -0
- package/dist/src/preview/redeem-url.js +14 -0
- package/dist/src/preview/redeem-url.js.map +1 -0
- package/dist/src/preview/site-middleware.d.ts.map +1 -1
- package/dist/src/preview/site-middleware.js +39 -12
- package/dist/src/preview/site-middleware.js.map +1 -1
- package/dist/src/preview-build.d.ts +19 -8
- package/dist/src/preview-build.d.ts.map +1 -1
- package/dist/src/preview-build.js +47 -21
- package/dist/src/preview-build.js.map +1 -1
- package/dist/src/skill.d.ts +11 -0
- package/dist/src/skill.d.ts.map +1 -1
- package/dist/src/skill.js +32 -9
- package/dist/src/skill.js.map +1 -1
- package/dist/src/types.d.ts +15 -12
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +33 -7
- package/src/constants.ts +14 -3
- package/src/d3-build.ts +315 -0
- package/src/descriptors.ts +4 -2
- package/src/doctor/checks-live.ts +10 -4
- package/src/doctor/checks-offline.ts +16 -25
- package/src/doctor/checks-preview-limits.ts +137 -0
- package/src/doctor/checks-preview-live.ts +77 -0
- package/src/doctor/checks-preview.ts +302 -0
- package/src/doctor/config-scan.ts +14 -0
- package/src/doctor/run.ts +4 -0
- package/src/doctor/types.ts +11 -1
- package/src/editor-page/bundle.ts +5 -0
- package/src/editor-page/data-schemas.ts +47 -0
- package/src/editor-page/emit.ts +124 -8
- package/src/index.ts +2 -0
- package/src/integration.ts +176 -40
- package/src/preview/_dispatch.ts +36 -1
- package/src/preview/_resolve-opts.ts +6 -1
- package/src/preview/banner.ts +61 -41
- package/src/preview/cloudflare-adapter.ts +103 -0
- package/src/preview/cookie.ts +14 -23
- package/src/preview/dispatcher.ts +407 -0
- package/src/preview/entry-code.ts +51 -0
- package/src/preview/headers.ts +35 -7
- package/src/preview/landing.ts +115 -37
- package/src/preview/middleware.ts +264 -88
- package/src/preview/preview-path.ts +57 -0
- package/src/preview/redeem-url.ts +14 -0
- package/src/preview/site-middleware.ts +47 -12
- package/src/preview-build.ts +67 -24
- package/src/preview-handler.astro +2 -1
- package/src/skill/SKILL.md +14 -2
- package/src/skill.ts +36 -8
- package/src/types.ts +15 -12
|
@@ -25,12 +25,13 @@
|
|
|
25
25
|
* production build. Deliberately fail-open: any request without a valid
|
|
26
26
|
* preview credential passes straight through to the ordinary page.
|
|
27
27
|
*/
|
|
28
|
-
import { fetchPageStatus } from './_dispatch.js';
|
|
28
|
+
import { fetchPageStatus, isShareEndedKind } from './_dispatch.js';
|
|
29
29
|
import { injectPreviewBanner } from './banner.js';
|
|
30
30
|
import { PreviewContentAPI } from './content-api.js';
|
|
31
|
-
import { applyPreviewHeaders } from './headers.js';
|
|
31
|
+
import { applyPreviewHeaders, PREVIEW_CACHE_HEADERS } from './headers.js';
|
|
32
|
+
import { renderPreviewUnavailable, renderShareEnded } from './landing.js';
|
|
32
33
|
import { handlePreviewRequest } from './middleware.js';
|
|
33
|
-
import { normalizeTrailingSlash,
|
|
34
|
+
import { normalizeTrailingSlash, PREVIEW_SLUG_HEADER, pathUnderBase, previewScope, stripPreviewPrefix, } from './preview-path.js';
|
|
34
35
|
/**
|
|
35
36
|
* Builds the Astro middleware `onRequest` handler.
|
|
36
37
|
*
|
|
@@ -57,15 +58,22 @@ export function createPreviewSiteMiddleware(resolveOpts, seams) {
|
|
|
57
58
|
warnUnconfiguredOnce(error);
|
|
58
59
|
return next();
|
|
59
60
|
}
|
|
61
|
+
// Under D3 the dispatcher names the requested branch's slug, after stripping any the browser sent.
|
|
62
|
+
const slug = opts.mode === 'd3' ? (context.request.headers.get(PREVIEW_SLUG_HEADER) ?? undefined) : undefined;
|
|
60
63
|
const verdict = await handlePreviewRequest(context.request, {
|
|
61
64
|
...opts,
|
|
62
|
-
|
|
65
|
+
...(slug === undefined ? {} : { slug }),
|
|
66
|
+
// No silent fallback: under the slug, a pass that doesn't verify gets the landing page, never the
|
|
67
|
+
// published page at the draft URL. Only the live site's own requests (no slug) pass through.
|
|
68
|
+
onMiss: slug === undefined ? 'pass-through' : 'landing',
|
|
63
69
|
fetchFn: opts.fetchFn ?? seams.fetchFn,
|
|
64
70
|
});
|
|
65
71
|
if (verdict.kind === 'response')
|
|
66
72
|
return verdict.response;
|
|
67
73
|
if (verdict.kind !== 'preview')
|
|
68
74
|
return next();
|
|
75
|
+
// A preview verdict under D3 means the slug was named, so the scope always resolves.
|
|
76
|
+
const exitPath = `${previewScope(opts.mode ?? 'd2', opts.base, slug).route}/__exit`;
|
|
69
77
|
// A valid credential on the preview route itself: canonicalize to the
|
|
70
78
|
// clean site path instead of rendering under the route — links, assets
|
|
71
79
|
// and the page lookup all assume clean paths.
|
|
@@ -74,13 +82,14 @@ export function createPreviewSiteMiddleware(resolveOpts, seams) {
|
|
|
74
82
|
if (stripPreviewPrefix(rawPath, opts.base) !== rawPath) {
|
|
75
83
|
return new Response(null, {
|
|
76
84
|
status: 302,
|
|
77
|
-
headers: { location: path,
|
|
85
|
+
headers: { location: path, ...PREVIEW_CACHE_HEADERS },
|
|
78
86
|
});
|
|
79
87
|
}
|
|
80
88
|
context.locals.conlocaPreview = verdict.ctx;
|
|
81
|
-
// An endpoint failure (5xx mid-deploy, auth envelope, network) must
|
|
82
|
-
// the
|
|
83
|
-
//
|
|
89
|
+
// An endpoint failure (5xx mid-deploy, auth envelope, network) must neither
|
|
90
|
+
// 500 the site nor pass published bytes off as the draft: answer with a
|
|
91
|
+
// retry page that also offers Exit, since the visitor can't remove the
|
|
92
|
+
// HttpOnly cookie.
|
|
84
93
|
let status;
|
|
85
94
|
try {
|
|
86
95
|
status = await fetchPageStatus({
|
|
@@ -94,9 +103,19 @@ export function createPreviewSiteMiddleware(resolveOpts, seams) {
|
|
|
94
103
|
});
|
|
95
104
|
}
|
|
96
105
|
catch (error) {
|
|
97
|
-
console.warn(`[@conloca/cloud-astro] preview page-status failed for ${path} —
|
|
106
|
+
console.warn(`[@conloca/cloud-astro] preview page-status failed for ${path} — showing the retry page: ` +
|
|
98
107
|
`${error instanceof Error ? error.message : String(error)}`);
|
|
99
|
-
return
|
|
108
|
+
return renderPreviewUnavailable({
|
|
109
|
+
// Collapse leading slashes: `//evil.test/x` would otherwise be a cross-origin link.
|
|
110
|
+
retryHref: `/${rawPath.replace(/^\/+/u, '')}${context.url.search}`,
|
|
111
|
+
exitHref: `${exitPath}?to=${encodeURIComponent(rawPath)}`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (isShareEndedKind(status.kind) && 'sharedBy' in status) {
|
|
115
|
+
return renderShareEnded(status.kind, {
|
|
116
|
+
sharedBy: status.sharedBy,
|
|
117
|
+
liveHref: `${exitPath}?to=${encodeURIComponent(path)}`,
|
|
118
|
+
});
|
|
100
119
|
}
|
|
101
120
|
if (status.kind === 'unchanged') {
|
|
102
121
|
// Production-equivalent bytes: render the ordinary route against the
|
|
@@ -109,7 +128,7 @@ export function createPreviewSiteMiddleware(resolveOpts, seams) {
|
|
|
109
128
|
// redirect can never be cached by intermediaries.
|
|
110
129
|
return new Response(null, {
|
|
111
130
|
status: 302,
|
|
112
|
-
headers: { location: status.target,
|
|
131
|
+
headers: { location: status.target, ...PREVIEW_CACHE_HEADERS },
|
|
113
132
|
});
|
|
114
133
|
}
|
|
115
134
|
// 'changed' and 'deleted' both render through the site's own route with
|
|
@@ -136,7 +155,15 @@ export function createPreviewSiteMiddleware(resolveOpts, seams) {
|
|
|
136
155
|
// through with the preview headers only.
|
|
137
156
|
return applyPreviewHeaders(rendered);
|
|
138
157
|
}
|
|
139
|
-
|
|
158
|
+
let shareUrl;
|
|
159
|
+
if (verdict.ctx.editorUrl !== undefined) {
|
|
160
|
+
const url = new URL(verdict.ctx.editorUrl);
|
|
161
|
+
url.searchParams.set('share', pathUnderBase(path, opts.base));
|
|
162
|
+
shareUrl = url.toString();
|
|
163
|
+
}
|
|
164
|
+
const html = injectPreviewBanner(await rendered.text(), verdict.ctx, opts.saasEndpoint, exitPath, shareUrl,
|
|
165
|
+
// The page's own path: under D3 the address bar holds the route, which Edit and Exit must not carry.
|
|
166
|
+
rawPath);
|
|
140
167
|
return applyPreviewHeaders(new Response(html, { status: rendered.status, headers: rendered.headers }));
|
|
141
168
|
};
|
|
142
169
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-middleware.js","sourceRoot":"","sources":["../../../src/preview/site-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,eAAe,EAAmB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"site-midd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|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* adapter
|
|
4
|
+
* How the preview build serves, from the options and the adapter the preview server would build with
|
|
5
|
+
* (`previewBuild.adapter`, else the project's own): off unless `previewBuild` is given as an object; D4 with
|
|
6
|
+
* `separate: true`; D3 for a static site, whose preview server runs next to it on Cloudflare Workers; D2 when an
|
|
7
|
+
* adapter is named, since the site's own server deploy serves the drafts. Throws for a refused adapter, so the build
|
|
8
|
+
* fails before it deploys anything.
|
|
7
9
|
*/
|
|
8
|
-
export declare function previewBuildMode(previewBuild: PreviewBuildOptions | false | undefined, adapterName: string | undefined): 'off' |
|
|
10
|
+
export declare function previewBuildMode(previewBuild: PreviewBuildOptions | false | undefined, adapterName: string | undefined): 'off' | PreviewServeMode;
|
|
11
|
+
/** The mode a preview build serves in: the site's build names D2 or D3; the flag alone is a separate preview deploy (D4). */
|
|
12
|
+
export declare function previewChildMode(env: NodeJS.ProcessEnv): PreviewServeMode;
|
|
13
|
+
/**
|
|
14
|
+
* One route the site's build prerendered, as a D3 child matches it: pattern and component together, since one
|
|
15
|
+
* entrypoint can be injected at two patterns, one published and one only the preview build has.
|
|
16
|
+
*/
|
|
17
|
+
export declare function prerenderedKey(pattern: string, component: string): string;
|
|
18
|
+
/** The routes (`prerenderedKey`) a D3 child's site build prerendered (`buildPreviewChildEnv`); none for any other child. */
|
|
19
|
+
export declare function previewChildPrerendered(env: NodeJS.ProcessEnv): Set<string>;
|
|
9
20
|
/**
|
|
10
21
|
* The minimal child-process surface this module relies on. Letting
|
|
11
22
|
* {@link _spawnPreviewBuildWith} accept any function that produces a process
|
|
@@ -30,7 +41,7 @@ export type PreviewBuildSpawn = (command: string, args: readonly string[], optio
|
|
|
30
41
|
* build vars (CF_PAGES_*, WORKERS_CI_*, GITHUB_*) reach the child, which reads
|
|
31
42
|
* the branch and commit it serves from them.
|
|
32
43
|
*/
|
|
33
|
-
export declare function buildPreviewChildEnv(parentEnv: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
44
|
+
export declare function buildPreviewChildEnv(parentEnv: NodeJS.ProcessEnv, mode?: 'd2' | 'd3', prerendered?: readonly string[]): NodeJS.ProcessEnv;
|
|
34
45
|
/**
|
|
35
46
|
* Locate the `astro` CLI binary in the site's `node_modules/.bin/`. We
|
|
36
47
|
* resolve relative to the current working directory (where `astro build` is
|
|
@@ -61,7 +72,7 @@ export declare function resolveAstroBin(cwd?: string): string;
|
|
|
61
72
|
* - `false` → resolves and logs a warning so onboarding setups can continue
|
|
62
73
|
* when the preview build is not yet wired correctly.
|
|
63
74
|
*/
|
|
64
|
-
export declare function spawnPreviewBuild(opts: PreviewBuildOptions): Promise<void>;
|
|
75
|
+
export declare function spawnPreviewBuild(opts: PreviewBuildOptions, mode?: 'd2' | 'd3', prerendered?: readonly string[]): Promise<void>;
|
|
65
76
|
/**
|
|
66
77
|
* Internal seam that takes the spawn function as a parameter so tests can
|
|
67
78
|
* substitute a fake. Public callers should use {@link spawnPreviewBuild}.
|
|
@@ -70,5 +81,5 @@ export declare function spawnPreviewBuild(opts: PreviewBuildOptions): Promise<vo
|
|
|
70
81
|
* and not part of the package's public surface; it is not re-exported from
|
|
71
82
|
* `src/index.ts` or `src/node.ts`.
|
|
72
83
|
*/
|
|
73
|
-
export declare function _spawnPreviewBuildWith(spawnFn: PreviewBuildSpawn, opts: PreviewBuildOptions): Promise<void>;
|
|
84
|
+
export declare function _spawnPreviewBuildWith(spawnFn: PreviewBuildSpawn, opts: PreviewBuildOptions, mode?: 'd2' | 'd3', prerendered?: readonly string[]): Promise<void>;
|
|
74
85
|
//# sourceMappingURL=preview-build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-build.d.ts","sourceRoot":"","sources":["../../src/preview-build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preview-build.d.ts","sourceRoot":"","sources":["../../src/preview-build.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,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GAiBG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,mBAAmB,EACzB,IAAI,GAAE,IAAI,GAAG,IAAW,EACxB,WAAW,GAAE,SAAS,MAAM,EAAO,GAClC,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;;;GAOG;AAEH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,iBAAiB,EAC1B,IAAI,EAAE,mBAAmB,EACzB,IAAI,GAAE,IAAI,GAAG,IAAW,EACxB,WAAW,GAAE,SAAS,MAAM,EAAO,GAClC,OAAO,CAAC,IAAI,CAAC,CAoCf"}
|
|
@@ -1,27 +1,51 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { existsSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { PACKAGE_NAME, PREVIEW_BUILD_ENV_FLAG, REFUSED_PREVIEW_ADAPTERS } from './constants.js';
|
|
4
|
+
import { PACKAGE_NAME, PREVIEW_BUILD_ENV_FLAG, PREVIEW_MODE_ENV, PREVIEW_PRERENDERED_ENV, REFUSED_PREVIEW_ADAPTERS, } from './constants.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* adapter
|
|
6
|
+
* How the preview build serves, from the options and the adapter the preview server would build with
|
|
7
|
+
* (`previewBuild.adapter`, else the project's own): off unless `previewBuild` is given as an object; D4 with
|
|
8
|
+
* `separate: true`; D3 for a static site, whose preview server runs next to it on Cloudflare Workers; D2 when an
|
|
9
|
+
* adapter is named, since the site's own server deploy serves the drafts. Throws for a refused adapter, so the build
|
|
10
|
+
* fails before it deploys anything.
|
|
10
11
|
*/
|
|
11
12
|
export function previewBuildMode(previewBuild, adapterName) {
|
|
12
13
|
if (!previewBuild)
|
|
13
14
|
return 'off';
|
|
14
|
-
if (adapterName
|
|
15
|
-
throw new Error(`${PACKAGE_NAME}: the preview build needs an SSR adapter — the project is static and ` +
|
|
16
|
-
'previewBuild.adapter is not set. Pass one (e.g. previewBuild: { adapter: cloudflare() }) ' +
|
|
17
|
-
'or remove previewBuild.');
|
|
18
|
-
}
|
|
19
|
-
if (REFUSED_PREVIEW_ADAPTERS.includes(adapterName)) {
|
|
15
|
+
if (adapterName !== undefined && REFUSED_PREVIEW_ADAPTERS.includes(adapterName)) {
|
|
20
16
|
throw new Error(`${PACKAGE_NAME}: previewBuild is not supported with ${adapterName} yet: that adapter writes its deployable ` +
|
|
21
17
|
'output at the project root, so the preview build could replace the live site. ' +
|
|
22
18
|
'Remove previewBuild from conlocaCloud(...).');
|
|
23
19
|
}
|
|
24
|
-
|
|
20
|
+
if (previewBuild.separate === true)
|
|
21
|
+
return 'd4';
|
|
22
|
+
return adapterName === undefined ? 'd3' : 'd2';
|
|
23
|
+
}
|
|
24
|
+
/** The mode a preview build serves in: the site's build names D2 or D3; the flag alone is a separate preview deploy (D4). */
|
|
25
|
+
export function previewChildMode(env) {
|
|
26
|
+
const named = env[PREVIEW_MODE_ENV];
|
|
27
|
+
return named === 'd2' || named === 'd3' ? named : 'd4';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* One route the site's build prerendered, as a D3 child matches it: pattern and component together, since one
|
|
31
|
+
* entrypoint can be injected at two patterns, one published and one only the preview build has.
|
|
32
|
+
*/
|
|
33
|
+
export function prerenderedKey(pattern, component) {
|
|
34
|
+
return JSON.stringify([pattern, component]);
|
|
35
|
+
}
|
|
36
|
+
/** The routes (`prerenderedKey`) a D3 child's site build prerendered (`buildPreviewChildEnv`); none for any other child. */
|
|
37
|
+
export function previewChildPrerendered(env) {
|
|
38
|
+
const text = env[PREVIEW_PRERENDERED_ENV];
|
|
39
|
+
if (previewChildMode(env) !== 'd3' || text === undefined)
|
|
40
|
+
return new Set();
|
|
41
|
+
let value;
|
|
42
|
+
try {
|
|
43
|
+
value = JSON.parse(text);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return new Set();
|
|
47
|
+
}
|
|
48
|
+
return new Set(Array.isArray(value) ? value.filter((item) => typeof item === 'string') : []);
|
|
25
49
|
}
|
|
26
50
|
/**
|
|
27
51
|
* Pure constructor for the child-process environment passed to the recursive
|
|
@@ -33,11 +57,13 @@ export function previewBuildMode(previewBuild, adapterName) {
|
|
|
33
57
|
* build vars (CF_PAGES_*, WORKERS_CI_*, GITHUB_*) reach the child, which reads
|
|
34
58
|
* the branch and commit it serves from them.
|
|
35
59
|
*/
|
|
36
|
-
export function buildPreviewChildEnv(parentEnv) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
60
|
+
export function buildPreviewChildEnv(parentEnv, mode = 'd2', prerendered = []) {
|
|
61
|
+
const env = { ...parentEnv, [PREVIEW_BUILD_ENV_FLAG]: '1', [PREVIEW_MODE_ENV]: mode };
|
|
62
|
+
// Only a D3 child reads it; a stale one from the environment must not reach a D2 child.
|
|
63
|
+
delete env[PREVIEW_PRERENDERED_ENV];
|
|
64
|
+
if (mode === 'd3')
|
|
65
|
+
env[PREVIEW_PRERENDERED_ENV] = JSON.stringify(prerendered);
|
|
66
|
+
return env;
|
|
41
67
|
}
|
|
42
68
|
/**
|
|
43
69
|
* Locate the `astro` CLI binary in the site's `node_modules/.bin/`. We
|
|
@@ -81,8 +107,8 @@ export function resolveAstroBin(cwd = process.cwd()) {
|
|
|
81
107
|
* - `false` → resolves and logs a warning so onboarding setups can continue
|
|
82
108
|
* when the preview build is not yet wired correctly.
|
|
83
109
|
*/
|
|
84
|
-
export async function spawnPreviewBuild(opts) {
|
|
85
|
-
await _spawnPreviewBuildWith(spawn, opts);
|
|
110
|
+
export async function spawnPreviewBuild(opts, mode = 'd2', prerendered = []) {
|
|
111
|
+
await _spawnPreviewBuildWith(spawn, opts, mode, prerendered);
|
|
86
112
|
}
|
|
87
113
|
/**
|
|
88
114
|
* Internal seam that takes the spawn function as a parameter so tests can
|
|
@@ -93,7 +119,7 @@ export async function spawnPreviewBuild(opts) {
|
|
|
93
119
|
* `src/index.ts` or `src/node.ts`.
|
|
94
120
|
*/
|
|
95
121
|
// oxlint-disable-next-line no-underscore-dangle -- the internal test seam.
|
|
96
|
-
export async function _spawnPreviewBuildWith(spawnFn, opts) {
|
|
122
|
+
export async function _spawnPreviewBuildWith(spawnFn, opts, mode = 'd2', prerendered = []) {
|
|
97
123
|
// Recursion guard: bail out before doing any work if we're already inside
|
|
98
124
|
// a recursive preview build. This matches the short-circuit in the
|
|
99
125
|
// integration's `astro:build:done` hook.
|
|
@@ -103,7 +129,7 @@ export async function _spawnPreviewBuildWith(spawnFn, opts) {
|
|
|
103
129
|
const required = opts.required ?? true;
|
|
104
130
|
const astroBin = resolveAstroBin();
|
|
105
131
|
const child = spawnFn(astroBin, ['build'], {
|
|
106
|
-
env: buildPreviewChildEnv(process.env),
|
|
132
|
+
env: buildPreviewChildEnv(process.env, mode, prerendered),
|
|
107
133
|
stdio: 'inherit',
|
|
108
134
|
});
|
|
109
135
|
await new Promise((resolve, reject) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-build.js","sourceRoot":"","sources":["../../src/preview-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"preview-build.js","sourceRoot":"","sources":["../../src/preview-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,gBAAgB,CAAC;AAIxB;;;;;;GAMG;AACH,MA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,QAAQ,CAAC,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC;YACzD,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,YAAY,2BAA2B,MAAM,GAAG,CAAC,CAAC,CAAC;gBACvE,OAAO;YACT,CAAC;YACD,mEAAmE;YACnE,wEAAwE;YACxE,kEAAkE;YAClE,wDAAwD;YACxD,qEAAqE;YACrE,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,2BAA2B,MAAM,4CAA4C,CAAC,CAAC;YAC3G,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/src/skill.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare const SKILL_RELATIVE_PATH: string;
|
|
2
|
+
/** The sha256 of every unstamped page a release wrote, so an upgrade can tell an untouched old page from an edited one. */
|
|
3
|
+
export declare const LEGACY_SKILL_CHECKSUMS: readonly string[];
|
|
2
4
|
/**
|
|
3
5
|
* The canonical page, located from the package root (through the package's own `./package.json` export) so the
|
|
4
6
|
* built `dist/src/skill.js` and the source `src/skill.ts` reach the same shipped `src/skill/SKILL.md`. Resolved on
|
|
@@ -17,6 +19,15 @@ type SkillLogger = {
|
|
|
17
19
|
* root: a project outside any repository gets nothing.
|
|
18
20
|
*/
|
|
19
21
|
export declare function findClaudeHome(projectRoot: string): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Where the site's agent skill page belongs and the text this release writes there, stamped with the release and the
|
|
24
|
+
* template's checksum. Null without a `.claude/` home or a readable package version.
|
|
25
|
+
*/
|
|
26
|
+
export declare function agentSkill(projectRoot: string): {
|
|
27
|
+
path: string;
|
|
28
|
+
text: string;
|
|
29
|
+
legacyChecksums: readonly string[];
|
|
30
|
+
} | null;
|
|
20
31
|
/**
|
|
21
32
|
* Write the skill page once — never overwrite, never throw. A read-only CI
|
|
22
33
|
* checkout must not break a build over documentation.
|
package/dist/src/skill.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../src/skill.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../src/skill.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,mBAAmB,QAAyD,CAAC;AAE1F,2HAA2H;AAC3H,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAGnD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,GAAG,CAGtC;AAED,KAAK,WAAW,GAAG;IAAE,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAEzE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAYtE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,GAClB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG,IAAI,CAS3E;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAuBnH"}
|
package/dist/src/skill.js
CHANGED
|
@@ -2,8 +2,15 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { stampSkill } from '@conloca/content-api/skill-stamp';
|
|
5
6
|
import { messageOf } from './message-of.js';
|
|
7
|
+
import { packageVersion } from './package-version.js';
|
|
6
8
|
export const SKILL_RELATIVE_PATH = join('.claude', 'skills', 'conloca-cloud', 'SKILL.md');
|
|
9
|
+
/** The sha256 of every unstamped page a release wrote, so an upgrade can tell an untouched old page from an edited one. */
|
|
10
|
+
export const LEGACY_SKILL_CHECKSUMS = [
|
|
11
|
+
'201dc9a1fe57038c32a46448228ab432cce060b0079225007ec6dec74ba46959', // 0.2.1, 0.2.2
|
|
12
|
+
'82edfffa022797265bee87289a491e7af12d8e13423f541892e281c416f0554a', // 0.2.3
|
|
13
|
+
];
|
|
7
14
|
/**
|
|
8
15
|
* The canonical page, located from the package root (through the package's own `./package.json` export) so the
|
|
9
16
|
* built `dist/src/skill.js` and the source `src/skill.ts` reach the same shipped `src/skill/SKILL.md`. Resolved on
|
|
@@ -36,22 +43,38 @@ export function findClaudeHome(projectRoot) {
|
|
|
36
43
|
dir = parent;
|
|
37
44
|
}
|
|
38
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Where the site's agent skill page belongs and the text this release writes there, stamped with the release and the
|
|
48
|
+
* template's checksum. Null without a `.claude/` home or a readable package version.
|
|
49
|
+
*/
|
|
50
|
+
export function agentSkill(projectRoot) {
|
|
51
|
+
const home = findClaudeHome(projectRoot);
|
|
52
|
+
const version = packageVersion();
|
|
53
|
+
if (home === undefined || version === undefined)
|
|
54
|
+
return null;
|
|
55
|
+
return {
|
|
56
|
+
path: join(home, SKILL_RELATIVE_PATH),
|
|
57
|
+
text: stampSkill(readFileSync(skillTemplateUrl(), 'utf8'), version),
|
|
58
|
+
legacyChecksums: LEGACY_SKILL_CHECKSUMS,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
39
61
|
/**
|
|
40
62
|
* Write the skill page once — never overwrite, never throw. A read-only CI
|
|
41
63
|
* checkout must not break a build over documentation.
|
|
42
64
|
*/
|
|
43
65
|
export function scaffoldSkill(projectRoot, logger) {
|
|
44
|
-
|
|
45
|
-
if (home === undefined) {
|
|
46
|
-
logger.debug('no .claude/ directory between the project and the git root — agent skill not scaffolded');
|
|
47
|
-
return 'skipped';
|
|
48
|
-
}
|
|
49
|
-
const target = join(home, SKILL_RELATIVE_PATH);
|
|
50
|
-
if (existsSync(target))
|
|
51
|
-
return 'exists';
|
|
66
|
+
let target = SKILL_RELATIVE_PATH;
|
|
52
67
|
try {
|
|
68
|
+
const skill = agentSkill(projectRoot);
|
|
69
|
+
if (skill === null) {
|
|
70
|
+
logger.debug('no .claude/ directory between the project and the git root, or no readable package version — agent skill not scaffolded');
|
|
71
|
+
return 'skipped';
|
|
72
|
+
}
|
|
73
|
+
target = skill.path;
|
|
74
|
+
if (existsSync(target))
|
|
75
|
+
return 'exists';
|
|
53
76
|
mkdirSync(dirname(target), { recursive: true });
|
|
54
|
-
writeFileSync(target,
|
|
77
|
+
writeFileSync(target, skill.text, { flag: 'wx' });
|
|
55
78
|
logger.info(`agent skill written to ${target}`);
|
|
56
79
|
return 'written';
|
|
57
80
|
}
|
package/dist/src/skill.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill.js","sourceRoot":"","sources":["../../src/skill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"skill.js","sourceRoot":"","sources":["../../src/skill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EA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,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAC;QACxE,MAAM,CAAC,IAAI,CAAC,8BAA8B,MAAM,KAAK,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1E,OAAO,QAAQ,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import type { AstroIntegration } from 'astro';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Off unless given as an object: the second build that serves draft previews.
|
|
8
|
-
* It needs an SSR adapter (the project's own or `adapter` here) and is refused
|
|
9
|
-
* under `@astrojs/vercel` and `@astrojs/netlify`.
|
|
3
|
+
* The second build that serves draft previews. Off unless given as an object. A static site's preview server runs on
|
|
4
|
+
* Cloudflare Workers under `/_conloca/preview/` next to the site (it needs `@astrojs/cloudflare` installed); a site
|
|
5
|
+
* with an adapter serves drafts from its own server deploy; `separate: true` builds a separate preview deploy.
|
|
6
|
+
* Refused under `@astrojs/vercel` and `@astrojs/netlify`.
|
|
10
7
|
*/
|
|
11
8
|
export interface PreviewBuildOptions {
|
|
12
9
|
/**
|
|
@@ -25,10 +22,17 @@ export interface PreviewBuildOptions {
|
|
|
25
22
|
*/
|
|
26
23
|
outDir?: string;
|
|
27
24
|
/**
|
|
28
|
-
* If true, fail the
|
|
29
|
-
*
|
|
25
|
+
* If true, fail the site's build when a D2 preview build fails. Defaults to true; set false while setting up.
|
|
26
|
+
* A failed D3 preview build fails the site's build only when its server also serves the live site (`run_worker_first`
|
|
27
|
+
* lists routes beyond the preview route, or `not_found_handling` is `"none"`); otherwise the site ships and its
|
|
28
|
+
* preview route answers "preview unavailable". This option changes neither.
|
|
30
29
|
*/
|
|
31
30
|
required?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Serve previews from a separate deploy (D4) instead of next to the site. The site's build then runs no preview
|
|
33
|
+
* build; a second deploy builds with `CONLOCA_PREVIEW_BUILD=1`, and its address goes in sites.json `previewUrl`.
|
|
34
|
+
*/
|
|
35
|
+
separate?: boolean;
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* Options accepted by {@link conlocaCloud}. Every one is optional: repository
|
|
@@ -78,9 +82,8 @@ export interface ConlocaCloudOptions {
|
|
|
78
82
|
*/
|
|
79
83
|
previewBuild?: PreviewBuildOptions | false;
|
|
80
84
|
/**
|
|
81
|
-
* The token issuer (the JWT `iss` the preview
|
|
82
|
-
*
|
|
83
|
-
* deployment must supply `CONLOCA_SAAS_ISSUER` at runtime.
|
|
85
|
+
* The token issuer (the JWT `iss`) every pass must name. Unset, the preview server checks the pass against the
|
|
86
|
+
* endpoint's published keys alone, so a site sets nothing at runtime; set it (or `CONLOCA_SAAS_ISSUER`) to pin it.
|
|
84
87
|
*/
|
|
85
88
|
saasIssuer?: string;
|
|
86
89
|
}
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,mBAAmB,GAAG,KAAK,CAAC;IAC3C;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conloca/cloud-astro",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -43,6 +43,11 @@
|
|
|
43
43
|
"import": "./dist/src/site-middleware.js",
|
|
44
44
|
"default": "./dist/src/site-middleware.js"
|
|
45
45
|
},
|
|
46
|
+
"./dispatcher": {
|
|
47
|
+
"types": "./dist/src/preview/dispatcher.d.ts",
|
|
48
|
+
"import": "./dist/src/preview/dispatcher.js",
|
|
49
|
+
"default": "./dist/src/preview/dispatcher.js"
|
|
50
|
+
},
|
|
46
51
|
"./doctor": {
|
|
47
52
|
"types": "./dist/src/doctor.d.ts",
|
|
48
53
|
"import": "./dist/src/doctor.js",
|
|
@@ -69,15 +74,16 @@
|
|
|
69
74
|
},
|
|
70
75
|
"peerDependencies": {
|
|
71
76
|
"@astrojs/react": "^6.0.5",
|
|
72
|
-
"@conloca/astro-cms": "0.2.
|
|
77
|
+
"@conloca/astro-cms": "0.2.4",
|
|
73
78
|
"astro": "^7.3.1",
|
|
74
79
|
"vite": "^8.2.2"
|
|
75
80
|
},
|
|
76
81
|
"dependencies": {
|
|
77
|
-
"@conloca/content-api": "0.2.
|
|
78
|
-
"@conloca/mdx": "0.2.
|
|
82
|
+
"@conloca/content-api": "0.2.4",
|
|
83
|
+
"@conloca/mdx": "0.2.4",
|
|
79
84
|
"hast-util-from-html": "^2.0.3",
|
|
80
85
|
"jose": "^6.2.10",
|
|
86
|
+
"jsonc-parser": "^3.3.1",
|
|
81
87
|
"sass": "^1.103.1",
|
|
82
88
|
"tslib": "^2.8.1"
|
|
83
89
|
},
|
|
@@ -85,7 +91,7 @@
|
|
|
85
91
|
"@astrojs/check": "^0.9.10",
|
|
86
92
|
"@astrojs/cloudflare": "14.3.2",
|
|
87
93
|
"@astrojs/sitemap": "^3.7.3",
|
|
88
|
-
"@conloca/astro-cms": "0.2.
|
|
94
|
+
"@conloca/astro-cms": "0.2.4",
|
|
89
95
|
"astro": "^7.3.1",
|
|
90
96
|
"typescript": "^6.0.3",
|
|
91
97
|
"vite": "^8.2.2",
|
|
@@ -103,7 +109,6 @@
|
|
|
103
109
|
"npm:public"
|
|
104
110
|
],
|
|
105
111
|
"targets": {
|
|
106
|
-
"clean": {},
|
|
107
112
|
"lint": {},
|
|
108
113
|
"typecheck": {
|
|
109
114
|
"dependsOn": [
|
|
@@ -148,7 +153,8 @@
|
|
|
148
153
|
"typecheck-tests",
|
|
149
154
|
"build",
|
|
150
155
|
"test-packed",
|
|
151
|
-
"test-editor-build"
|
|
156
|
+
"test-editor-build",
|
|
157
|
+
"test-preview-build"
|
|
152
158
|
],
|
|
153
159
|
"inputs": [
|
|
154
160
|
"{projectRoot}/**/*",
|
|
@@ -181,6 +187,26 @@
|
|
|
181
187
|
"killAfterMs": 10000
|
|
182
188
|
}
|
|
183
189
|
},
|
|
190
|
+
"test-preview-build": {
|
|
191
|
+
"//": "Real D3 and D4 builds (each runs the preview build too), a dry-run deploy and a local Cloudflare Worker: the slowest lane, with its own budget.",
|
|
192
|
+
"executor": "@smoothbricks/nx-plugin:bounded-exec",
|
|
193
|
+
"cache": true,
|
|
194
|
+
"inputs": [
|
|
195
|
+
"default",
|
|
196
|
+
"^production",
|
|
197
|
+
"{workspaceRoot}/bun.lock"
|
|
198
|
+
],
|
|
199
|
+
"dependsOn": [
|
|
200
|
+
"build",
|
|
201
|
+
"^build"
|
|
202
|
+
],
|
|
203
|
+
"options": {
|
|
204
|
+
"command": "bun test --timeout=600000 ./test-preview-build",
|
|
205
|
+
"cwd": "{projectRoot}",
|
|
206
|
+
"timeoutMs": 900000,
|
|
207
|
+
"killAfterMs": 10000
|
|
208
|
+
}
|
|
209
|
+
},
|
|
184
210
|
"test-packed": {
|
|
185
211
|
"//": "The packed shape is a function of the built outputs, the manifest and the locked dependency closure; cached on exactly those.",
|
|
186
212
|
"executor": "nx:run-commands",
|
package/src/constants.ts
CHANGED
|
@@ -5,12 +5,23 @@
|
|
|
5
5
|
export const PACKAGE_NAME = '@conloca/cloud-astro';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Environment variable that the
|
|
9
|
-
*
|
|
10
|
-
* it and skip the editor page and further recursion.
|
|
8
|
+
* Environment variable that makes a build the preview server: the site's build sets it on the child build it starts,
|
|
9
|
+
* and a separate preview deploy (D4) builds with it set.
|
|
11
10
|
*/
|
|
12
11
|
export const PREVIEW_BUILD_ENV_FLAG = 'CONLOCA_PREVIEW_BUILD';
|
|
13
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Environment variable the site's build names the child's mode in (`d2` or `d3`). A build started with
|
|
15
|
+
* {@link PREVIEW_BUILD_ENV_FLAG} alone, as a separate preview deploy runs it, has none: it is D4.
|
|
16
|
+
*/
|
|
17
|
+
export const PREVIEW_MODE_ENV = 'CONLOCA_PREVIEW_MODE';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Environment variable the site's build names, for a D3 child, the routes it prerendered (a JSON list of their
|
|
21
|
+
* components): the child keeps exactly those prerendered, and every other route keeps its own setting.
|
|
22
|
+
*/
|
|
23
|
+
export const PREVIEW_PRERENDERED_ENV = 'CONLOCA_PREVIEW_PRERENDERED';
|
|
24
|
+
|
|
14
25
|
/**
|
|
15
26
|
* Adapters the preview build is refused under: they write their deployable
|
|
16
27
|
* output at the project root whatever `outDir` says, so the preview build
|