contensis-cli 1.1.2-beta.9 → 1.2.1-beta.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/CHANGELOG.md +30 -0
- package/README.md +169 -8
- package/cli.js +16 -0
- package/dist/commands/copy.js +11 -3
- package/dist/commands/copy.js.map +2 -2
- package/dist/commands/create.js +1 -1
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/get.js +5 -5
- package/dist/commands/get.js.map +2 -2
- package/dist/commands/globalOptions.js +15 -2
- package/dist/commands/globalOptions.js.map +2 -2
- package/dist/commands/import.js +2 -2
- package/dist/commands/import.js.map +1 -1
- package/dist/localisation/en-GB.js +4 -4
- package/dist/localisation/en-GB.js.map +2 -2
- package/dist/services/ContensisCliService.js +66 -51
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/docs/copy_field_templates.md +354 -0
- package/docs/copy_field_transformation_matrix.md +65 -0
- package/package.json +4 -3
- package/src/commands/copy.ts +15 -1
- package/src/commands/create.ts +1 -1
- package/src/commands/get.ts +7 -7
- package/src/commands/globalOptions.ts +13 -3
- package/src/commands/import.ts +2 -2
- package/src/localisation/en-GB.ts +4 -4
- package/src/services/ContensisCliService.ts +75 -53
- package/src/version.ts +1 -1
- package/tsconfig.json +1 -0
package/dist/version.js
CHANGED
|
@@ -21,7 +21,7 @@ __export(version_exports, {
|
|
|
21
21
|
LIB_VERSION: () => LIB_VERSION
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(version_exports);
|
|
24
|
-
const LIB_VERSION = "1.1
|
|
24
|
+
const LIB_VERSION = "1.2.1-beta.0";
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
LIB_VERSION
|
package/dist/version.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/version.ts"],
|
|
4
|
-
"sourcesContent": ["export const LIB_VERSION = \"1.1
|
|
4
|
+
"sourcesContent": ["export const LIB_VERSION = \"1.2.1-beta.0\";\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
## Apply a template
|
|
2
|
+
|
|
3
|
+
If your field type is not supported in the [copy field transformation matrix](copy_field_transformation_matrix.md), or you wish to modify the output value for the field we can supply a [LiquidJS](https://liquidjs.com/tutorials/intro-to-liquid.html) template where we can make use of "tags" and "filters" available in LiquidJS to perform custom transformations on our entry field data
|
|
4
|
+
|
|
5
|
+
The result after parsing this template will become the new value for the destination field for every entry
|
|
6
|
+
|
|
7
|
+
Templates allow us to to make some very precise adjustments to the field value we will update
|
|
8
|
+
|
|
9
|
+
A number of variables are available to use in the liquid template
|
|
10
|
+
|
|
11
|
+
- `value` - the value of the source field in the entry
|
|
12
|
+
- `existing_value` - any existing value of the target field in the entry
|
|
13
|
+
- `target_value` - the value that has been prepared to go into the destination field
|
|
14
|
+
- `entry` - the entire entry object (if we need to reference another field in the entry)
|
|
15
|
+
- `field` - the content type configuration of the source field
|
|
16
|
+
- `target_field` - the content type configuration of the target field
|
|
17
|
+
|
|
18
|
+
### Examples
|
|
19
|
+
|
|
20
|
+
These are simple examples of using and chaining [LiquidJS filters](https://liquidjs.com/filters/overview.html)
|
|
21
|
+
|
|
22
|
+
- `"{{ value | capitalize }}"` will capitalise the first letter of the value
|
|
23
|
+
- `"{{ value | downcase }}"` will lowercase the entire value
|
|
24
|
+
- `"{{ value | downcase | capitalize }}"` will lowercase the entire value then capitalise the first letter
|
|
25
|
+
- `"{{ value >= 50 }}"` using logic based on a source field value we can set a boolean to true or false
|
|
26
|
+
|
|
27
|
+
Use of [LiquidJS tags](https://liquidjs.com/tags/overview.html) is also available for more complex scenarios
|
|
28
|
+
|
|
29
|
+
### Apply the template before any field transformation
|
|
30
|
+
|
|
31
|
+
Templates are parsed and rendered after field transformations have taken place and the resulting value is set on the entry as our new field's value.
|
|
32
|
+
|
|
33
|
+
A special variable is available called `source_value` (which is the same as `value`) except when used, the template is parsed and rendered *prior* to any field transformations taking place.
|
|
34
|
+
|
|
35
|
+
The result of this template when parsed will override the source field's value from each entry and this will be transformed again to the target field's type before the resulting value is set on the entry as our target field's value.
|
|
36
|
+
|
|
37
|
+
This is necessary if you wish to alter the source field value prior to any internal transformations (e.g. before we convert the value to a canvas field).
|
|
38
|
+
|
|
39
|
+
Using `source_value` means `target_value` and `value` variables are not available.
|
|
40
|
+
|
|
41
|
+
#### Examples
|
|
42
|
+
|
|
43
|
+
- `"<h1>{{ source_value }}</h1>"` allows us to surround our `source_value` with some text before it is converted into the destination field type (e.g. canvas)
|
|
44
|
+
- `"{{ source_value | remove: ".aspx" }}"` will remove any instance of `.aspx` from our source value
|
|
45
|
+
|
|
46
|
+
### Transform Composer content with a template
|
|
47
|
+
|
|
48
|
+
Because of the near infinite flexibility provided by Composer field configurations, in order to transform parts of, or the entire contents of a Composer field in an entry to another field type (except canvas which is now supported by default), we can do this by writing our own template to configure how each item in the Composer is to be "rendered" before adding the transformation result to our destination entry field.
|
|
49
|
+
|
|
50
|
+
#### Examples
|
|
51
|
+
|
|
52
|
+
If we have the following Composer content in JSON containing a number of different data types or "Composer items":
|
|
53
|
+
|
|
54
|
+
```JSON
|
|
55
|
+
[
|
|
56
|
+
{
|
|
57
|
+
"type": "text",
|
|
58
|
+
"value": "This is my plain text"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"type": "markup",
|
|
62
|
+
"value": "<p>This is rich <em>text</em> with some <strong>styling</strong></p>"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"type": "quote",
|
|
66
|
+
"value": {
|
|
67
|
+
"source": "This is the source",
|
|
68
|
+
"text": "This is a quote"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"type": "number",
|
|
73
|
+
"value": 123456789
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"type": "boolean",
|
|
77
|
+
"value": false
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"type": "location",
|
|
81
|
+
"value": {
|
|
82
|
+
"lat": 51.584151,
|
|
83
|
+
"lon": -2.997664
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"type": "list",
|
|
88
|
+
"value": [
|
|
89
|
+
"Plum",
|
|
90
|
+
"Orange",
|
|
91
|
+
"Banana"
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"type": "iconWithText",
|
|
96
|
+
"value": {
|
|
97
|
+
"icon": {
|
|
98
|
+
"sys": {
|
|
99
|
+
"id": "51639de0-a1e4-4352-b166-17f86e3558bf"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"text": "This is my icon text"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"type": "asset",
|
|
107
|
+
"value": {
|
|
108
|
+
"sys": {
|
|
109
|
+
"id": "e798df96-1de3-4b08-a270-3787b902a580"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"type": "image",
|
|
115
|
+
"value": {
|
|
116
|
+
"altText": "A photo of Richard Saunders.",
|
|
117
|
+
"asset": {
|
|
118
|
+
"sys": {
|
|
119
|
+
"id": "bc6435eb-c2e3-4cef-801f-b6061f9cdad6"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
We could supply a template to pull out specific item types into our destination field
|
|
128
|
+
|
|
129
|
+
The example below will take the list field above and allow the content to be copied into any string type field
|
|
130
|
+
|
|
131
|
+
```handlebars
|
|
132
|
+
{% # use a "for" tag to iterate over our "value" variable (composer field) %}
|
|
133
|
+
{% for c_item in value %}
|
|
134
|
+
{% # use an "if" tag to match a composer item type of list in the composer array %}
|
|
135
|
+
{% if c_item.type == 'list' %}
|
|
136
|
+
{% # render any list from the composer field, use a "join" filter to convert the value array to a string %}
|
|
137
|
+
{{ c_item.value | join: ', ' }}
|
|
138
|
+
{% # close the "if" tag %}
|
|
139
|
+
{% endif %}
|
|
140
|
+
{% # close the "for" tag %}
|
|
141
|
+
{% endfor %}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
A short hand example similar to the above using only LiquidJS filters
|
|
145
|
+
|
|
146
|
+
Taking the `value` (a composer item array), filtering just the composer item types of 'list', mapping just the 'value' taking the `first` found 'list' and concatenating the values into a comma-separated string.
|
|
147
|
+
|
|
148
|
+
```handlebars
|
|
149
|
+
{{ value | where: 'type', 'list' | map: 'value' | first | join: ', ' }}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
So a composer field containing this JSON
|
|
153
|
+
|
|
154
|
+
```JSON
|
|
155
|
+
[{
|
|
156
|
+
"type": "list",
|
|
157
|
+
"value": [
|
|
158
|
+
"Plum",
|
|
159
|
+
"Orange",
|
|
160
|
+
"Banana"
|
|
161
|
+
]
|
|
162
|
+
}]
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
becomes `Plum, Orange, Banana`
|
|
166
|
+
|
|
167
|
+
Or render the same list field data ready to copy into a Rich text or Canvas field, we are free to decorate any value with required markup so it is presented and transformed correctly.
|
|
168
|
+
|
|
169
|
+
```handlebars
|
|
170
|
+
{% for c_item in source_value %} {% if c_item.type == 'list' %}
|
|
171
|
+
<ul>
|
|
172
|
+
{% for l_item in c_item.value %}
|
|
173
|
+
<li>{{l_item}}</li>
|
|
174
|
+
{% endfor %}
|
|
175
|
+
</ul>
|
|
176
|
+
{% endif %} {% endfor %}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Transforming Composer content to Canvas
|
|
180
|
+
|
|
181
|
+
To transform the above Composer content into a Canvas field, we would need to "render" each item in the Composer that we require in the Canvas field as a very simple HTML representation, and this becomes the value we pass to the HTML parser that in turn renders the JSON that allows us to store the Canvas content in Contensis.
|
|
182
|
+
|
|
183
|
+
The same kind of theory can be applied to any source field we wish to convert to Canvas content
|
|
184
|
+
|
|
185
|
+
We must use the `source_value` variable in the template instead of `value` variable as the template needs to alter the source value and be applied _before_ the process transforms the value into Canvas
|
|
186
|
+
|
|
187
|
+
If the source field (or composer item value) is already a rich text field containing existing markup, we don't need to do any special rendering before this is parsed and converted to Canvas content
|
|
188
|
+
|
|
189
|
+
```handlebars
|
|
190
|
+
{% for c_item in source_value %}
|
|
191
|
+
{% if c_item.type == 'markup' %}{{ c_item.value }}
|
|
192
|
+
{% elsif c_item.type == 'quote' %}
|
|
193
|
+
<p>{{ c_item.value.source }}</p>
|
|
194
|
+
<blockquote>{{ c_item.value.text }}</blockquote>
|
|
195
|
+
{% elsif c_item.type == 'image' %}
|
|
196
|
+
<img src='{{ c_item.value.asset.sys.uri }}' alt='{{ c_item.value.altText }}'/>
|
|
197
|
+
{% else %}<p>{{ c_item.value | join: '</p><p>' | json }}</p>
|
|
198
|
+
{% endif %}
|
|
199
|
+
{% endfor %}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Embedding Component data in Canvas
|
|
203
|
+
|
|
204
|
+
We can curate and store Component data inline with Canvas content in the Contensis editor.
|
|
205
|
+
|
|
206
|
+
Component data will likely be encountered as part of a parent composer field when converting long-form composer-curated content to Canvas.
|
|
207
|
+
|
|
208
|
+
Following on from the examples above, we have a component in the composer data of type `iconWithText`. We need to also know the api id of the component (which can be found in the composer field definition in the Content type editor), as the component api id is often different from how it is named in the composer field.
|
|
209
|
+
|
|
210
|
+
```handlebars
|
|
211
|
+
{% for c_item in source_value %}
|
|
212
|
+
{% # ... %}
|
|
213
|
+
{% elsif c_item.type == 'iconWithText' %}
|
|
214
|
+
{{ c_item.value | canvas_component: 'iconWithText' }}
|
|
215
|
+
{% # ... %}
|
|
216
|
+
{% endif %}
|
|
217
|
+
{% endfor %}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
In the above template when we encounter a composer item with a type of `iconWithText` we can render it and apply the custom filter `canvas_component` to the composer item value, supplying the component api id as an argument to this filter
|
|
221
|
+
|
|
222
|
+
Rendering the component with the custom filter will produce an output that will allow the component (and its content) to be parsed and stored inline in Canvas field content:
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
<div class='component' data-component='iconWithText' data-component-value='{"icon":{"sys":{"id":"51639de0-a1e4-4352-b166-17f86e3558bf","dataFormat":"entry","contentTypeId":"icon"}},"text":"This is my icon text"}'></div>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### Further component customisation
|
|
229
|
+
|
|
230
|
+
If you need to customise the component output for the canvas content any further, you can instead not use the suggested custom filter and render the component data as markup following the example output above.
|
|
231
|
+
|
|
232
|
+
```handlebars
|
|
233
|
+
{% for c_item in source_value %}
|
|
234
|
+
{% # ... %}
|
|
235
|
+
{% elsif c_item.type == 'iconWithText' %}
|
|
236
|
+
<div class='component' data-component='iconWithText' data-component-value='{{ c_item.value | html_encode }}'></div>
|
|
237
|
+
{% # ... %}
|
|
238
|
+
{% endif %}
|
|
239
|
+
{% endfor %}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
Another custom filter `html_encode` used here is provided to help render the `data-component-value` attribute with the correct encoding to be parsed and embedded into the canvas content
|
|
243
|
+
|
|
244
|
+
#### Curate redundant components as canvas
|
|
245
|
+
|
|
246
|
+
If it is preferred for any reason, instead of embedding component data inline in the canvas content, you could stop using the component field and have the content curated, stored and rendered from regular canvas content blocks going forward.
|
|
247
|
+
|
|
248
|
+
You would use a template to render the data from each component field wrapped in simple appropriate markup so it will be represented like this within canvas content blocks in Contensis after the field data has been copied and converted to canvas.
|
|
249
|
+
|
|
250
|
+
### Embedding Entry (and asset) links in Canvas
|
|
251
|
+
|
|
252
|
+
Continuing the example above, we can embed an inline entry link from every matched composer item easily into the canvas content by applying custom filter `canvas_entry`
|
|
253
|
+
|
|
254
|
+
```handlebars
|
|
255
|
+
{% for c_item in source_value %}
|
|
256
|
+
{% # ... %}
|
|
257
|
+
{% elsif c_item.type == 'entry' %}
|
|
258
|
+
{{ c_item.value | canvas_entry }}
|
|
259
|
+
{% # ... %}
|
|
260
|
+
{% endif %}
|
|
261
|
+
{% endfor %}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Produces output similar to the HTML below which can be parsed and saved inside the canvas content
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
<a class='inline-entry' data-entry='{"sys":{"id":"eee9129e-70fc-4f70-b641-01e160af2438","dataFormat":"entry","contentTypeId":"person"}}'></a>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Another example of embedding an entry link into canvas where we could be converting existing rich text content to canvas and need to link/append a certain entry at the bottom of every entry's canvas content.
|
|
271
|
+
|
|
272
|
+
```handlebars
|
|
273
|
+
{{ source_value }}
|
|
274
|
+
{{ entry.tsAndCs | canvas_entry }}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
If we need to hard code a specific entry id into the canvas after a rich text field:
|
|
278
|
+
|
|
279
|
+
```handlebars
|
|
280
|
+
{{ source_value }}
|
|
281
|
+
{% capture link_entry %}
|
|
282
|
+
{ "sys": { "id": "eee9129e-70fc-4f70-b641-01e160af2438", "contentTypeId": "person" } }
|
|
283
|
+
{% endcapture %}
|
|
284
|
+
{{ link_entry | from_json | canvas_entry }}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
In the final output we are applying two custom filters to our `link_entry`, `from_json` allows us to use a `capture` tag and hardcode our own json, then parse this as a json object that can be read normally within the template (something which cannot be done natively in LiquidJS).
|
|
288
|
+
|
|
289
|
+
Further applying `canvas_entry` filter will convert our parsed JSON object into the markup that is valid for loading with canvas content
|
|
290
|
+
|
|
291
|
+
```handlebars
|
|
292
|
+
{{ source_value }}
|
|
293
|
+
{{ '{ "sys": { "id": "eee9129e-70fc-4f70-b641-01e160af2438", "contentTypeId": "person" } }' | from_json | canvas_entry }}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
We can achieve the same effect by applying the filter chain to a hardcoded valid JSON string
|
|
297
|
+
|
|
298
|
+
### Embedding Images in Canvas
|
|
299
|
+
|
|
300
|
+
Continuing with the composer example above, we can embed an existing image into the canvas content by applying custom filter `canvas_image`
|
|
301
|
+
|
|
302
|
+
We also need to ensure we have supplied the option to query the delivery api, as entries returned in the management api search do not contain the image uri in any image fields as the delivery api does.
|
|
303
|
+
|
|
304
|
+
```handlebars
|
|
305
|
+
{% for c_item in source_value %}
|
|
306
|
+
{% # ... %}
|
|
307
|
+
{% elsif c_item.type == 'image' %}
|
|
308
|
+
{{ c_item.value | canvas_image }}
|
|
309
|
+
{% # ... %}
|
|
310
|
+
{% endif %}
|
|
311
|
+
{% endfor %}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Produces output similar to the HTML below which can be parsed and saved inside the canvas content
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
<img src='/image-library/people-images/richard-saunders-blog-image.x67b5a698.png' altText='A photo of Richard Saunders.'/>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Images from existing, external or hardcoded content can be added to the canvas by rendering the image details out into valid markup including an `<img />` tag with a completed `src=""` attribute
|
|
321
|
+
|
|
322
|
+
### Complete composer example
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
```handlebars
|
|
326
|
+
{% for c_item in source_value %}
|
|
327
|
+
{% if c_item.type == 'markup' %}{{ c_item.value }}
|
|
328
|
+
{% elsif c_item.type == 'quote' %}
|
|
329
|
+
<p>{{ c_item.value.source }}</p>
|
|
330
|
+
<blockquote>{{ c_item.value.text }}</blockquote>
|
|
331
|
+
{% elsif c_item.type == 'iconWithText' %}{{ c_item.value | canvas_component: 'iconWithText' }}
|
|
332
|
+
{% elsif c_item.type == 'image' %}{{ c_item.value | canvas_image }}
|
|
333
|
+
{% elsif c_item.type == 'asset' or c_item.type == 'entry' %}{{ c_item.value | canvas_entry }}
|
|
334
|
+
{% elsif c_item.type == 'boolean' and c_item.value %}Boolean: Yes
|
|
335
|
+
{% else %}<p>{{ c_item.value | join: '</p><p>' | json }}</p>
|
|
336
|
+
{% endif %}
|
|
337
|
+
{% endfor %}
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Concatenate multiple entry fields
|
|
341
|
+
|
|
342
|
+
We can utilise a LiquidJS template to concatenate multiple field values together and copy to a destination field
|
|
343
|
+
|
|
344
|
+
In the example below we will copy the value of the source field to the destination field but also append any existing value if it exists
|
|
345
|
+
|
|
346
|
+
```handlebars
|
|
347
|
+
{{value}}{% if existing_value %} - {{existing_value}}{% endif %}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Or we can refer to other fields in the `entry` variable
|
|
351
|
+
|
|
352
|
+
```handlebars
|
|
353
|
+
{{entry.text}}{% if entry.heading %} - {{entry.heading}}{% endif %}
|
|
354
|
+
```
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
## Copy field transformation matrix
|
|
2
|
+
|
|
3
|
+
Copying field data directly from one field to another can be done directly with the source and destination field types metioned in the below table
|
|
4
|
+
|
|
5
|
+
When we copy certain field types, a transformation is made to the data to make it compatible with the destination field type.
|
|
6
|
+
|
|
7
|
+
Copying a field will overwrite any data in the destination field, it will not preserve or respect any data that currently exists or has been manually entered. The destination field also needs to exist in the Content Type we are targeting.
|
|
8
|
+
|
|
9
|
+
Finer grained control of the field data transformation (including field types not supported directly) can be made using a [template](copy_field_templates.md)
|
|
10
|
+
|
|
11
|
+
| source | destination | notes |
|
|
12
|
+
| ---------------------------- | ---------------------------- | ------------------------------------------------------------------------------------- |
|
|
13
|
+
| string | string | |
|
|
14
|
+
| | stringArray | |
|
|
15
|
+
| | canvas | Content is surrounded within a paragraph block (template can alter the source value) |
|
|
16
|
+
| | richText | |
|
|
17
|
+
| | richTextArray | |
|
|
18
|
+
| | boolean | True if evaluates "truthy" (0, false or null would be false) |
|
|
19
|
+
| stringArray | stringArray | |
|
|
20
|
+
| | string | Multiples separated with newline |
|
|
21
|
+
| | canvas | ^ |
|
|
22
|
+
| | richText | ^ |
|
|
23
|
+
| | richTextArray | |
|
|
24
|
+
| richText | canvas | |
|
|
25
|
+
| | richText | |
|
|
26
|
+
| | richTextArray | |
|
|
27
|
+
| | string | |
|
|
28
|
+
| | stringArray | |
|
|
29
|
+
| richTextArray | richTextArray | |
|
|
30
|
+
| | richText | Multiples separated with newline |
|
|
31
|
+
| | canvas | |
|
|
32
|
+
| boolean | boolean | |
|
|
33
|
+
| | string | "Yes" or "No" |
|
|
34
|
+
| | stringArray | ^ |
|
|
35
|
+
| | integer | True = 1, false = 0 |
|
|
36
|
+
| | integerArray | ^ |
|
|
37
|
+
| | decimal | True = 1, false = 0 |
|
|
38
|
+
| | decimalArray | ^ |
|
|
39
|
+
| integer | integer | |
|
|
40
|
+
| | integerArray | |
|
|
41
|
+
| | decimal | |
|
|
42
|
+
| | decimalArray | |
|
|
43
|
+
| | boolean | True if evaluates "truthy" (0, false or null would be false) |
|
|
44
|
+
| decimal | decimal | |
|
|
45
|
+
| | decimalArray | |
|
|
46
|
+
| | integer | Truncate any decimal precision (e.g. 44.9 = 44) |
|
|
47
|
+
| | integerArray | ^ |
|
|
48
|
+
| | boolean | True if evaluates "truthy" (0, false or null would be false) |
|
|
49
|
+
| dateTime | dateTime | |
|
|
50
|
+
| | dateTimeArray | |
|
|
51
|
+
| image | image | |
|
|
52
|
+
| | imageArray | |
|
|
53
|
+
| imageArray | imageArray | |
|
|
54
|
+
| | image | |
|
|
55
|
+
| component | component | Source and destination component must contain the same fields |
|
|
56
|
+
| | componentArray | ^ |
|
|
57
|
+
| component.\<field type> | \<field type> | Supports the field types mentioned above |
|
|
58
|
+
| componentArray.\<field type> | \<field type> | ^ at the first position in the array |
|
|
59
|
+
| \<field type> | component.\<field type> | Adds the field to existing component object or add new component with just this field |
|
|
60
|
+
| | componentArray.\<field type> | ^ at the first position in the array |
|
|
61
|
+
| composer | canvas | Renders composer content as simple HTML and parses to canvas JSON |
|
|
62
|
+
| \<field type> | composer | Not supported |
|
|
63
|
+
| canvas | \<field type> | Not supported |
|
|
64
|
+
|
|
65
|
+
Key: ^ = as above
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "contensis-cli",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1-beta.0",
|
|
4
4
|
"description": "A fully featured Contensis command line interface with a shell UI provides simple and intuitive ways to manage or profile your content in any NodeJS terminal.",
|
|
5
5
|
"repository": "https://github.com/contensis/cli",
|
|
6
6
|
"homepage": "https://github.com/contensis/cli/tree/main/packages/contensis-cli#readme",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"build:watch": "node esbuild.config.js --watch",
|
|
19
19
|
"cli": "node --inspect=9229 ./cli.js",
|
|
20
20
|
"postinstall": "npx patch-package",
|
|
21
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
21
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
22
|
+
"package-lock": "npm i --package-lock-only --workspaces false"
|
|
22
23
|
},
|
|
23
24
|
"author": "Zengenti",
|
|
24
25
|
"license": "ISC",
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"jsonpath-mapper": "^1.1.0",
|
|
40
41
|
"keytar": "^7.9.0",
|
|
41
42
|
"lodash": "^4.17.21",
|
|
42
|
-
"migratortron": "^1.0.0-beta.
|
|
43
|
+
"migratortron": "^1.0.0-beta.50",
|
|
43
44
|
"nanospinner": "^1.1.0",
|
|
44
45
|
"node-fetch": "^2.6.7",
|
|
45
46
|
"parse-git-config": "^3.0.0",
|
package/src/commands/copy.ts
CHANGED
|
@@ -4,9 +4,11 @@ import { cliCommand } from '~/services/ContensisCliService';
|
|
|
4
4
|
import {
|
|
5
5
|
commit,
|
|
6
6
|
concurrency,
|
|
7
|
+
entryId,
|
|
7
8
|
ignoreErrors,
|
|
8
9
|
mapContensisOpts,
|
|
9
10
|
outputEntries,
|
|
11
|
+
zenql,
|
|
10
12
|
} from './globalOptions';
|
|
11
13
|
|
|
12
14
|
export const makeCopyCommand = () => {
|
|
@@ -34,6 +36,16 @@ export const makeCopyCommand = () => {
|
|
|
34
36
|
.addOption(concurrency)
|
|
35
37
|
.addOption(ignoreErrors)
|
|
36
38
|
.addOption(outputEntries)
|
|
39
|
+
.option(
|
|
40
|
+
'--search <phrase>',
|
|
41
|
+
'get entries with the search phrase, use quotes for multiple words'
|
|
42
|
+
)
|
|
43
|
+
.addOption(entryId)
|
|
44
|
+
.addOption(zenql)
|
|
45
|
+
.option(
|
|
46
|
+
'-s --save-entries',
|
|
47
|
+
"save the entries we're migrating instead of the migration preview when using --output option"
|
|
48
|
+
)
|
|
37
49
|
.usage('<contentTypeId> <fieldId> <destinationId> (all arguments required)')
|
|
38
50
|
.addHelpText(
|
|
39
51
|
'after',
|
|
@@ -49,6 +61,7 @@ Example call:
|
|
|
49
61
|
destinationId: string,
|
|
50
62
|
opts: any
|
|
51
63
|
) => {
|
|
64
|
+
const { template, ...restOpts } = opts;
|
|
52
65
|
const copyField: CopyField = {
|
|
53
66
|
contentTypeId,
|
|
54
67
|
fieldId,
|
|
@@ -59,11 +72,12 @@ Example call:
|
|
|
59
72
|
return await cliCommand(
|
|
60
73
|
['copy', 'project', contentTypeId, fieldId, destinationId],
|
|
61
74
|
opts,
|
|
62
|
-
mapContensisOpts({ copyField })
|
|
75
|
+
mapContensisOpts({ copyField, ...restOpts })
|
|
63
76
|
).CopyEntryField({
|
|
64
77
|
commit: opts.commit,
|
|
65
78
|
fromFile: opts.fromFile,
|
|
66
79
|
logOutput: opts.outputEntries,
|
|
80
|
+
saveEntries: opts.saveEntries,
|
|
67
81
|
});
|
|
68
82
|
}
|
|
69
83
|
);
|
package/src/commands/create.ts
CHANGED
|
@@ -18,7 +18,7 @@ export const makeCreateCommand = () => {
|
|
|
18
18
|
.argument('<name>', 'the name of the project to create')
|
|
19
19
|
.argument('[description]', 'optional description of the project')
|
|
20
20
|
.option(
|
|
21
|
-
'-l --language',
|
|
21
|
+
'-l --language <language>',
|
|
22
22
|
'the default language of the project to create',
|
|
23
23
|
'en-GB'
|
|
24
24
|
)
|
package/src/commands/get.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
addGlobalOptions,
|
|
6
6
|
assetTypes,
|
|
7
7
|
contentTypes,
|
|
8
|
+
delivery,
|
|
8
9
|
entryId,
|
|
9
10
|
mapContensisOpts,
|
|
10
11
|
zenql,
|
|
@@ -184,7 +185,8 @@ Example call:
|
|
|
184
185
|
'-ob --order-by <orderBy...>',
|
|
185
186
|
'field name(s) to order the results by (prefix "-" for descending)'
|
|
186
187
|
)
|
|
187
|
-
)
|
|
188
|
+
)
|
|
189
|
+
.addOption(delivery);
|
|
188
190
|
|
|
189
191
|
sharedGetEntryOptions(
|
|
190
192
|
program
|
|
@@ -204,13 +206,13 @@ Example call:
|
|
|
204
206
|
> get assets --zenql "sys.contentTypeId = blog" --fields sys.id sys.properties.filePath sys.properties.filename
|
|
205
207
|
`
|
|
206
208
|
)
|
|
207
|
-
.action(async (
|
|
209
|
+
.action(async (search: string, opts) => {
|
|
208
210
|
// Maintaining a separate command for assets vs entries
|
|
209
211
|
// allows us to offer up more options when dealing with just assets
|
|
210
212
|
await cliCommand(
|
|
211
213
|
['get', 'assets'],
|
|
212
214
|
opts,
|
|
213
|
-
mapContensisOpts({ dataFormat: 'asset',
|
|
215
|
+
mapContensisOpts({ dataFormat: 'asset', search, ...opts })
|
|
214
216
|
).GetEntries({});
|
|
215
217
|
});
|
|
216
218
|
|
|
@@ -244,13 +246,11 @@ Example call:
|
|
|
244
246
|
> get entries --content-type blog --fields entryTitle sys.version.modified --order-by -sys.version.modified
|
|
245
247
|
`
|
|
246
248
|
)
|
|
247
|
-
.action(async (
|
|
248
|
-
// console.log('phrase: ', phrase, '\nopts:', JSON.stringify(opts, null, 2));
|
|
249
|
-
// console.log('opts:', JSON.stringify(opts, null, 2));
|
|
249
|
+
.action(async (search: string, opts, cmd) => {
|
|
250
250
|
await cliCommand(
|
|
251
251
|
['get', 'entries'],
|
|
252
252
|
opts,
|
|
253
|
-
mapContensisOpts({
|
|
253
|
+
mapContensisOpts({ search, ...opts })
|
|
254
254
|
).GetEntries({
|
|
255
255
|
withDependents: opts.dependents,
|
|
256
256
|
});
|
|
@@ -20,13 +20,14 @@ export const mapContensisOpts = (opts: any = {}): MigrateRequest => ({
|
|
|
20
20
|
query:
|
|
21
21
|
opts.id ||
|
|
22
22
|
opts.entryIds ||
|
|
23
|
-
opts.
|
|
23
|
+
opts.search ||
|
|
24
24
|
opts.fields ||
|
|
25
25
|
opts.orderBy ||
|
|
26
26
|
opts.paths ||
|
|
27
27
|
opts.assetType ||
|
|
28
28
|
opts.contentType ||
|
|
29
|
-
opts.dataFormat
|
|
29
|
+
opts.dataFormat ||
|
|
30
|
+
opts.deliveryApi
|
|
30
31
|
? {
|
|
31
32
|
assetTypes: opts.assetType,
|
|
32
33
|
contentTypeIds: opts.contentType,
|
|
@@ -35,7 +36,8 @@ export const mapContensisOpts = (opts: any = {}): MigrateRequest => ({
|
|
|
35
36
|
includeIds: opts.id || opts.entryIds,
|
|
36
37
|
includePaths: opts.paths,
|
|
37
38
|
orderBy: opts.orderBy,
|
|
38
|
-
searchTerm: opts.
|
|
39
|
+
searchTerm: opts.search,
|
|
40
|
+
useDelivery: opts.deliveryApi,
|
|
39
41
|
}
|
|
40
42
|
: undefined,
|
|
41
43
|
zenQL: opts.zenql,
|
|
@@ -85,6 +87,14 @@ const sharedSecret = new Option(
|
|
|
85
87
|
);
|
|
86
88
|
|
|
87
89
|
/* Entry get options */
|
|
90
|
+
export const delivery = new Option(
|
|
91
|
+
'-delivery --delivery-api',
|
|
92
|
+
'use delivery api to get the entries'
|
|
93
|
+
);
|
|
94
|
+
export const search = new Option(
|
|
95
|
+
'--search <phrase>',
|
|
96
|
+
'get entries with the search phrase, use quotes for multiple words'
|
|
97
|
+
);
|
|
88
98
|
export const zenql = new Option(
|
|
89
99
|
'-q --zenql <zenql>',
|
|
90
100
|
'get entries with a supplied ZenQL statement'
|
package/src/commands/import.ts
CHANGED
|
@@ -126,11 +126,11 @@ Example call:
|
|
|
126
126
|
> import entries --from-file myImportData.json --preserve-guids
|
|
127
127
|
`
|
|
128
128
|
)
|
|
129
|
-
.action(async (
|
|
129
|
+
.action(async (search: string, opts, cmd) => {
|
|
130
130
|
await cliCommand(
|
|
131
131
|
['import', 'entries'],
|
|
132
132
|
opts,
|
|
133
|
-
mapContensisOpts({
|
|
133
|
+
mapContensisOpts({ search, ...opts })
|
|
134
134
|
).ImportEntries({
|
|
135
135
|
commit: opts.commit,
|
|
136
136
|
fromFile: opts.fromFile,
|
|
@@ -183,9 +183,9 @@ export const LogMessages = {
|
|
|
183
183
|
removed: (env: string, id: string, commit: boolean) =>
|
|
184
184
|
`[${env}] ${
|
|
185
185
|
commit ? `Deleted` : `Will delete`
|
|
186
|
-
} content type ${Logger.highlightText(id)}`,
|
|
186
|
+
} content type(s) ${Logger.highlightText(id)}`,
|
|
187
187
|
failedRemove: (env: string, id: string) =>
|
|
188
|
-
`[${env}] Unable to delete content type ${Logger.highlightText(id)}`,
|
|
188
|
+
`[${env}] Unable to delete content type(s) ${Logger.highlightText(id)}`,
|
|
189
189
|
},
|
|
190
190
|
components: {
|
|
191
191
|
list: (projectId: string) =>
|
|
@@ -199,9 +199,9 @@ export const LogMessages = {
|
|
|
199
199
|
removed: (env: string, id: string, commit: boolean) =>
|
|
200
200
|
`[${env}] ${
|
|
201
201
|
commit ? `Deleted` : `Will delete`
|
|
202
|
-
} component ${Logger.highlightText(id)}`,
|
|
202
|
+
} component(s) ${Logger.highlightText(id)}`,
|
|
203
203
|
failedRemove: (env: string, id: string) =>
|
|
204
|
-
`[${env}] Unable to delete component ${Logger.highlightText(id)}`,
|
|
204
|
+
`[${env}] Unable to delete component(s) ${Logger.highlightText(id)}`,
|
|
205
205
|
},
|
|
206
206
|
version: {
|
|
207
207
|
set: (env: string, versionStatus: string) =>
|