contensis-cli 1.6.1-beta.13 → 1.6.1-beta.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/shell.js CHANGED
@@ -46465,7 +46465,7 @@ var progress = {
46465
46465
  };
46466
46466
 
46467
46467
  // src/version.ts
46468
- var LIB_VERSION = "1.6.1-beta.13";
46468
+ var LIB_VERSION = "1.6.1-beta.15";
46469
46469
 
46470
46470
  // src/commands/connect.ts
46471
46471
  var import_commander2 = require("commander");
@@ -46703,7 +46703,15 @@ ${Logger.errorText(">>")} Available commands:`,
46703
46703
  failedGet: (projectId) => `[${projectId}] Cannot retrieve nodes from Site view`,
46704
46704
  get: (projectId, root, depth) => `[${projectId}] Site view nodes at: ${Logger.highlightText(root)}${depth ? ` to a depth of ${depth}` : ``}
46705
46705
  `,
46706
- noChange: (env) => `[${env}] No changes to be made`
46706
+ noChange: (env) => `[${env}] No changes to be made`,
46707
+ setPayload: () => `Updating node with details
46708
+ `,
46709
+ set: (env) => `[${env}] Succesfully updated node
46710
+ `,
46711
+ failedSet: (env, name) => `[${env}] Unable to update node ${Logger.highlightText(name)}`,
46712
+ created: (env, name) => `[${env}] Created node ${Logger.highlightText(name)}
46713
+ `,
46714
+ failedCreate: (env, name) => `[${env}] Unable to create node ${Logger.highlightText(name)}`
46707
46715
  },
46708
46716
  contenttypes: {
46709
46717
  list: (projectId) => `Content types in ${Logger.highlightText(projectId)}:`,
@@ -50287,6 +50295,100 @@ Components:`));
50287
50295
  }
50288
50296
  }
50289
50297
  };
50298
+ CreateOrUpdateNode = async (nodePathOrId, nodeUpdates, displayName, slug, language) => {
50299
+ var _a, _b;
50300
+ const { currentEnv, currentProject, log, messages } = this;
50301
+ const contensis = await this.ConnectContensis();
50302
+ const nodePath = nodePathOrId.startsWith("/") ? nodePathOrId : void 0;
50303
+ let nodeId = isUuid(nodePathOrId) ? nodePathOrId : void 0;
50304
+ let existingNode;
50305
+ let parentNode;
50306
+ let updateNode;
50307
+ if (contensis) {
50308
+ if (nodePath) {
50309
+ const [, nodesByPath] = await (0, import_await_to_js2.default)(contensis.nodes.GetNodes(nodePath, 0));
50310
+ if (Array.isArray(nodesByPath) && ((_a = nodesByPath[0]) == null ? void 0 : _a.id)) {
50311
+ nodeId = nodesByPath[0].id;
50312
+ }
50313
+ }
50314
+ if (nodeId) {
50315
+ const [, nodeById] = await (0, import_await_to_js2.default)(
50316
+ contensis.source.repo.GetNodeById(nodeId)
50317
+ );
50318
+ if (nodeById) existingNode = nodeById;
50319
+ }
50320
+ if (!existingNode) {
50321
+ if (!language) {
50322
+ const project2 = await contensis.source.repo.GetProject(currentProject);
50323
+ language = (project2 == null ? void 0 : project2.primaryLanguage) || "en-GB";
50324
+ }
50325
+ if (!nodeUpdates.parentId) {
50326
+ if (!nodePath)
50327
+ throw new Error(
50328
+ `A node with id "${nodeId}" does not exist, and a path was not provided to find the parent node.`
50329
+ );
50330
+ const parentPath = nodePath.substring(0, nodePath.lastIndexOf("/")) || "/";
50331
+ const [, parentNodesByPath] = await (0, import_await_to_js2.default)(
50332
+ contensis.nodes.GetNodes(parentPath, 0)
50333
+ );
50334
+ if (!((_b = parentNodesByPath == null ? void 0 : parentNodesByPath[0]) == null ? void 0 : _b.id))
50335
+ throw new Error(
50336
+ `A node with id "${nodeId}" does not exist, and the parent node could not be found at path "${parentPath}".`
50337
+ );
50338
+ else parentNode = parentNodesByPath[0];
50339
+ }
50340
+ const pathSlug = nodePath == null ? void 0 : nodePath.substring(nodePath.lastIndexOf("/") + 1);
50341
+ const createNode = {
50342
+ id: nodeId,
50343
+ parentId: nodeUpdates.parentId || (parentNode == null ? void 0 : parentNode.id),
50344
+ projectId: currentProject,
50345
+ displayName: displayName ? {
50346
+ [language]: displayName
50347
+ } : nodeUpdates.displayName ? nodeUpdates.displayName : pathSlug ? {
50348
+ [language]: pathSlug
50349
+ } : void 0,
50350
+ slug: slug ? {
50351
+ [language]: slug
50352
+ } : nodeUpdates.slug ? nodeUpdates.slug : pathSlug ? {
50353
+ [language]: pathSlug
50354
+ } : void 0,
50355
+ entryId: nodeUpdates.entryId,
50356
+ isCanonical: nodeUpdates.isCanonical,
50357
+ renderer: nodeUpdates.renderer,
50358
+ proxy: nodeUpdates.proxy,
50359
+ includeInMenu: nodeUpdates.includeInMenu
50360
+ };
50361
+ updateNode = createNode;
50362
+ } else {
50363
+ updateNode = { ...existingNode, ...nodeUpdates };
50364
+ }
50365
+ if (updateNode) {
50366
+ log.info(messages.nodes.setPayload());
50367
+ log.object(updateNode);
50368
+ const [err, newNode] = await contensis.source.repo.UpdateOrCreateNode(
50369
+ existingNode,
50370
+ updateNode
50371
+ );
50372
+ if (err)
50373
+ log.error(
50374
+ messages.nodes[existingNode ? "failedSet" : "failedCreate"](
50375
+ currentEnv,
50376
+ nodePathOrId
50377
+ ),
50378
+ err
50379
+ );
50380
+ else if (newNode) {
50381
+ log.success(
50382
+ messages.nodes[existingNode ? "set" : "created"](
50383
+ currentEnv,
50384
+ newNode.id
50385
+ )
50386
+ );
50387
+ await this.HandleFormattingAndOutput(newNode, log.object);
50388
+ }
50389
+ }
50390
+ }
50391
+ };
50290
50392
  PrintWebhookSubscriptions = async (subscriptionIdsOrNames) => {
50291
50393
  const { currentEnv, log, messages } = this;
50292
50394
  const contensis = await this.ConnectContensis();
@@ -50735,25 +50837,29 @@ Components:`));
50735
50837
  }
50736
50838
  }
50737
50839
  };
50738
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
50739
50840
  PrintRenderers = async (rendererId) => {
50740
50841
  const { currentEnv, env, log, messages } = this;
50741
50842
  const contensis = await this.ConnectContensis();
50742
50843
  if (contensis) {
50743
50844
  const [err, renderers] = await contensis.renderers.GetRenderers();
50744
50845
  if (Array.isArray(renderers)) {
50745
- await this.HandleFormattingAndOutput(renderers, () => {
50846
+ const result = rendererId ? [renderers.find((r) => r.id === rendererId)].filter(
50847
+ Boolean
50848
+ ) : renderers || [];
50849
+ await this.HandleFormattingAndOutput(result, () => {
50746
50850
  log.success(messages.renderers.list(currentEnv, env.currentProject));
50747
50851
  for (const {
50852
+ uuid,
50748
50853
  id,
50749
50854
  description,
50750
50855
  assignedContentTypes,
50751
50856
  rules,
50752
50857
  version
50753
- } of renderers) {
50858
+ } of result) {
50754
50859
  console.log(
50755
50860
  ` - ${id} [${version.versionNo}] ${log.infoText`${description}`}`
50756
50861
  );
50862
+ console.log(log.infoText` uuid: ${uuid}`);
50757
50863
  if (assignedContentTypes == null ? void 0 : assignedContentTypes.length)
50758
50864
  console.log(
50759
50865
  log.infoText` assignedContentTypes: ${assignedContentTypes.join(
@@ -50767,7 +50873,7 @@ Components:`));
50767
50873
  );
50768
50874
  }
50769
50875
  });
50770
- return renderers;
50876
+ return result;
50771
50877
  }
50772
50878
  if (err) {
50773
50879
  log.error(messages.renderers.noList(currentEnv, env.currentProject));
@@ -51099,6 +51205,38 @@ Example call:
51099
51205
  description
51100
51206
  );
51101
51207
  });
51208
+ create.command("node").description("create a new site view node").argument('<"node path or id">', "the path or id of the node to create").argument(
51209
+ '["display name"]',
51210
+ "provide a separate display name for the node (optional)"
51211
+ ).argument(
51212
+ '["slug"]',
51213
+ "provide a slug for the node (defaults to slug from provided node path)"
51214
+ ).option(
51215
+ "--include-in-menu",
51216
+ "set include in menu flag on the created node",
51217
+ false
51218
+ ).option(
51219
+ "--language <language>",
51220
+ "language of the node to create (defaults to current project primary language)"
51221
+ ).option("--entry-id <entryId>", "attach an entry to the node").usage(
51222
+ '<"node path or id"> ["display name"] (both args in "double quotes")'
51223
+ ).addHelpText(
51224
+ "after",
51225
+ `
51226
+ Example call:
51227
+ > create node /test "Test Node" --include-in-menu
51228
+ `
51229
+ ).action(
51230
+ async (pathOrId, displayName, slug, opts) => {
51231
+ await cliCommand(["create", "node", pathOrId], opts).CreateOrUpdateNode(
51232
+ pathOrId,
51233
+ opts,
51234
+ displayName,
51235
+ slug,
51236
+ opts.language
51237
+ );
51238
+ }
51239
+ );
51102
51240
  create.command("role").description("create a new role").argument('<"Role name">', "the name of the role to create").argument('["Role description">', "the description of the role").option("--disabled", "do not enable the created role", false).addHelpText(
51103
51241
  "after",
51104
51242
  `
@@ -57547,6 +57685,40 @@ var import_commander14 = require("commander");
57547
57685
  var makeSetCommand = () => {
57548
57686
  const set = new import_commander14.Command().command("set").description("set command").addHelpText("after", `
57549
57687
  `).showHelpAfterError(true).exitOverride();
57688
+ const node = set.command("node").description("update a site view node");
57689
+ node.command("entry").description("assign an entry to a node").argument('<"node path or id">', "the path or id of the node to update").argument("<entryId>", "the new entry id to assign to the node").usage('<"node path or id"> <entryId>').addHelpText(
57690
+ "after",
57691
+ `
57692
+ Example call:
57693
+ > set node entry /path 1502f64e-e9b1-436b-b62f-e273f639ecb6
57694
+ `
57695
+ ).action(async (nodePathOrId, entryId2, opts) => {
57696
+ await cliCommand(["set", "node", "entry"], opts).CreateOrUpdateNode(
57697
+ nodePathOrId,
57698
+ { entryId: entryId2 }
57699
+ );
57700
+ });
57701
+ node.command("renderer").description("assign a renderer to a node").argument('<"node path or id">', "the path or id of the node to update").argument("<rendererUuid>", "the renderer uuid to assign to the node").option(
57702
+ "--is-partial-match-root",
57703
+ "should the renderer be used as the partial match root for the node",
57704
+ false
57705
+ ).usage('<"node path or id"> <rendererUuid>').addHelpText(
57706
+ "after",
57707
+ `
57708
+ Example call:
57709
+ > set node renderer /path 1502f64e-e9b1-436b-b62f-e273f639ecb6 --is-partial-match-root
57710
+ `
57711
+ ).action(async (nodePathOrId, rendererId, opts) => {
57712
+ await cliCommand(["set", "node", "renderer"], opts).CreateOrUpdateNode(
57713
+ nodePathOrId,
57714
+ {
57715
+ renderer: {
57716
+ id: rendererId,
57717
+ isPartialMatchRoot: opts.isPartialMatchRoot
57718
+ }
57719
+ }
57720
+ );
57721
+ });
57550
57722
  const project2 = set.command("project").description("set current working project").argument("<projectId>", "the project id to work with").usage("<projectId>").addHelpText(
57551
57723
  "after",
57552
57724
  `
@@ -57661,6 +57833,20 @@ Example call:
57661
57833
  ).option(
57662
57834
  "--entry-languages [entry-languages...]",
57663
57835
  "the entry languages to add to the role permissions"
57836
+ ).addOption(
57837
+ new import_commander14.Option(
57838
+ "--block-actions [block-actions...]",
57839
+ "the block actions to add to the role permissions"
57840
+ ).choices([
57841
+ "push",
57842
+ "release",
57843
+ "manageLive",
57844
+ "manualStartStop",
57845
+ "markAsBroken",
57846
+ "delete",
57847
+ "view",
57848
+ "*"
57849
+ ])
57664
57850
  ).addHelpText(
57665
57851
  "after",
57666
57852
  `
@@ -57677,7 +57863,8 @@ Example call:
57677
57863
  id,
57678
57864
  actions: opts.entryActions || [],
57679
57865
  languages: opts.entryLanguages || []
57680
- }))
57866
+ })),
57867
+ blocks: opts.blockActions ? { actions: opts.blockActions } : void 0
57681
57868
  }
57682
57869
  }
57683
57870
  );
@@ -57921,12 +58108,15 @@ var ContensisShell = class {
57921
58108
  "login",
57922
58109
  "list projects",
57923
58110
  "set project",
57924
- ...(((_a = this.env) == null ? void 0 : _a.projects) || []).map((project2) => `set project ${project2.id}`)
58111
+ ...(((_a = this.env) == null ? void 0 : _a.projects) || []).map(
58112
+ (project2) => `set project ${project2.id}`
58113
+ )
57925
58114
  );
57926
58115
  if (userId)
57927
58116
  availableCommands.push(
57928
58117
  "copy field",
57929
58118
  "create key",
58119
+ "create node",
57930
58120
  "create project",
57931
58121
  "create role",
57932
58122
  "create tag",
@@ -57987,6 +58177,8 @@ var ContensisShell = class {
57987
58177
  "remove tags",
57988
58178
  "remove tags in",
57989
58179
  "remove taggroup",
58180
+ "set node entry",
58181
+ "set node renderer",
57990
58182
  "set project name",
57991
58183
  "set project description",
57992
58184
  "set role name",