()
| 73 | } |
| 74 | |
| 75 | async function main() { |
| 76 | const args = parseArgs(); |
| 77 | console.log("Args:", args); |
| 78 | |
| 79 | if (!existsSync(args.input)) { |
| 80 | console.error(`Input not found: ${args.input}`); |
| 81 | console.error("Run scripts/extract-from-github.ts first."); |
| 82 | process.exit(1); |
| 83 | } |
| 84 | |
| 85 | const summary = { |
| 86 | processed: 0, |
| 87 | inserted: 0, |
| 88 | skipped_duplicate: 0, |
| 89 | skipped_other: 0, |
| 90 | failed: 0, |
| 91 | by_source: {} as Record<string, number>, |
| 92 | }; |
| 93 | |
| 94 | for await (const row of readRows(args.input)) { |
| 95 | if (summary.processed >= args.limit) break; |
| 96 | summary.processed++; |
| 97 | |
| 98 | const label = `${row.parsed.repository ?? row.github_repo_id} (${row.parsed.name})`; |
| 99 | |
| 100 | if (args.dryRun) { |
| 101 | console.log( |
| 102 | `[dry-run] would insert: ${label} (${row.parsed.components.length} components)`, |
| 103 | ); |
| 104 | summary.inserted++; |
| 105 | summary.by_source[row.discovery_source] = |
| 106 | (summary.by_source[row.discovery_source] ?? 0) + 1; |
| 107 | continue; |
| 108 | } |
| 109 | |
| 110 | try { |
| 111 | const { slug } = await insertPlugin( |
| 112 | { |
| 113 | name: row.parsed.name, |
| 114 | description: row.parsed.description, |
| 115 | logo: row.parsed.logo ?? null, |
| 116 | repository: row.parsed.repository, |
| 117 | homepage: row.parsed.homepage ?? null, |
| 118 | license: row.license ?? row.parsed.license ?? null, |
| 119 | keywords: row.parsed.keywords, |
| 120 | author_name: row.parsed.author_name ?? null, |
| 121 | author_url: row.parsed.author_url ?? null, |
| 122 | author_avatar: row.parsed.author_avatar ?? null, |
| 123 | components: row.parsed.components, |
| 124 | }, |
| 125 | { |
| 126 | ownerId: null, |
| 127 | source: row.discovery_source, |
| 128 | githubRepoId: row.github_repo_id, |
| 129 | skipScan: true, |
| 130 | }, |
| 131 | ); |
| 132 | summary.inserted++; |
no test coverage detected