diff --git a/package-lock.json b/package-lock.json index 90dc12aa..b634ccb2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "@iptv-org/database", "dependencies": { - "@freearhey/core": "^0.2.1", + "@freearhey/core": "^0.2.2", "@joi/date": "^2.1.0", "@json2csv/formatters": "^7.0.3", "@json2csv/node": "^7.0.3", @@ -798,9 +798,9 @@ } }, "node_modules/@freearhey/core": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@freearhey/core/-/core-0.2.1.tgz", - "integrity": "sha512-kEdIxZClykKhGpgyCSlkwuVuSCCAWr3J5YvOUMJQDPgVAYvT5VbD8MYKPm+OwNi9T4HFmF6qqY90qwKJPoOXCA==", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@freearhey/core/-/core-0.2.2.tgz", + "integrity": "sha512-8eikSh+alXohY/0Qv8lls+6BG738vOqxGuLvMjwBasbwuz8S/Abr7fUAH65dGjPAsB3HMaDhjK5c6kcVz5GrcA==", "dependencies": { "@types/fs-extra": "^11.0.2", "@types/lodash": "^4.14.198", @@ -6552,9 +6552,9 @@ "integrity": "sha512-NCC3zz2+nvYd+Ckfh87rA47zfu2QsQpvc6k1yzTk+b9KzRj0wkGa8LSoGOXN6Zv4lRf/EIoZ80biDh9HOI+RNQ==" }, "@freearhey/core": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@freearhey/core/-/core-0.2.1.tgz", - "integrity": "sha512-kEdIxZClykKhGpgyCSlkwuVuSCCAWr3J5YvOUMJQDPgVAYvT5VbD8MYKPm+OwNi9T4HFmF6qqY90qwKJPoOXCA==", + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@freearhey/core/-/core-0.2.2.tgz", + "integrity": "sha512-8eikSh+alXohY/0Qv8lls+6BG738vOqxGuLvMjwBasbwuz8S/Abr7fUAH65dGjPAsB3HMaDhjK5c6kcVz5GrcA==", "requires": { "@types/fs-extra": "^11.0.2", "@types/lodash": "^4.14.198", diff --git a/package.json b/package.json index 0bf4b521..29c9b01b 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "testRegex": "tests/(.*?/)?.*test.(js|ts)$" }, "dependencies": { - "@freearhey/core": "^0.2.1", + "@freearhey/core": "^0.2.2", "@joi/date": "^2.1.0", "@json2csv/formatters": "^7.0.3", "@json2csv/node": "^7.0.3", diff --git a/scripts/db/validate.ts b/scripts/db/validate.ts index 578987a4..ac976969 100644 --- a/scripts/db/validate.ts +++ b/scripts/db/validate.ts @@ -129,11 +129,11 @@ async function main() { } const schema = Joi.object(schemes[filename]) - rows.forEach((row: string | string[] | boolean, i: number) => { + rows.all().forEach((row: { [key: string]: string }, i: number) => { const { error } = schema.validate(row, { abortEarly: false }) if (error) { error.details.forEach(detail => { - fileErrors.push({ line: i + 2, message: detail.message }) + fileErrors.push({ line: i + 2, row, message: detail.message }) }) } }) @@ -142,7 +142,8 @@ async function main() { logger.info(`\n${chalk.underline(filepath)}`) fileErrors.forEach(err => { const position = err.line.toString().padEnd(6, ' ') - logger.info(` ${chalk.gray(position)} ${err.message}`) + const id = err.row && err.row.id ? ` ${err.row.id}:` : '' + logger.info(` ${chalk.gray(position)}${id} ${err.message}`) }) globalErrors = globalErrors.concat(fileErrors) } diff --git a/tests/__data__/input/validate/invalid_value/channels.csv b/tests/__data__/input/validate/invalid_value/channels.csv index 133d1c8c..80a8fa02 100644 --- a/tests/__data__/input/validate/invalid_value/channels.csv +++ b/tests/__data__/input/validate/invalid_value/channels.csv @@ -1,2 +1,2 @@ id,name,alt_names,network,owners,country,subdivision,city,broadcast_area,languages,categories,is_nsfw,launched,closed,replaced_by,website,logo -002RadioTV.do,002 Radio TV,,,,DO,,,c/DO,spa,,FALSE,,,,https://www.002radio.com/,https://i.imgur.com/7oNe8xj.png \ No newline at end of file +002RadioTV.do,002 Radio TV,,,,DO,,,c/DO,spa,,FALSE,,,,ttps://www.002radio.com/,https://i.imgur.com/7oNe8xj.png \ No newline at end of file diff --git a/tests/db/validate.test.ts b/tests/db/validate.test.ts index 1f9897f6..961a6ffe 100644 --- a/tests/db/validate.test.ts +++ b/tests/db/validate.test.ts @@ -68,8 +68,13 @@ describe('db:validate', () => { process.exit(1) } catch (error) { expect((error as ExecError).status).toBe(1) - expect((error as ExecError).stdout).toContain('"aaa.us" is missing in the channels.csv') - expect((error as ExecError).stdout).toContain('1 error(s)') + expect((error as ExecError).stdout).toContain( + '2 "aaa.us" is missing in the channels.csv' + ) + expect((error as ExecError).stdout).toContain( + '2 002RadioTV.do: "website" must be a valid uri with a scheme matching the http|https pattern' + ) + expect((error as ExecError).stdout).toContain('2 error(s)') } }) diff --git a/yarn.lock b/yarn.lock index c3f07bfc..144c0da5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -341,10 +341,10 @@ resolved "https://registry.npmjs.org/@eslint/js/-/js-8.50.0.tgz" integrity sha512-NCC3zz2+nvYd+Ckfh87rA47zfu2QsQpvc6k1yzTk+b9KzRj0wkGa8LSoGOXN6Zv4lRf/EIoZ80biDh9HOI+RNQ== -"@freearhey/core@^0.2.1": - version "0.2.1" - resolved "https://registry.npmjs.org/@freearhey/core/-/core-0.2.1.tgz" - integrity sha512-kEdIxZClykKhGpgyCSlkwuVuSCCAWr3J5YvOUMJQDPgVAYvT5VbD8MYKPm+OwNi9T4HFmF6qqY90qwKJPoOXCA== +"@freearhey/core@^0.2.2": + version "0.2.2" + resolved "https://registry.npmjs.org/@freearhey/core/-/core-0.2.2.tgz" + integrity sha512-8eikSh+alXohY/0Qv8lls+6BG738vOqxGuLvMjwBasbwuz8S/Abr7fUAH65dGjPAsB3HMaDhjK5c6kcVz5GrcA== dependencies: "@types/fs-extra" "^11.0.2" "@types/lodash" "^4.14.198"