@vatvaghool/create-ipl-dashboard 0.1.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.
Files changed (108) hide show
  1. package/README.md +75 -0
  2. package/package.json +27 -0
  3. package/src/generate-template.mjs +73 -0
  4. package/src/index.mjs +98 -0
  5. package/src/prompts.mjs +78 -0
  6. package/src/scaffold.mjs +129 -0
  7. package/src/scraper.mjs +79 -0
  8. package/template/.dockerignore +13 -0
  9. package/template/AGENTS.md +5 -0
  10. package/template/Dockerfile.sync +14 -0
  11. package/template/README.md +160 -0
  12. package/template/app/api/ipl/data.ts +24 -0
  13. package/template/app/api/ipl/route.ts +505 -0
  14. package/template/app/api/ipl/transfers/route.ts +261 -0
  15. package/template/app/api/ipl/transfers/transform.ts +156 -0
  16. package/template/app/api/ipl/transform.ts +20 -0
  17. package/template/app/api/ipl/upcoming-matches/route.ts +18 -0
  18. package/template/app/api/ops/status/route.ts +225 -0
  19. package/template/app/components/AIRoasting.tsx +278 -0
  20. package/template/app/components/ColorWave.tsx +193 -0
  21. package/template/app/components/CrownBattle.tsx +207 -0
  22. package/template/app/components/DashboardContent.tsx +377 -0
  23. package/template/app/components/FantasyStockTicker.tsx +192 -0
  24. package/template/app/components/FireworksBurst.tsx +225 -0
  25. package/template/app/components/LiveMatchTicker.tsx +117 -0
  26. package/template/app/components/MatchRecapScroll.tsx +135 -0
  27. package/template/app/components/MatchStoryScrubber.tsx +274 -0
  28. package/template/app/components/PerformanceTracker.tsx +132 -0
  29. package/template/app/components/ProgressGlowRings.tsx +157 -0
  30. package/template/app/components/TeamDNAScanner.tsx +238 -0
  31. package/template/app/components/ThemeToggle.tsx +74 -0
  32. package/template/app/components/dashboard/CaptainBoard.tsx +138 -0
  33. package/template/app/components/dashboard/ChartBoard.tsx +162 -0
  34. package/template/app/components/dashboard/LatestBadge.tsx +23 -0
  35. package/template/app/components/dashboard/LedgerTable.tsx +385 -0
  36. package/template/app/components/dashboard/SectionCard.tsx +59 -0
  37. package/template/app/components/dashboard/StickyMini.tsx +20 -0
  38. package/template/app/components/dashboard/index.ts +6 -0
  39. package/template/app/components/ui/DashboardChartFrame.tsx +74 -0
  40. package/template/app/components/ui/DoodleSpinner.tsx +15 -0
  41. package/template/app/components/ui/TeamPills.tsx +41 -0
  42. package/template/app/data/match-points.ts +3 -0
  43. package/template/app/data/teams.ts +32 -0
  44. package/template/app/globals.css +1267 -0
  45. package/template/app/hooks/dashboard/index.ts +1 -0
  46. package/template/app/hooks/dashboard/useDashboardModel.ts +25 -0
  47. package/template/app/hooks/dashboardCache.ts +53 -0
  48. package/template/app/hooks/dashboardPolling.ts +53 -0
  49. package/template/app/hooks/snapshotCache.ts +47 -0
  50. package/template/app/hooks/useDashboardData.ts +28 -0
  51. package/template/app/layout.tsx +75 -0
  52. package/template/app/lib/aiAgent.ts +444 -0
  53. package/template/app/lib/config.ts +29 -0
  54. package/template/app/lib/dashboard/index.ts +1 -0
  55. package/template/app/lib/dashboard/model.ts +257 -0
  56. package/template/app/lib/dashboardData.ts +50 -0
  57. package/template/app/lib/dashboardView.ts +22 -0
  58. package/template/app/lib/detailedData.ts +112 -0
  59. package/template/app/lib/matchStatus.ts +28 -0
  60. package/template/app/lib/matches.ts +131 -0
  61. package/template/app/lib/teamBadges.ts +223 -0
  62. package/template/app/lib/upcomingMatches.ts +154 -0
  63. package/template/app/lib/useDb.ts +29 -0
  64. package/template/app/lib/utils/diff.ts +24 -0
  65. package/template/app/lib/utils/getChartColor.ts +17 -0
  66. package/template/app/lib/utils/getStdDeviation.ts +6 -0
  67. package/template/app/lib/utils/time.ts +40 -0
  68. package/template/app/lib/utils.ts +70 -0
  69. package/template/app/page.tsx +15 -0
  70. package/template/app/store/dashboardStore.ts +85 -0
  71. package/template/app/types/dashboard.ts +75 -0
  72. package/template/app/types.ts +130 -0
  73. package/template/app/utils/dashboard/index.ts +72 -0
  74. package/template/eslint.config.mjs +18 -0
  75. package/template/infra/cloud-run/README.md +68 -0
  76. package/template/infra/cloud-run/sync-job.yaml +32 -0
  77. package/template/infra/cutover/README.md +84 -0
  78. package/template/infra/vercel/README.md +57 -0
  79. package/template/next.config.ts +7 -0
  80. package/template/package-lock.json +7330 -0
  81. package/template/package.json +47 -0
  82. package/template/packages/ipl-dashboard-utils/README.md +316 -0
  83. package/template/packages/ipl-dashboard-utils/package.json +34 -0
  84. package/template/packages/ipl-dashboard-utils/src/index.ts +22 -0
  85. package/template/packages/ipl-dashboard-utils/src/transform.ts +687 -0
  86. package/template/packages/ipl-dashboard-utils/src/types.ts +88 -0
  87. package/template/packages/ipl-dashboard-utils/tsconfig.build.json +17 -0
  88. package/template/postcss.config.mjs +7 -0
  89. package/template/scripts/capture-ipl-auth.mjs +54 -0
  90. package/template/scripts/deploy-cloud-run-sync.sh +48 -0
  91. package/template/scripts/deploy-cloud-scheduler.sh +42 -0
  92. package/template/scripts/dev-simple.js +31 -0
  93. package/template/scripts/dev-welcome.mjs +38 -0
  94. package/template/scripts/monitor-ops-status.sh +50 -0
  95. package/template/scripts/seed-mongodb.ts +115 -0
  96. package/template/scripts/sync-cloud.mjs +50 -0
  97. package/template/scripts/sync-ipl.mjs +238 -0
  98. package/template/scripts/sync-transfers-daily.mjs +175 -0
  99. package/template/scripts/verify-production.mjs +108 -0
  100. package/template/tests/coverage-gaps.test.ts +290 -0
  101. package/template/tests/dashboard-polling.test.ts +96 -0
  102. package/template/tests/detailed-data.test.ts +60 -0
  103. package/template/tests/ipl-transform.test.ts +590 -0
  104. package/template/tests/transfers-route.test.ts +109 -0
  105. package/template/tests/upcoming-matches.test.ts +34 -0
  106. package/template/tests/utils-and-cache.test.ts +267 -0
  107. package/template/tsconfig.json +35 -0
  108. package/template/vercel.json +7 -0
@@ -0,0 +1,34 @@
1
+ import assert from "node:assert/strict";
2
+ import { describe, it } from "node:test";
3
+
4
+ import { parseUpcomingMatches } from "../app/lib/upcomingMatches.ts";
5
+
6
+ describe("upcoming matches parser", () => {
7
+ it("parses business-standard schedule chunks into ticker fixtures", () => {
8
+ const html = `
9
+ <div>Match 51 Scheduled DC KKR Fri 8th May, 7:30 pm IST, Delhi</div>
10
+ <div>Delhi Capitals</div>
11
+ <div>VS</div>
12
+ <div>Kolkata Knight Riders</div>
13
+ <div>Match 52 Scheduled RR GT Sat 9th May, 7:30 pm IST, Jaipur</div>
14
+ <div>Rajasthan Royals</div>
15
+ <div>VS</div>
16
+ <div>Gujarat Titans</div>
17
+ `;
18
+
19
+ assert.deepEqual(parseUpcomingMatches(html), [
20
+ {
21
+ id: 51,
22
+ team1: "DC",
23
+ team2: "KKR",
24
+ date: "2026-05-08T14:00:00.000Z",
25
+ },
26
+ {
27
+ id: 52,
28
+ team1: "RR",
29
+ team2: "GT",
30
+ date: "2026-05-09T14:00:00.000Z",
31
+ },
32
+ ]);
33
+ });
34
+ });
@@ -0,0 +1,267 @@
1
+ import assert from "node:assert/strict";
2
+ import { afterEach, describe, it, mock } from "node:test";
3
+
4
+ import { readDashboardCache, writeDashboardCache } from "../app/hooks/dashboardCache.ts";
5
+ import { readSnapshotCache, writeSnapshotCache } from "../app/hooks/snapshotCache.ts";
6
+ import {
7
+ getDisplayLiveMatchId,
8
+ getLiveUpdateRow,
9
+ getPlayedMatchRows,
10
+ hasMeaningfulMatchData,
11
+ parseMatchId,
12
+ } from "../app/lib/dashboardData.ts";
13
+ import { getMatchViewState } from "../app/lib/dashboardView.ts";
14
+ import { getLatestMatchRow, hasLiveMatchRow } from "../app/lib/dashboardView.ts";
15
+ import { matches } from "../app/lib/matches.ts";
16
+ import { getDiff } from "../app/lib/utils/diff.ts";
17
+ import { getStdDeviation } from "../app/lib/utils/getStdDeviation.ts";
18
+ import { formatMatchTime, getMatchStatus, getTimeLeft } from "../app/lib/utils/time.ts";
19
+ import { splitTeamName, trimTeamName } from "../app/lib/utils.ts";
20
+
21
+ const createStorage = () => {
22
+ const store = new Map<string, string>();
23
+
24
+ return {
25
+ getItem: (key: string) => store.get(key) ?? null,
26
+ setItem: (key: string, value: string) => {
27
+ store.set(key, value);
28
+ },
29
+ removeItem: (key: string) => {
30
+ store.delete(key);
31
+ },
32
+ clear: () => {
33
+ store.clear();
34
+ },
35
+ };
36
+ };
37
+
38
+ describe("utility and cache coverage", () => {
39
+ afterEach(() => {
40
+ delete (globalThis as { window?: unknown }).window;
41
+ mock.timers.reset();
42
+ });
43
+
44
+ it("trims and splits team names across all branches", () => {
45
+ assert.equal(trimTeamName("Short"), "Short");
46
+ assert.equal(trimTeamName("VeryLongTeamName", 8), "VeryLong...");
47
+ assert.deepEqual(splitTeamName("Alpha"), ["Alpha", ""]);
48
+ assert.deepEqual(splitTeamName("Alpha Beta", 7), ["Alpha", "Beta"]);
49
+ assert.deepEqual(splitTeamName("NoSpacesHere", 4), ["NoSp", "acesHere"]);
50
+ assert.deepEqual(
51
+ splitTeamName("A very very long team name", 8),
52
+ ["A very", "very lon..."],
53
+ );
54
+ });
55
+
56
+ it("computes diffs and standard deviation", () => {
57
+ assert.deepEqual(
58
+ getDiff(
59
+ { a: 1, nested: { left: 2, same: 1 } },
60
+ { a: 2, nested: { left: 3, same: 1 }, added: true },
61
+ ),
62
+ {
63
+ a: 2,
64
+ "nested.left": 3,
65
+ added: true,
66
+ },
67
+ );
68
+ assert.equal(getStdDeviation([2, 4, 4, 4, 5, 5, 7, 9]), 2);
69
+ });
70
+
71
+ it("formats match times and covers all time status helpers", () => {
72
+ mock.timers.enable({ apis: ["Date"], now: new Date("2026-04-28T10:00:00.000Z") });
73
+
74
+ assert.match(
75
+ formatMatchTime("2026-04-28T14:00:00.000Z", "UTC"),
76
+ /28 Apr.*02:00 pm/i,
77
+ );
78
+ assert.equal(getMatchStatus("2026-04-28T05:30:00.000Z"), "ENDED");
79
+ assert.equal(getMatchStatus("2026-04-28T09:30:00.000Z"), "LIVE");
80
+ assert.equal(getMatchStatus("2026-04-28T10:20:00.000Z"), "STARTING SOON");
81
+ assert.equal(getMatchStatus("2026-04-28T12:00:00.000Z"), "UPCOMING");
82
+ assert.equal(getTimeLeft("2026-04-28T09:59:00.000Z"), "Started");
83
+ assert.equal(getTimeLeft("2026-04-28T10:45:00.000Z"), "45m");
84
+ assert.equal(getTimeLeft("2026-04-28T12:15:00.000Z"), "2h 15m");
85
+ });
86
+
87
+ it("normalizes dashboard daily rows for played matches and live match labels", () => {
88
+ const daily = [
89
+ { day: "Match 1", Alpha: 120, Beta: 90 },
90
+ { day: "Match 2", Alpha: 0, Beta: 0 },
91
+ { day: "Match 3", Alpha: 65, Beta: 55 },
92
+ { day: "Live Update", Alpha: 20, Beta: 18 },
93
+ ];
94
+
95
+ assert.equal(parseMatchId("Match 12"), 12);
96
+ assert.equal(parseMatchId("Live Update"), undefined);
97
+ assert.equal(hasMeaningfulMatchData(daily[0]), true);
98
+ assert.equal(hasMeaningfulMatchData(daily[1]), false);
99
+ assert.deepEqual(
100
+ getPlayedMatchRows(daily).map((row) => row.day),
101
+ ["Match 1", "Match 3"],
102
+ );
103
+ assert.equal(getLiveUpdateRow(daily)?.day, "Live Update");
104
+ assert.equal(getDisplayLiveMatchId(daily), 4);
105
+ });
106
+
107
+ it("falls back to the latest played row when no live match row exists", () => {
108
+ const daily = [
109
+ { day: "Match 1", Alpha: 10, Beta: 20 },
110
+ { day: "Match 2", Alpha: 15, Beta: 12 },
111
+ ];
112
+
113
+ assert.equal(hasLiveMatchRow(daily), false);
114
+ assert.equal(getLatestMatchRow(daily)?.day, "Match 2");
115
+ assert.equal(getMatchViewState(daily).isLive, false);
116
+ assert.equal(getMatchViewState(daily).latestRow?.day, "Match 2");
117
+ assert.equal(getMatchViewState(daily).hasMatches, true);
118
+ });
119
+
120
+ it("reads and writes dashboard cache with invalid payload safeguards", () => {
121
+ assert.equal(readDashboardCache(), null);
122
+ assert.doesNotThrow(() =>
123
+ writeDashboardCache({
124
+ source: "database",
125
+ overall: [],
126
+ daily: [],
127
+ }),
128
+ );
129
+
130
+ const storage = createStorage();
131
+ (globalThis as { window?: unknown }).window = {
132
+ localStorage: storage,
133
+ };
134
+
135
+ assert.equal(readDashboardCache(), null);
136
+
137
+ writeDashboardCache({
138
+ source: "database",
139
+ updatedAt: "2026-04-28T09:20:00.000Z",
140
+ snapshot: {
141
+ updatedAt: "2026-04-28T09:20:00.000Z",
142
+ leaders: [{ rank: 1, name: "Alpha", points: 120 }],
143
+ },
144
+ overall: [{ rank: 1, name: "Alpha", points: 120 }],
145
+ daily: [{ day: "Match 1", Alpha: 120 }],
146
+ });
147
+ const cached = readDashboardCache();
148
+ assert.ok(cached);
149
+ assert.equal(cached.data.overall[0].name, "Alpha");
150
+ assert.ok(cached.cachedAt);
151
+
152
+ storage.setItem(
153
+ "ipl:dashboard-cache:v1",
154
+ JSON.stringify({
155
+ data: { source: "database", overall: [], daily: [] },
156
+ }),
157
+ );
158
+ const fallbackCached = readDashboardCache();
159
+ assert.ok(fallbackCached);
160
+ assert.equal(typeof fallbackCached.cachedAt, "string");
161
+
162
+ storage.setItem(
163
+ "ipl:dashboard-cache:v1",
164
+ JSON.stringify({
165
+ cachedAt: "2026-04-28T09:20:00.000Z",
166
+ data: {
167
+ source: "database",
168
+ updatedAt: "2026-04-28T09:20:00.000Z",
169
+ overall: [],
170
+ daily: [],
171
+ },
172
+ }),
173
+ );
174
+ assert.equal(readDashboardCache(), null);
175
+
176
+ storage.setItem("ipl:dashboard-cache:v1", "{\"cachedAt\":1}");
177
+ assert.equal(readDashboardCache(), null);
178
+
179
+ storage.setItem("ipl:dashboard-cache:v1", "null");
180
+ assert.equal(readDashboardCache(), null);
181
+
182
+ storage.setItem("ipl:dashboard-cache:v1", "1");
183
+ assert.equal(readDashboardCache(), null);
184
+
185
+ storage.setItem("ipl:dashboard-cache:v1", JSON.stringify({ data: 1 }));
186
+ assert.equal(readDashboardCache(), null);
187
+
188
+ storage.setItem("ipl:dashboard-cache:v1", "not-json");
189
+ assert.equal(readDashboardCache(), null);
190
+ });
191
+
192
+ it("reads and writes snapshot cache with fallback timestamps", () => {
193
+ assert.equal(readSnapshotCache(), null);
194
+ assert.doesNotThrow(() =>
195
+ writeSnapshotCache({
196
+ leaders: [],
197
+ }),
198
+ );
199
+
200
+ const storage = createStorage();
201
+ (globalThis as { window?: unknown }).window = {
202
+ localStorage: storage,
203
+ };
204
+
205
+ assert.equal(readSnapshotCache(), null);
206
+
207
+ writeSnapshotCache({
208
+ updatedAt: "2026-04-28T09:15:00.000Z",
209
+ completedMatches: 41,
210
+ leaders: [{ rank: 1, name: "Alpha", points: 110 }],
211
+ });
212
+ const cached = readSnapshotCache();
213
+ assert.ok(cached);
214
+ assert.equal(cached.snapshot.leaders[0].name, "Alpha");
215
+ assert.ok(cached.cachedAt);
216
+
217
+ storage.setItem(
218
+ "ipl:snapshot-cache:v1",
219
+ JSON.stringify({
220
+ snapshot: { updatedAt: "2026-04-28T09:15:00.000Z", leaders: [] },
221
+ }),
222
+ );
223
+ const fallbackCached = readSnapshotCache();
224
+ assert.ok(fallbackCached);
225
+ assert.equal(typeof fallbackCached.cachedAt, "string");
226
+
227
+ storage.setItem("ipl:snapshot-cache:v1", "{\"cachedAt\":1}");
228
+ assert.equal(readSnapshotCache(), null);
229
+
230
+ storage.setItem("ipl:snapshot-cache:v1", "1");
231
+ assert.equal(readSnapshotCache(), null);
232
+
233
+ storage.setItem("ipl:snapshot-cache:v1", JSON.stringify({ snapshot: 1 }));
234
+ assert.equal(readSnapshotCache(), null);
235
+
236
+ storage.setItem("ipl:snapshot-cache:v1", "not-json");
237
+ assert.equal(readSnapshotCache(), null);
238
+ });
239
+
240
+ it("gracefully ignores cache write failures and exposes upcoming match data", () => {
241
+ (globalThis as { window?: unknown }).window = {
242
+ localStorage: {
243
+ getItem: () => null,
244
+ setItem: () => {
245
+ throw new Error("quota");
246
+ },
247
+ },
248
+ };
249
+
250
+ assert.doesNotThrow(() =>
251
+ writeDashboardCache({
252
+ source: "database",
253
+ overall: [],
254
+ daily: [],
255
+ }),
256
+ );
257
+ assert.doesNotThrow(() =>
258
+ writeSnapshotCache({
259
+ leaders: [],
260
+ }),
261
+ );
262
+
263
+ assert.equal(matches[0].id, 51);
264
+ assert.equal(matches.at(-1)?.id, 70);
265
+ assert.equal(matches.every((match) => match.team1 && match.team2 && match.date), true);
266
+ });
267
+ });
@@ -0,0 +1,35 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2017",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "allowImportingTsExtensions": true,
13
+ "resolveJsonModule": true,
14
+ "isolatedModules": true,
15
+ "jsx": "react-jsx",
16
+ "incremental": true,
17
+ "plugins": [
18
+ {
19
+ "name": "next"
20
+ }
21
+ ],
22
+ "paths": {
23
+ "@/*": ["./*"]
24
+ }
25
+ },
26
+ "include": [
27
+ "next-env.d.ts",
28
+ "**/*.ts",
29
+ "**/*.tsx",
30
+ ".next/types/**/*.ts",
31
+ ".next/dev/types/**/*.ts",
32
+ "**/*.mts"
33
+ ],
34
+ "exclude": ["node_modules"]
35
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://openapi.vercel.sh/vercel.json",
3
+ "framework": "nextjs",
4
+ "github": {
5
+ "enabled": true
6
+ }
7
+ }