@contrail/cli 3.5.2 → 3.5.3-alpha.0dcc977
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 +50 -25
- package/dist/api/org-config.d.ts +3 -0
- package/dist/api/org-config.js +26 -0
- package/dist/api/types.d.ts +0 -5
- package/dist/api/types.js +1 -36
- package/dist/commands/groups/export.js +1 -13
- package/dist/commands/instance/export.js +2 -0
- package/dist/commands/instance/import.js +2 -0
- package/dist/commands/org-config/export.d.ts +13 -0
- package/dist/commands/org-config/export.js +71 -0
- package/dist/commands/org-config/import.d.ts +12 -0
- package/dist/commands/org-config/import.js +70 -0
- package/dist/commands/types/getAll.js +0 -18
- package/dist/commands/types/loadAll.js +0 -2
- package/dist/commands/types/mergeTypeProperties.js +0 -5
- package/dist/commands/types/uploadOptionSetHierarchies.js +0 -117
- package/dist/commands/types/uploadOptionSets.js +1 -1
- package/dist/commands/types/uploadRuleSets.js +2 -85
- package/dist/commands/types/uploadTypeOverrides.js +10 -2
- package/dist/commands/types/uploadTypePolicies.js +2 -86
- package/dist/commands/types/uploadTypePropertyPolicies.d.ts +0 -1
- package/dist/commands/types/uploadTypePropertyPolicies.js +3 -139
- package/dist/commands/users/export.js +1 -13
- package/dist/helpers/file-helpers.d.ts +1 -0
- package/dist/helpers/file-helpers.js +15 -1
- package/dist/helpers/types/type-uploader.js +1 -1
- package/dist/interfaces.d.ts +0 -25
- package/dist/templates/typescript/tsup.config.ts +0 -0
- package/node_modules/@contrail/org-config-migration/.github/workflows/publish-to-npm.yml +117 -0
- package/node_modules/@contrail/org-config-migration/.husky/pre-commit +0 -0
- package/node_modules/@contrail/org-config-migration/lib/index.d.ts +3 -3
- package/node_modules/@contrail/org-config-migration/lib/index.js +19 -19
- package/node_modules/@contrail/org-config-migration/lib/interfaces.d.ts +87 -97
- package/node_modules/@contrail/org-config-migration/lib/interfaces.js +2 -2
- package/node_modules/@contrail/org-config-migration/lib/services/index.d.ts +1 -1
- package/node_modules/@contrail/org-config-migration/lib/services/index.js +17 -17
- package/node_modules/@contrail/org-config-migration/lib/services/types.d.ts +12 -17
- package/node_modules/@contrail/org-config-migration/lib/services/types.js +115 -155
- package/node_modules/@contrail/org-config-migration/lib/types/exportAll.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportAll.js +34 -40
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSet.js +20 -20
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportOptionSetHierarchies.js +16 -47
- package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportOverrides.js +8 -8
- package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportRuleSets.js +14 -39
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePolicies.js +44 -56
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.d.ts +2 -3
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypePropertyPolicies.js +44 -71
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportTypes.js +85 -85
- package/node_modules/@contrail/org-config-migration/lib/types/importAll.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/types/importAll.js +386 -451
- package/node_modules/@contrail/org-config-migration/lib/types/index.d.ts +8 -9
- package/node_modules/@contrail/org-config-migration/lib/types/index.js +24 -25
- package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.d.ts +3 -3
- package/node_modules/@contrail/org-config-migration/lib/types/parseOptionSetHierarchy.js +210 -210
- package/node_modules/@contrail/org-config-migration/lib/users/export.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/export.js +40 -40
- package/node_modules/@contrail/org-config-migration/lib/users/import.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/import.js +41 -41
- package/node_modules/@contrail/org-config-migration/lib/users/index.d.ts +2 -2
- package/node_modules/@contrail/org-config-migration/lib/users/index.js +18 -18
- package/node_modules/@contrail/org-config-migration/package.json +1 -1
- package/oclif.manifest.json +111 -52
- package/package.json +2 -2
- package/dist/commands/types/uploadUsageInfo.d.ts +0 -15
- package/dist/commands/types/uploadUsageInfo.js +0 -180
- package/dist/commands/types/uploadUsageInfo.spec.d.ts +0 -1
- package/dist/commands/types/uploadUsageInfo.spec.js +0 -249
- package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.d.ts +0 -2
- package/node_modules/@contrail/org-config-migration/lib/types/exportUsageInfo.js +0 -39
|
@@ -8,7 +8,6 @@ const path = tslib_1.__importStar(require("path"));
|
|
|
8
8
|
const login_1 = require("../../auth/login");
|
|
9
9
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
10
10
|
const core_1 = require("@oclif/core");
|
|
11
|
-
const type_extractor_1 = require("../../helpers/types/type-extractor");
|
|
12
11
|
const basecommand_1 = require("../../basecommand");
|
|
13
12
|
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
14
13
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
@@ -38,8 +37,6 @@ async function uploadOptionSetHierarchies(dir) {
|
|
|
38
37
|
logger_1.default.info(`${chalk_1.default.yellow.bold('OPTION SET HIERARCHIES')} Uploading`);
|
|
39
38
|
const optionSetHierarchies = await loadOptionSetHierarchies(dir);
|
|
40
39
|
await uploadOSH(optionSetHierarchies);
|
|
41
|
-
const optionSetHierarchyLinks = await loadOptionSetHierarchyLinks(dir);
|
|
42
|
-
await uploadOSHLinks(optionSetHierarchyLinks);
|
|
43
40
|
logger_1.default.info(`${chalk_1.default.yellow.bold('OPTION SET HIERARCHIES')} Uploaded`);
|
|
44
41
|
}
|
|
45
42
|
catch (e) {
|
|
@@ -63,14 +60,6 @@ function loadOptionSetHierarchies(fromDir) {
|
|
|
63
60
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
|
-
function loadOptionSetHierarchyLinks(fromDir) {
|
|
67
|
-
try {
|
|
68
|
-
return js_yaml_1.default.load(fs_1.default.readFileSync(path.join(fromDir, 'type-option-set-hierarchy-links.yml'), 'utf8'));
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
71
|
-
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
63
|
async function uploadOSH(loadedOSHs) {
|
|
75
64
|
const optionSets = await new sdk_1.Entities().get({
|
|
76
65
|
entityName: 'type-property-option-set',
|
|
@@ -150,109 +139,3 @@ function transformOSHNameToID(hierarchy, optionSets) {
|
|
|
150
139
|
}
|
|
151
140
|
return true;
|
|
152
141
|
}
|
|
153
|
-
async function uploadOSHLinks(reducedOSHLinks) {
|
|
154
|
-
const typesWithProperties = await (0, type_extractor_1.getTypes)();
|
|
155
|
-
const typeProperties = [];
|
|
156
|
-
typesWithProperties.forEach((type) => {
|
|
157
|
-
if (type.typeProperties) {
|
|
158
|
-
for (const tp of type.typeProperties) {
|
|
159
|
-
tp.typeId = type.id;
|
|
160
|
-
tp.typeSlug = type.slug;
|
|
161
|
-
typeProperties.push(tp);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
const currentOSHs = await new sdk_1.Entities().get({
|
|
166
|
-
entityName: 'option-set-hierarchy',
|
|
167
|
-
});
|
|
168
|
-
const currentOSHLinks = await new sdk_1.Entities().get({
|
|
169
|
-
entityName: 'type-option-set-hierarchy-link',
|
|
170
|
-
});
|
|
171
|
-
const currentOSHLinkHashes = {};
|
|
172
|
-
for (const currentLink of currentOSHLinks) {
|
|
173
|
-
const foundType = typesWithProperties.find((x) => x.id === currentLink.typeId);
|
|
174
|
-
const foundOSH = currentOSHs.find((osh) => osh.id === currentLink.optionSetHierarchyId);
|
|
175
|
-
const foundTPSlugs = typeProperties
|
|
176
|
-
.filter((x) => currentLink?.hierarchyTypePropertyIds?.includes(x.id))
|
|
177
|
-
.map((x) => x.slug);
|
|
178
|
-
if (!foundType ||
|
|
179
|
-
!foundOSH ||
|
|
180
|
-
foundTPSlugs.length !== currentLink.hierarchyTypePropertyIds.length) {
|
|
181
|
-
logger_1.default.info(`skipping unhashable, invalid type option set hierarchy link: ${JSON.stringify(currentLink, null, 2)}`);
|
|
182
|
-
}
|
|
183
|
-
// don't mutate original array
|
|
184
|
-
const sortedFoundTPSlugs = [...foundTPSlugs].sort();
|
|
185
|
-
const hash = `${foundType.slug}|${foundOSH.name}|${sortedFoundTPSlugs.join('|')}`;
|
|
186
|
-
currentOSHLinkHashes[hash] = currentLink;
|
|
187
|
-
}
|
|
188
|
-
const reducedLinksByHashes = {};
|
|
189
|
-
for (const loadedLink of reducedOSHLinks) {
|
|
190
|
-
// don't mutate original array
|
|
191
|
-
const sortedTPSlugs = [...loadedLink.typePropertySlugs].sort();
|
|
192
|
-
const hash = `${loadedLink.typeSlug}|${loadedLink.optionSetHierarchyIdentifier}|${sortedTPSlugs.join('|')}}`;
|
|
193
|
-
reducedLinksByHashes[hash] = loadedLink;
|
|
194
|
-
}
|
|
195
|
-
for (const loadedLink of reducedOSHLinks) {
|
|
196
|
-
try {
|
|
197
|
-
// don't mutate original array
|
|
198
|
-
const sortedTPSlugs = [...loadedLink.typePropertySlugs].sort();
|
|
199
|
-
const found = currentOSHLinkHashes[`${loadedLink.typeSlug}|${loadedLink.optionSetHierarchyIdentifier}|${sortedTPSlugs.join('|')}`];
|
|
200
|
-
if (!found) {
|
|
201
|
-
if (!transformReducedLink(loadedLink, typesWithProperties, currentOSHs)) {
|
|
202
|
-
continue;
|
|
203
|
-
}
|
|
204
|
-
logger_1.default.debug(`Creating: ${JSON.stringify(loadedLink, null, 2)}`);
|
|
205
|
-
await new sdk_1.Entities().create({
|
|
206
|
-
entityName: 'type-option-set-hierarchy-link',
|
|
207
|
-
object: {
|
|
208
|
-
hierarchyTypePropertyIds: loadedLink.hierarchyTypePropertyIds,
|
|
209
|
-
optionSetHierarchyId: loadedLink.optionSetHierarchyId,
|
|
210
|
-
typeId: loadedLink.typeId,
|
|
211
|
-
},
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
catch (err) {
|
|
216
|
-
logger_1.default.error(`Error uploading type option set hierarchy links: ${err}`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
for (const [currentLinkHash, currentLink] of Object.entries(currentOSHLinkHashes)) {
|
|
220
|
-
try {
|
|
221
|
-
const found = reducedLinksByHashes[currentLinkHash];
|
|
222
|
-
if (!found) {
|
|
223
|
-
logger_1.default.debug(`Deleting: ${JSON.stringify(currentLinkHash)}`);
|
|
224
|
-
await new sdk_1.Entities().delete({
|
|
225
|
-
entityName: 'type-option-set-hierarchy-link',
|
|
226
|
-
id: currentLink['id'],
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
catch (err) {
|
|
231
|
-
logger_1.default.error(`Error Deleting rule set link: ${err}`);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function transformReducedLink(OSHLink, typesWithProperties, OSHs) {
|
|
236
|
-
logger_1.default.debug(`OSHLink before transform: ${JSON.stringify(OSHLink, null, 2)}`);
|
|
237
|
-
const foundType = typesWithProperties.find((x) => x.slug === OSHLink.typeSlug);
|
|
238
|
-
if (!foundType) {
|
|
239
|
-
logger_1.default.error(`OSH Links: Could not find type with slug ${OSHLink.typeSlug}`);
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
242
|
-
OSHLink.typeId = foundType.id;
|
|
243
|
-
const foundTPs = foundType?.typeProperties?.filter((x) => OSHLink.typePropertySlugs.includes(x.slug)) ?? [];
|
|
244
|
-
if (foundTPs.length !== OSHLink.typePropertySlugs.length) {
|
|
245
|
-
logger_1.default.error(`OSH Links: Could not find all type properties with slugs ${OSHLink.typePropertySlugs}`);
|
|
246
|
-
return false;
|
|
247
|
-
}
|
|
248
|
-
logger_1.default.debug(`foundTPs: ${JSON.stringify(foundTPs)}`);
|
|
249
|
-
OSHLink.hierarchyTypePropertyIds = foundTPs.map((x) => x.id);
|
|
250
|
-
const foundOSH = OSHs.find((x) => x.identifier === OSHLink.optionSetHierarchyIdentifier);
|
|
251
|
-
if (!foundOSH) {
|
|
252
|
-
logger_1.default.error(`OSH Links: Could not find option set hierarchy with identifier ${OSHLink.optionSetHierarchyIdentifier}`);
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
OSHLink.optionSetHierarchyId = foundOSH.id;
|
|
256
|
-
logger_1.default.debug(`OSHLink after transform: ${JSON.stringify(OSHLink, null, 2)}`);
|
|
257
|
-
return true;
|
|
258
|
-
}
|
|
@@ -129,7 +129,7 @@ async function uploadOS(dir) {
|
|
|
129
129
|
}
|
|
130
130
|
function validateOptionSets(optionSets) {
|
|
131
131
|
optionSets.forEach((optionSet) => {
|
|
132
|
-
optionSet.optionSet
|
|
132
|
+
optionSet.optionSet?.forEach((option) => {
|
|
133
133
|
validateOption(option, optionSet.slug);
|
|
134
134
|
});
|
|
135
135
|
});
|
|
@@ -35,9 +35,8 @@ async function uploadRuleSets(dir) {
|
|
|
35
35
|
try {
|
|
36
36
|
await (0, login_1.authUser)();
|
|
37
37
|
logger_1.default.info(`${chalk_1.default.yellow.bold('RULE SET')} Uploading`);
|
|
38
|
-
const
|
|
38
|
+
const reducedRuleSets = await loadReducedRuleSets(dir);
|
|
39
39
|
await uploadRuleSetObjects(reducedRuleSets);
|
|
40
|
-
await uploadRuleSetLinkObjects(reducedRuleSetLinks);
|
|
41
40
|
logger_1.default.info(`${chalk_1.default.yellow.bold('RULE SET')} Uploaded`);
|
|
42
41
|
}
|
|
43
42
|
catch (e) {
|
|
@@ -49,15 +48,13 @@ async function uploadRuleSets(dir) {
|
|
|
49
48
|
exports.uploadRuleSets = uploadRuleSets;
|
|
50
49
|
function loadReducedRuleSets(fromDir) {
|
|
51
50
|
const ruleSets = [];
|
|
52
|
-
let ruleSetLinks = [];
|
|
53
51
|
const dir = path.join(fromDir, 'rule-sets');
|
|
54
52
|
try {
|
|
55
53
|
const files = fs_1.default.readdirSync(dir);
|
|
56
54
|
for (const file of files) {
|
|
57
55
|
ruleSets.push(js_yaml_1.default.load(fs_1.default.readFileSync(path.join(dir, file), 'utf8')));
|
|
58
56
|
}
|
|
59
|
-
|
|
60
|
-
return [ruleSets, ruleSetLinks];
|
|
57
|
+
return ruleSets;
|
|
61
58
|
}
|
|
62
59
|
catch (e) {
|
|
63
60
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
@@ -116,83 +113,3 @@ async function uploadRuleSetObjects(reducedRuleSets) {
|
|
|
116
113
|
}
|
|
117
114
|
}
|
|
118
115
|
}
|
|
119
|
-
async function uploadRuleSetLinkObjects(loadedRuleSetLinks) {
|
|
120
|
-
const types = await new sdk_1.Entities().get({
|
|
121
|
-
entityName: 'type',
|
|
122
|
-
});
|
|
123
|
-
const currentRuleSets = await new sdk_1.Entities().get({
|
|
124
|
-
entityName: 'type-rule-set',
|
|
125
|
-
});
|
|
126
|
-
const currentRuleSetLinks = await new sdk_1.Entities().get({
|
|
127
|
-
entityName: 'type-rule-set-link',
|
|
128
|
-
});
|
|
129
|
-
const currentLinksHashes = {};
|
|
130
|
-
for (const currentLink of currentRuleSetLinks) {
|
|
131
|
-
const foundType = types.find((t) => t.id === currentLink.typeId);
|
|
132
|
-
const foundRuleSet = currentRuleSets.find((rs) => rs.id === currentLink.typeRuleSetId);
|
|
133
|
-
const hash = `${foundType.slug}|${foundRuleSet.name}`;
|
|
134
|
-
currentLinksHashes[hash] = currentLink;
|
|
135
|
-
}
|
|
136
|
-
const reducedLinksByHashes = {};
|
|
137
|
-
for (const loadedLink of loadedRuleSetLinks) {
|
|
138
|
-
const hash = `${loadedLink.type}|${loadedLink.ruleSet}`;
|
|
139
|
-
reducedLinksByHashes[hash] = loadedLink;
|
|
140
|
-
}
|
|
141
|
-
for (const loadedRuleSetLink of loadedRuleSetLinks) {
|
|
142
|
-
try {
|
|
143
|
-
const found = currentLinksHashes[`${loadedRuleSetLink.type}|${loadedRuleSetLink.ruleSet}`];
|
|
144
|
-
if (!found) {
|
|
145
|
-
if (!transformReducedLink(loadedRuleSetLink, types, currentRuleSets)) {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
logger_1.default.info(`Creating: ${JSON.stringify(loadedRuleSetLink, null, 2)}`);
|
|
149
|
-
await new sdk_1.Entities().create({
|
|
150
|
-
entityName: 'type-rule-set-link',
|
|
151
|
-
object: {
|
|
152
|
-
typeRuleSetId: loadedRuleSetLink.ruleSet,
|
|
153
|
-
typeId: loadedRuleSetLink.type,
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
if (!transformReducedLink(loadedRuleSetLink, types, currentRuleSets)) {
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
logger_1.default.info(`skipping updating existing rule set link: ${loadedRuleSetLink}`);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
catch (err) {
|
|
165
|
-
logger_1.default.error(`Error Uploading rule set links: ${err}`);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
for (const [currentLinkHash, currentLink] of Object.entries(currentLinksHashes)) {
|
|
169
|
-
try {
|
|
170
|
-
const found = reducedLinksByHashes[currentLinkHash];
|
|
171
|
-
if (!found) {
|
|
172
|
-
logger_1.default.info(`Deleting: ${currentLinkHash}`);
|
|
173
|
-
await new sdk_1.Entities().delete({
|
|
174
|
-
entityName: 'type-rule-set-link',
|
|
175
|
-
id: currentLink['id'],
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
catch (err) {
|
|
180
|
-
logger_1.default.error(`Error Deleting rule set link: ${err}`);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
function transformReducedLink(ruleSetLink, types, ruleSets) {
|
|
185
|
-
const foundType = types.find((t) => t.slug === ruleSetLink.type);
|
|
186
|
-
if (!foundType) {
|
|
187
|
-
logger_1.default.error(`Could not find type with name ${ruleSetLink.type}`);
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
ruleSetLink.type = foundType.id;
|
|
191
|
-
const foundRuleSet = ruleSets.find((rs) => rs.identifier === ruleSetLink.ruleSet);
|
|
192
|
-
if (!foundRuleSet) {
|
|
193
|
-
logger_1.default.error(`Could not find rule set with name ${foundType.ruleSet}`);
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
ruleSetLink.ruleSet = foundRuleSet.id;
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
@@ -34,8 +34,12 @@ exports.default = UploadTypeOverrides;
|
|
|
34
34
|
async function uploadTypeOverrides(dir) {
|
|
35
35
|
try {
|
|
36
36
|
await (0, login_1.authUser)();
|
|
37
|
-
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE OVERRIDE')} Uploading`);
|
|
38
37
|
const reducedOverrides = readTypeOverridesFromFile(dir);
|
|
38
|
+
if (!reducedOverrides || reducedOverrides.length === 0) {
|
|
39
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE OVERRIDE')} No overrides found in type-overrides.yml — skipping upload to avoid wiping org overrides`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE OVERRIDE')} Uploading`);
|
|
39
43
|
await (0, types_1.uploadTypeOverrideObjects)(reducedOverrides);
|
|
40
44
|
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE OVERRIDE')} Uploaded`);
|
|
41
45
|
}
|
|
@@ -47,8 +51,12 @@ async function uploadTypeOverrides(dir) {
|
|
|
47
51
|
}
|
|
48
52
|
exports.uploadTypeOverrides = uploadTypeOverrides;
|
|
49
53
|
function readTypeOverridesFromFile(fromDir) {
|
|
54
|
+
const filePath = path.join(fromDir, 'type-overrides.yml');
|
|
55
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
50
58
|
try {
|
|
51
|
-
return js_yaml_1.default.load(fs_1.default.readFileSync(
|
|
59
|
+
return js_yaml_1.default.load(fs_1.default.readFileSync(filePath, 'utf8'));
|
|
52
60
|
}
|
|
53
61
|
catch (e) {
|
|
54
62
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
@@ -8,7 +8,6 @@ const path = tslib_1.__importStar(require("path"));
|
|
|
8
8
|
const login_1 = require("../../auth/login");
|
|
9
9
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
10
10
|
const core_1 = require("@oclif/core");
|
|
11
|
-
const type_extractor_1 = require("../../helpers/types/type-extractor");
|
|
12
11
|
const users_1 = require("../../api/users");
|
|
13
12
|
const basecommand_1 = require("../../basecommand");
|
|
14
13
|
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
@@ -37,9 +36,8 @@ async function uploadTypePolicies(dir) {
|
|
|
37
36
|
try {
|
|
38
37
|
await (0, login_1.authUser)();
|
|
39
38
|
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE POLICY')} Uploading`);
|
|
40
|
-
const
|
|
39
|
+
const reducedTypePolicies = await loadTypePolicies(dir);
|
|
41
40
|
await uploadTypePolicyObjects(reducedTypePolicies);
|
|
42
|
-
await uploadTypePolicyLinks(reducedTypePolicyLinks);
|
|
43
41
|
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE POLICY')} Uploaded`);
|
|
44
42
|
}
|
|
45
43
|
catch (e) {
|
|
@@ -51,15 +49,13 @@ async function uploadTypePolicies(dir) {
|
|
|
51
49
|
exports.uploadTypePolicies = uploadTypePolicies;
|
|
52
50
|
function loadTypePolicies(fromDir) {
|
|
53
51
|
const tps = [];
|
|
54
|
-
let tpLinks = [];
|
|
55
52
|
const dir = path.join(fromDir, 'type-policies');
|
|
56
53
|
try {
|
|
57
54
|
const files = fs_1.default.readdirSync(dir);
|
|
58
55
|
for (const file of files) {
|
|
59
56
|
tps.push(js_yaml_1.default.load(fs_1.default.readFileSync(path.join(dir, file), 'utf8')));
|
|
60
57
|
}
|
|
61
|
-
|
|
62
|
-
return [tps, tpLinks];
|
|
58
|
+
return tps;
|
|
63
59
|
}
|
|
64
60
|
catch (e) {
|
|
65
61
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
@@ -152,83 +148,3 @@ async function uploadTypePolicyObjects(reducedTypePolicies) {
|
|
|
152
148
|
}
|
|
153
149
|
}
|
|
154
150
|
}
|
|
155
|
-
async function uploadTypePolicyLinks(reducedTypePolicyLinks) {
|
|
156
|
-
const types = await (0, type_extractor_1.getTypes)();
|
|
157
|
-
const currentTypePolicies = await new sdk_1.Entities().get({
|
|
158
|
-
entityName: 'type-policy',
|
|
159
|
-
});
|
|
160
|
-
const currentTypePolicyLinks = await new sdk_1.Entities().get({
|
|
161
|
-
entityName: 'type-policy-link',
|
|
162
|
-
});
|
|
163
|
-
const currentLinksHashes = {};
|
|
164
|
-
for (const currentLink of currentTypePolicyLinks) {
|
|
165
|
-
const foundType = types.find((type) => type.id === currentLink.typeId);
|
|
166
|
-
const foundTypePolicy = currentTypePolicies.find((tp) => tp.id === currentLink.typePolicyId);
|
|
167
|
-
if (!foundType || !foundTypePolicy) {
|
|
168
|
-
logger_1.default.info(`skipping unhashable, invalid policy link: ${JSON.stringify(currentLink, null, 2)}`);
|
|
169
|
-
}
|
|
170
|
-
const hash = `${foundType.slug}|${foundTypePolicy.identifier}`;
|
|
171
|
-
currentLinksHashes[hash] = currentLink;
|
|
172
|
-
}
|
|
173
|
-
const reducedLinksByHashes = {};
|
|
174
|
-
for (const loadedLink of reducedTypePolicyLinks) {
|
|
175
|
-
const hash = `${loadedLink.typeSlug}|${loadedLink.typePolicyIdentifier}`;
|
|
176
|
-
reducedLinksByHashes[hash] = loadedLink;
|
|
177
|
-
}
|
|
178
|
-
for (const loadedTPLink of reducedTypePolicyLinks) {
|
|
179
|
-
try {
|
|
180
|
-
const found = currentLinksHashes[`${loadedTPLink.typeSlug}|${loadedTPLink.typePolicyIdentifier}`];
|
|
181
|
-
if (!found) {
|
|
182
|
-
if (!transformReducedLink(loadedTPLink, types, currentTypePolicies)) {
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
logger_1.default.info(`Creating: ${loadedTPLink.typeSlug}|${loadedTPLink.typePolicyIdentifier}`);
|
|
186
|
-
await new sdk_1.Entities().create({
|
|
187
|
-
entityName: 'type-policy-link',
|
|
188
|
-
object: {
|
|
189
|
-
typePolicyId: loadedTPLink.typePolicyId,
|
|
190
|
-
typeId: loadedTPLink.typeId,
|
|
191
|
-
},
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
if (!transformReducedLink(loadedTPLink, types, currentTypePolicies)) {
|
|
196
|
-
continue;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
catch (err) {
|
|
201
|
-
logger_1.default.error(`Error Uploading type policy links: ${err}`);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
for (const [currentLinkHash, currentLink] of Object.entries(currentLinksHashes)) {
|
|
205
|
-
try {
|
|
206
|
-
const found = reducedLinksByHashes[currentLinkHash];
|
|
207
|
-
if (!found) {
|
|
208
|
-
logger_1.default.info(`Deleting: ${currentLinkHash}`);
|
|
209
|
-
await new sdk_1.Entities().delete({
|
|
210
|
-
entityName: 'type-policy-link',
|
|
211
|
-
id: currentLink['id'],
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
catch (err) {
|
|
216
|
-
logger_1.default.error(`Error Deleting rule set link: ${err}`);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
function transformReducedLink(typePolicyLink, types, typePolicies) {
|
|
221
|
-
const foundType = types.find((type) => type.slug === typePolicyLink.typeSlug);
|
|
222
|
-
if (!foundType) {
|
|
223
|
-
logger_1.default.error(`Could not find type with slug ${typePolicyLink.typeSlug}`);
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
typePolicyLink.typeId = foundType.id;
|
|
227
|
-
const foundTypePolicy = typePolicies.find((tpp) => tpp.identifier === typePolicyLink.typePolicyIdentifier);
|
|
228
|
-
if (!foundTypePolicy) {
|
|
229
|
-
logger_1.default.error(`Could not find type policy with identifier ${typePolicyLink.typePolicyIdentifier}`);
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
typePolicyLink.typePolicyId = foundTypePolicy.id;
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.uploadTypePropertyPolicies = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const sdk_1 = require("@contrail/sdk");
|
|
6
6
|
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
@@ -8,12 +8,10 @@ const path = tslib_1.__importStar(require("path"));
|
|
|
8
8
|
const login_1 = require("../../auth/login");
|
|
9
9
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
10
10
|
const core_1 = require("@oclif/core");
|
|
11
|
-
const type_extractor_1 = require("../../helpers/types/type-extractor");
|
|
12
11
|
const users_1 = require("../../api/users");
|
|
13
12
|
const basecommand_1 = require("../../basecommand");
|
|
14
13
|
const logger_1 = tslib_1.__importDefault(require("../../logger"));
|
|
15
14
|
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
16
|
-
const _ = tslib_1.__importStar(require("lodash"));
|
|
17
15
|
class UploadTypePropertyPolicies extends basecommand_1.BaseCommand {
|
|
18
16
|
static description = 'Upload type property policies';
|
|
19
17
|
static examples = [
|
|
@@ -38,14 +36,12 @@ async function uploadTypePropertyPolicies(dir) {
|
|
|
38
36
|
try {
|
|
39
37
|
await (0, login_1.authUser)();
|
|
40
38
|
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE PROPERTY POLICY')} Uploading`);
|
|
41
|
-
const
|
|
39
|
+
const reducedTypePropertyPolicies = await loadTPPolicies(dir);
|
|
42
40
|
await uploadTPPolicyObjects(reducedTypePropertyPolicies);
|
|
43
|
-
await uploadTypePropertyPolicyLinks(reducedTypePropertyPolicyLinks);
|
|
44
41
|
logger_1.default.info(`${chalk_1.default.yellow.bold('TYPE PROPERTY POLICY')} Uploaded`);
|
|
45
42
|
}
|
|
46
43
|
catch (e) {
|
|
47
44
|
logger_1.default.info(`${chalk_1.default.red.bold('FAIL')} Type Property Policy Upload Failed . ${e}`);
|
|
48
|
-
//TODO make this only print if a debug flag is set
|
|
49
45
|
console.trace(e);
|
|
50
46
|
return;
|
|
51
47
|
}
|
|
@@ -54,15 +50,13 @@ async function uploadTypePropertyPolicies(dir) {
|
|
|
54
50
|
exports.uploadTypePropertyPolicies = uploadTypePropertyPolicies;
|
|
55
51
|
function loadTPPolicies(fromDir) {
|
|
56
52
|
const tpps = [];
|
|
57
|
-
let tppLinks = [];
|
|
58
53
|
const dir = path.join(fromDir, 'type-property-policies');
|
|
59
54
|
try {
|
|
60
55
|
const files = fs_1.default.readdirSync(dir);
|
|
61
56
|
for (const file of files) {
|
|
62
57
|
tpps.push(js_yaml_1.default.load(fs_1.default.readFileSync(path.join(dir, file), 'utf8')));
|
|
63
58
|
}
|
|
64
|
-
|
|
65
|
-
return [tpps, tppLinks];
|
|
59
|
+
return tpps;
|
|
66
60
|
}
|
|
67
61
|
catch (e) {
|
|
68
62
|
throw new Error(`ERROR PARSING YAML: ${e}`);
|
|
@@ -155,133 +149,3 @@ async function uploadTPPolicyObjects(reducedTypePropertyPolicies) {
|
|
|
155
149
|
}
|
|
156
150
|
}
|
|
157
151
|
}
|
|
158
|
-
async function uploadTypePropertyPolicyLinks(reducedTypePropertyPolicyLinks) {
|
|
159
|
-
const typesWithProperties = await (0, type_extractor_1.getTypes)();
|
|
160
|
-
const typeProperties = [];
|
|
161
|
-
typesWithProperties.forEach((type) => {
|
|
162
|
-
if (type.typeProperties) {
|
|
163
|
-
for (const tp of type.typeProperties) {
|
|
164
|
-
tp.typeId = type.id;
|
|
165
|
-
tp.typeSlug = type.slug;
|
|
166
|
-
typeProperties.push(tp);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
const currentTPPs = await new sdk_1.Entities().get({
|
|
171
|
-
entityName: 'type-property-policy',
|
|
172
|
-
});
|
|
173
|
-
const currentTPPLinks = await new sdk_1.Entities().get({
|
|
174
|
-
entityName: 'type-property-policy-link',
|
|
175
|
-
});
|
|
176
|
-
logger_1.default.info(`found ${currentTPPLinks.length} current type property policy links`);
|
|
177
|
-
logger_1.default.info(`found ${reducedTypePropertyPolicyLinks.length} type property policy links to load`);
|
|
178
|
-
const currentLinksHashes = {};
|
|
179
|
-
for (const currentLink of currentTPPLinks) {
|
|
180
|
-
const foundTPs = findAllOccurrences(typeProperties, (tp) => tp.id === currentLink.typePropertyId);
|
|
181
|
-
for (const foundTP of foundTPs) {
|
|
182
|
-
const foundTPP = currentTPPs.find((tpp) => tpp.id === currentLink.typePropertyPolicyId);
|
|
183
|
-
if (!foundTP || !foundTPP) {
|
|
184
|
-
logger_1.default.info(`skipping unhashable, invalid policy link: ${JSON.stringify(currentLink, null, 2)}`);
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
const hash = `${foundTP.typeSlug}|${foundTP.slug}|${foundTPP.identifier}`;
|
|
188
|
-
currentLinksHashes[hash] = currentLink;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
logger_1.default.debug(`current links hashes: ${JSON.stringify(currentLinksHashes, null, 2)}`);
|
|
192
|
-
const reducedLinksByHashes = {};
|
|
193
|
-
for (const loadedLink of reducedTypePropertyPolicyLinks) {
|
|
194
|
-
const hash = `${loadedLink.typeSlug}|${loadedLink.typePropertySlug}|${loadedLink.typePropertyPolicyIdentifier}`;
|
|
195
|
-
reducedLinksByHashes[hash] = loadedLink;
|
|
196
|
-
}
|
|
197
|
-
const toCreate = Object.keys(reducedLinksByHashes)
|
|
198
|
-
.filter((x) => !currentLinksHashes[x])
|
|
199
|
-
.map((x) => {
|
|
200
|
-
return {
|
|
201
|
-
[x]: reducedLinksByHashes[x],
|
|
202
|
-
};
|
|
203
|
-
})
|
|
204
|
-
.reduce((a, b) => Object.assign(a, b), {});
|
|
205
|
-
const toDelete = _.uniqBy(Object.keys(currentLinksHashes)
|
|
206
|
-
.filter((x) => !reducedLinksByHashes[x])
|
|
207
|
-
.map((x) => {
|
|
208
|
-
return {
|
|
209
|
-
[x]: currentLinksHashes[x],
|
|
210
|
-
};
|
|
211
|
-
}), 'id').reduce((a, b) => Object.assign(a, b), {});
|
|
212
|
-
logger_1.default.debug(`reduced links hashes: ${JSON.stringify(reducedLinksByHashes, null, 2)}`);
|
|
213
|
-
logger_1.default.info(`found ${Object.keys(toCreate).length} type property policy links to create`);
|
|
214
|
-
logger_1.default.info(`found ${Object.keys(toDelete).length} type property policy links to delete`);
|
|
215
|
-
logger_1.default.debug(`to create: ${JSON.stringify(toCreate, null, 2)}`);
|
|
216
|
-
logger_1.default.debug(`to delete: ${JSON.stringify(toDelete, null, 2)}`);
|
|
217
|
-
logger_1.default.debug(`current links hashes to delete: ${JSON.stringify(Object.keys(currentLinksHashes).filter((x) => !reducedLinksByHashes[x]), null, 2)}`);
|
|
218
|
-
// fs.writeFileSync('toCreate.json', JSON.stringify(toCreate, null, 2));
|
|
219
|
-
// fs.writeFileSync('toDelete.json', JSON.stringify(toDelete, null, 2));
|
|
220
|
-
// fs.writeFileSync('currentLinksHashes.json', JSON.stringify(currentLinksHashes, null, 2));
|
|
221
|
-
// fs.writeFileSync('reducedLinksByHashes.json', JSON.stringify(reducedLinksByHashes, null, 2));
|
|
222
|
-
// fs.writeFileSync(
|
|
223
|
-
// 'current_link_hashes_to_delete.json',
|
|
224
|
-
// JSON.stringify(
|
|
225
|
-
// Object.keys(currentLinksHashes).filter((x) => !reducedLinksByHashes[x]),
|
|
226
|
-
// null,
|
|
227
|
-
// 2,
|
|
228
|
-
// ),
|
|
229
|
-
// );
|
|
230
|
-
// return;
|
|
231
|
-
for (const [hash, link] of Object.entries(toCreate)) {
|
|
232
|
-
try {
|
|
233
|
-
if (!transformReducedLink(link, typeProperties, currentTPPs)) {
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
logger_1.default.info(`Creating: ${hash}: ${JSON.stringify(link, null, 2)}`);
|
|
237
|
-
await new sdk_1.Entities().create({
|
|
238
|
-
entityName: 'type-property-policy-link',
|
|
239
|
-
object: {
|
|
240
|
-
typePropertyPolicyId: link.typePropertyPolicyId,
|
|
241
|
-
typePropertyId: link.typePropertyId,
|
|
242
|
-
},
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
catch (err) {
|
|
246
|
-
logger_1.default.error(`Error Uploading type property policy links: ${err}`);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
for (const [hash, link] of Object.entries(toDelete)) {
|
|
250
|
-
try {
|
|
251
|
-
logger_1.default.info(`Deleting: ${hash}`);
|
|
252
|
-
await new sdk_1.Entities().delete({
|
|
253
|
-
entityName: 'type-property-policy-link',
|
|
254
|
-
id: link['id'],
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
catch (err) {
|
|
258
|
-
logger_1.default.error(`Error Deleting type property policy link: ${err}`);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
function transformReducedLink(TPPLink, typeProperties, typePropertyPolicies) {
|
|
262
|
-
const foundTP = typeProperties.find((tp) => tp.slug === TPPLink.typePropertySlug && tp.typeSlug === TPPLink.typeSlug);
|
|
263
|
-
if (!foundTP) {
|
|
264
|
-
logger_1.default.error(`Could not find type property with slug ${TPPLink.typePropertySlug} `);
|
|
265
|
-
return false;
|
|
266
|
-
}
|
|
267
|
-
TPPLink.typePropertyId = foundTP.id;
|
|
268
|
-
const foundTPP = typePropertyPolicies.find((tpp) => tpp.identifier === TPPLink.typePropertyPolicyIdentifier);
|
|
269
|
-
if (!foundTPP) {
|
|
270
|
-
logger_1.default.error(`Could not find type property policy with identifier ${TPPLink.typePropertyPolicyIdentifier} `);
|
|
271
|
-
return false;
|
|
272
|
-
}
|
|
273
|
-
TPPLink.typePropertyPolicyId = foundTPP.id;
|
|
274
|
-
return true;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
function findAllOccurrences(array, evaluator) {
|
|
278
|
-
const found = [];
|
|
279
|
-
for (let i = 0; i < array.length; i++) {
|
|
280
|
-
const element = array[i];
|
|
281
|
-
if (evaluator(element)) {
|
|
282
|
-
found.push(element);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return found;
|
|
286
|
-
}
|
|
287
|
-
exports.findAllOccurrences = findAllOccurrences;
|
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.exportUsers = exports.DEFAULT_FILE_LOCATION = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const path = tslib_1.__importStar(require("path"));
|
|
6
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
6
|
const login_1 = require("../../auth/login");
|
|
9
|
-
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
10
7
|
const core_1 = require("@oclif/core");
|
|
11
8
|
const file_helpers_1 = require("../../helpers/file-helpers");
|
|
12
9
|
const users_1 = require("../../api/users");
|
|
@@ -63,15 +60,6 @@ async function exportUsers(fileLocation, overwrite) {
|
|
|
63
60
|
});
|
|
64
61
|
}
|
|
65
62
|
users = users.sort((one, two) => (one.email < two.email ? -1 : 1));
|
|
66
|
-
await saveData(users, fileLocation, overwrite);
|
|
63
|
+
await (0, file_helpers_1.saveData)(users, fileLocation, overwrite);
|
|
67
64
|
}
|
|
68
65
|
exports.exportUsers = exportUsers;
|
|
69
|
-
async function saveData(data, fileLocation, overwrite) {
|
|
70
|
-
const yamlStr = js_yaml_1.default.dump(data);
|
|
71
|
-
const CURRENT_DIR = process.cwd();
|
|
72
|
-
const pathToWrite = path.resolve(path.join(CURRENT_DIR, fileLocation));
|
|
73
|
-
if (fs_1.default.existsSync(pathToWrite)) {
|
|
74
|
-
await (0, file_helpers_1.safeFileOverwrite)(pathToWrite, overwrite);
|
|
75
|
-
}
|
|
76
|
-
fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
|
|
77
|
-
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCSVData = exports.safeFileOverwrite = void 0;
|
|
3
|
+
exports.saveData = exports.parseCSVData = exports.safeFileOverwrite = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
7
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
8
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
6
9
|
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
7
10
|
const sync_1 = require("csv-parse/sync");
|
|
8
11
|
const PASS_FORCE_TO_OVERWRITE = 'Pass --overwrite to overwrite without prompting';
|
|
@@ -34,3 +37,14 @@ function parseCSVData(data) {
|
|
|
34
37
|
});
|
|
35
38
|
}
|
|
36
39
|
exports.parseCSVData = parseCSVData;
|
|
40
|
+
//saves data as yaml to fileLocation (relative to the current directory), prompting before overwriting unless overwrite is passed
|
|
41
|
+
async function saveData(data, fileLocation, overwrite) {
|
|
42
|
+
const yamlStr = js_yaml_1.default.dump(data);
|
|
43
|
+
const CURRENT_DIR = process.cwd();
|
|
44
|
+
const pathToWrite = path.resolve(path.join(CURRENT_DIR, fileLocation));
|
|
45
|
+
if (fs_1.default.existsSync(pathToWrite)) {
|
|
46
|
+
await safeFileOverwrite(pathToWrite, overwrite);
|
|
47
|
+
}
|
|
48
|
+
fs_1.default.writeFileSync(pathToWrite, yamlStr, 'utf8');
|
|
49
|
+
}
|
|
50
|
+
exports.saveData = saveData;
|
|
@@ -303,7 +303,7 @@ async function uploadReducedTypeProperties(type, currentPropertyTypes, newProper
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
catch (err) {
|
|
306
|
-
|
|
306
|
+
logger_1.default.error(`Error Deleting Type-Property ${currentPropertyType.slug}: ${err}`);
|
|
307
307
|
}
|
|
308
308
|
}
|
|
309
309
|
}
|