Skip to content

Commit

Permalink
fix: fix typos and capitalization
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdlg committed Jan 2, 2018
1 parent 81506f8 commit d5aa119
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 41 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# @semantic-release/github

Set of [semantic-release](https://github.com/semantic-release/semantic-release) plugins for publishing a
[Github release](https://help.github.com/articles/about-releases).
Set of [Semantic-release](https://github.com/semantic-release/semantic-release) plugins for publishing a
[GitHub release](https://help.github.com/articles/about-releases).

[![Travis](https://img.shields.io/travis/semantic-release/github.svg)](https://travis-ci.org/semantic-release/github)
[![Codecov](https://img.shields.io/codecov/c/github/semantic-release/github.svg)](https://codecov.io/gh/semantic-release/github)
Expand All @@ -14,17 +14,16 @@ the [assets](#assets) option configuration.

## publish

Publish a [Github release](https://help.github.com/articles/about-releases), optionally uploading files.
Publish a [GitHub release](https://help.github.com/articles/about-releases), optionally uploading files.

## Configuration

### Github Repository authentication
### GitHub authentication

The `Github` authentication configuration is **required** and can be set via
The GitHub authentication configuration is **required** and can be set via
[environment variables](#environment-variables).

Only the [personal token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line)
authentication is supported.
Follow the [Creating a personal access token for the command line](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) documentation to obtain an authentication token. The token has to be made available in your CI environment via the `GH_TOKEN` environment variable.

### Environment variables

Expand All @@ -50,16 +49,16 @@ Can be a [glob](https://github.com/isaacs/node-glob#glob-primer) or and `Array`
| Property | Description | Default |
| -------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| `path` | **Required.** A [glob](https://github.com/isaacs/node-glob#glob-primer) to identify the files to upload. | - |
| `name` | The name of the downloadable file on the Github release. | File name extracted from the `path`. |
| `label` | Short description of the file displayed on the Github release. | - |
| `name` | The name of the downloadable file on the GitHub release. | File name extracted from the `path`. |
| `label` | Short description of the file displayed on the GitHub release. | - |

Each entry in the `assets` `Array` is globbed individually. A [glob](https://github.com/isaacs/node-glob#glob-primer)
can be a `String` (`"dist/**/*.js"` or `"dist/mylib.js"`) or an `Array` of `String`s that will be globbed together
(`["dist/**", "!**/*.css"]`).

If a directory is configured, all the files under this directory and its children will be included.

Files can be included enven if they have a match in `.gitignore`.
Files can be included even if they have a match in `.gitignore`.

##### `assets` examples

Expand All @@ -70,15 +69,15 @@ files.

`[{path: 'dist/MyLibrary.js', label: 'MyLibrary JS distribution'}, {path: 'dist/MyLibrary.css', label: 'MyLibrary CSS
distribution'}]`: include the `dist/MyLibrary.js` and `dist/MyLibrary.css` files, and label them `MyLibrary JS
distribution` and `MyLibrary CSS distribution` in the Github release.
distribution` and `MyLibrary CSS distribution` in the GitHub release.

`[['dist/**/*.{js,css}', '!**/*.min.*'], {path: 'build/MyLibrary.zip', label: 'MyLibrary'}]`: include all the `js` and
`css` files in the `dist` directory and its sub-directories excluding the minified version, plus the
`build/MyLibrary.zip` file and label it `MyLibrary` in the Github release.
`build/MyLibrary.zip` file and label it `MyLibrary` in the GitHub release.

### Usage

The plugins are used by default by [semantic-release](https://github.com/semantic-release/semantic-release) so no
The plugins are used by default by [Semantic-release](https://github.com/semantic-release/semantic-release) so no
specific configuration is required if `githubUrl` and `githubApiPathPrefix` are set via environment variable.

Each individual plugin can be disabled, replaced or used with other plugins in the `package.json`:
Expand All @@ -93,7 +92,7 @@ Each individual plugin can be disabled, replaced or used with other plugins in t
}
```

Options can be set within the plugin definition in the `semantic-release` configuration file:
Options can be set within the plugin definition in the Semantic-release configuration file:

```json
{
Expand Down
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const verifyGithub = require('./lib/verify');
const publishGithub = require('./lib/publish');
const verifyGitHub = require('./lib/verify');
const publishGitHub = require('./lib/publish');

let verified;

async function verifyConditions(pluginConfig, {options, logger}) {
// If the Github publish plugin is used and has `assets` configured, validate it now in order to prevent any release if the configuration is wrong
// If the GitHub publish plugin is used and has `assets` configured, validate it now in order to prevent any release if the configuration is wrong
if (options.publish) {
const publishPlugin = (Array.isArray(options.publish) ? options.publish : [options.publish]).find(
config => config.path && config.path === '@semantic-release/github'
Expand All @@ -14,16 +14,16 @@ async function verifyConditions(pluginConfig, {options, logger}) {
}
}

await verifyGithub(pluginConfig, options, logger);
await verifyGitHub(pluginConfig, options, logger);
verified = true;
}

async function publish(pluginConfig, {nextRelease, options, logger}) {
if (!verified) {
await verifyGithub(pluginConfig, options, logger);
await verifyGitHub(pluginConfig, options, logger);
verified = true;
}
await publishGithub(pluginConfig, options, nextRelease, logger);
await publishGitHub(pluginConfig, options, nextRelease, logger);
}

module.exports = {verifyConditions, publish};
2 changes: 1 addition & 1 deletion lib/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = async (pluginConfig, {branch, repositoryUrl}, {version, gitHead
}

const {data: {html_url: htmlUrl, upload_url: uploadUrl}} = await github.repos.createRelease(release);
logger.log('Published Github release: %s', htmlUrl);
logger.log('Published GitHub release: %s', htmlUrl);

if (assets && assets.length > 0) {
const globbedAssets = await globAssets(assets);
Expand Down
8 changes: 4 additions & 4 deletions lib/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ module.exports = async (pluginConfig, {repositoryUrl}, logger) => {
const {name: repo, owner} = parseGithubUrl(repositoryUrl);
if (!owner || !repo) {
throw new SemanticReleaseError(
`The git repository URL ${repositoryUrl} is not a valid Github URL.`,
`The git repository URL ${repositoryUrl} is not a valid GitHub URL.`,
'EINVALIDGITURL'
);
}

if (githubUrl) {
logger.log('Verify Github authentication (%s)', urlJoin(githubUrl, githubApiPathPrefix));
logger.log('Verify GitHub authentication (%s)', urlJoin(githubUrl, githubApiPathPrefix));
} else {
logger.log('Verify Github authentication');
logger.log('Verify GitHub authentication');
}

const github = getClient(githubToken, githubUrl, githubApiPathPrefix);
Expand All @@ -47,7 +47,7 @@ module.exports = async (pluginConfig, {repositoryUrl}, logger) => {
({data: {permissions: {push}}} = await github.repos.get({repo, owner}));
} catch (err) {
if (err.code === 401) {
throw new SemanticReleaseError('Invalid Github token.', 'EINVALIDGHTOKEN');
throw new SemanticReleaseError('Invalid GitHub token.', 'EINVALIDGHTOKEN');
} else if (err.code === 404) {
throw new SemanticReleaseError(`The repository ${owner}/${repo} doesn't exist.`, 'EMISSINGREPO');
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@semantic-release/github",
"description": "Set of semantic-release plugins for publishing a Github release",
"description": "Set of semantic-release plugins for publishing a GitHub release",
"version": "0.0.0-development",
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
"bugs": {
Expand Down
16 changes: 8 additions & 8 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ test.afterEach.always(() => {
nock.cleanAll();
});

test.serial('Verify Github auth', async t => {
test.serial('Verify GitHub auth', async t => {
process.env.GITHUB_TOKEN = 'github_token';
const owner = 'test_user';
const repo = 'test_repo';
Expand All @@ -50,7 +50,7 @@ test.serial('Verify Github auth', async t => {
t.true(github.isDone());
});

test.serial('Verify Github auth with publish options', async t => {
test.serial('Verify GitHub auth with publish options', async t => {
process.env.GITHUB_TOKEN = 'github_token';
const owner = 'test_user';
const repo = 'test_repo';
Expand All @@ -67,7 +67,7 @@ test.serial('Verify Github auth with publish options', async t => {
t.true(github.isDone());
});

test.serial('Verify Github auth and assets config', async t => {
test.serial('Verify GitHub auth and assets config', async t => {
process.env.GH_TOKEN = 'github_token';
const owner = 'test_user';
const repo = 'test_repo';
Expand Down Expand Up @@ -153,16 +153,16 @@ test.serial('Publish a release with an array of assets', async t => {

await t.context.m.publish({assets}, {nextRelease, options, logger: t.context.logger});

t.deepEqual(t.context.log.args[0], ['Verify Github authentication']);
t.deepEqual(t.context.log.args[1], ['Published Github release: %s', releaseUrl]);
t.deepEqual(t.context.log.args[0], ['Verify GitHub authentication']);
t.deepEqual(t.context.log.args[1], ['Published GitHub release: %s', releaseUrl]);
t.deepEqual(t.context.log.args[2], ['Published file %s', assetUrl]);
t.deepEqual(t.context.log.args[3], ['Published file %s', otherAssetUrl]);
t.true(github.isDone());
t.true(githubUpload1.isDone());
t.true(githubUpload2.isDone());
});

test.serial('Verify Github auth and release', async t => {
test.serial('Verify GitHub auth and release', async t => {
process.env.GH_TOKEN = 'github_token';
const owner = 'test_user';
const repo = 'test_repo';
Expand Down Expand Up @@ -212,8 +212,8 @@ test.serial('Verify Github auth and release', async t => {
await t.notThrows(t.context.m.verifyConditions({}, {options, logger: t.context.logger}));
await t.context.m.publish({assets}, {nextRelease, options, logger: t.context.logger});

t.deepEqual(t.context.log.args[0], ['Verify Github authentication']);
t.deepEqual(t.context.log.args[1], ['Published Github release: %s', releaseUrl]);
t.deepEqual(t.context.log.args[0], ['Verify GitHub authentication']);
t.deepEqual(t.context.log.args[1], ['Published GitHub release: %s', releaseUrl]);
t.deepEqual(t.context.log.args[2], ['Published file %s', otherAssetUrl]);
t.deepEqual(t.context.log.args[3], ['Published file %s', assetUrl]);
t.true(github.isDone());
Expand Down
10 changes: 5 additions & 5 deletions test/publish.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test.serial('Publish a release', async t => {

await publish(pluginConfig, options, nextRelease, t.context.logger);

t.deepEqual(t.context.log.args[0], ['Published Github release: %s', releaseUrl]);
t.deepEqual(t.context.log.args[0], ['Published GitHub release: %s', releaseUrl]);
t.true(github.isDone());
});

Expand Down Expand Up @@ -89,7 +89,7 @@ test.serial('Publish a release with an existing tag', async t => {

await publish(pluginConfig, options, nextRelease, t.context.logger);

t.deepEqual(t.context.log.args[0], ['Published Github release: %s', releaseUrl]);
t.deepEqual(t.context.log.args[0], ['Published GitHub release: %s', releaseUrl]);
t.true(github.isDone());
});

Expand Down Expand Up @@ -130,7 +130,7 @@ test.serial('Publish a release with one asset', async t => {

await publish(pluginConfig, options, nextRelease, t.context.logger);

t.deepEqual(t.context.log.args[0], ['Published Github release: %s', releaseUrl]);
t.deepEqual(t.context.log.args[0], ['Published GitHub release: %s', releaseUrl]);
t.deepEqual(t.context.log.args[1], ['Published file %s', assetUrl]);
t.true(github.isDone());
t.true(githubUpload.isDone());
Expand Down Expand Up @@ -182,7 +182,7 @@ test.serial('Publish a release with one asset and custom github url', async t =>

await publish(pluginConfig, options, nextRelease, t.context.logger);

t.deepEqual(t.context.log.args[0], ['Published Github release: %s', releaseUrl]);
t.deepEqual(t.context.log.args[0], ['Published GitHub release: %s', releaseUrl]);
t.deepEqual(t.context.log.args[1], ['Published file %s', assetUrl]);
t.true(github.isDone());
t.true(githubUpload.isDone());
Expand Down Expand Up @@ -216,7 +216,7 @@ test.serial('Publish a release with an array of missing assets', async t => {

await publish(pluginConfig, options, nextRelease, t.context.logger);

t.deepEqual(t.context.log.args[0], ['Published Github release: %s', releaseUrl]);
t.deepEqual(t.context.log.args[0], ['Published GitHub release: %s', releaseUrl]);
t.deepEqual(t.context.error.args[0], [
'The asset %s cannot be read, and will be ignored.',
'test/fixtures/missing.txt',
Expand Down
4 changes: 2 additions & 2 deletions test/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test.serial('Verify package, token and repository access and custom URL', async
);

t.true(github.isDone());
t.deepEqual(t.context.log.args[0], ['Verify Github authentication (%s)', 'https://othertesturl.com:9090/prefix']);
t.deepEqual(t.context.log.args[0], ['Verify GitHub authentication (%s)', 'https://othertesturl.com:9090/prefix']);
});

test.serial('Verify package, token and repository with environment variables', async t => {
Expand All @@ -79,7 +79,7 @@ test.serial('Verify package, token and repository with environment variables', a
await t.notThrows(verify({}, {repositoryUrl: `git@othertesturl.com:${owner}/${repo}.git`}, t.context.logger));

t.true(github.isDone());
t.deepEqual(t.context.log.args[0], ['Verify Github authentication (%s)', 'https://othertesturl.com:443/prefix']);
t.deepEqual(t.context.log.args[0], ['Verify GitHub authentication (%s)', 'https://othertesturl.com:443/prefix']);
});

test.serial('Verify package, token and repository access with alternative environment varialbes', async t => {
Expand Down

0 comments on commit d5aa119

Please sign in to comment.