@brandon_m_behring/book-scaffold-astro 3.5.2 → 3.6.0

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AstroUserConfig, AstroIntegration } from 'astro';
2
- import { c as BookConfigOptions, f as BookScaffoldIntegrationOptions, E as volatilityLevels } from './types-CzXybcNA.js';
3
- export { A as AcademicChapter, B as BOOK_PRESETS, a as BOOK_PROFILES, b as BookConfigError, d as BookPreset, e as BookProfile, g as BookSchemasOptions, C as ChapterFor, h as CourseNotesChapter, M as MinimalChapter, P as ProfileDefinition, R as ResearchPortfolioChapter, i as RouteToggles, T as ToolsChapter, j as academicChapterSchema, k as academicParts, l as changeKinds, m as changelogSchema, n as chapterStatus, o as courseNotesChapterSchema, p as defineProfile, q as minimalChapterSchema, r as patternCategories, s as patternsSchema, t as researchPortfolioChapterSchema, u as resolvePreset, v as resolveProfile, w as sourceTiers, x as sourceTiersResearch, y as sourcesSchema, z as toolSlugs, D as toolsChapterSchema } from './types-CzXybcNA.js';
2
+ import { c as BookConfigOptions, f as BookScaffoldIntegrationOptions, E as volatilityLevels } from './types-DVbzso8w.js';
3
+ export { A as AcademicChapter, B as BOOK_PRESETS, a as BOOK_PROFILES, b as BookConfigError, d as BookPreset, e as BookProfile, g as BookSchemasOptions, C as ChapterFor, h as CourseNotesChapter, M as MinimalChapter, P as ProfileDefinition, R as ResearchPortfolioChapter, i as RouteToggles, T as ToolsChapter, j as academicChapterSchema, k as academicParts, l as changeKinds, m as changelogSchema, n as chapterStatus, o as courseNotesChapterSchema, p as defineProfile, q as minimalChapterSchema, r as patternCategories, s as patternsSchema, t as researchPortfolioChapterSchema, u as resolvePreset, v as resolveProfile, w as sourceTiers, x as sourceTiersResearch, y as sourcesSchema, z as toolSlugs, D as toolsChapterSchema } from './types-DVbzso8w.js';
4
4
  import 'astro/zod';
5
5
 
6
6
  declare function defineBookConfig(opts: BookConfigOptions): Promise<AstroUserConfig>;
package/dist/index.mjs CHANGED
@@ -588,6 +588,7 @@ async function defineBookConfig(opts) {
588
588
  "rehype-katex"
589
589
  );
590
590
  const { ssmMacros: ssmMacros2 } = await Promise.resolve().then(() => (init_katex_macros(), katex_macros_exports));
591
+ const macros = { ...ssmMacros2, ...opts.katexMacros ?? {} };
591
592
  remarkPlugins.push(remarkMath);
592
593
  rehypePlugins.push([
593
594
  rehypeKatex,
@@ -597,7 +598,7 @@ async function defineBookConfig(opts) {
597
598
  // for catching errors before deploy.
598
599
  strict: "error",
599
600
  trust: true,
600
- macros: ssmMacros2
601
+ macros
601
602
  }
602
603
  ]);
603
604
  }
@@ -638,6 +639,8 @@ async function defineBookConfig(opts) {
638
639
  extraIntegrations: _extraIntegrations,
639
640
  extraStyles: _extraStyles,
640
641
  markdown: _markdown,
642
+ katexMacros: _katexMacros,
643
+ // v3.6.0 (closes #22)
641
644
  ...rest
642
645
  } = opts;
643
646
  void _preset;
@@ -647,6 +650,7 @@ async function defineBookConfig(opts) {
647
650
  void _extraIntegrations;
648
651
  void _extraStyles;
649
652
  void _markdown;
653
+ void _katexMacros;
650
654
  const katexExternals = profile === "academic" ? [] : ["remark-math", "rehype-katex", "katex"];
651
655
  const config = {
652
656
  ...rest,
package/dist/schemas.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineCollection } from 'astro:content';
2
- import { g as BookSchemasOptions } from './types-CzXybcNA.js';
2
+ import { g as BookSchemasOptions } from './types-DVbzso8w.js';
3
3
  import 'astro';
4
4
  import 'astro/zod';
5
5
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@brandon_m_behring/book-scaffold-astro",
3
3
  "description": "Astro 6 + MDX toolkit for long-form technical books. Profile-aware (academic / tools / minimal); ships Tufte typography, KaTeX, BibTeX citations, Pagefind, Cloudflare Workers deploy. See PACKAGE_DESIGN.md for the API contract.",
4
- "version": "3.5.2",
4
+ "version": "3.6.0",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "Brandon Behring",
@@ -27,8 +27,40 @@
27
27
  */
28
28
  import { readFile, access } from 'node:fs/promises';
29
29
  import { glob } from 'node:fs/promises';
30
+ import { existsSync, readFileSync } from 'node:fs';
30
31
  import { resolve, dirname, join } from 'node:path';
31
32
 
33
+ /**
34
+ * Best-effort .env reader. Mirrors `readEnvFile` in src/types.ts; kept inline
35
+ * here because scripts/ is shipped as plain JS without compiling src/.
36
+ *
37
+ * Closes #20 — validate.mjs previously skipped the .env fallback that
38
+ * `resolveProfileWithSource` honors, so consumers who set BOOK_PROFILE in
39
+ * .env (per the SKILL.md and scaffold's create-book defaults) saw the CLI
40
+ * silently default to minimal, masking academic-profile errors.
41
+ */
42
+ function readEnvFile(path = '.env') {
43
+ try {
44
+ if (!existsSync(path)) return {};
45
+ const out = {};
46
+ for (const line of readFileSync(path, 'utf8').split(/\r?\n/)) {
47
+ const m = line.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*?)\s*$/);
48
+ if (!m) continue;
49
+ let val = m[2] ?? '';
50
+ if (
51
+ (val.startsWith('"') && val.endsWith('"')) ||
52
+ (val.startsWith("'") && val.endsWith("'"))
53
+ ) {
54
+ val = val.slice(1, -1);
55
+ }
56
+ out[m[1]] = val;
57
+ }
58
+ return out;
59
+ } catch {
60
+ return {};
61
+ }
62
+ }
63
+
32
64
  // --help / -h: non-mutating (closes #14).
33
65
  const USAGE = `Usage: book-scaffold validate [--preset <name>]
34
66
 
@@ -67,8 +99,20 @@ const CHAPTERS_DIR = resolve(ROOT, 'src/content/chapters');
67
99
  const PUBLIC_DIR = resolve(ROOT, 'public');
68
100
  const DATA_DIR = resolve(ROOT, 'src/data');
69
101
 
70
- // Preset resolution: --preset flag > BOOK_PRESET env > BOOK_PROFILE env > 'minimal'.
71
- const PRESET = presetFromFlag ?? process.env.BOOK_PRESET ?? process.env.BOOK_PROFILE ?? 'minimal';
102
+ // Preset resolution (matches resolvePreset in src/types.ts):
103
+ // --preset flag > BOOK_PRESET env > BOOK_PROFILE env >
104
+ // .env BOOK_PRESET > .env BOOK_PROFILE > 'minimal'.
105
+ // .env fallback closes #20 — without it, consumers who set BOOK_PROFILE in
106
+ // .env (the documented convenience in SKILL.md + create-book defaults) saw
107
+ // the CLI silently default to minimal, hiding academic-profile errors.
108
+ const dotenv = readEnvFile(resolve(ROOT, '.env'));
109
+ const PRESET =
110
+ presetFromFlag ??
111
+ process.env.BOOK_PRESET ??
112
+ process.env.BOOK_PROFILE ??
113
+ dotenv.BOOK_PRESET ??
114
+ dotenv.BOOK_PROFILE ??
115
+ 'minimal';
72
116
  // Alias kept for downstream message text only; the resolution above is canonical.
73
117
  const PROFILE = PRESET;
74
118
  const REPO_ROOT = process.env.BOOK_REPO_ROOT ?? null;