@onexapis/cli 1.1.20 → 1.1.22

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/cli.mjs CHANGED
@@ -98,6 +98,31 @@ __export(compile_theme_exports, {
98
98
  compileStandaloneThemeDev: () => compileStandaloneThemeDev,
99
99
  generateManifest: () => generateManifest
100
100
  });
101
+ async function generateThemeCSS(themePath, outDir) {
102
+ try {
103
+ const postcss = (await import('postcss')).default;
104
+ const tailwindcss = (await import('tailwindcss')).default;
105
+ const tailwindConfig = {
106
+ content: [
107
+ path8.join(themePath, "sections/**/*.{ts,tsx}"),
108
+ path8.join(themePath, "components/**/*.{ts,tsx}")
109
+ ],
110
+ theme: { extend: {} },
111
+ plugins: []
112
+ };
113
+ const inputCSS = "@tailwind base;\n@tailwind components;\n@tailwind utilities;";
114
+ const result = await postcss([tailwindcss(tailwindConfig)]).process(
115
+ inputCSS,
116
+ { from: void 0 }
117
+ );
118
+ await fs7.writeFile(path8.join(outDir, "bundle.css"), result.css);
119
+ logger.info("Generated bundle.css");
120
+ } catch (err) {
121
+ logger.warning(
122
+ `CSS generation skipped: ${err instanceof Error ? err.message : String(err)}`
123
+ );
124
+ }
125
+ }
101
126
  async function resolveNodeModulesFile(startDir, relativePath) {
102
127
  let dir = startDir;
103
128
  while (true) {
@@ -421,6 +446,25 @@ async function generateThemeData(themePath, outputDir, themeId) {
421
446
  } catch {
422
447
  }
423
448
  }
449
+ const schemas = {};
450
+ const sectionsDir = path8.join(themePath, "sections");
451
+ try {
452
+ const sectionDirs = await fs7.readdir(sectionsDir);
453
+ for (const dir of sectionDirs) {
454
+ const schemaFile = path8.join(sectionsDir, dir, `${dir}.schema.ts`);
455
+ try {
456
+ await fs7.access(schemaFile);
457
+ const mod = await jiti.import(schemaFile);
458
+ for (const [key, value] of Object.entries(mod)) {
459
+ if (key.endsWith("Schema") && value && typeof value === "object" && value.type) {
460
+ schemas[value.type] = value;
461
+ }
462
+ }
463
+ } catch {
464
+ }
465
+ }
466
+ } catch {
467
+ }
424
468
  const pagesDir = path8.join(themePath, "pages");
425
469
  try {
426
470
  const files = await fs7.readdir(pagesDir);
@@ -430,12 +474,25 @@ async function generateThemeData(themePath, outputDir, themeId) {
430
474
  try {
431
475
  const mod = await jiti.import(path8.join(pagesDir, file));
432
476
  const config = mod.default || mod;
477
+ const sections = (config.sections || []).map((section) => {
478
+ const schema = schemas[section.type];
479
+ if (!schema?.defaults) return section;
480
+ return {
481
+ ...section,
482
+ components: section.components?.length > 0 ? section.components : schema.defaults.components || [],
483
+ blocks: section.blocks?.length > 0 ? section.blocks : schema.defaults.blocks || [],
484
+ settings: {
485
+ ...schema.defaults.settings || {},
486
+ ...section.settings
487
+ }
488
+ };
489
+ });
433
490
  pages[name] = {
434
491
  id: name,
435
492
  name: config.title || name,
436
493
  path: config.path || `/${name}`,
437
- config: { id: name, ...config },
438
- sections: config.sections || [],
494
+ config: { id: name, ...config, sections },
495
+ sections,
439
496
  seo: config.seo
440
497
  };
441
498
  } catch {
@@ -677,6 +734,7 @@ async function compileStandaloneTheme(themePath, themeName) {
677
734
  await contentHashEntry(outputDir);
678
735
  await generateManifest(themeName, themePath, outputDir);
679
736
  await generateThemeData(themePath, outputDir, themeName);
737
+ await generateThemeCSS(themePath, outputDir);
680
738
  if (result.metafile) {
681
739
  const outputs = result.metafile.outputs;
682
740
  let totalSize = 0;