-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
302 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
#!/usr/bin/env node | ||
|
||
import { Command } from "commander"; | ||
import configurations from "../configLoader"; | ||
import { | ||
compressImages, | ||
compressVideos, | ||
generateImageSets, | ||
minifyWebdoc, | ||
minomax, | ||
} from "../minomax"; | ||
|
||
const program = new Command(); | ||
|
||
// Minomax command | ||
program | ||
.command("make") | ||
.description("Run the minomax process") | ||
.option( | ||
"-f, --format [jpg | avif | webp]", | ||
"Image output format", | ||
"webp", | ||
) | ||
.option( | ||
"-c, --codec [wav1 | mav1 | mx265]", | ||
"Output video codec type", | ||
"wav1", | ||
) | ||
.option("-e, --encode [1 | 2 | 3]", "Video encoding level", parseInt, 3) | ||
.option( | ||
"-d, --dest <path>", | ||
"Destination base path", | ||
configurations.destPath, | ||
) | ||
.option( | ||
"-i, --ignore <patterns>", | ||
"Ignore path patterns", | ||
(value) => value.split(","), | ||
[], | ||
) | ||
.action(async (options) => { | ||
await minomax( | ||
{ targetFormat: options.format }, | ||
{ codecType: options.codec, encodeLevel: options.encode }, | ||
options.dest, | ||
options.ignore, | ||
); | ||
}); | ||
|
||
// Compress Images command | ||
program | ||
.command("image") | ||
.description("Compress images") | ||
.option( | ||
"-p, --patterns <patterns>", | ||
"Path patterns", | ||
(value) => value.split(","), | ||
[], | ||
) | ||
.option( | ||
"-f, --format [jpg | avif | webp]", | ||
"Image output format", | ||
"webp", | ||
) | ||
.option( | ||
"-d, --dest <path>", | ||
"Destination base path", | ||
configurations.destPath, | ||
) | ||
.option( | ||
"-i, --ignore <patterns>", | ||
"Ignore patterns", | ||
(value) => value.split(","), | ||
[], | ||
) | ||
.action(async (options) => { | ||
await compressImages( | ||
options.patterns, | ||
options.format, | ||
options.dest, | ||
options.ignore, | ||
); | ||
}); | ||
|
||
// Compress Videos command | ||
program | ||
.command("video") | ||
.description("Compress videos") | ||
.option( | ||
"-p, --patterns <patterns>", | ||
"Path patterns", | ||
(value) => value.split(","), | ||
[], | ||
) | ||
.option( | ||
"-c, --codec [wav1 | mav1 | mx265]", | ||
"Output video codec type", | ||
"wav1", | ||
) | ||
.option("-e, --encode [1 | 2 | 3]", "Video encoding level", parseInt, 3) | ||
.option( | ||
"-d, --dest <path>", | ||
"Destination base path", | ||
configurations.destPath, | ||
) | ||
.option( | ||
"-I, --ignore <patterns>", | ||
"Ignore patterns", | ||
(value) => value.split(","), | ||
[], | ||
) | ||
.action(async (options) => { | ||
await compressVideos( | ||
options.patterns, | ||
options.codec, | ||
options.encode, | ||
options.dest, | ||
options.ignore, | ||
); | ||
}); | ||
|
||
// Minify Webdoc command | ||
program | ||
.command("minify") | ||
.description("Minify web documents - JS , CSS & HTML") | ||
.option( | ||
"-p, --patterns <patterns>", | ||
"Path patterns", | ||
(value) => value.split(","), | ||
[], | ||
) | ||
.option( | ||
"-d, --dest <path>", | ||
"Destination base path", | ||
configurations.destPath, | ||
) | ||
.option( | ||
"-s, --searchBase <path>", | ||
"File search base path", | ||
process.cwd(), | ||
) | ||
.option( | ||
"-i, --ignore <patterns>", | ||
"Ignore patterns", | ||
(value) => value.split(","), | ||
[], | ||
) | ||
.action(async (options) => { | ||
await minifyWebdoc( | ||
options.patterns, | ||
options.dest, | ||
options.searchBase, | ||
options.ignore, | ||
); | ||
}); | ||
|
||
// Generate Image Sets command | ||
program | ||
.command("genset") | ||
.description("Generate image sets") | ||
.option( | ||
"-p, --patterns <patterns>", | ||
"Path patterns", | ||
(value) => value.split(","), | ||
[], | ||
) | ||
.option( | ||
"-d, --dest <path>", | ||
"Destination base path", | ||
configurations.destPath, | ||
) | ||
.option( | ||
"-i, --ignore <patterns>", | ||
"Ignore patterns", | ||
(value) => value.split(","), | ||
[], | ||
) | ||
.action(async (options) => { | ||
await generateImageSets( | ||
options.patterns, | ||
options.dest, | ||
options.ignore, | ||
); | ||
}); | ||
|
||
program.parse(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2229,6 +2229,11 @@ colord@^2.9.3: | |
resolved "https://registry.yarnpkg.com/colord/-/colord-2.9.3.tgz#4f8ce919de456f1d5c1c368c307fe20f3e59fb43" | ||
integrity sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw== | ||
|
||
[email protected]: | ||
version "12.1.0" | ||
resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3" | ||
integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA== | ||
|
||
commander@^2.19.0, commander@^2.20.0, commander@^2.8.1: | ||
version "2.20.3" | ||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" | ||
|