UNPKG

themeify

Version:

A CLI tool to generate and manage custom UI themes.

2 lines 12.2 kB
#!/usr/bin/env node (()=>{var __webpack_modules__={78:(module,__unused_webpack_exports,__webpack_require__)=>{const figlet=__webpack_require__(679),cliColor=__webpack_require__(832);function generateAsciiArt(e,r,t){return cliColor[t](figlet.textSync(e,{font:r}))}const art1=generateAsciiArt("ThemeMaker","Standard","cyan"),art2=generateAsciiArt("ThemeMaker","Slant","green"),art3=generateAsciiArt("ThemeMaker","Big","magenta"),art4=generateAsciiArt("ThemeMaker","Small","yellow"),art5=generateAsciiArt("ThemeMaker","Banner","red"),art6=generateAsciiArt("ThemeMaker","Ghost","blue"),art7=generateAsciiArt("ThemeMaker","Lean","white"),art8=generateAsciiArt("ThemeMaker","Star Wars","cyan"),art9=generateAsciiArt("ThemeMaker","Bulbhead","green"),art10=generateAsciiArt("ThemeMaker","Acrobatic","yellow"),art11=generateAsciiArt("ThemeMaker","Blocks","blue"),art12=generateAsciiArt("ThemeMaker","Digital","red"),art13=generateAsciiArt("ThemeMaker","Epic","magenta"),art14=generateAsciiArt("ThemeMaker","Roman","white"),art15=generateAsciiArt("ThemeMaker","Isometric1","cyan"),art16=generateAsciiArt("ThemeMaker","Cyberlarge","green"),arts=new Array(16).fill(null).map(((_,index)=>eval(`art${index+1}`)));function displayRandomArt(){console.log(arts[Math.floor(Math.random()*arts.length)])}module.exports=displayRandomArt},404:(e,r,t)=>{const{generateFiles:o}=t(73),{detectFramework:a}=t(399),{startLoader:n,logSuccess:s,logError:c}=t(484),{getThemeConfig:i}=t(3);e.exports={applyTheme:async function(e){n("Detecting framework...");try{const r=a(),t=await i(),n=e.framework||t.framework||r;e.theme&&(t.theme=e.theme),e.palette&&(t.palette=e.palette),e.font&&(t.font=e.font),e.path&&(t.path=e.path);const c=o(n,t);s(`Theme applied successfully! Files generated at ${c}`)}catch(e){c("Error applying theme."),c(e.message)}}}},316:(e,r,t)=>{const o=t(896),a=t(928),{logInfo:n,logError:s,logSuccess:c}=t(484);e.exports=function({directory:e}){try{if(!e)throw new Error("Please specify a directory using --directory.");const r=a.resolve(process.cwd(),e);if(!o.existsSync(r))throw new Error(`Directory does not exist: ${r}`);n(`Cleaning up files in directory: ${r}...`);o.readdirSync(r).forEach((e=>{o.unlinkSync(a.join(r,e))})),c(`Cleanup completed for directory: ${r}`)}catch(e){s(`Error during cleanup: ${e.message}`)}}},984:(e,r,t)=>{const o=t(832),a=t(291),{logError:n}=t(484),s=t(196),c=t(421);e.exports={preview:function({paletteName:e,themeName:r,list:t}){if(t)return console.log(o.magentaBright("Available palettes:")),console.log(Object.keys(a).join(", ")),console.log("\n"),console.log(o.redBright("Available themes:")),void console.log(Object.keys(c).join(", "));e||r||(n("Please specify a palette name using --paletteName or a theme name using --themeName."),process.exit(1));const i=a[e]||c[r];i||(n("Invalid palette or theme name. Please run theme-maker preview --list to see available palettes and themes."),process.exit(1)),console.log(o.bgXterm(s(i.primary))(" "),o.bold("Primary: ")+i.primary),console.log("\n"),console.log(o.bgXterm(s(i.secondary))(" "),o.bold("Secondary: ")+i.secondary),console.log("\n"),console.log(o.bgXterm(s(i.error))(" "),o.bold("Error: ")+i.error),console.log("\n"),console.log(o.bgXterm(s(i.warning))(" "),o.bold("Warning: ")+i.warning),console.log("\n"),console.log(o.bgXterm(s(i.info))(" "),o.bold("Info: ")+i.info),console.log("\n"),console.log(o.bgXterm(s(i.success))(" "),o.bold("Success: ")+i.success)}}},3:(e,r,t)=>{const{Select:o}=t(365),{logInfo:a,logSuccess:n}=t(484),s=t(421),c=t(445),i=t(291),{fromCamelCase:l}=t(369),m="None (Custom Configuration)";e.exports={getThemeConfig:async function(){a("\nWelcome to the Theme Configurator!\n- Choose a predefined theme for quick setup.\n- If you select 'None,' you can customize your palette and font.\n");const e=new o({name:"framework",message:"Select your UI framework:",choices:["MUI","Tailwind","None","ShadCN","Bootstrap"]}),r=new o({name:"theme",message:"Would you like to use a predefined theme?",choices:[m,...Object.keys(s).map((e=>({name:l(e),value:e,message:l(e)})))]}),t={};if(t.framework=await e.run(),t.theme=await r.run(),t.theme===m){console.log("\nYou chose custom configuration. Let's pick your palette and font!\n");const e=new o({name:"palette",message:"Choose a color palette:",choices:Object.keys(i)}),r=new o({name:"font",message:"Choose a font:",choices:[...c]});return t.palette=await e.run(),t.font=await r.run(),t}return n(`\nYou selected the ${t.theme} theme. Palette and font are preconfigured for this theme.\n`),t},noTheme:m}},399:(e,r,t)=>{const o=t(896),a=t(928),{logInfo:n,logError:s}=t(484);e.exports={detectFramework:function(){try{n("Detecting framework...");const e=a.resolve(process.cwd(),"package.json");if(!o.existsSync(e))throw new Error("package.json not found in the current directory.");const r=JSON.parse(o.readFileSync(e,"utf-8")),t={...r.dependencies,...r.devDependencies};return t["@mui/material"]?(n("Framework detected: MUI"),"mui"):t.tailwindcss?(n("Framework detected: Tailwind CSS"),"tailwind"):t.bootstrap?(n("Framework detected: Bootstrap"),"bootstrap"):t["@shadcn/ui"]?(n("Framework detected: Shadcn UI"),"shadcn"):(n("No specific framework detected. Falling back to CSS."),"css")}catch(e){return s(`Error detecting framework: ${e.message}`),"css"}}}},73:(e,r,t)=>{const o=t(896),a=t(928),n=t(156),{logInfo:s,logError:c,logSuccess:i}=t(484),l=t(445),m=t(291),f=t(421),{toCamelCase:p}=t(369),{noTheme:d}=t(3);function u(e){o.existsSync(e)||(o.mkdirSync(e,{recursive:!0}),i(`Directory created: ${e}`))}e.exports={generateFiles:function(e,r){try{s(`Generating files for framework: ${e}...`);const t="css"===e.toLowerCase()?a.resolve(__dirname,"./templates/cssTheme.hbs"):a.resolve(__dirname,`./templates/${e.toLowerCase()}Theme.hbs`),g="css"===e.toLowerCase()||"bootstrap"===e.toLowerCase()?a.resolve(r.path||process.cwd(),"./style/theme.css"):a.resolve(r.path||process.cwd(),`./theme/${e.toLowerCase()}Theme.js`);u(a.resolve(process.cwd(),"./theme")),u(a.resolve(process.cwd(),"./style")),s(`Reading template from: ${t}`);const h=o.readFileSync(t,"utf-8");s("Compiling template with configuration...");const y=n.compile(h);let w;if(s(`Generating content and writing to: ${g}`),r.theme&&r.theme!==d){const e=f[p(r.theme)];e||(c("Please provide a valid theme name"),process.exit(1)),w={...e}}else{let e=m[r.palette],t=l.find(((e,t)=>(console.log(e,r.font,t),e===r.font)));e||(c("Please provide a valid palette name"),process.exit(1)),t||(c("Please provide a valid font name"),process.exit(1)),w={...e,font:t}}const b=y(w);return o.mkdirSync(a.dirname(g),{recursive:!0}),o.writeFileSync(g,b),i(`Files generated and saved to: ${g}`),g}catch(e){c(`Error generating files: ${e.message}`),process.exit(1)}}}},445:e=>{e.exports=["Roboto","Poppins","Open Sans","Lato","Montserrat","Raleway","Nunito","Merriweather","Playfair Display","Cabin","Source Sans Pro","Quicksand","Comfortaa","Josefin Sans","Oswald"]},291:e=>{e.exports={material:{primary:"#1976d2",secondary:"#dc004e",background:"#f5f5f5",error:"#d32f2f",warning:"#ed6c02",info:"#0288d1",success:"#2e7d32",textPrimary:"#212121",textSecondary:"#757575"},pastel:{primary:"#ff9aa2",secondary:"#ffb7b2",background:"#ffdac1",error:"#ff847c",warning:"#f8b88b",info:"#c1c8e4",success:"#a8e6cf",textPrimary:"#4e4e4e",textSecondary:"#7f8c8d"},dark:{primary:"#1a237e",secondary:"#ff4081",background:"#121212",error:"#d50000",warning:"#ffa000",info:"#00e5ff",success:"#00c853",textPrimary:"#ffffff",textSecondary:"#bdbdbd"},monochrome:{primary:"#333333",secondary:"#555555",background:"#f0f0f0",error:"#ff4444",warning:"#ffbb33",info:"#33b5e5",success:"#00c851",textPrimary:"#000000",textSecondary:"#444444"},neon:{primary:"#39ff14",secondary:"#ff073a",background:"#000000",error:"#ff073a",warning:"#ffcc00",info:"#00d2ff",success:"#00ff72",textPrimary:"#ffffff",textSecondary:"#aaaaaa"},vintage:{primary:"#6b4226",secondary:"#c0a060",background:"#f7f4e9",error:"#bc4749",warning:"#ffcb47",info:"#6082b6",success:"#8db580",textPrimary:"#2f2e2c",textSecondary:"#7a756f"},vibrant:{primary:"#ff6f61",secondary:"#6b5b95",background:"#fff7e1",error:"#d7263d",warning:"#f49f0a",info:"#4f9da6",success:"#88b04b",textPrimary:"#333333",textSecondary:"#6c757d"},ocean:{primary:"#005f73",secondary:"#0a9396",background:"#e9d8a6",error:"#9b2226",warning:"#ee9b00",info:"#94d2bd",success:"#ae2012",textPrimary:"#001219",textSecondary:"#94a1b2"},forest:{primary:"#2a9d8f",secondary:"#264653",background:"#f4a261",error:"#e76f51",warning:"#fabc60",info:"#88b04b",success:"#1f7a8c",textPrimary:"#122620",textSecondary:"#6b706c"},sunset:{primary:"#fe5f55",secondary:"#fbb13c",background:"#f9ed69",error:"#d7263d",warning:"#f49f0a",info:"#3a86ff",success:"#81b29a",textPrimary:"#372a28",textSecondary:"#b29580"}}},421:(e,r,t)=>{const o=t(291),a=t(445);e.exports={modern:{...o.material,font:a[0]},vibrantPastel:{...o.pastel,font:a[1]},elegantDark:{...o.dark,font:a[2]},monochromeBold:{...o.monochrome,font:a[3]},neonFuturistic:{...o.neon,font:a[4]},vintageClassic:{...o.vintage,font:a[5]},vibrantOcean:{...o.ocean,font:a[6]},forestCalm:{...o.forest,font:a[7]},sunsetWarm:{...o.sunset,font:a[8]},materialComfort:{...o.material,font:a[9]},pastelSerene:{...o.pastel,font:a[10]},darkMinimal:{...o.dark,font:a[11]},oceanDreamy:{...o.ocean,font:a[12]},forestNatural:{...o.forest,font:a[13]},sunsetElegant:{...o.sunset,font:a[14]}}},196:(e,r,t)=>{const o=t(826);e.exports=function(e){const r=o.hex.rgb(e);return o.rgb.ansi256(r[0],r[1],r[2])}},369:e=>{e.exports={toCamelCase:function(e){return e.split(" ").map(((e,r)=>0===r?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())).join("")},fromCamelCase:function(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,(e=>e.toUpperCase()))}}},484:(e,r,t)=>{const o=t(124),a=o.createLogger({level:"info",format:o.format.combine(o.format.colorize(),o.format.simple()),transports:[new o.transports.Console]});e.exports={startLoader:function(e){a.info(`⏳ ${e}...`)},logSuccess:function(e){a.info(`✔ ${e}`)},logError:function(e){a.error(`✖ ${e}`)},logInfo:function(e){a.info(`ℹ ${e}`)}}},832:e=>{"use strict";e.exports=require("cli-color")},826:e=>{"use strict";e.exports=require("color-convert")},858:e=>{"use strict";e.exports=require("commander")},365:e=>{"use strict";e.exports=require("enquirer")},679:e=>{"use strict";e.exports=require("figlet")},156:e=>{"use strict";e.exports=require("handlebars")},124:e=>{"use strict";e.exports=require("winston")},896:e=>{"use strict";e.exports=require("fs")},928:e=>{"use strict";e.exports=require("path")}},__webpack_module_cache__={};function __webpack_require__(e){var r=__webpack_module_cache__[e];if(void 0!==r)return r.exports;var t=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](t,t.exports,__webpack_require__),t.exports}var __webpack_exports__={};const{Command}=__webpack_require__(858),{applyTheme}=__webpack_require__(404),{preview}=__webpack_require__(984),{cleanup}=__webpack_require__(316),displayAsciiArt=__webpack_require__(78),program=new Command;displayAsciiArt(),program.name("theme-maker").description("A CLI tool to apply themes to React and Next.js projects").version("1.0.0"),program.command("apply").description("Apply a theme to your project").option("--path <path>","Path to your project").option("--framework <framework>","UI framework (e.g., MUI, Tailwind, CSS)").option("--theme <theme>","Theme name").option("--palette <palette>","Color palette name").option("--font <font>","Font name").action((e=>{console.log(e),applyTheme(e)})),program.command("preview").description("Preview a theme using a specified palette (e.g., --paletteName vibrant)").allowUnknownOption(!1).option("-p, --paletteName <name>","The palette name to preview").option("-t, --themeName <name>","The theme name to preview").option("-l, --list","List available palettes and themes").action(preview),program.command("cleanup").description("Clean up generated files in a specific directory (e.g., --directory)").option("--directory <path>","Directory to clean up").action(cleanup),program.parse(process.argv),module.exports=__webpack_exports__})();