@cmssy/cli 0.22.4 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/dist/index.js +435 -0
  2. package/package.json +25 -86
  3. package/LICENSE +0 -21
  4. package/README.md +0 -692
  5. package/config.d.ts +0 -3
  6. package/config.js +0 -4
  7. package/dist/cli.d.ts +0 -3
  8. package/dist/cli.d.ts.map +0 -1
  9. package/dist/cli.js +0 -340
  10. package/dist/cli.js.map +0 -1
  11. package/dist/commands/add-source.d.ts +0 -13
  12. package/dist/commands/add-source.d.ts.map +0 -1
  13. package/dist/commands/add-source.js +0 -273
  14. package/dist/commands/add-source.js.map +0 -1
  15. package/dist/commands/build.d.ts +0 -7
  16. package/dist/commands/build.d.ts.map +0 -1
  17. package/dist/commands/build.js +0 -127
  18. package/dist/commands/build.js.map +0 -1
  19. package/dist/commands/codegen.d.ts +0 -7
  20. package/dist/commands/codegen.d.ts.map +0 -1
  21. package/dist/commands/codegen.js +0 -150
  22. package/dist/commands/codegen.js.map +0 -1
  23. package/dist/commands/configure.d.ts +0 -6
  24. package/dist/commands/configure.d.ts.map +0 -1
  25. package/dist/commands/configure.js +0 -39
  26. package/dist/commands/configure.js.map +0 -1
  27. package/dist/commands/create.d.ts +0 -18
  28. package/dist/commands/create.d.ts.map +0 -1
  29. package/dist/commands/create.js +0 -403
  30. package/dist/commands/create.js.map +0 -1
  31. package/dist/commands/dev.d.ts +0 -6
  32. package/dist/commands/dev.d.ts.map +0 -1
  33. package/dist/commands/dev.js +0 -144
  34. package/dist/commands/dev.js.map +0 -1
  35. package/dist/commands/doctor.d.ts +0 -2
  36. package/dist/commands/doctor.d.ts.map +0 -1
  37. package/dist/commands/doctor.js +0 -230
  38. package/dist/commands/doctor.js.map +0 -1
  39. package/dist/commands/init.d.ts +0 -6
  40. package/dist/commands/init.d.ts.map +0 -1
  41. package/dist/commands/init.js +0 -414
  42. package/dist/commands/init.js.map +0 -1
  43. package/dist/commands/lib.d.ts +0 -17
  44. package/dist/commands/lib.d.ts.map +0 -1
  45. package/dist/commands/lib.js +0 -132
  46. package/dist/commands/lib.js.map +0 -1
  47. package/dist/commands/link.d.ts +0 -8
  48. package/dist/commands/link.d.ts.map +0 -1
  49. package/dist/commands/link.js +0 -116
  50. package/dist/commands/link.js.map +0 -1
  51. package/dist/commands/migrate.d.ts +0 -2
  52. package/dist/commands/migrate.d.ts.map +0 -1
  53. package/dist/commands/migrate.js +0 -231
  54. package/dist/commands/migrate.js.map +0 -1
  55. package/dist/commands/package.d.ts +0 -14
  56. package/dist/commands/package.d.ts.map +0 -1
  57. package/dist/commands/package.js +0 -137
  58. package/dist/commands/package.js.map +0 -1
  59. package/dist/commands/publish-block-buildtime.d.ts +0 -8
  60. package/dist/commands/publish-block-buildtime.d.ts.map +0 -1
  61. package/dist/commands/publish-block-buildtime.js +0 -290
  62. package/dist/commands/publish-block-buildtime.js.map +0 -1
  63. package/dist/commands/publish-template.d.ts +0 -22
  64. package/dist/commands/publish-template.d.ts.map +0 -1
  65. package/dist/commands/publish-template.js +0 -345
  66. package/dist/commands/publish-template.js.map +0 -1
  67. package/dist/commands/publish.d.ts +0 -15
  68. package/dist/commands/publish.d.ts.map +0 -1
  69. package/dist/commands/publish.js +0 -1003
  70. package/dist/commands/publish.js.map +0 -1
  71. package/dist/commands/skills.d.ts +0 -11
  72. package/dist/commands/skills.d.ts.map +0 -1
  73. package/dist/commands/skills.js +0 -178
  74. package/dist/commands/skills.js.map +0 -1
  75. package/dist/commands/sync.d.ts +0 -6
  76. package/dist/commands/sync.d.ts.map +0 -1
  77. package/dist/commands/sync.js +0 -208
  78. package/dist/commands/sync.js.map +0 -1
  79. package/dist/commands/test.d.ts +0 -8
  80. package/dist/commands/test.d.ts.map +0 -1
  81. package/dist/commands/test.js +0 -60
  82. package/dist/commands/test.js.map +0 -1
  83. package/dist/commands/upload.d.ts +0 -11
  84. package/dist/commands/upload.d.ts.map +0 -1
  85. package/dist/commands/upload.js +0 -128
  86. package/dist/commands/upload.js.map +0 -1
  87. package/dist/commands/workspaces.d.ts +0 -2
  88. package/dist/commands/workspaces.d.ts.map +0 -1
  89. package/dist/commands/workspaces.js +0 -62
  90. package/dist/commands/workspaces.js.map +0 -1
  91. package/dist/dev-ui/app.js +0 -1284
  92. package/dist/dev-ui/index.html +0 -1511
  93. package/dist/dev-ui-react/App.tsx +0 -164
  94. package/dist/dev-ui-react/__tests__/previewData.test.ts +0 -193
  95. package/dist/dev-ui-react/components/BlocksList.tsx +0 -232
  96. package/dist/dev-ui-react/components/Editor.tsx +0 -469
  97. package/dist/dev-ui-react/components/Preview.tsx +0 -146
  98. package/dist/dev-ui-react/hooks/useBlocks.ts +0 -80
  99. package/dist/dev-ui-react/index.html +0 -13
  100. package/dist/dev-ui-react/main.tsx +0 -8
  101. package/dist/dev-ui-react/styles.css +0 -856
  102. package/dist/dev-ui-react/types.ts +0 -45
  103. package/dist/skills/claude/cmssy-block.md +0 -454
  104. package/dist/skills/claude/cmssy-mcp-content.md +0 -235
  105. package/dist/test-helpers/index.d.ts +0 -23
  106. package/dist/test-helpers/index.d.ts.map +0 -1
  107. package/dist/test-helpers/index.js +0 -50
  108. package/dist/test-helpers/index.js.map +0 -1
  109. package/dist/types/block-config.d.ts +0 -6
  110. package/dist/types/block-config.d.ts.map +0 -1
  111. package/dist/types/block-config.js +0 -12
  112. package/dist/types/block-config.js.map +0 -1
  113. package/dist/types/publish-job.d.ts +0 -61
  114. package/dist/types/publish-job.d.ts.map +0 -1
  115. package/dist/types/publish-job.js +0 -13
  116. package/dist/types/publish-job.js.map +0 -1
  117. package/dist/utils/api-error.d.ts +0 -10
  118. package/dist/utils/api-error.d.ts.map +0 -1
  119. package/dist/utils/api-error.js +0 -55
  120. package/dist/utils/api-error.js.map +0 -1
  121. package/dist/utils/block-config.d.ts +0 -87
  122. package/dist/utils/block-config.d.ts.map +0 -1
  123. package/dist/utils/block-config.js +0 -214
  124. package/dist/utils/block-config.js.map +0 -1
  125. package/dist/utils/blocks-meta-cache.d.ts +0 -28
  126. package/dist/utils/blocks-meta-cache.d.ts.map +0 -1
  127. package/dist/utils/blocks-meta-cache.js +0 -72
  128. package/dist/utils/blocks-meta-cache.js.map +0 -1
  129. package/dist/utils/builder.d.ts +0 -34
  130. package/dist/utils/builder.d.ts.map +0 -1
  131. package/dist/utils/builder.js +0 -140
  132. package/dist/utils/builder.js.map +0 -1
  133. package/dist/utils/cmssy-config.d.ts +0 -16
  134. package/dist/utils/cmssy-config.d.ts.map +0 -1
  135. package/dist/utils/cmssy-config.js +0 -19
  136. package/dist/utils/cmssy-config.js.map +0 -1
  137. package/dist/utils/config.d.ts +0 -9
  138. package/dist/utils/config.d.ts.map +0 -1
  139. package/dist/utils/config.js +0 -51
  140. package/dist/utils/config.js.map +0 -1
  141. package/dist/utils/dependency-check.d.ts +0 -21
  142. package/dist/utils/dependency-check.d.ts.map +0 -1
  143. package/dist/utils/dependency-check.js +0 -56
  144. package/dist/utils/dependency-check.js.map +0 -1
  145. package/dist/utils/dev-generator/api-routes/blocks.d.ts +0 -3
  146. package/dist/utils/dev-generator/api-routes/blocks.d.ts.map +0 -1
  147. package/dist/utils/dev-generator/api-routes/blocks.js +0 -194
  148. package/dist/utils/dev-generator/api-routes/blocks.js.map +0 -1
  149. package/dist/utils/dev-generator/api-routes/config.d.ts +0 -2
  150. package/dist/utils/dev-generator/api-routes/config.d.ts.map +0 -1
  151. package/dist/utils/dev-generator/api-routes/config.js +0 -107
  152. package/dist/utils/dev-generator/api-routes/config.js.map +0 -1
  153. package/dist/utils/dev-generator/api-routes/preview.d.ts +0 -2
  154. package/dist/utils/dev-generator/api-routes/preview.d.ts.map +0 -1
  155. package/dist/utils/dev-generator/api-routes/preview.js +0 -50
  156. package/dist/utils/dev-generator/api-routes/preview.js.map +0 -1
  157. package/dist/utils/dev-generator/api-routes/workspaces.d.ts +0 -2
  158. package/dist/utils/dev-generator/api-routes/workspaces.d.ts.map +0 -1
  159. package/dist/utils/dev-generator/api-routes/workspaces.js +0 -128
  160. package/dist/utils/dev-generator/api-routes/workspaces.js.map +0 -1
  161. package/dist/utils/dev-generator/helpers.d.ts +0 -23
  162. package/dist/utils/dev-generator/helpers.d.ts.map +0 -1
  163. package/dist/utils/dev-generator/helpers.js +0 -128
  164. package/dist/utils/dev-generator/helpers.js.map +0 -1
  165. package/dist/utils/dev-generator/home-page.d.ts +0 -2
  166. package/dist/utils/dev-generator/home-page.d.ts.map +0 -1
  167. package/dist/utils/dev-generator/home-page.js +0 -643
  168. package/dist/utils/dev-generator/home-page.js.map +0 -1
  169. package/dist/utils/dev-generator/index.d.ts +0 -11
  170. package/dist/utils/dev-generator/index.d.ts.map +0 -1
  171. package/dist/utils/dev-generator/index.js +0 -85
  172. package/dist/utils/dev-generator/index.js.map +0 -1
  173. package/dist/utils/dev-generator/layout.d.ts +0 -3
  174. package/dist/utils/dev-generator/layout.d.ts.map +0 -1
  175. package/dist/utils/dev-generator/layout.js +0 -63
  176. package/dist/utils/dev-generator/layout.js.map +0 -1
  177. package/dist/utils/dev-generator/next-config.d.ts +0 -3
  178. package/dist/utils/dev-generator/next-config.d.ts.map +0 -1
  179. package/dist/utils/dev-generator/next-config.js +0 -111
  180. package/dist/utils/dev-generator/next-config.js.map +0 -1
  181. package/dist/utils/dev-generator/preview-pages.d.ts +0 -3
  182. package/dist/utils/dev-generator/preview-pages.d.ts.map +0 -1
  183. package/dist/utils/dev-generator/preview-pages.js +0 -833
  184. package/dist/utils/dev-generator/preview-pages.js.map +0 -1
  185. package/dist/utils/dev-generator.d.ts +0 -12
  186. package/dist/utils/dev-generator.d.ts.map +0 -1
  187. package/dist/utils/dev-generator.js +0 -1752
  188. package/dist/utils/dev-generator.js.map +0 -1
  189. package/dist/utils/field-schema.d.ts +0 -13
  190. package/dist/utils/field-schema.d.ts.map +0 -1
  191. package/dist/utils/field-schema.js +0 -182
  192. package/dist/utils/field-schema.js.map +0 -1
  193. package/dist/utils/graphql.d.ts +0 -39
  194. package/dist/utils/graphql.d.ts.map +0 -1
  195. package/dist/utils/graphql.js +0 -138
  196. package/dist/utils/graphql.js.map +0 -1
  197. package/dist/utils/lib-manifest.d.ts +0 -7
  198. package/dist/utils/lib-manifest.d.ts.map +0 -1
  199. package/dist/utils/lib-manifest.js +0 -59
  200. package/dist/utils/lib-manifest.js.map +0 -1
  201. package/dist/utils/publish-helpers.d.ts +0 -43
  202. package/dist/utils/publish-helpers.d.ts.map +0 -1
  203. package/dist/utils/publish-helpers.js +0 -215
  204. package/dist/utils/publish-helpers.js.map +0 -1
  205. package/dist/utils/publish-helpers.test.d.ts +0 -2
  206. package/dist/utils/publish-helpers.test.d.ts.map +0 -1
  207. package/dist/utils/publish-helpers.test.js +0 -24
  208. package/dist/utils/publish-helpers.test.js.map +0 -1
  209. package/dist/utils/resolve-workspace.d.ts +0 -6
  210. package/dist/utils/resolve-workspace.d.ts.map +0 -1
  211. package/dist/utils/resolve-workspace.js +0 -32
  212. package/dist/utils/resolve-workspace.js.map +0 -1
  213. package/dist/utils/scanner.d.ts +0 -42
  214. package/dist/utils/scanner.d.ts.map +0 -1
  215. package/dist/utils/scanner.js +0 -156
  216. package/dist/utils/scanner.js.map +0 -1
  217. package/dist/utils/schema-diff.d.ts +0 -22
  218. package/dist/utils/schema-diff.d.ts.map +0 -1
  219. package/dist/utils/schema-diff.js +0 -107
  220. package/dist/utils/schema-diff.js.map +0 -1
  221. package/dist/utils/source-collector.d.ts +0 -19
  222. package/dist/utils/source-collector.d.ts.map +0 -1
  223. package/dist/utils/source-collector.js +0 -565
  224. package/dist/utils/source-collector.js.map +0 -1
  225. package/dist/utils/theme-builder.d.ts +0 -12
  226. package/dist/utils/theme-builder.d.ts.map +0 -1
  227. package/dist/utils/theme-builder.js +0 -117
  228. package/dist/utils/theme-builder.js.map +0 -1
  229. package/dist/utils/type-generator.d.ts +0 -9
  230. package/dist/utils/type-generator.d.ts.map +0 -1
  231. package/dist/utils/type-generator.js +0 -86
  232. package/dist/utils/type-generator.js.map +0 -1
  233. package/dist/utils/version.d.ts +0 -10
  234. package/dist/utils/version.d.ts.map +0 -1
  235. package/dist/utils/version.js +0 -30
  236. package/dist/utils/version.js.map +0 -1
  237. package/dist/utils/versions.d.ts.map +0 -1
  238. package/dist/utils/versions.js.map +0 -1
  239. package/src/dev-app/app/api/blocks/[name]/config/route.ts +0 -140
  240. package/src/dev-app/app/api/blocks/route.ts +0 -61
  241. package/src/dev-app/app/api/config/route.ts +0 -98
  242. package/src/dev-app/app/api/context/route.ts +0 -126
  243. package/src/dev-app/app/api/preview/[name]/route.ts +0 -137
  244. package/src/dev-app/app/api/workspaces/route.ts +0 -124
  245. package/src/dev-app/app/layout.tsx +0 -18
  246. package/src/dev-app/app/page.tsx +0 -1785
  247. package/test.d.ts +0 -1
  248. package/test.js +0 -2
@@ -1,126 +0,0 @@
1
- import { NextResponse } from "next/server";
2
- import fs from "fs";
3
- import path from "path";
4
-
5
- const projectRoot = process.env.CMSSY_PROJECT_ROOT || process.cwd();
6
- const CONTEXT_PATH = path.join(projectRoot, ".cmssy", "dev-context.json");
7
-
8
- const DEFAULT_CONTEXT = {
9
- locale: {
10
- current: "en",
11
- default: "en",
12
- enabled: ["en"],
13
- },
14
- auth: null,
15
- workspace: {
16
- id: "dev-workspace",
17
- slug: "dev",
18
- name: "Dev Workspace",
19
- },
20
- isPreview: true,
21
- };
22
-
23
- const PRESETS: Record<string, any> = {
24
- empty: {
25
- locale: { current: "en", default: "en", enabled: ["en"] },
26
- auth: null,
27
- workspace: null,
28
- isPreview: true,
29
- },
30
- "logged-in": {
31
- locale: { current: "en", default: "en", enabled: ["en"] },
32
- auth: {
33
- isAuthenticated: true,
34
- member: {
35
- id: "dev-member-1",
36
- email: "user@example.com",
37
- profile: {
38
- firstName: "Jane",
39
- lastName: "Doe",
40
- displayName: "Jane Doe",
41
- avatarUrl: "",
42
- },
43
- role: "member",
44
- verified: true,
45
- },
46
- },
47
- workspace: { id: "dev-workspace", slug: "dev", name: "Dev Workspace" },
48
- isPreview: true,
49
- },
50
- "multi-language": {
51
- locale: { current: "en", default: "en", enabled: ["en", "pl", "de"] },
52
- auth: null,
53
- workspace: { id: "dev-workspace", slug: "dev", name: "Dev Workspace" },
54
- isPreview: true,
55
- },
56
- "blog-posts": {
57
- locale: { current: "en", default: "en", enabled: ["en"] },
58
- auth: null,
59
- workspace: { id: "dev-workspace", slug: "dev", name: "Dev Workspace" },
60
- isPreview: true,
61
- pages: {
62
- posts: [
63
- {
64
- slug: "hello-world",
65
- fullSlug: "/blog/hello-world",
66
- displayName: { en: "Hello World" },
67
- pageType: "post",
68
- },
69
- {
70
- slug: "getting-started",
71
- fullSlug: "/blog/getting-started",
72
- displayName: { en: "Getting Started" },
73
- pageType: "post",
74
- },
75
- {
76
- slug: "advanced-tips",
77
- fullSlug: "/blog/advanced-tips",
78
- displayName: { en: "Advanced Tips" },
79
- pageType: "post",
80
- },
81
- ],
82
- },
83
- },
84
- };
85
-
86
- export async function GET(request: Request) {
87
- const url = new URL(request.url);
88
-
89
- // Return presets list
90
- if (url.searchParams.get("presets") === "true") {
91
- return NextResponse.json({
92
- presets: Object.keys(PRESETS),
93
- });
94
- }
95
-
96
- // Return a specific preset
97
- const preset = url.searchParams.get("preset");
98
- if (preset && PRESETS[preset]) {
99
- return NextResponse.json(PRESETS[preset]);
100
- }
101
-
102
- // Return saved context
103
- let context = DEFAULT_CONTEXT;
104
- if (fs.existsSync(CONTEXT_PATH)) {
105
- try {
106
- context = JSON.parse(fs.readFileSync(CONTEXT_PATH, "utf-8"));
107
- } catch {
108
- context = DEFAULT_CONTEXT;
109
- }
110
- }
111
-
112
- return NextResponse.json(context);
113
- }
114
-
115
- export async function PUT(request: Request) {
116
- try {
117
- const body = await request.json();
118
- const dir = path.dirname(CONTEXT_PATH);
119
- fs.mkdirSync(dir, { recursive: true });
120
- fs.writeFileSync(CONTEXT_PATH, JSON.stringify(body, null, 2));
121
- return NextResponse.json({ success: true });
122
- } catch (error: any) {
123
- const status = error?.message?.includes("JSON") ? 400 : 500;
124
- return NextResponse.json({ error: error.message }, { status });
125
- }
126
- }
@@ -1,137 +0,0 @@
1
- import { NextResponse } from "next/server";
2
- import fs from "fs";
3
- import path from "path";
4
-
5
- const projectRoot = process.env.CMSSY_PROJECT_ROOT || process.cwd();
6
-
7
- const SAFE_NAME_RE = /^[a-zA-Z0-9_-]+$/;
8
-
9
- function isValidName(name: string): boolean {
10
- return SAFE_NAME_RE.test(name);
11
- }
12
-
13
- function resolveBlockPath(name: string): string | null {
14
- if (!isValidName(name)) return null;
15
- let blockPath = path.join(projectRoot, "blocks", name);
16
- if (fs.existsSync(blockPath)) return blockPath;
17
- blockPath = path.join(projectRoot, "templates", name);
18
- return fs.existsSync(blockPath) ? blockPath : null;
19
- }
20
-
21
- function getVariants(blockPath: string): string[] {
22
- const previewsDir = path.join(blockPath, "previews");
23
- if (!fs.existsSync(previewsDir)) return [];
24
- return fs
25
- .readdirSync(previewsDir)
26
- .filter((f) => f.endsWith(".json"))
27
- .map((f) => f.replace(/\.json$/, ""))
28
- .filter((name) => SAFE_NAME_RE.test(name))
29
- .sort((a, b) => a.localeCompare(b));
30
- }
31
-
32
- function getPreviewPath(blockPath: string, variant?: string): string {
33
- if (variant && isValidName(variant)) {
34
- const variantPath = path.join(blockPath, "previews", `${variant}.json`);
35
- if (fs.existsSync(variantPath)) return variantPath;
36
- }
37
- return path.join(blockPath, "preview.json");
38
- }
39
-
40
- export async function GET(
41
- request: Request,
42
- { params }: { params: Promise<{ name: string }> },
43
- ) {
44
- const { name } = await params;
45
- if (!isValidName(name)) {
46
- return NextResponse.json({ error: "Invalid name" }, { status: 400 });
47
- }
48
-
49
- const blockPath = resolveBlockPath(name);
50
- if (!blockPath) {
51
- return NextResponse.json({ error: "Not found" }, { status: 404 });
52
- }
53
-
54
- const url = new URL(request.url);
55
- const variant = url.searchParams.get("variant") || undefined;
56
-
57
- if (url.searchParams.get("list") === "variants") {
58
- return NextResponse.json({ variants: getVariants(blockPath) });
59
- }
60
-
61
- const previewPath = getPreviewPath(blockPath, variant);
62
- let data = {};
63
- if (fs.existsSync(previewPath)) {
64
- try {
65
- data = JSON.parse(fs.readFileSync(previewPath, "utf-8"));
66
- } catch {
67
- data = {};
68
- }
69
- }
70
-
71
- return NextResponse.json({
72
- data,
73
- variants: getVariants(blockPath),
74
- currentVariant: variant || null,
75
- });
76
- }
77
-
78
- export async function POST(
79
- request: Request,
80
- { params }: { params: Promise<{ name: string }> },
81
- ) {
82
- const { name } = await params;
83
- if (!isValidName(name)) {
84
- return NextResponse.json({ error: "Invalid name" }, { status: 400 });
85
- }
86
-
87
- const blockPath = resolveBlockPath(name);
88
- if (!blockPath) {
89
- return NextResponse.json({ error: "Not found" }, { status: 404 });
90
- }
91
-
92
- const url = new URL(request.url);
93
- const variant = url.searchParams.get("variant") || undefined;
94
- const action = url.searchParams.get("action");
95
-
96
- // Validate variant param if present
97
- if (variant && !isValidName(variant)) {
98
- return NextResponse.json({ error: "Invalid variant" }, { status: 400 });
99
- }
100
-
101
- // Save as new variant
102
- if (action === "save-variant") {
103
- const body = await request.json();
104
- const variantName = body.variantName;
105
- if (!variantName || !isValidName(variantName)) {
106
- return NextResponse.json(
107
- {
108
- error:
109
- "Invalid variant name (use alphanumeric, hyphens, underscores)",
110
- },
111
- { status: 400 },
112
- );
113
- }
114
- const previewsDir = path.join(blockPath, "previews");
115
- fs.mkdirSync(previewsDir, { recursive: true });
116
- const variantPath = path.join(previewsDir, `${variantName}.json`);
117
- const dataToWrite = body.data ?? {};
118
- fs.writeFileSync(variantPath, JSON.stringify(dataToWrite, null, 2));
119
- return NextResponse.json({ success: true, variant: variantName });
120
- }
121
-
122
- // Delete variant
123
- if (action === "delete-variant" && variant) {
124
- const variantPath = path.join(blockPath, "previews", `${variant}.json`);
125
- if (fs.existsSync(variantPath)) {
126
- fs.unlinkSync(variantPath);
127
- }
128
- return NextResponse.json({ success: true });
129
- }
130
-
131
- // Regular save
132
- const body = await request.json();
133
- const previewPath = getPreviewPath(blockPath, variant);
134
- fs.writeFileSync(previewPath, JSON.stringify(body, null, 2));
135
-
136
- return NextResponse.json({ success: true });
137
- }
@@ -1,124 +0,0 @@
1
- import { NextResponse } from "next/server";
2
- import fs from "fs";
3
- import path from "path";
4
-
5
- const projectRoot = process.env.CMSSY_PROJECT_ROOT || process.cwd();
6
-
7
- function loadEnvConfig(): {
8
- apiUrl: string;
9
- apiToken: string | null;
10
- workspaceId: string | null;
11
- } {
12
- const envPath = path.join(projectRoot, ".env");
13
- const config: any = {
14
- apiUrl: "https://api.cmssy.io/graphql",
15
- apiToken: null,
16
- workspaceId: null,
17
- };
18
- if (!fs.existsSync(envPath)) return config;
19
- const content = fs.readFileSync(envPath, "utf-8");
20
- for (const line of content.split("\n")) {
21
- const match = line.match(/^(CMSSY_\w+)=(.*)$/);
22
- if (!match) continue;
23
- const [, key, val] = match;
24
- if (key === "CMSSY_API_URL") config.apiUrl = val.trim();
25
- if (key === "CMSSY_API_TOKEN") config.apiToken = val.trim() || null;
26
- if (key === "CMSSY_WORKSPACE_ID") config.workspaceId = val.trim() || null;
27
- }
28
- return config;
29
- }
30
-
31
- const MY_WORKSPACES_QUERY = `
32
- query MyWorkspaces {
33
- myWorkspaces {
34
- id
35
- slug
36
- name
37
- myRole { name slug }
38
- }
39
- }
40
- `;
41
-
42
- const WORKSPACE_BLOCKS_QUERY = `
43
- query GetWorkspaceBlocks {
44
- workspaceBlocks {
45
- id
46
- blockType
47
- name
48
- version
49
- }
50
- }
51
- `;
52
-
53
- export async function GET() {
54
- const config = loadEnvConfig();
55
-
56
- if (!config.apiToken) {
57
- return NextResponse.json({ connected: false, reason: "no_token" });
58
- }
59
-
60
- try {
61
- const headers = {
62
- "Content-Type": "application/json",
63
- Authorization: `Bearer ${config.apiToken}`,
64
- };
65
-
66
- const wsRes = await fetch(config.apiUrl, {
67
- method: "POST",
68
- headers,
69
- body: JSON.stringify({ query: MY_WORKSPACES_QUERY }),
70
- });
71
- const wsData = await wsRes.json();
72
-
73
- if (wsData.errors?.length) {
74
- return NextResponse.json({
75
- connected: false,
76
- reason: "auth_error",
77
- error: wsData.errors[0].message,
78
- });
79
- }
80
-
81
- const workspaces = wsData.data?.myWorkspaces || [];
82
-
83
- let targetWorkspace = null;
84
- if (config.workspaceId) {
85
- targetWorkspace = workspaces.find(
86
- (w: any) => w.id === config.workspaceId,
87
- );
88
- }
89
- if (!targetWorkspace && workspaces.length > 0) {
90
- targetWorkspace = workspaces[0];
91
- }
92
-
93
- let publishedBlocks: any[] = [];
94
- if (targetWorkspace) {
95
- const blocksRes = await fetch(config.apiUrl, {
96
- method: "POST",
97
- headers: {
98
- ...headers,
99
- "x-workspace-id": targetWorkspace.id,
100
- },
101
- body: JSON.stringify({ query: WORKSPACE_BLOCKS_QUERY }),
102
- });
103
- const blocksData = await blocksRes.json();
104
- publishedBlocks = blocksData.data?.workspaceBlocks || [];
105
- }
106
-
107
- return NextResponse.json({
108
- connected: true,
109
- workspace: targetWorkspace,
110
- workspaces,
111
- publishedBlocks: publishedBlocks.map((b: any) => ({
112
- blockType: b.blockType,
113
- name: b.name,
114
- version: b.version || "1.0.0",
115
- })),
116
- });
117
- } catch (error: any) {
118
- return NextResponse.json({
119
- connected: false,
120
- reason: "network_error",
121
- error: error.message,
122
- });
123
- }
124
- }
@@ -1,18 +0,0 @@
1
- import type { Metadata } from "next";
2
- import type { ReactNode } from "react";
3
- import "./globals.css";
4
-
5
- export const metadata: Metadata = {
6
- title: "Cmssy Dev Server",
7
- icons: {
8
- icon: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' rx='20' fill='%23667eea'/%3E%3Ctext x='50' y='70' font-size='60' font-weight='bold' text-anchor='middle' fill='white' font-family='system-ui'%3EC%3C/text%3E%3C/svg%3E",
9
- },
10
- };
11
-
12
- export default function RootLayout({ children }: { children: ReactNode }) {
13
- return (
14
- <html lang="en">
15
- <body>{children}</body>
16
- </html>
17
- );
18
- }