contensis-cli 1.5.1-beta.6 → 1.5.1-beta.8

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.
@@ -29,15 +29,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var util_exports = {};
30
30
  __export(util_exports, {
31
31
  Logging: () => Logging,
32
- splitTagGroupsInModels: () => splitTagGroupsInModels,
33
- splitTagsAndGroups: () => splitTagsAndGroups,
34
32
  url: () => url
35
33
  });
36
34
  module.exports = __toCommonJS(util_exports);
37
35
  var import_mergeWith = __toESM(require("lodash/mergeWith"));
38
36
  var import_logger = require("./logger");
39
37
  var import_en_GB = require("../localisation/en-GB.js");
40
- var import_lodash = require("lodash");
41
38
  const url = (alias, project) => {
42
39
  const projectAndAlias = project && project.toLowerCase() !== "website" ? `${project.toLowerCase()}-${alias}` : alias;
43
40
  return {
@@ -63,27 +60,9 @@ const Logging = async (language = "en-GB") => {
63
60
  Log: import_logger.Logger
64
61
  };
65
62
  };
66
- const splitTagsAndGroups = (tagsAndGroups = [], tags = [], groups = []) => {
67
- for (const item of tagsAndGroups) {
68
- if ((0, import_lodash.isObject)(item) && "id" in item) {
69
- if ("name" in item) groups.push(item);
70
- else tags.push(item);
71
- }
72
- }
73
- };
74
- const splitTagGroupsInModels = (mixedData = [], models = [], groups = []) => {
75
- for (const item of mixedData) {
76
- if ((0, import_lodash.isObject)(item) && "id" in item) {
77
- if (!("dataFormat" in item)) groups.push(item);
78
- else models.push(item);
79
- }
80
- }
81
- };
82
63
  // Annotate the CommonJS export names for ESM import in node:
83
64
  0 && (module.exports = {
84
65
  Logging,
85
- splitTagGroupsInModels,
86
- splitTagsAndGroups,
87
66
  url
88
67
  });
89
68
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/util/index.ts"],
4
- "sourcesContent": ["import { ContentType, Component } from 'contensis-core-api';\nimport { ICreateTag, ICreateTagGroup } from 'contensis-management-api';\nimport mergeWith from 'lodash/mergeWith';\nimport { Logger } from './logger';\nimport { LogMessages as enGB } from '../localisation/en-GB.js';\nimport { isObject } from 'lodash';\n\nexport const url = (alias: string, project: string) => {\n const projectAndAlias =\n project && project.toLowerCase() !== 'website'\n ? `${project.toLowerCase()}-${alias}`\n : alias;\n return {\n api: `https://api-${alias}.cloud.contensis.com`,\n cms: `https://cms-${alias}.cloud.contensis.com`,\n liveWeb: `https://live-${projectAndAlias}.cloud.contensis.com`,\n previewWeb: `https://preview-${projectAndAlias}.cloud.contensis.com`,\n iisWeb: `https://iis-live-${projectAndAlias}.cloud.contensis.com`,\n iisPreviewWeb: `https://iis-preview-${projectAndAlias}.cloud.contensis.com`,\n };\n};\n\nexport const Logging = async (language = 'en-GB') => {\n const defaultMessages = enGB;\n // const { LogMessages: defaultMessages } = await import(\n // `../localisation/en-GB.js`\n // );\n const localisedMessages = defaultMessages;\n\n if (language === 'en-GB') {\n // Using a variable import e.g. `import(`../localisation/${language}.js`);`\n // does not play well with packaged executables\n // So we have to hard code the import for each language individually\n }\n return {\n messages: mergeWith(\n localisedMessages,\n defaultMessages,\n (v, s) => v || s\n ) as typeof defaultMessages,\n Log: Logger,\n };\n};\n\nexport const splitTagsAndGroups = (\n tagsAndGroups: unknown[] = [],\n tags: ICreateTag[] = [],\n groups: ICreateTagGroup[] = []\n) => {\n for (const item of tagsAndGroups) {\n if (isObject(item) && 'id' in item) {\n if ('name' in item) groups.push(item as ICreateTagGroup);\n else tags.push(item as ICreateTag);\n }\n }\n};\n\nexport const splitTagGroupsInModels = (\n mixedData: unknown[] = [],\n models: (ContentType | Component)[] = [],\n groups: ICreateTagGroup[] = []\n) => {\n for (const item of mixedData) {\n if (isObject(item) && 'id' in item) {\n if (!('dataFormat' in item)) groups.push(item as ICreateTagGroup);\n else models.push(item as ContentType | Component);\n }\n }\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;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AA,EACF;AACF;",
4
+ "sourcesContent": ["import { ContentType, Component } from 'contensis-core-api';\nimport { ICreateTag, ICreateTagGroup } from 'contensis-management-api';\nimport mergeWith from 'lodash/mergeWith';\nimport { Logger } from './logger';\nimport { LogMessages as enGB } from '../localisation/en-GB.js';\nimport { isObject } from 'lodash';\n\nexport const url = (alias: string, project: string) => {\n const projectAndAlias =\n project && project.toLowerCase() !== 'website'\n ? `${project.toLowerCase()}-${alias}`\n : alias;\n return {\n api: `https://api-${alias}.cloud.contensis.com`,\n cms: `https://cms-${alias}.cloud.contensis.com`,\n liveWeb: `https://live-${projectAndAlias}.cloud.contensis.com`,\n previewWeb: `https://preview-${projectAndAlias}.cloud.contensis.com`,\n iisWeb: `https://iis-live-${projectAndAlias}.cloud.contensis.com`,\n iisPreviewWeb: `https://iis-preview-${projectAndAlias}.cloud.contensis.com`,\n };\n};\n\nexport const Logging = async (language = 'en-GB') => {\n const defaultMessages = enGB;\n // const { LogMessages: defaultMessages } = await import(\n // `../localisation/en-GB.js`\n // );\n const localisedMessages = defaultMessages;\n\n if (language === 'en-GB') {\n // Using a variable import e.g. `import(`../localisation/${language}.js`);`\n // does not play well with packaged executables\n // So we have to hard code the import for each language individually\n }\n return {\n messages: mergeWith(\n localisedMessages,\n defaultMessages,\n (v, s) => v || s\n ) as typeof defaultMessages,\n Log: Logger,\n };\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uBAAsB;AACtB,oBAAuB;AACvB,mBAAoC;AAG7B,MAAM,MAAM,CAAC,OAAe,YAAoB;AACrD,QAAM,kBACJ,WAAW,QAAQ,YAAY,MAAM,YACjC,GAAG,QAAQ,YAAY,CAAC,IAAI,KAAK,KACjC;AACN,SAAO;AAAA,IACL,KAAK,eAAe,KAAK;AAAA,IACzB,KAAK,eAAe,KAAK;AAAA,IACzB,SAAS,gBAAgB,eAAe;AAAA,IACxC,YAAY,mBAAmB,eAAe;AAAA,IAC9C,QAAQ,oBAAoB,eAAe;AAAA,IAC3C,eAAe,uBAAuB,eAAe;AAAA,EACvD;AACF;AAEO,MAAM,UAAU,OAAO,WAAW,YAAY;AACnD,QAAM,kBAAkB,aAAAA;AAIxB,QAAM,oBAAoB;AAE1B,MAAI,aAAa,SAAS;AAAA,EAI1B;AACA,SAAO;AAAA,IACL,cAAU,iBAAAC;AAAA,MACR;AAAA,MACA;AAAA,MACA,CAAC,GAAG,MAAM,KAAK;AAAA,IACjB;AAAA,IACA,KAAK;AAAA,EACP;AACF;",
6
6
  "names": ["enGB", "mergeWith"]
7
7
  }
package/dist/version.js CHANGED
@@ -21,7 +21,7 @@ __export(version_exports, {
21
21
  LIB_VERSION: () => LIB_VERSION
22
22
  });
23
23
  module.exports = __toCommonJS(version_exports);
24
- const LIB_VERSION = "1.5.1-beta.6";
24
+ const LIB_VERSION = "1.5.1-beta.8";
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  LIB_VERSION
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/version.ts"],
4
- "sourcesContent": ["export const LIB_VERSION = \"1.5.1-beta.6\";\n"],
4
+ "sourcesContent": ["export const LIB_VERSION = \"1.5.1-beta.8\";\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contensis-cli",
3
- "version": "1.5.1-beta.6",
3
+ "version": "1.5.1-beta.8",
4
4
  "description": "A fully featured Contensis command line interface with a shell UI provides simple and intuitive ways to manage or profile your content in any NodeJS terminal.",
5
5
  "repository": "https://github.com/contensis/cli",
6
6
  "homepage": "https://github.com/contensis/cli/tree/main/packages/contensis-cli#readme",
@@ -39,7 +39,7 @@
39
39
  "inquirer-command-prompt": "^0.1.0",
40
40
  "keytar": "^7.9.0",
41
41
  "lodash": "^4.17.21",
42
- "migratortron": "^1.0.0-beta.77",
42
+ "migratortron": "^1.0.0-beta.78",
43
43
  "nanospinner": "^1.2.0",
44
44
  "node-fetch": "^2.6.7",
45
45
  "parse-git-config": "^3.0.0",
@@ -315,9 +315,16 @@ Example call:
315
315
  'get entries with the search phrase, use quotes for multiple words'
316
316
  )
317
317
  .addOption(contentTypes)
318
- .option(
319
- '-d --dependents',
320
- 'find and return any dependencies of all found entries'
318
+ .addOption(
319
+ new Option(
320
+ '-d --dependents [depth]',
321
+ 'find and return any dependencies of all found entries (optionally limit the number of dependency levels)'
322
+ ).argParser(value => {
323
+ // If value is undefined, treat as boolean true
324
+ if (value === undefined) return true;
325
+ const num = Number(value);
326
+ return isNaN(num) ? true : num;
327
+ })
321
328
  )
322
329
  )
323
330
  .addOption(
@@ -52,6 +52,12 @@ export const mapContensisOpts = (opts: any = {}): MigrateRequest => ({
52
52
  concurrency: opts.concurrency ? Number(opts.concurrency) : undefined,
53
53
  noPublish: !opts.publish, // arg is inverted automatically from `--no-publish` to `publish: false`
54
54
  outputLogs: opts.logLevel,
55
+ stopLevel:
56
+ typeof opts.stopLevel === 'number'
57
+ ? Number(opts.stopLevel)
58
+ : typeof opts.dependents === 'number'
59
+ ? Number(opts.dependents)
60
+ : undefined,
55
61
  });
56
62
 
57
63
  /* Output options */
@@ -195,6 +201,11 @@ export const noPublish = new Option(
195
201
  "don't publish created or updated entries"
196
202
  );
197
203
 
204
+ export const stopLevel = new Option(
205
+ '-d --stop-level <stopLevel>',
206
+ 'the level at which to stop resolving dependent entries (may result in incomplete entries)'
207
+ ).argParser(parseInt);
208
+
198
209
  export const addConnectOptions = (program: Command) =>
199
210
  program.addOption(alias.hideHelp()).addOption(project.hideHelp());
200
211
 
@@ -13,6 +13,7 @@ import {
13
13
  noPublish,
14
14
  outputDetail,
15
15
  saveEntries,
16
+ stopLevel,
16
17
  versionStatus,
17
18
  zenql,
18
19
  } from './globalOptions';
@@ -39,6 +40,7 @@ export const makeImportCommand = () => {
39
40
  '-preserve --preserve-guids',
40
41
  'import any default entries or nodes using the same id as the source'
41
42
  )
43
+ .addOption(ignoreErrors)
42
44
  .addHelpText(
43
45
  'after',
44
46
  `
@@ -131,6 +133,7 @@ Example call:
131
133
  .addOption(assetTypes)
132
134
  .addOption(latest)
133
135
  .addOption(versionStatus)
136
+ .addOption(stopLevel)
134
137
  .addOption(commit)
135
138
  .option(
136
139
  '-preserve --preserve-guids',
@@ -275,7 +278,7 @@ Example call:
275
278
  > import tags --from-file myImportData.json --preserve-guids
276
279
  `
277
280
  )
278
- .action(async (opts) => {
281
+ .action(async opts => {
279
282
  await cliCommand(
280
283
  ['import', 'tags'],
281
284
  opts,
@@ -0,0 +1,80 @@
1
+ import { Component, ContentType, Project } from 'contensis-core-api';
2
+ import {
3
+ Entry,
4
+ ICreateNode,
5
+ ICreateTag,
6
+ ICreateTagGroup,
7
+ Tag,
8
+ TagGroup,
9
+ } from 'contensis-management-api';
10
+ import { MigrateRequest } from 'migratortron';
11
+ import { readFileAsJSON } from '~/providers/file-provider';
12
+
13
+ export class MixedFileData
14
+ implements
15
+ Pick<MigrateRequest, 'models' | 'entries' | 'nodes' | 'tagGroups' | 'tags'>
16
+ {
17
+ models: (ContentType | Component)[] = [];
18
+ entries: Entry[] = [];
19
+ nodes: ICreateNode[] = [];
20
+ tagGroups: (TagGroup | ICreateTagGroup)[] = [];
21
+ tags: (Tag | ICreateTag)[] = [];
22
+
23
+ constructor(fileData?: any[]) {
24
+ if (Array.isArray(fileData)) this.init(fileData);
25
+ }
26
+ init = (fileData: any[]) => {
27
+ for (const item of fileData) {
28
+ if (
29
+ this.#isContentType(item) ||
30
+ this.#isComponent(item) ||
31
+ this.#isForm(item)
32
+ )
33
+ this.models.push(item);
34
+ if (this.#isEntry(item) || this.#isAsset(item)) this.entries.push(item);
35
+ if (this.#isNode(item)) this.nodes.push(item);
36
+ if (this.#isTagGroup(item)) this.tagGroups.push(item);
37
+ if (this.#isTag(item)) this.tags.push(item);
38
+ }
39
+ };
40
+ async readFile(filePath: string): Promise<any> {
41
+ const fileData = await readFileAsJSON(filePath);
42
+ if (typeof fileData === 'string')
43
+ throw new Error(`Import file format must be of type JSON`);
44
+ if (Array.isArray(fileData)) this.init(fileData);
45
+ return this;
46
+ }
47
+
48
+ #isProject = (item: any): item is Project =>
49
+ 'id' in item && 'name' in item && 'primaryLanguage' in item;
50
+
51
+ #isContentType = (item: any): item is ContentType =>
52
+ 'dataFormat' in item && item.dataFormat === 'entry';
53
+
54
+ #isComponent = (item: any): item is Component =>
55
+ 'dataFormat' in item && item.dataFormat === 'component';
56
+
57
+ #isForm = (item: any): item is ContentType =>
58
+ 'dataFormat' in item && item.dataFormat === 'form';
59
+
60
+ #isAsset = (item: any): item is Entry =>
61
+ 'sys' in item &&
62
+ 'contentTypeId' in item.sys &&
63
+ 'dataFormat' in item.sys &&
64
+ item.sys.dataFormat === 'asset';
65
+
66
+ #isEntry = (item: any): item is Entry =>
67
+ 'sys' in item &&
68
+ 'contentTypeId' in item.sys &&
69
+ 'dataFormat' in item.sys &&
70
+ item.sys.dataFormat === 'entry';
71
+
72
+ #isNode = (item: any): item is ICreateNode =>
73
+ ('slug' in item || 'path' in item) && 'displayName' in item;
74
+
75
+ #isTag = (item: any): item is ICreateTag =>
76
+ 'id' in item && 'groupId' in item && 'label' in item;
77
+
78
+ #isTagGroup = (item: any): item is ICreateTagGroup =>
79
+ 'id' in item && 'name' in item && 'tagCount' in item;
80
+ }