contensis-cli 1.5.1-beta.7 → 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.
- package/dist/mappers/MixedFileData.js +83 -0
- package/dist/mappers/MixedFileData.js.map +7 -0
- package/dist/services/ContensisCliService.js +55 -83
- package/dist/services/ContensisCliService.js.map +2 -2
- package/dist/util/index.js +0 -21
- package/dist/util/index.js.map +2 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/src/mappers/MixedFileData.ts +80 -0
- package/src/services/ContensisCliService.ts +62 -118
- package/src/util/index.ts +0 -26
- package/src/version.ts +1 -1
package/dist/util/index.js
CHANGED
|
@@ -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
|
package/dist/util/index.js.map
CHANGED
|
@@ -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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
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.
|
|
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
|
package/dist/version.js.map
CHANGED
|
@@ -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.
|
|
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.
|
|
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",
|
|
@@ -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
|
+
}
|
|
@@ -28,17 +28,17 @@ import {
|
|
|
28
28
|
import ContensisAuthService from './ContensisAuthService';
|
|
29
29
|
|
|
30
30
|
import { LogMessages } from '~/localisation/en-GB';
|
|
31
|
+
import { MixedFileData } from '~/mappers/MixedFileData';
|
|
31
32
|
import {
|
|
32
33
|
CliUrls,
|
|
33
34
|
OutputFormat,
|
|
34
35
|
OutputOptionsConstructorArg,
|
|
35
36
|
} from '~/models/CliService';
|
|
36
37
|
|
|
37
|
-
import { readFileAsJSON } from '~/providers/file-provider';
|
|
38
38
|
import SessionCacheProvider from '../providers/SessionCacheProvider';
|
|
39
39
|
import CredentialProvider from '~/providers/CredentialProvider';
|
|
40
40
|
|
|
41
|
-
import {
|
|
41
|
+
import { url } from '~/util';
|
|
42
42
|
import { sanitiseIds } from '~/util/api-ids';
|
|
43
43
|
import {
|
|
44
44
|
isPassword,
|
|
@@ -67,16 +67,6 @@ import { promiseDelay } from '~/util/timers';
|
|
|
67
67
|
import { GetTagsArgs } from 'migratortron/dist/services/TagsMigrationService';
|
|
68
68
|
import { GetTagGroupsArgs } from 'migratortron/dist/services/TagGroupsMigrationService';
|
|
69
69
|
|
|
70
|
-
type ImportDataType =
|
|
71
|
-
| 'entries'
|
|
72
|
-
| 'contentTypes'
|
|
73
|
-
| 'components'
|
|
74
|
-
| 'models'
|
|
75
|
-
| 'nodes'
|
|
76
|
-
| 'tagGroups'
|
|
77
|
-
| 'tags'
|
|
78
|
-
| 'user-input';
|
|
79
|
-
|
|
80
70
|
let insecurePasswordWarningShown = false;
|
|
81
71
|
|
|
82
72
|
class ContensisCli {
|
|
@@ -344,27 +334,21 @@ class ContensisCli {
|
|
|
344
334
|
|
|
345
335
|
ConnectContensisImport = async ({
|
|
346
336
|
commit = false,
|
|
337
|
+
noSource = false,
|
|
347
338
|
fromFile,
|
|
348
|
-
importDataType,
|
|
349
339
|
importData,
|
|
350
|
-
mixedData,
|
|
351
340
|
}: {
|
|
352
341
|
commit?: boolean;
|
|
342
|
+
noSource?: boolean;
|
|
353
343
|
fromFile?: string;
|
|
354
|
-
|
|
355
|
-
importData?: any[];
|
|
356
|
-
mixedData?: {
|
|
357
|
-
[K in ImportDataType]?: any[];
|
|
358
|
-
};
|
|
344
|
+
importData?: MixedFileData;
|
|
359
345
|
}) => {
|
|
360
|
-
const source: 'contensis' | '
|
|
361
|
-
fromFile || importData ||
|
|
362
|
-
|
|
363
|
-
const fileData =
|
|
364
|
-
importData || (fromFile ? (await readFileAsJSON(fromFile)) || [] : []);
|
|
346
|
+
const source: 'contensis' | 'user-input' =
|
|
347
|
+
fromFile || importData || noSource ? 'user-input' : 'contensis';
|
|
365
348
|
|
|
366
|
-
|
|
367
|
-
|
|
349
|
+
const mixedData = fromFile
|
|
350
|
+
? await new MixedFileData().readFile(fromFile)
|
|
351
|
+
: importData;
|
|
368
352
|
|
|
369
353
|
const { contensisOpts, currentEnv, env, log, messages, sourceAlias } = this;
|
|
370
354
|
const environments = this.cache.environments || {};
|
|
@@ -405,7 +389,7 @@ class ContensisCli {
|
|
|
405
389
|
const cachedTargetPassword = targetCredentials?.current?.password;
|
|
406
390
|
|
|
407
391
|
if (cachedSourcePassword && cachedTargetPassword) {
|
|
408
|
-
if (source === '
|
|
392
|
+
if (source === 'user-input') {
|
|
409
393
|
this.contensis = new ContensisMigrationService(
|
|
410
394
|
{
|
|
411
395
|
concurrency: 2,
|
|
@@ -420,7 +404,6 @@ class ContensisCli {
|
|
|
420
404
|
targetProjects: [env.currentProject || ''],
|
|
421
405
|
assetHostname: this.urls?.previewWeb,
|
|
422
406
|
},
|
|
423
|
-
...(importDataType ? { [importDataType]: fileData } : {}),
|
|
424
407
|
...(mixedData || {}),
|
|
425
408
|
},
|
|
426
409
|
!commit
|
|
@@ -1175,14 +1158,17 @@ class ContensisCli {
|
|
|
1175
1158
|
}) => {
|
|
1176
1159
|
const { currentEnv, currentProject, log, messages } = this;
|
|
1177
1160
|
|
|
1161
|
+
let importData;
|
|
1162
|
+
if (tags) {
|
|
1163
|
+
importData = new MixedFileData();
|
|
1164
|
+
importData.tags = tags;
|
|
1165
|
+
importData.tagGroups = data || [];
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1178
1168
|
const contensis = await this.ConnectContensisImport({
|
|
1179
1169
|
commit,
|
|
1180
1170
|
fromFile,
|
|
1181
|
-
|
|
1182
|
-
mixedData: {
|
|
1183
|
-
tagGroups: data,
|
|
1184
|
-
tags: tags,
|
|
1185
|
-
},
|
|
1171
|
+
importData,
|
|
1186
1172
|
});
|
|
1187
1173
|
|
|
1188
1174
|
if (contensis) {
|
|
@@ -1304,10 +1290,7 @@ class ContensisCli {
|
|
|
1304
1290
|
});
|
|
1305
1291
|
|
|
1306
1292
|
if (Array.isArray(result)) {
|
|
1307
|
-
|
|
1308
|
-
const groups: ICreateTagGroup[] = [];
|
|
1309
|
-
if (withDependents) splitTagsAndGroups(result, tags, groups);
|
|
1310
|
-
else tags = result;
|
|
1293
|
+
const { tags, tagGroups } = new MixedFileData(result);
|
|
1311
1294
|
|
|
1312
1295
|
log.success(messages.tags.list(currentEnv, tags.length));
|
|
1313
1296
|
|
|
@@ -1318,11 +1301,13 @@ class ContensisCli {
|
|
|
1318
1301
|
log.raw('');
|
|
1319
1302
|
log.object(tag);
|
|
1320
1303
|
}
|
|
1321
|
-
if (
|
|
1304
|
+
if (tagGroups.length) {
|
|
1322
1305
|
log.raw('');
|
|
1323
|
-
log.success(
|
|
1306
|
+
log.success(
|
|
1307
|
+
messages.taggroups.list(currentEnv, tagGroups.length)
|
|
1308
|
+
);
|
|
1324
1309
|
|
|
1325
|
-
for (const group of
|
|
1310
|
+
for (const group of tagGroups) {
|
|
1326
1311
|
log.raw('');
|
|
1327
1312
|
log.object(group);
|
|
1328
1313
|
}
|
|
@@ -1346,25 +1331,22 @@ class ContensisCli {
|
|
|
1346
1331
|
});
|
|
1347
1332
|
|
|
1348
1333
|
if (Array.isArray(result)) {
|
|
1349
|
-
|
|
1350
|
-
const groups: TagGroup[] = [];
|
|
1351
|
-
if (withDependents) splitTagsAndGroups(result, tags, groups);
|
|
1352
|
-
else tags = result;
|
|
1334
|
+
const { tags, tagGroups } = new MixedFileData(result);
|
|
1353
1335
|
log.success(messages.tags.list(currentEnv, tags.length));
|
|
1354
1336
|
|
|
1355
1337
|
if (!tags.length) log.help(messages.tags.noneExist());
|
|
1356
1338
|
|
|
1357
1339
|
await this.HandleFormattingAndOutput(result, () => {
|
|
1358
1340
|
// print the tags to console
|
|
1359
|
-
for (const { version, ...tag } of tags) {
|
|
1341
|
+
for (const { version, ...tag } of tags as Tag[]) {
|
|
1360
1342
|
log.raw('');
|
|
1361
1343
|
log.object(tag);
|
|
1362
1344
|
}
|
|
1363
|
-
if (
|
|
1345
|
+
if (tagGroups.length) {
|
|
1364
1346
|
log.raw('');
|
|
1365
|
-
log.success(messages.taggroups.list(currentEnv,
|
|
1347
|
+
log.success(messages.taggroups.list(currentEnv, tagGroups.length));
|
|
1366
1348
|
|
|
1367
|
-
for (const { version, ...group } of
|
|
1349
|
+
for (const { version, ...group } of tagGroups as TagGroup[]) {
|
|
1368
1350
|
log.raw('');
|
|
1369
1351
|
log.object(group);
|
|
1370
1352
|
}
|
|
@@ -1391,30 +1373,23 @@ class ContensisCli {
|
|
|
1391
1373
|
}) => {
|
|
1392
1374
|
const { currentEnv, currentProject, log, messages } = this;
|
|
1393
1375
|
|
|
1394
|
-
|
|
1395
|
-
tags: ICreateTag[];
|
|
1396
|
-
tagGroups: ICreateTagGroup[];
|
|
1397
|
-
} = { tags: [], tagGroups: [] };
|
|
1376
|
+
let importData;
|
|
1398
1377
|
|
|
1399
1378
|
if (data) {
|
|
1400
|
-
|
|
1401
|
-
|
|
1379
|
+
importData = new MixedFileData();
|
|
1380
|
+
importData.tags = data;
|
|
1381
|
+
importData.tagGroups = [...new Set(data.map(t => t.groupId))].map(
|
|
1402
1382
|
id =>
|
|
1403
1383
|
({
|
|
1404
1384
|
id,
|
|
1405
1385
|
}) as ICreateTagGroup
|
|
1406
1386
|
);
|
|
1407
1387
|
}
|
|
1408
|
-
if (fromFile) {
|
|
1409
|
-
// File may contain mix of tags and tag groups, separate those here
|
|
1410
|
-
const fileData = fromFile ? (await readFileAsJSON(fromFile)) || [] : [];
|
|
1411
|
-
splitTagsAndGroups(fileData, mixedData.tags, mixedData.tagGroups);
|
|
1412
|
-
}
|
|
1413
1388
|
|
|
1414
1389
|
const contensis = await this.ConnectContensisImport({
|
|
1415
1390
|
commit,
|
|
1416
|
-
|
|
1417
|
-
|
|
1391
|
+
fromFile,
|
|
1392
|
+
importData,
|
|
1418
1393
|
});
|
|
1419
1394
|
|
|
1420
1395
|
if (contensis) {
|
|
@@ -1492,7 +1467,7 @@ class ContensisCli {
|
|
|
1492
1467
|
this.contensisOpts.concurrency = 1;
|
|
1493
1468
|
const contensis = await this.ConnectContensisImport({
|
|
1494
1469
|
commit,
|
|
1495
|
-
|
|
1470
|
+
noSource: true,
|
|
1496
1471
|
});
|
|
1497
1472
|
if (contensis) {
|
|
1498
1473
|
log.line();
|
|
@@ -1839,25 +1814,9 @@ class ContensisCli {
|
|
|
1839
1814
|
}) => {
|
|
1840
1815
|
const { currentProject, log, messages } = this;
|
|
1841
1816
|
|
|
1842
|
-
const mixedData: {
|
|
1843
|
-
models: (ContentType | Component)[];
|
|
1844
|
-
tagGroups: ICreateTagGroup[];
|
|
1845
|
-
} = { models: [], tagGroups: [] };
|
|
1846
|
-
|
|
1847
|
-
if (fromFile) {
|
|
1848
|
-
// File may contain mix of content types, components and tag groups, separate those here
|
|
1849
|
-
const fileData = fromFile ? (await readFileAsJSON(fromFile)) || [] : [];
|
|
1850
|
-
splitTagGroupsInModels(fileData, mixedData.models, mixedData.tagGroups);
|
|
1851
|
-
}
|
|
1852
|
-
// const fileData = fromFile
|
|
1853
|
-
// ? (await readFileAsJSON<(ContentType | Component | TagGroup)[]>(fromFile)) || []
|
|
1854
|
-
// : [];
|
|
1855
|
-
// if (typeof fileData === 'string')
|
|
1856
|
-
// throw new Error(`Import file format must be of type JSON`);
|
|
1857
|
-
|
|
1858
1817
|
const contensis = await this.ConnectContensisImport({
|
|
1859
1818
|
commit,
|
|
1860
|
-
|
|
1819
|
+
fromFile,
|
|
1861
1820
|
});
|
|
1862
1821
|
|
|
1863
1822
|
if (contensis) {
|
|
@@ -2013,7 +1972,7 @@ class ContensisCli {
|
|
|
2013
1972
|
const { currentProject, log, messages } = this;
|
|
2014
1973
|
const contensis = await this.ConnectContensisImport({
|
|
2015
1974
|
commit,
|
|
2016
|
-
|
|
1975
|
+
noSource: true,
|
|
2017
1976
|
});
|
|
2018
1977
|
if (contensis) {
|
|
2019
1978
|
const [err, result] = await contensis.DeleteContentTypes(contentTypeIds);
|
|
@@ -2053,23 +2012,18 @@ class ContensisCli {
|
|
|
2053
2012
|
) => {
|
|
2054
2013
|
const { currentProject, log, messages } = this;
|
|
2055
2014
|
|
|
2056
|
-
let
|
|
2057
|
-
|
|
2058
|
-
: [];
|
|
2059
|
-
if (typeof fileData === 'string')
|
|
2060
|
-
throw new Error(`Import file format must be of type JSON`);
|
|
2061
|
-
|
|
2062
|
-
if (!Array.isArray(fileData)) fileData = [fileData];
|
|
2015
|
+
let importData;
|
|
2016
|
+
if (fromFile) importData = await new MixedFileData().readFile(fromFile);
|
|
2063
2017
|
|
|
2064
2018
|
const contensis = await this.ConnectContensisImport({
|
|
2065
2019
|
commit,
|
|
2066
|
-
|
|
2020
|
+
noSource: !!fromFile,
|
|
2067
2021
|
});
|
|
2068
2022
|
|
|
2069
2023
|
if (contensis) {
|
|
2070
2024
|
if (fromFile)
|
|
2071
2025
|
// Pass each content type to the target repo
|
|
2072
|
-
for (const contentType of
|
|
2026
|
+
for (const contentType of importData.models) {
|
|
2073
2027
|
// Fix invalid data
|
|
2074
2028
|
contentType.projectId = currentProject;
|
|
2075
2029
|
delete contentType.uuid;
|
|
@@ -2112,22 +2066,16 @@ class ContensisCli {
|
|
|
2112
2066
|
) => {
|
|
2113
2067
|
const { log } = this;
|
|
2114
2068
|
|
|
2115
|
-
let
|
|
2116
|
-
|
|
2117
|
-
: [];
|
|
2118
|
-
if (typeof fileData === 'string')
|
|
2119
|
-
throw new Error(`Import file format must be of type JSON`);
|
|
2120
|
-
|
|
2121
|
-
if (!Array.isArray(fileData)) fileData = [fileData];
|
|
2069
|
+
let importData;
|
|
2070
|
+
if (fromFile) importData = await new MixedFileData().readFile(fromFile);
|
|
2122
2071
|
|
|
2123
|
-
const contensis = await this.ConnectContensisImport({
|
|
2124
|
-
fromFile,
|
|
2125
|
-
importDataType: 'models',
|
|
2126
|
-
});
|
|
2072
|
+
const contensis = await this.ConnectContensisImport({ fromFile });
|
|
2127
2073
|
|
|
2128
2074
|
if (contensis) {
|
|
2129
2075
|
const [err, result] = (await to(
|
|
2130
|
-
contensis.models.Diff(
|
|
2076
|
+
contensis.models.Diff(
|
|
2077
|
+
importData.models.length ? importData.models : modelIds
|
|
2078
|
+
)
|
|
2131
2079
|
)) as [Error | null, ContentTypesResult | undefined];
|
|
2132
2080
|
|
|
2133
2081
|
if (err) log.error(err.message, err);
|
|
@@ -2201,10 +2149,12 @@ class ContensisCli {
|
|
|
2201
2149
|
|
|
2202
2150
|
RemoveComponents = async (componentIds: string[], commit = false) => {
|
|
2203
2151
|
const { currentProject, log, messages } = this;
|
|
2152
|
+
|
|
2204
2153
|
const contensis = await this.ConnectContensisImport({
|
|
2205
2154
|
commit,
|
|
2206
|
-
|
|
2155
|
+
noSource: true,
|
|
2207
2156
|
});
|
|
2157
|
+
|
|
2208
2158
|
if (contensis) {
|
|
2209
2159
|
const [err, result] = await contensis.DeleteContentTypes(
|
|
2210
2160
|
undefined,
|
|
@@ -2247,23 +2197,18 @@ class ContensisCli {
|
|
|
2247
2197
|
) => {
|
|
2248
2198
|
const { currentProject, log, messages } = this;
|
|
2249
2199
|
|
|
2250
|
-
let
|
|
2251
|
-
|
|
2252
|
-
: [];
|
|
2253
|
-
if (typeof fileData === 'string')
|
|
2254
|
-
throw new Error(`Import file format must be of type JSON`);
|
|
2255
|
-
|
|
2256
|
-
if (!Array.isArray(fileData)) fileData = [fileData];
|
|
2200
|
+
let importData;
|
|
2201
|
+
if (fromFile) importData = await new MixedFileData().readFile(fromFile);
|
|
2257
2202
|
|
|
2258
2203
|
const contensis = await this.ConnectContensisImport({
|
|
2259
2204
|
commit,
|
|
2260
|
-
|
|
2205
|
+
noSource: !!fromFile,
|
|
2261
2206
|
});
|
|
2262
2207
|
|
|
2263
2208
|
if (contensis) {
|
|
2264
2209
|
// Pass each component to the target repo
|
|
2265
2210
|
if (fromFile)
|
|
2266
|
-
for (const component of
|
|
2211
|
+
for (const component of importData.models) {
|
|
2267
2212
|
// Fix invalid data
|
|
2268
2213
|
component.projectId = currentProject;
|
|
2269
2214
|
delete component.uuid;
|
|
@@ -2302,7 +2247,7 @@ class ContensisCli {
|
|
|
2302
2247
|
this.contensisOpts.concurrency = 1;
|
|
2303
2248
|
const contensis = await this.ConnectContensisImport({
|
|
2304
2249
|
commit,
|
|
2305
|
-
|
|
2250
|
+
noSource: true,
|
|
2306
2251
|
});
|
|
2307
2252
|
|
|
2308
2253
|
if (contensis) {
|
|
@@ -2392,11 +2337,13 @@ class ContensisCli {
|
|
|
2392
2337
|
}) => {
|
|
2393
2338
|
const { currentEnv, currentProject, log, messages } = this;
|
|
2394
2339
|
|
|
2340
|
+
let importData;
|
|
2341
|
+
if (data) importData = new MixedFileData(data);
|
|
2342
|
+
|
|
2395
2343
|
const contensis = await this.ConnectContensisImport({
|
|
2396
2344
|
commit,
|
|
2397
2345
|
fromFile,
|
|
2398
|
-
|
|
2399
|
-
importData: data,
|
|
2346
|
+
importData,
|
|
2400
2347
|
});
|
|
2401
2348
|
|
|
2402
2349
|
if (contensis) {
|
|
@@ -2510,7 +2457,6 @@ class ContensisCli {
|
|
|
2510
2457
|
const contensis = await this.ConnectContensisImport({
|
|
2511
2458
|
commit,
|
|
2512
2459
|
fromFile,
|
|
2513
|
-
importDataType: 'entries',
|
|
2514
2460
|
});
|
|
2515
2461
|
|
|
2516
2462
|
if (contensis) {
|
|
@@ -2591,7 +2537,6 @@ class ContensisCli {
|
|
|
2591
2537
|
const contensis = await this.ConnectContensisImport({
|
|
2592
2538
|
commit,
|
|
2593
2539
|
fromFile,
|
|
2594
|
-
importDataType: 'entries',
|
|
2595
2540
|
});
|
|
2596
2541
|
|
|
2597
2542
|
if (contensis) {
|
|
@@ -2698,7 +2643,6 @@ class ContensisCli {
|
|
|
2698
2643
|
const contensis = await this.ConnectContensisImport({
|
|
2699
2644
|
commit,
|
|
2700
2645
|
fromFile,
|
|
2701
|
-
importDataType: 'nodes',
|
|
2702
2646
|
});
|
|
2703
2647
|
|
|
2704
2648
|
if (contensis) {
|
|
@@ -2773,7 +2717,7 @@ class ContensisCli {
|
|
|
2773
2717
|
const { currentEnv, currentProject, log, messages } = this;
|
|
2774
2718
|
const contensis = await this.ConnectContensisImport({
|
|
2775
2719
|
commit,
|
|
2776
|
-
|
|
2720
|
+
noSource: true,
|
|
2777
2721
|
});
|
|
2778
2722
|
|
|
2779
2723
|
if (contensis) {
|
package/src/util/index.ts
CHANGED
|
@@ -41,29 +41,3 @@ export const Logging = async (language = 'en-GB') => {
|
|
|
41
41
|
Log: Logger,
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
export const splitTagsAndGroups = (
|
|
46
|
-
tagsAndGroups: unknown[] = [],
|
|
47
|
-
tags: ICreateTag[] = [],
|
|
48
|
-
groups: ICreateTagGroup[] = []
|
|
49
|
-
) => {
|
|
50
|
-
for (const item of tagsAndGroups) {
|
|
51
|
-
if (isObject(item) && 'id' in item) {
|
|
52
|
-
if ('name' in item) groups.push(item as ICreateTagGroup);
|
|
53
|
-
else tags.push(item as ICreateTag);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const splitTagGroupsInModels = (
|
|
59
|
-
mixedData: unknown[] = [],
|
|
60
|
-
models: (ContentType | Component)[] = [],
|
|
61
|
-
groups: ICreateTagGroup[] = []
|
|
62
|
-
) => {
|
|
63
|
-
for (const item of mixedData) {
|
|
64
|
-
if (isObject(item) && 'id' in item) {
|
|
65
|
-
if (!('dataFormat' in item)) groups.push(item as ICreateTagGroup);
|
|
66
|
-
else models.push(item as ContentType | Component);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "1.5.1-beta.
|
|
1
|
+
export const LIB_VERSION = "1.5.1-beta.8";
|