node-publisher
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -0,1 +1,6 @@ | ||
### v1.1.1 (2018-12-11) | ||
- [#24](https://github.com/zendesk/node-publisher/pull/24) Add details to package.json + minor adjustments ([Attila Večerek](mailto:avecerek@zendesk.com)) | ||
- [#23](https://github.com/zendesk/node-publisher/pull/23) Fix small typo in readme ([Marc Høegh](mailto:Anifacted@users.noreply.github.com)) | ||
### v1.1.0 (2018-12-03) | ||
@@ -2,0 +7,0 @@ |
@@ -13,3 +13,3 @@ { | ||
}, | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"main": "src/index.js", | ||
@@ -16,0 +16,0 @@ "bin": { |
@@ -46,10 +46,16 @@ <p align="center"> | ||
```sh | ||
npm run release -- <version> | ||
``` | ||
npm run release -- (major | minor | patch) | ||
``` | ||
or | ||
```sh | ||
yarn release <version> | ||
``` | ||
yarn release (major | minor | patch) | ||
Since `v1.2.0`, node-publisher supports the version options supported by the detected npm client. In earlier versions, only `major`, `minor` and `patch` options were accepted. When using `yarn`, the pre-release identifier (`--preid`) is ignored. | ||
```sh | ||
npm run release -- <version> --preid alpha | ||
``` | ||
@@ -59,3 +65,3 @@ | ||
``` | ||
```sh | ||
npx node-publisher eject | ||
@@ -140,3 +146,3 @@ ``` | ||
## Install packages | ||
``` | ||
```sh | ||
yarn | ||
@@ -146,5 +152,5 @@ ``` | ||
## Release a new version | ||
```sh | ||
yarn release <version> | ||
``` | ||
yarn release (major|minor|patch) | ||
``` | ||
@@ -151,0 +157,0 @@ # Contributing |
@@ -1,3 +0,7 @@ | ||
const publish = (nextVersion, { execCommand }) => { | ||
execCommand(`lerna publish ${nextVersion}`); | ||
const publish = ({ nextVersion, execCommand, preid }) => { | ||
const publishCommand = preid | ||
? `lerna publish ${nextVersion} --preid ${preid}` | ||
: `lerna publish ${nextVersion}`; | ||
execCommand(publishCommand); | ||
}; | ||
@@ -4,0 +8,0 @@ |
const { publish } = require('./lerna'); | ||
describe('publish', () => { | ||
const options = { | ||
execCommand: jest.fn() | ||
}; | ||
describe('without preid', () => { | ||
const options = { | ||
nextVersion: 'patch', | ||
preid: undefined, | ||
execCommand: jest.fn() | ||
}; | ||
it('publishes new version', () => { | ||
expect(() => publish('patch', options)).not.toThrow(); | ||
expect(options.execCommand.mock.calls[0][0]).toBe('lerna publish patch'); | ||
it('publishes new version without a prerelease tag', () => { | ||
expect(() => publish(options)).not.toThrow(); | ||
expect(options.execCommand.mock.calls[0][0]).toBe('lerna publish patch'); | ||
}); | ||
}); | ||
describe('with preid', () => { | ||
const options = { | ||
nextVersion: 'major', | ||
preid: 'alpha', | ||
execCommand: jest.fn() | ||
}; | ||
it('publishes new version with a prerelease tag', () => { | ||
expect(() => publish(options)).not.toThrow(); | ||
expect(options.execCommand.mock.calls[0][0]).toBe( | ||
'lerna publish major --preid alpha' | ||
); | ||
}); | ||
}); | ||
}); |
@@ -1,3 +0,7 @@ | ||
const publish = (nextVersion, { execCommand }) => { | ||
execCommand(`npm version ${nextVersion}`); | ||
const publish = ({ nextVersion, execCommand, preid }) => { | ||
const versionCommand = preid | ||
? `npm version ${nextVersion} --preid=${preid}` | ||
: `npm version ${nextVersion}`; | ||
execCommand(versionCommand); | ||
execCommand('npm publish'); | ||
@@ -4,0 +8,0 @@ }; |
const { publish } = require('./npm'); | ||
describe('publish', () => { | ||
const options = { | ||
execCommand: jest.fn() | ||
}; | ||
describe('without preid', () => { | ||
const options = { | ||
nextVersion: 'patch', | ||
preid: undefined, | ||
execCommand: jest.fn() | ||
}; | ||
it('publishes new version', () => { | ||
expect(() => publish('patch', options)).not.toThrow(); | ||
expect(options.execCommand.mock.calls[0][0]).toBe('npm version patch'); | ||
expect(options.execCommand.mock.calls[1][0]).toBe('npm publish'); | ||
it('publishes new version without a prerelease tag', () => { | ||
expect(() => publish(options)).not.toThrow(); | ||
expect(options.execCommand.mock.calls[0][0]).toBe('npm version patch'); | ||
expect(options.execCommand.mock.calls[1][0]).toBe('npm publish'); | ||
}); | ||
}); | ||
describe('with preid', () => { | ||
const options = { | ||
nextVersion: 'major', | ||
preid: 'alpha', | ||
execCommand: jest.fn() | ||
}; | ||
it('publishes new version with a prerelease tag', () => { | ||
expect(() => publish(options)).not.toThrow(); | ||
expect(options.execCommand.mock.calls[0][0]).toBe( | ||
'npm version major --preid=alpha' | ||
); | ||
expect(options.execCommand.mock.calls[1][0]).toBe('npm publish'); | ||
}); | ||
}); | ||
}); |
@@ -1,2 +0,2 @@ | ||
const publish = (nextVersion, { execCommand }) => { | ||
const publish = ({ nextVersion, execCommand }) => { | ||
execCommand(`yarn publish --new-version ${nextVersion}`); | ||
@@ -3,0 +3,0 @@ }; |
const { publish } = require('./yarn'); | ||
describe('publish', () => { | ||
const options = { | ||
execCommand: jest.fn() | ||
}; | ||
describe('without preid', () => { | ||
const options = { | ||
nextVersion: 'patch', | ||
preid: undefined, | ||
execCommand: jest.fn() | ||
}; | ||
it('publishes new version', () => { | ||
expect(() => publish('patch', options)).not.toThrow(); | ||
expect(options.execCommand.mock.calls[0][0]).toBe( | ||
'yarn publish --new-version patch' | ||
); | ||
it('publishes new version without a prerelease id', () => { | ||
expect(() => publish(options)).not.toThrow(); | ||
expect(options.execCommand.mock.calls[0][0]).toBe( | ||
'yarn publish --new-version patch' | ||
); | ||
}); | ||
}); | ||
describe('with preid', () => { | ||
const options = { | ||
nextVersion: 'major', | ||
preid: 'alpha', | ||
execCommand: jest.fn() | ||
}; | ||
it('publishes new version without a prerelease id', () => { | ||
expect(() => publish(options)).not.toThrow(); | ||
expect(options.execCommand.mock.calls[0][0]).toBe( | ||
'yarn publish --new-version major' | ||
); | ||
}); | ||
}); | ||
}); |
const { | ||
loadReleaseConfig, | ||
execCommands, | ||
validVersion, | ||
currentCommitId, | ||
@@ -10,3 +9,4 @@ rollbackCommit | ||
const release = ({ env, nextVersion }) => { | ||
const release = (options) => { | ||
const { env } = options; | ||
const config = loadReleaseConfig(env); | ||
@@ -26,6 +26,5 @@ const publishClient = require(`./client/${env.publishClient}.js`); | ||
} else { | ||
publishClient.publish(nextVersion, { | ||
validVersion, | ||
execCommand: command.exec | ||
}); | ||
publishClient.publish(Object.assign( | ||
{}, options, { execCommand: command.exec } | ||
)); | ||
} | ||
@@ -32,0 +31,0 @@ |
@@ -22,11 +22,2 @@ const fs = require('fs'); | ||
const validateVersion = (version, env) => { | ||
if (env.publishClient === 'lerna') return; | ||
if (VERSIONS.includes(version)) return; | ||
throw new Error( | ||
'Version argument is not supported, use either `major`, `minor` or `patch`' | ||
); | ||
}; | ||
const validateLerna = () => { | ||
@@ -45,5 +36,4 @@ if (fs.existsSync(LERNA_JSON_PATH)) return; | ||
validateTestRunner, | ||
validateVersion, | ||
validateLerna, | ||
isBuildDefined | ||
}; |
const { | ||
validatePkgRoot, | ||
validateTestRunner, | ||
validateVersion, | ||
validateLerna, | ||
@@ -57,33 +56,2 @@ isBuildDefined | ||
describe('validateVersion', () => { | ||
describe('when lerna is the detected publish client', () => { | ||
const env = { publishClient: 'lerna' }; | ||
const version = null; | ||
it('does not throw an error', () => { | ||
expect(() => validateVersion(version, env)).not.toThrow(); | ||
}); | ||
}); | ||
describe('when lerna is not the detected publish client', () => { | ||
const env = { publishClient: 'yarn' }; | ||
describe('and version is valid', () => { | ||
const version = 'patch'; | ||
it('does not throw an error', () => { | ||
expect(() => validateVersion(version, env)).not.toThrow(); | ||
}); | ||
}); | ||
describe('and version is not valid', () => { | ||
const version = 'prepatch'; | ||
it('throws an error', () => { | ||
expect(() => validateVersion(version, env)).toThrow(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('validateLerna', () => { | ||
@@ -90,0 +58,0 @@ describe('when lerna was bootstrapped', () => { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171372
746
176