@@ -58,7 +58,7 @@ async function getVersionIncrement() {
5858 }
5959}
6060
61- async function updateVersion ( incrementType ) {
61+ function calculateNewVersion ( incrementType ) {
6262 const packagePath = path . join ( process . cwd ( ) , 'package.json' ) ;
6363 const packageJson = JSON . parse ( fs . readFileSync ( packagePath , 'utf8' ) ) ;
6464 const currentVersion = packageJson . version ;
@@ -83,14 +83,23 @@ async function updateVersion(incrementType) {
8383 }
8484
8585 const newVersion = `${ major } .${ minor } .${ patch } ` ;
86+
87+ log ( `\n📋 Version will be updated: ${ currentVersion } → ${ newVersion } ` , 'yellow' ) ;
88+
89+ return { currentVersion, newVersion } ;
90+ }
91+
92+ function writeVersionToPackage ( newVersion ) {
93+ const packagePath = path . join ( process . cwd ( ) , 'package.json' ) ;
94+ const packageJson = JSON . parse ( fs . readFileSync ( packagePath , 'utf8' ) ) ;
95+ const currentVersion = packageJson . version ;
96+
8697 packageJson . version = newVersion ;
8798
8899 // Write updated package.json
89100 fs . writeFileSync ( packagePath , JSON . stringify ( packageJson , null , 2 ) + '\n' ) ;
90101
91102 log ( `\n✅ Version updated: ${ currentVersion } → ${ newVersion } ` , 'green' ) ;
92-
93- return newVersion ;
94103}
95104
96105async function getBuildMethod ( ) {
@@ -103,7 +112,7 @@ async function getBuildMethod() {
103112 return choice === '1' ? 'local' : 'github' ;
104113}
105114
106- async function buildLocally ( ) {
115+ async function buildLocally ( newVersion ) {
107116 log ( '\n🏗️ Local Build' , 'bright' ) ;
108117 log ( 'Which platform(s) to build for?' , 'cyan' ) ;
109118 console . log ( ' 1) macOS only' ) ;
@@ -112,6 +121,10 @@ async function buildLocally() {
112121
113122 const choice = await question ( '\nSelect (1-3): ' ) ;
114123
124+ // Write version to package.json before building
125+ log ( '\n📝 Updating package.json version...' , 'blue' ) ;
126+ writeVersionToPackage ( newVersion ) ;
127+
115128 log ( '\n🚀 Starting build...' , 'yellow' ) ;
116129
117130 try {
@@ -143,20 +156,57 @@ async function buildLocally() {
143156
144157async function getReleaseNotes ( ) {
145158 log ( '\n📝 Release Notes' , 'bright' ) ;
146- log ( 'Enter release notes (Markdown supported, including emojis)' , 'cyan' ) ;
147- log ( 'Type each line and press Enter. When done, type "DONE" on a new line:' , 'yellow' ) ;
159+ log ( 'Choose input method:' , 'cyan' ) ;
160+ console . log ( ' 1) Paste multi-line text (recommended)' ) ;
161+ console . log ( ' 2) Enter line by line manually' ) ;
148162
149- const lines = [ ] ;
163+ const choice = await question ( '\nSelect (1-2): ' ) ;
150164
151- while ( true ) {
152- const line = await question ( '' ) ;
153- if ( line . toUpperCase ( ) === 'DONE' ) {
154- break ;
165+ if ( choice === '2' ) {
166+ log ( '\nManual entry mode - type each line and press Enter. When done, type "DONE" on a new line:' , 'yellow' ) ;
167+ const lines = [ ] ;
168+
169+ while ( true ) {
170+ const line = await question ( '' ) ;
171+ if ( line . toUpperCase ( ) === 'DONE' ) {
172+ break ;
173+ }
174+ lines . push ( line ) ;
155175 }
156- lines . push ( line ) ;
176+
177+ return lines . join ( '\n' ) ;
157178 }
158179
159- return lines . join ( '\n' ) ;
180+ // Paste mode - temporarily close readline and use raw stdin
181+ log ( '\n📋 Paste Mode Active' , 'yellow' ) ;
182+ log ( 'Paste your release notes below and press Ctrl+D when finished:' , 'cyan' ) ;
183+ log ( '(The text will appear as you paste it)\n' , 'yellow' ) ;
184+
185+ // Close readline temporarily
186+ rl . pause ( ) ;
187+
188+ return new Promise ( ( resolve ) => {
189+ const chunks = [ ] ;
190+
191+ process . stdin . resume ( ) ;
192+ process . stdin . setEncoding ( 'utf8' ) ;
193+
194+ process . stdin . on ( 'data' , ( chunk ) => {
195+ chunks . push ( chunk ) ;
196+ } ) ;
197+
198+ process . stdin . on ( 'end' , ( ) => {
199+ const fullInput = chunks . join ( '' ) . trim ( ) ;
200+
201+ // Resume readline for future questions
202+ process . stdin . removeAllListeners ( 'data' ) ;
203+ process . stdin . removeAllListeners ( 'end' ) ;
204+ rl . resume ( ) ;
205+
206+ log ( '\n✅ Release notes captured!' , 'green' ) ;
207+ resolve ( fullInput ) ;
208+ } ) ;
209+ } ) ;
160210}
161211
162212async function buildViaGitHub ( version ) {
@@ -166,7 +216,11 @@ async function buildViaGitHub(version) {
166216 log ( '\n🚀 Preparing GitHub release...' , 'yellow' ) ;
167217
168218 try {
169- // Check for uncommitted changes
219+ // Write version to package.json before committing
220+ log ( '📝 Updating package.json version...' , 'blue' ) ;
221+ writeVersionToPackage ( version ) ;
222+
223+ // Check for uncommitted changes (including the version update)
170224 const status = execCommand ( 'git status --porcelain' , true ) ;
171225 if ( status ) {
172226 log ( 'Uncommitted changes detected. Committing...' , 'blue' ) ;
@@ -247,14 +301,14 @@ async function main() {
247301 // Get version increment type
248302 const incrementType = await getVersionIncrement ( ) ;
249303
250- // Update version
251- const newVersion = await updateVersion ( incrementType ) ;
304+ // Calculate new version (but don't write it yet)
305+ const { currentVersion , newVersion } = calculateNewVersion ( incrementType ) ;
252306
253307 // Get build method
254308 const buildMethod = await getBuildMethod ( ) ;
255309
256310 if ( buildMethod === 'local' ) {
257- await buildLocally ( ) ;
311+ await buildLocally ( newVersion ) ;
258312 log ( '\n✅ Done! Check the dist/ directory for build artifacts.' , 'green' ) ;
259313 } else {
260314 await buildViaGitHub ( newVersion ) ;
0 commit comments