@contrail/cli 1.0.46 → 1.0.47
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.
|
@@ -33,3 +33,41 @@ export declare class ProjectConfiguration {
|
|
|
33
33
|
assortments: AssortmentConfiguration[];
|
|
34
34
|
subFolders: Folder[];
|
|
35
35
|
}
|
|
36
|
+
export declare class ProjectConfigurationTemplate {
|
|
37
|
+
projectName: string;
|
|
38
|
+
identifier: string;
|
|
39
|
+
commonConfig: CommonConfiguration;
|
|
40
|
+
allFolders: FolderSlim[];
|
|
41
|
+
allAssortments: AssortmentConfigurationSlim[];
|
|
42
|
+
allAssortmentRelationships: AssortmentConfigurationRelationships[];
|
|
43
|
+
}
|
|
44
|
+
export declare class FolderSlim {
|
|
45
|
+
identifier: string;
|
|
46
|
+
name: string;
|
|
47
|
+
folderIdentifier: string;
|
|
48
|
+
}
|
|
49
|
+
export declare class AssortmentConfigurationSlim {
|
|
50
|
+
identifier: string;
|
|
51
|
+
name: string;
|
|
52
|
+
type: AssortmentType;
|
|
53
|
+
folderIdentifier: string;
|
|
54
|
+
sourceAssortmentIdentifier?: string;
|
|
55
|
+
composedFromAssortmentIdentifiers?: string[];
|
|
56
|
+
ownerAtts?: {
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
};
|
|
59
|
+
assortmentAtts?: {
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export declare class AssortmentConfigurationRelationships {
|
|
64
|
+
identifier: string;
|
|
65
|
+
sourceAssortmentIdentifier?: string;
|
|
66
|
+
composedFromAssortmentIdentifiers?: string[];
|
|
67
|
+
ownerAtts?: {
|
|
68
|
+
[key: string]: any;
|
|
69
|
+
};
|
|
70
|
+
assortmentAtts?: {
|
|
71
|
+
[key: string]: any;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -13,3 +13,11 @@ export class Folder {
|
|
|
13
13
|
}
|
|
14
14
|
export class ProjectConfiguration {
|
|
15
15
|
}
|
|
16
|
+
export class ProjectConfigurationTemplate {
|
|
17
|
+
}
|
|
18
|
+
export class FolderSlim {
|
|
19
|
+
}
|
|
20
|
+
export class AssortmentConfigurationSlim {
|
|
21
|
+
}
|
|
22
|
+
export class AssortmentConfigurationRelationships {
|
|
23
|
+
}
|
|
@@ -34,7 +34,8 @@ function getProjectFile(fileName) {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
async function uploadProject(templateFileLocation) {
|
|
37
|
-
const
|
|
37
|
+
const projectConfigurationFromFile = getProjectFile(templateFileLocation);
|
|
38
|
+
const projectConfiguration = getProjectConfiguration(projectConfigurationFromFile);
|
|
38
39
|
console.log('Configuring Project.');
|
|
39
40
|
await Request.request('/project-configurator', {
|
|
40
41
|
method: 'POST',
|
|
@@ -45,3 +46,59 @@ async function uploadProject(templateFileLocation) {
|
|
|
45
46
|
},
|
|
46
47
|
});
|
|
47
48
|
}
|
|
49
|
+
function getProjectConfiguration(projectConfigurationFromFile) {
|
|
50
|
+
if (!projectConfigurationFromFile.allFolders && !projectConfigurationFromFile.allAssortments && !projectConfigurationFromFile.allAssortmentRelationships) {
|
|
51
|
+
return projectConfigurationFromFile;
|
|
52
|
+
}
|
|
53
|
+
const parsed = parseToProjectConfiguration(projectConfigurationFromFile);
|
|
54
|
+
return parsed;
|
|
55
|
+
}
|
|
56
|
+
function parseToProjectConfiguration(projectConfigurationFromFile) {
|
|
57
|
+
const projectConfiguration = {
|
|
58
|
+
projectName: projectConfigurationFromFile.projectName,
|
|
59
|
+
identifier: projectConfigurationFromFile.identifier,
|
|
60
|
+
commonConfig: projectConfigurationFromFile.commonConfig,
|
|
61
|
+
assortments: [],
|
|
62
|
+
subFolders: [],
|
|
63
|
+
};
|
|
64
|
+
const foldersByIdentifier = { [projectConfiguration.identifier]: projectConfiguration };
|
|
65
|
+
for (const folder of projectConfigurationFromFile.allFolders) {
|
|
66
|
+
foldersByIdentifier[folder.identifier] = folder;
|
|
67
|
+
}
|
|
68
|
+
const assortmentsByIdentifier = {};
|
|
69
|
+
for (const assortment of projectConfigurationFromFile.allAssortments) {
|
|
70
|
+
assortmentsByIdentifier[assortment.identifier] = assortment;
|
|
71
|
+
}
|
|
72
|
+
for (const assortmentRelationships of projectConfigurationFromFile.allAssortmentRelationships) {
|
|
73
|
+
const assortment = assortmentsByIdentifier[assortmentRelationships.identifier];
|
|
74
|
+
if (!assortment) {
|
|
75
|
+
console.warn('Relationship defined for assortment that is not defined.', assortmentRelationships);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
Object.assign(assortment, assortmentRelationships);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
for (const assortment of projectConfigurationFromFile.allAssortments) {
|
|
82
|
+
const folder = foldersByIdentifier[assortment.folderIdentifier];
|
|
83
|
+
if (!folder) {
|
|
84
|
+
console.warn('Assortment defined for folder that is not defined.', assortment);
|
|
85
|
+
}
|
|
86
|
+
if (!folder.assortments) {
|
|
87
|
+
folder.assortments = [];
|
|
88
|
+
}
|
|
89
|
+
delete assortment.folderIdentifier;
|
|
90
|
+
folder.assortments.push(assortment);
|
|
91
|
+
}
|
|
92
|
+
for (const folderSlim of projectConfigurationFromFile.allFolders) {
|
|
93
|
+
const folder = foldersByIdentifier[folderSlim.folderIdentifier];
|
|
94
|
+
if (!folder) {
|
|
95
|
+
console.warn('Folder defined for folder that is not defined.', folderSlim);
|
|
96
|
+
}
|
|
97
|
+
if (!folder.subFolders) {
|
|
98
|
+
folder.subFolders = [];
|
|
99
|
+
}
|
|
100
|
+
delete folderSlim.folderIdentifier;
|
|
101
|
+
folder.subFolders.push(folderSlim);
|
|
102
|
+
}
|
|
103
|
+
return projectConfiguration;
|
|
104
|
+
}
|
package/package.json
CHANGED
|
@@ -32,4 +32,38 @@ export class ProjectConfiguration {
|
|
|
32
32
|
commonConfig: CommonConfiguration;
|
|
33
33
|
assortments: AssortmentConfiguration[];
|
|
34
34
|
subFolders: Folder[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class ProjectConfigurationTemplate {
|
|
38
|
+
projectName: string;
|
|
39
|
+
identifier: string;
|
|
40
|
+
commonConfig: CommonConfiguration;
|
|
41
|
+
allFolders: FolderSlim[];
|
|
42
|
+
allAssortments: AssortmentConfigurationSlim[];
|
|
43
|
+
allAssortmentRelationships: AssortmentConfigurationRelationships[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class FolderSlim {
|
|
47
|
+
identifier: string;
|
|
48
|
+
name: string;
|
|
49
|
+
folderIdentifier: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class AssortmentConfigurationSlim {
|
|
53
|
+
identifier: string;
|
|
54
|
+
name: string;
|
|
55
|
+
type: AssortmentType;
|
|
56
|
+
folderIdentifier: string;
|
|
57
|
+
sourceAssortmentIdentifier?: string;
|
|
58
|
+
composedFromAssortmentIdentifiers?: string[];
|
|
59
|
+
ownerAtts?: {[key: string]: any};
|
|
60
|
+
assortmentAtts?: {[key: string]: any};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export class AssortmentConfigurationRelationships {
|
|
64
|
+
identifier: string;
|
|
65
|
+
sourceAssortmentIdentifier?: string;
|
|
66
|
+
composedFromAssortmentIdentifiers?: string[];
|
|
67
|
+
ownerAtts?: {[key: string]: any};
|
|
68
|
+
assortmentAtts?: {[key: string]: any};
|
|
35
69
|
}
|
|
@@ -3,7 +3,7 @@ import chalk from 'chalk';
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { authUser } from '../auth/login';
|
|
5
5
|
import { getSeparatorByPlatform } from '../common';
|
|
6
|
-
import { ProjectConfiguration } from './interfaces';
|
|
6
|
+
import { ProjectConfiguration, ProjectConfigurationTemplate } from './interfaces';
|
|
7
7
|
|
|
8
8
|
import yaml from 'js-yaml';
|
|
9
9
|
|
|
@@ -42,7 +42,9 @@ function getProjectFile(fileName){
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
async function uploadProject(templateFileLocation) {
|
|
45
|
-
const
|
|
45
|
+
const projectConfigurationFromFile = getProjectFile(templateFileLocation);
|
|
46
|
+
const projectConfiguration: ProjectConfiguration = getProjectConfiguration(projectConfigurationFromFile);
|
|
47
|
+
|
|
46
48
|
console.log('Configuring Project.');
|
|
47
49
|
|
|
48
50
|
await Request.request(
|
|
@@ -55,5 +57,74 @@ async function uploadProject(templateFileLocation) {
|
|
|
55
57
|
'Content-Type': 'application/json',
|
|
56
58
|
},
|
|
57
59
|
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getProjectConfiguration(projectConfigurationFromFile): ProjectConfiguration {
|
|
63
|
+
if (!projectConfigurationFromFile.allFolders && !projectConfigurationFromFile.allAssortments && !projectConfigurationFromFile.allAssortmentRelationships) {
|
|
64
|
+
return projectConfigurationFromFile;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const parsed = parseToProjectConfiguration(projectConfigurationFromFile);
|
|
68
|
+
return parsed;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function parseToProjectConfiguration(projectConfigurationFromFile: ProjectConfigurationTemplate): ProjectConfiguration {
|
|
72
|
+
|
|
73
|
+
const projectConfiguration: ProjectConfiguration = {
|
|
74
|
+
projectName: projectConfigurationFromFile.projectName,
|
|
75
|
+
identifier: projectConfigurationFromFile.identifier,
|
|
76
|
+
commonConfig: projectConfigurationFromFile.commonConfig,
|
|
77
|
+
assortments: [],
|
|
78
|
+
subFolders: [],
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const foldersByIdentifier: any = {[projectConfiguration.identifier]: projectConfiguration};
|
|
82
|
+
for (const folder of projectConfigurationFromFile.allFolders) {
|
|
83
|
+
foldersByIdentifier[folder.identifier] = folder;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const assortmentsByIdentifier = {};
|
|
87
|
+
for (const assortment of projectConfigurationFromFile.allAssortments) {
|
|
88
|
+
assortmentsByIdentifier[assortment.identifier] = assortment;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
for (const assortmentRelationships of projectConfigurationFromFile.allAssortmentRelationships) {
|
|
92
|
+
const assortment = assortmentsByIdentifier[assortmentRelationships.identifier];
|
|
93
|
+
if (!assortment) {
|
|
94
|
+
console.warn('Relationship defined for assortment that is not defined.', assortmentRelationships);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
Object.assign(assortment, assortmentRelationships);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
for (const assortment of projectConfigurationFromFile.allAssortments) {
|
|
102
|
+
const folder = foldersByIdentifier[assortment.folderIdentifier];
|
|
103
|
+
if (!folder) {
|
|
104
|
+
console.warn('Assortment defined for folder that is not defined.', assortment);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!folder.assortments) {
|
|
108
|
+
folder.assortments = [];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
delete assortment.folderIdentifier;
|
|
112
|
+
folder.assortments.push(assortment);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
for (const folderSlim of projectConfigurationFromFile.allFolders) {
|
|
116
|
+
const folder = foldersByIdentifier[folderSlim.folderIdentifier];
|
|
117
|
+
if (!folder) {
|
|
118
|
+
console.warn('Folder defined for folder that is not defined.', folderSlim);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (!folder.subFolders) {
|
|
122
|
+
folder.subFolders = [];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
delete folderSlim.folderIdentifier;
|
|
126
|
+
folder.subFolders.push(folderSlim);
|
|
127
|
+
}
|
|
58
128
|
|
|
129
|
+
return projectConfiguration;
|
|
59
130
|
}
|