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

Add "pack install" and "pack download" commands #1076

Merged
merged 10 commits into from
Jan 19, 2022

Conversation

shati-patel
Copy link
Contributor

@shati-patel shati-patel commented Jan 13, 2022

Adds commands to install and download packs 📦

For the "Download Packs" command, I've added a hard-coded option to download all core packs, and a custom option if users want to specify a custom pack.

Expand for demo GIF

2A0768B5-1B85-4653-9664-992D399DEBB8

For "Install Packs", the user can select packs from their workspace

Expand for demo GIF

9E18DA5E-DCBD-433E-AF25-F6563BADC1ED

PS: I will add a test for these commands 🧪 But I'd be grateful for a quick review first to see if this is a plausible way of doing things! 🙈 Done!

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request (internal issue)
  • If this pull request makes user-facing changes that require documentation changes, the ready-for-doc-review label has been added to this pull request or the corresponding issue. Docs PR: Docs: Mention packaging commands in CodeQL extension codeql#7661

@shati-patel shati-patel marked this pull request as ready for review January 13, 2022 17:41
@shati-patel shati-patel requested a review from a team as a code owner January 13, 2022 17:41
extensions/ql-vscode/src/packaging.ts Outdated Show resolved Hide resolved
extensions/ql-vscode/src/packaging.ts Outdated Show resolved Hide resolved
extensions/ql-vscode/src/packaging.ts Outdated Show resolved Hide resolved
extensions/ql-vscode/src/packaging.ts Outdated Show resolved Hide resolved
extensions/ql-vscode/src/packaging.ts Outdated Show resolved Hide resolved
1. Hard-code more common query packs
2. Correctly resolve workspace packs
3. Only install workspace packs
@shati-patel
Copy link
Contributor Author

Thanks for the review! (And for improving my understanding of how people use these packaging commands 😅)

Pushed some updates based your feedback. Next up: I'll add tests! 👩🏽‍🔬

Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

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

Just tried it out. Works beautifully. I didn't know there was a multi-select option for quick picks.

extensions/ql-vscode/src/packaging.ts Outdated Show resolved Hide resolved
extensions/ql-vscode/src/packaging.ts Outdated Show resolved Hide resolved
extensions/ql-vscode/src/packaging.ts Show resolved Hide resolved
@aeisenberg
Copy link
Contributor

The changes I'm suggesting are not blockers, but I will hold off approval until there are some tests.

@aeisenberg
Copy link
Contributor

To answer a question posed by Aditya in a comment (which I can't see right now, was it deleted?).

pack install is primarily useful for query authors who want to get started developing in vscode. It is one step along the way of making the starter repo no longer necessary.

pack download, on its own may not be entirely useful since we also need a way to run one or more queries from downloaded packs.

@shati-patel
Copy link
Contributor Author

shati-patel commented Jan 17, 2022

I'm struggling with tests (again)... 🙈 The functions I'm testing don't return anything, so I'm trying to just check the logging output.
The tests are failing with "TypeError: Cannot read property 'args' of null" and an "unhandled rejection" error, which I haven't been able to fix... 😅

I've pushed my attempt so far. @aeisenberg, would you be able to take a look? 🙏🏽

Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

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

It would also be nice to somehow test that the pack was actually downloaded, but there's no way to do it right now. You would need to run resolve queries. So, for now, just testing whether the command throws or not is good enough.

extensions/ql-vscode/src/packaging.ts Outdated Show resolved Hide resolved
@shati-patel
Copy link
Contributor Author

I'd forgotten to add a CLI version constraint for packaging 🤦🏽 🤦🏽 🤦🏽 (fixed in the latest commit)

The mysterious failures have now disappeared, so I'm optimistic that this is now in good shape 🤞🏽 😅

Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

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

Nice job!

I have a slight concern that these tests will now be downloading packs into the global package cache. So, if you run it locally, the tests will hit your cache (and likely not actually download anything). But on CI, the cache will be empty on each run, so packages will be downloaded.

I don't think this is an issue since the tests are not really about the CLI, but only about how he extension interacts with the CLI.

Copy link
Contributor

@adityasharad adityasharad left a comment

Choose a reason for hiding this comment

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

Nice! I have a few non-blocking suggestions about user-visible text, to indicate that pack install is really installing pack dependencies. Feel free to incorporate them now or consider them for later.

extensions/ql-vscode/src/packaging.ts Outdated Show resolved Hide resolved
extensions/ql-vscode/src/packaging.ts Outdated Show resolved Hide resolved
ignoreFocusOut: true,
});
if (packsToInstall && packsToInstall.length > 0) {
progress({
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: You know the total number of root packs, so you could make the progress monitor actually reflect the progress through the root packs. Save that for a future PR though :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I will try that in a follow-up PR 🔄

extensions/ql-vscode/package.json Outdated Show resolved Hide resolved
extensions/ql-vscode/CHANGELOG.md Outdated Show resolved Hide resolved
@shati-patel shati-patel enabled auto-merge (rebase) January 19, 2022 20:30
@shati-patel shati-patel merged commit c9a649f into github:main Jan 19, 2022
@shati-patel shati-patel deleted the packaging-commands branch January 19, 2022 20:44
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