|
| 1 | +const url = require('url'); |
| 2 | +const {inspect} = require('util'); |
| 3 | +const {isString} = require('lodash'); |
| 4 | +const pkg = require('../../package.json'); |
| 5 | + |
| 6 | +const homepage = url.format({...url.parse(pkg.homepage), ...{hash: null}}); |
| 7 | +const stringify = obj => (isString(obj) ? obj : inspect(obj, {breakLength: Infinity, depth: 2, maxArrayLength: 5})); |
| 8 | +const linkify = file => `${homepage}/blob/master/${file}`; |
| 9 | + |
| 10 | +module.exports = { |
| 11 | + EINVALIDASSETS: ({assets}) => ({ |
| 12 | + message: 'Invalid `assets` option.', |
| 13 | + details: `The [assets option](${linkify( |
| 14 | + 'README.md#assets' |
| 15 | + )}) option must be an \`Array\` of \`Strings\` or \`Objects\` with a \`path\` property. |
| 16 | +
|
| 17 | +Your configuration for the \`assets\` option is \`${stringify(assets)}\`.`, |
| 18 | + }), |
| 19 | + EINVALIDSUCCESSCOMMENT: ({successComment}) => ({ |
| 20 | + message: 'Invalid `successComment` option.', |
| 21 | + details: `The [successComment option](${linkify( |
| 22 | + 'README.md#successcomment' |
| 23 | + )}) option, if defined, must be a non empty \`String\`. |
| 24 | +
|
| 25 | +Your configuration for the \`successComment\` option is \`${stringify(successComment)}\`.`, |
| 26 | + }), |
| 27 | + EINVALIDGITHUBURL: () => ({ |
| 28 | + message: 'The git repository URL is not a valid GitHub URL.', |
| 29 | + details: `The **semantic-release** \`repositoryUrl\` option must a valid GitHub URL with the format \`<GitHub_or_GHE_URL>/<owner>/<repo>.git\`. |
| 30 | +
|
| 31 | +By default the \`repositoryUrl\` option is retrieved from the \`repository\` property of your \`package.json\` or the [git origin url](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes) of the repository cloned by your CI environment.`, |
| 32 | + }), |
| 33 | + EMISSINGREPO: ({owner, repo}) => ({ |
| 34 | + message: `The repository ${owner}/${repo} doesn't exist.`, |
| 35 | + details: `The **semantic-release** \`repositoryUrl\` option must refer to your GitHub repository. The repository must be accessible with the [GitHub API](https://developer.github.com/v3). |
| 36 | +
|
| 37 | +By default the \`repositoryUrl\` option is retrieved from the \`repository\` property of your \`package.json\` or the [git origin url](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes) of the repository cloned by your CI environment. |
| 38 | +
|
| 39 | +If you are using [GitHub Enterprise](https://enterprise.github.com) please make sure to configure the \`githubUrl\` and \`githubApiPathPrefix\` [options](${linkify( |
| 40 | + 'README.md#options' |
| 41 | + )}).`, |
| 42 | + }), |
| 43 | + EGHNOPERMISSION: ({owner, repo}) => ({ |
| 44 | + message: `The GitHub token doesn't allow to push on the repository ${owner}/${repo}.`, |
| 45 | + details: `The user associated with the [GitHub token](${linkify( |
| 46 | + 'README.md#github-authentication' |
| 47 | + )}) configured in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable must allows to push to the repository ${owner}/${repo}. |
| 48 | +
|
| 49 | +Please make sure the GitHub user associated with the token is an [owner](https://help.github.com/articles/permission-levels-for-a-user-account-repository/#owner-access-on-a-repository-owned-by-a-user-account) or a [collaborator](https://help.github.com/articles/permission-levels-for-a-user-account-repository/#collaborator-access-on-a-repository-owned-by-a-user-account) if the reposotory belong to a user account or has [write permissions](https://help.github.com/articles/managing-team-access-to-an-organization-repository) if the repository [belongs to an organization](https://help.github.com/articles/repository-permission-levels-for-an-organization).`, |
| 50 | + }), |
| 51 | + EINVALIDGHTOKEN: ({owner, repo}) => ({ |
| 52 | + message: 'Invalid GitHub token.', |
| 53 | + details: `The [GitHub token](${linkify( |
| 54 | + 'README.md#github-authentication' |
| 55 | + )}) configured in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable must be a valid [personnal token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) allowing to push to the repository ${owner}/${repo}. |
| 56 | +
|
| 57 | +Please make sure to set the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable in your CI with the exact value of the GitHub personnal token.`, |
| 58 | + }), |
| 59 | + ENOGHTOKEN: ({owner, repo}) => ({ |
| 60 | + message: 'No GitHub token specified.', |
| 61 | + details: `A [GitHub personnal token](${linkify( |
| 62 | + 'README.md#github-authentication' |
| 63 | + )}) must be created and set in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable on your CI environment. |
| 64 | +
|
| 65 | +Please make sure to create a [GitHub personnal token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) and to set it in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable on your CI environment. The token must allow to push to the repository ${owner}/${repo}.`, |
| 66 | + }), |
| 67 | +}; |
0 commit comments