contensis-cli 1.0.0-beta.5 → 1.0.0-beta.50

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 (71) hide show
  1. package/README.md +669 -74
  2. package/dist/commands/connect.js +3 -3
  3. package/dist/commands/connect.js.map +2 -2
  4. package/dist/commands/create.js +30 -10
  5. package/dist/commands/create.js.map +2 -2
  6. package/dist/commands/diff.js +57 -0
  7. package/dist/commands/diff.js.map +7 -0
  8. package/dist/commands/get.js +61 -12
  9. package/dist/commands/get.js.map +2 -2
  10. package/dist/commands/globalOptions.js +22 -17
  11. package/dist/commands/globalOptions.js.map +2 -2
  12. package/dist/commands/import.js +36 -10
  13. package/dist/commands/import.js.map +2 -2
  14. package/dist/commands/index.js +9 -1
  15. package/dist/commands/index.js.map +2 -2
  16. package/dist/commands/list.js +19 -8
  17. package/dist/commands/list.js.map +2 -2
  18. package/dist/commands/login.js +3 -3
  19. package/dist/commands/login.js.map +2 -2
  20. package/dist/commands/push.js +8 -4
  21. package/dist/commands/push.js.map +2 -2
  22. package/dist/commands/release.js +47 -0
  23. package/dist/commands/release.js.map +7 -0
  24. package/dist/commands/remove.js +10 -8
  25. package/dist/commands/remove.js.map +2 -2
  26. package/dist/commands/set.js +53 -12
  27. package/dist/commands/set.js.map +2 -2
  28. package/dist/localisation/en-GB.js +97 -47
  29. package/dist/localisation/en-GB.js.map +2 -2
  30. package/dist/providers/CredentialProvider.js +36 -7
  31. package/dist/providers/CredentialProvider.js.map +3 -3
  32. package/dist/providers/SessionCacheProvider.js +21 -1
  33. package/dist/providers/SessionCacheProvider.js.map +2 -2
  34. package/dist/providers/file-provider.js +8 -4
  35. package/dist/providers/file-provider.js.map +3 -3
  36. package/dist/services/ContensisCliService.js +600 -336
  37. package/dist/services/ContensisCliService.js.map +3 -3
  38. package/dist/shell.js +27 -10
  39. package/dist/shell.js.map +3 -3
  40. package/dist/util/console.printer.js +170 -47
  41. package/dist/util/console.printer.js.map +2 -2
  42. package/dist/util/index.js +5 -2
  43. package/dist/util/index.js.map +3 -3
  44. package/dist/util/logger.js +45 -13
  45. package/dist/util/logger.js.map +2 -2
  46. package/dist/version.js +1 -1
  47. package/dist/version.js.map +1 -1
  48. package/package.json +2 -2
  49. package/src/commands/connect.ts +3 -2
  50. package/src/commands/create.ts +37 -8
  51. package/src/commands/diff.ts +41 -0
  52. package/src/commands/get.ts +80 -5
  53. package/src/commands/globalOptions.ts +18 -17
  54. package/src/commands/import.ts +43 -4
  55. package/src/commands/index.ts +9 -1
  56. package/src/commands/list.ts +35 -9
  57. package/src/commands/login.ts +3 -2
  58. package/src/commands/push.ts +9 -2
  59. package/src/commands/release.ts +32 -0
  60. package/src/commands/remove.ts +12 -4
  61. package/src/commands/set.ts +65 -9
  62. package/src/localisation/en-GB.ts +142 -64
  63. package/src/providers/CredentialProvider.ts +39 -6
  64. package/src/providers/SessionCacheProvider.ts +29 -2
  65. package/src/providers/file-provider.ts +8 -4
  66. package/src/services/ContensisCliService.ts +741 -387
  67. package/src/shell.ts +31 -11
  68. package/src/util/console.printer.ts +234 -66
  69. package/src/util/index.ts +12 -6
  70. package/src/util/logger.ts +84 -15
  71. package/src/version.ts +1 -1
package/README.md CHANGED
@@ -1,20 +1,42 @@
1
1
  # Contensis CLI
2
2
 
3
- Use Contensis from your favourite terminal with NodeJS
3
+ Use Contensis from your favourite terminal
4
4
 
5
- Install the package via `npm` as a global module
5
+ Install the package via `npm` as a global module (requires NodeJS)
6
6
 
7
7
  ```shell
8
8
  npm i contensis-cli --global
9
9
  ```
10
10
 
11
- ## CLI usage
11
+ Alternatively, download the executable for your operating system from the [Releases page](https://github.com/contensis/node-cli/releases)
12
+
13
+ ## Skip to section
14
+
15
+ - [Contensis Shell](#contensis-shell)
16
+ - [Use in Terminal](#cli-usage)
17
+ - [Pass connection details anywhere](#pass-connection-details-anywhere)
18
+ - [Use in Docker](#use-in-docker)
19
+ - [Run cli commands](#run-cli-commands)
20
+ - [Persist connections to a local file](#persist-connections-to-a-local-file)
21
+ - [Use in GitLab CI](#use-in-gitlab-ci)
22
+ - [Use in GitHub CI](#use-in-github-ci)
23
+ - [Running headless?](#running-headless-)
24
+
25
+ ## Use in Terminal
26
+
27
+ Try
12
28
 
13
29
  ```shell
14
- contensis-cli connect example-dev
30
+ contensis connect example-dev
15
31
  ```
16
32
 
17
- The CLI uses the same commands and arguments as the shell. It is recommended you use and familiarise yourself with the cli via the shell and use the `contensis-cli` command to use the same cli commands in script-based context such as continuous integration.
33
+ or
34
+
35
+ ```shell
36
+ contensis help
37
+ ```
38
+
39
+ The CLI uses exactly the same commands as the shell. It is recommended you use and familiarise yourself with the cli by using the shell and then use the same cli commands when you need to in script-based context such as continuous integration environments.
18
40
 
19
41
  ### Pass connection details anywhere
20
42
 
@@ -31,16 +53,91 @@ You can supply the following options with any command - although they don't appe
31
53
  -s --shared-secret
32
54
  ```
33
55
 
34
- ### Running headless?
56
+ Using this approach in the cli or the shell will assume these credentials are for your current envioronment and will set the local environment cache for subsequent commands
57
+
58
+ ## Use in Docker
59
+
60
+ Running the container with the `-it` docker options will launch a shell session
61
+
62
+ ```bash
63
+ docker pull ghcr.io/contensis/node-cli/main/app:latest
64
+ docker run --rm -it ghcr.io/contensis/node-cli/main/app:latest
65
+ ```
66
+
67
+ ### Run cli commands
68
+
69
+ Add the cli command and any options after the container image in the `docker run` command e.g.
70
+
71
+ ```bash
72
+ docker run --rm ghcr.io/contensis/node-cli/main/app:latest get entries "test"
73
+ ```
74
+
75
+ ### Persist connections to a local file
76
+
77
+ To use the cli container for multiple commands or to save connections for future sessions, map a volume to the docker container
78
+
79
+ <aside>
80
+ ⚠️ Ensure a file called `environments.json` exists before mapping the volume to the docker container. If it doesn’t exist, create this empty file first.
81
+
82
+ </aside>
83
+
84
+ Linux
85
+
86
+ ```bash
87
+ touch environments.json
88
+ docker run --rm -v $(pwd)/environments.json:/usr/src/app/environments.json -it ghcr.io/contensis/node-cli/main/app:latest
89
+ ```
90
+
91
+ Windows
92
+
93
+ ```powershell
94
+ echo {} > environments.json
95
+ docker run --rm -v ${PWD}/environments.json:/usr/src/app/environments.json -it ghcr.io/contensis/node-cli/main/app:latest
96
+ ```
97
+
98
+ ## Use in GitLab CI
99
+
100
+ ```yaml
101
+ push-to-contensis-block:
102
+ stage: push-to-contensis
103
+ only:
104
+ - master
105
+ image: ghcr.io/contensis/node-cli/main/app:release
106
+ script:
107
+ # Create CI/CD Variables in repo settings called CONTENSIS_CLIENT_ID and CONTENSIS_SHARED_SECRET
108
+ - contensis connect example-dev --project-id website --client-id $CONTENSIS_CLIENT_ID --shared-secret $CONTENSIS_SHARED_SECRET
109
+ - contensis push block example-website-block $APP_IMAGE:latest --release
110
+ ```
111
+
112
+ ## Use in GitHub CI
113
+
114
+ ```yaml
115
+ - name: Push block to Contensis
116
+ uses: contensis/cli-action@v1
117
+ with:
118
+ block-id: example-website-block
119
+ # auto-release: true # release the block straight away
120
+ alias: example-dev
121
+ project-id: website
122
+ client-id: ${{ secrets.CONTENSIS_CLIENT_ID }} # create secrets for actions
123
+ shared-secret: ${{ secrets.CONTENSIS_SHARED_SECRET }} # in repo settings
124
+ tag-repo: true # tag commit with block version
125
+ git-token: ${{ github.token }} # to allow the git tag
126
+ ```
127
+
128
+ ## Running headless?
35
129
 
36
130
  Most lightweight CI environments will likely not ship with the ability to easily load and unlock an encrypted keychain.
37
131
 
38
- In these environments you will see a warning message when using the cli with any credentials
132
+ In these environments you will see a warning message when using the cli with any credentials, in most cases this type of envioronment is normally disposed of after the command/session has completed and the warning can be safely ignored.
39
133
 
40
134
  ```shell
41
135
  [WARN] Could not connect to local keystore - your password could be stored unencrypted!
42
136
  ```
43
137
 
138
+ > **Note**
139
+ > There is a workaround for installing a secret store and launching an X11 session with an unlocked keyring which has been left in here below for anyone who wishes to try it
140
+
44
141
  ~~The required credentials to run commands are stored and read from a secret store `libsecret`. Without the secret store running and unlocked we receive an error `Cannot autolaunch D-Bus without X11 $DISPLAY`~~
45
142
 
46
143
  ```shell
@@ -82,6 +179,47 @@ Press [TAB] for suggestions
82
179
  contensis >
83
180
  ```
84
181
 
182
+ ## Skip to section
183
+
184
+ - [Get started](#get-started)
185
+ - [Connect to a Contensis Cloud environment](#connect-to-a-contensis-cloud-environment)
186
+ - [Login to a connected Contensis environment](#login-to-a-connected-contensis-environment)
187
+ - [Manage Projects](#manage-projects)
188
+ - [List projects](#list-projects)
189
+ - [Set current project](#set-current-project)
190
+ - [Get project metadata](#get-project-metadata)
191
+ - [Set project metadata](#set-project-metadata)
192
+ - [Create a new project](#create-a-new-project)
193
+ - [Content Models](#content-models)
194
+ - [List content models](#list-content-models)
195
+ - [Examine a content model](#examine-a-content-model)
196
+ - [List content types, components](#list-content-types--components)
197
+ - [Examine a content type or component](#examine-a-content-type-or-component)
198
+ - [Entries](#entries)
199
+ - [Get entries](#get-entries)
200
+ - [Get an entry by id](#get-an-entry-by-id)
201
+ - [Get an entry with all of its dependents](#get-an-entry-with-all-of-its-dependents)
202
+ - [Get entries with a ZenQL statement](#get-entries-with-a-zenql-statement)
203
+ - [Choose entry fields to output](#choose-entry-fields-to-output)
204
+ - [Output results to a file](#output-results-to-a-file)
205
+ - [Format output](#format-output)
206
+ - [Manage API keys](#manage-api-keys)
207
+ - [List keys](#list-keys)
208
+ - [Create key](#create-key)
209
+ - [Remove key](#remove-key)
210
+ - [Manage content Blocks](#manage-content-blocks)
211
+ - [List blocks](#list-blocks)
212
+ - [Get block](#get-block)
213
+ - [Get block logs](#get-block-logs)
214
+ - [Push a block](#push-a-block)
215
+ - [Release a block version](#release-a-block-version)
216
+ - [Import content models](#import-content-models)
217
+ - [Import from another Contensis environment](#import-from-another-contensis-environment)
218
+ - [From a file](#from-a-file)
219
+ - [Import entries](#import-entries)
220
+ - [Import from another Contensis environment](#import-from-another-contensis-environment-1)
221
+ - [Import from a file](#import-from-a-file)
222
+
85
223
  ## Get started
86
224
 
87
225
  Press `[tab]` key at any time to show suggested commands or to attempt to auto-complete the command you are typign
@@ -107,6 +245,8 @@ Example call:
107
245
  > connect example-dev
108
246
  ```
109
247
 
248
+ Just type `help` to show the cli command help
249
+
110
250
  ## Connect to a Contensis Cloud environment
111
251
 
112
252
  Use the connect command followed by the cloud alias of your environment
@@ -121,9 +261,9 @@ contensis > connect example-dev
121
261
  contensis example-dev>
122
262
  ```
123
263
 
124
- After connecting you will notice the shell prompt will now contain the current "connected" environment - `contensis example-dev> `
264
+ After connecting you will notice the shell prompt will now contain the current "connected" environment e.g. `contensis example-dev> `
125
265
 
126
- The CMS must be online and available in order to connect to it
266
+ Contensis must be online and available in order to connect to it
127
267
 
128
268
  ```shell
129
269
  contensis > connect exemple-dev
@@ -145,9 +285,13 @@ contensis example-dev> login t.durden
145
285
  contensis t.durden@example-dev>
146
286
  ```
147
287
 
148
- If you are logging in via a script or service you will likely be using an API key set up in Contensis, you would provide the full credentials with the command `login {clientId} -s {sharedSecret}`
288
+ If you are logging in via a script or service you will likely be using an API key set up in Contensis, you would provide the full credentials with the command `login {clientId} -s {sharedSecret}`.
149
289
 
150
- ## List projects
290
+ If you need to skip this step for any reason you could [pass connection details anywhere](#pass-connection-details-anywhere)
291
+
292
+ ## Manage Projects
293
+
294
+ ### List projects
151
295
 
152
296
  Issuing the command `list projects` will fetch a list of projects from the connected Contensis environment
153
297
 
@@ -167,7 +311,7 @@ contensis example-dev> list projects
167
311
  [cli] ℹ Introduce yourself with "login {username}" or "login {clientId} -s {secret}"
168
312
  ```
169
313
 
170
- ## Set current project
314
+ ### Set current project
171
315
 
172
316
  Set your current working project with the `set project {projectId}` command
173
317
 
@@ -187,7 +331,168 @@ intranet t.durden@example-dev>
187
331
 
188
332
  You will notice the `contensis` prompt has been updated to show your current connected project
189
333
 
190
- ## List content types, components
334
+ ### Get project metadata
335
+
336
+ ```shell
337
+ contensis t.durden@example-dev> get project
338
+
339
+ id: contensis
340
+ uuid: 4df681ef-f3bc-3d79-57b8-de3f0570b9b3
341
+ name: Contensis
342
+ description:
343
+ primaryLanguage: en-GB
344
+ supportedLanguages:
345
+ en-GB
346
+ color: cobalt
347
+
348
+ contensis t.durden@example-dev>
349
+ ```
350
+
351
+ ### Set project metadata
352
+
353
+ Update a project name
354
+
355
+ ```shell
356
+ contensis t.durden@example-dev> set project name "Contensis website"
357
+ [cli] ✅ [example-dev] Updated project contensis
358
+ id: contensis
359
+ uuid: 4df681ef-f3bc-3d79-57b8-de3f0570b9b3
360
+ name: Contensis website
361
+ description:
362
+ primaryLanguage: en-GB
363
+ supportedLanguages:
364
+ en-GB
365
+ color: cobalt
366
+
367
+ contensis t.durden@example-dev>
368
+ ```
369
+
370
+ Update a project's description
371
+
372
+ ```shell
373
+ contensis t.durden@example-dev> set project description "Main product site"
374
+ [cli] ✅ [example-dev] Updated project contensis
375
+ id: contensis
376
+ uuid: 4df681ef-f3bc-3d79-57b8-de3f0570b9b3
377
+ name: Contensis website
378
+ description: Main product site
379
+ primaryLanguage: en-GB
380
+ supportedLanguages:
381
+ en-GB
382
+ color: cobalt
383
+
384
+ contensis t.durden@example-dev>
385
+ ```
386
+
387
+ ### Create a new project
388
+
389
+ ```shell
390
+ website t.durden@example-dev> create project testProject "Test project" --supported-languages cy
391
+ [cli] ✅ [example-dev] Created project testProject
392
+
393
+ [cli] ✅ Available projects:
394
+
395
+ >> testProject [cy *en-GB]
396
+ website [*en-GB]
397
+ wordPressSite [*en-GB]
398
+
399
+ [cli] ✅ Current project is set to testProject
400
+
401
+ testProject t.durden@example-dev>
402
+ ```
403
+
404
+ ## Content Models
405
+
406
+ Manage your content models like you are the chosen one
407
+
408
+ ### List content models
409
+
410
+ ```shell
411
+ contensis t.durden@example-dev> list models
412
+ [cli] ✅ [website] Content models [ 19 ]
413
+
414
+ - accessibleVideo { required by: 3 }
415
+ - blogListing { components: 1, contentTypes: 2, references: 33, required by: 4 }
416
+ - blogPost { components: 2, contentTypes: 6, references: 33, required by: 9 }
417
+ - callToAction { contentTypes: 9, references: 33, required by: 5 }
418
+ - category { required by: 1 }
419
+ - contentPage { components: 5, contentTypes: 6, references: 33, required by: 7 }
420
+ - externalLink { required by: 2 }
421
+ - growingConditions { components: 1, references: 1, required by: 1 }
422
+ - homepage { components: 4, contentTypes: 8, references: 33, required by: 3 }
423
+ - landingPage { components: 9, contentTypes: 12, references: 33, required by: 7 }
424
+ - person { required by: 2 }
425
+ - plant { components: 2, contentTypes: 3, references: 8, required by: 10 }
426
+ - plantType { required by: 2 }
427
+ - pot { components: 2, contentTypes: 1, references: 3, required by: 11 }
428
+ - productListing { components: 1, references: 1, required by: 4 }
429
+ - review { contentTypes: 3, references: 10, required by: 1 }
430
+ - siteSettings
431
+ - tag { required by: 5 }
432
+
433
+ contensis t.durden@example-dev>
434
+ ```
435
+
436
+ ### Examine a content model
437
+
438
+ A `model` is a complete view of a content type that includes all of its dependents - and the dependents of those dependents
439
+
440
+ - `contentTypes` are the content types that have content linked to the model directly from this content type
441
+ - `components` are the content types that have content linked to the model directly from this content type
442
+ - `dependencies` is an exhaustive list of dependencies and inner dependents [the values in brackets are the models that have required it to make it a dependency]
443
+ - `dependencyOf` is a list of all the other content types (or components) that reference this content type directly, this model is a dependency of those
444
+
445
+ ```shell
446
+ contensis t.durden@example-dev> get model plant
447
+ [cli] ✅ Content models in contensis:
448
+
449
+ id: plant
450
+ dataFormat: model
451
+ name:
452
+ en-GB: Plant
453
+ description:
454
+ en-GB: Use this content type to store information about individual plants.
455
+ contentTypes:
456
+ growingConditions
457
+ plantType
458
+ tag
459
+ components:
460
+ externalPromotion
461
+ plantVariant
462
+ dependencyOf:
463
+ callToAction
464
+ homepage
465
+ landingPage
466
+ review
467
+ button
468
+ cardRow
469
+ curatedProductSlider
470
+ featuredBlogPosts
471
+ featuredProduct
472
+ promotedProduct
473
+ dependencies:
474
+ growingConditions
475
+ [plant]
476
+ plantType
477
+ [plant]
478
+ pot
479
+ [plantVariant]
480
+ tag
481
+ [plant, pot]
482
+ externalPromotion
483
+ [plant, pot]
484
+ icon
485
+ [growingConditions]
486
+ plantVariant
487
+ [plant]
488
+ potVariant
489
+ [pot]
490
+
491
+
492
+ contensis t.durden@example-dev>
493
+ ```
494
+
495
+ ### List content types, components
191
496
 
192
497
  ```shell
193
498
  contensis t.durden@example-dev> list contenttypes
@@ -212,12 +517,12 @@ contensis t.durden@example-dev> list contenttypes
212
517
  - tag [1 field]
213
518
  ```
214
519
 
215
- ## Examine a content type or component
520
+ ### Examine a content type or component
216
521
 
217
522
  ```shell
218
523
  contensis t.durden@example-dev> get contenttype pot
219
524
  [cli] ✅ [website] Content type "pot"
220
- uuid: adc051ee-d584-4f2a-ba42-5e6190edadb8
525
+ uuid: 929a99d2-fe5c-4781-84fa-f5a3738aa96d
221
526
  id: pot
222
527
  projectId: website
223
528
  name:
@@ -226,19 +531,19 @@ contensis t.durden@example-dev> get contenttype pot
226
531
  entryTitleField: productName
227
532
  entryDescriptionField: description
228
533
  fields:
229
- productName: string
534
+ productName**: string
230
535
  description: string
231
- externalPromotion: object
536
+ externalPromotion: object<component.externalpromotion>
232
537
  colour: string
233
538
  material: string
234
- potVariant: objectArray
235
- primaryImage: object
236
- photos: objectArray
237
- externalCardImage: object
238
- tags: objectArray
539
+ potVariant: objectArray<component.potvariant>
540
+ primaryImage: object<image>
541
+ photos: objectArray<image>
542
+ externalCardImage: object<image>
543
+ tags: objectArray<entry, tag>
239
544
  defaultLanguage: en-GB
240
545
  supportedLanguages:
241
- 0: en-GB
546
+ en-GB
242
547
  workflowId: contensisEntryBasic
243
548
  dataFormat: entry
244
549
  groups:
@@ -250,7 +555,9 @@ contensis t.durden@example-dev> get contenttype pot
250
555
  contensis t.durden@example-dev>
251
556
  ```
252
557
 
253
- ## Get entries
558
+ ## Entries
559
+
560
+ ### Get entries
254
561
 
255
562
  Use the `get entries` command
256
563
 
@@ -280,7 +587,7 @@ Found 8 entries in [website]
280
587
  website t.durden@example-dev>
281
588
  ```
282
589
 
283
- ## Get an entry by id
590
+ ### Get an entry by id
284
591
 
285
592
  ```shell
286
593
  website t.durden@example-dev> get entries --id 7cf921a0-ee4f-4bd6-a3f2-0fb0fe1a2ac8
@@ -299,7 +606,7 @@ Found 1 entries in [website]
299
606
  website t.durden@example-dev>
300
607
  ```
301
608
 
302
- ## Get an entry with all of its dependents
609
+ ### Get an entry with all of its dependents
303
610
 
304
611
  Add the `--dependents` or `-d` flag to your `get entries` command to also find and fetch all dependent (linked) entries, recursively finding and including any dependent entries found inside those dependents.
305
612
 
@@ -333,7 +640,7 @@ Found 12 entries in [website]
333
640
  website t.durden@example-dev>
334
641
  ```
335
642
 
336
- ## Get entries with a ZenQL statement
643
+ ### Get entries with a ZenQL statement
337
644
 
338
645
  Use a ZenQL statement to find entries with the `--zenql` or `-q` option, add your statement inside `"double quotes"`. Refer to [ZenQL documentation](https://www.contensis.com/help-and-docs/user-guides/zenql-search) and test your statement for the right results in the Contensis web UI.
339
646
 
@@ -374,7 +681,7 @@ Found 21 entries in [website]
374
681
  website t.durden@example-dev>
375
682
  ```
376
683
 
377
- ## Choose entry fields to output
684
+ ### Choose entry fields to output
378
685
 
379
686
  Add the `--fields` or `-f` option to your `get entries` command to limit and order the entry fields that are returned, add the api key of each field to be returned separated by a space
380
687
 
@@ -406,7 +713,7 @@ Found 12 entries in [website]
406
713
  website t.durden@example-dev>
407
714
  ```
408
715
 
409
- ## Output results to a file
716
+ ### Output results to a file
410
717
 
411
718
  Use the `--output` or `-o` option followed by the file name you wish for command output to be written to
412
719
 
@@ -489,7 +796,7 @@ website t.durden@example-dev>
489
796
 
490
797
  Run `list keys` again and you will see your new API key has been removed from the list of keys
491
798
 
492
- ## Manage Content Blocks
799
+ ## Manage content Blocks
493
800
 
494
801
  You can manage blocks for any Contensis project using the following commands
495
802
 
@@ -554,7 +861,10 @@ website t.durden@example-dev> get block logs contensis-website master
554
861
  website t.durden@example-dev>
555
862
  ```
556
863
 
557
- ### Push block
864
+ ### Push a block
865
+
866
+ > **Note**
867
+ > It is far simpler doing this in [GitLab CI](#use-in-gitlab-ci) or [GitHub CI Actions](#use-in-github-ci)
558
868
 
559
869
  ```shell
560
870
  website t.durden@example-dev> push block cli-test-block ghcr.io/contensis/contensis-app:build-4359 master --release --commit-id 9ee20333 --commit-message "chore: sample commit message" --commit-datetime 2022-11-03T22:34 --author-email b.macka@zengenti.com --committer-email b.macka@zengenti.com --repository-url https://github.com/contensis/contensis-app.git --provider GitlabSelfHosted
@@ -563,69 +873,354 @@ website t.durden@example-dev> push block cli-test-block ghcr.io/contensis/conten
563
873
  website t.durden@example-dev>
564
874
  ```
565
875
 
566
- ## Use in Docker
876
+ ### Release a block version
567
877
 
568
- Running the container with the `-it` docker options will launch a shell session
878
+ First get the latest block version number
569
879
 
570
- ```bash
571
- docker pull ghcr.io/contensis/node-cli/main/app:latest
572
- docker run --rm -it ghcr.io/contensis/node-cli/main/app:latest
880
+ ```shell
881
+ website t.durden@example-dev>get block contensis-website master latest
882
+ [cli] [example-dev] Block contensis-website in project website:
883
+ v78 contensis-website
884
+ state: available
885
+ released: no
886
+ status:
887
+ deployment: deployed
888
+ workflow: draft
889
+ running status: available
890
+ datacentres:
891
+ hq: available
892
+ london: available
893
+ manchester: faulted
894
+ source:
895
+ commit: b946c1029c1b35aefee2e1a6b5780ddaf205ee74
896
+ message: build: syntax [nobuild]
897
+ committed: [22/11/2022 06:50] t.durden@zengenti.com
898
+ pushed: [22/11/2022 06:52] Gitlab CI block push
899
+ https://github.com/contensis/contensis-website/commit/b946c1029c1b35aefee2e1a6b5780ddaf205ee74
900
+ image:
901
+ uri: ghcr.io/contensis/contensis-website/main/app
902
+ tag: latest
903
+ staging url: https://staging-example-dev.cloud.contensis.com?block-contensis-website-versionstatus=draft
904
+
905
+ website t.durden@example-dev>
573
906
  ```
574
907
 
575
- ### Run cli commands
908
+ Add the block version number to the `release block` command
576
909
 
577
- Add the cli command and any options after the container image in the `docker run` command e.g.
910
+ ```shell
578
911
 
579
- ```bash
580
- docker run --rm ghcr.io/contensis/node-cli/main/app:latest get entries "test"
912
+ website t.durden@example-dev> release block contensis-website 78
913
+ [cli] [example-dev] Released block contensis-website in project website
914
+ v78 contensis-website
915
+ state: available
916
+ released: [23/11/2022 01:42] n.flatley
917
+ status:
918
+ deployment: deployed
919
+ workflow: released
920
+ running status: available
921
+ datacentres:
922
+ hq: available
923
+ london: available
924
+ manchester: faulted
925
+ source:
926
+ commit: b946c1029c1b35aefee2e1a6b5780ddaf205ee74
927
+ message: build: syntax [nobuild]
928
+ committed: [22/11/2022 06:50] t.durden@zengenti.com
929
+ pushed: [22/11/2022 06:52] Gitlab CI block push
930
+ null
931
+ image:
932
+ uri: ghcr.io/contensis/contensis-website/main/app
933
+ tag: latest
934
+ staging url: https://staging-example-dev.cloud.contensis.com?block-contensis-website-versionstatus=released
935
+
936
+ website t.durden@example-dev>
581
937
  ```
582
938
 
583
- ### Persist connections to a local file
939
+ ## Import content models
584
940
 
585
- To use the cli container for multiple commands or to save connections for future sessions, map a volume to the docker container
941
+ Connect to your "source" environment first, ensure you can fetch the models and these models contain the dependencies you plan on importing from here with the `get models` command. Add the `--dependents` option to fetch all of the entries that will eventually be imported.
586
942
 
587
- <aside>
588
- ⚠️ Ensure a file called `environments.json` exists before mapping the volume to the docker container. If it doesn’t exist, create this empty file first.
943
+ When you are happy your models contain the right dependencies for your import, connect to the "target" environment (and project) then use the same arguments as before except with the `import entries` command
589
944
 
590
- </aside>
945
+ ### Import from another Contensis environment
591
946
 
592
- Linux
947
+ Specify a list of models to import
593
948
 
594
- ```bash
595
- touch environments.json
596
- docker run --rm -v $(pwd)/environments.json:/usr/src/app/environments.json -it ghcr.io/contensis/node-cli/main/app:latest
949
+ ```shell
950
+ website t.durden@example-dev> import models plant --source-alias example-dev --source-project-id leif
951
+
952
+ -------------------------------------
953
+ -- IMPORT PREVIEW --
954
+
955
+ Content types:
956
+ - growingConditions [website: no change] v1.0
957
+ required by: [plant]
958
+ references: [icon]
959
+ - plant [website: update] v2.0
960
+ references: [growingConditions, plantGenus, plantType, tag]
961
+ diff: ...{'id':'<+>genus','name':{'en-GB':'Genus'},'dataType':'object','dataFormat':'entry','description':{},'default':null,'validations':{'allowedContentTypes':{'contentTypes':['plantGenus'],'message':null}},'editor':null,'groupId':'main'},{'id':'</+>plantVariant','name':{'en-GB':'Plant variant'}...
962
+ - plantGenus [website: create] v0.1
963
+ required by: [plant]
964
+ - plantType [website: no change] v1.0
965
+ required by: [plant]
966
+ - pot [website: no change] v2.0
967
+ required by: [plantVariant]
968
+ references: [externalPromotion, potVariant, tag]
969
+ - tag [website: no change] v1.0
970
+ required by: [plant, pot]
971
+
972
+ Components:
973
+ - externalPromotion [website: no change] v1.0
974
+ required by: [plant, pot]
975
+ - icon [website: no change] v1.0
976
+ required by: [growingConditions]
977
+ - plantVariant [website: no change] v2.0
978
+ required by: [plant]
979
+ references: [pot]
980
+ - potVariant [website: no change] v1.0
981
+ required by: [pot]
982
+
983
+ website t.durden@example-dev>
597
984
  ```
598
985
 
599
- Windows
986
+ Or import every model from the source
600
987
 
601
- ```powershell
602
- echo {} > environments.json
603
- docker run --rm -v ${PWD}/environments.json:/usr/src/app/environments.json -it ghcr.io/contensis/node-cli/main/app:latest
988
+ ```shell
989
+ website t.durden@example-dev> import models --source-alias example-dev --source-project-id leif
990
+ -------------------------------------
991
+ -- IMPORT PREVIEW --
992
+
993
+ Content types:
994
+ - accessibleVideo [website: no change] v1.0
995
+ required by: [blogPost, contentPage, landingPage]
996
+ - alert [website: create] v0.1
997
+ - blogListing [website: no change] v2.0
998
+ required by: [button, callToAction, homepage, landingPage]
999
+ references: [blogPost, callToAction, pageMetadata]
1000
+ - blogPost [website: update] v3.0
1001
+ required by: [blogListing, blogPost, button, callToAction, cardRow, contentPage, featuredBlogPosts, homepage, landingPage]
1002
+ references: [accessibleVideo, blogPost, callToAction, category, externalPromotion, featuredProduct, person, tag]
1003
+ diff: ...
1004
+ - callToAction [website: no change] v2.0
1005
+ required by: [blogListing, blogPost, contentPage, homepage, landingPage]
1006
+ references: [blogListing, blogPost, contentPage, externalLink, homepage, landingPage, plant, pot, productListing]
1007
+ - campus [website: create] v0.1
1008
+ - category [website: no change] v1.0
1009
+ required by: [blogPost, department, listing]
1010
+ - contentPage [website: no change] v2.0
1011
+ required by: [button, callToAction, cardRow, contentPage, featuredBlogPosts, homepage, landingPage]
1012
+ references: [accessibleVideo, blogPost, callToAction, callout, cardRow, contentPage, featuredProduct, formPicker, landingPage, pageMetadata, tag]
1013
+ - department [website: two-pass] v0.1
1014
+ references: [category]
1015
+ - event [website: create] v0.1
1016
+ - externalLink [website: no change] v1.0
1017
+ required by: [button, callToAction]
1018
+ - form [website: create] v0.1
1019
+ - growingConditions [website: no change] v1.0
1020
+ required by: [listing, plant]
1021
+ references: [icon]
1022
+ - homepage [website: update] v2.0
1023
+ required by: [button, callToAction, landingPage]
1024
+ references: [blogListing, blogPost, callToAction, contentPage, curatedProductSlider, filteredProductSlider, landingPage, pageMetadata, plant, pot, productListing, promotedProduct]
1025
+ diff: ...
1026
+ - landingPage [website: update] v2.0
1027
+ required by: [button, callToAction, cardRow, contentPage, featuredBlogPosts, homepage, landingPage]
1028
+ references: [accessibleVideo, blogListing, blogPost, bodyCopy, callToAction, contentBlock, contentPage, curatedProductSlider, featuredBlogPosts, featuredProduct, filteredProductSlider, formPicker, homepage, landingPage, pageMetadata, plant, pot, productListing, promotedProduct, review, tag]
1029
+ diff: ...
1030
+ - listing [website: two-pass] v0.1
1031
+ references: [category, growingConditions, plantType, tag]
1032
+ - newsArticle [website: two-pass] v0.1
1033
+ references: [person]
1034
+ - newsTest [website: two-pass] v0.1
1035
+ references: [person]
1036
+ - person [website: no change] v1.0
1037
+ required by: [blogPost, newsArticle, newsTest, review]
1038
+ - plant [website: update] v2.0
1039
+ required by: [button, callToAction, cardRow, curatedProductSlider, featuredBlogPosts, featuredProduct, homepage, landingPage, promotedProduct, review]
1040
+ references: [externalPromotion, growingConditions, plantGenus, plantType, plantVariant, tag]
1041
+ diff: ...
1042
+ - plantFamily [website: two-pass] v0.1
1043
+ required by: [plantOrder]
1044
+ references: [plantGenus]
1045
+ - plantGenus [website: create] v0.1
1046
+ required by: [plant, plantFamily]
1047
+ - plantOrder [website: two-pass] v0.1
1048
+ references: [plantFamily]
1049
+ - plantType [website: no change] v1.0
1050
+ required by: [filteredProductSlider, listing, plant]
1051
+ - pot [website: no change] v2.0
1052
+ required by: [button, callToAction, cardRow, curatedProductSlider, featuredBlogPosts, featuredProduct, homepage, landingPage, plantVariant, promotedProduct, review]
1053
+ references: [externalPromotion, potVariant, tag]
1054
+ - productListing [website: no change] v1.0
1055
+ required by: [button, callToAction, homepage, landingPage]
1056
+ references: [pageMetadata]
1057
+ - review [website: no change] v2.0
1058
+ required by: [landingPage]
1059
+ references: [person, plant, pot]
1060
+ - siteSettings [website: no change] v1.0
1061
+ - tag [website: no change] v1.0
1062
+ required by: [blogPost, contentPage, landingPage, listing, plant, pot]
1063
+ - testLang [website: create] v0.1
1064
+
1065
+ Components:
1066
+ - bodyCopy [website: no change] v1.0
1067
+ required by: [landingPage]
1068
+ - button [website: no change] v2.0
1069
+ required by: [promotedProduct]
1070
+ references: [blogListing, blogPost, contentPage, externalLink, homepage, landingPage, plant, pot, productListing]
1071
+ - callout [website: no change] v1.0
1072
+ required by: [contentPage, event]
1073
+ - cardRow [website: no change] v2.0
1074
+ required by: [contentPage]
1075
+ references: [blogPost, contentPage, landingPage, plant, pot]
1076
+ - contentBlock [website: no change] v1.0
1077
+ required by: [landingPage]
1078
+ - curatedProductSlider [website: no change] v2.0
1079
+ required by: [homepage, landingPage]
1080
+ references: [plant, pot]
1081
+ - externalPromotion [website: no change] v1.0
1082
+ required by: [blogPost, plant, pot]
1083
+ - featuredBlogPosts [website: no change] v2.0
1084
+ required by: [landingPage]
1085
+ references: [blogPost, contentPage, landingPage, plant, pot]
1086
+ - featuredProduct [website: no change] v2.0
1087
+ required by: [blogPost, contentPage, landingPage]
1088
+ references: [plant, pot]
1089
+ - filteredProductSlider [website: no change] v2.0
1090
+ required by: [homepage, landingPage]
1091
+ references: [plantType]
1092
+ - formPicker [website: no change] v1.0
1093
+ required by: [contentPage, landingPage]
1094
+ - icon [website: no change] v1.0
1095
+ required by: [growingConditions]
1096
+ - pageMetadata [website: no change] v1.0
1097
+ required by: [blogListing, contentPage, homepage, landingPage, productListing]
1098
+ - plantVariant [website: no change] v2.0
1099
+ required by: [plant]
1100
+ references: [pot]
1101
+ - potVariant [website: no change] v1.0
1102
+ required by: [pot]
1103
+ - promotedProduct [website: update] v2.0
1104
+ required by: [homepage, landingPage]
1105
+ references: [button, plant, pot]
1106
+ diff: ...
1107
+
1108
+ website t.durden@example-dev>
604
1109
  ```
605
1110
 
606
- ## Use in GitLab CI
1111
+ ### Import from a file
607
1112
 
608
- ```yaml
609
- push-to-contensis-block:
610
- stage: push-to-contensis
611
- only:
612
- - master
613
- image: ghcr.io/contensis/node-cli/main/app:latest
614
- script:
615
- # - contensis connect zenhub-dev --project-id migratortron --client-id 02c8fae0-1aa6-46d3-a0a4-9674fa7f10f1 --shared-secret 47a52c7755324debbcc984865e87200b-35b17f3d39ae40ee9b118358c4dd1666-a516b7c30ebb449ca26e93157588cd26
616
- - contensis push block example-website-block $APP_IMAGE:latest --release -a example-dev -p website -id 02c8fae0-1aa6-46d3-a0a4-9674fa7f10f1 -s 47a52c7755324debbcc984865e87200b-35b17f3d39ae40ee9b118358c4dd1666-a516b7c30ebb449ca26e93157588cd26
1113
+ ```shell
1114
+ website t.durden@example-dev> import models --from-file ./content-models.json
617
1115
  ```
618
1116
 
619
- ## Use in GitHub CI
1117
+ The output will be the same as the previous command
620
1118
 
621
- ```yaml
622
- - name: Push block to Contensis
623
- uses: contensis/cli-action@v1
624
- with:
625
- block-id: example-website-block
626
- # auto-release: true
627
- alias: zenhub-dev
628
- project-id: contensis
629
- client-id: ${{ secrets.CONTENSIS_CLIENT_ID }}
630
- shared-secret: ${{ secrets.CONTENSIS_SHARED_SECRET }}
1119
+ <sup><sub>Add the `--commit` option to make the changes, be very careful using this! There is no going back</sub></sup>
1120
+
1121
+ ## Import entries
1122
+
1123
+ The import commands are made possible by using the `migratortron` library. There is further documentation here:
1124
+
1125
+ - [`migratortron` on npmjs](https://www.npmjs.com/package/migratortron)
1126
+ - [`contensis-importer` on npmjs](https://www.npmjs.com/package/contensis-importer)
1127
+
1128
+ ### Import from another Contensis environment
1129
+
1130
+ Connect to your "source" environment first, ensure you can fetch the entries you plan on importing from here and your query / filters are working to fetch exactly the data you are expecting with the `get entries` command. Add the `--dependents` option to fetch all of the entries that will eventually be imported.
1131
+
1132
+ When you are happy you can fetch only the data you intend to import, connect to the "target" environment (and project) then use the same query as before except with the `import entries` command
1133
+
1134
+ ```shell
1135
+ website t.durden@example-dev> import entries --preserve-guids --zenql "sys.contentTypeId = plant" --source-alias example-dev --source-project-id leif
1136
+ -------------------------------------
1137
+ -- IMPORT PREVIEW --
1138
+ [23/11 02:10:48] [INFO] Fetching initial entries in project 'leif'
1139
+ [23/11 02:10:48] [INFO] Finding entries in project 'website'
1140
+ [23/11 02:10:49] [INFO] Building asset entries
1141
+ [23/11 02:10:49] [INFO] Building content entries
1142
+ --------------------------------------------
1143
+
1144
+ 1 errors
1145
+
1146
+ id error
1147
+ -----------------------------------------------------------
1148
+ 0 Content type 'plantGenus' does not exist in
1149
+ project 'website'
1150
+ -----------------------------------------------------------
1151
+ [23/11 02:10:49] [OK] Done migrating entries
1152
+
1153
+ growingConditions Likes high humidity
1154
+ 636b925b-a386-4c56-9f33-96cd99cc391c no change
1155
+ growingConditions Needs plenty of light
1156
+ 2d80e638-eb0d-4bc5-bc96-42b7b8f20678 no change
1157
+ growingConditions Partial shade
1158
+ 711251f9-f9c6-473b-8b62-0ec8a0d4978c no change
1159
+ growingConditions Prefers dry conditions
1160
+ d815819d-61c6-4037-95d3-c503acf52153 no change
1161
+
1162
+ plant Aloe vera
1163
+ 7cf921a0-ee4f-4bd6-a3f2-0fb0fe1a2ac8 no change
1164
+ plant Areca palm
1165
+ 0d94dbf2-89f8-45fb-96d5-175ae1f382ce no change
1166
+ plant Boston fern
1167
+ 43a60005-ea92-4b32-9af3-79560e48ecec no change
1168
+ plant Calathea orbifolia
1169
+ f0cac96c-39a1-4b85-b14b-e8d7d3d08767 no change
1170
+ plant Canary Island Date Palm
1171
+ d647012b-897e-4b6b-bfb5-b9844ef3d648 no change
1172
+
1173
+ plantGenus Aglaonema
1174
+ 98347340-a11c-4ee5-b4e7-1ae3b75496a2 error
1175
+ [cli] ❌ Content type 'plantGenus' does not exist in project 'website'
1176
+
1177
+ plantGenus Alocasia
1178
+ fa464489-6476-4694-b3d4-e77d0c00a185 error
1179
+ [cli] ❌ Content type 'plantGenus' does not exist in project 'website'
1180
+
1181
+ plantGenus Aloe
1182
+ 309d5fd7-a21f-45a8-8abb-f01f820b8f16 error
1183
+ [cli] ❌ Content type 'plantGenus' does not exist in project 'website'
1184
+
1185
+ plantGenus Beaucarnea
1186
+ 4ebdcc63-929f-4b06-8848-fe046468a63d error
1187
+ [cli] ❌ Content type 'plantGenus' does not exist in project 'website'
1188
+
1189
+
1190
+ plantType Ferns
1191
+ 90e128f5-582c-4430-a232-72022271ec8b no change
1192
+ plantType Foliage
1193
+ 25f5a78b-9274-4cc9-9a58-03d8dcd4cd17 no change
1194
+ plantType Orchids
1195
+ 44abca5b-a49b-48a1-8823-811ab31983c0 no change
1196
+ plantType Palm
1197
+ d66447c5-2198-4b19-bad3-c921e9ef0db0 no change
1198
+ plantType Succulents
1199
+ 70149568-9725-4c39-8ff5-ef69221a0899 no change
1200
+
1201
+ pot Barro decorated terracotta pot
1202
+ fa67e1c6-0637-4548-bd4f-c207ec62af0e no change
1203
+ pot Bianco white pot
1204
+ e3b7907c-f524-45e4-ba5f-e62d1557b477 no change
1205
+ pot Canasta mid-sized pot
1206
+ 058b20ba-99f7-49ec-9017-a0df35b00dcc no change
1207
+ pot Geo mid-sized pot
1208
+ dafc4810-a62e-43e5-a056-ab1248181eaf no change
1209
+ pot Grå small grey pot
1210
+ f2022069-7a92-491d-b197-a3564ab9a8ca no change
1211
+
1212
+ tag Promoted
1213
+ 3659a333-8d10-4325-9ea6-2f49ae47e7fe no change
1214
+
1215
+ website t.durden@example-dev>
631
1216
  ```
1217
+
1218
+ ### Import from a file
1219
+
1220
+ ```shell
1221
+ website t.durden@example-dev> import entries --preserve-guids --from-file ./content-entries.json
1222
+ ```
1223
+
1224
+ The output will be the same as the previous command
1225
+
1226
+ <sup><sub>Add the `--commit` option to make the changes, be very careful using this! There is no going back</sub></sup>