@programinglive/commiter 1.1.1 β†’ 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.3](https://github.com/programinglive/commiter/compare/v1.1.2...v1.1.3) (2025-11-05)
6
+
7
+ ### [1.1.2](https://github.com/programinglive/commiter/compare/v1.1.1...v1.1.2) (2025-11-05)
8
+
9
+
10
+ ### 🧹 Chores
11
+
12
+ * auto-update release notes during release ([99d1043](https://github.com/programinglive/commiter/commit/99d104374794a6a46dc34e8a91fa8b30ae9b297b))
13
+
5
14
  ### [1.1.1](https://github.com/programinglive/commiter/compare/v1.1.0...v1.1.1) (2025-11-05)
6
15
 
7
16
 
@@ -4,6 +4,9 @@ This document summarizes every published version of `@programinglive/commiter`.
4
4
 
5
5
  | Version | Date | Highlights |
6
6
  |---------|------|------------|
7
+ | 1.1.3 | 2025-11-05 | See CHANGELOG for details. |
8
+ | 1.1.2 | 2025-11-05 | auto-update release notes during release (99d1043) |
9
+ | 1.1.1 | 2025-11-05 | πŸ› Bug Fix – removed the fs.F_OK deprecation warning from release runs. |
7
10
  | 1.1.0 | 2025-10-29 | πŸ“ Documentation – clarified release automation flow. |
8
11
  | 1.0.12 | 2025-10-29 | ✨ Feature – autodetects project test command before releasing. |
9
12
  | 1.0.11 | 2025-10-29 | πŸ“ Documentation – added project status and download badges. |
@@ -19,7 +22,23 @@ This document summarizes every published version of `@programinglive/commiter`.
19
22
  | 1.0.1 | 2025-10-18 | πŸ› Bug Fix – aligned commitlint config with project module type. |
20
23
  | 1.0.0 | 2025-10-17 | ✨ Initial release – bootstrapped conventional release tooling; added community docs and metadata. |
21
24
 
22
- ## fs.F_OK Deprecation Warning Fix (Unreleased)
25
+
26
+
27
+ ## 1.1.3
28
+
29
+ Released on **2025-11-05**.
30
+
31
+ - See CHANGELOG for details.
32
+
33
+ ## 1.1.2 – 🧹 Chores
34
+
35
+ Released on **2025-11-05**.
36
+
37
+ - auto-update release notes during release (99d1043)
38
+
39
+ ## 1.1.1 – fs.F_OK Deprecation Warning Fix
40
+
41
+ Released on **2025-11-05**.
23
42
  - Eliminated the `[DEP0176] fs.F_OK` warning emitted during release commands by injecting a preload script that transparently rewrites `fs.F_OK` usage inside `standard-version`.
24
43
  - Ensured the preload script runs for both in-process unit tests and the child process that executes `standard-version` by appending a `--require` flag to `NODE_OPTIONS`.
25
44
  - Updated the test suite to cover the preload behaviour and the adjusted release workflow, switching the project to Node’s built-in test runner (`node --test`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@programinglive/commiter",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Commiter keeps repositories release-ready by enforcing conventional commits, generating icon-rich changelog entries, and orchestrating semantic version bumps without manual toil. It bootstraps Husky hooks, commitlint rules, and release scripts that inspect history, detect framework-specific test commands, run them automatically, tag git releases, coordinate npm publishing, surface release metrics, enforce project-specific checks, and give maintainers observability across distributed teams. Plus!",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -4,6 +4,8 @@ const { spawnSync } = require('child_process');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
 
7
+ const { updateReleaseNotes } = require('./update-release-notes');
8
+
7
9
  const fsFokPreloadPath = path.join(__dirname, 'preload', 'fs-f-ok.cjs');
8
10
  const FS_FOK_PRELOAD_FLAG = buildPreloadFlag(fsFokPreloadPath);
9
11
 
@@ -132,7 +134,13 @@ function runProjectTests({ spawn = spawnSync, env = process.env, cwd = process.c
132
134
  });
133
135
  }
134
136
 
135
- function runRelease({ argv = process.argv, env = process.env, spawn = spawnSync } = {}) {
137
+ function runRelease({
138
+ argv = process.argv,
139
+ env = process.env,
140
+ spawn = spawnSync,
141
+ cwd = process.cwd(),
142
+ dependencies = {}
143
+ } = {}) {
136
144
  const { releaseType: cliReleaseType, extraArgs } = getCliArguments(argv);
137
145
  const inferredReleaseType = cliReleaseType || getNpmRunArgument(env);
138
146
  const standardVersionArgs = buildStandardVersionArgs({
@@ -140,6 +148,12 @@ function runRelease({ argv = process.argv, env = process.env, spawn = spawnSync
140
148
  extraArgs
141
149
  });
142
150
 
151
+ const checkWorkingTreeClean = dependencies.isWorkingTreeClean || (() => isWorkingTreeClean({ cwd }));
152
+ const workingTreeClean = checkWorkingTreeClean();
153
+ if (!workingTreeClean) {
154
+ throw new Error('Working tree has uncommitted changes. Commit or stash before running release.');
155
+ }
156
+
143
157
  const testResult = runProjectTests({ spawn, env });
144
158
  if (testResult && typeof testResult.status === 'number' && testResult.status !== 0) {
145
159
  return testResult;
@@ -147,10 +161,76 @@ function runRelease({ argv = process.argv, env = process.env, spawn = spawnSync
147
161
 
148
162
  const standardVersionBin = require.resolve('standard-version/bin/cli.js');
149
163
  const childEnv = appendPreloadToNodeOptions(env, FS_FOK_PRELOAD_FLAG);
150
- return spawn(process.execPath, [standardVersionBin, ...standardVersionArgs], {
164
+ const releaseResult = spawn(process.execPath, [standardVersionBin, ...standardVersionArgs], {
151
165
  stdio: 'inherit',
152
- env: childEnv
166
+ env: childEnv,
167
+ cwd
168
+ });
169
+
170
+ if (releaseResult && typeof releaseResult.status === 'number' && releaseResult.status !== 0) {
171
+ return releaseResult;
172
+ }
173
+
174
+ const releaseNotesPath = dependencies.releaseNotesPath || path.join('docs', 'release-notes', 'RELEASE_NOTES.md');
175
+ const updateNotes = dependencies.updateReleaseNotes || ((options = {}) => updateReleaseNotes({ rootDir: cwd, ...options }));
176
+ const gitAdd = dependencies.gitAdd || ((files) => spawnSync('git', ['add', ...files], { stdio: 'inherit', cwd }));
177
+ const gitCommitAmend = dependencies.gitCommitAmend || (() => spawnSync('git', ['commit', '--amend', '--no-edit'], { stdio: 'inherit', cwd }));
178
+ const gitTag = dependencies.gitTag || ((tagName, tagMessage) => {
179
+ const args = tagMessage
180
+ ? ['tag', '-f', '-a', tagName, '-m', tagMessage]
181
+ : ['tag', '-f', tagName];
182
+ return spawnSync('git', args, { stdio: 'inherit', cwd });
153
183
  });
184
+ const getCommitMessage = dependencies.getCommitMessage || (() => spawnSync('git', ['log', '-1', '--pretty=%s'], { cwd, encoding: 'utf8' }));
185
+ const buildTagName = dependencies.buildTagName || ((version) => `v${version}`);
186
+ const loadPackage = dependencies.loadPackageJson || ((dir) => loadPackageJson(dir));
187
+
188
+ let notesUpdated = false;
189
+ try {
190
+ notesUpdated = updateNotes();
191
+ } catch (error) {
192
+ console.warn(`⚠️ Skipping release notes update: ${error.message}`);
193
+ }
194
+
195
+ if (notesUpdated) {
196
+ const gitAddResult = gitAdd([releaseNotesPath]);
197
+ if (!gitAddResult || typeof gitAddResult.status !== 'number' || gitAddResult.status !== 0) {
198
+ console.warn('⚠️ Release notes updated but failed to stage changes. Please add them manually.');
199
+ return releaseResult;
200
+ }
201
+
202
+ const gitCommitResult = gitCommitAmend();
203
+ if (!gitCommitResult || typeof gitCommitResult.status !== 'number' || gitCommitResult.status !== 0) {
204
+ console.warn('⚠️ Release notes updated but failed to amend release commit. Please amend manually.');
205
+ return releaseResult;
206
+ }
207
+
208
+ const packageJson = loadPackage(cwd);
209
+ const version = packageJson && packageJson.version;
210
+ if (!version) {
211
+ console.warn('⚠️ Cannot retag release: package.json version missing. Please update tag manually.');
212
+ return releaseResult;
213
+ }
214
+
215
+ const tagName = buildTagName(version);
216
+ let tagMessage;
217
+ try {
218
+ const commitMessageResult = getCommitMessage();
219
+ if (commitMessageResult && typeof commitMessageResult.status === 'number' && commitMessageResult.status === 0) {
220
+ const output = typeof commitMessageResult.stdout === 'string' ? commitMessageResult.stdout : '';
221
+ tagMessage = output.trim();
222
+ }
223
+ } catch (error) {
224
+ console.warn(`⚠️ Unable to read release commit message: ${error.message}`);
225
+ }
226
+
227
+ const gitTagResult = gitTag(tagName, tagMessage);
228
+ if (!gitTagResult || typeof gitTagResult.status !== 'number' || gitTagResult.status !== 0) {
229
+ console.warn(`⚠️ Failed to retag ${tagName}. Please update the tag manually before pushing.`);
230
+ }
231
+ }
232
+
233
+ return releaseResult;
154
234
  }
155
235
 
156
236
  if (require.main === module) {
@@ -174,7 +254,8 @@ module.exports = {
174
254
  loadPackageJson,
175
255
  detectPackageManager,
176
256
  runProjectTests,
177
- runRelease
257
+ runRelease,
258
+ isWorkingTreeClean
178
259
  };
179
260
 
180
261
  function buildPreloadFlag(filePath) {
@@ -191,3 +272,23 @@ function appendPreloadToNodeOptions(env, preloadFlag) {
191
272
  nextEnv.NODE_OPTIONS = existing ? `${existing} ${preloadFlag}` : preloadFlag;
192
273
  return nextEnv;
193
274
  }
275
+
276
+ function isWorkingTreeClean({ cwd = process.cwd() } = {}) {
277
+ const result = spawnSync('git', ['status', '--porcelain'], {
278
+ cwd,
279
+ encoding: 'utf8'
280
+ });
281
+
282
+ if (result.error) {
283
+ throw result.error;
284
+ }
285
+
286
+ if (typeof result.status === 'number' && result.status !== 0) {
287
+ const stderr = typeof result.stderr === 'string' ? result.stderr.trim() : '';
288
+ const message = stderr || 'Failed to determine working tree status.';
289
+ throw new Error(message);
290
+ }
291
+
292
+ const output = typeof result.stdout === 'string' ? result.stdout : '';
293
+ return output.trim().length === 0;
294
+ }
@@ -0,0 +1,182 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ function updateReleaseNotes({
7
+ rootDir = process.cwd(),
8
+ releaseNotesRelativePath = path.join('docs', 'release-notes', 'RELEASE_NOTES.md'),
9
+ changelogRelativePath = 'CHANGELOG.md',
10
+ packageJsonRelativePath = 'package.json',
11
+ now = () => new Date()
12
+ } = {}) {
13
+ const releaseNotesPath = path.join(rootDir, releaseNotesRelativePath);
14
+ if (!fs.existsSync(releaseNotesPath)) {
15
+ console.log(`ℹ️ Release notes file not found at ${releaseNotesPath}; skipping update.`);
16
+ return false;
17
+ }
18
+
19
+ const packageJsonPath = path.join(rootDir, packageJsonRelativePath);
20
+ if (!fs.existsSync(packageJsonPath)) {
21
+ console.log(`ℹ️ package.json not found at ${packageJsonPath}; skipping release notes update.`);
22
+ return false;
23
+ }
24
+
25
+ const changelogPath = path.join(rootDir, changelogRelativePath);
26
+ if (!fs.existsSync(changelogPath)) {
27
+ console.log(`ℹ️ CHANGELOG not found at ${changelogPath}; skipping release notes update.`);
28
+ return false;
29
+ }
30
+
31
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
32
+ const version = packageJson.version;
33
+ if (!version) {
34
+ console.log('ℹ️ package.json version is missing; skipping release notes update.');
35
+ return false;
36
+ }
37
+
38
+ const releaseNotesContent = fs.readFileSync(releaseNotesPath, 'utf8');
39
+ if (releaseNotesContent.includes(`| ${version} `) || releaseNotesContent.includes(`## ${version}`)) {
40
+ console.log(`ℹ️ Release notes already contain version ${version}; skipping.`);
41
+ return false;
42
+ }
43
+
44
+ const changelogContent = fs.readFileSync(changelogPath, 'utf8');
45
+ const changelogInfo = extractChangelogInfo({ changelogContent, version });
46
+
47
+ const releaseDate = changelogInfo.date || formatDate(now());
48
+ const highlight = changelogInfo.highlight || changelogInfo.heading || 'See CHANGELOG for details.';
49
+ const sectionHeading = changelogInfo.heading || '';
50
+ const detailBullets = Array.isArray(changelogInfo.bullets) && changelogInfo.bullets.length > 0
51
+ ? changelogInfo.bullets
52
+ : [highlight];
53
+
54
+ const updatedContent = insertReleaseNotesEntry({
55
+ content: releaseNotesContent,
56
+ version,
57
+ releaseDate,
58
+ highlight,
59
+ sectionHeading,
60
+ detailBullets
61
+ });
62
+
63
+ fs.writeFileSync(releaseNotesPath, updatedContent);
64
+ console.log(`βœ… Added release notes entry for version ${version}.`);
65
+ return true;
66
+ }
67
+
68
+ function insertReleaseNotesEntry({ content, version, releaseDate, highlight, sectionHeading, detailBullets }) {
69
+ const lines = content.split('\n');
70
+ const headerSeparatorIndex = lines.findIndex((line) => line.trim().startsWith('|---------'));
71
+ if (headerSeparatorIndex === -1) {
72
+ throw new Error('Unable to locate release notes table header.');
73
+ }
74
+
75
+ const newRow = `| ${version} | ${releaseDate} | ${escapePipes(highlight)} |`;
76
+ lines.splice(headerSeparatorIndex + 1, 0, newRow);
77
+
78
+ const sectionLines = [];
79
+ sectionLines.push('');
80
+ const trimmedHeading = typeof sectionHeading === 'string' ? sectionHeading.trim() : '';
81
+ const headingSuffix = trimmedHeading ? ` – ${trimmedHeading}` : '';
82
+ sectionLines.push(`## ${version}${headingSuffix}`);
83
+ sectionLines.push('');
84
+ sectionLines.push(`Released on **${releaseDate}**.`);
85
+ sectionLines.push('');
86
+ for (const bullet of detailBullets) {
87
+ sectionLines.push(`- ${bullet}`);
88
+ }
89
+ sectionLines.push('');
90
+
91
+ const firstSectionIndex = lines.findIndex((line, idx) => idx > headerSeparatorIndex && line.startsWith('## '));
92
+ if (firstSectionIndex === -1) {
93
+ lines.push(...sectionLines);
94
+ } else {
95
+ lines.splice(firstSectionIndex, 0, ...sectionLines);
96
+ }
97
+
98
+ return lines.join('\n');
99
+ }
100
+
101
+ function extractChangelogInfo({ changelogContent, version }) {
102
+ const versionHeadingRegex = new RegExp(`^### \\[${escapeRegExp(version)}\\][^\n]*`, 'm');
103
+ const match = changelogContent.match(versionHeadingRegex);
104
+ if (!match) {
105
+ return {};
106
+ }
107
+
108
+ const headingIndex = match.index;
109
+ const rest = changelogContent.slice(headingIndex + match[0].length);
110
+ const nextVersionRegex = /^### \[[^\n]*\]/m;
111
+ const nextVersionMatch = nextVersionRegex.exec(rest);
112
+ const section = nextVersionMatch ? rest.slice(0, nextVersionMatch.index) : rest;
113
+
114
+ const dateMatch = match[0].match(/\((\d{4}-\d{2}-\d{2})\)/);
115
+ const date = dateMatch ? dateMatch[1] : undefined;
116
+
117
+ const categoryRegex = /^###\s+([^\n]+)$/m;
118
+ const categoryMatch = section.match(categoryRegex);
119
+ let heading;
120
+ if (categoryMatch) {
121
+ heading = sanitizeText(categoryMatch[1]);
122
+ }
123
+
124
+ const bullets = [];
125
+ const bulletRegex = /^\*\s+([^\n]+)$/gm;
126
+ let bulletMatch;
127
+ while ((bulletMatch = bulletRegex.exec(section)) !== null) {
128
+ const sanitized = sanitizeText(bulletMatch[1]);
129
+ if (!bullets.includes(sanitized)) {
130
+ bullets.push(sanitized);
131
+ }
132
+ }
133
+
134
+ const highlight = bullets.length > 0 ? bullets[0] : undefined;
135
+
136
+ return {
137
+ date,
138
+ highlight,
139
+ heading,
140
+ bullets
141
+ };
142
+ }
143
+
144
+ function sanitizeText(text) {
145
+ return text
146
+ .replace(/\[([^\]]+)\]\([^\)]+\)/g, '$1')
147
+ .replace(/\s+/g, ' ')
148
+ .trim();
149
+ }
150
+
151
+ function escapeRegExp(string) {
152
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
153
+ }
154
+
155
+ function escapePipes(text) {
156
+ return text.replace(/\|/g, '\\|');
157
+ }
158
+
159
+ function formatDate(date) {
160
+ const year = date.getFullYear();
161
+ const month = String(date.getMonth() + 1).padStart(2, '0');
162
+ const day = String(date.getDate()).padStart(2, '0');
163
+ return `${year}-${month}-${day}`;
164
+ }
165
+
166
+ module.exports = {
167
+ updateReleaseNotes,
168
+ insertReleaseNotesEntry,
169
+ extractChangelogInfo,
170
+ sanitizeText,
171
+ escapePipes,
172
+ formatDate
173
+ };
174
+
175
+ if (require.main === module) {
176
+ try {
177
+ updateReleaseNotes();
178
+ } catch (error) {
179
+ console.error(`❌ Failed to update release notes: ${error.message}`);
180
+ process.exit(1);
181
+ }
182
+ }