Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Support --perf-output in CLI #125

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type { Module } from '@wakaru/unpacker'
enum Feature {
Unpacker = 'Unpacker',
Unminify = 'Unminify',
Perf = 'Perf',
AhmadFaraz-crypto marked this conversation as resolved.
Show resolved Hide resolved
}

const INPUT_SIZE_WARNING = 1024 * 1024 * 5 // 5MB
Expand Down Expand Up @@ -73,6 +74,10 @@ yargs(hideBin(process.argv))
describe: 'Override the output directory for unminify (default: out/unminify/)',
type: 'string',
})
.option('perf-output', {
describe: 'Specify the output directory (default: /)',
type: 'string',
})
.option('force', {
alias: 'f',
describe: 'Force overwrite output directory',
Expand Down Expand Up @@ -438,6 +443,7 @@ async function nonInteractive(features: Feature[], {
output: _output,
'unpacker-output': _unpackerOutput,
'unminify-output': _unminifyOutput,
'perf-output': _perfOutput,
force = false,
concurrency = 1,
perf,
Expand All @@ -446,6 +452,7 @@ async function nonInteractive(features: Feature[], {
output: string | undefined
'unpacker-output': string | undefined
'unminify-output': string | undefined
'perf-output': string | undefined
force: boolean | undefined
concurrency: number | undefined
perf: boolean | undefined
Expand Down Expand Up @@ -480,14 +487,15 @@ async function nonInteractive(features: Feature[], {
const unpackerOutput = _unpackerOutput ?? (singleFeature ? outputBase : path.join(outputBase, defaultUnpackerOutputFolder))
const unminifyOutput = _unminifyOutput ?? (singleFeature ? outputBase : path.join(outputBase, defaultUnminifyOutputFolder))

const perfOutputBase = singleFeature
const perfOutputBase = _perfOutput || (singleFeature
? features.includes(Feature.Unpacker) ? unpackerOutput : unminifyOutput
: findCommonBaseDir([unpackerOutput, unminifyOutput]) ?? outputBase
: findCommonBaseDir([unpackerOutput, unminifyOutput]) ?? outputBase)
const perfOutputPath = path.join(perfOutputBase, 'perf.json')

const outputPathsToCheck = []
if (features.includes(Feature.Unpacker)) outputPathsToCheck.push(unpackerOutput)
if (features.includes(Feature.Unminify)) outputPathsToCheck.push(unminifyOutput)
if (features.includes(Feature.Perf)) outputPathsToCheck.push(perfOutputPath)
AhmadFaraz-crypto marked this conversation as resolved.
Show resolved Hide resolved

const outputValidationError = getValidateFromPaths(outputPathsToCheck, outputFolderValidation)
if (outputValidationError) {
Expand Down