Skip to content

Fix packaging #157

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

Merged
merged 18 commits into from
Nov 19, 2024
Merged

Fix packaging #157

merged 18 commits into from
Nov 19, 2024

Conversation

sfdctaka
Copy link
Contributor

What does this PR do?

This PR consolidates 3 packages into one. There were 3 packages:

  1. Root. The gateway to extension
  2. LSP client
  3. LSP server

Consolidation allows:

  1. Packaging. npm workspace which was used before is removed because it was using symbolic links to child packages. And npx vsce package wasn't supporting symbolic links thus not producing vsix distributable.
  2. Give us a clean slate to eventually break the single package into multiple packages. Before this PR a clean code sharing was hard and code duplication was made.


const SETTING_KEY_SUPPRESS_ALL = 'suppressAll';
const SETTING_KEY_SUPPRESS_BY_RULE_ID = 'suppressByRuleId';

export function getUpdateDiagnosticsSettingCommand(
context: vscode.ExtensionContext
): string {
return `${getExtensionName(context)}.updateDiagnosticsSetting`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

getExtensionName() was only used here so no need to have a method defined in workspaceUtils.ts.

import { WorkspaceFolder } from 'vscode-languageserver';

export class WorkspaceUtils {
// WorkspaceFolders is null if Workspace is not configured
export class ServerWorkspace {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much of ServerWorkspace came from WorkspaceUtils which most of it was a code from previous iteration prior to LSP. The reason LSP needs a ServerWorkspace was because it wanted to stash workspaceFolders property(next line in the code) that gets passed to when the LSP server is initialized.

Rather than duplicating WorkspaceUtils, I created a property bag class with managing workspaceFolders property. Static methods are essentially the same as they were implemented when LSP feature was done.

Copy link
Contributor

@maliroteh-sf maliroteh-sf Nov 15, 2024

Choose a reason for hiding this comment

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

Hmm.... I'm not sure how I feel about ServerWorkspace as the name and I think we should stick to the original class+file name. This file contains helper code around the concept of Workspace in an extension, and to that end Server or Client workspace doesn't make sense (not to me at least).... but I'll differ to others on this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Discussed offline and will keep as is in this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

WorkSpaceFolder in the LSP server and VS Code are two distinct classes. In the previous workspace structure, the server and client were independent packages, so using workspace as a name made sense within a self-contained project. Now that we've consolidated everything into a single package, renaming it to ServerWorkSpace is more appropriate to distinguish it from VS Code's workspace.

Comment on lines +8 to +9
export const CORE_EXTENSION_ID = 'salesforce.salesforcedx-vscode-core';
export const SFDX_PROJECT_FILE = 'sfdx-project.json';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These constants, too, were originally defined in root, which moved to LSP server and then reverse exported back to the root project. Since we're consolidating they're back to where they were.

key: 'target-org'
};

export class TempProjectDirManager {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TempProjectDirManager coming back to the file where it was originally.

@@ -24,7 +24,7 @@ export function activate(
) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is renamed from extension.ts to client.ts. Extension.ts should be used for the main entry point in an extension. So following the same spirit as lsp/server I named it client.ts. I thought of changing activate() too since it could be anything if it is not an extension. Besides, it's taking extra parameters in updateDiagnosticSettingCommand and diagnosticSettingSection that aren't expected by extension loader. But changing the file name suffices so I left activate() as is.

Copy link
Contributor

@maliroteh-sf maliroteh-sf left a comment

Choose a reason for hiding this comment

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

Left some comments for your considerations. For some of the feedback we can see how the rest of the team feels about them so don't feel obligated to change things right away... if others are ok with the way things are in your PR then we can go as is.

@khawkins
Copy link
Collaborator

Nit: Do we need a yaml/ subdirectory under resources/? Seems like a folder structure that would benefit from being as flat as possible, at least for this project.

@sfdctaka
Copy link
Contributor Author

@khawkins yaml/ folder is not necessary. I have it so that it would look like it's logically divided like its sibling folders instructions and templates. I'll remove it.

@khawkins
Copy link
Collaborator

We lost esbuild as part of #127. We can't package without it.

@sfdctaka sfdctaka force-pushed the fixPackaging branch 14 times, most recently from 6861c18 to ddac535 Compare November 19, 2024 07:41
@sfdctaka sfdctaka force-pushed the fixPackaging branch 5 times, most recently from 865a22b to be50e99 Compare November 19, 2024 08:22
Copy link
Contributor

@ben-zhang-at-salesforce ben-zhang-at-salesforce left a comment

Choose a reason for hiding this comment

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

looks good for me, great job.

"compile": "rimraf ./out/tsconfig.tsbuildinfo && tsc -b ./ && npm run copy-yaml",
"copy-yaml-win": "mkdir out\\src\\resources && copy resources\\component-experiences.yaml out\\src\\resources",
"copy-yaml-unix": "mkdir -p ./out/src/resources && cp ./resources/component-experiences.yaml ./out/src/resources",
"copy-yaml": "npm run copy-yaml-win || npm run copy-yaml-unix",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This...is not my favorite, relying on fatal errors in the shell to take affirmative alternative action. It can be risky, and is otherwise not super intuitive. A more standard and maintainable way to do this would be to create a basic Node utility module to manage the logic. We know we have a Node.js environment in either case, so we can write a pretty simple OS-agnostic script with fs, path, and os to do the copying, give it an identifiable name, and voila, maintainable code. 🙂

It's slightly more code than this, but IMO it's easier to maintain, and more intuitive to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me take care in another PR. (This PR got merged few minutes ago.)

I think I remember why I had yaml folder under resources folder. It's because I was able to use cp -r. Since the yaml file was move and cp was failing on copying a single file claiming it can't find resources folder.

Copy link
Contributor

@haifeng-li-at-salesforce haifeng-li-at-salesforce left a comment

Choose a reason for hiding this comment

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

LGTM. Great job!

@sfdctaka sfdctaka merged commit 23757e6 into salesforce:main Nov 19, 2024
7 checks passed
@sfdctaka sfdctaka deleted the fixPackaging branch November 19, 2024 18:44
@@ -60,8 +60,8 @@ export function activate(

// Create the language client and start the client.
client = new LanguageClient(
'LSP Mobile',
'LSP Mobile Client',
'Salesforce Mobile Language Server',
Copy link
Collaborator

Choose a reason for hiding this comment

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

This first item would typically be an identifier, e.g. salesforceMobileLanguageServer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍
Will take care of this along with the above feedback that you made.

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.

5 participants