Install @freearhey/core

pull/14297/head
freearhey 1 year ago
parent 03208a262a
commit 4c92b4ecb1

61
package-lock.json generated

@ -7,6 +7,7 @@
"name": "iptv",
"license": "MIT",
"dependencies": {
"@freearhey/core": "^0.1.2",
"@octokit/core": "^4.2.1",
"@octokit/plugin-paginate-rest": "^7.1.2",
"@octokit/plugin-rest-endpoint-methods": "^7.1.3",
@ -675,6 +676,32 @@
"node": ">=12"
}
},
"node_modules/@freearhey/core": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/@freearhey/core/-/core-0.1.2.tgz",
"integrity": "sha512-o6FaLHiKED0JkUXxqHcUUM2P+Jd4kvE96p0MZlLjhCFAPii/lVr5mTwrHehKMzve/r7AbDUX7kyNLNG8Qec6uw==",
"dependencies": {
"@types/fs-extra": "^11.0.2",
"@types/lodash": "^4.14.198",
"fs-extra": "^11.1.1",
"glob": "^10.3.4",
"lodash": "^4.17.21",
"natural-orderby": "^3.0.2",
"normalize-url": "^6.1.0",
"signale": "^1.4.0"
}
},
"node_modules/@freearhey/core/node_modules/normalize-url": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz",
"integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@isaacs/cliui": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
@ -1430,9 +1457,9 @@
}
},
"node_modules/@types/fs-extra": {
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.1.tgz",
"integrity": "sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==",
"version": "11.0.2",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.2.tgz",
"integrity": "sha512-c0hrgAOVYr21EX8J0jBMXGLMgJqVf/v6yxi0dLaJboW9aQPh16Id+z6w2Tx1hm+piJOLv8xPfVKZCLfjPw/IMQ==",
"dependencies": {
"@types/jsonfile": "*",
"@types/node": "*"
@ -5563,6 +5590,28 @@
"@jridgewell/trace-mapping": "0.3.9"
}
},
"@freearhey/core": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/@freearhey/core/-/core-0.1.2.tgz",
"integrity": "sha512-o6FaLHiKED0JkUXxqHcUUM2P+Jd4kvE96p0MZlLjhCFAPii/lVr5mTwrHehKMzve/r7AbDUX7kyNLNG8Qec6uw==",
"requires": {
"@types/fs-extra": "^11.0.2",
"@types/lodash": "^4.14.198",
"fs-extra": "^11.1.1",
"glob": "^10.3.4",
"lodash": "^4.17.21",
"natural-orderby": "^3.0.2",
"normalize-url": "^6.1.0",
"signale": "^1.4.0"
},
"dependencies": {
"normalize-url": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz",
"integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A=="
}
}
},
"@isaacs/cliui": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
@ -6201,9 +6250,9 @@
}
},
"@types/fs-extra": {
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.1.tgz",
"integrity": "sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==",
"version": "11.0.2",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.2.tgz",
"integrity": "sha512-c0hrgAOVYr21EX8J0jBMXGLMgJqVf/v6yxi0dLaJboW9aQPh16Id+z6w2Tx1hm+piJOLv8xPfVKZCLfjPw/IMQ==",
"requires": {
"@types/jsonfile": "*",
"@types/node": "*"

@ -25,9 +25,9 @@
},
"jest": {
"transform": {
"^.*test.(ts|js)$": "ts-jest"
"^.+\\.ts$": "ts-jest"
},
"testRegex": "tests/(.*?/)?.*test.(ts|js)$",
"testRegex": "tests/(.*?/)?.*test.ts$",
"setupFilesAfterEnv": [
"jest-expect-message"
]
@ -40,8 +40,8 @@
"author": "Arhey",
"private": true,
"license": "MIT",
"type": "module",
"dependencies": {
"@freearhey/core": "^0.1.2",
"@octokit/core": "^4.2.1",
"@octokit/plugin-paginate-rest": "^7.1.2",
"@octokit/plugin-rest-endpoint-methods": "^7.1.3",

@ -1,5 +1,6 @@
import { Logger, Storage } from '@freearhey/core'
import { API_DIR, STREAMS_DIR } from '../../constants'
import { Logger, PlaylistParser, Storage } from '../../core'
import { PlaylistParser } from '../../core'
import { Stream } from '../../models'
async function main() {

@ -1,5 +1,6 @@
import { Logger, Storage, Collection } from '@freearhey/core'
import { STREAMS_DIR, DATA_DIR } from '../../constants'
import { Storage, Logger, PlaylistParser, Collection } from '../../core'
import { PlaylistParser } from '../../core'
import { Stream, Playlist, Channel } from '../../models'
import { program } from 'commander'

@ -1,7 +1,6 @@
import { File, PlaylistParser, Storage } from '../../core'
import { Logger, Storage, Collection, File } from '@freearhey/core'
import { PlaylistParser } from '../../core'
import { Stream, Category, Channel, Language, Country, Region, Subdivision } from '../../models'
import { Collection } from '../../core/collection'
import { Logger } from '../../core/logger'
import _ from 'lodash'
import {
CategoriesGenerator,
@ -124,7 +123,7 @@ async function loadStreams({
if (channel.logo) stream.logo = channel.logo
} else {
const file = new File(stream.filepath)
const [_, countryCode] = file.getFilename().match(/^([a-z]{2})(_|$)/) || [null, null]
const [_, countryCode] = file.name().match(/^([a-z]{2})(_|$)/) || [null, null]
const defaultBroadcastArea = countryCode ? [`c/${countryCode.toUpperCase()}`] : []
stream.broadcastArea = new Collection(defaultBroadcastArea)

@ -1,5 +1,6 @@
import { Logger, Storage, Collection, Dictionary } from '@freearhey/core'
import { DATA_DIR, STREAMS_DIR } from '../../constants'
import { Storage, Logger, Collection, Dictionary, IssueLoader, PlaylistParser } from '../../core'
import { IssueLoader, PlaylistParser } from '../../core'
import { Stream, Playlist, Channel, Issue } from '../../models'
let processedIssues = new Collection()

@ -1,4 +1,5 @@
import { Logger, Storage, PlaylistParser, Collection, File, Dictionary } from '../../core'
import { Logger, Storage, Collection, Dictionary, File } from '@freearhey/core'
import { PlaylistParser } from '../../core'
import { Channel, Stream, Blocked } from '../../models'
import { program } from 'commander'
import chalk from 'chalk'

@ -1,5 +1,6 @@
import { Logger } from '@freearhey/core'
import { CategoryTable, CountryTable, LanguageTable, RegionTable } from '../../tables'
import { Logger, Markdown } from '../../core'
import { Markdown } from '../../core'
import { README_DIR } from '../../constants'
import path from 'path'

@ -1,5 +1,6 @@
import { Logger, Storage, Collection, Dictionary } from '@freearhey/core'
import { DATA_DIR, STREAMS_DIR } from '../../constants'
import { Collection, Dictionary, IssueLoader, Storage, Logger, PlaylistParser } from '../../core'
import { IssueLoader, PlaylistParser } from '../../core'
import { Blocked, Channel, Issue, Stream } from '../../models'
async function main() {

@ -1,175 +0,0 @@
import _ from 'lodash'
import { orderBy, Order } from 'natural-orderby'
import { Dictionary } from './'
type Iteratee = (value: any, value2?: any) => void
export class Collection {
_items: any[]
constructor(items?: any[]) {
this._items = Array.isArray(items) ? items : []
}
first(predicate?: Iteratee) {
if (predicate) {
return this._items.find(predicate)
}
return this._items[0]
}
last(predicate?: Iteratee) {
if (predicate) {
return _.findLast(this._items, predicate)
}
return this._items[this._items.length - 1]
}
find(iteratee: Iteratee): Collection {
const found = this._items.filter(iteratee)
return new Collection(found)
}
add(data: any) {
this._items.push(data)
return this
}
intersects(collection: Collection): boolean {
return _.intersection(this._items, collection.all()).length > 0
}
count() {
return this._items.length
}
join(separator: string) {
return this._items.join(separator)
}
indexOf(value: string) {
return this._items.indexOf(value)
}
push(data: any) {
this.add(data)
}
uniq() {
const items = _.uniq(this._items)
return new Collection(items)
}
reduce(iteratee: Iteratee, accumulator: any) {
const items = _.reduce(this._items, iteratee, accumulator)
return new Collection(items)
}
filter(iteratee: Iteratee) {
const items = _.filter(this._items, iteratee)
return new Collection(items)
}
forEach(iteratee: Iteratee) {
for (let item of this._items) {
iteratee(item)
}
return this
}
remove(iteratee: Iteratee): Collection {
const removed = _.remove(this._items, iteratee)
return new Collection(removed)
}
concat(collection: Collection) {
const items = this._items.concat(collection._items)
return new Collection(items)
}
isEmpty(): boolean {
return this._items.length === 0
}
notEmpty(): boolean {
return this._items.length > 0
}
sort() {
const items = this._items.sort()
return new Collection(items)
}
orderBy(iteratees: Iteratee | Iteratee[], orders?: Order | Order[]) {
const items = orderBy(this._items, iteratees, orders)
return new Collection(items)
}
keyBy(iteratee: Iteratee) {
const items = _.keyBy(this._items, iteratee)
return new Dictionary(items)
}
empty() {
return this._items.length === 0
}
includes(value: any) {
if (typeof value === 'function') {
const found = this._items.find(value)
return !!found
}
return this._items.includes(value)
}
missing(value: any) {
if (typeof value === 'function') {
const found = this._items.find(value)
return !found
}
return !this._items.includes(value)
}
uniqBy(iteratee: Iteratee) {
const items = _.uniqBy(this._items, iteratee)
return new Collection(items)
}
groupBy(iteratee: Iteratee) {
const object = _.groupBy(this._items, iteratee)
return new Dictionary(object)
}
map(iteratee: Iteratee) {
const items = this._items.map(iteratee)
return new Collection(items)
}
all() {
return this._items
}
toJSON() {
return JSON.stringify(this._items)
}
}

@ -1,31 +0,0 @@
export class Dictionary {
dict: any
constructor(dict?: any) {
this.dict = dict || {}
}
set(key: string, value: any) {
this.dict[key] = value
}
has(key: string): boolean {
return !!this.dict[key]
}
missing(key: string): boolean {
return !this.dict[key]
}
get(key: string): any {
return this.dict[key] ? this.dict[key] : undefined
}
keys(): string[] {
return Object.keys(this.dict)
}
data() {
return this.dict
}
}

@ -1,31 +0,0 @@
import * as path from 'path'
export class File {
filepath: string
content: string
constructor(filepath: string, content?: string) {
this.filepath = path.normalize(filepath)
this.content = content || ''
}
getFilename() {
return path.parse(this.filepath).name
}
dirname() {
return path.dirname(this.filepath)
}
basename() {
return path.basename(this.filepath)
}
append(data: string) {
this.content = this.content + data
}
extension() {
return this.filepath.split('.').pop()
}
}

@ -1,13 +1,7 @@
export * from './logger'
export * from './playlistParser'
export * from './numberParser'
export * from './logParser'
export * from './markdown'
export * from './file'
export * from './collection'
export * from './dictionary'
export * from './storage'
export * from './url'
export * from './issueLoader'
export * from './issueParser'
export * from './htmlTable'

@ -1,7 +1,8 @@
import { Collection } from '@freearhey/core'
import { restEndpointMethods } from '@octokit/plugin-rest-endpoint-methods'
import { paginateRest } from '@octokit/plugin-paginate-rest'
import { Octokit } from '@octokit/core'
import { Collection, IssueParser } from './'
import { IssueParser } from './'
import { TESTING, OWNER, REPO } from '../constants'
const CustomOctokit = Octokit.plugin(paginateRest, restEndpointMethods)
@ -14,23 +15,22 @@ export class IssueLoader {
if (TESTING) {
switch (labels) {
case 'streams:add':
issues = (await import('../../tests/__data__/input/issues/streams_add')).default
issues = require('../../tests/__data__/input/issues/streams_add.js')
break
case 'streams:edit':
issues = (await import('../../tests/__data__/input/issues/streams_edit')).default
issues = require('../../tests/__data__/input/issues/streams_edit.js')
break
case 'broken stream':
issues = (await import('../../tests/__data__/input/issues/broken_stream')).default
issues = require('../../tests/__data__/input/issues/broken_stream.js')
break
case 'streams:add,approved':
issues = (await import('../../tests/__data__/input/issues/streams_add_approved')).default
issues = require('../../tests/__data__/input/issues/streams_add_approved.js')
break
case 'streams:edit,approved':
issues = (await import('../../tests/__data__/input/issues/streams_edit_approved')).default
issues = require('../../tests/__data__/input/issues/streams_edit_approved.js')
break
case 'streams:remove,approved':
issues = (await import('../../tests/__data__/input/issues/streams_remove_approved'))
.default
issues = require('../../tests/__data__/input/issues/streams_remove_approved.js')
break
}
} else {

@ -1,4 +1,4 @@
import { Dictionary } from './'
import { Dictionary } from '@freearhey/core'
import { Issue } from '../models'
import _ from 'lodash'

@ -1,9 +0,0 @@
import signale from 'signale'
const { Signale } = signale
export class Logger extends Signale {
constructor(options?: any) {
super(options)
}
}

@ -1,6 +1,6 @@
import { Collection, Storage } from '@freearhey/core'
import parser from 'iptv-playlist-parser'
import { Stream } from '../models'
import { Collection, Storage } from './'
import path from 'path'
import { STREAMS_DIR } from '../constants'
@ -26,7 +26,7 @@ export class PlaylistParser {
async parseFile(filepath: string): Promise<Collection> {
const streams = new Collection()
const content = await this.storage.read(filepath)
const content = await this.storage.load(filepath)
const parsed: parser.Playlist = parser.parse(content)
parsed.items.forEach((item: parser.PlaylistItem) => {

@ -1,84 +0,0 @@
import { File, Collection } from './'
import * as path from 'path'
import fs from 'fs-extra'
import { glob } from 'glob'
export class Storage {
rootDir: string
constructor(rootDir?: string) {
this.rootDir = path.normalize(rootDir || './')
}
async list(pattern: string): Promise<string[]> {
const files = await glob(pattern, {
cwd: this.rootDir
})
return files.sort()
}
async createDir(dir: string): Promise<void> {
if (await fs.exists(dir)) return
await fs.mkdir(dir, { recursive: true }).catch(console.error)
}
async load(filepath: string): Promise<any> {
return this.read(filepath)
}
async read(filepath: string): Promise<any> {
const absFilepath = path.join(this.rootDir, filepath)
return await fs.readFile(absFilepath, { encoding: 'utf8' })
}
async json(filepath: string): Promise<any> {
const absFilepath = path.join(this.rootDir, filepath)
const content = await fs.readFile(absFilepath, { encoding: 'utf8' })
return JSON.parse(content)
}
async exists(filepath: string): Promise<boolean> {
const absFilepath = path.join(this.rootDir, filepath)
return await fs.exists(absFilepath)
}
async write(filepath: string, data: string = ''): Promise<void> {
const absFilepath = path.join(this.rootDir, filepath)
const dir = path.dirname(absFilepath)
await this.createDir(dir)
await fs.writeFile(absFilepath, data, { encoding: 'utf8', flag: 'w' })
}
async append(filepath: string, data: string = ''): Promise<void> {
const absFilepath = path.join(this.rootDir, filepath)
await fs.appendFile(absFilepath, data, { encoding: 'utf8', flag: 'w' })
}
async clear(filepath: string): Promise<void> {
await this.write(filepath)
}
async createStream(filepath: string): Promise<NodeJS.WriteStream> {
const absFilepath = path.join(this.rootDir, filepath)
const dir = path.dirname(absFilepath)
await this.createDir(dir)
return fs.createWriteStream(absFilepath) as unknown as NodeJS.WriteStream
}
async save(filepath: string, content: string): Promise<void> {
await this.write(filepath, content)
}
async saveFile(file: File): Promise<void> {
await this.write(file.filepath, file.content)
}
}

@ -1,20 +0,0 @@
import normalizeUrl from 'normalize-url'
export class URL {
url: string
constructor(url: string) {
this.url = url
}
normalize(): URL {
const normalized = normalizeUrl(this.url, { stripWWW: false })
this.url = decodeURIComponent(normalized).replace(/\s/g, '+')
return this
}
toString(): string {
return this.url
}
}

@ -1,5 +1,5 @@
import { Generator } from './generator'
import { Collection, Storage, Logger } from '../core'
import { Collection, Storage, Logger } from '@freearhey/core'
import { Stream, Category, Playlist } from '../models'
import { PUBLIC_DIR } from '../constants'

@ -1,5 +1,5 @@
import { Generator } from './generator'
import { Collection, Storage, Logger } from '../core'
import { Collection, Storage, Logger } from '@freearhey/core'
import { Country, Region, Subdivision, Stream, Playlist } from '../models'
import { PUBLIC_DIR } from '../constants'

@ -1,5 +1,5 @@
import { Generator } from './generator'
import { Collection, Storage, Logger } from '../core'
import { Collection, Storage, Logger } from '@freearhey/core'
import { Stream, Playlist, Category } from '../models'
import { PUBLIC_DIR } from '../constants'

@ -1,5 +1,5 @@
import { Generator } from './generator'
import { Collection, Storage, Logger } from '../core'
import { Collection, Storage, Logger } from '@freearhey/core'
import { Stream, Playlist, Country, Subdivision, Region } from '../models'
import { PUBLIC_DIR } from '../constants'

@ -1,4 +1,4 @@
import { Collection, Logger, Storage } from '../core'
import { Collection, Logger, Storage } from '@freearhey/core'
import { Stream, Playlist } from '../models'
import { Generator } from './generator'
import { PUBLIC_DIR } from '../constants'

@ -1,5 +1,5 @@
import { Generator } from './generator'
import { Collection, Storage, Logger } from '../core'
import { Collection, Storage, Logger } from '@freearhey/core'
import { Stream, Playlist, Language } from '../models'
import { PUBLIC_DIR } from '../constants'

@ -1,4 +1,4 @@
import { Collection, Logger, Storage } from '../core'
import { Collection, Logger, Storage } from '@freearhey/core'
import { Stream, Playlist } from '../models'
import { Generator } from './generator'
import { PUBLIC_DIR } from '../constants'

@ -1,5 +1,5 @@
import { Generator } from './generator'
import { Collection, Storage, Logger } from '../core'
import { Collection, Storage, Logger } from '@freearhey/core'
import { Stream, Playlist, Region } from '../models'
import { PUBLIC_DIR } from '../constants'

@ -1,5 +1,5 @@
import { Generator } from './generator'
import { Collection, Storage, Logger } from '../core'
import { Collection, Storage, Logger } from '@freearhey/core'
import { Playlist, Language, Stream } from '../models'
import { PUBLIC_DIR } from '../constants'

@ -1,5 +1,5 @@
import { Generator } from './generator'
import { Collection, Storage, Logger } from '../core'
import { Collection, Storage, Logger } from '@freearhey/core'
import { Playlist, Subdivision, Region } from '../models'
import { PUBLIC_DIR } from '../constants'

@ -1,4 +1,4 @@
import { Collection } from '../core'
import { Collection } from '@freearhey/core'
type ChannelProps = {
id: string

@ -1,4 +1,4 @@
import { Dictionary } from '../core'
import { Dictionary } from '@freearhey/core'
type IssueProps = {
number: number

@ -1,4 +1,4 @@
import { Collection } from '../core'
import { Collection } from '@freearhey/core'
import { Stream } from '../models'
type PlaylistOptions = {

@ -1,4 +1,4 @@
import { Collection } from '../core'
import { Collection } from '@freearhey/core'
type RegionProps = {
code: string

@ -1,4 +1,4 @@
import { URL, Collection } from '../core'
import { URL, Collection } from '@freearhey/core'
import { Category, Language } from './index'
type StreamProps = {
@ -86,7 +86,7 @@ export class Stream {
}
noCategories(): boolean {
return this.categories.empty()
return this.categories.isEmpty()
}
hasCategory(category: Category): boolean {
@ -94,7 +94,7 @@ export class Stream {
}
noLanguages(): boolean {
return this.languages.empty()
return this.languages.isEmpty()
}
hasLanguage(language: Language): boolean {
@ -102,7 +102,7 @@ export class Stream {
}
noBroadcastArea(): boolean {
return this.broadcastArea.empty()
return this.broadcastArea.isEmpty()
}
isInternational(): boolean {

@ -1,4 +1,5 @@
import { Storage, HTMLTable, Collection, LogParser, LogItem, File } from '../core'
import { Storage, Collection, File } from '@freearhey/core'
import { HTMLTable, LogParser, LogItem } from '../core'
import { Category } from '../models'
import { DATA_DIR, LOGS_DIR, README_DIR } from '../constants'
import { Table } from './table'
@ -13,7 +14,7 @@ export class CategoryTable implements Table {
const parser = new LogParser()
const logsStorage = new Storage(LOGS_DIR)
const generatorsLog = await logsStorage.read('generators.log')
const generatorsLog = await logsStorage.load('generators.log')
let data = new Collection()
parser
@ -21,7 +22,7 @@ export class CategoryTable implements Table {
.filter((logItem: LogItem) => logItem.filepath.includes('categories/'))
.forEach((logItem: LogItem) => {
const file = new File(logItem.filepath)
const categoryId = file.getFilename()
const categoryId = file.name()
const category: Category = categories.first(
(category: Category) => category.id === categoryId
)

@ -1,4 +1,5 @@
import { Storage, HTMLTable, Collection, LogParser, LogItem, File } from '../core'
import { Storage, Collection, File } from '@freearhey/core'
import { HTMLTable, LogParser, LogItem } from '../core'
import { Country, Subdivision } from '../models'
import { DATA_DIR, LOGS_DIR, README_DIR } from '../constants'
import { Table } from './table'
@ -17,7 +18,7 @@ export class CountryTable implements Table {
const parser = new LogParser()
const logsStorage = new Storage(LOGS_DIR)
const generatorsLog = await logsStorage.read('generators.log')
const generatorsLog = await logsStorage.load('generators.log')
let data = new Collection()
parser
@ -28,7 +29,7 @@ export class CountryTable implements Table {
)
.forEach((logItem: LogItem) => {
const file = new File(logItem.filepath)
const code = file.getFilename().toUpperCase()
const code = file.name().toUpperCase()
const [countryCode, subdivisionCode] = code.split('-') || ['', '']
if (subdivisionCode) {

@ -1,4 +1,5 @@
import { Storage, HTMLTable, Collection, LogParser, LogItem, File } from '../core'
import { Storage, Collection, File } from '@freearhey/core'
import { HTMLTable, LogParser, LogItem } from '../core'
import { Language } from '../models'
import { DATA_DIR, LOGS_DIR, README_DIR } from '../constants'
import { Table } from './table'
@ -13,7 +14,7 @@ export class LanguageTable implements Table {
const parser = new LogParser()
const logsStorage = new Storage(LOGS_DIR)
const generatorsLog = await logsStorage.read('generators.log')
const generatorsLog = await logsStorage.load('generators.log')
let data = new Collection()
parser
@ -21,7 +22,7 @@ export class LanguageTable implements Table {
.filter((logItem: LogItem) => logItem.filepath.includes('languages/'))
.forEach((logItem: LogItem) => {
const file = new File(logItem.filepath)
const languageCode = file.getFilename()
const languageCode = file.name()
const language: Language = languages.first(
(language: Language) => language.code === languageCode
)

@ -1,4 +1,5 @@
import { Storage, HTMLTable, Collection, LogParser, LogItem, File } from '../core'
import { Storage, Collection, File } from '@freearhey/core'
import { HTMLTable, LogParser, LogItem } from '../core'
import { Region } from '../models'
import { DATA_DIR, LOGS_DIR, README_DIR } from '../constants'
import { Table } from './table'
@ -13,7 +14,7 @@ export class RegionTable implements Table {
const parser = new LogParser()
const logsStorage = new Storage(LOGS_DIR)
const generatorsLog = await logsStorage.read('generators.log')
const generatorsLog = await logsStorage.load('generators.log')
let data = new Collection()
parser
@ -21,7 +22,7 @@ export class RegionTable implements Table {
.filter((logItem: LogItem) => logItem.filepath.includes('regions/'))
.forEach((logItem: LogItem) => {
const file = new File(logItem.filepath)
const regionCode = file.getFilename().toUpperCase()
const regionCode = file.name().toUpperCase()
const region: Region = regions.first((region: Region) => region.code === regionCode)
if (region) {

@ -301,6 +301,20 @@
dependencies:
"@jridgewell/trace-mapping" "0.3.9"
"@freearhey/core@^0.1.2":
version "0.1.2"
resolved "https://registry.npmjs.org/@freearhey/core/-/core-0.1.2.tgz"
integrity sha512-o6FaLHiKED0JkUXxqHcUUM2P+Jd4kvE96p0MZlLjhCFAPii/lVr5mTwrHehKMzve/r7AbDUX7kyNLNG8Qec6uw==
dependencies:
"@types/fs-extra" "^11.0.2"
"@types/lodash" "^4.14.198"
fs-extra "^11.1.1"
glob "^10.3.4"
lodash "^4.17.21"
natural-orderby "^3.0.2"
normalize-url "^6.1.0"
signale "^1.4.0"
"@isaacs/cliui@^8.0.2":
version "8.0.2"
resolved "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz"
@ -742,10 +756,10 @@
dependencies:
"@babel/types" "^7.20.7"
"@types/fs-extra@^11.0.1":
version "11.0.1"
resolved "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.1.tgz"
integrity sha512-MxObHvNl4A69ofaTRU8DFqvgzzv8s9yRtaPPm5gud9HDNvpB3GPQFvNuTWAI59B9huVGV5jXYJwbCsmBsOGYWA==
"@types/fs-extra@^11.0.1", "@types/fs-extra@^11.0.2":
version "11.0.2"
resolved "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-11.0.2.tgz"
integrity sha512-c0hrgAOVYr21EX8J0jBMXGLMgJqVf/v6yxi0dLaJboW9aQPh16Id+z6w2Tx1hm+piJOLv8xPfVKZCLfjPw/IMQ==
dependencies:
"@types/jsonfile" "*"
"@types/node" "*"
@ -2340,6 +2354,11 @@ normalize-path@^3.0.0:
resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
normalize-url@^6.1.0:
version "6.1.0"
resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz"
integrity sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==
normalize-url@^7.2.0:
version "7.2.0"
resolved "https://registry.npmjs.org/normalize-url/-/normalize-url-7.2.0.tgz"

Loading…
Cancel
Save