skorbaz-updater
Version:
A CLI tool to handle Skorbaz App hot updates
69 lines (60 loc) • 2.22 kB
text/typescript
#!/usr/bin/env node
import { program } from "commander";
import inquirer from "inquirer";
import figlet from "figlet";
import { spawn } from "child_process";
import chalk from "chalk";
program
.version("1.0.0")
.description("A CLI tool to handle Skorbaz App hot updates.")
.action(async (options) => {
console.log("\n");
console.log(figlet.textSync("Skorbaz", {
font: "Big",
horizontalLayout: "default",
verticalLayout: "default"
}));
const inputs = await inquirer.prompt([
{
name: "platform",
type: "list",
message: "Select platform to update",
choices: [{ value: "android", name: "Android" }, { value: "ios", name: "iOS" }]
},
{
name: "force",
type: "confirm",
message: "Is this a force update?",
default: false
},
{
name: "packageManager",
type: "list",
message: "Select package manager to bundle app",
choices: [{ value: "bunx", name: "Bun" }, { value: "npx", name: "Npm" }]
}
]);
console.log("\n");
console.log(chalk.green("Starting update process for " + inputs.platform + "..."));
console.log("\n");
const args = [
"hot-updater",
"deploy",
"-p", inputs.platform,
...(inputs.force ? ["-f"] : [])
];
const cmd = spawn(inputs.packageManager, args, {
stdio: "inherit",
shell: true
});
cmd.on("exit", (code) => {
if (code === 0) {
// console.log(chalk.green("Update deployed successfully!"));
// console.log(chalk.green("Platform: " + inputs.platform));
// console.log(chalk.green("Command: bunx " + args.join(" ")));
} else {
console.error(chalk.red("Komut hata ile sonlandı. Çıkış kodu: " + code));
}
});
});
program.parse(process.argv);