-
Notifications
You must be signed in to change notification settings - Fork 406
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
Refactor "create template commands" to reduce code duplication #1246
Conversation
aa32b81
to
15d3799
Compare
}).execute(cancellationToken); | ||
|
||
execution.processExitSubject.subscribe(async data => { | ||
this.logMetric(execution.command.logName, startTime); |
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.
It looks like the logging for the directory type (default or custom) is missing. I think it had to do with me making this branch before I added that in 😛 . Check out one of the command files in a more recent version of develop.
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.
Good catch!
@allileong The forceLightningLwcCreate command should be updated to use the baseTemplateCommand now as well. That one is sneaky because it's in the lwc package. Besides that and the logging comment I left it looks good to me! |
Codecov Report
@@ Coverage Diff @@
## develop #1246 +/- ##
===========================================
+ Coverage 70.99% 72.83% +1.83%
===========================================
Files 198 201 +3
Lines 7471 7332 -139
Branches 786 761 -25
===========================================
+ Hits 5304 5340 +36
+ Misses 2010 1834 -176
- Partials 157 158 +1
Continue to review full report at Codecov.
|
283ff79
to
bebb903
Compare
@@ -30,74 +30,6 @@ import { taskViewService } from '../statuses'; | |||
import { telemetryService } from '../telemetry'; | |||
import { getRootWorkspacePath, hasRootWorkspace } from '../util'; | |||
|
|||
export class LightningFilePathExistsChecker |
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.
Consolidated the 2 LightningFilePathExistsCheckers
(one was here and the other was in the salesforcedx-vscode-lwc
extension) and the FilePathExistsChecker
from this file, and moved it to the baseTemplateCommand.ts
file.
return inputs; | ||
} else { | ||
const overwrite = await notificationService.showWarningMessage( | ||
nls.localize('warning_prompt_file_overwrite', this.metadataLabel), |
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.
fileNameGatherer, | ||
outputDirGatherer | ||
), | ||
new ForceLightningAppCreateExecutor(), |
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.
With the exception of this line, each of the forceLightning*Create()
methods are exactly the same. This may be a place to further reduce code duplication in the future.
@@ -308,217 +304,6 @@ describe('Command Utilities', () => { | |||
}); | |||
}); | |||
|
|||
describe('LightningFilePathExistsChecker', () => { |
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.
These tests were moved to the baseTemplateCommand.test.ts
file.
}); | ||
}); | ||
|
||
describe('FilePathExistsChecker for Aura bundle', () => { |
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.
The tests from this line to the end of the file were moved from commands.test.ts
. With more time, I would have assessed whether we should be keeping these tests and whether or not more tests need to be added.
Hey @brpowell @lcampos, these code changes are ready for review. With more time, I would have liked to:
|
94c0a14
to
b863d5d
Compare
@jonnyhork I've made some updates to the PR and functionality wise it's ready, I just want to add a couple more tests and will then get it merged. I'm thinking this will be merged later today or early tomorrow. |
Great, thanks! |
nls.localize('force_lightning_app_create_text') | ||
); | ||
expect(lightningAppCreate.getDefaultDirectory()).to.equal('aura'); | ||
expect(lightningAppCreate.getFileExtension()).to.equal('.app'); |
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.
Since we're checking defaultDirectory and fileExtension, we might as well check the sourcePathStrategy for the commands too. For the bundles we want to make sure they're using BundlePathStrategy, o/w DefaultPathStrategy.
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.
Looks good. Just had a comment about checking source path strategy as part of the tests.
fyi @jonnyhork this is now in |
Thanks for the contribution! Unfortunately we can't verify the commit author(s): Allison Leong <a***@s***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, refresh the status of this Pull Request. |
Thanks for the contribution! Unfortunately we can't verify the commit author(s): Allison Leong <a***@s***.com> Luis Campos <l***@s***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, refresh the status of this Pull Request. |
What does this PR do?
salesforcedx-vscode-lwc
tosaleforcedx-vscode-core
What issues does this PR fix or reference?
W-5988755