@onexapis/cli 1.1.18 → 1.1.20
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 +115 -20
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +115 -20
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/templates/default/package.json +4 -7
package/dist/cli.mjs
CHANGED
|
@@ -2545,6 +2545,79 @@ async function validateCommand(options) {
|
|
|
2545
2545
|
}
|
|
2546
2546
|
}
|
|
2547
2547
|
}
|
|
2548
|
+
if (fs.existsSync(sectionsDir)) {
|
|
2549
|
+
const sections = fs.readdirSync(sectionsDir).filter(
|
|
2550
|
+
(name) => fs.statSync(path8.join(sectionsDir, name)).isDirectory()
|
|
2551
|
+
);
|
|
2552
|
+
for (const sectionName of sections) {
|
|
2553
|
+
const sectionPath = path8.join(sectionsDir, sectionName);
|
|
2554
|
+
const tsxFiles = fs.readdirSync(sectionPath).filter((f) => f.endsWith(".tsx") && !f.endsWith(".schema.ts"));
|
|
2555
|
+
for (const tsxFile of tsxFiles) {
|
|
2556
|
+
const filePath = path8.join(sectionPath, tsxFile);
|
|
2557
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
2558
|
+
const relPath = `sections/${sectionName}/${tsxFile}`;
|
|
2559
|
+
if (!content.includes('"use client"') && !content.includes("'use client'")) {
|
|
2560
|
+
issues.push({
|
|
2561
|
+
type: "error",
|
|
2562
|
+
file: relPath,
|
|
2563
|
+
message: 'Missing "use client" directive at top of file'
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
if (!content.includes("ComponentRenderer") && !content.includes("BlockRenderer")) {
|
|
2567
|
+
issues.push({
|
|
2568
|
+
type: "warning",
|
|
2569
|
+
file: relPath,
|
|
2570
|
+
message: "No ComponentRenderer or BlockRenderer found \u2014 sections should use core renderers for content"
|
|
2571
|
+
});
|
|
2572
|
+
}
|
|
2573
|
+
if (!content.includes("data-section-id")) {
|
|
2574
|
+
issues.push({
|
|
2575
|
+
type: "error",
|
|
2576
|
+
file: relPath,
|
|
2577
|
+
message: "Missing data-section-id attribute \u2014 editor cannot select this section"
|
|
2578
|
+
});
|
|
2579
|
+
}
|
|
2580
|
+
if (/\beval\s*\(/.test(content)) {
|
|
2581
|
+
issues.push({
|
|
2582
|
+
type: "error",
|
|
2583
|
+
file: relPath,
|
|
2584
|
+
message: "eval() detected \u2014 arbitrary code execution risk"
|
|
2585
|
+
});
|
|
2586
|
+
}
|
|
2587
|
+
if (content.includes("document.cookie")) {
|
|
2588
|
+
issues.push({
|
|
2589
|
+
type: "error",
|
|
2590
|
+
file: relPath,
|
|
2591
|
+
message: "document.cookie access \u2014 session hijacking risk"
|
|
2592
|
+
});
|
|
2593
|
+
}
|
|
2594
|
+
if (/\brequire\s*\(/.test(content)) {
|
|
2595
|
+
issues.push({
|
|
2596
|
+
type: "warning",
|
|
2597
|
+
file: relPath,
|
|
2598
|
+
message: "require() detected \u2014 themes should use ES module imports"
|
|
2599
|
+
});
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
const registryPath = path8.join(themePath, "sections-registry.ts");
|
|
2605
|
+
const bundleEntryPath = path8.join(themePath, "bundle-entry.ts");
|
|
2606
|
+
const registryContent = fs.existsSync(registryPath) ? fs.readFileSync(registryPath, "utf-8") : fs.existsSync(bundleEntryPath) ? fs.readFileSync(bundleEntryPath, "utf-8") : "";
|
|
2607
|
+
if (fs.existsSync(sectionsDir) && registryContent) {
|
|
2608
|
+
const sections = fs.readdirSync(sectionsDir).filter(
|
|
2609
|
+
(name) => fs.statSync(path8.join(sectionsDir, name)).isDirectory()
|
|
2610
|
+
);
|
|
2611
|
+
for (const sectionName of sections) {
|
|
2612
|
+
if (!registryContent.includes(`sections/${sectionName}`) && !registryContent.includes(`"${sectionName}"`)) {
|
|
2613
|
+
issues.push({
|
|
2614
|
+
type: "warning",
|
|
2615
|
+
file: `sections/${sectionName}/`,
|
|
2616
|
+
message: "Section not found in sections-registry.ts or bundle-entry.ts \u2014 may not be included in build"
|
|
2617
|
+
});
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2548
2621
|
logger.stopSpinner(true, "Validation complete");
|
|
2549
2622
|
const errors = issues.filter((i) => i.type === "error");
|
|
2550
2623
|
const warnings = issues.filter((i) => i.type === "warning");
|
|
@@ -2657,7 +2730,7 @@ async function buildCommand(options) {
|
|
|
2657
2730
|
logger.stopSpinner(true, "Lint passed");
|
|
2658
2731
|
const pkgJson = fs.readJsonSync(packageJsonPath);
|
|
2659
2732
|
const buildScript = pkgJson.scripts?.build || "";
|
|
2660
|
-
const isRecursive = buildScript.includes("onexthm build") || buildScript.includes("onex-cli build");
|
|
2733
|
+
const isRecursive = buildScript.includes("onexthm build") || buildScript.includes("onex build") || buildScript.includes("onex-cli build");
|
|
2661
2734
|
logger.startSpinner(
|
|
2662
2735
|
options.watch ? "Building (watch mode)..." : "Building..."
|
|
2663
2736
|
);
|
|
@@ -2691,18 +2764,36 @@ function runCommand(command, args, cwd) {
|
|
|
2691
2764
|
return new Promise((resolve) => {
|
|
2692
2765
|
const proc = spawn(command, args, {
|
|
2693
2766
|
cwd,
|
|
2694
|
-
stdio: "pipe",
|
|
2767
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
2695
2768
|
shell: true
|
|
2696
2769
|
});
|
|
2697
|
-
let
|
|
2770
|
+
let stdout = "";
|
|
2771
|
+
let stderr = "";
|
|
2772
|
+
proc.stdout.on("data", (data) => {
|
|
2773
|
+
stdout += data.toString();
|
|
2774
|
+
});
|
|
2698
2775
|
proc.stderr.on("data", (data) => {
|
|
2699
|
-
|
|
2700
|
-
if (message.includes("error") || message.includes("Error") || message.includes("ERROR")) {
|
|
2701
|
-
hasError = true;
|
|
2702
|
-
}
|
|
2776
|
+
stderr += data.toString();
|
|
2703
2777
|
});
|
|
2704
2778
|
proc.on("close", (code) => {
|
|
2705
|
-
|
|
2779
|
+
if (code !== 0) {
|
|
2780
|
+
const output = (stderr + stdout).trim();
|
|
2781
|
+
if (output) {
|
|
2782
|
+
logger.newLine();
|
|
2783
|
+
for (const line of output.split("\n")) {
|
|
2784
|
+
const t = line.trim();
|
|
2785
|
+
if (!t) continue;
|
|
2786
|
+
if (t.includes("error") || t.includes("Error") || t.includes("TS")) {
|
|
2787
|
+
logger.log(` \u274C ${t}`);
|
|
2788
|
+
} else if (t.includes("warning") || t.includes("Warning")) {
|
|
2789
|
+
logger.log(` \u26A0\uFE0F ${t}`);
|
|
2790
|
+
} else {
|
|
2791
|
+
logger.log(` ${t}`);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
resolve(code === 0);
|
|
2706
2797
|
});
|
|
2707
2798
|
proc.on("error", () => {
|
|
2708
2799
|
resolve(false);
|
|
@@ -4490,18 +4581,17 @@ async function publishCommand(options) {
|
|
|
4490
4581
|
}
|
|
4491
4582
|
logger.startSpinner("Building theme...");
|
|
4492
4583
|
try {
|
|
4493
|
-
const {
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
);
|
|
4584
|
+
const { compileStandaloneTheme: compileStandaloneTheme2 } = await Promise.resolve().then(() => (init_compile_theme(), compile_theme_exports));
|
|
4585
|
+
const buildSuccess = await compileStandaloneTheme2(themePath, themeId);
|
|
4586
|
+
if (!buildSuccess) {
|
|
4587
|
+
logger.stopSpinner(false, "Build failed");
|
|
4588
|
+
logger.error("Run 'onexthm build' to see build errors");
|
|
4589
|
+
process.exit(1);
|
|
4590
|
+
}
|
|
4501
4591
|
logger.stopSpinner(true, "Theme compiled");
|
|
4502
|
-
} catch {
|
|
4592
|
+
} catch (error) {
|
|
4503
4593
|
logger.stopSpinner(false, "Build failed");
|
|
4504
|
-
logger.error(
|
|
4594
|
+
logger.error(error instanceof Error ? error.message : "Build error");
|
|
4505
4595
|
process.exit(1);
|
|
4506
4596
|
}
|
|
4507
4597
|
logger.startSpinner("Getting upload URL...");
|
|
@@ -4541,7 +4631,12 @@ async function publishCommand(options) {
|
|
|
4541
4631
|
process.exit(1);
|
|
4542
4632
|
}
|
|
4543
4633
|
const bundleZipPath = path8.join(themePath, "dist", "bundle.zip");
|
|
4544
|
-
await createZip(distDir, bundleZipPath, [
|
|
4634
|
+
await createZip(distDir, bundleZipPath, [
|
|
4635
|
+
"bundle.zip",
|
|
4636
|
+
"source.zip",
|
|
4637
|
+
"preview-runtime.js",
|
|
4638
|
+
"preview-runtime.js.map"
|
|
4639
|
+
]);
|
|
4545
4640
|
const bundleBuffer = fs.readFileSync(bundleZipPath);
|
|
4546
4641
|
const bundleRes = await fetch(bundleUploadUrl, {
|
|
4547
4642
|
method: "PUT",
|
|
@@ -4637,7 +4732,7 @@ async function createZip(sourceDir, outputPath, exclude) {
|
|
|
4637
4732
|
archive.pipe(output);
|
|
4638
4733
|
archive.glob("**/*", {
|
|
4639
4734
|
cwd: sourceDir,
|
|
4640
|
-
ignore: exclude.
|
|
4735
|
+
ignore: exclude.flatMap((e) => [e, `${e}/**`]),
|
|
4641
4736
|
dot: false
|
|
4642
4737
|
});
|
|
4643
4738
|
archive.finalize();
|