oraksoft-node-tools 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.oraksoft ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "ftp_host": "",
3
+ "ftp_user": "",
4
+ "ftp_password": "",
5
+ "ftp_secure": false,
6
+ "localFilePath": "",
7
+ "remoteFilePath": ""
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "folders": [
3
+ {
4
+ "path": ".."
5
+ }
6
+ ],
7
+ "settings": {}
8
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Oraksoft
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # Oraksoft Node Tools
2
+
3
+ Node.js projeleriniz için kullanışlı CLI araçları koleksiyonu.
4
+
5
+ ## Kurulum
6
+
7
+ ### Global kurulum (önerilen)
8
+ ```bash
9
+ npm install -g oraksoft-node-tools
10
+ ```
11
+
12
+ ### Proje bazında kurulum
13
+ ```bash
14
+ npm install oraksoft-node-tools --save-dev
15
+ ```
16
+
17
+ ## Komutlar
18
+
19
+ ### fi-copy-deps
20
+ Node.js bağımlılıklarınızı belirtilen klasöre kopyalar.
21
+
22
+ ```bash
23
+ fi-copy-deps
24
+ ```
25
+
26
+ **Gerekli package.json ayarları:**
27
+ ```json
28
+ {
29
+ "copyDepsModulesToCopy": [
30
+ {
31
+ "name": "module-name",
32
+ "file": "dist/module.js"
33
+ }
34
+ ],
35
+ "copyDepsLibFolder": "lib",
36
+ "copyDepsLibFolderEmpty": true
37
+ }
38
+ ```
39
+
40
+ ### fi-deploy-ftp
41
+ Dist klasöründeki dosyaları FTP sunucusuna yükler.
42
+
43
+ ```bash
44
+ fi-deploy-ftp
45
+ ```
46
+
47
+ **Gerekli .env.oraksoft ayarları:**
48
+ ```json
49
+ {
50
+ "ftp_host": "ftp.example.com",
51
+ "ftp_user": "username",
52
+ "ftp_password": "password",
53
+ "ftp_secure": false,
54
+ "localFilePath": "deployphp25.tar.gz",
55
+ "remoteFilePath": "/path/to/remote/file.tar.gz"
56
+ }
57
+ ```
58
+
59
+ ### fi-deploy-zip
60
+ Belirtilen dosya ve klasörleri tar.gz formatında arşivler.
61
+
62
+ ```bash
63
+ fi-deploy-zip
64
+ ```
65
+
66
+ **Gerekli package.json ayarları:**
67
+ ```json
68
+ {
69
+ "fiDeployZipContent": [
70
+ "src/",
71
+ "public/",
72
+ "package.json"
73
+ ]
74
+ }
75
+ ```
76
+
77
+ ### fi-env-change
78
+ Ortam dosyalarını (.env) değiştirir.
79
+
80
+ ```bash
81
+ fi-env-change dev
82
+ # veya
83
+ fi-env-change production
84
+ ```
85
+
86
+ **Opsiyonel package.json ayarları:**
87
+ ```json
88
+ {
89
+ "fiEnvChangeStatus": "dev"
90
+ }
91
+ ```
92
+
93
+ Bu durumda parametre vermeden `fi-env-change` komutunu çalıştırabilirsiniz.
94
+
95
+ ## Kullanım Örnekleri
96
+
97
+ ### 1. Bağımlılık Kopyalama
98
+ ```bash
99
+ # package.json'da tanımlanan modülleri kopyala
100
+ fi-copy-deps
101
+ ```
102
+
103
+ ### 2. Deployment İşlemi
104
+ ```bash
105
+ # Önce arşiv oluştur
106
+ fi-deploy-zip
107
+
108
+ # Sonra FTP'ye yükle
109
+ fi-deploy-ftp
110
+ ```
111
+
112
+ ### 3. Ortam Değiştirme
113
+ ```bash
114
+ # Development ortamına geç
115
+ fi-env-change dev
116
+
117
+ # Production ortamına geç
118
+ fi-env-change prod
119
+ ```
120
+
121
+ ## Gereksinimler
122
+
123
+ - Node.js >= 14.0.0
124
+ - NPM veya Yarn
125
+
126
+ ## Lisans
127
+
128
+ MIT
129
+
130
+ ## Katkıda Bulunma
131
+
132
+ 1. Fork edin
133
+ 2. Feature branch oluşturun (`git checkout -b feature/amazing-feature`)
134
+ 3. Değişikliklerinizi commit edin (`git commit -m 'Add amazing feature'`)
135
+ 4. Branch'i push edin (`git push origin feature/amazing-feature`)
136
+ 5. Pull Request oluşturun
137
+
138
+ ## Sorun Bildirimi
139
+
140
+ Sorunlarınızı [GitHub Issues](https://github.com/oraksoft/oraksoft-node-tools/issues) sayfasından bildirebilirsiniz.
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { copyDeps } from '../lib/copy-deps.js';
4
+
5
+ copyDeps();
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { deployFtp } from '../lib/deploy-ftp.js';
4
+
5
+ deployFtp();
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { deployZip } from '../lib/deploy-zip.js';
4
+
5
+ deployZip();
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { envChange } from '../lib/env-change.js';
4
+
5
+ envChange();
@@ -0,0 +1,70 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ export function copyDeps() {
5
+ // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
6
+ const projectRoot = process.cwd();
7
+ const srcDir = path.join(projectRoot, 'node_modules');
8
+
9
+ // package.json dosyasını oku
10
+ const packageJsonPath = path.join(projectRoot, 'package.json');
11
+
12
+ if (!fs.existsSync(packageJsonPath)) {
13
+ console.error("Error: package.json dosyası bulunamadı. Bu komutu bir Node.js projesi klasöründe çalıştırın.");
14
+ process.exit(1);
15
+ }
16
+
17
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
18
+
19
+ if (!packageJson.copyDepsModulesToCopy || !Array.isArray(packageJson.copyDepsModulesToCopy)) {
20
+ console.error("Error: 'copyDepsModulesToCopy' alanı package.json içinde bir dizi olarak tanımlanmalıdır.");
21
+ process.exit(1);
22
+ }
23
+
24
+ if (typeof packageJson.copyDepsLibFolder !== "string") {
25
+ console.error("Error: 'copyDepsLibFolder' alanı package.json içinde bir string olarak tanımlanmalıdır.");
26
+ process.exit(1);
27
+ }
28
+
29
+ // copyDepsLibFolder dizinini belirle
30
+ const destDir = path.join(projectRoot, packageJson.copyDepsLibFolder);
31
+
32
+ if (packageJson.copyDepsLibFolderEmpty) {
33
+ if (fs.existsSync(destDir)) {
34
+ fs.rmSync(destDir, { recursive: true, force: true });
35
+ console.log(`Deleted ${destDir} and its contents.`);
36
+ }
37
+ }
38
+
39
+ // Klasörü oluştur
40
+ if (!fs.existsSync(destDir)) {
41
+ fs.mkdirSync(destDir, { recursive: true });
42
+ }
43
+
44
+ // 📌 Kopyalanacak dosyaları belirle
45
+ const modulesToCopy = packageJson.copyDepsModulesToCopy;
46
+
47
+ modulesToCopy.forEach(({ name, file }) => {
48
+ const modPath = path.join(srcDir, name, file); // Kaynak dosya
49
+ const moduleDestDir = path.join(destDir, name); // Hedef bağımlılık klasörü
50
+ const destPath = path.join(moduleDestDir, path.basename(file)); // Hedef dosya
51
+
52
+ // Hedef bağımlılık klasörünü oluştur
53
+ if (!fs.existsSync(moduleDestDir)) {
54
+ fs.mkdirSync(moduleDestDir, { recursive: true });
55
+ }
56
+
57
+ if (!fs.existsSync(destPath)) { // Eğer dosya yoksa kopyala
58
+ if (fs.existsSync(modPath)) {
59
+ fs.cpSync(modPath, destPath, { recursive: false });
60
+ console.log(`✅ Copied: ${modPath} → ${destPath}`);
61
+ } else {
62
+ console.error(`❌ Error: ${modPath} not found!`);
63
+ }
64
+ } else {
65
+ console.log(`⚠️ Skipped (already exists): ${destPath}`);
66
+ }
67
+ });
68
+
69
+ console.log("🎉 Dependency sync process completed!");
70
+ }
@@ -0,0 +1,59 @@
1
+ import { Client } from "basic-ftp";
2
+ import path from "path";
3
+ import fs from 'fs';
4
+
5
+ export async function deployFtp() {
6
+ // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
7
+ const projectRoot = process.cwd();
8
+
9
+ // Arşivlenecek dosya ve klasörlerin yolları
10
+ const oraksoftJsonPath = path.join(projectRoot, '.env.oraksoft');
11
+
12
+ if (!fs.existsSync(oraksoftJsonPath)) {
13
+ console.error("Error: .env.oraksoft dosyası bulunamadı. Bu dosyayı oluşturup FTP bilgilerinizi ekleyin.");
14
+ process.exit(1);
15
+ }
16
+
17
+ const oraksoftJson = JSON.parse(fs.readFileSync(oraksoftJsonPath, 'utf-8'));
18
+
19
+ let ftpHost = oraksoftJson.ftp_host;
20
+ let ftpUser = oraksoftJson.ftp_user;
21
+ let ftpPassword = oraksoftJson.ftp_password;
22
+ let ftpSecure = oraksoftJson.ftp_secure || false;
23
+ let localFilePath1 = path.join(projectRoot, "dist", oraksoftJson.localFilePath);
24
+ let remoteFilePath1 = oraksoftJson.remoteFilePath;
25
+
26
+ if (!ftpHost || !ftpUser || !ftpPassword) {
27
+ console.error("Error: FTP bilgileri eksik. .env.oraksoft dosyasında ftp_host, ftp_user ve ftp_password alanlarını kontrol edin.");
28
+ process.exit(1);
29
+ }
30
+
31
+ const client = new Client();
32
+ client.ftp.verbose = true;
33
+
34
+ try {
35
+ await client.access({
36
+ host: ftpHost,
37
+ user: ftpUser,
38
+ password: ftpPassword,
39
+ secure: ftpSecure
40
+ });
41
+
42
+ const localFilePath = localFilePath1;
43
+ const remoteFilePath = remoteFilePath1;
44
+
45
+ if (!fs.existsSync(localFilePath)) {
46
+ console.error(`Error: Yerel dosya bulunamadı: ${localFilePath}`);
47
+ process.exit(1);
48
+ }
49
+
50
+ console.log(`Yükleniyor: ${localFilePath} -> ${remoteFilePath}`);
51
+ await client.uploadFrom(localFilePath, remoteFilePath);
52
+ console.log("✅ FTP yükleme tamamlandı!");
53
+ }
54
+ catch(err) {
55
+ console.error("❌ FTP Hatası:", err);
56
+ process.exit(1);
57
+ }
58
+ client.close();
59
+ }
@@ -0,0 +1,66 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import * as tar from 'tar';
4
+
5
+ export async function deployZip() {
6
+ // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
7
+ const projectRoot = process.cwd();
8
+
9
+ // Arşivlenecek dosya ve klasörlerin yolları
10
+ const packageJsonPath = path.join(projectRoot, 'package.json');
11
+
12
+ if (!fs.existsSync(packageJsonPath)) {
13
+ console.error("Error: package.json dosyası bulunamadı. Bu komutu bir Node.js projesi klasöründe çalıştırın.");
14
+ process.exit(1);
15
+ }
16
+
17
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
18
+
19
+ if (!packageJson.fiDeployZipContent || !Array.isArray(packageJson.fiDeployZipContent)) {
20
+ console.error("Error: 'fiDeployZipContent' alanı package.json içinde bir dizi olarak tanımlanmalıdır.");
21
+ process.exit(1);
22
+ }
23
+
24
+ const filesToArchive = packageJson.fiDeployZipContent;
25
+
26
+ // dist klasörü ve arşiv adı
27
+ const distDir = path.resolve(projectRoot, 'dist');
28
+ const archiveName = 'deployphp25.tar.gz';
29
+ const archivePath = path.join(distDir, archiveName);
30
+
31
+ // dist klasörü yoksa oluştur
32
+ if (!fs.existsSync(distDir)) {
33
+ fs.mkdirSync(distDir, { recursive: true });
34
+ }
35
+
36
+ // Arşiv oluştur
37
+ try {
38
+ await tar.c(
39
+ {
40
+ gzip: true,
41
+ file: archivePath,
42
+ cwd: projectRoot,
43
+ follow: true, // symlink/junction'ları takip et
44
+ filter: (path, stat) => {
45
+ // .git klasörlerini ve test dosyalarını hariç tut
46
+ const normalizedPath = path.replace(/\\/g, '/');
47
+ if (normalizedPath.includes('/.git/') || normalizedPath.includes('/.git') ||
48
+ normalizedPath.includes('/tests/') || normalizedPath.includes('/tests') ||
49
+ normalizedPath.includes('/fi-logs/') || normalizedPath.includes('/fi-logs') ||
50
+ normalizedPath.includes('/.github/') || normalizedPath.includes('/.github') ||
51
+ normalizedPath.endsWith('.md') || normalizedPath.endsWith('phpunit.xml.dist') ||
52
+ normalizedPath.endsWith('.gitignore') || normalizedPath.endsWith('.gitattributes')) {
53
+ console.log('Excluding:', path);
54
+ return false;
55
+ }
56
+ return true;
57
+ }
58
+ },
59
+ filesToArchive
60
+ );
61
+ console.log(`✅ Arşiv oluşturuldu: ${archivePath}`);
62
+ } catch (err) {
63
+ console.error('❌ Arşivleme hatası:', err);
64
+ process.exit(1);
65
+ }
66
+ }
@@ -0,0 +1,57 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ export function envChange() {
5
+ // Çalışma dizinini tespit et (komutun çalıştırıldığı yer)
6
+ const projectRoot = process.cwd();
7
+
8
+ // Arşivlenecek dosya ve klasörlerin yolları
9
+ const packageJsonPath = path.join(projectRoot, 'package.json');
10
+
11
+ let packageJson = {};
12
+ if (fs.existsSync(packageJsonPath)) {
13
+ packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
14
+ }
15
+
16
+ // Komut satırından argüman alma
17
+ // process.argv[0] = node executable
18
+ // process.argv[1] = script dosyası
19
+ // process.argv[2] = ilk argüman
20
+ const envArgument = process.argv[2];
21
+
22
+ let txEnv = envArgument || packageJson.fiEnvChangeStatus;
23
+
24
+ // Argüman kontrolü ve yardım mesajı
25
+ if (process.argv.includes('--help') || process.argv.includes('-h')) {
26
+ console.log('Kullanım: fi-env-change [ortam_adı]');
27
+ console.log('Örnek: fi-env-change dev');
28
+ console.log('Argüman verilmezse package.json\'daki fiEnvChangeStatus değeri kullanılır.');
29
+ process.exit(0);
30
+ }
31
+
32
+ if (!txEnv) {
33
+ console.error('❌ Ortam adı belirtilmedi ve package.json\'da fiEnvChangeStatus bulunamadı.');
34
+ console.log('Kullanım: fi-env-change [ortam_adı]');
35
+ process.exit(1);
36
+ }
37
+
38
+ try {
39
+ // .env dosyasının içeriğini .env.{txEnv} içeriğine eşitle
40
+ const envPath = path.join(projectRoot, '.env.' + txEnv);
41
+
42
+ if (!fs.existsSync(envPath)) {
43
+ console.error(`❌ Ortam dosyası bulunamadı: ${envPath}`);
44
+ process.exit(1);
45
+ }
46
+
47
+ const envContent = fs.readFileSync(envPath, 'utf-8');
48
+ fs.writeFileSync(path.join(projectRoot, '.env'), envContent);
49
+
50
+ // Başarı mesajı
51
+ console.log(`✅ Ortam dosyası başarıyla değiştirildi: .env.${txEnv} -> .env`);
52
+ console.log(`📁 Dosya yolu: ${path.join(projectRoot, '.env')}`);
53
+ } catch (error) {
54
+ console.error('❌ Ortam dosyası değiştirme hatası:', error.message);
55
+ process.exit(1);
56
+ }
57
+ }
package/lib/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { copyDeps } from './copy-deps.js';
2
+ export { deployFtp } from './deploy-ftp.js';
3
+ export { deployZip } from './deploy-zip.js';
4
+ export { envChange } from './env-change.js';
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "oraksoft-node-tools",
3
+ "version": "0.0.1",
4
+ "description": "CLI araçları koleksiyonu - fi-copy-deps, fi-deploy-ftp, fi-deploy-zip ve fi-env-change komutları",
5
+ "main": "lib/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "fi-copy-deps": "./bin/fi-copy-deps.js",
9
+ "fi-deploy-ftp": "./bin/fi-deploy-ftp.js",
10
+ "fi-deploy-zip": "./bin/fi-deploy-zip.js",
11
+ "fi-env-change": "./bin/fi-env-change.js"
12
+ },
13
+ "scripts": {
14
+ "test": "echo \"Error: no test specified\" && exit 1",
15
+ "prepublishOnly": "npm run build",
16
+ "build": "echo \"Build completed\""
17
+ },
18
+ "keywords": [
19
+ "cli",
20
+ "deploy",
21
+ "ftp",
22
+ "zip",
23
+ "copy-deps",
24
+ "env-change",
25
+ "oraksoft",
26
+ "development-tools"
27
+ ],
28
+ "author": "Oraksoft",
29
+ "license": "MIT",
30
+ "dependencies": {
31
+ "basic-ftp": "^5.0.5",
32
+ "tar": "^7.4.3"
33
+ },
34
+ "engines": {
35
+ "node": ">=14.0.0"
36
+ },
37
+ "preferGlobal": true,
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/engtuncay/oraksoft-node-tools.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/engtuncay/oraksoft-node-tools/issues"
44
+ },
45
+ "homepage": "https://github.com/engtuncay/oraksoft-node-tools#readme"
46
+ }