npm verdaccio 5.11.0
v5.11.0

latest releases: 6.0.1, 8.0.0-next-8.3, 8.0.0-next-8.2...
2 years ago

5.11.0 (2022-06-02)

The way to use verdaccio programatically is not very friendly if you are using

const startVerdaccio = require('verdaccio'); 

as this example.

⚠️ Deprecations

  • Using verdaccio with multiples listeners display a deprecation warning
    • (runServer) forbid this and only allows the first one listener listed
  • On verdaccio 6 will be removed and will throw an error

❌ Bad

listen:
 - localhost:4873            # default value
 - http://localhost:4873     # same thing

✅ Good (on v6.0.0 won't be a list anymore)

listen: localhost:4873

🚀 Feature

runServer method to run verdaccio programatically as a promise

I am looking for a better name, feel free to drop your ideas.

On v6 #2165 this was improved and I am moving the same API to v5 so is much easier to migrate in the future.

It's a bit experimental, it does not replace the old way, so won't break anything, but allows smooth migration

There are three ways to use it:

  • No input, it will find the config.yaml as is you would run verdaccio in the console
  • With a absolute path
  • With an object (there is a catch here, see below)
    const {runServer} = require('verdaccio');
    const app = await runServer(); // default configuration
    const app = await runServer('./config/config.yaml');
    const app = await runServer({ configuration });
    app.listen(4000, (event) => {
      // do something
    });

With an object you need to add self_path, manually (it's not nice but would be a breaking change changing it now) on v6 this is not longer need it.

      const configPath = join(__dirname, './config.yaml');
      const c = parseConfigFile(configPath);
      // workaround
      // on v5 the `self_path` still exists and will be removed in v6
      c.self_path = 'foo';
      runServer(c).then(() => {});

Read more here https://verdaccio.org/docs/verdaccio-programmatically

parseConfigFile method

Exposed for easy use parse a yaml file as an object

Don't miss a new verdaccio release

NewReleases is sending notifications on new releases.