@@ -70,7 +70,7 @@ function formatCommits(commits, filter = (commit) => commit) {
7070async function generateLogs ( name , logs ) {
7171 const pkg = await readPackageJson ( name )
7272 const content = await readPackageFile ( name )
73- const result = updateChangelog ( content , pkg . version , logs [ name ] )
73+ const result = updateChangelog ( content , pkg . version , logs [ name . toLowerCase ( ) ] )
7474 await writePackageFile ( name , result )
7575
7676 return result
@@ -80,15 +80,17 @@ async function generateLogs(name, logs) {
8080 const moduleRegex = / ^ [ a - z ] { 1 , 10 } \( \w + \) .* / i
8181 try {
8282 // const commits = await getCommitsSince('d9acb96')
83- const commits = await getCommitsSinceLatestTag ( )
83+ const commitId = args . commit || args . C
84+ const getCommitLogs = ( ) => ( commitId ? getCommitsSince ( commitId ) : getCommitsSinceLatestTag ( ) )
85+ const commits = await getCommitLogs ( )
8486 const formattedCommits = formatCommits ( commits , ( commit ) => {
8587 return moduleRegex . test ( commit . message )
8688 } ) . reduce ( ( acc , commit ) => {
8789 if ( ! commit . package ) throw new Error ( 'No package found in commit message: ' + commit . message )
8890 if ( ! acc [ commit . package ] ) {
8991 acc [ commit . package ] = [ ]
9092 }
91- acc [ commit . package ] . push (
93+ acc [ commit . package . toLowerCase ( ) ] . push (
9294 `- ${ commit . text } ([${ commit . hash . slice ( 0 , 7 ) } ](https://github.com/Meqn/pipflow/commit/${
9395 commit . hash
9496 } ))`
@@ -109,8 +111,14 @@ async function generateLogs(name, logs) {
109111 for ( const name of args . _ ) {
110112 await generateLogs ( name , formattedCommits )
111113 }
114+
115+ if ( args . push ) {
116+ await git . add ( [ '*/*/package.json' , '*/*/CHANGELOG.md' ] )
117+ await git . commit ( 'Version Packages' )
118+ await git . push ( 'origin' , 'main' )
119+ }
112120 }
113121 } catch ( err ) {
114- console . error ( 'error:' , err . message )
122+ console . error ( err )
115123 }
116124} ) ( )
0 commit comments