contensis-cli 1.6.1-beta.14 → 1.6.1-beta.16
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/index.js +185 -7
- package/dist/index.js.map +3 -3
- package/dist/shell.js +185 -7
- package/dist/shell.js.map +3 -3
- package/package.json +1 -1
- package/src/commands/create.ts +48 -0
- package/src/commands/set.ts +50 -0
- package/src/localisation/en-GB.ts +8 -0
- package/src/services/ContensisCliService.ts +151 -4
- package/src/shell.ts +6 -1
- package/src/version.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -46454,7 +46454,7 @@ var progress = {
|
|
|
46454
46454
|
};
|
|
46455
46455
|
|
|
46456
46456
|
// src/version.ts
|
|
46457
|
-
var LIB_VERSION = "1.6.1-beta.
|
|
46457
|
+
var LIB_VERSION = "1.6.1-beta.16";
|
|
46458
46458
|
|
|
46459
46459
|
// src/commands/connect.ts
|
|
46460
46460
|
var import_commander2 = require("commander");
|
|
@@ -46692,7 +46692,15 @@ ${Logger.errorText(">>")} Available commands:`,
|
|
|
46692
46692
|
failedGet: (projectId) => `[${projectId}] Cannot retrieve nodes from Site view`,
|
|
46693
46693
|
get: (projectId, root, depth) => `[${projectId}] Site view nodes at: ${Logger.highlightText(root)}${depth ? ` to a depth of ${depth}` : ``}
|
|
46694
46694
|
`,
|
|
46695
|
-
noChange: (env) => `[${env}] No changes to be made
|
|
46695
|
+
noChange: (env) => `[${env}] No changes to be made`,
|
|
46696
|
+
setPayload: () => `Updating node with details
|
|
46697
|
+
`,
|
|
46698
|
+
set: (env) => `[${env}] Succesfully updated node
|
|
46699
|
+
`,
|
|
46700
|
+
failedSet: (env, name) => `[${env}] Unable to update node ${Logger.highlightText(name)}`,
|
|
46701
|
+
created: (env, name) => `[${env}] Created node ${Logger.highlightText(name)}
|
|
46702
|
+
`,
|
|
46703
|
+
failedCreate: (env, name) => `[${env}] Unable to create node ${Logger.highlightText(name)}`
|
|
46696
46704
|
},
|
|
46697
46705
|
contenttypes: {
|
|
46698
46706
|
list: (projectId) => `Content types in ${Logger.highlightText(projectId)}:`,
|
|
@@ -50276,6 +50284,101 @@ Components:`));
|
|
|
50276
50284
|
}
|
|
50277
50285
|
}
|
|
50278
50286
|
};
|
|
50287
|
+
CreateOrUpdateNode = async (nodePathOrId, nodeUpdates, displayName, slug, language) => {
|
|
50288
|
+
var _a, _b;
|
|
50289
|
+
const { currentEnv, currentProject, log, messages } = this;
|
|
50290
|
+
const contensis = await this.ConnectContensis();
|
|
50291
|
+
const nodePath = nodePathOrId.startsWith("/") ? nodePathOrId : void 0;
|
|
50292
|
+
let nodeId = isUuid(nodePathOrId) ? nodePathOrId : void 0;
|
|
50293
|
+
let existingNode;
|
|
50294
|
+
let parentNode;
|
|
50295
|
+
let updateNode;
|
|
50296
|
+
if (contensis) {
|
|
50297
|
+
if (nodePath) {
|
|
50298
|
+
const [, nodesByPath] = await (0, import_await_to_js2.default)(contensis.nodes.GetNodes(nodePath, 0));
|
|
50299
|
+
if (Array.isArray(nodesByPath) && ((_a = nodesByPath[0]) == null ? void 0 : _a.id)) {
|
|
50300
|
+
nodeId = nodesByPath[0].id;
|
|
50301
|
+
}
|
|
50302
|
+
}
|
|
50303
|
+
if (nodeId) {
|
|
50304
|
+
const [, nodeById] = await (0, import_await_to_js2.default)(
|
|
50305
|
+
contensis.source.repo.GetNodeById(nodeId)
|
|
50306
|
+
);
|
|
50307
|
+
if (nodeById) existingNode = nodeById;
|
|
50308
|
+
}
|
|
50309
|
+
if (!existingNode) {
|
|
50310
|
+
if (!language) {
|
|
50311
|
+
const project2 = await contensis.source.repo.GetProject(currentProject);
|
|
50312
|
+
language = (project2 == null ? void 0 : project2.primaryLanguage) || "en-GB";
|
|
50313
|
+
}
|
|
50314
|
+
if (!nodeUpdates.parentId) {
|
|
50315
|
+
if (!nodePath)
|
|
50316
|
+
throw new Error(
|
|
50317
|
+
`A node with id "${nodeId}" does not exist, and a path was not provided to find the parent node.`
|
|
50318
|
+
);
|
|
50319
|
+
const parentPath = nodePath.substring(0, nodePath.lastIndexOf("/")) || "/";
|
|
50320
|
+
const [, parentNodesByPath] = await (0, import_await_to_js2.default)(
|
|
50321
|
+
contensis.nodes.GetNodes(parentPath, 0)
|
|
50322
|
+
);
|
|
50323
|
+
if (!((_b = parentNodesByPath == null ? void 0 : parentNodesByPath[0]) == null ? void 0 : _b.id))
|
|
50324
|
+
throw new Error(
|
|
50325
|
+
`A node with id "${nodeId}" does not exist, and the parent node could not be found at path "${parentPath}".`
|
|
50326
|
+
);
|
|
50327
|
+
else parentNode = parentNodesByPath[0];
|
|
50328
|
+
}
|
|
50329
|
+
const pathSlug = nodePath == null ? void 0 : nodePath.substring(nodePath.lastIndexOf("/") + 1);
|
|
50330
|
+
const createNode = {
|
|
50331
|
+
id: nodeId,
|
|
50332
|
+
parentId: nodeUpdates.parentId || (parentNode == null ? void 0 : parentNode.id),
|
|
50333
|
+
projectId: currentProject,
|
|
50334
|
+
displayName: displayName ? {
|
|
50335
|
+
[language]: displayName
|
|
50336
|
+
} : nodeUpdates.displayName ? nodeUpdates.displayName : pathSlug ? {
|
|
50337
|
+
[language]: pathSlug
|
|
50338
|
+
} : void 0,
|
|
50339
|
+
slug: slug ? {
|
|
50340
|
+
[language]: slug
|
|
50341
|
+
} : nodeUpdates.slug ? nodeUpdates.slug : pathSlug ? {
|
|
50342
|
+
[language]: pathSlug
|
|
50343
|
+
} : void 0,
|
|
50344
|
+
entryId: nodeUpdates.entryId,
|
|
50345
|
+
isCanonical: nodeUpdates.isCanonical,
|
|
50346
|
+
renderer: nodeUpdates.renderer,
|
|
50347
|
+
proxy: nodeUpdates.proxy,
|
|
50348
|
+
includeInMenu: nodeUpdates.includeInMenu
|
|
50349
|
+
};
|
|
50350
|
+
updateNode = createNode;
|
|
50351
|
+
} else {
|
|
50352
|
+
updateNode = { ...existingNode, ...nodeUpdates };
|
|
50353
|
+
}
|
|
50354
|
+
if (updateNode) {
|
|
50355
|
+
log.info(messages.nodes.setPayload());
|
|
50356
|
+
log.object(updateNode);
|
|
50357
|
+
log.raw("");
|
|
50358
|
+
const [err, newNode] = await contensis.source.repo.UpdateOrCreateNode(
|
|
50359
|
+
existingNode,
|
|
50360
|
+
updateNode
|
|
50361
|
+
);
|
|
50362
|
+
if (err)
|
|
50363
|
+
log.error(
|
|
50364
|
+
messages.nodes[existingNode ? "failedSet" : "failedCreate"](
|
|
50365
|
+
currentEnv,
|
|
50366
|
+
nodePathOrId
|
|
50367
|
+
),
|
|
50368
|
+
err
|
|
50369
|
+
);
|
|
50370
|
+
else if (newNode) {
|
|
50371
|
+
log.success(
|
|
50372
|
+
messages.nodes[existingNode ? "set" : "created"](
|
|
50373
|
+
currentEnv,
|
|
50374
|
+
newNode.id
|
|
50375
|
+
)
|
|
50376
|
+
);
|
|
50377
|
+
await this.HandleFormattingAndOutput(newNode, log.object);
|
|
50378
|
+
}
|
|
50379
|
+
}
|
|
50380
|
+
}
|
|
50381
|
+
};
|
|
50279
50382
|
PrintWebhookSubscriptions = async (subscriptionIdsOrNames) => {
|
|
50280
50383
|
const { currentEnv, log, messages } = this;
|
|
50281
50384
|
const contensis = await this.ConnectContensis();
|
|
@@ -50724,25 +50827,29 @@ Components:`));
|
|
|
50724
50827
|
}
|
|
50725
50828
|
}
|
|
50726
50829
|
};
|
|
50727
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
50728
50830
|
PrintRenderers = async (rendererId) => {
|
|
50729
50831
|
const { currentEnv, env, log, messages } = this;
|
|
50730
50832
|
const contensis = await this.ConnectContensis();
|
|
50731
50833
|
if (contensis) {
|
|
50732
50834
|
const [err, renderers] = await contensis.renderers.GetRenderers();
|
|
50733
50835
|
if (Array.isArray(renderers)) {
|
|
50734
|
-
|
|
50836
|
+
const result = rendererId ? [renderers.find((r) => r.id === rendererId)].filter(
|
|
50837
|
+
Boolean
|
|
50838
|
+
) : renderers || [];
|
|
50839
|
+
await this.HandleFormattingAndOutput(result, () => {
|
|
50735
50840
|
log.success(messages.renderers.list(currentEnv, env.currentProject));
|
|
50736
50841
|
for (const {
|
|
50842
|
+
uuid,
|
|
50737
50843
|
id,
|
|
50738
50844
|
description,
|
|
50739
50845
|
assignedContentTypes,
|
|
50740
50846
|
rules,
|
|
50741
50847
|
version
|
|
50742
|
-
} of
|
|
50848
|
+
} of result) {
|
|
50743
50849
|
console.log(
|
|
50744
50850
|
` - ${id} [${version.versionNo}] ${log.infoText`${description}`}`
|
|
50745
50851
|
);
|
|
50852
|
+
console.log(log.infoText` uuid: ${uuid}`);
|
|
50746
50853
|
if (assignedContentTypes == null ? void 0 : assignedContentTypes.length)
|
|
50747
50854
|
console.log(
|
|
50748
50855
|
log.infoText` assignedContentTypes: ${assignedContentTypes.join(
|
|
@@ -50756,7 +50863,7 @@ Components:`));
|
|
|
50756
50863
|
);
|
|
50757
50864
|
}
|
|
50758
50865
|
});
|
|
50759
|
-
return
|
|
50866
|
+
return result;
|
|
50760
50867
|
}
|
|
50761
50868
|
if (err) {
|
|
50762
50869
|
log.error(messages.renderers.noList(currentEnv, env.currentProject));
|
|
@@ -50931,12 +51038,15 @@ var ContensisShell = class {
|
|
|
50931
51038
|
"login",
|
|
50932
51039
|
"list projects",
|
|
50933
51040
|
"set project",
|
|
50934
|
-
...(((_a = this.env) == null ? void 0 : _a.projects) || []).map(
|
|
51041
|
+
...(((_a = this.env) == null ? void 0 : _a.projects) || []).map(
|
|
51042
|
+
(project2) => `set project ${project2.id}`
|
|
51043
|
+
)
|
|
50935
51044
|
);
|
|
50936
51045
|
if (userId)
|
|
50937
51046
|
availableCommands.push(
|
|
50938
51047
|
"copy field",
|
|
50939
51048
|
"create key",
|
|
51049
|
+
"create node",
|
|
50940
51050
|
"create project",
|
|
50941
51051
|
"create role",
|
|
50942
51052
|
"create tag",
|
|
@@ -50997,6 +51107,8 @@ var ContensisShell = class {
|
|
|
50997
51107
|
"remove tags",
|
|
50998
51108
|
"remove tags in",
|
|
50999
51109
|
"remove taggroup",
|
|
51110
|
+
"set node entry",
|
|
51111
|
+
"set node renderer",
|
|
51000
51112
|
"set project name",
|
|
51001
51113
|
"set project description",
|
|
51002
51114
|
"set role name",
|
|
@@ -51383,6 +51495,38 @@ Example call:
|
|
|
51383
51495
|
description
|
|
51384
51496
|
);
|
|
51385
51497
|
});
|
|
51498
|
+
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(
|
|
51499
|
+
'["display name"]',
|
|
51500
|
+
"provide a separate display name for the node (optional)"
|
|
51501
|
+
).argument(
|
|
51502
|
+
'["slug"]',
|
|
51503
|
+
"provide a slug for the node (defaults to slug from provided node path)"
|
|
51504
|
+
).option(
|
|
51505
|
+
"--include-in-menu",
|
|
51506
|
+
"set include in menu flag on the created node",
|
|
51507
|
+
false
|
|
51508
|
+
).option(
|
|
51509
|
+
"--language <language>",
|
|
51510
|
+
"language of the node to create (defaults to current project primary language)"
|
|
51511
|
+
).option("--entry-id <entryId>", "attach an entry to the node").usage(
|
|
51512
|
+
'<"node path or id"> ["display name"] (both args in "double quotes")'
|
|
51513
|
+
).addHelpText(
|
|
51514
|
+
"after",
|
|
51515
|
+
`
|
|
51516
|
+
Example call:
|
|
51517
|
+
> create node /test "Test Node" --include-in-menu
|
|
51518
|
+
`
|
|
51519
|
+
).action(
|
|
51520
|
+
async (pathOrId, displayName, slug, opts) => {
|
|
51521
|
+
await cliCommand(["create", "node", pathOrId], opts).CreateOrUpdateNode(
|
|
51522
|
+
pathOrId,
|
|
51523
|
+
opts,
|
|
51524
|
+
displayName,
|
|
51525
|
+
slug,
|
|
51526
|
+
opts.language
|
|
51527
|
+
);
|
|
51528
|
+
}
|
|
51529
|
+
);
|
|
51386
51530
|
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(
|
|
51387
51531
|
"after",
|
|
51388
51532
|
`
|
|
@@ -57831,6 +57975,40 @@ var import_commander14 = require("commander");
|
|
|
57831
57975
|
var makeSetCommand = () => {
|
|
57832
57976
|
const set = new import_commander14.Command().command("set").description("set command").addHelpText("after", `
|
|
57833
57977
|
`).showHelpAfterError(true).exitOverride();
|
|
57978
|
+
const node = set.command("node").description("update a site view node");
|
|
57979
|
+
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(
|
|
57980
|
+
"after",
|
|
57981
|
+
`
|
|
57982
|
+
Example call:
|
|
57983
|
+
> set node entry /path 1502f64e-e9b1-436b-b62f-e273f639ecb6
|
|
57984
|
+
`
|
|
57985
|
+
).action(async (nodePathOrId, entryId2, opts) => {
|
|
57986
|
+
await cliCommand(["set", "node", "entry"], opts).CreateOrUpdateNode(
|
|
57987
|
+
nodePathOrId,
|
|
57988
|
+
{ entryId: entryId2 }
|
|
57989
|
+
);
|
|
57990
|
+
});
|
|
57991
|
+
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(
|
|
57992
|
+
"--is-partial-match-root",
|
|
57993
|
+
"should the renderer be used as the partial match root for the node",
|
|
57994
|
+
false
|
|
57995
|
+
).usage('<"node path or id"> <rendererUuid>').addHelpText(
|
|
57996
|
+
"after",
|
|
57997
|
+
`
|
|
57998
|
+
Example call:
|
|
57999
|
+
> set node renderer /path 1502f64e-e9b1-436b-b62f-e273f639ecb6 --is-partial-match-root
|
|
58000
|
+
`
|
|
58001
|
+
).action(async (nodePathOrId, rendererId, opts) => {
|
|
58002
|
+
await cliCommand(["set", "node", "renderer"], opts).CreateOrUpdateNode(
|
|
58003
|
+
nodePathOrId,
|
|
58004
|
+
{
|
|
58005
|
+
renderer: {
|
|
58006
|
+
id: rendererId,
|
|
58007
|
+
isPartialMatchRoot: opts.isPartialMatchRoot
|
|
58008
|
+
}
|
|
58009
|
+
}
|
|
58010
|
+
);
|
|
58011
|
+
});
|
|
57834
58012
|
const project2 = set.command("project").description("set current working project").argument("<projectId>", "the project id to work with").usage("<projectId>").addHelpText(
|
|
57835
58013
|
"after",
|
|
57836
58014
|
`
|