Skip to content

Commit

Permalink
fix: pr feedback (case insensitivity)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Aug 19, 2024
1 parent cfd62d2 commit 51e004d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
1 change: 0 additions & 1 deletion scripts/update-registry/shared/updateRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const registryUpdate = (missingTypesAsDescribeResult: DescribeEntry[]) =>
registry.suffixes[suffix] = typeId;
}
});
console.log('Updated registry with new types:');
const jsonData = JSON.stringify(registry, null, 2);
fs.writeFileSync('./src/registry/metadataRegistry.json', jsonData);
};
Expand Down
10 changes: 7 additions & 3 deletions scripts/update-registry/updateRegistryFromCoreMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ const getMissingTypesFromDescribe = async (missingTypes: string[]): Promise<Desc
const logMissingEntry =
(describe: typeof describeFile) =>
(typeName: string): DescribeEntry | undefined => {
if (describe[typeName]) {
return describe[typeName];
const [, found] = Object.entries(describe).find(([key]) => key.toLowerCase() === typeName.toLowerCase()) ?? [];
if (found !== undefined) {
return found;
}
console.warn(`No entry for ${typeName}`);
};

(async () => {
const missingTypes = await whatTypesNeedDescribe();
const missingTypesAsDescribeEntry = await getMissingTypesFromDescribe(missingTypes);
console.log(missingTypesAsDescribeEntry);
(missingTypesAsDescribeEntry.length
? [`Updating types in the registry`, missingTypesAsDescribeEntry]
: ['No metadata changes made']
).map((i) => console.log(i));
registryUpdate(missingTypesAsDescribeEntry);
})();
18 changes: 15 additions & 3 deletions scripts/update-registry/updateRegistryFromOrg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ const getMissingTypesAsDescribeResult = async (missingTypes: string[]): Promise<
const describeResult = await execProm('sf org list metadata-types -o registryBuilder --json');
const metadataObjectsByName = new Map(
(JSON.parse(describeResult.stdout).result.metadataObjects as DescribeResult[]).map((describeObj) => [
describeObj.xmlName,
describeObj.xmlName.toLowerCase(),
describeObj,
])
);
// get the missingTypes from the describe
return missingTypes.map((key) => metadataObjectsByName.get(key)).filter(isDefined);
return missingTypes.map(lowercaseFn).map(getOrWarn(metadataObjectsByName)).filter(isDefined);
};

/** massage for slight differences between the 2 types */
Expand All @@ -33,6 +33,18 @@ const describeResultToDescribeEntry = (describeResult: DescribeResult): Describe
const missingTypes = await whatTypesNeedDescribe();

const missingTypesAsDescribeResult = await getMissingTypesAsDescribeResult(missingTypes);
console.log(missingTypesAsDescribeResult);
registryUpdate(missingTypesAsDescribeResult.map(describeResultToDescribeEntry));
})();

const lowercaseFn = (s: string) => s.toLowerCase();

const getOrWarn =
<T>(map: Map<string, T>) =>
(key: string): T | undefined => {
const result = map.get(key);
if (result === undefined) {
console.warn(`No entry for ${key}`);
return;
}
return result;
};

2 comments on commit 51e004d

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 51e004d Previous: dabbf72 Ratio
eda-componentSetCreate-linux 227 ms 233 ms 0.97
eda-sourceToMdapi-linux 2395 ms 2371 ms 1.01
eda-sourceToZip-linux 1913 ms 1878 ms 1.02
eda-mdapiToSource-linux 2889 ms 2940 ms 0.98
lotsOfClasses-componentSetCreate-linux 442 ms 435 ms 1.02
lotsOfClasses-sourceToMdapi-linux 3697 ms 3705 ms 1.00
lotsOfClasses-sourceToZip-linux 3245 ms 3286 ms 0.99
lotsOfClasses-mdapiToSource-linux 3586 ms 3656 ms 0.98
lotsOfClassesOneDir-componentSetCreate-linux 755 ms 758 ms 1.00
lotsOfClassesOneDir-sourceToMdapi-linux 6504 ms 6612 ms 0.98
lotsOfClassesOneDir-sourceToZip-linux 5643 ms 5827 ms 0.97
lotsOfClassesOneDir-mdapiToSource-linux 6478 ms 6564 ms 0.99

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 51e004d Previous: dabbf72 Ratio
eda-componentSetCreate-win32 607 ms 606 ms 1.00
eda-sourceToMdapi-win32 4134 ms 4276 ms 0.97
eda-sourceToZip-win32 2979 ms 2892 ms 1.03
eda-mdapiToSource-win32 5596 ms 5708 ms 0.98
lotsOfClasses-componentSetCreate-win32 1175 ms 1169 ms 1.01
lotsOfClasses-sourceToMdapi-win32 7576 ms 7659 ms 0.99
lotsOfClasses-sourceToZip-win32 4977 ms 5151 ms 0.97
lotsOfClasses-mdapiToSource-win32 7646 ms 7857 ms 0.97
lotsOfClassesOneDir-componentSetCreate-win32 2071 ms 2078 ms 1.00
lotsOfClassesOneDir-sourceToMdapi-win32 13399 ms 13720 ms 0.98
lotsOfClassesOneDir-sourceToZip-win32 9016 ms 8976 ms 1.00
lotsOfClassesOneDir-mdapiToSource-win32 13756 ms 14020 ms 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.