Integrate with PackXZExtract to support pack.xz libs.
All pack.xz libraries now have their MD5s properly calculated. Sha1 validations are performed on jar libraries. The checksums forge provides for compressed files are neither the sha1 or md5 of the initial or extracted file. Ignoring those for now. Still TODO is integration with baseurl. Might move both that and base path to the .env file to reduce redundency in command processing.
This commit is contained in:
43
src/util/PackXZExtractWrapper.ts
Normal file
43
src/util/PackXZExtractWrapper.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { spawn } from 'child_process'
|
||||
import { join } from 'path'
|
||||
|
||||
export class PackXZExtractWrapper {
|
||||
|
||||
public static getJavaExecutable() {
|
||||
return process.env.JAVA_EXECUTABLE as string
|
||||
}
|
||||
|
||||
public static getPackXZExtract() {
|
||||
return join(process.cwd(), 'libraries', 'java', 'PackXZExtract.jar')
|
||||
}
|
||||
|
||||
public static extractUnpack(paths: string[]) {
|
||||
return PackXZExtractWrapper.execute('-packxz', paths)
|
||||
}
|
||||
|
||||
public static extract(paths: string[]) {
|
||||
return PackXZExtractWrapper.execute('-xz', paths)
|
||||
}
|
||||
|
||||
public static unpack(paths: string[]) {
|
||||
return PackXZExtractWrapper.execute('-pack', paths)
|
||||
}
|
||||
|
||||
private static execute(command: string, paths: string[]) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn(PackXZExtractWrapper.getJavaExecutable(), [
|
||||
'-jar',
|
||||
PackXZExtractWrapper.getPackXZExtract(),
|
||||
command,
|
||||
paths.join(',')
|
||||
])
|
||||
child.stdout.on('data', (data) => console.log('[PackXZExtract]', data.toString('utf8')))
|
||||
child.stderr.on('data', (data) => console.error('[PackXZExtract]', data.toString('utf8')))
|
||||
child.on('close', (code, signal) => {
|
||||
console.log('[PackXZExtract]', 'Exited with code', code)
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,7 +17,7 @@ export class MavenUtil {
|
||||
|
||||
public static getMavenComponents(id: string, extension = 'jar') {
|
||||
if (!MavenUtil.isMavenIdentifier(id)) {
|
||||
return null
|
||||
throw new Error('Id is not a maven identifier.')
|
||||
}
|
||||
|
||||
let result
|
||||
@@ -38,7 +38,7 @@ export class MavenUtil {
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
throw new Error('Failed to process maven data.')
|
||||
}
|
||||
|
||||
public static mavenIdentifierToString(id: string, extension = 'jar') {
|
||||
|
||||
Reference in New Issue
Block a user