Skip to content

Wr/caching #1423

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: fix lint warnings
WillieRuemmele committed Sep 17, 2024

Verified

This commit was signed with the committer’s verified signature.
WillieRuemmele Willie Ruemmele
commit 5e08eb4f8f8458146a1b3c1b82cd241a567a2aa7
2 changes: 1 addition & 1 deletion src/client/metadataApiDeploy.ts
Original file line number Diff line number Diff line change
@@ -103,8 +103,8 @@ export class MetadataApiDeploy extends MetadataTransfer<

public constructor(options: MetadataApiDeployOptions) {
super(options);
options.apiOptions = { ...MetadataApiDeploy.DEFAULT_OPTIONS.apiOptions, ...options.apiOptions };
this.options = Object.assign({}, options);
this.options.apiOptions = { ...MetadataApiDeploy.DEFAULT_OPTIONS.apiOptions, ...options.apiOptions };
this.isRestDeploy = !!options.apiOptions?.rest;
this.registry = options.registry ?? new RegistryAccess();
if (this.mdapiTempDir) {
11 changes: 6 additions & 5 deletions src/convert/replacements.ts
Original file line number Diff line number Diff line change
@@ -117,16 +117,17 @@ class ReplacementMarkingStream extends Transform {
encoding: string,
callback: (err: Error | undefined, data: SourceComponent) => void
): Promise<void> {
const toBeReturned = chunk;
let err: Error | undefined;
// if deleting, or no configs, just pass through
if (!chunk.isMarkedForDelete() && this.replacementConfigs?.length) {
if (!toBeReturned.isMarkedForDelete() && this.replacementConfigs?.length) {
try {
chunk.replacements = await getReplacements(chunk, this.replacementConfigs);
if (chunk.replacements && chunk.parent?.type.strategies?.transformer === 'nonDecomposed') {
toBeReturned.replacements = await getReplacements(toBeReturned, this.replacementConfigs);
if (toBeReturned.replacements && toBeReturned.parent?.type.strategies?.transformer === 'nonDecomposed') {
// Set replacements on the parent of a nonDecomposed CustomLabel as well so that recomposing
// doesn't use the non-replaced content from parent cache.
// See RecompositionFinalizer.recompose() in convertContext.ts
chunk.parent.replacements = chunk.replacements;
toBeReturned.parent.replacements = toBeReturned.replacements;
}
} catch (e) {
if (!(e instanceof Error)) {
@@ -135,7 +136,7 @@ class ReplacementMarkingStream extends Transform {
err = e;
}
}
callback(err, chunk);
callback(err, toBeReturned);
}
}

12 changes: 7 additions & 5 deletions src/resolve/adapters/decomposedSourceAdapter.ts
Original file line number Diff line number Diff line change
@@ -83,6 +83,8 @@ export class DecomposedSourceAdapter extends MixedContentSourceAdapter {
isResolvingSource?: boolean
): SourceComponent | undefined {
const metaXml = parseMetadataXml(trigger);
const toBeReturned = component;

if (metaXml?.suffix) {
const pathToContent = this.trimPathToContent(trigger);
const childTypeId = this.type.children?.suffixes?.[metaXml.suffix];
@@ -97,7 +99,7 @@ export class DecomposedSourceAdapter extends MixedContentSourceAdapter {
) {
if (strategy === 'folderPerType' || strategy === 'topLevel' || isResolvingSource) {
const parent =
component ??
toBeReturned ??
new SourceComponent(
{
name: strategy === 'folderPerType' ? baseName(pathToContent) : pathToContent,
@@ -118,18 +120,18 @@ export class DecomposedSourceAdapter extends MixedContentSourceAdapter {
this.forceIgnore
);
}
} else if (!component) {
} else if (!toBeReturned) {
// This is most likely metadata found within a CustomObject folder that is not a
// child type of CustomObject. E.g., Layout, SharingRules, ApexClass.
throw new SfError(
messages.getMessage('error_unexpected_child_type', [trigger, this.type.name]),
'TypeInferenceError'
);
}
if (component) {
component.content = pathToContent;
if (toBeReturned) {
toBeReturned.content = pathToContent;
}
}
return component;
return toBeReturned;
}
}
7 changes: 4 additions & 3 deletions src/resolve/adapters/matchingContentSourceAdapter.ts
Original file line number Diff line number Diff line change
@@ -39,8 +39,9 @@ export class MatchingContentSourceAdapter extends BaseSourceAdapter {

protected populate(trigger: SourcePath, component: SourceComponent): SourceComponent {
let sourcePath: SourcePath | undefined;
const toBeReturned = component;

if (component.xml === trigger) {
if (toBeReturned.xml === trigger) {
const fsPath = removeMetaXmlSuffix(trigger);
if (this.tree.exists(fsPath)) {
sourcePath = fsPath;
@@ -58,8 +59,8 @@ export class MatchingContentSourceAdapter extends BaseSourceAdapter {
throw messages.createError('noSourceIgnore', [this.type.name, sourcePath]);
}

component.content = sourcePath;
return component;
toBeReturned.content = sourcePath;
return toBeReturned;
}
}

10 changes: 6 additions & 4 deletions src/resolve/adapters/mixedContentSourceAdapter.ts
Original file line number Diff line number Diff line change
@@ -67,10 +67,12 @@ export class MixedContentSourceAdapter extends BaseSourceAdapter {
);
}

if (component) {
component.content = contentPath;
let toBeReturned = component;

if (toBeReturned) {
toBeReturned.content = contentPath;
} else {
component = new SourceComponent(
toBeReturned = new SourceComponent(
{
name: baseName(contentPath),
type: this.type,
@@ -82,7 +84,7 @@ export class MixedContentSourceAdapter extends BaseSourceAdapter {
);
}

return component;
return toBeReturned;
}

/**