@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.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;
|
|
@@ -4623,18 +4681,17 @@ async function publishCommand(options) {
|
|
|
4623
4681
|
}
|
|
4624
4682
|
logger.startSpinner("Building theme...");
|
|
4625
4683
|
try {
|
|
4626
|
-
const {
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
);
|
|
4684
|
+
const { compileStandaloneTheme: compileStandaloneTheme2 } = await Promise.resolve().then(() => (init_compile_theme(), compile_theme_exports));
|
|
4685
|
+
const buildSuccess = await compileStandaloneTheme2(themePath, themeId);
|
|
4686
|
+
if (!buildSuccess) {
|
|
4687
|
+
logger.stopSpinner(false, "Build failed");
|
|
4688
|
+
logger.error("Run 'onexthm build' to see build errors");
|
|
4689
|
+
process.exit(1);
|
|
4690
|
+
}
|
|
4634
4691
|
logger.stopSpinner(true, "Theme compiled");
|
|
4635
|
-
} catch {
|
|
4692
|
+
} catch (error) {
|
|
4636
4693
|
logger.stopSpinner(false, "Build failed");
|
|
4637
|
-
logger.error(
|
|
4694
|
+
logger.error(error instanceof Error ? error.message : "Build error");
|
|
4638
4695
|
process.exit(1);
|
|
4639
4696
|
}
|
|
4640
4697
|
logger.startSpinner("Getting upload URL...");
|
|
@@ -4674,7 +4731,12 @@ async function publishCommand(options) {
|
|
|
4674
4731
|
process.exit(1);
|
|
4675
4732
|
}
|
|
4676
4733
|
const bundleZipPath = path8__default.default.join(themePath, "dist", "bundle.zip");
|
|
4677
|
-
await createZip(distDir, bundleZipPath, [
|
|
4734
|
+
await createZip(distDir, bundleZipPath, [
|
|
4735
|
+
"bundle.zip",
|
|
4736
|
+
"source.zip",
|
|
4737
|
+
"preview-runtime.js",
|
|
4738
|
+
"preview-runtime.js.map"
|
|
4739
|
+
]);
|
|
4678
4740
|
const bundleBuffer = fs__default.default.readFileSync(bundleZipPath);
|
|
4679
4741
|
const bundleRes = await fetch(bundleUploadUrl, {
|
|
4680
4742
|
method: "PUT",
|
|
@@ -4770,7 +4832,7 @@ async function createZip(sourceDir, outputPath, exclude) {
|
|
|
4770
4832
|
archive.pipe(output);
|
|
4771
4833
|
archive.glob("**/*", {
|
|
4772
4834
|
cwd: sourceDir,
|
|
4773
|
-
ignore: exclude.
|
|
4835
|
+
ignore: exclude.flatMap((e) => [e, `${e}/**`]),
|
|
4774
4836
|
dot: false
|
|
4775
4837
|
});
|
|
4776
4838
|
archive.finalize();
|