deno-cliffy icon indicating copy to clipboard operation
deno-cliffy copied to clipboard

Most upgrade command providers don't sort listed versions

Open Macil opened this issue 1 year ago • 0 comments

I noticed that most upgrade providers besides GithubProvider list versions in a pretty arbitrary order, which is a bit confusing and ugly. (I think they might always be shown in the order that the server responds with them in, and Github happens to sort the results.) I would expect the versions to be sorted descending using something like natural sorting (ie list.sort((a, b) => b.localeCompare(a, undefined, {numeric: true})); maybe this would only be done in non-Github providers because maybe Github does this or something smarter already).

import { Command } from "@cliffy/command";
import { UpgradeCommand } from "@cliffy/command/upgrade";
import { JsrProvider } from "@cliffy/command/upgrade/provider/jsr";
import { NpmProvider } from "@cliffy/command/upgrade/provider/npm";
import { GithubProvider } from "@cliffy/command/upgrade/provider/github";

await new Command()
  .name("test")
  .command(
    "upgrade",
    new UpgradeCommand({
      provider: [
        new JsrProvider({ scope: "std", name: "assert" }),
        new NpmProvider({ name: "chai" }),
        new GithubProvider({ repository: "c4spar/deno-cliffy", branches: false }),
      ],
    })
  )
  .parse();
$ deno run -A main.ts upgrade --registry jsr -l
  1.0.12    1.0.9     0.221.0      0.210.0   1.0.7     1.0.2        0.196.0   0.201.0   
  0.220.1   0.209.0   1.0.0        0.226.0   0.222.0   0.215.0      0.198.0   1.0.0-rc.2
  1.0.1     1.0.11    0.199.0      0.197.0   0.225.0   1.0.0-rc.3   0.203.0   0.218.0   
  1.0.5     1.0.3     0.222.1      1.0.4     0.219.0   0.218.2      0.224.0   0.213.1   
  0.212.0   0.214.0   0.208.0      0.223.0   0.211.0   0.206.0      1.0.6     0.207.0   
  0.216.0   0.204.0   1.0.0-rc.1   0.202.0   0.218.1   0.225.3      1.0.8     0.225.2   
  0.219.1   0.200.0   0.225.1      0.217.0   1.0.10    0.205.0      0.213.0             
$ deno run -A main.ts upgrade --registry npm -l
  5.2.0           4.3.9           4.1.2            3.1.0    1.8.0   1.1.0   0.3.4   0.1.4
  5.1.2           4.3.8           4.1.1            3.0.0    1.7.2   1.0.4   0.3.3   0.1.3
  4.5.0           5.0.0-alpha.1   4.1.0            2.3.0    1.7.1   1.0.3   0.3.2   0.1.2
  5.1.1           5.0.0-alpha.0   4.0.2            2.2.0    1.7.0   1.0.2   0.3.1   0.1.1
  5.1.0           4.3.7           4.0.1            2.1.2    1.6.1   1.0.1   0.3.0   0.1.0
  5.0.3           4.3.6           4.0.0            2.1.1    1.6.0   1.0.0   0.2.4   0.0.2
  5.0.2           4.3.5           4.0.0-canary.2   2.1.0    1.5.0   0.5.3   0.2.3   0.0.1
  4.4.1           4.3.4           4.0.0-canary.1   2.0.0    1.4.2   0.5.2   0.2.2        
  4.4.0           4.3.3           3.5.0            1.10.0   1.4.1   0.5.1   0.2.1        
  5.0.0           4.3.2           3.4.1            1.9.2    1.4.0   0.5.0   0.2.0        
  5.0.0-rc.0      4.3.1           3.4.0            1.9.1    1.3.0   0.4.2   0.1.7        
  5.0.0-alpha.2   4.3.0           3.3.0            1.9.0    1.2.0   0.4.1   0.1.6        
  4.3.10          4.2.0           3.2.0            1.8.1    1.1.1   0.4.0   0.1.5        
$ deno run -A main.ts upgrade --registry github -l
  0.12.1        v0.25.6   v0.24.1   v0.19.5   v0.17.2   v0.13.0   v0.8.1   v0.3.0
  v1.0.0-rc.7   v0.25.5   v0.24.0   v0.19.4   v0.17.1   v0.12.1   v0.8.0   v0.2.0
  v1.0.0-rc.6   v0.25.4   v0.23.2   v0.19.3   v0.17.0   v0.12.0   v0.7.1   v0.1.0
  v1.0.0-rc.5   v0.25.3   v0.23.1   v0.19.2   v0.16.0   v0.11.2   v0.7.0         
  v1.0.0-rc.4   v0.25.2   v0.23.0   v0.19.1   v0.15.0   v0.11.1   v0.6.1         
  v1.0.0-rc.3   v0.25.1   v0.22.2   v0.19.0   v0.14.3   v0.11.0   v0.6.0         
  v1.0.0-rc.2   v0.25.0   v0.20.1   v0.18.2   v0.14.2   v0.10.0   v0.5.1         
  v1.0.0-rc.1   v0.24.3   v0.20.0   v0.18.1   v0.14.1   v0.9.0    v0.5.0         
  v0.25.7       v0.24.2   v0.19.6   v0.18.0   v0.14.0   v0.8.2    v0.4.0         

Macil avatar Mar 27 '25 22:03 Macil