git-slot-machine 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +313 -0
- package/dist/animation/slotMachine.d.ts +9 -0
- package/dist/animation/slotMachine.d.ts.map +1 -0
- package/dist/animation/slotMachine.js +139 -0
- package/dist/animation/slotMachine.js.map +1 -0
- package/dist/api.d.ts +40 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +154 -0
- package/dist/api.js.map +1 -0
- package/dist/balance.d.ts +11 -0
- package/dist/balance.d.ts.map +1 -0
- package/dist/balance.js +131 -0
- package/dist/balance.js.map +1 -0
- package/dist/commands/auth.d.ts +4 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +91 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/balance.d.ts +2 -0
- package/dist/commands/balance.d.ts.map +1 -0
- package/dist/commands/balance.js +32 -0
- package/dist/commands/balance.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +60 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +148 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/play.d.ts +7 -0
- package/dist/commands/play.d.ts.map +1 -0
- package/dist/commands/play.js +137 -0
- package/dist/commands/play.js.map +1 -0
- package/dist/commands/spin.d.ts +6 -0
- package/dist/commands/spin.d.ts.map +1 -0
- package/dist/commands/spin.js +17 -0
- package/dist/commands/spin.js.map +1 -0
- package/dist/commands/sync.d.ts +2 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +52 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/test.d.ts +6 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +17 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/config.d.ts +27 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +144 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/dist/patterns.d.ts +27 -0
- package/dist/patterns.d.ts.map +1 -0
- package/dist/patterns.js +266 -0
- package/dist/patterns.js.map +1 -0
- package/dist/templates/post-commit.d.ts +2 -0
- package/dist/templates/post-commit.d.ts.map +1 -0
- package/dist/templates/post-commit.js +19 -0
- package/dist/templates/post-commit.js.map +1 -0
- package/dist/utils/git.d.ts +4 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +42 -0
- package/dist/utils/git.js.map +1 -0
- package/jest.config.js +12 -0
- package/package.json +50 -0
- package/src/animation/slotMachine.ts +159 -0
- package/src/api.ts +203 -0
- package/src/balance.ts +118 -0
- package/src/commands/auth.ts +92 -0
- package/src/commands/balance.ts +28 -0
- package/src/commands/config.ts +59 -0
- package/src/commands/init.ts +121 -0
- package/src/commands/play.ts +150 -0
- package/src/commands/spin.ts +17 -0
- package/src/commands/sync.ts +49 -0
- package/src/commands/test.ts +19 -0
- package/src/config.ts +154 -0
- package/src/index.ts +114 -0
- package/src/patterns.test.ts +44 -0
- package/src/patterns.ts +292 -0
- package/src/templates/post-commit.ts +15 -0
- package/src/utils/git.ts +38 -0
- package/test.txt +2 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const play_1 = require("./commands/play");
|
|
6
|
+
const spin_1 = require("./commands/spin");
|
|
7
|
+
const init_1 = require("./commands/init");
|
|
8
|
+
const balance_1 = require("./commands/balance");
|
|
9
|
+
const test_1 = require("./commands/test");
|
|
10
|
+
const auth_1 = require("./commands/auth");
|
|
11
|
+
const sync_1 = require("./commands/sync");
|
|
12
|
+
const config_1 = require("./commands/config");
|
|
13
|
+
const program = new commander_1.Command();
|
|
14
|
+
program
|
|
15
|
+
.name('git-slot-machine')
|
|
16
|
+
.description('Git commit hash slot machine')
|
|
17
|
+
.version('0.1.0');
|
|
18
|
+
program
|
|
19
|
+
.command('play')
|
|
20
|
+
.description('Play the slot machine with a git hash')
|
|
21
|
+
.argument('<hash>', '7-character git commit hash')
|
|
22
|
+
.option('-s, --small', 'Single line output')
|
|
23
|
+
.action(async (hash, options) => {
|
|
24
|
+
await (0, play_1.playCommand)(hash, options);
|
|
25
|
+
});
|
|
26
|
+
program
|
|
27
|
+
.command('spin')
|
|
28
|
+
.description('Play with the current git commit hash')
|
|
29
|
+
.option('-s, --small', 'Single line output')
|
|
30
|
+
.action(async (options) => {
|
|
31
|
+
await (0, spin_1.spinCommand)(options);
|
|
32
|
+
});
|
|
33
|
+
program
|
|
34
|
+
.command('init')
|
|
35
|
+
.description('Install post-commit hook in current repository')
|
|
36
|
+
.action(async () => {
|
|
37
|
+
await (0, init_1.initCommand)();
|
|
38
|
+
});
|
|
39
|
+
program
|
|
40
|
+
.command('balance')
|
|
41
|
+
.description('Show current repository balance and stats')
|
|
42
|
+
.action(balance_1.balanceCommand);
|
|
43
|
+
program
|
|
44
|
+
.command('test')
|
|
45
|
+
.description('Play with a random 7-character hash')
|
|
46
|
+
.option('-s, --small', 'Single line output')
|
|
47
|
+
.action(async (options) => {
|
|
48
|
+
await (0, test_1.testCommand)(options);
|
|
49
|
+
});
|
|
50
|
+
// Auth commands
|
|
51
|
+
const auth = program
|
|
52
|
+
.command('auth')
|
|
53
|
+
.description('Manage API authentication');
|
|
54
|
+
auth
|
|
55
|
+
.command('login')
|
|
56
|
+
.description('Login with GitHub username')
|
|
57
|
+
.argument('<github-username>', 'Your GitHub username')
|
|
58
|
+
.action(async (githubUsername) => {
|
|
59
|
+
await (0, auth_1.authLoginCommand)(githubUsername);
|
|
60
|
+
});
|
|
61
|
+
auth
|
|
62
|
+
.command('logout')
|
|
63
|
+
.description('Logout and clear API token')
|
|
64
|
+
.action(async () => {
|
|
65
|
+
await (0, auth_1.authLogoutCommand)();
|
|
66
|
+
});
|
|
67
|
+
auth
|
|
68
|
+
.command('status')
|
|
69
|
+
.description('Show authentication status')
|
|
70
|
+
.action(async () => {
|
|
71
|
+
await (0, auth_1.authStatusCommand)();
|
|
72
|
+
});
|
|
73
|
+
// Sync command
|
|
74
|
+
program
|
|
75
|
+
.command('sync')
|
|
76
|
+
.description('Sync balance with API')
|
|
77
|
+
.action(async () => {
|
|
78
|
+
await (0, sync_1.syncCommand)();
|
|
79
|
+
});
|
|
80
|
+
// Config commands
|
|
81
|
+
const config = program
|
|
82
|
+
.command('config')
|
|
83
|
+
.description('Manage CLI configuration');
|
|
84
|
+
config
|
|
85
|
+
.command('get')
|
|
86
|
+
.description('Get configuration value')
|
|
87
|
+
.argument('<key>', 'Configuration key (api-url, sync-enabled, all)')
|
|
88
|
+
.action(async (key) => {
|
|
89
|
+
await (0, config_1.configGetCommand)(key);
|
|
90
|
+
});
|
|
91
|
+
config
|
|
92
|
+
.command('set')
|
|
93
|
+
.description('Set configuration value')
|
|
94
|
+
.argument('<key>', 'Configuration key (api-url, sync-enabled)')
|
|
95
|
+
.argument('<value>', 'Configuration value')
|
|
96
|
+
.action(async (key, value) => {
|
|
97
|
+
await (0, config_1.configSetCommand)(key, value);
|
|
98
|
+
});
|
|
99
|
+
program.parse();
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,yCAAoC;AACpC,0CAA8C;AAC9C,0CAA8C;AAC9C,0CAA8C;A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C,KAAK,EAAE,GAAW,EAAE,EAAE;IAC5B,MAAM,IAAA,yBAAgB,EAAC,GAAG,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEL,MAAM;KACH,OAAO,CAAC,KAAK,CAAC;KACd,WAAW,CAAC,yBAAyB,CAAC;KACtC,QAAQ,CAAC,OAAO,EAAE,2CAA2C,CAAC;KAC9D,QAAQ,CAAC,SAAS,EAAE,qBAAqB,CAAC;KAC1C,MAAM,CAAC,KAAK,EAAE,GAAW,EAAE,KAAa,EAAE,EAAE;IAC3C,MAAM,IAAA,yBAAgB,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare enum PatternType {
|
|
2
|
+
ALL_SAME = "ALL_SAME",
|
|
3
|
+
SIX_OF_KIND = "SIX_OF_KIND",
|
|
4
|
+
STRAIGHT_7 = "STRAIGHT_7",
|
|
5
|
+
FULLEST_HOUSE = "FULLEST_HOUSE",// 4-3
|
|
6
|
+
FIVE_OF_KIND = "FIVE_OF_KIND",
|
|
7
|
+
STRAIGHT_6 = "STRAIGHT_6",
|
|
8
|
+
FOUR_OF_KIND = "FOUR_OF_KIND",
|
|
9
|
+
ALL_LETTERS = "ALL_LETTERS",
|
|
10
|
+
STRAIGHT_5 = "STRAIGHT_5",
|
|
11
|
+
THREE_OF_KIND_PLUS_THREE = "THREE_OF_KIND_PLUS_THREE",// 3-3-1
|
|
12
|
+
FULL_HOUSE = "FULL_HOUSE",// 4-2-1 or 3-2-2
|
|
13
|
+
THREE_PAIR = "THREE_PAIR",
|
|
14
|
+
THREE_OF_KIND = "THREE_OF_KIND",
|
|
15
|
+
TWO_PAIR = "TWO_PAIR",
|
|
16
|
+
ALL_NUMBERS = "ALL_NUMBERS",
|
|
17
|
+
NO_WIN = "NO_WIN"
|
|
18
|
+
}
|
|
19
|
+
export interface PatternResult {
|
|
20
|
+
type: PatternType;
|
|
21
|
+
name: string;
|
|
22
|
+
payout: number;
|
|
23
|
+
description: string;
|
|
24
|
+
highlightIndices: number[];
|
|
25
|
+
}
|
|
26
|
+
export declare function detectPattern(hash: string): PatternResult;
|
|
27
|
+
//# sourceMappingURL=patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../src/patterns.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACrB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,UAAU,eAAe;IACzB,aAAa,kBAAkB,CAAE,MAAM;IACvC,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,WAAW,gBAAgB;IAC3B,UAAU,eAAe;IACzB,wBAAwB,6BAA6B,CAAE,QAAQ;IAC/D,UAAU,eAAe,CAAE,iBAAiB;IAC5C,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAiLD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAyFzD"}
|
package/dist/patterns.js
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PatternType = void 0;
|
|
4
|
+
exports.detectPattern = detectPattern;
|
|
5
|
+
var PatternType;
|
|
6
|
+
(function (PatternType) {
|
|
7
|
+
PatternType["ALL_SAME"] = "ALL_SAME";
|
|
8
|
+
PatternType["SIX_OF_KIND"] = "SIX_OF_KIND";
|
|
9
|
+
PatternType["STRAIGHT_7"] = "STRAIGHT_7";
|
|
10
|
+
PatternType["FULLEST_HOUSE"] = "FULLEST_HOUSE";
|
|
11
|
+
PatternType["FIVE_OF_KIND"] = "FIVE_OF_KIND";
|
|
12
|
+
PatternType["STRAIGHT_6"] = "STRAIGHT_6";
|
|
13
|
+
PatternType["FOUR_OF_KIND"] = "FOUR_OF_KIND";
|
|
14
|
+
PatternType["ALL_LETTERS"] = "ALL_LETTERS";
|
|
15
|
+
PatternType["STRAIGHT_5"] = "STRAIGHT_5";
|
|
16
|
+
PatternType["THREE_OF_KIND_PLUS_THREE"] = "THREE_OF_KIND_PLUS_THREE";
|
|
17
|
+
PatternType["FULL_HOUSE"] = "FULL_HOUSE";
|
|
18
|
+
PatternType["THREE_PAIR"] = "THREE_PAIR";
|
|
19
|
+
PatternType["THREE_OF_KIND"] = "THREE_OF_KIND";
|
|
20
|
+
PatternType["TWO_PAIR"] = "TWO_PAIR";
|
|
21
|
+
PatternType["ALL_NUMBERS"] = "ALL_NUMBERS";
|
|
22
|
+
PatternType["NO_WIN"] = "NO_WIN";
|
|
23
|
+
})(PatternType || (exports.PatternType = PatternType = {}));
|
|
24
|
+
const PAYOUTS = {
|
|
25
|
+
[PatternType.ALL_SAME]: { name: 'JACKPOT', payout: 10000, description: 'All same character' },
|
|
26
|
+
[PatternType.SIX_OF_KIND]: { name: 'HEXTET', payout: 5000, description: 'Six of a kind' },
|
|
27
|
+
[PatternType.STRAIGHT_7]: { name: 'LUCKY SEVEN', payout: 2500, description: 'Seven in a row' },
|
|
28
|
+
[PatternType.FULLEST_HOUSE]: { name: 'FULLEST HOUSE', payout: 2000, description: '4 + 3 of a kind' },
|
|
29
|
+
[PatternType.FIVE_OF_KIND]: { name: 'FIVE OF A KIND', payout: 1000, description: 'Five of a kind' },
|
|
30
|
+
[PatternType.STRAIGHT_6]: { name: 'BIG STRAIGHT', payout: 500, description: 'Six in a row' },
|
|
31
|
+
[PatternType.FOUR_OF_KIND]: { name: 'FOUR OF A KIND', payout: 400, description: 'Four of a kind' },
|
|
32
|
+
[PatternType.ALL_LETTERS]: { name: 'ALL LETTERS', payout: 300, description: 'Only letters (a-f)' },
|
|
33
|
+
[PatternType.STRAIGHT_5]: { name: 'STRAIGHT', payout: 200, description: 'Five in a row' },
|
|
34
|
+
[PatternType.THREE_OF_KIND_PLUS_THREE]: { name: 'DOUBLE TRIPLE', payout: 150, description: 'Two three of a kinds' },
|
|
35
|
+
[PatternType.FULL_HOUSE]: { name: 'FULL HOUSE', payout: 100, description: 'Three and two of a kind' },
|
|
36
|
+
[PatternType.THREE_PAIR]: { name: 'THREE PAIR', payout: 150, description: 'Three pairs' },
|
|
37
|
+
[PatternType.THREE_OF_KIND]: { name: 'THREE OF A KIND', payout: 50, description: 'Three of a kind' },
|
|
38
|
+
[PatternType.TWO_PAIR]: { name: 'TWO PAIR', payout: 50, description: 'Two pairs' },
|
|
39
|
+
[PatternType.ALL_NUMBERS]: { name: 'ALL NUMBERS', payout: 10, description: 'Only numbers (0-9)' },
|
|
40
|
+
[PatternType.NO_WIN]: { name: 'NO WIN', payout: 0, description: 'No winning pattern' }
|
|
41
|
+
};
|
|
42
|
+
function countCharacters(hash) {
|
|
43
|
+
const counts = new Map();
|
|
44
|
+
for (const char of hash) {
|
|
45
|
+
counts.set(char, (counts.get(char) || 0) + 1);
|
|
46
|
+
}
|
|
47
|
+
return counts;
|
|
48
|
+
}
|
|
49
|
+
function getCountDistribution(counts) {
|
|
50
|
+
return Array.from(counts.values()).sort((a, b) => b - a);
|
|
51
|
+
}
|
|
52
|
+
function hasSequentialRun(hash, length) {
|
|
53
|
+
const hexValues = '0123456789abcdef';
|
|
54
|
+
for (let i = 0; i <= hash.length - length; i++) {
|
|
55
|
+
const substring = hash.substring(i, i + length);
|
|
56
|
+
// Check ascending
|
|
57
|
+
let isAscending = true;
|
|
58
|
+
for (let j = 0; j < substring.length - 1; j++) {
|
|
59
|
+
const currentIndex = hexValues.indexOf(substring[j]);
|
|
60
|
+
const nextIndex = hexValues.indexOf(substring[j + 1]);
|
|
61
|
+
if (nextIndex !== currentIndex + 1) {
|
|
62
|
+
isAscending = false;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (isAscending)
|
|
67
|
+
return true;
|
|
68
|
+
// Check descending
|
|
69
|
+
let isDescending = true;
|
|
70
|
+
for (let j = 0; j < substring.length - 1; j++) {
|
|
71
|
+
const currentIndex = hexValues.indexOf(substring[j]);
|
|
72
|
+
const nextIndex = hexValues.indexOf(substring[j + 1]);
|
|
73
|
+
if (nextIndex !== currentIndex - 1) {
|
|
74
|
+
isDescending = false;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (isDescending)
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
function isAllLetters(hash) {
|
|
84
|
+
return /^[a-f]+$/i.test(hash);
|
|
85
|
+
}
|
|
86
|
+
function isAllNumbers(hash) {
|
|
87
|
+
return /^[0-9]+$/.test(hash);
|
|
88
|
+
}
|
|
89
|
+
function countConsecutivePairs(hash) {
|
|
90
|
+
// Count pairs of consecutive identical characters (e.g., "33" or "bb")
|
|
91
|
+
let pairCount = 0;
|
|
92
|
+
let i = 0;
|
|
93
|
+
while (i < hash.length - 1) {
|
|
94
|
+
if (hash[i] === hash[i + 1]) {
|
|
95
|
+
pairCount++;
|
|
96
|
+
i += 2; // Skip both characters of the pair
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
i++;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return pairCount;
|
|
103
|
+
}
|
|
104
|
+
function getHighlightIndices(hash, type) {
|
|
105
|
+
const lowerHash = hash.toLowerCase();
|
|
106
|
+
// For straights, highlight all characters in the sequential run
|
|
107
|
+
if (type === PatternType.STRAIGHT_7 || type === PatternType.STRAIGHT_6 || type === PatternType.STRAIGHT_5) {
|
|
108
|
+
const length = type === PatternType.STRAIGHT_7 ? 7 : type === PatternType.STRAIGHT_6 ? 6 : 5;
|
|
109
|
+
const hexValues = '0123456789abcdef';
|
|
110
|
+
for (let i = 0; i <= lowerHash.length - length; i++) {
|
|
111
|
+
const substring = lowerHash.substring(i, i + length);
|
|
112
|
+
let isSequential = true;
|
|
113
|
+
// Check ascending
|
|
114
|
+
for (let j = 0; j < substring.length - 1; j++) {
|
|
115
|
+
const currentIndex = hexValues.indexOf(substring[j]);
|
|
116
|
+
const nextIndex = hexValues.indexOf(substring[j + 1]);
|
|
117
|
+
if (nextIndex !== currentIndex + 1 && nextIndex !== currentIndex - 1) {
|
|
118
|
+
isSequential = false;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (isSequential) {
|
|
123
|
+
return Array.from({ length }, (_, idx) => i + idx);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// For all letters or all numbers, highlight everything
|
|
128
|
+
if (type === PatternType.ALL_LETTERS || type === PatternType.ALL_NUMBERS || type === PatternType.ALL_SAME) {
|
|
129
|
+
return [0, 1, 2, 3, 4, 5, 6];
|
|
130
|
+
}
|
|
131
|
+
// For frequency-based patterns, highlight characters that appear in the pattern
|
|
132
|
+
const counts = countCharacters(lowerHash);
|
|
133
|
+
const indices = [];
|
|
134
|
+
if (type === PatternType.SIX_OF_KIND || type === PatternType.FIVE_OF_KIND ||
|
|
135
|
+
type === PatternType.FOUR_OF_KIND || type === PatternType.THREE_OF_KIND) {
|
|
136
|
+
// Find the character with the highest count and highlight all occurrences
|
|
137
|
+
const targetCount = type === PatternType.SIX_OF_KIND ? 6 :
|
|
138
|
+
type === PatternType.FIVE_OF_KIND ? 5 :
|
|
139
|
+
type === PatternType.FOUR_OF_KIND ? 4 : 3;
|
|
140
|
+
for (const [char, count] of counts.entries()) {
|
|
141
|
+
if (count === targetCount) {
|
|
142
|
+
for (let i = 0; i < lowerHash.length; i++) {
|
|
143
|
+
if (lowerHash[i] === char) {
|
|
144
|
+
indices.push(i);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else if (type === PatternType.FULLEST_HOUSE || type === PatternType.FULL_HOUSE ||
|
|
152
|
+
type === PatternType.THREE_OF_KIND_PLUS_THREE) {
|
|
153
|
+
// Highlight all paired/tripled characters
|
|
154
|
+
for (const [char, count] of counts.entries()) {
|
|
155
|
+
if (count >= 2) {
|
|
156
|
+
for (let i = 0; i < lowerHash.length; i++) {
|
|
157
|
+
if (lowerHash[i] === char) {
|
|
158
|
+
indices.push(i);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else if (type === PatternType.THREE_PAIR || type === PatternType.TWO_PAIR) {
|
|
165
|
+
// Highlight consecutive pairs only (e.g., "aa" and "bb" in "aa1bb2c")
|
|
166
|
+
let i = 0;
|
|
167
|
+
while (i < lowerHash.length - 1) {
|
|
168
|
+
if (lowerHash[i] === lowerHash[i + 1]) {
|
|
169
|
+
indices.push(i);
|
|
170
|
+
indices.push(i + 1);
|
|
171
|
+
i += 2; // Skip both characters of the pair
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
i++;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return indices.sort((a, b) => a - b);
|
|
179
|
+
}
|
|
180
|
+
function detectPattern(hash) {
|
|
181
|
+
// Validate input
|
|
182
|
+
if (hash.length !== 7) {
|
|
183
|
+
throw new Error('Hash must be 7 characters');
|
|
184
|
+
}
|
|
185
|
+
if (!/^[0-9a-f]+$/i.test(hash)) {
|
|
186
|
+
throw new Error('Hash must contain only hex characters');
|
|
187
|
+
}
|
|
188
|
+
const lowerHash = hash.toLowerCase();
|
|
189
|
+
const counts = countCharacters(lowerHash);
|
|
190
|
+
const distribution = getCountDistribution(counts);
|
|
191
|
+
// Detect pattern - check in order of rarity/value
|
|
192
|
+
let type;
|
|
193
|
+
// Check for all same first (highest value)
|
|
194
|
+
if (distribution[0] === 7) {
|
|
195
|
+
type = PatternType.ALL_SAME;
|
|
196
|
+
}
|
|
197
|
+
// Check for 6 of a kind
|
|
198
|
+
else if (distribution[0] === 6) {
|
|
199
|
+
type = PatternType.SIX_OF_KIND;
|
|
200
|
+
}
|
|
201
|
+
// Check for straight 7 (very rare)
|
|
202
|
+
else if (hasSequentialRun(lowerHash, 7)) {
|
|
203
|
+
type = PatternType.STRAIGHT_7;
|
|
204
|
+
}
|
|
205
|
+
// Check for fullest house (4-3)
|
|
206
|
+
else if (distribution[0] === 4 && distribution[1] === 3) {
|
|
207
|
+
type = PatternType.FULLEST_HOUSE;
|
|
208
|
+
}
|
|
209
|
+
// Check for 5 of a kind
|
|
210
|
+
else if (distribution[0] === 5) {
|
|
211
|
+
type = PatternType.FIVE_OF_KIND;
|
|
212
|
+
}
|
|
213
|
+
// Check for straight 6
|
|
214
|
+
else if (hasSequentialRun(lowerHash, 6)) {
|
|
215
|
+
type = PatternType.STRAIGHT_6;
|
|
216
|
+
}
|
|
217
|
+
// Check for 4 of a kind
|
|
218
|
+
else if (distribution[0] === 4) {
|
|
219
|
+
type = PatternType.FOUR_OF_KIND;
|
|
220
|
+
}
|
|
221
|
+
// Check for all letters
|
|
222
|
+
else if (isAllLetters(lowerHash)) {
|
|
223
|
+
type = PatternType.ALL_LETTERS;
|
|
224
|
+
}
|
|
225
|
+
// Check for straight 5
|
|
226
|
+
else if (hasSequentialRun(lowerHash, 5)) {
|
|
227
|
+
type = PatternType.STRAIGHT_5;
|
|
228
|
+
}
|
|
229
|
+
// Check for double triple (3-3-1)
|
|
230
|
+
else if (distribution[0] === 3 && distribution[1] === 3) {
|
|
231
|
+
type = PatternType.THREE_OF_KIND_PLUS_THREE;
|
|
232
|
+
}
|
|
233
|
+
// Check for full house (3-2-2 or 3-2-1-1)
|
|
234
|
+
else if (distribution[0] === 3 && distribution[1] === 2) {
|
|
235
|
+
type = PatternType.FULL_HOUSE;
|
|
236
|
+
}
|
|
237
|
+
// Check for 3 of a kind
|
|
238
|
+
else if (distribution[0] === 3) {
|
|
239
|
+
type = PatternType.THREE_OF_KIND;
|
|
240
|
+
}
|
|
241
|
+
// Check for three consecutive pairs
|
|
242
|
+
else if (countConsecutivePairs(lowerHash) === 3) {
|
|
243
|
+
type = PatternType.THREE_PAIR;
|
|
244
|
+
}
|
|
245
|
+
// Check for two consecutive pairs
|
|
246
|
+
else if (countConsecutivePairs(lowerHash) === 2) {
|
|
247
|
+
type = PatternType.TWO_PAIR;
|
|
248
|
+
}
|
|
249
|
+
// Check for all numbers (break-even)
|
|
250
|
+
else if (isAllNumbers(lowerHash)) {
|
|
251
|
+
type = PatternType.ALL_NUMBERS;
|
|
252
|
+
}
|
|
253
|
+
// Everything else is no win (including one pair)
|
|
254
|
+
else {
|
|
255
|
+
type = PatternType.NO_WIN;
|
|
256
|
+
}
|
|
257
|
+
const config = PAYOUTS[type];
|
|
258
|
+
return {
|
|
259
|
+
type,
|
|
260
|
+
name: config.name,
|
|
261
|
+
payout: config.payout,
|
|
262
|
+
description: config.description,
|
|
263
|
+
highlightIndices: getHighlightIndices(hash, type)
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.js","sourceRoot":"","sources":["../src/patterns.ts"],"names":[],"mappings":";;;AA0MA,sCAyFC;AAnSD,IAAY,WAiBX;AAjBD,WAAY,WAAW;IACrB,oCAAqB,CAAA;IACrB,0CAA2B,CAAA;IAC3B,wCAAyB,CAAA;IACzB,8CAA+B,CAAA;IAC/B,4CAA6B,CAAA;IAC7B,wCAAyB,CAAA;IACzB,4CAA6B,CAAA;IAC7B,0CAA2B,CAAA;IAC3B,wCAAyB,CAAA;IACzB,oEAAqD,CAAA;IACrD,w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C5B,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO;QACL,IAAI;QACJ,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,gBAAgB,EAAE,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC;KAClD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const POST_COMMIT_HOOK = "#!/bin/sh\n# Git Slot Machine post-commit hook\n\n# Get the commit hash\nHASH=$(git rev-parse --short=7 HEAD)\n\n# Check if git-slot-machine is installed\nif command -v git-slot-machine >/dev/null 2>&1; then\n git-slot-machine play \"$HASH\" --small\nelif [ -f \"./node_modules/.bin/git-slot-machine\" ]; then\n ./node_modules/.bin/git-slot-machine play \"$HASH\" --small\nelse\n echo \"git-slot-machine not found, skipping animation\"\nfi\n";
|
|
2
|
+
//# sourceMappingURL=post-commit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-commit.d.ts","sourceRoot":"","sources":["../../src/templates/post-commit.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,icAc5B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.POST_COMMIT_HOOK = void 0;
|
|
4
|
+
exports.POST_COMMIT_HOOK = `#!/bin/sh
|
|
5
|
+
# Git Slot Machine post-commit hook
|
|
6
|
+
|
|
7
|
+
# Get the commit hash
|
|
8
|
+
HASH=$(git rev-parse --short=7 HEAD)
|
|
9
|
+
|
|
10
|
+
# Check if git-slot-machine is installed
|
|
11
|
+
if command -v git-slot-machine >/dev/null 2>&1; then
|
|
12
|
+
git-slot-machine play "$HASH" --small
|
|
13
|
+
elif [ -f "./node_modules/.bin/git-slot-machine" ]; then
|
|
14
|
+
./node_modules/.bin/git-slot-machine play "$HASH" --small
|
|
15
|
+
else
|
|
16
|
+
echo "git-slot-machine not found, skipping animation"
|
|
17
|
+
fi
|
|
18
|
+
`;
|
|
19
|
+
//# sourceMappingURL=post-commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"post-commit.js","sourceRoot":"","sources":["../../src/templates/post-commit.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG;;;;;;;;;;;;;;CAc/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAEA,wBAAgB,oBAAoB,IAAI,MAAM,CAW7C;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAWjD;AAED,wBAAgB,SAAS,IAAI,OAAO,CASnC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCurrentCommitHash = getCurrentCommitHash;
|
|
4
|
+
exports.getCurrentCommitFullHash = getCurrentCommitFullHash;
|
|
5
|
+
exports.isGitRepo = isGitRepo;
|
|
6
|
+
const child_process_1 = require("child_process");
|
|
7
|
+
function getCurrentCommitHash() {
|
|
8
|
+
try {
|
|
9
|
+
const fullHash = (0, child_process_1.execSync)('git rev-parse HEAD', {
|
|
10
|
+
encoding: 'utf-8',
|
|
11
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
12
|
+
}).trim();
|
|
13
|
+
return fullHash.substring(0, 7);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
throw new Error('Not a git repository or no commits yet');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function getCurrentCommitFullHash() {
|
|
20
|
+
try {
|
|
21
|
+
const fullHash = (0, child_process_1.execSync)('git rev-parse HEAD', {
|
|
22
|
+
encoding: 'utf-8',
|
|
23
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
24
|
+
}).trim();
|
|
25
|
+
return fullHash;
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new Error('Not a git repository or no commits yet');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function isGitRepo() {
|
|
32
|
+
try {
|
|
33
|
+
(0, child_process_1.execSync)('git rev-parse --is-inside-work-tree', {
|
|
34
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
35
|
+
});
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":";;AAEA,oDAWC;AAED,4DAWC;AAED,8BASC;AArCD,iDAAyC;AAEzC,SAAgB,oBAAoB;IAClC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAA,wBAAQ,EAAC,oBAAoB,EAAE;YAC9C,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEV,OAAO,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED,SAAgB,wBAAwB;IACtC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,IAAA,wBAAQ,EAAC,oBAAoB,EAAE;YAC9C,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC,IAAI,EAAE,CAAC;QAEV,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED,SAAgB,SAAS;IACvB,IAAI,CAAC;QACH,IAAA,wBAAQ,EAAC,qCAAqC,EAAE;YAC9C,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
preset: 'ts-jest',
|
|
3
|
+
testEnvironment: 'node',
|
|
4
|
+
roots: ['<rootDir>/src'],
|
|
5
|
+
testMatch: ['**/*.test.ts'],
|
|
6
|
+
moduleFileExtensions: ['ts', 'js'],
|
|
7
|
+
collectCoverageFrom: [
|
|
8
|
+
'src/**/*.ts',
|
|
9
|
+
'!src/**/*.test.ts',
|
|
10
|
+
'!src/**/*.d.ts'
|
|
11
|
+
]
|
|
12
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "git-slot-machine",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Turn your git commits into a slot machine game! CLI tool with global leaderboards and win streaks.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"git-slot-machine": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/than/git-slot-machine.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://gitslotmachine.com",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/than/git-slot-machine/issues"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"test": "jest",
|
|
21
|
+
"lint": "eslint src --ext .ts"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"git",
|
|
25
|
+
"slot-machine",
|
|
26
|
+
"cli",
|
|
27
|
+
"fun",
|
|
28
|
+
"game",
|
|
29
|
+
"commit",
|
|
30
|
+
"leaderboard",
|
|
31
|
+
"poker",
|
|
32
|
+
"gamification"
|
|
33
|
+
],
|
|
34
|
+
"author": "Than Tibbetts <https://github.com/than>",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/jest": "^30.0.0",
|
|
38
|
+
"@types/node": "^20.0.0",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
40
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
41
|
+
"eslint": "^8.0.0",
|
|
42
|
+
"jest": "^29.0.0",
|
|
43
|
+
"ts-jest": "^29.0.0",
|
|
44
|
+
"typescript": "^5.0.0"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"chalk": "^5.3.0",
|
|
48
|
+
"commander": "^11.0.0"
|
|
49
|
+
}
|
|
50
|
+
}
|