@ea-utilities/build-capacitor
Version:
This CLI tool automates the process of setting up the necessary environment and building Capacitor.js applications, specifically targeting Android. It handles the installation and configuration of Java Development Kits (JDKs), Android SDK command-line too
56 lines (52 loc) • 1.45 kB
JavaScript
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
// Import the main build logic from the dist folder
import { runBuild, cleanDependencies, remove, gradlePath } from "./dist/index.js";
// Setup yargs to parse arguments
yargs(hideBin(process.argv))
.scriptName("build-capacitor")
.usage("$0 <cmd> [args]")
.command(
"build",
"Build a Capacitor project",
(yargs) => {
yargs.option("output-file", {
alias: "o",
describe: "The outputFile to build (e.g., C:/apks/myapp.apk)",
type: "string",
default: "dist/app",
});
// Add a new option for buildType
yargs.option("build-type", {
alias: "t",
describe: "The type of build (e.g., debug, release)",
type: "string",
default: "debug", // Set a default value
});
},
(argv) => {
// Pass the new buildType argument to your function
runBuild(argv.outputFile, argv.buildType);
}
)
.command(
"clean",
"Clean Capacitor build dependencies",
() => {},
(argv) => {
cleanDependencies();
}
)
.command(
"clean-cache",
"Remove only the Gradle cache",
() => {},
async (argv) => {
console.log(`Removing ${gradlePath}`);
await remove(gradlePath);
console.log("Gradle cache cleaned.");
}
)
.demandCommand(1, "You need at least one command before moving on")
.help().argv;