@lerna/npm-publish
Advanced tools
Comparing version 3.18.5 to 4.0.0
@@ -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 @@ |
@@ -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" | ||
} |
17288
8
112
+ Addedlibnpmpublish@^4.0.0
+ Added@gar/promisify@1.1.3(transitive)
+ Added@lerna/npm-conf@4.0.0(transitive)
+ Added@lerna/otplease@4.0.0(transitive)
+ Added@lerna/prompt@4.0.0(transitive)
+ Added@lerna/run-lifecycle@4.0.0(transitive)
+ Added@npmcli/fs@1.1.1(transitive)
+ Added@npmcli/move-file@1.1.2(transitive)
+ Added@tootallnate/once@1.1.2(transitive)
+ Addedagent-base@6.0.2(transitive)
+ Addedagentkeepalive@4.5.0(transitive)
+ Addedaggregate-error@3.1.0(transitive)
+ Addedansi-escapes@4.3.2(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedat-least-node@1.0.0(transitive)
+ Addedcacache@15.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedchownr@2.0.0(transitive)
+ Addedclean-stack@2.2.0(transitive)
+ Addedcli-cursor@3.1.0(transitive)
+ Addedcli-width@3.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddebug@4.3.5(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addederr-code@2.0.3(transitive)
+ Addedfigures@3.2.0(transitive)
+ Addedfs-extra@9.1.0(transitive)
+ Addedfs-minipass@2.1.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedhosted-git-info@4.1.0(transitive)
+ Addedhttp-cache-semantics@4.1.1(transitive)
+ Addedhttp-proxy-agent@4.0.1(transitive)
+ Addedhttps-proxy-agent@5.0.1(transitive)
+ Addedindent-string@4.0.0(transitive)
+ Addedinquirer@7.3.3(transitive)
+ Addedip-address@9.0.5(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedis-lambda@1.0.1(transitive)
+ Addedjsbn@1.1.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedlibnpmpublish@4.0.2(transitive)
+ Addedlru-cache@6.0.0(transitive)
+ Addedmake-fetch-happen@9.1.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedminipass@3.3.65.0.0(transitive)
+ Addedminipass-collect@1.0.2(transitive)
+ Addedminipass-fetch@1.4.1(transitive)
+ Addedminipass-flush@1.0.5(transitive)
+ Addedminipass-json-stream@1.0.1(transitive)
+ Addedminipass-pipeline@1.2.4(transitive)
+ Addedminipass-sized@1.0.3(transitive)
+ Addedminizlib@2.1.2(transitive)
+ Addedmkdirp@1.0.4(transitive)
+ Addedms@2.1.2(transitive)
+ Addedmute-stream@0.0.8(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addednormalize-package-data@3.0.3(transitive)
+ Addednpm-package-arg@8.1.5(transitive)
+ Addednpm-registry-fetch@11.0.0(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedp-map@4.0.0(transitive)
+ Addedpify@5.0.0(transitive)
+ Addedpromise-retry@2.0.1(transitive)
+ Addedread-package-json@3.0.1(transitive)
+ Addedrestore-cursor@3.1.0(transitive)
+ Addedretry@0.12.0(transitive)
+ Addedrimraf@3.0.2(transitive)
+ Addedsemver@7.6.2(transitive)
+ Addedsocks@2.8.3(transitive)
+ Addedsocks-proxy-agent@6.2.1(transitive)
+ Addedsprintf-js@1.1.3(transitive)
+ Addedssri@8.0.1(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedtar@6.2.1(transitive)
+ Addedtype-fest@0.21.3(transitive)
+ Addeduniversalify@2.0.1(transitive)
+ Addedyallist@4.0.0(transitive)
- Removed@evocateur/libnpmpublish@^1.2.2
- Removedfiggy-pudding@^3.5.1
- Removed@evocateur/libnpmpublish@1.2.2(transitive)
- Removed@evocateur/npm-registry-fetch@4.0.0(transitive)
- Removed@lerna/npm-conf@3.16.0(transitive)
- Removed@lerna/otplease@3.18.5(transitive)
- Removed@lerna/prompt@3.18.5(transitive)
- Removed@lerna/run-lifecycle@3.16.2(transitive)
- RemovedJSONStream@1.3.5(transitive)
- Removedagent-base@4.2.14.3.0(transitive)
- Removedagentkeepalive@3.5.3(transitive)
- Removedansi-escapes@3.2.0(transitive)
- Removedansi-regex@3.0.14.1.1(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedaproba@2.0.0(transitive)
- Removedbluebird@3.7.2(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedcacache@12.0.4(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcli-cursor@2.1.0(transitive)
- Removedcli-width@2.2.1(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedconcat-stream@1.6.2(transitive)
- Removedcopy-concurrently@1.0.5(transitive)
- Removedcyclist@1.0.2(transitive)
- Removeddebug@3.1.0(transitive)
- Removedduplexify@3.7.1(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removederr-code@1.1.2(transitive)
- Removedes6-promise@4.2.8(transitive)
- Removedes6-promisify@5.0.0(transitive)
- Removedfiggy-pudding@3.5.2(transitive)
- Removedfigures@2.0.0(transitive)
- Removedflush-write-stream@1.1.1(transitive)
- Removedfrom2@2.3.0(transitive)
- Removedfs-extra@8.1.0(transitive)
- Removedfs-write-stream-atomic@1.0.10(transitive)
- Removedget-stream@4.1.0(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedhttp-cache-semantics@3.8.1(transitive)
- Removedhttp-proxy-agent@2.1.0(transitive)
- Removedhttps-proxy-agent@2.2.4(transitive)
- Removediferr@0.1.5(transitive)
- Removedinquirer@6.5.2(transitive)
- Removedip@1.1.5(transitive)
- Removedis-fullwidth-code-point@2.0.0(transitive)
- Removedjson-parse-better-errors@1.0.2(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removedlodash.clonedeep@4.5.0(transitive)
- Removedlru-cache@5.1.1(transitive)
- Removedmake-fetch-happen@5.0.2(transitive)
- Removedmimic-fn@1.2.0(transitive)
- Removedmississippi@3.0.0(transitive)
- Removedmove-concurrently@1.0.1(transitive)
- Removedms@2.0.0(transitive)
- Removedmute-stream@0.0.7(transitive)
- Removednode-fetch-npm@2.0.4(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removednpm-package-arg@6.1.1(transitive)
- Removedonetime@2.0.1(transitive)
- Removedparallel-transform@1.2.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpify@4.0.1(transitive)
- Removedpromise-retry@1.1.1(transitive)
- Removedpump@2.0.13.0.0(transitive)
- Removedpumpify@1.5.1(transitive)
- Removedread-package-json@2.1.2(transitive)
- Removedresolve@1.22.8(transitive)
- Removedrestore-cursor@2.0.0(transitive)
- Removedretry@0.10.1(transitive)
- Removedrun-queue@1.0.3(transitive)
- Removedsocks@2.3.3(transitive)
- Removedsocks-proxy-agent@4.0.2(transitive)
- Removedssri@6.0.2(transitive)
- Removedstream-each@1.2.3(transitive)
- Removedstream-shift@1.0.3(transitive)
- Removedstring-width@2.1.1(transitive)
- Removedstrip-ansi@4.0.05.2.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedthrough2@2.0.5(transitive)
- Removedtypedarray@0.0.6(transitive)
- Removeduniversalify@0.1.2(transitive)
- Removedxtend@4.0.2(transitive)
- Removedy18n@4.0.3(transitive)
Updated@lerna/otplease@4.0.0
Updated@lerna/run-lifecycle@4.0.0
Updatedfs-extra@^9.1.0
Updatednpm-package-arg@^8.1.0
Updatedpify@^5.0.0
Updatedread-package-json@^3.0.0