Skip to content

Commit 16f36dd

Browse files
committed
feat: ✨ add vscode-marketplace-client dependency and implement update notifications
1 parent 841194e commit 16f36dd

File tree

5 files changed

+90
-19
lines changed

5 files changed

+90
-19
lines changed

.husky/commit-msg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
41
npx --no -- commitlint --edit ${1}

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.13.0] - 2025-03-11
11+
12+
### Added
13+
14+
- Add `vscode-marketplace-client` dependency to check for extension updates and display a notification
15+
16+
### Changed
17+
18+
- Update the `extension.ts` file to use the new `vscode-marketplace-client` dependency
19+
- Update Localization strings for the extension
20+
1021
## [1.12.0] - 2025-02-03
1122

1223
### Changed
@@ -223,7 +234,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
223234

224235
- Fix file creation issue when creating a new file
225236

226-
[unreleased]: https://github.com/ManuelGil/vscode-extension-starter-advanced/compare/v1.12.0...HEAD
237+
[unreleased]: https://github.com/ManuelGil/vscode-extension-starter-advanced/compare/v1.13.0...HEAD
238+
[1.13.0]: https://github.com/ManuelGil/vscode-extension-starter-advanced/compare/v1.12.0...v1.13.0
227239
[1.12.0]: https://github.com/ManuelGil/vscode-extension-starter-advanced/compare/v1.11.0...v1.12.0
228240
[1.11.0]: https://github.com/ManuelGil/vscode-extension-starter-advanced/compare/v1.10.0...v1.11.0
229241
[1.10.0]: https://github.com/ManuelGil/vscode-extension-starter-advanced/compare/v1.9.0...v1.10.0

l10n/bundle.l10n.es.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
{
2-
"No workspace folders are open. Please open a workspace folder to use this extension": "No hay carpetas de espacio de trabajo abiertas. Abra una carpeta de espacio de trabajo para usar esta extensión",
3-
"Select a workspace folder to use. This folder will be used to load workspace-specific configuration for the extension": "Selecciona una carpeta de espacio de trabajo para usar. Esta carpeta se utilizará para cargar la configuración específica del espacio de trabajo para la extensión",
4-
"Welcome to {0} version {1}! The extension is now active": "¡Bienvenido a {0} versión {1}! La extensión ahora está activa",
5-
"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}",
2+
"No workspace folders are open. Please open a workspace folder to use this extension": "No hay carpetas de trabajo abiertas. Abre una carpeta de trabajo para usar esta extensión",
3+
"Select a workspace folder to use. This folder will be used to load workspace-specific configuration for the extension": "Selecciona una carpeta de trabajo. Esta carpeta se usará para cargar la configuración específica de la extensión",
4+
"The {0} extension is now enabled and ready to use": "La extensión {0} está habilitada y lista para usarse",
5+
"The {0} extension is now disabled": "La extensión {0} está deshabilitada",
6+
"The {0} extension is disabled in settings. Enable it to use its features": "La extensión {0} está deshabilitada en la configuración. Habilítala para usar sus funciones",
7+
"Welcome to {0} version {1}! The extension is now active": "¡Bienvenido a {0} versión {1}! La extensión ya está activa",
8+
"The {0} extension has been updated. Check out what's new in version {1}": "La extensión {0} se ha actualizado. Consulta las novedades de la versión {1}",
69
"Release Notes": "Notas de la versión",
710
"Dismiss": "Descartar",
8-
"About Us": "Acerca de Nosotros",
11+
"A new version of {0} is available. Update to version {1} now": "¡Hay una nueva versión de {0} disponible! Actualiza a la versión {1} ahora",
12+
"Update Now": "Actualizar ahora",
13+
"About Us": "Acerca de nosotros",
914
"Documentation": "Documentación",
10-
"Report Issues": "Reportar Problemas",
11-
"Rate Us": "Calificanos",
15+
"Report Issues": "Reportar problemas",
16+
"Rate Us": "Califícanos",
1217
"Follow Us": "Síguenos",
1318
"Support Us": "Apóyanos",
14-
"Become a Sponsor": "Conviértete en Patrocinador",
19+
"Become a Sponsor": "Conviértete en patrocinador",
1520
"Donate via PayPal": "Donar a través de PayPal",
16-
"Although {0} is offered at no cost, your support is deeply appreciated if you find it beneficial. Thank you for considering!": "Aunque {0} se ofrece sin costo, su apoyo es muy apreciado si lo encuentra beneficioso. ¡Gracias por considerarlo!",
21+
"Although {0} is offered at no cost, your support is deeply appreciated if you find it beneficial. Thank you for considering!": "Aunque {0} se ofrece sin costo, tu apoyo es muy apreciado si lo encuentras útil. ¡Gracias por considerarlo!",
1722
"Hello World from {0}!": "¡Hola Mundo desde {0}!",
1823
"Files found and saved to files.json": "Archivos encontrados y guardados en files.json"
1924
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@
341341
"dependencies": {
342342
"@vscode/codicons": "^0.0.36",
343343
"json-to-ts": "^2.1.0",
344-
"openai": "^4.77.0"
344+
"openai": "^4.77.0",
345+
"vscode-marketplace-client": "^1.0.0"
345346
}
346347
}

src/extension.ts

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// The module 'vscode' contains the VS Code extensibility API
1+
// The module 'vscode' contains the VSCode extensibility API
22
// Import the module and reference it with the alias vscode in your code below
33
import * as vscode from 'vscode';
4+
import { VSCodeMarketplaceClient } from 'vscode-marketplace-client';
45

56
// Import the Configs, Controllers, and Providers
67
import {
@@ -66,10 +67,13 @@ export async function activate(context: vscode.ExtensionContext) {
6667

6768
// Watch for changes in the configuration
6869
vscode.workspace.onDidChangeConfiguration((event) => {
70+
const workspaceConfig = vscode.workspace.getConfiguration(
71+
EXTENSION_ID,
72+
resource?.uri,
73+
);
74+
6975
if (event.affectsConfiguration(EXTENSION_ID, resource?.uri)) {
70-
config.update(
71-
vscode.workspace.getConfiguration(EXTENSION_ID, resource?.uri),
72-
);
76+
config.update(workspaceConfig);
7377
}
7478
});
7579

@@ -106,7 +110,7 @@ export async function activate(context: vscode.ExtensionContext) {
106110
];
107111

108112
const message = vscode.l10n.t(
109-
'New version of {0} is available. Check out the release notes for version {1}',
113+
"The {0} extension has been updated. Check out what's new in version {1}",
110114
[EXTENSION_DISPLAY_NAME, currentVersion],
111115
);
112116
vscode.window.showInformationMessage(message, ...actions).then((option) => {
@@ -133,6 +137,58 @@ export async function activate(context: vscode.ExtensionContext) {
133137
context.globalState.update('version', currentVersion);
134138
}
135139

140+
// -----------------------------------------------------------------
141+
// Check for updates
142+
// -----------------------------------------------------------------
143+
144+
// Check for updates to the extension
145+
try {
146+
// Retrieve the latest version
147+
VSCodeMarketplaceClient.getLatestVersion(
148+
EXTENSION_USER_PUBLISHER,
149+
EXTENSION_NAME,
150+
).then((latestVersion) => {
151+
// Check if the latest version is different from the current version
152+
if (latestVersion !== currentVersion) {
153+
const actions: vscode.MessageItem[] = [
154+
{
155+
title: vscode.l10n.t('Update Now'),
156+
},
157+
{
158+
title: vscode.l10n.t('Dismiss'),
159+
},
160+
];
161+
162+
const message = vscode.l10n.t(
163+
'A new version of {0} is available. Update to version {1} now',
164+
[EXTENSION_DISPLAY_NAME, latestVersion],
165+
);
166+
vscode.window
167+
.showInformationMessage(message, ...actions)
168+
.then(async (option) => {
169+
if (!option) {
170+
return;
171+
}
172+
173+
// Handle the actions
174+
switch (option?.title) {
175+
case actions[0].title:
176+
await vscode.commands.executeCommand(
177+
'workbench.extensions.action.install.anotherVersion',
178+
`${EXTENSION_USER_PUBLISHER}.${EXTENSION_NAME}`,
179+
);
180+
break;
181+
182+
default:
183+
break;
184+
}
185+
});
186+
}
187+
});
188+
} catch (error) {
189+
console.error('Error retrieving extension version:', error);
190+
}
191+
136192
// #region Example
137193

138194
// -----------------------------------------------------------------

0 commit comments

Comments
 (0)