@chahuadev/chahuadev-hub-app 1.0.6 → 2.0.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 (3) hide show
  1. package/index.js +10 -16
  2. package/install.js +24 -47
  3. package/package.json +4 -4
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  'use strict';
3
3
  const path = require('path');
4
4
  const { spawnSync } = require('child_process');
@@ -9,21 +9,20 @@ const platform = os.platform();
9
9
  const arch = os.arch();
10
10
 
11
11
  let exeName = '';
12
-
13
12
  if (platform === 'win32') {
14
- exeName = 'chahuadev_hub.exe';
13
+ exeName = 'Chahuadev-Hub.exe';
15
14
  } else if (platform === 'linux') {
16
- exeName = 'chahuadev_hub';
15
+ exeName = 'Chahuadev-Hub.AppImage';
17
16
  } else {
18
- console.error(`❌ Chahuadev Hub does not support ${platform} ${arch} yet.`);
17
+ console.error(`Chahuadev Hub does not support ${platform} ${arch}`);
19
18
  process.exit(1);
20
19
  }
21
20
 
22
21
  const getPath = () => {
23
22
  const exePath = path.join(__dirname, 'bin', exeName);
24
23
  if (!fs.existsSync(exePath)) {
25
- console.error(`\n❌ Executable not found: ${exePath}`);
26
- console.error('👉 Try reinstalling: npm install -g @chahuadev/chahuadev-hub-app --foreground-scripts --force\n');
24
+ console.error(`Executable not found: ${exePath}`);
25
+ console.error('Try running "npm install" again to download the binary.');
27
26
  process.exit(1);
28
27
  }
29
28
  return exePath;
@@ -31,17 +30,12 @@ const getPath = () => {
31
30
 
32
31
  const run = () => {
33
32
  try {
34
- const exePath = getPath();
35
- const args = process.argv.slice(2);
36
- spawnSync(exePath, args, { stdio: 'inherit' });
33
+ spawnSync(getPath(), process.argv.slice(2), { stdio: 'inherit' });
37
34
  } catch (error) {
38
- console.error('Failed to start Chahuadev Hub:', error.message);
35
+ console.error('Failed to start Chahuadev Hub:', error.message);
39
36
  process.exit(1);
40
37
  }
41
38
  };
42
39
 
43
- if (require.main === module) {
44
- run();
45
- } else {
46
- module.exports = { run, getPath };
47
- }
40
+ if (require.main === module) run();
41
+ else module.exports = { run, getPath };
package/install.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ 'use strict';
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
4
  const https = require('https');
@@ -7,92 +7,69 @@ const os = require('os');
7
7
  const platform = os.platform();
8
8
  const arch = os.arch();
9
9
 
10
+ const R2_BASE = 'https://pub-419d22521da042dfb27d1f404b3eb8a6.r2.dev';
11
+
10
12
  let downloadUrl = '';
11
13
  let fileName = '';
12
14
 
13
15
  if (platform === 'win32') {
14
- // ชื่อไฟล์ตรงกับที่ PyInstaller build ออกมา
15
- downloadUrl = 'https://huggingface.co/datasets/chahuadev/chahuadev-framework-binaries/resolve/main/chahuadev_hub.exe?download=true';
16
- fileName = 'chahuadev_hub.exe';
16
+ downloadUrl = `${R2_BASE}/Chahuadev-Hub.exe`;
17
+ fileName = 'Chahuadev-Hub.exe';
17
18
  } else if (platform === 'linux') {
18
- downloadUrl = 'https://huggingface.co/datasets/chahuadev/chahuadev-framework-binaries/resolve/main/chahuadev_hub?download=true';
19
- fileName = 'chahuadev_hub';
20
- }
21
-
22
- if (!downloadUrl) {
23
- console.warn(`\n⚠️ Skipping download: Chahuadev Hub does not support ${platform} ${arch} yet.`);
19
+ downloadUrl = `${R2_BASE}/Chahuadev-Hub.AppImage`;
20
+ fileName = 'Chahuadev-Hub.AppImage';
21
+ } else {
22
+ console.warn(`Chahuadev Hub does not support ${platform} ${arch} yet.`);
24
23
  process.exit(0);
25
24
  }
26
25
 
27
26
  const binDir = path.join(__dirname, 'bin');
28
- if (!fs.existsSync(binDir)) {
29
- fs.mkdirSync(binDir, { recursive: true });
30
- }
27
+ if (!fs.existsSync(binDir)) fs.mkdirSync(binDir, { recursive: true });
31
28
 
32
29
  const filePath = path.join(binDir, fileName);
33
-
34
- console.log(`\n🚀 Chahuadev Hub Downloading binary for ${platform} (${arch})...`);
35
- console.log(`⏳ Please wait, this may take a few minutes depending on your connection.\n`);
30
+ console.log(`\nChahuadev Hub -- Downloading binary for ${platform} (${arch})...`);
31
+ console.log('Please wait, this may take a few minutes.\n');
36
32
 
37
33
  function downloadFile(url, dest) {
38
34
  https.get(url, (response) => {
39
35
  if (response.statusCode === 301 || response.statusCode === 302) {
40
36
  return downloadFile(response.headers.location, dest);
41
37
  }
42
-
43
38
  if (response.statusCode !== 200) {
44
- console.error(`\n❌ Download failed: HTTP ${response.statusCode}`);
39
+ console.error(`Download failed: HTTP ${response.statusCode}`);
45
40
  process.exit(1);
46
41
  }
47
-
48
42
  const totalBytes = parseInt(response.headers['content-length'], 10);
49
43
  let downloadedBytes = 0;
50
-
51
44
  const file = fs.createWriteStream(dest);
52
-
53
45
  response.on('data', (chunk) => {
54
46
  downloadedBytes += chunk.length;
55
-
56
47
  if (!isNaN(totalBytes)) {
57
48
  const percent = ((downloadedBytes / totalBytes) * 100).toFixed(1);
58
- const downloadedMB = (downloadedBytes / (1024 * 1024)).toFixed(1);
49
+ const dlMB = (downloadedBytes / (1024 * 1024)).toFixed(1);
59
50
  const totalMB = (totalBytes / (1024 * 1024)).toFixed(1);
60
-
61
- const barLength = 30;
62
- const filledLength = Math.round((barLength * downloadedBytes) / totalBytes);
63
- const bar = '█'.repeat(filledLength) + '░'.repeat(barLength - filledLength);
64
-
65
- process.stdout.write(`\r[${bar}] ${percent}% (${downloadedMB} MB / ${totalMB} MB)`);
51
+ const filled = Math.round(30 * downloadedBytes / totalBytes);
52
+ const bar = '#'.repeat(filled) + '-'.repeat(30 - filled);
53
+ process.stdout.write(`\r[${bar}] ${percent}% (${dlMB} MB / ${totalMB} MB)`);
66
54
  } else {
67
- const downloadedMB = (downloadedBytes / (1024 * 1024)).toFixed(1);
68
- process.stdout.write(`\rDownloading... ${downloadedMB} MB`);
55
+ process.stdout.write(`\rDownloading... ${(downloadedBytes / (1024 * 1024)).toFixed(1)} MB`);
69
56
  }
70
57
  });
71
-
72
58
  response.pipe(file);
73
-
74
59
  file.on('finish', () => {
75
60
  file.close();
76
- console.log('\n');
77
- console.log('✅ Download completed successfully!');
78
- console.log(`📂 Saved to: ${dest}`);
79
- console.log('');
80
- console.log('🚀 Launch the app with:');
61
+ console.log('\n\nDownload completed.');
62
+ console.log(`Saved to: ${dest}`);
63
+ console.log('\nLaunch the app with:');
81
64
  console.log(' chahuadev-hub');
82
65
  console.log(' npx @chahuadev/chahuadev-hub-app\n');
83
-
84
- // Make executable on Linux/macOS
85
- if (platform !== 'win32') {
86
- fs.chmodSync(dest, 0o755);
87
- console.log(' chmod +x applied');
88
- }
66
+ if (platform !== 'win32') fs.chmodSync(dest, 0o755);
89
67
  });
90
-
91
68
  }).on('error', (err) => {
92
69
  fs.unlink(dest, () => {});
93
- console.error('\n❌ Download failed:', err.message);
70
+ console.error('\nDownload failed:', err.message);
94
71
  process.exit(1);
95
72
  });
96
73
  }
97
74
 
98
- downloadFile(downloadUrl, filePath);
75
+ downloadFile(downloadUrl, filePath);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
- {
1
+ {
2
2
  "name": "@chahuadev/chahuadev-hub-app",
3
- "version": "1.0.6",
4
- "description": "Chahuadev Hub Official app launcher and distribution hub by Chahuadev",
3
+ "version": "2.0.0",
4
+ "description": "Chahuadev Hub โ€” Official app launcher and distribution hub by Chahuadev",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "chahuadev-hub": "index.js"
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",
36
- "url": "https://huggingface.co/datasets/chahuadev/chahuadev-framework-binaries"
36
+ "url": "https://huggingface.co/datasets/chahuadev/chahuadev-hub"
37
37
  },
38
38
  "homepage": "https://huggingface.co/chahuadev"
39
39
  }