1+ import jsonfile from "jsonfile" ;
2+ import moment from "moment" ;
3+ import simpleGit from "simple-git" ;
4+ import random from "random" ;
5+
6+ const path = "./data.json" ;
7+ const git = simpleGit ( ) ;
8+ const startDate = moment ( "2022-01-01" ) ;
9+ const endDate = moment ( "2022-12-31" ) ;
10+ const TARGET_TOTAL = 980 ;
11+
12+ const makeCommitsForDay = async ( date , commitsCount ) => {
13+ console . log ( `📅 Creating ${ commitsCount } commits for ${ date . format ( "YYYY-MM-DD" ) } ` ) ;
14+ for ( let i = 0 ; i < commitsCount ; i ++ ) {
15+ const commitDate = date . clone ( )
16+ . hour ( random . int ( 8 , 20 ) )
17+ . minute ( random . int ( 0 , 59 ) )
18+ . second ( random . int ( 0 , 59 ) ) ;
19+
20+ const data = { date : commitDate . format ( ) } ;
21+ await jsonfile . writeFile ( path , data ) ;
22+ await git . add ( path ) ;
23+ await git . commit ( `Commit on ${ commitDate . format ( ) } ` , { "--date" : commitDate . format ( ) } ) ;
24+ console . log ( `✅ Commit ${ i + 1 } /${ commitsCount } on ${ commitDate . format ( "YYYY-MM-DD HH:mm:ss" ) } ` ) ;
25+ }
26+ } ;
27+
28+ const run = async ( ) => {
29+ let totalCommits = 0 ;
30+ const allDays = [ ] ;
31+
32+ console . log ( "📊 Generating days for entire 2022..." ) ;
33+ for ( let date = startDate . clone ( ) ; date . isSameOrBefore ( endDate ) ; date . add ( 1 , "day" ) ) {
34+ allDays . push ( date . clone ( ) ) ;
35+ }
36+
37+ const commitsDistribution = {
38+ 0 : 95 , // Ιανουάριος
39+ 1 : 85 , // Φεβρουάριος
40+ 2 : 105 , // Μάρτιος
41+ 3 : 100 , // Απρίλιος
42+ 4 : 90 , // Μάιος
43+ 5 : 75 , // Ιούνιος
44+ 6 : 65 , // Ιούλιος
45+ 7 : 55 , // Αύγουστος
46+ 8 : 95 , // Σεπτέμβριος
47+ 9 : 100 , // Οκτώβριος
48+ 10 : 95 , // Νοέμβριος
49+ 11 : 80 // Δεκέμβριος
50+ } ;
51+
52+ console . log ( "🎯 Monthly distribution:" , commitsDistribution ) ;
53+
54+ for ( const month in commitsDistribution ) {
55+ const monthName = moment ( ) . month ( month ) . format ( "MMMM" ) ;
56+ console . log ( `\n🌙 Starting month: ${ monthName } ` ) ;
57+
58+ let monthCommitsLeft = commitsDistribution [ month ] ;
59+ const daysInMonth = allDays . filter ( d => d . month ( ) === parseInt ( month ) ) ;
60+ const activeDays = daysInMonth . filter ( ( ) => random . bool ( 0.70 ) ) ;
61+
62+ console . log ( `📅 ${ activeDays . length } active days in ${ monthName } ` ) ;
63+
64+ for ( let i = 0 ; i < activeDays . length ; i ++ ) {
65+ if ( monthCommitsLeft <= 0 ) {
66+ console . log ( `⚡ Month ${ monthName } target reached!` ) ;
67+ break ;
68+ }
69+
70+ const date = activeDays [ i ] ;
71+ const isWeekend = [ 0 , 6 ] . includes ( date . day ( ) ) ;
72+ const isSummer = [ 5 , 6 , 7 ] . includes ( date . month ( ) ) ;
73+ const isWinterHolidays = ( date . month ( ) === 11 && date . date ( ) >= 20 ) || ( date . month ( ) === 0 && date . date ( ) <= 10 ) ;
74+
75+ let commitsForDay ;
76+
77+ if ( isSummer ) {
78+ if ( isWeekend ) {
79+ commitsForDay = random . int ( 0 , 1 ) ;
80+ console . log ( `🏖️ Summer weekend: ${ commitsForDay } commits` ) ;
81+ } else {
82+ if ( Math . random ( ) < 0.8 ) {
83+ commitsForDay = random . int ( 1 , 2 ) ;
84+ console . log ( `☀️ Summer workday (low): ${ commitsForDay } commits` ) ;
85+ } else {
86+ commitsForDay = random . int ( 2 , 4 ) ;
87+ console . log ( `☀️ Summer workday (high): ${ commitsForDay } commits` ) ;
88+ }
89+ }
90+ } else if ( isWinterHolidays ) {
91+ commitsForDay = random . int ( 0 , 1 ) ;
92+ console . log ( `🎄 Winter holidays: ${ commitsForDay } commits` ) ;
93+ } else if ( isWeekend ) {
94+ if ( Math . random ( ) < 0.6 ) {
95+ commitsForDay = random . int ( 0 , 1 ) ;
96+ console . log ( `😴 Weekend rest: ${ commitsForDay } commits` ) ;
97+ } else {
98+ commitsForDay = random . int ( 1 , 3 ) ;
99+ console . log ( `📚 Weekend work: ${ commitsForDay } commits` ) ;
100+ }
101+ } else {
102+ const rand = Math . random ( ) ;
103+ if ( rand < 0.3 ) {
104+ commitsForDay = random . int ( 1 , 3 ) ;
105+ console . log ( `📉 Low activity day: ${ commitsForDay } commits` ) ;
106+ } else if ( rand < 0.7 ) {
107+ commitsForDay = random . int ( 3 , 6 ) ;
108+ console . log ( `📊 Normal day: ${ commitsForDay } commits` ) ;
109+ } else {
110+ commitsForDay = random . int ( 6 , 10 ) ;
111+ console . log ( `🚀 High activity day: ${ commitsForDay } commits` ) ;
112+ }
113+ }
114+
115+ commitsForDay = Math . min ( commitsForDay , monthCommitsLeft ) ;
116+ if ( commitsForDay > 0 ) {
117+ monthCommitsLeft -= commitsForDay ;
118+ await makeCommitsForDay ( date , commitsForDay ) ;
119+ totalCommits += commitsForDay ;
120+
121+ console . log ( `📈 ${ date . format ( "YYYY-MM-DD" ) } : ${ commitsForDay } commits | Month left: ${ monthCommitsLeft } | Total: ${ totalCommits } ` ) ;
122+ }
123+
124+ // Κάνε push ΚΑΘΕ Κυριακή για ανέβασμα όλων των αλλαγών
125+ if ( date . day ( ) === 0 ) {
126+ console . log ( `🔄 Sunday push - uploading all changes from week ${ date . week ( ) } to GitHub...` ) ;
127+ await git . push ( "origin" , "main" ) ;
128+ console . log ( `✅ Weekly contribution graph updated for ${ date . format ( "YYYY-MM-DD" ) } ` ) ;
129+ }
130+ }
131+
132+ console . log ( `🎉 Month ${ monthName } completed: ${ commitsDistribution [ month ] - monthCommitsLeft } commits` ) ;
133+ }
134+
135+ console . log ( `\n🚀 Final push to GitHub...` ) ;
136+ await git . push ( "origin" , "main" ) ;
137+ console . log ( `🎊 FINISHED!` ) ;
138+ console . log ( `📊 Total commits made: ${ totalCommits } ` ) ;
139+ console . log ( `🎯 Target was: ${ TARGET_TOTAL } ` ) ;
140+ console . log ( `📈 Difference: ${ totalCommits - TARGET_TOTAL } ` ) ;
141+ } ;
142+
143+ run ( ) . catch ( console . error ) ;
0 commit comments