@cmssy/cli 0.22.3 → 1.0.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 (260) hide show
  1. package/README.md +49 -650
  2. package/dist/cli.js +706 -328
  3. package/package.json +26 -73
  4. package/templates/block/Component.module.css.tpl +12 -0
  5. package/templates/block/Component.tsx.tpl +15 -0
  6. package/templates/block/block.ts.tpl +11 -0
  7. package/templates/init/app/[[...path]]/page.tsx +19 -0
  8. package/templates/init/app/api/draft/route.ts +5 -0
  9. package/templates/init/blocks/hero/Hero.module.css +131 -0
  10. package/templates/init/blocks/hero/Hero.tsx +100 -0
  11. package/templates/init/blocks/hero/block.ts +21 -0
  12. package/templates/init/cmssy/blocks.ts +5 -0
  13. package/templates/init/cmssy/editor.tsx +10 -0
  14. package/templates/init/cmssy.config.ts +8 -0
  15. package/templates/init/env.example +4 -0
  16. package/templates/init/next.config.mjs +8 -0
  17. package/templates/init/proxy.ts +32 -0
  18. package/config.d.ts +0 -3
  19. package/config.js +0 -4
  20. package/dist/cli.d.ts +0 -3
  21. package/dist/cli.d.ts.map +0 -1
  22. package/dist/cli.js.map +0 -1
  23. package/dist/commands/add-source.d.ts +0 -13
  24. package/dist/commands/add-source.d.ts.map +0 -1
  25. package/dist/commands/add-source.js +0 -273
  26. package/dist/commands/add-source.js.map +0 -1
  27. package/dist/commands/build.d.ts +0 -7
  28. package/dist/commands/build.d.ts.map +0 -1
  29. package/dist/commands/build.js +0 -127
  30. package/dist/commands/build.js.map +0 -1
  31. package/dist/commands/codegen.d.ts +0 -7
  32. package/dist/commands/codegen.d.ts.map +0 -1
  33. package/dist/commands/codegen.js +0 -150
  34. package/dist/commands/codegen.js.map +0 -1
  35. package/dist/commands/configure.d.ts +0 -6
  36. package/dist/commands/configure.d.ts.map +0 -1
  37. package/dist/commands/configure.js +0 -39
  38. package/dist/commands/configure.js.map +0 -1
  39. package/dist/commands/create.d.ts +0 -18
  40. package/dist/commands/create.d.ts.map +0 -1
  41. package/dist/commands/create.js +0 -403
  42. package/dist/commands/create.js.map +0 -1
  43. package/dist/commands/dev.d.ts +0 -6
  44. package/dist/commands/dev.d.ts.map +0 -1
  45. package/dist/commands/dev.js +0 -144
  46. package/dist/commands/dev.js.map +0 -1
  47. package/dist/commands/doctor.d.ts +0 -2
  48. package/dist/commands/doctor.d.ts.map +0 -1
  49. package/dist/commands/doctor.js +0 -230
  50. package/dist/commands/doctor.js.map +0 -1
  51. package/dist/commands/init.d.ts +0 -6
  52. package/dist/commands/init.d.ts.map +0 -1
  53. package/dist/commands/init.js +0 -414
  54. package/dist/commands/init.js.map +0 -1
  55. package/dist/commands/lib.d.ts +0 -17
  56. package/dist/commands/lib.d.ts.map +0 -1
  57. package/dist/commands/lib.js +0 -132
  58. package/dist/commands/lib.js.map +0 -1
  59. package/dist/commands/link.d.ts +0 -8
  60. package/dist/commands/link.d.ts.map +0 -1
  61. package/dist/commands/link.js +0 -116
  62. package/dist/commands/link.js.map +0 -1
  63. package/dist/commands/migrate.d.ts +0 -2
  64. package/dist/commands/migrate.d.ts.map +0 -1
  65. package/dist/commands/migrate.js +0 -231
  66. package/dist/commands/migrate.js.map +0 -1
  67. package/dist/commands/package.d.ts +0 -14
  68. package/dist/commands/package.d.ts.map +0 -1
  69. package/dist/commands/package.js +0 -137
  70. package/dist/commands/package.js.map +0 -1
  71. package/dist/commands/publish-block-buildtime.d.ts +0 -8
  72. package/dist/commands/publish-block-buildtime.d.ts.map +0 -1
  73. package/dist/commands/publish-block-buildtime.js +0 -290
  74. package/dist/commands/publish-block-buildtime.js.map +0 -1
  75. package/dist/commands/publish-template.d.ts +0 -22
  76. package/dist/commands/publish-template.d.ts.map +0 -1
  77. package/dist/commands/publish-template.js +0 -345
  78. package/dist/commands/publish-template.js.map +0 -1
  79. package/dist/commands/publish.d.ts +0 -15
  80. package/dist/commands/publish.d.ts.map +0 -1
  81. package/dist/commands/publish.js +0 -1003
  82. package/dist/commands/publish.js.map +0 -1
  83. package/dist/commands/skills.d.ts +0 -11
  84. package/dist/commands/skills.d.ts.map +0 -1
  85. package/dist/commands/skills.js +0 -178
  86. package/dist/commands/skills.js.map +0 -1
  87. package/dist/commands/sync.d.ts +0 -6
  88. package/dist/commands/sync.d.ts.map +0 -1
  89. package/dist/commands/sync.js +0 -208
  90. package/dist/commands/sync.js.map +0 -1
  91. package/dist/commands/test.d.ts +0 -8
  92. package/dist/commands/test.d.ts.map +0 -1
  93. package/dist/commands/test.js +0 -60
  94. package/dist/commands/test.js.map +0 -1
  95. package/dist/commands/upload.d.ts +0 -11
  96. package/dist/commands/upload.d.ts.map +0 -1
  97. package/dist/commands/upload.js +0 -128
  98. package/dist/commands/upload.js.map +0 -1
  99. package/dist/commands/workspaces.d.ts +0 -2
  100. package/dist/commands/workspaces.d.ts.map +0 -1
  101. package/dist/commands/workspaces.js +0 -62
  102. package/dist/commands/workspaces.js.map +0 -1
  103. package/dist/dev-ui/app.js +0 -1284
  104. package/dist/dev-ui/index.html +0 -1511
  105. package/dist/dev-ui-react/App.tsx +0 -164
  106. package/dist/dev-ui-react/__tests__/previewData.test.ts +0 -193
  107. package/dist/dev-ui-react/components/BlocksList.tsx +0 -232
  108. package/dist/dev-ui-react/components/Editor.tsx +0 -469
  109. package/dist/dev-ui-react/components/Preview.tsx +0 -146
  110. package/dist/dev-ui-react/hooks/useBlocks.ts +0 -80
  111. package/dist/dev-ui-react/index.html +0 -13
  112. package/dist/dev-ui-react/main.tsx +0 -8
  113. package/dist/dev-ui-react/styles.css +0 -856
  114. package/dist/dev-ui-react/types.ts +0 -45
  115. package/dist/skills/claude/cmssy-block.md +0 -454
  116. package/dist/skills/claude/cmssy-mcp-content.md +0 -231
  117. package/dist/test-helpers/index.d.ts +0 -23
  118. package/dist/test-helpers/index.d.ts.map +0 -1
  119. package/dist/test-helpers/index.js +0 -50
  120. package/dist/test-helpers/index.js.map +0 -1
  121. package/dist/types/block-config.d.ts +0 -6
  122. package/dist/types/block-config.d.ts.map +0 -1
  123. package/dist/types/block-config.js +0 -12
  124. package/dist/types/block-config.js.map +0 -1
  125. package/dist/types/publish-job.d.ts +0 -61
  126. package/dist/types/publish-job.d.ts.map +0 -1
  127. package/dist/types/publish-job.js +0 -13
  128. package/dist/types/publish-job.js.map +0 -1
  129. package/dist/utils/api-error.d.ts +0 -10
  130. package/dist/utils/api-error.d.ts.map +0 -1
  131. package/dist/utils/api-error.js +0 -55
  132. package/dist/utils/api-error.js.map +0 -1
  133. package/dist/utils/block-config.d.ts +0 -87
  134. package/dist/utils/block-config.d.ts.map +0 -1
  135. package/dist/utils/block-config.js +0 -214
  136. package/dist/utils/block-config.js.map +0 -1
  137. package/dist/utils/blocks-meta-cache.d.ts +0 -28
  138. package/dist/utils/blocks-meta-cache.d.ts.map +0 -1
  139. package/dist/utils/blocks-meta-cache.js +0 -72
  140. package/dist/utils/blocks-meta-cache.js.map +0 -1
  141. package/dist/utils/builder.d.ts +0 -34
  142. package/dist/utils/builder.d.ts.map +0 -1
  143. package/dist/utils/builder.js +0 -140
  144. package/dist/utils/builder.js.map +0 -1
  145. package/dist/utils/cmssy-config.d.ts +0 -16
  146. package/dist/utils/cmssy-config.d.ts.map +0 -1
  147. package/dist/utils/cmssy-config.js +0 -19
  148. package/dist/utils/cmssy-config.js.map +0 -1
  149. package/dist/utils/config.d.ts +0 -9
  150. package/dist/utils/config.d.ts.map +0 -1
  151. package/dist/utils/config.js +0 -51
  152. package/dist/utils/config.js.map +0 -1
  153. package/dist/utils/dependency-check.d.ts +0 -21
  154. package/dist/utils/dependency-check.d.ts.map +0 -1
  155. package/dist/utils/dependency-check.js +0 -56
  156. package/dist/utils/dependency-check.js.map +0 -1
  157. package/dist/utils/dev-generator/api-routes/blocks.d.ts +0 -3
  158. package/dist/utils/dev-generator/api-routes/blocks.d.ts.map +0 -1
  159. package/dist/utils/dev-generator/api-routes/blocks.js +0 -194
  160. package/dist/utils/dev-generator/api-routes/blocks.js.map +0 -1
  161. package/dist/utils/dev-generator/api-routes/config.d.ts +0 -2
  162. package/dist/utils/dev-generator/api-routes/config.d.ts.map +0 -1
  163. package/dist/utils/dev-generator/api-routes/config.js +0 -107
  164. package/dist/utils/dev-generator/api-routes/config.js.map +0 -1
  165. package/dist/utils/dev-generator/api-routes/preview.d.ts +0 -2
  166. package/dist/utils/dev-generator/api-routes/preview.d.ts.map +0 -1
  167. package/dist/utils/dev-generator/api-routes/preview.js +0 -50
  168. package/dist/utils/dev-generator/api-routes/preview.js.map +0 -1
  169. package/dist/utils/dev-generator/api-routes/workspaces.d.ts +0 -2
  170. package/dist/utils/dev-generator/api-routes/workspaces.d.ts.map +0 -1
  171. package/dist/utils/dev-generator/api-routes/workspaces.js +0 -128
  172. package/dist/utils/dev-generator/api-routes/workspaces.js.map +0 -1
  173. package/dist/utils/dev-generator/helpers.d.ts +0 -23
  174. package/dist/utils/dev-generator/helpers.d.ts.map +0 -1
  175. package/dist/utils/dev-generator/helpers.js +0 -128
  176. package/dist/utils/dev-generator/helpers.js.map +0 -1
  177. package/dist/utils/dev-generator/home-page.d.ts +0 -2
  178. package/dist/utils/dev-generator/home-page.d.ts.map +0 -1
  179. package/dist/utils/dev-generator/home-page.js +0 -643
  180. package/dist/utils/dev-generator/home-page.js.map +0 -1
  181. package/dist/utils/dev-generator/index.d.ts +0 -11
  182. package/dist/utils/dev-generator/index.d.ts.map +0 -1
  183. package/dist/utils/dev-generator/index.js +0 -85
  184. package/dist/utils/dev-generator/index.js.map +0 -1
  185. package/dist/utils/dev-generator/layout.d.ts +0 -3
  186. package/dist/utils/dev-generator/layout.d.ts.map +0 -1
  187. package/dist/utils/dev-generator/layout.js +0 -63
  188. package/dist/utils/dev-generator/layout.js.map +0 -1
  189. package/dist/utils/dev-generator/next-config.d.ts +0 -3
  190. package/dist/utils/dev-generator/next-config.d.ts.map +0 -1
  191. package/dist/utils/dev-generator/next-config.js +0 -111
  192. package/dist/utils/dev-generator/next-config.js.map +0 -1
  193. package/dist/utils/dev-generator/preview-pages.d.ts +0 -3
  194. package/dist/utils/dev-generator/preview-pages.d.ts.map +0 -1
  195. package/dist/utils/dev-generator/preview-pages.js +0 -833
  196. package/dist/utils/dev-generator/preview-pages.js.map +0 -1
  197. package/dist/utils/dev-generator.d.ts +0 -12
  198. package/dist/utils/dev-generator.d.ts.map +0 -1
  199. package/dist/utils/dev-generator.js +0 -1752
  200. package/dist/utils/dev-generator.js.map +0 -1
  201. package/dist/utils/field-schema.d.ts +0 -13
  202. package/dist/utils/field-schema.d.ts.map +0 -1
  203. package/dist/utils/field-schema.js +0 -182
  204. package/dist/utils/field-schema.js.map +0 -1
  205. package/dist/utils/graphql.d.ts +0 -39
  206. package/dist/utils/graphql.d.ts.map +0 -1
  207. package/dist/utils/graphql.js +0 -138
  208. package/dist/utils/graphql.js.map +0 -1
  209. package/dist/utils/lib-manifest.d.ts +0 -7
  210. package/dist/utils/lib-manifest.d.ts.map +0 -1
  211. package/dist/utils/lib-manifest.js +0 -59
  212. package/dist/utils/lib-manifest.js.map +0 -1
  213. package/dist/utils/publish-helpers.d.ts +0 -43
  214. package/dist/utils/publish-helpers.d.ts.map +0 -1
  215. package/dist/utils/publish-helpers.js +0 -215
  216. package/dist/utils/publish-helpers.js.map +0 -1
  217. package/dist/utils/publish-helpers.test.d.ts +0 -2
  218. package/dist/utils/publish-helpers.test.d.ts.map +0 -1
  219. package/dist/utils/publish-helpers.test.js +0 -24
  220. package/dist/utils/publish-helpers.test.js.map +0 -1
  221. package/dist/utils/resolve-workspace.d.ts +0 -6
  222. package/dist/utils/resolve-workspace.d.ts.map +0 -1
  223. package/dist/utils/resolve-workspace.js +0 -32
  224. package/dist/utils/resolve-workspace.js.map +0 -1
  225. package/dist/utils/scanner.d.ts +0 -42
  226. package/dist/utils/scanner.d.ts.map +0 -1
  227. package/dist/utils/scanner.js +0 -156
  228. package/dist/utils/scanner.js.map +0 -1
  229. package/dist/utils/schema-diff.d.ts +0 -22
  230. package/dist/utils/schema-diff.d.ts.map +0 -1
  231. package/dist/utils/schema-diff.js +0 -107
  232. package/dist/utils/schema-diff.js.map +0 -1
  233. package/dist/utils/source-collector.d.ts +0 -19
  234. package/dist/utils/source-collector.d.ts.map +0 -1
  235. package/dist/utils/source-collector.js +0 -565
  236. package/dist/utils/source-collector.js.map +0 -1
  237. package/dist/utils/theme-builder.d.ts +0 -12
  238. package/dist/utils/theme-builder.d.ts.map +0 -1
  239. package/dist/utils/theme-builder.js +0 -117
  240. package/dist/utils/theme-builder.js.map +0 -1
  241. package/dist/utils/type-generator.d.ts +0 -9
  242. package/dist/utils/type-generator.d.ts.map +0 -1
  243. package/dist/utils/type-generator.js +0 -86
  244. package/dist/utils/type-generator.js.map +0 -1
  245. package/dist/utils/version.d.ts +0 -10
  246. package/dist/utils/version.d.ts.map +0 -1
  247. package/dist/utils/version.js +0 -30
  248. package/dist/utils/version.js.map +0 -1
  249. package/dist/utils/versions.d.ts.map +0 -1
  250. package/dist/utils/versions.js.map +0 -1
  251. package/src/dev-app/app/api/blocks/[name]/config/route.ts +0 -140
  252. package/src/dev-app/app/api/blocks/route.ts +0 -61
  253. package/src/dev-app/app/api/config/route.ts +0 -98
  254. package/src/dev-app/app/api/context/route.ts +0 -126
  255. package/src/dev-app/app/api/preview/[name]/route.ts +0 -137
  256. package/src/dev-app/app/api/workspaces/route.ts +0 -124
  257. package/src/dev-app/app/layout.tsx +0 -18
  258. package/src/dev-app/app/page.tsx +0 -1785
  259. package/test.d.ts +0 -1
  260. package/test.js +0 -2
package/README.md CHANGED
@@ -1,692 +1,91 @@
1
- # cmssy-cli
1
+ # @cmssy/cli
2
2
 
3
- Unified CLI for building reusable UI blocks and publishing them to Cmssy workspaces.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install -g cmssy-cli
9
- ```
10
-
11
- ## Quick Start
3
+ The `cmssy` CLI wires cmssy into your existing [Next.js](https://nextjs.org) (App Router) app
4
+ and helps you grow it with blocks. It does not scaffold a Next app - bring your own
5
+ (`npx create-next-app@latest`).
12
6
 
13
7
  ```bash
14
- # 1. Create a new project
15
- npx cmssy init my-blocks
16
-
17
- # 2. Navigate to project + install deps
18
- cd my-blocks
19
- npm install
20
-
21
- # 3. Link the project to your Cmssy workspace (interactive - pick workspace, paste token)
22
- cmssy link
23
-
24
- # 4. Verify the setup is healthy
25
- cmssy doctor
26
-
27
- # 5. Start the dev server with hot reload
28
- cmssy dev
29
-
30
- # 6. Create a new block
31
- cmssy create block my-block
32
-
33
- # 7. Test your blocks
34
- cmssy test
35
-
36
- # 8. Build for production
37
- cmssy build
38
-
39
- # 9. Publish a block to your workspace via the sandbox build pipeline
40
- # (relies on CMSSY_WORKSPACE_ID from .env, or override with -w)
41
- cmssy publish-block my-block
42
- # or, override the workspace explicitly:
43
- cmssy publish-block my-block -w <id>
44
- ```
45
-
46
- ## Environment Configuration
47
-
48
- `cmssy link` (see below) writes these for you into `.env`. Manual setup:
49
-
50
- ```env
51
- # Required for publishing
52
- CMSSY_API_URL=https://api.cmssy.io/graphql
53
- CMSSY_API_TOKEN=your_api_token_here
54
-
55
- # Optional - default workspace ID for publishing commands that accept -w
56
- CMSSY_WORKSPACE_ID=507f1f77bcf86cd799439011
8
+ npx create-next-app@latest my-site # your app, your way
9
+ cd my-site
10
+ npx @cmssy/cli init # add cmssy
57
11
  ```
58
12
 
59
- **Recommended:** run `cmssy link` - interactive prompt that picks the workspace,
60
- accepts the API token, and writes all three values to `.env`.
61
-
62
- **Manual:**
63
-
64
- - **API Token**: Cmssy workspace Settings → API Tokens → new token with `blocks:write`
65
- - **Workspace ID**: `cmssy workspaces` (lists all accessible workspaces with their IDs)
13
+ Requires **Node 18.18+** and an existing **Next.js App Router** project.
66
14
 
67
15
  ## Commands
68
16
 
69
- ### Initialize Project
70
-
71
- ```bash
72
- cmssy init [name] [options]
73
- ```
74
-
75
- Create a new Cmssy project with example blocks.
76
-
77
- **Options:**
78
-
79
- - `-f, --framework <framework>` - Framework (react, vue, angular, vanilla). Default: react
80
-
81
- **Example:**
82
-
83
- ```bash
84
- cmssy init my-blocks --framework react
85
- ```
86
-
87
- **What it creates:**
88
-
89
- - Project structure with `blocks/` and `templates/` directories
90
- - Example hero block
91
- - `cmssy.config.js` configuration file
92
- - `.env.example` with API configuration template
93
-
94
- ---
95
-
96
- ### Create Block or Template
97
-
98
- ```bash
99
- cmssy create block <name>
100
- cmssy create template <name>
101
- ```
102
-
103
- Create a new block or page template in your project.
104
-
105
- **Example:**
106
-
107
- ```bash
108
- cmssy create block hero
109
- cmssy create template landing-page
110
- ```
111
-
112
- **What it creates:**
113
-
114
- - `blocks/<name>/` or `templates/<name>/` directory
115
- - `package.json` with metadata
116
- - `preview.json` for dev server
117
- - `src/` directory with component scaffold
118
-
119
- ---
120
-
121
- ### Build
122
-
123
- ```bash
124
- cmssy build [options]
125
- ```
126
-
127
- Build all blocks and templates for production.
128
-
129
- **Options:**
130
-
131
- - `--framework <framework>` - Override framework from config
132
-
133
- **Example:**
134
-
135
- ```bash
136
- cmssy build
137
- ```
138
-
139
- **Output:** Built files are generated in `public/@vendor/package-name/version/` directory.
140
-
141
- ---
142
-
143
- ### Development Server
144
-
145
- ```bash
146
- cmssy dev [options]
147
- ```
148
-
149
- Start development server with hot reload and preview UI.
150
-
151
- **Options:**
152
-
153
- - `-p, --port <port>` - Port number. Default: 3000
154
-
155
- **Example:**
156
-
157
- ```bash
158
- cmssy dev --port 4000
159
- ```
160
-
161
- **Features:**
162
-
163
- - Hot reload on file changes
164
- - Interactive block preview
165
- - Publish blocks directly from UI
166
- - Live progress tracking
167
- - Version badges and status indicators
17
+ ### `cmssy init [dir]`
168
18
 
169
- ---
19
+ Add the cmssy wiring to an existing Next.js App Router app, then link it to a workspace.
20
+ Idempotent - it never overwrites a file you already have; skipped files are reported.
170
21
 
171
- ### Link to a Workspace
22
+ It writes: `cmssy.config.ts`, a catch-all `app/[[...path]]/page.tsx`, the draft route,
23
+ `proxy.ts` (edit-mode + CSP), the block registry, the lazy editor, and one self-styled example
24
+ `hero` block (a CSS Module - cmssy does not impose a styling system). `next.config.mjs` is added
25
+ only if you don't already have one. Then it links and installs dependencies.
172
26
 
173
27
  ```bash
174
- cmssy link [options]
28
+ cmssy init # wire the current directory
29
+ cmssy init --pm pnpm # choose the package manager (npm | pnpm | yarn | bun)
30
+ cmssy init --skip-install # write files, install later
31
+ cmssy init --no-link # skip the workspace prompt
175
32
  ```
176
33
 
177
- Connect the current project to a Cmssy workspace. Interactive prompt by default:
178
- picks the workspace, accepts an API token, and writes `CMSSY_API_URL` /
179
- `CMSSY_API_TOKEN` / `CMSSY_WORKSPACE_ID` to `.env`.
180
-
181
- **Options:**
182
-
183
- - `--token <token>` - API token (non-interactive)
184
- - `--workspace <id|slug>` - Workspace to link to (non-interactive)
185
- - `--api-url <url>` - Override API endpoint (default: `https://api.cmssy.io/graphql`)
34
+ ### `cmssy link`
186
35
 
187
- **Examples:**
36
+ Connect an already-initialized project to a workspace. Prompts for the workspace slug and draft
37
+ secret (both from **cmssy dashboard → Settings → Headless**), validates the slug against the
38
+ delivery API, and writes them to `.env` without touching your other variables.
188
39
 
189
40
  ```bash
190
- # Interactive (recommended for first-time setup)
191
41
  cmssy link
192
-
193
- # CI / scripted setup
194
- cmssy link --token cs_xxx --workspace my-workspace-slug
195
-
196
- # Custom API
197
- cmssy link --api-url https://api.cmssy.dev/graphql
198
- ```
199
-
200
- Tokens come from https://cmssy.io/settings/tokens. List existing workspaces with
201
- `cmssy workspaces`.
202
-
203
- ---
204
-
205
- ### Health Check
206
-
207
- ```bash
208
- cmssy doctor
209
- ```
210
-
211
- All-in-one preflight check.
212
-
213
- **Required (fails the check):**
214
-
215
- - Node ≥ 18
216
- - `cmssy.config.js` present in project root
217
- - `CMSSY_API_TOKEN` set in the environment
218
-
219
- **Warnings only (run still succeeds):**
220
-
221
- - `npm`, `next`, `react` availability
222
- - `.env` file present
223
- - `CMSSY_API_URL` set (defaults to the public API if missing)
224
- - `CMSSY_WORKSPACE_ID` set
225
-
226
- When enough config is available, doctor also reaches out to the API to verify
227
- the token and workspace access.
228
-
229
- Run it before any non-trivial operation (publish, sync). Fix failures before
230
- proceeding; review warnings - they won't stop you but may point at missing
231
- setup steps.
232
-
233
- ---
234
-
235
- ### Test Blocks
236
-
237
- ```bash
238
- cmssy test [options]
239
- ```
240
-
241
- Run the vitest test suite against your blocks and templates. Test files live
242
- at `blocks/*/src/**/*.{test,spec}.{ts,tsx}` (same for templates).
243
-
244
- **Options:**
245
-
246
- - `--block <names...>` - Test only the listed blocks (space-separated)
247
- - `--watch` - Watch mode (re-run on file change)
248
- - `--coverage` - Generate coverage report
249
-
250
- **Examples:**
251
-
252
- ```bash
253
- # All tests
254
- cmssy test
255
-
256
- # Subset
257
- cmssy test --block hero faq
258
-
259
- # Watch mode
260
- cmssy test --watch
261
- ```
262
-
263
- **Writing block tests** - use the helpers from `@cmssy/cli/test`:
264
-
265
- ```ts
266
- import { test, expect } from "vitest";
267
- import { renderBlock, validatePreviewData } from "@cmssy/cli/test";
268
- import Hero from "./Hero";
269
- import previewData from "../preview.json";
270
- // Pull the runtime schema from the block's config.ts (defineBlock({ schema })).
271
- // Don't import from block.d.ts - that's a type declaration, no runtime value.
272
- import heroConfig from "../config";
273
-
274
- test("renders the heading from content", async () => {
275
- const { getByText } = await renderBlock(Hero, {
276
- content: { heading: "Welcome" },
277
- });
278
- expect(getByText("Welcome")).toBeTruthy();
279
- });
280
-
281
- test("preview data satisfies the block schema", () => {
282
- const { valid, errors } = validatePreviewData(heroConfig.schema, previewData);
283
- expect(valid, errors.join("\n")).toBe(true);
284
- });
285
- ```
286
-
287
- `@testing-library/react` and `react` are loaded dynamically - install them in
288
- your project when you need `renderBlock`:
289
-
290
- ```bash
291
- npm install -D @testing-library/react
292
- ```
293
-
294
- ---
295
-
296
- ### Generate Types from Workspace Schema
297
-
298
- ```bash
299
- cmssy codegen [options]
300
- ```
301
-
302
- Generate TypeScript types from your workspace's public GraphQL schema (powered
303
- by `@graphql-codegen/cli` under the hood).
304
-
305
- **Options:**
306
-
307
- - `-w, --workspace <slug>` - Workspace slug (**required** except for `--init`)
308
- - `-o, --output <path>` - Output path (default: `src/graphql/types.ts`)
309
- - `--init` - Generate a `codegen.ts` config file instead of running codegen
310
-
311
- **First-time setup:**
312
-
313
- ```bash
314
- # 1. Create codegen.ts (works on a fresh project, before `cmssy link`)
315
- cmssy codegen --init
316
-
317
- # 2. Install codegen deps
318
- npm install -D @graphql-codegen/cli @graphql-codegen/typescript @graphql-codegen/typescript-operations
319
-
320
- # 3. Run against your workspace
321
- cmssy codegen --workspace my-workspace-slug
322
- ```
323
-
324
- > **Note on `--workspace`**: this flag takes the workspace _slug_ (e.g.
325
- > `my-workspace-slug`), not the ObjectId stored in `CMSSY_WORKSPACE_ID`. Use
326
- > `cmssy workspaces` to look up the slug.
327
-
328
- ---
329
-
330
- ### Publish a Block
331
-
332
- ```bash
333
- cmssy publish-block <name> [options]
334
- ```
335
-
336
- Send a single block to your workspace via the sandbox build pipeline (Vercel Sandbox + Inngest). The CLI collects the block source tree, uploads it to the backend, and polls the build job until it finishes.
337
-
338
- **Options:**
339
-
340
- - `-w, --workspace [id]` - Workspace id (defaults to `CMSSY_WORKSPACE_ID`)
341
- - `--entry <path>` - Entry path inside the block dir (default: `src/index.tsx`)
342
- - `--dry-run` - Collect files and print the plan without uploading
343
-
344
- **Example:**
345
-
346
- ```bash
347
- # Publish to the workspace configured in .env
348
- cmssy publish-block hero
349
-
350
- # Override workspace
351
- cmssy publish-block hero -w 507f1f77bcf86cd799439011
352
-
353
- # See what would be sent without uploading
354
- cmssy publish-block hero --dry-run
355
- ```
356
-
357
- **Limits:** 200 files / 10 MB total per block. Build polling: 1.5 s interval, 10 min cap, gives up after 5 consecutive errors.
358
-
359
- The legacy `cmssy publish` command + ZIP packaging flow were removed in CMS-606 - all publishing now goes through the sandbox build pipeline.
360
-
361
- ---
362
-
363
- ### Publish a Template
364
-
365
- ```bash
366
- cmssy publish-template <name> [options]
367
- ```
368
-
369
- Publish a single template (page tree + content) to a workspace. Templates are declarative - no sandbox build. The CLI reads `templates/<name>/config.ts` + `pages.json` and uploads via GraphQL.
370
-
371
- **Options:**
372
-
373
- - `-w, --workspace [id]` - Workspace id (defaults to `CMSSY_WORKSPACE_ID`)
374
- - `--patch` / `--minor` / `--major` / `--no-bump` - Version bump strategy
375
- - `--dry-run` - Print the plan without uploading
376
- - `--overwrite-content` - Overwrite existing page content on republish (default: preserve)
377
-
378
- **Example:**
379
-
380
- ```bash
381
- # Publish to the workspace configured in .env
382
- cmssy publish-template marketing-site
383
-
384
- # Override workspace + minor bump
385
- cmssy publish-template blog -w 65f... --minor
386
- ```
387
-
388
- Required blocks listed in the template must already exist in the workspace - publish them via `cmssy publish-block` first.
389
-
390
- ---
391
-
392
- ### Sync from Design Library
393
-
394
- ```bash
395
- cmssy sync [package] [options]
396
- ```
397
-
398
- Pull blocks from Cmssy design library to local project.
399
-
400
- **Options:**
401
-
402
- - `--workspace <id>` - Workspace ID to sync from
403
-
404
- **Example:**
405
-
406
- ```bash
407
- cmssy sync @cmssy/blocks.hero
408
- cmssy sync @cmssy/blocks.hero --workspace 507f1f77bcf86cd799439011
409
- ```
410
-
411
- ---
412
-
413
- ### Migrate to config.ts
414
-
415
- ```bash
416
- cmssy migrate [block-name]
417
- ```
418
-
419
- Migrate from legacy `package.json` cmssy section to new `config.ts` format.
420
-
421
- **Example:**
422
-
423
- ```bash
424
- # Migrate specific block
425
- cmssy migrate hero
426
-
427
- # Migrate all blocks
428
- cmssy migrate
429
- ```
430
-
431
- **What it does:**
432
-
433
- - Converts `package.json` cmssy section to `config.ts`
434
- - Removes cmssy section from `package.json`
435
- - Generates TypeScript types from schema
436
-
437
- ---
438
-
439
- ### List Workspaces
440
-
441
- ```bash
442
- cmssy workspaces
42
+ cmssy link --slug my-workspace --secret <draft-secret> # non-interactive
443
43
  ```
444
44
 
445
- List all workspaces you have access to and get their IDs.
45
+ ### `cmssy add block <name>`
446
46
 
447
- **Example:**
47
+ Scaffold a new block and register it in `cmssy/blocks.ts`. The name is normalized: a folder in
48
+ kebab-case, a PascalCase component, a camelCase registry export.
448
49
 
449
50
  ```bash
450
- cmssy workspaces
51
+ cmssy add block "Feature Grid"
52
+ # -> blocks/feature-grid/{block.ts, FeatureGrid.tsx, FeatureGrid.module.css}
53
+ # registered as featureGridBlock
451
54
  ```
452
55
 
453
- **Output:**
56
+ ### `cmssy doctor`
454
57
 
455
- ```
456
- 📁 Your Workspaces (2):
457
-
458
- Acme Corporation
459
- Slug: acme-corp
460
- ID: 507f1f77bcf86cd799439011
461
- Role: owner
462
-
463
- Team Project
464
- Slug: team-project
465
- ID: 673e4f3b2e8d9c1a4b5f6e8d
466
- Role: member
467
-
468
- 💡 Tip: Copy the ID above and add to .env:
469
- CMSSY_WORKSPACE_ID=507f1f77bcf86cd799439011
470
- ```
471
-
472
- **Use this command to:**
473
-
474
- - Find your workspace IDs for publishing
475
- - See your role in each workspace
476
- - Copy workspace ID to `.env` for CLI usage
477
-
478
- **Requirements:**
479
-
480
- - API token must be configured (run `cmssy link` first)
481
-
482
- ### Install AI Assistant Skills
483
-
484
- ```bash
485
- cmssy skills list # Show available skills
486
- cmssy skills install # Interactive prompt (pick a skill)
487
- cmssy skills install block # CLI + block dev workflow skill
488
- cmssy skills install mcp-content # Content editing via @cmssy/mcp-server
489
- cmssy skills install --all # Install every skill
490
- cmssy skills install block --local # Install into current project's .claude/
491
- cmssy skills install block --force # Overwrite existing skill
492
- ```
493
-
494
- Drops cmssy skills into your Claude Code config so the assistant understands how
495
- to work with cmssy out of the box. Two skills ship today:
496
-
497
- - **`block`** - full CLI + block dev workflow (init, link, create, dev, test,
498
- build, publish, sync, `defineBlock`/`defineTemplate` authoring)
499
- - **`mcp-content`** - managing workspace content through the
500
- [@cmssy/mcp-server](https://www.npmjs.com/package/@cmssy/mcp-server) MCP tools
501
- (i18n rules, layout blocks, forms, publish flow). Requires the MCP server to
502
- be configured in your Claude Code settings first
503
-
504
- After installing, restart Claude Code (or start a new session) and try a prompt
505
- like _"scaffold a pricing block and publish as patch"_ or
506
- _"add a new testimonials block to the homepage, in English and Polish"_.
507
-
508
- **Options:**
509
-
510
- - `--target <editor>` - editor target (default: `claude`; more coming)
511
- - `--all` - install every available skill
512
- - `--local` - install into `./.claude/skills/` in the current project (default: `~/.claude/skills/`)
513
- - `--force` - overwrite an existing skill without prompting
514
- - `-y, --yes` - non-interactive mode (fails instead of prompting on conflict)
515
-
516
- > **Changed in 0.14.0:** the first positional argument is now the **skill
517
- > name** (`block`, `mcp-content`) rather than the editor target. If you were
518
- > using `cmssy skills install claude` on 0.13.x, switch to
519
- > `cmssy skills install block` (or `--all`). Editor target is now a flag:
520
- > `--target claude`.
521
-
522
- ---
523
-
524
- ## Project Structure
525
-
526
- ```
527
- my-blocks/
528
- ├── cmssy.config.js # Project configuration
529
- ├── .env # API credentials (not committed)
530
- ├── .env.example # Example environment variables
531
- ├── blocks/ # Your blocks
532
- │ └── hero/
533
- │ ├── package.json # Block metadata
534
- │ ├── preview.json # Preview data for dev server
535
- │ └── src/
536
- │ ├── index.tsx # Block component
537
- │ └── index.css # Block styles
538
- ├── templates/ # Your page templates
539
- ├── public/ # Build output
540
- │ └── @vendor/package-name/version/
541
- │ ├── index.js
542
- │ ├── index.css
543
- │ └── package.json
544
- └── package.json
545
- ```
546
-
547
- ## Block Metadata
548
-
549
- Each block requires a `cmssy` section in its `package.json`:
550
-
551
- ```json
552
- {
553
- "name": "@myorg/blocks.hero",
554
- "version": "1.0.0",
555
- "description": "Hero section block",
556
- "cmssy": {
557
- "packageType": "block",
558
- "displayName": "Hero Section",
559
- "category": "marketing",
560
- "tags": ["hero", "landing", "cta"],
561
- "schemaFields": [
562
- {
563
- "name": "title",
564
- "type": "singleLine",
565
- "label": "Section Title",
566
- "defaultValue": "Welcome"
567
- }
568
- ],
569
- "defaultContent": {
570
- "title": "Welcome to Our Platform"
571
- }
572
- }
573
- }
574
- ```
575
-
576
- ## Publishing Workflows
577
-
578
- ### Workspace Publishing
579
-
580
- For teams with their own block libraries:
58
+ Diagnose a project's cmssy setup: required files, `@cmssy/*` install + version alignment, env
59
+ vars, and that the block registry's imports resolve. Exits non-zero on a hard failure.
581
60
 
582
61
  ```bash
583
- # 1. Build your blocks locally (optional sanity check)
584
- cmssy build
585
-
586
- # 2. Publish each block via the sandbox build pipeline
587
- cmssy publish-block header -w 507f1f77bcf86cd799439011
588
- cmssy publish-block footer -w 507f1f77bcf86cd799439011
589
-
590
- # 3. Instantly available in your workspace
62
+ cmssy doctor
591
63
  ```
592
64
 
593
- **Use cases:**
594
-
595
- - Private company block libraries
596
- - Internal design systems
597
- - Client-specific components
598
-
599
- **Requirements:**
65
+ ## What "linked" means
600
66
 
601
- - API token with `blocks:write` scope
602
- - Workspace ID
603
- - Published instantly via the sandbox build pipeline (CMS-576)
67
+ Only two values are required (cmssy cloud provides the rest):
604
68
 
605
- ---
69
+ | Variable | Where to find it |
70
+ | ---------------------- | ----------------------------------------------------- |
71
+ | `CMSSY_WORKSPACE_SLUG` | cmssy dashboard → Settings → Headless |
72
+ | `CMSSY_DRAFT_SECRET` | cmssy dashboard → Settings → Headless (per-workspace) |
606
73
 
607
- ## Environment Variables Reference
74
+ ## Docs
608
75
 
609
- | Variable | Required | Description | Example |
610
- | -------------------- | -------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ------------------------------ |
611
- | `CMSSY_API_URL` | No (defaults to `https://api.cmssy.io/graphql`) | Cmssy API GraphQL endpoint - override only when targeting a local/staging backend | `https://api.cmssy.io/graphql` |
612
- | `CMSSY_API_TOKEN` | Yes (any command that hits the API: `publish-block`, `publish-template`, `sync`, `workspaces`, `doctor`) | API authentication token | `cmssy_abc123...` |
613
- | `CMSSY_WORKSPACE_ID` | No (commands that take `-w` fall back to this) | Default workspace ID (MongoDB ObjectId) | `507f1f77bcf86cd799439011` |
76
+ - [cmssy docs](https://www.cmssy.com/docs)
77
+ - [Installation](https://www.cmssy.com/docs/installation) · [Quickstart](https://www.cmssy.com/docs/quickstart)
78
+ - Built on the cmssy SDK: [`@cmssy/next` + `@cmssy/react`](https://github.com/cmssy-io/cmssy-sdk)
614
79
 
615
- ## Requirements
616
-
617
- - Node.js 18+
618
- - npm or yarn
619
-
620
- ## Complete Workflow Examples
621
-
622
- ### Example 1: Workspace Block Library
80
+ ## Contributing
623
81
 
624
82
  ```bash
625
- # Initialize project
626
- cmssy init company-blocks
627
- cd company-blocks
628
-
629
- # Create multiple blocks
630
- cmssy create block header
631
- cmssy create block footer
632
- cmssy create block cta
633
-
634
- # Link to workspace (interactive - picks workspace, writes .env)
635
- cmssy link
636
-
637
- # Verify credentials + API reachability
638
- cmssy doctor
639
-
640
- # Develop and test
641
- cmssy dev
642
-
643
- # Build (sanity check) and publish each block
644
- cmssy build
645
- cmssy publish-block header
646
- cmssy publish-block footer
647
- cmssy publish-block cta
83
+ pnpm install
84
+ pnpm run build # tsup -> dist/cli.js
85
+ pnpm run typecheck
86
+ pnpm test # vitest
648
87
  ```
649
88
 
650
- ---
651
-
652
- ## Troubleshooting
653
-
654
- ### "API token not configured"
655
-
656
- Run `cmssy link` (interactive) or manually add `CMSSY_API_TOKEN` to `.env`.
657
- Run `cmssy doctor` to verify the full setup.
658
-
659
- ### "Workspace ID required"
660
-
661
- **Option 1: From UI**
662
-
663
- 1. Go to Workspace Settings → General
664
- 2. Copy workspace ID using the copy button
665
- 3. Add to `.env`: `CMSSY_WORKSPACE_ID=507f1f77bcf86cd799439011`
666
-
667
- **Option 2: From CLI**
668
-
669
- 1. Run `cmssy workspaces` to list your workspaces
670
- 2. Copy the workspace ID (24-character hex string like `507f1f77bcf86cd799439011`)
671
- 3. Add to `.env`: `CMSSY_WORKSPACE_ID=507f1f77bcf86cd799439011`
672
-
673
- **Option 3: Use flag**
674
-
675
- - Use `--workspace 507f1f77bcf86cd799439011` flag in commands
676
-
677
- ### "Specify publish target"
678
-
679
- Must use `--workspace` flag when publishing
680
-
681
- ### "Not a Cmssy project"
682
-
683
- Make sure you're in a directory with `cmssy.config.js` file
684
-
685
89
  ## License
686
90
 
687
91
  MIT
688
-
689
- ## Support
690
-
691
- - Documentation: [https://cmssy.io/docs](https://cmssy.io/docs)
692
- - Issues: [https://github.com/maciekbe1/cmssy-cli/issues](https://github.com/maciekbe1/cmssy-cli/issues)