@eldrin-project/eldrin-server 0.0.0 → 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/README.md +52 -0
- package/bin/eldrin-server +95 -0
- package/package.json +36 -4
- package/scripts/postinstall.js +140 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @eldrin-project/eldrin-server
|
|
2
|
+
|
|
3
|
+
Local development server for the Eldrin micro-frontend platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @eldrin-project/eldrin-server
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Start the server:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
eldrin-server start
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Options
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
eldrin-server start --port 4000 # Custom port (default: 4000)
|
|
23
|
+
eldrin-server start --data-dir ~/data # Custom data directory (default: ~/.eldrin)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## What's Included
|
|
27
|
+
|
|
28
|
+
- HTTP server for serving micro-frontend applications
|
|
29
|
+
- SQLite database for local data persistence
|
|
30
|
+
- Event bus for cross-app communication
|
|
31
|
+
- App registry and manifest loading
|
|
32
|
+
|
|
33
|
+
## Data Storage
|
|
34
|
+
|
|
35
|
+
By default, Eldrin Server stores data in `~/.eldrin/`:
|
|
36
|
+
|
|
37
|
+
- `eldrin.db` - SQLite database
|
|
38
|
+
- `config.json` - Server configuration
|
|
39
|
+
|
|
40
|
+
## Supported Platforms
|
|
41
|
+
|
|
42
|
+
- macOS (Apple Silicon & Intel)
|
|
43
|
+
- Linux (x64 & ARM64)
|
|
44
|
+
- Windows (x64)
|
|
45
|
+
|
|
46
|
+
## Requirements
|
|
47
|
+
|
|
48
|
+
- Node.js 18 or later
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Eldrin Server CLI
|
|
5
|
+
*
|
|
6
|
+
* Wrapper script that executes the platform-specific binary.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { spawn } = require('child_process');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const fs = require('fs');
|
|
12
|
+
|
|
13
|
+
// Determine binary path
|
|
14
|
+
const binDir = __dirname;
|
|
15
|
+
const binaryName = process.platform === 'win32'
|
|
16
|
+
? 'eldrin-core-binary.exe'
|
|
17
|
+
: 'eldrin-core-binary';
|
|
18
|
+
const binaryPath = path.join(binDir, binaryName);
|
|
19
|
+
|
|
20
|
+
// Check if binary exists
|
|
21
|
+
if (!fs.existsSync(binaryPath)) {
|
|
22
|
+
console.error('Error: Eldrin Server binary not found.');
|
|
23
|
+
console.error('');
|
|
24
|
+
console.error('The binary may not have been downloaded during installation.');
|
|
25
|
+
console.error('Please try reinstalling the package:');
|
|
26
|
+
console.error('');
|
|
27
|
+
console.error(' npm uninstall -g @eldrin-project/eldrin-server');
|
|
28
|
+
console.error(' npm install -g @eldrin-project/eldrin-server');
|
|
29
|
+
console.error('');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Get command line arguments (skip 'node' and script path)
|
|
34
|
+
const args = process.argv.slice(2);
|
|
35
|
+
|
|
36
|
+
// Show help if no arguments provided or help requested
|
|
37
|
+
if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
|
|
38
|
+
console.log('');
|
|
39
|
+
console.log('Eldrin Server - Local development server for micro-frontends');
|
|
40
|
+
console.log('');
|
|
41
|
+
console.log('Usage:');
|
|
42
|
+
console.log(' eldrin-server start [options] Start the Eldrin server');
|
|
43
|
+
console.log('');
|
|
44
|
+
console.log('Options:');
|
|
45
|
+
console.log(' --port <number> Port to run on (default: 4000)');
|
|
46
|
+
console.log(' --data-dir <path> Data directory (default: ~/.eldrin)');
|
|
47
|
+
console.log(' --help, -h Show this help message');
|
|
48
|
+
console.log('');
|
|
49
|
+
|
|
50
|
+
if (args.length === 0) {
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Handle 'start' command - just run the binary
|
|
56
|
+
if (args[0] === 'start') {
|
|
57
|
+
// Remove 'start' from args since binary doesn't need it
|
|
58
|
+
const binaryArgs = args.slice(1);
|
|
59
|
+
|
|
60
|
+
// Set environment variables from flags
|
|
61
|
+
const env = { ...process.env };
|
|
62
|
+
|
|
63
|
+
// Parse --port flag
|
|
64
|
+
const portIndex = binaryArgs.indexOf('--port');
|
|
65
|
+
if (portIndex !== -1 && binaryArgs[portIndex + 1]) {
|
|
66
|
+
env.ELDRIN_PORT = binaryArgs[portIndex + 1];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Parse --data-dir flag
|
|
70
|
+
const dataDirIndex = binaryArgs.indexOf('--data-dir');
|
|
71
|
+
if (dataDirIndex !== -1 && binaryArgs[dataDirIndex + 1]) {
|
|
72
|
+
env.ELDRIN_DATA_DIR = binaryArgs[dataDirIndex + 1];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Spawn the binary
|
|
76
|
+
const child = spawn(binaryPath, [], {
|
|
77
|
+
stdio: 'inherit',
|
|
78
|
+
env,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
child.on('error', (error) => {
|
|
82
|
+
console.error('Failed to start Eldrin Server:', error.message);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
child.on('exit', (code) => {
|
|
87
|
+
process.exit(code || 0);
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
// Unknown command
|
|
91
|
+
console.error(`Unknown command: ${args[0]}`);
|
|
92
|
+
console.error('');
|
|
93
|
+
console.error('Run "eldrin-server --help" for usage information.');
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
"name": "@eldrin-project/eldrin-server",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Eldrin Server - Local development server for the Eldrin micro-frontend platform",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/eldrin-project/eldrin-server"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"eldrin-server": "./bin/eldrin-server"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"postinstall": "node scripts/postinstall.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"bin/",
|
|
18
|
+
"scripts/postinstall.js"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18"
|
|
22
|
+
},
|
|
23
|
+
"os": [
|
|
24
|
+
"darwin",
|
|
25
|
+
"linux",
|
|
26
|
+
"win32"
|
|
27
|
+
],
|
|
28
|
+
"cpu": [
|
|
29
|
+
"x64",
|
|
30
|
+
"arm64"
|
|
31
|
+
],
|
|
32
|
+
"keywords": [
|
|
33
|
+
"eldrin",
|
|
34
|
+
"micro-frontend",
|
|
35
|
+
"single-spa",
|
|
36
|
+
"development-server"
|
|
37
|
+
]
|
|
6
38
|
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Postinstall Script for @eldrin-project/eldrin-server
|
|
5
|
+
*
|
|
6
|
+
* Downloads the correct platform binary from GitHub releases.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const https = require('https');
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const { execSync } = require('child_process');
|
|
13
|
+
|
|
14
|
+
const PACKAGE_VERSION = require('../package.json').version;
|
|
15
|
+
const GITHUB_REPO = 'eldrin-project/eldrin-server';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get the binary name for the current platform
|
|
19
|
+
*/
|
|
20
|
+
function getBinaryName() {
|
|
21
|
+
const platform = process.platform;
|
|
22
|
+
const arch = process.arch;
|
|
23
|
+
|
|
24
|
+
const platformMap = {
|
|
25
|
+
'darwin-arm64': 'eldrin-core-darwin-arm64',
|
|
26
|
+
'darwin-x64': 'eldrin-core-darwin-x64',
|
|
27
|
+
'linux-x64': 'eldrin-core-linux-x64',
|
|
28
|
+
'linux-arm64': 'eldrin-core-linux-arm64',
|
|
29
|
+
'win32-x64': 'eldrin-core-win-x64.exe',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const key = `${platform}-${arch}`;
|
|
33
|
+
const binary = platformMap[key];
|
|
34
|
+
|
|
35
|
+
if (!binary) {
|
|
36
|
+
console.error(`Unsupported platform: ${platform}-${arch}`);
|
|
37
|
+
console.error('Supported platforms: darwin-arm64, darwin-x64, linux-x64, linux-arm64, win32-x64');
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return binary;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Download a file from a URL
|
|
46
|
+
*/
|
|
47
|
+
function downloadFile(url, dest) {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
const follow = (url, redirectCount = 0) => {
|
|
50
|
+
if (redirectCount > 5) {
|
|
51
|
+
reject(new Error('Too many redirects'));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const protocol = url.startsWith('https') ? https : require('http');
|
|
56
|
+
|
|
57
|
+
protocol.get(url, {
|
|
58
|
+
headers: {
|
|
59
|
+
'User-Agent': 'eldrin-server-postinstall',
|
|
60
|
+
},
|
|
61
|
+
}, (response) => {
|
|
62
|
+
// Handle redirects
|
|
63
|
+
if (response.statusCode >= 300 && response.statusCode < 400 && response.headers.location) {
|
|
64
|
+
follow(response.headers.location, redirectCount + 1);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (response.statusCode !== 200) {
|
|
69
|
+
reject(new Error(`Failed to download: ${response.statusCode} ${response.statusMessage}`));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const file = fs.createWriteStream(dest);
|
|
74
|
+
response.pipe(file);
|
|
75
|
+
|
|
76
|
+
file.on('finish', () => {
|
|
77
|
+
file.close();
|
|
78
|
+
resolve();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
file.on('error', (err) => {
|
|
82
|
+
fs.unlink(dest, () => {}); // Delete partial file
|
|
83
|
+
reject(err);
|
|
84
|
+
});
|
|
85
|
+
}).on('error', reject);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
follow(url);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Make binary executable on Unix systems
|
|
94
|
+
*/
|
|
95
|
+
function makeExecutable(filePath) {
|
|
96
|
+
if (process.platform !== 'win32') {
|
|
97
|
+
fs.chmodSync(filePath, 0o755);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function main() {
|
|
102
|
+
const binaryName = getBinaryName();
|
|
103
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
104
|
+
const binaryPath = path.join(binDir, 'eldrin-core-binary');
|
|
105
|
+
|
|
106
|
+
// On Windows, keep the .exe extension
|
|
107
|
+
const finalBinaryPath = process.platform === 'win32'
|
|
108
|
+
? binaryPath + '.exe'
|
|
109
|
+
: binaryPath;
|
|
110
|
+
|
|
111
|
+
// Check if binary already exists
|
|
112
|
+
if (fs.existsSync(finalBinaryPath)) {
|
|
113
|
+
console.log('Eldrin Server binary already installed.');
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Construct download URL
|
|
118
|
+
// Format: https://github.com/eldrin-project/eldrin-core/releases/download/v0.0.1/eldrin-core-darwin-arm64
|
|
119
|
+
const downloadUrl = `https://github.com/${GITHUB_REPO}/releases/download/v${PACKAGE_VERSION}/${binaryName}`;
|
|
120
|
+
|
|
121
|
+
console.log(`Downloading Eldrin Server for ${process.platform}-${process.arch}...`);
|
|
122
|
+
console.log(`URL: ${downloadUrl}`);
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
await downloadFile(downloadUrl, finalBinaryPath);
|
|
126
|
+
makeExecutable(finalBinaryPath);
|
|
127
|
+
console.log('Eldrin Server installed successfully!');
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.error('Failed to download Eldrin Server binary:', error.message);
|
|
130
|
+
console.error('');
|
|
131
|
+
console.error('You can manually download the binary from:');
|
|
132
|
+
console.error(` https://github.com/${GITHUB_REPO}/releases/tag/v${PACKAGE_VERSION}`);
|
|
133
|
+
console.error('');
|
|
134
|
+
console.error('And place it at:');
|
|
135
|
+
console.error(` ${finalBinaryPath}`);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
main();
|