cliforlw
Version:
A professionally designed animate react component library & templates market that brings together functionality, accessibility, and beautiful aesthetics for modern applications.
68 lines (58 loc) • 1.99 kB
JavaScript
const { execSync } = require("child_process");
const fs = require("fs-extra");
const path = require("path");
const args = process.argv.slice(2);
const componentArg = args[0];
const libFrom = path.join(__dirname, "lib");
const libTo = path.join(process.cwd(), "src", "components", "lib");
function installPackages(packages) {
try {
const installCmd = Object.entries(packages)
.map(([pkg, version]) => `${pkg}@${version}`)
.join(" ");
console.log("📦 Installing required packages...");
execSync(`npm install ${installCmd} --save`, { stdio: "inherit" });
console.log("✅ Dependencies installed successfully.");
} catch (error) {
console.error("❌ Failed to install dependencies:", error.message);
}
}
if (componentArg) {
// Install single component
const fileName = `${componentArg}.tsx`;
const fromComponent = path.join(__dirname, "Components", fileName);
const toComponent = path.join(
process.cwd(),
"src",
"components",
"lightswind",
fileName
);
if (fs.existsSync(fromComponent)) {
fs.ensureDirSync(path.dirname(toComponent));
fs.copyFileSync(fromComponent, toComponent);
console.log(`✅ Installed component: ${fileName}`);
} else {
console.error(`❌ Component '${componentArg}' not found.`);
process.exit(1);
}
if (fs.existsSync(libFrom)) {
fs.ensureDirSync(libTo);
fs.copySync(libFrom, libTo);
console.log(`✅ Installed shared lib`);
}
} else {
// Install all components
const allFrom = path.join(__dirname, "Components");
const allTo = path.join(process.cwd(), "src", "components", "lightswind");
if (fs.existsSync(allFrom)) {
fs.ensureDirSync(allTo);
fs.copySync(allFrom, allTo);
console.log(`✅ Installed all components`);
}
if (fs.existsSync(libFrom)) {
fs.ensureDirSync(libTo);
fs.copySync(libFrom, libTo);
console.log(`✅ Installed shared lib`);
}
}