@contrail/cli 2.1.20 → 2.1.22
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/README.md +311 -105
- package/dist/api/apps.js +15 -15
- package/dist/api/event-workflow-action-definition.d.ts +1 -1
- package/dist/api/event-workflow-action-definition.js +1 -1
- package/dist/api/event-workflow-template-definition.d.ts +4 -3
- package/dist/api/event-workflow-templates.d.ts +5 -4
- package/dist/api/event-workflow-templates.js +2 -2
- package/dist/api/types.d.ts +10 -10
- package/dist/api/users.js +4 -2
- package/dist/auth/login.js +12 -14
- package/dist/commands/app/create.d.ts +2 -2
- package/dist/commands/app/create.js +15 -10
- package/dist/commands/app/delete.d.ts +2 -2
- package/dist/commands/app/delete.js +4 -2
- package/dist/commands/app/getApiKey.d.ts +2 -2
- package/dist/commands/app/getApiKey.js +17 -11
- package/dist/commands/app/install.d.ts +2 -2
- package/dist/commands/app/install.js +42 -25
- package/dist/commands/app/publish.d.ts +2 -2
- package/dist/commands/app/publish.js +26 -11
- package/dist/commands/app/uninstall.d.ts +2 -2
- package/dist/commands/app/uninstall.js +20 -11
- package/dist/commands/app/upgrade.d.ts +2 -2
- package/dist/commands/app/upgrade.js +46 -23
- package/dist/commands/basecommand.d.ts +7 -0
- package/dist/commands/basecommand.js +29 -0
- package/dist/commands/colors/deleteAll.d.ts +2 -2
- package/dist/commands/colors/deleteAll.js +8 -5
- package/dist/commands/colors/load.d.ts +2 -2
- package/dist/commands/colors/load.js +10 -7
- package/dist/commands/config/list.d.ts +2 -2
- package/dist/commands/config/list.js +4 -2
- package/dist/commands/config/remove.d.ts +2 -2
- package/dist/commands/config/remove.js +4 -2
- package/dist/commands/config/set.d.ts +3 -2
- package/dist/commands/config/set.js +21 -7
- package/dist/commands/groups/export.d.ts +2 -2
- package/dist/commands/groups/export.js +20 -8
- package/dist/commands/groups/upload.d.ts +3 -3
- package/dist/commands/groups/upload.js +44 -32
- package/dist/commands/instance/export.d.ts +2 -2
- package/dist/commands/instance/export.js +15 -3
- package/dist/commands/instance/import.d.ts +2 -2
- package/dist/commands/instance/import.js +9 -2
- package/dist/commands/loader-process/load.d.ts +2 -2
- package/dist/commands/loader-process/load.js +13 -6
- package/dist/commands/loader-process/upload-and-load.d.ts +2 -2
- package/dist/commands/loader-process/upload-and-load.js +18 -7
- package/dist/commands/projects/export.d.ts +2 -2
- package/dist/commands/projects/export.js +4 -2
- package/dist/commands/projects/list.d.ts +2 -2
- package/dist/commands/projects/list.js +6 -4
- package/dist/commands/projects/load.d.ts +2 -2
- package/dist/commands/projects/load.js +16 -8
- package/dist/commands/types/exportOptionSetHierarchies.d.ts +2 -2
- package/dist/commands/types/exportOptionSetHierarchies.js +15 -12
- package/dist/commands/types/getAll.d.ts +2 -2
- package/dist/commands/types/getAll.js +107 -76
- package/dist/commands/types/loadAll.d.ts +2 -2
- package/dist/commands/types/loadAll.js +12 -4
- package/dist/commands/types/mergeOptionSets.d.ts +2 -2
- package/dist/commands/types/mergeOptionSets.js +13 -10
- package/dist/commands/types/mergeTypeProperties.d.ts +2 -2
- package/dist/commands/types/mergeTypeProperties.js +12 -9
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.d.ts +2 -2
- package/dist/commands/types/parseOptionSetsHierarchyLocalFile.js +19 -15
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.d.ts +10 -0
- package/dist/commands/types/parseOptionSetsHierarchyValuesToKeysLocalFile.js +102 -0
- package/dist/commands/types/parseOptionSetsLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseOptionSetsLocalFiles.js +21 -21
- package/dist/commands/types/parseOptionSetsToFolderStructure.d.ts +2 -2
- package/dist/commands/types/parseOptionSetsToFolderStructure.js +17 -18
- package/dist/commands/types/parseTypesFromFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromFiles.js +14 -8
- package/dist/commands/types/parseTypesFromLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromLocalFiles.js +10 -7
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromTemplateAndDataFromLocalFiles.js +11 -8
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.d.ts +2 -2
- package/dist/commands/types/parseTypesFromTemplateFromLocalFiles.js +11 -8
- package/dist/commands/types/uploadOptionSetHierarchies.d.ts +2 -2
- package/dist/commands/types/uploadOptionSetHierarchies.js +44 -32
- package/dist/commands/types/uploadOptionSets.d.ts +2 -2
- package/dist/commands/types/uploadOptionSets.js +21 -13
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.d.ts +2 -2
- package/dist/commands/types/uploadOptionSetsHierarchyLocalFile.js +26 -19
- package/dist/commands/types/uploadRuleSets.d.ts +2 -2
- package/dist/commands/types/uploadRuleSets.js +34 -26
- package/dist/commands/types/uploadTypePolicies.d.ts +2 -2
- package/dist/commands/types/uploadTypePolicies.js +37 -29
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +2 -2
- package/dist/commands/types/uploadTypePropertyPolicies.js +38 -30
- package/dist/commands/types/uploadTypes.d.ts +2 -2
- package/dist/commands/types/uploadTypes.js +10 -4
- package/dist/commands/types/uploadUsageInfo.d.ts +2 -2
- package/dist/commands/types/uploadUsageInfo.js +32 -24
- package/dist/commands/users/export.d.ts +2 -2
- package/dist/commands/users/export.js +15 -4
- package/dist/commands/users/upload.d.ts +2 -2
- package/dist/commands/users/upload.js +6 -4
- package/dist/commands/webhooks/create.d.ts +2 -2
- package/dist/commands/webhooks/create.js +8 -6
- package/dist/commands/webhooks/delete.d.ts +2 -2
- package/dist/commands/webhooks/delete.js +8 -5
- package/dist/commands/webhooks/getWebhookTrigger.d.ts +2 -2
- package/dist/commands/webhooks/getWebhookTrigger.js +10 -9
- package/dist/commands/webhooks/list.d.ts +2 -2
- package/dist/commands/webhooks/list.js +8 -6
- package/dist/commands/workflow-template-definitions/install.d.ts +2 -2
- package/dist/commands/workflow-template-definitions/install.js +4 -2
- package/dist/commands/workflow-template-definitions/list.d.ts +2 -2
- package/dist/commands/workflow-template-definitions/list.js +4 -2
- package/dist/commands/workflow-templates/delete.d.ts +2 -2
- package/dist/commands/workflow-templates/delete.js +4 -2
- package/dist/commands/workflow-templates/export.d.ts +2 -2
- package/dist/commands/workflow-templates/export.js +19 -17
- package/dist/commands/workflow-templates/list.d.ts +2 -2
- package/dist/commands/workflow-templates/list.js +4 -2
- package/dist/commands/workflow-templates/load.d.ts +2 -2
- package/dist/commands/workflow-templates/load.js +8 -3
- package/dist/common.d.ts +4 -1
- package/dist/common.js +10 -1
- package/dist/helpers/app/actions-deployer.d.ts +2 -2
- package/dist/helpers/app/actions-deployer.js +12 -7
- package/dist/helpers/app/app-deployer.d.ts +1 -1
- package/dist/helpers/app/app-deployer.js +70 -52
- package/dist/helpers/app/app-template-parsers.js +3 -1
- package/dist/helpers/app/load-app-config.d.ts +2 -1
- package/dist/helpers/app/load-app-config.js +2 -2
- package/dist/helpers/app/setup-template.js +4 -3
- package/dist/helpers/colors/helpers.d.ts +10 -2
- package/dist/helpers/colors/helpers.js +11 -10
- package/dist/helpers/config/config.js +15 -10
- package/dist/helpers/file-helpers.js +7 -4
- package/dist/helpers/loader-process/helpers.js +14 -13
- package/dist/helpers/projects/helpers.d.ts +2 -1
- package/dist/helpers/projects/helpers.js +16 -15
- package/dist/helpers/types/csv-parser.js +17 -14
- package/dist/helpers/types/type-extractor.d.ts +1 -1
- package/dist/helpers/types/type-extractor.js +3 -2
- package/dist/helpers/types/type-parser.js +22 -21
- package/dist/helpers/types/type-uploader.js +19 -15
- package/dist/helpers/workflow-template-definitions/workflow-template-definition-deployer.d.ts +1 -1
- package/dist/helpers/workflow-template-definitions/workflow-template-definition-deployer.js +47 -28
- package/dist/helpers/workflow-templates/helper.d.ts +3 -3
- package/dist/helpers/workflow-templates/helper.js +33 -23
- package/dist/interface-converters.spec.js +15 -15
- package/dist/interfaces.d.ts +6 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.js +32 -0
- package/dist/templates/typescript/src/actions/logItem.ts +9 -4
- package/dist/templates/typescript/src/main.ts +13 -8
- package/oclif.manifest.json +861 -31
- package/package.json +10 -7
|
@@ -11,10 +11,14 @@ const type_extractor_1 = require("../../helpers/types/type-extractor");
|
|
|
11
11
|
const types_1 = require("../../api/types");
|
|
12
12
|
const file_helpers_1 = require("../../helpers/file-helpers");
|
|
13
13
|
const users_1 = require("../../api/users");
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const basecommand_1 = require("../basecommand");
|
|
15
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
16
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
17
|
+
const common_1 = require("../../common");
|
|
18
|
+
class GetAllTypes extends basecommand_1.BaseCommand {
|
|
16
19
|
async run() {
|
|
17
20
|
const { flags } = await this.parse(GetAllTypes);
|
|
21
|
+
await super.setLogLevel(flags.logLevel);
|
|
18
22
|
await getAll(flags.outDir, flags.overwrite);
|
|
19
23
|
}
|
|
20
24
|
}
|
|
@@ -25,13 +29,23 @@ GetAllTypes.examples = [
|
|
|
25
29
|
`,
|
|
26
30
|
];
|
|
27
31
|
GetAllTypes.flags = {
|
|
28
|
-
outDir: core_1.Flags.string({
|
|
29
|
-
|
|
32
|
+
outDir: core_1.Flags.string({
|
|
33
|
+
char: 'd',
|
|
34
|
+
description: 'The directory to which to export the type data. Defaults to the current directory',
|
|
35
|
+
required: false,
|
|
36
|
+
default: '.',
|
|
37
|
+
}),
|
|
38
|
+
overwrite: core_1.Flags.boolean({
|
|
39
|
+
char: 'f',
|
|
40
|
+
description: 'Replaces any existing export files in outDir',
|
|
41
|
+
required: false,
|
|
42
|
+
default: false,
|
|
43
|
+
}),
|
|
30
44
|
};
|
|
31
45
|
async function getAll(outDir, overwrite) {
|
|
32
46
|
try {
|
|
33
47
|
const userConfig = await (0, login_1.authUser)();
|
|
34
|
-
|
|
48
|
+
logger_1.default.info(`%s Getting all types for orgId: ${userConfig.orgId}`, chalk_1.default.blue.bold('START'));
|
|
35
49
|
// make directory to house exports
|
|
36
50
|
if (!fs_1.default.existsSync(path.resolve(outDir))) {
|
|
37
51
|
fs_1.default.mkdirSync(path.resolve(outDir));
|
|
@@ -51,13 +65,13 @@ async function getAll(outDir, overwrite) {
|
|
|
51
65
|
};
|
|
52
66
|
const reducedData = await reduceData(data);
|
|
53
67
|
await saveData(reducedData, outDir, overwrite);
|
|
54
|
-
|
|
68
|
+
logger_1.default.info('%s Retrieved', chalk_1.default.yellow.bold('TYPES'));
|
|
55
69
|
}
|
|
56
70
|
catch (e) {
|
|
57
|
-
|
|
71
|
+
logger_1.default.info(`%s Types Retrieval Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
|
|
58
72
|
return;
|
|
59
73
|
}
|
|
60
|
-
|
|
74
|
+
logger_1.default.info('%s Types Retrieval Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
61
75
|
}
|
|
62
76
|
exports.getAll = getAll;
|
|
63
77
|
async function reduceTypePropertyPolicies(data) {
|
|
@@ -74,36 +88,36 @@ async function reduceTypePropertyPolicies(data) {
|
|
|
74
88
|
return statement;
|
|
75
89
|
}
|
|
76
90
|
if (type === 'group') {
|
|
77
|
-
const groupName = (_a = groups.find(x => x.id === id)) === null || _a === void 0 ? void 0 : _a.name;
|
|
91
|
+
const groupName = (_a = groups.find((x) => x.id === id)) === null || _a === void 0 ? void 0 : _a.name;
|
|
78
92
|
if (!groupName) {
|
|
79
|
-
|
|
93
|
+
logger_1.default.info(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
80
94
|
return statement;
|
|
81
95
|
}
|
|
82
96
|
statement.principal = `group:${groupName}`;
|
|
83
97
|
}
|
|
84
98
|
else if (type === 'user') {
|
|
85
|
-
const userEmail = (_b = orgUsers.find(x => x.user.id === id)) === null || _b === void 0 ? void 0 : _b.email;
|
|
99
|
+
const userEmail = (_b = orgUsers.find((x) => x.user.id === id)) === null || _b === void 0 ? void 0 : _b.email;
|
|
86
100
|
if (!userEmail) {
|
|
87
|
-
|
|
101
|
+
logger_1.default.info(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
88
102
|
return statement;
|
|
89
103
|
}
|
|
90
104
|
statement.principal = `user:${userEmail}`;
|
|
91
105
|
}
|
|
92
106
|
return statement;
|
|
93
107
|
}
|
|
94
|
-
return (_a = data === null || data === void 0 ? void 0 : data.typePropertyPolicies) === null || _a === void 0 ? void 0 : _a.map(x => {
|
|
108
|
+
return (_a = data === null || data === void 0 ? void 0 : data.typePropertyPolicies) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
95
109
|
return {
|
|
96
110
|
label: x.label,
|
|
97
111
|
policy: {
|
|
98
112
|
version: x.policy.version,
|
|
99
|
-
statements: x.policy.statements.map(x => reducePrincipal(x)),
|
|
100
|
-
}
|
|
113
|
+
statements: x.policy.statements.map((x) => reducePrincipal(x)),
|
|
114
|
+
},
|
|
101
115
|
};
|
|
102
116
|
}).sort((one, two) => (one.label < two.label ? -1 : 1));
|
|
103
117
|
}
|
|
104
118
|
function reduceTypePropertyPolicyLinks(data) {
|
|
105
119
|
var _a, _b;
|
|
106
|
-
const typeProperties = (_a = data === null || data === void 0 ? void 0 : data.types) === null || _a === void 0 ? void 0 : _a.map(x => x.typeProperties).reduce((x, y) => x.concat(y));
|
|
120
|
+
const typeProperties = (_a = data === null || data === void 0 ? void 0 : data.types) === null || _a === void 0 ? void 0 : _a.map((x) => x.typeProperties).reduce((x, y) => x.concat(y));
|
|
107
121
|
// make a map of all type properties to their type ids
|
|
108
122
|
const typePropertyIdToTypeSlugMap = data.types.reduce((map, obj) => {
|
|
109
123
|
for (const tp of obj.typeProperties) {
|
|
@@ -111,15 +125,13 @@ function reduceTypePropertyPolicyLinks(data) {
|
|
|
111
125
|
}
|
|
112
126
|
return map;
|
|
113
127
|
}, {});
|
|
114
|
-
return (_b = data === null || data === void 0 ? void 0 : data.typePropertyPolicyLinks) === null || _b === void 0 ? void 0 : _b.map(x => {
|
|
128
|
+
return (_b = data === null || data === void 0 ? void 0 : data.typePropertyPolicyLinks) === null || _b === void 0 ? void 0 : _b.map((x) => {
|
|
115
129
|
var _a, _b;
|
|
116
130
|
const typeSlug = typePropertyIdToTypeSlugMap[x.typePropertyId];
|
|
117
|
-
const typePropertySlug = (_a = typeProperties.find(y => y.id === x.typePropertyId)) === null || _a === void 0 ? void 0 : _a.slug;
|
|
118
|
-
const typePropertyPolicyLabel = (_b = data.typePropertyPolicies.find(y => y.id === x.typePropertyPolicyId)) === null || _b === void 0 ? void 0 : _b.label;
|
|
119
|
-
if (!typeSlug ||
|
|
120
|
-
|
|
121
|
-
!typePropertyPolicyLabel) {
|
|
122
|
-
console.warn('Could not reduce bad type property policy link... skipping', x);
|
|
131
|
+
const typePropertySlug = (_a = typeProperties.find((y) => y.id === x.typePropertyId)) === null || _a === void 0 ? void 0 : _a.slug;
|
|
132
|
+
const typePropertyPolicyLabel = (_b = data.typePropertyPolicies.find((y) => y.id === x.typePropertyPolicyId)) === null || _b === void 0 ? void 0 : _b.label;
|
|
133
|
+
if (!typeSlug || !typePropertySlug || !typePropertyPolicyLabel) {
|
|
134
|
+
logger_1.default.warn('Could not reduce bad type property policy link... skipping', x);
|
|
123
135
|
return null;
|
|
124
136
|
}
|
|
125
137
|
return {
|
|
@@ -127,7 +139,7 @@ function reduceTypePropertyPolicyLinks(data) {
|
|
|
127
139
|
typePropertySlug,
|
|
128
140
|
typePropertyPolicyLabel,
|
|
129
141
|
};
|
|
130
|
-
}).filter(x => !!x);
|
|
142
|
+
}).filter((x) => !!x);
|
|
131
143
|
}
|
|
132
144
|
async function reduceTypePolicies(data) {
|
|
133
145
|
var _a;
|
|
@@ -143,48 +155,48 @@ async function reduceTypePolicies(data) {
|
|
|
143
155
|
return statement;
|
|
144
156
|
}
|
|
145
157
|
if (type === 'group') {
|
|
146
|
-
const groupName = (_a = groups.find(x => x.id === id)) === null || _a === void 0 ? void 0 : _a.name;
|
|
158
|
+
const groupName = (_a = groups.find((x) => x.id === id)) === null || _a === void 0 ? void 0 : _a.name;
|
|
147
159
|
if (!groupName) {
|
|
148
|
-
|
|
160
|
+
logger_1.default.info(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
149
161
|
return statement;
|
|
150
162
|
}
|
|
151
163
|
statement.principal = `group:${groupName}`;
|
|
152
164
|
}
|
|
153
165
|
else if (type === 'user') {
|
|
154
|
-
const userEmail = (_b = orgUsers.find(x => x.user.id === id)) === null || _b === void 0 ? void 0 : _b.email;
|
|
166
|
+
const userEmail = (_b = orgUsers.find((x) => x.user.id === id)) === null || _b === void 0 ? void 0 : _b.email;
|
|
155
167
|
if (!userEmail) {
|
|
156
|
-
|
|
168
|
+
logger_1.default.info(`Could not find group for statement. skipping invalid policy conversion ${id}`);
|
|
157
169
|
return statement;
|
|
158
170
|
}
|
|
159
171
|
statement.principal = `user:${userEmail}`;
|
|
160
172
|
}
|
|
161
173
|
return statement;
|
|
162
174
|
}
|
|
163
|
-
return (_a = data === null || data === void 0 ? void 0 : data.typePolicies) === null || _a === void 0 ? void 0 : _a.map(x => {
|
|
175
|
+
return (_a = data === null || data === void 0 ? void 0 : data.typePolicies) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
164
176
|
return {
|
|
165
177
|
label: x.label,
|
|
166
178
|
policy: {
|
|
167
179
|
version: x.policy.version,
|
|
168
|
-
statements: x.policy.statements.map(x => reducePrincipal(x)),
|
|
169
|
-
}
|
|
180
|
+
statements: x.policy.statements.map((x) => reducePrincipal(x)),
|
|
181
|
+
},
|
|
170
182
|
};
|
|
171
183
|
}).sort((one, two) => (one.label < two.label ? -1 : 1));
|
|
172
184
|
}
|
|
173
185
|
function reduceTypePolicyLinks(data) {
|
|
174
186
|
var _a;
|
|
175
187
|
const types = data === null || data === void 0 ? void 0 : data.types;
|
|
176
|
-
return (_a = data === null || data === void 0 ? void 0 : data.typePolicyLinks) === null || _a === void 0 ? void 0 : _a.map(x => {
|
|
188
|
+
return (_a = data === null || data === void 0 ? void 0 : data.typePolicyLinks) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
177
189
|
var _a, _b;
|
|
178
190
|
return {
|
|
179
|
-
typeSlug: (_a = types.find(y => y.id === x.typeId)) === null || _a === void 0 ? void 0 : _a.slug,
|
|
180
|
-
typePolicyLabel: (_b = data.typePolicies.find(y => y.id === x.typePolicyId)) === null || _b === void 0 ? void 0 : _b.label,
|
|
191
|
+
typeSlug: (_a = types.find((y) => y.id === x.typeId)) === null || _a === void 0 ? void 0 : _a.slug,
|
|
192
|
+
typePolicyLabel: (_b = data.typePolicies.find((y) => y.id === x.typePolicyId)) === null || _b === void 0 ? void 0 : _b.label,
|
|
181
193
|
};
|
|
182
194
|
});
|
|
183
195
|
}
|
|
184
196
|
function reduceUsageInfo(data) {
|
|
185
197
|
var _a, _b;
|
|
186
|
-
const typeProperties = (_a = data === null || data === void 0 ? void 0 : data.types) === null || _a === void 0 ? void 0 : _a.map(x => x.typeProperties).reduce((x, y) => x.concat(y));
|
|
187
|
-
return (_b = data === null || data === void 0 ? void 0 : data.usageInfo) === null || _b === void 0 ? void 0 : _b.map(x => {
|
|
198
|
+
const typeProperties = (_a = data === null || data === void 0 ? void 0 : data.types) === null || _a === void 0 ? void 0 : _a.map((x) => x.typeProperties).reduce((x, y) => x.concat(y));
|
|
199
|
+
return (_b = data === null || data === void 0 ? void 0 : data.usageInfo) === null || _b === void 0 ? void 0 : _b.map((x) => {
|
|
188
200
|
var _a, _b;
|
|
189
201
|
return {
|
|
190
202
|
used: x.used,
|
|
@@ -194,8 +206,8 @@ function reduceUsageInfo(data) {
|
|
|
194
206
|
numberFormat: x.numberFormat,
|
|
195
207
|
defaultValue: x.defaultValue,
|
|
196
208
|
label: x.label,
|
|
197
|
-
typeSlug: (_a = data.types.find(y => y.id === x.typeId)) === null || _a === void 0 ? void 0 : _a.slug,
|
|
198
|
-
typePropertySlug: (_b = typeProperties.find(y => y.id === x.typePropertyId)) === null || _b === void 0 ? void 0 : _b.slug,
|
|
209
|
+
typeSlug: (_a = data.types.find((y) => y.id === x.typeId)) === null || _a === void 0 ? void 0 : _a.slug,
|
|
210
|
+
typePropertySlug: (_b = typeProperties.find((y) => y.id === x.typePropertyId)) === null || _b === void 0 ? void 0 : _b.slug,
|
|
199
211
|
};
|
|
200
212
|
}).sort((one, two) => (one.label < two.label ? -1 : 1));
|
|
201
213
|
}
|
|
@@ -206,14 +218,14 @@ function reduceRuleSetLinks(data) {
|
|
|
206
218
|
return [];
|
|
207
219
|
}
|
|
208
220
|
for (const ruleSetLink of data.ruleSetLinks) {
|
|
209
|
-
const ruleSet = (_a = data === null || data === void 0 ? void 0 : data.ruleSets) === null || _a === void 0 ? void 0 : _a.find(x => x.id === ruleSetLink.typeRuleSetId);
|
|
210
|
-
const type = (_b = data === null || data === void 0 ? void 0 : data.types) === null || _b === void 0 ? void 0 : _b.find(x => x.id === ruleSetLink.typeId);
|
|
221
|
+
const ruleSet = (_a = data === null || data === void 0 ? void 0 : data.ruleSets) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === ruleSetLink.typeRuleSetId);
|
|
222
|
+
const type = (_b = data === null || data === void 0 ? void 0 : data.types) === null || _b === void 0 ? void 0 : _b.find((x) => x.id === ruleSetLink.typeId);
|
|
211
223
|
if (!ruleSet || !type) {
|
|
212
|
-
|
|
224
|
+
logger_1.default.info('%s Skipping bad rule set link', ruleSetLink.id, chalk_1.default.red.bold('TYPES'));
|
|
213
225
|
}
|
|
214
226
|
reducedRuleSetLinks.push({
|
|
215
227
|
ruleSet: ruleSet.name,
|
|
216
|
-
type: type.slug
|
|
228
|
+
type: type.slug,
|
|
217
229
|
});
|
|
218
230
|
}
|
|
219
231
|
return reducedRuleSetLinks.sort((one, two) => {
|
|
@@ -225,7 +237,7 @@ function reduceRuleSetLinks(data) {
|
|
|
225
237
|
}
|
|
226
238
|
function reduceRuleSets(data) {
|
|
227
239
|
var _a;
|
|
228
|
-
return (_a = data === null || data === void 0 ? void 0 : data.ruleSets) === null || _a === void 0 ? void 0 : _a.map(x => {
|
|
240
|
+
return (_a = data === null || data === void 0 ? void 0 : data.ruleSets) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
229
241
|
return {
|
|
230
242
|
ruleSet: x.ruleSet,
|
|
231
243
|
name: x.name,
|
|
@@ -234,7 +246,7 @@ function reduceRuleSets(data) {
|
|
|
234
246
|
}
|
|
235
247
|
function reduceOptionSets(data) {
|
|
236
248
|
var _a;
|
|
237
|
-
return (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.map(optionSet => {
|
|
249
|
+
return (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.map((optionSet) => {
|
|
238
250
|
return {
|
|
239
251
|
name: optionSet.name,
|
|
240
252
|
isArchived: optionSet.isArchived,
|
|
@@ -244,34 +256,34 @@ function reduceOptionSets(data) {
|
|
|
244
256
|
}
|
|
245
257
|
function reduceOptionSetHierarchies(data) {
|
|
246
258
|
var _a;
|
|
247
|
-
return (_a = data.optionSetHierarchies) === null || _a === void 0 ? void 0 : _a.map(x => {
|
|
248
|
-
const hierarchyByName = x.hierarchy.map(optionSetId => { var _a, _b; return (_b = (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.find(x => x.id === optionSetId)) === null || _b === void 0 ? void 0 : _b.name; });
|
|
259
|
+
return (_a = data.optionSetHierarchies) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
260
|
+
const hierarchyByName = x.hierarchy.map((optionSetId) => { var _a, _b; return (_b = (_a = data.optionSets) === null || _a === void 0 ? void 0 : _a.find((x) => x.id === optionSetId)) === null || _b === void 0 ? void 0 : _b.name; });
|
|
249
261
|
return {
|
|
250
262
|
hierarchy: hierarchyByName,
|
|
251
263
|
options: x.options,
|
|
252
|
-
name: x.name
|
|
264
|
+
name: x.name,
|
|
253
265
|
};
|
|
254
266
|
}).sort((one, two) => (one.name < two.name ? -1 : 1));
|
|
255
267
|
}
|
|
256
268
|
function reduceOptionSetHierarchyLinks(data) {
|
|
257
269
|
var _a;
|
|
258
|
-
return (_a = data.optionSetHierarchyLinks) === null || _a === void 0 ? void 0 : _a.map(x => {
|
|
270
|
+
return (_a = data.optionSetHierarchyLinks) === null || _a === void 0 ? void 0 : _a.map((x) => {
|
|
259
271
|
var _a;
|
|
260
|
-
const osh = data.optionSetHierarchies.find(y => y.id === x.optionSetHierarchyId);
|
|
272
|
+
const osh = data.optionSetHierarchies.find((y) => y.id === x.optionSetHierarchyId);
|
|
261
273
|
if (!osh) {
|
|
262
|
-
|
|
274
|
+
logger_1.default.info('OSH Link: could not find option set hierarchy', x.optionSetHierarchyId, 'skipping...');
|
|
263
275
|
return null;
|
|
264
276
|
}
|
|
265
|
-
const type = data.types.find(y => y.id === x.typeId);
|
|
277
|
+
const type = data.types.find((y) => y.id === x.typeId);
|
|
266
278
|
if (!type) {
|
|
267
|
-
|
|
279
|
+
logger_1.default.info('OSH Link: could not find type', x.typeId, 'skipping...');
|
|
268
280
|
return null;
|
|
269
281
|
}
|
|
270
282
|
const typePropertySlugs = [];
|
|
271
283
|
for (const tpId of x.hierarchyTypePropertyIds) {
|
|
272
|
-
const typePropertySlug = (_a = type.typeProperties.find(y => y.id === tpId)) === null || _a === void 0 ? void 0 : _a.slug;
|
|
284
|
+
const typePropertySlug = (_a = type.typeProperties.find((y) => y.id === tpId)) === null || _a === void 0 ? void 0 : _a.slug;
|
|
273
285
|
if (!typePropertySlug) {
|
|
274
|
-
|
|
286
|
+
logger_1.default.info('OSH Link: could not find type property', tpId, 'skipping...');
|
|
275
287
|
return null;
|
|
276
288
|
}
|
|
277
289
|
typePropertySlugs.push(typePropertySlug);
|
|
@@ -281,10 +293,10 @@ function reduceOptionSetHierarchyLinks(data) {
|
|
|
281
293
|
typeSlug: type.slug,
|
|
282
294
|
typePropertySlugs,
|
|
283
295
|
};
|
|
284
|
-
}).filter(x => !!x).sort((one, two) => (one.typeSlug < two.typeSlug ? -1 : 1));
|
|
296
|
+
}).filter((x) => !!x).sort((one, two) => (one.typeSlug < two.typeSlug ? -1 : 1));
|
|
285
297
|
}
|
|
286
298
|
function reduceTypes(dataHolder) {
|
|
287
|
-
|
|
299
|
+
logger_1.default.info('Found types: ', dataHolder.types.length);
|
|
288
300
|
let reducedTypes = [];
|
|
289
301
|
const optionSetNameById = {};
|
|
290
302
|
for (const optionSet of dataHolder.optionSets) {
|
|
@@ -321,12 +333,14 @@ function reduceTypes(dataHolder) {
|
|
|
321
333
|
slug: type.slug,
|
|
322
334
|
label: type.label,
|
|
323
335
|
isArchived: type.isArchived,
|
|
324
|
-
typeProperties: reducedTypeProperties
|
|
336
|
+
typeProperties: reducedTypeProperties
|
|
337
|
+
.map((x) => {
|
|
325
338
|
delete x['id'];
|
|
326
339
|
return {
|
|
327
|
-
...x
|
|
340
|
+
...x,
|
|
328
341
|
};
|
|
329
|
-
})
|
|
342
|
+
})
|
|
343
|
+
.sort((one, two) => (one.slug < two.slug ? -1 : 1)),
|
|
330
344
|
};
|
|
331
345
|
reducedTypes.push(reducedType);
|
|
332
346
|
}
|
|
@@ -355,7 +369,7 @@ const saveTypesFunction = async (data, dir, overwrite) => {
|
|
|
355
369
|
for (const type of data.reducedTypes) {
|
|
356
370
|
const typePathParts = type.typePath.split(':');
|
|
357
371
|
if (!typePathParts) {
|
|
358
|
-
|
|
372
|
+
logger_1.default.warn('skipping bad type with no path', type);
|
|
359
373
|
}
|
|
360
374
|
const root = typePathParts[0];
|
|
361
375
|
if (roots[root]) {
|
|
@@ -371,12 +385,12 @@ const saveTypesFunction = async (data, dir, overwrite) => {
|
|
|
371
385
|
if (!fs_1.default.existsSync(subDir)) {
|
|
372
386
|
fs_1.default.mkdirSync(subDir);
|
|
373
387
|
}
|
|
374
|
-
const yamlStr =
|
|
388
|
+
const yamlStr = js_yaml_1.default.dump(types);
|
|
375
389
|
const fileLabel = root;
|
|
376
390
|
if (!fileLabel) {
|
|
377
|
-
|
|
391
|
+
logger_1.default.warn('skipping bad type root:', root);
|
|
378
392
|
}
|
|
379
|
-
const pathToWrite = path.join(subDir, `${removeSlash(fileLabel)}.yml`);
|
|
393
|
+
const pathToWrite = path.join(subDir, `${(0, common_1.removeSlash)(fileLabel)}.yml`);
|
|
380
394
|
if (fs_1.default.existsSync(pathToWrite)) {
|
|
381
395
|
await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
|
|
382
396
|
}
|
|
@@ -385,15 +399,36 @@ const saveTypesFunction = async (data, dir, overwrite) => {
|
|
|
385
399
|
};
|
|
386
400
|
async function saveData(reducedData, dir, overwrite) {
|
|
387
401
|
const propertyToFolderMap = {
|
|
388
|
-
reducedTypes: {
|
|
402
|
+
reducedTypes: {
|
|
403
|
+
filename: 'types',
|
|
404
|
+
split: false,
|
|
405
|
+
fileLabel: 'slug',
|
|
406
|
+
saveFunction: saveTypesFunction,
|
|
407
|
+
},
|
|
389
408
|
reducedOptionSets: { filename: 'option-sets', split: true, fileLabel: 'name' },
|
|
390
|
-
reducedOptionSetHierarchies: {
|
|
391
|
-
|
|
409
|
+
reducedOptionSetHierarchies: {
|
|
410
|
+
filename: 'option-set-hierarchies',
|
|
411
|
+
split: true,
|
|
412
|
+
fileLabel: 'name',
|
|
413
|
+
},
|
|
414
|
+
reducedOptionSetHierarchyLinks: {
|
|
415
|
+
filename: 'type-option-set-hierarchy-links',
|
|
416
|
+
split: false,
|
|
417
|
+
fileLabel: '',
|
|
418
|
+
},
|
|
392
419
|
reducedRuleSets: { filename: 'rule-sets', split: true, fileLabel: 'name' },
|
|
393
420
|
reducedRuleSetLinks: { filename: 'rule-set-links', split: false, fileLabel: '' },
|
|
394
421
|
reducedUsageInfo: { filename: 'usage-info', split: false, fileLabel: '' },
|
|
395
|
-
reducedTypePropertyPolicies: {
|
|
396
|
-
|
|
422
|
+
reducedTypePropertyPolicies: {
|
|
423
|
+
filename: 'type-property-policies',
|
|
424
|
+
split: true,
|
|
425
|
+
fileLabel: 'label',
|
|
426
|
+
},
|
|
427
|
+
reducedTypePropertyPolicyLinks: {
|
|
428
|
+
filename: 'type-property-policy-links',
|
|
429
|
+
split: false,
|
|
430
|
+
fileLabel: '',
|
|
431
|
+
},
|
|
397
432
|
reducedTypePolicies: { filename: 'type-policies', split: true, fileLabel: 'label' },
|
|
398
433
|
reducedTypePolicyLinks: { filename: 'type-policy-links', split: false, fileLabel: '' },
|
|
399
434
|
};
|
|
@@ -408,13 +443,13 @@ async function saveData(reducedData, dir, overwrite) {
|
|
|
408
443
|
fs_1.default.mkdirSync(subDir);
|
|
409
444
|
}
|
|
410
445
|
for (const item of reducedData[key]) {
|
|
411
|
-
const yamlStr =
|
|
446
|
+
const yamlStr = js_yaml_1.default.dump(item);
|
|
412
447
|
const fileLabel = item[folder.fileLabel];
|
|
413
448
|
if (!fileLabel) {
|
|
414
|
-
|
|
449
|
+
logger_1.default.warn('skipping bad data:', item);
|
|
415
450
|
continue;
|
|
416
451
|
}
|
|
417
|
-
const pathToWrite = path.join(subDir, `${removeSlash(fileLabel)}.yml`);
|
|
452
|
+
const pathToWrite = path.join(subDir, `${(0, common_1.removeSlash)(fileLabel)}.yml`);
|
|
418
453
|
if (fs_1.default.existsSync(pathToWrite)) {
|
|
419
454
|
await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
|
|
420
455
|
}
|
|
@@ -422,7 +457,7 @@ async function saveData(reducedData, dir, overwrite) {
|
|
|
422
457
|
}
|
|
423
458
|
}
|
|
424
459
|
else {
|
|
425
|
-
const yamlStr =
|
|
460
|
+
const yamlStr = js_yaml_1.default.dump(reducedData[key]);
|
|
426
461
|
const pathToWrite = path.join(CURRENT_DIR, dir, `${folder.filename}.yml`);
|
|
427
462
|
if (fs_1.default.existsSync(pathToWrite)) {
|
|
428
463
|
await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
|
|
@@ -431,7 +466,3 @@ async function saveData(reducedData, dir, overwrite) {
|
|
|
431
466
|
}
|
|
432
467
|
}
|
|
433
468
|
}
|
|
434
|
-
function removeSlash(string) {
|
|
435
|
-
const re = /\//gi;
|
|
436
|
-
return string.replace(re, '-');
|
|
437
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class LoadAllTypes extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class LoadAllTypes extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
@@ -12,9 +12,12 @@ const uploadRuleSets_1 = require("./uploadRuleSets");
|
|
|
12
12
|
const uploadTypePropertyPolicies_1 = require("./uploadTypePropertyPolicies");
|
|
13
13
|
const type_uploader_1 = require("../../helpers/types/type-uploader");
|
|
14
14
|
const uploadTypePolicies_1 = require("./uploadTypePolicies");
|
|
15
|
-
|
|
15
|
+
const basecommand_1 = require("../basecommand");
|
|
16
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
17
|
+
class LoadAllTypes extends basecommand_1.BaseCommand {
|
|
16
18
|
async run() {
|
|
17
19
|
const { flags } = await this.parse(LoadAllTypes);
|
|
20
|
+
await super.setLogLevel(flags.logLevel);
|
|
18
21
|
await loadAll(flags.dir);
|
|
19
22
|
}
|
|
20
23
|
}
|
|
@@ -25,7 +28,12 @@ LoadAllTypes.examples = [
|
|
|
25
28
|
`,
|
|
26
29
|
];
|
|
27
30
|
LoadAllTypes.flags = {
|
|
28
|
-
dir: core_1.Flags.string({
|
|
31
|
+
dir: core_1.Flags.string({
|
|
32
|
+
char: 'd',
|
|
33
|
+
description: 'The directory from which to load the types data. Defaults to the current directory.',
|
|
34
|
+
required: false,
|
|
35
|
+
default: '.',
|
|
36
|
+
}),
|
|
29
37
|
};
|
|
30
38
|
async function loadAll(dir, skipPolicies = false) {
|
|
31
39
|
try {
|
|
@@ -41,9 +49,9 @@ async function loadAll(dir, skipPolicies = false) {
|
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
catch (e) {
|
|
44
|
-
|
|
52
|
+
logger_1.default.info(`%s Types Upload Failed. ${e}`, chalk_1.default.red.bold('FAIL'));
|
|
45
53
|
return;
|
|
46
54
|
}
|
|
47
|
-
|
|
55
|
+
logger_1.default.info('%s Types Upload Complete.', chalk_1.default.green.bold('COMPLETE'));
|
|
48
56
|
}
|
|
49
57
|
exports.loadAll = loadAll;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class MergeOptionSets extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class MergeOptionSets extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static args: {
|
|
@@ -7,10 +7,13 @@ const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
|
7
7
|
const login_1 = require("../../auth/login");
|
|
8
8
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
9
9
|
const core_1 = require("@oclif/core");
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const basecommand_1 = require("../basecommand");
|
|
11
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
12
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
13
|
+
class MergeOptionSets extends basecommand_1.BaseCommand {
|
|
12
14
|
async run() {
|
|
13
15
|
const { args, flags } = await this.parse(MergeOptionSets);
|
|
16
|
+
await super.setLogLevel(flags.logLevel);
|
|
14
17
|
try {
|
|
15
18
|
this.log('%s Importing local file', chalk_1.default.yellow.bold('OPTION SET MERGE'));
|
|
16
19
|
this.log('Using File: ', args.file);
|
|
@@ -37,7 +40,7 @@ function loadOptionSets(fileLocation) {
|
|
|
37
40
|
const TARGET_DIR = process.cwd();
|
|
38
41
|
try {
|
|
39
42
|
const fullPath = path.resolve(path.join(TARGET_DIR, fileLocation));
|
|
40
|
-
const doc =
|
|
43
|
+
const doc = js_yaml_1.default.load(fs_1.default.readFileSync(fullPath, 'utf8'));
|
|
41
44
|
return doc;
|
|
42
45
|
}
|
|
43
46
|
catch (e) {
|
|
@@ -50,7 +53,7 @@ async function mergeOptionSets(fileLocation) {
|
|
|
50
53
|
const currentOptionSetsFull = await new sdk_1.Entities().get({
|
|
51
54
|
entityName: 'type-property-option-set',
|
|
52
55
|
});
|
|
53
|
-
const currentOptionSets = currentOptionSetsFull.map(os => Object.assign({}, {
|
|
56
|
+
const currentOptionSets = currentOptionSetsFull.map((os) => Object.assign({}, {
|
|
54
57
|
name: os.name,
|
|
55
58
|
isArchived: os.isArchived,
|
|
56
59
|
optionSet: os.optionSet,
|
|
@@ -68,21 +71,21 @@ async function mergeOptionSets(fileLocation) {
|
|
|
68
71
|
const existing = currentOptionSetsByName[uploadedOptionSet.name];
|
|
69
72
|
if (!existing) {
|
|
70
73
|
if (!uploadedOptionSet.optionSet) {
|
|
71
|
-
|
|
74
|
+
logger_1.default.info('No OptionSet for: ', uploadedOptionSet.name);
|
|
72
75
|
continue;
|
|
73
76
|
}
|
|
74
|
-
|
|
77
|
+
logger_1.default.info('Adding New: ', uploadedOptionSet.name);
|
|
75
78
|
mergedOptionSets.push(uploadedOptionSet);
|
|
76
79
|
}
|
|
77
80
|
else {
|
|
78
|
-
|
|
81
|
+
logger_1.default.info('Merging: ', uploadedOptionSet.name);
|
|
79
82
|
mergedOptionSets.push(mergeOptionSet(existing, uploadedOptionSet));
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
for (const currentOptionSet of currentOptionSets) {
|
|
83
86
|
const found = uploadedOptionSetsByName[currentOptionSet.name];
|
|
84
87
|
if (!found) {
|
|
85
|
-
|
|
88
|
+
logger_1.default.info('Adding Existing: ', currentOptionSet.name);
|
|
86
89
|
mergedOptionSets.push(currentOptionSet);
|
|
87
90
|
}
|
|
88
91
|
}
|
|
@@ -99,7 +102,7 @@ function mergeOptionSet(existingOptionSet, uploadedOptionSet) {
|
|
|
99
102
|
for (const keyVal of existingOptionSet.optionSet) {
|
|
100
103
|
const value = keyVal.value;
|
|
101
104
|
const display = keyVal.display;
|
|
102
|
-
const found = merged.optionSet.find(keyVal => keyVal.value === value);
|
|
105
|
+
const found = merged.optionSet.find((keyVal) => keyVal.value === value);
|
|
103
106
|
if (!found) {
|
|
104
107
|
merged.optionSet.push({ value, display });
|
|
105
108
|
}
|
|
@@ -108,7 +111,7 @@ function mergeOptionSet(existingOptionSet, uploadedOptionSet) {
|
|
|
108
111
|
return merged;
|
|
109
112
|
}
|
|
110
113
|
function saveData(data) {
|
|
111
|
-
const yamlStr =
|
|
114
|
+
const yamlStr = js_yaml_1.default.dump(data);
|
|
112
115
|
const CURRENT_DIR = process.cwd();
|
|
113
116
|
fs_1.default.writeFileSync(path.resolve(path.join(CURRENT_DIR, 'merged_optionSets.yml')), yamlStr, 'utf8');
|
|
114
117
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class MergeTypeProperties extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class MergeTypeProperties extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static strict: boolean;
|
|
@@ -9,14 +9,17 @@ const core_1 = require("@oclif/core");
|
|
|
9
9
|
const type_extractor_1 = require("../../helpers/types/type-extractor");
|
|
10
10
|
const getAll_1 = require("./getAll");
|
|
11
11
|
const types_1 = require("../../api/types");
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const basecommand_1 = require("../basecommand");
|
|
13
|
+
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
14
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
15
|
+
class MergeTypeProperties extends basecommand_1.BaseCommand {
|
|
14
16
|
async run() {
|
|
15
|
-
const { args, argv } = await this.parse(MergeTypeProperties);
|
|
17
|
+
const { args, argv, flags } = await this.parse(MergeTypeProperties);
|
|
18
|
+
await super.setLogLevel(flags.logLevel);
|
|
16
19
|
try {
|
|
17
20
|
this.log('%s Importing local file', chalk_1.default.yellow.bold('TYPE PROPERTIES MERGE'));
|
|
18
21
|
this.log('Using File: ', args.file);
|
|
19
|
-
|
|
22
|
+
logger_1.default.info('argv:', JSON.stringify(argv));
|
|
20
23
|
const typePaths = argv.slice(1);
|
|
21
24
|
this.log('Using TypePaths: ', typePaths);
|
|
22
25
|
await mergeTypeProperties(args.file, typePaths);
|
|
@@ -45,7 +48,7 @@ function loadTypeProperties(fileLocation) {
|
|
|
45
48
|
const TARGET_DIR = process.cwd();
|
|
46
49
|
try {
|
|
47
50
|
const fullPath = path.join(TARGET_DIR, fileLocation);
|
|
48
|
-
return
|
|
51
|
+
return js_yaml_1.default.load(fs_1.default.readFileSync(fullPath, 'utf8'));
|
|
49
52
|
}
|
|
50
53
|
catch (e) {
|
|
51
54
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
@@ -69,9 +72,9 @@ async function mergeTypeProperties(fileLocation, typePaths) {
|
|
|
69
72
|
};
|
|
70
73
|
const reducedData = await (0, getAll_1.reduceData)(data);
|
|
71
74
|
for (const typePath of typePaths) {
|
|
72
|
-
const foundType = reducedData.reducedTypes.find(reducedTypes => reducedTypes.typePath === typePath);
|
|
75
|
+
const foundType = reducedData.reducedTypes.find((reducedTypes) => reducedTypes.typePath === typePath);
|
|
73
76
|
if (!foundType) {
|
|
74
|
-
|
|
77
|
+
logger_1.default.warn(`%s No Type found for: ${typePath}`, chalk_1.default.red.bold('WARNING'));
|
|
75
78
|
}
|
|
76
79
|
mergeType(foundType, uploadedTypeProperties);
|
|
77
80
|
}
|
|
@@ -79,14 +82,14 @@ async function mergeTypeProperties(fileLocation, typePaths) {
|
|
|
79
82
|
}
|
|
80
83
|
function mergeType(reducedType, typePropertiesToAdd) {
|
|
81
84
|
for (const typeProperty of typePropertiesToAdd) {
|
|
82
|
-
const found = reducedType.typeProperties.find(tp => tp.slug === typeProperty.slug);
|
|
85
|
+
const found = reducedType.typeProperties.find((tp) => tp.slug === typeProperty.slug);
|
|
83
86
|
if (!found) {
|
|
84
87
|
reducedType.typeProperties.push(typeProperty);
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
function saveData(data) {
|
|
89
|
-
const yamlStr =
|
|
92
|
+
const yamlStr = js_yaml_1.default.dump(data);
|
|
90
93
|
const CURRENT_DIR = process.cwd();
|
|
91
94
|
fs_1.default.writeFileSync(path.resolve(path.join(CURRENT_DIR, 'merged_types.yml')), yamlStr, 'utf8');
|
|
92
95
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class ParseOptionSetsHierarchyLocalFile extends
|
|
1
|
+
import { BaseCommand } from '../basecommand';
|
|
2
|
+
export default class ParseOptionSetsHierarchyLocalFile extends BaseCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static args: {
|