@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.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 +5 -3
package/dist/cli.js
CHANGED
|
@@ -140,6 +140,31 @@ __export(compile_theme_exports, {
|
|
|
140
140
|
compileStandaloneThemeDev: () => compileStandaloneThemeDev,
|
|
141
141
|
generateManifest: () => generateManifest
|
|
142
142
|
});
|
|
143
|
+
async function generateThemeCSS(themePath, outDir) {
|
|
144
|
+
try {
|
|
145
|
+
const postcss = (await import('postcss')).default;
|
|
146
|
+
const tailwindcss = (await import('tailwindcss')).default;
|
|
147
|
+
const tailwindConfig = {
|
|
148
|
+
content: [
|
|
149
|
+
path8__default.default.join(themePath, "sections/**/*.{ts,tsx}"),
|
|
150
|
+
path8__default.default.join(themePath, "components/**/*.{ts,tsx}")
|
|
151
|
+
],
|
|
152
|
+
theme: { extend: {} },
|
|
153
|
+
plugins: []
|
|
154
|
+
};
|
|
155
|
+
const inputCSS = "@tailwind base;\n@tailwind components;\n@tailwind utilities;";
|
|
156
|
+
const result = await postcss([tailwindcss(tailwindConfig)]).process(
|
|
157
|
+
inputCSS,
|
|
158
|
+
{ from: void 0 }
|
|
159
|
+
);
|
|
160
|
+
await fs7__default.default.writeFile(path8__default.default.join(outDir, "bundle.css"), result.css);
|
|
161
|
+
logger.info("Generated bundle.css");
|
|
162
|
+
} catch (err) {
|
|
163
|
+
logger.warning(
|
|
164
|
+
`CSS generation skipped: ${err instanceof Error ? err.message : String(err)}`
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
143
168
|
async function resolveNodeModulesFile(startDir, relativePath) {
|
|
144
169
|
let dir = startDir;
|
|
145
170
|
while (true) {
|
|
@@ -463,6 +488,25 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
463
488
|
} catch {
|
|
464
489
|
}
|
|
465
490
|
}
|
|
491
|
+
const schemas = {};
|
|
492
|
+
const sectionsDir = path8__default.default.join(themePath, "sections");
|
|
493
|
+
try {
|
|
494
|
+
const sectionDirs = await fs7__default.default.readdir(sectionsDir);
|
|
495
|
+
for (const dir of sectionDirs) {
|
|
496
|
+
const schemaFile = path8__default.default.join(sectionsDir, dir, `${dir}.schema.ts`);
|
|
497
|
+
try {
|
|
498
|
+
await fs7__default.default.access(schemaFile);
|
|
499
|
+
const mod = await jiti.import(schemaFile);
|
|
500
|
+
for (const [key, value] of Object.entries(mod)) {
|
|
501
|
+
if (key.endsWith("Schema") && value && typeof value === "object" && value.type) {
|
|
502
|
+
schemas[value.type] = value;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
} catch {
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
} catch {
|
|
509
|
+
}
|
|
466
510
|
const pagesDir = path8__default.default.join(themePath, "pages");
|
|
467
511
|
try {
|
|
468
512
|
const files = await fs7__default.default.readdir(pagesDir);
|
|
@@ -472,12 +516,25 @@ async function generateThemeData(themePath, outputDir, themeId) {
|
|
|
472
516
|
try {
|
|
473
517
|
const mod = await jiti.import(path8__default.default.join(pagesDir, file));
|
|
474
518
|
const config = mod.default || mod;
|
|
519
|
+
const sections = (config.sections || []).map((section) => {
|
|
520
|
+
const schema = schemas[section.type];
|
|
521
|
+
if (!schema?.defaults) return section;
|
|
522
|
+
return {
|
|
523
|
+
...section,
|
|
524
|
+
components: section.components?.length > 0 ? section.components : schema.defaults.components || [],
|
|
525
|
+
blocks: section.blocks?.length > 0 ? section.blocks : schema.defaults.blocks || [],
|
|
526
|
+
settings: {
|
|
527
|
+
...schema.defaults.settings || {},
|
|
528
|
+
...section.settings
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
});
|
|
475
532
|
pages[name] = {
|
|
476
533
|
id: name,
|
|
477
534
|
name: config.title || name,
|
|
478
535
|
path: config.path || `/${name}`,
|
|
479
|
-
config: { id: name, ...config },
|
|
480
|
-
sections
|
|
536
|
+
config: { id: name, ...config, sections },
|
|
537
|
+
sections,
|
|
481
538
|
seo: config.seo
|
|
482
539
|
};
|
|
483
540
|
} catch {
|
|
@@ -719,6 +776,7 @@ async function compileStandaloneTheme(themePath, themeName) {
|
|
|
719
776
|
await contentHashEntry(outputDir);
|
|
720
777
|
await generateManifest(themeName, themePath, outputDir);
|
|
721
778
|
await generateThemeData(themePath, outputDir, themeName);
|
|
779
|
+
await generateThemeCSS(themePath, outputDir);
|
|
722
780
|
if (result.metafile) {
|
|
723
781
|
const outputs = result.metafile.outputs;
|
|
724
782
|
let totalSize = 0;
|