@exulu/backend 1.49.2 → 1.50.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.
- package/bin/setup-python.cjs +140 -0
- package/package.json +5 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CLI script for setting up the Python environment for @exulu/backend
|
|
4
|
+
*
|
|
5
|
+
* This script can be run standalone using:
|
|
6
|
+
* npx @exulu/backend setup-python
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { exec } = require('child_process');
|
|
10
|
+
const { promisify } = require('util');
|
|
11
|
+
const { existsSync } = require('fs');
|
|
12
|
+
const { resolve, join } = require('path');
|
|
13
|
+
|
|
14
|
+
const execAsync = promisify(exec);
|
|
15
|
+
|
|
16
|
+
// ANSI color codes
|
|
17
|
+
const colors = {
|
|
18
|
+
reset: '\x1b[0m',
|
|
19
|
+
green: '\x1b[32m',
|
|
20
|
+
yellow: '\x1b[33m',
|
|
21
|
+
blue: '\x1b[34m',
|
|
22
|
+
red: '\x1b[31m',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Check if Python environment already exists
|
|
27
|
+
*/
|
|
28
|
+
function pythonEnvironmentExists() {
|
|
29
|
+
const venvPath = resolve(__dirname, '..', 'ee/python/.venv');
|
|
30
|
+
const pythonPath = join(venvPath, 'bin', 'python');
|
|
31
|
+
return existsSync(venvPath) && existsSync(pythonPath);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Run the Python setup script
|
|
36
|
+
*/
|
|
37
|
+
async function setupPythonEnvironment(force = false) {
|
|
38
|
+
const setupScriptPath = resolve(__dirname, '..', 'ee/python/setup.sh');
|
|
39
|
+
|
|
40
|
+
if (!existsSync(setupScriptPath)) {
|
|
41
|
+
console.error(`${colors.red}✗${colors.reset} Setup script not found: ${setupScriptPath}`);
|
|
42
|
+
console.error('');
|
|
43
|
+
console.error('Make sure the @exulu/backend package is properly installed.');
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
console.log(`${colors.blue}Running Python environment setup...${colors.reset}`);
|
|
49
|
+
console.log('');
|
|
50
|
+
|
|
51
|
+
const command = force
|
|
52
|
+
? `bash "${setupScriptPath}" --force`
|
|
53
|
+
: `bash "${setupScriptPath}"`;
|
|
54
|
+
|
|
55
|
+
const { stdout, stderr } = await execAsync(command, {
|
|
56
|
+
cwd: resolve(__dirname, '..'),
|
|
57
|
+
timeout: 600000, // 10 minutes
|
|
58
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Show output
|
|
62
|
+
if (stdout) console.log(stdout);
|
|
63
|
+
if (stderr) console.error(stderr);
|
|
64
|
+
|
|
65
|
+
return true;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error(`${colors.red}✗${colors.reset} Python setup failed:`, error.message);
|
|
68
|
+
if (error.stdout) console.log(error.stdout);
|
|
69
|
+
if (error.stderr) console.error(error.stderr);
|
|
70
|
+
|
|
71
|
+
console.log('');
|
|
72
|
+
console.log('Requirements:');
|
|
73
|
+
console.log(' - Python 3.10 or higher must be installed');
|
|
74
|
+
console.log(' - pip must be available');
|
|
75
|
+
console.log(' - venv module must be available');
|
|
76
|
+
console.log('');
|
|
77
|
+
console.log('Installation instructions:');
|
|
78
|
+
console.log(' macOS: brew install python@3.12');
|
|
79
|
+
console.log(' Ubuntu/Debian: sudo apt-get install python3.12 python3-pip python3-venv');
|
|
80
|
+
console.log(' Alpine Linux: apk add python3 py3-pip python3-dev');
|
|
81
|
+
console.log(' Windows: Download from https://www.python.org/downloads/');
|
|
82
|
+
console.log('');
|
|
83
|
+
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Main CLI function
|
|
90
|
+
*/
|
|
91
|
+
async function main() {
|
|
92
|
+
const args = process.argv.slice(2);
|
|
93
|
+
const force = args.includes('--force') || args.includes('-f');
|
|
94
|
+
|
|
95
|
+
console.log('');
|
|
96
|
+
console.log(`${colors.blue}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${colors.reset}`);
|
|
97
|
+
console.log(`${colors.blue} @exulu/backend - Python Setup${colors.reset}`);
|
|
98
|
+
console.log(`${colors.blue}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${colors.reset}`);
|
|
99
|
+
console.log('');
|
|
100
|
+
|
|
101
|
+
// Check if already exists (and not forcing)
|
|
102
|
+
if (pythonEnvironmentExists() && !force) {
|
|
103
|
+
console.log(`${colors.green}✓${colors.reset} Python environment already set up`);
|
|
104
|
+
console.log('');
|
|
105
|
+
console.log('To rebuild the environment, run:');
|
|
106
|
+
console.log(` ${colors.green}npx @exulu/backend setup-python --force${colors.reset}`);
|
|
107
|
+
console.log('');
|
|
108
|
+
console.log(`${colors.blue}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${colors.reset}`);
|
|
109
|
+
console.log('');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (force && pythonEnvironmentExists()) {
|
|
114
|
+
console.log(`${colors.yellow}⚠${colors.reset} Rebuilding Python environment (--force flag detected)`);
|
|
115
|
+
console.log('');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Run setup
|
|
119
|
+
const success = await setupPythonEnvironment(force);
|
|
120
|
+
|
|
121
|
+
if (success) {
|
|
122
|
+
console.log('');
|
|
123
|
+
console.log(`${colors.green}✓${colors.reset} Python environment ready!`);
|
|
124
|
+
console.log('');
|
|
125
|
+
} else {
|
|
126
|
+
console.log('');
|
|
127
|
+
console.log(`${colors.red}✗${colors.reset} Setup failed`);
|
|
128
|
+
console.log('');
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log(`${colors.blue}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${colors.reset}`);
|
|
133
|
+
console.log('');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Run CLI
|
|
137
|
+
main().catch((error) => {
|
|
138
|
+
console.error('Error:', error.message);
|
|
139
|
+
process.exit(1);
|
|
140
|
+
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exulu/backend",
|
|
3
3
|
"author": "Qventu Bv.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.50.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"private": false,
|
|
7
7
|
"publishConfig": {
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
},
|
|
10
10
|
"module": "./dist/index.mjs",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
|
+
"bin": {
|
|
13
|
+
"setup-python": "./bin/setup-python.cjs"
|
|
14
|
+
},
|
|
12
15
|
"homepage": "https://exulu.com",
|
|
13
16
|
"engines": {
|
|
14
17
|
"node": "22.18.0"
|
|
@@ -151,6 +154,7 @@
|
|
|
151
154
|
"files": [
|
|
152
155
|
"dist",
|
|
153
156
|
"ee",
|
|
157
|
+
"bin",
|
|
154
158
|
"scripts/postinstall.cjs"
|
|
155
159
|
]
|
|
156
160
|
}
|