-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(esm): converted the package to esm
BREAKING CHANGE: `@semantic-release/npm` is now a native ES Module. It has named exports for each plugin hook (`verifyConditions`, `prepare`, `publish`, `addChannel`)
- Loading branch information
Showing
25 changed files
with
2,363 additions
and
4,443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
const semver = require('semver'); | ||
import semver from 'semver'; | ||
|
||
module.exports = (channel) => (channel ? (semver.validRange(channel) ? `release-${channel}` : channel) : 'latest'); | ||
export default function (channel) { | ||
return channel ? (semver.validRange(channel) ? `release-${channel}` : channel) : 'latest'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
const SemanticReleaseError = require('@semantic-release/error'); | ||
const ERROR_DEFINITIONS = require('./definitions/errors'); | ||
import SemanticReleaseError from '@semantic-release/error'; | ||
import * as ERROR_DEFINITIONS from './definitions/errors.js'; | ||
|
||
module.exports = (code, ctx = {}) => { | ||
export default function (code, ctx = {}) { | ||
const {message, details} = ERROR_DEFINITIONS[code](ctx); | ||
|
||
return new SemanticReleaseError(message, code, details); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
const path = require('path'); | ||
const rc = require('rc'); | ||
const getRegistryUrl = require('registry-auth-token/registry-url'); | ||
import path from 'path'; | ||
import rc from 'rc'; | ||
import getRegistryUrl from 'registry-auth-token/registry-url.js'; | ||
|
||
module.exports = ({publishConfig: {registry} = {}, name}, {cwd, env}) => | ||
registry || | ||
env.NPM_CONFIG_REGISTRY || | ||
getRegistryUrl( | ||
name.split('/')[0], | ||
rc( | ||
'npm', | ||
{registry: 'https://registry.npmjs.org/'}, | ||
{config: env.NPM_CONFIG_USERCONFIG || path.resolve(cwd, '.npmrc')} | ||
) | ||
); | ||
export default function ({ publishConfig: { registry } = {}, name }, { cwd, env }) { | ||
return registry || | ||
env.NPM_CONFIG_REGISTRY || | ||
getRegistryUrl( | ||
name.split('/')[0], | ||
rc( | ||
'npm', | ||
{ registry: 'https://registry.npmjs.org/' }, | ||
{ config: env.NPM_CONFIG_USERCONFIG || path.resolve(cwd, '.npmrc') } | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
const normalizeUrl = require('normalize-url'); | ||
import normalizeUrl from 'normalize-url'; | ||
|
||
module.exports = ( | ||
export default function ( | ||
{name}, | ||
{env: {DEFAULT_NPM_REGISTRY = 'https://registry.npmjs.org/'}, nextRelease: {version}}, | ||
distTag, | ||
registry | ||
) => ({ | ||
name: `npm package (@${distTag} dist-tag)`, | ||
url: | ||
) { | ||
return { | ||
name: `npm package (@${distTag} dist-tag)`, | ||
url: | ||
normalizeUrl(registry) === normalizeUrl(DEFAULT_NPM_REGISTRY) | ||
? `https://www.npmjs.com/package/${name}/v/${version}` | ||
: undefined, | ||
channel: distTag, | ||
}); | ||
channel: distTag, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = ({env}) => { | ||
export default function ({env}) { | ||
// Set the environment variable `LEGACY_TOKEN` when user use the legacy auth, so it can be resolved by npm CLI | ||
if (env.NPM_USERNAME && env.NPM_PASSWORD && env.NPM_EMAIL) { | ||
env.LEGACY_TOKEN = Buffer.from(`${env.NPM_USERNAME}:${env.NPM_PASSWORD}`, 'utf8').toString('base64'); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.