Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom registry support #552

Merged
merged 13 commits into from
Mar 28, 2024
Merged

custom registry support #552

merged 13 commits into from
Mar 28, 2024

Conversation

mshanemc
Copy link
Contributor

requires forcedotcom/source-deploy-retrieve#1217

What does this PR do?

componentSet and Resolver allow the passing in a registry.

STL will now resolve the registry once when instantiated, from the projectDir, and pass that around to everything that needs it.

What issues does this PR fix or reference?

part of making @W-14608988@ work with tracking

@@ -13,3 +22,23 @@ export const metadataMemberGuard = (
input: MetadataMember | undefined | Partial<MetadataMember>
): input is MetadataMember =>
input !== undefined && typeof input.fullName === 'string' && typeof input.type === 'string';

export const isSdrFailure = (fileResponse: FileResponse): fileResponse is FileResponseFailure =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a few of these already exist in PDR and probably could ship in SDR if they'd be broadly useful.

@@ -8,20 +8,9 @@ import { ForceIgnore, MetadataComponent, MetadataMember, RegistryAccess } from '
import { SfError } from '@salesforce/core';
import { filePathsFromMetadataComponent } from '@salesforce/source-deploy-retrieve/lib/src/utils/filePathGenerator';
import { ChangeResult } from './types';

export const changeResultToMetadataComponent = (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to the shared functions module for re-use

@mshanemc mshanemc requested a review from a team as a code owner March 28, 2024 14:26
@@ -26,15 +27,14 @@ export const findConflictsInComponentSet = (cs: ComponentSet, conflicts: ChangeR
// map do dedupe by name-type-filename
const conflictMap = new Map<string, ConflictResponse>();
conflicts
.filter((cr) => cr.name && cr.type && cs.has({ fullName: cr.name, type: cr.type }))
.filter(isChangeResultWithNameAndType)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

isChangeResultWithNameAndType narrows the ConflictResponse so that other functions can depend on those props existing

@@ -25,29 +33,39 @@ export const getKeyFromObject = (element: RemoteChangeElement | ChangeResult): s

export const supportsPartialDelete = (cmp: SourceComponent): boolean => !!cmp.type.supportsPartialDelete;

export const isLwcLocalOnlyTest = (filePath: string): boolean =>
filePath.includes('__utam__') || filePath.includes('__tests__');
export const excludeLwcLocalOnlyTest = (filePath: string): boolean =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just inverted it for clearer use as a filter. Both uses were negated by the consumer

export const getComponentSets = ({
groupings,
sourceApiVersion,
registry = new RegistryAccess(),
Copy link
Contributor Author

@mshanemc mshanemc Mar 28, 2024

Choose a reason for hiding this comment

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

feat: accepts a custom registry for passing to the metadataConverter

3 props so now it's an obj

}: {
elements: ChangeResult[];
packageDirPaths: string[];
registry: RegistryAccess;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

another place that needed the registry

@@ -61,6 +67,7 @@ export const populateFilePaths = (elements: ChangeResult[], packageDirPaths: str
const matchingLocalSourceComponentsSet = ComponentSet.fromSource({
fsPaths: packageDirPaths,
include: remoteChangesAsComponentSet,
registry,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

...here

@@ -84,10 +94,9 @@ export const populateFilePaths = (elements: ChangeResult[], packageDirPaths: str
...elementMap.get(key),
modified: true,
origin: 'remote',
filenames: [matchingComponent.xml as string, ...matchingComponent.walkContent()].filter((filename) => filename),
filenames: getAllFiles(matchingComponent),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

several places use [xml, ...walkContent] and then have filter out non-strings, so that's now shared fn

.filter(sourceComponentGuard);
// component set generated from the filenames on all local changes
const resolver = new MetadataResolver(
registry,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

needed custom reg here

@WillieRuemmele WillieRuemmele merged commit 07049cf into main Mar 28, 2024
30 checks passed
@WillieRuemmele WillieRuemmele deleted the sm/custom-registry-support branch March 28, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants