dsh-nextsteps 1.4.6 → 1.4.8

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.
package/client.js CHANGED
@@ -10,6 +10,8 @@ window.__ModuleLoader__.load({
10
10
  const MAX_FOLLOWUPS = 6;
11
11
  const PROMPT_TRUNCATE = 60;
12
12
  const CLICKED_KEY = 'dsh-nextsteps.clicked';
13
+ const UPDATE_KEY = 'dsh-nextsteps.updated';
14
+ const remembered = () => { try { return localStorage.getItem(UPDATE_KEY); } catch { return null; } };
13
15
 
14
16
 
15
17
  const CSS = `
@@ -371,14 +373,6 @@ window.__ModuleLoader__.load({
371
373
  let pluginSettings = { lang: 'auto', maxFollowups: 3, showHeader: true };
372
374
  let updateManager = undefined;
373
375
 
374
- function compareVersions(a, b) {
375
- const pa = String(a ?? '').replace(/^v/, '').split('.').map((part) => Number(part) || 0);
376
- const pb = String(b ?? '').replace(/^v/, '').split('.').map((part) => Number(part) || 0);
377
- for (let index = 0; index < Math.max(pa.length, pb.length); index += 1) {
378
- if ((pa[index] ?? 0) !== (pb[index] ?? 0)) return (pa[index] ?? 0) < (pb[index] ?? 0) ? -1 : 1;
379
- }
380
- return 0;
381
- }
382
376
  let pluginVersion;
383
377
 
384
378
  async function responseJson(response) {
@@ -565,8 +559,7 @@ window.__ModuleLoader__.load({
565
559
  const response = await fetch(UPDATE_ROUTE, { cache: 'no-store' });
566
560
  const info = await responseJson(response);
567
561
  if (!response.ok || info === null || typeof info !== 'object' || info.error !== undefined) throw new Error(info?.error ?? 'HTTP ' + response.status);
568
- const installedNewer = compareVersions(info.installed, info.current) > 0;
569
- const status = installedNewer ? 'restart' : info.newer !== true ? 'current' : info.managed ? 'available' : 'manual';
562
+ const status = info.newer !== true ? 'current' : remembered() === info.latest ? 'restart' : info.managed ? 'available' : 'manual';
570
563
  setUpdate({ status, info });
571
564
  } catch (error) {
572
565
  setUpdate((previous) => previous.status === 'restart' ? previous : { status: 'error', info: previous.info, error: String(error?.message ?? error) });
@@ -588,10 +581,12 @@ window.__ModuleLoader__.load({
588
581
  };
589
582
  let result = await installSpec(NPM_NAME + '@' + info.latest);
590
583
  if (result?.error?.code === 'already-installed') result = await installSpec('https://registry.npmjs.org/' + NPM_NAME + '/-/' + NPM_NAME + '-' + info.latest + '.tgz');
591
- const firstLine = () => result?.error?.diagnostic?.split(String.fromCharCode(10)).find((line) => line.trim() !== '') ?? result?.error?.code ?? result?.application;
584
+ const diagnosticLines = String(result?.error?.diagnostic ?? '').split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line !== '');
585
+ const firstLine = () => diagnosticLines.find((line) => line.startsWith('dsh:')) ?? diagnosticLines.at(-1) ?? result?.error?.code ?? result?.application;
592
586
  const live = result?.application === 'applied';
593
587
  if (!live && result?.application !== 'restart-required' && result?.version !== info.latest) throw new Error(firstLine());
594
588
  if (result?.application === 'failed') console.warn(`dsh-nextsteps: ${info.latest} is installed; dsh could not start it before a restart: ${firstLine()}`);
589
+ try { localStorage.setItem(UPDATE_KEY, info.latest); } catch { }
595
590
  setUpdate(live
596
591
  ? { status: 'current', info: { ...info, current: info.latest, newer: false } }
597
592
  : { status: 'restart', info });
@@ -0,0 +1,4 @@
1
+ - insert:
2
+ - id: dsh-nextsteps
3
+ name: 'dsh-nextsteps'
4
+ config: {}
package/index.js CHANGED
@@ -172,10 +172,6 @@ function nextstepsSectionText() {
172
172
  ].join('\n');
173
173
  }
174
174
 
175
- function onDiskVersion() {
176
- try { return JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')).version ?? null; } catch { return null; }
177
- }
178
-
179
175
  const PLUGIN_REV = 'sf-2';
180
176
 
181
177
  function toolSpec(settings = { lang: 'auto', maxFollowups: 3, model: '' }) {
@@ -453,7 +449,7 @@ async function apply(ctx) {
453
449
  fetch: async (request) => {
454
450
  try {
455
451
  const info = await checkUpdate(fetch, PACKAGE, request.signal);
456
- return json({ ...info, installed: onDiskVersion() });
452
+ return json({ ...info, installed: undefined });
457
453
  } catch (error) {
458
454
  return json({ error: String(error?.message ?? error) }, 502);
459
455
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-nextsteps",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -9,6 +9,7 @@
9
9
  "./package.json": "./package.json"
10
10
  },
11
11
  "files": [
12
+ "cordis.patch.yml",
12
13
  "index.js",
13
14
  "client.js",
14
15
  "lib/locale",