@chahuadev/chahuadev-hub-app 1.0.2 → 1.0.4

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 +59 -1
  2. package/index.js +47 -47
  3. package/install.js +98 -98
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -54,10 +54,68 @@ sudo npm install -g @chahuadev/chahuadev-hub-app --foreground-scripts --force
54
54
  ```bash
55
55
  chahuadev-hub
56
56
  ```
57
+ > **If the command fails, run the binary directly from the install folder:**
58
+ >
59
+ > ```bash
60
+ > # With ~/.npm-global prefix (no-sudo install)
61
+ > ~/.npm-global/lib/node_modules/@chahuadev/chahuadev-hub-app/bin/chahuadev_hub
62
+ >
63
+ > # Or navigate into the folder first
64
+ > cd ~/.npm-global/lib/node_modules/@chahuadev/chahuadev-hub-app/bin
65
+ > ./chahuadev_hub
66
+ > ```
67
+ >
68
+ > For sudo installs, the folder is usually under `/usr/lib/node_modules/` or `/usr/local/lib/node_modules/`:
69
+ > ```bash
70
+ > /usr/local/lib/node_modules/@chahuadev/chahuadev-hub-app/bin/chahuadev_hub
71
+ > ```
72
+ ---
73
+
74
+ ## �️ Troubleshooting
75
+
76
+ ### `node\r: No such file or directory` error (Linux)
77
+
78
+ This means the installed `index.js` has Windows line endings (CRLF). Fixed in v1.0.4+.
79
+ If you're on an older version, reinstall:
80
+
81
+ ```bash
82
+ rm -rf ~/.npm-global/lib/node_modules/@chahuadev/chahuadev-hub-app
83
+ npm install -g @chahuadev/chahuadev-hub-app --foreground-scripts --force
84
+ ```
85
+
86
+ Or run the binary directly without going through the Node wrapper:
87
+
88
+ ```bash
89
+ ~/.npm-global/lib/node_modules/@chahuadev/chahuadev-hub-app/bin/chahuadev_hub
90
+ ```
91
+
92
+ ### ENOTEMPTY error on Linux (directory not empty)
93
+
94
+ If you see `ENOTEMPTY` during install, a previous failed install left files behind. Clear them first:
95
+
96
+ ```bash
97
+ # If installed with npm-global prefix
98
+ rm -rf ~/.npm-global/lib/node_modules/@chahuadev/chahuadev-hub-app
99
+ npm install -g @chahuadev/chahuadev-hub-app --foreground-scripts --force
100
+
101
+ # If installed with sudo
102
+ sudo rm -rf /usr/lib/node_modules/@chahuadev/chahuadev-hub-app
103
+ sudo npm install -g @chahuadev/chahuadev-hub-app --foreground-scripts --force
104
+ ```
105
+
106
+ ### Executable not found after install
107
+
108
+ If `chahuadev-hub` command is not found after install, make sure `~/.npm-global/bin` is in your PATH:
109
+
110
+ ```bash
111
+ echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
112
+ source ~/.bashrc
113
+ chahuadev-hub
114
+ ```
57
115
 
58
116
  ---
59
117
 
60
- ## 🚀 What It Does
118
+ ## �🚀 What It Does
61
119
 
62
120
  Download and manage all Chahuadev apps in one place — including **Chahuadev Framework**, **Emoji Cleaner**, and **Junk Sweeper** — through a sleek dark-mode GUI.
63
121
 
package/index.js CHANGED
@@ -1,47 +1,47 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
- const path = require('path');
4
- const { spawnSync } = require('child_process');
5
- const os = require('os');
6
- const fs = require('fs');
7
-
8
- const platform = os.platform();
9
- const arch = os.arch();
10
-
11
- let exeName = '';
12
-
13
- if (platform === 'win32') {
14
- exeName = 'chahuadev_hub.exe';
15
- } else if (platform === 'linux') {
16
- exeName = 'chahuadev_hub';
17
- } else {
18
- console.error(`❌ Chahuadev Hub does not support ${platform} ${arch} yet.`);
19
- process.exit(1);
20
- }
21
-
22
- const getPath = () => {
23
- const exePath = path.join(__dirname, 'bin', exeName);
24
- 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');
27
- process.exit(1);
28
- }
29
- return exePath;
30
- };
31
-
32
- const run = () => {
33
- try {
34
- const exePath = getPath();
35
- const args = process.argv.slice(2);
36
- spawnSync(exePath, args, { stdio: 'inherit' });
37
- } catch (error) {
38
- console.error('❌ Failed to start Chahuadev Hub:', error.message);
39
- process.exit(1);
40
- }
41
- };
42
-
43
- if (require.main === module) {
44
- run();
45
- } else {
46
- module.exports = { run, getPath };
47
- }
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ const path = require('path');
4
+ const { spawnSync } = require('child_process');
5
+ const os = require('os');
6
+ const fs = require('fs');
7
+
8
+ const platform = os.platform();
9
+ const arch = os.arch();
10
+
11
+ let exeName = '';
12
+
13
+ if (platform === 'win32') {
14
+ exeName = 'chahuadev_hub.exe';
15
+ } else if (platform === 'linux') {
16
+ exeName = 'chahuadev_hub';
17
+ } else {
18
+ console.error(`❌ Chahuadev Hub does not support ${platform} ${arch} yet.`);
19
+ process.exit(1);
20
+ }
21
+
22
+ const getPath = () => {
23
+ const exePath = path.join(__dirname, 'bin', exeName);
24
+ 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');
27
+ process.exit(1);
28
+ }
29
+ return exePath;
30
+ };
31
+
32
+ const run = () => {
33
+ try {
34
+ const exePath = getPath();
35
+ const args = process.argv.slice(2);
36
+ spawnSync(exePath, args, { stdio: 'inherit' });
37
+ } catch (error) {
38
+ console.error('❌ Failed to start Chahuadev Hub:', error.message);
39
+ process.exit(1);
40
+ }
41
+ };
42
+
43
+ if (require.main === module) {
44
+ run();
45
+ } else {
46
+ module.exports = { run, getPath };
47
+ }
package/install.js CHANGED
@@ -1,98 +1,98 @@
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
- let downloadUrl = '';
11
- let fileName = '';
12
-
13
- 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';
17
- } 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.`);
24
- process.exit(0);
25
- }
26
-
27
- const binDir = path.join(__dirname, 'bin');
28
- if (!fs.existsSync(binDir)) {
29
- fs.mkdirSync(binDir, { recursive: true });
30
- }
31
-
32
- 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`);
36
-
37
- function downloadFile(url, dest) {
38
- https.get(url, (response) => {
39
- if (response.statusCode === 301 || response.statusCode === 302) {
40
- return downloadFile(response.headers.location, dest);
41
- }
42
-
43
- if (response.statusCode !== 200) {
44
- console.error(`\n❌ Download failed: HTTP ${response.statusCode}`);
45
- process.exit(1);
46
- }
47
-
48
- const totalBytes = parseInt(response.headers['content-length'], 10);
49
- let downloadedBytes = 0;
50
-
51
- const file = fs.createWriteStream(dest);
52
-
53
- response.on('data', (chunk) => {
54
- downloadedBytes += chunk.length;
55
-
56
- if (!isNaN(totalBytes)) {
57
- const percent = ((downloadedBytes / totalBytes) * 100).toFixed(1);
58
- const downloadedMB = (downloadedBytes / (1024 * 1024)).toFixed(1);
59
- 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)`);
66
- } else {
67
- const downloadedMB = (downloadedBytes / (1024 * 1024)).toFixed(1);
68
- process.stdout.write(`\rDownloading... ${downloadedMB} MB`);
69
- }
70
- });
71
-
72
- response.pipe(file);
73
-
74
- file.on('finish', () => {
75
- 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:');
81
- console.log(' chahuadev-hub');
82
- 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
- }
89
- });
90
-
91
- }).on('error', (err) => {
92
- fs.unlink(dest, () => {});
93
- console.error('\n❌ Download failed:', err.message);
94
- process.exit(1);
95
- });
96
- }
97
-
98
- downloadFile(downloadUrl, filePath);
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
+ let downloadUrl = '';
11
+ let fileName = '';
12
+
13
+ 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';
17
+ } 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.`);
24
+ process.exit(0);
25
+ }
26
+
27
+ const binDir = path.join(__dirname, 'bin');
28
+ if (!fs.existsSync(binDir)) {
29
+ fs.mkdirSync(binDir, { recursive: true });
30
+ }
31
+
32
+ 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`);
36
+
37
+ function downloadFile(url, dest) {
38
+ https.get(url, (response) => {
39
+ if (response.statusCode === 301 || response.statusCode === 302) {
40
+ return downloadFile(response.headers.location, dest);
41
+ }
42
+
43
+ if (response.statusCode !== 200) {
44
+ console.error(`\n❌ Download failed: HTTP ${response.statusCode}`);
45
+ process.exit(1);
46
+ }
47
+
48
+ const totalBytes = parseInt(response.headers['content-length'], 10);
49
+ let downloadedBytes = 0;
50
+
51
+ const file = fs.createWriteStream(dest);
52
+
53
+ response.on('data', (chunk) => {
54
+ downloadedBytes += chunk.length;
55
+
56
+ if (!isNaN(totalBytes)) {
57
+ const percent = ((downloadedBytes / totalBytes) * 100).toFixed(1);
58
+ const downloadedMB = (downloadedBytes / (1024 * 1024)).toFixed(1);
59
+ 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)`);
66
+ } else {
67
+ const downloadedMB = (downloadedBytes / (1024 * 1024)).toFixed(1);
68
+ process.stdout.write(`\rDownloading... ${downloadedMB} MB`);
69
+ }
70
+ });
71
+
72
+ response.pipe(file);
73
+
74
+ file.on('finish', () => {
75
+ 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:');
81
+ console.log(' chahuadev-hub');
82
+ 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
+ }
89
+ });
90
+
91
+ }).on('error', (err) => {
92
+ fs.unlink(dest, () => {});
93
+ console.error('\n❌ Download failed:', err.message);
94
+ process.exit(1);
95
+ });
96
+ }
97
+
98
+ downloadFile(downloadUrl, filePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chahuadev/chahuadev-hub-app",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Chahuadev Hub — Official app launcher and distribution hub by Chahuadev",
5
5
  "main": "index.js",
6
6
  "bin": {