CRITICAL FIXES: - Fix noAsyncPromiseExecutor in xcoba.ts and xcoba2.ts * Removed async promise executor pattern * Refactored to proper promise chain with .then()/.catch() * Added proper error handling for unhandled rejections - Fix useIterableCallbackReturn in seed_berita.ts * Replaced forEach with for...of loop to avoid returning values in callbacks MEDIUM FIXES: - Fix useNodejsImportProtocol (728 files auto-fixed) * Updated Node.js builtin imports to use node: protocol * Files: eslint.config.mjs, vitest.config.ts, zgen/image.ts, and 725+ more - Fix useOptionalChain in xcoba.ts (auto-fixed) * Changed 'resOut && resOut.body' to 'resOut?.body' - Fix noImportantStyles in dark-mode-table.css * Added biome-ignore suppression comments with justification * Required to override Mantine UI library styles - Fix noUselessContinue in find-port.ts (auto-fixed) * Removed unnecessary continue statement - Fix useLiteralKeys (700+ files auto-fixed) * Simplified computed expressions to use literal keys * Example: obj['create'] -> obj.create RESULTS: - Errors reduced: 4,516 → 3,521 (-22%) - Warnings reduced: 3,861 → 2,083 (-46%) - Total issues reduced: 8,991 → 6,115 (-32%) - 735 files auto-fixed by biome lint --fix Remaining issues (~6,115): - Mostly noExplicitAny warnings requiring manual refactoring - Will be addressed in gradual code quality improvements Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
import type { PrismaClient } from "@prisma/client";
|
|
import { safeSeedUnique } from "./safeseedUnique";
|
|
import cliProgress from 'cli-progress';
|
|
|
|
type SafeSeedOptions = {
|
|
skipUpdate?: boolean;
|
|
silent?: boolean; // Opsional: untuk suppress log
|
|
};
|
|
|
|
/**
|
|
* Batch upsert with progress logging
|
|
*/
|
|
export async function safeSeedMany<T extends keyof PrismaClient>(
|
|
model: T,
|
|
items: Array<{ where: Record<string, any>; data: Record<string, any> }>,
|
|
options: SafeSeedOptions = {}
|
|
) {
|
|
const bar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
|
|
bar.start(items.length, 0);
|
|
|
|
let success = 0;
|
|
let failed = 0;
|
|
let skipped = 0;
|
|
|
|
for (const [index, item] of items.entries()) {
|
|
try {
|
|
const result = await safeSeedUnique(model, item.where, item.data, {
|
|
...options,
|
|
silent: true,
|
|
});
|
|
if (result) success++;
|
|
else skipped++;
|
|
} catch (err) {
|
|
failed++;
|
|
}
|
|
bar.update(index + 1);
|
|
}
|
|
|
|
bar.stop();
|
|
console.log(`✅ ${String(model)}: ${success} seeded, ${skipped} skipped, ${failed} failed`);
|
|
|
|
return { success, skipped, failed };
|
|
} |