oraksoft-node-tools 0.1.18 → 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.
@@ -0,0 +1,104 @@
1
+ import path from "path";
2
+
3
+ /**
4
+ * Çoklu uzantı desteğiyle dosya adına versiyon ekler
5
+ * @param {string} pFileName
6
+ * @param {string} pVersion
7
+ * @returns {string}
8
+ */
9
+ export function addVersionToFilename(pFileName, pVersion) {
10
+ const txVersion = pVersion.replace(/\./g, '_');
11
+ //const path = require('path');
12
+ const parsed = path.parse(pFileName);
13
+ let parsedFile = parseFileNameAndExtension(pFileName);
14
+ // dosya uzantısı
15
+ let ext = parsedFile.ext;
16
+ let nameNoExt = parsedFile.name;
17
+ const seper = '_'; // nameNoExt.endsWith('-') || nameNoExt.endsWith('_') ? '' : '-';
18
+ const newBase = nameNoExt + seper + txVersion;
19
+ return parsed.dir ? path.join(parsed.dir, newBase + ext) : newBase + ext;
20
+ }
21
+
22
+ export function addVersionToFilename2(pFileName, pVersion) {
23
+ const txVersion = pVersion.replace(/\./g, '_');
24
+ //const path = require('path');
25
+ const parsed = path.parse(pFileName);
26
+ const base = parsed.base;
27
+ const multiExts = ['.tar.gz', '.tar.bz2', '.tar.xz', '.tar.lz', '.tar.Z', '.tgz'];
28
+ // dosya uzantısı
29
+ let ext = parsed.ext;
30
+ let nameNoExt = parsed.name;
31
+ for (const me of multiExts) {
32
+ if (base.toLowerCase().endsWith(me.toLowerCase())) {
33
+ ext = me;
34
+ // uzantısız dosya adı (örn. deploy.tar.gz -> deploy)
35
+ nameNoExt = base.slice(0, -me.length);
36
+ break;
37
+ }
38
+ }
39
+ const seper = '_'; // nameNoExt.endsWith('-') || nameNoExt.endsWith('_') ? '' : '-';
40
+ const newBase = nameNoExt + seper + txVersion;
41
+ return parsed.dir ? path.join(parsed.dir, newBase + ext) : newBase + ext;
42
+ }
43
+
44
+ // .env benzeri dosya içeriğini parse eden util fonksiyonu
45
+ export function parseEnvContent(envContent) {
46
+ const envVars = {};
47
+ envContent.split('\n').forEach(line => {
48
+ const trimmedLine = line.trim();
49
+ if (trimmedLine && !trimmedLine.startsWith('#')) {
50
+ const [key, ...valueParts] = trimmedLine.split('=');
51
+ if (key && valueParts.length > 0) {
52
+ envVars[key.trim()] = valueParts.join('=').trim();
53
+ }
54
+ }
55
+ });
56
+ return envVars;
57
+ }
58
+
59
+ export function appendRandomToFilename(filename) {
60
+ const parsed = path.parse(filename);
61
+ const randomStr = Math.random().toString(36).substring(2, 10); // 8 karakter
62
+
63
+ let parsedFile = parseFileNameAndExtension(filename);
64
+ let ext = parsedFile.ext;
65
+ let nameNoExt = parsedFile.name;
66
+ return nameNoExt + '_' + randomStr + ext;
67
+ }
68
+
69
+ export function appendRandomToFilename2(filename) {
70
+ const randomStr = Math.random().toString(36).substring(2, 10); // 8 karakter
71
+ const base = path.basename(filename);
72
+ const firstDotIdx = base.indexOf('.');
73
+ let nameNoExt = base;
74
+ let ext = '';
75
+ if (firstDotIdx !== -1) {
76
+ nameNoExt = base.slice(0, firstDotIdx);
77
+ ext = base.slice(firstDotIdx);
78
+ }
79
+ return nameNoExt + '_' + randomStr + ext;
80
+ }
81
+
82
+ /**
83
+ * Çoklu uzantı desteğiyle dosya adı ve uzantısını parse eder
84
+ *
85
+ * @param {*} filename
86
+ * @returns { {name: string, ext: string} } name: uzantısız dosya adı, ext: dosya uzantısı (çoklu uzantı destekli)
87
+ */
88
+ export function parseFileNameAndExtension(filename) {
89
+ const base = path.basename(filename);
90
+ const firstDotIdx = base.indexOf('.');
91
+ let nameNoExt = base;
92
+ let ext = '';
93
+ if (firstDotIdx !== -1) {
94
+ nameNoExt = base.slice(0, firstDotIdx);
95
+ ext = base.slice(firstDotIdx);
96
+ }
97
+ return { "name": nameNoExt, "ext": ext };
98
+ }
99
+
100
+ export class DeployConfig {
101
+ objOrakConfig = {};
102
+ pathProjectRoot = "";
103
+ objPackageJson = {};
104
+ }
@@ -1,92 +1,86 @@
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
+ // @ts-ignore
7
9
  const __filename = fileURLToPath(import.meta.url);
8
10
  const __dirname = path.dirname(__filename);
9
11
 
10
- export async function deployZipContent() {
12
+ export async function makeZipContent() {
11
13
  const args = parseArgs();
12
14
 
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
15
  // Argüman kontrolü ve yardım mesajı
18
16
  if (args.help || args.h) {
17
+ // package.json'dan versiyon al
18
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
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
 
26
33
  // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
27
34
  const projectRoot = process.cwd();
28
35
 
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
36
  // orak-config.json dosyasını oku
49
- const configPath = path.join(projectRoot, 'orak-config.json');
37
+ const pathOrakconfigJson = path.join(projectRoot, 'orak-config.json');
50
38
 
51
- if (!fs.existsSync(configPath)) {
52
- console.error("Error: orak-config.json dosyası bulunamadı. Bu komutu proje kök dizininde çalıştırın.");
39
+ if (!fs.existsSync(pathOrakconfigJson)) {
40
+ console.error("Error: orak-config.json dosyası bulunamadı. Lütfen ekleyiniz.");
53
41
  process.exit(1);
54
42
  }
55
43
 
56
- const jsnOrakConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
44
+ const objOrakConfigJson = JSON.parse(fs.readFileSync(pathOrakconfigJson, 'utf-8'));
57
45
 
58
- if (!jsnOrakConfig["zip_content"] || !Array.isArray(jsnOrakConfig["zip_content"])) {
46
+ if (!objOrakConfigJson["zip_content"] || !Array.isArray(objOrakConfigJson["zip_content"])) {
59
47
  console.error("Error: 'zip_content' alanı orak-config.json içinde bir dizi olarak tanımlanmalıdır.");
60
48
  process.exit(1);
61
49
  }
62
50
 
63
- let out_file_key = 'zip_content_out_file';
51
+ let outputFileKey = 'zip_content_out_file';
64
52
 
65
- if(args.profile) {
66
- console.log(`${args.profile} profil uygulandı.`);
67
- out_file_key = out_file_key + "_" + args.profile;
53
+ if (args.profile || args.p) {
54
+ args.profile = args.profile || args.p;
55
+ console.log(`🔖 Profil kullanılıyor: ${args.profile}`);
56
+ outputFileKey = outputFileKey + "_" + args.profile;
68
57
  }
69
58
 
70
- let archiveName = jsnOrakConfig[out_file_key];
59
+
60
+ let archiveName = objOrakConfigJson[outputFileKey];
71
61
 
72
62
  if (!archiveName) {
73
- console.error("Error: " + `${out_file_key} alanı orak-config.json içinde tanımlanmalıdır.`);
63
+ console.error("Error: " + `${outputFileKey} alanı orak-config.json içinde tanımlanmalıdır.`);
74
64
  process.exit(1);
75
65
  }
66
+
67
+ const packageJsonPath = path.join(projectRoot, 'package.json');
68
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
76
69
 
77
70
  let txVersionForFileName = packageJson.version.replace(/\./g, '_');
78
71
 
79
72
  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;
73
+ // Kelime Ayırıcı ekle (_) (ör. deploy-1_2_3.tar.gz) okunaklı olsun
74
+ const txWordSeper = '-'; // archiveName.endsWith('-') || archiveName.endsWith('_') ? '' : '-';
75
+ archiveName = archiveName + txWordSeper + txVersionForFileName;
83
76
  console.log(`📦 Versiyon eklendi: ${txVersionForFileName}`);
84
77
  }
85
78
 
86
- // Dosya adına .tar.gz uzantısını ekle
87
- archiveName = archiveName + '.tar.gz';
79
+ // Dosya adına uzantı ekle
80
+ const isZipFormat = args.zip || args.z;
81
+ archiveName = archiveName + (isZipFormat ? '.zip' : '.tar.gz');
88
82
 
89
- const filesToArchive = jsnOrakConfig["zip_content"];
83
+ const filesToArchive = objOrakConfigJson["zip_content"];
90
84
 
91
85
  if (!filesToArchive) {
92
86
  console.error("Error: 'zip_content' alanı orak-config.json içinde tanımlanmalıdır.");
@@ -108,10 +102,10 @@ export async function deployZipContent() {
108
102
 
109
103
  if (stat.isDirectory()) {
110
104
  // Klasörün içindeki dosyaları ekle
111
- const walkDir = (dir) => {
112
- const files = fs.readdirSync(dir);
105
+ const walkDir = (prmDir) => {
106
+ const files = fs.readdirSync(prmDir);
113
107
  for (const file of files) {
114
- const filePath = path.join(dir, file);
108
+ const filePath = path.join(prmDir, file);
115
109
  const fileStat = fs.statSync(filePath);
116
110
 
117
111
  if (fileStat.isDirectory()) {
@@ -148,7 +142,7 @@ export async function deployZipContent() {
148
142
  // Arşiv oluştur
149
143
  try {
150
144
  // Geçici klasör oluştur
151
- const tempDir = path.join(distDir, '.temp');
145
+ const tempDir = path.join(distDir, '.tempZipContentFi');
152
146
  if (fs.existsSync(tempDir)) {
153
147
  fs.rmSync(tempDir, { recursive: true, force: true });
154
148
  }
@@ -166,23 +160,56 @@ export async function deployZipContent() {
166
160
  fs.copyFileSync(file.src, destPath);
167
161
  }
168
162
 
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
- );
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
+ }
179
180
 
180
181
  // Geçici klasörü sil
181
182
  fs.rmSync(tempDir, { recursive: true, force: true });
182
-
183
- console.log(`✅ Arşiv oluşturuldu: ${archivePath}`);
184
183
  } catch (err) {
185
184
  console.error('❌ Arşivleme hatası:', err);
186
185
  process.exit(1);
187
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
+ });
188
215
  }
@@ -1,13 +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';
7
+ import { addVersionToFilename, parseEnvContent } from './osf-node-utils.js';
6
8
 
9
+ // @ts-ignore
7
10
  const __filename = fileURLToPath(import.meta.url);
8
11
  const __dirname = path.dirname(__filename);
9
12
 
10
- export async function zipPackage() {
13
+ export async function makeZipPackage() {
11
14
  const args = parseArgs();
12
15
 
13
16
  // Argüman kontrolü ve yardım mesajı
@@ -15,11 +18,16 @@ export async function zipPackage() {
15
18
  // package.json'dan versiyon al
16
19
  const packageJsonPath = path.join(__dirname, '..', 'package.json');
17
20
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
18
-
19
21
  console.log(`orak-zip-package version ${packageJson.version}`);
20
- console.log('Kullanım: orak-zip-package');
21
- 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.');
22
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');
23
31
  process.exit(0);
24
32
  }
25
33
 
@@ -27,24 +35,14 @@ export async function zipPackage() {
27
35
  const projectRoot = process.cwd();
28
36
 
29
37
  // .env dosyasını oku
30
- const envPath = path.join(projectRoot, '.env');
31
-
32
- const envVars = {};
38
+ // const envPath = path.join(projectRoot, '.env');
33
39
 
34
- if (fs.existsSync(envPath)) {
35
- const envContent = fs.readFileSync(envPath, 'utf-8');
40
+ // let envVars = {};
36
41
 
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
- }
42
+ // if (fs.existsSync(envPath)) {
43
+ // const envContent = fs.readFileSync(envPath, 'utf-8');
44
+ // envVars = parseEnvContent(envContent);
45
+ // }
48
46
 
49
47
  // orak-config.json dosyasını oku
50
48
  const configPath = path.join(projectRoot, 'orak-config.json');
@@ -54,42 +52,46 @@ export async function zipPackage() {
54
52
  process.exit(1);
55
53
  }
56
54
 
57
- const jsnOrakConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
55
+ const objOrakConfigJson = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
58
56
 
59
- if (!jsnOrakConfig.zip_package || !Array.isArray(jsnOrakConfig.zip_package)) {
57
+ if (!objOrakConfigJson.zip_package || !Array.isArray(objOrakConfigJson.zip_package)) {
60
58
  console.error("Error: 'zip_package' alanı orak-config.json içinde bir dizi olarak tanımlanmalıdır.");
61
59
  process.exit(1);
62
60
  }
63
61
 
64
- const filesToArchive = jsnOrakConfig.zip_package;
62
+ const filesToArchive = objOrakConfigJson.zip_package;
65
63
 
66
- let out_file_key = 'zip_package_out_file';
64
+ let outputFileKey = 'zip_package_out_file';
67
65
 
68
- if(args.profile) {
69
- out_file_key = `zip_package_out_file_${args.profile}`;
66
+ // --profile veya -p argümanı ile profil belirtme
67
+ if(args.profile || args.p) {
68
+ args.profile = args.profile || args.p;
69
+ console.log(`🔖 Profil kullanılıyor: ${args.profile}`);
70
+ outputFileKey = outputFileKey + "_" + args.profile;
70
71
  }
71
72
 
72
- if (!jsnOrakConfig[out_file_key]) {
73
- console.error("Error: " + `${out_file_key} alanı orak-config.json içinde tanımlanmalıdır.`);
73
+ if (!objOrakConfigJson[outputFileKey]) {
74
+ console.error(`Error : ${outputFileKey} alanı orak-config.json içinde tanımlanmalıdır.`);
74
75
  process.exit(1);
75
76
  }
76
77
 
77
- let archiveName = jsnOrakConfig[out_file_key];
78
+ let archiveName = objOrakConfigJson[outputFileKey];
78
79
 
79
80
  // package.json'dan versiyon al (opsiyonel --v ile eklenecek)
80
- const packageJsonPath = path.join(__dirname, '..', 'package.json');
81
+ const packageJsonPath = path.join(projectRoot, 'package.json');
81
82
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
83
+
82
84
  let txVersionForFileName = packageJson.version.replace(/\./g, '_');
83
85
 
84
86
  if (args.v) {
85
87
  // 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
+ archiveName = addVersionToFilename(archiveName, txVersionForFileName);
88
89
  console.log(`📦 Versiyon eklendi: ${txVersionForFileName}`);
89
90
  }
90
91
 
91
- // Dosya adına .tar.gz uzantısını ekle
92
- archiveName = archiveName + '.tar.gz';
92
+ // Dosya adına uzantı ekle
93
+ const isZipFormat = args.zip || args.z;
94
+ archiveName = archiveName + (isZipFormat ? '.zip' : '.tar.gz');
93
95
 
94
96
  // dist klasörü ve arşiv adı
95
97
  const distDir = projectRoot; // path.resolve(projectRoot, 'dist');
@@ -102,39 +104,138 @@ export async function zipPackage() {
102
104
 
103
105
  // Arşiv oluştur
104
106
  try {
105
- await tar.c(
106
- {
107
- gzip: true,
108
- file: archivePath,
109
- cwd: projectRoot,
110
- follow: true, // symlink/junction'ları takip et
111
- filter: (path, stat) => {
112
- // .git klasörlerini ve test dosyalarını hariç tut
113
- const normalizedPath = path.replace(/\\/g, '/');
114
- if (normalizedPath.includes('/.git/')
115
- || normalizedPath.includes('/.git')
116
- || normalizedPath.includes('/tests/')
117
- || normalizedPath.includes('/tests')
118
- || normalizedPath.includes('/fi-logs/')
119
- || normalizedPath.includes('/fi-logs')
120
- || normalizedPath.includes('/.github/')
121
- || normalizedPath.includes('/.github')
122
- || normalizedPath.endsWith('.md')
123
- || normalizedPath.endsWith('phpunit.xml.dist')
124
- || normalizedPath.endsWith('.gitignore')
125
- || normalizedPath.endsWith('.gitattributes')
126
- ) {
127
- console.log('Excluding:', path);
128
- return false;
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;
129
139
  }
130
- return true;
131
- }
132
- },
133
- filesToArchive
134
- );
135
- console.log(`✅ Arşiv oluşturuldu: ${archivePath}`);
140
+ },
141
+ filesToArchive
142
+ );
143
+ console.log(`✅ Arşiv oluşturuldu: ${archivePath}`);
144
+ }
136
145
  } catch (err) {
137
146
  console.error('❌ Arşivleme hatası:', err);
138
147
  process.exit(1);
139
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
+ }
140
241
  }
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "oraksoft-node-tools",
3
- "version": "0.1.18",
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",
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-ftp-files": "./bin/orak-deploy-ftp-files.js",
10
11
  "orak-env-change": "./bin/orak-env-change.js",
11
12
  "orak-env-dev-change": "./bin/orak-env-dev-change.js",
12
13
  "orak-zip-content": "./bin/orak-zip-content.js",
@@ -32,6 +33,7 @@
32
33
  "author": "Oraksoft",
33
34
  "license": "MIT",
34
35
  "dependencies": {
36
+ "archiver": "^8.0.0",
35
37
  "basic-ftp": "^5.0.5",
36
38
  "minimist": "^1.2.8",
37
39
  "tar": "^7.4.3"
@@ -49,10 +51,11 @@
49
51
  },
50
52
  "homepage": "https://github.com/oraksoftware/oraksoft-node-tools#readme",
51
53
  "scripts": {
54
+ "pn-install": "pnpm install",
52
55
  "test": "echo \"Error: no test specified\" && exit 1",
53
56
  "build": "echo \"Build completed\"",
54
- "pn-publish": "pnpm publish --access public",
55
57
  "pn-global-update": "pnpm link --global",
58
+ "pn-publish": "pnpm publish --access public",
56
59
  "orak-deploy-test": "orak-deploy-ftp"
57
60
  }
58
61
  }
Binary file
Binary file
Binary file