oraksoft-node-tools 0.0.2 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env ADDED
@@ -0,0 +1,15 @@
1
+ # Development Ortamı
2
+ NODE_ENV=development
3
+ API_URL=http://localhost:3000
4
+ DB_HOST=localhost
5
+ DB_NAME=myapp_dev
6
+ DEBUG=true
7
+
8
+ # Oraksoft
9
+
10
+ osf_ftp_host=ftp.example.com
11
+ osf_ftp_user=username
12
+ osf_ftp_password=password
13
+ osf_ftp_secure=false
14
+ osf_local_file=deployphp25.tar.gz
15
+ osf_remote_file=/public_html/deploy.tar.gz
package/.env.dev ADDED
@@ -0,0 +1,6 @@
1
+ # Development Ortamı
2
+ NODE_ENV=development
3
+ API_URL=http://localhost:3000
4
+ DB_HOST=localhost
5
+ DB_NAME=myapp_dev
6
+ DEBUG=true
package/.env.example ADDED
@@ -0,0 +1,10 @@
1
+ # FTP Deployment Ayarları
2
+ osf_ftp_host=ftp.example.com
3
+ osf_ftp_user=username
4
+ osf_ftp_password=password
5
+ osf_ftp_secure=false
6
+ osf_local_file=deployphp25.tar.gz
7
+ osf_remote_file=/public_html/deploy.tar.gz
8
+
9
+ # Bu dosyayı gerçek bilgilerinizle güncelleyin
10
+ # Bu dosya .gitignore'da olduğu için version control'e eklenmeyecek
package/.env.oraksoft CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
- "ftp_host": "",
3
- "ftp_user": "",
4
- "ftp_password": "",
5
- "ftp_secure": false,
6
- "localFilePath": "",
7
- "remoteFilePath": ""
2
+ "osf_ftp_host": "",
3
+ "osf_ftp_user": "",
4
+ "osf_ftp_password": "",
5
+ "osf_ftp_secure": false,
6
+ "osf_local_file": "",
7
+ "osf_remote_file": ""
8
8
  }
package/.env.prod ADDED
@@ -0,0 +1,6 @@
1
+ # Production Ortamı
2
+ NODE_ENV=production
3
+ API_URL=https://api.myapp.com
4
+ DB_HOST=prod-db-server
5
+ DB_NAME=myapp_prod
6
+ DEBUG=false
@@ -0,0 +1,10 @@
1
+ # .env dosyalarına erişimi engelle
2
+ <Files ".env*">
3
+ Require all denied
4
+ </Files>
5
+
6
+ # Alternatif yöntem
7
+ <FilesMatch "^\.env">
8
+ Order allow,deny
9
+ Deny from all
10
+ </FilesMatch>
@@ -4,5 +4,7 @@
4
4
  "path": ".."
5
5
  }
6
6
  ],
7
- "settings": {}
7
+ "settings": {
8
+ "window.title": "node-tools"
9
+ }
8
10
  }
package/README.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  Node.js projeleriniz için kullanışlı CLI araçları koleksiyonu.
4
4
 
5
+ - [Oraksoft Node Tools](#oraksoft-node-tools)
6
+ - [Kurulum](#kurulum)
7
+ - [Global kurulum (önerilen)](#global-kurulum-önerilen)
8
+ - [Proje bazında kurulum](#proje-bazında-kurulum)
9
+ - [Konfigürasyon](#konfigürasyon)
10
+ - [Komutlar](#komutlar)
11
+ - [orak-copy-deps](#orak-copy-deps)
12
+ - [orak-deploy-ftp](#orak-deploy-ftp)
13
+ - [orak-deploy-zip](#orak-deploy-zip)
14
+ - [orak-env-change](#orak-env-change)
15
+ - [Kullanım Örnekleri](#kullanım-örnekleri)
16
+ - [1. Bağımlılık Kopyalama](#1-bağımlılık-kopyalama)
17
+ - [2. Deployment İşlemi](#2-deployment-i̇şlemi)
18
+ - [3. Ortam Değiştirme](#3-ortam-değiştirme)
19
+ - [Gereksinimler](#gereksinimler)
20
+ - [Lisans](#lisans)
21
+ - [Katkıda Bulunma](#katkıda-bulunma)
22
+ - [Sorun Bildirimi](#sorun-bildirimi)
23
+
24
+
5
25
  ## Kurulum
6
26
 
7
27
  ### Global kurulum (önerilen)
@@ -14,16 +34,39 @@ pnpm install -g oraksoft-node-tools
14
34
  pnpm install oraksoft-node-tools --save-dev
15
35
  ```
16
36
 
37
+ ## Konfigürasyon
38
+
39
+ Bu araçlar `orak-config.json` dosyasını kullanarak konfigüre edilir. Bu dosyayı proje kök dizininizde oluşturun:
40
+
41
+ ```json
42
+ {
43
+ "copyDepsModulesToCopy": [
44
+ {
45
+ "name": "module-name",
46
+ "file": "dist/module.js"
47
+ }
48
+ ],
49
+ "copyDepsLibFolder": "lib",
50
+ "copyDepsLibFolderEmpty": true,
51
+ "fiDeployZipContent": [
52
+ "src/",
53
+ "public/",
54
+ "package.json"
55
+ ],
56
+ "fiEnvChangeStatus": "dev"
57
+ }
58
+ ```
59
+
17
60
  ## Komutlar
18
61
 
19
- ### fi-copy-deps
62
+ ### orak-copy-deps
20
63
  Node.js bağımlılıklarınızı belirtilen klasöre kopyalar.
21
64
 
22
65
  ```bash
23
- fi-copy-deps
66
+ orak-copy-deps
24
67
  ```
25
68
 
26
- **Gerekli package.json ayarları:**
69
+ **Gerekli orak-config.json ayarları:**
27
70
  ```json
28
71
  {
29
72
  "copyDepsModulesToCopy": [
@@ -37,33 +80,37 @@ fi-copy-deps
37
80
  }
38
81
  ```
39
82
 
40
- ### fi-deploy-ftp
83
+ ### orak-deploy-ftp
41
84
  Dist klasöründeki dosyaları FTP sunucusuna yükler.
42
85
 
43
86
  ```bash
44
- fi-deploy-ftp
87
+ orak-deploy-ftp
45
88
  ```
46
89
 
47
- **Gerekli .env.oraksoft ayarları:**
48
- ```json
49
- {
50
- "ftp_host": "ftp.example.com",
51
- "ftp_user": "username",
52
- "ftp_password": "password",
53
- "ftp_secure": false,
54
- "localFilePath": "deployphp25.tar.gz",
55
- "remoteFilePath": "/path/to/remote/file.tar.gz"
56
- }
90
+ **Gerekli .env dosyası:**
91
+
92
+ ```env
93
+ osf_ftp_host=ftp.example.com
94
+ osf_ftp_user=username
95
+ osf_ftp_password=password
96
+ osf_ftp_secure=false
97
+ osf_local_file=deployphp25.tar.gz
98
+ osf_remote_file=/path/to/remote/file.tar.gz
57
99
  ```
58
100
 
59
- ### fi-deploy-zip
101
+ **❗ Güvenlik Notları:**
102
+ - `.env` dosyası zaten .gitignore'da bulunuyor
103
+ - Web sunucunuzda `.env` dosyalarına erişimi engelleyin (.htaccess)
104
+ - Dosya izinlerini kısıtlayın: `chmod 600 .env`
105
+
106
+ ### orak-deploy-zip
60
107
  Belirtilen dosya ve klasörleri tar.gz formatında arşivler.
61
108
 
62
109
  ```bash
63
- fi-deploy-zip
110
+ orak-deploy-zip
64
111
  ```
65
112
 
66
- **Gerekli package.json ayarları:**
113
+ **Gerekli orak-config.json ayarları:**
67
114
  ```json
68
115
  {
69
116
  "fiDeployZipContent": [
@@ -74,48 +121,49 @@ fi-deploy-zip
74
121
  }
75
122
  ```
76
123
 
77
- ### fi-env-change
124
+ ### orak-env-change
78
125
  Ortam dosyalarını (.env) değiştirir.
79
126
 
80
127
  ```bash
81
- fi-env-change dev
128
+ orak-env-change dev
82
129
  # veya
83
- fi-env-change production
130
+ orak-env-change production
84
131
  ```
85
132
 
86
- **Opsiyonel package.json ayarları:**
133
+ **Opsiyonel orak-config.json ayarları:**
87
134
  ```json
88
135
  {
89
136
  "fiEnvChangeStatus": "dev"
90
137
  }
91
138
  ```
92
139
 
93
- Bu durumda parametre vermeden `fi-env-change` komutunu çalıştırabilirsiniz.
140
+ Bu durumda parametre vermeden `orak-env-change` komutunu çalıştırabilirsiniz.
94
141
 
95
142
  ## Kullanım Örnekleri
96
143
 
97
144
  ### 1. Bağımlılık Kopyalama
98
145
  ```bash
99
- # package.json'da tanımlanan modülleri kopyala
100
- fi-copy-deps
146
+ # orak-config.json'da tanımlanan modülleri kopyala
147
+ orak-copy-deps
101
148
  ```
102
149
 
103
150
  ### 2. Deployment İşlemi
104
151
  ```bash
152
+ # .env dosyası oluşturun ve FTP bilgilerinizi ekleyin
105
153
  # Önce arşiv oluştur
106
- fi-deploy-zip
154
+ orak-deploy-zip
107
155
 
108
156
  # Sonra FTP'ye yükle
109
- fi-deploy-ftp
157
+ orak-deploy-ftp
110
158
  ```
111
159
 
112
160
  ### 3. Ortam Değiştirme
113
161
  ```bash
114
162
  # Development ortamına geç
115
- fi-env-change dev
163
+ orak-env-change dev
116
164
 
117
165
  # Production ortamına geç
118
- fi-env-change prod
166
+ orak-env-change prod
119
167
  ```
120
168
 
121
169
  ## Gereksinimler
@@ -137,4 +185,4 @@ MIT
137
185
 
138
186
  ## Sorun Bildirimi
139
187
 
140
- Sorunlarınızı [GitHub Issues](https://github.com/oraksoft/oraksoft-node-tools/issues) sayfasından bildirebilirsiniz.
188
+ Sorunlarınızı [GitHub Issues](https://github.com/oraksoftware/oraksoft-node-tools/issues) sayfasından bildirebilirsiniz.
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import { copyDeps } from '../lib/copy-deps.js';
4
4
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import { deployFtp } from '../lib/deploy-ftp.js';
4
4
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import { deployZip } from '../lib/deploy-zip.js';
4
4
 
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import { envChange } from '../lib/env-change.js';
4
4
 
@@ -0,0 +1,77 @@
1
+ import crypto from 'crypto';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ const ENCRYPTION_KEY = process.env.ORAK_ENCRYPTION_KEY; // 32 byte key
6
+ const ALGORITHM = 'aes-256-gcm';
7
+
8
+ export function encryptConfig(config) {
9
+ if (!ENCRYPTION_KEY) {
10
+ throw new Error('ORAK_ENCRYPTION_KEY environment variable gerekli');
11
+ }
12
+
13
+ const iv = crypto.randomBytes(16);
14
+ const cipher = crypto.createCipher(ALGORITHM, ENCRYPTION_KEY);
15
+
16
+ let encrypted = cipher.update(JSON.stringify(config), 'utf8', 'hex');
17
+ encrypted += cipher.final('hex');
18
+
19
+ const authTag = cipher.getAuthTag();
20
+
21
+ return {
22
+ encrypted,
23
+ iv: iv.toString('hex'),
24
+ authTag: authTag.toString('hex')
25
+ };
26
+ }
27
+
28
+ export function decryptConfig(encryptedData) {
29
+ if (!ENCRYPTION_KEY) {
30
+ throw new Error('ORAK_ENCRYPTION_KEY environment variable gerekli');
31
+ }
32
+
33
+ const decipher = crypto.createDecipher(ALGORITHM, ENCRYPTION_KEY);
34
+ decipher.setAuthTag(Buffer.from(encryptedData.authTag, 'hex'));
35
+
36
+ let decrypted = decipher.update(encryptedData.encrypted, 'hex', 'utf8');
37
+ decrypted += decipher.final('utf8');
38
+
39
+ return JSON.parse(decrypted);
40
+ }
41
+
42
+ export function saveEncryptedConfig(config, filePath) {
43
+ const encrypted = encryptConfig(config);
44
+ fs.writeFileSync(filePath, JSON.stringify(encrypted, null, 2));
45
+ }
46
+
47
+ export function loadEncryptedConfig(filePath) {
48
+ if (!fs.existsSync(filePath)) {
49
+ return null;
50
+ }
51
+
52
+ const encryptedData = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
53
+ return decryptConfig(encryptedData);
54
+ }
55
+
56
+ // Konfigürasyon oluşturma utility'si
57
+ export function createEncryptedConfig() {
58
+ const config = {
59
+ ftp_host: "ftp.example.com",
60
+ ftp_user: "username",
61
+ ftp_password: "password",
62
+ ftp_secure: false,
63
+ localFilePath: "deployphp25.tar.gz",
64
+ remoteFilePath: "/path/to/remote/file.tar.gz"
65
+ };
66
+
67
+ const projectRoot = process.cwd();
68
+ const configPath = path.join(projectRoot, '.config.oraksoft.encrypted');
69
+
70
+ try {
71
+ saveEncryptedConfig(config, configPath);
72
+ console.log('✅ Şifreli konfigürasyon oluşturuldu:', configPath);
73
+ console.log('📝 Konfigürasyonu düzenleyin ve ORAK_ENCRYPTION_KEY environment variable\'ını ayarlayın');
74
+ } catch (error) {
75
+ console.error('❌ Şifreli konfigürasyon oluşturulamadı:', error.message);
76
+ }
77
+ }
package/lib/copy-deps.js CHANGED
@@ -1,35 +1,52 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
3
7
 
4
8
  export function copyDeps() {
9
+ // Argüman kontrolü ve yardım mesajı
10
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
11
+ // package.json'dan versiyon al
12
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
13
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
14
+
15
+ console.log(`orak-copy-deps version ${packageJson.version}`);
16
+ console.log('Kullanım: orak-copy-deps');
17
+ console.log('Node.js bağımlılıklarınızı belirtilen klasöre kopyalar.');
18
+ console.log('Konfigürasyon: orak-config.json dosyasında "copyDepsModulesToCopy" ve "copyDepsLibFolder" ayarları gerekli.');
19
+ process.exit(0);
20
+ }
21
+
5
22
  // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
6
23
  const projectRoot = process.cwd();
7
24
  const srcDir = path.join(projectRoot, 'node_modules');
8
25
 
9
- // package.json dosyasını oku
10
- const packageJsonPath = path.join(projectRoot, 'package.json');
26
+ // orak-config.json dosyasını oku
27
+ const configPath = path.join(projectRoot, 'orak-config.json');
11
28
 
12
- if (!fs.existsSync(packageJsonPath)) {
13
- console.error("Error: package.json dosyası bulunamadı. Bu komutu bir Node.js projesi klasöründe çalıştırın.");
29
+ if (!fs.existsSync(configPath)) {
30
+ console.error("Error: orak-config.json dosyası bulunamadı. Bu komutu proje kök dizininde çalıştırın.");
14
31
  process.exit(1);
15
32
  }
16
33
 
17
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
34
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
18
35
 
19
- if (!packageJson.copyDepsModulesToCopy || !Array.isArray(packageJson.copyDepsModulesToCopy)) {
20
- console.error("Error: 'copyDepsModulesToCopy' alanı package.json içinde bir dizi olarak tanımlanmalıdır.");
36
+ if (!config.copyDepsModulesToCopy || !Array.isArray(config.copyDepsModulesToCopy)) {
37
+ console.error("Error: 'copyDepsModulesToCopy' alanı orak-config.json içinde bir dizi olarak tanımlanmalıdır.");
21
38
  process.exit(1);
22
39
  }
23
40
 
24
- if (typeof packageJson.copyDepsLibFolder !== "string") {
25
- console.error("Error: 'copyDepsLibFolder' alanı package.json içinde bir string olarak tanımlanmalıdır.");
41
+ if (typeof config.copyDepsLibFolder !== "string") {
42
+ console.error("Error: 'copyDepsLibFolder' alanı orak-config.json içinde bir string olarak tanımlanmalıdır.");
26
43
  process.exit(1);
27
44
  }
28
45
 
29
46
  // copyDepsLibFolder dizinini belirle
30
- const destDir = path.join(projectRoot, packageJson.copyDepsLibFolder);
47
+ const destDir = path.join(projectRoot, config.copyDepsLibFolder);
31
48
 
32
- if (packageJson.copyDepsLibFolderEmpty) {
49
+ if (config.copyDepsLibFolderEmpty) {
33
50
  if (fs.existsSync(destDir)) {
34
51
  fs.rmSync(destDir, { recursive: true, force: true });
35
52
  console.log(`Deleted ${destDir} and its contents.`);
@@ -42,7 +59,7 @@ export function copyDeps() {
42
59
  }
43
60
 
44
61
  // 📌 Kopyalanacak dosyaları belirle
45
- const modulesToCopy = packageJson.copyDepsModulesToCopy;
62
+ const modulesToCopy = config.copyDepsModulesToCopy;
46
63
 
47
64
  modulesToCopy.forEach(({ name, file }) => {
48
65
  const modPath = path.join(srcDir, name, file); // Kaynak dosya
@@ -0,0 +1,79 @@
1
+ import { Client } from "basic-ftp";
2
+ import path from "path";
3
+ import fs from 'fs';
4
+
5
+ export async function deployFtp() {
6
+ const projectRoot = process.cwd();
7
+
8
+ // Önce environment variables'ı kontrol et
9
+ let ftpHost = process.env.ORAK_FTP_HOST;
10
+ let ftpUser = process.env.ORAK_FTP_USER;
11
+ let ftpPassword = process.env.ORAK_FTP_PASSWORD;
12
+ let ftpSecure = process.env.ORAK_FTP_SECURE === 'true';
13
+ let localFilePath = process.env.ORAK_LOCAL_FILE;
14
+ let remoteFilePath = process.env.ORAK_REMOTE_FILE;
15
+
16
+ // Eğer env variables yoksa, .env.oraksoft'a fallback et
17
+ if (!ftpHost || !ftpUser || !ftpPassword) {
18
+ const oraksoftJsonPath = path.join(projectRoot, '.env.oraksoft');
19
+
20
+ if (fs.existsSync(oraksoftJsonPath)) {
21
+ console.log("⚠️ Environment variables bulunamadı, .env.oraksoft dosyasından okuyorum...");
22
+ const oraksoftJson = JSON.parse(fs.readFileSync(oraksoftJsonPath, 'utf-8'));
23
+
24
+ ftpHost = ftpHost || oraksoftJson.osf_ftp_host;
25
+ ftpUser = ftpUser || oraksoftJson.osf_ftp_user;
26
+ ftpPassword = ftpPassword || oraksoftJson.osf_ftp_password;
27
+ ftpSecure = ftpSecure || oraksoftJson.osf_ftp_secure || false;
28
+ localFilePath = localFilePath || oraksoftJson.osf_local_file;
29
+ remoteFilePath = remoteFilePath || oraksoftJson.osf_remote_file;
30
+ }
31
+ } else {
32
+ console.log("✅ Environment variables kullanılıyor (güvenli)");
33
+ }
34
+
35
+ if (!ftpHost || !ftpUser || !ftpPassword) {
36
+ console.error(`
37
+ ❌ FTP bilgileri bulunamadı!
38
+
39
+ Güvenli yöntem (önerilen):
40
+ set ORAK_FTP_HOST=ftp.example.com
41
+ set ORAK_FTP_USER=username
42
+ set ORAK_FTP_PASSWORD=password
43
+ set ORAK_FTP_SECURE=false
44
+ set ORAK_LOCAL_FILE=deployphp25.tar.gz
45
+ set ORAK_REMOTE_FILE=/path/to/remote/file.tar.gz
46
+
47
+ Alternatif: .env.oraksoft dosyası oluşturun.
48
+ `);
49
+ process.exit(1);
50
+ }
51
+
52
+ const client = new Client();
53
+ client.ftp.verbose = true;
54
+
55
+ try {
56
+ await client.access({
57
+ host: ftpHost,
58
+ user: ftpUser,
59
+ password: ftpPassword,
60
+ secure: ftpSecure
61
+ });
62
+
63
+ const fullLocalPath = path.join(projectRoot, "dist", localFilePath);
64
+
65
+ if (!fs.existsSync(fullLocalPath)) {
66
+ console.error(`Error: Yerel dosya bulunamadı: ${fullLocalPath}`);
67
+ process.exit(1);
68
+ }
69
+
70
+ console.log(`Yükleniyor: ${fullLocalPath} -> ${remoteFilePath}`);
71
+ await client.uploadFrom(fullLocalPath, remoteFilePath);
72
+ console.log("✅ FTP yükleme tamamlandı!");
73
+ }
74
+ catch(err) {
75
+ console.error("❌ FTP Hatası:", err);
76
+ process.exit(1);
77
+ }
78
+ client.close();
79
+ }
package/lib/deploy-ftp.js CHANGED
@@ -1,30 +1,70 @@
1
1
  import { Client } from "basic-ftp";
2
2
  import path from "path";
3
3
  import fs from 'fs';
4
+ import { fileURLToPath } from 'url';
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
4
8
 
5
9
  export async function deployFtp() {
6
- // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
10
+ // Argüman kontrolü ve yardım mesajı
11
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
12
+ // package.json'dan versiyon al
13
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
14
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
15
+
16
+ console.log(`orak-deploy-ftp version ${packageJson.version}`);
17
+ console.log('Kullanım: orak-deploy-ftp');
18
+ console.log('Dist klasöründeki dosyaları FTP sunucusuna yükler.');
19
+ console.log('Konfigürasyon: .env dosyasında FTP bilgileri gerekli.');
20
+ process.exit(0);
21
+ }
22
+
7
23
  const projectRoot = process.cwd();
8
24
 
9
- // Arşivlenecek dosya ve klasörlerin yolları
10
- const oraksoftJsonPath = path.join(projectRoot, '.env.oraksoft');
25
+ // .env dosyasını oku
26
+ const envPath = path.join(projectRoot, '.env');
11
27
 
12
- if (!fs.existsSync(oraksoftJsonPath)) {
13
- console.error("Error: .env.oraksoft dosyası bulunamadı. Bu dosyayı oluşturup FTP bilgilerinizi ekleyin.");
28
+ if (!fs.existsSync(envPath)) {
29
+ console.error(`
30
+ ❌ .env dosyası bulunamadı!
31
+
32
+ .env dosyası oluşturun ve şu bilgileri ekleyin:
33
+ osf_ftp_host=ftp.example.com
34
+ osf_ftp_user=username
35
+ osf_ftp_password=password
36
+ osf_ftp_secure=false
37
+ osf_local_file=deployphp25.tar.gz
38
+ osf_remote_file=/path/to/remote/file.tar.gz
39
+ `);
14
40
  process.exit(1);
15
41
  }
16
42
 
17
- const oraksoftJson = JSON.parse(fs.readFileSync(oraksoftJsonPath, 'utf-8'));
43
+ // .env dosyasını parse et
44
+ const envContent = fs.readFileSync(envPath, 'utf-8');
45
+ const envVars = {};
46
+
47
+ envContent.split('\n').forEach(line => {
48
+ const trimmedLine = line.trim();
49
+ if (trimmedLine && !trimmedLine.startsWith('#')) {
50
+ const [key, ...valueParts] = trimmedLine.split('=');
51
+ if (key && valueParts.length > 0) {
52
+ envVars[key.trim()] = valueParts.join('=').trim();
53
+ }
54
+ }
55
+ });
56
+
57
+ const ftpHost = envVars.osf_ftp_host;
58
+ const ftpUser = envVars.osf_ftp_user;
59
+ const ftpPassword = envVars.osf_ftp_password;
60
+ const ftpSecure = envVars.osf_ftp_secure === 'true';
61
+ const localFileName = envVars.osf_local_file;
62
+ const remoteFilePath1 = envVars.osf_remote_file;
18
63
 
19
- let ftpHost = oraksoftJson.ftp_host;
20
- let ftpUser = oraksoftJson.ftp_user;
21
- let ftpPassword = oraksoftJson.ftp_password;
22
- let ftpSecure = oraksoftJson.ftp_secure || false;
23
- let localFilePath1 = path.join(projectRoot, "dist", oraksoftJson.localFilePath);
24
- let remoteFilePath1 = oraksoftJson.remoteFilePath;
64
+ let localFilePath1 = path.join(projectRoot, "dist", localFileName);
25
65
 
26
66
  if (!ftpHost || !ftpUser || !ftpPassword) {
27
- console.error("Error: FTP bilgileri eksik. .env.oraksoft dosyasında ftp_host, ftp_user ve ftp_password alanlarını kontrol edin.");
67
+ console.error("Error: FTP bilgileri eksik. .env.oraksoft dosyasında osf_ftp_host, osf_ftp_user ve osf_ftp_password alanlarını kontrol edin.");
28
68
  process.exit(1);
29
69
  }
30
70
 
package/lib/deploy-zip.js CHANGED
@@ -1,66 +1,90 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import * as tar from 'tar';
4
+ import { fileURLToPath } from 'url';
4
5
 
5
- export async function deployZip() {
6
- // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
7
- const projectRoot = process.cwd();
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
8
 
9
- // Arşivlenecek dosya ve klasörlerin yolları
10
- const packageJsonPath = path.join(projectRoot, 'package.json');
9
+ export async function deployZip() {
10
+ // Argüman kontrolü ve yardım mesajı
11
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
12
+ // package.json'dan versiyon al
13
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
14
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
11
15
 
12
- if (!fs.existsSync(packageJsonPath)) {
13
- console.error("Error: package.json dosyası bulunamadı. Bu komutu bir Node.js projesi klasöründe çalıştırın.");
14
- process.exit(1);
15
- }
16
+ console.log(`orak-deploy-zip version ${packageJson.version}`);
17
+ console.log('Kullanım: orak-deploy-zip');
18
+ console.log('Belirtilen dosya ve klasörleri tar.gz formatında arşivler.');
19
+ console.log('Konfigürasyon: orak-config.json dosyasında "fiDeployZipContent" ayarı gerekli.');
20
+ process.exit(0);
21
+ }
16
22
 
17
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
23
+ // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
24
+ const projectRoot = process.cwd();
25
+
26
+ // orak-config.json dosyasını oku
27
+ const configPath = path.join(projectRoot, 'orak-config.json');
28
+
29
+ if (!fs.existsSync(configPath)) {
30
+ console.error("Error: orak-config.json dosyası bulunamadı. Bu komutu proje kök dizininde çalıştırın.");
31
+ process.exit(1);
32
+ }
33
+
34
+ const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
18
35
 
19
- if (!packageJson.fiDeployZipContent || !Array.isArray(packageJson.fiDeployZipContent)) {
20
- console.error("Error: 'fiDeployZipContent' alanı package.json içinde bir dizi olarak tanımlanmalıdır.");
21
- process.exit(1);
22
- }
36
+ if (!config.fiDeployZipContent || !Array.isArray(config.fiDeployZipContent)) {
37
+ console.error("Error: 'fiDeployZipContent' alanı orak-config.json içinde bir dizi olarak tanımlanmalıdır.");
38
+ process.exit(1);
39
+ }
23
40
 
24
- const filesToArchive = packageJson.fiDeployZipContent;
41
+ const filesToArchive = config.fiDeployZipContent;
25
42
 
26
- // dist klasörü ve arşiv adı
27
- const distDir = path.resolve(projectRoot, 'dist');
28
- const archiveName = 'deployphp25.tar.gz';
29
- const archivePath = path.join(distDir, archiveName);
43
+ // dist klasörü ve arşiv adı
44
+ const distDir = path.resolve(projectRoot, 'dist');
45
+ const archiveName = 'deployphp25.tar.gz';
46
+ const archivePath = path.join(distDir, archiveName);
30
47
 
31
- // dist klasörü yoksa oluştur
32
- if (!fs.existsSync(distDir)) {
33
- fs.mkdirSync(distDir, { recursive: true });
34
- }
48
+ // dist klasörü yoksa oluştur
49
+ if (!fs.existsSync(distDir)) {
50
+ fs.mkdirSync(distDir, { recursive: true });
51
+ }
35
52
 
36
- // Arşiv oluştur
37
- try {
38
- await tar.c(
39
- {
40
- gzip: true,
41
- file: archivePath,
42
- cwd: projectRoot,
43
- follow: true, // symlink/junction'ları takip et
44
- filter: (path, stat) => {
45
- // .git klasörlerini ve test dosyalarını hariç tut
46
- const normalizedPath = path.replace(/\\/g, '/');
47
- if (normalizedPath.includes('/.git/') || normalizedPath.includes('/.git') ||
48
- normalizedPath.includes('/tests/') || normalizedPath.includes('/tests') ||
49
- normalizedPath.includes('/fi-logs/') || normalizedPath.includes('/fi-logs') ||
50
- normalizedPath.includes('/.github/') || normalizedPath.includes('/.github') ||
51
- normalizedPath.endsWith('.md') || normalizedPath.endsWith('phpunit.xml.dist') ||
52
- normalizedPath.endsWith('.gitignore') || normalizedPath.endsWith('.gitattributes')) {
53
- console.log('Excluding:', path);
54
- return false;
55
- }
56
- return true;
57
- }
58
- },
59
- filesToArchive
60
- );
61
- console.log(`✅ Arşiv oluşturuldu: ${archivePath}`);
62
- } catch (err) {
63
- console.error('❌ Arşivleme hatası:', err);
64
- process.exit(1);
65
- }
53
+ // Arşiv oluştur
54
+ try {
55
+ await tar.c(
56
+ {
57
+ gzip: true,
58
+ file: archivePath,
59
+ cwd: projectRoot,
60
+ follow: true, // symlink/junction'ları takip et
61
+ filter: (path, stat) => {
62
+ // .git klasörlerini ve test dosyalarını hariç tut
63
+ const normalizedPath = path.replace(/\\/g, '/');
64
+ if (normalizedPath.includes('/.git/')
65
+ || normalizedPath.includes('/.git')
66
+ || normalizedPath.includes('/tests/')
67
+ || normalizedPath.includes('/tests')
68
+ || normalizedPath.includes('/fi-logs/')
69
+ || normalizedPath.includes('/fi-logs')
70
+ || normalizedPath.includes('/.github/')
71
+ || normalizedPath.includes('/.github')
72
+ || normalizedPath.endsWith('.md')
73
+ || normalizedPath.endsWith('phpunit.xml.dist')
74
+ || normalizedPath.endsWith('.gitignore')
75
+ || normalizedPath.endsWith('.gitattributes')
76
+ ) {
77
+ console.log('Excluding:', path);
78
+ return false;
79
+ }
80
+ return true;
81
+ }
82
+ },
83
+ filesToArchive
84
+ );
85
+ console.log(`✅ Arşiv oluşturuldu: ${archivePath}`);
86
+ } catch (err) {
87
+ console.error('❌ Arşivleme hatası:', err);
88
+ process.exit(1);
89
+ }
66
90
  }
package/lib/env-change.js CHANGED
@@ -1,5 +1,9 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
3
7
 
4
8
  export function envChange() {
5
9
 
@@ -9,31 +13,36 @@ export function envChange() {
9
13
  // process.argv[2] = ilk argüman
10
14
  const envArgument = process.argv[2];
11
15
 
12
- let txEnv = envArgument || packageJson.fiEnvChangeStatus;
13
-
14
16
  // Argüman kontrolü ve yardım mesajı
15
17
  if (process.argv.includes('--help') || process.argv.includes('-h')) {
16
- console.log('fi-env-change version 0.0.2');
17
- console.log('Kullanım: fi-env-change [ortam_adı]');
18
- console.log('Örnek: fi-env-change dev');
19
- console.log('Argüman verilmezse package.json\'daki fiEnvChangeStatus değeri kullanılır.');
18
+ // package.json'dan versiyon al
19
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
20
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
21
+
22
+ console.log(`orak-env-change version ${packageJson.version}`);
23
+ console.log('Kullanım: orak-env-change [ortam_adı]');
24
+ console.log('Örnek: orak-env-change dev');
25
+ console.log('Argüman verilmezse orak-config.json\'daki fiEnvChangeStatus değeri kullanılır.');
20
26
  process.exit(0);
21
27
  }
22
28
 
23
29
  // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
24
30
  const projectRoot = process.cwd();
25
31
 
26
- // Arşivlenecek dosya ve klasörlerin yolları
27
- const packageJsonPath = path.join(projectRoot, 'package.json');
32
+ // orak-config.json dosyasını oku
33
+ const configPath = path.join(projectRoot, 'orak-config.json');
28
34
 
29
- let packageJson = {};
30
- if (fs.existsSync(packageJsonPath)) {
31
- packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
35
+ let config = {};
36
+ if (fs.existsSync(configPath)) {
37
+ config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
32
38
  }
33
39
 
40
+ let txEnv = envArgument || config.fiEnvChangeStatus;
41
+
34
42
  if (!txEnv) {
35
- console.error('❌ Ortam adı belirtilmedi ve package.json\'da fiEnvChangeStatus bulunamadı.');
36
- console.log('Kullanım: fi-env-change [ortam_adı]');
43
+ console.error('❌ Ortam adı belirtilmedi ve orak-config.json\'da fiEnvChangeStatus bulunamadı.');
44
+ console.log('Kullanım: orak-env-change [ortam_adı]');
45
+ console.log('Alternatif: orak-config.json dosyasında "fiEnvChangeStatus" değeri tanımlayın.');
37
46
  process.exit(1);
38
47
  }
39
48
 
@@ -0,0 +1,16 @@
1
+ {
2
+ "copyDepsModulesToCopy": [
3
+ {
4
+ "name": "module-name",
5
+ "file": "dist/module.js"
6
+ }
7
+ ],
8
+ "copyDepsLibFolder": "lib",
9
+ "copyDepsLibFolderEmpty": true,
10
+ "fiDeployZipContent": [
11
+ "src/",
12
+ "public/",
13
+ "package.json"
14
+ ],
15
+ "fiEnvChangeStatus": "dev"
16
+ }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "oraksoft-node-tools",
3
- "version": "0.0.2",
4
- "description": "CLI araçları koleksiyonu - fi-copy-deps, fi-deploy-ftp, fi-deploy-zip ve fi-env-change komutları",
3
+ "version": "0.1.1",
4
+ "description": "CLI araçları koleksiyonu - orak-copy-deps, orak-deploy-ftp, orak-deploy-zip ve orak-env-change komutları",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
7
7
  "bin": {
8
- "fi-copy-deps": "./bin/fi-copy-deps.js",
9
- "fi-deploy-ftp": "./bin/fi-deploy-ftp.js",
10
- "fi-deploy-zip": "./bin/fi-deploy-zip.js",
11
- "fi-env-change": "./bin/fi-env-change.js"
8
+ "orak-copy-deps": "./bin/orak-copy-deps.js",
9
+ "orak-deploy-ftp": "./bin/orak-deploy-ftp.js",
10
+ "orak-deploy-zip": "./bin/orak-deploy-zip.js",
11
+ "orak-env-change": "./bin/orak-env-change.js"
12
12
  },
13
13
  "keywords": [
14
14
  "cli",
@@ -32,12 +32,12 @@
32
32
  "preferGlobal": true,
33
33
  "repository": {
34
34
  "type": "git",
35
- "url": "git+https://github.com/engtuncay/oraksoft-node-tools.git"
35
+ "url": "git+https://github.com/oraksoftware/oraksoft-node-tools.git"
36
36
  },
37
37
  "bugs": {
38
- "url": "https://github.com/engtuncay/oraksoft-node-tools/issues"
38
+ "url": "https://github.com/oraksoftware/oraksoft-node-tools/issues"
39
39
  },
40
- "homepage": "https://github.com/engtuncay/oraksoft-node-tools#readme",
40
+ "homepage": "https://github.com/oraksoftware/oraksoft-node-tools#readme",
41
41
  "scripts": {
42
42
  "test": "echo \"Error: no test specified\" && exit 1",
43
43
  "build": "echo \"Build completed\""