frinyvonnick / gitmoji-changelog

A changelog generator for gitmoji 😜
https://www.npmjs.com/package/gitmoji-changelog
MIT License
390 stars 49 forks source link

Verify that the client has the last version when he runs the CLI #37

Closed fabienjuif closed 6 years ago

fabienjuif commented 6 years ago

yarn

Code: https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/install.js#L1083 It calls a server that returns the version. The requestManager seems to be a custom client that cache the dns resolution for the yarn registry: https://github.com/yarnpkg/yarn/blob/master/src/util/request-manager.js But I think we can use anything we like (like got ?). The URL is: https://yarnpkg.com/latest-version

idea

Maybe we can use the npmregistry: https://docs.npmjs.com/misc/registry https://registry.npmjs.org/ I bet there is some node clients :)

fabienjuif commented 6 years ago
const { manifest } = require('libnpm')

manifest('gitmoji-changelog@latest')
  .then(console.log)
➜  test git:(bug/empty-tag) ✗ time node index.js
Manifest {
  name: 'gitmoji-changelog',
  version: '1.0.0',
  engines: { node: '>=10' },
  cpu: undefined,
  os: undefined,
  dependencies:
   { '@gitmoji-changelog/core': '^1.0.0',
     '@gitmoji-changelog/markdown': '^1.0.0',
     yargs: '^12.0.1' },
  optionalDependencies: {},
  devDependencies: {},
  bundleDependencies: false,
  peerDependencies: {},
  deprecated: false,
  _resolved:
   'https://registry.npmjs.org/gitmoji-changelog/-/gitmoji-changelog-1.0.0.tgz',
  _integrity:
   'sha512-eBy+f/Ef/EO7FX78+y3lTQ7nLznJt6K3TtLWQJA4Jfi2AoOaCTXfe7oVRp8MTut/Xcu53
z+fUzYbuWVMIQWBvw==',
  _shasum: '3d8837482f121930b40c7343a00117f795d963b0',
  _shrinkwrap: null,
  bin: { 'gitmoji-changelog': './src/index.js' },
  _id: 'gitmoji-changelog@1.0.0' }
node index.js  0.31s user 0.06s system 80% cpu 0.463 total➜  test git:(bug/empty-tag) ✗