Skip to content

Commit 4162963

Browse files
committed
v1.0.0
1 parent c9bed64 commit 4162963

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Unpublished
1+
# 1.0.0
22

3-
- (feature): COMMITMSG
4-
- (breaking): COMMITMSG
3+
- (feature): Initial implementatation, including prep command. (#3)
4+
- (breaking): Initial implementatation, including prep command. (#3)

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ pnpm exec husky
1212
echo "exec < /dev/tty && pnpm exec heeler add" > .husky/pre-commit
1313
```
1414

15-
Then add `heeler prep` to package.json `scripts.prepublishOnly`.
16-
1715
Then add `pnpm exec heeler check` to your CI/CD configuration, to ensure every pull request has added to the changelog
1816

1917
To work with Github's actions/checkout, add the following to your Github workflow:
@@ -28,4 +26,4 @@ To work with Github's actions/checkout, add the following to your Github workflo
2826
2927
Whenever a user runs `git commit`, they will be prompted for whether the change is breaking, feature, or fix. A line is added to the CHANGELOG.md for all commits that are unpublished.
3028

31-
When publishing, the `heeler prep` command will update the CHANGELOG.md to have the correct version number and messages.
29+
When publishing, run the `heeler prep` command to update the CHANGELOG.md to have the correct version number and messages.

bin/heeler.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ switch (command) {
1919
name: "changetype",
2020
message: "Is this a breaking change, new feature, or fix?",
2121
type: "list",
22-
choices: ["breaking", "feature", "fix"],
22+
choices: ["breaking", "feature", "fix", "skip"],
2323
},
2424
])
2525
.then((answers) => {
26-
return addToChangelog(answers);
26+
if (answers.changetype !== "skip") {
27+
return addToChangelog(answers);
28+
}
2729
});
2830
break;
2931
case "check":

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "heeler",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"type": "module",
55
"description": "Changelog pre-commit",
66
"bin": {
@@ -22,6 +22,5 @@
2222
"prettier": "^3.6.2",
2323
"pretty-quick": "^4.2.2",
2424
"semver": "^7.7.2"
25-
},
26-
"packageManager": "pnpm@10.13.1"
25+
}
2726
}

src/changelog-utils.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from "node:fs";
22
import path from "path";
33
import simpleGit from "simple-git";
44
import semver from "semver";
5+
import childProcess from "child_process";
56

67
export function addToChangelog(answers) {
78
const packageJson = fs.readFileSync(
@@ -61,9 +62,8 @@ export async function assertChangelogMostRecentCommit() {
6162

6263
export async function prepareRelease() {
6364
const changelogPath = path.resolve(process.cwd(), "CHANGELOG.md");
64-
const packageJson = JSON.parse(
65-
fs.readFileSync(path.resolve(process.cwd(), "package.json"), "utf-8"),
66-
);
65+
const packageJsonPath = path.resolve(process.cwd(), "package.json");
66+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
6767
const originalChangelogLines = fs
6868
.readFileSync(changelogPath, "utf-8")
6969
.split("\n");
@@ -103,7 +103,7 @@ export async function prepareRelease() {
103103
} else if (!versionBump) {
104104
versionBump = "patch";
105105
}
106-
changelogLines.push(message.replace("COMMIT_MSG", gitLog.message));
106+
changelogLines.push(message.replace("COMMITMSG", gitLog.message));
107107
}
108108
}
109109
}
@@ -114,7 +114,17 @@ export async function prepareRelease() {
114114

115115
fs.writeFileSync(
116116
changelogPath,
117-
`# ${newVersion}\n\n${changelogLines.join("\n")}\n${unalteredLines}`,
117+
`# ${newVersion.version}\n\n${changelogLines.join("\n")}\n${unalteredLines}`,
118118
);
119119
console.log("CHANGELOG.md updated and is ready for release");
120+
121+
packageJson.version = newVersion.version;
122+
123+
fs.writeFileSync(
124+
packageJsonPath,
125+
JSON.stringify(packageJson, null, 2),
126+
"utf-8",
127+
);
128+
129+
console.log("package.json version updated");
120130
}

0 commit comments

Comments
 (0)