From edfe0a961b2e0e6b46193186df6ae4518005b521 Mon Sep 17 00:00:00 2001 From: ManuelGil Date: Wed, 8 Jan 2025 10:47:03 -0500 Subject: [PATCH] feat: :sparkles: update dependencies, improve warning messages, and add test configuration --- .nvmrc | 2 +- .vscode-test.mjs | 5 ++++ CHANGELOG.md | 14 +++++++++- README.md | 2 +- l10n/bundle.l10n.es.json | 3 ++- package.json | 12 ++++----- src/app/configs/constants.config.ts | 12 +++++++++ src/app/controllers/files.controller.ts | 13 +++++----- src/extension.ts | 17 +++++++++++-- src/test/{suite => }/extension.test.ts | 0 src/test/runTest.ts | 23 ----------------- src/test/suite/index.ts | 34 ------------------------- 12 files changed, 62 insertions(+), 75 deletions(-) create mode 100644 .vscode-test.mjs rename src/test/{suite => }/extension.test.ts (100%) delete mode 100644 src/test/runTest.ts delete mode 100644 src/test/suite/index.ts diff --git a/.nvmrc b/.nvmrc index 790e110..e4f846d 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v20.10.0 +v22.10.0 diff --git a/.vscode-test.mjs b/.vscode-test.mjs new file mode 100644 index 0000000..b62ba25 --- /dev/null +++ b/.vscode-test.mjs @@ -0,0 +1,5 @@ +import { defineConfig } from '@vscode/test-cli'; + +export default defineConfig({ + files: 'out/test/**/*.test.js', +}); diff --git a/CHANGELOG.md b/CHANGELOG.md index f204576..990ffd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.17.0] - 2025-01-08 + +### Added + +- Add VS Code test configuration and update test scripts. + +### Changed + +- Improve the warning messages in the `FileController` class when the file is not found. +- Upgrade dependencies to the latest versions available. + ## [1.16.1] - 2025-01-06 ### Fixed @@ -166,7 +177,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add basic functionality for generating barrel files. - Add support for TypeScript and JavaScript projects. -[Unreleased]: https://github.com/ManuelGil/vscode-auto-barrel/compare/v1.16.1...HEAD +[Unreleased]: https://github.com/ManuelGil/vscode-auto-barrel/compare/v1.17.0...HEAD +[1.17.0]: https://github.com/ManuelGil/vscode-auto-barrel/compare/v1.16.1...v1.17.0 [1.16.1]: https://github.com/ManuelGil/vscode-auto-barrel/compare/v1.16.0...v1.16.1 [1.16.0]: https://github.com/ManuelGil/vscode-auto-barrel/compare/v1.15.0...v1.16.0 [1.15.0]: https://github.com/ManuelGil/vscode-auto-barrel/compare/v1.14.0...v1.15.0 diff --git a/README.md b/README.md index 1c77306..62425f2 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ This extension is inspired by the [auto-barrel](https://github.com/mike-hanson/a ## Requirements -- VSCode 1.76.0 or later +- VSCode 1.90.0 or later ## Features diff --git a/l10n/bundle.l10n.es.json b/l10n/bundle.l10n.es.json index c4cec93..1b6836f 100644 --- a/l10n/bundle.l10n.es.json +++ b/l10n/bundle.l10n.es.json @@ -7,13 +7,14 @@ "Welcome to {0} version {1}! The extension is now active": "¡Bienvenido a {0} versión {1}! La extensión ahora está activa", "New version of {0} is available. Check out the release notes for version {1}": "Hay disponible una nueva versión de {0}. Consulte las notas de la versión {1}", "Release Notes": "Notas de la versión", + "Close": "Cerrar", "The folder is not valid!": "¡La carpeta no es válida!", "The folder is not in the workspace!": "¡La carpeta no está en el espacio de trabajo!", "Remember to update the barrel file": "Recuerda actualizar el archivo barrel", "The file does not exist!": "¡El archivo no existe!", "No files found in the folder!": "¡No se encontraron archivos en la carpeta!", "The {0} folder is empty!": "¡La carpeta {0} está vacía!", - "No files found matching the specified patterns!": "¡No se encontraron archivos que coincidan con los patrones especificados!", + "No files found matching the specified patterns in the {0} folder! Please check the include and exclude files in the settings": "¡No se encontraron archivos que coincidan con los patrones especificados en la carpeta {0}! Compruebe los archivos incluidos y excluidos en la configuración", "The file has not been created!": "¡El archivo no ha sido creado!", "File created successfully!": "¡Archivo creado con éxito!", "File successfully updated!": "¡Archivo actualizado con éxito!", diff --git a/package.json b/package.json index e603ff3..7fe2a63 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-auto-barrel", "displayName": "Auto Barrel for VSCode", "description": "🛢️ Automatically generate index files for your project.", - "version": "1.16.1", + "version": "1.17.0", "icon": "icon.png", "license": "MIT", "publisher": "imgildev", @@ -11,7 +11,7 @@ "url": "https://github.com/sponsors/ManuelGil" }, "engines": { - "vscode": "^1.76.0" + "vscode": "^1.90.0" }, "categories": [ "Other" @@ -280,7 +280,7 @@ "format": "biome format --write", "lint": "biome lint --write", "lint:check": "biome check --write", - "test": "node ./out/test/runTest.js", + "test": "vscode-test", "compodoc": "npx compodoc -p tsconfig.doc.json -d compodoc --theme readthedocs -s", "prepare": "husky" }, @@ -291,12 +291,12 @@ "@compodoc/compodoc": "^1.1.26", "@types/mocha": "^10.0.10", "@types/node": "^22.10.0", - "@types/vscode": "^1.76.0", + "@types/vscode": "^1.90.0", "@vscode/l10n-dev": "^0.0.35", - "globals": "^15.12.0", + "@vscode/test-cli": "^0.0.10", + "@vscode/test-electron": "^2.4.1", "husky": "^9.1.7", "lint-staged": "^15.2.10", - "mocha": "^10.8.2", "rimraf": "^6.0.1", "typescript": "^5.7.2", "vscode-test": "^1.6.1" diff --git a/src/app/configs/constants.config.ts b/src/app/configs/constants.config.ts index c45b2d1..3e48cc0 100644 --- a/src/app/configs/constants.config.ts +++ b/src/app/configs/constants.config.ts @@ -46,6 +46,18 @@ export const EXTENSION_DISPLAY_NAME: string = 'Auto Barrel'; */ export const USER_NAME: string = 'ManuelGil'; +/** + * USER_PUBLISHER: The publisher of the extension. + * @type {string} + * @public + * @memberof Constants + * @example + * console.log(USER_PUBLISHER); + * + * @returns {string} - The publisher of the extension + */ +export const USER_PUBLISHER: string = 'imgildev'; + /** * REPOSITORY_URL: The documentation URL of the extension. * @type {string} diff --git a/src/app/controllers/files.controller.ts b/src/app/controllers/files.controller.ts index 765a8ec..0cba508 100644 --- a/src/app/controllers/files.controller.ts +++ b/src/app/controllers/files.controller.ts @@ -1,4 +1,4 @@ -import * as fg from 'fast-glob'; +import * as fastGlob from 'fast-glob'; import { access, existsSync, @@ -264,11 +264,12 @@ export class FilesController { ); if (allFilesInFolder.length === 0) { - const message = l10n.t('The {0} folder is empty!', [folderPath]); + const message = l10n.t('The {0} folder is empty!', [relativePath]); window.showWarningMessage(message); } else { const message = l10n.t( - 'No files found matching the specified patterns!', + 'No files found matching the specified patterns in the {0} folder! Please check the include and exclude files in the settings', + [relativePath], ); window.showWarningMessage(message); } @@ -549,18 +550,18 @@ export class FilesController { try { // Use fast-glob to find matching files - let filePaths = await fg(include, options); + let foundFilePaths = await fastGlob(include, options); if (gitignore) { // Filter out files that are ignored by .gitignore - filePaths = filePaths.filter((filePath) => { + foundFilePaths = foundFilePaths.filter((filePath) => { const relativePath = relative(baseDir, filePath); // Convert to relative paths return !gitignore.ignores(relativePath); }); } // Convert file paths to VS Code Uri objects - return filePaths.sort().map((filePath) => Uri.file(filePath)); + return foundFilePaths.sort().map((filePath) => Uri.file(filePath)); } catch (error) { const message = l10n.t('Error while finding files: {0}', [error]); window.showErrorMessage(message); diff --git a/src/extension.ts b/src/extension.ts index 055781f..58fcbf5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -6,8 +6,9 @@ import * as vscode from 'vscode'; import { EXTENSION_DISPLAY_NAME, EXTENSION_ID, + EXTENSION_NAME, ExtensionConfig, - REPOSITORY_URL, + USER_PUBLISHER, } from './app/configs'; import { FilesController } from './app/controllers'; @@ -109,6 +110,9 @@ export async function activate(context: vscode.ExtensionContext) { { title: vscode.l10n.t('Release Notes'), }, + { + title: vscode.l10n.t('Close'), + }, ]; const message = vscode.l10n.t( @@ -116,13 +120,22 @@ export async function activate(context: vscode.ExtensionContext) { [EXTENSION_DISPLAY_NAME, currentVersion], ); vscode.window.showInformationMessage(message, ...actions).then((option) => { + if (!option) { + return; + } + // Handle the actions switch (option?.title) { case actions[0].title: vscode.env.openExternal( - vscode.Uri.parse(`${REPOSITORY_URL}/blob/main/CHANGELOG.md`), + vscode.Uri.parse( + `https://marketplace.visualstudio.com/items/${USER_PUBLISHER}.${EXTENSION_NAME}/changelog`, + ), ); break; + + default: + break; } }); diff --git a/src/test/suite/extension.test.ts b/src/test/extension.test.ts similarity index 100% rename from src/test/suite/extension.test.ts rename to src/test/extension.test.ts diff --git a/src/test/runTest.ts b/src/test/runTest.ts deleted file mode 100644 index a629e3e..0000000 --- a/src/test/runTest.ts +++ /dev/null @@ -1,23 +0,0 @@ -import * as path from 'path'; - -import { runTests } from 'vscode-test'; - -async function main() { - try { - // The folder containing the Extension Manifest package.json - // Passed to `--extensionDevelopmentPath` - const extensionDevelopmentPath = path.resolve(__dirname, '../../'); - - // The path to test runner - // Passed to --extensionTestsPath - const extensionTestsPath = path.resolve(__dirname, './suite/index'); - - // Download VS Code, unzip it and run the integration test - await runTests({ extensionDevelopmentPath, extensionTestsPath }); - } catch (err) { - console.error('Failed to run tests'); - process.exit(1); - } -} - -main(); diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts deleted file mode 100644 index 3321d44..0000000 --- a/src/test/suite/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -import * as path from 'path'; -import * as Mocha from 'mocha'; -import * as glob from 'glob'; - -export function run(): Promise { - // Create the mocha test - const mocha = new Mocha({ - ui: 'tdd', - color: true, - }); - - const testsRoot = path.resolve(__dirname, '..'); - - return new Promise((c, e) => { - glob.glob('**/**.test.js', { cwd: testsRoot }).then((files: string[]) => { - // Add files to the test suite - files.forEach((f: string) => mocha.addFile(path.resolve(testsRoot, f))); - - try { - // Run the mocha test - mocha.run((failures) => { - if (failures > 0) { - e(new Error(`${failures} tests failed.`)); - } else { - c(); - } - }); - } catch (err) { - console.error(err); - e(err); - } - }); - }); -}