mirror of
https://github.com/open-webui/open-webui
synced 2024-11-24 13:07:25 +00:00
refac
This commit is contained in:
parent
ce659b9e1c
commit
b6ad539379
28
package-lock.json
generated
28
package-lock.json
generated
@ -3997,37 +3997,17 @@
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-client": {
|
||||
"version": "6.5.3",
|
||||
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.3.tgz",
|
||||
"integrity": "sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==",
|
||||
"version": "6.5.4",
|
||||
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.4.tgz",
|
||||
"integrity": "sha512-GeZeeRjpD2qf49cZQ0Wvh/8NJNfeXkXXcoGh+F77oEAgo9gUHwT1fCRxSNU+YEEaysOJTnsFHmM5oAcPy4ntvQ==",
|
||||
"dependencies": {
|
||||
"@socket.io/component-emitter": "~3.1.0",
|
||||
"debug": "~4.3.1",
|
||||
"engine.io-parser": "~5.2.1",
|
||||
"ws": "~8.11.0",
|
||||
"ws": "~8.17.1",
|
||||
"xmlhttprequest-ssl": "~2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-client/node_modules/ws": {
|
||||
"version": "8.11.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
|
||||
"integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": "^5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-parser": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.2.tgz",
|
||||
|
@ -17,32 +17,60 @@ import { writeFile, readFile, copyFile, readdir, rmdir } from 'fs/promises';
|
||||
|
||||
async function downloadPackages() {
|
||||
console.log('Setting up pyodide + micropip');
|
||||
const pyodide = await loadPyodide({
|
||||
|
||||
let pyodide;
|
||||
try {
|
||||
pyodide = await loadPyodide({
|
||||
packageCacheDir: 'static/pyodide'
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Failed to load Pyodide:', err);
|
||||
return;
|
||||
}
|
||||
|
||||
const packageJson = JSON.parse(await readFile('package.json'));
|
||||
const pyodideVersion = packageJson.dependencies.pyodide;
|
||||
const pyodideVersion = packageJson.dependencies.pyodide.replace('^', '');
|
||||
|
||||
try {
|
||||
const pyodidePackageJson = JSON.parse(await readFile('static/pyodide/package.json'));
|
||||
const pyodidePackageVersion = pyodidePackageJson.version;
|
||||
const pyodidePackageVersion = pyodidePackageJson.version.replace('^', '');
|
||||
|
||||
if (pyodideVersion.replace('^', '') !== pyodidePackageVersion) {
|
||||
if (pyodideVersion !== pyodidePackageVersion) {
|
||||
console.log('Pyodide version mismatch, removing static/pyodide directory');
|
||||
await rmdir('static/pyodide', { recursive: true });
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Pyodide package not found, downloading packages');
|
||||
console.log('Pyodide package not found, proceeding with download.');
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('Loading micropip package');
|
||||
await pyodide.loadPackage('micropip');
|
||||
|
||||
const micropip = pyodide.pyimport('micropip');
|
||||
console.log('Downloading Pyodide packages:', packages);
|
||||
await micropip.install(packages);
|
||||
|
||||
try {
|
||||
for (const pkg of packages) {
|
||||
console.log(`Installing package: ${pkg}`);
|
||||
await micropip.install(pkg);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Package installation failed:', err);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Pyodide packages downloaded, freezing into lock file');
|
||||
|
||||
try {
|
||||
const lockFile = await micropip.freeze();
|
||||
await writeFile('static/pyodide/pyodide-lock.json', lockFile);
|
||||
} catch (err) {
|
||||
console.error('Failed to write lock file:', err);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to load or install micropip:', err);
|
||||
}
|
||||
}
|
||||
|
||||
async function copyPyodide() {
|
||||
|
Loading…
Reference in New Issue
Block a user