@chahuadev/framework 1.0.10 → 3.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/README.md +112 -24
  2. package/index.js +96 -12
  3. package/package.json +7 -3
package/README.md CHANGED
@@ -8,60 +8,148 @@ The official core executable framework for Chahuadev.
8
8
 
9
9
  This package provides a seamless way to integrate and run the Chahuadev Framework directly from your Node.js environment or Command Line Interface (CLI).
10
10
 
11
- > **Note:** Currently, this framework is optimized exclusively for **Windows (x64)** architecture.
11
+ > **Multi-Platform Support:** This framework runs on **Windows (x64, ia32)** and **Linux (x64)**.
12
+ > Our system automatically detects your operating system and downloads the required binary behind the scenes.
12
13
 
13
14
  ---
14
15
 
15
16
  ## Installation
16
17
 
17
- You only need to install this main package. Our system uses `optionalDependencies` to automatically detect your operating system and securely download the required Windows binary (`.exe`) behind the scenes.
18
-
19
18
  ### Global Install (Recommended for CLI)
20
- If you want to use the framework directly from your terminal anywhere on your system:
19
+ If you want to use the framework from your terminal anywhere on your system:
21
20
 
22
21
  ```bash
23
22
  npm install -g @chahuadev/framework
24
23
  ```
24
+
25
+ After installation, simply launch it:
26
+ ```bash
27
+ chahuadev-framework
28
+ ```
29
+
30
+ The framework will:
31
+ Auto-detect your OS (Windows 32/64-bit or Linux x64)
32
+ Load the appropriate executable (.exe for Windows, AppImage for Linux)
33
+ Start immediately without any configuration
34
+
25
35
  ### Local Install (For Node.js projects)
26
36
  If you want to integrate the framework into your specific project:
27
37
 
28
- Bash
29
38
  ```bash
30
39
  npm install @chahuadev/framework
31
40
  ```
32
41
 
33
- ### 💻 Usage
34
- You can use the Chahuadev Framework either via Command Line or programmatically in your Node.js code.
42
+ ---
43
+
44
+ ## Usage
35
45
 
36
46
  ### 1. Command Line Interface (CLI)
37
- If installed globally, you can launch the application by simply typing:
47
+ If installed globally:
38
48
 
39
- Bash
49
+ ```bash
50
+ # Simple launch
40
51
  chahuadev-framework
41
- (You can also pass arguments directly, e.g., chahuadev-framework --start)
52
+
53
+ # With arguments
54
+ chahuadev-framework --dev-mode
55
+ chahuadev-framework --help
56
+ ```
42
57
 
43
58
  ### 2. Node.js API
44
- If installed locally in your project, you can require and run it via code:
59
+ If installed locally in your project:
45
60
 
46
- ```JavaScript
47
- const chf = require('@chahuadev/framework');
61
+ ```javascript
62
+ const framework = require('@chahuadev/framework');
48
63
 
49
- // Launch the application
50
- chf.run();
64
+ // The framework will auto-detect and run with appropriate binary
65
+ framework.run();
51
66
 
52
- // Or if you just need the absolute path to the .exe file
53
- const exePath = chf.getPath();
54
- console.log('Executable is located at:', exePath);
67
+ // Get path to the executable
68
+ const path = framework.getExecutablePath();
69
+ console.log('Executable:', path);
55
70
  ```
56
71
 
57
- ### Platform Support
58
- OS: Windows (win32)
72
+ ---
73
+
74
+ ## How It Works
75
+
76
+ This package uses **`optionalDependencies`** to handle platform-specific binaries:
77
+
78
+ ```json
79
+ {
80
+ "optionalDependencies": {
81
+ "@chahuadev/framework-win32-x64": "^1.1.0",
82
+ "@chahuadev/framework-win32-ia32": "^1.1.0",
83
+ "@chahuadev/framework-linux-x64": "^1.1.0"
84
+ }
85
+ }
86
+ ```
87
+
88
+ **When you install:**
89
+ 1. npm detects your OS and architecture
90
+ 2. Installs only the required platform-specific package
91
+ 3. index.js routes to the correct executable
59
92
 
60
- Architecture: 64-bit (x64) only
93
+ This ensures:
94
+ - Minimal disk space usage (only your OS binary)
95
+ - No cross-platform conflicts
96
+ - Automatic binary selection
61
97
 
62
- If you attempt to install or run this on Mac or Linux, it will safely exit and notify you of the platform requirement.
98
+ ---
99
+
100
+ ## Platform Support
101
+
102
+ | Platform | Architecture | Status | Format |
103
+ |----------|-------------|--------|--------|
104
+ | Windows | 64-bit (x64) | Supported | EXE/MSI |
105
+ | Windows | 32-bit (ia32) | Supported | EXE/MSI |
106
+ | Linux | 64-bit (x64) | Supported | AppImage |
107
+ | macOS | Intel (x64) | Coming Soon | DMG/App |
108
+ | macOS | Apple Silicon (arm64) | Coming Soon | DMG/App |
109
+
110
+ ---
63
111
 
64
- ### License
112
+ ## Package Structure
113
+
114
+ ```
115
+ @chahuadev/
116
+ ├── framework/ ← Main package (you install this)
117
+ │ └── index.js (Auto-detects OS and routes to correct binary)
118
+ ├── framework-win32-x64/
119
+ │ └── bin/ (Windows 64-bit executables)
120
+ ├── framework-win32-ia32/
121
+ │ └── bin/ (Windows 32-bit executables)
122
+ └── framework-linux-x64/
123
+ └── bin/ (Linux x64 AppImage)
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Troubleshooting
129
+
130
+ ### "Command not found: chahuadev-framework"
131
+ Make sure you installed globally:
132
+ ```bash
133
+ npm install -g @chahuadev/framework
134
+ ```
135
+
136
+ ### "Module not found"
137
+ If using locally, ensure it's installed:
138
+ ```bash
139
+ npm install @chahuadev/framework
140
+ ```
141
+
142
+ ### "Unsupported platform"
143
+ Your OS/architecture combination is not yet supported. Check the Platform Support table above.
144
+
145
+ ---
146
+
147
+ ## License
65
148
  Proprietary - Chahua Development Thailand
66
- #
149
+
150
+ ---
151
+
152
+ ## Support
153
+ For issues or questions, visit: https://github.com/chahuadev/chahuadev-framework
154
+
67
155
 
package/index.js CHANGED
@@ -3,24 +3,108 @@ const path = require('path');
3
3
  const { spawnSync } = require('child_process');
4
4
  const os = require('os');
5
5
 
6
- // เช็คว่าใช่ Windows x64 หรือไม่
7
- if (os.platform() !== 'win32' || os.arch() !== 'x64') {
8
- console.error('Error: Chahuadev Framework currently only supports Windows x64.');
6
+ // Define OS and architecture mapping
7
+ const platform = os.platform();
8
+ const arch = os.arch();
9
+ const packageMap = {
10
+ 'win32-x64': '@chahuadev/framework-win32-x64',
11
+ 'win32-ia32': '@chahuadev/framework-win32-ia32',
12
+ 'linux-x64': '@chahuadev/framework-linux',
13
+ 'linux-arm64': '@chahuadev/framework-linux',
14
+ 'darwin-x64': '@chahuadev/framework-darwin-x64',
15
+ 'darwin-arm64': '@chahuadev/framework-darwin-arm64',
16
+ };
17
+
18
+ // Determine which package to use based on OS and architecture
19
+ const packageKey = `${platform}-${arch}`;
20
+ const packageName = packageMap[packageKey];
21
+
22
+ if (!packageName) {
23
+ const supportedPlatforms = Object.keys(packageMap).join(', ');
24
+ console.error(`Error: Chahuadev Framework does not support ${platform} ${arch} (${platform}-${arch}).`);
25
+ console.error(`Supported platforms: ${supportedPlatforms}`);
9
26
  process.exit(1);
10
27
  }
11
28
 
12
29
  try {
13
- // หา Path ของไฟล์ .exe จากแพ็กเกจย่อยที่เราตั้งไว้ใน optionalDependencies
14
- const exePath = path.join(
15
- require.resolve('@chahuadev/framework-win32-x64/package.json'),
16
- '../bin/chahuadev-framework.exe'
17
- );
18
-
19
- // รันไฟล์ .exe และส่งต่อคำสั่งต่างๆ (arguments) ไปให้แอปของคุณ
30
+ // Resolve the path to the OS-specific package
31
+ const packageJsonPath = require.resolve(`${packageName}/package.json`);
32
+ const packageDir = path.dirname(packageJsonPath);
33
+ const binDir = path.join(packageDir, 'bin');
34
+
35
+ // Find the executable file based on platform and architecture
36
+ const fs = require('fs');
37
+ let exePath;
38
+
39
+ if (platform === 'win32') {
40
+ // For Windows, prioritize Portable EXE over Installer EXE
41
+ const files = fs.readdirSync(binDir);
42
+
43
+ // Step 1: Look for Portable EXE (preferred - runs without installation)
44
+ let exeFile = files.find(f => f.includes('Portable') && f.endsWith('.exe'));
45
+
46
+ // Step 2: If no Portable, look for regular EXE matching architecture
47
+ if (!exeFile) {
48
+ const exeFiles = files.filter(f => f.endsWith('.exe') && !f.includes('.msi'));
49
+ exeFile = arch === 'ia32'
50
+ ? exeFiles.find(f => f.includes('ia32')) || exeFiles.find(f => !f.includes('x64'))
51
+ : exeFiles.find(f => !f.includes('ia32')) || exeFiles[0];
52
+ }
53
+
54
+ if (!exeFile) {
55
+ throw new Error(`No executable found in ${binDir} for ${arch}`);
56
+ }
57
+ exePath = path.join(binDir, exeFile);
58
+ } else if (platform === 'linux') {
59
+ // For Linux, look for AppImage dynamically (version-independent)
60
+ const files = fs.readdirSync(binDir);
61
+
62
+ // Step 1: Look for .AppImage file
63
+ const appImageFile = files.find(f => f.endsWith('.AppImage'));
64
+
65
+ if (appImageFile) {
66
+ exePath = path.join(binDir, appImageFile);
67
+ } else {
68
+ // Step 2: Fall back to linux-unpacked directory
69
+ const unpackedDir = path.join(binDir, 'linux-unpacked');
70
+ if (fs.existsSync(unpackedDir)) {
71
+ const exeFiles = fs.readdirSync(unpackedDir);
72
+ const exe = exeFiles.find(f => f.toLowerCase().includes('chahuadev') || f.toLowerCase().includes('framework'));
73
+ exePath = path.join(unpackedDir, exe || exeFiles[0]);
74
+ } else {
75
+ throw new Error(`No executable found in ${binDir}`);
76
+ }
77
+ }
78
+ } else if (platform === 'darwin') {
79
+ // For macOS, look for .app or executable
80
+ const files = fs.readdirSync(binDir).filter(f => f.endsWith('.app') || !f.includes('.'));
81
+ const exeFile = files[0];
82
+ if (!exeFile) {
83
+ throw new Error(`No executable found in ${binDir} for macOS`);
84
+ }
85
+ exePath = path.join(binDir, exeFile);
86
+ } else {
87
+ throw new Error(`Unknown platform: ${platform}`);
88
+ }
89
+
90
+ // Make the executable file (chmod +x on Unix-like systems)
91
+ if (platform !== 'win32') {
92
+ fs.chmodSync(exePath, 0o755);
93
+ }
94
+
95
+ // Pass all arguments to the executable
20
96
  const args = process.argv.slice(2);
21
- spawnSync(exePath, args, { stdio: 'inherit' });
97
+ const result = spawnSync(exePath, args, { stdio: 'inherit' });
98
+
99
+ // Exit with the same code as the executable
100
+ process.exit(result.status || 0);
22
101
 
23
102
  } catch (error) {
24
- console.error('Failed to start Chahuadev Framework:', error.message);
103
+ if (error.code === 'MODULE_NOT_FOUND') {
104
+ console.error(`Error: The ${packageName} package is not installed.`);
105
+ console.error(`Make sure to run: npm install ${packageName}`);
106
+ } else {
107
+ console.error('Failed to start Chahuadev Framework:', error.message);
108
+ }
25
109
  process.exit(1);
26
110
  }
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "@chahuadev/framework",
3
- "version": "1.0.10",
3
+ "version": "3.0.0",
4
4
  "description": "Chahuadev Framework",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "chahuadev-framework": "index.js"
8
8
  },
9
9
  "optionalDependencies": {
10
- "@chahuadev/framework-win32-x64": "^1.0.0"
10
+ "@chahuadev/framework-win32-x64": "^3.0.0",
11
+ "@chahuadev/framework-win32-ia32": "^3.0.0",
12
+ "@chahuadev/framework-linux-x64": "^3.0.0",
13
+ "@chahuadev/framework-darwin-x64": "^3.0.0",
14
+ "@chahuadev/framework-darwin-arm64": "^3.0.0"
11
15
  },
12
16
  "publishConfig": {
13
17
  "access": "public"
14
18
  }
15
- }
19
+ }