@contrail/cli 1.0.5 → 1.0.6
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.
|
@@ -75,7 +75,7 @@ export class ActionsDeployer {
|
|
|
75
75
|
id: existingActionDefinition.id,
|
|
76
76
|
object: updates,
|
|
77
77
|
});
|
|
78
|
-
console.log(`%s Updated
|
|
78
|
+
console.log(`%s Updated existing action definition: ${actionDefinition.identifier}`, chalk.yellow.bold('APP'));
|
|
79
79
|
return actionDefinition;
|
|
80
80
|
}
|
|
81
81
|
getActionDeclarationIdentifier(actionKey, app) {
|
|
@@ -25,11 +25,11 @@ async function getOptionSets() {
|
|
|
25
25
|
const optionSets = await new Entities().get({
|
|
26
26
|
entityName: 'type-property-option-set',
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
let reducedOptionSets = [];
|
|
29
29
|
for (const optionSet of optionSets) {
|
|
30
30
|
const reducedOptionSet = {
|
|
31
|
-
id: optionSet.id,
|
|
32
31
|
name: optionSet.name,
|
|
32
|
+
id: optionSet.id,
|
|
33
33
|
isArchived: optionSet.isArchived,
|
|
34
34
|
optionSet: optionSet.optionSet,
|
|
35
35
|
};
|
|
@@ -38,6 +38,7 @@ async function getOptionSets() {
|
|
|
38
38
|
const optionSetsHolder = {
|
|
39
39
|
optionSets: reducedOptionSets,
|
|
40
40
|
};
|
|
41
|
+
reducedOptionSets = reducedOptionSets.sort((one, two) => (one.name < two.name ? -1 : 1));
|
|
41
42
|
const CURRENT_DIR = process.cwd();
|
|
42
43
|
const separator = getSeparatorByPlatform();
|
|
43
44
|
const yamlStr = yaml.dump(optionSetsHolder);
|
|
@@ -48,7 +49,7 @@ async function getReducedTypes() {
|
|
|
48
49
|
entityName: 'type',
|
|
49
50
|
});
|
|
50
51
|
console.log('Found types: ', types.length);
|
|
51
|
-
|
|
52
|
+
let reducedTypes = [];
|
|
52
53
|
for (const type of types) {
|
|
53
54
|
const typeWithProperties = await new Entities().get({
|
|
54
55
|
entityName: 'type',
|
|
@@ -58,10 +59,10 @@ async function getReducedTypes() {
|
|
|
58
59
|
const reducedTypeProperties = [];
|
|
59
60
|
for (const typeProperty of typeWithProperties.typeProperties) {
|
|
60
61
|
const reducedTypeProperty = {
|
|
62
|
+
slug: typeProperty.slug,
|
|
61
63
|
id: typeProperty.id,
|
|
62
64
|
isArchived: typeProperty.isArchived,
|
|
63
65
|
propertyType: typeProperty.propertyType,
|
|
64
|
-
slug: typeProperty.slug,
|
|
65
66
|
label: typeProperty.label,
|
|
66
67
|
editable: typeProperty.editable,
|
|
67
68
|
core: typeProperty.core,
|
|
@@ -75,14 +76,15 @@ async function getReducedTypes() {
|
|
|
75
76
|
reducedTypeProperties.push(reducedTypeProperty);
|
|
76
77
|
}
|
|
77
78
|
const reducedType = {
|
|
79
|
+
typePath: typeWithProperties.typePath,
|
|
78
80
|
slug: typeWithProperties.slug,
|
|
79
81
|
label: typeWithProperties.label,
|
|
80
|
-
typePath: typeWithProperties.typePath,
|
|
81
82
|
isArchived: typeWithProperties.isArchived,
|
|
82
83
|
typeProperties: reducedTypeProperties,
|
|
83
84
|
};
|
|
84
85
|
reducedTypes.push(reducedType);
|
|
85
86
|
}
|
|
87
|
+
reducedTypes = reducedTypes.sort((one, two) => (one.typePath < two.typePath ? -1 : 1));
|
|
86
88
|
const typesHolder = {
|
|
87
89
|
types: reducedTypes,
|
|
88
90
|
};
|
package/package.json
CHANGED
|
@@ -95,7 +95,7 @@ export class ActionsDeployer {
|
|
|
95
95
|
object: updates,
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
console.log(`%s Updated
|
|
98
|
+
console.log(`%s Updated existing action definition: ${actionDefinition.identifier}`, chalk.yellow.bold('APP'));
|
|
99
99
|
|
|
100
100
|
return actionDefinition;
|
|
101
101
|
}
|
|
@@ -34,11 +34,11 @@ async function getOptionSets() {
|
|
|
34
34
|
entityName: 'type-property-option-set',
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
let reducedOptionSets = [];
|
|
38
38
|
for (const optionSet of optionSets) {
|
|
39
39
|
const reducedOptionSet: ReducedOptionSet = {
|
|
40
|
-
id: optionSet.id,
|
|
41
40
|
name: optionSet.name,
|
|
41
|
+
id: optionSet.id,
|
|
42
42
|
isArchived: optionSet.isArchived,
|
|
43
43
|
optionSet: optionSet.optionSet,
|
|
44
44
|
};
|
|
@@ -50,6 +50,8 @@ async function getOptionSets() {
|
|
|
50
50
|
optionSets: reducedOptionSets,
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
reducedOptionSets = reducedOptionSets.sort((one, two) => (one.name < two.name ? -1 : 1));
|
|
54
|
+
|
|
53
55
|
const CURRENT_DIR = process.cwd();
|
|
54
56
|
const separator = getSeparatorByPlatform();
|
|
55
57
|
|
|
@@ -64,7 +66,7 @@ async function getReducedTypes() {
|
|
|
64
66
|
|
|
65
67
|
console.log('Found types: ', types.length);
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
let reducedTypes = [];
|
|
68
70
|
for (const type of types) {
|
|
69
71
|
const typeWithProperties = await new Entities().get({
|
|
70
72
|
entityName: 'type',
|
|
@@ -75,10 +77,10 @@ async function getReducedTypes() {
|
|
|
75
77
|
const reducedTypeProperties = [];
|
|
76
78
|
for (const typeProperty of typeWithProperties.typeProperties) {
|
|
77
79
|
const reducedTypeProperty: ReducedTypeProperties = {
|
|
80
|
+
slug: typeProperty.slug,
|
|
78
81
|
id: typeProperty.id,
|
|
79
82
|
isArchived: typeProperty.isArchived,
|
|
80
83
|
propertyType: typeProperty.propertyType,
|
|
81
|
-
slug: typeProperty.slug,
|
|
82
84
|
label: typeProperty.label,
|
|
83
85
|
editable: typeProperty.editable,
|
|
84
86
|
core: typeProperty.core,
|
|
@@ -94,9 +96,9 @@ async function getReducedTypes() {
|
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
const reducedType: ReducedType = {
|
|
99
|
+
typePath: typeWithProperties.typePath,
|
|
97
100
|
slug: typeWithProperties.slug,
|
|
98
101
|
label: typeWithProperties.label,
|
|
99
|
-
typePath: typeWithProperties.typePath,
|
|
100
102
|
isArchived: typeWithProperties.isArchived,
|
|
101
103
|
typeProperties: reducedTypeProperties,
|
|
102
104
|
};
|
|
@@ -104,6 +106,8 @@ async function getReducedTypes() {
|
|
|
104
106
|
reducedTypes.push(reducedType);
|
|
105
107
|
}
|
|
106
108
|
|
|
109
|
+
reducedTypes = reducedTypes.sort((one, two) => (one.typePath < two.typePath ? -1 : 1));
|
|
110
|
+
|
|
107
111
|
const typesHolder = {
|
|
108
112
|
types: reducedTypes,
|
|
109
113
|
};
|
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
console.log('
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
export { } // Leave empty export - This allows for multiple files with a function named execute.
|
|
2
|
+
async function execute(config, event, Functions) {
|
|
3
|
+
const getBodyFromEvent = (config, event) => {
|
|
4
|
+
let body = Functions.stringUtil.parseVariables(config.message, event);
|
|
5
|
+
console.log('body: ', body);
|
|
6
|
+
if (config.sendDetails) {
|
|
7
|
+
const data = event;
|
|
8
|
+
const properties = {};
|
|
9
|
+
let addedProperty = false;
|
|
10
|
+
for (const property of config.fieldsToForward) {
|
|
11
|
+
const variableLevels = property.split('.');
|
|
12
|
+
let replacementValue = data;
|
|
13
|
+
for (let i = 0; i < variableLevels.length; i++) {
|
|
14
|
+
replacementValue = replacementValue[variableLevels[i]];
|
|
15
|
+
}
|
|
16
|
+
properties[property] = replacementValue;
|
|
17
|
+
addedProperty = true;
|
|
18
|
+
}
|
|
19
|
+
if (addedProperty) {
|
|
20
|
+
body = body + ' Properties: ' + JSON.stringify(properties) + '.';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return JSON.stringify({ text: body });
|
|
24
|
+
};
|
|
25
|
+
const body = getBodyFromEvent(config, event);
|
|
26
|
+
console.log('Sending message: ', body);
|
|
27
|
+
const response = await Functions.fetch(config.url, {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
body: body,
|
|
30
|
+
headers: { 'Content-Type': 'application/json' }
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
console.log('Webhook event failed to publish');
|
|
34
|
+
console.log('Response: ', JSON.stringify(response));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.log('Published!');
|
|
38
|
+
}
|
|
38
39
|
}
|