Skip to content

Commit 4562fbb

Browse files
committed
feat(one-release-commit): create plugin with automation
1 parent 42b71a5 commit 4562fbb

File tree

8 files changed

+129
-3
lines changed

8 files changed

+129
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Auto has an extensive plugin system and wide variety of official plugins. Make a
6969
- [microsoft-teams](./plugins/microsoft-teams) - Post your release notes to a Microsoft teams channel
7070
- [omit-commits](./plugins/omit-commits) - Ignore commits base on name, email, subject, labels, and username
7171
- [omit-release-notes](./plugins/omit-release-notes) - Ignore release notes in PRs made by certain accounts
72+
- [one-release-commit](./plugins/one-release-commit) - Allow to create a single release commit
7273
- [pr-body-labels](./plugins/pr-body-labels) - Allow outside contributors to indicate what semver label should be applied to the Pull Request
7374
- [released](./plugins/released) - Add a `released` label to published PRs, comment with the version it's included in and comment on the issues the PR closes
7475
- [s3](./plugins/s3) - Post your built artifacts to amazon s3

docs/pages/docs/configuration/plugins.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ If you don't configure plugins in your `.autorc` configuration file `auto` will
1717
- Installed through `npm` => uses [`npm`](../generated/npm)
1818
- Installed through executable => uses [`git-tag`](../generated/git-tag)
1919

20-
For the majority of "package manager" plugins you should only use one at a time.
21-
Using multiple _will_ lead to undesired results.
20+
> :warning: For the majority of "package manager" plugins you should only use one at a time.
21+
> Using multiple _will_ lead to undesired results.
2222
2323
### No Plugins
2424

plugins/one-release-commit/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# One-Release-Commit Plugin
2+
3+
Allow to create a single release commit
4+
5+
## Installation
6+
7+
This plugin is not included with the `auto` CLI installed via NPM. To install:
8+
9+
```bash
10+
npm i --save-dev @auto-it/one-release-commit
11+
# or
12+
yarn add -D @auto-it/one-release-commit
13+
```
14+
15+
## Usage
16+
17+
```json
18+
{
19+
"plugins": [
20+
"one-release-commit"
21+
// other plugins
22+
]
23+
}
24+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Auto from '@auto-it/core';
2+
import OneReleaseCommit from '../src';
3+
4+
describe('One-Release-Commit Plugin', () => {
5+
test('should do something', async () => {
6+
});
7+
});
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "@auto-it/one-release-commit",
3+
"version": "10.34.2",
4+
"main": "dist/index.js",
5+
"description": "Allow to squash release commit in a single one",
6+
"license": "MIT",
7+
"author": {
8+
"name": "Andrew Lisowski",
9+
"email": "[email protected]"
10+
},
11+
"publishConfig": {
12+
"registry": "https://registry.npmjs.org/",
13+
"access": "public"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/intuit/auto"
18+
},
19+
"files": [
20+
"dist"
21+
],
22+
"keywords": [
23+
"automation",
24+
"semantic",
25+
"release",
26+
"github",
27+
"labels",
28+
"automated",
29+
"continuos integration",
30+
"changelog"
31+
],
32+
"scripts": {
33+
"build": "tsc -b",
34+
"start": "npm run build -- -w",
35+
"lint": "eslint src --ext .ts",
36+
"test": "jest --maxWorkers=2 --config ../../package.json"
37+
},
38+
"dependencies": {
39+
"@auto-it/core": "link:../../packages/core",
40+
"fp-ts": "^2.5.3",
41+
"io-ts": "^2.1.2",
42+
"tslib": "1.10.0"
43+
}
44+
}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Auto, IPlugin, validatePluginConfiguration } from '@auto-it/core';
2+
import * as t from "io-ts";
3+
4+
const pluginOptions = t.partial({
5+
});
6+
7+
export type IOneReleaseCommitPluginOptions = t.TypeOf<typeof pluginOptions>;
8+
9+
/** Allow to squash release commit in a single one */
10+
export default class OneReleaseCommitPlugin implements IPlugin {
11+
/** The name of the plugin */
12+
name = 'one-release-commit';
13+
14+
/** The options of the plugin */
15+
readonly options: IOneReleaseCommitPluginOptions;
16+
17+
/** Initialize the plugin with it's options */
18+
constructor(options: IOneReleaseCommitPluginOptions) {
19+
this.options = options;
20+
}
21+
22+
/** Tap into auto plugin points. */
23+
apply(auto: Auto) {
24+
auto.hooks.validateConfig.tapPromise(this.name, async (name, options) => {
25+
// If it's a string thats valid config
26+
if (name === this.name && typeof options !== "string") {
27+
return validatePluginConfiguration(this.name, pluginOptions, options);
28+
}
29+
});
30+
}
31+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": ["src/**/*", "../../typings/**/*"],
4+
5+
"compilerOptions": {
6+
"outDir": "./dist",
7+
"rootDir": "./src",
8+
"composite": true
9+
},
10+
11+
"references": [
12+
{
13+
"path": "../../packages/core"
14+
}
15+
]
16+
}

tsconfig.dev.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@
9191
},
9292
{
9393
"path": "plugins/sbt"
94+
},
95+
{
96+
"path": "plugins/one-release-commit"
9497
}
9598
]
96-
}
99+
}

0 commit comments

Comments
 (0)