@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/cli.js +60 -2
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +60 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +60 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -2
- package/dist/index.mjs.map +1 -1
- package/dist/preview/preview-app.tsx +47 -45
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -133,6 +133,31 @@ __export(compile_theme_exports, {
|
|
|
133
133
|
compileStandaloneThemeDev: () => compileStandaloneThemeDev,
|
|
134
134
|
generateManifest: () => generateManifest
|
|
135
135
|
});
|
|
136
|
+
async function generateThemeCSS(themePath, outDir) {
|
|
137
|
+
try {
|
|
138
|
+
const postcss = (await import('postcss')).default;
|
|
139
|
+
const tailwindcss = (await import('tailwindcss')).default;
|
|
140
|
+
const tailwindConfig = {
|
|
141
|
+
content: [
|
|
142
|
+
path7__default.default.join(themePath, "sections/**/*.{ts,tsx}"),
|
|
143
|
+
path7__default.default.join(themePath, "components/**/*.{ts,tsx}")
|
|
144
|
+
],
|
|
145
|
+
theme: { extend: {} },
|
|
146
|
+
plugins: []
|
|
147
|
+
};
|
|
148
|
+
const inputCSS = "@tailwind base;\n@tailwind components;\n@tailwind utilities;";
|
|
149
|
+
const result = await postcss([tailwindcss(tailwindConfig)]).process(
|
|
150
|
+
inputCSS,
|
|
151
|
+
{ from: void 0 }
|
|
152
|
+
);
|
|
153
|
+
await fs6__default.default.writeFile(path7__default.default.join(outDir, "bundle.css"), result.css);
|
|
154
|
+
exports.logger.info("Generated bundle.css");
|
|
155
|
+
} catch (err) {
|
|
156
|
+
exports.logger.warning(
|
|
157
|
+
`CSS generation skipped: ${err instanceof Error ? err.message : String(err)}`
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
136
161
|
async function resolveNodeModulesFile(startDir, relativePath) {
|
|
137
162
|
let dir = startDir;
|
|
138
163
|
while (true) {
|
|
@@ -456,6 +481,25 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
456
481
|
} catch {
|
|
457
482
|
}
|
|
458
483
|
}
|
|
484
|
+
const schemas = {};
|
|
485
|
+
const sectionsDir = path7__default.default.join(themePath, "sections");
|
|
486
|
+
try {
|
|
487
|
+
const sectionDirs = await fs6__default.default.readdir(sectionsDir);
|
|
488
|
+
for (const dir of sectionDirs) {
|
|
489
|
+
const schemaFile = path7__default.default.join(sectionsDir, dir, `${dir}.schema.ts`);
|
|
490
|
+
try {
|
|
491
|
+
await fs6__default.default.access(schemaFile);
|
|
492
|
+
const mod = await jiti.import(schemaFile);
|
|
493
|
+
for (const [key, value] of Object.entries(mod)) {
|
|
494
|
+
if (key.endsWith("Schema") && value && typeof value === "object" && value.type) {
|
|
495
|
+
schemas[value.type] = value;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
} catch {
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
} catch {
|
|
502
|
+
}
|
|
459
503
|
const pagesDir = path7__default.default.join(themePath, "pages");
|
|
460
504
|
try {
|
|
461
505
|
const files = await fs6__default.default.readdir(pagesDir);
|
|
@@ -465,12 +509,25 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
465
509
|
try {
|
|
466
510
|
const mod = await jiti.import(path7__default.default.join(pagesDir, file));
|
|
467
511
|
const config = mod.default || mod;
|
|
512
|
+
const sections = (config.sections || []).map((section) => {
|
|
513
|
+
const schema = schemas[section.type];
|
|
514
|
+
if (!schema?.defaults) return section;
|
|
515
|
+
return {
|
|
516
|
+
...section,
|
|
517
|
+
components: section.components?.length > 0 ? section.components : schema.defaults.components || [],
|
|
518
|
+
blocks: section.blocks?.length > 0 ? section.blocks : schema.defaults.blocks || [],
|
|
519
|
+
settings: {
|
|
520
|
+
...schema.defaults.settings || {},
|
|
521
|
+
...section.settings
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
});
|
|
468
525
|
pages[name] = {
|
|
469
526
|
id: name,
|
|
470
527
|
name: config.title || name,
|
|
471
528
|
path: config.path || `/${name}`,
|
|
472
|
-
config: { id: name, ...config },
|
|
473
|
-
sections
|
|
529
|
+
config: { id: name, ...config, sections },
|
|
530
|
+
sections,
|
|
474
531
|
seo: config.seo
|
|
475
532
|
};
|
|
476
533
|
} catch {
|
|
@@ -712,6 +769,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
712
769
|
await contentHashEntry(outputDir);
|
|
713
770
|
await generateManifest(themeName, themePath, outputDir);
|
|
714
771
|
await generateThemeData(themePath, outputDir, themeName);
|
|
772
|
+
await generateThemeCSS(themePath, outputDir);
|
|
715
773
|
if (result.metafile) {
|
|
716
774
|
const outputs = result.metafile.outputs;
|
|
717
775
|
let totalSize = 0;
|