meno-core 1.0.38 → 1.0.40

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 (57) hide show
  1. package/build-astro.ts +1041 -0
  2. package/dist/bin/cli.js +1 -1
  3. package/dist/build-static.js +6 -6
  4. package/dist/chunks/{chunk-JACS3C25.js → chunk-3NOZVNM4.js} +3 -3
  5. package/dist/chunks/{chunk-EUCAKI5U.js → chunk-GKICS7CF.js} +34 -14
  6. package/dist/chunks/chunk-GKICS7CF.js.map +7 -0
  7. package/dist/chunks/{chunk-P3FX5HJM.js → chunk-LOJLO2EY.js} +1 -1
  8. package/dist/chunks/chunk-LOJLO2EY.js.map +7 -0
  9. package/dist/chunks/{chunk-UR7L5UZ3.js → chunk-MOCRENNU.js} +55 -5
  10. package/dist/chunks/{chunk-UR7L5UZ3.js.map → chunk-MOCRENNU.js.map} +3 -3
  11. package/dist/chunks/{chunk-NV25WXCA.js → chunk-OJ5SROQN.js} +5 -3
  12. package/dist/chunks/chunk-OJ5SROQN.js.map +7 -0
  13. package/dist/chunks/{chunk-AIXKUVNG.js → chunk-V4SVSX3X.js} +3 -3
  14. package/dist/chunks/{chunk-KULPBDC7.js → chunk-Z7SAOCDG.js} +5 -2
  15. package/dist/chunks/{chunk-KULPBDC7.js.map → chunk-Z7SAOCDG.js.map} +2 -2
  16. package/dist/chunks/{constants-5CRJRQNR.js → constants-L75FR445.js} +2 -2
  17. package/dist/entries/server-router.js +6 -6
  18. package/dist/lib/client/index.js +10 -8
  19. package/dist/lib/client/index.js.map +2 -2
  20. package/dist/lib/server/index.js +3653 -8
  21. package/dist/lib/server/index.js.map +4 -4
  22. package/dist/lib/shared/index.js +8 -6
  23. package/dist/lib/shared/index.js.map +2 -2
  24. package/dist/lib/test-utils/index.js +1 -1
  25. package/lib/client/core/builders/embedBuilder.ts +2 -2
  26. package/lib/client/theme.ts +4 -1
  27. package/lib/server/astro/cmsPageEmitter.ts +417 -0
  28. package/lib/server/astro/componentEmitter.ts +293 -0
  29. package/lib/server/astro/cssCollector.ts +147 -0
  30. package/lib/server/astro/index.ts +5 -0
  31. package/lib/server/astro/nodeToAstro.ts +1564 -0
  32. package/lib/server/astro/pageEmitter.ts +226 -0
  33. package/lib/server/astro/tailwindMapper.ts +608 -0
  34. package/lib/server/astro/templateTransformer.ts +107 -0
  35. package/lib/server/index.ts +12 -0
  36. package/lib/server/routes/api/components.ts +62 -0
  37. package/lib/server/routes/api/core-routes.ts +8 -0
  38. package/lib/server/ssr/htmlGenerator.ts +3 -0
  39. package/lib/server/ssr/ssrRenderer.test.ts +8 -4
  40. package/lib/server/ssr/ssrRenderer.ts +31 -13
  41. package/lib/server/webflow/buildWebflow.ts +415 -0
  42. package/lib/server/webflow/index.ts +22 -0
  43. package/lib/server/webflow/nodeToWebflow.ts +423 -0
  44. package/lib/server/webflow/styleMapper.ts +241 -0
  45. package/lib/server/webflow/types.ts +196 -0
  46. package/lib/shared/constants.ts +2 -0
  47. package/lib/shared/themeDefaults.test.ts +1 -1
  48. package/lib/shared/themeDefaults.ts +4 -1
  49. package/lib/shared/types/components.ts +1 -0
  50. package/lib/shared/validation/schemas.ts +1 -0
  51. package/package.json +1 -1
  52. package/dist/chunks/chunk-EUCAKI5U.js.map +0 -7
  53. package/dist/chunks/chunk-NV25WXCA.js.map +0 -7
  54. package/dist/chunks/chunk-P3FX5HJM.js.map +0 -7
  55. /package/dist/chunks/{chunk-JACS3C25.js.map → chunk-3NOZVNM4.js.map} +0 -0
  56. /package/dist/chunks/{chunk-AIXKUVNG.js.map → chunk-V4SVSX3X.js.map} +0 -0
  57. /package/dist/chunks/{constants-5CRJRQNR.js.map → constants-L75FR445.js.map} +0 -0
package/build-astro.ts ADDED
@@ -0,0 +1,1041 @@
1
+ /**
2
+ * Astro Export Build Script
3
+ * Renders all pages via the SSR pipeline, then wraps them as Astro page files
4
+ * with a shared layout, global CSS, and optional CMS content collections.
5
+ */
6
+
7
+ import { existsSync, readdirSync, mkdirSync, rmSync, statSync, copyFileSync, writeFileSync } from "fs";
8
+ import { writeFile, readFile } from "fs/promises";
9
+ import { join } from "path";
10
+ import { createHash } from "crypto";
11
+ import { inspect, minifyJS as runtimeMinifyJS } from './lib/server/runtime';
12
+ import {
13
+ loadJSONFile,
14
+ loadComponentDirectory,
15
+ mapPageNameToPath,
16
+ parseJSON,
17
+ loadI18nConfig
18
+ } from "./lib/server/jsonLoader";
19
+ import { generateSSRHTML } from "./lib/server/ssrRenderer";
20
+ import type { SSRHTMLResult } from "./lib/server/ssr/htmlGenerator";
21
+ import { projectPaths } from "./lib/server/projectContext";
22
+ import { loadProjectConfig, generateFontCSS, generateFontPreloadTags } from "./lib/shared/fontLoader";
23
+ import { FileSystemCMSProvider } from "./lib/server/providers/fileSystemCMSProvider";
24
+ import { CMSService } from "./lib/server/services/cmsService";
25
+ import { isI18nValue, resolveI18nValue } from "./lib/shared/i18n";
26
+ import type { ComponentDefinition, JSONPage, CMSSchema, CMSItem, I18nConfig } from "./lib/shared/types";
27
+ import type { CMSFieldDefinition } from "./lib/shared/types/cms";
28
+ import { isItemDraftForLocale } from "./lib/shared/types";
29
+ import type { SlugMap } from "./lib/shared/slugTranslator";
30
+ import { renderPageSSR } from "./lib/server/ssr/ssrRenderer";
31
+ import { generateThemeColorVariablesCSS, generateVariablesCSS } from "./lib/server/cssGenerator";
32
+ import { generateAllInteractiveCSS } from "./lib/shared/cssGeneration";
33
+ import { colorService } from "./lib/server/services/ColorService";
34
+ import { variableService } from "./lib/server/services/VariableService";
35
+ import { configService } from "./lib/server/services/configService";
36
+ import { loadBreakpointConfig, loadResponsiveScalesConfig } from "./lib/server/jsonLoader";
37
+ import type { InteractiveStyles } from "./lib/shared/types/styles";
38
+ import { collectComponentLibraries, filterLibrariesByContext, mergeLibraries, generateLibraryTags } from "./lib/shared/libraryLoader";
39
+ import { migrateTemplatesDirectory } from "./lib/server/migrateTemplates";
40
+ import { emitAstroComponent } from "./lib/server/astro/componentEmitter";
41
+ import { emitAstroPage } from "./lib/server/astro/pageEmitter";
42
+ import { emitCMSPage } from './lib/server/astro/cmsPageEmitter';
43
+ import { collectAllMappingClasses } from "./lib/server/astro/cssCollector";
44
+ import { buildImageMetadataMap } from "./lib/server/ssr/imageMetadata";
45
+ import { extractUtilityClassesFromHTML, generateUtilityCSS } from "./lib/shared/cssGeneration";
46
+
47
+ // ---------------------------------------------------------------------------
48
+ // Helpers
49
+ // ---------------------------------------------------------------------------
50
+
51
+ function hashContent(content: string): string {
52
+ return createHash('sha256').update(content).digest('hex').slice(0, 8);
53
+ }
54
+
55
+ function copyDirectory(src: string, dest: string): void {
56
+ if (!existsSync(src)) return;
57
+ if (!existsSync(dest)) mkdirSync(dest, { recursive: true });
58
+ const files = readdirSync(src);
59
+ for (const file of files) {
60
+ const srcPath = join(src, file);
61
+ const destPath = join(dest, file);
62
+ const stat = statSync(srcPath);
63
+ if (stat.isDirectory()) copyDirectory(srcPath, destPath);
64
+ else copyFileSync(srcPath, destPath);
65
+ }
66
+ }
67
+
68
+ function isCMSPage(pageData: JSONPage): boolean {
69
+ return pageData.meta?.source === 'cms' && !!pageData.meta?.cms;
70
+ }
71
+
72
+ /**
73
+ * Build URL path for a CMS item based on the URL pattern
74
+ */
75
+ function buildCMSItemPath(
76
+ urlPattern: string,
77
+ item: CMSItem,
78
+ slugField: string,
79
+ locale: string,
80
+ i18nConfig: I18nConfig
81
+ ): string {
82
+ let slug = item[slugField] ?? item._slug ?? item._id;
83
+ if (isI18nValue(slug)) {
84
+ slug = resolveI18nValue(slug, locale, i18nConfig) as string;
85
+ }
86
+ return urlPattern.replace('{{slug}}', String(slug));
87
+ }
88
+
89
+ /**
90
+ * Recursively scan a directory for .json files, returning relative paths.
91
+ */
92
+ function scanJSONFiles(dir: string, prefix: string = ''): string[] {
93
+ const results: string[] = [];
94
+ if (!existsSync(dir)) return results;
95
+ const entries = readdirSync(dir, { withFileTypes: true });
96
+ for (const entry of entries) {
97
+ if (entry.isFile() && entry.name.endsWith('.json')) {
98
+ results.push(prefix ? `${prefix}/${entry.name}` : entry.name);
99
+ } else if (entry.isDirectory()) {
100
+ results.push(...scanJSONFiles(join(dir, entry.name), prefix ? `${prefix}/${entry.name}` : entry.name));
101
+ }
102
+ }
103
+ return results;
104
+ }
105
+
106
+ /**
107
+ * Compute the relative import path from a file at `fromDepth` levels under src/pages/
108
+ * back to src/layouts/BaseLayout.astro.
109
+ */
110
+ function layoutImportPath(fileDepth: number): string {
111
+ // fileDepth = 0 means file is at src/pages/index.astro -> ../layouts/BaseLayout.astro
112
+ // fileDepth = 1 means src/pages/en/index.astro -> ../../layouts/BaseLayout.astro
113
+ const ups = '../'.repeat(fileDepth + 1);
114
+ return `${ups}layouts/BaseLayout.astro`;
115
+ }
116
+
117
+ /**
118
+ * Escape a string for use inside a JS template literal (backtick string).
119
+ */
120
+ function escapeTemplateLiteral(s: string): string {
121
+ return s.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$\{/g, '\\${');
122
+ }
123
+
124
+ /**
125
+ * Compute locale → URL path map for a page's slug translations.
126
+ * Used by locale list rendering to generate correct links.
127
+ */
128
+ function computePageSlugMap(
129
+ slugs: Record<string, string>,
130
+ i18nConfig: I18nConfig
131
+ ): Record<string, string> {
132
+ const map: Record<string, string> = {};
133
+ for (const localeConfig of i18nConfig.locales) {
134
+ const code = localeConfig.code;
135
+ const isDefault = code === i18nConfig.defaultLocale;
136
+ const slug = slugs[code] || '';
137
+ if (isDefault) {
138
+ map[code] = slug === '' ? '/' : `/${slug}`;
139
+ } else {
140
+ map[code] = slug === '' ? `/${code}` : `/${code}/${slug}`;
141
+ }
142
+ }
143
+ return map;
144
+ }
145
+
146
+ /**
147
+ * Map a CMS field type to a Zod schema string for the Astro content config.
148
+ */
149
+ function cmsFieldToZod(field: CMSFieldDefinition): string {
150
+ switch (field.type) {
151
+ case 'string':
152
+ case 'text':
153
+ case 'rich-text':
154
+ // Support both plain strings and i18n objects { _i18n: true, en: "...", pl: "..." }
155
+ return 'z.union([z.string(), z.object({ _i18n: z.literal(true) }).passthrough()])';
156
+ case 'number':
157
+ return 'z.number()';
158
+ case 'boolean':
159
+ return 'z.boolean()';
160
+ case 'date':
161
+ return 'z.coerce.date()';
162
+ case 'select':
163
+ if (field.options && field.options.length > 0) {
164
+ const opts = field.options.map(o => `'${o.replace(/'/g, "\\'")}'`).join(', ');
165
+ return `z.enum([${opts}])`;
166
+ }
167
+ return 'z.string()';
168
+ case 'image':
169
+ case 'file':
170
+ return 'z.string()';
171
+ case 'reference':
172
+ return 'z.string()';
173
+ default:
174
+ return 'z.string()';
175
+ }
176
+ }
177
+
178
+ // ---------------------------------------------------------------------------
179
+ // Types
180
+ // ---------------------------------------------------------------------------
181
+
182
+ interface PageRenderResult {
183
+ /** Body HTML (inner content, no DOCTYPE wrapper) */
184
+ html: string;
185
+ /** Head meta tags HTML string */
186
+ meta: string;
187
+ /** Page title */
188
+ title: string;
189
+ /** Extracted JavaScript (if any) */
190
+ javascript: string;
191
+ /** Per-component CSS */
192
+ componentCSS?: string;
193
+ /** Locale used */
194
+ locale: string;
195
+ /** Interactive styles (hover, focus, etc.) */
196
+ interactiveStylesMap: Map<string, InteractiveStyles>;
197
+ /** The URL path this page will live at */
198
+ urlPath: string;
199
+ /** File depth relative to src/pages/ (0 = root, 1 = one dir deep, etc.) */
200
+ fileDepth: number;
201
+ /** Relative file path within src/pages/ */
202
+ astroFilePath: string;
203
+ /** Original page data (for Pass 2 component-structured emission) */
204
+ pageData?: JSONPage;
205
+ /** Page name without extension */
206
+ pageName?: string;
207
+ /** Whether this is a CMS template page */
208
+ isCMSPage?: boolean;
209
+ /** SSR fallback HTML for complex nodes (list, locale-list) keyed by element path */
210
+ ssrFallbackCollector?: Map<string, string>;
211
+ }
212
+
213
+ interface AstroBuildStats {
214
+ pages: number;
215
+ cmsPages: number;
216
+ collections: number;
217
+ errors: number;
218
+ }
219
+
220
+ // ---------------------------------------------------------------------------
221
+ // SSR Fallback page builder (used for CMS pages and error fallback)
222
+ // ---------------------------------------------------------------------------
223
+
224
+ function buildSSRFallbackPage(
225
+ result: PageRenderResult,
226
+ importPath: string,
227
+ fontPreloads: string,
228
+ libraryTags: { headCSS?: string; headJS?: string; bodyEndJS?: string },
229
+ defaultTheme: string,
230
+ scriptPaths: string[]
231
+ ): string {
232
+ const escapedMeta = escapeTemplateLiteral(result.meta);
233
+ const escapedHTML = escapeTemplateLiteral(result.html);
234
+ const escapedFontPreloads = escapeTemplateLiteral(fontPreloads);
235
+
236
+ const scriptsArrayLiteral = scriptPaths.length > 0
237
+ ? `[${scriptPaths.map(s => `"${s}"`).join(', ')}]`
238
+ : '[]';
239
+
240
+ const libraryTagsLiteral = `{ headCSS: \`${escapeTemplateLiteral(libraryTags.headCSS || '')}\`, headJS: \`${escapeTemplateLiteral(libraryTags.headJS || '')}\`, bodyEndJS: \`${escapeTemplateLiteral(libraryTags.bodyEndJS || '')}\` }`;
241
+
242
+ return `---
243
+ import BaseLayout from '${importPath}';
244
+ ---
245
+ <BaseLayout
246
+ title="${result.title.replace(/"/g, '&quot;')}"
247
+ meta={\`${escapedMeta}\`}
248
+ scripts={${scriptsArrayLiteral}}
249
+ locale="${result.locale}"
250
+ theme="${defaultTheme}"
251
+ fontPreloads={\`${escapedFontPreloads}\`}
252
+ libraryTags={${libraryTagsLiteral}}
253
+ >
254
+ <Fragment set:html={\`<div id="root">${escapedHTML}</div>\`} />
255
+ </BaseLayout>
256
+ `;
257
+ }
258
+
259
+ // ---------------------------------------------------------------------------
260
+ // Main export
261
+ // ---------------------------------------------------------------------------
262
+
263
+ export async function buildAstroProject(
264
+ projectRoot?: string,
265
+ outputDir?: string
266
+ ): Promise<AstroBuildStats> {
267
+ const startTime = Date.now();
268
+
269
+ console.log('🏗️ Building Astro export...\n');
270
+
271
+ // ----------------------------------------------------------
272
+ // 1. Setup: load project configuration
273
+ // ----------------------------------------------------------
274
+ configService.reset();
275
+
276
+ const projectConfig = await loadProjectConfig();
277
+ const siteUrl = (projectConfig as { siteUrl?: string }).siteUrl?.replace(/\/$/, '') || '';
278
+
279
+ const i18nConfig = await loadI18nConfig();
280
+ console.log(`🌐 Locales: ${i18nConfig.locales.map(l => l.code).join(', ')} (default: ${i18nConfig.defaultLocale})\n`);
281
+
282
+ await migrateTemplatesDirectory();
283
+
284
+ const { components, warnings, errors: compErrors } = await loadComponentDirectory(projectPaths.components());
285
+ const globalComponents: Record<string, ComponentDefinition> = {};
286
+ components.forEach((value, key) => { globalComponents[key] = value; });
287
+ for (const w of warnings) console.warn(` Warning: ${w}`);
288
+ for (const e of compErrors) console.error(` Error: ${e}`);
289
+ console.log(`Loaded ${components.size} global component(s)\n`);
290
+
291
+ const cmsProvider = new FileSystemCMSProvider(projectPaths.templates(), projectPaths.cms());
292
+ const cmsService = new CMSService(cmsProvider);
293
+ await cmsService.initialize();
294
+ console.log('CMS service initialized\n');
295
+
296
+ const themeConfig = await colorService.loadThemeConfig();
297
+ const variablesConfig = await variableService.loadConfig();
298
+ const breakpoints = await loadBreakpointConfig();
299
+ const responsiveScales = await loadResponsiveScalesConfig();
300
+
301
+ // Libraries (global + component)
302
+ await configService.load();
303
+ const globalLibraries = configService.getLibraries();
304
+ const componentLibraries = collectComponentLibraries(globalComponents);
305
+
306
+ // Build image metadata map for responsive image generation
307
+ const imageMetadataMap = await buildImageMetadataMap();
308
+ if (imageMetadataMap.size > 0) {
309
+ console.log(`Loaded image metadata for ${imageMetadataMap.size} image(s)\n`);
310
+ }
311
+
312
+ // ----------------------------------------------------------
313
+ // 2. Clean and create output directory
314
+ // ----------------------------------------------------------
315
+ const outDir = outputDir || join(projectPaths.project, 'astro-export');
316
+
317
+ if (existsSync(outDir)) {
318
+ rmSync(outDir, { recursive: true, force: true });
319
+ }
320
+ mkdirSync(outDir, { recursive: true });
321
+
322
+ // Create directory structure
323
+ const srcDir = join(outDir, 'src');
324
+ const pagesOutDir = join(srcDir, 'pages');
325
+ const layoutsDir = join(srcDir, 'layouts');
326
+ const stylesDir = join(srcDir, 'styles');
327
+ const componentsOutDir = join(srcDir, 'components');
328
+ const publicDir = join(outDir, 'public');
329
+ const scriptsDir = join(publicDir, '_scripts');
330
+ for (const d of [srcDir, pagesOutDir, layoutsDir, stylesDir, componentsOutDir, publicDir]) {
331
+ mkdirSync(d, { recursive: true });
332
+ }
333
+
334
+ // ----------------------------------------------------------
335
+ // 3. Scan pages
336
+ // ----------------------------------------------------------
337
+ const pagesDir = projectPaths.pages();
338
+ if (!existsSync(pagesDir)) {
339
+ console.error('Pages directory not found!');
340
+ return { pages: 0, cmsPages: 0, collections: 0, errors: 1 };
341
+ }
342
+
343
+ const pageFiles = scanJSONFiles(pagesDir);
344
+ if (pageFiles.length === 0) {
345
+ console.warn('No pages found in ./pages directory');
346
+ return { pages: 0, cmsPages: 0, collections: 0, errors: 0 };
347
+ }
348
+
349
+ console.log(`Found ${pageFiles.length} page(s) to process\n`);
350
+
351
+ // Collect slug mappings (first pass)
352
+ const slugMappings: SlugMap[] = [];
353
+ for (const file of pageFiles) {
354
+ const pageName = file.replace('.json', '');
355
+ const basePath = mapPageNameToPath(pageName);
356
+ const pageContent = await loadJSONFile(join(pagesDir, file));
357
+ if (!pageContent) continue;
358
+ try {
359
+ const pageData = parseJSON<JSONPage>(pageContent);
360
+ if (pageData.meta?.slugs) {
361
+ const pageId = basePath === '/' ? 'index' : basePath.substring(1);
362
+ slugMappings.push({ pageId, slugs: pageData.meta.slugs });
363
+ }
364
+ } catch { /* ignore parse errors in first pass */ }
365
+ }
366
+
367
+ // ----------------------------------------------------------
368
+ // 4 & 5. Render all pages (regular + CMS templates)
369
+ // ----------------------------------------------------------
370
+ const allResults: PageRenderResult[] = [];
371
+ const allInteractiveStyles = new Map<string, InteractiveStyles>();
372
+ const allComponentCSS = new Set<string>();
373
+ const jsContents = new Map<string, string>(); // hash -> JS content
374
+ let errorCount = 0;
375
+
376
+ // Helper to merge interactive styles maps
377
+ function mergeInteractiveStyles(source: Map<string, InteractiveStyles>): void {
378
+ for (const [key, value] of source) {
379
+ if (!allInteractiveStyles.has(key)) {
380
+ allInteractiveStyles.set(key, value);
381
+ }
382
+ }
383
+ }
384
+
385
+ // Helper to process a render result
386
+ function processRenderResult(
387
+ result: { html: string; meta: string; title: string; javascript: string; componentCSS?: string; locale: string; interactiveStylesMap: Map<string, InteractiveStyles>; preloadImages: any[]; neededCollections: Set<string>; ssrFallbackCollector?: Map<string, string> },
388
+ urlPath: string,
389
+ astroFilePath: string,
390
+ fileDepth: number,
391
+ pageData?: JSONPage,
392
+ pageName?: string,
393
+ isCMSPage?: boolean
394
+ ): void {
395
+ // Collect interactive styles
396
+ mergeInteractiveStyles(result.interactiveStylesMap);
397
+
398
+ // Collect component CSS
399
+ if (result.componentCSS) {
400
+ allComponentCSS.add(result.componentCSS);
401
+ }
402
+
403
+ // Deduplicate JavaScript by content hash
404
+ if (result.javascript) {
405
+ const hash = hashContent(result.javascript);
406
+ if (!jsContents.has(hash)) {
407
+ jsContents.set(hash, result.javascript);
408
+ }
409
+ }
410
+
411
+ allResults.push({
412
+ html: result.html,
413
+ meta: result.meta,
414
+ title: result.title,
415
+ javascript: result.javascript,
416
+ componentCSS: result.componentCSS,
417
+ locale: result.locale,
418
+ interactiveStylesMap: result.interactiveStylesMap,
419
+ urlPath,
420
+ fileDepth,
421
+ astroFilePath,
422
+ pageData,
423
+ pageName,
424
+ isCMSPage,
425
+ ssrFallbackCollector: result.ssrFallbackCollector,
426
+ });
427
+ }
428
+
429
+ // ---------- Regular pages ----------
430
+ for (const file of pageFiles) {
431
+ const pageName = file.replace('.json', '');
432
+ const basePath = mapPageNameToPath(pageName);
433
+ const pageContent = await loadJSONFile(join(pagesDir, file));
434
+
435
+ if (!pageContent) {
436
+ console.warn(` Skipping ${basePath} (empty file)`);
437
+ errorCount++;
438
+ continue;
439
+ }
440
+
441
+ try {
442
+ const pageData = parseJSON<JSONPage>(pageContent);
443
+
444
+ // Skip draft pages in production
445
+ const isDevBuild = process.env.MENO_DEV_BUILD === 'true';
446
+ if (pageData.meta?.draft === true && !isDevBuild) {
447
+ console.log(` Skipping draft: ${basePath}`);
448
+ continue;
449
+ }
450
+
451
+ const slugs = pageData.meta?.slugs;
452
+
453
+ for (const localeConfig of i18nConfig.locales) {
454
+ const locale = localeConfig.code;
455
+ const isDefault = locale === i18nConfig.defaultLocale;
456
+
457
+ // Compute URL path
458
+ let slug: string;
459
+ if (slugs && slugs[locale]) {
460
+ slug = slugs[locale];
461
+ } else if (basePath === '/') {
462
+ slug = '';
463
+ } else {
464
+ slug = basePath.substring(1);
465
+ }
466
+
467
+ const urlPath = isDefault
468
+ ? (slug === '' ? '/' : `/${slug}`)
469
+ : (slug === '' ? `/${locale}` : `/${locale}/${slug}`);
470
+
471
+ // Determine .astro file path relative to src/pages/
472
+ const astroFileName = slug === '' ? 'index.astro' : `${slug}.astro`;
473
+ const astroFilePath = isDefault ? astroFileName : `${locale}/${astroFileName}`;
474
+ const fileDepth = astroFilePath.split('/').length - 1;
475
+
476
+ const result = await renderPageSSR(
477
+ pageData,
478
+ globalComponents,
479
+ urlPath,
480
+ siteUrl,
481
+ locale,
482
+ i18nConfig,
483
+ slugMappings,
484
+ undefined, // cmsContext
485
+ cmsService,
486
+ true // isProductionBuild
487
+ );
488
+
489
+ processRenderResult(result, urlPath, astroFilePath, fileDepth, pageData, pageName, false);
490
+ console.log(` Rendered: ${urlPath}`);
491
+ }
492
+ } catch (error: any) {
493
+ console.error(` Error rendering ${basePath}:`, error?.message || error);
494
+ errorCount++;
495
+ }
496
+ }
497
+
498
+ // Pre-compute layout dependencies needed by both CMS and regular page emission
499
+ const fontPreloads = generateFontPreloadTags();
500
+ const mergedLibraries = mergeLibraries(globalLibraries, componentLibraries);
501
+ const buildLibraries = filterLibrariesByContext(mergedLibraries, 'build');
502
+ const libraryTags = generateLibraryTags(buildLibraries);
503
+ const defaultTheme = themeConfig.default || 'light';
504
+
505
+ // ---------- CMS template pages ----------
506
+ const templatesDir = projectPaths.templates();
507
+ const templateSchemas: CMSSchema[] = [];
508
+ let cmsPageCount = 0;
509
+
510
+ if (existsSync(templatesDir)) {
511
+ const templateFiles = readdirSync(templatesDir).filter(f => f.endsWith('.json'));
512
+
513
+ if (templateFiles.length > 0) {
514
+ console.log(`\nProcessing ${templateFiles.length} CMS template(s)...\n`);
515
+ }
516
+
517
+ for (const file of templateFiles) {
518
+ const templateContent = await loadJSONFile(join(templatesDir, file));
519
+ if (!templateContent) continue;
520
+
521
+ try {
522
+ const pageData = parseJSON<JSONPage>(templateContent);
523
+
524
+ const isDevBuild = process.env.MENO_DEV_BUILD === 'true';
525
+ if (pageData.meta?.draft === true && !isDevBuild) {
526
+ console.log(` Skipping draft template: ${file}`);
527
+ continue;
528
+ }
529
+
530
+ if (!isCMSPage(pageData)) {
531
+ console.warn(` ${file} is in templates/ but missing meta.source: "cms"`);
532
+ continue;
533
+ }
534
+
535
+ const cmsSchema = pageData.meta!.cms as CMSSchema;
536
+ templateSchemas.push(cmsSchema);
537
+ console.log(` CMS Collection: ${cmsSchema.id}`);
538
+
539
+ // Count items for stats
540
+ const items = await cmsService.queryItems({ collection: cmsSchema.id });
541
+ const itemCount = items.length;
542
+
543
+ if (itemCount === 0) {
544
+ console.log(` No items found in cms/${cmsSchema.id}/`);
545
+ } else {
546
+ console.log(` Found ${itemCount} item(s)`);
547
+ }
548
+
549
+ // Render SSR once for metadata collection (interactive styles, component CSS, JS)
550
+ const defaultLocale = i18nConfig.defaultLocale;
551
+ const dummyPath = cmsSchema.urlPattern.replace('{{slug}}', '__placeholder__');
552
+
553
+ const metaResult = await renderPageSSR(
554
+ pageData,
555
+ globalComponents,
556
+ dummyPath,
557
+ siteUrl,
558
+ defaultLocale,
559
+ i18nConfig,
560
+ slugMappings,
561
+ undefined, // no CMS context - just collecting metadata
562
+ cmsService,
563
+ true
564
+ );
565
+
566
+ // Collect interactive styles and component CSS
567
+ mergeInteractiveStyles(metaResult.interactiveStylesMap);
568
+ if (metaResult.componentCSS) {
569
+ allComponentCSS.add(metaResult.componentCSS);
570
+ }
571
+
572
+ // Deduplicate JavaScript by content hash
573
+ const scriptPaths: string[] = [];
574
+ if (metaResult.javascript) {
575
+ const hash = hashContent(metaResult.javascript);
576
+ if (!jsContents.has(hash)) {
577
+ jsContents.set(hash, metaResult.javascript);
578
+ }
579
+ scriptPaths.push(`/_scripts/${hash}.js`);
580
+ }
581
+
582
+ // Determine route file path from urlPattern
583
+ const isMultiLocale = i18nConfig.locales.length > 1;
584
+ const urlPatternWithoutSlash = cmsSchema.urlPattern.replace(/^\//, '');
585
+ const slugPlaceholderIdx = urlPatternWithoutSlash.indexOf('{{');
586
+ const pathPrefix = slugPlaceholderIdx > 0 ? urlPatternWithoutSlash.substring(0, slugPlaceholderIdx) : '';
587
+
588
+ // Generate CMS page with getStaticPaths()
589
+ const ssrFallbacks = metaResult.ssrFallbackCollector ?? new Map<string, string>();
590
+
591
+ // For each locale (or just default), generate a route file
592
+ const localesToEmit = isMultiLocale ? i18nConfig.locales : [{ code: i18nConfig.defaultLocale }];
593
+
594
+ for (const localeEntry of localesToEmit) {
595
+ const localeCode = localeEntry.code;
596
+ const isDefault = localeCode === i18nConfig.defaultLocale;
597
+
598
+ // Route file path: blog/[slug].astro for default, pl/blog/[slug].astro for non-default
599
+ let astroFilePath: string;
600
+ if (pathPrefix) {
601
+ astroFilePath = isDefault
602
+ ? `${pathPrefix}[slug].astro`
603
+ : `${localeCode}/${pathPrefix}[slug].astro`;
604
+ } else {
605
+ astroFilePath = isDefault
606
+ ? '[slug].astro'
607
+ : `${localeCode}/[slug].astro`;
608
+ }
609
+
610
+ const fileDepth = astroFilePath.split('/').length - 1;
611
+ const importPath = layoutImportPath(fileDepth);
612
+
613
+ const astroContent = emitCMSPage({
614
+ pageData,
615
+ globalComponents,
616
+ cmsSchema,
617
+ title: String(pageData.meta?.title || cmsSchema.name),
618
+ meta: metaResult.meta,
619
+ locale: localeCode,
620
+ theme: defaultTheme,
621
+ fontPreloads,
622
+ libraryTags,
623
+ scriptPaths,
624
+ layoutImportPath: importPath,
625
+ fileDepth,
626
+ ssrFallbacks,
627
+ pageName: file.replace('.json', ''),
628
+ breakpoints,
629
+ imageMetadataMap,
630
+ i18nConfig,
631
+ isMultiLocale: false, // Each file handles one locale
632
+ slugMappings,
633
+ });
634
+
635
+ const astroFileFull = join(pagesOutDir, astroFilePath);
636
+ const astroFileDir = astroFileFull.substring(0, astroFileFull.lastIndexOf('/'));
637
+ if (!existsSync(astroFileDir)) {
638
+ mkdirSync(astroFileDir, { recursive: true });
639
+ }
640
+
641
+ await writeFile(astroFileFull, astroContent, 'utf-8');
642
+ }
643
+
644
+ console.log(` Generated: ${pathPrefix}[slug].astro (${itemCount} items × ${localesToEmit.length} locale(s))`);
645
+
646
+ cmsPageCount += itemCount * i18nConfig.locales.length;
647
+ } catch (error: any) {
648
+ console.error(` Error processing template ${file}:`, error?.message || error);
649
+ errorCount++;
650
+ }
651
+ }
652
+ }
653
+
654
+ // ----------------------------------------------------------
655
+ // 6. Generate global CSS (Tailwind + theme + interactive styles)
656
+ // ----------------------------------------------------------
657
+ // Collect Tailwind safelist classes from mapping variants
658
+ const mappingClasses = collectAllMappingClasses(globalComponents, breakpoints);
659
+
660
+ const fontCSS = generateFontCSS();
661
+ const themeColorCSS = generateThemeColorVariablesCSS(themeConfig);
662
+ const variablesCSS = generateVariablesCSS(variablesConfig, breakpoints, responsiveScales);
663
+ const interactiveCSS = generateAllInteractiveCSS(allInteractiveStyles, breakpoints);
664
+ const componentCSSCombined = Array.from(allComponentCSS).join('\n');
665
+
666
+ const baseCSS = `@layer base {
667
+ * { margin: 0; padding: 0; box-sizing: border-box; }
668
+ body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif; }
669
+ button { background: none; border: none; padding: 0; font: inherit; cursor: pointer; outline: inherit; }
670
+ img { display: block; width: 100%; height: 100%; }
671
+ picture { display: block; }
672
+ .olink { text-decoration: none; display: block; }
673
+ .oem { display: inline-block; }
674
+ }`;
675
+
676
+ const tailwindDirectives = `@tailwind base;
677
+ @tailwind components;
678
+ @tailwind utilities;`;
679
+
680
+ const globalCSS = [tailwindDirectives, fontCSS, themeColorCSS, variablesCSS, baseCSS, componentCSSCombined, interactiveCSS]
681
+ .filter(Boolean)
682
+ .join('\n\n');
683
+
684
+ await writeFile(join(stylesDir, 'global.css'), globalCSS, 'utf-8');
685
+ console.log(`\nGenerated global.css (${(globalCSS.length / 1024).toFixed(1)} KB)`);
686
+
687
+ // ----------------------------------------------------------
688
+ // 7. Generate BaseLayout.astro
689
+ // ----------------------------------------------------------
690
+ const baseLayoutContent = `---
691
+ import '../styles/global.css';
692
+
693
+ interface Props {
694
+ title: string;
695
+ meta?: string;
696
+ scripts?: string[];
697
+ locale?: string;
698
+ theme?: string;
699
+ fontPreloads?: string;
700
+ libraryTags?: { headCSS?: string; headJS?: string; bodyEndJS?: string };
701
+ }
702
+
703
+ const { title, meta = '', scripts = [], locale = 'en', theme = '${themeConfig.default || 'light'}', fontPreloads = '', libraryTags = {} } = Astro.props;
704
+ ---
705
+ <!DOCTYPE html>
706
+ <html lang={locale} data-theme={theme}>
707
+ <head>
708
+ <meta charset="UTF-8">
709
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
710
+ <Fragment set:html={fontPreloads} />
711
+ <Fragment set:html={libraryTags.headCSS || ''} />
712
+ <Fragment set:html={libraryTags.headJS || ''} />
713
+ <Fragment set:html={meta} />
714
+ <title>{title}</title>
715
+ </head>
716
+ <body>
717
+ <slot />
718
+ {scripts.map((s) => <script src={s} />)}
719
+ <Fragment set:html={libraryTags.bodyEndJS || ''} />
720
+ </body>
721
+ </html>
722
+ `;
723
+
724
+ await writeFile(join(layoutsDir, 'BaseLayout.astro'), baseLayoutContent, 'utf-8');
725
+ console.log('Generated BaseLayout.astro');
726
+
727
+ // ----------------------------------------------------------
728
+ // 7.5. Generate component .astro files
729
+ // ----------------------------------------------------------
730
+ let componentFileCount = 0;
731
+ for (const [compName, compDef] of Object.entries(globalComponents)) {
732
+ try {
733
+ const astroContent = emitAstroComponent(compName, compDef, globalComponents, breakpoints, i18nConfig.defaultLocale);
734
+ await writeFile(join(componentsOutDir, `${compName}.astro`), astroContent, 'utf-8');
735
+ componentFileCount++;
736
+ } catch (error: any) {
737
+ console.warn(` Warning: could not generate component ${compName}: ${error?.message}`);
738
+ }
739
+ }
740
+ console.log(`Generated ${componentFileCount} component .astro file(s)`);
741
+
742
+ // ----------------------------------------------------------
743
+ // 8. Generate .astro page files (component-structured)
744
+ // ----------------------------------------------------------
745
+ const allFallbackHtml: string[] = []; // Collect SSR fallback HTML for utility CSS generation
746
+
747
+ for (const result of allResults) {
748
+ const importPath = layoutImportPath(result.fileDepth);
749
+
750
+ // Write JavaScript to public/_scripts/ if present
751
+ const scriptPaths: string[] = [];
752
+ if (result.javascript) {
753
+ const hash = hashContent(result.javascript);
754
+ const scriptFile = `${hash}.js`;
755
+ const scriptPublicPath = `/_scripts/${scriptFile}`;
756
+
757
+ if (!existsSync(scriptsDir)) {
758
+ mkdirSync(scriptsDir, { recursive: true });
759
+ }
760
+
761
+ const fullScriptPath = join(scriptsDir, scriptFile);
762
+ if (!existsSync(fullScriptPath)) {
763
+ await writeFile(fullScriptPath, result.javascript, 'utf-8');
764
+ }
765
+ scriptPaths.push(scriptPublicPath);
766
+ }
767
+
768
+ let astroContent: string;
769
+
770
+ // Use component-structured emission for pages with page data
771
+ if (result.pageData) {
772
+ try {
773
+ // Use SSR fallback collector from the initial render (paths already match nodeToAstro convention)
774
+ const ssrFallbacks = result.ssrFallbackCollector ?? new Map<string, string>();
775
+ ssrFallbacks.forEach((html) => {
776
+ allFallbackHtml.push(html);
777
+ });
778
+
779
+ // Compute slug map for locale list rendering
780
+ const pageSlugMap: Record<string, string> | undefined =
781
+ result.pageData.meta?.slugs
782
+ ? computePageSlugMap(result.pageData.meta.slugs, i18nConfig)
783
+ : undefined;
784
+
785
+ astroContent = emitAstroPage({
786
+ pageData: result.pageData,
787
+ globalComponents,
788
+ title: result.title,
789
+ meta: result.meta,
790
+ locale: result.locale,
791
+ theme: defaultTheme,
792
+ fontPreloads,
793
+ libraryTags,
794
+ scriptPaths,
795
+ layoutImportPath: importPath,
796
+ fileDepth: result.fileDepth,
797
+ ssrFallbacks,
798
+ pageName: result.pageName || 'index',
799
+ breakpoints,
800
+ imageMetadataMap,
801
+ i18nConfig: i18nConfig.locales.length > 1 ? i18nConfig : undefined,
802
+ currentPageSlugMap: pageSlugMap,
803
+ slugMappings: i18nConfig.locales.length > 1 ? slugMappings : undefined,
804
+ });
805
+ } catch (error: any) {
806
+ // Fallback to SSR HTML if component emission fails
807
+ console.warn(` Warning: component emission failed for ${result.urlPath}, using SSR fallback: ${error?.message}`);
808
+ astroContent = buildSSRFallbackPage(result, importPath, fontPreloads, libraryTags, defaultTheme, scriptPaths);
809
+ }
810
+ } else {
811
+ // Pages without pageData: use SSR fallback
812
+ astroContent = buildSSRFallbackPage(result, importPath, fontPreloads, libraryTags, defaultTheme, scriptPaths);
813
+ allFallbackHtml.push(result.html);
814
+ }
815
+
816
+ const astroFileFull = join(pagesOutDir, result.astroFilePath);
817
+ const astroFileDir = astroFileFull.substring(0, astroFileFull.lastIndexOf('/'));
818
+ if (!existsSync(astroFileDir)) {
819
+ mkdirSync(astroFileDir, { recursive: true });
820
+ }
821
+
822
+ await writeFile(astroFileFull, astroContent, 'utf-8');
823
+ }
824
+
825
+ console.log(`Generated ${allResults.length} .astro page file(s)`);
826
+
827
+ // ----------------------------------------------------------
828
+ // 8.5. Generate utility CSS for SSR fallback HTML
829
+ // ----------------------------------------------------------
830
+ if (allFallbackHtml.length > 0) {
831
+ const allClasses = new Set<string>();
832
+ for (const html of allFallbackHtml) {
833
+ for (const cls of extractUtilityClassesFromHTML(html)) {
834
+ allClasses.add(cls);
835
+ }
836
+ }
837
+ if (allClasses.size > 0) {
838
+ const utilityCSS = generateUtilityCSS(allClasses, breakpoints, responsiveScales);
839
+ if (utilityCSS) {
840
+ const existingCSS = await readFile(join(stylesDir, 'global.css'), 'utf-8');
841
+ await writeFile(join(stylesDir, 'global.css'), existingCSS + '\n\n/* SSR fallback utility classes */\n' + utilityCSS, 'utf-8');
842
+ console.log(`Added ${allClasses.size} utility classes for SSR fallback content`);
843
+ }
844
+ }
845
+ }
846
+
847
+ // ----------------------------------------------------------
848
+ // 9. Generate CMS content collections (if templates exist)
849
+ // ----------------------------------------------------------
850
+ let collectionCount = 0;
851
+
852
+ if (templateSchemas.length > 0) {
853
+ const contentDir = join(srcDir, 'content');
854
+ mkdirSync(contentDir, { recursive: true });
855
+
856
+ const collectionDefs: string[] = [];
857
+
858
+ for (const schema of templateSchemas) {
859
+ const collectionDir = join(contentDir, schema.id);
860
+ mkdirSync(collectionDir, { recursive: true });
861
+
862
+ // Copy CMS item JSON files, resolving i18n values to default locale
863
+ const cmsItemsDir = join(projectPaths.cms(), schema.id);
864
+ if (existsSync(cmsItemsDir)) {
865
+ const itemFiles = readdirSync(cmsItemsDir).filter(f => f.endsWith('.json'));
866
+
867
+ for (const itemFile of itemFiles) {
868
+ try {
869
+ const rawContent = await readFile(join(cmsItemsDir, itemFile), 'utf-8');
870
+ const item = JSON.parse(rawContent) as CMSItem;
871
+
872
+ // Keep i18n values as-is so getStaticPaths() can resolve per-locale
873
+ const resolved: Record<string, unknown> = { ...item };
874
+
875
+ await writeFile(
876
+ join(collectionDir, itemFile),
877
+ JSON.stringify(resolved, null, 2),
878
+ 'utf-8'
879
+ );
880
+ } catch (err: any) {
881
+ console.warn(` Warning: could not process CMS item ${itemFile}: ${err?.message}`);
882
+ }
883
+ }
884
+ }
885
+
886
+ // Build Zod schema for this collection
887
+ const fieldDefs: string[] = [];
888
+ if (schema.fields) {
889
+ for (const [fieldName, fieldDef] of Object.entries(schema.fields)) {
890
+ const zodType = cmsFieldToZod(fieldDef);
891
+ const optional = fieldDef.required ? '' : '.optional()';
892
+ fieldDefs.push(` ${fieldName}: ${zodType}${optional}`);
893
+ }
894
+ }
895
+
896
+ collectionDefs.push(` '${schema.id}': defineCollection({
897
+ type: 'data',
898
+ schema: z.object({
899
+ ${fieldDefs.join(',\n')}
900
+ })
901
+ })`);
902
+
903
+ collectionCount++;
904
+ }
905
+
906
+ // Write src/content/config.ts
907
+ const configContent = `import { z, defineCollection } from 'astro:content';
908
+
909
+ const collections = {
910
+ ${collectionDefs.join(',\n')}
911
+ };
912
+
913
+ export { collections };
914
+ `;
915
+
916
+ await writeFile(join(contentDir, 'config.ts'), configContent, 'utf-8');
917
+ console.log(`Generated ${collectionCount} content collection(s) with config.ts`);
918
+ }
919
+
920
+ // ----------------------------------------------------------
921
+ // 10. Copy assets to public/
922
+ // ----------------------------------------------------------
923
+ const assetDirs = ['fonts', 'images', 'icons', 'videos', 'assets'];
924
+ let copiedAssets = 0;
925
+
926
+ for (const dir of assetDirs) {
927
+ const srcAssetDir = join(projectPaths.project, dir);
928
+ if (existsSync(srcAssetDir)) {
929
+ copyDirectory(srcAssetDir, join(publicDir, dir));
930
+ copiedAssets++;
931
+ }
932
+ }
933
+
934
+ // Copy libraries folder if it exists
935
+ const librariesDir = join(projectPaths.project, 'libraries');
936
+ if (existsSync(librariesDir)) {
937
+ copyDirectory(librariesDir, join(publicDir, 'libraries'));
938
+ copiedAssets++;
939
+ }
940
+
941
+ if (copiedAssets > 0) {
942
+ console.log(`Copied ${copiedAssets} asset director${copiedAssets === 1 ? 'y' : 'ies'} to public/`);
943
+ }
944
+
945
+ // ----------------------------------------------------------
946
+ // 11. Generate scaffold files
947
+ // ----------------------------------------------------------
948
+
949
+ // package.json
950
+ const packageJson = {
951
+ name: 'astro-export',
952
+ type: 'module',
953
+ version: '0.0.1',
954
+ private: true,
955
+ scripts: {
956
+ dev: 'astro dev',
957
+ start: 'astro dev',
958
+ build: 'astro build',
959
+ preview: 'astro preview',
960
+ },
961
+ dependencies: {
962
+ 'astro': '^4.0.0',
963
+ '@astrojs/tailwind': '^5.0.0',
964
+ 'tailwindcss': '^3.4.0',
965
+ },
966
+ };
967
+
968
+ await writeFile(join(outDir, 'package.json'), JSON.stringify(packageJson, null, 2), 'utf-8');
969
+
970
+ // astro.config.mjs
971
+ const localeCodes = i18nConfig.locales.map(l => l.code);
972
+ const i18nBlock = i18nConfig.locales.length > 1
973
+ ? `\n i18n: {\n defaultLocale: '${i18nConfig.defaultLocale}',\n locales: [${localeCodes.map(c => `'${c}'`).join(', ')}],\n routing: { prefixDefaultLocale: false },\n },`
974
+ : '';
975
+
976
+ const astroConfig = `import { defineConfig } from 'astro/config';
977
+ import tailwind from '@astrojs/tailwind';
978
+
979
+ export default defineConfig({${siteUrl ? `\n site: '${siteUrl}',` : ''}${i18nBlock}
980
+ integrations: [tailwind({ applyBaseStyles: false })],
981
+ });
982
+ `;
983
+
984
+ // tailwind.config.mjs
985
+ const safelistArray = Array.from(mappingClasses);
986
+ const safelistLiteral = safelistArray.length > 0
987
+ ? `\n safelist: [\n${safelistArray.map(c => ` '${c}'`).join(',\n')}\n ],`
988
+ : '';
989
+
990
+ const tailwindConfig = `/** @type {import('tailwindcss').Config} */
991
+ export default {
992
+ content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],${safelistLiteral}
993
+ theme: {
994
+ extend: {},
995
+ },
996
+ plugins: [],
997
+ };
998
+ `;
999
+
1000
+ await writeFile(join(outDir, 'tailwind.config.mjs'), tailwindConfig, 'utf-8');
1001
+
1002
+ await writeFile(join(outDir, 'astro.config.mjs'), astroConfig, 'utf-8');
1003
+
1004
+ // tsconfig.json
1005
+ const tsConfig = {
1006
+ extends: 'astro/tsconfigs/strict',
1007
+ };
1008
+
1009
+ await writeFile(join(outDir, 'tsconfig.json'), JSON.stringify(tsConfig, null, 2), 'utf-8');
1010
+
1011
+ console.log('Generated package.json, astro.config.mjs, tailwind.config.mjs, tsconfig.json');
1012
+
1013
+ // ----------------------------------------------------------
1014
+ // 12. Summary
1015
+ // ----------------------------------------------------------
1016
+ const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
1017
+ const totalPages = allResults.length;
1018
+
1019
+ console.log('\n' + '='.repeat(50));
1020
+ console.log('Astro export complete!');
1021
+ console.log(` Pages: ${totalPages - cmsPageCount}`);
1022
+ if (cmsPageCount > 0) {
1023
+ console.log(` CMS pages: ${cmsPageCount}`);
1024
+ }
1025
+ if (collectionCount > 0) {
1026
+ console.log(` Content collections: ${collectionCount}`);
1027
+ }
1028
+ if (errorCount > 0) {
1029
+ console.log(` Errors: ${errorCount}`);
1030
+ }
1031
+ console.log(` Time: ${elapsed}s`);
1032
+ console.log(` Output: ${outDir}`);
1033
+ console.log('');
1034
+
1035
+ return {
1036
+ pages: totalPages - cmsPageCount,
1037
+ cmsPages: cmsPageCount,
1038
+ collections: collectionCount,
1039
+ errors: errorCount,
1040
+ };
1041
+ }