|
|
@@ -1,154 +1,39 @@
|
|
|
#!/usr/bin/env node
|
|
|
-/* eslint-disable @typescript-eslint/no-require-imports */
|
|
|
+/* eslint-disable */
|
|
|
|
|
|
-const fs = require("fs");
|
|
|
+const {
|
|
|
+ execSync
|
|
|
+} = require("child_process");
|
|
|
const path = require("path");
|
|
|
+const fs = require("fs");
|
|
|
|
|
|
-const targetDir = process.cwd();
|
|
|
-const sourceDir = path.resolve(__dirname, "..");
|
|
|
-
|
|
|
-const args = process.argv.slice(2);
|
|
|
-const initAll = args.includes("--init-all");
|
|
|
-const initVscode = args.includes("--init-vscode") || initAll;
|
|
|
-const initEslint = args.includes("--init-eslint") || initAll;
|
|
|
-const initTsconfig = args.includes("--init-tsconfig") || initAll;
|
|
|
-
|
|
|
-console.log("NCore UI Kit Environment Setup Tool");
|
|
|
-console.log("=====================================");
|
|
|
-console.log(`Hedef Proje Dizini: ${targetDir}`);
|
|
|
-console.log("");
|
|
|
-
|
|
|
-if (!initVscode && !initEslint && !initTsconfig) {
|
|
|
- console.log("Herhangi bir başlatma argümanı (--init-vscode, --init-eslint, --init-tsconfig, --init-all) bulunamadı.");
|
|
|
- console.log("Otomatik ayar kopyalama/birleştirme işlemleri atlanıyor...");
|
|
|
- console.log("Not: Ayarları projeye dahil etmek için kurulum komutuna ilgili bayrakları ekleyebilirsiniz.");
|
|
|
- console.log("");
|
|
|
- process.exit(0);
|
|
|
-}
|
|
|
-
|
|
|
-// JSON parse helper that ignores comments
|
|
|
-function parseJSON(content) {
|
|
|
- try {
|
|
|
- const jsonc = content.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m, g) => g ? "" : m);
|
|
|
- return JSON.parse(jsonc);
|
|
|
- } catch (e) {
|
|
|
- console.error(e);
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-// 1. .vscode/settings.json
|
|
|
-if (initVscode) {
|
|
|
- const sourceVscodeDir = path.join(sourceDir, ".vscode");
|
|
|
- const targetVscodeDir = path.join(targetDir, ".vscode");
|
|
|
-
|
|
|
- if (fs.existsSync(sourceVscodeDir)) {
|
|
|
- if (!fs.existsSync(targetVscodeDir)) {
|
|
|
- fs.mkdirSync(targetVscodeDir, {
|
|
|
- recursive: true
|
|
|
- });
|
|
|
- }
|
|
|
- const sourceSettings = path.join(sourceVscodeDir, "settings.json");
|
|
|
- const targetSettings = path.join(targetVscodeDir, "settings.json");
|
|
|
-
|
|
|
- if (fs.existsSync(sourceSettings)) {
|
|
|
- if (fs.existsSync(targetSettings)) {
|
|
|
- const targetContent = parseJSON(fs.readFileSync(targetSettings, "utf-8")) || {};
|
|
|
- const sourceContent = parseJSON(fs.readFileSync(sourceSettings, "utf-8")) || {};
|
|
|
- const merged = {
|
|
|
- ...sourceContent,
|
|
|
- ...targetContent
|
|
|
- };
|
|
|
- fs.writeFileSync(targetSettings, JSON.stringify(merged, null, 4));
|
|
|
- console.log("✅ .vscode/settings.json birleştirildi (mevcut ayarlarınız korundu).");
|
|
|
- } else {
|
|
|
- fs.copyFileSync(sourceSettings, targetSettings);
|
|
|
- console.log("✅ .vscode/settings.json kopyalandı.");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+console.log("NCore UI Kit - Genel Kurulum (Web & Mobile)");
|
|
|
+console.log("===========================================");
|
|
|
|
|
|
-// 2 & 3. ESLint configs
|
|
|
-if (initEslint) {
|
|
|
- const sourceEslint = path.join(sourceDir, "eslint.config.mjs");
|
|
|
- const targetEslint = path.join(targetDir, "eslint.config.mjs");
|
|
|
- if (fs.existsSync(sourceEslint)) {
|
|
|
- if (!fs.existsSync(targetEslint)) {
|
|
|
- fs.copyFileSync(sourceEslint, targetEslint);
|
|
|
- console.log("✅ eslint.config.mjs kopyalandı.");
|
|
|
- } else {
|
|
|
- console.log("⚠️ eslint.config.mjs hedef projede zaten var, üzerine yazılmadı.");
|
|
|
- }
|
|
|
- }
|
|
|
+const setupWebPath = path.join(__dirname, "setup-web.js");
|
|
|
+const setupMobilePath = path.join(__dirname, "setup-mobile.js");
|
|
|
|
|
|
- const sourceLocalRules = path.join(sourceDir, "eslint-local-rules");
|
|
|
- const targetLocalRules = path.join(targetDir, "eslint-local-rules");
|
|
|
- if (fs.existsSync(sourceLocalRules)) {
|
|
|
- if (!fs.existsSync(targetLocalRules)) {
|
|
|
- fs.mkdirSync(targetLocalRules, {
|
|
|
- recursive: true
|
|
|
- });
|
|
|
- }
|
|
|
- const files = fs.readdirSync(sourceLocalRules);
|
|
|
- files.forEach(file => {
|
|
|
- const sourceFile = path.join(sourceLocalRules, file);
|
|
|
- const targetFile = path.join(targetLocalRules, file);
|
|
|
- if (fs.lstatSync(sourceFile).isFile()) {
|
|
|
- fs.copyFileSync(sourceFile, targetFile);
|
|
|
- }
|
|
|
+try {
|
|
|
+ if (fs.existsSync(setupWebPath)) {
|
|
|
+ execSync(`node "${setupWebPath}"`, {
|
|
|
+ stdio: "inherit"
|
|
|
});
|
|
|
- console.log("✅ eslint-local-rules/ güncellendi.");
|
|
|
}
|
|
|
+} catch (error) {
|
|
|
+ console.error("Web kurulumu sırasında bir hata oluştu:", error.message);
|
|
|
}
|
|
|
|
|
|
-// 4. tsconfig.json
|
|
|
-if (initTsconfig) {
|
|
|
- const sourceTsconfigPath = path.join(sourceDir, "tsconfig.json");
|
|
|
- const targetTsconfigPath = path.join(targetDir, "tsconfig.json");
|
|
|
-
|
|
|
- if (fs.existsSync(sourceTsconfigPath)) {
|
|
|
- const sourceTsconfig = parseJSON(fs.readFileSync(sourceTsconfigPath, "utf-8")) || {};
|
|
|
+console.log(""); // Boşluk
|
|
|
|
|
|
- // ncore-ui-kit iç path tanımlarını projeye aktarmamak için temizliyoruz
|
|
|
- if (sourceTsconfig.compilerOptions && sourceTsconfig.compilerOptions.paths && sourceTsconfig.compilerOptions.paths["ncore-ui-kit"]) {
|
|
|
- delete sourceTsconfig.compilerOptions.paths["ncore-ui-kit"];
|
|
|
- }
|
|
|
-
|
|
|
- if (fs.existsSync(targetTsconfigPath)) {
|
|
|
- const targetTsconfig = parseJSON(fs.readFileSync(targetTsconfigPath, "utf-8")) || {};
|
|
|
-
|
|
|
- // Üzerine ekleme metodu (hedef projenin ayarları önceliklidir)
|
|
|
- const mergedTsconfig = {
|
|
|
- ...sourceTsconfig,
|
|
|
- ...targetTsconfig,
|
|
|
- compilerOptions: {
|
|
|
- ...(sourceTsconfig.compilerOptions || {}),
|
|
|
- ...(targetTsconfig.compilerOptions || {})
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- // Paths birleştirme
|
|
|
- if (sourceTsconfig.compilerOptions?.paths || targetTsconfig.compilerOptions?.paths) {
|
|
|
- mergedTsconfig.compilerOptions.paths = {
|
|
|
- ...(sourceTsconfig.compilerOptions?.paths || {}),
|
|
|
- ...(targetTsconfig.compilerOptions?.paths || {})
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- // Kullanıcının include ve exclude ayarlarını KESİNLİKLE koru
|
|
|
- if (targetTsconfig.include) mergedTsconfig.include = targetTsconfig.include;
|
|
|
- if (targetTsconfig.exclude) mergedTsconfig.exclude = targetTsconfig.exclude;
|
|
|
-
|
|
|
- fs.writeFileSync(targetTsconfigPath, JSON.stringify(mergedTsconfig, null, 4));
|
|
|
- console.log("✅ tsconfig.json mevcut dosyanız ile birleştirildi (include/exclude ve proje ayarları korundu).");
|
|
|
- } else {
|
|
|
- fs.writeFileSync(targetTsconfigPath, JSON.stringify(sourceTsconfig, null, 4));
|
|
|
- console.log("✅ tsconfig.json oluşturuldu.");
|
|
|
- }
|
|
|
+try {
|
|
|
+ if (fs.existsSync(setupMobilePath)) {
|
|
|
+ execSync(`node "${setupMobilePath}"`, {
|
|
|
+ stdio: "inherit"
|
|
|
+ });
|
|
|
}
|
|
|
+} catch (error) {
|
|
|
+ console.error("Mobile kurulumu sırasında bir hata oluştu:", error.message);
|
|
|
}
|
|
|
|
|
|
console.log("");
|
|
|
-console.log("NCore standartlarıyla iyi kodlamalar dileriz!");
|
|
|
+console.log("Not: Tip ayarlarını (tsconfig, eslint vb.) yapmak isterseniz 'npx ncore-type-kit' komutunu kullanabilirsiniz.");
|