1- #!/usr/bin/env node
1+ #!/usr/bin/env bun
22
3- const { execSync } = require ( 'child_process' )
4- const fs = require ( 'fs' )
5- const path = require ( 'path' )
6- const readline = require ( 'readline' )
3+ import { execSync } from 'child_process'
4+ import fs from 'fs'
5+ import path from 'path'
6+ import readline from 'readline'
77
8- const packageJson = require ( '../package.json' )
8+ const packageJson = JSON . parse ( fs . readFileSync ( path . resolve ( __dirname , '../package.json' ) , 'utf8' ) )
99
1010const PROJECT_PATH = path . resolve ( __dirname , '../' )
1111const ACTIONS_URL = 'https://github.com/N-Flow/' + packageJson . name + '/actions'
1212
13- function checkPackageJson ( projectPath ) {
13+ function checkPackageJson ( projectPath : string ) : void {
1414 if ( ! fs . existsSync ( path . join ( projectPath , 'package.json' ) ) ) {
1515 console . error ( `package.json file not found in ${ projectPath } ` )
1616 process . exit ( 1 )
1717 }
1818}
1919
20- function getCurrentVersion ( projectPath ) {
21- const packageJson = require ( path . join ( projectPath , 'package.json' ) )
20+ function getCurrentVersion ( projectPath : string ) : string {
21+ const packageJson = JSON . parse ( fs . readFileSync ( path . join ( projectPath , 'package.json' ) , 'utf8 ') )
2222 return packageJson . version
2323}
2424
25- function updateVersion ( projectPath , newVersion ) {
25+ function updateVersion ( projectPath : string , newVersion : string ) : void {
2626 const packageJsonPath = path . join ( projectPath , 'package.json' )
2727 const packageLockPath = path . join ( projectPath , 'package-lock.json' )
2828
@@ -37,7 +37,7 @@ function updateVersion(projectPath, newVersion) {
3737 }
3838}
3939
40- function executeGitCommit ( projectPath , commitMessage ) {
40+ function executeGitCommit ( projectPath : string , commitMessage : string ) : void {
4141 try {
4242 execSync ( 'git add .' , { cwd : projectPath , stdio : 'inherit' } )
4343 execSync ( `git commit -m "${ commitMessage } "` , { cwd : projectPath , stdio : 'inherit' } )
@@ -47,7 +47,7 @@ function executeGitCommit(projectPath, commitMessage) {
4747 }
4848}
4949
50- function createGitTag ( projectPath , version ) {
50+ function createGitTag ( projectPath : string , version : string ) : void {
5151 try {
5252 execSync ( `git tag v${ version } ` , { cwd : projectPath , stdio : 'inherit' } )
5353 } catch ( error ) {
@@ -56,7 +56,7 @@ function createGitTag(projectPath, version) {
5656 }
5757}
5858
59- function executeGitPush ( projectPath ) {
59+ function executeGitPush ( projectPath : string ) : void {
6060 try {
6161 execSync ( 'git push --follow-tags' , { cwd : projectPath , stdio : 'inherit' } )
6262 } catch ( error ) {
@@ -65,7 +65,7 @@ function executeGitPush(projectPath) {
6565 }
6666}
6767
68- function getCommitMessage ( ) {
68+ function getCommitMessage ( ) : Promise < string > {
6969 return new Promise ( ( resolve ) => {
7070 const rl = readline . createInterface ( {
7171 input : process . stdin ,
@@ -84,7 +84,7 @@ function getCommitMessage() {
8484 } )
8585}
8686
87- function executeBuild ( projectPath ) {
87+ function executeBuild ( projectPath : string ) : void {
8888 try {
8989 console . log ( `\nBuilding project...` )
9090 execSync ( 'npm run build' , { cwd : projectPath , stdio : 'inherit' } )
@@ -94,14 +94,14 @@ function executeBuild(projectPath) {
9494 }
9595}
9696
97- function executePublish ( projectPath ) {
97+ function executePublish ( projectPath : string ) : void {
9898 try {
9999 console . log ( `\nPublishing package...` )
100100 execSync ( 'npm publish' , { cwd : projectPath , stdio : 'inherit' } )
101101 } catch ( error ) { }
102102}
103103
104- function incrementVersion ( version ) {
104+ function incrementVersion ( version : string ) : string {
105105 const parts = version . split ( '.' )
106106 const patch = parseInt ( parts [ 2 ] , 10 ) + 1
107107 return `${ parts [ 0 ] } .${ parts [ 1 ] } .${ patch } `
0 commit comments