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

[rush] VSCode Extension #3162

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

chengcyber
Copy link
Contributor

@chengcyber chengcyber commented Jan 16, 2022

Summary

RushStack VSCode Extention

Details

Fixes #3157

How to develop in local

  1. Prepare
rush update
rush build --to rushstack
  1. Run predefined launcher in your VSCode

2022-02-05 at 5 29 AM

  1. Play in Extension Host

a [Extension Development Host] window should popup if everything works fine. Open a rush project now

2022-02-05 at 5 34 AM

2022-02-05 at 5 35 AM

2022-02-05 at 5 59 AM

How to pack a production version and install it locally

Run the following command, a vsix format file called "rushstack-0.0.0.vsix" will be generated.

cd vsce/vscode-extension
rushx package

Run code --install-extension rushstack-0.0.0.vsix to install the prod version of rushstack vscode extension
Run code --uninstall-extension rushstack to uninstall it

Recipe: code --uninstall-extension rushstack || true && code --install-extension rushstack-0.0.0.vsix

@chengcyber chengcyber changed the title feat(vscode-extension): hello world [rush] VSCode Extension Jan 16, 2022
@chengcyber chengcyber force-pushed the feat-vscode-extension branch from 773045f to 15afb42 Compare January 16, 2022 15:04
@chengcyber
Copy link
Contributor Author

chengcyber commented Mar 3, 2022

Questions 2022/3/3

  1. The way to get RushConfiguration and RushCommandLineParser
    1.1 RushConfiguration is used to extract projects.
    1.2 RushCommandLineParser is used to extract Rush commands and parameters
    For now, the idea is leverage rush-sdk, making rush-sdk supports reload from another location, may related with [rush] Refactor rush-sdk to expose a loader API. #3212

  2. rush add is a smart CLI, it uses the working directory (cwd) to decide the target project where the package should be installed to. It can be hardcode in Extension side like rush add push a project selector, or involving sth like a parameter configuration to make it as a canonical use case.

@iclanton
Copy link
Member

iclanton commented Apr 9, 2022

Note: PR #3337 has renamed our GitHub master branch to main. This should not affect your pull request, but we recommend to redo your git clone to avoid confusion with the old branch name.

"dependencies": {
"@microsoft/rush-lib": "workspace:*",
"@rushstack/node-core-library": "workspace:*",
"@rushstack/rush-sdk": "workspace:*",
Copy link
Contributor

Choose a reason for hiding this comment

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

The trick to running webpack on @rushstack/rush-sdk is the @rushstack/webpack-preserve-dynamic-require-plugin, FYI.

@chengcyber chengcyber force-pushed the feat-vscode-extension branch 3 times, most recently from 3c343eb to 0bf58a3 Compare November 23, 2022 14:37
@chengcyber chengcyber force-pushed the feat-vscode-extension branch 2 times, most recently from 37b58fe to 7c7ef34 Compare November 23, 2022 16:06
@chengcyber chengcyber force-pushed the feat-vscode-extension branch from 7c7ef34 to 7142099 Compare November 24, 2022 02:00
@chengcyber
Copy link
Contributor Author

Thanks to the hints from David's PR: #3651

I updated the building and packing process to rushstack vscode extension

Now, in extension development, it will be always try to load @microsoft/rush-lib first, while in a production version of extension, it will try to load @rushstack/rush-sdk from current workspace folders.

Also, this extension can be correctly packed to a "visx" format file, which means it's ready to be published to VSCode marketplace!

@chengcyber chengcyber marked this pull request as ready for review November 29, 2022 11:53
"outFiles": [
"${workspaceFolder}/vscode-extensions/rush-vscode-extension/dist/**/*.js"
],
"preLaunchTask": "npm: build:watch - vscode-extensions/rush-vscode-extension"
Copy link
Member

@TheLarkInn TheLarkInn Dec 6, 2022

Choose a reason for hiding this comment

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

Do heft commands work instead as the preLaunchTask?

@@ -154,6 +154,8 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/repo-scripts/generate-api-docs](./repo-scripts/generate-api-docs/) | Used to generate API docs for the rushstack.io website |
| [/repo-scripts/repo-toolbox](./repo-scripts/repo-toolbox/) | Used to execute various operations specific to this repo |
| [/rush-plugins/rush-litewatch-plugin](./rush-plugins/rush-litewatch-plugin/) | An experimental alternative approach for multi-project watch mode |
| [/vscode-extensions/rush-vscode-command-webview](./vscode-extensions/rush-vscode-command-webview/) | Webview to run rush command in VSCode Extension |
Copy link
Member

Choose a reason for hiding this comment

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

I think we should use rushstack instead of rush as the language here. This extension will be a collection of all the relevant rushstack tools. In the future we wouldn't want an extension for rush, heft, etc.


useEffect(() => {
// const defaultValues: FieldValues = defaultValuesRef.current;
console.log('rest', defaultValues);
Copy link
Member

Choose a reason for hiding this comment

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

Remove console.log

}, [form]);
const { control, watch, reset } = form;

// const defaultValuesRef: MutableRefObject<FieldValues> = useRef<FieldValues>({});
Copy link
Member

Choose a reason for hiding this comment

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

Remove commented out code

},
devtool: production ? undefined : 'source-map',
optimization: {
runtimeChunk: false,
Copy link
Member

Choose a reason for hiding this comment

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

Are we just attempting to achieve one output bundle with this config? Looking for some rationale behind these config changes.

new HtmlWebpackPlugin({
template: 'public/index.html'
}),
new BundleAnalyzerPlugin({
Copy link
Member

Choose a reason for hiding this comment

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

Let's only run this during production in the same way we only generate sourcemaps for production. BundleAnalyzer is known for slowing down builds considerably.

"license": "MIT",
"author": "Cheng Liu<[email protected]>",
"publisher": "Microsoft",
"main": "./dist/extension.js",
Copy link
Member

Choose a reason for hiding this comment

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

We use /lib/ as our convention no?

"@vscode/test-electron": "^1.6.2",
"eslint": "~8.7.0",
"glob": "~7.0.5",
"mocha": "^9.1.3",
Copy link
Member

Choose a reason for hiding this comment

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

I know the default scaffolding for vscode extensions for yeoman provides mocha, but shouldn't we absolutely use jest and the infrastructure we have in place for testing?

const date = now.getDate();
const hour = now.getHours();
const min = now.getMinutes();
const version = `${year}_${month}_${date}_${hour}_${min}`;
Copy link
Member

Choose a reason for hiding this comment

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

Will this be our versioning schema for the extension package. Is this the best practice and what does vscode do with their community extensions for versioning?

// your extension is activated the very first time the command is executed
export async function activate(context: vscode.ExtensionContext): Promise<void> {
context.subscriptions.push(
vscode.commands.registerCommand('rushstack.selectWorkspace', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

If there is no inscope state needs, we should simply extract the entire command into a separate module. It should be crystal clear where each of our commands live and we should separate each of them into their own modules. And example of this looks like:

https://github.com/TheLarkInn/rushstack/blob/018a69eb56cf2460e4a81de92809d86f595f2fc5/apps/rushstack-vscode-extension/src/extension.ts#L2-L7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[rush] VSCode Extension
5 participants