-
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
Add SFDX: Create LWC Bundle command #277
Conversation
@@ -0,0 +1,41 @@ | |||
/* |
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.
I moved all the command type declarations into salesforcedx-utils-vscode so we can share them.
@@ -10,6 +10,14 @@ import { | |||
Command, | |||
CommandExecution | |||
} from '@salesforce/salesforcedx-utils-vscode/out/src/cli'; | |||
import { |
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.
So, now we import them from the salesforcedx-utils-vscode package.
@@ -265,6 +273,21 @@ export async function activate(context: vscode.ExtensionContext) { | |||
scratchOrgDecorator.showOrg(); | |||
scratchOrgDecorator.monitorConfigChanges(); | |||
} | |||
|
|||
const api: any = { |
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.
We export these using https://code.visualstudio.com/docs/extensionAPI/vscode-api#_extensions
@DatGuyJonathan - I was deciding between the way we discussed and this way. Ultimately I felt this was better since it is more scalable. If we have other packages in the future, we want to allow them to add it in their package and not pollute core.
SfdxCommandlet, | ||
SfdxCommandletExecutor, | ||
SfdxWorkspaceChecker, | ||
channelService, |
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.
By exporting the singleton services, we ensure that there is only one instance of it so we won't have any weird behavior.
Had we somehow made what Gunnar was trying to do in microsoft/vscode-vsce#207 it still might not have worked because we lose the singleton-ness of the service and you could have multiple of the services activating.
import * as vscode from 'vscode'; | ||
import { nls } from '../messages'; | ||
|
||
const sfdxCoreExports = vscode.extensions.getExtension( |
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.
Here is how we import it.
The downside of this is that all of these things are exported as any
so we lose the type safety... 😞
* | ||
* If ommitted, we will assume _message. | ||
*/ | ||
export const messages = { |
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.
@ruthemmanuelle - These are the customer facing text. I followed what we had for lightning.
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, @vazexqi . I added one comment.
Codecov Report
@@ Coverage Diff @@
## develop #277 +/- ##
===========================================
+ Coverage 75.07% 82.04% +6.97%
===========================================
Files 116 134 +18
Lines 4414 5025 +611
Branches 728 833 +105
===========================================
+ Hits 3314 4123 +809
+ Misses 915 724 -191
+ Partials 185 178 -7
Continue to review full report at Codecov.
|
return vscode.Disposable.from(forceLightningLwcCreateCmd); | ||
} | ||
|
||
export async function activate(context: vscode.ExtensionContext) { |
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.
🐛 - I have to be careful while activating this command. It's actually possible for an extension to be installed without any of its extension-dependencies being installed (e.g, the user doesn't say install all dependencies, the user forcibly deletes the dependencies after, etc).
I need to have a check here for to ensure we don't activate if salesforcedx.salesforcedx-vscode-core exists and it has the api exported.
This is a bit more crucial because of the way the forceLightningLwcCreate
gets its dependencies since the series of const on the top of that file.
*In the future, forceLightningLwcCreate
is likely to move back into salesforcedx-vscode-core with the other create commands but for the time being, it's important to put it under here.
} | ||
} | ||
|
||
class ForceLightningLwcCreateExecutor extends (SfdxCommandletExecutor as { |
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.
This syntax is because of microsoft/TypeScript#17032
const fileNameGatherer = new SelectFileName(); | ||
const lightningFilePathExistsChecker = new LightningFilePathExistsChecker(); | ||
|
||
export async function forceLightningLwcCreate(explorerDir?: any) { |
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.
🎗 I cannot write a test (that will pass on our CI) for this until the next force-language-services@pre-release/release goes out since it has a dependency on that. The sfdx force:lightning:lwc:create
command is in there. That is not going to happen until next week.
warning_prompt_lightning_bundle_overwrite: | ||
'An LWC bundle with the specified path already exists in your workspace. Do you want to overwrite any existing files in this bundle?', | ||
warning_prompt_yes: 'Yes', | ||
warning_prompt_no: 'No' |
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.
Can we change these from 'Yes' and 'No' to 'Overwrite' and 'Cancel'? We try to be as specific as possible about these confirmations, since people often just skim the text and don't necessarily realize what they're agreeing to.
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.
Yes. The text was taken from the other scaffolding commands. I'll make those changes over there as well. Specifically, I will create a newconfirm_overwrite_text
This allows us to export the singletons and classes to the other modules. See https://code.visualstudio.com/docs/extensionAPI/vscode-api#_extensions
bb5b606
to
0b8db1c
Compare
@@ -83,35 +83,43 @@ | |||
"explorer/context": [ | |||
{ | |||
"command": "sfdx.force.apex.class.create", | |||
"when": "explorerResourceIsFolder && sfdx:project_opened" | |||
"when": | |||
"explorerResourceIsFolder && resourceFilename != aura && resourceFilename != lightningcomponents && sfdx:project_opened" |
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 would be nice if we could create a re-usable compound when-clause. I don't think they have that support yet though.
What's a LWC bundle? |
What does this PR do?
What issues does this PR fix or reference?
@W-4642992, W-4326859@