contensis-cli 1.6.1-beta.9 → 1.7.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.
Files changed (138) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENSE +674 -0
  3. package/dist/index.js +58362 -11
  4. package/dist/index.js.map +4 -4
  5. package/dist/shell.js +58100 -52
  6. package/dist/shell.js.map +4 -4
  7. package/docs/copy_field_templates.md +112 -0
  8. package/esbuild.config.js +15 -13
  9. package/package.json +3 -4
  10. package/src/commands/create.ts +48 -0
  11. package/src/commands/dev.ts +6 -0
  12. package/src/commands/push.ts +38 -6
  13. package/src/commands/set.ts +70 -1
  14. package/src/localisation/en-GB.ts +12 -0
  15. package/src/mappers/DevRequests-to-RequestHanderCliArgs.ts +3 -0
  16. package/src/models/CliService.d.ts +5 -1
  17. package/src/services/ContensisCliService.ts +189 -7
  18. package/src/shell.ts +6 -1
  19. package/src/util/logger.ts +3 -4
  20. package/src/version.ts +1 -1
  21. package/dist/commands/connect.js +0 -44
  22. package/dist/commands/connect.js.map +0 -7
  23. package/dist/commands/copy.js +0 -78
  24. package/dist/commands/copy.js.map +0 -7
  25. package/dist/commands/create.js +0 -170
  26. package/dist/commands/create.js.map +0 -7
  27. package/dist/commands/dev.js +0 -81
  28. package/dist/commands/dev.js.map +0 -7
  29. package/dist/commands/diff.js +0 -57
  30. package/dist/commands/diff.js.map +0 -7
  31. package/dist/commands/execute.js +0 -103
  32. package/dist/commands/execute.js.map +0 -7
  33. package/dist/commands/get.js +0 -330
  34. package/dist/commands/get.js.map +0 -7
  35. package/dist/commands/globalOptions.js +0 -252
  36. package/dist/commands/globalOptions.js.map +0 -7
  37. package/dist/commands/import.js +0 -256
  38. package/dist/commands/import.js.map +0 -7
  39. package/dist/commands/index.js +0 -107
  40. package/dist/commands/index.js.map +0 -7
  41. package/dist/commands/list.js +0 -195
  42. package/dist/commands/list.js.map +0 -7
  43. package/dist/commands/login.js +0 -55
  44. package/dist/commands/login.js.map +0 -7
  45. package/dist/commands/push.js +0 -234
  46. package/dist/commands/push.js.map +0 -7
  47. package/dist/commands/remove.js +0 -193
  48. package/dist/commands/remove.js.map +0 -7
  49. package/dist/commands/set.js +0 -180
  50. package/dist/commands/set.js.map +0 -7
  51. package/dist/commands/update.js +0 -70
  52. package/dist/commands/update.js.map +0 -7
  53. package/dist/factories/RequestHandlerFactory.js +0 -230
  54. package/dist/factories/RequestHandlerFactory.js.map +0 -7
  55. package/dist/localisation/en-GB.js +0 -559
  56. package/dist/localisation/en-GB.js.map +0 -7
  57. package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js +0 -56
  58. package/dist/mappers/ContensisCliService-to-RequestHanderSiteConfigYaml.js.map +0 -7
  59. package/dist/mappers/DevInit-to-CIWorkflow.js +0 -409
  60. package/dist/mappers/DevInit-to-CIWorkflow.js.map +0 -7
  61. package/dist/mappers/DevInit-to-RolePermissions.js +0 -56
  62. package/dist/mappers/DevInit-to-RolePermissions.js.map +0 -7
  63. package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js +0 -168
  64. package/dist/mappers/DevRequests-to-RequestHanderCliArgs.js.map +0 -7
  65. package/dist/mappers/MixedFileData.js +0 -83
  66. package/dist/mappers/MixedFileData.js.map +0 -7
  67. package/dist/models/AppError.d.js +0 -2
  68. package/dist/models/AppError.d.js.map +0 -7
  69. package/dist/models/Cache.d.js +0 -2
  70. package/dist/models/Cache.d.js.map +0 -7
  71. package/dist/models/CliService.d.js +0 -17
  72. package/dist/models/CliService.d.js.map +0 -7
  73. package/dist/models/DevService.d.js +0 -17
  74. package/dist/models/DevService.d.js.map +0 -7
  75. package/dist/models/JsModules.d.js +0 -2
  76. package/dist/models/JsModules.d.js.map +0 -7
  77. package/dist/providers/CredentialProvider.js +0 -126
  78. package/dist/providers/CredentialProvider.js.map +0 -7
  79. package/dist/providers/GitHubCliModuleProvider.js +0 -115
  80. package/dist/providers/GitHubCliModuleProvider.js.map +0 -7
  81. package/dist/providers/HttpProvider.js +0 -73
  82. package/dist/providers/HttpProvider.js.map +0 -7
  83. package/dist/providers/ManifestProvider.js +0 -50
  84. package/dist/providers/ManifestProvider.js.map +0 -7
  85. package/dist/providers/SessionCacheProvider.js +0 -132
  86. package/dist/providers/SessionCacheProvider.js.map +0 -7
  87. package/dist/providers/file-provider.js +0 -177
  88. package/dist/providers/file-provider.js.map +0 -7
  89. package/dist/services/ContensisAuthService.js +0 -88
  90. package/dist/services/ContensisAuthService.js.map +0 -7
  91. package/dist/services/ContensisCliService.js +0 -2661
  92. package/dist/services/ContensisCliService.js.map +0 -7
  93. package/dist/services/ContensisDevService.js +0 -435
  94. package/dist/services/ContensisDevService.js.map +0 -7
  95. package/dist/services/ContensisRoleService.js +0 -112
  96. package/dist/services/ContensisRoleService.js.map +0 -7
  97. package/dist/util/api-ids.js +0 -110
  98. package/dist/util/api-ids.js.map +0 -7
  99. package/dist/util/assert.js +0 -62
  100. package/dist/util/assert.js.map +0 -7
  101. package/dist/util/console.printer.js +0 -461
  102. package/dist/util/console.printer.js.map +0 -7
  103. package/dist/util/csv.formatter.js +0 -118
  104. package/dist/util/csv.formatter.js.map +0 -7
  105. package/dist/util/debug.js +0 -29
  106. package/dist/util/debug.js.map +0 -7
  107. package/dist/util/diff.js +0 -118
  108. package/dist/util/diff.js.map +0 -7
  109. package/dist/util/dotenv.js +0 -56
  110. package/dist/util/dotenv.js.map +0 -7
  111. package/dist/util/error.js +0 -36
  112. package/dist/util/error.js.map +0 -7
  113. package/dist/util/fetch.js +0 -69
  114. package/dist/util/fetch.js.map +0 -7
  115. package/dist/util/find.js +0 -39
  116. package/dist/util/find.js.map +0 -7
  117. package/dist/util/git.js +0 -145
  118. package/dist/util/git.js.map +0 -7
  119. package/dist/util/gitignore.js +0 -61
  120. package/dist/util/gitignore.js.map +0 -7
  121. package/dist/util/html.formatter.js +0 -70
  122. package/dist/util/html.formatter.js.map +0 -7
  123. package/dist/util/index.js +0 -68
  124. package/dist/util/index.js.map +0 -7
  125. package/dist/util/json.formatter.js +0 -66
  126. package/dist/util/json.formatter.js.map +0 -7
  127. package/dist/util/logger.js +0 -304
  128. package/dist/util/logger.js.map +0 -7
  129. package/dist/util/os.js +0 -49
  130. package/dist/util/os.js.map +0 -7
  131. package/dist/util/timers.js +0 -49
  132. package/dist/util/timers.js.map +0 -7
  133. package/dist/util/xml.formatter.js +0 -62
  134. package/dist/util/xml.formatter.js.map +0 -7
  135. package/dist/util/yaml.js +0 -44
  136. package/dist/util/yaml.js.map +0 -7
  137. package/dist/version.js +0 -29
  138. package/dist/version.js.map +0 -7
@@ -352,3 +352,115 @@ Or we can refer to other fields in the `entry` variable
352
352
  ```handlebars
353
353
  {{entry.text}}{% if entry.heading %} - {{entry.heading}}{% endif %}
354
354
  ```
355
+
356
+ ### Transforming fields inside Canvas blocks
357
+
358
+ Canvas fields contain an array of blocks (objects with `id`, `type`, `value`, `properties`). Some blocks are components (`_component` type with `properties.component`) that hold nested fields inside `value`. To transform those inner fields - for example converting a rich text field inside a component to canvas format - you need to rebuild the canvas array by iterating over the blocks and selectively transforming the ones you need.
359
+
360
+ This is done using the `capture` tag to build the output as a JSON string, then `from_json | json` to validate and minify the result.
361
+
362
+ #### Example: Convert rich text to canvas inside a component block
363
+
364
+ Given a canvas field containing a `linkedComponent` block with a `richText` field:
365
+
366
+ ```json
367
+ {
368
+ "id": "5b03fe6a",
369
+ "type": "_component",
370
+ "properties": { "component": "linkedComponent" },
371
+ "value": {
372
+ "entry": [{ "sys": { "id": "abc123", "dataFormat": "entry" } }],
373
+ "title": "My component",
374
+ "richText": "<h2>Original rich text</h2>",
375
+ "canvas": null
376
+ }
377
+ }
378
+ ```
379
+
380
+ This template converts `richText` to canvas via `html_to_canvas`, storing it in the `canvas` field. Other blocks pass through unchanged:
381
+
382
+ ```handlebars
383
+ {% capture out %}
384
+ [
385
+ {%- for b in value -%}
386
+ {%- if forloop.index0 > 0 %},{% endif -%}
387
+ {%- if b.properties.component == "linkedComponent" -%}
388
+ {
389
+ "id": {{ b.id | json }},
390
+ "type": {{ b.type | json }},
391
+ "properties": {{ b.properties | json }},
392
+ "value": {
393
+ "entry": {{ b.value.entry | json }},
394
+ "title": {{ b.value.title | json }},
395
+ "richText": {{ b.value.richText | json }},
396
+ "canvas": {% if b.value.richText and b.value.richText != "" %}{{ b.value.richText | html_to_canvas | json }}{% else %}{{ b.value.canvas | json }}{% endif %}
397
+ }
398
+ }
399
+ {%- else -%}
400
+ {{ b | json }}
401
+ {%- endif -%}
402
+ {%- endfor -%}
403
+ ]
404
+ {% endcapture %}
405
+ {{ out | from_json | json }}
406
+ ```
407
+
408
+ #### How it works
409
+
410
+ 1. `{% capture out %}` starts building the output as a JSON string
411
+ 2. The outer `[` opens the canvas array
412
+ 3. `{% for b in value %}` iterates over every block in the canvas
413
+ 4. `{% if b.properties.component == "linkedComponent" %}` matches the block we want to transform
414
+ 5. Each field in the block is mapped with `|json` to ensure valid JSON output (strings get quotes, objects serialize correctly)
415
+ 6. The `canvas` field conditionally applies `html_to_canvas` when `richText` exists, otherwise passes the existing value through
416
+ 7. `{% else %}` passes non-matching blocks through unchanged via `{{ b | json }}`
417
+ 8. `{% endcapture %}` closes the string, then `{{ out | from_json | json }}` parses and re-serializes to validate the JSON
418
+
419
+ #### Why `|json` is needed on every mapped field
420
+
421
+ Without it, strings would render bare (invalid JSON: `hello` instead of `"hello"`) and objects would render as `[object Object]`. The `|json` filter handles strings, objects, arrays, nulls, and booleans correctly.
422
+
423
+ #### Handling nested component blocks
424
+
425
+ If a canvas block contains a repeatable array of sub-components, you can nest the same pattern. For example, a `nestingLinkedComponent` block has `linkedComponent[]` items, each with their own `richText` and `canvas`:
426
+
427
+ ```handlebars
428
+ {% capture out %}
429
+ [
430
+ {%- for b in value -%}
431
+ {%- if forloop.index0 > 0 %},{% endif -%}
432
+ {%- if b.properties.component == "nestingLinkedComponent" -%}
433
+ {
434
+ "id": {{ b.id | json }},
435
+ "type": {{ b.type | json }},
436
+ "properties": {{ b.properties | json }},
437
+ "value": {
438
+ "linkedComponent": [
439
+ {%- for it in b.value.linkedComponent -%}
440
+ {%- if forloop.index0 > 0 %},{% endif -%}
441
+ {
442
+ "entry": {{ it.entry | json }},
443
+ "title": {{ it.title | json }},
444
+ "richText": {{ it.richText | json }},
445
+ "canvas": {% if it.richText and it.richText != "" %}{{ it.richText | html_to_canvas | json }}{% else %}{{ it.canvas | json }}{% endif %}
446
+ }
447
+ {%- endfor -%}
448
+ ],
449
+ "singleLinkedComponent": {
450
+ "entry": {{ b.value.singleLinkedComponent.entry | json }},
451
+ "title": {{ b.value.singleLinkedComponent.title | json }},
452
+ "richText": {{ b.value.singleLinkedComponent.richText | json }},
453
+ "canvas": {% if b.value.singleLinkedComponent.richText and b.value.singleLinkedComponent.richText != "" %}{{ b.value.singleLinkedComponent.richText | html_to_canvas | json }}{% else %}{{ b.value.singleLinkedComponent.canvas | json }}{% endif %}
454
+ }
455
+ }
456
+ }
457
+ {%- else -%}
458
+ {{ b | json }}
459
+ {%- endif -%}
460
+ {%- endfor -%}
461
+ ]
462
+ {% endcapture %}
463
+ {{ out | from_json | json }}
464
+ ```
465
+
466
+ The same `richText` to `canvas` conversion is applied to each item in the repeatable `linkedComponent` array and to the singular `singleLinkedComponent` block.
package/esbuild.config.js CHANGED
@@ -1,3 +1,4 @@
1
+ const fs = require('fs');
1
2
  const { rimraf } = require('rimraf');
2
3
  const esbuild = require('esbuild');
3
4
  const chalk = require('chalk');
@@ -5,7 +6,12 @@ const { globPlugin } = require('esbuild-plugin-glob');
5
6
  const { nodeExternalsPlugin } = require('esbuild-node-externals');
6
7
  const { replaceTscAliasPaths } = require('tsc-alias');
7
8
 
8
- // const watch = !!process.argv.includes('--watch');
9
+ // embed the current package version into the build
10
+ // (package.json is the single source of truth; this used to be a `prebuild`
11
+ // npm lifecycle script, which lerna/yarn builds never fire - see release 1.7.0)
12
+ const { version } = require('./package.json');
13
+ fs.writeFileSync('./src/version.ts', `export const LIB_VERSION = ${JSON.stringify(version)};\n`);
14
+
9
15
  const completed = `${chalk.green('[contensis-cli]')} Build successful 👍\n`;
10
16
 
11
17
  console.time(completed);
@@ -16,9 +22,9 @@ rimraf('./dist').then(() => {
16
22
  console.time(' - esbuild complete');
17
23
  esbuild
18
24
  .build({
19
- entryPoints: ['src/**/*.[jt]s'],
25
+ entryPoints: ['src/index.ts', 'src/shell.ts'],
20
26
  outdir: 'dist',
21
- bundle: false,
27
+ bundle: true,
22
28
  minify: false,
23
29
  platform: 'node',
24
30
  format: 'cjs',
@@ -26,16 +32,12 @@ rimraf('./dist').then(() => {
26
32
  // needs to be node12 to transform dynamic imports into requires
27
33
  // so the bundles are compatible with the pkg exe builds
28
34
  target: 'node12',
29
- plugins: [globPlugin(), nodeExternalsPlugin()],
30
- // watch: watch && {
31
- // onRebuild(error) {
32
- // if (error) console.error('esbuild watch build failed:', error);
33
- // else
34
- // console.log(
35
- // 'esbuild watch build succeeded, waiting for changes...'
36
- // );
37
- // },
38
- // },
35
+ plugins: [globPlugin(), nodeExternalsPlugin({
36
+ allowList: [/^@inquirer\//],
37
+ dependencies: true,
38
+ forceExternalList: ['enterprise-fetch']
39
+ // forceExternalList: ['keytar', '@action-validator/core', 'figlet', 'node-fetch', 'enterprise-fetch']
40
+ })],
39
41
  })
40
42
  .then(() => {
41
43
  console.timeEnd(' - esbuild complete');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contensis-cli",
3
- "version": "1.6.1-beta.9",
3
+ "version": "1.7.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": {
6
6
  "type": "git",
@@ -16,7 +16,6 @@
16
16
  "prestart": "npm run build",
17
17
  "start": "npm run cli",
18
18
  "dev:shell": "npm run prestart && nodemon --watch dist --inspect=9229 ./dist/shell.js",
19
- "prebuild": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
20
19
  "build": "node esbuild.config.js",
21
20
  "build:watch": "node esbuild.config.js --watch",
22
21
  "cli": "node --inspect=9229 ./cli.js",
@@ -25,7 +24,7 @@
25
24
  "package-lock": "npm i --package-lock-only --workspaces false"
26
25
  },
27
26
  "author": "Zengenti",
28
- "license": "ISC",
27
+ "license": "GPL-3.0",
29
28
  "dependencies": {
30
29
  "@action-validator/core": "^0.6.0",
31
30
  "@inquirer/prompts": "^8.2.0",
@@ -43,7 +42,7 @@
43
42
  "inquirer-command-prompt": "^0.1.0",
44
43
  "keytar": "^7.9.0",
45
44
  "lodash": "^4.17.21",
46
- "migratortron": "^1.0.0-beta.86",
45
+ "migratortron": "^1.0.0-beta.89",
47
46
  "nanospinner": "^1.2.0",
48
47
  "node-fetch": "^2.6.7",
49
48
  "parse-git-config": "^3.0.0",
@@ -71,6 +71,54 @@ Example call:
71
71
  );
72
72
  });
73
73
 
74
+ create
75
+ .command('node')
76
+ .description('create a new site view node')
77
+ .argument('<"node path or id">', 'the path or id of the node to create')
78
+ .argument(
79
+ '["display name"]',
80
+ 'provide a separate display name for the node (optional)'
81
+ )
82
+ .argument(
83
+ '["slug"]',
84
+ 'provide a slug for the node (defaults to slug from provided node path)'
85
+ )
86
+ .option(
87
+ '--include-in-menu',
88
+ 'set include in menu flag on the created node',
89
+ false
90
+ )
91
+ .option(
92
+ '--language <language>',
93
+ 'language of the node to create (defaults to current project primary language)'
94
+ )
95
+ .option('--entry-id <entryId>', 'attach an entry to the node')
96
+ .usage(
97
+ '<"node path or id"> ["display name"] (both args in "double quotes")'
98
+ )
99
+ .addHelpText(
100
+ 'after',
101
+ `
102
+ Example call:
103
+ > create node /test "Test Node" --include-in-menu\n`
104
+ )
105
+ .action(
106
+ async (
107
+ pathOrId: string,
108
+ displayName: string,
109
+ slug: string,
110
+ opts: any
111
+ ) => {
112
+ await cliCommand(['create', 'node', pathOrId], opts).CreateOrUpdateNode(
113
+ pathOrId,
114
+ opts,
115
+ displayName,
116
+ slug,
117
+ opts.language
118
+ );
119
+ }
120
+ );
121
+
74
122
  create
75
123
  .command('role')
76
124
  .description('create a new role')
@@ -62,6 +62,12 @@ Example call:
62
62
  '--override [override...]',
63
63
  'override configurations for other blocks'
64
64
  )
65
+ .addOption(
66
+ new Option(
67
+ '-ll --log-level <logLevel>',
68
+ 'set the request handler logging level'
69
+ ).choices(['debug', 'information', 'warning', 'error', 'none'])
70
+ )
65
71
  .usage('[block-id] [local-uri]')
66
72
  .addHelpText(
67
73
  'after',
@@ -212,6 +212,13 @@ Example call:
212
212
  },
213
213
  projectId: () => cli.env.currentProject || '',
214
214
  source: {
215
+ // Provenance resolution order per field:
216
+ // 1. explicit cli flag (camelCase key from commander opts)
217
+ // 2. CONTENSIS_* env var - a safe channel for CI actions to supply
218
+ // values without embedding them in the command string (where mapped)
219
+ // 3. generic CI variables the runner exports
220
+ // The mapper skips empty/undefined candidates and uses the first
221
+ // non-empty value, so unset optional vars never mask a fallback.
215
222
  provider: {
216
223
  $path: ['provider'],
217
224
  $return: (provider: string, { GITHUB_ACTIONS, GITLAB_CI }) => {
@@ -221,9 +228,15 @@ Example call:
221
228
  },
222
229
  },
223
230
  repositoryUrl: {
224
- $path: ['repositoryUrl', 'CI_PROJECT_URL', 'GITHUB_REPOSITORY'],
231
+ $path: [
232
+ 'repositoryUrl',
233
+ 'CONTENSIS_REPOSITORY_URL',
234
+ 'CI_PROJECT_URL',
235
+ 'GITHUB_REPOSITORY',
236
+ ],
225
237
  $formatting: (url: string, { GITHUB_ACTIONS }) => {
226
- if (GITHUB_ACTIONS) url = `https://github.com/${url}`;
238
+ if (GITHUB_ACTIONS && !url.startsWith(`https://`))
239
+ url = `https://github.com/${url}`;
227
240
 
228
241
  if (url && !url.endsWith('.git')) return `${url}.git`;
229
242
  return url;
@@ -231,16 +244,35 @@ Example call:
231
244
  },
232
245
  branch: ['branch', 'CI_COMMIT_REF_NAME', 'GITHUB_REF_NAME'],
233
246
  commit: {
234
- id: ['commitId', 'CI_COMMIT_SHORT_SHA', 'GITHUB_SHA'],
247
+ id: [
248
+ 'commitId',
249
+ 'CONTENSIS_COMMIT_ID',
250
+ 'CI_COMMIT_SHORT_SHA',
251
+ 'GITHUB_SHA',
252
+ ],
235
253
  message: {
236
- $path: ['commitMessage', 'CI_COMMIT_MESSAGE'], // ${{ github.event.head_commit.message }}
254
+ $path: [
255
+ 'commitMessage',
256
+ 'CONTENSIS_COMMIT_MESSAGE',
257
+ 'CI_COMMIT_MESSAGE',
258
+ ], // ${{ github.event.head_commit.message }}
237
259
  $formatting: (msg?: string) =>
238
260
  msg?.replace(/\\n/g, ' ').replace(/\\n/g, ' ').trim(),
239
261
  },
240
- dateTime: ['commitDatetime', 'CI_COMMIT_TIMESTAMP'], // ${{ github.event.head_commit.timestamp }}
241
- authorEmail: ['authorEmail', 'GITLAB_USER_EMAIL', 'GITHUB_ACTOR'], // ${{ github.event.head_commit.author.email }}
262
+ dateTime: [
263
+ 'commitDatetime',
264
+ 'CONTENSIS_COMMIT_DATETIME',
265
+ 'CI_COMMIT_TIMESTAMP',
266
+ ], // ${{ github.event.head_commit.timestamp }}
267
+ authorEmail: [
268
+ 'authorEmail',
269
+ 'CONTENSIS_AUTHOR_EMAIL',
270
+ 'GITLAB_USER_EMAIL',
271
+ 'GITHUB_ACTOR',
272
+ ], // ${{ github.event.head_commit.author.email }}
242
273
  committerEmail: [
243
274
  'committerEmail',
275
+ 'CONTENSIS_COMMITTER_EMAIL',
244
276
  'GITLAB_USER_EMAIL',
245
277
  'GITHUB_TRIGGERING_ACTOR',
246
278
  ], // ${{ github.event.head_commit.committer.email }}
@@ -1,4 +1,4 @@
1
- import { Argument, Command } from 'commander';
1
+ import { Argument, Command, Option } from 'commander';
2
2
  import { cliCommand } from '~/services/ContensisCliService';
3
3
  import { shell } from '~/shell';
4
4
 
@@ -10,6 +10,57 @@ export const makeSetCommand = () => {
10
10
  .showHelpAfterError(true)
11
11
  .exitOverride();
12
12
 
13
+ const node = set.command('node').description('update a site view node');
14
+
15
+ node
16
+ .command('entry')
17
+ .description('assign an entry to a node')
18
+ .argument('<"node path or id">', 'the path or id of the node to update')
19
+ .argument('<entryId>', 'the new entry id to assign to the node')
20
+ .usage('<"node path or id"> <entryId>')
21
+ .addHelpText(
22
+ 'after',
23
+ `
24
+ Example call:
25
+ > set node entry /path 1502f64e-e9b1-436b-b62f-e273f639ecb6\n`
26
+ )
27
+ .action(async (nodePathOrId: string, entryId: string, opts) => {
28
+ await cliCommand(['set', 'node', 'entry'], opts).CreateOrUpdateNode(
29
+ nodePathOrId,
30
+ { entryId }
31
+ );
32
+ });
33
+
34
+ node
35
+ .command('renderer')
36
+ .description('assign a renderer to a node')
37
+ .argument('<"node path or id">', 'the path or id of the node to update')
38
+ .argument('<rendererUuidOrName>', 'the renderer uuid, id or name to assign to the node')
39
+ .option(
40
+ '--is-partial-match-root',
41
+ 'should the renderer be used as the partial match root for the node',
42
+ false
43
+ )
44
+ .usage('<"node path or id"> <rendererUuidOrName>')
45
+ .addHelpText(
46
+ 'after',
47
+ `
48
+ Example call:
49
+ > set node renderer /path 1502f64e-e9b1-436b-b62f-e273f639ecb6 --is-partial-match-root
50
+ > set node renderer /path my-block --is-partial-match-root\n`
51
+ )
52
+ .action(async (nodePathOrId: string, rendererId: string, opts) => {
53
+ await cliCommand(['set', 'node', 'renderer'], opts).CreateOrUpdateNode(
54
+ nodePathOrId,
55
+ {
56
+ renderer: {
57
+ id: rendererId,
58
+ isPartialMatchRoot: opts.isPartialMatchRoot,
59
+ },
60
+ }
61
+ );
62
+ });
63
+
13
64
  const project = set
14
65
  .command('project')
15
66
  .description('set current working project')
@@ -178,6 +229,21 @@ Example call:
178
229
  '--entry-languages [entry-languages...]',
179
230
  'the entry languages to add to the role permissions'
180
231
  )
232
+ .addOption(
233
+ new Option(
234
+ '--block-actions [block-actions...]',
235
+ 'the block actions to add to the role permissions'
236
+ ).choices([
237
+ 'push',
238
+ 'release',
239
+ 'manageLive',
240
+ 'manualStartStop',
241
+ 'markAsBroken',
242
+ 'delete',
243
+ 'view',
244
+ '*',
245
+ ])
246
+ )
181
247
  .addHelpText(
182
248
  'after',
183
249
  `
@@ -194,6 +260,9 @@ Example call:
194
260
  actions: opts.entryActions || [],
195
261
  languages: opts.entryLanguages || [],
196
262
  })),
263
+ blocks: opts.blockActions
264
+ ? { actions: opts.blockActions }
265
+ : undefined,
197
266
  },
198
267
  }
199
268
  );
@@ -188,6 +188,14 @@ export const LogMessages = {
188
188
  depth ? ` to a depth of ${depth}` : ``
189
189
  }\n`,
190
190
  noChange: (env: string) => `[${env}] No changes to be made`,
191
+ setPayload: () => `Updating node with details\n`,
192
+ set: (env: string) => `[${env}] Succesfully updated node\n`,
193
+ failedSet: (env: string, name?: string) =>
194
+ `[${env}] Unable to update node ${Logger.highlightText(name)}`,
195
+ created: (env: string, name: string) =>
196
+ `[${env}] Created node ${Logger.highlightText(name)}\n`,
197
+ failedCreate: (env: string, name?: string) =>
198
+ `[${env}] Unable to create node ${Logger.highlightText(name)}`,
191
199
  },
192
200
  contenttypes: {
193
201
  list: (projectId: string) =>
@@ -317,6 +325,10 @@ export const LogMessages = {
317
325
  `[${env}] Unable to find renderer ${Logger.highlightText(
318
326
  name
319
327
  )} in project ${projectId}`,
328
+ resolved: (env: string, name: string, uuid: string) =>
329
+ `[${env}] Resolved renderer ${Logger.highlightText(
330
+ name
331
+ )} to uuid ${Logger.highlightText(uuid)}`,
320
332
  created: (env: string, name: string, projectId: string) =>
321
333
  `[${env}] Created renderer ${Logger.highlightText(
322
334
  name
@@ -179,6 +179,9 @@ class RequestHandlerArgs {
179
179
  args.push('--password', client.password);
180
180
  }
181
181
 
182
+ if (cli.logLevel && !args.find(a => a === '--log-level'))
183
+ args.push('--log-level', cli.logLevel);
184
+
182
185
  return args;
183
186
  };
184
187
 
@@ -1,3 +1,5 @@
1
+ import ContensisCli from '~/services/ContensisCliService';
2
+
1
3
  export type CliUrls =
2
4
  | {
3
5
  api: string;
@@ -33,7 +35,9 @@ export interface IImportOptions {
33
35
  sourceProjectId?: string;
34
36
  }
35
37
 
36
- export type OutputOptionsConstructorArg = OutputOptions &
38
+ export type OutputOptionsConstructorArg = {
39
+ logLevel?: ContensisCli['logLevel'];
40
+ } & OutputOptions &
37
41
  IConnectOptions &
38
42
  IImportOptions;
39
43