@onexapis/cli 1.1.19 → 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 +76 -14
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +76 -14
- 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/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
|
|
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;
|
|
@@ -4581,18 +4639,17 @@ async function publishCommand(options) {
|
|
|
4581
4639
|
}
|
|
4582
4640
|
logger.startSpinner("Building theme...");
|
|
4583
4641
|
try {
|
|
4584
|
-
const {
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
);
|
|
4642
|
+
const { compileStandaloneTheme: compileStandaloneTheme2 } = await Promise.resolve().then(() => (init_compile_theme(), compile_theme_exports));
|
|
4643
|
+
const buildSuccess = await compileStandaloneTheme2(themePath, themeId);
|
|
4644
|
+
if (!buildSuccess) {
|
|
4645
|
+
logger.stopSpinner(false, "Build failed");
|
|
4646
|
+
logger.error("Run 'onexthm build' to see build errors");
|
|
4647
|
+
process.exit(1);
|
|
4648
|
+
}
|
|
4592
4649
|
logger.stopSpinner(true, "Theme compiled");
|
|
4593
|
-
} catch {
|
|
4650
|
+
} catch (error) {
|
|
4594
4651
|
logger.stopSpinner(false, "Build failed");
|
|
4595
|
-
logger.error(
|
|
4652
|
+
logger.error(error instanceof Error ? error.message : "Build error");
|
|
4596
4653
|
process.exit(1);
|
|
4597
4654
|
}
|
|
4598
4655
|
logger.startSpinner("Getting upload URL...");
|
|
@@ -4632,7 +4689,12 @@ async function publishCommand(options) {
|
|
|
4632
4689
|
process.exit(1);
|
|
4633
4690
|
}
|
|
4634
4691
|
const bundleZipPath = path8.join(themePath, "dist", "bundle.zip");
|
|
4635
|
-
await createZip(distDir, bundleZipPath, [
|
|
4692
|
+
await createZip(distDir, bundleZipPath, [
|
|
4693
|
+
"bundle.zip",
|
|
4694
|
+
"source.zip",
|
|
4695
|
+
"preview-runtime.js",
|
|
4696
|
+
"preview-runtime.js.map"
|
|
4697
|
+
]);
|
|
4636
4698
|
const bundleBuffer = fs.readFileSync(bundleZipPath);
|
|
4637
4699
|
const bundleRes = await fetch(bundleUploadUrl, {
|
|
4638
4700
|
method: "PUT",
|
|
@@ -4728,7 +4790,7 @@ async function createZip(sourceDir, outputPath, exclude) {
|
|
|
4728
4790
|
archive.pipe(output);
|
|
4729
4791
|
archive.glob("**/*", {
|
|
4730
4792
|
cwd: sourceDir,
|
|
4731
|
-
ignore: exclude.
|
|
4793
|
+
ignore: exclude.flatMap((e) => [e, `${e}/**`]),
|
|
4732
4794
|
dot: false
|
|
4733
4795
|
});
|
|
4734
4796
|
archive.finalize();
|