Skip to content

Add download-dependencies script#100

Open
iFreilicht wants to merge 1 commit into
muhammadsammy:masterfrom
iFreilicht:add-download-dependencies-script
Open

Add download-dependencies script#100
iFreilicht wants to merge 1 commit into
muhammadsammy:masterfrom
iFreilicht:add-download-dependencies-script

Conversation

@iFreilicht

Copy link
Copy Markdown

Rationale

Currently, the extension downloads some of its runtime dependencies on-the-fly after starting for the first time. This does not work for air-gapped or otherwise restricted environments without access to the internet. It's also suboptimal for remote development environments (like Coder, GitLab Workspaces, Posit Workbench, etc.) that run vscode from within a docker container. In these cases, pre-downloading the runtime dependencies into the docker container without running vscode is very useful. Potentially, one might want to publish a version with the dependencies built in on an internal registry, too.

Solution

To satisfy these use cases, I wrote a script that imports the relevant functionality for downloading the runtime dependencies directly from the extension modules and executes them such that the dependencies are downloaded to ./dist, where the extension would be built as well.

Testing

I've already tested this script extensively in our own environments and on my macOS development machine with multiple versions of the extension (down to 2.90.60, which we have to run on some systems) and it seems to work perfectly, i.e. the extension no longer displays any logs about downloading its dependencies and all analysis features work as expected.

I have not tested this script on Windows.

I am also unsure how one would write an integration test for this, my overview over the codebase is currently not sufficient for that.

Alternatives

Right now, there's one universal build of the extension. All platform-specific dependencies are downloaded on startup. It might also be possible to publish separate builds of the extension for every supported platform that already includes the dependencies. This would increase the size of the extension bundle by ~120MB AFAICT and would complicate the release process.

I opted for this simpler approach because my usecase is admittedly quite niche already, so it seems unreasonable to expect you to dedicate such a high amount of work to satisfying it. This small script seems almost trivial in maintenance cost.

Disclosure of AI Assistance

The script was mostly written with GitHub Copilot using Claude Sonnet 4.6. I gave it a pretty clear prompt based on my own understanding of the codebase:

The repository you're in is a vscode extension. I want to use it in an air-gapped environment, but many dependencies are not bundled with the extension. Instead, they are downloaded from the internet on demand once the extension starts for the first time. You can see an example for this in razorOmnisharpDownloader.ts.

What I want you to do is to add a command download-dependencies to package.json that downloads and unpacks all the dependencies as the extension would do it at runtime. This means that this script is NOT allowed to reimplement the logic that's already present in the different modules of the extension as they might contain custom unpacking etc. The base folder for the output should be dist. I think the best course of action is to write a new module that wraps getRuntimeDependenciesPackages, getAbsolutePathPackagesToInstall, filterPlatformPackages and downloadAndInstallPackages in a new script that only filters the runtimeDependencies by platform and then installs them.

Afterwards, I reviewed the entire script and did some small modifications (like not hardcoding the platform).

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.

1 participant