repo-wrapped 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/commands/generate.js +104 -95
  2. package/dist/constants/chronotypes.js +23 -23
  3. package/dist/constants/colors.js +18 -18
  4. package/dist/constants/index.js +18 -18
  5. package/dist/formatters/index.js +17 -17
  6. package/dist/formatters/timeFormatter.js +28 -29
  7. package/dist/generators/html/templates/achievementsSection.js +42 -43
  8. package/dist/generators/html/templates/commitQualitySection.js +25 -26
  9. package/dist/generators/html/templates/contributionGraph.js +47 -48
  10. package/dist/generators/html/templates/impactSection.js +19 -20
  11. package/dist/generators/html/templates/knowledgeSection.js +86 -87
  12. package/dist/generators/html/templates/streakSection.js +8 -9
  13. package/dist/generators/html/templates/timePatternsSection.js +45 -46
  14. package/dist/generators/html/utils/colorUtils.js +21 -21
  15. package/dist/generators/html/utils/commitMapBuilder.js +23 -24
  16. package/dist/generators/html/utils/dateRangeCalculator.js +56 -57
  17. package/dist/generators/html/utils/developerStatsCalculator.js +28 -29
  18. package/dist/generators/html/utils/scriptLoader.js +15 -16
  19. package/dist/generators/html/utils/styleLoader.js +17 -18
  20. package/dist/generators/html/utils/weekGrouper.js +27 -28
  21. package/dist/index.js +78 -78
  22. package/dist/types/index.js +2 -2
  23. package/dist/utils/achievementDefinitions.js +433 -433
  24. package/dist/utils/achievementEngine.js +169 -170
  25. package/dist/utils/commitQualityAnalyzer.js +367 -368
  26. package/dist/utils/fileHotspotAnalyzer.js +269 -270
  27. package/dist/utils/gitParser.js +136 -126
  28. package/dist/utils/htmlGenerator.js +232 -233
  29. package/dist/utils/impactAnalyzer.js +247 -248
  30. package/dist/utils/knowledgeDistributionAnalyzer.js +373 -374
  31. package/dist/utils/matrixGenerator.js +349 -350
  32. package/dist/utils/slideGenerator.js +170 -171
  33. package/dist/utils/streakCalculator.js +134 -135
  34. package/dist/utils/timePatternAnalyzer.js +304 -305
  35. package/dist/utils/wrappedDisplay.js +124 -115
  36. package/dist/utils/wrappedGenerator.js +376 -377
  37. package/dist/utils/wrappedHtmlGenerator.js +105 -106
  38. package/package.json +10 -10
@@ -1,170 +1,169 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNextMilestone = exports.getAchievementsByCategory = exports.getRecentAchievements = exports.checkAchievements = void 0;
4
- const achievementDefinitions_1 = require("./achievementDefinitions");
5
- function checkAchievements(data) {
6
- // Create a deep copy of achievements to avoid mutation
7
- const achievements = achievementDefinitions_1.ACHIEVEMENTS.map(a => ({ ...a }));
8
- const newlyEarned = [];
9
- // Check each achievement
10
- for (const achievement of achievements) {
11
- if (!achievement.isUnlocked) {
12
- // Calculate progress
13
- achievement.progress = calculateProgress(achievement, data);
14
- // Check if criteria is met
15
- if (meetsCriteria(achievement, data)) {
16
- achievement.isUnlocked = true;
17
- achievement.earnedDate = new Date();
18
- newlyEarned.push(achievement);
19
- }
20
- }
21
- else {
22
- // Already unlocked, progress is 100
23
- achievement.progress = 100;
24
- }
25
- }
26
- // Check meta achievements (based on unlocked count)
27
- const unlockedCount = achievements.filter(a => a.isUnlocked && a.category !== 'meta').length;
28
- const metaAchievements = achievements.filter(a => a.category === 'meta');
29
- for (const metaAch of metaAchievements) {
30
- if (!metaAch.isUnlocked) {
31
- if (metaAch.id === 'collector' && unlockedCount >= 10) {
32
- metaAch.isUnlocked = true;
33
- metaAch.earnedDate = new Date();
34
- metaAch.progress = 100;
35
- newlyEarned.push(metaAch);
36
- }
37
- else if (metaAch.id === 'completionist' && unlockedCount >= 25) {
38
- metaAch.isUnlocked = true;
39
- metaAch.earnedDate = new Date();
40
- metaAch.progress = 100;
41
- newlyEarned.push(metaAch);
42
- }
43
- else if (metaAch.id === 'badge-king' && unlockedCount >= 50) {
44
- metaAch.isUnlocked = true;
45
- metaAch.earnedDate = new Date();
46
- metaAch.progress = 100;
47
- newlyEarned.push(metaAch);
48
- }
49
- else {
50
- // Calculate meta progress
51
- if (metaAch.id === 'collector') {
52
- metaAch.progress = Math.min(100, (unlockedCount / 10) * 100);
53
- }
54
- else if (metaAch.id === 'completionist') {
55
- metaAch.progress = Math.min(100, (unlockedCount / 25) * 100);
56
- }
57
- else if (metaAch.id === 'badge-king') {
58
- metaAch.progress = Math.min(100, (unlockedCount / 50) * 100);
59
- }
60
- }
61
- }
62
- }
63
- // Find next milestones (top 3 closest to unlocking)
64
- const lockedAchievements = achievements.filter(a => !a.isUnlocked);
65
- const nextMilestones = lockedAchievements
66
- .sort((a, b) => b.progress - a.progress)
67
- .slice(0, 3);
68
- const totalUnlocked = achievements.filter(a => a.isUnlocked).length;
69
- const completionPercentage = (totalUnlocked / achievements.length) * 100;
70
- return {
71
- achievements,
72
- unlockedCount: totalUnlocked,
73
- totalCount: achievements.length,
74
- recentlyEarned: newlyEarned,
75
- nextMilestones,
76
- completionPercentage
77
- };
78
- }
79
- exports.checkAchievements = checkAchievements;
80
- function meetsCriteria(achievement, data) {
81
- const { type, threshold, comparator, customCheck } = achievement.criteria;
82
- // Handle custom criteria
83
- if (customCheck) {
84
- return customCheck(data);
85
- }
86
- // Handle standard criteria
87
- if (threshold === undefined || comparator === undefined) {
88
- return false;
89
- }
90
- const value = extractValue(data, type);
91
- return compare(value, threshold, comparator);
92
- }
93
- function calculateProgress(achievement, data) {
94
- const { type, threshold, customCheck } = achievement.criteria;
95
- // Custom checks don't have numeric progress
96
- if (customCheck) {
97
- // Try to calculate progress for known patterns
98
- if (achievement.id === 'early-bird' || achievement.id === 'night-owl') {
99
- const isEarlyBird = achievement.id === 'early-bird';
100
- const targetCommits = data.commits.filter(c => {
101
- const hour = new Date(c.date).getHours();
102
- if (isEarlyBird) {
103
- return hour >= 5 && hour < 9;
104
- }
105
- else {
106
- return hour >= 21 || hour < 5;
107
- }
108
- }).length;
109
- return Math.min(100, (targetCommits / 50) * 100);
110
- }
111
- // For other custom checks, return 0 or 100
112
- return meetsCriteria(achievement, data) ? 100 : 0;
113
- }
114
- if (threshold === undefined) {
115
- return 0;
116
- }
117
- const current = extractValue(data, type);
118
- return Math.min(100, (current / threshold) * 100);
119
- }
120
- function extractValue(data, type) {
121
- switch (type) {
122
- case 'commit-count':
123
- return data.totalCommits;
124
- case 'streak':
125
- return data.streakData.longestStreak.days;
126
- case 'quality-score':
127
- return data.commitQuality.overallScore;
128
- default:
129
- return 0;
130
- }
131
- }
132
- function compare(value, threshold, comparator) {
133
- switch (comparator) {
134
- case '>=':
135
- return value >= threshold;
136
- case '>':
137
- return value > threshold;
138
- case '==':
139
- return value === threshold;
140
- case '<':
141
- return value < threshold;
142
- case '<=':
143
- return value <= threshold;
144
- default:
145
- return false;
146
- }
147
- }
148
- function getRecentAchievements(progress, days = 7) {
149
- const cutoffDate = new Date();
150
- cutoffDate.setDate(cutoffDate.getDate() - days);
151
- return progress.achievements
152
- .filter(a => a.isUnlocked && a.earnedDate && a.earnedDate >= cutoffDate)
153
- .sort((a, b) => {
154
- if (!a.earnedDate || !b.earnedDate)
155
- return 0;
156
- return b.earnedDate.getTime() - a.earnedDate.getTime();
157
- });
158
- }
159
- exports.getRecentAchievements = getRecentAchievements;
160
- function getAchievementsByCategory(progress, category) {
161
- return progress.achievements.filter(a => a.category === category);
162
- }
163
- exports.getAchievementsByCategory = getAchievementsByCategory;
164
- function getNextMilestone(progress) {
165
- const locked = progress.achievements.filter(a => !a.isUnlocked);
166
- if (locked.length === 0)
167
- return null;
168
- return locked.reduce((closest, current) => current.progress > closest.progress ? current : closest);
169
- }
170
- exports.getNextMilestone = getNextMilestone;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkAchievements = checkAchievements;
4
+ exports.getRecentAchievements = getRecentAchievements;
5
+ exports.getAchievementsByCategory = getAchievementsByCategory;
6
+ exports.getNextMilestone = getNextMilestone;
7
+ const achievementDefinitions_1 = require("./achievementDefinitions");
8
+ function checkAchievements(data) {
9
+ // Create a deep copy of achievements to avoid mutation
10
+ const achievements = achievementDefinitions_1.ACHIEVEMENTS.map(a => ({ ...a }));
11
+ const newlyEarned = [];
12
+ // Check each achievement
13
+ for (const achievement of achievements) {
14
+ if (!achievement.isUnlocked) {
15
+ // Calculate progress
16
+ achievement.progress = calculateProgress(achievement, data);
17
+ // Check if criteria is met
18
+ if (meetsCriteria(achievement, data)) {
19
+ achievement.isUnlocked = true;
20
+ achievement.earnedDate = new Date();
21
+ newlyEarned.push(achievement);
22
+ }
23
+ }
24
+ else {
25
+ // Already unlocked, progress is 100
26
+ achievement.progress = 100;
27
+ }
28
+ }
29
+ // Check meta achievements (based on unlocked count)
30
+ const unlockedCount = achievements.filter(a => a.isUnlocked && a.category !== 'meta').length;
31
+ const metaAchievements = achievements.filter(a => a.category === 'meta');
32
+ for (const metaAch of metaAchievements) {
33
+ if (!metaAch.isUnlocked) {
34
+ if (metaAch.id === 'collector' && unlockedCount >= 10) {
35
+ metaAch.isUnlocked = true;
36
+ metaAch.earnedDate = new Date();
37
+ metaAch.progress = 100;
38
+ newlyEarned.push(metaAch);
39
+ }
40
+ else if (metaAch.id === 'completionist' && unlockedCount >= 25) {
41
+ metaAch.isUnlocked = true;
42
+ metaAch.earnedDate = new Date();
43
+ metaAch.progress = 100;
44
+ newlyEarned.push(metaAch);
45
+ }
46
+ else if (metaAch.id === 'badge-king' && unlockedCount >= 50) {
47
+ metaAch.isUnlocked = true;
48
+ metaAch.earnedDate = new Date();
49
+ metaAch.progress = 100;
50
+ newlyEarned.push(metaAch);
51
+ }
52
+ else {
53
+ // Calculate meta progress
54
+ if (metaAch.id === 'collector') {
55
+ metaAch.progress = Math.min(100, (unlockedCount / 10) * 100);
56
+ }
57
+ else if (metaAch.id === 'completionist') {
58
+ metaAch.progress = Math.min(100, (unlockedCount / 25) * 100);
59
+ }
60
+ else if (metaAch.id === 'badge-king') {
61
+ metaAch.progress = Math.min(100, (unlockedCount / 50) * 100);
62
+ }
63
+ }
64
+ }
65
+ }
66
+ // Find next milestones (top 3 closest to unlocking)
67
+ const lockedAchievements = achievements.filter(a => !a.isUnlocked);
68
+ const nextMilestones = lockedAchievements
69
+ .sort((a, b) => b.progress - a.progress)
70
+ .slice(0, 3);
71
+ const totalUnlocked = achievements.filter(a => a.isUnlocked).length;
72
+ const completionPercentage = (totalUnlocked / achievements.length) * 100;
73
+ return {
74
+ achievements,
75
+ unlockedCount: totalUnlocked,
76
+ totalCount: achievements.length,
77
+ recentlyEarned: newlyEarned,
78
+ nextMilestones,
79
+ completionPercentage
80
+ };
81
+ }
82
+ function meetsCriteria(achievement, data) {
83
+ const { type, threshold, comparator, customCheck } = achievement.criteria;
84
+ // Handle custom criteria
85
+ if (customCheck) {
86
+ return customCheck(data);
87
+ }
88
+ // Handle standard criteria
89
+ if (threshold === undefined || comparator === undefined) {
90
+ return false;
91
+ }
92
+ const value = extractValue(data, type);
93
+ return compare(value, threshold, comparator);
94
+ }
95
+ function calculateProgress(achievement, data) {
96
+ const { type, threshold, customCheck } = achievement.criteria;
97
+ // Custom checks don't have numeric progress
98
+ if (customCheck) {
99
+ // Try to calculate progress for known patterns
100
+ if (achievement.id === 'early-bird' || achievement.id === 'night-owl') {
101
+ const isEarlyBird = achievement.id === 'early-bird';
102
+ const targetCommits = data.commits.filter(c => {
103
+ const hour = new Date(c.date).getHours();
104
+ if (isEarlyBird) {
105
+ return hour >= 5 && hour < 9;
106
+ }
107
+ else {
108
+ return hour >= 21 || hour < 5;
109
+ }
110
+ }).length;
111
+ return Math.min(100, (targetCommits / 50) * 100);
112
+ }
113
+ // For other custom checks, return 0 or 100
114
+ return meetsCriteria(achievement, data) ? 100 : 0;
115
+ }
116
+ if (threshold === undefined) {
117
+ return 0;
118
+ }
119
+ const current = extractValue(data, type);
120
+ return Math.min(100, (current / threshold) * 100);
121
+ }
122
+ function extractValue(data, type) {
123
+ switch (type) {
124
+ case 'commit-count':
125
+ return data.totalCommits;
126
+ case 'streak':
127
+ return data.streakData.longestStreak.days;
128
+ case 'quality-score':
129
+ return data.commitQuality.overallScore;
130
+ default:
131
+ return 0;
132
+ }
133
+ }
134
+ function compare(value, threshold, comparator) {
135
+ switch (comparator) {
136
+ case '>=':
137
+ return value >= threshold;
138
+ case '>':
139
+ return value > threshold;
140
+ case '==':
141
+ return value === threshold;
142
+ case '<':
143
+ return value < threshold;
144
+ case '<=':
145
+ return value <= threshold;
146
+ default:
147
+ return false;
148
+ }
149
+ }
150
+ function getRecentAchievements(progress, days = 7) {
151
+ const cutoffDate = new Date();
152
+ cutoffDate.setDate(cutoffDate.getDate() - days);
153
+ return progress.achievements
154
+ .filter(a => a.isUnlocked && a.earnedDate && a.earnedDate >= cutoffDate)
155
+ .sort((a, b) => {
156
+ if (!a.earnedDate || !b.earnedDate)
157
+ return 0;
158
+ return b.earnedDate.getTime() - a.earnedDate.getTime();
159
+ });
160
+ }
161
+ function getAchievementsByCategory(progress, category) {
162
+ return progress.achievements.filter(a => a.category === category);
163
+ }
164
+ function getNextMilestone(progress) {
165
+ const locked = progress.achievements.filter(a => !a.isUnlocked);
166
+ if (locked.length === 0)
167
+ return null;
168
+ return locked.reduce((closest, current) => current.progress > closest.progress ? current : closest);
169
+ }