oraksoft-node-tools 0.1.5 → 0.1.18

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.
Binary file
Binary file
Binary file
File without changes
File without changes
package/README.md CHANGED
@@ -10,11 +10,12 @@ Node.js projeleriniz için kullanışlı CLI araçları koleksiyonu.
10
10
  - [Komutlar](#komutlar)
11
11
  - [orak-copy-deps](#orak-copy-deps)
12
12
  - [orak-deploy-ftp](#orak-deploy-ftp)
13
- - [orak-deploy-zip](#orak-deploy-zip)
13
+ - [orak-zip-content](#orak-zip-content)
14
+ - [orak-zip-package](#orak-zip-package)
14
15
  - [orak-env-change](#orak-env-change)
15
16
  - [Kullanım Örnekleri](#kullanım-örnekleri)
16
17
  - [1. Bağımlılık Kopyalama](#1-bağımlılık-kopyalama)
17
- - [2. Deployment İşlemi](#2-deployment-i̇şlemi)
18
+ - [2. Arşiv Oluşturma ve FTP Yükleme](#2-arşiv-oluşturma-ve-ftp-yükleme)
18
19
  - [3. Ortam Değiştirme](#3-ortam-değiştirme)
19
20
  - [Gereksinimler](#gereksinimler)
20
21
  - [Lisans](#lisans)
@@ -30,6 +31,7 @@ pnpm install -g oraksoft-node-tools
30
31
  ```
31
32
 
32
33
  ### Proje bazında kurulum
34
+
33
35
  ```bash
34
36
  pnpm install oraksoft-node-tools --save-dev
35
37
  ```
@@ -48,19 +50,17 @@ Bu araçlar `orak-config.json` dosyasını kullanarak konfigüre edilir. Bu dosy
48
50
  ],
49
51
  "copyDepsLibFolder": "lib",
50
52
  "copyDepsLibFolderEmpty": true,
51
- "fiDeployZipFile": "orak-deploy-zip",
52
- "fiDeployZipContent": [
53
- "src/",
54
- "public/",
55
- "package.json"
56
- ],
57
- "fiEnvChangeStatus": "dev"
53
+ "zip_package": ["lib/", "bin/"],
54
+ "zip_package_out_file": ".orak-dist/deploy1.tar.gz",
55
+ "zip_content": ["bin", "lib"],
56
+ "zip_content_out_file": ".orak-dist/deploy.tar.gz"
58
57
  }
59
58
  ```
60
59
 
61
60
  ## Komutlar
62
61
 
63
62
  ### orak-copy-deps
63
+
64
64
  Node.js bağımlılıklarınızı belirtilen klasöre kopyalar.
65
65
 
66
66
  ```bash
@@ -68,6 +68,7 @@ orak-copy-deps
68
68
  ```
69
69
 
70
70
  **Gerekli orak-config.json ayarları:**
71
+
71
72
  ```json
72
73
  {
73
74
  "copyDepsModulesToCopy": [
@@ -79,54 +80,100 @@ orak-copy-deps
79
80
  "copyDepsLibFolder": "lib",
80
81
  "copyDepsLibFolderEmpty": true
81
82
  }
83
+
82
84
  ```
83
85
 
84
86
  ### orak-deploy-ftp
85
- Dist klasöründeki dosyaları FTP sunucusuna yükler.
87
+
88
+ Belirtilen dosyayı FTP sunucusuna yükler.
86
89
 
87
90
  ```bash
88
- orak-deploy-ftp
91
+ orak-deploy-ftp [--profile <name>] [--v]
89
92
  ```
90
93
 
91
- **Gerekli .env dosyası:**
94
+ **Gerekli .env.orakconfig dosyası:**
92
95
 
93
96
  ```env
94
97
  osf_ftp_host=ftp.example.com
95
98
  osf_ftp_user=username
96
99
  osf_ftp_password=password
97
100
  osf_ftp_secure=false
98
- osf_local_file=orak-deploy-zip.tar.gz
99
- osf_remote_file=/path/to/remote/file.tar.gz
101
+ osf_ftp_local_file=deploy.tar.gz
102
+ osf_ftp_remote_path=public_html
100
103
  ```
101
104
 
102
- - `osf_local_file` belirtilmezse, `orak-config.json`'daki `fiDeployZipFile` değeri kullanılır
105
+ - `osf_ftp_host`: FTP sunucusunun adresi
106
+ - `osf_ftp_user`: FTP kullanıcı adı
107
+ - `osf_ftp_password`: FTP şifresi
108
+ - `osf_ftp_secure`: `true` FTPS kullanır, `false` FTP kullanır (varsayılan: `false`)
109
+ - `osf_ftp_local_file`: Yüklenmek istenen dosyanın proje köküne göre yolu (**uzantılı** olarak yazın, ör: `deploy.tar.gz`)
110
+ - `osf_ftp_remote_path`: Uzak sunucudaki hedef klasör yolu (varsayılan: `/`)
111
+ - Dosya adı otomatik olarak `osf_ftp_local_file`'ın son bölümünden alınır
112
+
113
+ Ek opsiyonlar:
114
+
115
+ - `--profile <name>`: Belirtilen profil için önce `osf_ftp_local_file_<name>` (veya `orak-config.json` içinde aynı anahtar) aranır. Örnek: `--profile test` -> `osf_ftp_local_file_test`. Konsolda: `test profil uygulandı.`
116
+
117
+ - `--v`: Paket sürümünü (`package.json` içindeki `version`) dosya adına ekler. Noktalar `_` ile değiştirilecek (örn. `1.2.3` -> `1_2_3`) ve çok parçalı uzantılar korunacaktır (`deploy.tar.gz` -> `deploy-1_2_3.tar.gz`). Konsolda: `📦 Versiyon eklendi: 1_2_3` ve `📄 Güncel dosya adı: ...`
103
118
 
104
119
  **❗ Güvenlik Notları:**
105
- - `.env` dosyası zaten .gitignore'da bulunuyor
106
- - Web sunucunuzda `.env` dosyalarına erişimi engelleyin (.htaccess)
107
- - Dosya izinlerini kısıtlayın: `chmod 600 .env`
120
+ - `.env.orakconfig` dosyası zaten .gitignore'da bulunuyor
121
+ - Web sunucunuzda `.env.orakconfig` dosyalarına erişimi engelleyin (.htaccess)
122
+ - Dosya izinlerini kısıtlayın: `chmod 600 .env.orakconfig`
123
+
124
+ 📝 `osf_ftp_host, osf_ftp_local_file` ve `osf_ftp_remote_path` değerleri `orak-config.json` içinde de tanımlanabilir. `.env.orakconfig`'de yoksa `orak-config.json`'a bakar. Profil kullanılıyorsa `osf_ftp_local_file_<profile>` anahtarı da desteklenir.
125
+
126
+ ### orak-zip-content
108
127
 
109
- ### orak-deploy-zip
110
128
  Belirtilen dosya ve klasörleri tar.gz formatında arşivler.
111
129
 
112
130
  ```bash
113
- orak-deploy-zip
131
+ orak-zip-content [--profile <name>] [--v]
114
132
  ```
115
133
 
116
134
  **Gerekli orak-config.json ayarları:**
135
+
117
136
  ```json
118
137
  {
119
- "fiDeployZipFile": "orak-deploy-zip",
120
- "fiDeployZipContent": [
121
- "src/",
122
- "public/",
123
- "package.json"
124
- ]
138
+ "zip_content": ["bin", "lib"],
139
+ "zip_content_out_file": ".orak-dist/deploy"
125
140
  }
126
141
  ```
127
142
 
128
- - `fiDeployZipFile`: Oluşturulacak arşiv dosyasının adı (.tar.gz uzantısı otomatik eklenir)
129
- - `fiDeployZipContent`: Arşive dahil edilecek dosya ve klasörler
143
+ - `zip_content`: Arşive dahil edilecek dosya ve klasörler
144
+ - `zip_content_out_file`: Oluşturulacak arşiv dosyasının tam yolu (**uzantısız**; `.tar.gz` kod tarafından eklenir)
145
+
146
+ Ek opsiyonlar:
147
+
148
+ - `--profile <name>`: Profil adı verildiğinde `zip_content_out_file_<name>` anahtarı tercih edilir (örn: `zip_content_out_file_test`). Konsolda: `test profil uygulandı.`
149
+
150
+ - `--v`: Paket sürümünü (`package.json` içindeki `version`) dosya adına ekler; noktalar `_` ile değişir ve dosya uzantısı korunur (örn. `.orak-dist/deploy` -> `.orak-dist/deploy-1_2_3.tar.gz`). Konsolda: `📦 Versiyon eklendi: 1_2_3`
151
+
152
+ ### orak-zip-package
153
+
154
+ Belirtilen dosya ve klasörleri tar.gz formatında paket arşivi olarak oluşturur.
155
+
156
+ ```bash
157
+ orak-zip-package [--profile <name>] [--v]
158
+ ```
159
+
160
+ **Gerekli orak-config.json ayarları:**
161
+
162
+ ```json
163
+ {
164
+ "zip_package": ["lib/", "bin/"],
165
+ "zip_package_out_file": ".orak-dist/deploy1"
166
+ }
167
+ ```
168
+
169
+ - `zip_package`: Paket arşivine dahil edilecek dosya ve klasörler
170
+ - `zip_package_out_file`: Oluşturulacak paket arşiv dosyasının tam yolu (**uzantısız**; `.tar.gz` kod tarafından eklenir)
171
+
172
+ Ek opsiyonlar:
173
+
174
+ - `--profile <name>`: Profil adı verildiğinde `zip_package_out_file_<name>` anahtarı tercih edilir (örn: `zip_package_out_file_test`).
175
+
176
+ - `--v`: Paket sürümünü (`package.json` içindeki `version`) dosya adına ekler; noktalar `_` ile değişir ve dosya uzantısı korunur (örn. `.orak-dist/deploy1` -> `.orak-dist/deploy1-1_2_3.tar.gz`).
130
177
 
131
178
  ### orak-env-change
132
179
  Ortam dosyalarını (.env) değiştirir.
@@ -154,14 +201,18 @@ Bu durumda parametre vermeden `orak-env-change` komutunu çalıştırabilirsiniz
154
201
  orak-copy-deps
155
202
  ```
156
203
 
157
- ### 2. Deployment İşlemi
204
+ ### 2. Arşiv Oluşturma ve FTP Yükleme
158
205
  ```bash
159
- # .env dosyası oluşturun ve FTP bilgilerinizi ekleyin
160
- # Önce arşiv oluştur
161
- orak-deploy-zip
206
+ # .env.orakconfig dosyası oluşturun ve FTP bilgilerinizi ekleyin
162
207
 
163
- # Sonra FTP'ye yükle
208
+ # İçerik arşivi oluştur
209
+ orak-zip-content
210
+
211
+ # FTP'ye yükle
164
212
  orak-deploy-ftp
213
+
214
+ # Alternatif olarak paket arşivi oluştur
215
+ orak-zip-package
165
216
  ```
166
217
 
167
218
  ### 3. Ortam Değiştirme
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { deployZipContent } from '../lib/zip-content.js';
4
+
5
+ deployZipContent();
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { zipPackage } from '../lib/zip-package.js';
4
+
5
+ zipPackage();
@@ -3,7 +3,7 @@ osf_ftp_host=ftp.example.com
3
3
  osf_ftp_user=username
4
4
  osf_ftp_password=password
5
5
  osf_ftp_secure=false
6
- osf_local_file=deployphp25.tar.gz
6
+ osf_ftp_local_file=deployphp25.tar.gz
7
7
  osf_remote_file=/public_html/deploy.tar.gz
8
8
 
9
9
  # Bu dosyayı gerçek bilgilerinizle güncelleyin
@@ -0,0 +1,22 @@
1
+ import minimist from 'minimist';
2
+
3
+ /**
4
+ * Komut satırı argümanlarını parse eder
5
+ * @param {string[]} argv - process.argv.slice(2) ile geçilir
6
+ * @param {object} options - minimist options (opsiyonel)
7
+ * @returns {object} Parsed argümanlar
8
+ */
9
+ export function parseArgs(argv = process.argv.slice(2), options = {}) {
10
+ return minimist(argv, options);
11
+ }
12
+
13
+ /**
14
+ * Belirli bir argümanı alma (--key:value veya --key value formatları)
15
+ * @param {string} name - Argüman adı
16
+ * @param {string} defaultValue - Varsayılan değer
17
+ * @returns {string} Argüman değeri
18
+ */
19
+ export function getArg(name, defaultValue = null) {
20
+ const args = parseArgs();
21
+ return args[name] || defaultValue;
22
+ }
package/lib/copy-deps.js CHANGED
@@ -1,13 +1,16 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { fileURLToPath } from 'url';
4
+ import { parseArgs } from './args-parser.js';
4
5
 
5
6
  const __filename = fileURLToPath(import.meta.url);
6
7
  const __dirname = path.dirname(__filename);
7
8
 
8
9
  export function copyDeps() {
10
+ const args = parseArgs();
11
+
9
12
  // Argüman kontrolü ve yardım mesajı
10
- if (process.argv.includes('--help') || process.argv.includes('-h')) {
13
+ if (args.help || args.h) {
11
14
  // package.json'dan versiyon al
12
15
  const packageJsonPath = path.join(__dirname, '..', 'package.json');
13
16
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
@@ -25,7 +25,7 @@ export async function deployFtp() {
25
25
  ftpUser = ftpUser || oraksoftJson.osf_ftp_user;
26
26
  ftpPassword = ftpPassword || oraksoftJson.osf_ftp_password;
27
27
  ftpSecure = ftpSecure || oraksoftJson.osf_ftp_secure || false;
28
- localFilePath = localFilePath || oraksoftJson.osf_local_file;
28
+ localFilePath = localFilePath || oraksoftJson.osf_ftp_local_file;
29
29
  remoteFilePath = remoteFilePath || oraksoftJson.osf_remote_file;
30
30
  }
31
31
  } else {
package/lib/deploy-ftp.js CHANGED
@@ -2,109 +2,166 @@ import { Client } from "basic-ftp";
2
2
  import path from "path";
3
3
  import fs from 'fs';
4
4
  import { fileURLToPath } from 'url';
5
+ import { parseArgs } from './args-parser.js';
5
6
 
6
7
  const __filename = fileURLToPath(import.meta.url);
7
8
  const __dirname = path.dirname(__filename);
8
9
 
9
10
  export async function deployFtp() {
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
- }
11
+ const args = parseArgs();
22
12
 
23
- const projectRoot = process.cwd();
24
-
25
- // orak-config.json dosyasını oku
26
- const configPath = path.join(projectRoot, 'orak-config.json');
27
- let deployZipFile = 'deploy';
28
-
29
- if (fs.existsSync(configPath)) {
30
- const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
31
- if (config.fiDeployZipFile) {
32
- deployZipFile = config.fiDeployZipFile;
33
- }
34
- }
13
+ // Argüman kontrolü ve yardım mesajı
14
+ if (args.help || args.h) {
15
+ // package.json'dan versiyon al
16
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
17
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
18
+
19
+ console.log(`orak-deploy-ftp version ${packageJson.version}`);
20
+ console.log('Kullanım: orak-deploy-ftp');
21
+ console.log('Dist klasöründeki dosyaları FTP sunucusuna yükler.');
22
+ console.log('Konfigürasyon: .env dosyasında FTP bilgileri gerekli.');
23
+ process.exit(0);
24
+ }
25
+
26
+ console.log("🚀 FTP Deploy Başlatılıyor...");
35
27
 
36
- // .env dosyasını oku
37
- const envPath = path.join(projectRoot, '.env');
38
-
39
- if (!fs.existsSync(envPath)) {
40
- console.error(`
41
- ❌ .env dosyası bulunamadı!
28
+ const projectRoot = process.cwd();
42
29
 
43
- .env dosyası oluşturun ve şu bilgileri ekleyin:
30
+ // .env.orakconfig dosyasını oku
31
+ const envPath = path.join(projectRoot, '.env.orakconfig');
32
+
33
+ if (!fs.existsSync(envPath)) {
34
+ console.error(`
35
+ ❌ .env.orakconfig dosyası bulunamadı!
36
+
37
+ .env.orakconfig dosyası oluşturun ve şu bilgileri ekleyin:
44
38
  osf_ftp_host=ftp.example.com
45
39
  osf_ftp_user=username
46
40
  osf_ftp_password=password
47
41
  osf_ftp_secure=false
48
- osf_local_file=${deployZipFile}.tar.gz
49
- osf_remote_file=/path/to/remote/file.tar.gz
50
- `);
51
- process.exit(1);
52
- }
42
+ osf_ftp_local_file=deploy.tar.gz
43
+ osf_ftp_remote_path=public_html
44
+ `);
45
+ process.exit(1);
46
+ }
53
47
 
54
- // .env dosyasını parse et
55
- const envContent = fs.readFileSync(envPath, 'utf-8');
56
- const envVars = {};
57
-
58
- envContent.split('\n').forEach(line => {
59
- const trimmedLine = line.trim();
60
- if (trimmedLine && !trimmedLine.startsWith('#')) {
61
- const [key, ...valueParts] = trimmedLine.split('=');
62
- if (key && valueParts.length > 0) {
63
- envVars[key.trim()] = valueParts.join('=').trim();
64
- }
65
- }
66
- });
48
+ // .env.xx dosyasını parse et
49
+ const envContent = fs.readFileSync(envPath, 'utf-8');
50
+ const envVars = {};
51
+
52
+ envContent.split('\n').forEach(line => {
53
+ const trimmedLine = line.trim();
54
+ if (trimmedLine && !trimmedLine.startsWith('#')) {
55
+ const [key, ...valueParts] = trimmedLine.split('=');
56
+ if (key && valueParts.length > 0) {
57
+ envVars[key.trim()] = valueParts.join('=').trim();
58
+ }
59
+ }
60
+ });
67
61
 
68
- const ftpHost = envVars.osf_ftp_host;
69
- const ftpUser = envVars.osf_ftp_user;
70
- const ftpPassword = envVars.osf_ftp_password;
71
- const ftpSecure = envVars.osf_ftp_secure === 'true';
72
- const localFileName = envVars.osf_local_file || `${deployZipFile}.tar.gz`;
73
- const remoteFilePath1 = envVars.osf_remote_file;
62
+ let ftpHost = envVars.osf_ftp_host;
63
+ const ftpUser = envVars.osf_ftp_user;
64
+ const ftpPassword = envVars.osf_ftp_password;
65
+ const ftpSecure = envVars.osf_ftp_secure === 'true';
74
66
 
75
- let localFilePath1 = path.join(projectRoot, "dist", localFileName);
67
+ // osf_ftp_local_file support with profile suffix (osf_ftp_local_file_{profile})
68
+ let localFileKey = 'osf_ftp_local_file';
69
+ if (args.profile) {
70
+ console.log(`${args.profile} profil uygulandı.`);
71
+ localFileKey = localFileKey + '_' + args.profile;
72
+ }
73
+ let localFileName = envVars[localFileKey] ?? envVars.osf_ftp_local_file;
74
+ let remotePath = envVars.osf_ftp_remote_path; // || '/';
76
75
 
77
- if (!ftpHost || !ftpUser || !ftpPassword) {
78
- console.error("Error: FTP bilgileri eksik. .env.oraksoft dosyasında osf_ftp_host, osf_ftp_user ve osf_ftp_password alanlarını kontrol edin.");
79
- process.exit(1);
76
+ if (!ftpHost || !localFileName || !remotePath) {
77
+ const pathOrakConfigJson = path.join(projectRoot, 'orak-config.json');
78
+ if (fs.existsSync(pathOrakConfigJson)) {
79
+ //orak-config.json dosyasını oku
80
+ const jsonOrakConfig = JSON.parse(fs.readFileSync(pathOrakConfigJson, 'utf-8'));
81
+ ftpHost = ftpHost ?? jsonOrakConfig.osf_ftp_host;
82
+ localFileName = localFileName ?? (jsonOrakConfig[localFileKey] ?? jsonOrakConfig.osf_ftp_local_file);
83
+ remotePath = remotePath ?? jsonOrakConfig.osf_ftp_remote_path;
84
+ //remotePath = remotePath ?? '/';
80
85
  }
86
+ }
87
+
88
+ // Eğer --v verilmişse filename uzantısının öncesine versiyon ekle (örn: test-1_2_3.txt veya deploy-1_2_3.tar.gz)
89
+ if (args.v && localFileName) {
90
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
91
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
92
+ const txVersion = packageJson.version.replace(/\./g, '_');
93
+
94
+ const parsed = path.parse(localFileName);
95
+ const base = parsed.base; // filename with possible multi-part ext
96
+
97
+ // Desteklenen çok parçalı uzantılar
98
+ const multiExts = ['.tar.gz', '.tar.bz2', '.tar.xz', '.tar.lz', '.tar.Z', '.tgz'];
99
+ let ext = parsed.ext;
100
+ let nameNoExt = parsed.name;
81
101
 
82
- const client = new Client();
83
- client.ftp.verbose = true;
84
-
85
- try {
86
- await client.access({
87
- host: ftpHost,
88
- user: ftpUser,
89
- password: ftpPassword,
90
- secure: ftpSecure
91
- });
92
-
93
- const localFilePath = localFilePath1;
94
- const remoteFilePath = remoteFilePath1;
95
-
96
- if (!fs.existsSync(localFilePath)) {
97
- console.error(`Error: Yerel dosya bulunamadı: ${localFilePath}`);
98
- process.exit(1);
99
- }
100
-
101
- console.log(`Yükleniyor: ${localFilePath} -> ${remoteFilePath}`);
102
- await client.uploadFrom(localFilePath, remoteFilePath);
103
- console.log("✅ FTP yükleme tamamlandı!");
102
+ for (const me of multiExts) {
103
+ if (base.endsWith(me)) {
104
+ ext = me;
105
+ nameNoExt = base.slice(0, -me.length);
106
+ break;
107
+ }
104
108
  }
105
- catch(err) {
106
- console.error("❌ FTP Hatası:", err);
107
- process.exit(1);
109
+
110
+ const sep = nameNoExt.endsWith('-') || nameNoExt.endsWith('_') ? '' : '-';
111
+ const newBase = nameNoExt + sep + txVersion;
112
+ localFileName = parsed.dir ? path.join(parsed.dir, newBase + ext) : newBase + ext;
113
+
114
+ console.log(`📦 Versiyon eklendi: ${txVersion}`);
115
+ console.log(`📄 Güncel dosya adı: ${localFileName}`);
116
+ }
117
+
118
+ let localFilePath1 = path.join(projectRoot, localFileName); //"dist"
119
+ let remoteFilePath1 = path.posix.join(remotePath, path.basename(localFileName));
120
+
121
+ console.log(`Yerel dosya: ${localFilePath1}`);
122
+ console.log(`Remote adres: ${remoteFilePath1}`);
123
+
124
+ if (!ftpHost || !ftpUser || !ftpPassword) {
125
+ console.error("Error: FTP bilgileri eksik. .env.orakconfig dosyasında osf_ftp_host, osf_ftp_user ve osf_ftp_password alanlarını kontrol edin.");
126
+ process.exit(1);
127
+ }
128
+
129
+ if (!remoteFilePath1) {
130
+ console.error("Error: FTP bilgileri eksik. .env.orakconfig dosyasında osf_ftp_remote_path alanını kontrol edin.");
131
+ process.exit(1);
132
+ }
133
+
134
+ if (!localFilePath1) {
135
+ console.error("Error: FTP bilgileri eksik. .env.orakconfig dosyasında osf_ftp_local_file alanını kontrol edin.");
136
+ process.exit(1);
137
+ }
138
+
139
+ const client = new Client();
140
+ client.ftp.verbose = true;
141
+
142
+ try {
143
+ await client.access({
144
+ host: ftpHost,
145
+ user: ftpUser,
146
+ password: ftpPassword,
147
+ secure: ftpSecure
148
+ });
149
+
150
+ const localFilePath = localFilePath1;
151
+ const remoteFilePath = remoteFilePath1;
152
+
153
+ if (!fs.existsSync(localFilePath)) {
154
+ console.error(`Error: Yerel dosya bulunamadı: ${localFilePath}`);
155
+ process.exit(1);
108
156
  }
109
- client.close();
157
+
158
+ console.log(`Yükleniyor: ${localFilePath} -> ${remoteFilePath}`);
159
+ await client.uploadFrom(localFilePath, remoteFilePath);
160
+ console.log("✅ FTP yükleme tamamlandı!");
161
+ }
162
+ catch (err) {
163
+ console.error("❌ FTP Hatası:", err);
164
+ process.exit(1);
165
+ }
166
+ client.close();
110
167
  }
package/lib/env-change.js CHANGED
@@ -1,68 +1,71 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { fileURLToPath } from 'url';
4
+ import { parseArgs } from './args-parser.js';
4
5
 
5
6
  const __filename = fileURLToPath(import.meta.url);
6
7
  const __dirname = path.dirname(__filename);
7
8
 
8
9
  export function envChange() {
10
+ const args = parseArgs();
9
11
 
10
- // Komut satırından argüman alma
11
- // process.argv[0] = node executable
12
- // process.argv[1] = script dosyası
13
- // process.argv[2] = ilk argüman
14
- const envArgument = process.argv[2];
12
+ // Komut satırından argüman alma (named ve positional)
13
+ // Named: --env dev veya --environment prod
14
+ // Positional: orak-env-change dev (args._[0])
15
+ const envArgument = args.env || args.environment || args._?.[0];
16
+ //console.log(args);
15
17
 
16
- // Argüman kontrolü ve yardım mesajı
17
- if (process.argv.includes('--help') || process.argv.includes('-h')) {
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.');
26
- process.exit(0);
27
- }
18
+ // Argüman kontrolü ve yardım mesajı
19
+ if (args.help || args.h) {
20
+ // oraksoft-node-tools package.json'dan versiyon al
21
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
22
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
28
23
 
29
- // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
30
- const projectRoot = process.cwd();
24
+ console.log(`orak-env-change version ${packageJson.version}`);
25
+ console.log('Kullanım: orak-env-change [ortam_adı]');
26
+ console.log('Örnek: orak-env-change dev');
27
+ //console.log('Argüman verilmezse orak-config.json\'daki fiEnvChangeStatus değeri kullanılır.');
28
+ process.exit(0);
29
+ }
31
30
 
32
- // orak-config.json dosyasını oku
33
- const configPath = path.join(projectRoot, 'orak-config.json');
34
-
35
- let config = {};
36
- if (fs.existsSync(configPath)) {
37
- config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
38
- }
31
+ // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
32
+ const projectRoot = process.cwd();
33
+
34
+ // orak-config.json dosyasını okuma
35
+ const configPath = path.join(projectRoot, 'orak-config.json');
36
+
37
+ let jsoOrakConfig = {};
38
+ // exists - Path olup olmadığına bakar
39
+ if (fs.existsSync(configPath)) {
40
+ jsoOrakConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
41
+ }
39
42
 
40
- let txEnv = envArgument || config.fiEnvChangeStatus;
43
+ let txEnv = envArgument; // || jsoOrakConfig.fiEnvChangeStatus;
41
44
 
42
- if (!txEnv) {
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.');
46
- process.exit(1);
47
- }
45
+ if (!txEnv) {
46
+ console.error('❌ Ortam adı belirtilmedi '); //ve orak-config.json\'da fiEnvChangeStatus bulunamadı.
47
+ console.log('Kullanım: orak-env-change [ortam_adı]');
48
+ console.log('Alternatif: orak-config.json dosyasında "fiEnvChangeStatus" değeri tanımlayın.');
49
+ process.exit(1);
50
+ }
48
51
 
49
- try {
50
- // .env dosyasının içeriğini .env.{txEnv} içeriğine eşitle
51
- const envPath = path.join(projectRoot, '.env.' + txEnv);
52
-
53
- if (!fs.existsSync(envPath)) {
54
- console.error(`❌ Ortam dosyası bulunamadı: ${envPath}`);
55
- process.exit(1);
56
- }
57
-
58
- const envContent = fs.readFileSync(envPath, 'utf-8');
59
- fs.writeFileSync(path.join(projectRoot, '.env'), envContent);
60
-
61
- // Başarı mesajı
62
- console.log(`✅ Ortam dosyası başarıyla değiştirildi: .env.${txEnv} -> .env`);
63
- console.log(`📁 Dosya yolu: ${path.join(projectRoot, '.env')}`);
64
- } catch (error) {
65
- console.error('❌ Ortam dosyası değiştirme hatası:', error.message);
66
- process.exit(1);
52
+ try {
53
+ // .env dosyasının içeriğini .env.{txEnv} içeriğine eşitle
54
+ const envPath = path.join(projectRoot, '.env.' + txEnv);
55
+
56
+ if (!fs.existsSync(envPath)) {
57
+ console.error(`❌ Ortam dosyası bulunamadı: ${envPath}`);
58
+ process.exit(1);
67
59
  }
60
+
61
+ const envContent = fs.readFileSync(envPath, 'utf-8');
62
+ fs.writeFileSync(path.join(projectRoot, '.env'), envContent);
63
+
64
+ // Başarı mesajı
65
+ console.log(`✅ Ortam dosyası başarıyla değiştirildi: .env.${txEnv} -> .env`);
66
+ console.log(`📁 Dosya yolu: ${path.join(projectRoot, '.env')}`);
67
+ } catch (error) {
68
+ console.error('❌ Ortam dosyası değiştirme hatası:', error.message);
69
+ process.exit(1);
70
+ }
68
71
  }
@@ -1,68 +1,70 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { fileURLToPath } from 'url';
4
+ import { parseArgs } from './args-parser.js';
4
5
 
5
6
  const __filename = fileURLToPath(import.meta.url);
6
7
  const __dirname = path.dirname(__filename);
7
8
 
8
9
  export function envDevChange() {
10
+ const args = parseArgs();
9
11
 
10
- // Komut satırından argüman alma
11
- // process.argv[0] = node executable
12
- // process.argv[1] = script dosyası
13
- // process.argv[2] = ilk argüman
14
- const envArgument = process.argv[2];
12
+ // Komut satırından argüman alma (named ve positional)
13
+ // Named: --env dev veya --environment prod
14
+ // Positional: orak-env-dev-change dev (args._[0])
15
+ const envArgument = args.env || args.environment || args._?.[0];
16
+ //console.log(args);
15
17
 
16
- // Argüman kontrolü ve yardım mesajı
17
- if (process.argv.includes('--help') || process.argv.includes('-h')) {
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-dev-change version ${packageJson.version}`);
23
- console.log('Kullanım: orak-env-dev-change [ortam_adı]');
24
- console.log('Örnek: orak-env-dev-change dev');
25
- console.log('Argüman verilmezse orak-config.json\'daki fiEnvChangeStatus değeri kullanılır.');
26
- process.exit(0);
27
- }
18
+ // Argüman kontrolü ve yardım mesajı
19
+ if (args.help || args.h) {
20
+ // oraksoft-node-tools package.json'dan versiyon al
21
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
22
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
28
23
 
29
- // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
30
- const projectRoot = process.cwd();
24
+ console.log(`orak-env-dev-change version ${packageJson.version}`);
25
+ console.log('Kullanım: orak-env-dev-change [ortam_adı]');
26
+ console.log('Örnek: orak-env-dev-change dev');
27
+ process.exit(0);
28
+ }
31
29
 
32
- // orak-config.json dosyasını oku
33
- const configPath = path.join(projectRoot, 'orak-config.json');
34
-
35
- let config = {};
36
- if (fs.existsSync(configPath)) {
37
- config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
38
- }
30
+ // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
31
+ const projectRoot = process.cwd();
32
+
33
+ // orak-config.json dosyasını okuma
34
+ // const configPath = path.join(projectRoot, 'orak-config.json');
35
+
36
+ // let objOrakConfigJson = {};
37
+ // // exists - Path olup olmadığına bakar
38
+ // if (fs.existsSync(configPath)) {
39
+ // objOrakConfigJson = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
40
+ // }
39
41
 
40
- let txEnv = envArgument || config.fiEnvChangeStatus;
42
+ let txEnv = envArgument; // || objOrakConfigJson.fiEnvDevChangeStatus;
41
43
 
42
- if (!txEnv) {
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.');
46
- process.exit(1);
47
- }
44
+ if (!txEnv) {
45
+ console.error('❌ Ortam adı belirtilmedi ');
46
+ console.log('Kullanım: orak-env-dev-change [ortam_adı]');
47
+ //console.log('Alternatif: orak-config.json dosyasında "fiEnvDevChangeStatus" değeri tanımlayın.');
48
+ process.exit(1);
49
+ }
48
50
 
49
- try {
50
- // .env dosyasının içeriğini .env.{txEnv} içeriğine eşitle
51
- const envPath = path.join(projectRoot, '.env.' + txEnv);
52
-
53
- if (!fs.existsSync(envPath)) {
54
- console.error(`❌ Ortam dosyası bulunamadı: ${envPath}`);
55
- process.exit(1);
56
- }
57
-
58
- const envContent = fs.readFileSync(envPath, 'utf-8');
59
- fs.writeFileSync(path.join(projectRoot, '.env.development'), envContent);
60
-
61
- // Başarı mesajı
62
- console.log(`✅ Ortam dosyası başarıyla değiştirildi: .env.${txEnv} -> .env.development`);
63
- console.log(`📁 Dosya yolu: ${path.join(projectRoot, '.env.development')}`);
64
- } catch (error) {
65
- console.error('❌ Ortam dosyası değiştirme hatası:', error.message);
66
- process.exit(1);
51
+ try {
52
+ // .env dosyasının içeriğini .env.{txEnv} içeriğine eşitle
53
+ const envPath = path.join(projectRoot, '.env.' + txEnv);
54
+
55
+ if (!fs.existsSync(envPath)) {
56
+ console.error(`❌ Ortam dosyası bulunamadı: ${envPath}`);
57
+ process.exit(1);
67
58
  }
59
+
60
+ const envContent = fs.readFileSync(envPath, 'utf-8');
61
+ fs.writeFileSync(path.join(projectRoot, '.env.development'), envContent);
62
+
63
+ // Başarı mesajı
64
+ console.log(`✅ Ortam dosyası başarıyla değiştirildi: .env.${txEnv} -> .env.development`);
65
+ console.log(`📁 Dosya yolu: ${path.join(projectRoot, '.env.development')}`);
66
+ } catch (error) {
67
+ console.error('❌ Ortam dosyası değiştirme hatası:', error.message);
68
+ process.exit(1);
69
+ }
68
70
  }
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { copyDeps } from './copy-deps.js';
2
2
  export { deployFtp } from './deploy-ftp.js';
3
- export { deployZip } from './deploy-zip.js';
3
+ export { zipPackage } from './zip-package.js';
4
+ export { zipContent } from './zip-content.js';
4
5
  export { envChange } from './env-change.js';
5
- export { envDevChange } from './env-dev-change.js';
@@ -0,0 +1,188 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import * as tar from 'tar';
4
+ import { fileURLToPath } from 'url';
5
+ import { parseArgs } from './args-parser.js';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ export async function deployZipContent() {
11
+ const args = parseArgs();
12
+
13
+ // package.json'dan versiyon al
14
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
15
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
16
+
17
+ // Argüman kontrolü ve yardım mesajı
18
+ if (args.help || args.h) {
19
+ console.log(`orak-zip-content version ${packageJson.version}`);
20
+ console.log('Kullanım: orak-zip-content');
21
+ console.log('Belirtilen dosya ve klasörleri tar.gz formatında arşivler.');
22
+ console.log('Konfigürasyon: orak-config.json dosyasında "zip-content" (array) ayarı gerekli.');
23
+ process.exit(0);
24
+ }
25
+
26
+ // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
27
+ const projectRoot = process.cwd();
28
+
29
+ // .env dosyasını oku
30
+ // const envPath = path.join(projectRoot, '.env');
31
+
32
+ // if (fs.existsSync(envPath)) {
33
+ // const envContent = fs.readFileSync(envPath, 'utf-8');
34
+ // const envVars = {};
35
+
36
+ // envContent.split('\n').forEach(line => {
37
+ // const trimmedLine = line.trim();
38
+ // if (trimmedLine && !trimmedLine.startsWith('#')) {
39
+ // const [key, ...valueParts] = trimmedLine.split('=');
40
+ // if (key && valueParts.length > 0) {
41
+ // envVars[key.trim()] = valueParts.join('=').trim();
42
+ // }
43
+ // }
44
+ // });
45
+
46
+ // }
47
+
48
+ // orak-config.json dosyasını oku
49
+ const configPath = path.join(projectRoot, 'orak-config.json');
50
+
51
+ if (!fs.existsSync(configPath)) {
52
+ console.error("Error: orak-config.json dosyası bulunamadı. Bu komutu proje kök dizininde çalıştırın.");
53
+ process.exit(1);
54
+ }
55
+
56
+ const jsnOrakConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
57
+
58
+ if (!jsnOrakConfig["zip_content"] || !Array.isArray(jsnOrakConfig["zip_content"])) {
59
+ console.error("Error: 'zip_content' alanı orak-config.json içinde bir dizi olarak tanımlanmalıdır.");
60
+ process.exit(1);
61
+ }
62
+
63
+ let out_file_key = 'zip_content_out_file';
64
+
65
+ if(args.profile) {
66
+ console.log(`${args.profile} profil uygulandı.`);
67
+ out_file_key = out_file_key + "_" + args.profile;
68
+ }
69
+
70
+ let archiveName = jsnOrakConfig[out_file_key];
71
+
72
+ if (!archiveName) {
73
+ console.error("Error: " + `${out_file_key} alanı orak-config.json içinde tanımlanmalıdır.`);
74
+ process.exit(1);
75
+ }
76
+
77
+ let txVersionForFileName = packageJson.version.replace(/\./g, '_');
78
+
79
+ if (args.v) {
80
+ // Ayırıcı ekle (ör. deploy-1_2_3.tar.gz) okunaklı olsun
81
+ const sep = archiveName.endsWith('-') || archiveName.endsWith('_') ? '' : '-';
82
+ archiveName = archiveName + sep + txVersionForFileName;
83
+ console.log(`📦 Versiyon eklendi: ${txVersionForFileName}`);
84
+ }
85
+
86
+ // Dosya adına .tar.gz uzantısını ekle
87
+ archiveName = archiveName + '.tar.gz';
88
+
89
+ const filesToArchive = jsnOrakConfig["zip_content"];
90
+
91
+ if (!filesToArchive) {
92
+ console.error("Error: 'zip_content' alanı orak-config.json içinde tanımlanmalıdır.");
93
+ process.exit(1);
94
+ }
95
+
96
+ // Her klasör için dosyaları topla
97
+ const allFilesToArchive = [];
98
+
99
+ for (const item of filesToArchive) {
100
+ const fullPath = path.join(projectRoot, item);
101
+
102
+ if (!fs.existsSync(fullPath)) {
103
+ console.warn(`⚠️ Bulunamadı: ${item}`);
104
+ continue;
105
+ }
106
+
107
+ const stat = fs.statSync(fullPath);
108
+
109
+ if (stat.isDirectory()) {
110
+ // Klasörün içindeki dosyaları ekle
111
+ const walkDir = (dir) => {
112
+ const files = fs.readdirSync(dir);
113
+ for (const file of files) {
114
+ const filePath = path.join(dir, file);
115
+ const fileStat = fs.statSync(filePath);
116
+
117
+ if (fileStat.isDirectory()) {
118
+ walkDir(filePath);
119
+ } else {
120
+ // Klasör root'undan relative path
121
+ const relPath = path.relative(fullPath, filePath).replace(/\\/g, '/');
122
+ allFilesToArchive.push({
123
+ src: filePath,
124
+ dest: relPath
125
+ });
126
+ }
127
+ }
128
+ };
129
+ walkDir(fullPath);
130
+ } else {
131
+ // Tek dosya
132
+ allFilesToArchive.push({
133
+ src: fullPath,
134
+ dest: path.basename(item)
135
+ });
136
+ }
137
+ }
138
+
139
+ // dist klasörü ve arşiv adı
140
+ const distDir = projectRoot; // path.resolve(projectRoot, '.orak-dist');
141
+ const archivePath = path.join(distDir, archiveName);
142
+
143
+ // dist klasörü yoksa oluştur
144
+ if (!fs.existsSync(distDir)) {
145
+ fs.mkdirSync(distDir, { recursive: true });
146
+ }
147
+
148
+ // Arşiv oluştur
149
+ try {
150
+ // Geçici klasör oluştur
151
+ const tempDir = path.join(distDir, '.temp');
152
+ if (fs.existsSync(tempDir)) {
153
+ fs.rmSync(tempDir, { recursive: true, force: true });
154
+ }
155
+ fs.mkdirSync(tempDir, { recursive: true });
156
+
157
+ // Dosyaları geçici klasöre kopyala
158
+ for (const file of allFilesToArchive) {
159
+ const destPath = path.join(tempDir, file.dest);
160
+ const destDir = path.dirname(destPath);
161
+
162
+ if (!fs.existsSync(destDir)) {
163
+ fs.mkdirSync(destDir, { recursive: true });
164
+ }
165
+
166
+ fs.copyFileSync(file.src, destPath);
167
+ }
168
+
169
+ // Geçici klasörden arşiv oluştur
170
+ await tar.c(
171
+ {
172
+ gzip: true,
173
+ file: archivePath,
174
+ cwd: tempDir,
175
+ follow: true,
176
+ },
177
+ fs.readdirSync(tempDir)
178
+ );
179
+
180
+ // Geçici klasörü sil
181
+ fs.rmSync(tempDir, { recursive: true, force: true });
182
+
183
+ console.log(`✅ Arşiv oluşturuldu: ${archivePath}`);
184
+ } catch (err) {
185
+ console.error('❌ Arşivleme hatası:', err);
186
+ process.exit(1);
187
+ }
188
+ }
@@ -2,27 +2,50 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
  import * as tar from 'tar';
4
4
  import { fileURLToPath } from 'url';
5
+ import { parseArgs } from './args-parser.js';
5
6
 
6
7
  const __filename = fileURLToPath(import.meta.url);
7
8
  const __dirname = path.dirname(__filename);
8
9
 
9
- export async function deployZip() {
10
+ export async function zipPackage() {
11
+ const args = parseArgs();
12
+
10
13
  // Argüman kontrolü ve yardım mesajı
11
- if (process.argv.includes('--help') || process.argv.includes('-h')) {
14
+ if (args.help || args.h) {
12
15
  // package.json'dan versiyon al
13
16
  const packageJsonPath = path.join(__dirname, '..', 'package.json');
14
17
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
15
-
16
- console.log(`orak-deploy-zip version ${packageJson.version}`);
17
- console.log('Kullanım: orak-deploy-zip');
18
+
19
+ console.log(`orak-zip-package version ${packageJson.version}`);
20
+ console.log('Kullanım: orak-zip-package');
18
21
  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.');
22
+ console.log('Konfigürasyon: orak-config.json dosyasında "zip_package" ayarı gerekli.');
20
23
  process.exit(0);
21
24
  }
22
25
 
23
26
  // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
24
27
  const projectRoot = process.cwd();
25
28
 
29
+ // .env dosyasını oku
30
+ const envPath = path.join(projectRoot, '.env');
31
+
32
+ const envVars = {};
33
+
34
+ if (fs.existsSync(envPath)) {
35
+ const envContent = fs.readFileSync(envPath, 'utf-8');
36
+
37
+ envContent.split('\n').forEach(line => {
38
+ const trimmedLine = line.trim();
39
+ if (trimmedLine && !trimmedLine.startsWith('#')) {
40
+ const [key, ...valueParts] = trimmedLine.split('=');
41
+ if (key && valueParts.length > 0) {
42
+ envVars[key.trim()] = valueParts.join('=').trim();
43
+ }
44
+ }
45
+ });
46
+
47
+ }
48
+
26
49
  // orak-config.json dosyasını oku
27
50
  const configPath = path.join(projectRoot, 'orak-config.json');
28
51
 
@@ -31,18 +54,45 @@ export async function deployZip() {
31
54
  process.exit(1);
32
55
  }
33
56
 
34
- const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
57
+ const jsnOrakConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
35
58
 
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.");
59
+ if (!jsnOrakConfig.zip_package || !Array.isArray(jsnOrakConfig.zip_package)) {
60
+ console.error("Error: 'zip_package' alanı orak-config.json içinde bir dizi olarak tanımlanmalıdır.");
38
61
  process.exit(1);
39
62
  }
40
63
 
41
- const filesToArchive = config.fiDeployZipContent;
64
+ const filesToArchive = jsnOrakConfig.zip_package;
65
+
66
+ let out_file_key = 'zip_package_out_file';
67
+
68
+ if(args.profile) {
69
+ out_file_key = `zip_package_out_file_${args.profile}`;
70
+ }
71
+
72
+ if (!jsnOrakConfig[out_file_key]) {
73
+ console.error("Error: " + `${out_file_key} alanı orak-config.json içinde tanımlanmalıdır.`);
74
+ process.exit(1);
75
+ }
76
+
77
+ let archiveName = jsnOrakConfig[out_file_key];
78
+
79
+ // package.json'dan versiyon al (opsiyonel --v ile eklenecek)
80
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
81
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
82
+ let txVersionForFileName = packageJson.version.replace(/\./g, '_');
83
+
84
+ if (args.v) {
85
+ // Ayırıcı ekle (örn. deploy-1_2_3.tar.gz) okunaklı olsun
86
+ const sep = archiveName.endsWith('-') || archiveName.endsWith('_') ? '' : '-';
87
+ archiveName = archiveName + sep + txVersionForFileName;
88
+ console.log(`📦 Versiyon eklendi: ${txVersionForFileName}`);
89
+ }
90
+
91
+ // Dosya adına .tar.gz uzantısını ekle
92
+ archiveName = archiveName + '.tar.gz';
42
93
 
43
94
  // dist klasörü ve arşiv adı
44
- const distDir = path.resolve(projectRoot, 'dist');
45
- const archiveName = config.fiDeployZipFile ? `${config.fiDeployZipFile}.tar.gz` : 'deploy.tar.gz';
95
+ const distDir = projectRoot; // path.resolve(projectRoot, 'dist');
46
96
  const archivePath = path.join(distDir, archiveName);
47
97
 
48
98
  // dist klasörü yoksa oluştur
package/package.json CHANGED
@@ -1,15 +1,23 @@
1
1
  {
2
2
  "name": "oraksoft-node-tools",
3
- "version": "0.1.5",
3
+ "version": "0.1.18",
4
4
  "description": "CLI araçları koleksiyonu - orak-copy-deps, orak-deploy-ftp, orak-deploy-zip, orak-env-change ve orak-env-dev-change komutları",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "orak-copy-deps": "./bin/orak-copy-deps.js",
9
9
  "orak-deploy-ftp": "./bin/orak-deploy-ftp.js",
10
- "orak-deploy-zip": "./bin/orak-deploy-zip.js",
11
10
  "orak-env-change": "./bin/orak-env-change.js",
12
- "orak-env-dev-change": "./bin/orak-env-dev-change.js"
11
+ "orak-env-dev-change": "./bin/orak-env-dev-change.js",
12
+ "orak-zip-content": "./bin/orak-zip-content.js",
13
+ "orak-zip-package": "./bin/orak-zip-package.js"
14
+ },
15
+ "scripts_comment": {
16
+ "test": "Test komutu henüz tanımlanmadı.",
17
+ "prepublishOnly": "Yayınlamadan önce çalıştırılacak komut.",
18
+ "build": "Proje derleme komutu.",
19
+ "pn-publish": "Paketin genel erişimle yayınlanması için komut.",
20
+ "pn-global-update": "Paketin global olarak güncellenmesi için komut."
13
21
  },
14
22
  "keywords": [
15
23
  "cli",
@@ -25,6 +33,7 @@
25
33
  "license": "MIT",
26
34
  "dependencies": {
27
35
  "basic-ftp": "^5.0.5",
36
+ "minimist": "^1.2.8",
28
37
  "tar": "^7.4.3"
29
38
  },
30
39
  "engines": {
@@ -42,6 +51,8 @@
42
51
  "scripts": {
43
52
  "test": "echo \"Error: no test specified\" && exit 1",
44
53
  "build": "echo \"Build completed\"",
45
- "pn-publish": "pnpm publish --access public"
54
+ "pn-publish": "pnpm publish --access public",
55
+ "pn-global-update": "pnpm link --global",
56
+ "orak-deploy-test": "orak-deploy-ftp"
46
57
  }
47
58
  }
package/.env DELETED
@@ -1,15 +0,0 @@
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 DELETED
@@ -1,6 +0,0 @@
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.prod DELETED
@@ -1,6 +0,0 @@
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
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { deployZip } from '../lib/deploy-zip.js';
4
-
5
- deployZip();
package/orak-config.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "copyDepsModulesToCopy": [
3
- {
4
- "name": "module-name",
5
- "file": "dist/module.js"
6
- }
7
- ],
8
- "copyDepsLibFolder": "lib",
9
- "copyDepsLibFolderEmpty": true,
10
- "fiDeployZipFile": "orak-deploy-zip",
11
- "fiDeployZipContent": [
12
- "src/",
13
- "public/",
14
- "package.json"
15
- ],
16
- "fiEnvChangeStatus": "dev"
17
- }
File without changes