mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-06 19:46:44 +03:00
tsc fixes
This commit is contained in:
5
bun.lock
5
bun.lock
@@ -59,6 +59,7 @@
|
|||||||
"@testing-library/jest-dom": "^6.6.3",
|
"@testing-library/jest-dom": "^6.6.3",
|
||||||
"@testing-library/react": "^16.3.0",
|
"@testing-library/react": "^16.3.0",
|
||||||
"@types/bcryptjs": "^3.0.0",
|
"@types/bcryptjs": "^3.0.0",
|
||||||
|
"@types/bun": "^1.2.18",
|
||||||
"@types/jsonwebtoken": "^9.0.10",
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
"@types/uuid": "^10.0.0",
|
"@types/uuid": "^10.0.0",
|
||||||
"@vitejs/plugin-react": "^4.6.0",
|
"@vitejs/plugin-react": "^4.6.0",
|
||||||
@@ -540,6 +541,8 @@
|
|||||||
|
|
||||||
"@types/bcryptjs": ["@types/bcryptjs@3.0.0", "", { "dependencies": { "bcryptjs": "*" } }, "sha512-WRZOuCuaz8UcZZE4R5HXTco2goQSI2XxjGY3hbM/xDvwmqFWd4ivooImsMx65OKM6CtNKbnZ5YL+YwAwK7c1dg=="],
|
"@types/bcryptjs": ["@types/bcryptjs@3.0.0", "", { "dependencies": { "bcryptjs": "*" } }, "sha512-WRZOuCuaz8UcZZE4R5HXTco2goQSI2XxjGY3hbM/xDvwmqFWd4ivooImsMx65OKM6CtNKbnZ5YL+YwAwK7c1dg=="],
|
||||||
|
|
||||||
|
"@types/bun": ["@types/bun@1.2.18", "", { "dependencies": { "bun-types": "1.2.18" } }, "sha512-Xf6RaWVheyemaThV0kUfaAUvCNokFr+bH8Jxp+tTZfx7dAPA8z9ePnP9S9+Vspzuxxx9JRAXhnyccRj3GyCMdQ=="],
|
||||||
|
|
||||||
"@types/canvas-confetti": ["@types/canvas-confetti@1.9.0", "", {}, "sha512-aBGj/dULrimR1XDZLtG9JwxX1b4HPRF6CX9Yfwh3NvstZEm1ZL7RBnel4keCPSqs1ANRu1u2Aoz9R+VmtjYuTg=="],
|
"@types/canvas-confetti": ["@types/canvas-confetti@1.9.0", "", {}, "sha512-aBGj/dULrimR1XDZLtG9JwxX1b4HPRF6CX9Yfwh3NvstZEm1ZL7RBnel4keCPSqs1ANRu1u2Aoz9R+VmtjYuTg=="],
|
||||||
|
|
||||||
"@types/chai": ["@types/chai@5.2.2", "", { "dependencies": { "@types/deep-eql": "*" } }, "sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg=="],
|
"@types/chai": ["@types/chai@5.2.2", "", { "dependencies": { "@types/deep-eql": "*" } }, "sha512-8kB30R7Hwqf40JPiKhVzodJs2Qc1ZJ5zuT3uzw5Hq/dhNCl3G3l83jfpdI1e20BP348+fV7VIL/+FxaXkqBmWg=="],
|
||||||
@@ -672,6 +675,8 @@
|
|||||||
|
|
||||||
"buffer-from": ["buffer-from@1.1.2", "", {}, "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="],
|
"buffer-from": ["buffer-from@1.1.2", "", {}, "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ=="],
|
||||||
|
|
||||||
|
"bun-types": ["bun-types@1.2.18", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-04+Eha5NP7Z0A9YgDAzMk5PHR16ZuLVa83b26kH5+cp1qZW4F6FmAURngE7INf4tKOvCE69vYvDEwoNl1tGiWw=="],
|
||||||
|
|
||||||
"cac": ["cac@6.7.14", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="],
|
"cac": ["cac@6.7.14", "", {}, "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ=="],
|
||||||
|
|
||||||
"camelcase": ["camelcase@8.0.0", "", {}, "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA=="],
|
"camelcase": ["camelcase@8.0.0", "", {}, "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA=="],
|
||||||
|
|||||||
@@ -93,6 +93,7 @@
|
|||||||
"@testing-library/jest-dom": "^6.6.3",
|
"@testing-library/jest-dom": "^6.6.3",
|
||||||
"@testing-library/react": "^16.3.0",
|
"@testing-library/react": "^16.3.0",
|
||||||
"@types/bcryptjs": "^3.0.0",
|
"@types/bcryptjs": "^3.0.0",
|
||||||
|
"@types/bun": "^1.2.18",
|
||||||
"@types/jsonwebtoken": "^9.0.10",
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
"@types/uuid": "^10.0.0",
|
"@types/uuid": "^10.0.0",
|
||||||
"@vitejs/plugin-react": "^4.6.0",
|
"@vitejs/plugin-react": "^4.6.0",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { db, mirrorJobs } from "../src/lib/db";
|
import { db, mirrorJobs } from "../src/lib/db";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq, and } from "drizzle-orm";
|
||||||
|
|
||||||
// Parse command line arguments
|
// Parse command line arguments
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
@@ -21,18 +21,19 @@ async function fixInterruptedJobs() {
|
|||||||
console.log("Checking for interrupted jobs...");
|
console.log("Checking for interrupted jobs...");
|
||||||
|
|
||||||
// Build the query
|
// Build the query
|
||||||
let query = db
|
const whereConditions = userId
|
||||||
.select()
|
? and(eq(mirrorJobs.inProgress, true), eq(mirrorJobs.userId, userId))
|
||||||
.from(mirrorJobs)
|
: eq(mirrorJobs.inProgress, true);
|
||||||
.where(eq(mirrorJobs.inProgress, true));
|
|
||||||
|
|
||||||
if (userId) {
|
if (userId) {
|
||||||
console.log(`Filtering for user: ${userId}`);
|
console.log(`Filtering for user: ${userId}`);
|
||||||
query = query.where(eq(mirrorJobs.userId, userId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find all in-progress jobs
|
// Find all in-progress jobs
|
||||||
const inProgressJobs = await query;
|
const inProgressJobs = await db
|
||||||
|
.select()
|
||||||
|
.from(mirrorJobs)
|
||||||
|
.where(whereConditions);
|
||||||
|
|
||||||
if (inProgressJobs.length === 0) {
|
if (inProgressJobs.length === 0) {
|
||||||
console.log("No interrupted jobs found.");
|
console.log("No interrupted jobs found.");
|
||||||
@@ -45,7 +46,7 @@ async function fixInterruptedJobs() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Mark all in-progress jobs as failed
|
// Mark all in-progress jobs as failed
|
||||||
let updateQuery = db
|
await db
|
||||||
.update(mirrorJobs)
|
.update(mirrorJobs)
|
||||||
.set({
|
.set({
|
||||||
inProgress: false,
|
inProgress: false,
|
||||||
@@ -53,13 +54,7 @@ async function fixInterruptedJobs() {
|
|||||||
status: "failed",
|
status: "failed",
|
||||||
message: "Job interrupted and marked as failed by cleanup script"
|
message: "Job interrupted and marked as failed by cleanup script"
|
||||||
})
|
})
|
||||||
.where(eq(mirrorJobs.inProgress, true));
|
.where(whereConditions);
|
||||||
|
|
||||||
if (userId) {
|
|
||||||
updateQuery = updateQuery.where(eq(mirrorJobs.userId, userId));
|
|
||||||
}
|
|
||||||
|
|
||||||
await updateQuery;
|
|
||||||
|
|
||||||
console.log(`✅ Successfully marked ${inProgressJobs.length} interrupted jobs as failed.`);
|
console.log(`✅ Successfully marked ${inProgressJobs.length} interrupted jobs as failed.`);
|
||||||
console.log("These jobs can now be deleted through the normal cleanup process.");
|
console.log("These jobs can now be deleted through the normal cleanup process.");
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ const auth = betterAuth({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Generate the schema
|
// Generate the schema
|
||||||
const schema = auth.$internal.schema;
|
// Note: $internal API is not available in current better-auth version
|
||||||
|
// const schema = auth.$internal.schema;
|
||||||
|
|
||||||
console.log("Better Auth Tables Required:");
|
console.log("Better Auth Tables Required:");
|
||||||
console.log("============================");
|
console.log("============================");
|
||||||
|
|||||||
@@ -79,11 +79,11 @@ async function investigateRepository() {
|
|||||||
if (config.length > 0) {
|
if (config.length > 0) {
|
||||||
const userConfig = config[0];
|
const userConfig = config[0];
|
||||||
console.log(` User ID: ${userConfig.userId}`);
|
console.log(` User ID: ${userConfig.userId}`);
|
||||||
console.log(` GitHub Username: ${userConfig.githubConfig?.username || "Not set"}`);
|
console.log(` GitHub Owner: ${userConfig.githubConfig?.owner || "Not set"}`);
|
||||||
console.log(` Gitea URL: ${userConfig.giteaConfig?.url || "Not set"}`);
|
console.log(` Gitea URL: ${userConfig.giteaConfig?.url || "Not set"}`);
|
||||||
console.log(` Gitea Username: ${userConfig.giteaConfig?.username || "Not set"}`);
|
console.log(` Gitea Default Owner: ${userConfig.giteaConfig?.defaultOwner || "Not set"}`);
|
||||||
console.log(` Preserve Org Structure: ${userConfig.githubConfig?.preserveOrgStructure || false}`);
|
console.log(` Mirror Strategy: ${userConfig.githubConfig?.mirrorStrategy || "preserve"}`);
|
||||||
console.log(` Mirror Issues: ${userConfig.githubConfig?.mirrorIssues || false}`);
|
console.log(` Include Starred: ${userConfig.githubConfig?.includeStarred || false}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for any active jobs
|
// Check for any active jobs
|
||||||
@@ -123,7 +123,7 @@ async function investigateRepository() {
|
|||||||
try {
|
try {
|
||||||
const giteaUrl = userConfig.giteaConfig?.url;
|
const giteaUrl = userConfig.giteaConfig?.url;
|
||||||
const giteaToken = userConfig.giteaConfig?.token;
|
const giteaToken = userConfig.giteaConfig?.token;
|
||||||
const giteaUsername = userConfig.giteaConfig?.username;
|
const giteaUsername = userConfig.giteaConfig?.defaultOwner;
|
||||||
|
|
||||||
if (giteaUrl && giteaToken && giteaUsername) {
|
if (giteaUrl && giteaToken && giteaUsername) {
|
||||||
const checkUrl = `${giteaUrl}/api/v1/repos/${giteaUsername}/${repo.name}`;
|
const checkUrl = `${giteaUrl}/api/v1/repos/${giteaUsername}/${repo.name}`;
|
||||||
|
|||||||
@@ -46,12 +46,14 @@ async function migrateUsers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create credential account with existing password hash
|
// Create credential account with existing password hash
|
||||||
|
const accountId = uuidv4();
|
||||||
await db.insert(accounts).values({
|
await db.insert(accounts).values({
|
||||||
id: uuidv4(),
|
id: accountId,
|
||||||
|
accountId: accountId,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
providerId: "credential",
|
providerId: "credential",
|
||||||
providerUserId: user.email, // Use email as provider user ID
|
providerUserId: user.email, // Use email as provider user ID
|
||||||
password: user.password, // Move existing password hash
|
// password: user.password, // Password is not in users table anymore
|
||||||
createdAt: user.createdAt,
|
createdAt: user.createdAt,
|
||||||
updatedAt: user.updatedAt,
|
updatedAt: user.updatedAt,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -81,21 +81,23 @@ async function repairMirroredRepositories() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Find repositories that might need repair
|
// Find repositories that might need repair
|
||||||
let query = db
|
const whereConditions = specificRepo
|
||||||
.select()
|
? and(
|
||||||
.from(repositories)
|
or(
|
||||||
.where(
|
eq(repositories.status, "imported"),
|
||||||
or(
|
eq(repositories.status, "failed")
|
||||||
|
),
|
||||||
|
eq(repositories.name, specificRepo)
|
||||||
|
)
|
||||||
|
: or(
|
||||||
eq(repositories.status, "imported"),
|
eq(repositories.status, "imported"),
|
||||||
eq(repositories.status, "failed")
|
eq(repositories.status, "failed")
|
||||||
)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (specificRepo) {
|
const repos = await db
|
||||||
query = query.where(eq(repositories.name, specificRepo));
|
.select()
|
||||||
}
|
.from(repositories)
|
||||||
|
.where(whereConditions);
|
||||||
const repos = await query;
|
|
||||||
|
|
||||||
if (repos.length === 0) {
|
if (repos.length === 0) {
|
||||||
if (!isStartupMode) {
|
if (!isStartupMode) {
|
||||||
@@ -137,7 +139,7 @@ async function repairMirroredRepositories() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const userConfig = config[0];
|
const userConfig = config[0];
|
||||||
const giteaUsername = userConfig.giteaConfig?.username;
|
const giteaUsername = userConfig.giteaConfig?.defaultOwner;
|
||||||
|
|
||||||
if (!giteaUsername) {
|
if (!giteaUsername) {
|
||||||
if (!isStartupMode) {
|
if (!isStartupMode) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ async function createTestJob(): Promise<string> {
|
|||||||
jobType: "mirror",
|
jobType: "mirror",
|
||||||
totalItems: 10,
|
totalItems: 10,
|
||||||
itemIds: ['item-1', 'item-2', 'item-3', 'item-4', 'item-5'],
|
itemIds: ['item-1', 'item-2', 'item-3', 'item-4', 'item-5'],
|
||||||
completedItemIds: ['item-1', 'item-2'], // Simulate partial completion
|
completedItems: 2, // Simulate partial completion
|
||||||
inProgress: true,
|
inProgress: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ export const repositorySchema = z.object({
|
|||||||
"skipped",
|
"skipped",
|
||||||
"deleting",
|
"deleting",
|
||||||
"deleted",
|
"deleted",
|
||||||
|
"syncing",
|
||||||
|
"synced",
|
||||||
])
|
])
|
||||||
.default("imported"),
|
.default("imported"),
|
||||||
lastMirrored: z.coerce.date().optional().nullable(),
|
lastMirrored: z.coerce.date().optional().nullable(),
|
||||||
@@ -157,6 +159,8 @@ export const mirrorJobSchema = z.object({
|
|||||||
"skipped",
|
"skipped",
|
||||||
"deleting",
|
"deleting",
|
||||||
"deleted",
|
"deleted",
|
||||||
|
"syncing",
|
||||||
|
"synced",
|
||||||
])
|
])
|
||||||
.default("imported"),
|
.default("imported"),
|
||||||
message: z.string(),
|
message: z.string(),
|
||||||
@@ -191,6 +195,8 @@ export const organizationSchema = z.object({
|
|||||||
"skipped",
|
"skipped",
|
||||||
"deleting",
|
"deleting",
|
||||||
"deleted",
|
"deleted",
|
||||||
|
"syncing",
|
||||||
|
"synced",
|
||||||
])
|
])
|
||||||
.default("imported"),
|
.default("imported"),
|
||||||
lastMirrored: z.coerce.date().optional().nullable(),
|
lastMirrored: z.coerce.date().optional().nullable(),
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ export async function apiRequest<T>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getStatusColor = (status: RepoStatus): string => {
|
export const getStatusColor = (status: string): string => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case "imported":
|
case "imported":
|
||||||
return "bg-blue-500"; // Info/primary-like
|
return "bg-blue-500"; // Info/primary-like
|
||||||
@@ -208,6 +208,12 @@ export const getStatusColor = (status: RepoStatus): string => {
|
|||||||
return "bg-indigo-500"; // Sync in progress
|
return "bg-indigo-500"; // Sync in progress
|
||||||
case "synced":
|
case "synced":
|
||||||
return "bg-teal-500"; // Sync complete
|
return "bg-teal-500"; // Sync complete
|
||||||
|
case "skipped":
|
||||||
|
return "bg-gray-500"; // Skipped
|
||||||
|
case "deleting":
|
||||||
|
return "bg-orange-500"; // Deleting
|
||||||
|
case "deleted":
|
||||||
|
return "bg-gray-600"; // Deleted
|
||||||
default:
|
default:
|
||||||
return "bg-gray-400"; // Unknown/neutral
|
return "bg-gray-400"; // Unknown/neutral
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export const POST: APIRoute = async ({ request }) => {
|
|||||||
// Fetch GitHub data in parallel
|
// Fetch GitHub data in parallel
|
||||||
const [basicAndForkedRepos, starredRepos, gitOrgs] = await Promise.all([
|
const [basicAndForkedRepos, starredRepos, gitOrgs] = await Promise.all([
|
||||||
getGithubRepositories({ octokit, config }),
|
getGithubRepositories({ octokit, config }),
|
||||||
config.githubConfig?.mirrorStarred
|
config.githubConfig?.includeStarred
|
||||||
? getGithubStarredRepositories({ octokit, config })
|
? getGithubStarredRepositories({ octokit, config })
|
||||||
: Promise.resolve([]),
|
: Promise.resolve([]),
|
||||||
getGithubOrganizations({ octokit, config }),
|
getGithubOrganizations({ octokit, config }),
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"@/*": [
|
"@/*": [
|
||||||
"./src/*"
|
"./src/*"
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
"types": ["bun-types"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,25 +35,24 @@ const buttonVariants = cva(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
function Button({
|
const Button = React.forwardRef<
|
||||||
className,
|
HTMLButtonElement,
|
||||||
variant,
|
React.ComponentProps<"button"> &
|
||||||
size,
|
VariantProps<typeof buttonVariants> & {
|
||||||
asChild = false,
|
asChild?: boolean
|
||||||
...props
|
}
|
||||||
}: React.ComponentProps<"button"> &
|
>(({ className, variant, size, asChild = false, ...props }, ref) => {
|
||||||
VariantProps<typeof buttonVariants> & {
|
|
||||||
asChild?: boolean
|
|
||||||
}) {
|
|
||||||
const Comp = asChild ? Slot : "button"
|
const Comp = asChild ? Slot : "button"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Comp
|
<Comp
|
||||||
data-slot="button"
|
data-slot="button"
|
||||||
className={cn(buttonVariants({ variant, size, className }))}
|
className={cn(buttonVariants({ variant, size, className }))}
|
||||||
|
ref={ref}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
Button.displayName = "Button"
|
||||||
|
|
||||||
export { Button, buttonVariants }
|
export { Button, buttonVariants }
|
||||||
|
|||||||
Reference in New Issue
Block a user