mirror of
https://github.com/Lifeforge-app/lifeforge.git
synced 2026-06-28 06:46:24 +00:00
Former-commit-id: fdfcdd448252f83750bfc4cc9c96cd71b50a1de8 [formerly d8851261213d137b7033f6c5463ed9ebcd8702b6] [formerly 412fc672a3cc15d14804d81b8a6ba90b2e564017 [formerly 12391a582c230f1d9fa4ea6c84ee2062d3d8805b]] Former-commit-id: 034eeb80e5b9121c5cc68b21356b4807def94a92 [formerly 830833354a52b04ef1ebf2e9b16663ac5c702610] Former-commit-id: 2163c17f0b2e4221f90731b0ecd8a8a8b9d4d692
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import dotenv from 'dotenv'
|
|
import _ from 'lodash'
|
|
import path from 'path'
|
|
import Pocketbase from 'pocketbase'
|
|
|
|
dotenv.config({
|
|
path: path.resolve(__dirname, '../server/env/.env.local')
|
|
})
|
|
|
|
if (!process.env.PB_HOST || !process.env.PB_EMAIL || !process.env.PB_PASSWORD) {
|
|
console.error(
|
|
'Please provide PB_HOST, PB_EMAIL, and PB_PASSWORD in your environment variables.'
|
|
)
|
|
process.exit(1)
|
|
}
|
|
|
|
const pb = new Pocketbase(process.env.PB_HOST)
|
|
|
|
try {
|
|
await pb
|
|
.collection('_superusers')
|
|
.authWithPassword(process.env.PB_EMAIL, process.env.PB_PASSWORD)
|
|
|
|
if (!pb.authStore.isSuperuser || !pb.authStore.isValid) {
|
|
console.error('Invalid credentials.')
|
|
process.exit(1)
|
|
}
|
|
} catch {
|
|
console.error('Server is not reachable or credentials are invalid.')
|
|
process.exit(1)
|
|
}
|
|
|
|
const allEntries = await pb.collection('scores_library__entries').getFullList()
|
|
|
|
for (const entry of allEntries) {
|
|
const firstPart = entry.pdf.split('_')[0] as string
|
|
if (firstPart.match(/^\d+$/)) {
|
|
const firstPartNumber = parseInt(firstPart, 10)
|
|
|
|
if (firstPartNumber < 1000) continue
|
|
|
|
await pb.collection('scores_library__entries').update(entry.id, {
|
|
guitar_world_id: firstPartNumber
|
|
})
|
|
}
|
|
}
|