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

W-16323982 - Command for tooling hub Komaci Offline Analysis #114

Closed
wants to merge 11 commits into from

Conversation

angelamuliu
Copy link

@angelamuliu angelamuliu commented Sep 20, 2024

⚠️ ### DO NOT MERGE UNTIL CORE RELEASE!

What does this PR do?

  • Adds command to open a browser tab navigating to the tooling hub tool -> Komaci Offline Analysis -> with arguments for lwc name, namespace piped in
  • Command shows up only for LWC relevant files in editor, explorer, and command palette (while file is open)
  • Instruments above command by extending CoreExtensionService to pull in telemetry service
  • Integration tests

https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07EE00001xNomIYAS/view

@angelamuliu angelamuliu requested a review from a team as a code owner September 20, 2024 23:23

// Deploy LWC so analysis runs against current code
// TODO: Commented out until TD-0215753 is delivered
// const result = await vscode.commands.executeCommand('sf.deploy.current.source.file');
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, where would have result be in the following code? It seems as though it's not required to create toolingHubUrl?

Copy link
Author

Choose a reason for hiding this comment

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

Result was originally going to be a boolean - true if deploy success, false if deploy false. This is in the air though, maybe they'd want to return a map with a status code.

It isn't necessary to build the url however - because we grab everything we need from the context (which file is open, namespace, etc).

Copy link
Contributor

@sfdctaka sfdctaka left a comment

Choose a reason for hiding this comment

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

LGTM!

@sfdctaka
Copy link
Contributor

@angelamuliu Can you run prettier please.

@angelamuliu
Copy link
Author

@sfdctaka I ran prettier:write and verify, both passed locally. I see the CICD is having issues with it though? Lmk if this is something to be worried about

@sfdctaka
Copy link
Contributor

sfdctaka commented Oct 2, 2024

@angelamuliu I made a PR to your branch. On my machine there was one file that needed to be formatted. Maybe that will get over this CI failures? I am certain that formatting will pass, however, this test failure I was also getting on my local machine. Do you see this too?
image

@khawkins
Copy link
Collaborator

khawkins commented Oct 3, 2024

@angelamuliu I made a PR to your branch. On my machine there was one file that needed to be formatted. Maybe that will get over this CI failures? I am certain that formatting will pass, however, this test failure I was also getting on my local machine. Do you see this too? image

I'm getting the test failure too. Wasn't sure if we just weren't at that point yet or not, but +1.

package.nls.json Outdated
@@ -6,6 +6,7 @@
"extension.commands.salesforce-mobile-offline.lwc-mobile.version": "Version of ESLint Plugin LWC Mobile to include in devDependencies",
"extension.commands.salesforce-mobile-offline.komaci.version": "Version of ESLint Plugin LWC Graph Analyzer to include in devDependencies",
"extension.commands.salesforce-mobile-offline.eslint.version": "Version of ESLint to include in devDependencies",
"extension.commands.salesforce-mobile-offline.toolinghub.liveKomaciAnalysis": "(TODO) Salesforce Mobile Offline: Live Komaci Analysis",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: This is where you make use of the category configuration option in package.json, similar to the linting command. So you'd take out the "Salesforce Mobile Offline:" part here, and let the category value/configuration add the prefix.

Copy link
Author

Choose a reason for hiding this comment

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

I had that originally actually - but while developing, I noticed it doesn't append the category consistently? I forget exactly which one out of command palette, editor, and context, but one or two of them was missing category.

I figure this is why the base project opts to have "SFDX:" coded into the command label itself.
https://github.com/forcedotcom/salesforcedx-vscode/blob/232e5af3d5d18d4816338e891175ade9bc3f37bf/packages/salesforcedx-vscode-core/package.nls.json

package.nls.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
});
}

static getUriFromActiveEditor = (): vscode.Uri | undefined => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's be consistent with the format of function definitions, unless there's a specific binding consideration here that I missed. The rest of the functions are defined as methods rather than arrow function properties.


static getUriFromActiveEditor = (): vscode.Uri | undefined => {
const editor = vscode.window.activeTextEditor;
if (editor && editor.document.languageId !== 'forcesourcemanifest') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Am I reading this correctly that we're only looking for the URIs of non-XML LWC files? It might be worth a brief comment here on the intention.

Copy link
Author

Choose a reason for hiding this comment

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

I'm going to remove this, it's not necessary since I later added file filtering (see package.json where command only shows up for js/ts/css/html)

But for extra context, this code is only triggered when accessing via command palette, and uri for the other files are things like "javascript" and "html." I originally copy pasted this snippet from the deploy command so unsure why they didn't want to include the js-meta file

static extractLwcNameFromSourceUri(
sourceUriInput: vscode.Uri | undefined
): string {
const path = sourceUriInput?.path ? sourceUriInput?.path : null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: nullish coalescing would be cleaner here:

const path = sourceUriInput?.path ?? null;

@khawkins
Copy link
Collaborator

Going to close this for the time being, as we're going to take a different approach for supporting its service.

@khawkins khawkins closed this Jan 13, 2025
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.

3 participants