UNPKG

satu-ui

Version:

Library component for boosting your Javascript Apps

81 lines (71 loc) 2.39 kB
#!/usr/bin/env node import inquirer from "inquirer"; import chalk from "chalk"; import fs from "fs-extra"; import { fileURLToPath } from "url"; import path from "path"; import prompts from "prompts"; import { exec } from "child_process"; // Untuk path __dirname di ESM const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const args = process.argv.slice(2); switch(args[0]) { case "install": const { framework } = await inquirer.prompt([ { type: "list", name: "framework", message: "Choose your javacript framework:", choices: [ { name: chalk.blue("React"), value: "react" }, { name: chalk.green("Vue"), value: "vue" }, { name: chalk.hex('#FFA500')('Svelte'), value: "svelte" }, { name: chalk.red("Angular"), value: "angular" } ] } ]) const { language } = await inquirer.prompt([ { type: "list", name: "language", message: "Would you like to use TypeScript?", choices: ["ts", "js"] } ]); const pkgName = `@satu-ui/${framework}-${language}`; // Tulis ke satu-ui.json const config = { framework, language, package: pkgName }; await fs.writeJson("satu-ui.json", config, { spaces: 2 }); console.log("Konfigurasi disimpan ke satu-ui.json"); break; case "get": exec(`npx @satu-ui/react-ts get ${args[1]}`, (error, stdout, stderr) => { if (error) { console.error(`❌ Error: ${error.message}`); return; } if (stderr) { console.error(`⚠️ Stderr: ${stderr}`); return; } console.log(`✅ Output:\n${stdout}`); }); break; }