From e7894228b1a8069067fe123701fc0b5f7bbc4fc1 Mon Sep 17 00:00:00 2001 From: Bronley Plumb Date: Tue, 15 Oct 2024 09:56:41 -0400 Subject: [PATCH 1/3] rebuildPathFilterer now retains project-specific patterns on rebuild (#1327) * rebuildPathFilterer now retains project-specific patterns on rebuild * Add test to verify removed project includeLists get unregistered --- src/LanguageServer.spec.ts | 64 ++++++++++++++++++++++++++++++++++++++ src/LanguageServer.ts | 46 +++++++++++++++++---------- 2 files changed, 93 insertions(+), 17 deletions(-) diff --git a/src/LanguageServer.spec.ts b/src/LanguageServer.spec.ts index fb8feb56b..9bcebcbd5 100644 --- a/src/LanguageServer.spec.ts +++ b/src/LanguageServer.spec.ts @@ -704,6 +704,70 @@ describe('LanguageServer', () => { s`${workspaceConfigs[1].workspaceFolder}/src/source/file.brs` ]); }); + + it('does not erase project-specific filters', async () => { + let filterer = await server['rebuildPathFilterer'](); + const files = [ + s`${rootDir}/node_modules/one/file.xml`, + s`${rootDir}/node_modules/two.bs`, + s`${rootDir}/node_modules/three/dist/lib.bs` + ]; + + //all node_modules files are filtered out by default, unless included in an includeList + expect(filterer.filter(files)).to.eql([]); + + //register two specific node_module folders to include + filterer.registerIncludeList(rootDir, ['node_modules/one/**/*', 'node_modules/two.bs']); + + //unless included in an includeList + expect(filterer.filter(files)).to.eql([ + s`${rootDir}/node_modules/one/file.xml`, + s`${rootDir}/node_modules/two.bs` + //three should still be excluded + ]); + + //rebuild the path filterer, make sure the project's includeList is still retained + filterer = await server['rebuildPathFilterer'](); + + expect(filterer.filter(files)).to.eql([ + //one and two should still make it through the filter unscathed + s`${rootDir}/node_modules/one/file.xml`, + s`${rootDir}/node_modules/two.bs` + //three should still be excluded + ]); + }); + + it('a removed project includeList gets unregistered', async () => { + let filterer = await server['rebuildPathFilterer'](); + const files = [ + s`${rootDir}/project1/node_modules/one/file.xml`, + s`${rootDir}/project1/node_modules/two.bs`, + s`${rootDir}/project1/node_modules/three/dist/lib.bs` + ]; + + //all node_modules files are filtered out by default, unless included in an includeList + expect(filterer.filter(files)).to.eql([]); + + //register a new project that references a file from node_modules + fsExtra.outputFileSync(s`${rootDir}/project1/bsconfig.json`, JSON.stringify({ + files: ['node_modules/one/file.xml'] + })); + + await server['syncProjects'](); + + //one should be included because the project references it + expect(filterer.filter(files)).to.eql([ + s`${rootDir}/project1/node_modules/one/file.xml` + ]); + + //delete the project's bsconfig.json and sync again (thus destroying the project) + fsExtra.removeSync(s`${rootDir}/project1/bsconfig.json`); + + await server['syncProjects'](); + + //the project's pathFilterer pattern has been unregistered + expect(filterer.filter(files)).to.eql([]); + }); }); describe('onDidChangeWatchedFiles', () => { diff --git a/src/LanguageServer.ts b/src/LanguageServer.ts index a7a44d6eb..4ee22a025 100644 --- a/src/LanguageServer.ts +++ b/src/LanguageServer.ts @@ -588,25 +588,35 @@ export class LanguageServer { } private busyStatusIndex = -1; + private pathFiltererDisposables: Array<() => void> = []; + /** * Populate the path filterer with the client's include/exclude lists and the projects include lists * @returns the instance of the path filterer */ private async rebuildPathFilterer() { - this.pathFilterer.clear(); + //dispose of any previous pathFilterer disposables + this.pathFiltererDisposables?.forEach(dispose => dispose()); + //keep track of all the pathFilterer disposables so we can dispose them later + this.pathFiltererDisposables = []; + const workspaceConfigs = await this.getWorkspaceConfigs(); await Promise.all(workspaceConfigs.map(async (workspaceConfig) => { const rootDir = util.uriToPath(workspaceConfig.workspaceFolder); //always exclude everything from these common folders - this.pathFilterer.registerExcludeList(rootDir, [ - '**/node_modules/**/*', - '**/.git/**/*', - 'out/**/*', - '**/.roku-deploy-staging/**/*' - ]); + this.pathFiltererDisposables.push( + this.pathFilterer.registerExcludeList(rootDir, [ + '**/node_modules/**/*', + '**/.git/**/*', + 'out/**/*', + '**/.roku-deploy-staging/**/*' + ]) + ); //get any `files.exclude` patterns from the client from this workspace - this.pathFilterer.registerExcludeList(rootDir, workspaceConfig.excludePatterns); + this.pathFiltererDisposables.push( + this.pathFilterer.registerExcludeList(rootDir, workspaceConfig.excludePatterns) + ); //get any .gitignore patterns from the client from this workspace const gitignorePath = path.resolve(rootDir, '.gitignore'); @@ -614,15 +624,17 @@ export class LanguageServer { const matcher = ignore({ ignoreCase: true }).add( fsExtra.readFileSync(gitignorePath).toString() ); - this.pathFilterer.registerExcludeMatcher((p: string) => { - const relPath = path.relative(rootDir, p); - if (ignore.isPathValid(relPath)) { - return matcher.test(relPath).ignored; - } else { - //we do not have a valid relative path, so we cannot determine if it is ignored...thus it is NOT ignored - return false; - } - }); + this.pathFiltererDisposables.push( + this.pathFilterer.registerExcludeMatcher((p: string) => { + const relPath = path.relative(rootDir, p); + if (ignore.isPathValid(relPath)) { + return matcher.test(relPath).ignored; + } else { + //we do not have a valid relative path, so we cannot determine if it is ignored...thus it is NOT ignored + return false; + } + }) + ); } })); this.logger.log('pathFilterer successfully reconstructed'); From 4da1d69bbee5f773ed5e0d719d9875ad31c2b79e Mon Sep 17 00:00:00 2001 From: Bronley Plumb Date: Fri, 18 Oct 2024 15:18:01 -0400 Subject: [PATCH 2/3] Update changelog for v0.67.8 --- CHANGELOG.md | 10 ++++++++++ package-lock.json | 14 +++++++------- package.json | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a01d98ac7..be532616b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +## [0.67.8](https://github.com/rokucommunity/brighterscript/compare/v0.67.7...v0.67.8) - 2024-10-18 +### Changed + - upgrade to [roku-deploy@3.12.2](https://github.com/rokucommunity/roku-deploy/blob/master/CHANGELOG.md#3122---2024-10-18). Notable changes since 3.12.1: + - fixes #175 - updated regex to find a signed package on `/plugin_package` page ([roku-deploy#176](https://github.com/rokucommunity/roku-deploy/pull/176)) +### Fixed + - namespace-relative transpile bug for standalone file ([#1324](https://github.com/rokucommunity/brighterscript/pull/1324)) + - Prevent crash when `ProgramBuilder.run` called with no options ([#1316](https://github.com/rokucommunity/brighterscript/pull/1316)) + + + ## [0.67.7](https://github.com/rokucommunity/brighterscript/compare/v0.67.6...v0.67.7) - 2024-09-25 ### Changed - Ast node clone ([#1281](https://github.com/rokucommunity/brighterscript/pull/1281)) diff --git a/package-lock.json b/package-lock.json index 3ae0ae0be..c8f97a81b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,7 +32,7 @@ "parse-ms": "^2.1.0", "readline": "^1.3.0", "require-relative": "^0.8.7", - "roku-deploy": "^3.12.1", + "roku-deploy": "^3.12.2", "serialize-error": "^7.0.1", "source-map": "^0.7.4", "vscode-languageserver": "^9.0.1", @@ -7694,9 +7694,9 @@ } }, "node_modules/roku-deploy": { - "version": "3.12.1", - "resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.12.1.tgz", - "integrity": "sha512-PEOdiFKGW1jrcoC9zjb+9kOWC/Q3eH7dzPvSi5kKignjNcyDiyJi+/wINwNrzw9SsxAVtw+NLvYueyZi9wQVsw==", + "version": "3.12.2", + "resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.12.2.tgz", + "integrity": "sha512-CePBiVk+6u4Pka/aq7WR4GnTW39BlAveEbhuDHQX2UfR9+4j3+YEvfXqxB0R69RU52eGfnk1ejI7H0HStEKa2Q==", "dependencies": { "chalk": "^2.4.2", "dateformat": "^3.0.3", @@ -14867,9 +14867,9 @@ } }, "roku-deploy": { - "version": "3.12.1", - "resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.12.1.tgz", - "integrity": "sha512-PEOdiFKGW1jrcoC9zjb+9kOWC/Q3eH7dzPvSi5kKignjNcyDiyJi+/wINwNrzw9SsxAVtw+NLvYueyZi9wQVsw==", + "version": "3.12.2", + "resolved": "https://registry.npmjs.org/roku-deploy/-/roku-deploy-3.12.2.tgz", + "integrity": "sha512-CePBiVk+6u4Pka/aq7WR4GnTW39BlAveEbhuDHQX2UfR9+4j3+YEvfXqxB0R69RU52eGfnk1ejI7H0HStEKa2Q==", "requires": { "chalk": "^2.4.2", "dateformat": "^3.0.3", diff --git a/package.json b/package.json index 39002ee65..23406d46d 100644 --- a/package.json +++ b/package.json @@ -152,7 +152,7 @@ "parse-ms": "^2.1.0", "readline": "^1.3.0", "require-relative": "^0.8.7", - "roku-deploy": "^3.12.1", + "roku-deploy": "^3.12.2", "serialize-error": "^7.0.1", "source-map": "^0.7.4", "vscode-languageserver": "^9.0.1", From 7cfaaa0479ed7eecea90fb33c87ad4df5ddb7b06 Mon Sep 17 00:00:00 2001 From: Bronley Plumb Date: Fri, 18 Oct 2024 15:18:41 -0400 Subject: [PATCH 3/3] 0.67.8 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c8f97a81b..5c7f0372b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "brighterscript", - "version": "0.67.7", + "version": "0.67.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "brighterscript", - "version": "0.67.7", + "version": "0.67.8", "license": "MIT", "dependencies": { "@rokucommunity/bslib": "^0.1.1", diff --git a/package.json b/package.json index 23406d46d..0718ff064 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "brighterscript", - "version": "0.67.7", + "version": "0.67.8", "description": "A superset of Roku's BrightScript language.", "scripts": { "preversion": "npm run build && npm run lint && npm run test",