From adc8e42bc9fd9c6003ec18fa626843ae1403753b Mon Sep 17 00:00:00 2001 From: Ioan Lucut Date: Mon, 2 Oct 2023 10:47:24 +0300 Subject: [PATCH] Refactor importSongsFromRcByAuthors and importSongsFromRcByIds to use COLON constant. --- package.json | 1 + temp-runners/importSongsFromRcByAuthors.ts | 3 +- temp-runners/importSongsFromRcByIds.ts | 6 +- temp-runners/rc_authors_to_process.txt | 65 ---------------------- temp-runners/rc_ids_to_process.txt | 1 - 5 files changed, 7 insertions(+), 69 deletions(-) diff --git a/package.json b/package.json index fdd29be81b..1c5ff3456b 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "reprocess:filename": "node --no-warnings=ExperimentalWarning --loader ts-node/esm ./bin/lyricsFileNameReprocessorRunner.ts", "import:rc:by-authors": "node --no-warnings=ExperimentalWarning --loader ts-node/esm ./temp-runners/importSongsFromRcByAuthors.ts", "import:rc:by-ids": "node --no-warnings=ExperimentalWarning --loader ts-node/esm ./temp-runners/importSongsFromRcByIds.ts", + "import:rc:ci": "npm run import:rc:by-authors && npm run import:rc:by-ids", "build:ci": "npm run lint && npm run test && npm run verify", "meta:ci": "npm run reprocess:filename && npm run reprocess:content && npm run verify && npm run format" }, diff --git a/temp-runners/importSongsFromRcByAuthors.ts b/temp-runners/importSongsFromRcByAuthors.ts index e66558bc79..d395936f2c 100644 --- a/temp-runners/importSongsFromRcByAuthors.ts +++ b/temp-runners/importSongsFromRcByAuthors.ts @@ -10,6 +10,7 @@ import { fileURLToPath } from 'url'; import { parse } from '../src/songParser.js'; import { print } from '../src/songPrinter.js'; import { + COLON, logFileWithLinkInConsole, logProcessingFile, NEW_LINE, @@ -49,7 +50,7 @@ const runFor = async (songsDirs: string[]) => { const allRcIds = allSongsInRepo.map(({ rcId }) => rcId).filter(Boolean); await pMap(rcAuthorPathsToProcess, async (pathConfig) => { - const [counts, composer, authorPath] = pathConfig.split(':'); + const [counts, composer, authorPath] = pathConfig.split(COLON); const dirToImportFrom = `${RC_DIR}/${authorPath}`; (await readFiles(dirToImportFrom)).forEach( ({ contentAsString, filePath, fileName }) => { diff --git a/temp-runners/importSongsFromRcByIds.ts b/temp-runners/importSongsFromRcByIds.ts index 04ae35d2cf..e2c3e52fc1 100644 --- a/temp-runners/importSongsFromRcByIds.ts +++ b/temp-runners/importSongsFromRcByIds.ts @@ -5,11 +5,12 @@ import fsExtra from 'fs-extra'; import dotenv from 'dotenv'; import recursive from 'recursive-readdir'; import pMap from 'p-map'; -import { flatten } from 'lodash-es'; +import { first, flatten } from 'lodash-es'; import { fileURLToPath } from 'url'; import { parse } from '../src/songParser.js'; import { print } from '../src/songPrinter.js'; import { + COLON, logFileWithLinkInConsole, logProcessingFile, NEW_LINE, @@ -56,7 +57,8 @@ const runFor = async (songsDirs: string[]) => { .map(({ rcId }) => rcId) .filter(Boolean); - await pMap(RC_IDS_TO_PROCESS, async (rcSongIdToImport) => { + await pMap(RC_IDS_TO_PROCESS, async (rcSongIdLine) => { + const rcSongIdToImport = first(rcSongIdLine.split(COLON)) as string; const filePath = RC_INDEX[rcSongIdToImport] as string; const contentAsString = fsExtra .readFileSync(filePath.replace('./', `${IN_LYRICS_PARSER}/`)) diff --git a/temp-runners/rc_authors_to_process.txt b/temp-runners/rc_authors_to_process.txt index b97980a4e8..c0969d20cd 100644 --- a/temp-runners/rc_authors_to_process.txt +++ b/temp-runners/rc_authors_to_process.txt @@ -1,67 +1,2 @@ 10:BBSO:Bbso -10:Excelsis Worship:Excelsis_worship -10:Excelsis Worship:Excelsis_worship -10:Omega:Omega -10:William J. Gaither:William_j_gaither -11:Callatis Praise:Callatis_praise -11:Eldad:Eldad -11:Florin Mesaroș:Florin_mesaros -11:Messis:Messis -11:Ramona Ibănescu:Ramona_ibanescu -12:Grup Eldad:Grup_eldad -12:Ionuţ Crăciun:Ionut_craciun -13:Andreea Popoi:Andreea_popoi -14:Emma Repede:Emma_repede -14:Sunny Tranca:Sunny_tranca -17:Ami şi Crista:Ami_si_crista -18:Ekklesia:Ekklesia -18:Grupul Eldad:Grupul_eldad -2:Armonix:Armonix 2:Bbso Baia Mare:Bbso_baia_mare -3:Adi Lup:Adi_lup -3:Ahava:Ahava -3:Alin, Emima Timofte:Alin_emima_timofte -3:Avalon:Avalon -3:Biserica Betania Dublin:Biserica_betania_dublin -3:Grupul Ava:Grupul_ava -3:Ioan Panican:Ioan_panican -3:Kari Jobe:Kari_jobe -4:Born again:Born_again -4:Casting Crowns:Casting_crowns -4:Damaris Cauneac:Damaris_cauneac -4:Elim Harmony Band:Elim_harmony_band -4:Harvest Arad:Harvest_arad -4:Iovan Miclea:Iovan_miclea -4:Sanctus Pro Deo:Sanctus_pro_deo -5:Adi Kovaci:Adi_kovaci -5:Agape:Agape -5:Betania Worship Dublin:Betania_worship_dublin -5:Contrast:Contrast -5:Eliza Pirosca:Eliza_pirosca -5:Marius Pop, Naomi Borota:Marius_pop_naomi_borota -5:Marius Pop:Marius_pop -5:Ruben Filoti:Ruben_filoti -5:Samuel Bratu:Samuel_bratu -5:Speranța_pentru_copii:Sperantapentrucopii -5:Utu Şuteu:Utu_suteu -5:William H.Doane:William_hdoane -6:Chris Tomlin:Chris_tomlin -6:Diana Pup:Diana_pup -6:Ekklesia Arad:Ekklesia_arad -6:Flaviu Mitar:Flaviu_mitar -6:Ioan Timofte:Ioan_timofte -6:Profides:Profides -6:Shalom:Shalom -6:Traian Dorz si Nicolae Moldoveanu:Traian_dorz_si_nicolae_moldoveanu -7:Andreea Mois:Andreea_mois -7:Andreea şi Andrei Mois:Andreea_si_andrei_mois -7:David Lela:David_lela -7:Dolores:Dolores -7:Laud:Laud -7:Michael W. Smith:Michael_w_smith -7:Not an idol:Not_an_idol -8:Grupul Speranta:Grupul_speranta -8:Tabara 477:Tabara -9:Adonia:Adonia -9:Chris:Chris -9:Dan Muncaciu:Dan_muncaciu diff --git a/temp-runners/rc_ids_to_process.txt b/temp-runners/rc_ids_to_process.txt index a0fb71f9e0..e69de29bb2 100644 --- a/temp-runners/rc_ids_to_process.txt +++ b/temp-runners/rc_ids_to_process.txt @@ -1 +0,0 @@ -212152