@onexapis/cli 1.1.20 → 1.1.21

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