Skip to content

Commit

Permalink
ci: fail on empty commits (#9)
Browse files Browse the repository at this point in the history
* ci: fail on empty commits

* ci: commit lockfile
  • Loading branch information
Wroud authored Sep 7, 2024
1 parent 722359c commit 4c3610d
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 50 deletions.
27 changes: 27 additions & 0 deletions packages/ci/bin/getVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env node

import { Bumper } from "conventional-recommended-bump";

class RestrictEmptyCommits extends Bumper {
bump(whatBump = this.whatBump) {
return super.bump((commits) => {
if (commits.length === 0) {
throw new Error("No commits found");
}
return whatBump(commits);
});
}
}

const [_, __, preset, tagPrefix, commitPath] = process.argv;

const bumper = new RestrictEmptyCommits(process.cwd())
.loadPreset(preset)
.tag({
prefix: tagPrefix,
})
.commits({ path: commitPath });

const recommendation = await bumper.bump();

console.log(recommendation.releaseType);
14 changes: 14 additions & 0 deletions packages/ci/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@wroud/ci",
"private": true,
"type": "module",
"packageManager": "[email protected]",
"bin": {
"get-version": "./bin/getVersion.js"
},
"devDependencies": {
"@tsconfig/node20": "^20",
"conventional-changelog-conventionalcommits": "^8",
"conventional-recommended-bump": "^10"
}
}
46 changes: 0 additions & 46 deletions packages/di/CHANGELOG.md

This file was deleted.

7 changes: 4 additions & 3 deletions packages/di/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"LICENSE",
"package.json",
"README.md",
"CHANGELOG.md",
"lib",
"!lib/**/*.test.js",
"!lib/**/*.test.d.ts",
Expand All @@ -42,9 +43,9 @@
"!.tsbuildinfo"
],
"scripts": {
"ci:version": "yarn version $(yarn conventional-recommended-bump -p conventionalcommits -t di-v --commit-path .)",
"ci:version": "yarn version $(yarn get-version conventionalcommits di-v .)",
"ci:changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s -t di-v --commit-path .",
"ci:tag": "VERSION=$(grep '\"version\"' package.json | awk -F '\"' '{print $4}') && git add package.json CHANGELOG.md && git commit -m \"Release v$VERSION\" && git tag -a \"di-v$VERSION\" -m \"Release version $VERSION\" && git push",
"ci:tag": "VERSION=$(grep '\"version\"' package.json | awk -F '\"' '{print $4}') && git add package.json CHANGELOG.md && git commit -m \"Release di-v$VERSION\" && git tag -a \"di-v$VERSION\" -m \"Release version $VERSION\" && git push && git push origin tag \"di-v$VERSION\"",
"ci:prepublish": "yarn run ci:version || exit 0 && yarn run ci:changelog && yarn run ci:tag",
"test": "tests-runner",
"test:ci": "CI=true yarn run test",
Expand All @@ -56,12 +57,12 @@
"devDependencies": {
"@types/node": "^20",
"@vitest/coverage-v8": "^2",
"@wroud/ci": "workspace:^",
"@wroud/tests-runner": "workspace:^",
"@wroud/tsconfig": "workspace:^",
"concurrently": "^8",
"conventional-changelog-cli": "^5",
"conventional-changelog-conventionalcommits": "^8",
"conventional-recommended-bump": "^10",
"rimraf": "^6",
"tslib": "^2",
"typescript": "^5",
Expand Down
14 changes: 13 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2958,6 +2958,18 @@ __metadata:
languageName: unknown
linkType: soft

"@wroud/ci@workspace:^, @wroud/ci@workspace:packages/ci":
version: 0.0.0-use.local
resolution: "@wroud/ci@workspace:packages/ci"
dependencies:
"@tsconfig/node20": "npm:^20"
conventional-changelog-conventionalcommits: "npm:^8"
conventional-recommended-bump: "npm:^10"
bin:
get-version: ./bin/getVersion.js
languageName: unknown
linkType: soft

"@wroud/di-react@workspace:packages/di-react":
version: 0.0.0-use.local
resolution: "@wroud/di-react@workspace:packages/di-react"
Expand Down Expand Up @@ -3031,12 +3043,12 @@ __metadata:
dependencies:
"@types/node": "npm:^20"
"@vitest/coverage-v8": "npm:^2"
"@wroud/ci": "workspace:^"
"@wroud/tests-runner": "workspace:^"
"@wroud/tsconfig": "workspace:^"
concurrently: "npm:^8"
conventional-changelog-cli: "npm:^5"
conventional-changelog-conventionalcommits: "npm:^8"
conventional-recommended-bump: "npm:^10"
rimraf: "npm:^6"
tslib: "npm:^2"
typescript: "npm:^5"
Expand Down

0 comments on commit 4c3610d

Please sign in to comment.