@contrail/cli 1.0.51 → 1.0.53
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/lib/cli.js +19 -2
- package/lib/projects/project-exporter.d.ts +2 -0
- package/lib/projects/project-exporter.js +163 -0
- package/package.json +2 -2
- package/src/cli.ts +19 -2
- package/src/projects/project-exporter.ts +194 -0
package/lib/cli.js
CHANGED
|
@@ -15,6 +15,7 @@ import { installApp, uninstallApp } from './apps/install-app/app-installer';
|
|
|
15
15
|
import { upgradeApp } from './apps/upgrade-app/app-upgrader';
|
|
16
16
|
import { cliInstallWorkflowTemplateDefinitions, listWorkflowTemplateDefinitions } from './workflow-template-definitions/workflow-template-definition-commands';
|
|
17
17
|
import { configureProject } from './projects/project-uploader';
|
|
18
|
+
import { ListProjects, ExportProject } from './projects/project-exporter';
|
|
18
19
|
import { Load, UploadAndLoad } from './loader-process/loader-process';
|
|
19
20
|
const cliUsage = require('command-line-usage');
|
|
20
21
|
/**
|
|
@@ -164,10 +165,18 @@ export async function cli(args) {
|
|
|
164
165
|
}
|
|
165
166
|
case 'projects': {
|
|
166
167
|
switch (command) {
|
|
167
|
-
case '
|
|
168
|
+
case 'load': {
|
|
168
169
|
await configureProject(args);
|
|
169
170
|
break;
|
|
170
171
|
}
|
|
172
|
+
case 'list': {
|
|
173
|
+
await ListProjects();
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
case 'export': {
|
|
177
|
+
await ExportProject(args);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
171
180
|
default: {
|
|
172
181
|
printIllegalCommand();
|
|
173
182
|
}
|
|
@@ -316,8 +325,16 @@ const helpSections = [
|
|
|
316
325
|
{
|
|
317
326
|
header: 'Project Commands - Domain: projects',
|
|
318
327
|
content: [{
|
|
319
|
-
name: '
|
|
328
|
+
name: 'load <File Path>',
|
|
320
329
|
summary: 'Configure a project from a yml file.'
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
name: 'list',
|
|
333
|
+
summary: 'Get a list of all projects.'
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: 'export <Project Name>',
|
|
337
|
+
summary: 'Export a project.'
|
|
321
338
|
}
|
|
322
339
|
],
|
|
323
340
|
},
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Entities } from '@contrail/sdk';
|
|
2
|
+
import { ObjectUtil } from '@contrail/util';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import { authUser } from '../auth/login';
|
|
6
|
+
import { getSeparatorByPlatform } from '../common';
|
|
7
|
+
import yaml from 'js-yaml';
|
|
8
|
+
export async function ListProjects() {
|
|
9
|
+
try {
|
|
10
|
+
await authUser();
|
|
11
|
+
console.log('%s Getting Projects.', chalk.blue.bold('START'));
|
|
12
|
+
await listProjects();
|
|
13
|
+
console.log('%s Done', chalk.yellow.bold('PROJECTS'));
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
console.log(`%s Project download Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
console.log('%s Project download Complete.', chalk.green.bold('COMPLETE'));
|
|
20
|
+
}
|
|
21
|
+
export async function ExportProject(args) {
|
|
22
|
+
try {
|
|
23
|
+
await authUser();
|
|
24
|
+
console.log('%s Exporting Project.', chalk.blue.bold('START'));
|
|
25
|
+
console.log('%s Exporting', chalk.yellow.bold('PROJECT'));
|
|
26
|
+
const projectName = args[3];
|
|
27
|
+
await exportProject(projectName);
|
|
28
|
+
console.log('%s Exported', chalk.yellow.bold('PROJECT'));
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
console.log(`%s Project Export Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
console.log('%s Project Export Complete.', chalk.green.bold('COMPLETE'));
|
|
35
|
+
}
|
|
36
|
+
async function listProjects() {
|
|
37
|
+
const allWorkspaces = await new Entities().get({
|
|
38
|
+
entityName: 'workspace',
|
|
39
|
+
criteria: { isArchived: false }
|
|
40
|
+
});
|
|
41
|
+
console.log('%s', chalk.green.bold('PROJECTS:'));
|
|
42
|
+
//console.log(allWorkspaces.map(w => Object.assign({}, {name: w.name, id: w.id}))); // if we want ids
|
|
43
|
+
console.log(allWorkspaces.map(w => w.name));
|
|
44
|
+
}
|
|
45
|
+
async function exportProject(name) {
|
|
46
|
+
const allWorkspaces = await new Entities().get({
|
|
47
|
+
entityName: 'workspace',
|
|
48
|
+
useSearch: false,
|
|
49
|
+
});
|
|
50
|
+
const workspace = allWorkspaces.find(w => w.name === name);
|
|
51
|
+
if (!workspace) {
|
|
52
|
+
throw new Error('Project was not found.');
|
|
53
|
+
}
|
|
54
|
+
const projectConfiguration = {
|
|
55
|
+
projectName: workspace.name,
|
|
56
|
+
identifier: workspace.identifier,
|
|
57
|
+
commonConfig: {},
|
|
58
|
+
assortments: [],
|
|
59
|
+
subFolders: []
|
|
60
|
+
};
|
|
61
|
+
const allAssortments = [];
|
|
62
|
+
await getAssortmentsAndSubFolders(workspace.id, projectConfiguration.assortments, projectConfiguration.subFolders, allAssortments);
|
|
63
|
+
await convertRelationshipsInFolders(projectConfiguration, allAssortments);
|
|
64
|
+
saveData({ projectConfiguration: projectConfiguration }, name);
|
|
65
|
+
}
|
|
66
|
+
async function getAssortmentsAndSubFolders(parentId, assortments, subFolders, allAssortments) {
|
|
67
|
+
const workspaceAssortments = await new Entities().get({
|
|
68
|
+
entityName: 'assortment',
|
|
69
|
+
criteria: {
|
|
70
|
+
workspaceId: parentId,
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const integrationAssortments = workspaceAssortments === null || workspaceAssortments === void 0 ? void 0 : workspaceAssortments.filter(a => a.assortmentType === 'INTEGRATION');
|
|
74
|
+
if ((integrationAssortments === null || integrationAssortments === void 0 ? void 0 : integrationAssortments.length) > 0) {
|
|
75
|
+
allAssortments.push(...integrationAssortments);
|
|
76
|
+
for (const a of integrationAssortments) {
|
|
77
|
+
const integrationAssortmentsCopy = ObjectUtil.cloneDeep(a);
|
|
78
|
+
deleteNonUserKeys(integrationAssortmentsCopy);
|
|
79
|
+
const converted = {
|
|
80
|
+
identifier: a.identifier,
|
|
81
|
+
name: a.name,
|
|
82
|
+
type: 'ASSORTMENT',
|
|
83
|
+
sourceAssortmentIdentifier: [],
|
|
84
|
+
sourceAssortmentIds: a.sourceAssortmentIds,
|
|
85
|
+
composedFromAssortmentIdentifiers: [],
|
|
86
|
+
composedFromAssortmentIds: a.composedFromAssortmentIds,
|
|
87
|
+
assortmentAtts: Object.assign({}, integrationAssortmentsCopy),
|
|
88
|
+
};
|
|
89
|
+
assortments.push(converted);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
console.log('workspaceFolderLinks call');
|
|
93
|
+
const workspaceFolderLinks = await new Entities().get({
|
|
94
|
+
entityName: 'workspace-entity',
|
|
95
|
+
criteria: {
|
|
96
|
+
workspaceId: parentId,
|
|
97
|
+
entityType: 'workspace'
|
|
98
|
+
},
|
|
99
|
+
relations: ['entity']
|
|
100
|
+
});
|
|
101
|
+
const workspaceFolders = workspaceFolderLinks === null || workspaceFolderLinks === void 0 ? void 0 : workspaceFolderLinks.map(wfl => wfl.entity);
|
|
102
|
+
if ((workspaceFolders === null || workspaceFolders === void 0 ? void 0 : workspaceFolders.length) > 0) {
|
|
103
|
+
for (const folder of workspaceFolders) {
|
|
104
|
+
const converted = {
|
|
105
|
+
identifier: folder.identifier,
|
|
106
|
+
name: folder.name,
|
|
107
|
+
assortments: [],
|
|
108
|
+
subFolders: [],
|
|
109
|
+
};
|
|
110
|
+
await getAssortmentsAndSubFolders(folder.id, converted.assortments, converted.subFolders, allAssortments);
|
|
111
|
+
subFolders.push(converted);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function convertRelationshipsInFolders(folder, allAssortments) {
|
|
116
|
+
if (!(allAssortments.length > 0)) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
convertRelationshipsToIdentifiers(folder.assortments, allAssortments);
|
|
120
|
+
for (const f of folder.subFolders) {
|
|
121
|
+
convertRelationshipsInFolders(f, allAssortments);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function convertRelationshipsToIdentifiers(assortments, allAssortments) {
|
|
125
|
+
if (!(allAssortments.length > 0)) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
for (const assortment of assortments) {
|
|
129
|
+
if (assortment.sourceAssortmentIds) {
|
|
130
|
+
assortment.sourceAssortmentIdentifier = assortment.sourceAssortmentIds.map(id => { var _a; return (_a = allAssortments.find(a => a.id === id)) === null || _a === void 0 ? void 0 : _a.identifier; });
|
|
131
|
+
}
|
|
132
|
+
delete assortment.sourceAssortmentIds;
|
|
133
|
+
if (assortment.composedFromAssortmentIds) {
|
|
134
|
+
assortment.composedFromAssortmentIdentifiers = assortment.composedFromAssortmentIds.map(id => { var _a; return (_a = allAssortments.find(a => a.id === id)) === null || _a === void 0 ? void 0 : _a.identifier; });
|
|
135
|
+
}
|
|
136
|
+
delete assortment.composedFromAssortmentIds;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function deleteNonUserKeys(assortment) {
|
|
140
|
+
delete assortment.name;
|
|
141
|
+
delete assortment.identifier;
|
|
142
|
+
delete assortment.assortmentType;
|
|
143
|
+
delete assortment.createdById;
|
|
144
|
+
delete assortment.createdForReference;
|
|
145
|
+
delete assortment.createdOn;
|
|
146
|
+
delete assortment.entityType;
|
|
147
|
+
delete assortment.id;
|
|
148
|
+
delete assortment.orgId;
|
|
149
|
+
delete assortment.rootWorkspaceId;
|
|
150
|
+
delete assortment.composedFromAssortmentIds;
|
|
151
|
+
delete assortment.sourceAssortmentIds;
|
|
152
|
+
delete assortment.typeId;
|
|
153
|
+
delete assortment.typePath;
|
|
154
|
+
delete assortment.updatedById;
|
|
155
|
+
delete assortment.updatedOn;
|
|
156
|
+
delete assortment.workspaceId;
|
|
157
|
+
}
|
|
158
|
+
function saveData(data, name) {
|
|
159
|
+
const yamlStr = yaml.dump(data);
|
|
160
|
+
const CURRENT_DIR = process.cwd();
|
|
161
|
+
const separator = getSeparatorByPlatform();
|
|
162
|
+
fs.writeFileSync(CURRENT_DIR + separator + name + '-export.yml', yamlStr, 'utf8');
|
|
163
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.53",
|
|
4
4
|
"description": "VibeIQ's Contrail Platform CLI.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@contrail/sdk": "^1.1.
|
|
26
|
+
"@contrail/sdk": "^1.1.52",
|
|
27
27
|
"@contrail/types": "^3.0.20",
|
|
28
28
|
"@contrail/util": "^1.0.17",
|
|
29
29
|
"amazon-cognito-identity-js": "^5.2.3",
|
package/src/cli.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { installApp, uninstallApp } from './apps/install-app/app-installer';
|
|
|
16
16
|
import { upgradeApp } from './apps/upgrade-app/app-upgrader';
|
|
17
17
|
import { cliInstallWorkflowTemplateDefinitions, listWorkflowTemplateDefinitions } from './workflow-template-definitions/workflow-template-definition-commands';
|
|
18
18
|
import { configureProject } from './projects/project-uploader';
|
|
19
|
+
import { ListProjects, ExportProject } from './projects/project-exporter';
|
|
19
20
|
import { Load, UploadAndLoad } from './loader-process/loader-process';
|
|
20
21
|
|
|
21
22
|
const cliUsage = require('command-line-usage');
|
|
@@ -174,10 +175,18 @@ export async function cli(args) {
|
|
|
174
175
|
}
|
|
175
176
|
case 'projects': {
|
|
176
177
|
switch (command) {
|
|
177
|
-
case '
|
|
178
|
+
case 'load': {
|
|
178
179
|
await configureProject(args);
|
|
179
180
|
break;
|
|
180
181
|
}
|
|
182
|
+
case 'list': {
|
|
183
|
+
await ListProjects();
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
case 'export': {
|
|
187
|
+
await ExportProject(args);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
181
190
|
default: {
|
|
182
191
|
printIllegalCommand();
|
|
183
192
|
}
|
|
@@ -331,8 +340,16 @@ const helpSections = [
|
|
|
331
340
|
{
|
|
332
341
|
header: 'Project Commands - Domain: projects',
|
|
333
342
|
content: [{
|
|
334
|
-
name: '
|
|
343
|
+
name: 'load <File Path>',
|
|
335
344
|
summary: 'Configure a project from a yml file.'
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: 'list',
|
|
348
|
+
summary: 'Get a list of all projects.'
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
name: 'export <Project Name>',
|
|
352
|
+
summary: 'Export a project.'
|
|
336
353
|
}
|
|
337
354
|
],
|
|
338
355
|
},
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { Entities } from '@contrail/sdk';
|
|
2
|
+
import { ObjectUtil } from '@contrail/util';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import { authUser } from '../auth/login';
|
|
6
|
+
import { getSeparatorByPlatform } from '../common';
|
|
7
|
+
import yaml from 'js-yaml';
|
|
8
|
+
|
|
9
|
+
export async function ListProjects() {
|
|
10
|
+
try {
|
|
11
|
+
await authUser();
|
|
12
|
+
console.log('%s Getting Projects.', chalk.blue.bold('START'));
|
|
13
|
+
|
|
14
|
+
await listProjects();
|
|
15
|
+
console.log('%s Done', chalk.yellow.bold('PROJECTS'));
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
console.log(`%s Project download Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
console.log('%s Project download Complete.', chalk.green.bold('COMPLETE'));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function ExportProject(args) {
|
|
27
|
+
try {
|
|
28
|
+
await authUser();
|
|
29
|
+
console.log('%s Exporting Project.', chalk.blue.bold('START'));
|
|
30
|
+
|
|
31
|
+
console.log('%s Exporting', chalk.yellow.bold('PROJECT'));
|
|
32
|
+
const projectName = args[3];
|
|
33
|
+
await exportProject(projectName);
|
|
34
|
+
console.log('%s Exported', chalk.yellow.bold('PROJECT'));
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
console.log(`%s Project Export Failed. ${e}`, chalk.red.bold('FAIL'));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log('%s Project Export Complete.', chalk.green.bold('COMPLETE'));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function listProjects() {
|
|
46
|
+
const allWorkspaces = await new Entities().get({
|
|
47
|
+
entityName: 'workspace',
|
|
48
|
+
criteria: {isArchived: false}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
console.log('%s', chalk.green.bold('PROJECTS:'));
|
|
52
|
+
//console.log(allWorkspaces.map(w => Object.assign({}, {name: w.name, id: w.id}))); // if we want ids
|
|
53
|
+
console.log(allWorkspaces.map(w => w.name));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function exportProject(name) {
|
|
57
|
+
const allWorkspaces = await new Entities().get({
|
|
58
|
+
entityName: 'workspace',
|
|
59
|
+
useSearch: false,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const workspace = allWorkspaces.find(w => w.name === name);
|
|
63
|
+
if (!workspace) {
|
|
64
|
+
throw new Error('Project was not found.');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const projectConfiguration = {
|
|
68
|
+
projectName: workspace.name,
|
|
69
|
+
identifier: workspace.identifier,
|
|
70
|
+
commonConfig: {},
|
|
71
|
+
assortments: [],
|
|
72
|
+
subFolders: []
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const allAssortments = [];
|
|
76
|
+
await getAssortmentsAndSubFolders(workspace.id, projectConfiguration.assortments, projectConfiguration.subFolders, allAssortments);
|
|
77
|
+
await convertRelationshipsInFolders(projectConfiguration, allAssortments);
|
|
78
|
+
saveData({projectConfiguration: projectConfiguration}, name);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function getAssortmentsAndSubFolders(parentId, assortments, subFolders, allAssortments) {
|
|
82
|
+
const workspaceAssortments = await new Entities().get({
|
|
83
|
+
entityName: 'assortment',
|
|
84
|
+
criteria: {
|
|
85
|
+
workspaceId: parentId,
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const integrationAssortments = workspaceAssortments?.filter(a => a.assortmentType === 'INTEGRATION');
|
|
90
|
+
|
|
91
|
+
if (integrationAssortments?.length > 0) {
|
|
92
|
+
allAssortments.push(...integrationAssortments);
|
|
93
|
+
for (const a of integrationAssortments) {
|
|
94
|
+
const integrationAssortmentsCopy = ObjectUtil.cloneDeep(a);
|
|
95
|
+
deleteNonUserKeys(integrationAssortmentsCopy);
|
|
96
|
+
const converted = {
|
|
97
|
+
identifier: a.identifier,
|
|
98
|
+
name: a.name,
|
|
99
|
+
type: 'ASSORTMENT',
|
|
100
|
+
sourceAssortmentIdentifier: [],
|
|
101
|
+
sourceAssortmentIds: a.sourceAssortmentIds,
|
|
102
|
+
composedFromAssortmentIdentifiers: [],
|
|
103
|
+
composedFromAssortmentIds: a.composedFromAssortmentIds,
|
|
104
|
+
assortmentAtts: Object.assign({}, integrationAssortmentsCopy),
|
|
105
|
+
};
|
|
106
|
+
assortments.push(converted);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
console.log('workspaceFolderLinks call');
|
|
111
|
+
|
|
112
|
+
const workspaceFolderLinks = await new Entities().get({
|
|
113
|
+
entityName: 'workspace-entity',
|
|
114
|
+
criteria: {
|
|
115
|
+
workspaceId: parentId,
|
|
116
|
+
entityType: 'workspace'
|
|
117
|
+
},
|
|
118
|
+
relations: ['entity']
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const workspaceFolders = workspaceFolderLinks?.map(wfl => wfl.entity);
|
|
122
|
+
|
|
123
|
+
if (workspaceFolders?.length > 0) {
|
|
124
|
+
for (const folder of workspaceFolders) {
|
|
125
|
+
const converted = {
|
|
126
|
+
identifier: folder.identifier,
|
|
127
|
+
name: folder.name,
|
|
128
|
+
assortments: [],
|
|
129
|
+
subFolders: [],
|
|
130
|
+
};
|
|
131
|
+
await getAssortmentsAndSubFolders(folder.id, converted.assortments, converted.subFolders, allAssortments);
|
|
132
|
+
subFolders.push(converted);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function convertRelationshipsInFolders(folder, allAssortments) {
|
|
139
|
+
if (!(allAssortments.length > 0)) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
convertRelationshipsToIdentifiers(folder.assortments, allAssortments);
|
|
144
|
+
|
|
145
|
+
for (const f of folder.subFolders) {
|
|
146
|
+
convertRelationshipsInFolders(f, allAssortments);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function convertRelationshipsToIdentifiers(assortments, allAssortments) {
|
|
152
|
+
if (!(allAssortments.length > 0)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
for (const assortment of assortments) {
|
|
157
|
+
if (assortment.sourceAssortmentIds) {
|
|
158
|
+
assortment.sourceAssortmentIdentifier = assortment.sourceAssortmentIds.map(id => allAssortments.find(a => a.id === id)?.identifier);
|
|
159
|
+
}
|
|
160
|
+
delete assortment.sourceAssortmentIds;
|
|
161
|
+
|
|
162
|
+
if (assortment.composedFromAssortmentIds) {
|
|
163
|
+
assortment.composedFromAssortmentIdentifiers = assortment.composedFromAssortmentIds.map(id => allAssortments.find(a => a.id === id)?.identifier);
|
|
164
|
+
}
|
|
165
|
+
delete assortment.composedFromAssortmentIds;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function deleteNonUserKeys(assortment) {
|
|
170
|
+
delete assortment.name;
|
|
171
|
+
delete assortment.identifier;
|
|
172
|
+
delete assortment.assortmentType;
|
|
173
|
+
delete assortment.createdById;
|
|
174
|
+
delete assortment.createdForReference;
|
|
175
|
+
delete assortment.createdOn;
|
|
176
|
+
delete assortment.entityType;
|
|
177
|
+
delete assortment.id;
|
|
178
|
+
delete assortment.orgId;
|
|
179
|
+
delete assortment.rootWorkspaceId;
|
|
180
|
+
delete assortment.composedFromAssortmentIds;
|
|
181
|
+
delete assortment.sourceAssortmentIds;
|
|
182
|
+
delete assortment.typeId;
|
|
183
|
+
delete assortment.typePath;
|
|
184
|
+
delete assortment.updatedById;
|
|
185
|
+
delete assortment.updatedOn;
|
|
186
|
+
delete assortment.workspaceId;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function saveData(data, name) {
|
|
190
|
+
const yamlStr = yaml.dump(data);
|
|
191
|
+
const CURRENT_DIR = process.cwd();
|
|
192
|
+
const separator = getSeparatorByPlatform();
|
|
193
|
+
fs.writeFileSync(CURRENT_DIR + separator + name + '-export.yml', yamlStr, 'utf8');
|
|
194
|
+
}
|