semantic-release-gh
Version:
The official GitHub plugin, modified to accept repositoryUrl as a parameter
148 lines (133 loc) • 8.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ERROR_DEFINITIONS = exports.ENOGHTOKEN = exports.EMISSINGREPO = exports.EINVALIDSUCCESSCOMMENT = exports.EINVALIDRELEASEDLABELS = exports.EINVALIDPROXY = exports.EINVALIDLABELS = exports.EINVALIDGITHUBURL = exports.EINVALIDGHTOKEN = exports.EINVALIDFAILTITLE = exports.EINVALIDFAILCOMMENT = exports.EINVALIDASSIGNEES = exports.EINVALIDASSETS = exports.EINVALIDADDRELEASES = exports.EGHNOPERMISSION = void 0;
const lodash_1 = require("lodash");
const node_util_1 = require("node:util");
const packageJson = require('../../package.json');
const [homepage] = packageJson.homepage.split('#');
const stringify = (object) => (0, lodash_1.isString)(object) ? object : (0, node_util_1.inspect)(object, { breakLength: Number.POSITIVE_INFINITY, depth: 2, maxArrayLength: 5 });
const linkify = (file) => `${homepage}/blob/master/${file}`;
const GITHUB_AUTH = linkify('README.md#github-authentication');
const README_OPTIONS = linkify('README.md#options');
const EGHNOPERMISSION = (owner, repo) => ({
details: `The user associated with the [GitHub token](${GITHUB_AUTH}) configured in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` \
environment variable must allows to push to the repository ${owner}/${repo}.
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).`,
message: `The GitHub token doesn't allow to push on the repository ${owner}/${repo}.`
});
exports.EGHNOPERMISSION = EGHNOPERMISSION;
const EINVALIDADDRELEASES = (addReleases) => ({
details: `The [addReleases option](${README_OPTIONS}) if defined, must be one of \`false|top|bottom\`.
Your configuration for the \`addReleases\` option is \`${stringify(addReleases)}\`.`,
message: 'Invalid `addReleases` option.'
});
exports.EINVALIDADDRELEASES = EINVALIDADDRELEASES;
const EINVALIDASSETS = (assets) => ({
details: `The [assets option](${linkify('README.md#assets')}) must be an \`Array\` of \`Strings\` or \`Objects\` with a \`path\` property.
Your configuration for the \`assets\` option is \`${stringify(assets)}\`.`,
message: 'Invalid `assets` option.'
});
exports.EINVALIDASSETS = EINVALIDASSETS;
const EINVALIDASSIGNEES = (assignees) => ({
details: `The [assignees option](${README_OPTIONS}) must be an \`Array\` of non empty \`Strings\`.
Your configuration for the \`assignees\` option is \`${stringify(assignees)}\`.`,
message: 'Invalid `assignees` option.'
});
exports.EINVALIDASSIGNEES = EINVALIDASSIGNEES;
const EINVALIDFAILCOMMENT = (failComment) => ({
details: `The [failComment option](${linkify('README.md#failcomment')}) if defined, must be a non empty \`String\`.
Your configuration for the \`failComment\` option is \`${stringify(failComment)}\`.`,
message: 'Invalid `failComment` option.'
});
exports.EINVALIDFAILCOMMENT = EINVALIDFAILCOMMENT;
const EINVALIDFAILTITLE = (failTitle) => ({
details: `The [failTitle option](${linkify('README.md#failtitle')}) if defined, must be a non empty \`String\`.
Your configuration for the \`failTitle\` option is \`${stringify(failTitle)}\`.`,
message: 'Invalid `failTitle` option.'
});
exports.EINVALIDFAILTITLE = EINVALIDFAILTITLE;
const EINVALIDGHTOKEN = (owner, repo) => ({
details: `The [GitHub token](${GITHUB_AUTH}) configured in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` \
environment variable must be a valid \
[personal token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) \
allowing to push to the repository ${owner}/${repo}.
Please make sure to set the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable in your CI with the \
exact value of the GitHub personal token.`,
message: 'Invalid GitHub token.'
});
exports.EINVALIDGHTOKEN = EINVALIDGHTOKEN;
const EINVALIDGITHUBURL = () => ({
details: `The **semantic-release** \`repositoryUrl\` option must a valid GitHub URL with the \
format \`<GitHub_or_GHE_URL>/<owner>/<repo>.git\`.
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.`,
message: 'The git repository URL is not a valid GitHub URL.'
});
exports.EINVALIDGITHUBURL = EINVALIDGITHUBURL;
const EINVALIDLABELS = (labels) => ({
details: `The [labels option](${README_OPTIONS}) if defined, must be an \`Array\` of non empty \`String\`.
Your configuration for the \`labels\` option is \`${stringify(labels)}\`.`,
message: 'Invalid `labels` option.'
});
exports.EINVALIDLABELS = EINVALIDLABELS;
const EINVALIDPROXY = (proxy) => ({
details: `The [proxy option](${linkify('README.md#proxy')}) must be a \`String\` or an \`Objects\` with a \`host\` and a \`port\` property.
Your configuration for the \`proxy\` option is \`${stringify(proxy)}\`.`,
message: 'Invalid `proxy` option.'
});
exports.EINVALIDPROXY = EINVALIDPROXY;
const EINVALIDRELEASEDLABELS = (releasedLabels) => ({
details: `The [releasedLabels option](${README_OPTIONS}) if defined, must be an \`Array\` of non empty \`String\`.
Your configuration for the \`releasedLabels\` option is \`${stringify(releasedLabels)}\`.`,
message: 'Invalid `releasedLabels` option.'
});
exports.EINVALIDRELEASEDLABELS = EINVALIDRELEASEDLABELS;
const EINVALIDSUCCESSCOMMENT = (successComment) => ({
details: `The [successComment option](${linkify('README.md#successcomment')}) if defined, must be a non empty \`String\`.
Your configuration for the \`successComment\` option is \`${stringify(successComment)}\`.`,
message: 'Invalid `successComment` option.'
});
exports.EINVALIDSUCCESSCOMMENT = EINVALIDSUCCESSCOMMENT;
const EMISSINGREPO = (owner, repo) => ({
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).
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.
If you are using [GitHub Enterprise](https://enterprise.github.com) please make sure to configure the \`githubUrl\` \
and \`githubApiPathPrefix\` [options](${README_OPTIONS}).`,
message: `The repository ${owner}/${repo} doesn't exist.`
});
exports.EMISSINGREPO = EMISSINGREPO;
const ENOGHTOKEN = (owner, repo) => ({
details: `A [GitHub personal token](${GITHUB_AUTH}) must be created and set in the \`GH_TOKEN\` \
or \`GITHUB_TOKEN\` environment variable on your CI environment.
Please make sure to create a \
[GitHub personal 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}.`,
message: 'No GitHub token specified.'
});
exports.ENOGHTOKEN = ENOGHTOKEN;
exports.ERROR_DEFINITIONS = {
EGHNOPERMISSION: exports.EGHNOPERMISSION,
EINVALIDADDRELEASES: exports.EINVALIDADDRELEASES,
EINVALIDASSETS: exports.EINVALIDASSETS,
EINVALIDASSIGNEES: exports.EINVALIDASSIGNEES,
EINVALIDFAILCOMMENT: exports.EINVALIDFAILCOMMENT,
EINVALIDFAILTITLE: exports.EINVALIDFAILTITLE,
EINVALIDGHTOKEN: exports.EINVALIDGHTOKEN,
EINVALIDGITHUBURL: exports.EINVALIDGITHUBURL,
EINVALIDLABELS: exports.EINVALIDLABELS,
EINVALIDPROXY: exports.EINVALIDPROXY,
EINVALIDRELEASEDLABELS: exports.EINVALIDRELEASEDLABELS,
EINVALIDSUCCESSCOMMENT: exports.EINVALIDSUCCESSCOMMENT,
EMISSINGREPO: exports.EMISSINGREPO,
ENOGHTOKEN: exports.ENOGHTOKEN
};
//# sourceMappingURL=errors.js.map