setup-web.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env node
  2. /* eslint-disable */
  3. const fs = require("fs");
  4. const path = require("path");
  5. console.log("NCore UI Kit - Web Kurulumu");
  6. console.log("===========================");
  7. const targetDir = process.cwd();
  8. const targetPath = path.resolve(targetDir, "webpack.config.js");
  9. if (fs.existsSync(targetPath)) {
  10. let content = fs.readFileSync(targetPath, "utf-8");
  11. if (!content.includes("withNCoreUIKitWebpack")) {
  12. content = "const { withNCoreUIKitWebpack } = require(\"ncore-ui-kit/webpack-config\");\n" + content;
  13. if (/module\.exports\s*=\s*\{/.test(content)) {
  14. content = content.replace(/module\.exports\s*=\s*\{/g, "const _ncoreConfig = {");
  15. content += "\nmodule.exports = withNCoreUIKitWebpack(_ncoreConfig, webpack);\n";
  16. fs.writeFileSync(targetPath, content);
  17. console.log("✅ webpack.config.js başarıyla güncellendi.");
  18. }
  19. else if (/module\.exports\s*=\s*([a-zA-Z0-9_]+)/.test(content)) {
  20. content = content.replace(/module\.exports\s*=\s*([a-zA-Z0-9_]+);?/g, "module.exports = withNCoreUIKitWebpack($1, webpack);");
  21. fs.writeFileSync(targetPath, content);
  22. console.log("✅ webpack.config.js başarıyla güncellendi.");
  23. } else {
  24. console.log("⚠️ webpack.config.js formatı anlaşılamadı. Lütfen config objesini withNCoreUIKitWebpack ile manuel olarak sarmalayın.");
  25. }
  26. } else {
  27. console.log("✅ webpack.config.js zaten ayarlı.");
  28. }
  29. } else {
  30. console.log("⚠️ webpack.config.js bulunamadı. Web projesi değilse bu adımı atlayabilirsiniz.");
  31. }