Pass arguments to Claritas via an argFile to bypass cli length limits. (#16)

This commit is contained in:
Daniel Scalzi
2020-08-02 16:01:04 -04:00
parent 0e83a071d7
commit f287388931
6 changed files with 70 additions and 56 deletions

Binary file not shown.

94
package-lock.json generated
View File

@@ -104,9 +104,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "12.12.50", "version": "12.12.53",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.50.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.53.tgz",
"integrity": "sha512-5ImO01Fb8YsEOYpV+aeyGYztcYcjGsBvN4D7G5r1ef2cuQOpymjWNQi5V0rKHE6PC2ru3HkoUr/Br2/8GUA84w==", "integrity": "sha512-51MYTDTyCziHb70wtGNFRwB4l+5JNvdqzFSkbDvpbftEgVUBEE+T5f7pROhWMp/fxp07oNIEQZd5bbfAH22ohQ==",
"dev": true "dev": true
}, },
"@types/triple-beam": { "@types/triple-beam": {
@@ -131,12 +131,12 @@
"dev": true "dev": true
}, },
"@typescript-eslint/eslint-plugin": { "@typescript-eslint/eslint-plugin": {
"version": "3.6.1", "version": "3.7.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.6.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.7.1.tgz",
"integrity": "sha512-06lfjo76naNeOMDl+mWG9Fh/a0UHKLGhin+mGaIw72FUMbMGBkdi/FEJmgEDzh4eE73KIYzHWvOCYJ0ak7nrJQ==", "integrity": "sha512-3DB9JDYkMrc8Au00rGFiJLK2Ja9CoMP6Ut0sHsXp3ZtSugjNxvSSHTnKLfo4o+QmjYBJqEznDqsG1zj4F2xnsg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@typescript-eslint/experimental-utils": "3.6.1", "@typescript-eslint/experimental-utils": "3.7.1",
"debug": "^4.1.1", "debug": "^4.1.1",
"functional-red-black-tree": "^1.0.1", "functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0", "regexpp": "^3.0.0",
@@ -162,45 +162,45 @@
} }
}, },
"@typescript-eslint/experimental-utils": { "@typescript-eslint/experimental-utils": {
"version": "3.6.1", "version": "3.7.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.6.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.1.tgz",
"integrity": "sha512-oS+hihzQE5M84ewXrTlVx7eTgc52eu+sVmG7ayLfOhyZmJ8Unvf3osyFQNADHP26yoThFfbxcibbO0d2FjnYhg==", "integrity": "sha512-TqE97pv7HrqWcGJbLbZt1v59tcqsSVpWTOf1AqrWK7n8nok2sGgVtYRuGXeNeLw3wXlLEbY1MKP3saB2HsO/Ng==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/json-schema": "^7.0.3", "@types/json-schema": "^7.0.3",
"@typescript-eslint/types": "3.6.1", "@typescript-eslint/types": "3.7.1",
"@typescript-eslint/typescript-estree": "3.6.1", "@typescript-eslint/typescript-estree": "3.7.1",
"eslint-scope": "^5.0.0", "eslint-scope": "^5.0.0",
"eslint-utils": "^2.0.0" "eslint-utils": "^2.0.0"
} }
}, },
"@typescript-eslint/parser": { "@typescript-eslint/parser": {
"version": "3.6.1", "version": "3.7.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.6.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.7.1.tgz",
"integrity": "sha512-SLihQU8RMe77YJ/jGTqOt0lMq7k3hlPVfp7v/cxMnXA9T0bQYoMDfTsNgHXpwSJM1Iq2aAJ8WqekxUwGv5F67Q==", "integrity": "sha512-W4QV/gXvfIsccN8225784LNOorcm7ch68Fi3V4Wg7gmkWSQRKevO4RrRqWo6N/Z/myK1QAiGgeaXN57m+R/8iQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/eslint-visitor-keys": "^1.0.0", "@types/eslint-visitor-keys": "^1.0.0",
"@typescript-eslint/experimental-utils": "3.6.1", "@typescript-eslint/experimental-utils": "3.7.1",
"@typescript-eslint/types": "3.6.1", "@typescript-eslint/types": "3.7.1",
"@typescript-eslint/typescript-estree": "3.6.1", "@typescript-eslint/typescript-estree": "3.7.1",
"eslint-visitor-keys": "^1.1.0" "eslint-visitor-keys": "^1.1.0"
} }
}, },
"@typescript-eslint/types": { "@typescript-eslint/types": {
"version": "3.6.1", "version": "3.7.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.6.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-3.7.1.tgz",
"integrity": "sha512-NPxd5yXG63gx57WDTW1rp0cF3XlNuuFFB5G+Kc48zZ+51ZnQn9yjDEsjTPQ+aWM+V+Z0I4kuTFKjKvgcT1F7xQ==", "integrity": "sha512-PZe8twm5Z4b61jt7GAQDor6KiMhgPgf4XmUb9zdrwTbgtC/Sj29gXP1dws9yEn4+aJeyXrjsD9XN7AWFhmnUfg==",
"dev": true "dev": true
}, },
"@typescript-eslint/typescript-estree": { "@typescript-eslint/typescript-estree": {
"version": "3.6.1", "version": "3.7.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.6.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.1.tgz",
"integrity": "sha512-G4XRe/ZbCZkL1fy09DPN3U0mR6SayIv1zSeBNquRFRk7CnVLgkC2ZPj8llEMJg5Y8dJ3T76SvTGtceytniaztQ==", "integrity": "sha512-m97vNZkI08dunYOr2lVZOHoyfpqRs0KDpd6qkGaIcLGhQ2WPtgHOd/eVbsJZ0VYCQvupKrObAGTOvk3tfpybYA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@typescript-eslint/types": "3.6.1", "@typescript-eslint/types": "3.7.1",
"@typescript-eslint/visitor-keys": "3.6.1", "@typescript-eslint/visitor-keys": "3.7.1",
"debug": "^4.1.1", "debug": "^4.1.1",
"glob": "^7.1.6", "glob": "^7.1.6",
"is-glob": "^4.0.1", "is-glob": "^4.0.1",
@@ -227,9 +227,9 @@
} }
}, },
"@typescript-eslint/visitor-keys": { "@typescript-eslint/visitor-keys": {
"version": "3.6.1", "version": "3.7.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.6.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.1.tgz",
"integrity": "sha512-qC8Olwz5ZyMTZrh4Wl3K4U6tfms0R/mzU4/5W3XeUZptVraGVmbptJbn6h2Ey6Rb3hOs3zWoAUebZk8t47KGiQ==", "integrity": "sha512-xn22sQbEya+Utj2IqJHGLA3i1jDzR43RzWupxojbSWnj3nnPLavaQmWe5utw03CwYao3r00qzXfgJMGNkrzrAA==",
"dev": true, "dev": true,
"requires": { "requires": {
"eslint-visitor-keys": "^1.1.0" "eslint-visitor-keys": "^1.1.0"
@@ -248,9 +248,9 @@
"dev": true "dev": true
}, },
"ajv": { "ajv": {
"version": "6.12.2", "version": "6.12.3",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz",
"integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==", "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==",
"dev": true, "dev": true,
"requires": { "requires": {
"fast-deep-equal": "^3.1.1", "fast-deep-equal": "^3.1.1",
@@ -517,9 +517,9 @@
"dev": true "dev": true
}, },
"eslint": { "eslint": {
"version": "7.4.0", "version": "7.6.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-7.4.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.6.0.tgz",
"integrity": "sha512-gU+lxhlPHu45H3JkEGgYhWhkR9wLHHEXC9FbWFnTlEkbKyZKWgWRLgf61E8zWmBuI6g5xKBph9ltg3NtZMVF8g==", "integrity": "sha512-QlAManNtqr7sozWm5TF4wIH9gmUm2hE3vNRUvyoYAa4y1l5/jxD/PQStEjBMQtCqZmSep8UxrcecI60hOpe61w==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",
@@ -530,9 +530,9 @@
"doctrine": "^3.0.0", "doctrine": "^3.0.0",
"enquirer": "^2.3.5", "enquirer": "^2.3.5",
"eslint-scope": "^5.1.0", "eslint-scope": "^5.1.0",
"eslint-utils": "^2.0.0", "eslint-utils": "^2.1.0",
"eslint-visitor-keys": "^1.2.0", "eslint-visitor-keys": "^1.3.0",
"espree": "^7.1.0", "espree": "^7.2.0",
"esquery": "^1.2.0", "esquery": "^1.2.0",
"esutils": "^2.0.2", "esutils": "^2.0.2",
"file-entry-cache": "^5.0.1", "file-entry-cache": "^5.0.1",
@@ -546,7 +546,7 @@
"js-yaml": "^3.13.1", "js-yaml": "^3.13.1",
"json-stable-stringify-without-jsonify": "^1.0.1", "json-stable-stringify-without-jsonify": "^1.0.1",
"levn": "^0.4.1", "levn": "^0.4.1",
"lodash": "^4.17.14", "lodash": "^4.17.19",
"minimatch": "^3.0.4", "minimatch": "^3.0.4",
"natural-compare": "^1.4.0", "natural-compare": "^1.4.0",
"optionator": "^0.9.1", "optionator": "^0.9.1",
@@ -603,14 +603,14 @@
"dev": true "dev": true
}, },
"espree": { "espree": {
"version": "7.1.0", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/espree/-/espree-7.1.0.tgz", "resolved": "https://registry.npmjs.org/espree/-/espree-7.2.0.tgz",
"integrity": "sha512-dcorZSyfmm4WTuTnE5Y7MEN1DyoPYy1ZR783QW1FJoenn7RailyWFsq/UL6ZAAA7uXurN9FIpYyUs3OfiIW+Qw==", "integrity": "sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g==",
"dev": true, "dev": true,
"requires": { "requires": {
"acorn": "^7.2.0", "acorn": "^7.3.1",
"acorn-jsx": "^5.2.0", "acorn-jsx": "^5.2.0",
"eslint-visitor-keys": "^1.2.0" "eslint-visitor-keys": "^1.3.0"
} }
}, },
"esprima": { "esprima": {
@@ -1290,9 +1290,9 @@
} }
}, },
"strip-json-comments": { "strip-json-comments": {
"version": "3.1.0", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.0.tgz", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
"integrity": "sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true "dev": true
}, },
"supports-color": { "supports-color": {

View File

@@ -27,12 +27,12 @@
"homepage": "https://github.com/dscalzi/Nebula#readme", "homepage": "https://github.com/dscalzi/Nebula#readme",
"devDependencies": { "devDependencies": {
"@types/fs-extra": "^9.0.1", "@types/fs-extra": "^9.0.1",
"@types/node": "^12.12.50", "@types/node": "^12.12.53",
"@types/triple-beam": "^1.3.1", "@types/triple-beam": "^1.3.1",
"@types/yargs": "^15.0.5", "@types/yargs": "^15.0.5",
"@typescript-eslint/eslint-plugin": "^3.6.1", "@typescript-eslint/eslint-plugin": "^3.7.1",
"@typescript-eslint/parser": "^3.6.1", "@typescript-eslint/parser": "^3.7.1",
"eslint": "^7.4.0", "eslint": "^7.6.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^3.9.7" "typescript": "^3.9.7"
}, },

View File

@@ -3,17 +3,19 @@ import { join, resolve } from 'path'
import { ClaritasResult } from '../../model/claritas/ClaritasResult' import { ClaritasResult } from '../../model/claritas/ClaritasResult'
import { MinecraftVersion } from '../MinecraftVersion' import { MinecraftVersion } from '../MinecraftVersion'
import { LibraryType } from '../../model/claritas/ClaritasLibraryType' import { LibraryType } from '../../model/claritas/ClaritasLibraryType'
import { pathExists, remove, readFile } from 'fs-extra' import { pathExists, remove, readFile, writeFile, mkdirs } from 'fs-extra'
export class ClaritasWrapper extends JarExecutor<ClaritasResult> { export class ClaritasWrapper extends JarExecutor<ClaritasResult> {
private readonly WORK_DIR: string private readonly WORK_DIR: string
private readonly ARG_FILE: string
private readonly OUTPUT_FILE: string private readonly OUTPUT_FILE: string
constructor(cwd: string) { constructor(cwd: string) {
super('Claritas') super('Claritas')
this.WORK_DIR = resolve(cwd, 'claritasWork') this.WORK_DIR = resolve(cwd, 'claritasWork')
this.ARG_FILE = resolve(this.WORK_DIR, 'claritasArgFile.txt')
this.OUTPUT_FILE = resolve(this.WORK_DIR, 'claritasOutput.json') this.OUTPUT_FILE = resolve(this.WORK_DIR, 'claritasOutput.json')
this.onCloseListeners.push(async (code) => { this.onCloseListeners.push(async (code) => {
@@ -37,14 +39,25 @@ export class ClaritasWrapper extends JarExecutor<ClaritasResult> {
return join(process.cwd(), 'libraries', 'java', 'Claritas.jar') return join(process.cwd(), 'libraries', 'java', 'Claritas.jar')
} }
public execute(libraryType: LibraryType, mcVersion: MinecraftVersion, absoluteJarPaths: string[]): Promise<ClaritasResult> { private async writeArgFile(...programArgs: string[]): Promise<void> {
return super.executeJar( await mkdirs(this.WORK_DIR)
await writeFile(
this.ARG_FILE,
programArgs.join('\n')
)
}
public async execute(libraryType: LibraryType, mcVersion: MinecraftVersion, absoluteJarPaths: string[]): Promise<ClaritasResult> {
await this.writeArgFile(
'--absoluteJarPaths', absoluteJarPaths.join(','), '--absoluteJarPaths', absoluteJarPaths.join(','),
'--libraryType', libraryType, '--libraryType', libraryType,
'--mcVersion', mcVersion.toString(), '--mcVersion', mcVersion.toString(),
'--outputFile', this.OUTPUT_FILE, '--outputFile', this.OUTPUT_FILE,
'--previewOutput', 'true' '--previewOutput', 'true'
) )
return await super.executeJar(
[`-Dclaritas.argFile=${this.ARG_FILE}`]
)
} }
private async cleanOutput(): Promise<void> { private async cleanOutput(): Promise<void> {

View File

@@ -21,10 +21,11 @@ export abstract class JarExecutor<T> {
protected abstract getJarPath(): string protected abstract getJarPath(): string
protected executeJar(...args: string[]): Promise<T> { protected executeJar(vmOptions: string[], ...args: string[]): Promise<T> {
this.lastExecutionResult = undefined! this.lastExecutionResult = undefined!
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const child = spawn(JavaUtil.getJavaExecutable(), [ const child = spawn(JavaUtil.getJavaExecutable(), [
...vmOptions,
'-jar', '-jar',
this.getJarPath(), this.getJarPath(),
...args ...args

View File

@@ -12,7 +12,7 @@ export class PackXZExtractWrapper extends JarExecutor<void> {
} }
protected execute(command: string, paths: string[]): Promise<void> { protected execute(command: string, paths: string[]): Promise<void> {
return super.executeJar(command, paths.join(',')) return super.executeJar([], command, paths.join(','))
} }
public extractUnpack(paths: string[]): Promise<void> { public extractUnpack(paths: string[]): Promise<void> {