oraksoft-node-tools 0.1.6 → 0.1.30

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.
@@ -0,0 +1,4 @@
1
+ {
2
+ "oa1TxVersion": "0.1.27",
3
+ "oa1TxUrl": "https://temp/test-0_1_27_j40vs285.txt"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "oa1TxVersion": "0.1.25",
3
+ "oa1RemoteFile": "temp/test-0_1_25_c2jsfdui.txt"
4
+ }
Binary file
File without changes
File without changes
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,55 +80,108 @@ 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
- ```env
96
+ ```bash
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_path=/public_html
101
+
100
102
  ```
101
103
 
102
- - `osf_local_file` belirtilmezse, `orak-config.json`'daki `fiDeployZipFile` değeri kullanılır
103
- - `osf_remote_path` uzak sunucudaki hedef klasör yolunu belirtir, dosya adı otomatik olarak `osf_local_file`'dan alınır
104
+ **Gerekli orak-config.json dosyası:**
105
+
106
+ ```bash
107
+ osf_ftp_local_file=deploy.tar.gz
108
+ osf_ftp_remote_path=public_html
109
+
110
+ ```
111
+
112
+
113
+ - `osf_ftp_host`: FTP sunucusunun adresi
114
+ - `osf_ftp_user`: FTP kullanıcı adı
115
+ - `osf_ftp_password`: FTP şifresi
116
+ - `osf_ftp_secure`: `true` FTPS kullanır, `false` FTP kullanır (varsayılan: `false`)
117
+ - `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`)
118
+ - `osf_ftp_remote_path`: Uzak sunucudaki hedef klasör yolu (varsayılan: `/`)
119
+ - Dosya adı otomatik olarak `osf_ftp_local_file`'ın son bölümünden alınır
120
+
121
+ Ek opsiyonlar:
122
+
123
+ - `--profile <profil_name>`: Belirtilen profil için önce `osf_ftp_local_file_<profil_name>` (veya `orak-config.json` içinde aynı anahtar) aranır. Örnek: `--profile test` -> `osf_ftp_local_file_test`. Konsolda: `test profil uygulandı.`
124
+
125
+ - `--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ı: ...`
104
126
 
105
127
  **❗ Güvenlik Notları:**
106
- - `.env` dosyası zaten .gitignore'da bulunuyor
107
- - Web sunucunuzda `.env` dosyalarına erişimi engelleyin (.htaccess)
108
- - Dosya izinlerini kısıtlayın: `chmod 600 .env`
128
+ - `.env.orakconfig` dosyası zaten .gitignore'da bulunuyor
129
+ - Web sunucunuzda `.env.orakconfig` dosyalarına erişimi engelleyin (.htaccess)
130
+ - Dosya izinlerini kısıtlayın: `chmod 600 .env.orakconfig`
131
+
132
+ 📝 `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.
133
+
134
+ ### orak-zip-content
109
135
 
110
- ### orak-deploy-zip
111
136
  Belirtilen dosya ve klasörleri tar.gz formatında arşivler.
112
137
 
113
138
  ```bash
114
- orak-deploy-zip
139
+ orak-zip-content [--profile <name>] [--v]
140
+ ```
141
+
142
+ **Gerekli orak-config.json ayarları:**
143
+
144
+ ```json
145
+ {
146
+ "zip_content": ["bin", "lib"],
147
+ "zip_content_out_file": ".orak-dist/deploy"
148
+ }
149
+ ```
150
+
151
+ - `zip_content`: Arşive dahil edilecek dosya ve klasörler
152
+ - `zip_content_out_file`: Oluşturulacak arşiv dosyasının tam yolu (**uzantısız**; `.tar.gz` kod tarafından eklenir)
153
+
154
+ Ek opsiyonlar:
155
+
156
+ - `--profile <name>`: Profil adı verildiğinde `zip_content_out_file_<name>` anahtarı tercih edilir (örn: `zip_content_out_file_test`). Konsolda: `test profil uygulandı.`
157
+
158
+ - `--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`
159
+
160
+ ### orak-zip-package
161
+
162
+ Belirtilen dosya ve klasörleri tar.gz formatında paket arşivi olarak oluşturur.
163
+
164
+ ```bash
165
+ orak-zip-package [--profile <name>] [--v]
115
166
  ```
116
167
 
117
168
  **Gerekli orak-config.json ayarları:**
169
+
118
170
  ```json
119
171
  {
120
- "fiDeployZipFile": "orak-deploy-zip",
121
- "fiDeployZipContent": [
122
- "src/",
123
- "public/",
124
- "package.json"
125
- ]
172
+ "zip_package": ["lib/", "bin/"],
173
+ "zip_package_out_file": ".orak-dist/deploy1"
126
174
  }
127
175
  ```
128
176
 
129
- - `fiDeployZipFile`: Oluşturulacak arşiv dosyasının adı (.tar.gz uzantısı otomatik eklenir)
130
- - `fiDeployZipContent`: Arşive dahil edilecek dosya ve klasörler
177
+ - `zip_package`: Paket arşivine dahil edilecek dosya ve klasörler
178
+ - `zip_package_out_file`: Oluşturulacak paket arşiv dosyasının tam yolu (**uzantısız**; `.tar.gz` kod tarafından eklenir)
179
+
180
+ Ek opsiyonlar:
181
+
182
+ - `--profile <name>`: Profil adı verildiğinde `zip_package_out_file_<name>` anahtarı tercih edilir (örn: `zip_package_out_file_test`).
183
+
184
+ - `--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`).
131
185
 
132
186
  ### orak-env-change
133
187
  Ortam dosyalarını (.env) değiştirir.
@@ -155,14 +209,18 @@ Bu durumda parametre vermeden `orak-env-change` komutunu çalıştırabilirsiniz
155
209
  orak-copy-deps
156
210
  ```
157
211
 
158
- ### 2. Deployment İşlemi
212
+ ### 2. Arşiv Oluşturma ve FTP Yükleme
159
213
  ```bash
160
- # .env dosyası oluşturun ve FTP bilgilerinizi ekleyin
161
- # Önce arşiv oluştur
162
- orak-deploy-zip
214
+ # .env.orakconfig dosyası oluşturun ve FTP bilgilerinizi ekleyin
163
215
 
164
- # Sonra FTP'ye yükle
216
+ # İçerik arşivi oluştur
217
+ orak-zip-content
218
+
219
+ # FTP'ye yükle
165
220
  orak-deploy-ftp
221
+
222
+ # Alternatif olarak paket arşivi oluştur
223
+ orak-zip-package
166
224
  ```
167
225
 
168
226
  ### 3. Ortam Değiştirme
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { deployFtpFiles } from '../lib/deploy-ftp-files.js';
4
+
5
+ deployFtpFiles();
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  import { envDevChange } from '../lib/env-dev-change.js';
4
4
 
@@ -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
package/jsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2020",
4
+ "module": "commonjs",
5
+ "checkJs": true,
6
+ "allowJs": true,
7
+ "moduleResolution": "node",
8
+ "baseUrl": ".",
9
+ "paths": {
10
+ "*": ["node_modules/*", "lib/*"]
11
+ }
12
+ },
13
+ "exclude": [
14
+ "node_modules",
15
+ "**/dist",
16
+ "**/build"
17
+ ]
18
+ }
@@ -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'));
@@ -0,0 +1,152 @@
1
+ import { Client } from "basic-ftp";
2
+ import path from "path";
3
+ import fs from 'fs';
4
+ import { fileURLToPath } from 'url';
5
+ import { parseArgs } from './args-parser.js';
6
+ import { parseEnvContent, addVersionToFilename, DeployConfig } from './osf-node-utils.js';
7
+
8
+ // @ts-ignore
9
+ const __filename = fileURLToPath(import.meta.url);
10
+ const __dirname = path.dirname(__filename);
11
+
12
+ //console.log("filename:" + __filename);
13
+ //console.log("dirname:" + __dirname);
14
+
15
+ export async function deployFtpFiles() {
16
+ const args = parseArgs();
17
+
18
+ let deployConfig = new DeployConfig();
19
+
20
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
21
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
22
+ deployConfig.objPackageJson = packageJson;
23
+
24
+ // Argüman kontrolü ve yardım mesajı
25
+ if (args.help || args.h) {
26
+ // package.json'dan versiyon al
27
+ console.log(`orak-deploy-ftp-files version ${packageJson.version}`);
28
+ console.log('Kullanım: orak-deploy-ftp-files');
29
+ console.log('');
30
+ console.log('Konfigürasyon: .env dosyasında FTP bilgileri gerekli.');
31
+ process.exit(0);
32
+ }
33
+
34
+ console.log("🚀 FTP Deploy Files Başlatılıyor...");
35
+
36
+ const projectRoot = process.cwd();
37
+ deployConfig.pathProjectRoot = projectRoot;
38
+
39
+ //console.log("Project Root:"+ projectRoot);
40
+ //Project Root:Y:\devrepo-oraksoft-web\oraksoft-node-tools
41
+
42
+ // .env.orakconfig dosyasını oku
43
+ const pathEnvOrakConfig = path.join(projectRoot, '.env.orakconfig');
44
+
45
+ //console.log("envPath:" + pathEnvOrakConfig);
46
+ //envPath:Y:\devrepo-oraksoft-web\oraksoft-node-tools\.env.orakconfig
47
+
48
+ if (!fs.existsSync(pathEnvOrakConfig)) {
49
+ console.error(`
50
+ ❌ .env.orakconfig dosyası bulunamadı!
51
+
52
+ .env.orakconfig dosyası oluşturun ve şu bilgileri ekleyin:
53
+ osf_ftp_host=ftp.example.com
54
+ osf_ftp_user=username
55
+ osf_ftp_password=password
56
+ osf_ftp_secure=false
57
+ `);
58
+ process.exit(1);
59
+ }
60
+
61
+ // .env.xx dosyasını parse et
62
+ const envContent = fs.readFileSync(pathEnvOrakConfig, 'utf-8');
63
+ const envVars = parseEnvContent(envContent);
64
+
65
+ // ftp güvenlik bilgileri
66
+ let ftpHost = envVars.osf_ftp_host;
67
+ const ftpUser = envVars.osf_ftp_user;
68
+ const ftpPassword = envVars.osf_ftp_password;
69
+ const ftpSecure = envVars.osf_ftp_secure === 'true';
70
+
71
+ // osf_ftp_local_file support with profile suffix (osf_ftp_local_file_{profile})
72
+ let remotePathKey = 'dff_remote_path';
73
+
74
+ if (args.profile || args.p) {
75
+ args.profile = args.profile || args.p;
76
+ console.log(`🔖 Profil kullanılıyor: ${args.profile}`);
77
+ remotePathKey = remotePathKey + '_' + args.profile;
78
+ }
79
+
80
+ //let localFileName = envVars[localFileKey];
81
+ let remotePath = envVars[remotePathKey];
82
+
83
+ // if (!ftpHost || !remotePath) {
84
+ const pathOrakConfigJson = path.join(projectRoot, 'orak-config.json');
85
+
86
+ if (!fs.existsSync(pathOrakConfigJson)) {
87
+ console.error(`
88
+ ❌ orak-config.json dosyası bulunamadı!
89
+
90
+ .orak-config.json dosyası oluşturun ve şu bilgileri ekleyin:
91
+ ${remotePathKey}=<remote_path>
92
+ `);
93
+ process.exit(1);
94
+ }
95
+
96
+ //orak-config.json dosyasını oku
97
+ const jsonOrakConfig = JSON.parse(fs.readFileSync(pathOrakConfigJson, 'utf-8'));
98
+ deployConfig.objOrakConfig = jsonOrakConfig;
99
+
100
+ //ftpHost = ftpHost ?? jsonOrakConfig.osf_ftp_host;
101
+ remotePath = deployConfig.objOrakConfig[remotePathKey] ?? ''; //remotePath ??
102
+
103
+ if (!ftpHost || !ftpUser || !ftpPassword) {
104
+ console.error("Error: FTP bilgileri eksik. .env.orakconfig dosyasında osf_ftp_host, osf_ftp_user ve osf_ftp_password alanlarını kontrol edin.");
105
+ process.exit(1);
106
+ }
107
+
108
+ const client = new Client();
109
+ client.ftp.verbose = true;
110
+
111
+ /* @type {string[]} */
112
+ const filesToArchive = deployConfig.objOrakConfig.dff_list || [];
113
+
114
+ // "dff_list": [
115
+ // {
116
+ // "local": ".orak-dist/test1.txt",
117
+ // "remote": "temp"
118
+ // }
119
+ // ]
120
+
121
+ try {
122
+ await client.access({
123
+ host: ftpHost,
124
+ user: ftpUser,
125
+ password: ftpPassword,
126
+ secure: ftpSecure
127
+ });
128
+
129
+ // dff_list içindeki dosyaları yükle
130
+ for (const objFile of filesToArchive) {
131
+ const localFilePath = path.join(projectRoot, objFile.local);
132
+ // remoteFilePath: remote klasör + dosya adı
133
+ const remoteFilePath = path.posix.join(remotePath, objFile.remote, path.basename(objFile.local));
134
+ if (!fs.existsSync(localFilePath)) {
135
+ console.error(`Error: Yerel dosya bulunamadı: ${localFilePath}`);
136
+ continue;
137
+ }
138
+ console.log(`Yükleniyor: ${localFilePath} -> ${remoteFilePath}`);
139
+ await client.uploadFrom(localFilePath, remoteFilePath);
140
+ console.log(`✅ Lokal: ${localFilePath}`);
141
+ console.log(`✅ Remote: ${remoteFilePath}`);
142
+ console.log('-----------------------------');
143
+ }
144
+ console.log("✅ FTP yükleme tamamlandı!");
145
+ }
146
+ catch (err) {
147
+ console.error("❌ FTP Hatası:", err);
148
+ process.exit(1);
149
+ }
150
+ client.close();
151
+
152
+ }
@@ -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 {