Skip to content

Commit

Permalink
feat: remove getLastRelease hook
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The `getLastRelease` hook is removed

The plugin is compatible only with `semantic-release@13.0.0` and above.
  • Loading branch information
pvdlg committed Jan 27, 2018
1 parent 0f774fc commit 9383a98
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 724 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ Set of [semantic-release](https://github.com/semantic-release/semantic-release)

Verify the presence of the `NPM_TOKEN` environment variable, create or update the `.npmrc` file with the token and verify the token is valid.

## getLastRelease

Determine the last release of the package on the `npm` registry.

## publish

Update the `package.json` version, [create](https://docs.npmjs.com/cli/pack) the `npm` package tarball and [publish](https://docs.npmjs.com/cli/publish) to the `npm` registry.
Expand Down Expand Up @@ -73,7 +69,6 @@ Each individual plugin can be disabled, replaced or used with other plugins in t
{
"release": {
"verifyConditions": ["@semantic-release/npm", "verify-other-condition"],
"getLastRelease": "custom-get-last-release",
"publish": ["@semantic-release/npm", "custom-publish"]
}
}
Expand All @@ -85,7 +80,6 @@ The `npmPublish` and `tarballDir` option can be used to skip the publishing to t
{
"release": {
"verifyConditions": ["@semantic-release/npm", "@semantic-release/git", "@semantic-release/github"],
"getLastRelease": "@semantic-release/git",
"publish": [
{
"path": "@semantic-release/npm",
Expand All @@ -107,7 +101,6 @@ When publishing from a sub-directory with the `pkgRoot` option, the `package.jso
{
"release": {
"verifyConditions": ["@semantic-release/npm", "@semantic-release/git"],
"getLastRelease": "@semantic-release/npm",
"publish": [
{
"path": "@semantic-release/npm",
Expand Down
30 changes: 4 additions & 26 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ const getPkg = require('./lib/get-pkg');
const verifyNpmConfig = require('./lib/verify-config');
const verifyNpmAuth = require('./lib/verify-auth');
const publishNpm = require('./lib/publish');
const getLastReleaseNpm = require('./lib/get-last-release');

let verified;

async function verifyConditions(pluginConfig, {options: {publish, getLastRelease}, logger}) {
async function verifyConditions(pluginConfig, {options: {publish}, logger}) {
// If the npm publish plugin is used and has `npmPublish`, `tarballDir` or `pkgRoot` configured, validate them now in order to prevent any release if the configuration is wrong
if (publish) {
const publishPlugin = castArray(publish).find(config => config.path && config.path === '@semantic-release/npm');
Expand All @@ -26,35 +25,14 @@ async function verifyConditions(pluginConfig, {options: {publish, getLastRelease
const pkg = await getPkg(pluginConfig.pkgRoot);
await verifyNpmConfig(pluginConfig, pkg, logger);

// Verify the npm authentication only if `npmPublish` is not false and if the npm plugin is used as `getLastRelease`
if (
pluginConfig.npmPublish !== false ||
(getLastRelease && (getLastRelease === '@semantic-release/npm' || getLastRelease.path === '@semantic-release/npm'))
) {
// Verify the npm authentication only if `npmPublish` is not false
if (pluginConfig.npmPublish !== false) {
setLegacyToken();
await verifyNpmAuth(pluginConfig, pkg, logger);
}
verified = true;
}

async function getLastRelease(pluginConfig, {options: {publish, branch}, logger}) {
setLegacyToken();
// Reload package.json in case a previous external step updated it
const pkg = await getPkg(pluginConfig.pkgRoot);
if (!verified) {
if (publish) {
const publishPlugin = castArray(publish).find(config => config.path && config.path === '@semantic-release/npm');
if (publishPlugin && publishPlugin.pkgRoot) {
pluginConfig.pkgRoot = publishPlugin.pkgRoot;
}
}
await verifyNpmConfig(pluginConfig, pkg, logger);
await verifyNpmAuth(pluginConfig, pkg, logger);
verified = true;
}
return getLastReleaseNpm(pkg, branch, logger);
}

async function publish(pluginConfig, {nextRelease: {version}, logger}) {
setLegacyToken();
// Reload package.json in case a previous external step updated it
Expand All @@ -69,4 +47,4 @@ async function publish(pluginConfig, {nextRelease: {version}, logger}) {
await publishNpm(pluginConfig, pkg, version, logger);
}

module.exports = {verifyConditions, getLastRelease, publish};
module.exports = {verifyConditions, publish};
26 changes: 0 additions & 26 deletions lib/get-client-config.js

This file was deleted.

57 changes: 0 additions & 57 deletions lib/get-last-release.js

This file was deleted.

20 changes: 0 additions & 20 deletions lib/get-version-head.js

This file was deleted.

27 changes: 0 additions & 27 deletions lib/git.js

This file was deleted.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@
],
"dependencies": {
"@semantic-release/error": "^2.1.0",
"debug": "^3.1.0",
"execa": "^0.9.0",
"fs-extra": "^5.0.0",
"lodash": "^4.17.4",
"nerf-dart": "^1.0.0",
"normalize-url": "^2.0.1",
"npm-conf": "^1.1.3",
"npm-registry-client": "^8.5.0",
"read-pkg": "^3.0.0",
"registry-auth-token": "^3.3.1"
},
Expand Down
Loading

0 comments on commit 9383a98

Please sign in to comment.