Skip to content

Commit

Permalink
chore: experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
WillieRuemmele committed Sep 10, 2024
1 parent f4b7033 commit 1630022
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
needs: yarn-lockfile-check
uses: salesforcecli/github-workflows/.github/workflows/unitTestsLinux.yml@main
windows-unit-tests:
needs: linux-unit-tests
needs: yarn-lockfile-check
uses: salesforcecli/github-workflows/.github/workflows/unitTestsWindows.yml@main

nuts:
Expand Down
6 changes: 3 additions & 3 deletions src/convert/transformers/decomposedMetadataTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { dirname, join } from 'node:path';
import fs from 'node:fs';
import { AnyJson, JsonMap, ensureString, isJsonMap } from '@salesforce/ts-types';
import { JsonMap, ensureString, isJsonMap } from '@salesforce/ts-types';
import { ensureArray } from '@salesforce/kit';
import { Messages } from '@salesforce/core';
import { calculateRelativePath } from '../../utils/path';
Expand Down Expand Up @@ -251,7 +251,7 @@ const getKey = (component: MetadataComponent): string => `${component.type.name}
const getComposedMetadataEntries = async (component: SourceComponent): Promise<ComposedMetadata[]> =>
// composedMetadata might be undefined if you call toSourceFormat() from a non-source-backed Component
Object.entries((await component.parseXml())[component.type.name] ?? {}).map(
([tagKey, tagValue]: [string, AnyJson]): ComposedMetadata => ({
([tagKey, tagValue]: [string, JsonMap | JsonMap[]]): ComposedMetadata => ({
tagKey,
tagValue,
parentType: component.type,
Expand Down Expand Up @@ -315,7 +315,7 @@ export const forceIgnoreAllowsComponent =
/** wrap some xml in the Metadata type and add the NS stuff */
const objectToSource =
(childTypeName: string) =>
(obj: JsonMap): JsToXml =>
(obj: JsonMap | JsonMap[]): JsToXml =>
new JsToXml({ [childTypeName]: { [XML_NS_KEY]: XML_NS_URL, ...obj } });

/** filter out the children and create the remaining parentXml */
Expand Down
12 changes: 6 additions & 6 deletions src/convert/transformers/decomposedPermissionSetTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { dirname, join } from 'node:path';
import { AnyJson, ensureString, JsonMap } from '@salesforce/ts-types';
import { ensureString, JsonMap } from '@salesforce/ts-types';
import { Messages } from '@salesforce/core';
import type { PermissionSet } from '@jsforce/jsforce-node/lib/api/metadata/schema';
import { calculateRelativePath } from '../../utils/path';
Expand Down Expand Up @@ -72,7 +72,7 @@ export class DecomposedPermissionSetTransformer extends BaseMetadataTransformer
}

/**
* will decomopse a .permissionset into a directory containing files, and an 'objectSettings' folder for object-specific settings
* will decompose a .permissionset into a directory containing files, and an 'objectSettings' folder for object-specific settings
*
* @param {SourceComponent} component A SourceComponent representing a metadata-formatted permission set
* @param {SourceComponent | undefined} mergeWith any existing source-formatted permission sets to be merged with, think existing source merging with new information from a retrieve
Expand Down Expand Up @@ -102,7 +102,7 @@ export class DecomposedPermissionSetTransformer extends BaseMetadataTransformer
const preparedMetadata = composedMetadata
.filter(hasChildTypeId)
.map(addChildType)
.map((c) => toInfoContainer(mergeWith)(component)(c.childType)(c.tagValue as JsonMap))
.map((c) => toInfoContainer(mergeWith)(component)(c.childType)(c.tagValue))
.filter(forceIgnoreAllowsComponent(forceIgnore));

const writeInfosForChildren = combineChildWriteInfos(
Expand Down Expand Up @@ -145,7 +145,7 @@ const hasXml = (c: SourceComponent): c is SourceComponent & { xml: string } => t
const getComposedMetadataEntries = async (component: SourceComponent): Promise<ComposedMetadata[]> =>
// composedMetadata might be undefined if you call toSourceFormat() from a non-source-backed Component
Object.entries((await component.parseXml())[component.type.name] ?? {}).map(
([tagKey, tagValue]: [string, AnyJson]): ComposedMetadata => ({
([tagKey, tagValue]: [string, JsonMap | JsonMap[]]): ComposedMetadata => ({
tagKey,
tagValue,
parentType: component.type,
Expand Down Expand Up @@ -248,9 +248,9 @@ const toInfoContainer =
(mergeWith: SourceComponent | undefined) =>
(parent: SourceComponent) =>
(childType: MetadataType) =>
(tagValue: JsonMap): InfoContainer => {
(tagValue: JsonMap[] | JsonMap): InfoContainer => {
const entryName = childType.directoryName
? ((tagValue as unknown as JsonMap[]).at(0)?.[childType.uniqueIdElement!] as string).split('.')[0]
? ((Array.isArray(tagValue) ? tagValue.at(0) : tagValue)?.[childType.uniqueIdElement!] as string).split('.')[0]
: parent.name;
return {
parentComponent: parent,
Expand Down
11 changes: 8 additions & 3 deletions src/convert/transformers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { AnyJson, JsonMap } from '@salesforce/ts-types';
import { JsonMap } from '@salesforce/ts-types';
import { MetadataType } from '../../registry';
import { MetadataComponent, SourceComponent } from '../../resolve';

export type ComposedMetadata = { tagKey: string; tagValue: AnyJson; parentType: MetadataType; childTypeId?: string };
export type ComposedMetadata = {
tagKey: string;
tagValue: JsonMap | JsonMap[];
parentType: MetadataType;
childTypeId?: string;
};
export type ComposedMetadataWithChildType = ComposedMetadata & { childType: MetadataType };

export type InfoContainer = {
entryName: string;
childComponent: MetadataComponent;
/** the parsed xml */
value: JsonMap;
value: JsonMap | JsonMap[];
parentComponent: SourceComponent;
mergeWith?: SourceComponent;
};

2 comments on commit 1630022

@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: 1630022 Previous: f4b7033 Ratio
eda-componentSetCreate-linux 226 ms 234 ms 0.97
eda-sourceToMdapi-linux 2403 ms 2352 ms 1.02
eda-sourceToZip-linux 1928 ms 1891 ms 1.02
eda-mdapiToSource-linux 2953 ms 2893 ms 1.02
lotsOfClasses-componentSetCreate-linux 426 ms 437 ms 0.97
lotsOfClasses-sourceToMdapi-linux 3877 ms 3795 ms 1.02
lotsOfClasses-sourceToZip-linux 3298 ms 3096 ms 1.07
lotsOfClasses-mdapiToSource-linux 3785 ms 3620 ms 1.05
lotsOfClassesOneDir-componentSetCreate-linux 774 ms 755 ms 1.03
lotsOfClassesOneDir-sourceToMdapi-linux 6685 ms 6537 ms 1.02
lotsOfClassesOneDir-sourceToZip-linux 5934 ms 5628 ms 1.05
lotsOfClassesOneDir-mdapiToSource-linux 6617 ms 6563 ms 1.01

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: 1630022 Previous: f4b7033 Ratio
eda-componentSetCreate-win32 673 ms 619 ms 1.09
eda-sourceToMdapi-win32 4620 ms 4338 ms 1.07
eda-sourceToZip-win32 3178 ms 3058 ms 1.04
eda-mdapiToSource-win32 6213 ms 5664 ms 1.10
lotsOfClasses-componentSetCreate-win32 1313 ms 1213 ms 1.08
lotsOfClasses-sourceToMdapi-win32 8326 ms 7580 ms 1.10
lotsOfClasses-sourceToZip-win32 5387 ms 4989 ms 1.08
lotsOfClasses-mdapiToSource-win32 7984 ms 7761 ms 1.03
lotsOfClassesOneDir-componentSetCreate-win32 2107 ms 2076 ms 1.01
lotsOfClassesOneDir-sourceToMdapi-win32 13670 ms 13616 ms 1.00
lotsOfClassesOneDir-sourceToZip-win32 9454 ms 9374 ms 1.01
lotsOfClassesOneDir-mdapiToSource-win32 14071 ms 14187 ms 0.99

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

Please sign in to comment.