cmx-sdk 0.2.6 → 0.2.8
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/README.md +16 -0
- package/dist/add-studio-YUDYE2OH.js +72 -0
- package/dist/{chunk-XPP5MZKG.js → chunk-7TDMLYBI.js} +17 -45
- package/dist/chunk-EDXXR5BE.js +80 -0
- package/dist/chunk-EZMBZWH7.js +121 -0
- package/dist/chunk-FPQYL5GE.js +128 -0
- package/dist/chunk-NZQ6SBFS.js +35 -0
- package/dist/cli.js +1152 -619
- package/dist/index.d.ts +253 -385
- package/dist/index.js +154 -25
- package/dist/index.js.map +1 -1
- package/dist/{init-NDNG5Q5T.js → init-FLRQXJX4.js} +23 -51
- package/dist/interactive-menu-FYVOQSTL.js +80 -0
- package/dist/studio-HAS6DYLO.js +8 -0
- package/dist/update-sdk-KJZ6VB4M.js +10 -0
- package/dist/update-studio-TWCYSYIS.js +14 -0
- package/package.json +18 -10
- package/templates/AGENTS.md +173 -0
- package/templates/CLAUDE.md +28 -0
- package/templates/claude/commands/check.md +64 -0
- package/templates/claude/commands/next-action.md +66 -0
- package/templates/claude/skills/cmx-cache/SKILL.md +50 -0
- package/templates/claude/skills/cmx-cache/references/cache-patterns.md +153 -0
- package/templates/claude/skills/cmx-component/SKILL.md +108 -0
- package/templates/claude/skills/cmx-component/references/component-schema.md +123 -0
- package/templates/claude/skills/cmx-content/SKILL.md +158 -0
- package/templates/claude/skills/cmx-content/references/migration-patterns.md +120 -0
- package/templates/claude/skills/cmx-content/references/seed-patterns.md +146 -0
- package/templates/claude/skills/cmx-dev/SKILL.md +266 -0
- package/templates/claude/skills/cmx-dev/references/api-patterns.md +220 -0
- package/templates/claude/skills/cmx-dev/references/cli-reference.md +54 -0
- package/templates/claude/skills/cmx-form/SKILL.md +103 -0
- package/templates/claude/skills/cmx-form/references/form-template.md +152 -0
- package/templates/claude/skills/cmx-migrate/SKILL.md +501 -0
- package/templates/claude/skills/cmx-migrate/references/analysis-guide.md +127 -0
- package/templates/claude/skills/cmx-migrate/references/html-to-mdx.md +99 -0
- package/templates/claude/skills/cmx-migrate/references/intermediate-format.md +196 -0
- package/templates/claude/skills/cmx-migrate/references/tool-setup.md +150 -0
- package/templates/claude/skills/cmx-schema/SKILL.md +159 -0
- package/templates/claude/skills/cmx-schema/references/field-types.md +164 -0
- package/templates/claude/skills/cmx-schema/references/migration-scenarios.md +44 -0
- package/templates/claude/skills/cmx-seo/SKILL.md +54 -0
- package/templates/claude/skills/cmx-seo/references/seo-patterns.md +216 -0
- package/templates/claude/skills/cmx-style/SKILL.md +48 -0
- package/templates/claude/skills/cmx-style/references/style-patterns.md +114 -0
- package/dist/add-studio-J7M7KOWM.js +0 -125
- package/dist/interactive-menu-RPPCBCOU.js +0 -66
- package/dist/studio-3YGVKWS4.js +0 -7
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
studio
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7TDMLYBI.js";
|
|
5
|
+
import {
|
|
6
|
+
updateStudio
|
|
7
|
+
} from "./chunk-FPQYL5GE.js";
|
|
8
|
+
import {
|
|
9
|
+
updateSdk
|
|
10
|
+
} from "./chunk-EZMBZWH7.js";
|
|
11
|
+
import "./chunk-NZQ6SBFS.js";
|
|
12
|
+
import "./chunk-EDXXR5BE.js";
|
|
13
|
+
import "./chunk-IIQLQIDP.js";
|
|
5
14
|
|
|
6
15
|
// src/cli.ts
|
|
7
16
|
import { Command } from "commander";
|
|
@@ -9,12 +18,84 @@ import { config } from "dotenv";
|
|
|
9
18
|
|
|
10
19
|
// src/commands/utils.ts
|
|
11
20
|
import { readFileSync } from "fs";
|
|
21
|
+
function stringifyErrorValue(value) {
|
|
22
|
+
if (typeof value === "string") return value;
|
|
23
|
+
if (value === null || value === void 0) return "";
|
|
24
|
+
if (typeof value === "object") {
|
|
25
|
+
const objectValue = value;
|
|
26
|
+
if (typeof objectValue.message === "string" && objectValue.message.length > 0) {
|
|
27
|
+
return objectValue.message;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
return JSON.stringify(value);
|
|
31
|
+
} catch {
|
|
32
|
+
return String(value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return String(value);
|
|
36
|
+
}
|
|
37
|
+
function formatApiErrorPayload(payload) {
|
|
38
|
+
if (typeof payload === "string") {
|
|
39
|
+
return formatApiErrorMessage(payload);
|
|
40
|
+
}
|
|
41
|
+
const parsed = payload ?? {};
|
|
42
|
+
const main = stringifyErrorValue(parsed.error ?? parsed.message);
|
|
43
|
+
const details = stringifyErrorValue(parsed.details);
|
|
44
|
+
const code = typeof parsed.code === "string" ? parsed.code : void 0;
|
|
45
|
+
const message = [main, details].filter((part, index, parts) => part.length > 0 && parts.indexOf(part) === index).join(" | ");
|
|
46
|
+
if (code && message) return `${code}: ${message}`;
|
|
47
|
+
if (code) return code;
|
|
48
|
+
if (message) return message;
|
|
49
|
+
return "\u4E0D\u660E\u306A\u30A8\u30E9\u30FC";
|
|
50
|
+
}
|
|
51
|
+
function formatApiErrorMessage(errorBody) {
|
|
52
|
+
if (!errorBody) return "\u4E0D\u660E\u306A\u30A8\u30E9\u30FC";
|
|
53
|
+
try {
|
|
54
|
+
return formatApiErrorPayload(JSON.parse(errorBody));
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
return errorBody;
|
|
58
|
+
}
|
|
59
|
+
var sdkFetchInterceptorInstalled = false;
|
|
60
|
+
function installSdkFetchInterceptor() {
|
|
61
|
+
if (sdkFetchInterceptorInstalled) return;
|
|
62
|
+
if (typeof globalThis.fetch !== "function") return;
|
|
63
|
+
const originalFetch = globalThis.fetch.bind(globalThis);
|
|
64
|
+
globalThis.fetch = async (input, init) => {
|
|
65
|
+
if (typeof input === "string" || input instanceof URL) {
|
|
66
|
+
const rawUrl = input.toString();
|
|
67
|
+
if (rawUrl.startsWith("/api/v1/sdk")) {
|
|
68
|
+
const apiUrl = process.env.CMX_API_URL;
|
|
69
|
+
const apiKey = process.env.CMX_API_KEY;
|
|
70
|
+
if (!apiUrl || !apiKey) {
|
|
71
|
+
throw new Error("\u74B0\u5883\u5909\u6570 CMX_API_URL \u3068 CMX_API_KEY \u3092\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
72
|
+
}
|
|
73
|
+
const baseUrl = apiUrl.replace(/\/$/, "");
|
|
74
|
+
const absoluteUrl = `${baseUrl}${rawUrl}`;
|
|
75
|
+
const headers = new Headers(init?.headers);
|
|
76
|
+
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
77
|
+
return originalFetch(absoluteUrl, {
|
|
78
|
+
...init,
|
|
79
|
+
headers
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return originalFetch(input, init);
|
|
84
|
+
};
|
|
85
|
+
sdkFetchInterceptorInstalled = true;
|
|
86
|
+
}
|
|
87
|
+
function assertSdkSuccess(response) {
|
|
88
|
+
if (response.status >= 200 && response.status < 300) {
|
|
89
|
+
return response.data;
|
|
90
|
+
}
|
|
91
|
+
throw new Error(`API \u30A8\u30E9\u30FC (${response.status}): ${formatApiErrorPayload(response.data)}`);
|
|
92
|
+
}
|
|
12
93
|
function readJsonInput(options) {
|
|
13
94
|
if (options.json) {
|
|
14
95
|
try {
|
|
15
96
|
return JSON.parse(options.json);
|
|
16
97
|
} catch {
|
|
17
|
-
console.error("
|
|
98
|
+
console.error("\u30A8\u30E9\u30FC: --json \u306E JSON \u6587\u5B57\u5217\u304C\u4E0D\u6B63\u3067\u3059");
|
|
18
99
|
process.exit(1);
|
|
19
100
|
}
|
|
20
101
|
}
|
|
@@ -23,65 +104,577 @@ function readJsonInput(options) {
|
|
|
23
104
|
const content = readFileSync(options.file, "utf-8");
|
|
24
105
|
return JSON.parse(content);
|
|
25
106
|
} catch (err) {
|
|
26
|
-
console.error(
|
|
107
|
+
console.error(`\u30A8\u30E9\u30FC: JSON \u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${options.file}`);
|
|
27
108
|
console.error(err instanceof Error ? err.message : err);
|
|
28
109
|
process.exit(1);
|
|
29
110
|
}
|
|
30
111
|
}
|
|
31
|
-
console.error("
|
|
112
|
+
console.error("\u30A8\u30E9\u30FC: --json \u307E\u305F\u306F --file \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
32
113
|
process.exit(1);
|
|
33
114
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
headers: {
|
|
39
|
-
"Content-Type": "application/json",
|
|
40
|
-
Authorization: `Bearer ${apiKey}`
|
|
41
|
-
},
|
|
42
|
-
...body ? { body: JSON.stringify(body) } : {}
|
|
43
|
-
});
|
|
44
|
-
if (!response.ok) {
|
|
45
|
-
const errorBody = await response.text();
|
|
46
|
-
let errorMsg;
|
|
47
|
-
try {
|
|
48
|
-
const parsed = JSON.parse(errorBody);
|
|
49
|
-
errorMsg = parsed.error || errorBody;
|
|
50
|
-
} catch {
|
|
51
|
-
errorMsg = errorBody;
|
|
52
|
-
}
|
|
53
|
-
throw new Error(`API error (${response.status}): ${errorMsg}`);
|
|
115
|
+
function ensureApiCredentials() {
|
|
116
|
+
if (!process.env.CMX_API_URL || !process.env.CMX_API_KEY) {
|
|
117
|
+
console.error("\u30A8\u30E9\u30FC: \u74B0\u5883\u5909\u6570 CMX_API_URL \u3068 CMX_API_KEY \u3092\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
118
|
+
process.exit(1);
|
|
54
119
|
}
|
|
55
|
-
return response.json();
|
|
56
120
|
}
|
|
57
121
|
|
|
122
|
+
// src/core/date-reviver.ts
|
|
123
|
+
var isoDateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/;
|
|
124
|
+
function dateReviver(_key, value) {
|
|
125
|
+
if (typeof value === "string" && isoDateFormat.test(value)) {
|
|
126
|
+
return new Date(value);
|
|
127
|
+
}
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/generated/sdk/endpoints/sdk.ts
|
|
132
|
+
var getGetManageCollectionsUrl = () => {
|
|
133
|
+
return `/api/v1/sdk/manage/collections`;
|
|
134
|
+
};
|
|
135
|
+
var getManageCollections = async (options) => {
|
|
136
|
+
const res = await fetch(
|
|
137
|
+
getGetManageCollectionsUrl(),
|
|
138
|
+
{
|
|
139
|
+
...options,
|
|
140
|
+
method: "GET"
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
144
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
145
|
+
return { data, status: res.status, headers: res.headers };
|
|
146
|
+
};
|
|
147
|
+
var getPostManageCollectionsUrl = () => {
|
|
148
|
+
return `/api/v1/sdk/manage/collections`;
|
|
149
|
+
};
|
|
150
|
+
var postManageCollections = async (createCollectionRequest, options) => {
|
|
151
|
+
const res = await fetch(
|
|
152
|
+
getPostManageCollectionsUrl(),
|
|
153
|
+
{
|
|
154
|
+
...options,
|
|
155
|
+
method: "POST",
|
|
156
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
157
|
+
body: JSON.stringify(
|
|
158
|
+
createCollectionRequest
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
163
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
164
|
+
return { data, status: res.status, headers: res.headers };
|
|
165
|
+
};
|
|
166
|
+
var getGetManageCollectionsSlugUrl = (slug) => {
|
|
167
|
+
return `/api/v1/sdk/manage/collections/${slug}`;
|
|
168
|
+
};
|
|
169
|
+
var getManageCollectionsSlug = async (slug, options) => {
|
|
170
|
+
const res = await fetch(
|
|
171
|
+
getGetManageCollectionsSlugUrl(slug),
|
|
172
|
+
{
|
|
173
|
+
...options,
|
|
174
|
+
method: "GET"
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
178
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
179
|
+
return { data, status: res.status, headers: res.headers };
|
|
180
|
+
};
|
|
181
|
+
var getPutManageCollectionsSlugUrl = (slug) => {
|
|
182
|
+
return `/api/v1/sdk/manage/collections/${slug}`;
|
|
183
|
+
};
|
|
184
|
+
var putManageCollectionsSlug = async (slug, updateCollectionRequest, options) => {
|
|
185
|
+
const res = await fetch(
|
|
186
|
+
getPutManageCollectionsSlugUrl(slug),
|
|
187
|
+
{
|
|
188
|
+
...options,
|
|
189
|
+
method: "PUT",
|
|
190
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
191
|
+
body: JSON.stringify(
|
|
192
|
+
updateCollectionRequest
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
197
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
198
|
+
return { data, status: res.status, headers: res.headers };
|
|
199
|
+
};
|
|
200
|
+
var getDeleteManageCollectionsSlugUrl = (slug) => {
|
|
201
|
+
return `/api/v1/sdk/manage/collections/${slug}`;
|
|
202
|
+
};
|
|
203
|
+
var deleteManageCollectionsSlug = async (slug, options) => {
|
|
204
|
+
const res = await fetch(
|
|
205
|
+
getDeleteManageCollectionsSlugUrl(slug),
|
|
206
|
+
{
|
|
207
|
+
...options,
|
|
208
|
+
method: "DELETE"
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
212
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
213
|
+
return { data, status: res.status, headers: res.headers };
|
|
214
|
+
};
|
|
215
|
+
var getGetManageDataTypesUrl = () => {
|
|
216
|
+
return `/api/v1/sdk/manage/data-types`;
|
|
217
|
+
};
|
|
218
|
+
var getManageDataTypes = async (options) => {
|
|
219
|
+
const res = await fetch(
|
|
220
|
+
getGetManageDataTypesUrl(),
|
|
221
|
+
{
|
|
222
|
+
...options,
|
|
223
|
+
method: "GET"
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
227
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
228
|
+
return { data, status: res.status, headers: res.headers };
|
|
229
|
+
};
|
|
230
|
+
var getPostManageDataTypesUrl = () => {
|
|
231
|
+
return `/api/v1/sdk/manage/data-types`;
|
|
232
|
+
};
|
|
233
|
+
var postManageDataTypes = async (createDataTypeRequest, options) => {
|
|
234
|
+
const res = await fetch(
|
|
235
|
+
getPostManageDataTypesUrl(),
|
|
236
|
+
{
|
|
237
|
+
...options,
|
|
238
|
+
method: "POST",
|
|
239
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
240
|
+
body: JSON.stringify(
|
|
241
|
+
createDataTypeRequest
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
246
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
247
|
+
return { data, status: res.status, headers: res.headers };
|
|
248
|
+
};
|
|
249
|
+
var getPutManageDataTypesSlugUrl = (slug) => {
|
|
250
|
+
return `/api/v1/sdk/manage/data-types/${slug}`;
|
|
251
|
+
};
|
|
252
|
+
var putManageDataTypesSlug = async (slug, updateDataTypeRequest, options) => {
|
|
253
|
+
const res = await fetch(
|
|
254
|
+
getPutManageDataTypesSlugUrl(slug),
|
|
255
|
+
{
|
|
256
|
+
...options,
|
|
257
|
+
method: "PUT",
|
|
258
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
259
|
+
body: JSON.stringify(
|
|
260
|
+
updateDataTypeRequest
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
265
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
266
|
+
return { data, status: res.status, headers: res.headers };
|
|
267
|
+
};
|
|
268
|
+
var getDeleteManageDataTypesSlugUrl = (slug) => {
|
|
269
|
+
return `/api/v1/sdk/manage/data-types/${slug}`;
|
|
270
|
+
};
|
|
271
|
+
var deleteManageDataTypesSlug = async (slug, options) => {
|
|
272
|
+
const res = await fetch(
|
|
273
|
+
getDeleteManageDataTypesSlugUrl(slug),
|
|
274
|
+
{
|
|
275
|
+
...options,
|
|
276
|
+
method: "DELETE"
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
280
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
281
|
+
return { data, status: res.status, headers: res.headers };
|
|
282
|
+
};
|
|
283
|
+
var getGetManageDataTypeSlugUrl = (typeSlug, params) => {
|
|
284
|
+
const normalizedParams = new URLSearchParams();
|
|
285
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
286
|
+
if (value !== void 0) {
|
|
287
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
const stringifiedParams = normalizedParams.toString();
|
|
291
|
+
return stringifiedParams.length > 0 ? `/api/v1/sdk/manage/data/${typeSlug}?${stringifiedParams}` : `/api/v1/sdk/manage/data/${typeSlug}`;
|
|
292
|
+
};
|
|
293
|
+
var getManageDataTypeSlug = async (typeSlug, params, options) => {
|
|
294
|
+
const res = await fetch(
|
|
295
|
+
getGetManageDataTypeSlugUrl(typeSlug, params),
|
|
296
|
+
{
|
|
297
|
+
...options,
|
|
298
|
+
method: "GET"
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
302
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
303
|
+
return { data, status: res.status, headers: res.headers };
|
|
304
|
+
};
|
|
305
|
+
var getPostManageDataTypeSlugUrl = (typeSlug) => {
|
|
306
|
+
return `/api/v1/sdk/manage/data/${typeSlug}`;
|
|
307
|
+
};
|
|
308
|
+
var postManageDataTypeSlug = async (typeSlug, sdkCreateEntryRequest, options) => {
|
|
309
|
+
const res = await fetch(
|
|
310
|
+
getPostManageDataTypeSlugUrl(typeSlug),
|
|
311
|
+
{
|
|
312
|
+
...options,
|
|
313
|
+
method: "POST",
|
|
314
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
315
|
+
body: JSON.stringify(
|
|
316
|
+
sdkCreateEntryRequest
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
);
|
|
320
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
321
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
322
|
+
return { data, status: res.status, headers: res.headers };
|
|
323
|
+
};
|
|
324
|
+
var getGetManageDataTypeSlugIdUrl = (typeSlug, id) => {
|
|
325
|
+
return `/api/v1/sdk/manage/data/${typeSlug}/${id}`;
|
|
326
|
+
};
|
|
327
|
+
var getManageDataTypeSlugId = async (typeSlug, id, options) => {
|
|
328
|
+
const res = await fetch(
|
|
329
|
+
getGetManageDataTypeSlugIdUrl(typeSlug, id),
|
|
330
|
+
{
|
|
331
|
+
...options,
|
|
332
|
+
method: "GET"
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
336
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
337
|
+
return { data, status: res.status, headers: res.headers };
|
|
338
|
+
};
|
|
339
|
+
var getPatchManageDataTypeSlugIdUrl = (typeSlug, id) => {
|
|
340
|
+
return `/api/v1/sdk/manage/data/${typeSlug}/${id}`;
|
|
341
|
+
};
|
|
342
|
+
var patchManageDataTypeSlugId = async (typeSlug, id, sdkUpdateEntryRequest, options) => {
|
|
343
|
+
const res = await fetch(
|
|
344
|
+
getPatchManageDataTypeSlugIdUrl(typeSlug, id),
|
|
345
|
+
{
|
|
346
|
+
...options,
|
|
347
|
+
method: "PATCH",
|
|
348
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
349
|
+
body: JSON.stringify(
|
|
350
|
+
sdkUpdateEntryRequest
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
);
|
|
354
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
355
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
356
|
+
return { data, status: res.status, headers: res.headers };
|
|
357
|
+
};
|
|
358
|
+
var getDeleteManageDataTypeSlugIdUrl = (typeSlug, id, params) => {
|
|
359
|
+
const normalizedParams = new URLSearchParams();
|
|
360
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
361
|
+
if (value !== void 0) {
|
|
362
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
const stringifiedParams = normalizedParams.toString();
|
|
366
|
+
return stringifiedParams.length > 0 ? `/api/v1/sdk/manage/data/${typeSlug}/${id}?${stringifiedParams}` : `/api/v1/sdk/manage/data/${typeSlug}/${id}`;
|
|
367
|
+
};
|
|
368
|
+
var deleteManageDataTypeSlugId = async (typeSlug, id, params, options) => {
|
|
369
|
+
const res = await fetch(
|
|
370
|
+
getDeleteManageDataTypeSlugIdUrl(typeSlug, id, params),
|
|
371
|
+
{
|
|
372
|
+
...options,
|
|
373
|
+
method: "DELETE"
|
|
374
|
+
}
|
|
375
|
+
);
|
|
376
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
377
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
378
|
+
return { data, status: res.status, headers: res.headers };
|
|
379
|
+
};
|
|
380
|
+
var getGetManageComponentsUrl = () => {
|
|
381
|
+
return `/api/v1/sdk/manage/components`;
|
|
382
|
+
};
|
|
383
|
+
var getManageComponents = async (options) => {
|
|
384
|
+
const res = await fetch(
|
|
385
|
+
getGetManageComponentsUrl(),
|
|
386
|
+
{
|
|
387
|
+
...options,
|
|
388
|
+
method: "GET"
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
392
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
393
|
+
return { data, status: res.status, headers: res.headers };
|
|
394
|
+
};
|
|
395
|
+
var getPostManageComponentsSyncUrl = () => {
|
|
396
|
+
return `/api/v1/sdk/manage/components/sync`;
|
|
397
|
+
};
|
|
398
|
+
var postManageComponentsSync = async (sdkComponentSyncRequest, options) => {
|
|
399
|
+
const res = await fetch(
|
|
400
|
+
getPostManageComponentsSyncUrl(),
|
|
401
|
+
{
|
|
402
|
+
...options,
|
|
403
|
+
method: "POST",
|
|
404
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
405
|
+
body: JSON.stringify(
|
|
406
|
+
sdkComponentSyncRequest
|
|
407
|
+
)
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
411
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
412
|
+
return { data, status: res.status, headers: res.headers };
|
|
413
|
+
};
|
|
414
|
+
var getGetManageFormDefinitionsUrl = () => {
|
|
415
|
+
return `/api/v1/sdk/manage/form-definitions`;
|
|
416
|
+
};
|
|
417
|
+
var getManageFormDefinitions = async (options) => {
|
|
418
|
+
const res = await fetch(
|
|
419
|
+
getGetManageFormDefinitionsUrl(),
|
|
420
|
+
{
|
|
421
|
+
...options,
|
|
422
|
+
method: "GET"
|
|
423
|
+
}
|
|
424
|
+
);
|
|
425
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
426
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
427
|
+
return { data, status: res.status, headers: res.headers };
|
|
428
|
+
};
|
|
429
|
+
var getPostManageFormDefinitionsUrl = () => {
|
|
430
|
+
return `/api/v1/sdk/manage/form-definitions`;
|
|
431
|
+
};
|
|
432
|
+
var postManageFormDefinitions = async (createFormDefinitionRequest, options) => {
|
|
433
|
+
const res = await fetch(
|
|
434
|
+
getPostManageFormDefinitionsUrl(),
|
|
435
|
+
{
|
|
436
|
+
...options,
|
|
437
|
+
method: "POST",
|
|
438
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
439
|
+
body: JSON.stringify(
|
|
440
|
+
createFormDefinitionRequest
|
|
441
|
+
)
|
|
442
|
+
}
|
|
443
|
+
);
|
|
444
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
445
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
446
|
+
return { data, status: res.status, headers: res.headers };
|
|
447
|
+
};
|
|
448
|
+
var getPutManageFormDefinitionsSlugUrl = (slug) => {
|
|
449
|
+
return `/api/v1/sdk/manage/form-definitions/${slug}`;
|
|
450
|
+
};
|
|
451
|
+
var putManageFormDefinitionsSlug = async (slug, updateFormDefinitionRequest, options) => {
|
|
452
|
+
const res = await fetch(
|
|
453
|
+
getPutManageFormDefinitionsSlugUrl(slug),
|
|
454
|
+
{
|
|
455
|
+
...options,
|
|
456
|
+
method: "PUT",
|
|
457
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
458
|
+
body: JSON.stringify(
|
|
459
|
+
updateFormDefinitionRequest
|
|
460
|
+
)
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
464
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
465
|
+
return { data, status: res.status, headers: res.headers };
|
|
466
|
+
};
|
|
467
|
+
var getDeleteManageFormDefinitionsSlugUrl = (slug) => {
|
|
468
|
+
return `/api/v1/sdk/manage/form-definitions/${slug}`;
|
|
469
|
+
};
|
|
470
|
+
var deleteManageFormDefinitionsSlug = async (slug, options) => {
|
|
471
|
+
const res = await fetch(
|
|
472
|
+
getDeleteManageFormDefinitionsSlugUrl(slug),
|
|
473
|
+
{
|
|
474
|
+
...options,
|
|
475
|
+
method: "DELETE"
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
479
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
480
|
+
return { data, status: res.status, headers: res.headers };
|
|
481
|
+
};
|
|
482
|
+
var getGetManageCollectionsSlugDataTypesUrl = (slug) => {
|
|
483
|
+
return `/api/v1/sdk/manage/collections/${slug}/data-types`;
|
|
484
|
+
};
|
|
485
|
+
var getManageCollectionsSlugDataTypes = async (slug, options) => {
|
|
486
|
+
const res = await fetch(
|
|
487
|
+
getGetManageCollectionsSlugDataTypesUrl(slug),
|
|
488
|
+
{
|
|
489
|
+
...options,
|
|
490
|
+
method: "GET"
|
|
491
|
+
}
|
|
492
|
+
);
|
|
493
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
494
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
495
|
+
return { data, status: res.status, headers: res.headers };
|
|
496
|
+
};
|
|
497
|
+
var getPostManageCollectionsSlugDataTypesUrl = (slug) => {
|
|
498
|
+
return `/api/v1/sdk/manage/collections/${slug}/data-types`;
|
|
499
|
+
};
|
|
500
|
+
var postManageCollectionsSlugDataTypes = async (slug, sdkAddCollectionDataTypeRequest, options) => {
|
|
501
|
+
const res = await fetch(
|
|
502
|
+
getPostManageCollectionsSlugDataTypesUrl(slug),
|
|
503
|
+
{
|
|
504
|
+
...options,
|
|
505
|
+
method: "POST",
|
|
506
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
507
|
+
body: JSON.stringify(
|
|
508
|
+
sdkAddCollectionDataTypeRequest
|
|
509
|
+
)
|
|
510
|
+
}
|
|
511
|
+
);
|
|
512
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
513
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
514
|
+
return { data, status: res.status, headers: res.headers };
|
|
515
|
+
};
|
|
516
|
+
var getDeleteManageCollectionsSlugDataTypesDtSlugUrl = (slug, dtSlug) => {
|
|
517
|
+
return `/api/v1/sdk/manage/collections/${slug}/data-types/${dtSlug}`;
|
|
518
|
+
};
|
|
519
|
+
var deleteManageCollectionsSlugDataTypesDtSlug = async (slug, dtSlug, options) => {
|
|
520
|
+
const res = await fetch(
|
|
521
|
+
getDeleteManageCollectionsSlugDataTypesDtSlugUrl(slug, dtSlug),
|
|
522
|
+
{
|
|
523
|
+
...options,
|
|
524
|
+
method: "DELETE"
|
|
525
|
+
}
|
|
526
|
+
);
|
|
527
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
528
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
529
|
+
return { data, status: res.status, headers: res.headers };
|
|
530
|
+
};
|
|
531
|
+
var getPostManageCollectionsSlugDataTypesLinkUrl = (slug) => {
|
|
532
|
+
return `/api/v1/sdk/manage/collections/${slug}/data-types/link`;
|
|
533
|
+
};
|
|
534
|
+
var postManageCollectionsSlugDataTypesLink = async (slug, sdkLinkExistingDataTypeRequest, options) => {
|
|
535
|
+
const res = await fetch(
|
|
536
|
+
getPostManageCollectionsSlugDataTypesLinkUrl(slug),
|
|
537
|
+
{
|
|
538
|
+
...options,
|
|
539
|
+
method: "POST",
|
|
540
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
541
|
+
body: JSON.stringify(
|
|
542
|
+
sdkLinkExistingDataTypeRequest
|
|
543
|
+
)
|
|
544
|
+
}
|
|
545
|
+
);
|
|
546
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
547
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
548
|
+
return { data, status: res.status, headers: res.headers };
|
|
549
|
+
};
|
|
550
|
+
var getGetManageCollectionPresetsUrl = (params) => {
|
|
551
|
+
const normalizedParams = new URLSearchParams();
|
|
552
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
553
|
+
if (value !== void 0) {
|
|
554
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
const stringifiedParams = normalizedParams.toString();
|
|
558
|
+
return stringifiedParams.length > 0 ? `/api/v1/sdk/manage/collection-presets?${stringifiedParams}` : `/api/v1/sdk/manage/collection-presets`;
|
|
559
|
+
};
|
|
560
|
+
var getManageCollectionPresets = async (params, options) => {
|
|
561
|
+
const res = await fetch(
|
|
562
|
+
getGetManageCollectionPresetsUrl(params),
|
|
563
|
+
{
|
|
564
|
+
...options,
|
|
565
|
+
method: "GET"
|
|
566
|
+
}
|
|
567
|
+
);
|
|
568
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
569
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
570
|
+
return { data, status: res.status, headers: res.headers };
|
|
571
|
+
};
|
|
572
|
+
var getPostManageContentsUrl = () => {
|
|
573
|
+
return `/api/v1/sdk/manage/contents`;
|
|
574
|
+
};
|
|
575
|
+
var postManageContents = async (createContentRequest, options) => {
|
|
576
|
+
const res = await fetch(
|
|
577
|
+
getPostManageContentsUrl(),
|
|
578
|
+
{
|
|
579
|
+
...options,
|
|
580
|
+
method: "POST",
|
|
581
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
582
|
+
body: JSON.stringify(
|
|
583
|
+
createContentRequest
|
|
584
|
+
)
|
|
585
|
+
}
|
|
586
|
+
);
|
|
587
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
588
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
589
|
+
return { data, status: res.status, headers: res.headers };
|
|
590
|
+
};
|
|
591
|
+
var getPostManageContentsIdRequestReviewUrl = (id) => {
|
|
592
|
+
return `/api/v1/sdk/manage/contents/${id}/request-review`;
|
|
593
|
+
};
|
|
594
|
+
var postManageContentsIdRequestReview = async (id, options) => {
|
|
595
|
+
const res = await fetch(
|
|
596
|
+
getPostManageContentsIdRequestReviewUrl(id),
|
|
597
|
+
{
|
|
598
|
+
...options,
|
|
599
|
+
method: "POST"
|
|
600
|
+
}
|
|
601
|
+
);
|
|
602
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
603
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
604
|
+
return { data, status: res.status, headers: res.headers };
|
|
605
|
+
};
|
|
606
|
+
var getPostManageContentsIdPublishUrl = (id) => {
|
|
607
|
+
return `/api/v1/sdk/manage/contents/${id}/publish`;
|
|
608
|
+
};
|
|
609
|
+
var postManageContentsIdPublish = async (id, options) => {
|
|
610
|
+
const res = await fetch(
|
|
611
|
+
getPostManageContentsIdPublishUrl(id),
|
|
612
|
+
{
|
|
613
|
+
...options,
|
|
614
|
+
method: "POST"
|
|
615
|
+
}
|
|
616
|
+
);
|
|
617
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
618
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
619
|
+
return { data, status: res.status, headers: res.headers };
|
|
620
|
+
};
|
|
621
|
+
var getGetManageContentsIdReferencesUrl = (id) => {
|
|
622
|
+
return `/api/v1/sdk/manage/contents/${id}/references`;
|
|
623
|
+
};
|
|
624
|
+
var getManageContentsIdReferences = async (id, options) => {
|
|
625
|
+
const res = await fetch(
|
|
626
|
+
getGetManageContentsIdReferencesUrl(id),
|
|
627
|
+
{
|
|
628
|
+
...options,
|
|
629
|
+
method: "GET"
|
|
630
|
+
}
|
|
631
|
+
);
|
|
632
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
633
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
634
|
+
return { data, status: res.status, headers: res.headers };
|
|
635
|
+
};
|
|
636
|
+
var getPutManageContentsIdReferencesUrl = (id) => {
|
|
637
|
+
return `/api/v1/sdk/manage/contents/${id}/references`;
|
|
638
|
+
};
|
|
639
|
+
var putManageContentsIdReferences = async (id, sdkSetContentReferencesRequest, options) => {
|
|
640
|
+
const res = await fetch(
|
|
641
|
+
getPutManageContentsIdReferencesUrl(id),
|
|
642
|
+
{
|
|
643
|
+
...options,
|
|
644
|
+
method: "PUT",
|
|
645
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
646
|
+
body: JSON.stringify(
|
|
647
|
+
sdkSetContentReferencesRequest
|
|
648
|
+
)
|
|
649
|
+
}
|
|
650
|
+
);
|
|
651
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
652
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
653
|
+
return { data, status: res.status, headers: res.headers };
|
|
654
|
+
};
|
|
655
|
+
|
|
58
656
|
// src/commands/list-collections.ts
|
|
59
657
|
async function listCollections() {
|
|
60
|
-
|
|
61
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
62
|
-
if (!apiUrl || !apiKey) {
|
|
63
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
|
658
|
+
ensureApiCredentials();
|
|
66
659
|
try {
|
|
67
|
-
console.log("
|
|
68
|
-
const collections = await
|
|
660
|
+
console.log("\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059...");
|
|
661
|
+
const collections = assertSdkSuccess(await getManageCollections());
|
|
69
662
|
if (!Array.isArray(collections) || collections.length === 0) {
|
|
70
|
-
console.log("
|
|
663
|
+
console.log("\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002");
|
|
71
664
|
return;
|
|
72
665
|
}
|
|
73
666
|
console.log(`
|
|
74
|
-
|
|
667
|
+
${collections.length} \u4EF6\u306E\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F:
|
|
75
668
|
`);
|
|
76
669
|
collections.forEach((c) => {
|
|
77
670
|
console.log(` ${c.name} (${c.slug})`);
|
|
78
671
|
if (c.description) {
|
|
79
|
-
console.log(`
|
|
672
|
+
console.log(` \u8AAC\u660E: ${c.description}`);
|
|
80
673
|
}
|
|
81
674
|
console.log();
|
|
82
675
|
});
|
|
83
676
|
} catch (error) {
|
|
84
|
-
console.error("\u2717
|
|
677
|
+
console.error("\u2717 \u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u4E00\u89A7\u306E\u53D6\u5F97\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
85
678
|
console.error(error instanceof Error ? error.message : String(error));
|
|
86
679
|
process.exit(1);
|
|
87
680
|
}
|
|
@@ -89,32 +682,27 @@ Found ${collections.length} collection(s):
|
|
|
89
682
|
|
|
90
683
|
// src/commands/list-data-types.ts
|
|
91
684
|
async function listDataTypes() {
|
|
92
|
-
|
|
93
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
94
|
-
if (!apiUrl || !apiKey) {
|
|
95
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
96
|
-
process.exit(1);
|
|
97
|
-
}
|
|
685
|
+
ensureApiCredentials();
|
|
98
686
|
try {
|
|
99
|
-
console.log("
|
|
100
|
-
const dataTypes = await
|
|
687
|
+
console.log("\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059...");
|
|
688
|
+
const dataTypes = assertSdkSuccess(await getManageDataTypes());
|
|
101
689
|
if (!Array.isArray(dataTypes) || dataTypes.length === 0) {
|
|
102
|
-
console.log("
|
|
690
|
+
console.log("\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002");
|
|
103
691
|
return;
|
|
104
692
|
}
|
|
105
693
|
console.log(`
|
|
106
|
-
|
|
694
|
+
${dataTypes.length} \u4EF6\u306E\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F:
|
|
107
695
|
`);
|
|
108
696
|
dataTypes.forEach((dt) => {
|
|
109
697
|
console.log(` ${dt.name} (${dt.slug})`);
|
|
110
698
|
if (dt.description) {
|
|
111
|
-
console.log(`
|
|
699
|
+
console.log(` \u8AAC\u660E: ${dt.description}`);
|
|
112
700
|
}
|
|
113
|
-
console.log(`
|
|
701
|
+
console.log(` \u30D5\u30A3\u30FC\u30EB\u30C9\u6570: ${dt.fields?.length || 0}`);
|
|
114
702
|
console.log();
|
|
115
703
|
});
|
|
116
704
|
} catch (error) {
|
|
117
|
-
console.error("\u2717
|
|
705
|
+
console.error("\u2717 \u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u4E00\u89A7\u306E\u53D6\u5F97\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
118
706
|
console.error(error instanceof Error ? error.message : String(error));
|
|
119
707
|
process.exit(1);
|
|
120
708
|
}
|
|
@@ -122,32 +710,27 @@ Found ${dataTypes.length} data type(s):
|
|
|
122
710
|
|
|
123
711
|
// src/commands/list-forms.ts
|
|
124
712
|
async function listForms() {
|
|
125
|
-
|
|
126
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
127
|
-
if (!apiUrl || !apiKey) {
|
|
128
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
129
|
-
process.exit(1);
|
|
130
|
-
}
|
|
713
|
+
ensureApiCredentials();
|
|
131
714
|
try {
|
|
132
|
-
console.log("
|
|
133
|
-
const forms = await
|
|
715
|
+
console.log("\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059...");
|
|
716
|
+
const forms = assertSdkSuccess(await getManageFormDefinitions());
|
|
134
717
|
if (!Array.isArray(forms) || forms.length === 0) {
|
|
135
|
-
console.log("
|
|
718
|
+
console.log("\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002");
|
|
136
719
|
return;
|
|
137
720
|
}
|
|
138
721
|
console.log(`
|
|
139
|
-
|
|
722
|
+
${forms.length} \u4EF6\u306E\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F:
|
|
140
723
|
`);
|
|
141
724
|
forms.forEach((f) => {
|
|
142
725
|
console.log(` ${f.name} (${f.slug})`);
|
|
143
726
|
if (f.description) {
|
|
144
|
-
console.log(`
|
|
727
|
+
console.log(` \u8AAC\u660E: ${f.description}`);
|
|
145
728
|
}
|
|
146
|
-
console.log(`
|
|
729
|
+
console.log(` \u30D5\u30A3\u30FC\u30EB\u30C9\u6570: ${f.fields?.length || 0}`);
|
|
147
730
|
console.log();
|
|
148
731
|
});
|
|
149
732
|
} catch (error) {
|
|
150
|
-
console.error("\u2717
|
|
733
|
+
console.error("\u2717 \u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u4E00\u89A7\u306E\u53D6\u5F97\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
151
734
|
console.error(error instanceof Error ? error.message : String(error));
|
|
152
735
|
process.exit(1);
|
|
153
736
|
}
|
|
@@ -155,32 +738,27 @@ Found ${forms.length} form definition(s):
|
|
|
155
738
|
|
|
156
739
|
// src/commands/list-components.ts
|
|
157
740
|
async function listComponents() {
|
|
158
|
-
|
|
159
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
160
|
-
if (!apiUrl || !apiKey) {
|
|
161
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
162
|
-
process.exit(1);
|
|
163
|
-
}
|
|
741
|
+
ensureApiCredentials();
|
|
164
742
|
try {
|
|
165
|
-
console.log("
|
|
166
|
-
const result = await
|
|
167
|
-
const components =
|
|
743
|
+
console.log("\u30AB\u30B9\u30BF\u30E0\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059...");
|
|
744
|
+
const result = assertSdkSuccess(await getManageComponents());
|
|
745
|
+
const components = result.components || [];
|
|
168
746
|
if (components.length === 0) {
|
|
169
|
-
console.log("
|
|
747
|
+
console.log("\u30AB\u30B9\u30BF\u30E0\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002");
|
|
170
748
|
return;
|
|
171
749
|
}
|
|
172
750
|
console.log(`
|
|
173
|
-
|
|
751
|
+
${components.length} \u4EF6\u306E\u30AB\u30B9\u30BF\u30E0\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F:
|
|
174
752
|
`);
|
|
175
753
|
components.forEach((c) => {
|
|
176
754
|
console.log(` ${c.displayName} (${c.name})`);
|
|
177
755
|
if (c.description) {
|
|
178
|
-
console.log(`
|
|
756
|
+
console.log(` \u8AAC\u660E: ${c.description}`);
|
|
179
757
|
}
|
|
180
758
|
console.log();
|
|
181
759
|
});
|
|
182
760
|
} catch (error) {
|
|
183
|
-
console.error("\u2717
|
|
761
|
+
console.error("\u2717 \u30AB\u30B9\u30BF\u30E0\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u4E00\u89A7\u306E\u53D6\u5F97\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
184
762
|
console.error(error instanceof Error ? error.message : String(error));
|
|
185
763
|
process.exit(1);
|
|
186
764
|
}
|
|
@@ -188,18 +766,13 @@ Found ${components.length} custom component(s):
|
|
|
188
766
|
|
|
189
767
|
// src/commands/create-collection.ts
|
|
190
768
|
async function createCollection(options) {
|
|
191
|
-
|
|
192
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
193
|
-
if (!apiUrl || !apiKey) {
|
|
194
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
195
|
-
process.exit(1);
|
|
196
|
-
}
|
|
769
|
+
ensureApiCredentials();
|
|
197
770
|
let input;
|
|
198
771
|
if (options.json || options.file) {
|
|
199
772
|
input = readJsonInput(options);
|
|
200
773
|
} else {
|
|
201
774
|
if (!options.type || !options.slug || !options.name) {
|
|
202
|
-
console.error("
|
|
775
|
+
console.error("\u30A8\u30E9\u30FC: --json \u307E\u305F\u306F --type\u30FB--slug\u30FB--name \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
203
776
|
process.exit(1);
|
|
204
777
|
}
|
|
205
778
|
input = {
|
|
@@ -210,49 +783,39 @@ async function createCollection(options) {
|
|
|
210
783
|
};
|
|
211
784
|
}
|
|
212
785
|
if (!input.type || !input.slug || !input.name) {
|
|
213
|
-
console.error("
|
|
786
|
+
console.error("\u30A8\u30E9\u30FC: JSON \u306B\u306F type\u30FBslug\u30FBname \u304C\u5FC5\u8981\u3067\u3059");
|
|
214
787
|
process.exit(1);
|
|
215
788
|
}
|
|
216
|
-
console.log(
|
|
217
|
-
const result = await
|
|
218
|
-
console.log("
|
|
789
|
+
console.log(`\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059: ${input.slug} (${input.type})...`);
|
|
790
|
+
const result = assertSdkSuccess(await postManageCollections(input));
|
|
791
|
+
console.log("\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u4F5C\u6210\u3057\u307E\u3057\u305F:");
|
|
219
792
|
console.log(JSON.stringify(result, null, 2));
|
|
220
793
|
}
|
|
221
794
|
|
|
222
795
|
// src/commands/create-data-type.ts
|
|
223
796
|
async function createDataType(options) {
|
|
224
|
-
|
|
225
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
226
|
-
if (!apiUrl || !apiKey) {
|
|
227
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
228
|
-
process.exit(1);
|
|
229
|
-
}
|
|
797
|
+
ensureApiCredentials();
|
|
230
798
|
const input = readJsonInput(options);
|
|
231
799
|
if (!input.slug || !input.name || !input.fields) {
|
|
232
|
-
console.error("
|
|
800
|
+
console.error("\u30A8\u30E9\u30FC: JSON \u306B\u306F slug\u30FBname\u30FBfields \u304C\u5FC5\u8981\u3067\u3059");
|
|
233
801
|
process.exit(1);
|
|
234
802
|
}
|
|
235
|
-
console.log(
|
|
236
|
-
const result = await
|
|
237
|
-
console.log("
|
|
803
|
+
console.log(`\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059: ${input.slug}...`);
|
|
804
|
+
const result = assertSdkSuccess(await postManageDataTypes(input));
|
|
805
|
+
console.log("\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u4F5C\u6210\u3057\u307E\u3057\u305F:");
|
|
238
806
|
console.log(JSON.stringify(result, null, 2));
|
|
239
807
|
}
|
|
240
808
|
|
|
241
809
|
// src/commands/create-form.ts
|
|
242
810
|
async function createForm(options) {
|
|
243
|
-
|
|
244
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
245
|
-
if (!apiUrl || !apiKey) {
|
|
246
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
247
|
-
process.exit(1);
|
|
248
|
-
}
|
|
811
|
+
ensureApiCredentials();
|
|
249
812
|
try {
|
|
250
813
|
let data;
|
|
251
814
|
if (options.json) {
|
|
252
815
|
data = JSON.parse(options.json);
|
|
253
816
|
} else {
|
|
254
817
|
if (!options.slug || !options.name) {
|
|
255
|
-
throw new Error("--slug
|
|
818
|
+
throw new Error("--slug \u3068 --name \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u3082\u3057\u304F\u306F --json \u3092\u5229\u7528\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
256
819
|
}
|
|
257
820
|
data = {
|
|
258
821
|
slug: options.slug,
|
|
@@ -261,12 +824,12 @@ async function createForm(options) {
|
|
|
261
824
|
fields: []
|
|
262
825
|
};
|
|
263
826
|
}
|
|
264
|
-
console.log(
|
|
265
|
-
const result = await
|
|
266
|
-
console.log("\u2713
|
|
827
|
+
console.log(`\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059: ${data.name} (${data.slug})...`);
|
|
828
|
+
const result = assertSdkSuccess(await postManageFormDefinitions(data));
|
|
829
|
+
console.log("\u2713 \u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u4F5C\u6210\u3057\u307E\u3057\u305F");
|
|
267
830
|
console.log(JSON.stringify(result, null, 2));
|
|
268
831
|
} catch (error) {
|
|
269
|
-
console.error("\u2717
|
|
832
|
+
console.error("\u2717 \u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306E\u4F5C\u6210\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
270
833
|
console.error(error instanceof Error ? error.message : String(error));
|
|
271
834
|
process.exit(1);
|
|
272
835
|
}
|
|
@@ -274,15 +837,10 @@ async function createForm(options) {
|
|
|
274
837
|
|
|
275
838
|
// src/commands/update-collection.ts
|
|
276
839
|
async function updateCollection(options) {
|
|
277
|
-
|
|
278
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
279
|
-
if (!apiUrl || !apiKey) {
|
|
280
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
281
|
-
process.exit(1);
|
|
282
|
-
}
|
|
840
|
+
ensureApiCredentials();
|
|
283
841
|
try {
|
|
284
842
|
if (!options.slug) {
|
|
285
|
-
throw new Error("--slug
|
|
843
|
+
throw new Error("--slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u66F4\u65B0\u5BFE\u8C61\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u73FE\u5728\u30B9\u30E9\u30C3\u30B0\uFF09");
|
|
286
844
|
}
|
|
287
845
|
let data;
|
|
288
846
|
if (options.json) {
|
|
@@ -294,14 +852,14 @@ async function updateCollection(options) {
|
|
|
294
852
|
if (options.description !== void 0) data.description = options.description;
|
|
295
853
|
}
|
|
296
854
|
if (Object.keys(data).length === 0) {
|
|
297
|
-
throw new Error("
|
|
855
|
+
throw new Error("\u66F4\u65B0\u9805\u76EE\u304C\u3042\u308A\u307E\u305B\u3093\u3002--json / --new-slug / --name / --description \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
298
856
|
}
|
|
299
|
-
console.log(
|
|
300
|
-
const result = await
|
|
301
|
-
console.log("\u2713
|
|
857
|
+
console.log(`\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u66F4\u65B0\u3057\u3066\u3044\u307E\u3059: ${options.slug}...`);
|
|
858
|
+
const result = assertSdkSuccess(await putManageCollectionsSlug(options.slug, data));
|
|
859
|
+
console.log("\u2713 \u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u66F4\u65B0\u3057\u307E\u3057\u305F");
|
|
302
860
|
console.log(JSON.stringify(result, null, 2));
|
|
303
861
|
} catch (error) {
|
|
304
|
-
console.error("\u2717
|
|
862
|
+
console.error("\u2717 \u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u66F4\u65B0\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
305
863
|
console.error(error instanceof Error ? error.message : String(error));
|
|
306
864
|
process.exit(1);
|
|
307
865
|
}
|
|
@@ -309,34 +867,34 @@ async function updateCollection(options) {
|
|
|
309
867
|
|
|
310
868
|
// src/commands/update-data-type.ts
|
|
311
869
|
async function updateDataType(options) {
|
|
312
|
-
|
|
313
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
314
|
-
if (!apiUrl || !apiKey) {
|
|
315
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
316
|
-
process.exit(1);
|
|
317
|
-
}
|
|
870
|
+
ensureApiCredentials();
|
|
318
871
|
try {
|
|
319
872
|
if (!options.slug) {
|
|
320
|
-
throw new Error("--slug
|
|
873
|
+
throw new Error("--slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u66F4\u65B0\u5BFE\u8C61\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u73FE\u5728\u30B9\u30E9\u30C3\u30B0\uFF09");
|
|
874
|
+
}
|
|
875
|
+
if (options.newSlug) {
|
|
876
|
+
throw new Error("--new-slug \u306F API \u3067\u975E\u5BFE\u5FDC\u3067\u3059\u3002\u30B9\u30E9\u30C3\u30B0\u5909\u66F4\u306F\u518D\u4F5C\u6210\u3057\u3066\u304F\u3060\u3055\u3044\u3002");
|
|
321
877
|
}
|
|
322
878
|
let data;
|
|
323
879
|
if (options.json) {
|
|
324
880
|
data = JSON.parse(options.json);
|
|
881
|
+
if ("slug" in data) {
|
|
882
|
+
throw new Error("update-data-type \u3067\u306F slug \u3092\u66F4\u65B0\u3067\u304D\u307E\u305B\u3093");
|
|
883
|
+
}
|
|
325
884
|
} else {
|
|
326
885
|
data = {};
|
|
327
|
-
if (options.newSlug) data.slug = options.newSlug;
|
|
328
886
|
if (options.name) data.name = options.name;
|
|
329
887
|
if (options.description !== void 0) data.description = options.description;
|
|
330
888
|
}
|
|
331
889
|
if (Object.keys(data).length === 0) {
|
|
332
|
-
throw new Error("
|
|
890
|
+
throw new Error("\u66F4\u65B0\u9805\u76EE\u304C\u3042\u308A\u307E\u305B\u3093\u3002--json / --name / --description \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
333
891
|
}
|
|
334
|
-
console.log(
|
|
335
|
-
const result = await
|
|
336
|
-
console.log("\u2713
|
|
892
|
+
console.log(`\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u66F4\u65B0\u3057\u3066\u3044\u307E\u3059: ${options.slug}...`);
|
|
893
|
+
const result = assertSdkSuccess(await putManageDataTypesSlug(options.slug, data));
|
|
894
|
+
console.log("\u2713 \u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u66F4\u65B0\u3057\u307E\u3057\u305F");
|
|
337
895
|
console.log(JSON.stringify(result, null, 2));
|
|
338
896
|
} catch (error) {
|
|
339
|
-
console.error("\u2717
|
|
897
|
+
console.error("\u2717 \u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u66F4\u65B0\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
340
898
|
console.error(error instanceof Error ? error.message : String(error));
|
|
341
899
|
process.exit(1);
|
|
342
900
|
}
|
|
@@ -344,34 +902,34 @@ async function updateDataType(options) {
|
|
|
344
902
|
|
|
345
903
|
// src/commands/update-form.ts
|
|
346
904
|
async function updateForm(options) {
|
|
347
|
-
|
|
348
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
349
|
-
if (!apiUrl || !apiKey) {
|
|
350
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
351
|
-
process.exit(1);
|
|
352
|
-
}
|
|
905
|
+
ensureApiCredentials();
|
|
353
906
|
try {
|
|
354
907
|
if (!options.slug) {
|
|
355
|
-
throw new Error("--slug
|
|
908
|
+
throw new Error("--slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u66F4\u65B0\u5BFE\u8C61\u30D5\u30A9\u30FC\u30E0\u306E\u73FE\u5728\u30B9\u30E9\u30C3\u30B0\uFF09");
|
|
909
|
+
}
|
|
910
|
+
if (options.newSlug) {
|
|
911
|
+
throw new Error("--new-slug \u306F API \u3067\u975E\u5BFE\u5FDC\u3067\u3059\u3002\u30B9\u30E9\u30C3\u30B0\u5909\u66F4\u306F\u518D\u4F5C\u6210\u3057\u3066\u304F\u3060\u3055\u3044\u3002");
|
|
356
912
|
}
|
|
357
913
|
let data;
|
|
358
914
|
if (options.json) {
|
|
359
915
|
data = JSON.parse(options.json);
|
|
916
|
+
if ("slug" in data) {
|
|
917
|
+
throw new Error("update-form \u3067\u306F slug \u3092\u66F4\u65B0\u3067\u304D\u307E\u305B\u3093");
|
|
918
|
+
}
|
|
360
919
|
} else {
|
|
361
920
|
data = {};
|
|
362
|
-
if (options.newSlug) data.slug = options.newSlug;
|
|
363
921
|
if (options.name) data.name = options.name;
|
|
364
922
|
if (options.description !== void 0) data.description = options.description;
|
|
365
923
|
}
|
|
366
924
|
if (Object.keys(data).length === 0) {
|
|
367
|
-
throw new Error("
|
|
925
|
+
throw new Error("\u66F4\u65B0\u9805\u76EE\u304C\u3042\u308A\u307E\u305B\u3093\u3002--json / --name / --description \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
368
926
|
}
|
|
369
|
-
console.log(
|
|
370
|
-
const result = await
|
|
371
|
-
console.log("\u2713
|
|
927
|
+
console.log(`\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u66F4\u65B0\u3057\u3066\u3044\u307E\u3059: ${options.slug}...`);
|
|
928
|
+
const result = assertSdkSuccess(await putManageFormDefinitionsSlug(options.slug, data));
|
|
929
|
+
console.log("\u2713 \u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u66F4\u65B0\u3057\u307E\u3057\u305F");
|
|
372
930
|
console.log(JSON.stringify(result, null, 2));
|
|
373
931
|
} catch (error) {
|
|
374
|
-
console.error("\u2717
|
|
932
|
+
console.error("\u2717 \u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306E\u66F4\u65B0\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
375
933
|
console.error(error instanceof Error ? error.message : String(error));
|
|
376
934
|
process.exit(1);
|
|
377
935
|
}
|
|
@@ -392,31 +950,26 @@ async function confirm(message) {
|
|
|
392
950
|
});
|
|
393
951
|
}
|
|
394
952
|
async function deleteCollection(options) {
|
|
395
|
-
|
|
396
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
397
|
-
if (!apiUrl || !apiKey) {
|
|
398
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
399
|
-
process.exit(1);
|
|
400
|
-
}
|
|
953
|
+
ensureApiCredentials();
|
|
401
954
|
try {
|
|
402
955
|
if (!options.slug) {
|
|
403
|
-
throw new Error("--slug
|
|
956
|
+
throw new Error("--slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
404
957
|
}
|
|
405
958
|
if (!options.force) {
|
|
406
959
|
console.log(`
|
|
407
|
-
\u26A0\uFE0F
|
|
408
|
-
console.log("
|
|
409
|
-
const confirmed = await confirm("
|
|
960
|
+
\u26A0\uFE0F \u30B3\u30EC\u30AF\u30B7\u30E7\u30F3 "${options.slug}" \u3092\u524A\u9664\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307E\u3059`);
|
|
961
|
+
console.log(" \u3053\u306E\u64CD\u4F5C\u306F\u53D6\u308A\u6D88\u305B\u307E\u305B\u3093\u3002\n");
|
|
962
|
+
const confirmed = await confirm("\u3053\u306E\u307E\u307E\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F");
|
|
410
963
|
if (!confirmed) {
|
|
411
|
-
console.log("
|
|
964
|
+
console.log("\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u307E\u3057\u305F\u3002");
|
|
412
965
|
return;
|
|
413
966
|
}
|
|
414
967
|
}
|
|
415
|
-
console.log(
|
|
416
|
-
await
|
|
417
|
-
console.log("\u2713
|
|
968
|
+
console.log(`\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u524A\u9664\u3057\u3066\u3044\u307E\u3059: ${options.slug}...`);
|
|
969
|
+
assertSdkSuccess(await deleteManageCollectionsSlug(options.slug));
|
|
970
|
+
console.log("\u2713 \u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u524A\u9664\u3057\u307E\u3057\u305F");
|
|
418
971
|
} catch (error) {
|
|
419
|
-
console.error("\u2717
|
|
972
|
+
console.error("\u2717 \u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u524A\u9664\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
420
973
|
console.error(error instanceof Error ? error.message : String(error));
|
|
421
974
|
process.exit(1);
|
|
422
975
|
}
|
|
@@ -437,31 +990,26 @@ async function confirm2(message) {
|
|
|
437
990
|
});
|
|
438
991
|
}
|
|
439
992
|
async function deleteDataType(options) {
|
|
440
|
-
|
|
441
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
442
|
-
if (!apiUrl || !apiKey) {
|
|
443
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
444
|
-
process.exit(1);
|
|
445
|
-
}
|
|
993
|
+
ensureApiCredentials();
|
|
446
994
|
try {
|
|
447
995
|
if (!options.slug) {
|
|
448
|
-
throw new Error("--slug
|
|
996
|
+
throw new Error("--slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
449
997
|
}
|
|
450
998
|
if (!options.force) {
|
|
451
999
|
console.log(`
|
|
452
|
-
\u26A0\uFE0F
|
|
453
|
-
console.log("
|
|
454
|
-
const confirmed = await confirm2("
|
|
1000
|
+
\u26A0\uFE0F \u30C7\u30FC\u30BF\u30BF\u30A4\u30D7 "${options.slug}" \u3092\u524A\u9664\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307E\u3059`);
|
|
1001
|
+
console.log(" \u3053\u306E\u64CD\u4F5C\u306F\u53D6\u308A\u6D88\u305B\u307E\u305B\u3093\u3002\n");
|
|
1002
|
+
const confirmed = await confirm2("\u3053\u306E\u307E\u307E\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F");
|
|
455
1003
|
if (!confirmed) {
|
|
456
|
-
console.log("
|
|
1004
|
+
console.log("\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u307E\u3057\u305F\u3002");
|
|
457
1005
|
return;
|
|
458
1006
|
}
|
|
459
1007
|
}
|
|
460
|
-
console.log(
|
|
461
|
-
await
|
|
462
|
-
console.log("\u2713
|
|
1008
|
+
console.log(`\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u524A\u9664\u3057\u3066\u3044\u307E\u3059: ${options.slug}...`);
|
|
1009
|
+
assertSdkSuccess(await deleteManageDataTypesSlug(options.slug));
|
|
1010
|
+
console.log("\u2713 \u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u524A\u9664\u3057\u307E\u3057\u305F");
|
|
463
1011
|
} catch (error) {
|
|
464
|
-
console.error("\u2717
|
|
1012
|
+
console.error("\u2717 \u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u524A\u9664\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
465
1013
|
console.error(error instanceof Error ? error.message : String(error));
|
|
466
1014
|
process.exit(1);
|
|
467
1015
|
}
|
|
@@ -482,32 +1030,27 @@ async function confirm3(message) {
|
|
|
482
1030
|
});
|
|
483
1031
|
}
|
|
484
1032
|
async function deleteForm(options) {
|
|
485
|
-
|
|
486
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
487
|
-
if (!apiUrl || !apiKey) {
|
|
488
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
489
|
-
process.exit(1);
|
|
490
|
-
}
|
|
1033
|
+
ensureApiCredentials();
|
|
491
1034
|
try {
|
|
492
1035
|
if (!options.slug) {
|
|
493
|
-
throw new Error("--slug
|
|
1036
|
+
throw new Error("--slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
494
1037
|
}
|
|
495
1038
|
if (!options.force) {
|
|
496
1039
|
console.log(`
|
|
497
|
-
\u26A0\uFE0F
|
|
498
|
-
console.log("
|
|
499
|
-
console.log("
|
|
500
|
-
const confirmed = await confirm3("
|
|
1040
|
+
\u26A0\uFE0F \u30D5\u30A9\u30FC\u30E0 "${options.slug}" \u3092\u524A\u9664\u3057\u3088\u3046\u3068\u3057\u3066\u3044\u307E\u3059`);
|
|
1041
|
+
console.log(" \u65E2\u5B58\u306E\u30D5\u30A9\u30FC\u30E0\u9001\u4FE1\u30C7\u30FC\u30BF\u306F\u4FDD\u6301\u3055\u308C\u307E\u3059\u3002");
|
|
1042
|
+
console.log(" \u3053\u306E\u64CD\u4F5C\u306F\u53D6\u308A\u6D88\u305B\u307E\u305B\u3093\u3002\n");
|
|
1043
|
+
const confirmed = await confirm3("\u3053\u306E\u307E\u307E\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F");
|
|
501
1044
|
if (!confirmed) {
|
|
502
|
-
console.log("
|
|
1045
|
+
console.log("\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u307E\u3057\u305F\u3002");
|
|
503
1046
|
return;
|
|
504
1047
|
}
|
|
505
1048
|
}
|
|
506
|
-
console.log(
|
|
507
|
-
await
|
|
508
|
-
console.log("\u2713
|
|
1049
|
+
console.log(`\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u524A\u9664\u3057\u3066\u3044\u307E\u3059: ${options.slug}...`);
|
|
1050
|
+
assertSdkSuccess(await deleteManageFormDefinitionsSlug(options.slug));
|
|
1051
|
+
console.log("\u2713 \u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u524A\u9664\u3057\u307E\u3057\u305F");
|
|
509
1052
|
} catch (error) {
|
|
510
|
-
console.error("\u2717
|
|
1053
|
+
console.error("\u2717 \u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306E\u524A\u9664\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
511
1054
|
console.error(error instanceof Error ? error.message : String(error));
|
|
512
1055
|
process.exit(1);
|
|
513
1056
|
}
|
|
@@ -653,12 +1196,12 @@ var ComponentDefinitionSchema = z2.object({
|
|
|
653
1196
|
name: z2.string().min(1).max(100).regex(/^[A-Z][a-zA-Z0-9]*$/),
|
|
654
1197
|
displayName: z2.string().min(1).max(255),
|
|
655
1198
|
description: z2.string().optional(),
|
|
656
|
-
propsSchema: z2.record(ComponentPropSchema).default({}),
|
|
1199
|
+
propsSchema: z2.record(z2.string(), ComponentPropSchema).default({}),
|
|
657
1200
|
examples: z2.array(z2.string()).default([])
|
|
658
1201
|
});
|
|
659
1202
|
function readComponentDefinitions(componentsDir) {
|
|
660
1203
|
if (!existsSync(componentsDir)) {
|
|
661
|
-
console.log("
|
|
1204
|
+
console.log("cmx/components/ \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002");
|
|
662
1205
|
return { exists: false, components: [] };
|
|
663
1206
|
}
|
|
664
1207
|
const files = readdirSync(componentsDir).filter((f) => f.endsWith(".json"));
|
|
@@ -670,7 +1213,7 @@ function readComponentDefinitions(componentsDir) {
|
|
|
670
1213
|
const parsed = JSON.parse(content);
|
|
671
1214
|
const result = ComponentDefinitionSchema.safeParse(parsed);
|
|
672
1215
|
if (!result.success) {
|
|
673
|
-
console.error(`
|
|
1216
|
+
console.error(` ${file} \u306E\u5F62\u5F0F\u304C\u4E0D\u6B63\u3067\u3059`);
|
|
674
1217
|
for (const issue of result.error.issues) {
|
|
675
1218
|
const path = issue.path.length > 0 ? issue.path.join(".") : "(root)";
|
|
676
1219
|
console.error(` - ${path}: ${issue.message}`);
|
|
@@ -683,45 +1226,39 @@ function readComponentDefinitions(componentsDir) {
|
|
|
683
1226
|
}
|
|
684
1227
|
components.push(result.data);
|
|
685
1228
|
} catch (error) {
|
|
686
|
-
console.error(`
|
|
1229
|
+
console.error(` ${file} \u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F:`, error instanceof Error ? error.message : error);
|
|
687
1230
|
process.exit(1);
|
|
688
1231
|
}
|
|
689
1232
|
}
|
|
690
1233
|
return { exists: true, components };
|
|
691
1234
|
}
|
|
692
1235
|
async function syncComponents() {
|
|
693
|
-
|
|
694
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
695
|
-
if (!apiUrl || !apiKey) {
|
|
696
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
697
|
-
process.exit(1);
|
|
698
|
-
}
|
|
1236
|
+
ensureApiCredentials();
|
|
699
1237
|
const componentsDir = join(process.cwd(), "cmx/components");
|
|
700
1238
|
const { exists, components } = readComponentDefinitions(componentsDir);
|
|
701
1239
|
if (!exists) {
|
|
702
|
-
console.log("
|
|
1240
|
+
console.log("\u540C\u671F\u5BFE\u8C61\u306E\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u3042\u308A\u307E\u305B\u3093\u3002");
|
|
703
1241
|
return;
|
|
704
1242
|
}
|
|
705
1243
|
if (components.length === 0) {
|
|
706
|
-
console.log("
|
|
1244
|
+
console.log("\u5B9A\u7FA9\u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u7A7A\u30EA\u30B9\u30C8\u3067\u540C\u671F\u3057\u307E\u3059\uFF08\u65E2\u5B58\u30AB\u30B9\u30BF\u30E0\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u306F\u524A\u9664\u3055\u308C\u307E\u3059\uFF09\u3002");
|
|
707
1245
|
} else {
|
|
708
|
-
console.log(
|
|
1246
|
+
console.log(`${components.length} \u4EF6\u306E\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u3092\u540C\u671F\u3057\u307E\u3059:`);
|
|
709
1247
|
for (const c of components) {
|
|
710
1248
|
console.log(` - ${c.name} (${c.displayName})`);
|
|
711
1249
|
}
|
|
712
1250
|
}
|
|
713
|
-
console.log(
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
{ components }
|
|
1251
|
+
console.log("\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u3092\u540C\u671F\u3057\u3066\u3044\u307E\u3059...");
|
|
1252
|
+
const requestBody = {
|
|
1253
|
+
components
|
|
1254
|
+
};
|
|
1255
|
+
const result = assertSdkSuccess(
|
|
1256
|
+
await postManageComponentsSync(requestBody)
|
|
720
1257
|
);
|
|
721
|
-
console.log(
|
|
722
|
-
if (result.created) console.log(`
|
|
723
|
-
if (result.updated) console.log(`
|
|
724
|
-
if (result.deleted) console.log(`
|
|
1258
|
+
console.log(`\u5B8C\u4E86: ${result.message || "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u3092\u540C\u671F\u3057\u307E\u3057\u305F"}`);
|
|
1259
|
+
if (result.created) console.log(` \u4F5C\u6210: ${result.created}`);
|
|
1260
|
+
if (result.updated) console.log(` \u66F4\u65B0: ${result.updated}`);
|
|
1261
|
+
if (result.deleted) console.log(` \u524A\u9664: ${result.deleted}`);
|
|
725
1262
|
}
|
|
726
1263
|
|
|
727
1264
|
// src/codegen/generator.ts
|
|
@@ -740,7 +1277,7 @@ async function fetchSchema(apiUrl, apiKey) {
|
|
|
740
1277
|
});
|
|
741
1278
|
if (!response.ok) {
|
|
742
1279
|
const body = await response.text().catch(() => "");
|
|
743
|
-
throw new Error(
|
|
1280
|
+
throw new Error(`\u30B9\u30AD\u30FC\u30DE\u306E\u53D6\u5F97\u306B\u5931\u6557\u3057\u307E\u3057\u305F (HTTP ${response.status}): ${body}`);
|
|
744
1281
|
}
|
|
745
1282
|
return response.json();
|
|
746
1283
|
}
|
|
@@ -1073,12 +1610,10 @@ function generateRootIndex(hasDataTypes, hasCollections, hasForms) {
|
|
|
1073
1610
|
// src/codegen/generator.ts
|
|
1074
1611
|
async function generate(options) {
|
|
1075
1612
|
const { apiUrl, apiKey, outputDir } = options;
|
|
1076
|
-
console.log(
|
|
1613
|
+
console.log(`\u30B9\u30AD\u30FC\u30DE\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059: ${apiUrl} ...`);
|
|
1077
1614
|
const schema = await fetchSchema(apiUrl, apiKey);
|
|
1078
1615
|
const forms = schema.forms ?? [];
|
|
1079
|
-
console.log(
|
|
1080
|
-
`Found ${schema.dataTypes.length} data type(s), ${schema.collections.length} collection(s), and ${forms.length} form(s)`
|
|
1081
|
-
);
|
|
1616
|
+
console.log(`${schema.dataTypes.length} \u4EF6\u306E\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3001${schema.collections.length} \u4EF6\u306E\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3001${forms.length} \u4EF6\u306E\u30D5\u30A9\u30FC\u30E0\u3092\u691C\u51FA\u3057\u307E\u3057\u305F`);
|
|
1082
1617
|
await rm(outputDir, { recursive: true, force: true });
|
|
1083
1618
|
await mkdir(outputDir, { recursive: true });
|
|
1084
1619
|
const dataTypeSlugs = [];
|
|
@@ -1091,14 +1626,14 @@ async function generate(options) {
|
|
|
1091
1626
|
for (const dt of schema.dataTypes) {
|
|
1092
1627
|
const safeSlug = sanitizeIdentifier(dt.slug);
|
|
1093
1628
|
if (!safeSlug) {
|
|
1094
|
-
console.warn(`
|
|
1629
|
+
console.warn(` \u30B9\u30E9\u30C3\u30B0\u304C\u4E0D\u6B63\u306A\u305F\u3081\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3059: "${dt.slug}"`);
|
|
1095
1630
|
continue;
|
|
1096
1631
|
}
|
|
1097
1632
|
const fileName = nameTracker(safeSlug);
|
|
1098
1633
|
const content = generateDataTypeFile(dt);
|
|
1099
1634
|
await writeFile(join2(dataTypesDir, `${fileName}.ts`), content, "utf-8");
|
|
1100
1635
|
dataTypeSlugs.push(fileName);
|
|
1101
|
-
console.log(`
|
|
1636
|
+
console.log(` \u751F\u6210: data-types/${fileName}.ts (${dt.name})`);
|
|
1102
1637
|
}
|
|
1103
1638
|
const indexContent = generateDataTypesIndex(dataTypeSlugs);
|
|
1104
1639
|
await writeFile(join2(dataTypesDir, "index.ts"), indexContent, "utf-8");
|
|
@@ -1110,14 +1645,14 @@ async function generate(options) {
|
|
|
1110
1645
|
for (const col of schema.collections) {
|
|
1111
1646
|
const safeSlug = sanitizeIdentifier(col.slug);
|
|
1112
1647
|
if (!safeSlug) {
|
|
1113
|
-
console.warn(`
|
|
1648
|
+
console.warn(` \u30B9\u30E9\u30C3\u30B0\u304C\u4E0D\u6B63\u306A\u305F\u3081\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3059: "${col.slug}"`);
|
|
1114
1649
|
continue;
|
|
1115
1650
|
}
|
|
1116
1651
|
const fileName = nameTracker(safeSlug);
|
|
1117
1652
|
const content = generateCollectionFile(col);
|
|
1118
1653
|
await writeFile(join2(collectionsDir, `${fileName}.ts`), content, "utf-8");
|
|
1119
1654
|
collectionSlugs.push(fileName);
|
|
1120
|
-
console.log(`
|
|
1655
|
+
console.log(` \u751F\u6210: collections/${fileName}.ts (${col.name})`);
|
|
1121
1656
|
}
|
|
1122
1657
|
const indexContent = generateCollectionsIndex(collectionSlugs);
|
|
1123
1658
|
await writeFile(join2(collectionsDir, "index.ts"), indexContent, "utf-8");
|
|
@@ -1129,14 +1664,14 @@ async function generate(options) {
|
|
|
1129
1664
|
for (const form of forms) {
|
|
1130
1665
|
const safeSlug = sanitizeIdentifier(form.slug);
|
|
1131
1666
|
if (!safeSlug) {
|
|
1132
|
-
console.warn(`
|
|
1667
|
+
console.warn(` \u30B9\u30E9\u30C3\u30B0\u304C\u4E0D\u6B63\u306A\u305F\u3081\u30D5\u30A9\u30FC\u30E0\u3092\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3059: "${form.slug}"`);
|
|
1133
1668
|
continue;
|
|
1134
1669
|
}
|
|
1135
1670
|
const fileName = nameTracker(safeSlug);
|
|
1136
1671
|
const content = generateFormFile(form);
|
|
1137
1672
|
await writeFile(join2(formsDir, `${fileName}.ts`), content, "utf-8");
|
|
1138
1673
|
formSlugs.push(fileName);
|
|
1139
|
-
console.log(`
|
|
1674
|
+
console.log(` \u751F\u6210: forms/${fileName}.ts (${form.name})`);
|
|
1140
1675
|
}
|
|
1141
1676
|
const indexContent = generateFormsIndex(formSlugs);
|
|
1142
1677
|
await writeFile(join2(formsDir, "index.ts"), indexContent, "utf-8");
|
|
@@ -1148,47 +1683,39 @@ async function generate(options) {
|
|
|
1148
1683
|
);
|
|
1149
1684
|
await writeFile(join2(outputDir, "index.ts"), rootIndex, "utf-8");
|
|
1150
1685
|
console.log(`
|
|
1151
|
-
|
|
1686
|
+
\u751F\u6210\u5B8C\u4E86: ${outputDir}`);
|
|
1152
1687
|
}
|
|
1153
1688
|
|
|
1154
1689
|
// src/commands/list-collection-data-types.ts
|
|
1155
1690
|
async function listCollectionDataTypes(opts) {
|
|
1156
|
-
|
|
1157
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
1158
|
-
if (!apiUrl || !apiKey) {
|
|
1159
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
1160
|
-
process.exit(1);
|
|
1161
|
-
}
|
|
1691
|
+
ensureApiCredentials();
|
|
1162
1692
|
const collectionSlug = opts.collection;
|
|
1163
1693
|
if (!collectionSlug) {
|
|
1164
|
-
console.error("
|
|
1694
|
+
console.error("\u30A8\u30E9\u30FC: --collection \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
1165
1695
|
process.exit(1);
|
|
1166
1696
|
}
|
|
1167
1697
|
try {
|
|
1168
|
-
console.log(
|
|
1169
|
-
const dataTypes =
|
|
1170
|
-
|
|
1171
|
-
apiKey,
|
|
1172
|
-
"GET",
|
|
1173
|
-
`/collections/${collectionSlug}/data-types`
|
|
1698
|
+
console.log(`\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059: ${collectionSlug}...`);
|
|
1699
|
+
const dataTypes = assertSdkSuccess(
|
|
1700
|
+
await getManageCollectionsSlugDataTypes(collectionSlug)
|
|
1174
1701
|
);
|
|
1175
1702
|
if (dataTypes.length === 0) {
|
|
1176
|
-
console.log("
|
|
1703
|
+
console.log("\u3053\u306E\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306B\u7D10\u3065\u304F\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306F\u3042\u308A\u307E\u305B\u3093\u3002");
|
|
1177
1704
|
return;
|
|
1178
1705
|
}
|
|
1179
1706
|
console.log(`
|
|
1180
|
-
|
|
1707
|
+
${dataTypes.length} \u4EF6\u306E\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F:
|
|
1181
1708
|
`);
|
|
1182
1709
|
dataTypes.forEach((dt) => {
|
|
1183
1710
|
console.log(` ${dt.name} (${dt.slug})`);
|
|
1184
1711
|
if (dt.description) {
|
|
1185
|
-
console.log(`
|
|
1712
|
+
console.log(` \u8AAC\u660E: ${dt.description}`);
|
|
1186
1713
|
}
|
|
1187
|
-
console.log(`
|
|
1714
|
+
console.log(` \u30D5\u30A3\u30FC\u30EB\u30C9\u6570: ${dt.fields?.length || 0}`);
|
|
1188
1715
|
console.log();
|
|
1189
1716
|
});
|
|
1190
1717
|
} catch (error) {
|
|
1191
|
-
console.error("\u2717
|
|
1718
|
+
console.error("\u2717 \u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u4E00\u89A7\u53D6\u5F97\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
1192
1719
|
console.error(error instanceof Error ? error.message : String(error));
|
|
1193
1720
|
process.exit(1);
|
|
1194
1721
|
}
|
|
@@ -1196,15 +1723,10 @@ Found ${dataTypes.length} data type(s):
|
|
|
1196
1723
|
|
|
1197
1724
|
// src/commands/add-collection-data-type.ts
|
|
1198
1725
|
async function addCollectionDataType(opts) {
|
|
1199
|
-
|
|
1200
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
1201
|
-
if (!apiUrl || !apiKey) {
|
|
1202
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
1203
|
-
process.exit(1);
|
|
1204
|
-
}
|
|
1726
|
+
ensureApiCredentials();
|
|
1205
1727
|
const collectionSlug = opts.collection;
|
|
1206
1728
|
if (!collectionSlug) {
|
|
1207
|
-
console.error("
|
|
1729
|
+
console.error("\u30A8\u30E9\u30FC: --collection \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
1208
1730
|
process.exit(1);
|
|
1209
1731
|
}
|
|
1210
1732
|
try {
|
|
@@ -1214,21 +1736,17 @@ async function addCollectionDataType(opts) {
|
|
|
1214
1736
|
} else if (opts.json || opts.file) {
|
|
1215
1737
|
input = readJsonInput(opts);
|
|
1216
1738
|
} else {
|
|
1217
|
-
console.error("
|
|
1739
|
+
console.error("\u30A8\u30E9\u30FC: --preset \u307E\u305F\u306F --json/--file \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
1218
1740
|
process.exit(1);
|
|
1219
1741
|
}
|
|
1220
|
-
console.log(
|
|
1221
|
-
const result =
|
|
1222
|
-
|
|
1223
|
-
apiKey,
|
|
1224
|
-
"POST",
|
|
1225
|
-
`/collections/${collectionSlug}/data-types`,
|
|
1226
|
-
input
|
|
1742
|
+
console.log(`\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3078\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u8FFD\u52A0\u3057\u3066\u3044\u307E\u3059: ${collectionSlug}...`);
|
|
1743
|
+
const result = assertSdkSuccess(
|
|
1744
|
+
await postManageCollectionsSlugDataTypes(collectionSlug, input)
|
|
1227
1745
|
);
|
|
1228
|
-
console.log("
|
|
1746
|
+
console.log("\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u8FFD\u52A0\u3057\u307E\u3057\u305F:");
|
|
1229
1747
|
console.log(JSON.stringify(result, null, 2));
|
|
1230
1748
|
} catch (error) {
|
|
1231
|
-
console.error("\u2717
|
|
1749
|
+
console.error("\u2717 \u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3078\u306E\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u8FFD\u52A0\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
1232
1750
|
console.error(error instanceof Error ? error.message : String(error));
|
|
1233
1751
|
process.exit(1);
|
|
1234
1752
|
}
|
|
@@ -1236,32 +1754,24 @@ async function addCollectionDataType(opts) {
|
|
|
1236
1754
|
|
|
1237
1755
|
// src/commands/remove-collection-data-type.ts
|
|
1238
1756
|
async function removeCollectionDataType(opts) {
|
|
1239
|
-
|
|
1240
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
1241
|
-
if (!apiUrl || !apiKey) {
|
|
1242
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
1243
|
-
process.exit(1);
|
|
1244
|
-
}
|
|
1757
|
+
ensureApiCredentials();
|
|
1245
1758
|
const collectionSlug = opts.collection;
|
|
1246
1759
|
if (!collectionSlug) {
|
|
1247
|
-
console.error("
|
|
1760
|
+
console.error("\u30A8\u30E9\u30FC: --collection \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
1248
1761
|
process.exit(1);
|
|
1249
1762
|
}
|
|
1250
1763
|
if (!opts.dataType) {
|
|
1251
|
-
console.error("
|
|
1764
|
+
console.error("\u30A8\u30E9\u30FC: --data-type \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
1252
1765
|
process.exit(1);
|
|
1253
1766
|
}
|
|
1254
1767
|
try {
|
|
1255
|
-
console.log(
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
apiKey,
|
|
1259
|
-
"DELETE",
|
|
1260
|
-
`/collections/${collectionSlug}/data-types/${opts.dataType}`
|
|
1768
|
+
console.log(`\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u304B\u3089\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u524A\u9664\u3057\u3066\u3044\u307E\u3059: ${collectionSlug} (${opts.dataType})...`);
|
|
1769
|
+
assertSdkSuccess(
|
|
1770
|
+
await deleteManageCollectionsSlugDataTypesDtSlug(collectionSlug, opts.dataType)
|
|
1261
1771
|
);
|
|
1262
|
-
console.log("
|
|
1772
|
+
console.log("\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u524A\u9664\u3057\u307E\u3057\u305F\u3002");
|
|
1263
1773
|
} catch (error) {
|
|
1264
|
-
console.error("\u2717
|
|
1774
|
+
console.error("\u2717 \u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u304B\u3089\u306E\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u524A\u9664\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
1265
1775
|
console.error(error instanceof Error ? error.message : String(error));
|
|
1266
1776
|
process.exit(1);
|
|
1267
1777
|
}
|
|
@@ -1269,34 +1779,24 @@ async function removeCollectionDataType(opts) {
|
|
|
1269
1779
|
|
|
1270
1780
|
// src/commands/list-collection-presets.ts
|
|
1271
1781
|
async function listCollectionPresets(opts) {
|
|
1272
|
-
|
|
1273
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
1274
|
-
if (!apiUrl || !apiKey) {
|
|
1275
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
1276
|
-
process.exit(1);
|
|
1277
|
-
}
|
|
1782
|
+
ensureApiCredentials();
|
|
1278
1783
|
try {
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
const result = await
|
|
1282
|
-
apiUrl,
|
|
1283
|
-
apiKey,
|
|
1284
|
-
"GET",
|
|
1285
|
-
`/collection-presets${query}`
|
|
1286
|
-
);
|
|
1784
|
+
console.log(opts.type ? `\u7A2E\u5225 "${opts.type}" \u5411\u3051\u30D7\u30EA\u30BB\u30C3\u30C8\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059...` : "\u30D7\u30EA\u30BB\u30C3\u30C8\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059...");
|
|
1785
|
+
const params = opts.type ? { type: opts.type } : void 0;
|
|
1786
|
+
const result = assertSdkSuccess(await getManageCollectionPresets(params));
|
|
1287
1787
|
if (opts.type && result.recommended) {
|
|
1288
1788
|
console.log(`
|
|
1289
|
-
|
|
1789
|
+
"${opts.type}" \u306B\u304A\u3059\u3059\u3081\u306E\u30D7\u30EA\u30BB\u30C3\u30C8:
|
|
1290
1790
|
`);
|
|
1291
1791
|
result.recommended.forEach((p) => {
|
|
1292
|
-
const defaultMark = p.default ? " [
|
|
1792
|
+
const defaultMark = p.default ? " [\u65E2\u5B9A]" : "";
|
|
1293
1793
|
console.log(` ${p.name} (${p.slug})${defaultMark}`);
|
|
1294
|
-
console.log(`
|
|
1295
|
-
console.log(`
|
|
1794
|
+
console.log(` \u53C2\u7167\u30BF\u30A4\u30D7: ${p.referenceType}, \u968E\u5C64\u69CB\u9020: ${p.hierarchical}`);
|
|
1795
|
+
console.log(` \u30D5\u30A3\u30FC\u30EB\u30C9: ${p.fields.map((f) => f.key).join(", ")}`);
|
|
1296
1796
|
console.log();
|
|
1297
1797
|
});
|
|
1298
1798
|
if (result.others && result.others.length > 0) {
|
|
1299
|
-
console.log("
|
|
1799
|
+
console.log("\u305D\u306E\u4ED6\u306E\u5229\u7528\u53EF\u80FD\u30D7\u30EA\u30BB\u30C3\u30C8:\n");
|
|
1300
1800
|
result.others.forEach((p) => {
|
|
1301
1801
|
console.log(` ${p.name} (${p.slug})`);
|
|
1302
1802
|
console.log();
|
|
@@ -1304,19 +1804,19 @@ Recommended presets for "${opts.type}":
|
|
|
1304
1804
|
}
|
|
1305
1805
|
} else if (result.all) {
|
|
1306
1806
|
console.log(`
|
|
1307
|
-
|
|
1807
|
+
${result.all.length} \u4EF6\u306E\u30D7\u30EA\u30BB\u30C3\u30C8\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F:
|
|
1308
1808
|
`);
|
|
1309
1809
|
result.all.forEach((p) => {
|
|
1310
1810
|
console.log(` ${p.name} (${p.slug})`);
|
|
1311
|
-
console.log(`
|
|
1312
|
-
console.log(`
|
|
1811
|
+
console.log(` \u53C2\u7167\u30BF\u30A4\u30D7: ${p.referenceType}, \u968E\u5C64\u69CB\u9020: ${p.hierarchical}`);
|
|
1812
|
+
console.log(` \u30D5\u30A3\u30FC\u30EB\u30C9: ${p.fields.map((f) => f.key).join(", ")}`);
|
|
1313
1813
|
console.log();
|
|
1314
1814
|
});
|
|
1315
1815
|
} else {
|
|
1316
|
-
console.log("
|
|
1816
|
+
console.log("\u30D7\u30EA\u30BB\u30C3\u30C8\u306F\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002");
|
|
1317
1817
|
}
|
|
1318
1818
|
} catch (error) {
|
|
1319
|
-
console.error("\u2717
|
|
1819
|
+
console.error("\u2717 \u30D7\u30EA\u30BB\u30C3\u30C8\u4E00\u89A7\u306E\u53D6\u5F97\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
1320
1820
|
console.error(error instanceof Error ? error.message : String(error));
|
|
1321
1821
|
process.exit(1);
|
|
1322
1822
|
}
|
|
@@ -1324,52 +1824,44 @@ Found ${result.all.length} preset(s):
|
|
|
1324
1824
|
|
|
1325
1825
|
// src/commands/link-collection-data-type.ts
|
|
1326
1826
|
async function linkCollectionDataType(opts) {
|
|
1327
|
-
|
|
1328
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
1329
|
-
if (!apiUrl || !apiKey) {
|
|
1330
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
1331
|
-
process.exit(1);
|
|
1332
|
-
}
|
|
1827
|
+
ensureApiCredentials();
|
|
1333
1828
|
const collectionSlug = opts.collection;
|
|
1334
1829
|
if (!collectionSlug) {
|
|
1335
|
-
console.error("
|
|
1830
|
+
console.error("\u30A8\u30E9\u30FC: --collection \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
1336
1831
|
process.exit(1);
|
|
1337
1832
|
}
|
|
1338
1833
|
if (!opts.dataType) {
|
|
1339
|
-
console.error("
|
|
1834
|
+
console.error("\u30A8\u30E9\u30FC: --data-type \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
1340
1835
|
process.exit(1);
|
|
1341
1836
|
}
|
|
1342
1837
|
if (!opts.fieldSlug) {
|
|
1343
|
-
console.error("
|
|
1838
|
+
console.error("\u30A8\u30E9\u30FC: --field-slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
1344
1839
|
process.exit(1);
|
|
1345
1840
|
}
|
|
1346
1841
|
if (!opts.label) {
|
|
1347
|
-
console.error("
|
|
1842
|
+
console.error("\u30A8\u30E9\u30FC: --label \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
1348
1843
|
process.exit(1);
|
|
1349
1844
|
}
|
|
1350
1845
|
const referenceType = opts.referenceType || "single";
|
|
1351
1846
|
if (referenceType !== "single" && referenceType !== "multiple") {
|
|
1352
|
-
console.error("
|
|
1847
|
+
console.error("\u30A8\u30E9\u30FC: --reference-type \u306F 'single' \u307E\u305F\u306F 'multiple' \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
1353
1848
|
process.exit(1);
|
|
1354
1849
|
}
|
|
1355
1850
|
try {
|
|
1356
|
-
console.log(
|
|
1357
|
-
const
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
label: opts.label,
|
|
1366
|
-
referenceType
|
|
1367
|
-
}
|
|
1851
|
+
console.log(`\u30B0\u30ED\u30FC\u30D0\u30EB\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u7D10\u3065\u3051\u3066\u3044\u307E\u3059: ${collectionSlug} <- ${opts.dataType}...`);
|
|
1852
|
+
const requestBody = {
|
|
1853
|
+
dataTypeSlug: opts.dataType,
|
|
1854
|
+
fieldSlug: opts.fieldSlug,
|
|
1855
|
+
label: opts.label,
|
|
1856
|
+
referenceType
|
|
1857
|
+
};
|
|
1858
|
+
const result = assertSdkSuccess(
|
|
1859
|
+
await postManageCollectionsSlugDataTypesLink(collectionSlug, requestBody)
|
|
1368
1860
|
);
|
|
1369
|
-
console.log("
|
|
1861
|
+
console.log("\u30B0\u30ED\u30FC\u30D0\u30EB\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u7D10\u3065\u3051\u307E\u3057\u305F:");
|
|
1370
1862
|
console.log(JSON.stringify(result, null, 2));
|
|
1371
1863
|
} catch (error) {
|
|
1372
|
-
console.error("\u2717
|
|
1864
|
+
console.error("\u2717 \u30B0\u30ED\u30FC\u30D0\u30EB\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u7D10\u3065\u3051\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
1373
1865
|
console.error(error instanceof Error ? error.message : String(error));
|
|
1374
1866
|
process.exit(1);
|
|
1375
1867
|
}
|
|
@@ -2044,7 +2536,7 @@ async function writeScaffoldFile(filePath, content, result, options) {
|
|
|
2044
2536
|
const resolvedBaseDir = resolve(options.baseDir);
|
|
2045
2537
|
if (!resolvedPath.startsWith(resolvedBaseDir + "/") && resolvedPath !== resolvedBaseDir) {
|
|
2046
2538
|
throw new Error(
|
|
2047
|
-
|
|
2539
|
+
`\u4E0D\u6B63\u306A\u30D1\u30B9\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F: "${filePath}" \u306F\u30D9\u30FC\u30B9\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA "${options.baseDir}" \u306E\u5916\u5074\u3067\u3059`
|
|
2048
2540
|
);
|
|
2049
2541
|
}
|
|
2050
2542
|
if (!options.force && existsSync2(filePath)) {
|
|
@@ -2074,7 +2566,7 @@ function parseTemplate(template) {
|
|
|
2074
2566
|
if (template === "legacy") {
|
|
2075
2567
|
return "legacy";
|
|
2076
2568
|
}
|
|
2077
|
-
throw new Error(
|
|
2569
|
+
throw new Error(`\u7121\u52B9\u306A\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3067\u3059: "${template}"\u3002 "legacy" \u307E\u305F\u306F "layered" \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002`);
|
|
2078
2570
|
}
|
|
2079
2571
|
function inferFeaturesDir(appDir) {
|
|
2080
2572
|
const normalized = appDir.replace(/\\/g, "/");
|
|
@@ -2095,7 +2587,7 @@ function inferFeatureImportBase(featuresDir) {
|
|
|
2095
2587
|
return `@/${normalized.slice("src/".length)}`;
|
|
2096
2588
|
}
|
|
2097
2589
|
throw new Error(
|
|
2098
|
-
`
|
|
2590
|
+
`layered \u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3067\u306F --features-dir \u3092 src/ \u914D\u4E0B\u306B\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u6307\u5B9A\u5024: "${featuresDir}"\uFF09`
|
|
2099
2591
|
);
|
|
2100
2592
|
}
|
|
2101
2593
|
async function scaffold(options) {
|
|
@@ -2103,12 +2595,12 @@ async function scaffold(options) {
|
|
|
2103
2595
|
const template = parseTemplate(options.template);
|
|
2104
2596
|
const featuresDir = template === "layered" ? options.featuresDir ?? inferFeaturesDir(appDir) : null;
|
|
2105
2597
|
const featureImportBase = template === "layered" ? inferFeatureImportBase(featuresDir ?? inferFeaturesDir(appDir)) : null;
|
|
2106
|
-
console.log(
|
|
2598
|
+
console.log(`\u30B9\u30AD\u30FC\u30DE\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059: ${apiUrl} ...`);
|
|
2107
2599
|
const schema = await fetchSchema(apiUrl, apiKey);
|
|
2108
2600
|
const forms = schema.forms ?? [];
|
|
2109
2601
|
const filter = only ? parseOnly(only) : null;
|
|
2110
2602
|
if (only && !filter) {
|
|
2111
|
-
console.error(
|
|
2603
|
+
console.error(`--only \u306E\u5F62\u5F0F\u304C\u4E0D\u6B63\u3067\u3059: "${only}"\u3002 category:slug\uFF08\u4F8B: collections:blog\uFF09\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044`);
|
|
2112
2604
|
process.exit(1);
|
|
2113
2605
|
}
|
|
2114
2606
|
const result = { created: [], skipped: [] };
|
|
@@ -2289,64 +2781,54 @@ async function scaffold(options) {
|
|
|
2289
2781
|
}
|
|
2290
2782
|
console.log("");
|
|
2291
2783
|
if (result.created.length > 0) {
|
|
2292
|
-
console.log(`${prefix}
|
|
2784
|
+
console.log(`${prefix}${result.created.length} \u4EF6\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u3057\u307E\u3057\u305F:`);
|
|
2293
2785
|
for (const f of result.created) {
|
|
2294
2786
|
console.log(` ${prefix}+ ${f}`);
|
|
2295
2787
|
}
|
|
2296
2788
|
}
|
|
2297
2789
|
if (result.skipped.length > 0) {
|
|
2298
2790
|
console.log(`
|
|
2299
|
-
|
|
2791
|
+
${result.skipped.length} \u4EF6\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u30B9\u30AD\u30C3\u30D7\u3057\u307E\u3057\u305F\uFF08\u65E2\u306B\u5B58\u5728\uFF09:`);
|
|
2300
2792
|
for (const f of result.skipped) {
|
|
2301
2793
|
console.log(` - ${f}`);
|
|
2302
2794
|
}
|
|
2303
2795
|
}
|
|
2304
2796
|
if (result.created.length === 0 && result.skipped.length === 0) {
|
|
2305
|
-
console.log("
|
|
2797
|
+
console.log("\u751F\u6210\u5BFE\u8C61\u306E\u30D5\u30A1\u30A4\u30EB\u306F\u3042\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002");
|
|
2306
2798
|
}
|
|
2307
2799
|
console.log("");
|
|
2308
|
-
console.log("
|
|
2800
|
+
console.log("\u6B21\u306E\u30B9\u30C6\u30C3\u30D7:");
|
|
2309
2801
|
if (template === "layered") {
|
|
2310
|
-
console.log(" 1.
|
|
2311
|
-
console.log(` 2.
|
|
2802
|
+
console.log(" 1. \u751F\u6210\u3055\u308C\u305F features \u914D\u4E0B\u306E view \u30D5\u30A1\u30A4\u30EB\u3092\u8ABF\u6574\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2803
|
+
console.log(` 2. \u30C7\u30FC\u30BF\u53D6\u5F97\u306F resolver \u30D5\u30A1\u30A4\u30EB\uFF08${featuresDir}\uFF09\u306B\u96C6\u7D04\u3057\u3066\u304F\u3060\u3055\u3044`);
|
|
2312
2804
|
} else {
|
|
2313
|
-
console.log(" 1.
|
|
2314
|
-
console.log(" 2.
|
|
2805
|
+
console.log(" 1. \u751F\u6210\u30DA\u30FC\u30B8\u306E\u30C7\u30B6\u30A4\u30F3\uFF08HTML/CSS\uFF09\u3092\u8ABF\u6574\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2806
|
+
console.log(" 2. \u30EC\u30A4\u30A2\u30A6\u30C8\u306B\u30CA\u30D3\u30B2\u30FC\u30B7\u30E7\u30F3\u30EA\u30F3\u30AF\u3092\u8FFD\u52A0\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2315
2807
|
}
|
|
2316
|
-
console.log(" 3.
|
|
2808
|
+
console.log(" 3. `npm run dev` \u3067\u30B5\u30A4\u30C8\u3092\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2317
2809
|
}
|
|
2318
2810
|
|
|
2319
2811
|
// src/commands/create-data-entry.ts
|
|
2320
2812
|
async function createDataEntry(options) {
|
|
2321
|
-
|
|
2322
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
2323
|
-
if (!apiUrl || !apiKey) {
|
|
2324
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
2325
|
-
process.exit(1);
|
|
2326
|
-
}
|
|
2813
|
+
ensureApiCredentials();
|
|
2327
2814
|
if (!options.typeSlug) {
|
|
2328
|
-
console.error("
|
|
2815
|
+
console.error("\u30A8\u30E9\u30FC: --type-slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2329
2816
|
process.exit(1);
|
|
2330
2817
|
}
|
|
2331
2818
|
const input = readJsonInput(options);
|
|
2332
2819
|
if (!input.dataJson) {
|
|
2333
|
-
console.error("
|
|
2820
|
+
console.error("\u30A8\u30E9\u30FC: JSON \u306B\u306F dataJson \u304C\u5FC5\u8981\u3067\u3059");
|
|
2334
2821
|
process.exit(1);
|
|
2335
2822
|
}
|
|
2336
|
-
console.log(
|
|
2337
|
-
const result = await
|
|
2338
|
-
console.log("
|
|
2823
|
+
console.log(`\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059: ${options.typeSlug}...`);
|
|
2824
|
+
const result = assertSdkSuccess(await postManageDataTypeSlug(options.typeSlug, input));
|
|
2825
|
+
console.log("\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3092\u4F5C\u6210\u3057\u307E\u3057\u305F:");
|
|
2339
2826
|
console.log(JSON.stringify(result, null, 2));
|
|
2340
2827
|
}
|
|
2341
2828
|
|
|
2342
2829
|
// src/commands/create-content.ts
|
|
2343
2830
|
async function createContent(options) {
|
|
2344
|
-
|
|
2345
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
2346
|
-
if (!apiUrl || !apiKey) {
|
|
2347
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
2348
|
-
process.exit(1);
|
|
2349
|
-
}
|
|
2831
|
+
ensureApiCredentials();
|
|
2350
2832
|
let input;
|
|
2351
2833
|
if (options.json || options.file) {
|
|
2352
2834
|
input = readJsonInput(options);
|
|
@@ -2358,233 +2840,193 @@ async function createContent(options) {
|
|
|
2358
2840
|
mdx: options.mdx
|
|
2359
2841
|
};
|
|
2360
2842
|
} else {
|
|
2361
|
-
console.error("
|
|
2843
|
+
console.error("\u30A8\u30E9\u30FC: --json/--file \u304B --title \u3068 --slug \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2362
2844
|
process.exit(1);
|
|
2363
2845
|
}
|
|
2364
|
-
if (!input.
|
|
2365
|
-
console.error("
|
|
2846
|
+
if (!input.title || !input.slug) {
|
|
2847
|
+
console.error("\u30A8\u30E9\u30FC: title \u3068 slug \u306F\u5FC5\u9808\u3067\u3059");
|
|
2366
2848
|
process.exit(1);
|
|
2367
2849
|
}
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2850
|
+
const collectionSlug = options.collection ?? input.collectionSlug;
|
|
2851
|
+
let collectionId = options.collection ? void 0 : input.collectionId;
|
|
2852
|
+
if (!collectionId && !collectionSlug) {
|
|
2853
|
+
console.error("\u30A8\u30E9\u30FC: collectionId / collectionSlug / --collection \u306E\u3044\u305A\u308C\u304B\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2854
|
+
process.exit(1);
|
|
2371
2855
|
}
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
)
|
|
2380
|
-
|
|
2856
|
+
if (!collectionId && collectionSlug) {
|
|
2857
|
+
console.log(`\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u30B9\u30E9\u30C3\u30B0\u3092\u89E3\u6C7A\u3057\u3066\u3044\u307E\u3059: ${collectionSlug}...`);
|
|
2858
|
+
const collection = assertSdkSuccess(
|
|
2859
|
+
await getManageCollectionsSlug(encodeURIComponent(collectionSlug))
|
|
2860
|
+
);
|
|
2861
|
+
collectionId = collection.id;
|
|
2862
|
+
}
|
|
2863
|
+
if (!collectionId) {
|
|
2864
|
+
console.error("\u30A8\u30E9\u30FC: collectionId \u3092\u89E3\u6C7A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F");
|
|
2865
|
+
process.exit(1);
|
|
2866
|
+
}
|
|
2867
|
+
const requestBody = {
|
|
2868
|
+
title: input.title,
|
|
2869
|
+
slug: input.slug,
|
|
2870
|
+
mdx: input.mdx ?? "",
|
|
2871
|
+
collectionId,
|
|
2872
|
+
...input.description !== void 0 ? { description: input.description } : {}
|
|
2873
|
+
};
|
|
2874
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u4F5C\u6210\u3057\u3066\u3044\u307E\u3059: ${collectionSlug || collectionId}...`);
|
|
2875
|
+
const result = assertSdkSuccess(await postManageContents(requestBody));
|
|
2876
|
+
console.log("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u4F5C\u6210\u3057\u307E\u3057\u305F:");
|
|
2381
2877
|
console.log(JSON.stringify(result, null, 2));
|
|
2382
2878
|
console.log(`
|
|
2383
|
-
|
|
2384
|
-
console.log(
|
|
2879
|
+
\u30B3\u30F3\u30C6\u30F3\u30C4 ID: ${result.id}`);
|
|
2880
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4 slug: ${result.slug}`);
|
|
2385
2881
|
}
|
|
2386
2882
|
|
|
2387
2883
|
// src/commands/request-review-content.ts
|
|
2388
2884
|
async function requestReviewContent(options) {
|
|
2389
|
-
|
|
2390
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
2391
|
-
if (!apiUrl || !apiKey) {
|
|
2392
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
2393
|
-
process.exit(1);
|
|
2394
|
-
}
|
|
2885
|
+
ensureApiCredentials();
|
|
2395
2886
|
if (!options.id) {
|
|
2396
|
-
console.error("
|
|
2887
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2397
2888
|
process.exit(1);
|
|
2398
2889
|
}
|
|
2399
|
-
console.log(
|
|
2400
|
-
const result = await
|
|
2401
|
-
|
|
2402
|
-
apiKey,
|
|
2403
|
-
"POST",
|
|
2404
|
-
`/contents/${options.id}/request-review`
|
|
2405
|
-
);
|
|
2406
|
-
console.log("Review requested successfully:");
|
|
2890
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u30EC\u30D3\u30E5\u30FC\u4F9D\u983C\u306B\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
2891
|
+
const result = assertSdkSuccess(await postManageContentsIdRequestReview(options.id));
|
|
2892
|
+
console.log("\u30EC\u30D3\u30E5\u30FC\u4F9D\u983C\u3092\u9001\u4FE1\u3057\u307E\u3057\u305F:");
|
|
2407
2893
|
console.log(JSON.stringify(result, null, 2));
|
|
2408
2894
|
}
|
|
2409
2895
|
|
|
2410
2896
|
// src/commands/publish-content.ts
|
|
2411
2897
|
async function publishContent(options) {
|
|
2412
|
-
|
|
2413
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
2414
|
-
if (!apiUrl || !apiKey) {
|
|
2415
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
2416
|
-
process.exit(1);
|
|
2417
|
-
}
|
|
2898
|
+
ensureApiCredentials();
|
|
2418
2899
|
if (!options.id) {
|
|
2419
|
-
console.error("
|
|
2900
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2420
2901
|
process.exit(1);
|
|
2421
2902
|
}
|
|
2422
|
-
console.log(
|
|
2423
|
-
const result = await
|
|
2424
|
-
|
|
2425
|
-
apiKey,
|
|
2426
|
-
"POST",
|
|
2427
|
-
`/contents/${options.id}/publish`
|
|
2428
|
-
);
|
|
2429
|
-
console.log("Content published successfully:");
|
|
2903
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u516C\u958B\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
2904
|
+
const result = assertSdkSuccess(await postManageContentsIdPublish(options.id));
|
|
2905
|
+
console.log("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u516C\u958B\u3057\u307E\u3057\u305F:");
|
|
2430
2906
|
console.log(JSON.stringify(result, null, 2));
|
|
2431
2907
|
console.log(`
|
|
2432
|
-
|
|
2908
|
+
\u516C\u958BURL: ${result.url}`);
|
|
2433
2909
|
}
|
|
2434
2910
|
|
|
2435
2911
|
// src/commands/get-content-references.ts
|
|
2436
2912
|
async function getContentReferences(options) {
|
|
2437
|
-
|
|
2438
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
2439
|
-
if (!apiUrl || !apiKey) {
|
|
2440
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
2441
|
-
process.exit(1);
|
|
2442
|
-
}
|
|
2913
|
+
ensureApiCredentials();
|
|
2443
2914
|
if (!options.id) {
|
|
2444
|
-
console.error("
|
|
2915
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2445
2916
|
process.exit(1);
|
|
2446
2917
|
}
|
|
2447
|
-
console.log(
|
|
2448
|
-
const result = await
|
|
2449
|
-
|
|
2450
|
-
apiKey,
|
|
2451
|
-
"GET",
|
|
2452
|
-
`/contents/${options.id}/references`
|
|
2453
|
-
);
|
|
2454
|
-
console.log("Content references:");
|
|
2918
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u53C2\u7167\u60C5\u5831\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
2919
|
+
const result = assertSdkSuccess(await getManageContentsIdReferences(options.id));
|
|
2920
|
+
console.log("\u30B3\u30F3\u30C6\u30F3\u30C4\u53C2\u7167\u60C5\u5831:");
|
|
2455
2921
|
console.log(JSON.stringify(result, null, 2));
|
|
2456
2922
|
}
|
|
2457
2923
|
|
|
2458
2924
|
// src/commands/set-content-references.ts
|
|
2459
2925
|
async function setContentReferences(options) {
|
|
2460
|
-
|
|
2461
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
2462
|
-
if (!apiUrl || !apiKey) {
|
|
2463
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
2464
|
-
process.exit(1);
|
|
2465
|
-
}
|
|
2926
|
+
ensureApiCredentials();
|
|
2466
2927
|
if (!options.id) {
|
|
2467
|
-
console.error("
|
|
2928
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2468
2929
|
process.exit(1);
|
|
2469
2930
|
}
|
|
2470
2931
|
const input = readJsonInput(options);
|
|
2471
2932
|
if (!input.references || !Array.isArray(input.references)) {
|
|
2472
|
-
console.error("
|
|
2933
|
+
console.error("\u30A8\u30E9\u30FC: JSON \u306B\u306F references \u914D\u5217\u304C\u5FC5\u8981\u3067\u3059");
|
|
2473
2934
|
process.exit(1);
|
|
2474
2935
|
}
|
|
2475
|
-
console.log(
|
|
2476
|
-
const result =
|
|
2477
|
-
|
|
2478
|
-
apiKey,
|
|
2479
|
-
"PUT",
|
|
2480
|
-
`/contents/${options.id}/references`,
|
|
2481
|
-
input
|
|
2936
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u53C2\u7167\u60C5\u5831\u3092\u66F4\u65B0\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
2937
|
+
const result = assertSdkSuccess(
|
|
2938
|
+
await putManageContentsIdReferences(options.id, input)
|
|
2482
2939
|
);
|
|
2483
|
-
console.log("
|
|
2940
|
+
console.log("\u30B3\u30F3\u30C6\u30F3\u30C4\u53C2\u7167\u60C5\u5831\u3092\u66F4\u65B0\u3057\u307E\u3057\u305F:");
|
|
2484
2941
|
console.log(JSON.stringify(result, null, 2));
|
|
2485
2942
|
}
|
|
2486
2943
|
|
|
2944
|
+
// src/generated/sdk/models/getManageDataTypeSlugSortBy.ts
|
|
2945
|
+
var GetManageDataTypeSlugSortBy = {
|
|
2946
|
+
sortOrder: "sortOrder",
|
|
2947
|
+
createdAt: "createdAt",
|
|
2948
|
+
updatedAt: "updatedAt"
|
|
2949
|
+
};
|
|
2950
|
+
|
|
2487
2951
|
// src/commands/list-data-entries.ts
|
|
2488
2952
|
async function listDataEntries(options) {
|
|
2489
|
-
|
|
2490
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
2491
|
-
if (!apiUrl || !apiKey) {
|
|
2492
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
2493
|
-
process.exit(1);
|
|
2494
|
-
}
|
|
2953
|
+
ensureApiCredentials();
|
|
2495
2954
|
if (!options.typeSlug) {
|
|
2496
|
-
console.error("
|
|
2955
|
+
console.error("\u30A8\u30E9\u30FC: --type-slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2497
2956
|
process.exit(1);
|
|
2498
2957
|
}
|
|
2499
|
-
|
|
2500
|
-
if (options.sortBy
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
const
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2958
|
+
let sortBy;
|
|
2959
|
+
if (options.sortBy !== void 0) {
|
|
2960
|
+
const validSortByValues = Object.values(GetManageDataTypeSlugSortBy);
|
|
2961
|
+
if (!validSortByValues.includes(options.sortBy)) {
|
|
2962
|
+
console.error(`\u30A8\u30E9\u30FC: --sort-by \u306F\u6B21\u304B\u3089\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044: ${validSortByValues.join(", ")}`);
|
|
2963
|
+
process.exit(1);
|
|
2964
|
+
}
|
|
2965
|
+
sortBy = options.sortBy;
|
|
2966
|
+
}
|
|
2967
|
+
const params = {
|
|
2968
|
+
...sortBy ? { sortBy } : {},
|
|
2969
|
+
...options.sortOrder ? { sortOrder: options.sortOrder } : {},
|
|
2970
|
+
...options.limit !== void 0 ? { limit: options.limit } : {},
|
|
2971
|
+
...options.offset !== void 0 ? { offset: options.offset } : {},
|
|
2972
|
+
...options.status ? { status: options.status } : {}
|
|
2973
|
+
};
|
|
2974
|
+
console.log(`\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059: ${options.typeSlug}...`);
|
|
2975
|
+
const result = assertSdkSuccess(
|
|
2976
|
+
await getManageDataTypeSlug(options.typeSlug, params)
|
|
2513
2977
|
);
|
|
2514
|
-
console.log(
|
|
2978
|
+
console.log(`${result.entries.length} \u4EF6\u306E\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F:`);
|
|
2515
2979
|
console.log(JSON.stringify(result, null, 2));
|
|
2516
2980
|
}
|
|
2517
2981
|
|
|
2518
2982
|
// src/commands/get-data-entry.ts
|
|
2519
2983
|
async function getDataEntry(options) {
|
|
2520
|
-
|
|
2521
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
2522
|
-
if (!apiUrl || !apiKey) {
|
|
2523
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
2524
|
-
process.exit(1);
|
|
2525
|
-
}
|
|
2984
|
+
ensureApiCredentials();
|
|
2526
2985
|
if (!options.typeSlug) {
|
|
2527
|
-
console.error("
|
|
2986
|
+
console.error("\u30A8\u30E9\u30FC: --type-slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2528
2987
|
process.exit(1);
|
|
2529
2988
|
}
|
|
2530
2989
|
if (!options.id) {
|
|
2531
|
-
console.error("
|
|
2990
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2532
2991
|
process.exit(1);
|
|
2533
2992
|
}
|
|
2534
|
-
console.log(
|
|
2535
|
-
const result =
|
|
2536
|
-
|
|
2537
|
-
apiKey,
|
|
2538
|
-
"GET",
|
|
2539
|
-
`/data/${options.typeSlug}/${options.id}`
|
|
2993
|
+
console.log(`\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
2994
|
+
const result = assertSdkSuccess(
|
|
2995
|
+
await getManageDataTypeSlugId(options.typeSlug, options.id)
|
|
2540
2996
|
);
|
|
2541
|
-
console.log("
|
|
2997
|
+
console.log("\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC:");
|
|
2542
2998
|
console.log(JSON.stringify(result, null, 2));
|
|
2543
2999
|
}
|
|
2544
3000
|
|
|
2545
3001
|
// src/commands/update-data-entry.ts
|
|
2546
3002
|
async function updateDataEntry(options) {
|
|
2547
|
-
|
|
2548
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
2549
|
-
if (!apiUrl || !apiKey) {
|
|
2550
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
2551
|
-
process.exit(1);
|
|
2552
|
-
}
|
|
3003
|
+
ensureApiCredentials();
|
|
2553
3004
|
if (!options.typeSlug) {
|
|
2554
|
-
console.error("
|
|
3005
|
+
console.error("\u30A8\u30E9\u30FC: --type-slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2555
3006
|
process.exit(1);
|
|
2556
3007
|
}
|
|
2557
3008
|
if (!options.id) {
|
|
2558
|
-
console.error("
|
|
3009
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2559
3010
|
process.exit(1);
|
|
2560
3011
|
}
|
|
2561
3012
|
const input = readJsonInput(options);
|
|
2562
|
-
console.log(
|
|
2563
|
-
const result =
|
|
2564
|
-
|
|
2565
|
-
apiKey,
|
|
2566
|
-
"PATCH",
|
|
2567
|
-
`/data/${options.typeSlug}/${options.id}`,
|
|
2568
|
-
input
|
|
3013
|
+
console.log(`\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3092\u66F4\u65B0\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
3014
|
+
const result = assertSdkSuccess(
|
|
3015
|
+
await patchManageDataTypeSlugId(options.typeSlug, options.id, input)
|
|
2569
3016
|
);
|
|
2570
|
-
console.log("
|
|
3017
|
+
console.log("\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3092\u66F4\u65B0\u3057\u307E\u3057\u305F:");
|
|
2571
3018
|
console.log(JSON.stringify(result, null, 2));
|
|
2572
3019
|
}
|
|
2573
3020
|
|
|
2574
3021
|
// src/commands/delete-data-entry.ts
|
|
2575
3022
|
async function deleteDataEntry(options) {
|
|
2576
|
-
|
|
2577
|
-
const apiKey = process.env.CMX_API_KEY;
|
|
2578
|
-
if (!apiUrl || !apiKey) {
|
|
2579
|
-
console.error("Error: CMX_API_URL and CMX_API_KEY environment variables are required");
|
|
2580
|
-
process.exit(1);
|
|
2581
|
-
}
|
|
3023
|
+
ensureApiCredentials();
|
|
2582
3024
|
if (!options.typeSlug) {
|
|
2583
|
-
console.error("
|
|
3025
|
+
console.error("\u30A8\u30E9\u30FC: --type-slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2584
3026
|
process.exit(1);
|
|
2585
3027
|
}
|
|
2586
3028
|
if (!options.id) {
|
|
2587
|
-
console.error("
|
|
3029
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2588
3030
|
process.exit(1);
|
|
2589
3031
|
}
|
|
2590
3032
|
if (!options.force) {
|
|
@@ -2595,24 +3037,21 @@ async function deleteDataEntry(options) {
|
|
|
2595
3037
|
});
|
|
2596
3038
|
const answer = await new Promise((resolve5) => {
|
|
2597
3039
|
rl.question(
|
|
2598
|
-
|
|
3040
|
+
`\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC ${options.id} \u3092\u524A\u9664\u3057\u307E\u3059\u304B\uFF1F (yes/no): `,
|
|
2599
3041
|
resolve5
|
|
2600
3042
|
);
|
|
2601
3043
|
});
|
|
2602
3044
|
rl.close();
|
|
2603
3045
|
if (answer.toLowerCase() !== "yes") {
|
|
2604
|
-
console.log("
|
|
3046
|
+
console.log("\u524A\u9664\u3092\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u307E\u3057\u305F\u3002");
|
|
2605
3047
|
process.exit(0);
|
|
2606
3048
|
}
|
|
2607
3049
|
}
|
|
2608
|
-
console.log(
|
|
2609
|
-
const result =
|
|
2610
|
-
|
|
2611
|
-
apiKey,
|
|
2612
|
-
"DELETE",
|
|
2613
|
-
`/data/${options.typeSlug}/${options.id}`
|
|
3050
|
+
console.log(`\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3092\u524A\u9664\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
3051
|
+
const result = assertSdkSuccess(
|
|
3052
|
+
await deleteManageDataTypeSlugId(options.typeSlug, options.id)
|
|
2614
3053
|
);
|
|
2615
|
-
console.log("
|
|
3054
|
+
console.log("\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3092\u524A\u9664\u3057\u307E\u3057\u305F:");
|
|
2616
3055
|
console.log(JSON.stringify(result, null, 2));
|
|
2617
3056
|
}
|
|
2618
3057
|
|
|
@@ -2648,7 +3087,7 @@ function ensureExport(indexPath, exportName) {
|
|
|
2648
3087
|
async function scaffoldComponent(options) {
|
|
2649
3088
|
const pascalName = toPascalCase(options.name);
|
|
2650
3089
|
if (!/^[A-Z][a-zA-Z0-9]*$/.test(pascalName)) {
|
|
2651
|
-
console.error("
|
|
3090
|
+
console.error("\u30A8\u30E9\u30FC: name \u306F PascalCase\uFF08\u4F8B: FeatureCard\uFF09\u306B\u306A\u308B\u5024\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2652
3091
|
process.exit(1);
|
|
2653
3092
|
}
|
|
2654
3093
|
const kebabName = toKebabCase(pascalName);
|
|
@@ -2660,7 +3099,7 @@ async function scaffoldComponent(options) {
|
|
|
2660
3099
|
const definitionPath = join4(definitionsDir, `${kebabName}.json`);
|
|
2661
3100
|
const indexPath = join4(componentsDir, "index.ts");
|
|
2662
3101
|
if (!options.force && (existsSync3(componentPath) || existsSync3(definitionPath))) {
|
|
2663
|
-
console.error("
|
|
3102
|
+
console.error("\u30A8\u30E9\u30FC: \u5BFE\u8C61\u30D5\u30A1\u30A4\u30EB\u304C\u65E2\u306B\u5B58\u5728\u3057\u307E\u3059\u3002\u4E0A\u66F8\u304D\u3059\u308B\u5834\u5408\u306F --force \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2664
3103
|
process.exit(1);
|
|
2665
3104
|
}
|
|
2666
3105
|
const definition = {
|
|
@@ -2698,7 +3137,6 @@ async function scaffoldComponent(options) {
|
|
|
2698
3137
|
}
|
|
2699
3138
|
|
|
2700
3139
|
export function ${pascalName}({ contentId, title }: ${pascalName}Props) {
|
|
2701
|
-
// TODO: Resolve data by contentId and map it to presentational props.
|
|
2702
3140
|
return (
|
|
2703
3141
|
<section className="rounded-lg border p-4">
|
|
2704
3142
|
{title ? <h3 className="mb-2 text-lg font-semibold">{title}</h3> : null}
|
|
@@ -2724,10 +3162,10 @@ export function ${pascalName}({ title, children }: ${pascalName}Props) {
|
|
|
2724
3162
|
`, "utf-8");
|
|
2725
3163
|
writeFileSync(componentPath, componentCode, "utf-8");
|
|
2726
3164
|
ensureExport(indexPath, pascalName);
|
|
2727
|
-
console.log(
|
|
2728
|
-
console.log(
|
|
2729
|
-
console.log(
|
|
2730
|
-
console.log("
|
|
3165
|
+
console.log(`\u4F5C\u6210: ${definitionPath}`);
|
|
3166
|
+
console.log(`\u4F5C\u6210: ${componentPath}`);
|
|
3167
|
+
console.log(`\u66F4\u65B0: ${indexPath}`);
|
|
3168
|
+
console.log("\u6B21\u306E\u624B\u9806: `cmx-sdk sync-components` \u3092\u5B9F\u884C\u3057\u3066\u5B9A\u7FA9\u3092\u53CD\u6620\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
2731
3169
|
}
|
|
2732
3170
|
|
|
2733
3171
|
// src/commands/codegen-check.ts
|
|
@@ -2794,48 +3232,48 @@ async function runCodegenCheck(options = {}) {
|
|
|
2794
3232
|
const warnings = [];
|
|
2795
3233
|
const checks = [];
|
|
2796
3234
|
if (!existsSync4(outputDirAbs)) {
|
|
2797
|
-
errors.push(
|
|
3235
|
+
errors.push(`\u751F\u6210\u30B3\u30FC\u30C9\u306E\u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${relative(projectRoot, outputDirAbs)}`);
|
|
2798
3236
|
} else {
|
|
2799
|
-
checks.push(
|
|
3237
|
+
checks.push(`\u751F\u6210\u30B3\u30FC\u30C9\u306E\u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u78BA\u8A8D: ${relative(projectRoot, outputDirAbs)}`);
|
|
2800
3238
|
const indexPath = join5(outputDirAbs, "index.ts");
|
|
2801
3239
|
if (!existsSync4(indexPath)) {
|
|
2802
|
-
errors.push(
|
|
3240
|
+
errors.push(`\u751F\u6210\u30B3\u30FC\u30C9\u306E index \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${relative(projectRoot, indexPath)}`);
|
|
2803
3241
|
} else {
|
|
2804
|
-
checks.push(
|
|
3242
|
+
checks.push(`\u751F\u6210\u30B3\u30FC\u30C9\u306E index \u3092\u78BA\u8A8D: ${relative(projectRoot, indexPath)}`);
|
|
2805
3243
|
}
|
|
2806
3244
|
}
|
|
2807
3245
|
if (!existsSync4(tsconfigAbs)) {
|
|
2808
|
-
errors.push(`tsconfig
|
|
3246
|
+
errors.push(`tsconfig \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${relative(projectRoot, tsconfigAbs)}`);
|
|
2809
3247
|
} else {
|
|
2810
3248
|
try {
|
|
2811
3249
|
const raw = readFileSync4(tsconfigAbs, "utf-8");
|
|
2812
3250
|
const parsed = JSON.parse(stripTrailingCommas(stripJsonComments(raw)));
|
|
2813
3251
|
const aliasValues = parsed.compilerOptions?.paths?.["@cmx/*"] ?? [];
|
|
2814
3252
|
if (aliasValues.length === 0) {
|
|
2815
|
-
errors.push("tsconfig compilerOptions.paths['@cmx/*']
|
|
3253
|
+
errors.push("tsconfig \u306E compilerOptions.paths['@cmx/*'] \u304C\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093");
|
|
2816
3254
|
} else {
|
|
2817
3255
|
const normalizedAliasValues = aliasValues.map(normalizePathValue);
|
|
2818
3256
|
if (!normalizedAliasValues.includes("cmx/*")) {
|
|
2819
3257
|
errors.push(
|
|
2820
|
-
"tsconfig compilerOptions.paths['@cmx/*']
|
|
3258
|
+
"tsconfig \u306E compilerOptions.paths['@cmx/*'] \u306B\u306F './cmx/*'\uFF08\u307E\u305F\u306F\u540C\u7B49\u5024\uFF09\u304C\u5FC5\u8981\u3067\u3059"
|
|
2821
3259
|
);
|
|
2822
3260
|
} else {
|
|
2823
|
-
checks.push("tsconfig '@cmx/*'
|
|
3261
|
+
checks.push("tsconfig \u306E '@cmx/*' \u30A8\u30A4\u30EA\u30A2\u30B9\u8A2D\u5B9A\u3092\u78BA\u8A8D");
|
|
2824
3262
|
}
|
|
2825
3263
|
}
|
|
2826
3264
|
const includeValues = parsed.include ?? [];
|
|
2827
3265
|
const normalizedIncludeValues = includeValues.map(normalizePathValue);
|
|
2828
3266
|
if (!normalizedIncludeValues.includes("cmx/**/*.ts")) {
|
|
2829
|
-
warnings.push("tsconfig include
|
|
3267
|
+
warnings.push("tsconfig \u306E include \u306B 'cmx/**/*.ts' \u304C\u542B\u307E\u308C\u3066\u3044\u307E\u305B\u3093");
|
|
2830
3268
|
} else {
|
|
2831
|
-
checks.push("tsconfig include
|
|
3269
|
+
checks.push("tsconfig \u306E include \u306B 'cmx/**/*.ts' \u3092\u78BA\u8A8D");
|
|
2832
3270
|
}
|
|
2833
3271
|
} catch (error) {
|
|
2834
|
-
errors.push(`
|
|
3272
|
+
errors.push(`tsconfig \u306E\u89E3\u6790\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${error instanceof Error ? error.message : String(error)}`);
|
|
2835
3273
|
}
|
|
2836
3274
|
}
|
|
2837
3275
|
if (!existsSync4(srcDirAbs)) {
|
|
2838
|
-
warnings.push(
|
|
3276
|
+
warnings.push(`\u30BD\u30FC\u30B9\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${relative(projectRoot, srcDirAbs)}`);
|
|
2839
3277
|
} else {
|
|
2840
3278
|
const sourceFiles = collectFiles(srcDirAbs, /* @__PURE__ */ new Set([".ts", ".tsx"]));
|
|
2841
3279
|
const legacyImportHits = [];
|
|
@@ -2857,7 +3295,7 @@ async function runCodegenCheck(options = {}) {
|
|
|
2857
3295
|
const isLast = candidate === candidates.at(-1);
|
|
2858
3296
|
if (isLast) {
|
|
2859
3297
|
errors.push(
|
|
2860
|
-
|
|
3298
|
+
`${relative(projectRoot, sourceFile)} \u3067\u53C2\u7167\u3057\u3066\u3044\u308B import '${importPath}' \u306E\u751F\u6210\u5148\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093`
|
|
2861
3299
|
);
|
|
2862
3300
|
}
|
|
2863
3301
|
}
|
|
@@ -2865,17 +3303,17 @@ async function runCodegenCheck(options = {}) {
|
|
|
2865
3303
|
}
|
|
2866
3304
|
}
|
|
2867
3305
|
if (legacyImportHits.length > 0) {
|
|
2868
|
-
errors.push("
|
|
3306
|
+
errors.push("\u65E7\u5F62\u5F0F '@/cmx/generated' \u306E import \u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F:");
|
|
2869
3307
|
for (const hit of legacyImportHits) {
|
|
2870
3308
|
errors.push(` - ${hit}`);
|
|
2871
3309
|
}
|
|
2872
3310
|
} else {
|
|
2873
|
-
checks.push("
|
|
3311
|
+
checks.push("\u65E7\u5F62\u5F0F '@/cmx/generated' \u306E import \u306F\u3042\u308A\u307E\u305B\u3093");
|
|
2874
3312
|
}
|
|
2875
3313
|
if (generatedImportHits.length === 0) {
|
|
2876
|
-
warnings.push("
|
|
3314
|
+
warnings.push("src/ \u914D\u4E0B\u306B '@cmx/generated' \u306E import \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\uFF08\u7A7A\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3067\u306F\u60F3\u5B9A\u5185\u3067\u3059\uFF09");
|
|
2877
3315
|
} else {
|
|
2878
|
-
checks.push(`
|
|
3316
|
+
checks.push(`src/ \u914D\u4E0B\u3067 '@cmx/generated' \u306E import \u3092 ${generatedImportHits.length} \u4EF6\u78BA\u8A8D`);
|
|
2879
3317
|
}
|
|
2880
3318
|
}
|
|
2881
3319
|
return {
|
|
@@ -2888,7 +3326,7 @@ async function runCodegenCheck(options = {}) {
|
|
|
2888
3326
|
async function codegenCheck(options = {}) {
|
|
2889
3327
|
const projectRoot = resolve2(options.projectRoot ?? process.cwd());
|
|
2890
3328
|
const result = await runCodegenCheck(options);
|
|
2891
|
-
console.log("Codegen
|
|
3329
|
+
console.log("Codegen \u30C1\u30A7\u30C3\u30AF\u7D50\u679C:");
|
|
2892
3330
|
for (const check of result.checks) {
|
|
2893
3331
|
console.log(` \u2713 ${check}`);
|
|
2894
3332
|
}
|
|
@@ -2900,10 +3338,10 @@ async function codegenCheck(options = {}) {
|
|
|
2900
3338
|
}
|
|
2901
3339
|
if (!result.success) {
|
|
2902
3340
|
console.error(`
|
|
2903
|
-
Codegen
|
|
3341
|
+
Codegen \u30C1\u30A7\u30C3\u30AF\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${projectRoot}`);
|
|
2904
3342
|
process.exit(1);
|
|
2905
3343
|
}
|
|
2906
|
-
console.log("\nCodegen
|
|
3344
|
+
console.log("\nCodegen \u30C1\u30A7\u30C3\u30AF\u306B\u6210\u529F\u3057\u307E\u3057\u305F");
|
|
2907
3345
|
}
|
|
2908
3346
|
|
|
2909
3347
|
// src/commands/mdx-validate.ts
|
|
@@ -2913,7 +3351,7 @@ import { extname as extname2, join as join6, relative as relative2, resolve as r
|
|
|
2913
3351
|
// src/mdx/validator.ts
|
|
2914
3352
|
import { compile } from "@mdx-js/mdx";
|
|
2915
3353
|
var FORBIDDEN_PATTERNS = [
|
|
2916
|
-
// import/export statements
|
|
3354
|
+
// import/export statements (at MDX level, not inside code blocks)
|
|
2917
3355
|
{ pattern: /^\s*import\s+/m, message: "import\u6587\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093" },
|
|
2918
3356
|
{ pattern: /^\s*export\s+/m, message: "export\u6587\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093" },
|
|
2919
3357
|
// JS expressions in curly braces (except component props)
|
|
@@ -2930,21 +3368,111 @@ var FORBIDDEN_PATTERNS = [
|
|
|
2930
3368
|
// data: URLs (for images - can be XSS vector)
|
|
2931
3369
|
{ pattern: /src\s*=\s*["']?\s*data:/i, message: "data: URL\u306F\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093" }
|
|
2932
3370
|
];
|
|
3371
|
+
function stripCodeBlocksForPatternCheck(mdx) {
|
|
3372
|
+
let result = mdx.replace(/<CodeBlock[^>]*>([^]*?)<\/CodeBlock>/g, (_match, content) => {
|
|
3373
|
+
const newlineCount = (content.match(/\n/g) || []).length;
|
|
3374
|
+
return "<CodeBlock>__CODE_PLACEHOLDER__" + "\n".repeat(newlineCount) + "</CodeBlock>";
|
|
3375
|
+
});
|
|
3376
|
+
result = result.replace(/```[\s\S]*?```/g, (match) => {
|
|
3377
|
+
const newlineCount = (match.match(/\n/g) || []).length;
|
|
3378
|
+
return "```__CODE_PLACEHOLDER__" + "\n".repeat(Math.max(0, newlineCount - 1)) + "```";
|
|
3379
|
+
});
|
|
3380
|
+
return result;
|
|
3381
|
+
}
|
|
3382
|
+
function escapeCodeBlocksForCompile(mdx) {
|
|
3383
|
+
let result = mdx.replace(/<CodeBlock([^>]*)>([^]*?)<\/CodeBlock>/g, (_match, attrs, content) => {
|
|
3384
|
+
const escapedContent = content.replace(/^(\s*)(import|export)\s/gm, "$1/* $2 */ ").replace(/\{/g, "{").replace(/\}/g, "}").replace(/</g, "<").replace(/>/g, ">");
|
|
3385
|
+
return `<CodeBlock${attrs}>${escapedContent}</CodeBlock>`;
|
|
3386
|
+
});
|
|
3387
|
+
result = result.replace(/```([a-z]*)\n([\s\S]*?)```/g, (_match, lang, content) => {
|
|
3388
|
+
const escapedContent = content.replace(/^(\s*)(import|export)\s/gm, "$1/* $2 */ ").replace(/\{/g, "{").replace(/\}/g, "}").replace(/</g, "<").replace(/>/g, ">");
|
|
3389
|
+
return "```" + lang + "\n" + escapedContent + "```";
|
|
3390
|
+
});
|
|
3391
|
+
return result;
|
|
3392
|
+
}
|
|
2933
3393
|
function extractComponents(mdx) {
|
|
2934
3394
|
const components = [];
|
|
2935
3395
|
const lines = mdx.split("\n");
|
|
2936
|
-
const
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
3396
|
+
const lineOffsets = [];
|
|
3397
|
+
let offset = 0;
|
|
3398
|
+
for (const line of lines) {
|
|
3399
|
+
lineOffsets.push(offset);
|
|
3400
|
+
offset += line.length + 1;
|
|
3401
|
+
}
|
|
3402
|
+
function getLineNumber(index) {
|
|
3403
|
+
let lo = 0, hi = lineOffsets.length - 1;
|
|
3404
|
+
while (lo < hi) {
|
|
3405
|
+
const mid = Math.floor((lo + hi + 1) / 2);
|
|
3406
|
+
if (lineOffsets[mid] <= index) {
|
|
3407
|
+
lo = mid;
|
|
3408
|
+
} else {
|
|
3409
|
+
hi = mid - 1;
|
|
3410
|
+
}
|
|
3411
|
+
}
|
|
3412
|
+
return lo + 1;
|
|
3413
|
+
}
|
|
3414
|
+
const stack = [];
|
|
3415
|
+
let i = 0;
|
|
3416
|
+
while (i < mdx.length) {
|
|
3417
|
+
if (mdx[i] !== "<") {
|
|
3418
|
+
i++;
|
|
3419
|
+
continue;
|
|
3420
|
+
}
|
|
3421
|
+
const tagStart = i;
|
|
3422
|
+
i++;
|
|
3423
|
+
if (mdx[i] === "/") {
|
|
3424
|
+
i++;
|
|
3425
|
+
const closeMatch = mdx.slice(i).match(/^([A-Z][a-zA-Z0-9]*)\s*>/);
|
|
3426
|
+
if (closeMatch) {
|
|
3427
|
+
const closingName = closeMatch[1];
|
|
3428
|
+
i += closeMatch[0].length;
|
|
3429
|
+
for (let s = stack.length - 1; s >= 0; s--) {
|
|
3430
|
+
if (stack[s].name === closingName) {
|
|
3431
|
+
const opening = stack[s];
|
|
3432
|
+
const children = mdx.slice(opening.contentStart, tagStart).trim();
|
|
3433
|
+
const props = parseProps(opening.propsString);
|
|
3434
|
+
if (children) {
|
|
3435
|
+
props.children = children;
|
|
3436
|
+
}
|
|
3437
|
+
components.push({
|
|
3438
|
+
name: opening.name,
|
|
3439
|
+
props,
|
|
3440
|
+
line: opening.line
|
|
3441
|
+
});
|
|
3442
|
+
stack.splice(s, 1);
|
|
3443
|
+
break;
|
|
3444
|
+
}
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
continue;
|
|
3448
|
+
}
|
|
3449
|
+
if (mdx[i] === "!" && mdx[i + 1] === "-" && mdx[i + 2] === "-") {
|
|
3450
|
+
const commentEnd = mdx.indexOf("-->", i + 3);
|
|
3451
|
+
i = commentEnd !== -1 ? commentEnd + 3 : mdx.length;
|
|
3452
|
+
continue;
|
|
3453
|
+
}
|
|
3454
|
+
const tagMatch = mdx.slice(i).match(/^([A-Z][a-zA-Z0-9]*)([\s\S]*?)(\/)?>/);
|
|
3455
|
+
if (!tagMatch) {
|
|
3456
|
+
continue;
|
|
3457
|
+
}
|
|
3458
|
+
const name = tagMatch[1];
|
|
3459
|
+
const attrsPart = tagMatch[2].trim();
|
|
3460
|
+
const isSelfClosing = tagMatch[3] === "/";
|
|
3461
|
+
i += tagMatch[0].length;
|
|
3462
|
+
if (isSelfClosing) {
|
|
2944
3463
|
components.push({
|
|
2945
3464
|
name,
|
|
2946
|
-
props,
|
|
2947
|
-
line:
|
|
3465
|
+
props: parseProps(attrsPart),
|
|
3466
|
+
line: getLineNumber(tagStart)
|
|
3467
|
+
});
|
|
3468
|
+
} else {
|
|
3469
|
+
stack.push({
|
|
3470
|
+
name,
|
|
3471
|
+
propsString: attrsPart,
|
|
3472
|
+
tagStart,
|
|
3473
|
+
contentStart: tagStart + 1 + tagMatch[0].length,
|
|
3474
|
+
// after '>'
|
|
3475
|
+
line: getLineNumber(tagStart)
|
|
2948
3476
|
});
|
|
2949
3477
|
}
|
|
2950
3478
|
}
|
|
@@ -3009,9 +3537,10 @@ function extractReferences(components) {
|
|
|
3009
3537
|
async function validateMdx(mdx) {
|
|
3010
3538
|
const errors = [];
|
|
3011
3539
|
const warnings = [];
|
|
3540
|
+
const mdxWithoutCodeBlocks = stripCodeBlocksForPatternCheck(mdx);
|
|
3012
3541
|
for (const { pattern, message } of FORBIDDEN_PATTERNS) {
|
|
3013
|
-
if (pattern.test(
|
|
3014
|
-
const lines =
|
|
3542
|
+
if (pattern.test(mdxWithoutCodeBlocks)) {
|
|
3543
|
+
const lines = mdxWithoutCodeBlocks.split("\n");
|
|
3015
3544
|
for (let i = 0; i < lines.length; i++) {
|
|
3016
3545
|
if (pattern.test(lines[i])) {
|
|
3017
3546
|
errors.push({
|
|
@@ -3024,10 +3553,10 @@ async function validateMdx(mdx) {
|
|
|
3024
3553
|
}
|
|
3025
3554
|
}
|
|
3026
3555
|
}
|
|
3556
|
+
const escapedMdx = escapeCodeBlocksForCompile(mdx);
|
|
3027
3557
|
try {
|
|
3028
|
-
await compile(
|
|
3558
|
+
await compile(escapedMdx, {
|
|
3029
3559
|
development: false
|
|
3030
|
-
// Minimal compilation to check syntax
|
|
3031
3560
|
});
|
|
3032
3561
|
} catch (error) {
|
|
3033
3562
|
const err = error;
|
|
@@ -3038,7 +3567,8 @@ async function validateMdx(mdx) {
|
|
|
3038
3567
|
column: err.column
|
|
3039
3568
|
});
|
|
3040
3569
|
}
|
|
3041
|
-
const
|
|
3570
|
+
const mdxForComponentExtraction = stripCodeBlocksForPatternCheck(mdx);
|
|
3571
|
+
const components = extractComponents(mdxForComponentExtraction);
|
|
3042
3572
|
for (const component of components) {
|
|
3043
3573
|
if (!isValidComponent(component.name)) {
|
|
3044
3574
|
errors.push({
|
|
@@ -3100,7 +3630,7 @@ async function mdxValidate(options) {
|
|
|
3100
3630
|
const targets = [];
|
|
3101
3631
|
if (inputFile) {
|
|
3102
3632
|
if (!existsSync5(inputFile)) {
|
|
3103
|
-
console.error(
|
|
3633
|
+
console.error(`\u30A8\u30E9\u30FC: \u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${options.file}`);
|
|
3104
3634
|
process.exit(1);
|
|
3105
3635
|
}
|
|
3106
3636
|
targets.push(inputFile);
|
|
@@ -3109,7 +3639,7 @@ async function mdxValidate(options) {
|
|
|
3109
3639
|
targets.push(...dirFiles);
|
|
3110
3640
|
}
|
|
3111
3641
|
if (targets.length === 0) {
|
|
3112
|
-
console.error("
|
|
3642
|
+
console.error("\u691C\u8A3C\u5BFE\u8C61\u306E MDX \u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F");
|
|
3113
3643
|
process.exit(1);
|
|
3114
3644
|
}
|
|
3115
3645
|
let invalidCount = 0;
|
|
@@ -3136,9 +3666,9 @@ async function mdxValidate(options) {
|
|
|
3136
3666
|
}
|
|
3137
3667
|
}
|
|
3138
3668
|
console.log("");
|
|
3139
|
-
console.log(
|
|
3140
|
-
console.log(
|
|
3141
|
-
console.log(
|
|
3669
|
+
console.log(`\u691C\u8A3C\u30D5\u30A1\u30A4\u30EB\u6570: ${targets.length}`);
|
|
3670
|
+
console.log(`\u30A8\u30E9\u30FC\u4EF6\u6570: ${invalidCount}`);
|
|
3671
|
+
console.log(`\u8B66\u544A\u4EF6\u6570: ${warningCount}`);
|
|
3142
3672
|
if (invalidCount > 0) {
|
|
3143
3673
|
process.exit(1);
|
|
3144
3674
|
}
|
|
@@ -3177,13 +3707,13 @@ function parseDefinitionFiles(projectRoot, files) {
|
|
|
3177
3707
|
const raw = readFileSync6(file, "utf-8");
|
|
3178
3708
|
const parsed = JSON.parse(raw);
|
|
3179
3709
|
if (typeof parsed.name !== "string" || parsed.name.length === 0) {
|
|
3180
|
-
errors.push(`${relative3(projectRoot, file)}:
|
|
3710
|
+
errors.push(`${relative3(projectRoot, file)}: \u6587\u5B57\u5217\u306E 'name' \u304C\u5FC5\u8981\u3067\u3059`);
|
|
3181
3711
|
continue;
|
|
3182
3712
|
}
|
|
3183
3713
|
definitions.push({ name: parsed.name, file });
|
|
3184
3714
|
} catch (error) {
|
|
3185
3715
|
errors.push(
|
|
3186
|
-
`${relative3(projectRoot, file)}:
|
|
3716
|
+
`${relative3(projectRoot, file)}: JSON \u304C\u4E0D\u6B63\u3067\u3059 (${error instanceof Error ? error.message : String(error)})`
|
|
3187
3717
|
);
|
|
3188
3718
|
}
|
|
3189
3719
|
}
|
|
@@ -3212,10 +3742,10 @@ async function mdxDoctor(options = {}) {
|
|
|
3212
3742
|
const issues = [];
|
|
3213
3743
|
const checks = [];
|
|
3214
3744
|
if (!existsSync6(definitionsDir)) {
|
|
3215
|
-
issues.push(
|
|
3745
|
+
issues.push(`\u5B9A\u7FA9\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${relative3(projectRoot, definitionsDir)}`);
|
|
3216
3746
|
}
|
|
3217
3747
|
if (!existsSync6(componentsDir)) {
|
|
3218
|
-
issues.push(
|
|
3748
|
+
issues.push(`\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5B9F\u88C5\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${relative3(projectRoot, componentsDir)}`);
|
|
3219
3749
|
}
|
|
3220
3750
|
if (issues.length > 0) {
|
|
3221
3751
|
for (const issue of issues) {
|
|
@@ -3225,8 +3755,8 @@ async function mdxDoctor(options = {}) {
|
|
|
3225
3755
|
}
|
|
3226
3756
|
const definitionFiles = collectFiles2(definitionsDir, ".json");
|
|
3227
3757
|
const implFiles = collectFiles2(componentsDir, ".tsx").filter((f) => basename(f) !== "index.tsx");
|
|
3228
|
-
checks.push(
|
|
3229
|
-
checks.push(
|
|
3758
|
+
checks.push(`\u5B9A\u7FA9\u30D5\u30A1\u30A4\u30EB\u3092 ${definitionFiles.length} \u4EF6\u691C\u51FA`);
|
|
3759
|
+
checks.push(`\u5B9F\u88C5\u30D5\u30A1\u30A4\u30EB\u3092 ${implFiles.length} \u4EF6\u691C\u51FA`);
|
|
3230
3760
|
const { definitions, errors } = parseDefinitionFiles(projectRoot, definitionFiles);
|
|
3231
3761
|
for (const error of errors) {
|
|
3232
3762
|
issues.push(error);
|
|
@@ -3237,32 +3767,32 @@ async function mdxDoctor(options = {}) {
|
|
|
3237
3767
|
);
|
|
3238
3768
|
for (const def of definitions) {
|
|
3239
3769
|
if (isStandardComponentName(def.name)) {
|
|
3240
|
-
issues.push(`${relative3(projectRoot, def.file)}: '${def.name}'
|
|
3770
|
+
issues.push(`${relative3(projectRoot, def.file)}: '${def.name}' \u306F\u6A19\u6E96\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u540D\u306E\u305F\u3081\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093`);
|
|
3241
3771
|
}
|
|
3242
3772
|
}
|
|
3243
3773
|
for (const defName of definitionNames) {
|
|
3244
3774
|
if (!implementationNames.has(defName)) {
|
|
3245
|
-
issues.push(
|
|
3775
|
+
issues.push(`\u5B9A\u7FA9\u306F\u3042\u308A\u307E\u3059\u304C\u5B9F\u88C5\u304C\u3042\u308A\u307E\u305B\u3093: ${defName}.tsx`);
|
|
3246
3776
|
}
|
|
3247
3777
|
}
|
|
3248
3778
|
for (const implName of implementationNames) {
|
|
3249
3779
|
if (!definitionNames.has(implName)) {
|
|
3250
|
-
issues.push(
|
|
3780
|
+
issues.push(`\u5B9F\u88C5\u306F\u3042\u308A\u307E\u3059\u304C\u5B9A\u7FA9\u304C\u3042\u308A\u307E\u305B\u3093: ${implName}.json`);
|
|
3251
3781
|
}
|
|
3252
3782
|
}
|
|
3253
3783
|
if (!existsSync6(indexFile)) {
|
|
3254
|
-
issues.push(
|
|
3784
|
+
issues.push(`\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u7528 index \u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${relative3(projectRoot, indexFile)}`);
|
|
3255
3785
|
} else {
|
|
3256
3786
|
const indexContent = readFileSync6(indexFile, "utf-8");
|
|
3257
3787
|
const exportedNames = collectExportedComponentNames(indexContent);
|
|
3258
3788
|
for (const implName of implementationNames) {
|
|
3259
3789
|
if (!exportedNames.has(implName)) {
|
|
3260
|
-
issues.push(
|
|
3790
|
+
issues.push(`${relative3(projectRoot, indexFile)} \u3067\u5B9F\u88C5\u304C export \u3055\u308C\u3066\u3044\u307E\u305B\u3093: ${implName}`);
|
|
3261
3791
|
}
|
|
3262
3792
|
}
|
|
3263
|
-
checks.push(
|
|
3793
|
+
checks.push(`${relative3(projectRoot, indexFile)} \u306E export \u5B9A\u7FA9\u3092\u78BA\u8A8D`);
|
|
3264
3794
|
}
|
|
3265
|
-
console.log("MDX doctor:");
|
|
3795
|
+
console.log("MDX doctor \u7D50\u679C:");
|
|
3266
3796
|
for (const check of checks) {
|
|
3267
3797
|
console.log(` \u2713 ${check}`);
|
|
3268
3798
|
}
|
|
@@ -3271,49 +3801,52 @@ async function mdxDoctor(options = {}) {
|
|
|
3271
3801
|
console.error(` \u2717 ${issue}`);
|
|
3272
3802
|
}
|
|
3273
3803
|
console.error(`
|
|
3274
|
-
|
|
3804
|
+
\u554F\u984C\u3092 ${issues.length} \u4EF6\u691C\u51FA\u3057\u307E\u3057\u305F`);
|
|
3275
3805
|
process.exit(1);
|
|
3276
3806
|
}
|
|
3277
|
-
console.log("\
|
|
3807
|
+
console.log("\n\u3059\u3079\u3066\u306E\u30C1\u30A7\u30C3\u30AF\u306B\u6210\u529F\u3057\u307E\u3057\u305F");
|
|
3278
3808
|
}
|
|
3279
3809
|
|
|
3280
3810
|
// src/cli.ts
|
|
3281
3811
|
config();
|
|
3812
|
+
installSdkFetchInterceptor();
|
|
3282
3813
|
var program = new Command();
|
|
3283
|
-
program.name("cmx-sdk").description("CMX
|
|
3814
|
+
program.name("cmx-sdk").description("CMX \u30B9\u30AD\u30FC\u30DE\u3068\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u64CD\u4F5C\u3059\u308B CLI \u30C4\u30FC\u30EB").version("0.2.6").allowExcessArguments(false);
|
|
3284
3815
|
function requireApiCredentials() {
|
|
3285
3816
|
const apiUrl = process.env.CMX_API_URL;
|
|
3286
3817
|
const apiKey = process.env.CMX_API_KEY;
|
|
3287
3818
|
if (!apiUrl || !apiKey) {
|
|
3288
|
-
console.error("
|
|
3819
|
+
console.error("\u30A8\u30E9\u30FC: \u74B0\u5883\u5909\u6570 CMX_API_URL \u3068 CMX_API_KEY \u3092\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
3289
3820
|
process.exit(1);
|
|
3290
3821
|
}
|
|
3291
3822
|
return { apiUrl, apiKey };
|
|
3292
3823
|
}
|
|
3293
3824
|
program.action(async () => {
|
|
3294
|
-
const { interactiveMenu } = await import("./interactive-menu-
|
|
3825
|
+
const { interactiveMenu } = await import("./interactive-menu-FYVOQSTL.js");
|
|
3295
3826
|
await interactiveMenu();
|
|
3296
3827
|
});
|
|
3297
|
-
program.command("init [project-name]").description("\u65B0\
|
|
3298
|
-
const { init } = await import("./init-
|
|
3828
|
+
program.command("init [project-name]").description("\u65B0\u3057\u3044 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)").option("--key <key>", "CMX API \u30AD\u30FC\uFF08\u5FC5\u9808\u3002\u672A\u6307\u5B9A\u6642\u306F\u30D7\u30ED\u30F3\u30D7\u30C8\u8868\u793A\uFF09").option("--api-url <url>", "CMX API \u30B5\u30FC\u30D0\u30FC\u306E URL").action(async (projectName, options) => {
|
|
3829
|
+
const { init } = await import("./init-FLRQXJX4.js");
|
|
3299
3830
|
await init(projectName, options);
|
|
3300
3831
|
});
|
|
3301
3832
|
program.command("add-studio").description("\u65E2\u5B58\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306B CMX Studio \u3092\u8FFD\u52A0").action(async () => {
|
|
3302
|
-
const { addStudio } = await import("./add-studio-
|
|
3833
|
+
const { addStudio } = await import("./add-studio-YUDYE2OH.js");
|
|
3303
3834
|
await addStudio();
|
|
3304
3835
|
});
|
|
3305
|
-
program.command("studio").description("\
|
|
3306
|
-
program.command("
|
|
3307
|
-
program.command("
|
|
3308
|
-
program.command("list-
|
|
3309
|
-
program.command("list-
|
|
3310
|
-
program.command("
|
|
3311
|
-
program.command("
|
|
3312
|
-
program.command("create-
|
|
3313
|
-
program.command("
|
|
3314
|
-
program.command("
|
|
3315
|
-
|
|
3316
|
-
|
|
3836
|
+
program.command("update-studio").description("\u65E2\u5B58\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E CMX Studio \u3092\u6700\u65B0\u5316").option("--force", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action((options) => updateStudio(options));
|
|
3837
|
+
program.command("update-sdk").description("\u65E2\u5B58\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E cmx-sdk \u4F9D\u5B58\u30D0\u30FC\u30B8\u30E7\u30F3\u3092\u66F4\u65B0").option("--version <version>", "\u66F4\u65B0\u5148\u30D0\u30FC\u30B8\u30E7\u30F3\uFF08\u65E2\u5B9A: latest\uFF09").action((options) => updateSdk(options));
|
|
3838
|
+
program.command("studio").description("\u30B5\u30A4\u30C8\uFF084000\uFF09\u3068 Studio\uFF084001\uFF09\u3092\u540C\u6642\u8D77\u52D5").action(studio);
|
|
3839
|
+
program.command("list-collections").description("\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u4E00\u89A7\u3092\u8868\u793A").action(listCollections);
|
|
3840
|
+
program.command("list-data-types").description("\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u4E00\u89A7\u3092\u8868\u793A").action(listDataTypes);
|
|
3841
|
+
program.command("list-forms").description("\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u4E00\u89A7\u3092\u8868\u793A").action(listForms);
|
|
3842
|
+
program.command("list-components").description("\u30AB\u30B9\u30BF\u30E0\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u4E00\u89A7\u3092\u8868\u793A").action(listComponents);
|
|
3843
|
+
program.command("create-collection").description("\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u4F5C\u6210").option("--json <json>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u5B9A\u7FA9\u306E JSON \u6587\u5B57\u5217").option("--type <type>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u7A2E\u5225 (post, page, doc, news)").option("--slug <slug>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u30B9\u30E9\u30C3\u30B0").option("--name <name>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u540D").option("--description <description>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u8AAC\u660E").action(createCollection);
|
|
3844
|
+
program.command("create-data-type").description("\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u4F5C\u6210").option("--json <json>", "\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u5B9A\u7FA9\u306E JSON \u6587\u5B57\u5217\uFF08\u63A8\u5968\uFF09").option("--slug <slug>", "\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u30B9\u30E9\u30C3\u30B0").option("--name <name>", "\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u540D").option("--description <description>", "\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u8AAC\u660E").action(createDataType);
|
|
3845
|
+
program.command("create-form").description("\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u4F5C\u6210").option("--json <json>", "\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u306E JSON \u6587\u5B57\u5217\uFF08\u63A8\u5968\uFF09").option("--slug <slug>", "\u30D5\u30A9\u30FC\u30E0\u306E\u30B9\u30E9\u30C3\u30B0").option("--name <name>", "\u30D5\u30A9\u30FC\u30E0\u540D").option("--description <description>", "\u30D5\u30A9\u30FC\u30E0\u306E\u8AAC\u660E").action(createForm);
|
|
3846
|
+
program.command("sync-components").description("\u30AB\u30B9\u30BF\u30E0\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5B9A\u7FA9\u3092\u540C\u671F").action(syncComponents);
|
|
3847
|
+
program.command("components").description("\u30AB\u30B9\u30BF\u30E0\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5B9A\u7FA9\u3068\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u7BA1\u7406").command("scaffold").description("\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5B9A\u7FA9\u3068\u5B9F\u88C5\u3072\u306A\u5F62\u3092\u751F\u6210").requiredOption("--name <name>", "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u540D\uFF08PascalCase\uFF09").option("--data-bound", "ID \u89E3\u6C7A\u7528 props \u3092\u542B\u3080\u30C7\u30FC\u30BF\u9023\u643A\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u3092\u751F\u6210").option("--force", "\u65E2\u5B58\u30D5\u30A1\u30A4\u30EB\u3092\u4E0A\u66F8\u304D").option("--components-dir <dir>", "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5B9F\u88C5\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\uFF08\u65E2\u5B9A: src/components/custom\uFF09").option("--definitions-dir <dir>", "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5B9A\u7FA9\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\uFF08\u65E2\u5B9A: cmx/components\uFF09").action((options) => scaffoldComponent(options));
|
|
3848
|
+
var codegenCommand = program.command("codegen").description("\u578B\u4ED8\u304D\u30B3\u30FC\u30C9\u751F\u6210\u30FB\u30DA\u30FC\u30B8\u3072\u306A\u5F62\u751F\u6210\u30FB\u6574\u5408\u6027\u30C1\u30A7\u30C3\u30AF\u3092\u5B9F\u884C");
|
|
3849
|
+
codegenCommand.command("types").description("CMX \u30B9\u30AD\u30FC\u30DE\u304B\u3089 TypeScript \u578B\u3068\u53D6\u5F97\u30D8\u30EB\u30D1\u30FC\u3092\u751F\u6210").option("--output <dir>", "\u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA", "cmx/generated").action(async (options) => {
|
|
3317
3850
|
const { apiUrl, apiKey } = requireApiCredentials();
|
|
3318
3851
|
await generate({
|
|
3319
3852
|
apiUrl,
|
|
@@ -3321,7 +3854,7 @@ codegenCommand.command("types").description("Generate TypeScript types and fetch
|
|
|
3321
3854
|
outputDir: options.output
|
|
3322
3855
|
});
|
|
3323
3856
|
});
|
|
3324
|
-
codegenCommand.command("pages").description("
|
|
3857
|
+
codegenCommand.command("pages").description("CMX \u30B9\u30AD\u30FC\u30DE\u304B\u3089 Next.js \u30DA\u30FC\u30B8\u3092\u751F\u6210").option("--app-dir <dir>", "app \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30D1\u30B9", "src/app").option("--features-dir <dir>", "features \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30D1\u30B9\uFF08layered \u306E\u307F\uFF09", "src/features").option("--template <template>", "\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u7A2E\u5225\uFF08layered \u307E\u305F\u306F legacy\uFF09", "layered").option("--dry-run", "\u30D5\u30A1\u30A4\u30EB\u3092\u66F8\u304D\u8FBC\u307E\u305A\u306B\u7D50\u679C\u3092\u78BA\u8A8D").option("--force", "\u65E2\u5B58\u30D5\u30A1\u30A4\u30EB\u3092\u4E0A\u66F8\u304D").option("--only <filter>", "\u7279\u5B9A\u8981\u7D20\u306E\u307F\u751F\u6210\uFF08\u4F8B: collections:blog\uFF09").action(
|
|
3325
3858
|
async (options) => {
|
|
3326
3859
|
const { apiUrl, apiKey } = requireApiCredentials();
|
|
3327
3860
|
await scaffold({
|
|
@@ -3336,7 +3869,7 @@ codegenCommand.command("pages").description("Generate Next.js pages from CMX sch
|
|
|
3336
3869
|
});
|
|
3337
3870
|
}
|
|
3338
3871
|
);
|
|
3339
|
-
codegenCommand.command("check").description("
|
|
3872
|
+
codegenCommand.command("check").description("\u751F\u6210\u30B3\u30FC\u30C9\u3068\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u8A2D\u5B9A\u306E\u6574\u5408\u6027\u3092\u691C\u8A3C").option("--project-root <dir>", "\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u30EB\u30FC\u30C8").option("--output-dir <dir>", "\u751F\u6210\u30B3\u30FC\u30C9\u306E\u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA", "cmx/generated").option("--src-dir <dir>", "import \u53C2\u7167\u3092\u691C\u67FB\u3059\u308B\u30BD\u30FC\u30B9\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA", "src").option("--tsconfig <path>", "tsconfig \u306E\u30D1\u30B9", "tsconfig.json").action(
|
|
3340
3873
|
async (options) => {
|
|
3341
3874
|
await codegenCheck({
|
|
3342
3875
|
projectRoot: options.projectRoot,
|
|
@@ -3346,16 +3879,16 @@ codegenCommand.command("check").description("Check generated code and project wi
|
|
|
3346
3879
|
});
|
|
3347
3880
|
}
|
|
3348
3881
|
);
|
|
3349
|
-
codegenCommand.command("all").description("
|
|
3882
|
+
codegenCommand.command("all").description("`codegen types` \u2192 `codegen pages` \u2192 `codegen check` \u3092\u9806\u306B\u5B9F\u884C").option("--output <dir>", "\u578B\u751F\u6210\u306E\u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA", "cmx/generated").option("--app-dir <dir>", "app \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30D1\u30B9", "src/app").option("--features-dir <dir>", "features \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306E\u30D1\u30B9\uFF08layered \u306E\u307F\uFF09", "src/features").option("--template <template>", "\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u7A2E\u5225\uFF08layered \u307E\u305F\u306F legacy\uFF09", "layered").option("--dry-run", "\u30DA\u30FC\u30B8\u751F\u6210\u3092\u30D5\u30A1\u30A4\u30EB\u672A\u66F8\u304D\u8FBC\u307F\u3067\u78BA\u8A8D").option("--force", "\u30DA\u30FC\u30B8\u751F\u6210\u6642\u306B\u65E2\u5B58\u30D5\u30A1\u30A4\u30EB\u3092\u4E0A\u66F8\u304D").option("--only <filter>", "\u7279\u5B9A\u8981\u7D20\u306E\u307F\u751F\u6210\uFF08\u4F8B: collections:blog\uFF09").option("--src-dir <dir>", "import \u53C2\u7167\u3092\u691C\u67FB\u3059\u308B\u30BD\u30FC\u30B9\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA", "src").option("--tsconfig <path>", "tsconfig \u306E\u30D1\u30B9", "tsconfig.json").action(
|
|
3350
3883
|
async (options) => {
|
|
3351
3884
|
const { apiUrl, apiKey } = requireApiCredentials();
|
|
3352
|
-
console.log("\n[1/3] codegen types");
|
|
3885
|
+
console.log("\n[1/3] \u578B\u751F\u6210\u3092\u5B9F\u884C\u3057\u307E\u3059 (codegen types)");
|
|
3353
3886
|
await generate({
|
|
3354
3887
|
apiUrl,
|
|
3355
3888
|
apiKey,
|
|
3356
3889
|
outputDir: options.output
|
|
3357
3890
|
});
|
|
3358
|
-
console.log("\n[2/3] codegen pages");
|
|
3891
|
+
console.log("\n[2/3] \u30DA\u30FC\u30B8\u751F\u6210\u3092\u5B9F\u884C\u3057\u307E\u3059 (codegen pages)");
|
|
3359
3892
|
await scaffold({
|
|
3360
3893
|
apiUrl,
|
|
3361
3894
|
apiKey,
|
|
@@ -3366,7 +3899,7 @@ codegenCommand.command("all").description("Run `codegen types`, `codegen pages`,
|
|
|
3366
3899
|
force: options.force,
|
|
3367
3900
|
only: options.only
|
|
3368
3901
|
});
|
|
3369
|
-
console.log("\n[3/3] codegen check");
|
|
3902
|
+
console.log("\n[3/3] \u6574\u5408\u6027\u30C1\u30A7\u30C3\u30AF\u3092\u5B9F\u884C\u3057\u307E\u3059 (codegen check)");
|
|
3370
3903
|
await codegenCheck({
|
|
3371
3904
|
outputDir: options.output,
|
|
3372
3905
|
srcDir: options.srcDir,
|
|
@@ -3374,30 +3907,30 @@ codegenCommand.command("all").description("Run `codegen types`, `codegen pages`,
|
|
|
3374
3907
|
});
|
|
3375
3908
|
}
|
|
3376
3909
|
);
|
|
3377
|
-
var mdxCommand = program.command("mdx").description("MDX
|
|
3378
|
-
mdxCommand.command("validate").description("
|
|
3379
|
-
mdxCommand.command("doctor").description("
|
|
3910
|
+
var mdxCommand = program.command("mdx").description("MDX \u958B\u767A\u30C4\u30FC\u30EB");
|
|
3911
|
+
mdxCommand.command("validate").description("MDX \u306E\u69CB\u6587\u30FB\u7981\u6B62\u30D1\u30BF\u30FC\u30F3\u30FB\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5229\u7528\u3092\u691C\u8A3C").option("--file <path>", "\u5358\u4E00\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u8A3C").option("--dir <dir>", "\u6307\u5B9A\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u914D\u4E0B\u306E .mdx \u3092\u691C\u8A3C", "src").action((options) => mdxValidate(options));
|
|
3912
|
+
mdxCommand.command("doctor").description("MDX \u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5B9A\u7FA9\u3068\u5B9F\u88C5\u306E\u6574\u5408\u6027\u3092\u691C\u8A3C").option("--definitions-dir <dir>", "\u5B9A\u7FA9\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA", "cmx/components").option("--components-dir <dir>", "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5B9F\u88C5\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA", "src/components/custom").option("--index-file <path>", "\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8 export \u7528\u30A4\u30F3\u30C7\u30C3\u30AF\u30B9\u30D5\u30A1\u30A4\u30EB", "src/components/custom/index.ts").action(
|
|
3380
3913
|
(options) => mdxDoctor(options)
|
|
3381
3914
|
);
|
|
3382
|
-
program.command("update-collection").description("
|
|
3383
|
-
program.command("delete-collection").description("
|
|
3384
|
-
program.command("update-data-type").description("
|
|
3385
|
-
program.command("delete-data-type").description("
|
|
3386
|
-
program.command("update-form").description("
|
|
3387
|
-
program.command("delete-form").description("
|
|
3388
|
-
program.command("list-collection-data-types").description("
|
|
3389
|
-
program.command("add-collection-data-type").description("
|
|
3390
|
-
program.command("remove-collection-data-type").description("
|
|
3391
|
-
program.command("link-collection-data-type").description("
|
|
3392
|
-
program.command("list-collection-presets").description("
|
|
3393
|
-
program.command("create-data-entry").description("
|
|
3394
|
-
program.command("list-data-entries").description("
|
|
3395
|
-
program.command("get-data-entry").description("
|
|
3396
|
-
program.command("update-data-entry").description("
|
|
3397
|
-
program.command("delete-data-entry").description("
|
|
3398
|
-
program.command("create-content").description("
|
|
3399
|
-
program.command("request-review-content").description("
|
|
3400
|
-
program.command("publish-content").description("
|
|
3401
|
-
program.command("get-content-references").description("
|
|
3402
|
-
program.command("set-content-references").description("
|
|
3915
|
+
program.command("update-collection").description("\u65E2\u5B58\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u66F4\u65B0").requiredOption("--slug <slug>", "\u66F4\u65B0\u5BFE\u8C61\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u73FE\u5728\u30B9\u30E9\u30C3\u30B0").option("--json <json>", "\u66F4\u65B0\u5185\u5BB9\u306E JSON \u6587\u5B57\u5217").option("--new-slug <slug>", "\u65B0\u3057\u3044\u30B9\u30E9\u30C3\u30B0").option("--name <name>", "\u65B0\u3057\u3044\u540D\u524D").option("--description <description>", "\u65B0\u3057\u3044\u8AAC\u660E").action(updateCollection);
|
|
3916
|
+
program.command("delete-collection").description("\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3092\u524A\u9664").requiredOption("--slug <slug>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u30B9\u30E9\u30C3\u30B0").option("--force", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").option("--cascade", "\u95A2\u9023\u30B3\u30F3\u30C6\u30F3\u30C4\u3082\u3042\u308F\u305B\u3066\u524A\u9664").action(deleteCollection);
|
|
3917
|
+
program.command("update-data-type").description("\u65E2\u5B58\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u66F4\u65B0").requiredOption("--slug <slug>", "\u66F4\u65B0\u5BFE\u8C61\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u73FE\u5728\u30B9\u30E9\u30C3\u30B0").option("--json <json>", "\u66F4\u65B0\u5185\u5BB9\u306E JSON \u6587\u5B57\u5217").option("--name <name>", "\u65B0\u3057\u3044\u540D\u524D").option("--description <description>", "\u65B0\u3057\u3044\u8AAC\u660E").action(updateDataType);
|
|
3918
|
+
program.command("delete-data-type").description("\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u524A\u9664").requiredOption("--slug <slug>", "\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u30B9\u30E9\u30C3\u30B0").option("--force", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").option("--cascade", "\u95A2\u9023\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3082\u3042\u308F\u305B\u3066\u524A\u9664").action(deleteDataType);
|
|
3919
|
+
program.command("update-form").description("\u65E2\u5B58\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u66F4\u65B0").requiredOption("--slug <slug>", "\u66F4\u65B0\u5BFE\u8C61\u30D5\u30A9\u30FC\u30E0\u306E\u73FE\u5728\u30B9\u30E9\u30C3\u30B0").option("--json <json>", "\u66F4\u65B0\u5185\u5BB9\u306E JSON \u6587\u5B57\u5217").option("--name <name>", "\u65B0\u3057\u3044\u540D\u524D").option("--description <description>", "\u65B0\u3057\u3044\u8AAC\u660E").action(updateForm);
|
|
3920
|
+
program.command("delete-form").description("\u30D5\u30A9\u30FC\u30E0\u5B9A\u7FA9\u3092\u524A\u9664").requiredOption("--slug <slug>", "\u30D5\u30A9\u30FC\u30E0\u306E\u30B9\u30E9\u30C3\u30B0").option("--force", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(deleteForm);
|
|
3921
|
+
program.command("list-collection-data-types").description("\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306B\u7D10\u3065\u304F\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u4E00\u89A7\u3092\u8868\u793A").requiredOption("--collection <slug>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u30B9\u30E9\u30C3\u30B0").action(listCollectionDataTypes);
|
|
3922
|
+
program.command("add-collection-data-type").description("\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306B\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u8FFD\u52A0\uFF08\u30D7\u30EA\u30BB\u30C3\u30C8\u307E\u305F\u306F\u30AB\u30B9\u30BF\u30E0\uFF09").requiredOption("--collection <slug>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u30B9\u30E9\u30C3\u30B0").option("--preset <slug>", "\u30D7\u30EA\u30BB\u30C3\u30C8\u30B9\u30E9\u30C3\u30B0\uFF08\u4F8B: categories, tags, authors\uFF09").option("--json <json>", "\u30AB\u30B9\u30BF\u30E0\u5B9A\u7FA9\u306E JSON \u6587\u5B57\u5217").option("--file <file>", "\u30AB\u30B9\u30BF\u30E0\u5B9A\u7FA9 JSON \u30D5\u30A1\u30A4\u30EB\u306E\u30D1\u30B9").action(addCollectionDataType);
|
|
3923
|
+
program.command("remove-collection-data-type").description("\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u304B\u3089\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u524A\u9664").requiredOption("--collection <slug>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u30B9\u30E9\u30C3\u30B0").requiredOption("--data-type <slug>", "\u524A\u9664\u3059\u308B\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u30B9\u30E9\u30C3\u30B0").action(removeCollectionDataType);
|
|
3924
|
+
program.command("link-collection-data-type").description("\u65E2\u5B58\u306E\u30B0\u30ED\u30FC\u30D0\u30EB\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3092\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u3078\u7D10\u3065\u3051").requiredOption("--collection <slug>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u30B9\u30E9\u30C3\u30B0").requiredOption("--data-type <slug>", "\u7D10\u3065\u3051\u308B\u30B0\u30ED\u30FC\u30D0\u30EB\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u30B9\u30E9\u30C3\u30B0").requiredOption("--field-slug <slug>", "\u53C2\u7167\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u30B9\u30E9\u30C3\u30B0").requiredOption("--label <label>", "\u53C2\u7167\u30D5\u30A3\u30FC\u30EB\u30C9\u306E\u8868\u793A\u540D").option("--reference-type <type>", "\u53C2\u7167\u30BF\u30A4\u30D7\uFF08single \u307E\u305F\u306F multiple\u3001\u65E2\u5B9A: single\uFF09", "single").action(linkCollectionDataType);
|
|
3925
|
+
program.command("list-collection-presets").description("\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u5411\u3051\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u30D7\u30EA\u30BB\u30C3\u30C8\u4E00\u89A7\u3092\u8868\u793A").option("--type <type>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u7A2E\u5225 (post, news, doc, page)").action(listCollectionPresets);
|
|
3926
|
+
program.command("create-data-entry").description("\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3092\u4F5C\u6210").requiredOption("--type-slug <slug>", "\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u30B9\u30E9\u30C3\u30B0").option("--json <json>", "\u30A8\u30F3\u30C8\u30EA\u30FC\u5185\u5BB9\u306E JSON \u6587\u5B57\u5217").option("--file <file>", "\u30A8\u30F3\u30C8\u30EA\u30FC\u5185\u5BB9 JSON \u30D5\u30A1\u30A4\u30EB\u306E\u30D1\u30B9").action(createDataEntry);
|
|
3927
|
+
program.command("list-data-entries").description("\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u3054\u3068\u306E\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u4E00\u89A7\u3092\u8868\u793A").requiredOption("--type-slug <slug>", "\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u30B9\u30E9\u30C3\u30B0").option("--sort-by <field>", "\u4E26\u3073\u66FF\u3048\u5BFE\u8C61\u30D5\u30A3\u30FC\u30EB\u30C9").option("--sort-order <order>", "\u4E26\u3073\u9806 (asc \u307E\u305F\u306F desc)").option("--limit <number>", "\u53D6\u5F97\u4EF6\u6570\u306E\u4E0A\u9650").option("--offset <number>", "\u30B9\u30AD\u30C3\u30D7\u4EF6\u6570").option("--status <status>", "\u30B9\u30C6\u30FC\u30BF\u30B9\u3067\u7D5E\u308A\u8FBC\u307F\uFF08draft \u307E\u305F\u306F published\uFF09").action(listDataEntries);
|
|
3928
|
+
program.command("get-data-entry").description("\u5358\u4E00\u306E\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3092\u53D6\u5F97").requiredOption("--type-slug <slug>", "\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u30B9\u30E9\u30C3\u30B0").requiredOption("--id <id>", "\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC ID").action(getDataEntry);
|
|
3929
|
+
program.command("update-data-entry").description("\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3092\u66F4\u65B0").requiredOption("--type-slug <slug>", "\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u30B9\u30E9\u30C3\u30B0").requiredOption("--id <id>", "\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC ID").option("--json <json>", "\u66F4\u65B0\u5185\u5BB9\u306E JSON \u6587\u5B57\u5217").option("--file <file>", "\u66F4\u65B0\u5185\u5BB9 JSON \u30D5\u30A1\u30A4\u30EB\u306E\u30D1\u30B9").action(updateDataEntry);
|
|
3930
|
+
program.command("delete-data-entry").description("\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u3092\u524A\u9664").requiredOption("--type-slug <slug>", "\u30C7\u30FC\u30BF\u30BF\u30A4\u30D7\u306E\u30B9\u30E9\u30C3\u30B0").requiredOption("--id <id>", "\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC ID").option("--force", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(deleteDataEntry);
|
|
3931
|
+
program.command("create-content").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u4F5C\u6210").option("--collection <slug>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306E\u30B9\u30E9\u30C3\u30B0").option("--json <json>", "\u30B3\u30F3\u30C6\u30F3\u30C4\u5B9A\u7FA9\u306E JSON \u6587\u5B57\u5217\uFF08\u63A8\u5968\uFF09").option("--file <file>", "\u30B3\u30F3\u30C6\u30F3\u30C4\u5B9A\u7FA9 JSON \u30D5\u30A1\u30A4\u30EB\u306E\u30D1\u30B9").option("--title <title>", "\u30B3\u30F3\u30C6\u30F3\u30C4\u30BF\u30A4\u30C8\u30EB").option("--slug <slug>", "\u30B3\u30F3\u30C6\u30F3\u30C4\u30B9\u30E9\u30C3\u30B0").option("--description <description>", "\u30B3\u30F3\u30C6\u30F3\u30C4\u8AAC\u660E").option("--mdx <mdx>", "\u30B3\u30F3\u30C6\u30F3\u30C4\u306E MDX \u672C\u6587").action(createContent);
|
|
3932
|
+
program.command("request-review-content").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u30EC\u30D3\u30E5\u30FC\u4F9D\u983C\u306B\u3059\u308B").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").action(requestReviewContent);
|
|
3933
|
+
program.command("publish-content").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u516C\u958B").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").action(publishContent);
|
|
3934
|
+
program.command("get-content-references").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u53C2\u7167\u60C5\u5831\u3092\u53D6\u5F97").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").action(getContentReferences);
|
|
3935
|
+
program.command("set-content-references").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u53C2\u7167\u60C5\u5831\u3092\u66F4\u65B0").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").option("--json <json>", "\u53C2\u7167\u60C5\u5831\u306E JSON \u6587\u5B57\u5217").option("--file <file>", "\u53C2\u7167\u60C5\u5831 JSON \u30D5\u30A1\u30A4\u30EB\u306E\u30D1\u30B9").action(setContentReferences);
|
|
3403
3936
|
program.parse();
|