cmssy-cli 0.19.6 → 0.20.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.
- package/dist/cli.js +6 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/create.d.ts +12 -2
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +104 -64
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +1 -0
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +157 -12
- package/dist/commands/publish.js.map +1 -1
- package/dist/dev-ui/app.js +245 -7
- package/dist/dev-ui/index.html +264 -0
- package/dist/utils/graphql.d.ts +1 -0
- package/dist/utils/graphql.d.ts.map +1 -1
- package/dist/utils/graphql.js +18 -0
- package/dist/utils/graphql.js.map +1 -1
- package/dist/utils/publish-helpers.d.ts +35 -0
- package/dist/utils/publish-helpers.d.ts.map +1 -0
- package/dist/utils/publish-helpers.js +141 -0
- package/dist/utils/publish-helpers.js.map +1 -0
- package/package.json +7 -2
package/dist/dev-ui/index.html
CHANGED
|
@@ -206,8 +206,244 @@
|
|
|
206
206
|
transform: rotate(180deg);
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
/* Filters Section */
|
|
210
|
+
.blocks-filters {
|
|
211
|
+
padding: 12px;
|
|
212
|
+
border-bottom: 1px solid #e0e0e0;
|
|
213
|
+
background: #fafafa;
|
|
214
|
+
display: flex;
|
|
215
|
+
flex-direction: column;
|
|
216
|
+
gap: 12px;
|
|
217
|
+
flex-shrink: 0;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.container.left-collapsed .blocks-filters {
|
|
221
|
+
opacity: 0;
|
|
222
|
+
pointer-events: none;
|
|
223
|
+
height: 0;
|
|
224
|
+
padding: 0;
|
|
225
|
+
overflow: hidden;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.search-input {
|
|
229
|
+
width: 100%;
|
|
230
|
+
padding: 8px 12px;
|
|
231
|
+
border: 1px solid #ddd;
|
|
232
|
+
border-radius: 6px;
|
|
233
|
+
font-size: 13px;
|
|
234
|
+
background: white;
|
|
235
|
+
transition: all 0.2s;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.search-input:focus {
|
|
239
|
+
outline: none;
|
|
240
|
+
border-color: #667eea;
|
|
241
|
+
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.search-input::placeholder {
|
|
245
|
+
color: #999;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.filter-tabs {
|
|
249
|
+
display: flex;
|
|
250
|
+
gap: 4px;
|
|
251
|
+
background: #e0e0e0;
|
|
252
|
+
padding: 3px;
|
|
253
|
+
border-radius: 8px;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.filter-tab {
|
|
257
|
+
flex: 1;
|
|
258
|
+
padding: 6px 12px;
|
|
259
|
+
border: none;
|
|
260
|
+
background: transparent;
|
|
261
|
+
cursor: pointer;
|
|
262
|
+
font-size: 12px;
|
|
263
|
+
font-weight: 500;
|
|
264
|
+
color: #666;
|
|
265
|
+
border-radius: 6px;
|
|
266
|
+
transition: all 0.2s;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.filter-tab:hover {
|
|
270
|
+
color: #333;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.filter-tab.active {
|
|
274
|
+
background: white;
|
|
275
|
+
color: #333;
|
|
276
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.filter-row {
|
|
280
|
+
display: flex;
|
|
281
|
+
gap: 8px;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.filter-select {
|
|
285
|
+
flex: 1;
|
|
286
|
+
padding: 6px 10px;
|
|
287
|
+
border: 1px solid #ddd;
|
|
288
|
+
border-radius: 6px;
|
|
289
|
+
font-size: 12px;
|
|
290
|
+
background: white;
|
|
291
|
+
cursor: pointer;
|
|
292
|
+
color: #333;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.filter-select:focus {
|
|
296
|
+
outline: none;
|
|
297
|
+
border-color: #667eea;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/* Tags Multi-Select */
|
|
301
|
+
.tags-filter {
|
|
302
|
+
display: flex;
|
|
303
|
+
flex-wrap: wrap;
|
|
304
|
+
gap: 6px;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.tag-chip {
|
|
308
|
+
display: inline-flex;
|
|
309
|
+
align-items: center;
|
|
310
|
+
padding: 4px 10px;
|
|
311
|
+
border: 1px solid #ddd;
|
|
312
|
+
border-radius: 12px;
|
|
313
|
+
font-size: 11px;
|
|
314
|
+
cursor: pointer;
|
|
315
|
+
background: white;
|
|
316
|
+
color: #666;
|
|
317
|
+
transition: all 0.2s;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.tag-chip:hover {
|
|
321
|
+
border-color: #667eea;
|
|
322
|
+
color: #667eea;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.tag-chip.active {
|
|
326
|
+
background: #667eea;
|
|
327
|
+
border-color: #667eea;
|
|
328
|
+
color: white;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.clear-filters {
|
|
332
|
+
padding: 4px 10px;
|
|
333
|
+
border: 1px dashed #ddd;
|
|
334
|
+
border-radius: 12px;
|
|
335
|
+
font-size: 11px;
|
|
336
|
+
cursor: pointer;
|
|
337
|
+
background: transparent;
|
|
338
|
+
color: #999;
|
|
339
|
+
transition: all 0.2s;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.clear-filters:hover {
|
|
343
|
+
border-color: #e53935;
|
|
344
|
+
color: #e53935;
|
|
345
|
+
}
|
|
346
|
+
|
|
209
347
|
.blocks-list {
|
|
210
348
|
padding: 12px;
|
|
349
|
+
overflow-y: auto;
|
|
350
|
+
flex: 1;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/* Category Group */
|
|
354
|
+
.block-category {
|
|
355
|
+
margin-bottom: 16px;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.block-category:last-child {
|
|
359
|
+
margin-bottom: 0;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.category-header {
|
|
363
|
+
font-size: 11px;
|
|
364
|
+
font-weight: 600;
|
|
365
|
+
text-transform: uppercase;
|
|
366
|
+
letter-spacing: 0.5px;
|
|
367
|
+
color: #999;
|
|
368
|
+
padding: 8px 12px 6px;
|
|
369
|
+
margin-bottom: 4px;
|
|
370
|
+
display: flex;
|
|
371
|
+
align-items: center;
|
|
372
|
+
gap: 8px;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.category-count {
|
|
376
|
+
font-size: 10px;
|
|
377
|
+
font-weight: 500;
|
|
378
|
+
background: #e0e0e0;
|
|
379
|
+
padding: 2px 6px;
|
|
380
|
+
border-radius: 10px;
|
|
381
|
+
color: #666;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/* Template badge */
|
|
385
|
+
.type-badge {
|
|
386
|
+
font-size: 10px;
|
|
387
|
+
padding: 2px 6px;
|
|
388
|
+
border-radius: 4px;
|
|
389
|
+
font-weight: 500;
|
|
390
|
+
margin-left: 8px;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
.type-badge.template {
|
|
394
|
+
background: #f3e8ff;
|
|
395
|
+
color: #7c3aed;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.type-badge.block {
|
|
399
|
+
background: #e8f5e9;
|
|
400
|
+
color: #2e7d32;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/* Active filters indicator */
|
|
404
|
+
.active-filters {
|
|
405
|
+
display: flex;
|
|
406
|
+
flex-wrap: wrap;
|
|
407
|
+
gap: 6px;
|
|
408
|
+
padding-top: 4px;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.active-filter-chip {
|
|
412
|
+
display: inline-flex;
|
|
413
|
+
align-items: center;
|
|
414
|
+
gap: 4px;
|
|
415
|
+
padding: 2px 8px;
|
|
416
|
+
background: #667eea;
|
|
417
|
+
color: white;
|
|
418
|
+
border-radius: 10px;
|
|
419
|
+
font-size: 11px;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
.active-filter-chip button {
|
|
423
|
+
background: none;
|
|
424
|
+
border: none;
|
|
425
|
+
color: white;
|
|
426
|
+
cursor: pointer;
|
|
427
|
+
padding: 0;
|
|
428
|
+
font-size: 12px;
|
|
429
|
+
opacity: 0.8;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.active-filter-chip button:hover {
|
|
433
|
+
opacity: 1;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/* Empty state for filtered results */
|
|
437
|
+
.no-results {
|
|
438
|
+
text-align: center;
|
|
439
|
+
padding: 40px 20px;
|
|
440
|
+
color: #999;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.no-results-icon {
|
|
444
|
+
font-size: 32px;
|
|
445
|
+
margin-bottom: 12px;
|
|
446
|
+
opacity: 0.5;
|
|
211
447
|
}
|
|
212
448
|
|
|
213
449
|
.block-item {
|
|
@@ -907,6 +1143,34 @@
|
|
|
907
1143
|
</div>
|
|
908
1144
|
</button>
|
|
909
1145
|
</div>
|
|
1146
|
+
|
|
1147
|
+
<!-- Filters Section -->
|
|
1148
|
+
<div class="blocks-filters" id="blocks-filters">
|
|
1149
|
+
<input
|
|
1150
|
+
type="search"
|
|
1151
|
+
class="search-input"
|
|
1152
|
+
id="search-input"
|
|
1153
|
+
placeholder="Search blocks..."
|
|
1154
|
+
oninput="handleSearchInput(event)"
|
|
1155
|
+
/>
|
|
1156
|
+
|
|
1157
|
+
<div class="filter-tabs">
|
|
1158
|
+
<button class="filter-tab active" data-type="all" onclick="setTypeFilter('all')">All</button>
|
|
1159
|
+
<button class="filter-tab" data-type="block" onclick="setTypeFilter('block')">Blocks</button>
|
|
1160
|
+
<button class="filter-tab" data-type="template" onclick="setTypeFilter('template')">Templates</button>
|
|
1161
|
+
</div>
|
|
1162
|
+
|
|
1163
|
+
<div class="filter-row">
|
|
1164
|
+
<select class="filter-select" id="category-filter" onchange="setCategoryFilter(this.value)">
|
|
1165
|
+
<option value="">All Categories</option>
|
|
1166
|
+
</select>
|
|
1167
|
+
</div>
|
|
1168
|
+
|
|
1169
|
+
<div class="tags-filter" id="tags-filter">
|
|
1170
|
+
<!-- Tags will be populated dynamically -->
|
|
1171
|
+
</div>
|
|
1172
|
+
</div>
|
|
1173
|
+
|
|
910
1174
|
<div class="blocks-list" id="blocks-list">
|
|
911
1175
|
<div class="loading">
|
|
912
1176
|
<div class="spinner"></div>
|
package/dist/utils/graphql.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ import { GraphQLClient } from "graphql-request";
|
|
|
2
2
|
export declare function createClient(): GraphQLClient;
|
|
3
3
|
export declare const PUBLISH_PACKAGE_MUTATION = "\n mutation PublishPackage($token: String!, $input: PublishPackageInput!) {\n publishPackage(token: $token, input: $input) {\n success\n message\n packageId\n status\n }\n }\n";
|
|
4
4
|
export declare const IMPORT_BLOCK_MUTATION = "\n mutation ImportBlock($input: ImportBlockInput!) {\n importBlock(input: $input) {\n id\n blockType\n name\n description\n icon\n category\n layoutSlot\n schemaFields {\n key\n type\n label\n defaultValue\n placeholder\n required\n helperText\n options\n minValue\n maxValue\n group\n showWhen {\n field\n equals\n notEquals\n notEmpty\n isEmpty\n }\n validation {\n minLength\n maxLength\n min\n max\n pattern\n message\n }\n }\n defaultContent\n requires {\n auth\n language\n workspace\n modules\n permissions\n features\n }\n version\n createdAt\n }\n }\n";
|
|
5
|
+
export declare const IMPORT_TEMPLATE_MUTATION = "\n mutation ImportTemplate($input: ImportTemplateInput!) {\n importTemplate(input: $input) {\n success\n block {\n id\n blockType\n name\n version\n }\n pagesCreated\n pagesUpdated\n layoutSlotsCreated\n layoutSlotsUpdated\n message\n }\n }\n";
|
|
5
6
|
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/utils/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,wBAAgB,YAAY,IAAI,aAAa,CAe5C;AAGD,eAAO,MAAM,wBAAwB,gNASpC,CAAC;AAEF,eAAO,MAAM,qBAAqB,y3BAmDjC,CAAC"}
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../src/utils/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,wBAAgB,YAAY,IAAI,aAAa,CAe5C;AAGD,eAAO,MAAM,wBAAwB,gNASpC,CAAC;AAEF,eAAO,MAAM,qBAAqB,y3BAmDjC,CAAC;AAEF,eAAO,MAAM,wBAAwB,mUAiBpC,CAAC"}
|
package/dist/utils/graphql.js
CHANGED
|
@@ -75,4 +75,22 @@ export const IMPORT_BLOCK_MUTATION = `
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
`;
|
|
78
|
+
export const IMPORT_TEMPLATE_MUTATION = `
|
|
79
|
+
mutation ImportTemplate($input: ImportTemplateInput!) {
|
|
80
|
+
importTemplate(input: $input) {
|
|
81
|
+
success
|
|
82
|
+
block {
|
|
83
|
+
id
|
|
84
|
+
blockType
|
|
85
|
+
name
|
|
86
|
+
version
|
|
87
|
+
}
|
|
88
|
+
pagesCreated
|
|
89
|
+
pagesUpdated
|
|
90
|
+
layoutSlotsCreated
|
|
91
|
+
layoutSlotsUpdated
|
|
92
|
+
message
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
78
96
|
//# sourceMappingURL=graphql.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/utils/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,UAAU,YAAY;IAC1B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAE5B,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,sDAAsD,CACvD,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE;QACtC,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,MAAM,CAAC,QAAQ,EAAE;SAC3C;KACF,CAAC,CAAC;AACL,CAAC;AAED,oBAAoB;AACpB,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;CASvC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDpC,CAAC"}
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../../src/utils/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,UAAU,YAAY;IAC1B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAE5B,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,sDAAsD,CACvD,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE;QACtC,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,MAAM,CAAC,QAAQ,EAAE;SAC3C;KACF,CAAC,CAAC;AACL,CAAC;AAED,oBAAoB;AACpB,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;CASvC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDpC,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;CAiBvC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for the publish command.
|
|
3
|
+
* Extracted for testability.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Convert block.config.ts schema to schemaFields array for GraphQL mutation.
|
|
7
|
+
*/
|
|
8
|
+
export declare function convertSchemaToFields(schema: Record<string, any>): any[];
|
|
9
|
+
/**
|
|
10
|
+
* Extract default content values from schema.
|
|
11
|
+
*/
|
|
12
|
+
export declare function extractDefaultContent(schema: Record<string, any>): any;
|
|
13
|
+
/**
|
|
14
|
+
* Extract block type from full package name.
|
|
15
|
+
* @example "@cmssy/blocks.hero" -> "hero"
|
|
16
|
+
* @example "@org/templates.landing" -> "landing"
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractBlockType(packageName: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Add __component to mount/update pattern for SSR compatibility.
|
|
21
|
+
* This makes blocks work in both dev environment (mount/update) and SSR (__component).
|
|
22
|
+
*/
|
|
23
|
+
export declare function addComponentForSSR(code: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Detect if a package is a template based on type.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isTemplate(packageType: "block" | "template"): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Parse pages.json data and convert to mutation input format.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parsePagesJson(pagesData: any): {
|
|
32
|
+
pages: any[];
|
|
33
|
+
layoutSlots: any[];
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=publish-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/publish-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,CAwDxE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAYtE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAK5D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAsCvD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,WAAW,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAErE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,GAAG,GAAG;IAC9C,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,WAAW,EAAE,GAAG,EAAE,CAAC;CACpB,CA0BA"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for the publish command.
|
|
3
|
+
* Extracted for testability.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Convert block.config.ts schema to schemaFields array for GraphQL mutation.
|
|
7
|
+
*/
|
|
8
|
+
export function convertSchemaToFields(schema) {
|
|
9
|
+
const fields = [];
|
|
10
|
+
Object.entries(schema).forEach(([key, field]) => {
|
|
11
|
+
const baseField = {
|
|
12
|
+
key,
|
|
13
|
+
type: field.type,
|
|
14
|
+
label: field.label,
|
|
15
|
+
required: field.required || false,
|
|
16
|
+
};
|
|
17
|
+
// Add defaultValue if present
|
|
18
|
+
if (field.defaultValue !== undefined) {
|
|
19
|
+
baseField.defaultValue = field.defaultValue;
|
|
20
|
+
}
|
|
21
|
+
// Add placeholder if present
|
|
22
|
+
if (field.placeholder) {
|
|
23
|
+
baseField.placeholder = field.placeholder;
|
|
24
|
+
}
|
|
25
|
+
// Add helpText if present
|
|
26
|
+
if (field.helpText) {
|
|
27
|
+
baseField.helperText = field.helpText;
|
|
28
|
+
}
|
|
29
|
+
// Add group if present
|
|
30
|
+
if (field.group) {
|
|
31
|
+
baseField.group = field.group;
|
|
32
|
+
}
|
|
33
|
+
// Add showWhen conditional visibility
|
|
34
|
+
if (field.showWhen) {
|
|
35
|
+
baseField.showWhen = field.showWhen;
|
|
36
|
+
}
|
|
37
|
+
// Add validation rules
|
|
38
|
+
if (field.validation) {
|
|
39
|
+
baseField.validation = field.validation;
|
|
40
|
+
}
|
|
41
|
+
if (field.type === "select" && field.options) {
|
|
42
|
+
baseField.options = field.options;
|
|
43
|
+
}
|
|
44
|
+
if (field.type === "repeater" && field.schema) {
|
|
45
|
+
baseField.minItems = field.minItems;
|
|
46
|
+
baseField.maxItems = field.maxItems;
|
|
47
|
+
// Backend expects itemSchema to be a flat array of field definitions
|
|
48
|
+
baseField.itemSchema = convertSchemaToFields(field.schema);
|
|
49
|
+
}
|
|
50
|
+
fields.push(baseField);
|
|
51
|
+
});
|
|
52
|
+
return fields;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Extract default content values from schema.
|
|
56
|
+
*/
|
|
57
|
+
export function extractDefaultContent(schema) {
|
|
58
|
+
const content = {};
|
|
59
|
+
Object.entries(schema).forEach(([key, field]) => {
|
|
60
|
+
if (field.defaultValue !== undefined) {
|
|
61
|
+
content[key] = field.defaultValue;
|
|
62
|
+
}
|
|
63
|
+
else if (field.type === "repeater") {
|
|
64
|
+
content[key] = [];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return content;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Extract block type from full package name.
|
|
71
|
+
* @example "@cmssy/blocks.hero" -> "hero"
|
|
72
|
+
* @example "@org/templates.landing" -> "landing"
|
|
73
|
+
*/
|
|
74
|
+
export function extractBlockType(packageName) {
|
|
75
|
+
return packageName
|
|
76
|
+
.replace(/@[^/]+\//, "") // Remove @scope/
|
|
77
|
+
.replace(/^blocks\./, "") // Remove blocks. prefix
|
|
78
|
+
.replace(/^templates\./, ""); // Remove templates. prefix
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Add __component to mount/update pattern for SSR compatibility.
|
|
82
|
+
* This makes blocks work in both dev environment (mount/update) and SSR (__component).
|
|
83
|
+
*/
|
|
84
|
+
export function addComponentForSSR(code) {
|
|
85
|
+
// Check if code exports mount/update pattern
|
|
86
|
+
const hasPattern = /exports\.default\s*=\s*\{[^}]*mount\s*\([^)]*\)/s.test(code) ||
|
|
87
|
+
/module\.exports\s*=\s*\{[^}]*mount\s*\([^)]*\)/s.test(code);
|
|
88
|
+
if (!hasPattern) {
|
|
89
|
+
// No mount/update pattern - return as-is
|
|
90
|
+
return code;
|
|
91
|
+
}
|
|
92
|
+
// Find the component that's being used in mount()
|
|
93
|
+
// Pattern: export default { mount() { ... render(<Component ... /> or createElement(Component ...) } }
|
|
94
|
+
const componentMatch = code.match(/(?:render|createElement)\s*\(\s*(?:<\s*)?(\w+)/);
|
|
95
|
+
const componentName = componentMatch?.[1];
|
|
96
|
+
if (!componentName) {
|
|
97
|
+
console.warn("[CLI] Warning: Found mount/update pattern but could not extract component name for __component");
|
|
98
|
+
return code;
|
|
99
|
+
}
|
|
100
|
+
// Add __component to the exports object
|
|
101
|
+
// Replace: module.exports = { mount, update, unmount };
|
|
102
|
+
// With: module.exports = { mount, update, unmount, __component: ComponentName };
|
|
103
|
+
const updatedCode = code.replace(/((?:exports\.default|module\.exports)\s*=\s*\{[^}]*)(}\s*;)/s, `$1,\n // Auto-added by CLI for SSR compatibility\n __component: ${componentName}\n$2`);
|
|
104
|
+
if (updatedCode === code) {
|
|
105
|
+
console.warn("[CLI] Warning: Could not add __component to exports");
|
|
106
|
+
}
|
|
107
|
+
return updatedCode;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Detect if a package is a template based on type.
|
|
111
|
+
*/
|
|
112
|
+
export function isTemplate(packageType) {
|
|
113
|
+
return packageType === "template";
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Parse pages.json data and convert to mutation input format.
|
|
117
|
+
*/
|
|
118
|
+
export function parsePagesJson(pagesData) {
|
|
119
|
+
// Convert pages
|
|
120
|
+
const pages = (pagesData.pages || []).map((page) => ({
|
|
121
|
+
name: page.name,
|
|
122
|
+
slug: page.slug,
|
|
123
|
+
blocks: (page.blocks || []).map((block) => ({
|
|
124
|
+
type: block.type,
|
|
125
|
+
content: block.content || {},
|
|
126
|
+
})),
|
|
127
|
+
}));
|
|
128
|
+
// Convert layoutSlots to array format
|
|
129
|
+
const layoutSlots = [];
|
|
130
|
+
if (pagesData.layoutSlots) {
|
|
131
|
+
for (const [slot, data] of Object.entries(pagesData.layoutSlots)) {
|
|
132
|
+
layoutSlots.push({
|
|
133
|
+
slot,
|
|
134
|
+
type: data.type,
|
|
135
|
+
content: data.content || {},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return { pages, layoutSlots };
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=publish-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-helpers.js","sourceRoot":"","sources":["../../src/utils/publish-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAA2B;IAC/D,MAAM,MAAM,GAAU,EAAE,CAAC;IAEzB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAgB,EAAE,EAAE;QAC7D,MAAM,SAAS,GAAQ;YACrB,GAAG;YACH,IAAI,EAAE,KAAK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MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CACvC,SAAS,CAAC,WAAkC,CAC7C,EAAE,CAAC;YACF,WAAW,CAAC,IAAI,CAAC;gBACf,IAAI;gBACJ,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;aAC5B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cmssy-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Unified CLI for building and publishing blocks to Cmssy marketplace",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "tsc && tsc config.ts --module esnext --target esnext --moduleResolution bundler && tsc config.ts --declaration --emitDeclarationOnly --module esnext --target esnext --moduleResolution bundler && cp -r src/dev-ui dist/",
|
|
16
16
|
"dev": "tsc --watch",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:watch": "vitest",
|
|
19
|
+
"test:coverage": "vitest run --coverage",
|
|
17
20
|
"prepare": "npm run build"
|
|
18
21
|
},
|
|
19
22
|
"keywords": [
|
|
@@ -71,6 +74,8 @@
|
|
|
71
74
|
"@types/node": "^22.10.2",
|
|
72
75
|
"@types/node-fetch": "^2.6.13",
|
|
73
76
|
"@types/semver": "^7.7.1",
|
|
74
|
-
"
|
|
77
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
78
|
+
"typescript": "^5.7.2",
|
|
79
|
+
"vitest": "^3.2.4"
|
|
75
80
|
}
|
|
76
81
|
}
|