@object-ui/cli 0.5.0 → 3.0.0
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
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
parseSchemaFile,
|
|
7
7
|
scanPagesDirectory,
|
|
8
8
|
serve
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LWXDPPSW.js";
|
|
10
10
|
|
|
11
11
|
// src/cli.ts
|
|
12
12
|
import { Command } from "commander";
|
|
@@ -49,6 +49,15 @@ async function dev(schemaPath, options) {
|
|
|
49
49
|
if (existsSync(localPagesDir)) {
|
|
50
50
|
hasPagesDir = true;
|
|
51
51
|
pagesDir = localPagesDir;
|
|
52
|
+
const appJsonPath = join(cwd, "app.json");
|
|
53
|
+
if (existsSync(appJsonPath)) {
|
|
54
|
+
try {
|
|
55
|
+
appConfig = parseSchemaFile(appJsonPath);
|
|
56
|
+
console.log(chalk.blue("\u2699\uFE0F Loaded App Config from app.json"));
|
|
57
|
+
} catch (_e) {
|
|
58
|
+
console.warn("Failed to parse app.json config");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
52
61
|
}
|
|
53
62
|
}
|
|
54
63
|
const require2 = createRequire(join(cwd, "package.json"));
|
|
@@ -534,12 +543,61 @@ async function doctor() {
|
|
|
534
543
|
issues++;
|
|
535
544
|
}
|
|
536
545
|
const tailwindConfigPath = join7(cwd, "tailwind.config.js");
|
|
537
|
-
|
|
538
|
-
|
|
546
|
+
const tailwindTsPath = join7(cwd, "tailwind.config.ts");
|
|
547
|
+
if (existsSync7(tailwindConfigPath) || existsSync7(tailwindTsPath)) {
|
|
548
|
+
const configFile = existsSync7(tailwindConfigPath) ? "tailwind.config.js" : "tailwind.config.ts";
|
|
549
|
+
const configPath = existsSync7(tailwindConfigPath) ? tailwindConfigPath : tailwindTsPath;
|
|
550
|
+
console.log(chalk7.green(`\u2713 ${configFile} found`));
|
|
551
|
+
try {
|
|
552
|
+
const configContent = readFileSync(configPath, "utf-8");
|
|
553
|
+
if (configContent.includes("content") && (configContent.includes("./src") || configContent.includes("./app") || configContent.includes("./pages"))) {
|
|
554
|
+
console.log(chalk7.green("\u2713 Tailwind content paths configured"));
|
|
555
|
+
} else {
|
|
556
|
+
console.log(chalk7.yellow("\u26A0\uFE0F Tailwind content paths may not be configured. Ensure your content array includes source directories."));
|
|
557
|
+
issues++;
|
|
558
|
+
}
|
|
559
|
+
} catch (_e) {
|
|
560
|
+
}
|
|
539
561
|
} else {
|
|
540
562
|
console.log(chalk7.yellow("\u26A0\uFE0F tailwind.config.js not found"));
|
|
541
563
|
issues++;
|
|
542
564
|
}
|
|
565
|
+
const tsConfigPath = join7(cwd, "tsconfig.json");
|
|
566
|
+
if (existsSync7(tsConfigPath)) {
|
|
567
|
+
console.log(chalk7.green("\u2713 tsconfig.json found"));
|
|
568
|
+
try {
|
|
569
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
570
|
+
const tsVer = pkg.devDependencies?.typescript || pkg.dependencies?.typescript;
|
|
571
|
+
if (tsVer) {
|
|
572
|
+
const majorVer = parseInt(tsVer.replace(/[^0-9.]/g, "").split(".")[0], 10);
|
|
573
|
+
if (majorVer >= 5) {
|
|
574
|
+
console.log(chalk7.green(`\u2713 TypeScript ${tsVer} (5.0+ required)`));
|
|
575
|
+
} else {
|
|
576
|
+
console.log(chalk7.yellow(`\u26A0\uFE0F TypeScript ${tsVer} detected \u2014 version 5.0+ recommended`));
|
|
577
|
+
issues++;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
} catch (_e) {
|
|
581
|
+
}
|
|
582
|
+
} else {
|
|
583
|
+
console.log(chalk7.yellow("\u26A0\uFE0F tsconfig.json not found"));
|
|
584
|
+
issues++;
|
|
585
|
+
}
|
|
586
|
+
if (existsSync7(pkgPath)) {
|
|
587
|
+
try {
|
|
588
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
589
|
+
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
590
|
+
if (allDeps["@object-ui/react"] && !allDeps["react"]) {
|
|
591
|
+
console.log(chalk7.yellow("\u26A0\uFE0F @object-ui/react requires react as a peer dependency"));
|
|
592
|
+
issues++;
|
|
593
|
+
}
|
|
594
|
+
if (allDeps["@object-ui/components"] && !allDeps["tailwindcss"]) {
|
|
595
|
+
console.log(chalk7.yellow("\u26A0\uFE0F @object-ui/components requires tailwindcss as a peer dependency"));
|
|
596
|
+
issues++;
|
|
597
|
+
}
|
|
598
|
+
} catch (_e) {
|
|
599
|
+
}
|
|
600
|
+
}
|
|
543
601
|
console.log("\nResult:");
|
|
544
602
|
if (issues === 0) {
|
|
545
603
|
console.log(chalk7.green("Everything looks good! \u2728"));
|
|
@@ -558,16 +616,54 @@ async function add(component) {
|
|
|
558
616
|
|
|
559
617
|
// src/commands/studio.ts
|
|
560
618
|
import chalk9 from "chalk";
|
|
619
|
+
import { spawn } from "child_process";
|
|
620
|
+
import { existsSync as existsSync8 } from "fs";
|
|
621
|
+
import { join as join8, resolve as resolve4, dirname as dirname2 } from "path";
|
|
622
|
+
import { fileURLToPath } from "url";
|
|
561
623
|
async function studio() {
|
|
562
|
-
console.log(chalk9.bold("Starting
|
|
563
|
-
|
|
624
|
+
console.log(chalk9.bold("\n\u{1F3A8} Starting ObjectUI Studio...\n"));
|
|
625
|
+
const cwd = process.cwd();
|
|
626
|
+
const __filename3 = fileURLToPath(import.meta.url);
|
|
627
|
+
const __dirname3 = dirname2(__filename3);
|
|
628
|
+
const candidates = [
|
|
629
|
+
join8(cwd, "apps/console"),
|
|
630
|
+
resolve4(__dirname3, "../../apps/console"),
|
|
631
|
+
resolve4(__dirname3, "../../../apps/console")
|
|
632
|
+
];
|
|
633
|
+
let consolePath = null;
|
|
634
|
+
for (const candidate of candidates) {
|
|
635
|
+
if (existsSync8(join8(candidate, "package.json"))) {
|
|
636
|
+
consolePath = candidate;
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
if (!consolePath) {
|
|
641
|
+
console.log(chalk9.yellow("\u26A0 Console app not found in workspace."));
|
|
642
|
+
console.log(chalk9.dim(" Hint: Run this command from the monorepo root."));
|
|
643
|
+
console.log(chalk9.dim(" Expected: apps/console/package.json\n"));
|
|
644
|
+
process.exit(1);
|
|
645
|
+
}
|
|
646
|
+
console.log(chalk9.dim(` Console: ${consolePath}`));
|
|
647
|
+
console.log(chalk9.dim(" Mode: MSW (in-browser mock server)\n"));
|
|
648
|
+
const child = spawn("pnpm", ["run", "dev"], {
|
|
649
|
+
cwd: consolePath,
|
|
650
|
+
stdio: "inherit",
|
|
651
|
+
env: { ...process.env, NODE_ENV: "development" },
|
|
652
|
+
shell: true
|
|
653
|
+
});
|
|
654
|
+
child.on("error", (err) => {
|
|
655
|
+
console.error(chalk9.red(`
|
|
656
|
+
\u2717 Failed to start studio: ${err.message}`));
|
|
657
|
+
process.exit(1);
|
|
658
|
+
});
|
|
659
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
564
660
|
}
|
|
565
661
|
|
|
566
662
|
// src/commands/check.ts
|
|
567
663
|
import chalk10 from "chalk";
|
|
568
664
|
import { globSync } from "glob";
|
|
569
665
|
import { readFileSync as readFileSync2 } from "fs";
|
|
570
|
-
import { join as
|
|
666
|
+
import { join as join9 } from "path";
|
|
571
667
|
async function check() {
|
|
572
668
|
console.log(chalk10.bold("Object UI Schema Check"));
|
|
573
669
|
const cwd = process.cwd();
|
|
@@ -580,7 +676,31 @@ async function check() {
|
|
|
580
676
|
for (const file of files) {
|
|
581
677
|
try {
|
|
582
678
|
if (file.endsWith(".json")) {
|
|
583
|
-
JSON.parse(readFileSync2(
|
|
679
|
+
const content = JSON.parse(readFileSync2(join9(cwd, file), "utf-8"));
|
|
680
|
+
if (content && typeof content === "object" && content.type) {
|
|
681
|
+
const knownTypes = [
|
|
682
|
+
"page",
|
|
683
|
+
"form",
|
|
684
|
+
"grid",
|
|
685
|
+
"crud",
|
|
686
|
+
"kanban",
|
|
687
|
+
"calendar",
|
|
688
|
+
"dashboard",
|
|
689
|
+
"chart",
|
|
690
|
+
"detail",
|
|
691
|
+
"list",
|
|
692
|
+
"timeline",
|
|
693
|
+
"gantt",
|
|
694
|
+
"map",
|
|
695
|
+
"gallery",
|
|
696
|
+
"object-view",
|
|
697
|
+
"detail-view",
|
|
698
|
+
"object-chart"
|
|
699
|
+
];
|
|
700
|
+
if (typeof content.type === "string" && !knownTypes.includes(content.type)) {
|
|
701
|
+
console.log(chalk10.yellow(`\u26A0\uFE0F Unknown schema type "${content.type}" in ${file}`));
|
|
702
|
+
}
|
|
703
|
+
}
|
|
584
704
|
}
|
|
585
705
|
} catch (e) {
|
|
586
706
|
console.log(chalk10.red(`x Invalid JSON in ${file}: ${e.message}`));
|
|
@@ -597,14 +717,14 @@ async function check() {
|
|
|
597
717
|
|
|
598
718
|
// src/commands/validate.ts
|
|
599
719
|
import chalk11 from "chalk";
|
|
600
|
-
import { readFileSync as readFileSync3, existsSync as
|
|
601
|
-
import { resolve as
|
|
720
|
+
import { readFileSync as readFileSync3, existsSync as existsSync9 } from "fs";
|
|
721
|
+
import { resolve as resolve5 } from "path";
|
|
602
722
|
import { load as loadYaml } from "js-yaml";
|
|
603
723
|
import { safeValidateSchema } from "@object-ui/types/zod";
|
|
604
724
|
async function validate(schemaPath) {
|
|
605
725
|
console.log(chalk11.blue("\u{1F50D} ObjectUI Schema Validator\n"));
|
|
606
|
-
const resolvedPath =
|
|
607
|
-
if (!
|
|
726
|
+
const resolvedPath = resolve5(process.cwd(), schemaPath);
|
|
727
|
+
if (!existsSync9(resolvedPath)) {
|
|
608
728
|
console.error(chalk11.red(`\u2717 Error: Schema file not found: ${schemaPath}`));
|
|
609
729
|
process.exit(1);
|
|
610
730
|
}
|
|
@@ -671,19 +791,19 @@ ${index + 1}. ${error.message}`));
|
|
|
671
791
|
|
|
672
792
|
// src/commands/create-plugin.ts
|
|
673
793
|
import chalk12 from "chalk";
|
|
674
|
-
import { spawn } from "child_process";
|
|
675
|
-
import { resolve as
|
|
676
|
-
import { fileURLToPath } from "url";
|
|
677
|
-
var __filename =
|
|
678
|
-
var __dirname =
|
|
794
|
+
import { spawn as spawn2 } from "child_process";
|
|
795
|
+
import { resolve as resolve6, dirname as dirname3 } from "path";
|
|
796
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
797
|
+
var __filename = fileURLToPath2(import.meta.url);
|
|
798
|
+
var __dirname = dirname3(__filename);
|
|
679
799
|
async function createPlugin(pluginName) {
|
|
680
800
|
console.log(chalk12.blue("\u{1F680} Creating ObjectUI plugin...\n"));
|
|
681
|
-
const createPluginScript =
|
|
801
|
+
const createPluginScript = resolve6(
|
|
682
802
|
__dirname,
|
|
683
803
|
"../../../create-plugin/dist/index.js"
|
|
684
804
|
);
|
|
685
|
-
return new Promise((
|
|
686
|
-
const child =
|
|
805
|
+
return new Promise((resolve8, reject) => {
|
|
806
|
+
const child = spawn2("node", [createPluginScript, pluginName], {
|
|
687
807
|
stdio: "inherit",
|
|
688
808
|
shell: true
|
|
689
809
|
});
|
|
@@ -693,7 +813,7 @@ async function createPlugin(pluginName) {
|
|
|
693
813
|
});
|
|
694
814
|
child.on("exit", (code) => {
|
|
695
815
|
if (code === 0) {
|
|
696
|
-
|
|
816
|
+
resolve8();
|
|
697
817
|
} else {
|
|
698
818
|
reject(new Error(`create-plugin exited with code ${code}`));
|
|
699
819
|
}
|
|
@@ -703,12 +823,12 @@ async function createPlugin(pluginName) {
|
|
|
703
823
|
|
|
704
824
|
// src/commands/analyze.ts
|
|
705
825
|
import chalk13 from "chalk";
|
|
706
|
-
import { existsSync as
|
|
707
|
-
import { resolve as
|
|
826
|
+
import { existsSync as existsSync10, statSync as statSync2, readdirSync } from "fs";
|
|
827
|
+
import { resolve as resolve7, join as join10, extname } from "path";
|
|
708
828
|
async function analyzeBundleSize() {
|
|
709
829
|
console.log(chalk13.bold("\n\u{1F4E6} Bundle Size Analysis\n"));
|
|
710
|
-
const distDir =
|
|
711
|
-
if (!
|
|
830
|
+
const distDir = resolve7(process.cwd(), "dist");
|
|
831
|
+
if (!existsSync10(distDir)) {
|
|
712
832
|
console.log(chalk13.yellow("\u26A0 No dist directory found. Run build first."));
|
|
713
833
|
return;
|
|
714
834
|
}
|
|
@@ -716,7 +836,7 @@ async function analyzeBundleSize() {
|
|
|
716
836
|
function scanDirectory(dir) {
|
|
717
837
|
const items = readdirSync(dir);
|
|
718
838
|
for (const item of items) {
|
|
719
|
-
const fullPath =
|
|
839
|
+
const fullPath = join10(dir, item);
|
|
720
840
|
const stat = statSync2(fullPath);
|
|
721
841
|
if (stat.isDirectory()) {
|
|
722
842
|
scanDirectory(fullPath);
|
|
@@ -798,12 +918,12 @@ async function analyze(options = {}) {
|
|
|
798
918
|
|
|
799
919
|
// src/cli.ts
|
|
800
920
|
import { readFileSync as readFileSync4 } from "fs";
|
|
801
|
-
import { fileURLToPath as
|
|
802
|
-
import { dirname as
|
|
803
|
-
var __filename2 =
|
|
804
|
-
var __dirname2 =
|
|
921
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
922
|
+
import { dirname as dirname4, join as join11 } from "path";
|
|
923
|
+
var __filename2 = fileURLToPath3(import.meta.url);
|
|
924
|
+
var __dirname2 = dirname4(__filename2);
|
|
805
925
|
var packageJson = JSON.parse(
|
|
806
|
-
readFileSync4(
|
|
926
|
+
readFileSync4(join11(__dirname2, "../package.json"), "utf-8")
|
|
807
927
|
);
|
|
808
928
|
var program = new Command();
|
|
809
929
|
program.name("objectui").description("CLI tool for Object UI - Build applications from JSON schemas").version(packageJson.version);
|