mirror of
https://github.com/iptv-org/database.git
synced 2024-12-21 23:40:23 -05:00
Replace require() with import
This commit is contained in:
parent
67cc28a408
commit
ea14a63978
16 changed files with 93 additions and 74 deletions
|
@ -15,19 +15,24 @@ export class IssueLoader {
|
||||||
if (TESTING) {
|
if (TESTING) {
|
||||||
switch (labels) {
|
switch (labels) {
|
||||||
case 'channels:add,approved':
|
case 'channels:add,approved':
|
||||||
issues = require('../../tests/__data__/input/issues/channels_add_approved.js')
|
issues = (await import('../../tests/__data__/input/issues/channels_add_approved.js'))
|
||||||
|
.default
|
||||||
break
|
break
|
||||||
case 'channels:edit,approved':
|
case 'channels:edit,approved':
|
||||||
issues = require('../../tests/__data__/input/issues/channels_edit_approved.js')
|
issues = (await import('../../tests/__data__/input/issues/channels_edit_approved.js'))
|
||||||
|
.default
|
||||||
break
|
break
|
||||||
case 'channels:remove,approved':
|
case 'channels:remove,approved':
|
||||||
issues = require('../../tests/__data__/input/issues/channels_remove_approved.js')
|
issues = (await import('../../tests/__data__/input/issues/channels_remove_approved.js'))
|
||||||
|
.default
|
||||||
break
|
break
|
||||||
case 'blocklist:add,approved':
|
case 'blocklist:add,approved':
|
||||||
issues = require('../../tests/__data__/input/issues/blocklist_add_approved.js')
|
issues = (await import('../../tests/__data__/input/issues/blocklist_add_approved.js'))
|
||||||
|
.default
|
||||||
break
|
break
|
||||||
case 'blocklist:remove,approved':
|
case 'blocklist:remove,approved':
|
||||||
issues = require('../../tests/__data__/input/issues/blocklist_remove_approved.js')
|
issues = (await import('../../tests/__data__/input/issues/blocklist_remove_approved.js'))
|
||||||
|
.default
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Collection, Storage, File, Dictionary, Logger } from '@freearhey/core'
|
import { Collection, Storage, File, Dictionary, Logger } from '@freearhey/core'
|
||||||
import { DATA_DIR } from '../constants'
|
import { DATA_DIR } from '../constants'
|
||||||
|
import schemesData from '../schemes'
|
||||||
import { program } from 'commander'
|
import { program } from 'commander'
|
||||||
import Joi from 'joi'
|
import Joi from 'joi'
|
||||||
import { CSVParser, IDCreator } from '../core'
|
import { CSVParser, IDCreator } from '../core'
|
||||||
|
@ -10,7 +11,7 @@ program.argument('[filepath]', 'Path to file to validate').parse(process.argv)
|
||||||
const logger = new Logger()
|
const logger = new Logger()
|
||||||
const buffer = new Dictionary()
|
const buffer = new Dictionary()
|
||||||
const files = new Dictionary()
|
const files = new Dictionary()
|
||||||
const schemes: { [key: string]: object } = require('../schemes')
|
const schemes: { [key: string]: object } = schemesData
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const dataStorage = new Storage(DATA_DIR)
|
const dataStorage = new Storage(DATA_DIR)
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
const Joi = require('joi')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
channel: Joi.string()
|
|
||||||
.regex(/^[A-Za-z0-9]+\.[a-z]{2}$/)
|
|
||||||
.required(),
|
|
||||||
ref: Joi.string().uri().required()
|
|
||||||
}
|
|
8
scripts/schemes/blocklist.ts
Normal file
8
scripts/schemes/blocklist.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import Joi from 'joi'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
channel: Joi.string()
|
||||||
|
.regex(/^[A-Za-z0-9]+\.[a-z]{2}$/)
|
||||||
|
.required(),
|
||||||
|
ref: Joi.string().uri().required()
|
||||||
|
}
|
|
@ -1,10 +0,0 @@
|
||||||
const Joi = require('joi')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
id: Joi.string()
|
|
||||||
.regex(/^[a-z]+$/)
|
|
||||||
.required(),
|
|
||||||
name: Joi.string()
|
|
||||||
.regex(/^[A-Z]+$/i)
|
|
||||||
.required()
|
|
||||||
}
|
|
10
scripts/schemes/categories.ts
Normal file
10
scripts/schemes/categories.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import Joi from 'joi'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
id: Joi.string()
|
||||||
|
.regex(/^[a-z]+$/)
|
||||||
|
.required(),
|
||||||
|
name: Joi.string()
|
||||||
|
.regex(/^[A-Z]+$/i)
|
||||||
|
.required()
|
||||||
|
}
|
|
@ -1,8 +1,11 @@
|
||||||
const Joi = require('joi').extend(require('@joi/date'))
|
import BaseJoi from 'joi'
|
||||||
const path = require('path')
|
import JoiDate from '@joi/date'
|
||||||
const url = require('url')
|
import path from 'path'
|
||||||
|
import url from 'url'
|
||||||
|
|
||||||
module.exports = {
|
const Joi = BaseJoi.extend(JoiDate)
|
||||||
|
|
||||||
|
export default {
|
||||||
id: Joi.string()
|
id: Joi.string()
|
||||||
.regex(/^[A-Za-z0-9]+\.[a-z]{2}$/)
|
.regex(/^[A-Za-z0-9]+\.[a-z]{2}$/)
|
||||||
.required(),
|
.required(),
|
|
@ -1,18 +0,0 @@
|
||||||
const Joi = require('joi')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
name: Joi.string()
|
|
||||||
.regex(/^[\sA-Z\u00C0-\u00FF().-]+$/i)
|
|
||||||
.required(),
|
|
||||||
code: Joi.string()
|
|
||||||
.regex(/^[A-Z]{2}$/)
|
|
||||||
.required(),
|
|
||||||
languages: Joi.array().items(
|
|
||||||
Joi.string()
|
|
||||||
.regex(/^[a-z]{3}$/)
|
|
||||||
.required()
|
|
||||||
),
|
|
||||||
flag: Joi.string()
|
|
||||||
.regex(/^[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]$/)
|
|
||||||
.required()
|
|
||||||
}
|
|
18
scripts/schemes/countries.ts
Normal file
18
scripts/schemes/countries.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import Joi from 'joi'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: Joi.string()
|
||||||
|
.regex(/^[\sA-Z\u00C0-\u00FF().-]+$/i)
|
||||||
|
.required(),
|
||||||
|
code: Joi.string()
|
||||||
|
.regex(/^[A-Z]{2}$/)
|
||||||
|
.required(),
|
||||||
|
languages: Joi.array().items(
|
||||||
|
Joi.string()
|
||||||
|
.regex(/^[a-z]{3}$/)
|
||||||
|
.required()
|
||||||
|
),
|
||||||
|
flag: Joi.string()
|
||||||
|
.regex(/^[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]$/)
|
||||||
|
.required()
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
exports.channels = require('./channels')
|
|
||||||
exports.categories = require('./categories')
|
|
||||||
exports.countries = require('./countries')
|
|
||||||
exports.languages = require('./languages')
|
|
||||||
exports.regions = require('./regions')
|
|
||||||
exports.subdivisions = require('./subdivisions')
|
|
||||||
exports.blocklist = require('./blocklist')
|
|
17
scripts/schemes/index.ts
Normal file
17
scripts/schemes/index.ts
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import { default as channels } from './channels'
|
||||||
|
import { default as categories } from './categories'
|
||||||
|
import { default as countries } from './countries'
|
||||||
|
import { default as languages } from './languages'
|
||||||
|
import { default as regions } from './regions'
|
||||||
|
import { default as subdivisions } from './subdivisions'
|
||||||
|
import { default as blocklist } from './blocklist'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
channels,
|
||||||
|
categories,
|
||||||
|
countries,
|
||||||
|
languages,
|
||||||
|
regions,
|
||||||
|
subdivisions,
|
||||||
|
blocklist
|
||||||
|
}
|
|
@ -1,8 +0,0 @@
|
||||||
const Joi = require('joi')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
code: Joi.string()
|
|
||||||
.regex(/^[a-z]{3}$/)
|
|
||||||
.required(),
|
|
||||||
name: Joi.string().required()
|
|
||||||
}
|
|
8
scripts/schemes/languages.ts
Normal file
8
scripts/schemes/languages.ts
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
import Joi from 'joi'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
code: Joi.string()
|
||||||
|
.regex(/^[a-z]{3}$/)
|
||||||
|
.required(),
|
||||||
|
name: Joi.string().required()
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
const Joi = require('joi')
|
import Joi from 'joi'
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
name: Joi.string()
|
name: Joi.string()
|
||||||
.regex(/^[\sA-Z\u00C0-\u00FF().,-]+$/i)
|
.regex(/^[\sA-Z\u00C0-\u00FF().,-]+$/i)
|
||||||
.required(),
|
.required(),
|
|
@ -1,11 +0,0 @@
|
||||||
const Joi = require('joi')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
country: Joi.string()
|
|
||||||
.regex(/^[A-Z]{2}$/)
|
|
||||||
.required(),
|
|
||||||
name: Joi.string().required(),
|
|
||||||
code: Joi.string()
|
|
||||||
.regex(/^[A-Z]{2}-[A-Z0-9]{1,3}$/)
|
|
||||||
.required()
|
|
||||||
}
|
|
11
scripts/schemes/subdivisions.ts
Normal file
11
scripts/schemes/subdivisions.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import Joi from 'joi'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
country: Joi.string()
|
||||||
|
.regex(/^[A-Z]{2}$/)
|
||||||
|
.required(),
|
||||||
|
name: Joi.string().required(),
|
||||||
|
code: Joi.string()
|
||||||
|
.regex(/^[A-Z]{2}-[A-Z0-9]{1,3}$/)
|
||||||
|
.required()
|
||||||
|
}
|
Loading…
Reference in a new issue