cmx-sdk 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-EZMBZWH7.js → chunk-Y3S3K6M3.js} +73 -28
- package/dist/cli.js +487 -89
- package/dist/index.d.ts +341 -1
- package/dist/index.js.map +1 -1
- package/dist/{interactive-menu-FYVOQSTL.js → interactive-menu-5PRQIESI.js} +1 -1
- package/dist/{update-sdk-KJZ6VB4M.js → update-sdk-ZXMWQF3I.js} +2 -1
- package/package.json +1 -2
- package/templates/AGENTS.md +0 -173
- package/templates/CLAUDE.md +0 -28
- package/templates/claude/commands/check.md +0 -64
- package/templates/claude/commands/next-action.md +0 -66
- package/templates/claude/skills/cmx-cache/SKILL.md +0 -50
- package/templates/claude/skills/cmx-cache/references/cache-patterns.md +0 -153
- package/templates/claude/skills/cmx-component/SKILL.md +0 -108
- package/templates/claude/skills/cmx-component/references/component-schema.md +0 -123
- package/templates/claude/skills/cmx-content/SKILL.md +0 -158
- package/templates/claude/skills/cmx-content/references/migration-patterns.md +0 -120
- package/templates/claude/skills/cmx-content/references/seed-patterns.md +0 -146
- package/templates/claude/skills/cmx-dev/SKILL.md +0 -266
- package/templates/claude/skills/cmx-dev/references/api-patterns.md +0 -220
- package/templates/claude/skills/cmx-dev/references/cli-reference.md +0 -54
- package/templates/claude/skills/cmx-form/SKILL.md +0 -103
- package/templates/claude/skills/cmx-form/references/form-template.md +0 -152
- package/templates/claude/skills/cmx-migrate/SKILL.md +0 -501
- package/templates/claude/skills/cmx-migrate/references/analysis-guide.md +0 -127
- package/templates/claude/skills/cmx-migrate/references/html-to-mdx.md +0 -99
- package/templates/claude/skills/cmx-migrate/references/intermediate-format.md +0 -196
- package/templates/claude/skills/cmx-migrate/references/tool-setup.md +0 -150
- package/templates/claude/skills/cmx-schema/SKILL.md +0 -159
- package/templates/claude/skills/cmx-schema/references/field-types.md +0 -164
- package/templates/claude/skills/cmx-schema/references/migration-scenarios.md +0 -44
- package/templates/claude/skills/cmx-seo/SKILL.md +0 -54
- package/templates/claude/skills/cmx-seo/references/seo-patterns.md +0 -216
- package/templates/claude/skills/cmx-style/SKILL.md +0 -48
- package/templates/claude/skills/cmx-style/references/style-patterns.md +0 -114
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-FPQYL5GE.js";
|
|
8
8
|
import {
|
|
9
9
|
updateSdk
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-Y3S3K6M3.js";
|
|
11
11
|
import "./chunk-NZQ6SBFS.js";
|
|
12
12
|
import "./chunk-EDXXR5BE.js";
|
|
13
13
|
import "./chunk-IIQLQIDP.js";
|
|
@@ -321,12 +321,19 @@ var postManageDataTypeSlug = async (typeSlug, sdkCreateEntryRequest, options) =>
|
|
|
321
321
|
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
322
322
|
return { data, status: res.status, headers: res.headers };
|
|
323
323
|
};
|
|
324
|
-
var getGetManageDataTypeSlugIdUrl = (typeSlug, id) => {
|
|
325
|
-
|
|
324
|
+
var getGetManageDataTypeSlugIdUrl = (typeSlug, id, params) => {
|
|
325
|
+
const normalizedParams = new URLSearchParams();
|
|
326
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
327
|
+
if (value !== void 0) {
|
|
328
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
const stringifiedParams = normalizedParams.toString();
|
|
332
|
+
return stringifiedParams.length > 0 ? `/api/v1/sdk/manage/data/${typeSlug}/${id}?${stringifiedParams}` : `/api/v1/sdk/manage/data/${typeSlug}/${id}`;
|
|
326
333
|
};
|
|
327
|
-
var getManageDataTypeSlugId = async (typeSlug, id, options) => {
|
|
334
|
+
var getManageDataTypeSlugId = async (typeSlug, id, params, options) => {
|
|
328
335
|
const res = await fetch(
|
|
329
|
-
getGetManageDataTypeSlugIdUrl(typeSlug, id),
|
|
336
|
+
getGetManageDataTypeSlugIdUrl(typeSlug, id, params),
|
|
330
337
|
{
|
|
331
338
|
...options,
|
|
332
339
|
method: "GET"
|
|
@@ -377,6 +384,21 @@ var deleteManageDataTypeSlugId = async (typeSlug, id, params, options) => {
|
|
|
377
384
|
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
378
385
|
return { data, status: res.status, headers: res.headers };
|
|
379
386
|
};
|
|
387
|
+
var getGetManageDataTypeSlugIdDeletionImpactUrl = (typeSlug, id) => {
|
|
388
|
+
return `/api/v1/sdk/manage/data/${typeSlug}/${id}/deletion-impact`;
|
|
389
|
+
};
|
|
390
|
+
var getManageDataTypeSlugIdDeletionImpact = async (typeSlug, id, options) => {
|
|
391
|
+
const res = await fetch(
|
|
392
|
+
getGetManageDataTypeSlugIdDeletionImpactUrl(typeSlug, id),
|
|
393
|
+
{
|
|
394
|
+
...options,
|
|
395
|
+
method: "GET"
|
|
396
|
+
}
|
|
397
|
+
);
|
|
398
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
399
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
400
|
+
return { data, status: res.status, headers: res.headers };
|
|
401
|
+
};
|
|
380
402
|
var getGetManageComponentsUrl = () => {
|
|
381
403
|
return `/api/v1/sdk/manage/components`;
|
|
382
404
|
};
|
|
@@ -588,6 +610,28 @@ var postManageContents = async (createContentRequest, options) => {
|
|
|
588
610
|
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
589
611
|
return { data, status: res.status, headers: res.headers };
|
|
590
612
|
};
|
|
613
|
+
var getGetManageContentsUrl = (params) => {
|
|
614
|
+
const normalizedParams = new URLSearchParams();
|
|
615
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
616
|
+
if (value !== void 0) {
|
|
617
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
const stringifiedParams = normalizedParams.toString();
|
|
621
|
+
return stringifiedParams.length > 0 ? `/api/v1/sdk/manage/contents?${stringifiedParams}` : `/api/v1/sdk/manage/contents`;
|
|
622
|
+
};
|
|
623
|
+
var getManageContents = async (params, options) => {
|
|
624
|
+
const res = await fetch(
|
|
625
|
+
getGetManageContentsUrl(params),
|
|
626
|
+
{
|
|
627
|
+
...options,
|
|
628
|
+
method: "GET"
|
|
629
|
+
}
|
|
630
|
+
);
|
|
631
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
632
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
633
|
+
return { data, status: res.status, headers: res.headers };
|
|
634
|
+
};
|
|
591
635
|
var getPostManageContentsIdRequestReviewUrl = (id) => {
|
|
592
636
|
return `/api/v1/sdk/manage/contents/${id}/request-review`;
|
|
593
637
|
};
|
|
@@ -652,6 +696,103 @@ var putManageContentsIdReferences = async (id, sdkSetContentReferencesRequest, o
|
|
|
652
696
|
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
653
697
|
return { data, status: res.status, headers: res.headers };
|
|
654
698
|
};
|
|
699
|
+
var getGetManageContentsIdUrl = (id, params) => {
|
|
700
|
+
const normalizedParams = new URLSearchParams();
|
|
701
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
702
|
+
if (value !== void 0) {
|
|
703
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
const stringifiedParams = normalizedParams.toString();
|
|
707
|
+
return stringifiedParams.length > 0 ? `/api/v1/sdk/manage/contents/${id}?${stringifiedParams}` : `/api/v1/sdk/manage/contents/${id}`;
|
|
708
|
+
};
|
|
709
|
+
var getManageContentsId = async (id, params, options) => {
|
|
710
|
+
const res = await fetch(
|
|
711
|
+
getGetManageContentsIdUrl(id, params),
|
|
712
|
+
{
|
|
713
|
+
...options,
|
|
714
|
+
method: "GET"
|
|
715
|
+
}
|
|
716
|
+
);
|
|
717
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
718
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
719
|
+
return { data, status: res.status, headers: res.headers };
|
|
720
|
+
};
|
|
721
|
+
var getPutManageContentsIdUrl = (id) => {
|
|
722
|
+
return `/api/v1/sdk/manage/contents/${id}`;
|
|
723
|
+
};
|
|
724
|
+
var putManageContentsId = async (id, updateContentRequest, options) => {
|
|
725
|
+
const res = await fetch(
|
|
726
|
+
getPutManageContentsIdUrl(id),
|
|
727
|
+
{
|
|
728
|
+
...options,
|
|
729
|
+
method: "PUT",
|
|
730
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
731
|
+
body: JSON.stringify(
|
|
732
|
+
updateContentRequest
|
|
733
|
+
)
|
|
734
|
+
}
|
|
735
|
+
);
|
|
736
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
737
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
738
|
+
return { data, status: res.status, headers: res.headers };
|
|
739
|
+
};
|
|
740
|
+
var getDeleteManageContentsIdUrl = (id, params) => {
|
|
741
|
+
const normalizedParams = new URLSearchParams();
|
|
742
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
743
|
+
if (value !== void 0) {
|
|
744
|
+
normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
const stringifiedParams = normalizedParams.toString();
|
|
748
|
+
return stringifiedParams.length > 0 ? `/api/v1/sdk/manage/contents/${id}?${stringifiedParams}` : `/api/v1/sdk/manage/contents/${id}`;
|
|
749
|
+
};
|
|
750
|
+
var deleteManageContentsId = async (id, params, options) => {
|
|
751
|
+
const res = await fetch(
|
|
752
|
+
getDeleteManageContentsIdUrl(id, params),
|
|
753
|
+
{
|
|
754
|
+
...options,
|
|
755
|
+
method: "DELETE"
|
|
756
|
+
}
|
|
757
|
+
);
|
|
758
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
759
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
760
|
+
return { data, status: res.status, headers: res.headers };
|
|
761
|
+
};
|
|
762
|
+
var getGetManageContentsIdValidateUrl = (id) => {
|
|
763
|
+
return `/api/v1/sdk/manage/contents/${id}/validate`;
|
|
764
|
+
};
|
|
765
|
+
var getManageContentsIdValidate = async (id, options) => {
|
|
766
|
+
const res = await fetch(
|
|
767
|
+
getGetManageContentsIdValidateUrl(id),
|
|
768
|
+
{
|
|
769
|
+
...options,
|
|
770
|
+
method: "GET"
|
|
771
|
+
}
|
|
772
|
+
);
|
|
773
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
774
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
775
|
+
return { data, status: res.status, headers: res.headers };
|
|
776
|
+
};
|
|
777
|
+
var getPutManageDocsTypeUrl = (type) => {
|
|
778
|
+
return `/api/v1/sdk/manage/docs/${type}`;
|
|
779
|
+
};
|
|
780
|
+
var putManageDocsType = async (type, sdkUpsertDocBody, options) => {
|
|
781
|
+
const res = await fetch(
|
|
782
|
+
getPutManageDocsTypeUrl(type),
|
|
783
|
+
{
|
|
784
|
+
...options,
|
|
785
|
+
method: "PUT",
|
|
786
|
+
headers: { "Content-Type": "application/json", ...options?.headers },
|
|
787
|
+
body: JSON.stringify(
|
|
788
|
+
sdkUpsertDocBody
|
|
789
|
+
)
|
|
790
|
+
}
|
|
791
|
+
);
|
|
792
|
+
const body = [204, 205, 304].includes(res.status) ? null : await res.text();
|
|
793
|
+
const data = body ? JSON.parse(body, dateReviver) : {};
|
|
794
|
+
return { data, status: res.status, headers: res.headers };
|
|
795
|
+
};
|
|
655
796
|
|
|
656
797
|
// src/commands/list-collections.ts
|
|
657
798
|
async function listCollections() {
|
|
@@ -1261,9 +1402,46 @@ async function syncComponents() {
|
|
|
1261
1402
|
if (result.deleted) console.log(` \u524A\u9664: ${result.deleted}`);
|
|
1262
1403
|
}
|
|
1263
1404
|
|
|
1405
|
+
// src/commands/sync-docs.ts
|
|
1406
|
+
import { readFileSync as readFileSync3, existsSync as existsSync2 } from "fs";
|
|
1407
|
+
import { join as join2 } from "path";
|
|
1408
|
+
var DOC_FILES = [
|
|
1409
|
+
{ type: "style_guide", file: "cmx/style-guide.md", label: "\u30B9\u30BF\u30A4\u30EB\u30AC\u30A4\u30C9" }
|
|
1410
|
+
];
|
|
1411
|
+
async function syncDocs() {
|
|
1412
|
+
ensureApiCredentials();
|
|
1413
|
+
const results = [];
|
|
1414
|
+
try {
|
|
1415
|
+
for (const { type, file, label } of DOC_FILES) {
|
|
1416
|
+
const filePath = join2(process.cwd(), file);
|
|
1417
|
+
if (!existsSync2(filePath)) {
|
|
1418
|
+
console.log(` ${label} (${file}): \u30D5\u30A1\u30A4\u30EB\u304C\u5B58\u5728\u3057\u306A\u3044\u305F\u3081\u30B9\u30AD\u30C3\u30D7`);
|
|
1419
|
+
results.push({ type, label, status: "skipped" });
|
|
1420
|
+
continue;
|
|
1421
|
+
}
|
|
1422
|
+
const markdown = readFileSync3(filePath, "utf-8");
|
|
1423
|
+
console.log(` ${label} \u3092\u540C\u671F\u3057\u3066\u3044\u307E\u3059...`);
|
|
1424
|
+
assertSdkSuccess(await putManageDocsType(type, { markdown }));
|
|
1425
|
+
results.push({ type, label, status: "synced" });
|
|
1426
|
+
}
|
|
1427
|
+
} catch (error) {
|
|
1428
|
+
console.error("\u2717 \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u540C\u671F\u306B\u5931\u6557\u3057\u307E\u3057\u305F:");
|
|
1429
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
1430
|
+
process.exit(1);
|
|
1431
|
+
}
|
|
1432
|
+
const synced = results.filter((r) => r.status === "synced");
|
|
1433
|
+
const skipped = results.filter((r) => r.status === "skipped");
|
|
1434
|
+
if (synced.length > 0) {
|
|
1435
|
+
console.log(`\u5B8C\u4E86: ${synced.map((r) => r.label).join(", ")} \u3092\u540C\u671F\u3057\u307E\u3057\u305F`);
|
|
1436
|
+
}
|
|
1437
|
+
if (skipped.length > 0) {
|
|
1438
|
+
console.log(`\u30B9\u30AD\u30C3\u30D7: ${skipped.map((r) => r.label).join(", ")}`);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1264
1442
|
// src/codegen/generator.ts
|
|
1265
1443
|
import { mkdir, writeFile, rm } from "fs/promises";
|
|
1266
|
-
import { join as
|
|
1444
|
+
import { join as join3 } from "path";
|
|
1267
1445
|
|
|
1268
1446
|
// src/codegen/fetch-schema.ts
|
|
1269
1447
|
async function fetchSchema(apiUrl, apiKey) {
|
|
@@ -1620,7 +1798,7 @@ async function generate(options) {
|
|
|
1620
1798
|
const collectionSlugs = [];
|
|
1621
1799
|
const formSlugs = [];
|
|
1622
1800
|
if (schema.dataTypes.length > 0) {
|
|
1623
|
-
const dataTypesDir =
|
|
1801
|
+
const dataTypesDir = join3(outputDir, "data-types");
|
|
1624
1802
|
await mkdir(dataTypesDir, { recursive: true });
|
|
1625
1803
|
const nameTracker = createNameTracker();
|
|
1626
1804
|
for (const dt of schema.dataTypes) {
|
|
@@ -1631,15 +1809,15 @@ async function generate(options) {
|
|
|
1631
1809
|
}
|
|
1632
1810
|
const fileName = nameTracker(safeSlug);
|
|
1633
1811
|
const content = generateDataTypeFile(dt);
|
|
1634
|
-
await writeFile(
|
|
1812
|
+
await writeFile(join3(dataTypesDir, `${fileName}.ts`), content, "utf-8");
|
|
1635
1813
|
dataTypeSlugs.push(fileName);
|
|
1636
1814
|
console.log(` \u751F\u6210: data-types/${fileName}.ts (${dt.name})`);
|
|
1637
1815
|
}
|
|
1638
1816
|
const indexContent = generateDataTypesIndex(dataTypeSlugs);
|
|
1639
|
-
await writeFile(
|
|
1817
|
+
await writeFile(join3(dataTypesDir, "index.ts"), indexContent, "utf-8");
|
|
1640
1818
|
}
|
|
1641
1819
|
if (schema.collections.length > 0) {
|
|
1642
|
-
const collectionsDir =
|
|
1820
|
+
const collectionsDir = join3(outputDir, "collections");
|
|
1643
1821
|
await mkdir(collectionsDir, { recursive: true });
|
|
1644
1822
|
const nameTracker = createNameTracker();
|
|
1645
1823
|
for (const col of schema.collections) {
|
|
@@ -1650,15 +1828,15 @@ async function generate(options) {
|
|
|
1650
1828
|
}
|
|
1651
1829
|
const fileName = nameTracker(safeSlug);
|
|
1652
1830
|
const content = generateCollectionFile(col);
|
|
1653
|
-
await writeFile(
|
|
1831
|
+
await writeFile(join3(collectionsDir, `${fileName}.ts`), content, "utf-8");
|
|
1654
1832
|
collectionSlugs.push(fileName);
|
|
1655
1833
|
console.log(` \u751F\u6210: collections/${fileName}.ts (${col.name})`);
|
|
1656
1834
|
}
|
|
1657
1835
|
const indexContent = generateCollectionsIndex(collectionSlugs);
|
|
1658
|
-
await writeFile(
|
|
1836
|
+
await writeFile(join3(collectionsDir, "index.ts"), indexContent, "utf-8");
|
|
1659
1837
|
}
|
|
1660
1838
|
if (forms.length > 0) {
|
|
1661
|
-
const formsDir =
|
|
1839
|
+
const formsDir = join3(outputDir, "forms");
|
|
1662
1840
|
await mkdir(formsDir, { recursive: true });
|
|
1663
1841
|
const nameTracker = createNameTracker();
|
|
1664
1842
|
for (const form of forms) {
|
|
@@ -1669,19 +1847,19 @@ async function generate(options) {
|
|
|
1669
1847
|
}
|
|
1670
1848
|
const fileName = nameTracker(safeSlug);
|
|
1671
1849
|
const content = generateFormFile(form);
|
|
1672
|
-
await writeFile(
|
|
1850
|
+
await writeFile(join3(formsDir, `${fileName}.ts`), content, "utf-8");
|
|
1673
1851
|
formSlugs.push(fileName);
|
|
1674
1852
|
console.log(` \u751F\u6210: forms/${fileName}.ts (${form.name})`);
|
|
1675
1853
|
}
|
|
1676
1854
|
const indexContent = generateFormsIndex(formSlugs);
|
|
1677
|
-
await writeFile(
|
|
1855
|
+
await writeFile(join3(formsDir, "index.ts"), indexContent, "utf-8");
|
|
1678
1856
|
}
|
|
1679
1857
|
const rootIndex = generateRootIndex(
|
|
1680
1858
|
dataTypeSlugs.length > 0,
|
|
1681
1859
|
collectionSlugs.length > 0,
|
|
1682
1860
|
formSlugs.length > 0
|
|
1683
1861
|
);
|
|
1684
|
-
await writeFile(
|
|
1862
|
+
await writeFile(join3(outputDir, "index.ts"), rootIndex, "utf-8");
|
|
1685
1863
|
console.log(`
|
|
1686
1864
|
\u751F\u6210\u5B8C\u4E86: ${outputDir}`);
|
|
1687
1865
|
}
|
|
@@ -1868,9 +2046,9 @@ async function linkCollectionDataType(opts) {
|
|
|
1868
2046
|
}
|
|
1869
2047
|
|
|
1870
2048
|
// src/codegen/scaffolder.ts
|
|
1871
|
-
import { existsSync as
|
|
2049
|
+
import { existsSync as existsSync3 } from "fs";
|
|
1872
2050
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
1873
|
-
import { dirname, join as
|
|
2051
|
+
import { dirname, join as join4, resolve } from "path";
|
|
1874
2052
|
|
|
1875
2053
|
// src/codegen/scaffold-collection.ts
|
|
1876
2054
|
function scaffoldCollectionListPage(collection) {
|
|
@@ -2539,7 +2717,7 @@ async function writeScaffoldFile(filePath, content, result, options) {
|
|
|
2539
2717
|
`\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`
|
|
2540
2718
|
);
|
|
2541
2719
|
}
|
|
2542
|
-
if (!options.force &&
|
|
2720
|
+
if (!options.force && existsSync3(filePath)) {
|
|
2543
2721
|
result.skipped.push(filePath);
|
|
2544
2722
|
return;
|
|
2545
2723
|
}
|
|
@@ -2611,12 +2789,12 @@ async function scaffold(options) {
|
|
|
2611
2789
|
const safeSlug = sanitizeIdentifier(col.slug);
|
|
2612
2790
|
if (!safeSlug) continue;
|
|
2613
2791
|
if (template === "legacy") {
|
|
2614
|
-
const listPath =
|
|
2792
|
+
const listPath = join4(appDir, safeSlug, "page.tsx");
|
|
2615
2793
|
await writeScaffoldFile(listPath, scaffoldCollectionListPage(col), result, { dryRun, force, baseDir: appDir });
|
|
2616
|
-
const detailPath =
|
|
2794
|
+
const detailPath = join4(appDir, safeSlug, "[slug]", "page.tsx");
|
|
2617
2795
|
await writeScaffoldFile(detailPath, scaffoldCollectionDetailPage(col), result, { dryRun, force, baseDir: appDir });
|
|
2618
2796
|
} else {
|
|
2619
|
-
const listRoutePath =
|
|
2797
|
+
const listRoutePath = join4(appDir, safeSlug, "page.tsx");
|
|
2620
2798
|
await writeScaffoldFile(
|
|
2621
2799
|
listRoutePath,
|
|
2622
2800
|
scaffoldLayeredCollectionListRoute(col, featureImportBase ?? "@/features"),
|
|
@@ -2627,7 +2805,7 @@ async function scaffold(options) {
|
|
|
2627
2805
|
baseDir: appDir
|
|
2628
2806
|
}
|
|
2629
2807
|
);
|
|
2630
|
-
const detailRoutePath =
|
|
2808
|
+
const detailRoutePath = join4(appDir, safeSlug, "[slug]", "page.tsx");
|
|
2631
2809
|
await writeScaffoldFile(
|
|
2632
2810
|
detailRoutePath,
|
|
2633
2811
|
scaffoldLayeredCollectionDetailRoute(col, featureImportBase ?? "@/features"),
|
|
@@ -2638,9 +2816,9 @@ async function scaffold(options) {
|
|
|
2638
2816
|
baseDir: appDir
|
|
2639
2817
|
}
|
|
2640
2818
|
);
|
|
2641
|
-
const listFeatureBase =
|
|
2819
|
+
const listFeatureBase = join4(featuresDir, "collections", safeSlug, "list");
|
|
2642
2820
|
await writeScaffoldFile(
|
|
2643
|
-
|
|
2821
|
+
join4(listFeatureBase, "resolver.ts"),
|
|
2644
2822
|
scaffoldLayeredCollectionListResolver(col),
|
|
2645
2823
|
result,
|
|
2646
2824
|
{
|
|
@@ -2649,19 +2827,19 @@ async function scaffold(options) {
|
|
|
2649
2827
|
baseDir: featuresDir
|
|
2650
2828
|
}
|
|
2651
2829
|
);
|
|
2652
|
-
await writeScaffoldFile(
|
|
2830
|
+
await writeScaffoldFile(join4(listFeatureBase, "meta.ts"), scaffoldLayeredCollectionListMeta(col), result, {
|
|
2653
2831
|
dryRun,
|
|
2654
2832
|
force,
|
|
2655
2833
|
baseDir: featuresDir
|
|
2656
2834
|
});
|
|
2657
|
-
await writeScaffoldFile(
|
|
2835
|
+
await writeScaffoldFile(join4(listFeatureBase, "view.tsx"), scaffoldLayeredCollectionListView(col), result, {
|
|
2658
2836
|
dryRun,
|
|
2659
2837
|
force,
|
|
2660
2838
|
baseDir: featuresDir
|
|
2661
2839
|
});
|
|
2662
|
-
const detailFeatureBase =
|
|
2840
|
+
const detailFeatureBase = join4(featuresDir, "collections", safeSlug, "detail");
|
|
2663
2841
|
await writeScaffoldFile(
|
|
2664
|
-
|
|
2842
|
+
join4(detailFeatureBase, "resolver.ts"),
|
|
2665
2843
|
scaffoldLayeredCollectionDetailResolver(col),
|
|
2666
2844
|
result,
|
|
2667
2845
|
{
|
|
@@ -2670,12 +2848,12 @@ async function scaffold(options) {
|
|
|
2670
2848
|
baseDir: featuresDir
|
|
2671
2849
|
}
|
|
2672
2850
|
);
|
|
2673
|
-
await writeScaffoldFile(
|
|
2851
|
+
await writeScaffoldFile(join4(detailFeatureBase, "meta.ts"), scaffoldLayeredCollectionDetailMeta(col), result, {
|
|
2674
2852
|
dryRun,
|
|
2675
2853
|
force,
|
|
2676
2854
|
baseDir: featuresDir
|
|
2677
2855
|
});
|
|
2678
|
-
await writeScaffoldFile(
|
|
2856
|
+
await writeScaffoldFile(join4(detailFeatureBase, "view.tsx"), scaffoldLayeredCollectionDetailView(col), result, {
|
|
2679
2857
|
dryRun,
|
|
2680
2858
|
force,
|
|
2681
2859
|
baseDir: featuresDir
|
|
@@ -2689,10 +2867,10 @@ async function scaffold(options) {
|
|
|
2689
2867
|
const safeSlug = sanitizeIdentifier(dt.slug);
|
|
2690
2868
|
if (!safeSlug) continue;
|
|
2691
2869
|
if (template === "legacy") {
|
|
2692
|
-
const pagePath =
|
|
2870
|
+
const pagePath = join4(appDir, safeSlug, "page.tsx");
|
|
2693
2871
|
await writeScaffoldFile(pagePath, scaffoldDataTypePage(dt), result, { dryRun, force, baseDir: appDir });
|
|
2694
2872
|
} else {
|
|
2695
|
-
const pagePath =
|
|
2873
|
+
const pagePath = join4(appDir, safeSlug, "page.tsx");
|
|
2696
2874
|
await writeScaffoldFile(
|
|
2697
2875
|
pagePath,
|
|
2698
2876
|
scaffoldLayeredDataTypeRoute(dt, featureImportBase ?? "@/features"),
|
|
@@ -2703,18 +2881,18 @@ async function scaffold(options) {
|
|
|
2703
2881
|
baseDir: appDir
|
|
2704
2882
|
}
|
|
2705
2883
|
);
|
|
2706
|
-
const featureBase =
|
|
2707
|
-
await writeScaffoldFile(
|
|
2884
|
+
const featureBase = join4(featuresDir, "data-types", safeSlug, "list");
|
|
2885
|
+
await writeScaffoldFile(join4(featureBase, "resolver.ts"), scaffoldLayeredDataTypeResolver(dt), result, {
|
|
2708
2886
|
dryRun,
|
|
2709
2887
|
force,
|
|
2710
2888
|
baseDir: featuresDir
|
|
2711
2889
|
});
|
|
2712
|
-
await writeScaffoldFile(
|
|
2890
|
+
await writeScaffoldFile(join4(featureBase, "meta.ts"), scaffoldLayeredDataTypeMeta(dt), result, {
|
|
2713
2891
|
dryRun,
|
|
2714
2892
|
force,
|
|
2715
2893
|
baseDir: featuresDir
|
|
2716
2894
|
});
|
|
2717
|
-
await writeScaffoldFile(
|
|
2895
|
+
await writeScaffoldFile(join4(featureBase, "view.tsx"), scaffoldLayeredDataTypeView(dt), result, {
|
|
2718
2896
|
dryRun,
|
|
2719
2897
|
force,
|
|
2720
2898
|
baseDir: featuresDir
|
|
@@ -2728,39 +2906,39 @@ async function scaffold(options) {
|
|
|
2728
2906
|
const safeSlug = sanitizeIdentifier(form.slug);
|
|
2729
2907
|
if (!safeSlug) continue;
|
|
2730
2908
|
if (template === "legacy") {
|
|
2731
|
-
const pagePath =
|
|
2909
|
+
const pagePath = join4(appDir, safeSlug, "page.tsx");
|
|
2732
2910
|
await writeScaffoldFile(pagePath, scaffoldFormPage(form), result, { dryRun, force, baseDir: appDir });
|
|
2733
|
-
const componentPath =
|
|
2911
|
+
const componentPath = join4(appDir, safeSlug, "_components", `${safeSlug}-form.tsx`);
|
|
2734
2912
|
await writeScaffoldFile(componentPath, scaffoldFormComponent(form), result, {
|
|
2735
2913
|
dryRun,
|
|
2736
2914
|
force,
|
|
2737
2915
|
baseDir: appDir
|
|
2738
2916
|
});
|
|
2739
2917
|
} else {
|
|
2740
|
-
const pagePath =
|
|
2918
|
+
const pagePath = join4(appDir, safeSlug, "page.tsx");
|
|
2741
2919
|
await writeScaffoldFile(
|
|
2742
2920
|
pagePath,
|
|
2743
2921
|
scaffoldLayeredFormRoute(form, featureImportBase ?? "@/features"),
|
|
2744
2922
|
result,
|
|
2745
2923
|
{ dryRun, force, baseDir: appDir }
|
|
2746
2924
|
);
|
|
2747
|
-
const featureBase =
|
|
2748
|
-
await writeScaffoldFile(
|
|
2925
|
+
const featureBase = join4(featuresDir, "forms", safeSlug);
|
|
2926
|
+
await writeScaffoldFile(join4(featureBase, "resolver.ts"), scaffoldLayeredFormResolver(form), result, {
|
|
2749
2927
|
dryRun,
|
|
2750
2928
|
force,
|
|
2751
2929
|
baseDir: featuresDir
|
|
2752
2930
|
});
|
|
2753
|
-
await writeScaffoldFile(
|
|
2931
|
+
await writeScaffoldFile(join4(featureBase, "meta.ts"), scaffoldLayeredFormMeta(form), result, {
|
|
2754
2932
|
dryRun,
|
|
2755
2933
|
force,
|
|
2756
2934
|
baseDir: featuresDir
|
|
2757
2935
|
});
|
|
2758
|
-
await writeScaffoldFile(
|
|
2936
|
+
await writeScaffoldFile(join4(featureBase, "view.tsx"), scaffoldLayeredFormView(form), result, {
|
|
2759
2937
|
dryRun,
|
|
2760
2938
|
force,
|
|
2761
2939
|
baseDir: featuresDir
|
|
2762
2940
|
});
|
|
2763
|
-
await writeScaffoldFile(
|
|
2941
|
+
await writeScaffoldFile(join4(featureBase, "form-view.tsx"), scaffoldLayeredFormClientView(form), result, {
|
|
2764
2942
|
dryRun,
|
|
2765
2943
|
force,
|
|
2766
2944
|
baseDir: featuresDir
|
|
@@ -2769,7 +2947,7 @@ async function scaffold(options) {
|
|
|
2769
2947
|
}
|
|
2770
2948
|
}
|
|
2771
2949
|
if (!filter) {
|
|
2772
|
-
const sitemapPath =
|
|
2950
|
+
const sitemapPath = join4(appDir, "sitemap.ts");
|
|
2773
2951
|
if (schema.collections.length > 0) {
|
|
2774
2952
|
const siteUrl = apiUrl.replace(/\/api\/.*$/, "");
|
|
2775
2953
|
await writeScaffoldFile(sitemapPath, scaffoldSitemap(schema.collections, siteUrl), result, {
|
|
@@ -3056,8 +3234,8 @@ async function deleteDataEntry(options) {
|
|
|
3056
3234
|
}
|
|
3057
3235
|
|
|
3058
3236
|
// src/commands/scaffold-component.ts
|
|
3059
|
-
import { existsSync as
|
|
3060
|
-
import { join as
|
|
3237
|
+
import { existsSync as existsSync4, mkdirSync, readFileSync as readFileSync4, writeFileSync } from "fs";
|
|
3238
|
+
import { join as join5 } from "path";
|
|
3061
3239
|
function toPascalCase(input) {
|
|
3062
3240
|
const cleaned = input.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
3063
3241
|
return cleaned.split(/[-_\s]+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()).join("");
|
|
@@ -3066,18 +3244,18 @@ function toKebabCase(input) {
|
|
|
3066
3244
|
return input.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
|
|
3067
3245
|
}
|
|
3068
3246
|
function ensureDir(path) {
|
|
3069
|
-
if (!
|
|
3247
|
+
if (!existsSync4(path)) {
|
|
3070
3248
|
mkdirSync(path, { recursive: true });
|
|
3071
3249
|
}
|
|
3072
3250
|
}
|
|
3073
3251
|
function ensureExport(indexPath, exportName) {
|
|
3074
3252
|
const exportLine = `export { ${exportName} } from "./${exportName}"
|
|
3075
3253
|
`;
|
|
3076
|
-
if (!
|
|
3254
|
+
if (!existsSync4(indexPath)) {
|
|
3077
3255
|
writeFileSync(indexPath, exportLine, "utf-8");
|
|
3078
3256
|
return;
|
|
3079
3257
|
}
|
|
3080
|
-
const current =
|
|
3258
|
+
const current = readFileSync4(indexPath, "utf-8");
|
|
3081
3259
|
if (current.includes(exportLine.trim())) {
|
|
3082
3260
|
return;
|
|
3083
3261
|
}
|
|
@@ -3091,14 +3269,14 @@ async function scaffoldComponent(options) {
|
|
|
3091
3269
|
process.exit(1);
|
|
3092
3270
|
}
|
|
3093
3271
|
const kebabName = toKebabCase(pascalName);
|
|
3094
|
-
const componentsDir = options.componentsDir ||
|
|
3095
|
-
const definitionsDir = options.definitionsDir ||
|
|
3272
|
+
const componentsDir = options.componentsDir || join5(process.cwd(), "src/components/custom");
|
|
3273
|
+
const definitionsDir = options.definitionsDir || join5(process.cwd(), "cmx/components");
|
|
3096
3274
|
ensureDir(componentsDir);
|
|
3097
3275
|
ensureDir(definitionsDir);
|
|
3098
|
-
const componentPath =
|
|
3099
|
-
const definitionPath =
|
|
3100
|
-
const indexPath =
|
|
3101
|
-
if (!options.force && (
|
|
3276
|
+
const componentPath = join5(componentsDir, `${pascalName}.tsx`);
|
|
3277
|
+
const definitionPath = join5(definitionsDir, `${kebabName}.json`);
|
|
3278
|
+
const indexPath = join5(componentsDir, "index.ts");
|
|
3279
|
+
if (!options.force && (existsSync4(componentPath) || existsSync4(definitionPath))) {
|
|
3102
3280
|
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");
|
|
3103
3281
|
process.exit(1);
|
|
3104
3282
|
}
|
|
@@ -3169,8 +3347,8 @@ export function ${pascalName}({ title, children }: ${pascalName}Props) {
|
|
|
3169
3347
|
}
|
|
3170
3348
|
|
|
3171
3349
|
// src/commands/codegen-check.ts
|
|
3172
|
-
import { existsSync as
|
|
3173
|
-
import { extname, join as
|
|
3350
|
+
import { existsSync as existsSync5, readFileSync as readFileSync5, readdirSync as readdirSync2, statSync } from "fs";
|
|
3351
|
+
import { extname, join as join6, relative, resolve as resolve2 } from "path";
|
|
3174
3352
|
import stripJsonComments from "strip-json-comments";
|
|
3175
3353
|
function stripTrailingCommas(input) {
|
|
3176
3354
|
return input.replace(/,\s*([}\]])/g, "$1");
|
|
@@ -3183,7 +3361,7 @@ function collectFiles(rootDir, extensions) {
|
|
|
3183
3361
|
function walk(dir) {
|
|
3184
3362
|
const entries = readdirSync2(dir);
|
|
3185
3363
|
for (const entry of entries) {
|
|
3186
|
-
const fullPath =
|
|
3364
|
+
const fullPath = join6(dir, entry);
|
|
3187
3365
|
const stat = statSync(fullPath);
|
|
3188
3366
|
if (stat.isDirectory()) {
|
|
3189
3367
|
if (entry === "node_modules" || entry === ".next" || entry === "dist") {
|
|
@@ -3195,7 +3373,7 @@ function collectFiles(rootDir, extensions) {
|
|
|
3195
3373
|
}
|
|
3196
3374
|
}
|
|
3197
3375
|
}
|
|
3198
|
-
if (
|
|
3376
|
+
if (existsSync5(rootDir)) {
|
|
3199
3377
|
walk(rootDir);
|
|
3200
3378
|
}
|
|
3201
3379
|
return files;
|
|
@@ -3215,12 +3393,12 @@ function extractImports(code) {
|
|
|
3215
3393
|
}
|
|
3216
3394
|
function resolveGeneratedImport(outputDirAbs, importPath) {
|
|
3217
3395
|
if (importPath === "@cmx/generated") {
|
|
3218
|
-
return [
|
|
3396
|
+
return [join6(outputDirAbs, "index.ts")];
|
|
3219
3397
|
}
|
|
3220
3398
|
const subPath = importPath.replace(/^@cmx\/generated\//, "");
|
|
3221
3399
|
return [
|
|
3222
|
-
|
|
3223
|
-
|
|
3400
|
+
join6(outputDirAbs, `${subPath}.ts`),
|
|
3401
|
+
join6(outputDirAbs, subPath, "index.ts")
|
|
3224
3402
|
];
|
|
3225
3403
|
}
|
|
3226
3404
|
async function runCodegenCheck(options = {}) {
|
|
@@ -3231,22 +3409,22 @@ async function runCodegenCheck(options = {}) {
|
|
|
3231
3409
|
const errors = [];
|
|
3232
3410
|
const warnings = [];
|
|
3233
3411
|
const checks = [];
|
|
3234
|
-
if (!
|
|
3412
|
+
if (!existsSync5(outputDirAbs)) {
|
|
3235
3413
|
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)}`);
|
|
3236
3414
|
} else {
|
|
3237
3415
|
checks.push(`\u751F\u6210\u30B3\u30FC\u30C9\u306E\u51FA\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3092\u78BA\u8A8D: ${relative(projectRoot, outputDirAbs)}`);
|
|
3238
|
-
const indexPath =
|
|
3239
|
-
if (!
|
|
3416
|
+
const indexPath = join6(outputDirAbs, "index.ts");
|
|
3417
|
+
if (!existsSync5(indexPath)) {
|
|
3240
3418
|
errors.push(`\u751F\u6210\u30B3\u30FC\u30C9\u306E index \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${relative(projectRoot, indexPath)}`);
|
|
3241
3419
|
} else {
|
|
3242
3420
|
checks.push(`\u751F\u6210\u30B3\u30FC\u30C9\u306E index \u3092\u78BA\u8A8D: ${relative(projectRoot, indexPath)}`);
|
|
3243
3421
|
}
|
|
3244
3422
|
}
|
|
3245
|
-
if (!
|
|
3423
|
+
if (!existsSync5(tsconfigAbs)) {
|
|
3246
3424
|
errors.push(`tsconfig \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${relative(projectRoot, tsconfigAbs)}`);
|
|
3247
3425
|
} else {
|
|
3248
3426
|
try {
|
|
3249
|
-
const raw =
|
|
3427
|
+
const raw = readFileSync5(tsconfigAbs, "utf-8");
|
|
3250
3428
|
const parsed = JSON.parse(stripTrailingCommas(stripJsonComments(raw)));
|
|
3251
3429
|
const aliasValues = parsed.compilerOptions?.paths?.["@cmx/*"] ?? [];
|
|
3252
3430
|
if (aliasValues.length === 0) {
|
|
@@ -3272,14 +3450,14 @@ async function runCodegenCheck(options = {}) {
|
|
|
3272
3450
|
errors.push(`tsconfig \u306E\u89E3\u6790\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${error instanceof Error ? error.message : String(error)}`);
|
|
3273
3451
|
}
|
|
3274
3452
|
}
|
|
3275
|
-
if (!
|
|
3453
|
+
if (!existsSync5(srcDirAbs)) {
|
|
3276
3454
|
warnings.push(`\u30BD\u30FC\u30B9\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${relative(projectRoot, srcDirAbs)}`);
|
|
3277
3455
|
} else {
|
|
3278
3456
|
const sourceFiles = collectFiles(srcDirAbs, /* @__PURE__ */ new Set([".ts", ".tsx"]));
|
|
3279
3457
|
const legacyImportHits = [];
|
|
3280
3458
|
const generatedImportHits = [];
|
|
3281
3459
|
for (const sourceFile of sourceFiles) {
|
|
3282
|
-
const code =
|
|
3460
|
+
const code = readFileSync5(sourceFile, "utf-8");
|
|
3283
3461
|
const imports = extractImports(code);
|
|
3284
3462
|
for (const importPath of imports) {
|
|
3285
3463
|
if (importPath.startsWith("@/cmx/generated")) {
|
|
@@ -3289,7 +3467,7 @@ async function runCodegenCheck(options = {}) {
|
|
|
3289
3467
|
generatedImportHits.push(`${relative(projectRoot, sourceFile)} -> ${importPath}`);
|
|
3290
3468
|
const candidates = resolveGeneratedImport(outputDirAbs, importPath);
|
|
3291
3469
|
for (const candidate of candidates) {
|
|
3292
|
-
if (
|
|
3470
|
+
if (existsSync5(candidate)) {
|
|
3293
3471
|
break;
|
|
3294
3472
|
}
|
|
3295
3473
|
const isLast = candidate === candidates.at(-1);
|
|
@@ -3345,8 +3523,8 @@ Codegen \u30C1\u30A7\u30C3\u30AF\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${pr
|
|
|
3345
3523
|
}
|
|
3346
3524
|
|
|
3347
3525
|
// src/commands/mdx-validate.ts
|
|
3348
|
-
import { existsSync as
|
|
3349
|
-
import { extname as extname2, join as
|
|
3526
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6, readdirSync as readdirSync3, statSync as statSync2 } from "fs";
|
|
3527
|
+
import { extname as extname2, join as join7, relative as relative2, resolve as resolve3 } from "path";
|
|
3350
3528
|
|
|
3351
3529
|
// src/mdx/validator.ts
|
|
3352
3530
|
import { compile } from "@mdx-js/mdx";
|
|
@@ -3606,7 +3784,7 @@ function collectMdxFiles(rootDir) {
|
|
|
3606
3784
|
function walk(dir) {
|
|
3607
3785
|
const entries = readdirSync3(dir);
|
|
3608
3786
|
for (const entry of entries) {
|
|
3609
|
-
const fullPath =
|
|
3787
|
+
const fullPath = join7(dir, entry);
|
|
3610
3788
|
const stat = statSync2(fullPath);
|
|
3611
3789
|
if (stat.isDirectory()) {
|
|
3612
3790
|
if (entry === "node_modules" || entry === ".git" || entry === ".next" || entry === "dist") {
|
|
@@ -3618,7 +3796,7 @@ function collectMdxFiles(rootDir) {
|
|
|
3618
3796
|
}
|
|
3619
3797
|
}
|
|
3620
3798
|
}
|
|
3621
|
-
if (
|
|
3799
|
+
if (existsSync6(rootDir)) {
|
|
3622
3800
|
walk(rootDir);
|
|
3623
3801
|
}
|
|
3624
3802
|
return files;
|
|
@@ -3629,7 +3807,7 @@ async function mdxValidate(options) {
|
|
|
3629
3807
|
const inputDir = resolve3(projectRoot, options.dir ?? "src");
|
|
3630
3808
|
const targets = [];
|
|
3631
3809
|
if (inputFile) {
|
|
3632
|
-
if (!
|
|
3810
|
+
if (!existsSync6(inputFile)) {
|
|
3633
3811
|
console.error(`\u30A8\u30E9\u30FC: \u30D5\u30A1\u30A4\u30EB\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${options.file}`);
|
|
3634
3812
|
process.exit(1);
|
|
3635
3813
|
}
|
|
@@ -3645,7 +3823,7 @@ async function mdxValidate(options) {
|
|
|
3645
3823
|
let invalidCount = 0;
|
|
3646
3824
|
let warningCount = 0;
|
|
3647
3825
|
for (const filePath of targets) {
|
|
3648
|
-
const mdx =
|
|
3826
|
+
const mdx = readFileSync6(filePath, "utf-8");
|
|
3649
3827
|
const result = await validateMdx(mdx);
|
|
3650
3828
|
const relPath = relative2(projectRoot, filePath);
|
|
3651
3829
|
if (result.valid) {
|
|
@@ -3675,14 +3853,14 @@ async function mdxValidate(options) {
|
|
|
3675
3853
|
}
|
|
3676
3854
|
|
|
3677
3855
|
// src/commands/mdx-doctor.ts
|
|
3678
|
-
import { existsSync as
|
|
3679
|
-
import { basename, extname as extname3, join as
|
|
3856
|
+
import { existsSync as existsSync7, readFileSync as readFileSync7, readdirSync as readdirSync4, statSync as statSync3 } from "fs";
|
|
3857
|
+
import { basename, extname as extname3, join as join8, relative as relative3, resolve as resolve4 } from "path";
|
|
3680
3858
|
function collectFiles2(rootDir, extension) {
|
|
3681
3859
|
const files = [];
|
|
3682
3860
|
function walk(dir) {
|
|
3683
3861
|
const entries = readdirSync4(dir);
|
|
3684
3862
|
for (const entry of entries) {
|
|
3685
|
-
const fullPath =
|
|
3863
|
+
const fullPath = join8(dir, entry);
|
|
3686
3864
|
const stat = statSync3(fullPath);
|
|
3687
3865
|
if (stat.isDirectory()) {
|
|
3688
3866
|
if (entry === "node_modules" || entry === ".git" || entry === ".next" || entry === "dist") {
|
|
@@ -3694,7 +3872,7 @@ function collectFiles2(rootDir, extension) {
|
|
|
3694
3872
|
}
|
|
3695
3873
|
}
|
|
3696
3874
|
}
|
|
3697
|
-
if (
|
|
3875
|
+
if (existsSync7(rootDir)) {
|
|
3698
3876
|
walk(rootDir);
|
|
3699
3877
|
}
|
|
3700
3878
|
return files;
|
|
@@ -3704,7 +3882,7 @@ function parseDefinitionFiles(projectRoot, files) {
|
|
|
3704
3882
|
const errors = [];
|
|
3705
3883
|
for (const file of files) {
|
|
3706
3884
|
try {
|
|
3707
|
-
const raw =
|
|
3885
|
+
const raw = readFileSync7(file, "utf-8");
|
|
3708
3886
|
const parsed = JSON.parse(raw);
|
|
3709
3887
|
if (typeof parsed.name !== "string" || parsed.name.length === 0) {
|
|
3710
3888
|
errors.push(`${relative3(projectRoot, file)}: \u6587\u5B57\u5217\u306E 'name' \u304C\u5FC5\u8981\u3067\u3059`);
|
|
@@ -3738,13 +3916,13 @@ async function mdxDoctor(options = {}) {
|
|
|
3738
3916
|
const projectRoot = process.cwd();
|
|
3739
3917
|
const definitionsDir = resolve4(projectRoot, options.definitionsDir ?? "cmx/components");
|
|
3740
3918
|
const componentsDir = resolve4(projectRoot, options.componentsDir ?? "src/components/custom");
|
|
3741
|
-
const indexFile = resolve4(projectRoot, options.indexFile ??
|
|
3919
|
+
const indexFile = resolve4(projectRoot, options.indexFile ?? join8(options.componentsDir ?? "src/components/custom", "index.ts"));
|
|
3742
3920
|
const issues = [];
|
|
3743
3921
|
const checks = [];
|
|
3744
|
-
if (!
|
|
3922
|
+
if (!existsSync7(definitionsDir)) {
|
|
3745
3923
|
issues.push(`\u5B9A\u7FA9\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093: ${relative3(projectRoot, definitionsDir)}`);
|
|
3746
3924
|
}
|
|
3747
|
-
if (!
|
|
3925
|
+
if (!existsSync7(componentsDir)) {
|
|
3748
3926
|
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)}`);
|
|
3749
3927
|
}
|
|
3750
3928
|
if (issues.length > 0) {
|
|
@@ -3780,10 +3958,10 @@ async function mdxDoctor(options = {}) {
|
|
|
3780
3958
|
issues.push(`\u5B9F\u88C5\u306F\u3042\u308A\u307E\u3059\u304C\u5B9A\u7FA9\u304C\u3042\u308A\u307E\u305B\u3093: ${implName}.json`);
|
|
3781
3959
|
}
|
|
3782
3960
|
}
|
|
3783
|
-
if (!
|
|
3961
|
+
if (!existsSync7(indexFile)) {
|
|
3784
3962
|
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)}`);
|
|
3785
3963
|
} else {
|
|
3786
|
-
const indexContent =
|
|
3964
|
+
const indexContent = readFileSync7(indexFile, "utf-8");
|
|
3787
3965
|
const exportedNames = collectExportedComponentNames(indexContent);
|
|
3788
3966
|
for (const implName of implementationNames) {
|
|
3789
3967
|
if (!exportedNames.has(implName)) {
|
|
@@ -3807,6 +3985,210 @@ async function mdxDoctor(options = {}) {
|
|
|
3807
3985
|
console.log("\n\u3059\u3079\u3066\u306E\u30C1\u30A7\u30C3\u30AF\u306B\u6210\u529F\u3057\u307E\u3057\u305F");
|
|
3808
3986
|
}
|
|
3809
3987
|
|
|
3988
|
+
// src/commands/list-contents.ts
|
|
3989
|
+
async function listContents(options) {
|
|
3990
|
+
ensureApiCredentials();
|
|
3991
|
+
const params = {
|
|
3992
|
+
...options.status ? { status: options.status } : {},
|
|
3993
|
+
...options.collectionId ? { collectionId: options.collectionId } : {},
|
|
3994
|
+
...options.limit !== void 0 ? { limit: options.limit } : {},
|
|
3995
|
+
...options.offset !== void 0 ? { offset: options.offset } : {},
|
|
3996
|
+
...options.fields ? { fields: options.fields } : {}
|
|
3997
|
+
};
|
|
3998
|
+
console.log("\u30B3\u30F3\u30C6\u30F3\u30C4\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059...");
|
|
3999
|
+
const result = assertSdkSuccess(await getManageContents(params));
|
|
4000
|
+
console.log(`${result.contents.length} \u4EF6\u306E\u30B3\u30F3\u30C6\u30F3\u30C4\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F:`);
|
|
4001
|
+
console.log(JSON.stringify(result, null, 2));
|
|
4002
|
+
}
|
|
4003
|
+
|
|
4004
|
+
// src/commands/get-content.ts
|
|
4005
|
+
async function getContent(options) {
|
|
4006
|
+
ensureApiCredentials();
|
|
4007
|
+
if (!options.id) {
|
|
4008
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4009
|
+
process.exit(1);
|
|
4010
|
+
}
|
|
4011
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u53D6\u5F97\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
4012
|
+
const params = {
|
|
4013
|
+
...options.fields ? { fields: options.fields } : {}
|
|
4014
|
+
};
|
|
4015
|
+
const result = assertSdkSuccess(await getManageContentsId(options.id, params));
|
|
4016
|
+
console.log("\u30B3\u30F3\u30C6\u30F3\u30C4:");
|
|
4017
|
+
console.log(JSON.stringify(result, null, 2));
|
|
4018
|
+
}
|
|
4019
|
+
|
|
4020
|
+
// src/commands/update-content.ts
|
|
4021
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
4022
|
+
async function updateContent(options) {
|
|
4023
|
+
ensureApiCredentials();
|
|
4024
|
+
if (!options.id) {
|
|
4025
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4026
|
+
process.exit(1);
|
|
4027
|
+
}
|
|
4028
|
+
const body = {};
|
|
4029
|
+
if (options.title !== void 0) body.title = options.title;
|
|
4030
|
+
if (options.slug !== void 0) body.slug = options.slug;
|
|
4031
|
+
if (options.description !== void 0) body.description = options.description;
|
|
4032
|
+
if (options.status !== void 0) body.status = options.status;
|
|
4033
|
+
if (options.mdxFile) {
|
|
4034
|
+
try {
|
|
4035
|
+
body.mdx = readFileSync8(options.mdxFile, "utf-8");
|
|
4036
|
+
} catch {
|
|
4037
|
+
console.error(`\u30A8\u30E9\u30FC: MDX\u30D5\u30A1\u30A4\u30EB\u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F: ${options.mdxFile}`);
|
|
4038
|
+
process.exit(1);
|
|
4039
|
+
}
|
|
4040
|
+
} else if (options.mdx !== void 0) {
|
|
4041
|
+
body.mdx = options.mdx;
|
|
4042
|
+
}
|
|
4043
|
+
if (Object.keys(body).length === 0) {
|
|
4044
|
+
console.error("\u30A8\u30E9\u30FC: \u66F4\u65B0\u3059\u308B\u30D5\u30A3\u30FC\u30EB\u30C9\u3092\u5C11\u306A\u304F\u3068\u30821\u3064\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4045
|
+
process.exit(1);
|
|
4046
|
+
}
|
|
4047
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u66F4\u65B0\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
4048
|
+
const result = assertSdkSuccess(await putManageContentsId(options.id, body));
|
|
4049
|
+
if (result.warnings && result.warnings.length > 0) {
|
|
4050
|
+
console.warn(`\u8B66\u544A: ${result.warnings.length} \u4EF6\u306E\u53C2\u7167\u6574\u5408\u6027\u306E\u554F\u984C\u304C\u3042\u308A\u307E\u3059:`);
|
|
4051
|
+
for (const warning of result.warnings) {
|
|
4052
|
+
console.warn(` [${warning.issueType}] ${warning.componentName}.${warning.propName}: ${warning.message}`);
|
|
4053
|
+
}
|
|
4054
|
+
}
|
|
4055
|
+
console.log("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u66F4\u65B0\u3057\u307E\u3057\u305F:");
|
|
4056
|
+
console.log(JSON.stringify(result, null, 2));
|
|
4057
|
+
}
|
|
4058
|
+
|
|
4059
|
+
// src/commands/delete-content.ts
|
|
4060
|
+
async function deleteContent(options) {
|
|
4061
|
+
ensureApiCredentials();
|
|
4062
|
+
if (!options.id) {
|
|
4063
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4064
|
+
process.exit(1);
|
|
4065
|
+
}
|
|
4066
|
+
if (!options.force) {
|
|
4067
|
+
const readline4 = await import("readline");
|
|
4068
|
+
const rl = readline4.createInterface({
|
|
4069
|
+
input: process.stdin,
|
|
4070
|
+
output: process.stdout
|
|
4071
|
+
});
|
|
4072
|
+
const action2 = options.hard ? "\u7269\u7406\u524A\u9664" : "\u30A2\u30FC\u30AB\u30A4\u30D6\uFF08\u8AD6\u7406\u524A\u9664\uFF09";
|
|
4073
|
+
const answer = await new Promise((resolve5) => {
|
|
4074
|
+
rl.question(
|
|
4075
|
+
`\u30B3\u30F3\u30C6\u30F3\u30C4 ${options.id} \u3092${action2}\u3057\u307E\u3059\u304B\uFF1F (yes/no): `,
|
|
4076
|
+
resolve5
|
|
4077
|
+
);
|
|
4078
|
+
});
|
|
4079
|
+
rl.close();
|
|
4080
|
+
if (answer.toLowerCase() !== "yes") {
|
|
4081
|
+
console.log("\u524A\u9664\u3092\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u307E\u3057\u305F\u3002");
|
|
4082
|
+
process.exit(0);
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
4085
|
+
const action = options.hard ? "\u7269\u7406\u524A\u9664\u3057\u3066\u3044\u307E\u3059" : "\u30A2\u30FC\u30AB\u30A4\u30D6\u3057\u3066\u3044\u307E\u3059";
|
|
4086
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u3092${action}: ${options.id}...`);
|
|
4087
|
+
const params = {
|
|
4088
|
+
...options.hard ? { hard: true } : {}
|
|
4089
|
+
};
|
|
4090
|
+
const result = assertSdkSuccess(await deleteManageContentsId(options.id, params));
|
|
4091
|
+
const doneMsg = options.hard ? "\u7269\u7406\u524A\u9664\u3057\u307E\u3057\u305F" : "\u30A2\u30FC\u30AB\u30A4\u30D6\u3057\u307E\u3057\u305F\uFF08\u8AD6\u7406\u524A\u9664\uFF09";
|
|
4092
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u3092${doneMsg}:`);
|
|
4093
|
+
console.log(JSON.stringify(result, null, 2));
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
// src/commands/cancel-review-content.ts
|
|
4097
|
+
async function cancelReviewContent(options) {
|
|
4098
|
+
ensureApiCredentials();
|
|
4099
|
+
if (!options.id) {
|
|
4100
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4101
|
+
process.exit(1);
|
|
4102
|
+
}
|
|
4103
|
+
console.log(`\u30EC\u30D3\u30E5\u30FC\u3092\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u3066\u3044\u307E\u3059\uFF08\u30C9\u30E9\u30D5\u30C8\u306B\u623B\u3057\u307E\u3059\uFF09: ${options.id}...`);
|
|
4104
|
+
const result = assertSdkSuccess(
|
|
4105
|
+
await putManageContentsId(options.id, { status: "draft" })
|
|
4106
|
+
);
|
|
4107
|
+
console.log("\u30EC\u30D3\u30E5\u30FC\u3092\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u307E\u3057\u305F\uFF08\u30C9\u30E9\u30D5\u30C8\u306B\u623B\u3057\u307E\u3057\u305F\uFF09:");
|
|
4108
|
+
console.log(JSON.stringify(result, null, 2));
|
|
4109
|
+
}
|
|
4110
|
+
|
|
4111
|
+
// src/commands/unpublish-content.ts
|
|
4112
|
+
async function unpublishContent(options) {
|
|
4113
|
+
ensureApiCredentials();
|
|
4114
|
+
if (!options.id) {
|
|
4115
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4116
|
+
process.exit(1);
|
|
4117
|
+
}
|
|
4118
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u975E\u516C\u958B\u306B\u3057\u3066\u3044\u307E\u3059\uFF08\u30C9\u30E9\u30D5\u30C8\u306B\u623B\u3057\u307E\u3059\uFF09: ${options.id}...`);
|
|
4119
|
+
const result = assertSdkSuccess(
|
|
4120
|
+
await putManageContentsId(options.id, { status: "draft" })
|
|
4121
|
+
);
|
|
4122
|
+
console.log("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u975E\u516C\u958B\u306B\u3057\u307E\u3057\u305F\uFF08\u30C9\u30E9\u30D5\u30C8\u306B\u623B\u3057\u307E\u3057\u305F\uFF09:");
|
|
4123
|
+
console.log(JSON.stringify(result, null, 2));
|
|
4124
|
+
}
|
|
4125
|
+
|
|
4126
|
+
// src/commands/archive-content.ts
|
|
4127
|
+
async function archiveContent(options) {
|
|
4128
|
+
ensureApiCredentials();
|
|
4129
|
+
if (!options.id) {
|
|
4130
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4131
|
+
process.exit(1);
|
|
4132
|
+
}
|
|
4133
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u30A2\u30FC\u30AB\u30A4\u30D6\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
4134
|
+
const result = assertSdkSuccess(
|
|
4135
|
+
await putManageContentsId(options.id, { status: "archived" })
|
|
4136
|
+
);
|
|
4137
|
+
console.log("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u30A2\u30FC\u30AB\u30A4\u30D6\u3057\u307E\u3057\u305F:");
|
|
4138
|
+
console.log(JSON.stringify(result, null, 2));
|
|
4139
|
+
}
|
|
4140
|
+
|
|
4141
|
+
// src/commands/validate-content.ts
|
|
4142
|
+
async function validateContent(options) {
|
|
4143
|
+
ensureApiCredentials();
|
|
4144
|
+
if (!options.id) {
|
|
4145
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4146
|
+
process.exit(1);
|
|
4147
|
+
}
|
|
4148
|
+
console.log(`\u30B3\u30F3\u30C6\u30F3\u30C4\u306EMDX\u53C2\u7167\u6574\u5408\u6027\u3092\u691C\u8A3C\u3057\u3066\u3044\u307E\u3059: ${options.id}...`);
|
|
4149
|
+
const result = assertSdkSuccess(await getManageContentsIdValidate(options.id));
|
|
4150
|
+
if (result.valid) {
|
|
4151
|
+
console.log("\u2713 \u691C\u8A3C\u6210\u529F: \u53C2\u7167\u6574\u5408\u6027\u306E\u554F\u984C\u306F\u3042\u308A\u307E\u305B\u3093");
|
|
4152
|
+
} else {
|
|
4153
|
+
console.error(`\u2717 \u691C\u8A3C\u5931\u6557: ${result.issues.length} \u4EF6\u306E\u554F\u984C\u304C\u898B\u3064\u304B\u308A\u307E\u3057\u305F:`);
|
|
4154
|
+
for (const issue of result.issues) {
|
|
4155
|
+
console.error(
|
|
4156
|
+
` [${issue.issueType}] ${issue.componentName}.${issue.propName}: ${issue.message}`
|
|
4157
|
+
);
|
|
4158
|
+
}
|
|
4159
|
+
console.log(JSON.stringify(result, null, 2));
|
|
4160
|
+
process.exit(1);
|
|
4161
|
+
}
|
|
4162
|
+
}
|
|
4163
|
+
|
|
4164
|
+
// src/commands/get-data-entry-deletion-impact.ts
|
|
4165
|
+
async function getDataEntryDeletionImpact(options) {
|
|
4166
|
+
ensureApiCredentials();
|
|
4167
|
+
if (!options.typeSlug) {
|
|
4168
|
+
console.error("\u30A8\u30E9\u30FC: --type-slug \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4169
|
+
process.exit(1);
|
|
4170
|
+
}
|
|
4171
|
+
if (!options.id) {
|
|
4172
|
+
console.error("\u30A8\u30E9\u30FC: --id \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044");
|
|
4173
|
+
process.exit(1);
|
|
4174
|
+
}
|
|
4175
|
+
console.log(`\u524A\u9664\u5F71\u97FF\u3092\u8ABF\u3079\u3066\u3044\u307E\u3059: ${options.id} (${options.typeSlug})...`);
|
|
4176
|
+
const result = assertSdkSuccess(
|
|
4177
|
+
await getManageDataTypeSlugIdDeletionImpact(options.typeSlug, options.id)
|
|
4178
|
+
);
|
|
4179
|
+
console.log("\u524A\u9664\u5F71\u97FF\u5206\u6790:");
|
|
4180
|
+
console.log(JSON.stringify(result, null, 2));
|
|
4181
|
+
if (!result.canDelete) {
|
|
4182
|
+
console.warn(
|
|
4183
|
+
`
|
|
4184
|
+
\u26A0 \u3053\u306E\u30A8\u30F3\u30C8\u30EA\u30FC\u306F ${result.publishedReferences} \u4EF6\u306E\u516C\u958B\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u542B\u3080 ${result.totalReferences} \u4EF6\u304B\u3089\u53C2\u7167\u3055\u308C\u3066\u3044\u308B\u305F\u3081\u524A\u9664\u3067\u304D\u307E\u305B\u3093\u3002`
|
|
4185
|
+
);
|
|
4186
|
+
console.warn("\u524A\u9664\u3059\u308B\u5834\u5408\u306F --force \u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002");
|
|
4187
|
+
} else {
|
|
4188
|
+
console.log("\n\u2713 \u3053\u306E\u30A8\u30F3\u30C8\u30EA\u30FC\u306F\u5B89\u5168\u306B\u524A\u9664\u3067\u304D\u307E\u3059\u3002");
|
|
4189
|
+
}
|
|
4190
|
+
}
|
|
4191
|
+
|
|
3810
4192
|
// src/cli.ts
|
|
3811
4193
|
config();
|
|
3812
4194
|
installSdkFetchInterceptor();
|
|
@@ -3822,7 +4204,7 @@ function requireApiCredentials() {
|
|
|
3822
4204
|
return { apiUrl, apiKey };
|
|
3823
4205
|
}
|
|
3824
4206
|
program.action(async () => {
|
|
3825
|
-
const { interactiveMenu } = await import("./interactive-menu-
|
|
4207
|
+
const { interactiveMenu } = await import("./interactive-menu-5PRQIESI.js");
|
|
3826
4208
|
await interactiveMenu();
|
|
3827
4209
|
});
|
|
3828
4210
|
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) => {
|
|
@@ -3844,6 +4226,13 @@ program.command("create-collection").description("\u30B3\u30EC\u30AF\u30B7\u30E7
|
|
|
3844
4226
|
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
4227
|
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
4228
|
program.command("sync-components").description("\u30AB\u30B9\u30BF\u30E0\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5B9A\u7FA9\u3092\u540C\u671F").action(syncComponents);
|
|
4229
|
+
program.command("sync-docs").description("\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\uFF08\u30B9\u30BF\u30A4\u30EB\u30AC\u30A4\u30C9\u7B49\uFF09\u3092\u540C\u671F").action(syncDocs);
|
|
4230
|
+
program.command("sync").description("\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5B9A\u7FA9\u3068\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u307E\u3068\u3081\u3066\u540C\u671F").action(async () => {
|
|
4231
|
+
console.log("[1/2] \u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u5B9A\u7FA9\u3092\u540C\u671F\u3057\u3066\u3044\u307E\u3059...");
|
|
4232
|
+
await syncComponents();
|
|
4233
|
+
console.log("[2/2] \u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u540C\u671F\u3057\u3066\u3044\u307E\u3059...");
|
|
4234
|
+
await syncDocs();
|
|
4235
|
+
});
|
|
3847
4236
|
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
4237
|
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
4238
|
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) => {
|
|
@@ -3933,4 +4322,13 @@ program.command("request-review-content").description("\u30B3\u30F3\u30C6\u30F3\
|
|
|
3933
4322
|
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
4323
|
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
4324
|
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);
|
|
4325
|
+
program.command("list-contents").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u4E00\u89A7\u3092\u8868\u793A").option("--status <status>", "\u30B9\u30C6\u30FC\u30BF\u30B9\u30D5\u30A3\u30EB\u30BF\uFF08plan, draft, review, published, archived\uFF09").option("--collection-id <id>", "\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3ID\u30D5\u30A3\u30EB\u30BF").option("--limit <number>", "\u53D6\u5F97\u4EF6\u6570\uFF08\u6700\u5927100\uFF09").option("--offset <number>", "\u30AA\u30D5\u30BB\u30C3\u30C8").option("--fields <fields>", "\u53D6\u5F97\u3059\u308B\u30D5\u30A3\u30FC\u30EB\u30C9\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09\u4F8B: id,slug,title,status").action(listContents);
|
|
4326
|
+
program.command("get-content").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u53D6\u5F97").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").option("--fields <fields>", "\u53D6\u5F97\u3059\u308B\u30D5\u30A3\u30FC\u30EB\u30C9\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09\u4F8B: id,slug,title,mdx").action(getContent);
|
|
4327
|
+
program.command("update-content").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u66F4\u65B0").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").option("--title <title>", "\u65B0\u3057\u3044\u30BF\u30A4\u30C8\u30EB").option("--slug <slug>", "\u65B0\u3057\u3044\u30B9\u30E9\u30C3\u30B0").option("--description <description>", "\u65B0\u3057\u3044\u8AAC\u660E").option("--mdx <mdx>", "\u65B0\u3057\u3044 MDX \u672C\u6587").option("--mdx-file <file>", "MDX \u3092\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u8AAD\u307F\u8FBC\u3080").option("--status <status>", "\u65B0\u3057\u3044\u30B9\u30C6\u30FC\u30BF\u30B9\uFF08plan, draft, review, archived\uFF09").action(updateContent);
|
|
4328
|
+
program.command("delete-content").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u524A\u9664\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8: \u30A2\u30FC\u30AB\u30A4\u30D6\uFF09").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").option("--hard", "\u7269\u7406\u524A\u9664\uFF08\u30C7\u30D5\u30A9\u30EB\u30C8\u306F\u30A2\u30FC\u30AB\u30A4\u30D6\uFF09").option("--force", "\u78BA\u8A8D\u30D7\u30ED\u30F3\u30D7\u30C8\u3092\u30B9\u30AD\u30C3\u30D7").action(deleteContent);
|
|
4329
|
+
program.command("cancel-review-content").description("\u30EC\u30D3\u30E5\u30FC\u4F9D\u983C\u3092\u30AD\u30E3\u30F3\u30BB\u30EB\u3057\u3066\u30C9\u30E9\u30D5\u30C8\u306B\u623B\u3059").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").action(cancelReviewContent);
|
|
4330
|
+
program.command("unpublish-content").description("\u516C\u958B\u6E08\u307F\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u30C9\u30E9\u30D5\u30C8\u306B\u623B\u3059").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").action(unpublishContent);
|
|
4331
|
+
program.command("archive-content").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u30A2\u30FC\u30AB\u30A4\u30D6").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").action(archiveContent);
|
|
4332
|
+
program.command("validate-content").description("\u30B3\u30F3\u30C6\u30F3\u30C4\u306E MDX \u53C2\u7167\u6574\u5408\u6027\u3092\u691C\u8A3C\uFF08\u554F\u984C\u3042\u308A\u6642\u306F exit code 1\uFF09").requiredOption("--id <id>", "\u30B3\u30F3\u30C6\u30F3\u30C4 ID").action(validateContent);
|
|
4333
|
+
program.command("get-data-entry-deletion-impact").description("\u30C7\u30FC\u30BF\u30A8\u30F3\u30C8\u30EA\u30FC\u524A\u9664\u6642\u306E\u5F71\u97FF\u3092\u78BA\u8A8D").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(getDataEntryDeletionImpact);
|
|
3936
4334
|
program.parse();
|