Socket
Socket
Sign inDemoInstall

@lerna/npm-publish

Package Overview
Dependencies
206
Maintainers
2
Versions
83
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.18.5 to 4.0.0

33

CHANGELOG.md

@@ -6,2 +6,35 @@ # Change Log

# [4.0.0](https://github.com/lerna/lerna/compare/v3.22.1...v4.0.0) (2021-02-10)
### Features
* **deps:** Bump dependencies ([affed1c](https://github.com/lerna/lerna/commit/affed1ce0fce91f01b0a9eafe357db2d985b974f))
* Consume named exports of sibling modules ([63499e3](https://github.com/lerna/lerna/commit/63499e33652bc78fe23751875d74017e2f16a689))
* Expose named export ([c1303f1](https://github.com/lerna/lerna/commit/c1303f13adc4cf15f96ff25889b52149f8224c0e))
* Remove default export ([e2f1ec3](https://github.com/lerna/lerna/commit/e2f1ec3dd049d2a89880029908a2aa7c66f15082))
* **deps:** @evocateur/libnpmpublish -> libnpmpublish@^4.0.0 ([341146e](https://github.com/lerna/lerna/commit/341146ef6c9111607f99d2f1663f973ab16c755e))
* **deps:** fs-extra@^9.0.1 ([2f6f4e0](https://github.com/lerna/lerna/commit/2f6f4e066d5a41b4cd508b3405ac1d0a342932dc))
* **deps:** npm-package-arg@^8.1.0 ([12c8923](https://github.com/lerna/lerna/commit/12c892342d33b86a00ee2cf9079f9b26fe316dc6))
* **deps:** pify@^5.0.0 ([6b34452](https://github.com/lerna/lerna/commit/6b3445219f0f022411a7cb282b0ba39a072e2ef2))
* **deps:** read-package-json@^3.0.0 ([2a02865](https://github.com/lerna/lerna/commit/2a02865a70a0b9ea60220a98bfff745128c90c6f))
* **npm-publish:** Remove figgy-pudding ([bdc162d](https://github.com/lerna/lerna/commit/bdc162d2719fee38d6189daeb37fe4e22338fda7))
* Drop support for Node v6.x & v8.x ([ff4bb4d](https://github.com/lerna/lerna/commit/ff4bb4da215555e3bb136f5af09b5cbc631e57bb))
### BREAKING CHANGES
* The default export has been removed, please use a named export instead.
* Node v6.x & v8.x are no longer supported. Please upgrade to the latest LTS release.
Here's the gnarly one-liner I used to make these changes:
```
npx lerna exec --concurrency 1 --stream -- 'json -I -f package.json -e '"'"'this.engines=this.engines||{};this.engines.node=">= 10.18.0"'"'"
```
(requires `npm i -g json` beforehand)
## [3.18.5](https://github.com/lerna/lerna/compare/v3.18.4...v3.18.5) (2019-11-20)

@@ -8,0 +41,0 @@

105

npm-publish.js

@@ -6,37 +6,53 @@ "use strict";

const log = require("npmlog");
const { publish } = require("@evocateur/libnpmpublish");
const { publish } = require("libnpmpublish");
const pify = require("pify");
const readJSON = require("read-package-json");
const figgyPudding = require("figgy-pudding");
const runLifecycle = require("@lerna/run-lifecycle");
const { runLifecycle } = require("@lerna/run-lifecycle");
const npa = require("npm-package-arg");
const otplease = require("@lerna/otplease");
const { otplease } = require("@lerna/otplease");
module.exports = npmPublish;
module.exports.npmPublish = npmPublish;
const readJSONAsync = pify(readJSON);
const PublishConfig = figgyPudding(
{
"dry-run": { default: false },
dryRun: "dry-run",
log: { default: log },
"project-scope": {},
projectScope: "project-scope",
tag: { default: "latest" },
},
{
other() {
// open it up for the sake of tests
return true;
},
}
);
/**
* @typedef {object} NpmPublishOptions
* @property {boolean} [dryRun]
* @property {string} [tag] Passed to libnpmpublish as `opts.defaultTag` to preserve npm v6 back-compat
*/
function npmPublish(pkg, tarFilePath, _opts, otpCache) {
/**
* Alias dash-cased npmConf to camelCase
* @param {NpmPublishOptions} obj
* @returns {NpmPublishOptions}
*/
function flattenOptions(obj) {
return {
// eslint-disable-next-line dot-notation -- (npm v7 compat)
defaultTag: obj["tag"] || "latest",
dryRun: obj["dry-run"],
...obj,
};
}
/**
* @typedef {import('npm-registry-fetch').FetchOptions & { access?: 'public' | 'restricted'; defaultTag?: string; }} LibNpmPublishOptions https://github.com/npm/libnpmpublish#opts
*/
/**
* Publish a package to the configured registry.
* @param {import("@lerna/package").Package} pkg
* @param {string} tarFilePath
* @param {LibNpmPublishOptions & NpmPublishOptions} [options]
* @param {import("@lerna/otplease").OneTimePasswordCache} [otpCache]
*/
function npmPublish(pkg, tarFilePath, options = {}, otpCache) {
const { dryRun, ...remainingOptions } = flattenOptions(options);
const { scope } = npa(pkg.name);
// pass only the package scope to libnpmpublish
const opts = PublishConfig(_opts, {
const opts = {
log,
...remainingOptions,
projectScope: scope,
});
};

@@ -47,3 +63,3 @@ opts.log.verbose("publish", pkg.name);

if (!opts.dryRun) {
if (!dryRun) {
chain = chain.then(() => {

@@ -61,14 +77,19 @@ let { manifestLocation } = pkg;

// non-default tag needs to override publishConfig.tag,
// which is merged over opts.tag in libnpmpublish
// which is merged into opts below if necessary
if (
opts.tag !== "latest" &&
opts.defaultTag !== "latest" &&
manifest.publishConfig &&
manifest.publishConfig.tag &&
manifest.publishConfig.tag !== opts.tag
manifest.publishConfig.tag !== opts.defaultTag
) {
// eslint-disable-next-line no-param-reassign
manifest.publishConfig.tag = opts.tag;
manifest.publishConfig.tag = opts.defaultTag;
}
return otplease(innerOpts => publish(manifest, tarData, innerOpts), opts, otpCache).catch(err => {
// publishConfig is no longer consumed in n-r-f, so merge here
if (manifest.publishConfig) {
Object.assign(opts, publishConfigToOpts(manifest.publishConfig));
}
return otplease((innerOpts) => publish(manifest, tarData, innerOpts), opts, otpCache).catch((err) => {
opts.log.silly("", err);

@@ -94,1 +115,25 @@ opts.log.error(err.code, (err.body && err.body.error) || err.message);

}
/**
* @typedef {object} PackagePublishConfig
* @property {'public' | 'restricted'} [access]
* @property {string} [registry]
* @property {string} [tag]
*/
/**
* Obtain an object suitable for assignment onto existing options from `pkg.publishConfig`.
* @param {PackagePublishConfig} publishConfig
* @returns {Omit<PackagePublishConfig, 'tag'> & { defaultTag?: string }}
*/
function publishConfigToOpts(publishConfig) {
const opts = { ...publishConfig };
// npm v7 renamed tag internally
if (publishConfig.tag) {
opts.defaultTag = publishConfig.tag;
delete opts.tag;
}
return opts;
}
{
"name": "@lerna/npm-publish",
"version": "3.18.5",
"version": "4.0.0",
"description": "An internal Lerna tool",

@@ -20,3 +20,3 @@ "keywords": [

"engines": {
"node": ">= 6.9.0"
"node": ">= 10.18.0"
},

@@ -35,13 +35,12 @@ "publishConfig": {

"dependencies": {
"@evocateur/libnpmpublish": "^1.2.2",
"@lerna/otplease": "3.18.5",
"@lerna/run-lifecycle": "3.16.2",
"figgy-pudding": "^3.5.1",
"fs-extra": "^8.1.0",
"npm-package-arg": "^6.1.0",
"@lerna/otplease": "4.0.0",
"@lerna/run-lifecycle": "4.0.0",
"fs-extra": "^9.1.0",
"libnpmpublish": "^4.0.0",
"npm-package-arg": "^8.1.0",
"npmlog": "^4.1.2",
"pify": "^4.0.1",
"read-package-json": "^2.0.13"
"pify": "^5.0.0",
"read-package-json": "^3.0.0"
},
"gitHead": "2612f51e7eecec58eacf0571724e6989e4b8e42d"
"gitHead": "4582c476e07dddddd6b2e3ab6e7f52c1f9eed59a"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc