@onexapis/cli 1.1.18 → 1.1.19
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 +99 -8
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +99 -8
- 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.js
CHANGED
|
@@ -2587,6 +2587,79 @@ async function validateCommand(options) {
|
|
|
2587
2587
|
}
|
|
2588
2588
|
}
|
|
2589
2589
|
}
|
|
2590
|
+
if (fs__default.default.existsSync(sectionsDir)) {
|
|
2591
|
+
const sections = fs__default.default.readdirSync(sectionsDir).filter(
|
|
2592
|
+
(name) => fs__default.default.statSync(path8__default.default.join(sectionsDir, name)).isDirectory()
|
|
2593
|
+
);
|
|
2594
|
+
for (const sectionName of sections) {
|
|
2595
|
+
const sectionPath = path8__default.default.join(sectionsDir, sectionName);
|
|
2596
|
+
const tsxFiles = fs__default.default.readdirSync(sectionPath).filter((f) => f.endsWith(".tsx") && !f.endsWith(".schema.ts"));
|
|
2597
|
+
for (const tsxFile of tsxFiles) {
|
|
2598
|
+
const filePath = path8__default.default.join(sectionPath, tsxFile);
|
|
2599
|
+
const content = fs__default.default.readFileSync(filePath, "utf-8");
|
|
2600
|
+
const relPath = `sections/${sectionName}/${tsxFile}`;
|
|
2601
|
+
if (!content.includes('"use client"') && !content.includes("'use client'")) {
|
|
2602
|
+
issues.push({
|
|
2603
|
+
type: "error",
|
|
2604
|
+
file: relPath,
|
|
2605
|
+
message: 'Missing "use client" directive at top of file'
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
if (!content.includes("ComponentRenderer") && !content.includes("BlockRenderer")) {
|
|
2609
|
+
issues.push({
|
|
2610
|
+
type: "warning",
|
|
2611
|
+
file: relPath,
|
|
2612
|
+
message: "No ComponentRenderer or BlockRenderer found \u2014 sections should use core renderers for content"
|
|
2613
|
+
});
|
|
2614
|
+
}
|
|
2615
|
+
if (!content.includes("data-section-id")) {
|
|
2616
|
+
issues.push({
|
|
2617
|
+
type: "error",
|
|
2618
|
+
file: relPath,
|
|
2619
|
+
message: "Missing data-section-id attribute \u2014 editor cannot select this section"
|
|
2620
|
+
});
|
|
2621
|
+
}
|
|
2622
|
+
if (/\beval\s*\(/.test(content)) {
|
|
2623
|
+
issues.push({
|
|
2624
|
+
type: "error",
|
|
2625
|
+
file: relPath,
|
|
2626
|
+
message: "eval() detected \u2014 arbitrary code execution risk"
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2629
|
+
if (content.includes("document.cookie")) {
|
|
2630
|
+
issues.push({
|
|
2631
|
+
type: "error",
|
|
2632
|
+
file: relPath,
|
|
2633
|
+
message: "document.cookie access \u2014 session hijacking risk"
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
if (/\brequire\s*\(/.test(content)) {
|
|
2637
|
+
issues.push({
|
|
2638
|
+
type: "warning",
|
|
2639
|
+
file: relPath,
|
|
2640
|
+
message: "require() detected \u2014 themes should use ES module imports"
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
const registryPath = path8__default.default.join(themePath, "sections-registry.ts");
|
|
2647
|
+
const bundleEntryPath = path8__default.default.join(themePath, "bundle-entry.ts");
|
|
2648
|
+
const registryContent = fs__default.default.existsSync(registryPath) ? fs__default.default.readFileSync(registryPath, "utf-8") : fs__default.default.existsSync(bundleEntryPath) ? fs__default.default.readFileSync(bundleEntryPath, "utf-8") : "";
|
|
2649
|
+
if (fs__default.default.existsSync(sectionsDir) && registryContent) {
|
|
2650
|
+
const sections = fs__default.default.readdirSync(sectionsDir).filter(
|
|
2651
|
+
(name) => fs__default.default.statSync(path8__default.default.join(sectionsDir, name)).isDirectory()
|
|
2652
|
+
);
|
|
2653
|
+
for (const sectionName of sections) {
|
|
2654
|
+
if (!registryContent.includes(`sections/${sectionName}`) && !registryContent.includes(`"${sectionName}"`)) {
|
|
2655
|
+
issues.push({
|
|
2656
|
+
type: "warning",
|
|
2657
|
+
file: `sections/${sectionName}/`,
|
|
2658
|
+
message: "Section not found in sections-registry.ts or bundle-entry.ts \u2014 may not be included in build"
|
|
2659
|
+
});
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2590
2663
|
logger.stopSpinner(true, "Validation complete");
|
|
2591
2664
|
const errors = issues.filter((i) => i.type === "error");
|
|
2592
2665
|
const warnings = issues.filter((i) => i.type === "warning");
|
|
@@ -2699,7 +2772,7 @@ async function buildCommand(options) {
|
|
|
2699
2772
|
logger.stopSpinner(true, "Lint passed");
|
|
2700
2773
|
const pkgJson = fs__default.default.readJsonSync(packageJsonPath);
|
|
2701
2774
|
const buildScript = pkgJson.scripts?.build || "";
|
|
2702
|
-
const isRecursive = buildScript.includes("onexthm build") || buildScript.includes("onex-cli build");
|
|
2775
|
+
const isRecursive = buildScript.includes("onexthm build") || buildScript.includes("onex build") || buildScript.includes("onex-cli build");
|
|
2703
2776
|
logger.startSpinner(
|
|
2704
2777
|
options.watch ? "Building (watch mode)..." : "Building..."
|
|
2705
2778
|
);
|
|
@@ -2733,18 +2806,36 @@ function runCommand(command, args, cwd) {
|
|
|
2733
2806
|
return new Promise((resolve) => {
|
|
2734
2807
|
const proc = child_process.spawn(command, args, {
|
|
2735
2808
|
cwd,
|
|
2736
|
-
stdio: "pipe",
|
|
2809
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
2737
2810
|
shell: true
|
|
2738
2811
|
});
|
|
2739
|
-
let
|
|
2812
|
+
let stdout = "";
|
|
2813
|
+
let stderr = "";
|
|
2814
|
+
proc.stdout.on("data", (data) => {
|
|
2815
|
+
stdout += data.toString();
|
|
2816
|
+
});
|
|
2740
2817
|
proc.stderr.on("data", (data) => {
|
|
2741
|
-
|
|
2742
|
-
if (message.includes("error") || message.includes("Error") || message.includes("ERROR")) {
|
|
2743
|
-
hasError = true;
|
|
2744
|
-
}
|
|
2818
|
+
stderr += data.toString();
|
|
2745
2819
|
});
|
|
2746
2820
|
proc.on("close", (code) => {
|
|
2747
|
-
|
|
2821
|
+
if (code !== 0) {
|
|
2822
|
+
const output = (stderr + stdout).trim();
|
|
2823
|
+
if (output) {
|
|
2824
|
+
logger.newLine();
|
|
2825
|
+
for (const line of output.split("\n")) {
|
|
2826
|
+
const t = line.trim();
|
|
2827
|
+
if (!t) continue;
|
|
2828
|
+
if (t.includes("error") || t.includes("Error") || t.includes("TS")) {
|
|
2829
|
+
logger.log(` \u274C ${t}`);
|
|
2830
|
+
} else if (t.includes("warning") || t.includes("Warning")) {
|
|
2831
|
+
logger.log(` \u26A0\uFE0F ${t}`);
|
|
2832
|
+
} else {
|
|
2833
|
+
logger.log(` ${t}`);
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
resolve(code === 0);
|
|
2748
2839
|
});
|
|
2749
2840
|
proc.on("error", () => {
|
|
2750
2841
|
resolve(false);
|