oraksoft-node-tools 0.1.30 → 0.1.38
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/.orak-dist/app-deploy-info.jsn +2 -2
- package/.orak-dist/deploy-0_1_34.zip +0 -0
- package/.orak-dist/deploy.tar.gz +0 -0
- package/.orak-dist/deploy.zip +0 -0
- package/.orak-dist/deploy_0_1_34.tar.gz +0 -0
- package/.orak-dist/deploy_0_1_34.zip +0 -0
- package/.orak-dist/deploy_0_1_37.tar.gz +0 -0
- package/README.md +41 -8
- package/bin/orak-zip-content.js +2 -2
- package/bin/orak-zip-package.js +2 -2
- package/lib/copy-deps.js +73 -67
- package/lib/deploy-ftp.js +10 -3
- package/lib/index.js +2 -2
- package/lib/zip-content.js +58 -17
- package/lib/zip-package.js +144 -38
- package/package.json +4 -2
- package/test-archive.zip +0 -0
- package/lib/deploy-ftp-files.js +0 -152
- package/lib/deploy-ftp-secure.js +0 -79
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/README.md
CHANGED
|
@@ -106,6 +106,7 @@ osf_ftp_secure=false
|
|
|
106
106
|
```bash
|
|
107
107
|
osf_ftp_local_file=deploy.tar.gz
|
|
108
108
|
osf_ftp_remote_path=public_html
|
|
109
|
+
osf_ftp_remote_abs_path=https://entegre.oraksoft.tr/
|
|
109
110
|
|
|
110
111
|
```
|
|
111
112
|
|
|
@@ -116,7 +117,9 @@ osf_ftp_remote_path=public_html
|
|
|
116
117
|
- `osf_ftp_secure`: `true` FTPS kullanır, `false` FTP kullanır (varsayılan: `false`)
|
|
117
118
|
- `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
119
|
- `osf_ftp_remote_path`: Uzak sunucudaki hedef klasör yolu (varsayılan: `/`)
|
|
119
|
-
-
|
|
120
|
+
- - `osf_ftp_remote_url`: meta dosyasına konulacak url adresi, buraya dosya adı eklenir
|
|
121
|
+
|
|
122
|
+
Not: Dosya adı otomatik olarak `osf_ftp_local_file`'ın son bölümünden alınır
|
|
120
123
|
|
|
121
124
|
Ek opsiyonlar:
|
|
122
125
|
|
|
@@ -124,19 +127,21 @@ Ek opsiyonlar:
|
|
|
124
127
|
|
|
125
128
|
- `--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ı: ...`
|
|
126
129
|
|
|
130
|
+
- `--meta`: Meta bilgi json dosyasını üretir
|
|
131
|
+
|
|
127
132
|
**❗ Güvenlik Notları:**
|
|
128
133
|
- `.env.orakconfig` dosyası zaten .gitignore'da bulunuyor
|
|
129
134
|
- Web sunucunuzda `.env.orakconfig` dosyalarına erişimi engelleyin (.htaccess)
|
|
130
135
|
- Dosya izinlerini kısıtlayın: `chmod 600 .env.orakconfig`
|
|
131
136
|
|
|
132
|
-
📝
|
|
137
|
+
📝 Profil kullanılıyorsa `osf_ftp_local_file_<profile>` anahtarı ile aranır.
|
|
133
138
|
|
|
134
139
|
### orak-zip-content
|
|
135
140
|
|
|
136
|
-
Belirtilen dosya ve klasörleri tar.gz formatında arşivler.
|
|
141
|
+
Belirtilen dosya ve klasörleri tar.gz veya ZIP formatında arşivler.
|
|
137
142
|
|
|
138
143
|
```bash
|
|
139
|
-
orak-zip-content [--profile <name>] [--v]
|
|
144
|
+
orak-zip-content [--profile <name>] [--v] [--zip]
|
|
140
145
|
```
|
|
141
146
|
|
|
142
147
|
**Gerekli orak-config.json ayarları:**
|
|
@@ -149,7 +154,7 @@ orak-zip-content [--profile <name>] [--v]
|
|
|
149
154
|
```
|
|
150
155
|
|
|
151
156
|
- `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)
|
|
157
|
+
- `zip_content_out_file`: Oluşturulacak arşiv dosyasının tam yolu (**uzantısız**; `.tar.gz` veya `.zip` kod tarafından eklenir)
|
|
153
158
|
|
|
154
159
|
Ek opsiyonlar:
|
|
155
160
|
|
|
@@ -157,12 +162,26 @@ Ek opsiyonlar:
|
|
|
157
162
|
|
|
158
163
|
- `--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
164
|
|
|
165
|
+
- `--zip, -z`: ZIP formatında arşiv oluşturur. Varsayılan format tar.gz'dir (örn: `.orak-dist/deploy` -> `.orak-dist/deploy-1_2_3.zip`).
|
|
166
|
+
|
|
167
|
+
**Kullanım Örnekleri:**
|
|
168
|
+
```bash
|
|
169
|
+
# tar.gz formatında arşiv oluştur
|
|
170
|
+
orak-zip-content -v
|
|
171
|
+
|
|
172
|
+
# ZIP formatında arşiv oluştur
|
|
173
|
+
orak-zip-content -z -v
|
|
174
|
+
|
|
175
|
+
# Profil ile ZIP formatında
|
|
176
|
+
orak-zip-content --zip --profile production -v
|
|
177
|
+
```
|
|
178
|
+
|
|
160
179
|
### orak-zip-package
|
|
161
180
|
|
|
162
|
-
Belirtilen dosya ve klasörleri tar.gz formatında paket arşivi olarak oluşturur.
|
|
181
|
+
Belirtilen dosya ve klasörleri tar.gz veya ZIP formatında paket arşivi olarak oluşturur.
|
|
163
182
|
|
|
164
183
|
```bash
|
|
165
|
-
orak-zip-package [--profile <name>] [--v]
|
|
184
|
+
orak-zip-package [--profile <name>] [--v] [--zip]
|
|
166
185
|
```
|
|
167
186
|
|
|
168
187
|
**Gerekli orak-config.json ayarları:**
|
|
@@ -175,7 +194,7 @@ orak-zip-package [--profile <name>] [--v]
|
|
|
175
194
|
```
|
|
176
195
|
|
|
177
196
|
- `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)
|
|
197
|
+
- `zip_package_out_file`: Oluşturulacak paket arşiv dosyasının tam yolu (**uzantısız**; `.tar.gz` veya `.zip` kod tarafından eklenir)
|
|
179
198
|
|
|
180
199
|
Ek opsiyonlar:
|
|
181
200
|
|
|
@@ -183,6 +202,20 @@ Ek opsiyonlar:
|
|
|
183
202
|
|
|
184
203
|
- `--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`).
|
|
185
204
|
|
|
205
|
+
- `--zip, -z`: ZIP formatında paket arşivi oluşturur. Varsayılan format tar.gz'dir (örn: `.orak-dist/deploy1` -> `.orak-dist/deploy1-1_2_3.zip`).
|
|
206
|
+
|
|
207
|
+
**Kullanım Örnekleri:**
|
|
208
|
+
```bash
|
|
209
|
+
# tar.gz formatında paket oluştur
|
|
210
|
+
orak-zip-package -v
|
|
211
|
+
|
|
212
|
+
# ZIP formatında paket oluştur
|
|
213
|
+
orak-zip-package -z -v
|
|
214
|
+
|
|
215
|
+
# Profil ile ZIP formatında
|
|
216
|
+
orak-zip-package --zip --profile production -v
|
|
217
|
+
```
|
|
218
|
+
|
|
186
219
|
### orak-env-change
|
|
187
220
|
Ortam dosyalarını (.env) değiştirir.
|
|
188
221
|
|
package/bin/orak-zip-content.js
CHANGED
package/bin/orak-zip-package.js
CHANGED
package/lib/copy-deps.js
CHANGED
|
@@ -3,88 +3,94 @@ import path from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { parseArgs } from './args-parser.js';
|
|
5
5
|
|
|
6
|
+
// @ts-ignore
|
|
6
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
8
|
const __dirname = path.dirname(__filename);
|
|
8
9
|
|
|
9
10
|
export function copyDeps() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// Argüman kontrolü ve yardım mesajı
|
|
13
|
-
if (args.help || args.h) {
|
|
14
|
-
// package.json'dan versiyon al
|
|
15
|
-
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
16
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
17
|
-
|
|
18
|
-
console.log(`orak-copy-deps version ${packageJson.version}`);
|
|
19
|
-
console.log('Kullanım: orak-copy-deps');
|
|
20
|
-
console.log('Node.js bağımlılıklarınızı belirtilen klasöre kopyalar.');
|
|
21
|
-
console.log('Konfigürasyon: orak-config.json dosyasında "copyDepsModulesToCopy" ve "copyDepsLibFolder" ayarları gerekli.');
|
|
22
|
-
process.exit(0);
|
|
23
|
-
}
|
|
11
|
+
const args = parseArgs();
|
|
24
12
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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'));
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
console.log(`orak-copy-deps version ${packageJson.version}`);
|
|
20
|
+
console.log('Kullanım: orak-copy-deps');
|
|
21
|
+
console.log('Node.js bağımlılıklarınızı belirtilen klasöre kopyalar.');
|
|
22
|
+
console.log('Konfigürasyon: orak-config.json dosyasında "copyDepsModulesToCopy" ve "copyDepsLibFolder" ayarları 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
|
+
const srcDir = path.join(projectRoot, 'node_modules');
|
|
29
|
+
|
|
30
|
+
// orak-config.json dosyasını oku
|
|
31
|
+
const configPath = path.join(projectRoot, 'orak-config.json');
|
|
32
|
+
|
|
33
|
+
if (!fs.existsSync(configPath)) {
|
|
34
|
+
console.error("Error: orak-config.json dosyası bulunamadı. Bu komutu proje kök dizininde çalıştırın.");
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
if (!config.copyDepsModulesToCopy || !Array.isArray(config.copyDepsModulesToCopy)) {
|
|
41
|
+
console.error("Error: 'copyDepsModulesToCopy' alanı orak-config.json içinde bir dizi olarak tanımlanmalıdır.");
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
38
44
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
if (typeof config.copyDepsLibFolder !== "string") {
|
|
46
|
+
console.error("Error: 'copyDepsLibFolder' alanı orak-config.json içinde bir string olarak tanımlanmalıdır.");
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// copyDepsLibFolder dizinini belirle
|
|
51
|
+
const destDir = path.join(projectRoot, config.copyDepsLibFolder);
|
|
52
|
+
|
|
53
|
+
if (config.copyDepsLibFolderEmpty) {
|
|
54
|
+
if (fs.existsSync(destDir)) {
|
|
55
|
+
fs.rmSync(destDir, { recursive: true, force: true });
|
|
56
|
+
console.log(`Deleted ${destDir} and its contents.`);
|
|
42
57
|
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Klasörü oluştur
|
|
61
|
+
if (!fs.existsSync(destDir)) {
|
|
62
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ** Kopyalanacak dosyaları belirle **
|
|
66
|
+
const modulesToCopy = config.copyDepsModulesToCopy;
|
|
67
|
+
|
|
68
|
+
modulesToCopy.forEach(({ name, file, destFolder }) => {
|
|
69
|
+
const modPath = path.join(srcDir, name, file); // Kaynak dosya
|
|
70
|
+
let moduleDestDir = path.join(destDir, name); // Hedef bağımlılık klasörü
|
|
43
71
|
|
|
44
|
-
if
|
|
45
|
-
|
|
46
|
-
process.exit(1);
|
|
72
|
+
if(destFolder){
|
|
73
|
+
moduleDestDir = path.join(destDir, name, destFolder); // Hedef bağımlılık klasörü
|
|
47
74
|
}
|
|
48
75
|
|
|
49
|
-
//
|
|
50
|
-
const destDir = path.join(projectRoot, config.copyDepsLibFolder);
|
|
76
|
+
let destPath = path.join(moduleDestDir, path.basename(file)); // Hedef dosya
|
|
51
77
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
console.log(`Deleted ${destDir} and its contents.`);
|
|
56
|
-
}
|
|
78
|
+
// Hedef bağımlılık klasörünü oluştur
|
|
79
|
+
if (!fs.existsSync(moduleDestDir)) {
|
|
80
|
+
fs.mkdirSync(moduleDestDir, { recursive: true });
|
|
57
81
|
}
|
|
58
82
|
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
fs.
|
|
83
|
+
if (!fs.existsSync(destPath)) { // Eğer dosya yoksa kopyala
|
|
84
|
+
if (fs.existsSync(modPath)) {
|
|
85
|
+
fs.cpSync(modPath, destPath, { recursive: false });
|
|
86
|
+
console.log(`✅ Copied: ${modPath} → ${destPath}`);
|
|
87
|
+
} else {
|
|
88
|
+
console.error(`❌ Error: ${modPath} not found!`);
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
console.log(`⚠️ Skipped (already exists): ${destPath}`);
|
|
62
92
|
}
|
|
93
|
+
});
|
|
63
94
|
|
|
64
|
-
|
|
65
|
-
const modulesToCopy = config.copyDepsModulesToCopy;
|
|
66
|
-
|
|
67
|
-
modulesToCopy.forEach(({ name, file }) => {
|
|
68
|
-
const modPath = path.join(srcDir, name, file); // Kaynak dosya
|
|
69
|
-
const moduleDestDir = path.join(destDir, name); // Hedef bağımlılık klasörü
|
|
70
|
-
const destPath = path.join(moduleDestDir, path.basename(file)); // Hedef dosya
|
|
71
|
-
|
|
72
|
-
// Hedef bağımlılık klasörünü oluştur
|
|
73
|
-
if (!fs.existsSync(moduleDestDir)) {
|
|
74
|
-
fs.mkdirSync(moduleDestDir, { recursive: true });
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (!fs.existsSync(destPath)) { // Eğer dosya yoksa kopyala
|
|
78
|
-
if (fs.existsSync(modPath)) {
|
|
79
|
-
fs.cpSync(modPath, destPath, { recursive: false });
|
|
80
|
-
console.log(`✅ Copied: ${modPath} → ${destPath}`);
|
|
81
|
-
} else {
|
|
82
|
-
console.error(`❌ Error: ${modPath} not found!`);
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
console.log(`⚠️ Skipped (already exists): ${destPath}`);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
console.log("🎉 Dependency sync process completed!");
|
|
95
|
+
console.log("🎉 Dependency sync process completed!");
|
|
90
96
|
}
|
package/lib/deploy-ftp.js
CHANGED
|
@@ -3,7 +3,7 @@ import path, { parse } from "path";
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import { parseArgs } from './args-parser.js';
|
|
6
|
-
import { addVersionToFilename, appendRandomToFilename, parseEnvContent } from "./osf-node-utils.js";
|
|
6
|
+
import { addVersionToFilename, appendRandomToFilename, parseEnvContent, parseFileNameAndExtension } from "./osf-node-utils.js";
|
|
7
7
|
|
|
8
8
|
// @ts-ignore
|
|
9
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -94,7 +94,7 @@ ${remotePathKey}=<remote_path>
|
|
|
94
94
|
|
|
95
95
|
const txVersion = objPackageJsonCurrProj.version; //.replace(/\./g, '_');
|
|
96
96
|
localFileName = addVersionToFilename(localFileName, txVersion);
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
console.log(`📦 Versiyon eklendi: ${txVersion}`);
|
|
99
99
|
console.log(`📄 Güncel dosya adı: ${localFileName}`);
|
|
100
100
|
}
|
|
@@ -145,11 +145,18 @@ ${remotePathKey}=<remote_path>
|
|
|
145
145
|
|
|
146
146
|
// --meta argümanı verilirse yükleme bilgilerini içeren bir JSON dosyası oluştur ve FTP'ye yükler
|
|
147
147
|
if (args.meta) {
|
|
148
|
+
|
|
149
|
+
let objFile = parseFileNameAndExtension(remoteFilePath);
|
|
150
|
+
|
|
151
|
+
let txUrl = objOrakConfig.osf_ftp_remote_url + objFile.name + objFile.ext;
|
|
152
|
+
|
|
148
153
|
let objFileInfo = {
|
|
149
154
|
"oa1TxVersion": objPackageJsonCurrProj.version,
|
|
150
|
-
"oa1TxUrl":
|
|
155
|
+
"oa1TxUrl": txUrl,
|
|
151
156
|
};
|
|
152
157
|
|
|
158
|
+
console.log(`📄 Url : ${txUrl}`);
|
|
159
|
+
|
|
153
160
|
let metaFileName = 'app-deploy-info.jsn';
|
|
154
161
|
// objFileInfo bilgi uploadInfo olarak kaydet
|
|
155
162
|
const pathMetaFile = path.join(projectRoot, '.orak-dist', metaFileName);
|
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 {
|
|
4
|
-
export {
|
|
3
|
+
export { makeZipPackage } from './zip-package.js';
|
|
4
|
+
export { makeZipContent } from './zip-content.js';
|
|
5
5
|
export { envChange } from './env-change.js';
|
package/lib/zip-content.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import * as tar from 'tar';
|
|
4
|
+
import { ZipArchive } from 'archiver';
|
|
4
5
|
import { fileURLToPath } from 'url';
|
|
5
6
|
import { parseArgs } from './args-parser.js';
|
|
6
7
|
|
|
@@ -8,7 +9,7 @@ import { parseArgs } from './args-parser.js';
|
|
|
8
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
9
10
|
const __dirname = path.dirname(__filename);
|
|
10
11
|
|
|
11
|
-
export async function
|
|
12
|
+
export async function makeZipContent() {
|
|
12
13
|
const args = parseArgs();
|
|
13
14
|
|
|
14
15
|
// Argüman kontrolü ve yardım mesajı
|
|
@@ -17,9 +18,15 @@ export async function deployZipContent() {
|
|
|
17
18
|
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
18
19
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
19
20
|
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.');
|
|
21
|
+
console.log('Kullanım: orak-zip-content [seçenekler]');
|
|
22
|
+
console.log('Belirtilen dosya ve klasörleri tar.gz (veya --zip ile ZIP) formatında arşivler.');
|
|
22
23
|
console.log('Konfigürasyon: orak-config.json dosyasında "zip-content" (array) ayarı gerekli.');
|
|
24
|
+
console.log('');
|
|
25
|
+
console.log('Seçenekler:');
|
|
26
|
+
console.log(' -v, --version Dosya adına versiyon ekle');
|
|
27
|
+
console.log(' -z, --zip ZIP formatında arşiv oluştur (varsayılan: tar.gz)');
|
|
28
|
+
console.log(' -p, --profile Profil belirtme');
|
|
29
|
+
console.log(' -h, --help Bu yardım mesajını göster');
|
|
23
30
|
process.exit(0);
|
|
24
31
|
}
|
|
25
32
|
|
|
@@ -69,8 +76,9 @@ export async function deployZipContent() {
|
|
|
69
76
|
console.log(`📦 Versiyon eklendi: ${txVersionForFileName}`);
|
|
70
77
|
}
|
|
71
78
|
|
|
72
|
-
// Dosya adına
|
|
73
|
-
|
|
79
|
+
// Dosya adına uzantı ekle
|
|
80
|
+
const isZipFormat = args.zip || args.z;
|
|
81
|
+
archiveName = archiveName + (isZipFormat ? '.zip' : '.tar.gz');
|
|
74
82
|
|
|
75
83
|
const filesToArchive = objOrakConfigJson["zip_content"];
|
|
76
84
|
|
|
@@ -152,23 +160,56 @@ export async function deployZipContent() {
|
|
|
152
160
|
fs.copyFileSync(file.src, destPath);
|
|
153
161
|
}
|
|
154
162
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
if (isZipFormat) {
|
|
164
|
+
// ZIP formatında arşiv oluştur
|
|
165
|
+
await createZipArchive(archivePath, tempDir, fs.readdirSync(tempDir));
|
|
166
|
+
console.log(`✅ ZIP arşivi oluşturuldu: ${archivePath}`);
|
|
167
|
+
} else {
|
|
168
|
+
// tar.gz formatında arşiv oluştur
|
|
169
|
+
await tar.c(
|
|
170
|
+
{
|
|
171
|
+
gzip: true,
|
|
172
|
+
file: archivePath,
|
|
173
|
+
cwd: tempDir,
|
|
174
|
+
follow: true,
|
|
175
|
+
},
|
|
176
|
+
fs.readdirSync(tempDir)
|
|
177
|
+
);
|
|
178
|
+
console.log(`✅ Arşiv oluşturuldu: ${archivePath}`);
|
|
179
|
+
}
|
|
165
180
|
|
|
166
181
|
// Geçici klasörü sil
|
|
167
182
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
168
|
-
|
|
169
|
-
console.log(`✅ Arşiv oluşturuldu: ${archivePath}`);
|
|
170
183
|
} catch (err) {
|
|
171
184
|
console.error('❌ Arşivleme hatası:', err);
|
|
172
185
|
process.exit(1);
|
|
173
186
|
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ZIP arşivi oluşturma yardımcı fonksiyonu
|
|
190
|
+
async function createZipArchive(archivePath, sourceDir, files) {
|
|
191
|
+
return new Promise((resolve, reject) => {
|
|
192
|
+
const output = fs.createWriteStream(archivePath);
|
|
193
|
+
const archive = new ZipArchive({ zlib: { level: 9 } });
|
|
194
|
+
|
|
195
|
+
output.on('close', resolve);
|
|
196
|
+
archive.on('error', reject);
|
|
197
|
+
output.on('error', reject);
|
|
198
|
+
|
|
199
|
+
archive.pipe(output);
|
|
200
|
+
|
|
201
|
+
// Dosyaları arşive ekle
|
|
202
|
+
for (const item of files) {
|
|
203
|
+
const itemPath = path.join(sourceDir, item);
|
|
204
|
+
const stat = fs.statSync(itemPath);
|
|
205
|
+
|
|
206
|
+
if (stat.isDirectory()) {
|
|
207
|
+
archive.directory(itemPath, item);
|
|
208
|
+
} else {
|
|
209
|
+
archive.file(itemPath, { name: item });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
archive.finalize();
|
|
214
|
+
});
|
|
174
215
|
}
|
package/lib/zip-package.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import * as tar from 'tar';
|
|
4
|
+
import { ZipArchive } from 'archiver';
|
|
4
5
|
import { fileURLToPath } from 'url';
|
|
5
6
|
import { parseArgs } from './args-parser.js';
|
|
6
|
-
import { parseEnvContent } from './osf-node-utils.js';
|
|
7
|
+
import { addVersionToFilename, parseEnvContent } from './osf-node-utils.js';
|
|
7
8
|
|
|
8
9
|
// @ts-ignore
|
|
9
10
|
const __filename = fileURLToPath(import.meta.url);
|
|
10
11
|
const __dirname = path.dirname(__filename);
|
|
11
12
|
|
|
12
|
-
export async function
|
|
13
|
+
export async function makeZipPackage() {
|
|
13
14
|
const args = parseArgs();
|
|
14
15
|
|
|
15
16
|
// Argüman kontrolü ve yardım mesajı
|
|
@@ -18,9 +19,15 @@ export async function zipPackage() {
|
|
|
18
19
|
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
19
20
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
20
21
|
console.log(`orak-zip-package version ${packageJson.version}`);
|
|
21
|
-
console.log('Kullanım: orak-zip-package');
|
|
22
|
-
console.log('Belirtilen dosya ve klasörleri tar.gz formatında arşivler.');
|
|
22
|
+
console.log('Kullanım: orak-zip-package [seçenekler]');
|
|
23
|
+
console.log('Belirtilen dosya ve klasörleri tar.gz (veya --zip ile ZIP) formatında arşivler.');
|
|
23
24
|
console.log('Konfigürasyon: orak-config.json dosyasında "zip_package" ayarı gerekli.');
|
|
25
|
+
console.log('');
|
|
26
|
+
console.log('Seçenekler:');
|
|
27
|
+
console.log(' -v, --version Dosya adına versiyon ekle');
|
|
28
|
+
console.log(' -z, --zip ZIP formatında paket oluştur (varsayılan: tar.gz)');
|
|
29
|
+
console.log(' -p, --profile Profil belirtme');
|
|
30
|
+
console.log(' -h, --help Bu yardım mesajını göster');
|
|
24
31
|
process.exit(0);
|
|
25
32
|
}
|
|
26
33
|
|
|
@@ -78,13 +85,13 @@ export async function zipPackage() {
|
|
|
78
85
|
|
|
79
86
|
if (args.v) {
|
|
80
87
|
// Ayırıcı ekle (örn. deploy-1_2_3.tar.gz) okunaklı olsun
|
|
81
|
-
|
|
82
|
-
archiveName = archiveName + sep + txVersionForFileName;
|
|
88
|
+
archiveName = addVersionToFilename(archiveName, txVersionForFileName);
|
|
83
89
|
console.log(`📦 Versiyon eklendi: ${txVersionForFileName}`);
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
// Dosya adına
|
|
87
|
-
|
|
92
|
+
// Dosya adına uzantı ekle
|
|
93
|
+
const isZipFormat = args.zip || args.z;
|
|
94
|
+
archiveName = archiveName + (isZipFormat ? '.zip' : '.tar.gz');
|
|
88
95
|
|
|
89
96
|
// dist klasörü ve arşiv adı
|
|
90
97
|
const distDir = projectRoot; // path.resolve(projectRoot, 'dist');
|
|
@@ -97,39 +104,138 @@ export async function zipPackage() {
|
|
|
97
104
|
|
|
98
105
|
// Arşiv oluştur
|
|
99
106
|
try {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
107
|
+
if (isZipFormat) {
|
|
108
|
+
// ZIP formatında arşiv oluştur
|
|
109
|
+
await createZipArchive(archivePath, projectRoot, filesToArchive);
|
|
110
|
+
console.log(`✅ ZIP arşivi oluşturuldu: ${archivePath}`);
|
|
111
|
+
} else {
|
|
112
|
+
// tar.gz formatında arşiv oluştur
|
|
113
|
+
await tar.c(
|
|
114
|
+
{
|
|
115
|
+
gzip: true,
|
|
116
|
+
file: archivePath,
|
|
117
|
+
cwd: projectRoot,
|
|
118
|
+
follow: true, // symlink/junction'ları takip et
|
|
119
|
+
filter: (path, stat) => {
|
|
120
|
+
// .git klasörlerini ve test dosyalarını hariç tut
|
|
121
|
+
const normalizedPath = path.replace(/\\/g, '/');
|
|
122
|
+
if (normalizedPath.includes('/.git/')
|
|
123
|
+
|| normalizedPath.includes('/.git')
|
|
124
|
+
|| normalizedPath.includes('/tests/')
|
|
125
|
+
|| normalizedPath.includes('/tests')
|
|
126
|
+
|| normalizedPath.includes('/fi-logs/')
|
|
127
|
+
|| normalizedPath.includes('/fi-logs')
|
|
128
|
+
|| normalizedPath.includes('/.github/')
|
|
129
|
+
|| normalizedPath.includes('/.github')
|
|
130
|
+
|| normalizedPath.endsWith('.md')
|
|
131
|
+
|| normalizedPath.endsWith('phpunit.xml.dist')
|
|
132
|
+
|| normalizedPath.endsWith('.gitignore')
|
|
133
|
+
|| normalizedPath.endsWith('.gitattributes')
|
|
134
|
+
) {
|
|
135
|
+
console.log('Excluding:', path);
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
124
139
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
console.log(`✅ Arşiv oluşturuldu: ${archivePath}`);
|
|
140
|
+
},
|
|
141
|
+
filesToArchive
|
|
142
|
+
);
|
|
143
|
+
console.log(`✅ Arşiv oluşturuldu: ${archivePath}`);
|
|
144
|
+
}
|
|
131
145
|
} catch (err) {
|
|
132
146
|
console.error('❌ Arşivleme hatası:', err);
|
|
133
147
|
process.exit(1);
|
|
134
148
|
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// ZIP arşivi oluşturma yardımcı fonksiyonu
|
|
152
|
+
async function createZipArchive(archivePath, projectRoot, filesToArchive) {
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
154
|
+
const output = fs.createWriteStream(archivePath);
|
|
155
|
+
const archive = new ZipArchive({ zlib: { level: 9 } });
|
|
156
|
+
|
|
157
|
+
output.on('close', resolve);
|
|
158
|
+
archive.on('error', reject);
|
|
159
|
+
output.on('error', reject);
|
|
160
|
+
|
|
161
|
+
archive.pipe(output);
|
|
162
|
+
|
|
163
|
+
// Dosya ve klasörleri arşive ekle
|
|
164
|
+
for (const item of filesToArchive) {
|
|
165
|
+
const itemPath = path.join(projectRoot, item);
|
|
166
|
+
|
|
167
|
+
if (!fs.existsSync(itemPath)) {
|
|
168
|
+
console.warn(`⚠️ Uyarı: "${item}" bulunamadı, atlanıyor.`);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// Symlink ise gerçek path'ini al
|
|
173
|
+
let realPath = itemPath;
|
|
174
|
+
const lstat = fs.lstatSync(itemPath);
|
|
175
|
+
|
|
176
|
+
if (lstat.isSymbolicLink()) {
|
|
177
|
+
realPath = fs.realpathSync(itemPath);
|
|
178
|
+
console.log(`🔗 Sembolik link takip ediliyor: ${item} -> ${realPath}`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const stat = fs.statSync(realPath);
|
|
182
|
+
|
|
183
|
+
if (stat.isDirectory()) {
|
|
184
|
+
addDirectoryToArchive(archive, realPath, item);
|
|
185
|
+
} else {
|
|
186
|
+
archive.file(realPath, { name: item });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
archive.finalize();
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Yardımcı fonksiyon: Klasörü recursive olarak arşive ekle ve sembolik linkler takip et
|
|
195
|
+
function addDirectoryToArchive(archive, directoryPath, baseArchivePath) {
|
|
196
|
+
const entries = fs.readdirSync(directoryPath);
|
|
197
|
+
|
|
198
|
+
for (const entry of entries) {
|
|
199
|
+
const entryPath = path.join(directoryPath, entry);
|
|
200
|
+
const archiveEntryPath = path.join(baseArchivePath, entry);
|
|
201
|
+
const normalizedPath = archiveEntryPath.replace(/\\/g, '/');
|
|
202
|
+
|
|
203
|
+
// Filtrele - .git, tests, vb. klasörleri hariç tut
|
|
204
|
+
if (normalizedPath.includes('/.git/')
|
|
205
|
+
|| normalizedPath.includes('/.git')
|
|
206
|
+
|| normalizedPath.includes('/tests/')
|
|
207
|
+
|| normalizedPath.includes('/tests')
|
|
208
|
+
|| normalizedPath.includes('/fi-logs/')
|
|
209
|
+
|| normalizedPath.includes('/fi-logs')
|
|
210
|
+
|| normalizedPath.includes('/.github/')
|
|
211
|
+
|| normalizedPath.includes('/.github')
|
|
212
|
+
|| normalizedPath.endsWith('.md')
|
|
213
|
+
|| normalizedPath.endsWith('phpunit.xml.dist')
|
|
214
|
+
|| normalizedPath.endsWith('.gitignore')
|
|
215
|
+
|| normalizedPath.endsWith('.gitattributes')
|
|
216
|
+
) {
|
|
217
|
+
console.log('Excluding:', archiveEntryPath);
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
let realPath = entryPath;
|
|
222
|
+
const lstat = fs.lstatSync(entryPath);
|
|
223
|
+
|
|
224
|
+
// Symlink ise gerçek path'ini al
|
|
225
|
+
if (lstat.isSymbolicLink()) {
|
|
226
|
+
realPath = fs.realpathSync(entryPath);
|
|
227
|
+
console.log(`🔗 Sembolik link takip ediliyor: ${archiveEntryPath} -> ${realPath}`);
|
|
228
|
+
const stat = fs.statSync(realPath);
|
|
229
|
+
|
|
230
|
+
if (stat.isDirectory()) {
|
|
231
|
+
addDirectoryToArchive(archive, realPath, archiveEntryPath);
|
|
232
|
+
} else {
|
|
233
|
+
archive.file(realPath, { name: archiveEntryPath });
|
|
234
|
+
}
|
|
235
|
+
} else if (lstat.isDirectory()) {
|
|
236
|
+
addDirectoryToArchive(archive, realPath, archiveEntryPath);
|
|
237
|
+
} else {
|
|
238
|
+
archive.file(realPath, { name: archiveEntryPath });
|
|
239
|
+
}
|
|
240
|
+
}
|
|
135
241
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oraksoft-node-tools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
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",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"author": "Oraksoft",
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"dependencies": {
|
|
36
|
+
"archiver": "^8.0.0",
|
|
36
37
|
"basic-ftp": "^5.0.5",
|
|
37
38
|
"minimist": "^1.2.8",
|
|
38
39
|
"tar": "^7.4.3"
|
|
@@ -50,10 +51,11 @@
|
|
|
50
51
|
},
|
|
51
52
|
"homepage": "https://github.com/oraksoftware/oraksoft-node-tools#readme",
|
|
52
53
|
"scripts": {
|
|
54
|
+
"pn-install": "pnpm install",
|
|
53
55
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
54
56
|
"build": "echo \"Build completed\"",
|
|
55
|
-
"pn-publish": "pnpm publish --access public",
|
|
56
57
|
"pn-global-update": "pnpm link --global",
|
|
58
|
+
"pn-publish": "pnpm publish --access public",
|
|
57
59
|
"orak-deploy-test": "orak-deploy-ftp"
|
|
58
60
|
}
|
|
59
61
|
}
|
package/test-archive.zip
ADDED
|
Binary file
|
package/lib/deploy-ftp-files.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
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
|
-
}
|
package/lib/deploy-ftp-secure.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
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_ftp_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
|
-
}
|