JonShort / npm-bumpall

Utility to bump all packages to latest
MIT License
0 stars 0 forks source link

[Refactor] - Switch to use JSON output rather than parseable #21

Open JonShort opened 1 year ago

JonShort commented 1 year ago

Currently we use the --parseable output of npm outdated which requires a bit of work from bumpall to collect all the different data points from the provided string - see Package::new()

The --json output would remove most of the parsing (we can offload this to serde), leaving just the logic

Example outputs

Parseable

npm outdated --parseable
/npm_dir/node_modules/@jonshort/cenv:@jonshort/cenv@0.0.6:@jonshort/cenv@0.0.6:@jonshort/cenv@0.1.0:b
/npm_dir/node_modules/@jonshort/cenv:@jonshort/cenv@0.0.6:@jonshort/cenv@0.0.6:@jonshort/cenv@0.1.0:npm_dir
/npm_dir/workspaces/a/node_modules/abbrev:abbrev@1.1.1:abbrev@1.1.1:abbrev@2.0.0:a
/npm_dir/node_modules/debug:debug@4.3.4:debug@4.3.2:debug@4.3.4:npm_dir
/npm_dir/node_modules/left-pad:left-pad@1.3.0:left-pad@1.2.0:left-pad@1.3.0:npm_dir
/npm_dir/node_modules/polished:polished@3.7.2:polished@3.6.5:polished@4.2.2:npm_dir

JSON

npm outdated --json
{
  "@jonshort/cenv": {
    "current": "0.0.6",
    "wanted": "0.0.6",
    "latest": "0.1.0",
    "dependent": "b",
    "location": "/npm_dir/node_modules/@jonshort/cenv"
  },
  "abbrev": {
    "current": "1.1.1",
    "wanted": "1.1.1",
    "latest": "2.0.0",
    "dependent": "a",
    "location": "/npm_dir/workspaces/a/node_modules/abbrev"
  },
  "debug": {
    "current": "4.3.2",
    "wanted": "4.3.4",
    "latest": "4.3.4",
    "dependent": "npm_dir",
    "location": "/npm_dir/node_modules/debug"
  },
  "left-pad": {
    "current": "1.2.0",
    "wanted": "1.3.0",
    "latest": "1.3.0",
    "dependent": "npm_dir",
    "location": "/npm_dir/node_modules/left-pad"
  },
  "polished": {
    "current": "3.6.5",
    "wanted": "3.7.2",
    "latest": "4.2.2",
    "dependent": "npm_dir",
    "location": "/npm_dir/node_modules/polished"
  }
}
jaysc commented 1 year ago

Windows:

{
  "@jonshort/cenv": {
    "current": "0.0.6",
    "wanted": "0.0.6",
    "latest": "0.1.0",
    "dependent": "npm_dir",
    "location": "D:\\Users\\USERNAME\\Documents\\Git\\npm-bumpall\\npm_dir\\node_modules\\@jonshort\\cenv"
  },
  "debug": {
    "current": "4.3.2",
    "wanted": "4.3.4",
    "latest": "4.3.4",
    "dependent": "npm_dir",
    "location": "D:\\Users\\USERNAME\\Documents\\Git\\npm-bumpall\\npm_dir\\node_modules\\debug"
  },
  "left-pad": {
    "current": "1.2.0",
    "wanted": "1.3.0",
    "latest": "1.3.0",
    "dependent": "npm_dir",
    "location": "D:\\Users\\USERNAME\\Documents\\Git\\npm-bumpall\\npm_dir\\node_modules\\left-pad"
  },
  "polished": {
    "current": "3.6.5",
    "wanted": "3.7.2",
    "latest": "4.2.2",
    "dependent": "npm_dir",
    "location": "D:\\Users\\USERNAME\\Documents\\Git\\npm-bumpall\\npm_dir\\node_modules\\polished"
  }
}