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

fix: allow the same SC in delete and deploy manifests #1261

Merged
merged 12 commits into from
Mar 22, 2024

Conversation

WillieRuemmele
Copy link
Member

What does this PR do?

allows the same source component to be placed in all types of manifests (pre/post/manifest) simultaneously

What issues does this PR fix or reference?

@W-15231435@

Functionality Before

you could not pre-deploy-delete, deploy, or deploy, post-deploy-delete the same MD

Functionality After

now you can 🚀

@WillieRuemmele WillieRuemmele requested a review from a team as a code owner March 19, 2024 17:35
}
deletions.get(key)?.set(sourceKey(component), component);
this.destructiveComponents[deletionType].get(key)?.set(sourceKey(component), component);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's subjective, but I find the previous version of the code easier to read.

Copy link
Member Author

Choose a reason for hiding this comment

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

but it doesn't end up updating anything of importance the old way.

@@ -721,7 +739,7 @@ export class ComponentSet extends LazyCollection<MetadataComponent> {

const sourceKey = (component: SourceComponent): string => {
const { fullName, type, xml, content } = component;
return `${type.name}${fullName}${xml ?? ''}${content ?? ''}`;
return `${type.name}${fullName}${xml ?? ''}${content ?? ''}${component.isMarkedForDelete()}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

If this really is needed I think it should be more descriptive than appending false or true. I'm hopeful that we can rely on the source components being accurate and assigning them into the correct component sets on add.

@shetzel
Copy link
Contributor

shetzel commented Mar 21, 2024

QA:
package-classes.xml -> contains all classes in the project
preDestructiveChanges-class.xml -> contains 1 class; Foo.cls which also exists in the project
preDestructiveChanges-classes.xml -> contains 2 classes; Foo.cls and Bar.cls which also exist in the project
`package-empty.xml -> no types listed

  1. project deploy start --manifest package-classes.xml --pre-destructive-changes preDestructiveChanges-class.xml -> deletes a class (Foo) in pre, deploys all classes including Foo. ✅ Output does not explicitly display deleted class Foo.
  2. project deploy start --manifest package-empty.xml --pre-destructive-changes preDestructiveChanges-class.xml -> deletes a class (Foo) in pre. ✅ Output lists that the class was deleted in a deleted section and also was deleted in the deploy section, which is likely from PDR.
  3. project deploy start --manifest preDestructiveChanges-class.xml --pre-destructive-changes preDestructiveChanges-class.xml -> deletes a class (Foo) in pre, then deploys that same class. ✅ Output does not explicitly display deleted class Foo.
  4. project deploy start --manifest package-classes.xml --pre-destructive-changes preDestructiveChanges-classes.xml -> deletes classes (Foo and Bar) in pre, deploys all classes including Foo and Bar. ✅ Output does not explicitly display deleted classes Foo and Bar.
  5. project deploy start --manifest package-classes.xml --pre-destructive-changes package-empty.xml -> nothing deleted. all classes deployed. ✅

@@ -11,8 +11,8 @@ import { statSync, existsSync, readdirSync, createReadStream, readFileSync } fro
import * as JSZip from 'jszip';
import { Messages, SfError } from '@salesforce/core';
import { isString } from '@salesforce/ts-types';
import { baseName, parseMetadataXml } from '../utils/path';
import type { SourcePath } from '../common/types';
import { baseName, parseMetadataXml } from '../utils';
Copy link
Contributor

Choose a reason for hiding this comment

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

lets only load the required files instead of the barrel

destructiveChangeType === DestructiveChangesType.PRE
? (this.destructiveChangesType = DestructiveChangesType.PRE)
: (this.destructiveChangesType = DestructiveChangesType.POST);
this.destructiveChangesType =
Copy link
Contributor

Choose a reason for hiding this comment

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

I had to stare at this one for a second. comment could be
// [POST, true, undefined ] => POST. Only PRE means PRE

@WillieRuemmele WillieRuemmele merged commit d4c7f53 into main Mar 22, 2024
68 checks passed
@WillieRuemmele WillieRuemmele deleted the wr/deleteAndDeploy branch March 22, 2024 16:02
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.

4 participants