@chahuadev/framework 5.0.6 → 5.1.0

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.
Files changed (4) hide show
  1. package/README.md +2 -1
  2. package/index.js +26 -31
  3. package/install.js +71 -97
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -5,12 +5,13 @@ The official core executable framework for Chahuadev.
5
5
  <div align="center">
6
6
 
7
7
  <p align="center">
8
- <img src="https://huggingface.co/datasets/chahuadev/chahuadev-framework-binaries/resolve/main/chahuadev-framework-binaries.png" width="600" alt="Chahuadev Framework">
8
+ <img src="https://huggingface.co/datasets/chahuadev/chahuadev-emoji-cleaner-tool/blob/main/chahuadev-framework.png" width="600" alt="Chahuadev Framework">
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
12
  <a href="https://www.npmjs.com/package/@chahuadev/framework"><img src="https://img.shields.io/npm/v/@chahuadev/framework?style=for-the-badge&color=blue" alt="NPM Version"></a>
13
13
  <a href="https://www.npmjs.com/package/@chahuadev/framework"><img src="https://img.shields.io/npm/dt/@chahuadev/framework?style=for-the-badge&color=success" alt="NPM Downloads"></a>
14
+ <a href="https://huggingface.co/datasets/chahuadev/chahuadev-framework-binaries"><img src="https://img.shields.io/badge/Hugging%20Face-Dataset-FFD21E?style=for-the-badge" alt="Hugging Face Dataset"></a>
14
15
  </p>
15
16
 
16
17
  > ⏳ **Development Journey:** This framework is the proud result of **1 full year of dedicated development**. What began as a simple concept evolved into a highly advanced, secure, and robust architecture. Every line of code was meticulously crafted to ensure maximum stability and a premium experience for developers.
package/index.js CHANGED
@@ -1,31 +1,26 @@
1
- #!/usr/bin/env node
2
- const path = require('path');
3
- const { spawnSync } = require('child_process');
4
- const fs = require('fs');
5
- const os = require('os');
6
-
7
- const platform = os.platform();
8
- const arch = os.arch();
9
- let exeName = '';
10
-
11
- if (platform === 'win32') {
12
- exeName = arch === 'ia32' ? 'Chahuadev Framework-win-ia32.exe' : 'Chahuadev Framework-win-x64.exe';
13
- } else if (platform === 'linux') {
14
- exeName = 'Chahuadev Framework.AppImage';
15
- } else {
16
- console.error(`Unsupported platform: ${platform}`);
17
- process.exit(1);
18
- }
19
-
20
- const exePath = path.join(__dirname, 'bin', exeName);
21
-
22
- if (!fs.existsSync(exePath)) {
23
- console.error(`Executable not found: ${exePath}`);
24
- console.error('Try running "npm install" again to download the binary.');
25
- process.exit(1);
26
- }
27
-
28
- const args = process.argv.slice(2);
29
- const result = spawnSync(exePath, args, { stdio: 'inherit' });
30
-
31
- process.exit(result.status || 0);
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ const path = require('path');
4
+ const { spawnSync } = require('child_process');
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+
8
+ const platform = os.platform();
9
+ let exeName = '';
10
+
11
+ if (platform === 'win32') {
12
+ exeName = 'Chahuadev-Framework.exe';
13
+ } else {
14
+ console.error(`Chahuadev Framework does not support ${platform} yet.`);
15
+ process.exit(1);
16
+ }
17
+
18
+ const exePath = path.join(__dirname, 'bin', exeName);
19
+ if (!fs.existsSync(exePath)) {
20
+ console.error(`Executable not found: ${exePath}`);
21
+ console.error('Try running "npm install" again to download the binary.');
22
+ process.exit(1);
23
+ }
24
+
25
+ const result = spawnSync(exePath, process.argv.slice(2), { stdio: 'inherit' });
26
+ process.exit(result.status ?? 0);
package/install.js CHANGED
@@ -1,98 +1,72 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const https = require('https');
4
- const os = require('os');
5
-
6
- const platform = os.platform();
7
- const arch = os.arch();
8
-
9
- let downloadUrl = '';
10
- let fileName = '';
11
-
12
- // 1. เช็ก OS เพื่อเลือกลิงก์ดาวน์โหลด
13
- if (platform === 'win32') {
14
- if (arch === 'ia32') {
15
- downloadUrl = 'https://huggingface.co/datasets/chahuadev/chahuadev-framework-binaries/resolve/main/Chahuadev%20Framework-win-ia32.exe?download=true';
16
- fileName = 'Chahuadev Framework-win-ia32.exe';
17
- } else if (arch === 'x64') {
18
- downloadUrl = 'https://huggingface.co/datasets/chahuadev/chahuadev-framework-binaries/resolve/main/Chahuadev%20Framework-win-x64.exe?download=true';
19
- fileName = 'Chahuadev Framework-win-x64.exe';
20
- }
21
- } else if (platform === 'linux') {
22
- downloadUrl = 'https://huggingface.co/datasets/chahuadev/chahuadev-framework-binaries/resolve/main/Chahuadev%20Framework.AppImage?download=true';
23
- fileName = 'Chahuadev Framework.AppImage';
24
- }
25
-
26
- if (!downloadUrl) {
27
- console.error(`Error: Chahuadev Framework does not support ${platform} ${arch}`);
28
- process.exit(1);
29
- }
30
-
31
- // 2. สร้างโฟลเดอร์ bin เพื่อเก็บไฟล์ที่โหลดมา
32
- const binDir = path.join(__dirname, 'bin');
33
- if (!fs.existsSync(binDir)) {
34
- fs.mkdirSync(binDir);
35
- }
36
-
37
- const filePath = path.join(binDir, fileName);
38
- console.log(`Downloading Chahuadev Framework for ${platform} (${arch})...`);
39
- console.log(`Please wait, this may take a few minutes depending on your connection.\n`);
40
-
41
- // 3. ฟังก์ชันดาวน์โหลดพร้อมระบบโชว์ Progress Bar
42
- function downloadFile(url, dest) {
43
- https.get(url, (response) => {
44
- // จัดการกรณีลิงก์ถูก Redirect
45
- if (response.statusCode === 301 || response.statusCode === 302) {
46
- return downloadFile(response.headers.location, dest);
47
- }
48
-
49
- // ดึงขนาดไฟล์ทั้งหมดมาเพื่อคำนวณ %
50
- const totalBytes = parseInt(response.headers['content-length'], 10);
51
- let downloadedBytes = 0;
52
-
53
- const file = fs.createWriteStream(dest);
54
-
55
- // ดักจับข้อมูลตอนที่กำลังโหลดทีละก้อน (chunk)
56
- response.on('data', (chunk) => {
57
- downloadedBytes += chunk.length;
58
-
59
- if (!isNaN(totalBytes)) {
60
- // คำนวณเปอร์เซ็นต์
61
- const percent = ((downloadedBytes / totalBytes) * 100).toFixed(2);
62
- const downloadedMB = (downloadedBytes / (1024 * 1024)).toFixed(2);
63
- const totalMB = (totalBytes / (1024 * 1024)).toFixed(2);
64
-
65
- // วาดหลอด Progress Bar
66
- const barLength = 30;
67
- const filledLength = Math.round((barLength * downloadedBytes) / totalBytes);
68
- const bar = '█'.repeat(filledLength) + '-'.repeat(barLength - filledLength);
69
-
70
- process.stdout.write(`\r[${bar}] ${percent}% (${downloadedMB} MB / ${totalMB} MB)`);
71
- } else {
72
- const downloadedMB = (downloadedBytes / (1024 * 1024)).toFixed(2);
73
- process.stdout.write(`\rDownloading... ${downloadedMB} MB`);
74
- }
75
- });
76
-
77
- response.pipe(file);
78
-
79
- file.on('finish', () => {
80
- file.close();
81
- console.log('\n\n✅ Download completed successfully!');
82
-
83
- // *** ชี้เป้าหมายที่อยู่ไฟล์แบบชัดเจน ***
84
- console.log(`📂 File saved to: ${dest}\n`);
85
-
86
- // ให้สิทธิ์รันบน Linux
87
- if (platform !== 'win32') fs.chmodSync(dest, 0o755);
88
- });
89
-
90
- }).on('error', (err) => {
91
- fs.unlink(dest, () => {}); // ถ้า error ให้ลบไฟล์ที่โหลดค้างทิ้ง
92
- console.error('\n❌ Download failed:', err.message);
93
- process.exit(1);
94
- });
95
- }
96
-
97
- // เริ่มดาวน์โหลด
1
+ 'use strict';
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const https = require('https');
5
+ const os = require('os');
6
+
7
+ const platform = os.platform();
8
+ const arch = os.arch();
9
+
10
+ const R2_BASE = 'https://pub-419d22521da042dfb27d1f404b3eb8a6.r2.dev';
11
+
12
+ let downloadUrl = '';
13
+ let fileName = '';
14
+
15
+ if (platform === 'win32') {
16
+ downloadUrl = `${R2_BASE}/Chahuadev-Framework.exe`;
17
+ fileName = 'Chahuadev-Framework.exe';
18
+ } else {
19
+ console.warn(`Chahuadev Framework does not have a binary for ${platform} ${arch} yet.`);
20
+ process.exit(0);
21
+ }
22
+
23
+ const binDir = path.join(__dirname, 'bin');
24
+ if (!fs.existsSync(binDir)) fs.mkdirSync(binDir, { recursive: true });
25
+
26
+ const filePath = path.join(binDir, fileName);
27
+ console.log(`Downloading Chahuadev Framework for ${platform} (${arch})...`);
28
+ console.log('Please wait, this may take a few minutes.\n');
29
+
30
+ function downloadFile(url, dest) {
31
+ https.get(url, (response) => {
32
+ if (response.statusCode === 301 || response.statusCode === 302) {
33
+ return downloadFile(response.headers.location, dest);
34
+ }
35
+ if (response.statusCode !== 200) {
36
+ console.error(`Download failed: HTTP ${response.statusCode}`);
37
+ process.exit(1);
38
+ }
39
+
40
+ const totalBytes = parseInt(response.headers['content-length'], 10);
41
+ let downloadedBytes = 0;
42
+ const file = fs.createWriteStream(dest);
43
+
44
+ response.on('data', (chunk) => {
45
+ downloadedBytes += chunk.length;
46
+ if (!isNaN(totalBytes)) {
47
+ const percent = ((downloadedBytes / totalBytes) * 100).toFixed(1);
48
+ const dlMB = (downloadedBytes / (1024 * 1024)).toFixed(1);
49
+ const totalMB = (totalBytes / (1024 * 1024)).toFixed(1);
50
+ const filled = Math.round(30 * downloadedBytes / totalBytes);
51
+ const bar = '#'.repeat(filled) + '-'.repeat(30 - filled);
52
+ process.stdout.write(`\r[${bar}] ${percent}% (${dlMB} MB / ${totalMB} MB)`);
53
+ } else {
54
+ process.stdout.write(`\rDownloading... ${(downloadedBytes / (1024 * 1024)).toFixed(1)} MB`);
55
+ }
56
+ });
57
+
58
+ response.pipe(file);
59
+ file.on('finish', () => {
60
+ file.close();
61
+ console.log('\n\nDownload completed.');
62
+ console.log(`Saved to: ${dest}\n`);
63
+ if (platform !== 'win32') fs.chmodSync(dest, 0o755);
64
+ });
65
+ }).on('error', (err) => {
66
+ fs.unlink(dest, () => {});
67
+ console.error('\nDownload failed:', err.message);
68
+ process.exit(1);
69
+ });
70
+ }
71
+
98
72
  downloadFile(downloadUrl, filePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chahuadev/framework",
3
- "version": "5.0.6",
3
+ "version": "5.1.0",
4
4
  "description": "Chahuadev Framework",
5
5
  "main": "index.js",
6
6
  "bin": {