generated from salesforcecli/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 21
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/delete custom labels #613
Merged
Merged
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
3350400
fix: deletes singular CL when from CLs when specified
WillieRuemmele 5eaea8a
test: fix logic caught by UT
WillieRuemmele 2b366dd
test: move NUT to it's own describe
WillieRuemmele 6cc016f
test: use TestSession
WillieRuemmele d37e090
test: create and set default SO
WillieRuemmele df11b53
test: devhub auth - auto
WillieRuemmele 6a4a295
test: if you're asserting on json, use the --json flag
WillieRuemmele a9de587
test: use my fork for consistency
WillieRuemmele 59d1e38
chore: nicely handle last CL delete, allow retrieve:start to only del…
WillieRuemmele a4f65da
test: remove deprecated command from NUTs
WillieRuemmele 7b5d263
chore: use method in STLgp
WillieRuemmele 5dcec48
chore: consume new STL changes
WillieRuemmele 7b7ecda
chore: optimize a bit more
WillieRuemmele 8327fec
chore: qa package for STL
mshanemc 4dd229b
chore: fix delete source output, errors
WillieRuemmele 8ccca3e
chore: merge main, resolve conflicts
WillieRuemmele 57d6aa8
Merge branch 'wr/deleteCustomLabels' of https://github.com/salesforce…
mshanemc 678d7be
chore: bump stl, consume label delete return type
mshanemc 612c8cf
chore: merge main, resolve conflicts
WillieRuemmele a96ab03
chore: bump stl
mshanemc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright (c) 2020, salesforce.com, inc. | ||
* All rights reserved. | ||
* 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 * as path from 'path'; | ||
import * as fs from 'fs'; | ||
import { expect } from 'chai'; | ||
|
||
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { AuthInfo, Connection } from '@salesforce/core'; | ||
import { DeployResultJson, RetrieveResultJson } from '../../../src/utils/types'; | ||
|
||
let session: TestSession; | ||
|
||
describe('CustomLabel source tracking', () => { | ||
before(async () => { | ||
session = await TestSession.create({ | ||
project: { | ||
gitClone: 'https://github.com/WillieRuemmele/sfdx-delete-customlabel', | ||
}, | ||
devhubAuthStrategy: 'AUTO', | ||
scratchOrgs: [ | ||
{ | ||
duration: 1, | ||
setDefault: true, | ||
wait: 10, | ||
config: path.join('config', 'project-scratch-def.json'), | ||
}, | ||
], | ||
}); | ||
}); | ||
|
||
after(async () => { | ||
await session?.zip(undefined, 'artifacts'); | ||
await session?.clean(); | ||
}); | ||
|
||
it('pushes to initiate the remote', () => { | ||
execCmd<DeployResultJson>('project:deploy:start --json', { ensureExitCode: 0 }); | ||
}); | ||
|
||
it("deletes the 'DeleteMe' CustomLabel", async () => { | ||
const clFile = path.join( | ||
session.project.dir, | ||
'force-app', | ||
'main', | ||
'default', | ||
'labels', | ||
'CustomLabels.labels-meta.xml' | ||
); | ||
const conn = await Connection.create({ | ||
authInfo: await AuthInfo.create({ | ||
username: session.orgs.get('default')?.username, | ||
}), | ||
}); | ||
const id = ( | ||
await conn.singleRecordQuery<{ Id: string }>("SELECT Id FROM CustomLabel WHERE name = 'DeleteMe'", { | ||
tooling: true, | ||
}) | ||
).Id; | ||
await conn.tooling.sobject('CustomLabel').delete(id); | ||
|
||
const result = execCmd<RetrieveResultJson>('project:retrieve:start --json', { ensureExitCode: 0 }).jsonOutput | ||
?.result; | ||
expect(result?.fileProperties).length.to.equal(1); | ||
expect(fs.existsSync(clFile)).to.be.true; | ||
expect(fs.readFileSync(clFile, { encoding: 'utf-8' })).to.not.include('DeleteMe'); | ||
expect(fs.readFileSync(clFile, { encoding: 'utf-8' })).to.include('KeepMe1'); | ||
}); | ||
|
||
it('deletes the remaining CustomLabel', async () => { | ||
const clFile = path.join( | ||
session.project.dir, | ||
'force-app', | ||
'main', | ||
'default', | ||
'labels', | ||
'CustomLabels.labels-meta.xml' | ||
); | ||
const conn = await Connection.create({ | ||
authInfo: await AuthInfo.create({ | ||
username: session.orgs.get('default')?.username, | ||
}), | ||
}); | ||
const ids = (await conn.tooling.query<{ Id: string }>('SELECT Id FROM CustomLabel')).records.map((r) => r.Id); | ||
await conn.tooling.sobject('CustomLabel').delete(ids); | ||
|
||
const result = execCmd<RetrieveResultJson>('force:source:pull -f', { ensureExitCode: 0 }).shellOutput.stdout; | ||
expect(fs.existsSync(clFile)).to.be.false; | ||
expect(result).to.contain('KeepMe1'); | ||
expect(result).to.contain('KeepMe2'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for every custom label in the CS, this calls STL.deleteCustomLabels on every label in the set.
Some of those are going to be targeted multiple times?
Maybe you want to do that filter of labels once at the top of the method rather than inside the per-component loop