Ignore .gitkeep, remove deprecated url.resolve(), update dependencies (resolves #25).

This commit is contained in:
Daniel Scalzi
2021-04-06 17:34:06 -04:00
parent 3f90a22972
commit 362bbc1d83
11 changed files with 204 additions and 110 deletions

View File

@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { Stats } from 'fs'
import { Type, Module } from 'helios-distribution-types'
import { resolve as resolveURL } from 'url'
import { URL } from 'url'
import { ModuleStructure } from './Module.struct'
import { readdir, stat } from 'fs-extra'
import { join, resolve, sep } from 'path'
@@ -41,7 +41,9 @@ export class MiscFileStructure extends ModuleStructure {
if (stats.isDirectory()) {
acc = acc.concat(await this.recursiveModuleScan(filePath))
} else {
acc.push(await this.parseModule(file, filePath, stats))
if(!this.FILE_NAME_BLACKLIST.includes(file)) {
acc.push(await this.parseModule(file, filePath, stats))
}
}
}
return acc
@@ -54,7 +56,7 @@ export class MiscFileStructure extends ModuleStructure {
return name
}
protected async getModuleUrl(name: string, path: string, stats: Stats): Promise<string> {
return resolveURL(this.baseUrl, join(this.relativeRoot, ...path.substr(this.containerDirectory.length+1).split(sep)))
return new URL(join(this.relativeRoot, ...path.substr(this.containerDirectory.length+1).split(sep)), this.baseUrl).toString()
}
protected async getModulePath(name: string, path: string, stats: Stats): Promise<string | null> {
return path.substr(this.containerDirectory.length+1).replace(/\\/g, '/')

View File

@@ -1,7 +1,7 @@
import { Stats } from 'fs-extra'
import { Type, Module } from 'helios-distribution-types'
import { join } from 'path'
import { resolve } from 'url'
import { URL } from 'url'
import { VersionSegmented } from '../../../util/VersionSegmented'
import { MinecraftVersion } from '../../../util/MinecraftVersion'
import { ToggleableModuleStructure } from './ToggleableModule.struct'
@@ -36,7 +36,7 @@ export abstract class BaseForgeModStructure extends ToggleableModuleStructure im
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected async getModuleUrl(name: string, path: string, stats: Stats): Promise<string> {
return resolve(this.baseUrl, join(this.relativeRoot, this.getActiveNamespace(), name))
return new URL(join(this.relativeRoot, this.getActiveNamespace(), name), this.baseUrl).toString()
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected async getModulePath(name: string, path: string, stats: Stats): Promise<string | null> {

View File

@@ -2,7 +2,7 @@ import { ModuleStructure } from './Module.struct'
import { Type, TypeMetadata } from 'helios-distribution-types'
import { Stats } from 'fs-extra'
import { join } from 'path'
import { resolve } from 'url'
import { URL } from 'url'
import { MinecraftVersion } from '../../../util/MinecraftVersion'
import { UntrackedFilesOption } from '../../../model/nebula/servermeta'
@@ -36,7 +36,7 @@ export class LibraryStructure extends ModuleStructure {
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected async getModuleUrl(name: string, path: string, stats: Stats): Promise<string> {
return resolve(this.baseUrl, join(this.relativeRoot, name))
return new URL(join(this.relativeRoot, name), this.baseUrl).toString()
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected async getModulePath(name: string, path: string, stats: Stats): Promise<string | null> {

View File

@@ -2,7 +2,7 @@ import StreamZip from 'node-stream-zip'
import { Stats } from 'fs-extra'
import { Type } from 'helios-distribution-types'
import { join } from 'path'
import { resolve } from 'url'
import { URL } from 'url'
import { capitalize } from '../../../util/stringutils'
import { LiteMod } from '../../../model/liteloader/litemod'
import { ToggleableModuleStructure } from './ToggleableModule.struct'
@@ -39,7 +39,7 @@ export class LiteModStructure extends ToggleableModuleStructure {
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected async getModuleUrl(name: string, path: string, stats: Stats): Promise<string> {
return resolve(this.baseUrl, join(this.relativeRoot, this.getActiveNamespace(), name))
return new URL(join(this.relativeRoot, this.getActiveNamespace(), name), this.baseUrl).toString()
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected async getModulePath(name: string, path: string, stats: Stats): Promise<string | null> {

View File

@@ -25,6 +25,9 @@ export abstract class ModuleStructure extends BaseModelStructure<Module> {
private readonly crudeRegex = /(.+?)-(.+).[jJ][aA][rR]/
protected readonly DEFAULT_VERSION = '0.0.0'
protected readonly FILE_NAME_BLACKLIST = [
'.gitkeep'
]
protected untrackedFilePatterns: string[] // List of glob patterns.
protected claritasResult!: ClaritasResult
@@ -130,8 +133,10 @@ export abstract class ModuleStructure extends BaseModelStructure<Module> {
const filePath = resolve(scanDirectory, file)
const stats = await lstat(filePath)
if (stats.isFile()) {
if(this.filter == null || this.filter(file, filePath, stats)) {
moduleCandidates.push({file, filePath, stats})
if(!this.FILE_NAME_BLACKLIST.includes(file)) {
if(this.filter == null || this.filter(file, filePath, stats)) {
moduleCandidates.push({file, filePath, stats})
}
}
}
}