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

Wr/destructive deploy #230

Merged
merged 10 commits into from
Oct 21, 2021
Merged

Wr/destructive deploy #230

merged 10 commits into from
Oct 21, 2021

Conversation

WillieRuemmele
Copy link
Contributor

@WillieRuemmele WillieRuemmele commented Sep 28, 2021

WARNING: BEFORE MERGING BUMP SDR VERSION TO 5.0.0

What does this PR do?

a draft PR adding destructive operations to the deploy command

QA notes:
link this SDR PR

generate manifests with source:manifest:create

What issues does this PR fix or reference?

@W-9892380@

throw SfdxError.create('@salesforce/plugin-source', 'deploy', 'MissingRequiredParam', [this.xorFlags.join(', ')]);
}

if ((this.flags.predestructivechanges || this.flags.postdestructivechanges) && !this.flags.manifest) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why custom validation rather than dependsOn : ['manifest'] on these flags?

@@ -107,7 +108,7 @@ export class DeployResultFormatter extends ResultFormatter {

protected displaySuccesses(): void {
if (this.isSuccess() && this.fileResponses?.length) {
const successes = this.fileResponses.filter((f) => f.state !== 'Failed');
const successes = this.fileResponses.filter((f) => f.state !== 'Failed' && f.state !== 'Deleted');
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const successes = this.fileResponses.filter((f) => f.state !== 'Failed' && f.state !== 'Deleted');
const successes = this.fileResponses.filter((f) => !['Failed','Deleted'].includes(f.state);

src/commands/force/source/deploy.ts Show resolved Hide resolved
execCmd(`force:source:manifest:create --metadata ${metadata} --manifesttype ${manifesttype}`);
};

const query = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const query = (
const sourceMemberQuery = (

): { result: { records: Array<{ IsNameObsolete: boolean }> } } => {
return JSON.parse(
exec(
`sfdx force:data:soql:query -q "SELECT IsNameObsolete FROM SourceMember WHERE MemberType='${memberType}' AND MemberName='${memberName}'" -t --json`,
Copy link
Contributor

Choose a reason for hiding this comment

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

one alternative is to create a Connection (since you have the username in testkit.project.setup from the org:create command) and use the query or singleRecordQuery features there. It's probably faster than the shell route and you can use its support

});

describe('errors', () => {
it('should throw an error when a destructive flag is passed without the manifest flag', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens when a value of destructive flag is passed, but the file doesn't exist (typo, or user in wrong directory level, etc)

{ silent: true }
)
) as { result: { records: Array<{ IsNameObsolete: boolean }> } };
const isNameObsolete = async (memberType: string, memberName: string): Promise<boolean> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

that turned out nice.

Copy link
Contributor

@mshanemc mshanemc left a comment

Choose a reason for hiding this comment

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

looks OK except for the xorFlag stuff disappearing

I assume the tests would have caught that if you had SDRv5 available?

@@ -21,18 +21,6 @@ export abstract class DeployCommand extends SourceCommand {
});

protected deployResult: DeployResult;

protected validateFlags(): void {
// verify that the user defined one of the flag names specified in requiredFlags property
Copy link
Contributor

Choose a reason for hiding this comment

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

don't you still need the xorFlag validations?

Copy link
Contributor Author

@WillieRuemmele WillieRuemmele Oct 13, 2021

Choose a reason for hiding this comment

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

it's handled in the SourceCommand base class still - that method overrode it to add the post/pre flag validation that's fixed with dependsOn property in the flag definition

Copy link
Contributor

@shetzel shetzel left a comment

Choose a reason for hiding this comment

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

LGTM

const { apexName } = createApexClass();

createManifest('ApexClass:GeocodingService', 'package');
createManifest(`ApexClass:${apexName}`, 'pre');
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe you want to use the post name here ?

@WillieRuemmele WillieRuemmele merged commit e18c197 into main Oct 21, 2021
@WillieRuemmele WillieRuemmele deleted the wr/destructiveDeploy branch October 21, 2021 15:12
mshanemc added a commit that referenced this pull request Oct 23, 2021
…ename

* fix: show conflicts from both remote and local, including remote filename

* test: better output, workaroun for Audience type

* fix: push gets its own formatter for json reasons

* fix: missing pull messages

* chore: bump SDR to 4.5.7 (#253)

* chore(release): 1.2.3 [ci skip]

* Updated/Added CODEOWNERS with ECCN

* chore(release): 1.2.4 [ci skip]

* chore: sync .gitignore [skip-validate-pr] (#251)

Authored via Leif

* test: parallelize nuts, exclude async deploy nut

* test: one NUT for special types

* test: remove tracking NUTs

* ci: custom nut commands

* test: fix folderTypes, cross-env for windows

* test:  cross-env for windows SEED_FILTER, nyc only top-level

* ci: no sha; change nut order

* test: deploy nuts in parallel

* ci: disable async nuts

* test: exclude async nuts

* test: revert async-exclude

* test: revert tsconfig, revert config.yml

* test: exclude env for seeds

* feat: mark ignores

* feat: status shows remote ignores

* refactor: consistent naming of command classes

* refactor: push feedback

* style: comment is no longer a question

* test: ebikes from clone instead of fs

* fix: status flags are better

* test: nuts with conn adjusted for git checkout

* chore: bump sdr for Created state fix

* test: unignore profiles

* test: was not using ebikes, revert

* chore: change status' flags in snapshot

* refactor: move status logic to STL

* test: update ignore nut

* style: formatting line length

* fix: push uses correct json

* test: update tests for new push json format

* test: ut on lts, not node17

* Wr/destructive deploy (#230)

* fix: implementing destructive change deploy, 1 NUT

* chore: add NUTs, fix UTs

* chore: post-review board updates

* chore: fix linting

* chore: minor updates to flag logic, redo NUT query method

* chore: remove unnecessary checks in NUTs

* chore: bump SDR to 5, include deploy:destructive in NUTs

* chore(release): 1.2.5 [ci skip]

* fix: use cross-env for test:nuts script (#260)

* chore(release): 1.2.6 [ci skip]

* chore: unhide beta commands

* chore: bump SDR and STL

* test: and tracking nuts

* ci: windows UT

* test: nuts are hub-auth-agnostic

* ci: windows only

* ci: restore windows tests

Co-authored-by: Willie Ruemmele <[email protected]>
Co-authored-by: SF-CLI-BOT <[email protected]>
Co-authored-by: svc-scm <[email protected]>
Co-authored-by: Steve Hetzel <[email protected]>
mshanemc added a commit that referenced this pull request Oct 28, 2021
* refactor: redo open for sfdx-core dependency reasons

* test: ebikes for nuts

* feat: source tracking commands in source:beta

* test: nuts for source tracking commands

* docs: new subtopics

* chore: remove imported asserted project/org

* chore: restore breaking comma

* chore: bump source tracking version

* chore: rebuild with latest lockfile

* refactor: feedback from WR

* style: typo and cleaner concats

* chore: pr feedback

* refactor: pull more like retrieve

* refactor: status formatter

* test: remove unused export

* chore: bump stl

* fix: missing header for pull

* fix: show conflicts from both remote and local, including remote filename

* test: better output, workaroun for Audience type

* refactor: consistent naming of command classes

* refactor: push feedback

* style: comment is no longer a question

* test: ebikes from clone instead of fs

* fix: status flags are better

* test: nuts with conn adjusted for git checkout

* chore: bump sdr for Created state fix

* test: unignore profiles

* test: was not using ebikes, revert

* chore: change status' flags in snapshot

* feat: show conflicts from both remote and local, including remote filename

* fix: show conflicts from both remote and local, including remote filename

* test: better output, workaroun for Audience type

* fix: push gets its own formatter for json reasons

* fix: missing pull messages

* chore: bump SDR to 4.5.7 (#253)

* chore(release): 1.2.3 [ci skip]

* Updated/Added CODEOWNERS with ECCN

* chore(release): 1.2.4 [ci skip]

* chore: sync .gitignore [skip-validate-pr] (#251)

Authored via Leif

* test: parallelize nuts, exclude async deploy nut

* test: one NUT for special types

* test: remove tracking NUTs

* ci: custom nut commands

* test: fix folderTypes, cross-env for windows

* test:  cross-env for windows SEED_FILTER, nyc only top-level

* ci: no sha; change nut order

* test: deploy nuts in parallel

* ci: disable async nuts

* test: exclude async nuts

* test: revert async-exclude

* test: revert tsconfig, revert config.yml

* test: exclude env for seeds

* feat: mark ignores

* feat: status shows remote ignores

* refactor: consistent naming of command classes

* refactor: push feedback

* style: comment is no longer a question

* test: ebikes from clone instead of fs

* fix: status flags are better

* test: nuts with conn adjusted for git checkout

* chore: bump sdr for Created state fix

* test: unignore profiles

* test: was not using ebikes, revert

* chore: change status' flags in snapshot

* refactor: move status logic to STL

* test: update ignore nut

* style: formatting line length

* fix: push uses correct json

* test: update tests for new push json format

* test: ut on lts, not node17

* Wr/destructive deploy (#230)

* fix: implementing destructive change deploy, 1 NUT

* chore: add NUTs, fix UTs

* chore: post-review board updates

* chore: fix linting

* chore: minor updates to flag logic, redo NUT query method

* chore: remove unnecessary checks in NUTs

* chore: bump SDR to 5, include deploy:destructive in NUTs

* chore(release): 1.2.5 [ci skip]

* fix: use cross-env for test:nuts script (#260)

* chore(release): 1.2.6 [ci skip]

* chore: unhide beta commands

* chore: bump SDR and STL

* test: and tracking nuts

* ci: windows UT

* test: nuts are hub-auth-agnostic

* ci: windows only

* ci: restore windows tests

Co-authored-by: Willie Ruemmele <[email protected]>
Co-authored-by: SF-CLI-BOT <[email protected]>
Co-authored-by: svc-scm <[email protected]>
Co-authored-by: Steve Hetzel <[email protected]>

* Sm/quiet-flag (#259)

* fix: push gets its own formatter for json reasons

* fix: missing pull messages

* feat: mark ignores

* feat: status shows remote ignores

* refactor: move status logic to STL

* test: update ignore nut

* style: formatting line length

* fix: push uses correct json

* test: update tests for new push json format

* test: ut on lts, not node17

* test: include tracking nuts

* feat: quiet flag on push (for stdout and json)

* test: put the individual tracking nuts back

* feat: quiet shows only failures in json

* refactor: simplify quiet logic

* test: ut for formatter with quiet

* feat: show ignored if any

* refactor: ignored as first column

* fix: no spinner for conflict check on --overwrite

* fix: early exit when there are no results

* fix: handle no-result (deletes only, or no changes)

* chore: bump sdr and stl

Co-authored-by: Willie Ruemmele <[email protected]>
Co-authored-by: SF-CLI-BOT <[email protected]>
Co-authored-by: svc-scm <[email protected]>
Co-authored-by: Steve Hetzel <[email protected]>
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