Skip to content

Commit 5647dec

Browse files
committed
fix: update changelog display and fix typescript issues
1 parent 25b71cf commit 5647dec

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

packages/bumpx/src/interrupt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import process from 'node:process'
1+
import * as process from 'node:process'
22

33
/**
44
* Global flag to track user interrupt status

packages/bumpx/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { execSync, spawnSync } from 'node:child_process'
44
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
55
import { readdir, readFile, stat } from 'node:fs/promises'
66
import { join, relative } from 'node:path'
7-
import process from 'node:process'
8-
import readline from 'node:readline'
7+
import * as process from 'node:process'
8+
import * as readline from 'node:readline'
99

1010
/**
1111
* Custom SemVer implementation to handle version parsing and manipulation

packages/bumpx/src/version-bump.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { FileInfo, VersionBumpOptions } from './types'
33
import { readFileSync, writeFileSync } from 'node:fs'
44
import { dirname, join, relative, resolve } from 'node:path'
5-
import process from 'node:process'
5+
import * as process from 'node:process'
66
import { checkInterruption, userInterrupted } from './interrupt'
77
import { ProgressEvent } from './types'
88
import {
@@ -1099,16 +1099,17 @@ function showGeneratedChangelog(newContent: string, existingContent: string): vo
10991099
for (const line of lines) {
11001100
// Look for version headers like "## [1.0.1]" or "### v1.0.1"
11011101
if (line.match(/^#+\s*(\[?v?\d+\.\d+\.\d+.*?\]?|Release)/i)) {
1102+
// If we already found a changelog entry and now hit another header, stop processing
1103+
// This ensures we only get the first/latest entry
1104+
if (inChangelog) {
1105+
break
1106+
}
11021107
inChangelog = true
11031108
relevantLines.push(line)
11041109
}
11051110
else if (inChangelog) {
1106-
// Stop at the next version header or empty sections
1107-
if (line.match(/^#+\s*(\[?v?\d+\.\d+\.\d+.*?\]?|Release)/i)) {
1108-
break
1109-
}
11101111
// Add content lines but limit output
1111-
if (relevantLines.length < 15) { // Limit to ~15 lines
1112+
if (relevantLines.length < 30) { // Allow for a bit more content
11121113
relevantLines.push(line)
11131114
}
11141115
}
@@ -1201,6 +1202,9 @@ async function generateChangelog(cwd: string, fromVersion?: string, toVersion?:
12011202

12021203
// Write the combined content back to the file
12031204
fs.writeFileSync(changelogPath, newContent, 'utf-8')
1205+
1206+
// Show the newly generated changelog section
1207+
showGeneratedChangelog(newContent, existingContent)
12041208
}
12051209
else {
12061210
// Use CLI approach in test mode
@@ -1297,15 +1301,20 @@ async function rollbackChanges(fileBackups: Map<string, { content: string, versi
12971301
}
12981302

12991303
// Then restore file contents to their original state
1300-
for (const [filePath, backup] of fileBackups) {
1304+
// Use Array.from to convert Map entries to an array for compatibility
1305+
Array.from(fileBackups.entries()).forEach(([filePath, backup]) => {
13011306
try {
1302-
const fs = await import('node:fs')
1303-
fs.writeFileSync(filePath, backup.content, 'utf-8')
1307+
// Use a dynamic import for fs
1308+
import('node:fs').then(fs => {
1309+
fs.writeFileSync(filePath, backup.content, 'utf-8')
1310+
}).catch(importError => {
1311+
console.warn(`Warning: Failed to import fs module: ${importError}`)
1312+
})
13041313
}
13051314
catch (rollbackError) {
13061315
console.warn(`Warning: Failed to rollback ${filePath}: ${rollbackError}`)
13071316
}
1308-
}
1317+
})
13091318
}
13101319

13111320
/**

0 commit comments

Comments
 (0)