-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathfeature-data.ts
More file actions
27 lines (22 loc) · 1.19 KB
/
feature-data.ts
File metadata and controls
27 lines (22 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Run `npm run vitest` to update these files
import importedFeaturesRaw from '../build/__snapshots__/imported-features.json' with {type: 'json'};
import featuresMetasRaw from '../build/__snapshots__/features-meta.json' with {type: 'json'};
import renamedFeatures from './feature-renames.json' with {type: 'json'};
export const importedFeatures = importedFeaturesRaw as FeatureId[];
export const featuresMeta = featuresMetasRaw as FeatureMeta[];
// eslint-disable-next-line unicorn/prefer-export-from -- The build silently fails to provide `renamedFeatures` in this scope. I don't know whose fault it is.
export {renamedFeatures};
export function getNewFeatureName(possibleFeatureName: string): FeatureId | undefined {
// @ts-expect-error Useless "no index type" error as usual
const newFeatureName = renamedFeatures[possibleFeatureName] as FeatureId ?? possibleFeatureName;
return importedFeatures.includes(newFeatureName) ? newFeatureName : undefined;
}
export function getOldFeatureNames(featureName: string): string[] {
const oldNames: string[] = [];
for (const [oldName, newName] of Object.entries(renamedFeatures)) {
if (newName === featureName) {
oldNames.push(oldName);
}
}
return oldNames;
}