File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,18 +105,28 @@ async function loadWorkspace(dir: string) {
105105 } ;
106106}
107107
108+ function fmtDate ( d : Date ) : string {
109+ // YYMMDD-HHMMSS: 20240919-140954
110+ const date = joinNumbers ( [ d . getFullYear ( ) , d . getMonth ( ) + 1 , d . getDate ( ) ] ) ;
111+ const time = joinNumbers ( [ d . getHours ( ) , d . getMinutes ( ) , d . getSeconds ( ) ] ) ;
112+ return `${ date } -${ time } ` ;
113+ }
114+
115+ function joinNumbers ( items : number [ ] ) : string {
116+ return items . map ( ( i ) => ( i + "" ) . padStart ( 2 , "0" ) ) . join ( "" ) ;
117+ }
118+
108119async function main ( ) {
109120 const workspace = await loadWorkspace ( process . cwd ( ) ) ;
110121
111122 const commit = await execaCommand ( "git rev-parse --short HEAD" ) . then ( ( r ) =>
112123 r . stdout . trim ( )
113124 ) ;
114- const date = Math . round ( Date . now ( ) / ( 1000 * 60 ) ) ;
115125
116126 for ( const pkg of workspace . packages . filter ( ( p ) => ! p . data . private ) ) {
117127 workspace . setVersion (
118128 pkg . data . name ,
119- `${ pkg . data . version } -${ date } .${ commit } `
129+ `${ pkg . data . version } -${ fmtDate ( new Date ( ) ) } .${ commit } `
120130 ) ;
121131 workspace . rename ( pkg . data . name , pkg . data . name + "-nightly" ) ;
122132 pkg . updateDeps ( ( dep ) => {
You can’t perform that action at this time.
0 commit comments