dsh-plugin-syncup 4.1.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +28 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -228,7 +228,32 @@ export function apply(ctx, rawConfig) {
228
228
 
229
229
  registerApiRoutes({ ctx, runtime, config })
230
230
 
231
- ctx.effect(() => ctx.tools.register({
231
+ // A leftover row for a previous package id can register `plugin_sync` first,
232
+ // which makes this whole bundle fail to load ("tool is already registered").
233
+ // Registering conditionally keeps the settings page and the HTTP API working,
234
+ // and says what to fix instead of dying silently.
235
+ const toolAlreadyTaken = () => {
236
+ try {
237
+ const registry = ctx.get('tools')
238
+ const list = registry?.list?.()
239
+ if (!Array.isArray(list)) return false
240
+ return list.some((tool) => (tool?.name ?? tool) === 'plugin_sync')
241
+ } catch {
242
+ return false
243
+ }
244
+ }
245
+
246
+ ctx.effect(() => {
247
+ if (toolAlreadyTaken()) {
248
+ ctx.logger?.warn?.(
249
+ 'plugin-syncup: "plugin_sync" is already registered by another entry, so this plugin '
250
+ + 'skipped its own tool. This normally means a row for the pre-rename id (dsh-plugin-sync) '
251
+ + 'is still in the profile cordis.patch.yml; remove that row and restart DSH. '
252
+ + 'The settings page and the HTTP API keep working.',
253
+ )
254
+ return () => {}
255
+ }
256
+ return ctx.tools.register({
232
257
  name: 'plugin_sync',
233
258
  description:
234
259
  'Preview and apply a GitHub Gist plugin manifest. Manual only: no background sync. '
@@ -344,7 +369,8 @@ export function apply(ctx, rawConfig) {
344
369
  }
345
370
  }
346
371
  },
347
- }), 'plugin-sync: tool')
372
+ })
373
+ }, 'plugin-sync: tool')
348
374
 
349
375
  if (config.configError !== undefined) {
350
376
  runtime.log('warn', config.configError)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-syncup",
3
- "version": "4.1.1",
3
+ "version": "4.2.0",
4
4
  "description": "Sync plugin inventories through a secret GitHub Gist and update every plugin to its newest release, with conflict-aware preview and an install log.",
5
5
  "type": "module",
6
6
  "icon": "icon.svg",