Skip to content

Commit

Permalink
Housekeeping some old docs
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Aug 22, 2020
1 parent 557cade commit ea67fbe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions docs/dev/README.md
Expand Up @@ -3,8 +3,8 @@
## GitHub

- [octokit/rest.js](https://github.com/octokit/rest.js)
- [repos.createRelease](https://octokit.github.io/rest.js/#api-Repos-createRelease)
- [repos.uploadReleaseAsset](https://octokit.github.io/rest.js/#api-Repos-uploadReleaseAsset)
- [repos.createRelease](https://octokit.github.io/rest.js/#repos-create-release)
- [repos.uploadReleaseAsset](https://octokit.github.io/rest.js/#repos-upload-release-asset)

## GitLab

Expand Down
11 changes: 4 additions & 7 deletions docs/recipes/distribution-repo.md
Expand Up @@ -12,9 +12,6 @@ In `.release-it.json` of the source repo:

```json
{
"increment": "minor",
"preRelease": "alpha",
"git": { "tagName": "v${version}" },
"hooks": {
"before:init": "git clone https://github.com/example/dist-repo .stage",
"after:release": "cd .stage && npm version ${version} && cd -"
Expand All @@ -29,7 +26,7 @@ In `package.json` of dist repo:
"name": "my-dist-package",
"version": "1.0.0",
"scripts": {
"version": "echo release-line >> dist-file && git add . --all",
"version": "echo copy ../dist/files > ./files && git add . --all",
"postversion": "git push --follow-tags"
}
}
Expand All @@ -47,9 +44,9 @@ A single repository, with e.g. a `dist` or `gh-pages` branch. In `package.json`:
"name": "my-package",
"version": "1.0.0",
"release-it": {
"increment": "minor",
"git": { "tagName": "v${version}" },
"npm": { "publish": false },
"npm": {
"publish": false
},
"hooks": {
"before:init": "git clone https://github.com/my/my-package -b dist .stage",
"before:release": "npm run build",
Expand Down
25 changes: 14 additions & 11 deletions docs/recipes/my-version.md
@@ -1,7 +1,7 @@
# Example plugin: my-version

This example reads a `VERSION` file, bumps it, and publishes to a package repository. It is only enabled if the
`./VERSION` actually exists.
`./VERSION` file actually exists.

```javascript
const { Plugin } = require('release-it');
Expand All @@ -11,15 +11,15 @@ const path = require('path');
const prompts = {
publish: {
type: 'confirm',
message: context => `Publish version ${context.version} of ${context['my-version'].name}?`
message: context => `Publish version ${context.version} of ${context.name}?`
}
};

class MyVersionPlugin extends Plugin {
constructor(...args) {
super(...args);
this.registerPrompts(prompts);
this.versionFile = path.resolve('./VERSION');
this.setContext({ versionFile: path.resolve('./VERSION') });
}
static isEnabled() {
try {
Expand All @@ -30,17 +30,18 @@ class MyVersionPlugin extends Plugin {
}
init() {
const data = fs.readFileSync(this.versionFile);
this.latestVersion = data.toString().trim();
const latestVersion = data.toString().trim();
this.setContext({ latestVersion });
}
getName() {
return this.options.name;
getPackageName() {
return this.config.getContext('name');
}
getLatestVersion() {
return this.latestVersion;
return this.getContext('latestVersion');
}
bump(version) {
this.version = version;
fs.writeFileSync(this.versionFile, version);
this.setContext({ version });
fs.writeFileSync(this.getContext('versionFile'), version);
}
async release() {
await this.step({ task: () => this.publish(), label: 'Publish with pkg-manager', prompt: 'publish' });
Expand All @@ -51,7 +52,9 @@ class MyVersionPlugin extends Plugin {
}
afterRelease() {
if (this.isReleased) {
this.log.log(`🔗 https://example.package-manager.org/${this.getName()}/${this.version}`);
const name = this.getPackageName();
const { version } = this.getContext();
this.log.log(`🔗 https://example.package-manager.org/${name}/${version}`);
}
}
}
Expand All @@ -65,7 +68,7 @@ To add this plugin to a project, use this configuration:
{
"plugins": {
"my-version": {
"name": "my-pkg"
"unused": "option"
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/recipes/require-commits.md
Expand Up @@ -7,8 +7,8 @@ release-it process if there are no commits since the latest tag.

It is a good idea to verify things are working properly (e.g. by running tests) before releasing the project. However,
the check enabled by `git.requireCommits` occurs after `hooks.before:init` (as the former is part of the Git plugin). In
case time-consuming scripts are defined in `hooks.before:init` and things should be sped up, consider adding a custom
shell script like this:
case time-consuming scripts are defined in `hooks.before:init` and things should be sped up, consider either moving the
scripts to `hooks.after:init`, or adding a custom shell script like this:

```json
{
Expand Down

0 comments on commit ea67fbe

Please sign in to comment.