@conloca/cloud-astro 0.0.0-bootstrap.0 → 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.
Files changed (196) hide show
  1. package/README.md +327 -2
  2. package/dist/src/build-commit.d.ts +19 -0
  3. package/dist/src/build-commit.d.ts.map +1 -0
  4. package/dist/src/build-commit.js +6 -0
  5. package/dist/src/build-commit.js.map +1 -0
  6. package/dist/src/bundle.d.ts +173 -0
  7. package/dist/src/bundle.d.ts.map +1 -0
  8. package/dist/src/bundle.js +413 -0
  9. package/dist/src/bundle.js.map +1 -0
  10. package/dist/src/component-manifest.d.ts +29 -0
  11. package/dist/src/component-manifest.d.ts.map +1 -0
  12. package/dist/src/component-manifest.js +53 -0
  13. package/dist/src/component-manifest.js.map +1 -0
  14. package/dist/src/constants.d.ts +26 -0
  15. package/dist/src/constants.d.ts.map +1 -0
  16. package/dist/src/constants.js +26 -0
  17. package/dist/src/constants.js.map +1 -0
  18. package/dist/src/descriptors.d.ts +25 -0
  19. package/dist/src/descriptors.d.ts.map +1 -0
  20. package/dist/src/descriptors.js +65 -0
  21. package/dist/src/descriptors.js.map +1 -0
  22. package/dist/src/discovery.d.ts +58 -0
  23. package/dist/src/discovery.d.ts.map +1 -0
  24. package/dist/src/discovery.js +133 -0
  25. package/dist/src/discovery.js.map +1 -0
  26. package/dist/src/doctor/checks-live.d.ts +15 -0
  27. package/dist/src/doctor/checks-live.d.ts.map +1 -0
  28. package/dist/src/doctor/checks-live.js +229 -0
  29. package/dist/src/doctor/checks-live.js.map +1 -0
  30. package/dist/src/doctor/checks-offline.d.ts +36 -0
  31. package/dist/src/doctor/checks-offline.d.ts.map +1 -0
  32. package/dist/src/doctor/checks-offline.js +301 -0
  33. package/dist/src/doctor/checks-offline.js.map +1 -0
  34. package/dist/src/doctor/config-scan.d.ts +55 -0
  35. package/dist/src/doctor/config-scan.d.ts.map +1 -0
  36. package/dist/src/doctor/config-scan.js +178 -0
  37. package/dist/src/doctor/config-scan.js.map +1 -0
  38. package/dist/src/doctor/run.d.ts +4 -0
  39. package/dist/src/doctor/run.d.ts.map +1 -0
  40. package/dist/src/doctor/run.js +29 -0
  41. package/dist/src/doctor/run.js.map +1 -0
  42. package/dist/src/doctor/types.d.ts +60 -0
  43. package/dist/src/doctor/types.d.ts.map +1 -0
  44. package/dist/src/doctor/types.js +18 -0
  45. package/dist/src/doctor/types.js.map +1 -0
  46. package/dist/src/doctor.d.ts +9 -0
  47. package/dist/src/doctor.d.ts.map +1 -0
  48. package/dist/src/doctor.js +12 -0
  49. package/dist/src/doctor.js.map +1 -0
  50. package/dist/src/git.d.ts +38 -0
  51. package/dist/src/git.d.ts.map +1 -0
  52. package/dist/src/git.js +43 -0
  53. package/dist/src/git.js.map +1 -0
  54. package/dist/src/index.d.ts +3 -0
  55. package/dist/src/index.d.ts.map +1 -0
  56. package/dist/src/index.js +7 -0
  57. package/dist/src/index.js.map +1 -0
  58. package/dist/src/integration.d.ts +6 -0
  59. package/dist/src/integration.d.ts.map +1 -0
  60. package/dist/src/integration.js +532 -0
  61. package/dist/src/integration.js.map +1 -0
  62. package/dist/src/message-of.d.ts +3 -0
  63. package/dist/src/message-of.d.ts.map +1 -0
  64. package/dist/src/message-of.js +5 -0
  65. package/dist/src/message-of.js.map +1 -0
  66. package/dist/src/node.d.ts +3 -0
  67. package/dist/src/node.d.ts.map +1 -0
  68. package/dist/src/node.js +4 -0
  69. package/dist/src/node.js.map +1 -0
  70. package/dist/src/package-version.d.ts +7 -0
  71. package/dist/src/package-version.d.ts.map +1 -0
  72. package/dist/src/package-version.js +17 -0
  73. package/dist/src/package-version.js.map +1 -0
  74. package/dist/src/preview/_dispatch.d.ts +52 -0
  75. package/dist/src/preview/_dispatch.d.ts.map +1 -0
  76. package/dist/src/preview/_dispatch.js +70 -0
  77. package/dist/src/preview/_dispatch.js.map +1 -0
  78. package/dist/src/preview/_resolve-opts.d.ts +28 -0
  79. package/dist/src/preview/_resolve-opts.d.ts.map +1 -0
  80. package/dist/src/preview/_resolve-opts.js +70 -0
  81. package/dist/src/preview/_resolve-opts.js.map +1 -0
  82. package/dist/src/preview/banner.d.ts +29 -0
  83. package/dist/src/preview/banner.d.ts.map +1 -0
  84. package/dist/src/preview/banner.js +94 -0
  85. package/dist/src/preview/banner.js.map +1 -0
  86. package/dist/src/preview/content-api.d.ts +110 -0
  87. package/dist/src/preview/content-api.d.ts.map +1 -0
  88. package/dist/src/preview/content-api.js +216 -0
  89. package/dist/src/preview/content-api.js.map +1 -0
  90. package/dist/src/preview/cookie.d.ts +36 -0
  91. package/dist/src/preview/cookie.d.ts.map +1 -0
  92. package/dist/src/preview/cookie.js +59 -0
  93. package/dist/src/preview/cookie.js.map +1 -0
  94. package/dist/src/preview/headers.d.ts +25 -0
  95. package/dist/src/preview/headers.d.ts.map +1 -0
  96. package/dist/src/preview/headers.js +31 -0
  97. package/dist/src/preview/headers.js.map +1 -0
  98. package/dist/src/preview/landing.d.ts +22 -0
  99. package/dist/src/preview/landing.d.ts.map +1 -0
  100. package/dist/src/preview/landing.js +70 -0
  101. package/dist/src/preview/landing.js.map +1 -0
  102. package/dist/src/preview/middleware.d.ts +112 -0
  103. package/dist/src/preview/middleware.d.ts.map +1 -0
  104. package/dist/src/preview/middleware.js +197 -0
  105. package/dist/src/preview/middleware.js.map +1 -0
  106. package/dist/src/preview/preview-path.d.ts +21 -0
  107. package/dist/src/preview/preview-path.d.ts.map +1 -0
  108. package/dist/src/preview/preview-path.js +29 -0
  109. package/dist/src/preview/preview-path.js.map +1 -0
  110. package/dist/src/preview/satteri-workerd.d.ts +17 -0
  111. package/dist/src/preview/satteri-workerd.d.ts.map +1 -0
  112. package/dist/src/preview/satteri-workerd.js +18 -0
  113. package/dist/src/preview/satteri-workerd.js.map +1 -0
  114. package/dist/src/preview/site-middleware.d.ts +69 -0
  115. package/dist/src/preview/site-middleware.d.ts.map +1 -0
  116. package/dist/src/preview/site-middleware.js +159 -0
  117. package/dist/src/preview/site-middleware.js.map +1 -0
  118. package/dist/src/preview/workerd-shim.d.ts +19 -0
  119. package/dist/src/preview/workerd-shim.d.ts.map +1 -0
  120. package/dist/src/preview/workerd-shim.js +33 -0
  121. package/dist/src/preview/workerd-shim.js.map +1 -0
  122. package/dist/src/preview-build.d.ts +71 -0
  123. package/dist/src/preview-build.d.ts.map +1 -0
  124. package/dist/src/preview-build.js +115 -0
  125. package/dist/src/preview-build.js.map +1 -0
  126. package/dist/src/preview.d.ts +6 -0
  127. package/dist/src/preview.d.ts.map +1 -0
  128. package/dist/src/preview.js +12 -0
  129. package/dist/src/preview.js.map +1 -0
  130. package/dist/src/register.d.ts +98 -0
  131. package/dist/src/register.d.ts.map +1 -0
  132. package/dist/src/register.js +103 -0
  133. package/dist/src/register.js.map +1 -0
  134. package/dist/src/repository.d.ts +18 -0
  135. package/dist/src/repository.d.ts.map +1 -0
  136. package/dist/src/repository.js +46 -0
  137. package/dist/src/repository.js.map +1 -0
  138. package/dist/src/site-id.d.ts +18 -0
  139. package/dist/src/site-id.d.ts.map +1 -0
  140. package/dist/src/site-id.js +70 -0
  141. package/dist/src/site-id.js.map +1 -0
  142. package/dist/src/site-middleware.d.ts +18 -0
  143. package/dist/src/site-middleware.d.ts.map +1 -0
  144. package/dist/src/site-middleware.js +47 -0
  145. package/dist/src/site-middleware.js.map +1 -0
  146. package/dist/src/skill.d.ts +26 -0
  147. package/dist/src/skill.d.ts.map +1 -0
  148. package/dist/src/skill.js +67 -0
  149. package/dist/src/skill.js.map +1 -0
  150. package/dist/src/types.d.ts +125 -0
  151. package/dist/src/types.d.ts.map +1 -0
  152. package/dist/src/types.js +2 -0
  153. package/dist/src/types.js.map +1 -0
  154. package/package.json +170 -5
  155. package/src/build-commit.ts +22 -0
  156. package/src/bundle.ts +563 -0
  157. package/src/component-manifest.ts +75 -0
  158. package/src/constants.ts +28 -0
  159. package/src/descriptors.ts +92 -0
  160. package/src/discovery.ts +183 -0
  161. package/src/doctor/checks-live.ts +324 -0
  162. package/src/doctor/checks-offline.ts +325 -0
  163. package/src/doctor/config-scan.ts +205 -0
  164. package/src/doctor/run.ts +39 -0
  165. package/src/doctor/types.ts +71 -0
  166. package/src/doctor.ts +14 -0
  167. package/src/git.ts +66 -0
  168. package/src/index.ts +8 -0
  169. package/src/integration.ts +595 -0
  170. package/src/message-of.ts +4 -0
  171. package/src/node.ts +5 -0
  172. package/src/package-version.ts +16 -0
  173. package/src/preview/_dispatch.ts +101 -0
  174. package/src/preview/_resolve-opts.ts +84 -0
  175. package/src/preview/banner.ts +96 -0
  176. package/src/preview/content-api.ts +293 -0
  177. package/src/preview/cookie.ts +54 -0
  178. package/src/preview/headers.ts +30 -0
  179. package/src/preview/landing.ts +73 -0
  180. package/src/preview/middleware.ts +303 -0
  181. package/src/preview/preview-path.ts +28 -0
  182. package/src/preview/satteri-workerd.ts +24 -0
  183. package/src/preview/site-middleware.ts +209 -0
  184. package/src/preview/workerd-shim.ts +31 -0
  185. package/src/preview-build.ts +147 -0
  186. package/src/preview-handler.astro +55 -0
  187. package/src/preview-handler.d.ts +6 -0
  188. package/src/preview.ts +22 -0
  189. package/src/register.ts +180 -0
  190. package/src/repository.ts +54 -0
  191. package/src/site-id.ts +86 -0
  192. package/src/site-middleware.ts +55 -0
  193. package/src/skill/SKILL.md +69 -0
  194. package/src/skill.ts +66 -0
  195. package/src/types.ts +127 -0
  196. package/src/virtual-modules.d.ts +51 -0
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Astro middleware entrypoint for the recursive preview build.
3
+ *
4
+ * `addMiddleware({ entrypoint: '@conloca/cloud-astro/site-middleware' })` in
5
+ * the integration resolves to this module, so it must export `onRequest` —
6
+ * Astro's middleware contract. The verdict/render logic lives in
7
+ * `./preview/site-middleware.ts`, which is env-free and unit-testable; this
8
+ * file binds it to the runtime env resolution and to the site's own build
9
+ * graph: `astro:content` and the routing-config virtual module only resolve
10
+ * here, so the collection-backed baseline is constructed here and injected as
11
+ * a seam.
12
+ *
13
+ * Mounted ONLY inside the preview build (see `integration.ts`), never in the
14
+ * site's production build.
15
+ */
16
+ import { getCollection } from 'astro:content';
17
+ import baked from 'virtual:conloca-preview-opts';
18
+ import routingConfig from 'virtual:conloca-routing-config';
19
+ import { createCollectionBackedContentAPI } from '@conloca/astro-cms';
20
+ import { resolveEndpointFetch, resolveFromBaked } from './preview/_resolve-opts.js';
21
+ import { createPreviewSiteMiddleware, } from './preview/site-middleware.js';
22
+ import { untagWorkerdProcess } from './preview/workerd-shim.js';
23
+ // At Cloudflare Worker start-up, before any render: workerd's nodejs_compat
24
+ // process can masquerade as Node's, sending Astro down a streaming branch whose
25
+ // body the Cloudflare Workers Response cannot consume — every on-demand page then renders as the
26
+ // literal string "[object Object]". See the shim's doc for the full chain.
27
+ untagWorkerdProcess();
28
+ // One baseline per process: the built collections are immutable at runtime,
29
+ // and constructing the collection-backed reader walks every collection.
30
+ let baselinePromise;
31
+ function baselineApi() {
32
+ baselinePromise ??= createCollectionBackedContentAPI({
33
+ getCollection: (name) => getCollection(name),
34
+ routing: routingConfig,
35
+ });
36
+ return baselinePromise;
37
+ }
38
+ export async function onRequest(context, next) {
39
+ const handler = createPreviewSiteMiddleware(() => resolveFromBaked(baked, (name) => process.env[name]), {
40
+ baselineApi,
41
+ site: routingConfig.siteName,
42
+ locale: routingConfig.locale,
43
+ fetchFn: await resolveEndpointFetch(),
44
+ });
45
+ return handler(context, next);
46
+ }
47
+ //# sourceMappingURL=site-middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-middleware.js","sourceRoot":"","sources":["../../src/site-middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,MAAM,8BAA8B,CAAC;AACjD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACpF,OAAO,EACL,2BAA2B,GAG5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,4EAA4E;AAC5E,gFAAgF;AAChF,iGAAiG;AACjG,2EAA2E;AAC3E,mBAAmB,EAAE,CAAC;AAEtB,4EAA4E;AAC5E,wEAAwE;AACxE,IAAI,eAAgD,CAAC;AACrD,SAAS,WAAW;IAClB,eAAe,KAAK,gCAAgC,CAAC;QACnD,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC;QAC5C,OAAO,EAAE,aAAa;KACvB,CAAC,CAAC;IACH,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAiC,EAAE,IAA2B;IAC5F,MAAM,OAAO,GAAG,2BAA2B,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;QACtG,WAAW;QACX,IAAI,EAAE,aAAa,CAAC,QAAQ;QAC5B,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,OAAO,EAAE,MAAM,oBAAoB,EAAE;KACtC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,26 @@
1
+ export declare const SKILL_RELATIVE_PATH: string;
2
+ /**
3
+ * The canonical page, located from the package root (through the package's own `./package.json` export) so the
4
+ * built `dist/src/skill.js` and the source `src/skill.ts` reach the same shipped `src/skill/SKILL.md`. Resolved on
5
+ * demand, not at import: a copy running outside its package boundary must fail inside scaffoldSkill's
6
+ * fail-soft path, never while the site's Astro config is loading.
7
+ */
8
+ export declare function skillTemplateUrl(): URL;
9
+ type SkillLogger = {
10
+ info(msg: string): void;
11
+ debug(msg: string): void;
12
+ };
13
+ /**
14
+ * The nearest directory, from the Astro project root up to the git root, that
15
+ * carries a `.claude/`. Repo-root layouts are the real ones: a site's
16
+ * Astro project is usually a workspace member below the repo root. Needs a git
17
+ * root: a project outside any repository gets nothing.
18
+ */
19
+ export declare function findClaudeHome(projectRoot: string): string | undefined;
20
+ /**
21
+ * Write the skill page once — never overwrite, never throw. A read-only CI
22
+ * checkout must not break a build over documentation.
23
+ */
24
+ export declare function scaffoldSkill(projectRoot: string, logger: SkillLogger): 'written' | 'exists' | 'skipped' | 'failed';
25
+ export {};
26
+ //# sourceMappingURL=skill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../src/skill.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,mBAAmB,QAAyD,CAAC;AAE1F;;;;;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,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAoBnH"}
@@ -0,0 +1,67 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
+ import { createRequire } from 'node:module';
3
+ import { dirname, join } from 'node:path';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { messageOf } from './message-of.js';
6
+ export const SKILL_RELATIVE_PATH = join('.claude', 'skills', 'conloca-cloud', 'SKILL.md');
7
+ /**
8
+ * The canonical page, located from the package root (through the package's own `./package.json` export) so the
9
+ * built `dist/src/skill.js` and the source `src/skill.ts` reach the same shipped `src/skill/SKILL.md`. Resolved on
10
+ * demand, not at import: a copy running outside its package boundary must fail inside scaffoldSkill's
11
+ * fail-soft path, never while the site's Astro config is loading.
12
+ */
13
+ export function skillTemplateUrl() {
14
+ const packageRoot = dirname(createRequire(import.meta.url).resolve('@conloca/cloud-astro/package.json'));
15
+ return pathToFileURL(join(packageRoot, 'src', 'skill', 'SKILL.md'));
16
+ }
17
+ /**
18
+ * The nearest directory, from the Astro project root up to the git root, that
19
+ * carries a `.claude/`. Repo-root layouts are the real ones: a site's
20
+ * Astro project is usually a workspace member below the repo root. Needs a git
21
+ * root: a project outside any repository gets nothing.
22
+ */
23
+ export function findClaudeHome(projectRoot) {
24
+ let dir = projectRoot;
25
+ let home;
26
+ for (;;) {
27
+ if (home === undefined && existsSync(join(dir, '.claude')))
28
+ home = dir;
29
+ // The git root bounds the walk; without one there is no repo to scaffold into
30
+ // (a stray ~/.claude must never receive a global copy).
31
+ if (existsSync(join(dir, '.git')))
32
+ return home;
33
+ const parent = dirname(dir);
34
+ if (parent === dir)
35
+ return undefined;
36
+ dir = parent;
37
+ }
38
+ }
39
+ /**
40
+ * Write the skill page once — never overwrite, never throw. A read-only CI
41
+ * checkout must not break a build over documentation.
42
+ */
43
+ export function scaffoldSkill(projectRoot, logger) {
44
+ const home = findClaudeHome(projectRoot);
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';
52
+ try {
53
+ mkdirSync(dirname(target), { recursive: true });
54
+ writeFileSync(target, readFileSync(skillTemplateUrl(), 'utf8'), { flag: 'wx' });
55
+ logger.info(`agent skill written to ${target}`);
56
+ return 'written';
57
+ }
58
+ catch (error) {
59
+ // The exclusive write lost a race with a concurrent build (or a symlink sits
60
+ // at the path): the page is there, which is the truthful outcome.
61
+ if (error.code === 'EEXIST')
62
+ return 'exists';
63
+ logger.info(`agent skill not written to ${target} (${messageOf(error)})`);
64
+ return 'failed';
65
+ }
66
+ }
67
+ //# sourceMappingURL=skill.js.map
@@ -0,0 +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;AAE5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC;AAE1F;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAC,CAAC;IACzG,OAAO,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AACtE,CAAC;AAID;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,WAAmB;IAChD,IAAI,GAAG,GAAG,WAAW,CAAC;IACtB,IAAI,IAAwB,CAAC;IAC7B,SAAS,CAAC;QACR,IAAI,IAAI,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAAE,IAAI,GAAG,GAAG,CAAC;QACvE,8EAA8E;QAC9E,wDAAwD;QACxD,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QAC/C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,OAAO,SAAS,CAAC;QACrC,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,WAAmB,EAAE,MAAmB;IACpE,MAAM,IAAI,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;IACzC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,CAAC,KAAK,CAAC,yFAAyF,CAAC,CAAC;QACxG,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;IAC/C,IAAI,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,QAAQ,CAAC;IACxC,IAAI,CAAC;QACH,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC,gBAAgB,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAChF,MAAM,CAAC,IAAI,CAAC,0BAA0B,MAAM,EAAE,CAAC,CAAC;QAChD,OAAO,SAAS,CAAC;IACnB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,6EAA6E;QAC7E,kEAAkE;QAClE,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"}
@@ -0,0 +1,125 @@
1
+ import type { AstroIntegration } from 'astro';
2
+ /**
3
+ * Configuration for a recursive preview build that runs immediately after the
4
+ * site's production build completes. The preview build emits the SSR routes
5
+ * that serve draft preview.
6
+ *
7
+ * Set to `false` to explicitly opt out of preview builds for sites that do not
8
+ * need a draft/preview pipeline.
9
+ */
10
+ export interface PreviewBuildOptions {
11
+ /**
12
+ * Optional alternative Astro adapter to use for the preview build.
13
+ * Falls back to the project's default adapter when omitted.
14
+ */
15
+ adapter?: AstroIntegration;
16
+ /**
17
+ * Adapter-specific config overrides forwarded to the recursive build.
18
+ */
19
+ config?: Record<string, unknown>;
20
+ /**
21
+ * Output directory for the preview build. Defaults to `.conloca/preview-server`
22
+ * — outside `dist/`, so the secret-baked artifact can never ride a wholesale
23
+ * static upload of the site and Astro's dist-clearing cannot wipe it.
24
+ */
25
+ outDir?: string;
26
+ /**
27
+ * If true, fail the parent build when the preview build fails. Defaults to
28
+ * true; set false while setting up.
29
+ */
30
+ required?: boolean;
31
+ }
32
+ /**
33
+ * Options accepted by {@link conlocaCloud}.
34
+ *
35
+ * Registration authenticates with one build token (`cbt_<id>.<secret>`)
36
+ * issued by the endpoint. Repository identity is normally detected from CI metadata or the Git
37
+ * checkout.
38
+ */
39
+ export interface ConlocaCloudOptions {
40
+ /** Editor endpoint, e.g. 'https://cms.example.com', no trailing slash. */
41
+ endpoint: string;
42
+ /**
43
+ * Advanced override for repository identity, normalized to `owner/repo`.
44
+ * Normally omit this: Conloca detects GitHub, Vercel, or GitLab CI metadata,
45
+ * then falls back to the checkout's `remote.origin.url`. Registration is
46
+ * rejected when the token does not cover the detected repo.
47
+ */
48
+ repoUri?: string;
49
+ /**
50
+ * Advanced override for the deployable-site id, for CMS-less builds where
51
+ * `conlocaCMS` does not publish CONLOCA_CONTENT_ROOT. When the CMS channel IS
52
+ * present, the content root's sites.json is authoritative and an override
53
+ * that contradicts it fails the build — never a silent pick.
54
+ */
55
+ siteId?: string;
56
+ /**
57
+ * Build token issued by the endpoint. Prefer injecting it via the
58
+ * CONLOCA_BUILD_TOKEN environment variable instead of committing it here;
59
+ * when neither is present the build skips registration (fail soft, unless
60
+ * `requireRegistration` is set).
61
+ */
62
+ buildToken?: string;
63
+ /**
64
+ * Entry module of the puck config to compile into the editor bundle,
65
+ * e.g. './src/puck.config.tsx'. Same option name as @conloca/astro-cms.
66
+ */
67
+ puckConfigPath: string;
68
+ /**
69
+ * Site CSS for accurate preview rendering — same option name and shape
70
+ * as `conlocaCMS({ siteStyles })`, and compiled the same way: by the site's
71
+ * own Vite pipeline (its plugins, PostCSS config and preprocessors), into
72
+ * the canvas stylesheet each build registers, ahead of the
73
+ * component modules, e.g. './src/styles/index.scss'. Paths resolve against
74
+ * the project root. The assets these stylesheets reference are emitted under
75
+ * `/_conloca/`, and an entry that fails to compile fails the build. Component
76
+ * `*.module.(s)css` imports compile in automatically — list here only what
77
+ * lives outside the component graph.
78
+ */
79
+ siteStyles?: string | string[];
80
+ /**
81
+ * Representative content route for build-time style discovery — the SAME
82
+ * name and meaning as `conlocaCMS`'s option: the page whose styles and
83
+ * content-wrapper shape prose editing should adopt. When set, the build
84
+ * reads that route's rendered page (a prerendered file, or the booted node
85
+ * server entry), collects its CSS and wrapper shape, and registers them
86
+ * alongside the bundle. Unset: discovery is skipped and the editor falls
87
+ * back to the prose-safe derived tier.
88
+ *
89
+ * @example '/blog/welcome-post'
90
+ */
91
+ fragmentPreviewRoute?: string;
92
+ /**
93
+ * Public base URL of the deployed site, used to absolutize the editor
94
+ * bundle URL when no dedicated preview domain is configured. Falls back to
95
+ * the CF_PAGES_URL env var; without either, registration is skipped.
96
+ */
97
+ publicBaseUrl?: string;
98
+ /**
99
+ * Optional dedicated preview deployment as a hostname or absolute URL. A
100
+ * hostname is normalized to HTTPS. When set, editor assets and preview links
101
+ * use this deployment instead of the production site's public base URL.
102
+ */
103
+ previewDomain?: string;
104
+ /**
105
+ * Recursive preview build configuration. Set to `false` to opt out.
106
+ * Defaults to enabled with project defaults.
107
+ */
108
+ previewBuild?: PreviewBuildOptions | false;
109
+ /**
110
+ * The token issuer (the JWT `iss` the preview middleware pins).
111
+ * Set it to bake the value into the preview artifact; otherwise the
112
+ * deployment must supply `CONLOCA_SAAS_ISSUER` at runtime.
113
+ */
114
+ saasIssuer?: string;
115
+ /**
116
+ * Fail the build when registration is SKIPPED for a missing prerequisite
117
+ * (no build token, no repository identity, no git sha/branch, no public
118
+ * base URL). Default false, so a plain `astro build` without the token
119
+ * stays untouched. Turn it on in CI once setup is done: a deploy can
120
+ * then never silently leave the editor at the endpoint stale. An ATTEMPTED
121
+ * registration that fails always fails the build, regardless of this.
122
+ */
123
+ requireRegistration?: boolean;
124
+ }
125
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +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;;;;;;;GAOG;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;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B;;;;;;;;;;OAUG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,mBAAmB,GAAG,KAAK,CAAC;IAC3C;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,14 +1,179 @@
1
1
  {
2
2
  "name": "@conloca/cloud-astro",
3
- "version": "0.0.0-bootstrap.0",
4
- "description": "Bootstrap placeholder for @conloca/cloud-astro. Real releases are published by SmoothBricks CI.",
5
- "license": "FSL-1.1-ALv2",
3
+ "version": "0.2.1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
6
7
  "repository": {
7
8
  "type": "git",
8
9
  "url": "git+https://github.com/conloca/conloca.git",
9
10
  "directory": "packages/cloud-astro"
10
11
  },
11
- "publishConfig": {
12
- "access": "public"
12
+ "license": "FSL-1.1-ALv2",
13
+ "description": "Astro integration that registers each build's editor bundle at an editor endpoint",
14
+ "type": "module",
15
+ "sideEffects": false,
16
+ "main": "./dist/src/index.js",
17
+ "module": "./dist/src/index.js",
18
+ "types": "./dist/src/index.d.ts",
19
+ "exports": {
20
+ "./package.json": "./package.json",
21
+ ".": {
22
+ "types": "./dist/src/index.d.ts",
23
+ "import": "./dist/src/index.js",
24
+ "default": "./dist/src/index.js"
25
+ },
26
+ "./node": {
27
+ "types": "./dist/src/node.d.ts",
28
+ "import": "./dist/src/node.js",
29
+ "default": "./dist/src/node.js"
30
+ },
31
+ "./preview": {
32
+ "types": "./dist/src/preview.d.ts",
33
+ "import": "./dist/src/preview.js",
34
+ "default": "./dist/src/preview.js"
35
+ },
36
+ "./site-middleware": {
37
+ "types": "./dist/src/site-middleware.d.ts",
38
+ "import": "./dist/src/site-middleware.js",
39
+ "default": "./dist/src/site-middleware.js"
40
+ },
41
+ "./bundle": {
42
+ "types": "./dist/src/bundle.d.ts",
43
+ "import": "./dist/src/bundle.js",
44
+ "default": "./dist/src/bundle.js"
45
+ },
46
+ "./doctor": {
47
+ "types": "./dist/src/doctor.d.ts",
48
+ "import": "./dist/src/doctor.js",
49
+ "default": "./dist/src/doctor.js"
50
+ },
51
+ "./satteri-workerd": {
52
+ "types": "./dist/src/preview/satteri-workerd.d.ts",
53
+ "import": "./dist/src/preview/satteri-workerd.js",
54
+ "default": "./dist/src/preview/satteri-workerd.js"
55
+ },
56
+ "./preview-handler": {
57
+ "types": "./src/preview-handler.d.ts",
58
+ "default": "./src/preview-handler.astro"
59
+ }
60
+ },
61
+ "files": [
62
+ "dist",
63
+ "src",
64
+ "!src/__tests__",
65
+ "!**/*.tsbuildinfo"
66
+ ],
67
+ "scripts": {
68
+ "test": "nx run cloud-astro:test --outputStyle=stream"
69
+ },
70
+ "peerDependencies": {
71
+ "@astrojs/react": "^6.0.5",
72
+ "@conloca/astro-cms": "0.2.1",
73
+ "astro": "^7.3.1",
74
+ "vite": "^8.2.2"
75
+ },
76
+ "dependencies": {
77
+ "@conloca/content-api": "0.2.1",
78
+ "esbuild": "^0.28.2",
79
+ "hast-util-from-html": "^2.0.3",
80
+ "jose": "^6.2.10",
81
+ "sass": "^1.103.1",
82
+ "tslib": "^2.8.1"
83
+ },
84
+ "devDependencies": {
85
+ "@astrojs/check": "^0.9.10",
86
+ "@conloca/astro-cms": "0.2.1",
87
+ "astro": "^7.3.1",
88
+ "typescript": "^6.0.3",
89
+ "vite": "^8.2.2"
90
+ },
91
+ "engines": {
92
+ "node": ">=20.0.0"
93
+ },
94
+ "conloca": {
95
+ "doctor": "./dist/src/doctor.js"
96
+ },
97
+ "nx": {
98
+ "name": "cloud-astro",
99
+ "tags": [
100
+ "npm:public"
101
+ ],
102
+ "targets": {
103
+ "clean": {},
104
+ "lint": {},
105
+ "typecheck": {
106
+ "dependsOn": [
107
+ "^*-js",
108
+ "typecheck-astro"
109
+ ]
110
+ },
111
+ "typecheck-astro": {
112
+ "executor": "nx:run-commands",
113
+ "cache": true,
114
+ "dependsOn": [
115
+ "^*-js"
116
+ ],
117
+ "inputs": [
118
+ "versionlessProduction",
119
+ "^production",
120
+ "{workspaceRoot}/tsconfig.base.json",
121
+ {
122
+ "json": "{workspaceRoot}/package.json",
123
+ "excludeFields": [
124
+ "version"
125
+ ]
126
+ },
127
+ {
128
+ "json": "{workspaceRoot}/bun.lock",
129
+ "excludeFields": [
130
+ "workspaces"
131
+ ]
132
+ },
133
+ "{projectRoot}/tsconfig.astro.json"
134
+ ],
135
+ "outputs": [],
136
+ "options": {
137
+ "command": "astro check --noSync --tsconfig tsconfig.astro.json --minimumSeverity warning --minimumFailingSeverity warning",
138
+ "cwd": "{projectRoot}"
139
+ }
140
+ },
141
+ "test": {
142
+ "executor": "@smoothbricks/nx-plugin:bounded-exec",
143
+ "dependsOn": [
144
+ "typecheck-tests",
145
+ "build",
146
+ "test-packed"
147
+ ],
148
+ "options": {
149
+ "command": "bun test --timeout=30000 ./src",
150
+ "cwd": "{projectRoot}",
151
+ "timeoutMs": 120000,
152
+ "killAfterMs": 10000
153
+ }
154
+ },
155
+ "test-packed": {
156
+ "//": "The packed shape is a function of the built outputs, the manifest and the locked dependency closure; cached on exactly those.",
157
+ "executor": "nx:run-commands",
158
+ "cache": true,
159
+ "inputs": [
160
+ {
161
+ "dependentTasksOutputFiles": "**/*",
162
+ "transitive": true
163
+ },
164
+ "{projectRoot}/package.json",
165
+ "{workspaceRoot}/bun.lock",
166
+ "{workspaceRoot}/tooling/packaging/**/*"
167
+ ],
168
+ "dependsOn": [
169
+ "build",
170
+ "^build"
171
+ ],
172
+ "options": {
173
+ "command": "bun tooling/packaging/test-packed.ts cloud-astro",
174
+ "cwd": "{workspaceRoot}"
175
+ }
176
+ }
177
+ }
13
178
  }
14
179
  }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The commit a registration names and the commit the artifact was built from.
3
+ * They differ only when CI hands over the branch's latest commit
4
+ * (`CF_PAGES_COMMIT_SHA`) while building another commit — a pull request's
5
+ * merge commit — because the endpoint can only serve a commit the branch
6
+ * actually carries.
7
+ */
8
+ export interface RegistrationCommits {
9
+ gitSha: string | undefined;
10
+ buildId: string | undefined;
11
+ }
12
+
13
+ /** Resolves which commit the registration names and which commit produced the bundle. */
14
+ export function registrationCommits(input: {
15
+ /** The branch's latest commit, as CI hands it over through CF_PAGES_COMMIT_SHA. */
16
+ eventCommitSha: string | undefined;
17
+ /** git rev-parse HEAD in the build checkout. */
18
+ checkoutCommitSha: string | undefined;
19
+ }): RegistrationCommits {
20
+ const gitSha = input.eventCommitSha ?? input.checkoutCommitSha;
21
+ return { gitSha, buildId: input.checkoutCommitSha ?? gitSha };
22
+ }