Skip to content

Commit

Permalink
feat: manual review plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Sep 15, 2021
1 parent 0fec79c commit 2c7ef2f
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .releaseconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"plugins": ["lerna", "license"],
"plugins": ["lerna", "license", "manual-review"],
"exec": {
"before_commit": "yarn run build"
}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-->
## **WORK IN PROGRESS**
* New plugin `license` to check for outdated license years
* New plugin `manual-review` to do manual changes before committing

## 3.0.0 (2021-09-15)
* Split into plugins
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,12 @@ Since version 3, the release script is separated into several plugins, making it
If you need some of these plugins, you have to install and them separately:
| Plugin name | Description |
| ----------- | ----------------------------------------- |
| `iobroker` | Update ioBroker's `io-package.json` |
| `lerna` | Monorepo support with `lerna` |
| `license` | Check for outdated years in license files |
| Plugin name | Description |
| --------------- | ---------------------------------------------------------------------------------- |
| `iobroker` | Update ioBroker's `io-package.json` |
| `lerna` | Monorepo support with `lerna` |
| `license` | Check for outdated years in license files |
| `manual-review` | Asks you to review the changes before committing and lets you do additional edits. |
To do so, add them as a `devDependency`:
Expand Down Expand Up @@ -345,6 +346,10 @@ By default, the files `LICENSE`, `README` with and without `.md` extension are c
npm run release patch -- --license "**/LICENSE" "packages/*/README.md"
```
### `manual-review` plugin options
_none_
## Workflow file for automatic release
When using Github Actions, you can enable automatic release on `npm` and `Github Releases` after a tagged build was successful. To do so, include the following job in your workflow definition file (e.g. `.github/workflows/test-and-release.yml`) and configure it to depend on the build jobs (here, they are called `unit-tests`).
Expand Down
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
"<rootDir>/packages/plugin-iobroker/src",
"<rootDir>/packages/plugin-lerna/src",
"<rootDir>/packages/plugin-license/src",
"<rootDir>/packages/plugin-manual-review/src",
"<rootDir>/packages/plugin-package/src",
"<rootDir>/packages/plugin-version/src",
// Add others as necessary
Expand All @@ -25,6 +26,8 @@ module.exports = {
"<rootDir>/packages/plugin-iobroker/src$1",
"^@alcalzone/release-script-plugin-lerna(.*)": "<rootDir>/packages/plugin-lerna/src$1",
"^@alcalzone/release-script-plugin-license(.*)": "<rootDir>/packages/plugin-license/src$1",
"^@alcalzone/release-script-plugin-manual-review(.*)":
"<rootDir>/packages/plugin-manual-review/src$1",
"^@alcalzone/release-script-plugin-package(.*)": "<rootDir>/packages/plugin-package/src$1",
"^@alcalzone/release-script-plugin-version(.*)": "<rootDir>/packages/plugin-version/src$1",
"^@alcalzone/release-script-testing(.*)": "<rootDir>/packages/testing/src$1",
Expand Down
61 changes: 61 additions & 0 deletions packages/plugin-manual-review/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"name": "@alcalzone/release-script-plugin-manual-review",
"publishConfig": {
"access": "public"
},
"version": "3.0.0",
"description": "Plugin for Al Calzone's release script: manual review",
"keywords": [],
"license": "MIT",
"author": {
"name": "AlCalzone",
"email": "[email protected]"
},
"main": "build/index.js",
"exports": {
".": "./build/index.js",
"./package.json": "./package.json",
"./*.map": "./build/*.js.map",
"./*": "./build/*.js"
},
"types": "build/index.d.ts",
"typesVersions": {
"*": {
"build/index.d.ts": [
"build/index.d.ts"
],
"*": [
"build/*"
]
}
},
"files": [
"build/",
"LICENSE"
],
"engines": {
"node": ">=12.20"
},
"dependencies": {
"@alcalzone/release-script-core": "3.0.0"
},
"devDependencies": {
"@alcalzone/release-script-testing": "3.0.0",
"jest-extended": "^0.11.5",
"typescript": "*"
},
"scripts": {
"clean": "tsc -b tsconfig.build.json --clean",
"build": "tsc -b tsconfig.build.json",
"watch": "tsc -b tsconfig.build.json --watch"
},
"homepage": "https://github.com/AlCalzone/release-script/tree/main/packages/plugin-manual-review#readme",
"repository": {
"type": "git",
"url": "[email protected]:AlCalzone/release-script.git"
},
"bugs": {
"url": "https://github.com/AlCalzone/release-script/issues"
},
"readmeFilename": "README.md"
}
5 changes: 5 additions & 0 deletions packages/plugin-manual-review/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe("Manual Review plugin", () => {
describe("check stage", () => {
it.todo("does something");
});
});
29 changes: 29 additions & 0 deletions packages/plugin-manual-review/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { DefaultStages } from "@alcalzone/release-script-core";
import type { Context, Plugin, Stage } from "@alcalzone/release-script-core/types";

class ManualReviewPlugin implements Plugin {
public readonly id = "manual-review";
public readonly stages = [DefaultStages.edit];

// dependencies?: string[] | undefined;
public readonly stageAfter = {
edit: "*" as const,
};
// stageBefore?: Record<string, ConstOrDynamic<string[]>> | undefined;

async executeStage(context: Context, stage: Stage): Promise<void> {
if (stage.id === "edit" && !context.argv.dryRun) {
context.cli.log("Please review the changes and correct them manually if necessary.");
let result: boolean;
do {
result =
(await context.cli.select("Are you done?", [
{ value: "no", label: "no" },
{ value: "yes", label: "yes" },
])) === "yes";
} while (!result);
}
}
}

export default ManualReviewPlugin;
20 changes: 20 additions & 0 deletions packages/plugin-manual-review/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// tsconfig for building - only applies to the src directory
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
},
"references": [
// Add references to other projects here
{
"path": "../core/tsconfig.build.json"
},
],
"include": [
"src/**/*.ts"
],
"exclude": [
"src/**/*.test.ts"
]
}
21 changes: 21 additions & 0 deletions packages/plugin-manual-review/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// tsconfig for IntelliSense - active in all files in the current package
{
"extends": "../../tsconfig.json",
"compilerOptions": {},
"references": [
// Add references to other projects here
{
"path": "../core/tsconfig.build.json"
},
{
"path": "../testing/tsconfig.build.json"
},
],
"include": [
"src/**/*.ts"
],
"exclude": [
"build/**",
"node_modules/**"
]
}
3 changes: 3 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
{
"path": "packages/plugin-license/tsconfig.build.json"
},
{
"path": "packages/plugin-manual-review/tsconfig.build.json"
},
{
"path": "packages/plugin-package/tsconfig.build.json"
},
Expand Down
11 changes: 11 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ __metadata:
languageName: unknown
linkType: soft

"@alcalzone/release-script-plugin-manual-review@workspace:packages/plugin-manual-review":
version: 0.0.0-use.local
resolution: "@alcalzone/release-script-plugin-manual-review@workspace:packages/plugin-manual-review"
dependencies:
"@alcalzone/release-script-core": 3.0.0
"@alcalzone/release-script-testing": 3.0.0
jest-extended: ^0.11.5
typescript: "*"
languageName: unknown
linkType: soft

"@alcalzone/[email protected], @alcalzone/release-script-plugin-package@workspace:packages/plugin-package":
version: 0.0.0-use.local
resolution: "@alcalzone/release-script-plugin-package@workspace:packages/plugin-package"
Expand Down

0 comments on commit 2c7ef2f

Please sign in to comment.