cmx-sdk 0.2.1 → 0.2.2
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/{add-studio-C2L2NYQC.js → add-studio-TLDFTZTX.js} +3 -19
- package/dist/chunk-XPP5MZKG.js +109 -0
- package/dist/cli.js +7 -3
- package/dist/{init-OD2XGZI2.js → init-XUTF5IBZ.js} +1 -1
- package/dist/{interactive-menu-BAMWXEKP.js → interactive-menu-UQHS5FLW.js} +10 -4
- package/dist/studio-3YGVKWS4.js +7 -0
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/commands/add-studio.ts
|
|
4
|
-
import { existsSync, readFileSync,
|
|
4
|
+
import { existsSync, readFileSync, mkdirSync } from "fs";
|
|
5
5
|
import { join, resolve } from "path";
|
|
6
6
|
import { execSync } from "child_process";
|
|
7
7
|
import { createWriteStream } from "fs";
|
|
@@ -96,22 +96,6 @@ async function addStudio() {
|
|
|
96
96
|
`);
|
|
97
97
|
process.exit(1);
|
|
98
98
|
}
|
|
99
|
-
const pkgJsonPath = join(projectRoot, "package.json");
|
|
100
|
-
try {
|
|
101
|
-
const pkg = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
|
|
102
|
-
if (!pkg.scripts) pkg.scripts = {};
|
|
103
|
-
if (!pkg.scripts.studio) {
|
|
104
|
-
pkg.scripts.studio = "next dev --turbopack --port 4000 & npm --prefix .cmx/studio run dev";
|
|
105
|
-
}
|
|
106
|
-
if (!pkg.scripts["studio:only"]) {
|
|
107
|
-
pkg.scripts["studio:only"] = "npm --prefix .cmx/studio run dev";
|
|
108
|
-
}
|
|
109
|
-
writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
110
|
-
console.log(" \u2713 package.json \u306B studio \u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u8FFD\u52A0\u3057\u307E\u3057\u305F");
|
|
111
|
-
} catch {
|
|
112
|
-
console.error(" \u26A0\uFE0F package.json \u306E\u66F4\u65B0\u306B\u5931\u6557\u3057\u307E\u3057\u305F");
|
|
113
|
-
console.error(" \u624B\u52D5\u3067 studio \u30B9\u30AF\u30EA\u30D7\u30C8\u3092\u8FFD\u52A0\u3057\u3066\u304F\u3060\u3055\u3044\n");
|
|
114
|
-
}
|
|
115
99
|
console.log("\n \u{1F4E6} Studio \u306E\u4F9D\u5B58\u30D1\u30C3\u30B1\u30FC\u30B8\u3092\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u4E2D...");
|
|
116
100
|
try {
|
|
117
101
|
const pm = existsSync(join(projectRoot, "pnpm-lock.yaml")) ? "pnpm" : existsSync(join(projectRoot, "yarn.lock")) ? "yarn" : "npm";
|
|
@@ -125,8 +109,8 @@ async function addStudio() {
|
|
|
125
109
|
\u2705 CMX Studio \u3092\u8FFD\u52A0\u3057\u307E\u3057\u305F\uFF01
|
|
126
110
|
|
|
127
111
|
\u8D77\u52D5\u65B9\u6CD5:
|
|
128
|
-
|
|
129
|
-
npm run
|
|
112
|
+
npx cmx-sdk studio # \u30B5\u30A4\u30C8 + Studio \u3092\u8D77\u52D5
|
|
113
|
+
npm --prefix .cmx/studio run dev # Studio \u306E\u307F\u8D77\u52D5
|
|
130
114
|
`);
|
|
131
115
|
process.exit(0);
|
|
132
116
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/commands/studio.ts
|
|
4
|
+
import { existsSync, readFileSync } from "fs";
|
|
5
|
+
import { spawn } from "child_process";
|
|
6
|
+
import { join, resolve } from "path";
|
|
7
|
+
function findProjectRoot() {
|
|
8
|
+
let dir = resolve(process.cwd());
|
|
9
|
+
const root = resolve("/");
|
|
10
|
+
while (dir !== root) {
|
|
11
|
+
const pkgPath = join(dir, "package.json");
|
|
12
|
+
if (existsSync(pkgPath)) {
|
|
13
|
+
try {
|
|
14
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
15
|
+
if (pkg.dependencies?.["cmx-sdk"] || pkg.devDependencies?.["cmx-sdk"]) {
|
|
16
|
+
return dir;
|
|
17
|
+
}
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
dir = resolve(dir, "..");
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
function detectPackageManager(dir) {
|
|
26
|
+
if (existsSync(join(dir, "pnpm-lock.yaml"))) return "pnpm";
|
|
27
|
+
if (existsSync(join(dir, "yarn.lock"))) return "yarn";
|
|
28
|
+
return "npm";
|
|
29
|
+
}
|
|
30
|
+
function getRunCommand(pm) {
|
|
31
|
+
if (pm === "pnpm") return { command: "pnpm", args: ["dev"] };
|
|
32
|
+
if (pm === "yarn") return { command: "yarn", args: ["dev"] };
|
|
33
|
+
return { command: "npm", args: ["run", "dev"] };
|
|
34
|
+
}
|
|
35
|
+
function toPlatformCommand(command) {
|
|
36
|
+
if (process.platform === "win32") {
|
|
37
|
+
if (command === "npm") return "npm.cmd";
|
|
38
|
+
if (command === "pnpm") return "pnpm.cmd";
|
|
39
|
+
if (command === "yarn") return "yarn.cmd";
|
|
40
|
+
}
|
|
41
|
+
return command;
|
|
42
|
+
}
|
|
43
|
+
async function studio() {
|
|
44
|
+
console.log("\n CMX Studio \u8D77\u52D5\u4E2D...\n");
|
|
45
|
+
const projectRoot = findProjectRoot();
|
|
46
|
+
if (!projectRoot) {
|
|
47
|
+
console.error(" \u274C CMX \u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093");
|
|
48
|
+
console.error(" package.json \u306B cmx-sdk \u4F9D\u5B58\u304C\u3042\u308B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3067\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\n");
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
const studioDir = join(projectRoot, ".cmx", "studio");
|
|
52
|
+
if (!existsSync(join(studioDir, "package.json"))) {
|
|
53
|
+
console.error(" \u274C .cmx/studio \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093");
|
|
54
|
+
console.error(" \u5148\u306B npx cmx-sdk add-studio \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\n");
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
const rootPm = detectPackageManager(projectRoot);
|
|
58
|
+
const studioPm = detectPackageManager(studioDir);
|
|
59
|
+
const rootRun = getRunCommand(rootPm);
|
|
60
|
+
const studioRun = getRunCommand(studioPm);
|
|
61
|
+
const children = [];
|
|
62
|
+
let shuttingDown = false;
|
|
63
|
+
const shutdown = (exitCode) => {
|
|
64
|
+
if (shuttingDown) return;
|
|
65
|
+
shuttingDown = true;
|
|
66
|
+
for (const child of children) {
|
|
67
|
+
if (!child.killed) child.kill("SIGTERM");
|
|
68
|
+
}
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
for (const child of children) {
|
|
71
|
+
if (!child.killed) child.kill("SIGKILL");
|
|
72
|
+
}
|
|
73
|
+
process.exit(exitCode);
|
|
74
|
+
}, 300).unref();
|
|
75
|
+
};
|
|
76
|
+
const spawnDev = (label, cwd, run) => {
|
|
77
|
+
const command = toPlatformCommand(run.command);
|
|
78
|
+
const child = spawn(command, run.args, {
|
|
79
|
+
cwd,
|
|
80
|
+
stdio: "inherit",
|
|
81
|
+
env: process.env
|
|
82
|
+
});
|
|
83
|
+
child.on("error", (error) => {
|
|
84
|
+
console.error(`
|
|
85
|
+
\u274C ${label} \u306E\u8D77\u52D5\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${error.message}
|
|
86
|
+
`);
|
|
87
|
+
shutdown(1);
|
|
88
|
+
});
|
|
89
|
+
child.on("exit", (code, signal) => {
|
|
90
|
+
if (shuttingDown) return;
|
|
91
|
+
const detail = signal ? `signal ${signal}` : `code ${code ?? 1}`;
|
|
92
|
+
console.error(`
|
|
93
|
+
\u26A0\uFE0F ${label} \u30D7\u30ED\u30BB\u30B9\u304C\u7D42\u4E86\u3057\u307E\u3057\u305F (${detail})
|
|
94
|
+
`);
|
|
95
|
+
shutdown(code ?? 1);
|
|
96
|
+
});
|
|
97
|
+
children.push(child);
|
|
98
|
+
};
|
|
99
|
+
console.log(" - site : http://localhost:4000");
|
|
100
|
+
console.log(" - studio : http://localhost:4001\n");
|
|
101
|
+
spawnDev("site", projectRoot, rootRun);
|
|
102
|
+
spawnDev("studio", studioDir, studioRun);
|
|
103
|
+
process.on("SIGINT", () => shutdown(0));
|
|
104
|
+
process.on("SIGTERM", () => shutdown(0));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
studio
|
|
109
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
studio
|
|
4
|
+
} from "./chunk-XPP5MZKG.js";
|
|
2
5
|
|
|
3
6
|
// src/cli.ts
|
|
4
7
|
import { Command } from "commander";
|
|
@@ -1935,17 +1938,18 @@ config();
|
|
|
1935
1938
|
var program = new Command();
|
|
1936
1939
|
program.name("cmx-sdk").description("CMX SDK - CLI tool for managing CMX schemas and content").version("0.1.13");
|
|
1937
1940
|
program.action(async () => {
|
|
1938
|
-
const { interactiveMenu } = await import("./interactive-menu-
|
|
1941
|
+
const { interactiveMenu } = await import("./interactive-menu-UQHS5FLW.js");
|
|
1939
1942
|
await interactiveMenu();
|
|
1940
1943
|
});
|
|
1941
1944
|
program.command("init [project-name]").description("\u65B0\u898F CMX \u30B5\u30A4\u30C8\u3092\u4F5C\u6210").option("--no-studio", "CMX Studio \u3092\u30B9\u30AD\u30C3\u30D7").option("--pm <manager>", "\u30D1\u30C3\u30B1\u30FC\u30B8\u30DE\u30CD\u30FC\u30B8\u30E3\u30FC (npm, pnpm, yarn)").action(async (projectName, options) => {
|
|
1942
|
-
const { init } = await import("./init-
|
|
1945
|
+
const { init } = await import("./init-XUTF5IBZ.js");
|
|
1943
1946
|
await init(projectName, options);
|
|
1944
1947
|
});
|
|
1945
1948
|
program.command("add-studio").description("\u65E2\u5B58\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306B CMX Studio \u3092\u8FFD\u52A0").action(async () => {
|
|
1946
|
-
const { addStudio } = await import("./add-studio-
|
|
1949
|
+
const { addStudio } = await import("./add-studio-TLDFTZTX.js");
|
|
1947
1950
|
await addStudio();
|
|
1948
1951
|
});
|
|
1952
|
+
program.command("studio").description("\u30B5\u30A4\u30C8 (4000) \u3068 Studio (4001) \u3092\u540C\u6642\u8D77\u52D5").action(studio);
|
|
1949
1953
|
program.command("list-collections").description("List all collections").action(listCollections);
|
|
1950
1954
|
program.command("list-data-types").description("List all data types").action(listDataTypes);
|
|
1951
1955
|
program.command("list-forms").description("List all form definitions").action(listForms);
|
|
@@ -159,7 +159,7 @@ async function init(projectName, options) {
|
|
|
159
159
|
\u6B21\u306E\u30B9\u30C6\u30C3\u30D7:
|
|
160
160
|
cd ${name}
|
|
161
161
|
${runCmd} dev # \u30B5\u30A4\u30C8\u3092\u8D77\u52D5 (localhost:4000)${includeStudio ? `
|
|
162
|
-
|
|
162
|
+
npx cmx-sdk studio # \u30B5\u30A4\u30C8 + Studio \u3092\u8D77\u52D5` : ""}
|
|
163
163
|
|
|
164
164
|
\u{1F4D6} \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8: https://cmx-ai.org/docs
|
|
165
165
|
\u{1F3A8} CMX Admin: https://app.cmx-ai.org
|
|
@@ -9,6 +9,7 @@ async function interactiveMenu() {
|
|
|
9
9
|
choices: [
|
|
10
10
|
{ name: "\u65B0\u898F\u30B5\u30A4\u30C8\u3092\u4F5C\u6210", value: "init" },
|
|
11
11
|
{ name: "Studio \u3092\u8FFD\u52A0", value: "add-studio" },
|
|
12
|
+
{ name: "Studio \u3092\u8D77\u52D5", value: "studio" },
|
|
12
13
|
{ name: "\u578B\u3092\u751F\u6210", value: "generate" },
|
|
13
14
|
{ name: "\u30DA\u30FC\u30B8\u3092\u751F\u6210", value: "scaffold" },
|
|
14
15
|
{ name: "\u30D8\u30EB\u30D7", value: "help" }
|
|
@@ -16,13 +17,17 @@ async function interactiveMenu() {
|
|
|
16
17
|
});
|
|
17
18
|
switch (action) {
|
|
18
19
|
case "init": {
|
|
19
|
-
const { init } = await import("./init-
|
|
20
|
+
const { init } = await import("./init-XUTF5IBZ.js");
|
|
20
21
|
return init(void 0, {});
|
|
21
22
|
}
|
|
22
23
|
case "add-studio": {
|
|
23
|
-
const { addStudio } = await import("./add-studio-
|
|
24
|
+
const { addStudio } = await import("./add-studio-TLDFTZTX.js");
|
|
24
25
|
return addStudio();
|
|
25
26
|
}
|
|
27
|
+
case "studio": {
|
|
28
|
+
const { studio } = await import("./studio-3YGVKWS4.js");
|
|
29
|
+
return studio();
|
|
30
|
+
}
|
|
26
31
|
case "generate": {
|
|
27
32
|
console.log("\n npx cmx-sdk generate \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044\n");
|
|
28
33
|
process.exit(0);
|
|
@@ -38,14 +43,15 @@ async function interactiveMenu() {
|
|
|
38
43
|
\u4F7F\u3044\u65B9:
|
|
39
44
|
npx cmx-sdk init [project-name] \u65B0\u898F\u30B5\u30A4\u30C8\u3092\u4F5C\u6210
|
|
40
45
|
npx cmx-sdk add-studio Studio \u3092\u8FFD\u52A0
|
|
46
|
+
npx cmx-sdk studio \u30B5\u30A4\u30C8 + Studio \u3092\u8D77\u52D5
|
|
41
47
|
npx cmx-sdk generate TypeScript \u578B\u3092\u751F\u6210
|
|
42
48
|
npx cmx-sdk scaffold Next.js \u30DA\u30FC\u30B8\u3092\u751F\u6210
|
|
43
49
|
npx cmx-sdk --help \u5168\u30B3\u30DE\u30F3\u30C9\u3092\u8868\u793A
|
|
44
50
|
|
|
45
51
|
\u8D77\u52D5:
|
|
46
52
|
npm run dev \u30B5\u30A4\u30C8\u3092\u8D77\u52D5 (localhost:4000)
|
|
47
|
-
|
|
48
|
-
npm run
|
|
53
|
+
npx cmx-sdk studio \u30B5\u30A4\u30C8 + Studio \u3092\u8D77\u52D5
|
|
54
|
+
npm --prefix .cmx/studio run dev Studio \u306E\u307F\u8D77\u52D5
|
|
49
55
|
`);
|
|
50
56
|
process.exit(0);
|
|
51
57
|
break;
|