diff --git a/CHANGELOG.md b/CHANGELOG.md index 42c34056d9..e76ff309e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.10.8](https://github.com/lerna/lerna/compare/v3.10.7...v3.10.8) (2019-02-01) + + +### Bug Fixes + +* **conventional-commits:** Support legacy callback presets ([60647b4](https://github.com/lerna/lerna/commit/60647b4)), closes [#1896](https://github.com/lerna/lerna/issues/1896) +* **publish:** Skip private package lookup ([#1905](https://github.com/lerna/lerna/issues/1905)) ([f9e18fa](https://github.com/lerna/lerna/commit/f9e18fa)) +* **version:** Fix negated option links in readme ([0908212](https://github.com/lerna/lerna/commit/0908212)) + + + + + ## [3.10.7](https://github.com/lerna/lerna/compare/v3.10.6...v3.10.7) (2019-01-22) diff --git a/commands/changed/CHANGELOG.md b/commands/changed/CHANGELOG.md index fe4df7bd51..9da8dc07c9 100644 --- a/commands/changed/CHANGELOG.md +++ b/commands/changed/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.10.8](https://github.com/lerna/lerna/compare/v3.10.7...v3.10.8) (2019-02-01) + +**Note:** Version bump only for package @lerna/changed + + + + + ## [3.10.6](https://github.com/lerna/lerna/compare/v3.10.5...v3.10.6) (2019-01-19) **Note:** Version bump only for package @lerna/changed diff --git a/commands/changed/package.json b/commands/changed/package.json index a4a9ff75c4..faf2aa18cf 100644 --- a/commands/changed/package.json +++ b/commands/changed/package.json @@ -1,6 +1,6 @@ { "name": "@lerna/changed", - "version": "3.10.6", + "version": "3.10.8", "description": "List local packages that have changed since the last tagged release", "keywords": [ "lerna", diff --git a/commands/publish/CHANGELOG.md b/commands/publish/CHANGELOG.md index f8a3bb1112..551de6f979 100644 --- a/commands/publish/CHANGELOG.md +++ b/commands/publish/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.10.8](https://github.com/lerna/lerna/compare/v3.10.7...v3.10.8) (2019-02-01) + + +### Bug Fixes + +* **publish:** Skip private package lookup ([#1905](https://github.com/lerna/lerna/issues/1905)) ([f9e18fa](https://github.com/lerna/lerna/commit/f9e18fa)) + + + + + ## [3.10.7](https://github.com/lerna/lerna/compare/v3.10.6...v3.10.7) (2019-01-22) **Note:** Version bump only for package @lerna/publish diff --git a/commands/publish/README.md b/commands/publish/README.md index 0e3c33d8d6..7d41aacc18 100644 --- a/commands/publish/README.md +++ b/commands/publish/README.md @@ -69,7 +69,11 @@ lerna publish --canary preminor # 1.0.0 => 1.1.0-alpha.0+${SHA} ``` -When run with this flag, `lerna publish` publishes packages in a more granular way (per commit). Before publishing to npm, it creates the new `version` tag by taking the current `version`, bumping it to the next _minor_ version, adding the provided meta suffix (defaults to `alpha`) and appending the current git sha (ex: `1.0.0` becomes `1.1.0-alpha.81e3b443`). +When run with this flag, `lerna publish` publishes packages in a more granular way (per commit). +Before publishing to npm, it creates the new `version` tag by taking the current `version`, bumping it to the next _minor_ version, adding the provided meta suffix (defaults to `alpha`) and appending the current git sha (ex: `1.0.0` becomes `1.1.0-alpha.0+81e3b443`). + +If you have publish canary releases from multiple active development branches in CI, +it is recommended to customize the [`--preid`](#--preid) and [`--dist-tag `](#--dist-tag-tag) on a per-branch basis to avoid clashing versions. > The intended use case for this flag is a per commit level release or nightly release. diff --git a/commands/publish/__tests__/__fixtures__/public-private/LICENSE b/commands/publish/__tests__/__fixtures__/public-private/LICENSE new file mode 100644 index 0000000000..de4d3b4095 --- /dev/null +++ b/commands/publish/__tests__/__fixtures__/public-private/LICENSE @@ -0,0 +1,3 @@ +Copyright (c) 2018 Tester McPerson + +ABC License diff --git a/commands/publish/__tests__/__fixtures__/public-private/lerna.json b/commands/publish/__tests__/__fixtures__/public-private/lerna.json new file mode 100644 index 0000000000..1587a66968 --- /dev/null +++ b/commands/publish/__tests__/__fixtures__/public-private/lerna.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} diff --git a/commands/publish/__tests__/__fixtures__/public-private/package.json b/commands/publish/__tests__/__fixtures__/public-private/package.json new file mode 100644 index 0000000000..d9659f8eb7 --- /dev/null +++ b/commands/publish/__tests__/__fixtures__/public-private/package.json @@ -0,0 +1,4 @@ +{ + "name": "licenses", + "version": "0.0.0-monorepo" +} diff --git a/commands/publish/__tests__/__fixtures__/public-private/packages/package-1/package.json b/commands/publish/__tests__/__fixtures__/public-private/packages/package-1/package.json new file mode 100644 index 0000000000..8eb2fba205 --- /dev/null +++ b/commands/publish/__tests__/__fixtures__/public-private/packages/package-1/package.json @@ -0,0 +1,4 @@ +{ + "name": "package-1", + "version": "1.0.0" +} diff --git a/commands/publish/__tests__/__fixtures__/public-private/packages/package-2/package.json b/commands/publish/__tests__/__fixtures__/public-private/packages/package-2/package.json new file mode 100644 index 0000000000..7f3763b5eb --- /dev/null +++ b/commands/publish/__tests__/__fixtures__/public-private/packages/package-2/package.json @@ -0,0 +1,5 @@ +{ + "name": "package-2", + "version": "1.0.0", + "private": true +} diff --git a/commands/publish/__tests__/get-unpublished-packages.test.js b/commands/publish/__tests__/get-unpublished-packages.test.js index 29882d6c60..fe15121b17 100644 --- a/commands/publish/__tests__/get-unpublished-packages.test.js +++ b/commands/publish/__tests__/get-unpublished-packages.test.js @@ -68,3 +68,23 @@ Array [ ] `); }); + +test("getUnpublishedPackages with private package", async () => { + const cwd = await initFixture("public-private"); + const packages = await getPackages(cwd); + const packageGraph = new PackageGraph(packages); + + const opts = new Map(); + const pkgs = await getUnpublishedPackages(packageGraph, opts); + + expect(pkgs).toMatchInlineSnapshot(` +Array [ + PackageGraphNode { + "externalDependencies": Map {}, + "localDependencies": Map {}, + "localDependents": Map {}, + "name": "package-1", + }, +] +`); +}); diff --git a/commands/publish/lib/get-unpublished-packages.js b/commands/publish/lib/get-unpublished-packages.js index 4e5cbf2b8d..fe83bd9047 100644 --- a/commands/publish/lib/get-unpublished-packages.js +++ b/commands/publish/lib/get-unpublished-packages.js @@ -11,6 +11,9 @@ function getUnpublishedPackages(packageGraph, opts) { let chain = Promise.resolve(); + // don't bother attempting to get the packument for private packages + const graphNodesToCheck = Array.from(packageGraph.values()).filter(({ pkg }) => !pkg.private); + const mapper = pkg => getPackument(pkg.name, opts).then( packument => { @@ -24,7 +27,7 @@ function getUnpublishedPackages(packageGraph, opts) { } ); - chain = chain.then(() => pMap(packageGraph.values(), mapper, { concurrency: 4 })); + chain = chain.then(() => pMap(graphNodesToCheck, mapper, { concurrency: 4 })); return chain.then(results => results.filter(Boolean)); } diff --git a/commands/publish/package.json b/commands/publish/package.json index 8f07821018..5bc48ae011 100644 --- a/commands/publish/package.json +++ b/commands/publish/package.json @@ -1,6 +1,6 @@ { "name": "@lerna/publish", - "version": "3.10.7", + "version": "3.10.8", "description": "Publish packages in the current project", "keywords": [ "lerna", diff --git a/commands/version/CHANGELOG.md b/commands/version/CHANGELOG.md index 172dae1738..83f16e72a3 100644 --- a/commands/version/CHANGELOG.md +++ b/commands/version/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.10.8](https://github.com/lerna/lerna/compare/v3.10.7...v3.10.8) (2019-02-01) + + +### Bug Fixes + +* **version:** Fix negated option links in readme ([0908212](https://github.com/lerna/lerna/commit/0908212)) + + + + + ## [3.10.6](https://github.com/lerna/lerna/compare/v3.10.5...v3.10.6) (2019-01-19) diff --git a/commands/version/README.md b/commands/version/README.md index 8dfa9b9ab2..c887b5521e 100644 --- a/commands/version/README.md +++ b/commands/version/README.md @@ -63,7 +63,7 @@ It is easiest (and recommended) to configure in `lerna.json`, but it is possible ```json { "command": { - "publish": { + "version": { "allowBranch": "master" } } @@ -76,7 +76,7 @@ It is considered a best-practice to limit `lerna version` to the primary branch ```json { "command": { - "publish": { + "version": { "allowBranch": ["master", "feature/*"] } } @@ -222,7 +222,7 @@ This can be configured in lerna.json, as well: ```json { "command": { - "publish": { + "version": { "message": "chore(release): publish %s" } } @@ -301,6 +301,29 @@ Pass an explicit version number to the [`bump`](#bump) positional instead. ### `--skip-git` -Use [`--no-git-tag-version`](https://github.com/lerna/lerna/tree/master/commands/version#--git-tag-version) and [`--no-push`](https://github.com/lerna/lerna/tree/master/commands/version#--push) instead. +Use [`--no-git-tag-version`](#--no-git-tag-version) and [`--no-push`](#--no-push) instead. > NOTE: This option **does not** restrict _all_ git commands from being executed. `git` is still required by `lerna version`. + +## Tips + +### Generating Initial Changelogs + +If you start using the [`--conventional-commits`](#--conventional-commits) option _after_ the monorepo has been active for awhile, you can still generate changelogs for previous releases using [`conventional-changelog-cli`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-cli#readme) and [`lerna exec`](https://github.com/lerna/lerna/tree/master/commands/exec#readme): + +```bash +# Lerna does not actually use conventional-changelog-cli, so you need to install it temporarily +npm i -D conventional-changelog-cli +# Documentation: `npx conventional-changelog --help` + +# fixed versioning (default) +# run in root, then leaves +npx conventional-changelog --preset angular --release-count 0 --outfile ./CHANGELOG.md --verbose +npx lerna exec --concurrency 1 --stream -- 'conventional-changelog --preset angular --release-count 0 --commit-path $PWD --pkg $PWD/package.json --outfile $PWD/CHANGELOG.md --verbose' + +# independent versioning +# (no root changelog) +npx lerna exec --concurrency 1 --stream -- 'conventional-changelog --preset angular --release-count 0 --commit-path $PWD --pkg $PWD/package.json --outfile $PWD/CHANGELOG.md --verbose --lerna-package $LERNA_PACKAGE_NAME' +``` + +If you use a custom [`--changelog-preset`](#--changelog-preset), you should change `--preset` value accordingly in the example above. diff --git a/commands/version/package.json b/commands/version/package.json index 292f154413..a7d7d319e0 100644 --- a/commands/version/package.json +++ b/commands/version/package.json @@ -1,6 +1,6 @@ { "name": "@lerna/version", - "version": "3.10.6", + "version": "3.10.8", "description": "Bump version of packages changed since the last release", "keywords": [ "lerna", diff --git a/core/conventional-commits/CHANGELOG.md b/core/conventional-commits/CHANGELOG.md index 65f9696ecf..fca0be086b 100644 --- a/core/conventional-commits/CHANGELOG.md +++ b/core/conventional-commits/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.10.8](https://github.com/lerna/lerna/compare/v3.10.7...v3.10.8) (2019-02-01) + + +### Bug Fixes + +* **conventional-commits:** Support legacy callback presets ([60647b4](https://github.com/lerna/lerna/commit/60647b4)), closes [#1896](https://github.com/lerna/lerna/issues/1896) + + + + + # [3.10.0](https://github.com/lerna/lerna/compare/v3.9.1...v3.10.0) (2019-01-08) **Note:** Version bump only for package @lerna/conventional-commits diff --git a/core/conventional-commits/__tests__/__fixtures__/fixed/scripts/legacy-callback-preset.js b/core/conventional-commits/__tests__/__fixtures__/fixed/scripts/legacy-callback-preset.js new file mode 100644 index 0000000000..b5854ac909 --- /dev/null +++ b/core/conventional-commits/__tests__/__fixtures__/fixed/scripts/legacy-callback-preset.js @@ -0,0 +1,17 @@ +"use strict"; + +// https://git.io/vx5iq (conventional-changelog-angular/conventional-recommended-bump.js, etc) +const parserOpts = require("./parser-opts"); +const writerOpts = require("./writer-opts"); +const whatBump = require("./what-bump"); + +// https://git.io/fhyKK +module.exports = presetOpts; + +function presetOpts(cb) { + process.nextTick(cb, null, { + parserOpts, + writerOpts, + whatBump, + }); +} diff --git a/core/conventional-commits/__tests__/conventional-commits.test.js b/core/conventional-commits/__tests__/conventional-commits.test.js index 497c705783..4ec70bbbfe 100644 --- a/core/conventional-commits/__tests__/conventional-commits.test.js +++ b/core/conventional-commits/__tests__/conventional-commits.test.js @@ -331,6 +331,28 @@ describe("conventional-commits", () => { expect(leafChangelogContent).toMatchSnapshot(); }); + it("supports legacy callback presets", async () => { + const cwd = await initFixture("fixed"); + + await gitTag(cwd, "v1.0.0"); + + const [, pkg2] = await getPackages(cwd); + + // make a change in package-2 + await pkg2.set("changed", 1).serialize(); + await gitAdd(cwd, pkg2.manifestLocation); + await gitCommit(cwd, "fix(pkg2): A commit using a legacy callback preset"); + + // update version + await pkg2.set("version", "1.0.1").serialize(); + + const leafChangelogContent = await updateChangelog(pkg2, "fixed", { + changelogPreset: "./scripts/legacy-callback-preset", + }).then(getFileContent); + + expect(leafChangelogContent).toContain("fix(pkg2): A commit using a legacy callback preset"); + }); + it("updates independent changelogs", async () => { const cwd = await initFixture("independent"); diff --git a/core/conventional-commits/lib/get-changelog-config.js b/core/conventional-commits/lib/get-changelog-config.js index 924d069038..f4d5f57b75 100644 --- a/core/conventional-commits/lib/get-changelog-config.js +++ b/core/conventional-commits/lib/get-changelog-config.js @@ -2,12 +2,29 @@ const log = require("libnpm/log"); const npa = require("libnpm/parse-arg"); +const pify = require("pify"); const ValidationError = require("@lerna/validation-error"); module.exports = getChangelogConfig; const cfgCache = new Map(); +function isFunction(config) { + return Object.prototype.toString.call(config) === "[object Function]"; +} + +function resolveConfigPromise(presetPackageName) { + // eslint-disable-next-line global-require, import/no-dynamic-require + let config = require(presetPackageName); + + // legacy presets export an errback function instead of Q.all() + if (isFunction(config)) { + config = pify(config)(); + } + + return config; +} + function getChangelogConfig(changelogPreset = "conventional-changelog-angular", rootPath) { let config = cfgCache.get(changelogPreset); @@ -33,8 +50,7 @@ function getChangelogConfig(changelogPreset = "conventional-changelog-angular", // Maybe it doesn't need an implicit 'conventional-changelog-' prefix? try { - // eslint-disable-next-line global-require, import/no-dynamic-require - config = require(presetPackageName); + config = resolveConfigPromise(presetPackageName); cfgCache.set(changelogPreset, config); @@ -62,8 +78,7 @@ function getChangelogConfig(changelogPreset = "conventional-changelog-angular", } try { - // eslint-disable-next-line global-require, import/no-dynamic-require - config = require(presetPackageName); + config = resolveConfigPromise(presetPackageName); cfgCache.set(changelogPreset, config); } catch (err) { diff --git a/core/conventional-commits/package.json b/core/conventional-commits/package.json index 06d7e2ff87..6ad1b0637c 100644 --- a/core/conventional-commits/package.json +++ b/core/conventional-commits/package.json @@ -1,6 +1,6 @@ { "name": "@lerna/conventional-commits", - "version": "3.10.0", + "version": "3.10.8", "description": "Lerna's internal interface to conventional-changelog and friends", "keywords": [ "lerna", @@ -38,6 +38,7 @@ "fs-extra": "^7.0.0", "get-stream": "^4.0.0", "libnpm": "^2.0.1", + "pify": "^3.0.0", "semver": "^5.5.0" } } diff --git a/core/lerna/CHANGELOG.md b/core/lerna/CHANGELOG.md index 629bcf8323..9d9bac8430 100644 --- a/core/lerna/CHANGELOG.md +++ b/core/lerna/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.10.8](https://github.com/lerna/lerna/compare/v3.10.7...v3.10.8) (2019-02-01) + +**Note:** Version bump only for package lerna + + + + + ## [3.10.7](https://github.com/lerna/lerna/compare/v3.10.6...v3.10.7) (2019-01-22) **Note:** Version bump only for package lerna diff --git a/core/lerna/package.json b/core/lerna/package.json index a73dc8d4ae..44a1aa66e6 100644 --- a/core/lerna/package.json +++ b/core/lerna/package.json @@ -1,6 +1,6 @@ { "name": "lerna", - "version": "3.10.7", + "version": "3.10.8", "description": "A tool for managing JavaScript projects with multiple packages.", "keywords": [ "lerna", diff --git a/lerna.json b/lerna.json index 839ec7eea4..384732ff8a 100644 --- a/lerna.json +++ b/lerna.json @@ -22,5 +22,5 @@ "**/__tests__/**", "**/*.md" ], - "version": "3.10.7" + "version": "3.10.8" } diff --git a/package-lock.json b/package-lock.json index 1b580d1026..4ecf66745b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -407,6 +407,7 @@ "fs-extra": "^7.0.0", "get-stream": "^4.0.0", "libnpm": "^2.0.1", + "pify": "^3.0.0", "semver": "^5.5.0" } },