@featurevisor/core
Advanced tools
Comparing version
@@ -6,2 +6,13 @@ # Change Log | ||
# [1.25.0](https://github.com/featurevisor/featurevisor/compare/v1.24.0...v1.25.0) (2024-07-16) | ||
### Features | ||
* allow showing authors when finding unused entities ([#313](https://github.com/featurevisor/featurevisor/issues/313)) ([67e1158](https://github.com/featurevisor/featurevisor/commit/67e1158b0a2d8636700d167e69f391c1f03a7ed6)) | ||
# [1.24.0](https://github.com/featurevisor/featurevisor/compare/v1.23.0...v1.24.0) (2024-06-24) | ||
@@ -8,0 +19,0 @@ |
@@ -30,3 +30,4 @@ import { FeatureKey, SegmentKey, AttributeKey } from "@featurevisor/types"; | ||
unusedAttributes?: boolean; | ||
authors?: boolean; | ||
} | ||
export declare function findUsageInProject(deps: Dependencies, options: FindUsageOptions): Promise<void>; |
@@ -327,26 +327,41 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var usedInFeatures, usedIn, unusedSegments, unusedAttributes; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var datasource, usedInFeatures, _i, _a, featureKey, entries, authors, usedIn, _b, _c, featureKey, entries, authors, _d, _e, segmentKey, entries, authors, unusedSegments, _f, _g, segmentKey, entries, authors, unusedAttributes, _h, _j, attributeKey, entries, authors; | ||
return __generator(this, function (_k) { | ||
switch (_k.label) { | ||
case 0: | ||
datasource = deps.datasource; | ||
console.log(""); | ||
if (!options.segment) return [3 /*break*/, 2]; | ||
if (!options.segment) return [3 /*break*/, 8]; | ||
return [4 /*yield*/, findSegmentUsage(deps, options.segment)]; | ||
case 1: | ||
usedInFeatures = _a.sent(); | ||
if (usedInFeatures.size === 0) { | ||
console.log("Segment \"".concat(options.segment, "\" is not used in any features.")); | ||
} | ||
else { | ||
console.log("Segment \"".concat(options.segment, "\" is used in the following features:\n")); | ||
usedInFeatures.forEach(function (featureKey) { | ||
console.log(" - ".concat(featureKey)); | ||
}); | ||
} | ||
return [2 /*return*/]; | ||
usedInFeatures = _k.sent(); | ||
if (!(usedInFeatures.size === 0)) return [3 /*break*/, 2]; | ||
console.log("Segment \"".concat(options.segment, "\" is not used in any features.")); | ||
return [3 /*break*/, 7]; | ||
case 2: | ||
if (!options.attribute) return [3 /*break*/, 4]; | ||
console.log("Segment \"".concat(options.segment, "\" is used in the following features:\n")); | ||
_i = 0, _a = Array.from(usedInFeatures); | ||
_k.label = 3; | ||
case 3: | ||
if (!(_i < _a.length)) return [3 /*break*/, 7]; | ||
featureKey = _a[_i]; | ||
if (!options.authors) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, datasource.listHistoryEntries("feature", featureKey)]; | ||
case 4: | ||
entries = _k.sent(); | ||
authors = Array.from(new Set(entries.map(function (entry) { return entry.author; }))); | ||
console.log(" - ".concat(featureKey, " (Authors: ").concat(authors.join(", "), ")")); | ||
return [3 /*break*/, 6]; | ||
case 5: | ||
console.log(" - ".concat(featureKey)); | ||
_k.label = 6; | ||
case 6: | ||
_i++; | ||
return [3 /*break*/, 3]; | ||
case 7: return [2 /*return*/]; | ||
case 8: | ||
if (!options.attribute) return [3 /*break*/, 21]; | ||
return [4 /*yield*/, findAttributeUsage(deps, options.attribute)]; | ||
case 3: | ||
usedIn = _a.sent(); | ||
case 9: | ||
usedIn = _k.sent(); | ||
if (usedIn.features.size === 0 && usedIn.segments.size === 0) { | ||
@@ -356,47 +371,106 @@ console.log("Attribute \"".concat(options.attribute, "\" is not used in any features or segments.")); | ||
} | ||
if (usedIn.features.size > 0) { | ||
console.log("Attribute \"".concat(options.attribute, "\" is used in the following features:\n")); | ||
usedIn.features.forEach(function (featureKey) { | ||
console.log(" - ".concat(featureKey)); | ||
}); | ||
console.log(""); | ||
} | ||
if (usedIn.segments.size > 0) { | ||
console.log("Attribute \"".concat(options.attribute, "\" is used in the following segments:\n")); | ||
usedIn.segments.forEach(function (segmentKey) { | ||
console.log(" - ".concat(segmentKey)); | ||
}); | ||
} | ||
return [2 /*return*/]; | ||
case 4: | ||
if (!options.unusedSegments) return [3 /*break*/, 6]; | ||
if (!(usedIn.features.size > 0)) return [3 /*break*/, 15]; | ||
console.log("Attribute \"".concat(options.attribute, "\" is used in the following features:\n")); | ||
_b = 0, _c = Array.from(usedIn.features); | ||
_k.label = 10; | ||
case 10: | ||
if (!(_b < _c.length)) return [3 /*break*/, 14]; | ||
featureKey = _c[_b]; | ||
if (!options.authors) return [3 /*break*/, 12]; | ||
return [4 /*yield*/, datasource.listHistoryEntries("feature", featureKey)]; | ||
case 11: | ||
entries = _k.sent(); | ||
authors = Array.from(new Set(entries.map(function (entry) { return entry.author; }))); | ||
console.log(" - ".concat(featureKey, " (Authors: ").concat(authors.join(", "), ")")); | ||
return [3 /*break*/, 13]; | ||
case 12: | ||
console.log(" - ".concat(featureKey)); | ||
_k.label = 13; | ||
case 13: | ||
_b++; | ||
return [3 /*break*/, 10]; | ||
case 14: | ||
console.log(""); | ||
_k.label = 15; | ||
case 15: | ||
if (!(usedIn.segments.size > 0)) return [3 /*break*/, 20]; | ||
console.log("Attribute \"".concat(options.attribute, "\" is used in the following segments:\n")); | ||
_d = 0, _e = Array.from(usedIn.segments); | ||
_k.label = 16; | ||
case 16: | ||
if (!(_d < _e.length)) return [3 /*break*/, 20]; | ||
segmentKey = _e[_d]; | ||
if (!options.authors) return [3 /*break*/, 18]; | ||
return [4 /*yield*/, datasource.listHistoryEntries("segment", segmentKey)]; | ||
case 17: | ||
entries = _k.sent(); | ||
authors = Array.from(new Set(entries.map(function (entry) { return entry.author; }))); | ||
console.log(" - ".concat(segmentKey, " (Authors: ").concat(authors.join(", "), ")")); | ||
return [3 /*break*/, 19]; | ||
case 18: | ||
console.log(" - ".concat(segmentKey)); | ||
_k.label = 19; | ||
case 19: | ||
_d++; | ||
return [3 /*break*/, 16]; | ||
case 20: return [2 /*return*/]; | ||
case 21: | ||
if (!options.unusedSegments) return [3 /*break*/, 29]; | ||
return [4 /*yield*/, findUnusedSegments(deps)]; | ||
case 5: | ||
unusedSegments = _a.sent(); | ||
if (unusedSegments.size === 0) { | ||
console.log("No unused segments found."); | ||
} | ||
else { | ||
console.log("Unused segments:\n"); | ||
unusedSegments.forEach(function (segmentKey) { | ||
console.log(" - ".concat(segmentKey)); | ||
}); | ||
} | ||
return [2 /*return*/]; | ||
case 6: | ||
if (!options.unusedAttributes) return [3 /*break*/, 8]; | ||
case 22: | ||
unusedSegments = _k.sent(); | ||
if (!(unusedSegments.size === 0)) return [3 /*break*/, 23]; | ||
console.log("No unused segments found."); | ||
return [3 /*break*/, 28]; | ||
case 23: | ||
console.log("Unused segments:\n"); | ||
_f = 0, _g = Array.from(unusedSegments); | ||
_k.label = 24; | ||
case 24: | ||
if (!(_f < _g.length)) return [3 /*break*/, 28]; | ||
segmentKey = _g[_f]; | ||
if (!options.authors) return [3 /*break*/, 26]; | ||
return [4 /*yield*/, datasource.listHistoryEntries("segment", segmentKey)]; | ||
case 25: | ||
entries = _k.sent(); | ||
authors = Array.from(new Set(entries.map(function (entry) { return entry.author; }))); | ||
console.log(" - ".concat(segmentKey, " (Authors: ").concat(authors.join(", "), ")")); | ||
return [3 /*break*/, 27]; | ||
case 26: | ||
console.log(" - ".concat(segmentKey)); | ||
_k.label = 27; | ||
case 27: | ||
_f++; | ||
return [3 /*break*/, 24]; | ||
case 28: return [2 /*return*/]; | ||
case 29: | ||
if (!options.unusedAttributes) return [3 /*break*/, 37]; | ||
return [4 /*yield*/, findUnusedAttributes(deps)]; | ||
case 7: | ||
unusedAttributes = _a.sent(); | ||
if (unusedAttributes.size === 0) { | ||
console.log("No unused attributes found."); | ||
} | ||
else { | ||
console.log("Unused attributes:\n"); | ||
unusedAttributes.forEach(function (attributeKey) { | ||
console.log(" - ".concat(attributeKey)); | ||
}); | ||
} | ||
return [2 /*return*/]; | ||
case 8: | ||
case 30: | ||
unusedAttributes = _k.sent(); | ||
if (!(unusedAttributes.size === 0)) return [3 /*break*/, 31]; | ||
console.log("No unused attributes found."); | ||
return [3 /*break*/, 36]; | ||
case 31: | ||
console.log("Unused attributes:\n"); | ||
_h = 0, _j = Array.from(unusedAttributes); | ||
_k.label = 32; | ||
case 32: | ||
if (!(_h < _j.length)) return [3 /*break*/, 36]; | ||
attributeKey = _j[_h]; | ||
if (!options.authors) return [3 /*break*/, 34]; | ||
return [4 /*yield*/, datasource.listHistoryEntries("attribute", attributeKey)]; | ||
case 33: | ||
entries = _k.sent(); | ||
authors = Array.from(new Set(entries.map(function (entry) { return entry.author; }))); | ||
console.log(" - ".concat(attributeKey, " (Authors: ").concat(authors.join(", "), ")")); | ||
return [3 /*break*/, 35]; | ||
case 34: | ||
console.log(" - ".concat(attributeKey)); | ||
_k.label = 35; | ||
case 35: | ||
_h++; | ||
return [3 /*break*/, 32]; | ||
case 36: return [2 /*return*/]; | ||
case 37: | ||
console.log("Please specify a segment or attribute."); | ||
@@ -403,0 +477,0 @@ return [2 /*return*/]; |
{ | ||
"name": "@featurevisor/core", | ||
"version": "1.24.0", | ||
"version": "1.25.0", | ||
"description": "Core package of Featurevisor for Node.js usage", | ||
@@ -60,3 +60,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "de3c67ad46b69d7bce44de3a0a00450625561964" | ||
"gitHead": "4ba871333e577b6164af64e9d66955306fb0fc04" | ||
} |
@@ -246,5 +246,9 @@ import { Condition, FeatureKey, SegmentKey, AttributeKey } from "@featurevisor/types"; | ||
unusedAttributes?: boolean; | ||
authors?: boolean; | ||
} | ||
export async function findUsageInProject(deps: Dependencies, options: FindUsageOptions) { | ||
const { datasource } = deps; | ||
console.log(""); | ||
@@ -261,5 +265,12 @@ | ||
usedInFeatures.forEach((featureKey) => { | ||
console.log(` - ${featureKey}`); | ||
}); | ||
for (const featureKey of Array.from(usedInFeatures)) { | ||
if (options.authors) { | ||
const entries = await datasource.listHistoryEntries("feature", featureKey); | ||
const authors = Array.from(new Set(entries.map((entry) => entry.author))); | ||
console.log(` - ${featureKey} (Authors: ${authors.join(", ")})`); | ||
} else { | ||
console.log(` - ${featureKey}`); | ||
} | ||
} | ||
} | ||
@@ -283,6 +294,13 @@ | ||
usedIn.features.forEach((featureKey) => { | ||
console.log(` - ${featureKey}`); | ||
}); | ||
for (const featureKey of Array.from(usedIn.features)) { | ||
if (options.authors) { | ||
const entries = await datasource.listHistoryEntries("feature", featureKey); | ||
const authors = Array.from(new Set(entries.map((entry) => entry.author))); | ||
console.log(` - ${featureKey} (Authors: ${authors.join(", ")})`); | ||
} else { | ||
console.log(` - ${featureKey}`); | ||
} | ||
} | ||
console.log(""); | ||
@@ -294,5 +312,12 @@ } | ||
usedIn.segments.forEach((segmentKey) => { | ||
console.log(` - ${segmentKey}`); | ||
}); | ||
for (const segmentKey of Array.from(usedIn.segments)) { | ||
if (options.authors) { | ||
const entries = await datasource.listHistoryEntries("segment", segmentKey); | ||
const authors = Array.from(new Set(entries.map((entry) => entry.author))); | ||
console.log(` - ${segmentKey} (Authors: ${authors.join(", ")})`); | ||
} else { | ||
console.log(` - ${segmentKey}`); | ||
} | ||
} | ||
} | ||
@@ -312,5 +337,12 @@ | ||
unusedSegments.forEach((segmentKey) => { | ||
console.log(` - ${segmentKey}`); | ||
}); | ||
for (const segmentKey of Array.from(unusedSegments)) { | ||
if (options.authors) { | ||
const entries = await datasource.listHistoryEntries("segment", segmentKey); | ||
const authors = Array.from(new Set(entries.map((entry) => entry.author))); | ||
console.log(` - ${segmentKey} (Authors: ${authors.join(", ")})`); | ||
} else { | ||
console.log(` - ${segmentKey}`); | ||
} | ||
} | ||
} | ||
@@ -330,5 +362,12 @@ | ||
unusedAttributes.forEach((attributeKey) => { | ||
console.log(` - ${attributeKey}`); | ||
}); | ||
for (const attributeKey of Array.from(unusedAttributes)) { | ||
if (options.authors) { | ||
const entries = await datasource.listHistoryEntries("attribute", attributeKey); | ||
const authors = Array.from(new Set(entries.map((entry) => entry.author))); | ||
console.log(` - ${attributeKey} (Authors: ${authors.join(", ")})`); | ||
} else { | ||
console.log(` - ${attributeKey}`); | ||
} | ||
} | ||
} | ||
@@ -335,0 +374,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1111966
0.75%14578
0.74%