Skip to content

Commit

Permalink
Adds ability to install a missing bsc version (#583)
Browse files Browse the repository at this point in the history
* Adds ability to install a missing bsc version

* Fix broken test

* Add support for loading lsp from npm or url

* Proper url hashing

* Add command to clear local npm cache

* Add language server menu option for clearing cached packages

* Delete bsc versions after 45 days of inactivity

* Add command to view packages dir in explorer

* Prevent installing same bsc dependency multiple times

* Better messaging around removing cached brighterscript versions

* Fix bug keeping test process alive for too long

* Add `LocalPackageManager` class, not finished yet

* Add ability to delete all of a given package

* Add ability to remove a specific package.

* Fix coverage issues

* Update LanguageServermanager to use localPackageManager

* Tweak comment

* Better internal package object handling

* Add live npm install test

* support for non-semver versions

* Refactored LanguageServerManager to better handle bsc version

* Add unit tests for parseVersionInfo and getVersionDirName

* Fix some broken tests

* Handle loading bsc version using version number

* Split mainline releases and prereleases

* Fixed json parse issue when fetching npm package versions

* Fix lint issue
  • Loading branch information
TwitchBronBron authored Sep 23, 2024
1 parent b915a4a commit db3dfcd
Show file tree
Hide file tree
Showing 20 changed files with 1,639 additions and 140 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--timeout",
"0"
"987654"
],
"internalConsoleOptions": "openOnSessionStart"
}
Expand Down Expand Up @@ -104,4 +104,4 @@
]
}
]
}
}
71 changes: 63 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 18 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"iconv-lite": "0.4.24",
"jszip": "^3.10.1",
"just-throttle": "^4.0.1",
"md5": "^2.3.0",
"net": "^1.0.2",
"node-cache": "^4.2.0",
"node-ssdp": "^4.0.0",
Expand Down Expand Up @@ -97,8 +98,10 @@
"@types/clone-deep": "^4.0.3",
"@types/fs-extra": "^5.0.4",
"@types/glob": "^7.1.1",
"@types/lodash": "^4.17.7",
"@types/md5": "^2.3.5",
"@types/mocha": "^7.0.2",
"@types/node": "^12.12.0",
"@types/node": "^20.14.10",
"@types/node-ssdp": "^3.3.0",
"@types/prompt": "^1.1.2",
"@types/resolve": "^1.20.6",
Expand All @@ -114,11 +117,12 @@
"chalk": "^4.1.2",
"changelog-parser": "^2.8.0",
"coveralls-next": "^4.2.0",
"dayjs": "^1.11.7",
"dayjs": "^1.11.12",
"deferred": "^0.7.11",
"eslint": "^8.10.0",
"eslint-plugin-github": "^4.3.5",
"eslint-plugin-no-only-tests": "^2.6.0",
"lodash": "^4.17.21",
"mocha": "^9.1.3",
"node-notifier": "^10.0.1",
"nyc": "^15.0.0",
Expand Down Expand Up @@ -1810,6 +1814,12 @@
"description": "Path to the BrighterScript module to use for the BrightScript and BrighterScript language features",
"scope": "resource"
},
"brightscript.npmCacheRetentionDays": {
"type": "number",
"description": "How long should the extension keep around unused extension-managed npm packages such as brighterscript",
"default": 45,
"scope": "resource"
},
"brightscript.enableLanguageServer": {
"type": "boolean",
"description": "Enable the Language Server, which includes things like syntax checking, intellisense, completions, etc.",
Expand Down Expand Up @@ -3084,6 +3094,12 @@
"title": "Open SceneGraph Inspector In New Window",
"category": "BrighterScript",
"icon": "$(link-external)"
},
{
"command": "extension.brightscript.clearNpmPackageCache",
"title": "Clear the extension's local node_modules cache",
"category": "BrighterScript",
"icon": "$(link-external)"
}
],
"keybindings": [
Expand Down
4 changes: 2 additions & 2 deletions src/ActiveDeviceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ class RokuFinder extends EventEmitter {
}

private readonly client: Client;
private intervalId: NodeJS.Timer | null = null;
private timeoutId: NodeJS.Timer | null = null;
private intervalId: NodeJS.Timeout | null = null;
private timeoutId: NodeJS.Timeout | null = null;
private running = false;

public start(timeout: number) {
Expand Down
2 changes: 1 addition & 1 deletion src/BrightScriptCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('BrightScriptFileUtils ', () => {
let languagesMock;

beforeEach(() => {
commands = new BrightScriptCommands({} as any, {} as any, {} as any, {} as any, {} as any);
commands = new BrightScriptCommands({} as any, {} as any, {} as any, {} as any, {} as any, {} as any);
commandsMock = sinon.mock(commands);
languagesMock = sinon.mock(vscode.languages);
});
Expand Down
8 changes: 6 additions & 2 deletions src/BrightScriptCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import type { ActiveDeviceManager } from './ActiveDeviceManager';
import * as xml2js from 'xml2js';
import { firstBy } from 'thenby';
import type { UserInputManager } from './managers/UserInputManager';
import { clearNpmPackageCacheCommand } from './commands/ClearNpmPackageCacheCommand';
import type { LocalPackageManager } from './managers/LocalPackageManager';

export class BrightScriptCommands {

Expand All @@ -22,7 +24,8 @@ export class BrightScriptCommands {
private whatsNewManager: WhatsNewManager,
private context: vscode.ExtensionContext,
private activeDeviceManager: ActiveDeviceManager,
private userInputManager: UserInputManager
private userInputManager: UserInputManager,
private localPackageManager: LocalPackageManager
) {
this.fileUtils = new BrightScriptFileUtils();
}
Expand All @@ -36,9 +39,10 @@ export class BrightScriptCommands {
public registerCommands() {

brighterScriptPreviewCommand.register(this.context);
languageServerInfoCommand.register(this.context);
languageServerInfoCommand.register(this.context, this.localPackageManager);
captureScreenshotCommand.register(this.context, this);
rekeyAndPackageCommand.register(this.context, this, this.userInputManager);
clearNpmPackageCacheCommand.register(this.context, this.localPackageManager);

this.registerGeneralCommands();

Expand Down
2 changes: 1 addition & 1 deletion src/GlobalStateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class GlobalStateManager {
sendRemoteTextHistory: 'sendRemoteTextHistory',
debugProtocolPopupSnoozeUntilDate: 'debugProtocolPopupSnoozeUntilDate',
debugProtocolPopupSnoozeValue: 'debugProtocolPopupSnoozeValue'

};
private remoteTextHistoryLimit: number;
private remoteTextHistoryEnabled: boolean;
Expand All @@ -38,7 +39,6 @@ export class GlobalStateManager {
void this.context.globalState.update(this.keys.lastSeenReleaseNotesVersion, value);
}


public get debugProtocolPopupSnoozeUntilDate(): Date {
const epoch = this.context.globalState.get<number>(this.keys.debugProtocolPopupSnoozeUntilDate);
if (epoch) {
Expand Down
Loading

0 comments on commit db3dfcd

Please sign in to comment.