@conloca/cloud-astro 0.0.0-stage → 0.2.2
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 +328 -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 +181 -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 +544 -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 +55 -0
- package/dist/src/preview/_dispatch.d.ts.map +1 -0
- package/dist/src/preview/_dispatch.js +72 -0
- package/dist/src/preview/_dispatch.js.map +1 -0
- package/dist/src/preview/_resolve-opts.d.ts +30 -0
- package/dist/src/preview/_resolve-opts.d.ts.map +1 -0
- package/dist/src/preview/_resolve-opts.js +73 -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 +118 -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 +160 -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 +135 -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 +182 -4
- package/src/build-commit.ts +22 -0
- package/src/bundle.ts +570 -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 +607 -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 +105 -0
- package/src/preview/_resolve-opts.ts +89 -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 +309 -0
- package/src/preview/preview-path.ts +28 -0
- package/src/preview/satteri-workerd.ts +24 -0
- package/src/preview/site-middleware.ts +210 -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 +137 -0
- package/src/virtual-modules.d.ts +52 -0
package/src/git.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { detectRepositoryUri, type RepositoryEnvironment } from './repository.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Runs `git <args>` and returns trimmed stdout, or undefined when git is
|
|
6
|
+
* unavailable or the directory is not a checkout (e.g. tarball-based CI).
|
|
7
|
+
* `cwd` names the checkout to ask; without it git resolves against the
|
|
8
|
+
* process's own directory, which is the build's project but NOT the doctor's.
|
|
9
|
+
*/
|
|
10
|
+
export function gitOutput(args: string[], cwd?: string): string | undefined {
|
|
11
|
+
try {
|
|
12
|
+
const output = execFileSync('git', args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], cwd }).trim();
|
|
13
|
+
return output === '' ? undefined : output;
|
|
14
|
+
} catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The resolved pair. An empty commit variable is passed through unchanged
|
|
21
|
+
* (`CF_PAGES_COMMIT_SHA=''` yields `gitSha: ''`); callers treat a falsy value
|
|
22
|
+
* as unresolved, exactly as the build hook's guard does. An empty BRANCH
|
|
23
|
+
* variable counts as unset instead: GitHub Actions exports GITHUB_HEAD_REF=''
|
|
24
|
+
* on every push build, which would otherwise hide GITHUB_REF_NAME.
|
|
25
|
+
*/
|
|
26
|
+
interface BuildRef {
|
|
27
|
+
gitSha?: string;
|
|
28
|
+
branch?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The commit and branch this checkout stands on — the pair a registration is
|
|
33
|
+
* keyed by. CI metadata first, most-specific source per provider. GitHub
|
|
34
|
+
* Actions checkouts are DETACHED, so the git fallback returns the literal
|
|
35
|
+
* 'HEAD' there — GITHUB_HEAD_REF (PR builds) / GITHUB_REF_NAME cover that
|
|
36
|
+
* case, and a surviving literal 'HEAD' is treated as unresolvable: a
|
|
37
|
+
* registration under branch 'HEAD' would never match the editor's
|
|
38
|
+
* branch-keyed lookup, silently registering dead weight.
|
|
39
|
+
*/
|
|
40
|
+
export function resolveBuildRef(
|
|
41
|
+
env: RepositoryEnvironment = process.env,
|
|
42
|
+
git: (args: string[]) => string | undefined = gitOutput,
|
|
43
|
+
): BuildRef {
|
|
44
|
+
const gitSha = env.CF_PAGES_COMMIT_SHA ?? git(['rev-parse', 'HEAD']);
|
|
45
|
+
const rawBranch =
|
|
46
|
+
env.CF_PAGES_BRANCH || env.GITHUB_HEAD_REF || env.GITHUB_REF_NAME || git(['rev-parse', '--abbrev-ref', 'HEAD']);
|
|
47
|
+
const branch = rawBranch === 'HEAD' ? undefined : rawBranch;
|
|
48
|
+
return { ...(gitSha === undefined ? {} : { gitSha }), ...(branch === undefined ? {} : { branch }) };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The repository a registration is filed under: the explicit option and CI
|
|
53
|
+
* metadata are free to read; git is spawned ONLY when neither resolved it.
|
|
54
|
+
* Config loading is a hot path in Astro and must not start a subprocess on
|
|
55
|
+
* every integration instance.
|
|
56
|
+
*/
|
|
57
|
+
export function resolveRepositoryUri(
|
|
58
|
+
explicit: string | undefined,
|
|
59
|
+
env: RepositoryEnvironment,
|
|
60
|
+
git: (args: string[]) => string | undefined = gitOutput,
|
|
61
|
+
): string | undefined {
|
|
62
|
+
return (
|
|
63
|
+
detectRepositoryUri({ explicit, env }) ??
|
|
64
|
+
detectRepositoryUri({ env: {}, remote: git(['config', '--get', 'remote.origin.url']) })
|
|
65
|
+
);
|
|
66
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Public surface for `@conloca/cloud-astro` — the site's Astro
|
|
2
|
+
// integration. The build pipeline (editor-bundle compile + registration POST)
|
|
3
|
+
// runs from `astro:build:done`; the preview modules serve draft pages out of
|
|
4
|
+
// the recursive preview build and read their content through
|
|
5
|
+
// `PreviewContentAPI`.
|
|
6
|
+
|
|
7
|
+
export { conlocaCloud, PACKAGE_NAME, PREVIEW_BUILD_ENV_FLAG } from './integration.js';
|
|
8
|
+
export type { ConlocaCloudOptions, PreviewBuildOptions } from './types.js';
|