Skip to content

Commit 55d05e8

Browse files
authored
Remove external dependency on FileDownloader (#99)
* Remove external dependency on FileDownloader * File newlines * Test and lint fixes * Fix non-idiomatic js
1 parent 166cc4a commit 55d05e8

24 files changed

+707
-47
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ tmp
33
node_modules
44
.vscode-test/
55
*.vsix
6-
vendor

package-lock.json

Lines changed: 176 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "bazel-stack-vscode",
33
"displayName": "bazel-stack-vscode",
44
"description": "Bazel Support for Visual Studio Code",
5-
"version": "1.8.3",
5+
"version": "1.8.4",
66
"publisher": "StackBuild",
77
"license": "Apache-2.0",
88
"icon": "stackb-full.png",
@@ -761,15 +761,13 @@
761761
"vscode-package": "vsce package --out out/extension.vsix",
762762
"vscode:prepublish": "npm run clean && npm run compile"
763763
},
764-
"extensionDependencies": [
765-
"mindaro-dev.file-downloader"
766-
],
767764
"dependencies": {
768765
"@grpc/grpc-js": "^1.3.4",
769766
"@grpc/proto-loader": "0.6.4",
770-
"@microsoft/vscode-file-downloader-api": "^1.0.1",
771767
"@octokit/rest": "18.0.3",
768+
"axios": "^0.21.1",
772769
"bazel-stack-vscode-api": "^1.2.2",
770+
"extract-zip": "^2.0.1",
773771
"find-up": "^5.0.0",
774772
"fs-extra": "9.0.1",
775773
"graceful-fs": "4.2.4",
@@ -779,10 +777,11 @@
779777
"normalize-path": "^3.0.0",
780778
"protobufjs": "6.10.1",
781779
"request": "2.88.2",
780+
"rimraf": "^3.0.2",
782781
"semver": "7.3.5",
783782
"sha256-file": "1.0.0",
784-
"shiki": "^0.2.6",
785783
"shiki-themes": "^0.2.6",
784+
"shiki": "^0.2.6",
786785
"strip-ansi": "^6.0.0",
787786
"tmp": "0.2.1",
788787
"vscode-common": "1.50.0",
@@ -804,6 +803,7 @@
804803
"@types/node": "^13.11.0",
805804
"@types/normalize-path": "^3.0.0",
806805
"@types/request": "2.48.5",
806+
"@types/rimraf": "^3.0.2",
807807
"@types/semver": "5.5.0",
808808
"@types/sha256-file": "1.0.0",
809809
"@types/sinon": "9.0.4",
@@ -831,4 +831,4 @@
831831
"tabWidth": 2,
832832
"arrowParens": "avoid"
833833
}
834-
}
834+
}

src/bezel/debugger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export class StarlarkDebugger
172172
*/
173173
async resolveDebugConfigurationWithSubstitutedVariables(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, token?: vscode.CancellationToken): Promise<vscode.DebugConfiguration | undefined> {
174174
if (config.request !== 'launch') {
175-
return config
175+
return config;
176176
}
177177

178178
//

src/bezel/download.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import * as vscode from 'vscode';
44
import * as fs from 'fs';
5-
import { getApi, FileDownloader } from '@microsoft/vscode-file-downloader-api';
5+
import { IFileDownloader } from '../vendor/microsoft/vscode-file-downloader/IFileDownloader';
6+
import FileDownloader from '../vendor/microsoft/vscode-file-downloader/FileDownloader';
7+
import { Container } from '../container';
8+
import HttpRequestHandler from '../vendor/microsoft/vscode-file-downloader/networking/HttpRequestHandler';
69

710
/**
811
* Configuration type that describes a desired asset from bzl.io.
@@ -20,7 +23,7 @@ export interface BzlAssetConfiguration {
2023
}
2124

2225
export class BzlAssetDownloader {
23-
private constructor(private downloaderApi: FileDownloader, private cfg: BzlAssetConfiguration) {}
26+
private constructor(private downloaderApi: IFileDownloader, private cfg: BzlAssetConfiguration) {}
2427

2528
getBasename(): string {
2629
let basename = 'bzl';
@@ -129,7 +132,8 @@ export class BzlAssetDownloader {
129132
* @returns
130133
*/
131134
static async fromConfiguration(cfg: BzlAssetConfiguration): Promise<BzlAssetDownloader> {
132-
const api = await getApi();
133-
return new BzlAssetDownloader(api, cfg);
135+
const requestHandler = new HttpRequestHandler(Container.logger);
136+
const downloader = new FileDownloader(requestHandler, Container.logger);
137+
return new BzlAssetDownloader(downloader, cfg);
134138
}
135139
}

src/bezel/feature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class BzlFeature implements vscode.Disposable {
6666
private readonly invocations: Invocations | undefined;
6767

6868
constructor(private api: API, ctx: vscode.ExtensionContext, private configCtx: ConfigurationContext) {
69-
let cwd = "."
69+
let cwd = '.';
7070
if (vscode.workspace.workspaceFolders?.length) {
7171
cwd = vscode.workspace.workspaceFolders[0].uri.fsPath;
7272
}

src/bezel/invocations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class InvocationsItem
155155

156156
async getChildrenInternal(): Promise<vscode.TreeItem[]> {
157157
const items: vscode.TreeItem[] = [];
158-
items.push(new DocumentationLinkItem('invocations'))
158+
items.push(new DocumentationLinkItem('invocations'));
159159

160160
if (this.invocations.status === Status.DISABLED) {
161161
items.push(new DisabledItem('Depends on the Bzl Service'));

src/bezel/workspaceView.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -396,23 +396,23 @@ class SubscriptionItem
396396

397397
async getChildrenInternal(): Promise<vscode.TreeItem[]> {
398398
const items: vscode.TreeItem[] = [];
399-
items.push(new DocumentationLinkItem('subscription'))
399+
items.push(new DocumentationLinkItem('subscription'));
400400

401401
if (this.component.status === Status.DISABLED) {
402402
items.push(new DisabledItem('Subscription token not available.'));
403403
items.push(
404404
new MarkdownItem(
405-
"Sign up to enable additional hover documentation, autocompletion, and other features."
405+
'Sign up to enable additional hover documentation, autocompletion, and other features.'
406406
)
407407
);
408408
items.push(
409409
new MarkdownItem(
410-
"Using this at work? Encourage your employer to support developer productivity."
410+
'Using this at work? Encourage your employer to support developer productivity.'
411411
)
412412
);
413413
items.push(
414414
new MarkdownItem(
415-
"Contact hello@stack.build for organizational onboarding."
415+
'Contact hello@stack.build for organizational onboarding.'
416416
)
417417
);
418418
items.push(
@@ -520,7 +520,7 @@ class BuildozerItem
520520

521521
async getChildrenInternal(): Promise<vscode.TreeItem[]> {
522522
const items: vscode.TreeItem[] = [];
523-
items.push(new DocumentationLinkItem('buildozer'))
523+
items.push(new DocumentationLinkItem('buildozer'));
524524
items.push(this.createRunWizardItem());
525525
return items;
526526
}
@@ -552,7 +552,7 @@ class RemoteCacheItem
552552

553553
async getChildrenInternal(): Promise<vscode.TreeItem[]> {
554554
const items: vscode.TreeItem[] = [];
555-
items.push(new DocumentationLinkItem('remote-cache'))
555+
items.push(new DocumentationLinkItem('remote-cache'));
556556

557557
if (!this.remoteCache.terminal) {
558558
items.push(this.createLaunchItem());
@@ -599,7 +599,7 @@ class BzlServerItem
599599

600600
async getChildrenInternal(): Promise<vscode.TreeItem[]> {
601601
const items: vscode.TreeItem[] = [];
602-
items.push(new DocumentationLinkItem('ui'))
602+
items.push(new DocumentationLinkItem('ui'));
603603

604604
if (this.bzl.status === Status.DISABLED) {
605605
items.push(new DisabledItem('The Stack.Build subscription is not enabled.'));
@@ -702,7 +702,7 @@ class BuildEventServiceItem
702702

703703
async getChildrenInternal(): Promise<vscode.TreeItem[]> {
704704
const items: vscode.TreeItem[] = [];
705-
items.push(new DocumentationLinkItem('build-events'))
705+
items.push(new DocumentationLinkItem('build-events'));
706706

707707
if (this.bes.status === Status.DISABLED) {
708708
items.push(new DisabledItem('Depends on the Bzl Service'));
@@ -742,7 +742,7 @@ class StarlarkDebuggerItem
742742

743743
async getChildrenInternal(): Promise<vscode.TreeItem[]> {
744744
const items: vscode.TreeItem[] = [];
745-
items.push(new DocumentationLinkItem('debugger'))
745+
items.push(new DocumentationLinkItem('debugger'));
746746

747747
if (this.debug.status === Status.DISABLED) {
748748
items.push(new DisabledItem('The Starlark Debugger is not enabled.'));
@@ -783,7 +783,7 @@ class CodeSearchItem
783783

784784
async getChildrenInternal(): Promise<vscode.TreeItem[]> {
785785
const items: vscode.TreeItem[] = [];
786-
items.push(new DocumentationLinkItem('codesearch'))
786+
items.push(new DocumentationLinkItem('codesearch'));
787787

788788
items.push(this.createUsageItem());
789789

@@ -805,7 +805,7 @@ class BazelServerItem
805805

806806
async getChildrenInternal(): Promise<vscode.TreeItem[]> {
807807
const items: vscode.TreeItem[] = [];
808-
items.push(new DocumentationLinkItem('bazel'))
808+
items.push(new DocumentationLinkItem('bazel'));
809809

810810
if (this.bazel.status === Status.DISABLED) {
811811
items.push(new DisabledItem('Depends on the Bzl Service'));

src/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import { Timestamp } from './proto/google/protobuf/Timestamp';
66
import Long = require('long');
77
import crypto = require('crypto');
88
import path = require('path');
9+
import ILogger from './vendor/microsoft/vscode-file-downloader/logging/ILogger';
910

1011
export class ConfigurationContext {
1112
constructor(
13+
public readonly logger: ILogger,
1214
public readonly extensionUri: vscode.Uri,
1315
public readonly globalStorageUri: vscode.Uri,
1416
public readonly workspaceState: vscode.Memento,

src/container.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import TelemetryReporter from 'vscode-extension-telemetry';
33
import { ConfigurationContext, ITelemetry } from './common';
44
import { AIKey, ExtensionID, Telemetry } from './constants';
55
import path = require('path');
6+
import ILogger from './vendor/microsoft/vscode-file-downloader/logging/ILogger';
67

78
export class Container {
89
private static _configCtx: ConfigurationContext;
@@ -20,6 +21,10 @@ export class Container {
2021
Container.telemetry.sendTelemetryEvent(Telemetry.ExtensionActivate);
2122
}
2223

24+
static get logger(): ILogger {
25+
return Container._configCtx.logger;
26+
}
27+
2328
static get telemetry(): ITelemetry {
2429
return Container._telemetry;
2530
}

0 commit comments

Comments
 (0)