Skip to content

Commit

Permalink
feat(publish): Add npm-session, npm-version, and user-agent fields to…
Browse files Browse the repository at this point in the history
… libnpm/fetch config
  • Loading branch information
evocateur committed Dec 18, 2018
1 parent bfe0f98 commit 5edb27d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions commands/publish/index.js
Expand Up @@ -2,6 +2,7 @@

const os = require("os");
const path = require("path");
const crypto = require("crypto");
const pFinally = require("p-finally");
const pMap = require("p-map");
const pPipe = require("p-pipe");
Expand Down Expand Up @@ -70,12 +71,25 @@ class PublishCommand extends Command {
// https://docs.npmjs.com/misc/config#save-prefix
this.savePrefix = this.options.exact ? "" : "^";

// npmSession and user-agent are consumed by libnpm/fetch (via libnpm/publish)
const npmSession = crypto.randomBytes(8).toString("hex");
const userAgent = `lerna/${this.options.lernaVersion}/node@${process.version}+${process.arch} (${
process.platform
})`;

this.logger.verbose("session", npmSession);
this.logger.verbose("user-agent", userAgent);

this.conf = npmConf({
command: "publish",
log: this.logger,
npmSession,
npmVersion: userAgent,
registry: this.options.registry,
});

this.conf.set("user-agent", userAgent, "cli");

if (this.conf.get("registry") === "https://registry.yarnpkg.com") {
this.logger.warn("", "Yarn's registry proxy is broken, replacing with public npm registry");
this.logger.warn("", "If you don't have an npm token, you should exit and run `npm login`");
Expand Down

0 comments on commit 5edb27d

Please sign in to comment.