Skip to content

Commit 938a909

Browse files
committed
tsc fixes
1 parent fad7851 commit 938a909

13 files changed

+69
-51
lines changed

bun.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@testing-library/jest-dom": "^6.6.3",
6060
"@testing-library/react": "^16.3.0",
6161
"@types/bcryptjs": "^3.0.0",
62+
"@types/bun": "^1.2.18",
6263
"@types/jsonwebtoken": "^9.0.10",
6364
"@types/uuid": "^10.0.0",
6465
"@vitejs/plugin-react": "^4.6.0",
@@ -540,6 +541,8 @@
540541

541542
"@types/bcryptjs": ["@types/[email protected]", "", { "dependencies": { "bcryptjs": "*" } }, "sha512-WRZOuCuaz8UcZZE4R5HXTco2goQSI2XxjGY3hbM/xDvwmqFWd4ivooImsMx65OKM6CtNKbnZ5YL+YwAwK7c1dg=="],
542543

544+
"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.2.18" } }, "sha512-Xf6RaWVheyemaThV0kUfaAUvCNokFr+bH8Jxp+tTZfx7dAPA8z9ePnP9S9+Vspzuxxx9JRAXhnyccRj3GyCMdQ=="],
545+
543546
"@types/canvas-confetti": ["@types/[email protected]", "", {}, "sha512-aBGj/dULrimR1XDZLtG9JwxX1b4HPRF6CX9Yfwh3NvstZEm1ZL7RBnel4keCPSqs1ANRu1u2Aoz9R+VmtjYuTg=="],
544547

545548
"@types/chai": ["@types/[email protected]", "", { "dependencies": { "@types/deep-eql": "*" } }, "sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg=="],
@@ -672,6 +675,8 @@
672675

673676
"buffer-from": ["[email protected]", "", {}, "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="],
674677

678+
"bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-04+Eha5NP7Z0A9YgDAzMk5PHR16ZuLVa83b26kH5+cp1qZW4F6FmAURngE7INf4tKOvCE69vYvDEwoNl1tGiWw=="],
679+
675680
"cac": ["[email protected]", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="],
676681

677682
"camelcase": ["[email protected]", "", {}, "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA=="],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"@testing-library/jest-dom": "^6.6.3",
9494
"@testing-library/react": "^16.3.0",
9595
"@types/bcryptjs": "^3.0.0",
96+
"@types/bun": "^1.2.18",
9697
"@types/jsonwebtoken": "^9.0.10",
9798
"@types/uuid": "^10.0.0",
9899
"@vitejs/plugin-react": "^4.6.0",

scripts/fix-interrupted-jobs.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
import { db, mirrorJobs } from "../src/lib/db";
13-
import { eq } from "drizzle-orm";
13+
import { eq, and } from "drizzle-orm";
1414

1515
// Parse command line arguments
1616
const args = process.argv.slice(2);
@@ -21,18 +21,19 @@ async function fixInterruptedJobs() {
2121
console.log("Checking for interrupted jobs...");
2222

2323
// Build the query
24-
let query = db
25-
.select()
26-
.from(mirrorJobs)
27-
.where(eq(mirrorJobs.inProgress, true));
24+
const whereConditions = userId
25+
? and(eq(mirrorJobs.inProgress, true), eq(mirrorJobs.userId, userId))
26+
: eq(mirrorJobs.inProgress, true);
2827

2928
if (userId) {
3029
console.log(`Filtering for user: ${userId}`);
31-
query = query.where(eq(mirrorJobs.userId, userId));
3230
}
3331

3432
// Find all in-progress jobs
35-
const inProgressJobs = await query;
33+
const inProgressJobs = await db
34+
.select()
35+
.from(mirrorJobs)
36+
.where(whereConditions);
3637

3738
if (inProgressJobs.length === 0) {
3839
console.log("No interrupted jobs found.");
@@ -45,21 +46,15 @@ async function fixInterruptedJobs() {
4546
});
4647

4748
// Mark all in-progress jobs as failed
48-
let updateQuery = db
49+
await db
4950
.update(mirrorJobs)
5051
.set({
5152
inProgress: false,
5253
completedAt: new Date(),
5354
status: "failed",
5455
message: "Job interrupted and marked as failed by cleanup script"
5556
})
56-
.where(eq(mirrorJobs.inProgress, true));
57-
58-
if (userId) {
59-
updateQuery = updateQuery.where(eq(mirrorJobs.userId, userId));
60-
}
61-
62-
await updateQuery;
57+
.where(whereConditions);
6358

6459
console.log(`✅ Successfully marked ${inProgressJobs.length} interrupted jobs as failed.`);
6560
console.log("These jobs can now be deleted through the normal cleanup process.");

scripts/generate-better-auth-schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const auth = betterAuth({
2222
});
2323

2424
// Generate the schema
25-
const schema = auth.$internal.schema;
25+
// Note: $internal API is not available in current better-auth version
26+
// const schema = auth.$internal.schema;
2627

2728
console.log("Better Auth Tables Required:");
2829
console.log("============================");

scripts/investigate-repo.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ async function investigateRepository() {
7979
if (config.length > 0) {
8080
const userConfig = config[0];
8181
console.log(` User ID: ${userConfig.userId}`);
82-
console.log(` GitHub Username: ${userConfig.githubConfig?.username || "Not set"}`);
82+
console.log(` GitHub Owner: ${userConfig.githubConfig?.owner || "Not set"}`);
8383
console.log(` Gitea URL: ${userConfig.giteaConfig?.url || "Not set"}`);
84-
console.log(` Gitea Username: ${userConfig.giteaConfig?.username || "Not set"}`);
85-
console.log(` Preserve Org Structure: ${userConfig.githubConfig?.preserveOrgStructure || false}`);
86-
console.log(` Mirror Issues: ${userConfig.githubConfig?.mirrorIssues || false}`);
84+
console.log(` Gitea Default Owner: ${userConfig.giteaConfig?.defaultOwner || "Not set"}`);
85+
console.log(` Mirror Strategy: ${userConfig.githubConfig?.mirrorStrategy || "preserve"}`);
86+
console.log(` Include Starred: ${userConfig.githubConfig?.includeStarred || false}`);
8787
}
8888

8989
// Check for any active jobs
@@ -123,7 +123,7 @@ async function investigateRepository() {
123123
try {
124124
const giteaUrl = userConfig.giteaConfig?.url;
125125
const giteaToken = userConfig.giteaConfig?.token;
126-
const giteaUsername = userConfig.giteaConfig?.username;
126+
const giteaUsername = userConfig.giteaConfig?.defaultOwner;
127127

128128
if (giteaUrl && giteaToken && giteaUsername) {
129129
const checkUrl = `${giteaUrl}/api/v1/repos/${giteaUsername}/${repo.name}`;

scripts/migrate-to-better-auth.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ async function migrateUsers() {
4646
}
4747

4848
// Create credential account with existing password hash
49+
const accountId = uuidv4();
4950
await db.insert(accounts).values({
50-
id: uuidv4(),
51+
id: accountId,
52+
accountId: accountId,
5153
userId: user.id,
5254
providerId: "credential",
5355
providerUserId: user.email, // Use email as provider user ID
54-
password: user.password, // Move existing password hash
56+
// password: user.password, // Password is not in users table anymore
5557
createdAt: user.createdAt,
5658
updatedAt: user.updatedAt,
5759
});

scripts/repair-mirrored-repos.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,23 @@ async function repairMirroredRepositories() {
8181

8282
try {
8383
// Find repositories that might need repair
84-
let query = db
85-
.select()
86-
.from(repositories)
87-
.where(
88-
or(
84+
const whereConditions = specificRepo
85+
? and(
86+
or(
87+
eq(repositories.status, "imported"),
88+
eq(repositories.status, "failed")
89+
),
90+
eq(repositories.name, specificRepo)
91+
)
92+
: or(
8993
eq(repositories.status, "imported"),
9094
eq(repositories.status, "failed")
91-
)
92-
);
95+
);
9396

94-
if (specificRepo) {
95-
query = query.where(eq(repositories.name, specificRepo));
96-
}
97-
98-
const repos = await query;
97+
const repos = await db
98+
.select()
99+
.from(repositories)
100+
.where(whereConditions);
99101

100102
if (repos.length === 0) {
101103
if (!isStartupMode) {
@@ -137,7 +139,7 @@ async function repairMirroredRepositories() {
137139
}
138140

139141
const userConfig = config[0];
140-
const giteaUsername = userConfig.giteaConfig?.username;
142+
const giteaUsername = userConfig.giteaConfig?.defaultOwner;
141143

142144
if (!giteaUsername) {
143145
if (!isStartupMode) {

scripts/test-graceful-shutdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async function createTestJob(): Promise<string> {
4747
jobType: "mirror",
4848
totalItems: 10,
4949
itemIds: ['item-1', 'item-2', 'item-3', 'item-4', 'item-5'],
50-
completedItemIds: ['item-1', 'item-2'], // Simulate partial completion
50+
completedItems: 2, // Simulate partial completion
5151
inProgress: true,
5252
});
5353

src/lib/db/schema.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ export const repositorySchema = z.object({
131131
"skipped",
132132
"deleting",
133133
"deleted",
134+
"syncing",
135+
"synced",
134136
])
135137
.default("imported"),
136138
lastMirrored: z.coerce.date().optional().nullable(),
@@ -157,6 +159,8 @@ export const mirrorJobSchema = z.object({
157159
"skipped",
158160
"deleting",
159161
"deleted",
162+
"syncing",
163+
"synced",
160164
])
161165
.default("imported"),
162166
message: z.string(),
@@ -191,6 +195,8 @@ export const organizationSchema = z.object({
191195
"skipped",
192196
"deleting",
193197
"deleted",
198+
"syncing",
199+
"synced",
194200
])
195201
.default("imported"),
196202
lastMirrored: z.coerce.date().optional().nullable(),

src/lib/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export async function apiRequest<T>(
194194
}
195195
}
196196

197-
export const getStatusColor = (status: RepoStatus): string => {
197+
export const getStatusColor = (status: string): string => {
198198
switch (status) {
199199
case "imported":
200200
return "bg-blue-500"; // Info/primary-like
@@ -208,6 +208,12 @@ export const getStatusColor = (status: RepoStatus): string => {
208208
return "bg-indigo-500"; // Sync in progress
209209
case "synced":
210210
return "bg-teal-500"; // Sync complete
211+
case "skipped":
212+
return "bg-gray-500"; // Skipped
213+
case "deleting":
214+
return "bg-orange-500"; // Deleting
215+
case "deleted":
216+
return "bg-gray-600"; // Deleted
211217
default:
212218
return "bg-gray-400"; // Unknown/neutral
213219
}

0 commit comments

Comments
 (0)