cmx-sdk 0.2.8 → 0.2.10
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/{chunk-EZMBZWH7.js → chunk-Y3S3K6M3.js} +73 -28
- package/dist/cli.js +487 -89
- package/dist/index.d.ts +341 -1
- package/dist/index.js.map +1 -1
- package/dist/{interactive-menu-FYVOQSTL.js → interactive-menu-5PRQIESI.js} +1 -1
- package/dist/{update-sdk-KJZ6VB4M.js → update-sdk-ZXMWQF3I.js} +2 -1
- package/package.json +1 -2
- package/templates/AGENTS.md +0 -173
- package/templates/CLAUDE.md +0 -28
- package/templates/claude/commands/check.md +0 -64
- package/templates/claude/commands/next-action.md +0 -66
- package/templates/claude/skills/cmx-cache/SKILL.md +0 -50
- package/templates/claude/skills/cmx-cache/references/cache-patterns.md +0 -153
- package/templates/claude/skills/cmx-component/SKILL.md +0 -108
- package/templates/claude/skills/cmx-component/references/component-schema.md +0 -123
- package/templates/claude/skills/cmx-content/SKILL.md +0 -158
- package/templates/claude/skills/cmx-content/references/migration-patterns.md +0 -120
- package/templates/claude/skills/cmx-content/references/seed-patterns.md +0 -146
- package/templates/claude/skills/cmx-dev/SKILL.md +0 -266
- package/templates/claude/skills/cmx-dev/references/api-patterns.md +0 -220
- package/templates/claude/skills/cmx-dev/references/cli-reference.md +0 -54
- package/templates/claude/skills/cmx-form/SKILL.md +0 -103
- package/templates/claude/skills/cmx-form/references/form-template.md +0 -152
- package/templates/claude/skills/cmx-migrate/SKILL.md +0 -501
- package/templates/claude/skills/cmx-migrate/references/analysis-guide.md +0 -127
- package/templates/claude/skills/cmx-migrate/references/html-to-mdx.md +0 -99
- package/templates/claude/skills/cmx-migrate/references/intermediate-format.md +0 -196
- package/templates/claude/skills/cmx-migrate/references/tool-setup.md +0 -150
- package/templates/claude/skills/cmx-schema/SKILL.md +0 -159
- package/templates/claude/skills/cmx-schema/references/field-types.md +0 -164
- package/templates/claude/skills/cmx-schema/references/migration-scenarios.md +0 -44
- package/templates/claude/skills/cmx-seo/SKILL.md +0 -54
- package/templates/claude/skills/cmx-seo/references/seo-patterns.md +0 -216
- package/templates/claude/skills/cmx-style/SKILL.md +0 -48
- package/templates/claude/skills/cmx-style/references/style-patterns.md +0 -114
|
@@ -6,15 +6,17 @@ import {
|
|
|
6
6
|
getAddDependencyCommand,
|
|
7
7
|
readSdkVersion
|
|
8
8
|
} from "./chunk-EDXXR5BE.js";
|
|
9
|
+
import {
|
|
10
|
+
cleanupTempFile,
|
|
11
|
+
downloadTarball
|
|
12
|
+
} from "./chunk-IIQLQIDP.js";
|
|
9
13
|
|
|
10
14
|
// src/commands/update-sdk.ts
|
|
11
15
|
import { execSync } from "child_process";
|
|
12
|
-
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
16
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
17
|
+
import { tmpdir } from "os";
|
|
13
18
|
import { dirname, join } from "path";
|
|
14
|
-
import {
|
|
15
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
16
|
-
var __dirname = dirname(__filename);
|
|
17
|
-
var SDK_ROOT = join(__dirname, "..", "..");
|
|
19
|
+
import { extract } from "tar";
|
|
18
20
|
function resolveRequestedVersion(version) {
|
|
19
21
|
if (version === void 0) return "latest";
|
|
20
22
|
const normalized = version.trim();
|
|
@@ -23,27 +25,25 @@ function resolveRequestedVersion(version) {
|
|
|
23
25
|
}
|
|
24
26
|
return normalized;
|
|
25
27
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
function readProjectCmxConfig(projectRoot) {
|
|
29
|
+
const envFiles = [".env.local", ".env"];
|
|
30
|
+
for (const envFile of envFiles) {
|
|
31
|
+
const envPath = join(projectRoot, envFile);
|
|
32
|
+
if (!existsSync(envPath)) continue;
|
|
33
|
+
try {
|
|
34
|
+
const content = readFileSync(envPath, "utf-8");
|
|
35
|
+
const apiUrl = content.match(/^CMX_API_URL=(.+)$/m)?.[1]?.trim();
|
|
36
|
+
const apiKey = content.match(/^CMX_API_KEY=(.+)$/m)?.[1]?.trim();
|
|
37
|
+
if (apiUrl && apiKey) {
|
|
38
|
+
return { apiUrl, apiKey };
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
41
44
|
}
|
|
42
|
-
function
|
|
43
|
-
const templatePath = join(SDK_ROOT, "templates", relativePath);
|
|
44
|
-
if (!existsSync(templatePath)) return;
|
|
45
|
+
function syncManagedFileFromContent(projectRoot, relativePath, templateContent) {
|
|
45
46
|
const destPath = join(projectRoot, relativePath);
|
|
46
|
-
const templateContent = readFileSync(templatePath, "utf-8");
|
|
47
47
|
if (!existsSync(destPath)) {
|
|
48
48
|
mkdirSync(dirname(destPath), { recursive: true });
|
|
49
49
|
writeFileSync(destPath, templateContent);
|
|
@@ -69,6 +69,40 @@ function syncManagedFile(projectRoot, relativePath) {
|
|
|
69
69
|
console.log(` \u2705 ${relativePath} \u3092\u66F4\u65B0\u3057\u307E\u3057\u305F\uFF08${updatedBlocks} \u30D6\u30ED\u30C3\u30AF\uFF09`);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
async function syncFromApi(projectRoot, apiUrl, apiKey) {
|
|
73
|
+
const tmpFile = join(tmpdir(), `.tmp-starter-kit-${Date.now()}.tar.gz`);
|
|
74
|
+
const tmpExtractDir = join(tmpdir(), `.tmp-starter-kit-extract-${Date.now()}`);
|
|
75
|
+
try {
|
|
76
|
+
await downloadTarball(`${apiUrl}/api/v1/sdk/download/starter-kit`, tmpFile, {
|
|
77
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
78
|
+
});
|
|
79
|
+
mkdirSync(tmpExtractDir, { recursive: true });
|
|
80
|
+
await extract({
|
|
81
|
+
file: tmpFile,
|
|
82
|
+
cwd: tmpExtractDir,
|
|
83
|
+
strip: 1,
|
|
84
|
+
filter: (entryPath) => entryPath.includes("/.claude/") || entryPath.endsWith("/AGENTS.md") || entryPath.endsWith("/CLAUDE.md")
|
|
85
|
+
});
|
|
86
|
+
const extractedClaude = join(tmpExtractDir, ".claude");
|
|
87
|
+
if (existsSync(extractedClaude)) {
|
|
88
|
+
mkdirSync(join(projectRoot, ".claude"), { recursive: true });
|
|
89
|
+
cpSync(extractedClaude, join(projectRoot, ".claude"), { recursive: true, force: true });
|
|
90
|
+
console.log(" \u2705 .claude/ \u3092\u66F4\u65B0\u3057\u307E\u3057\u305F");
|
|
91
|
+
}
|
|
92
|
+
for (const filename of ["AGENTS.md", "CLAUDE.md"]) {
|
|
93
|
+
const extractedFile = join(tmpExtractDir, filename);
|
|
94
|
+
if (existsSync(extractedFile)) {
|
|
95
|
+
syncManagedFileFromContent(projectRoot, filename, readFileSync(extractedFile, "utf-8"));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} finally {
|
|
99
|
+
cleanupTempFile(tmpFile);
|
|
100
|
+
try {
|
|
101
|
+
rmSync(tmpExtractDir, { recursive: true, force: true });
|
|
102
|
+
} catch {
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
72
106
|
async function updateSdk(options = {}) {
|
|
73
107
|
console.log("\n cmx-sdk \u306E\u4F9D\u5B58\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u66F4\u65B0\u3057\u307E\u3059...\n");
|
|
74
108
|
const projectRoot = findProjectRoot();
|
|
@@ -103,10 +137,21 @@ async function updateSdk(options = {}) {
|
|
|
103
137
|
console.log("\n \u2705 cmx-sdk \u3092\u66F4\u65B0\u3057\u307E\u3057\u305F\uFF01");
|
|
104
138
|
console.log(` \u66F4\u65B0\u5F8C\u30D0\u30FC\u30B8\u30E7\u30F3: ${updatedVersion ?? "\u4E0D\u660E"}`);
|
|
105
139
|
console.log("\n \u23F3 Claude Code \u30D5\u30A1\u30A4\u30EB\u3092\u66F4\u65B0\u4E2D...");
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
140
|
+
const cmxConfig = readProjectCmxConfig(projectRoot);
|
|
141
|
+
if (!cmxConfig) {
|
|
142
|
+
console.warn(" \u26A0\uFE0F CMX_API_URL / CMX_API_KEY \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093");
|
|
143
|
+
console.warn(" .env.local \u306B\u8A2D\u5B9A\u3059\u308B\u3068 .claude/ / AGENTS.md / CLAUDE.md \u3082\u81EA\u52D5\u66F4\u65B0\u3055\u308C\u307E\u3059\n");
|
|
144
|
+
} else {
|
|
145
|
+
try {
|
|
146
|
+
console.log(" \u23F3 \u30B9\u30BF\u30FC\u30BF\u30FC\u30AD\u30C3\u30C8\u304B\u3089\u6700\u65B0\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u53D6\u5F97\u4E2D...");
|
|
147
|
+
await syncFromApi(projectRoot, cmxConfig.apiUrl, cmxConfig.apiKey);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.error(
|
|
150
|
+
` \u274C Claude Code \u30D5\u30A1\u30A4\u30EB\u306E\u66F4\u65B0\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${error instanceof Error ? error.message : "\u4E0D\u660E\u306A\u30A8\u30E9\u30FC"}
|
|
151
|
+
`
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
110
155
|
console.log("\n \u6B21\u306E\u30B9\u30C6\u30C3\u30D7:");
|
|
111
156
|
console.log(" 1. \u578B\u751F\u6210\u3092\u518D\u5B9F\u884C");
|
|
112
157
|
console.log(" npx cmx-sdk codegen types");
|