mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Improve extension type indication
This commit is contained in:
@@ -246,26 +246,28 @@ router.get('/discover', jsonParser, function (request, response) {
|
||||
}
|
||||
|
||||
// Get all folders in system extensions folder, excluding third-party
|
||||
const buildInExtensions = fs
|
||||
const builtInExtensions = fs
|
||||
.readdirSync(PUBLIC_DIRECTORIES.extensions)
|
||||
.filter(f => fs.statSync(path.join(PUBLIC_DIRECTORIES.extensions, f)).isDirectory())
|
||||
.filter(f => f !== 'third-party')
|
||||
.map(f => ({ type: 'system', name: f }));
|
||||
|
||||
// Get all folders in global extensions folder
|
||||
const globalExtensions = fs
|
||||
.readdirSync(PUBLIC_DIRECTORIES.globalExtensions)
|
||||
.filter(f => fs.statSync(path.join(PUBLIC_DIRECTORIES.globalExtensions, f)).isDirectory())
|
||||
.map(f => ({ type: 'global', name: `third-party/${f}` }));
|
||||
|
||||
// Get all folders in local extensions folder
|
||||
const userExtensions = fs
|
||||
.readdirSync(path.join(request.user.directories.extensions))
|
||||
.filter(f => fs.statSync(path.join(request.user.directories.extensions, f)).isDirectory())
|
||||
.map(f => ({ type: 'local', name: `third-party/${f}` }));
|
||||
|
||||
// Get all folders in global extensions folder
|
||||
// In case of a conflict, the extension will be loaded from the user folder
|
||||
const globalExtensions = fs
|
||||
.readdirSync(PUBLIC_DIRECTORIES.globalExtensions)
|
||||
.filter(f => fs.statSync(path.join(PUBLIC_DIRECTORIES.globalExtensions, f)).isDirectory())
|
||||
.map(f => ({ type: 'global', name: `third-party/${f}` }))
|
||||
.filter(f => !userExtensions.some(e => e.name === f.name));
|
||||
|
||||
// Combine all extensions
|
||||
const allExtensions = Array.from(new Set([...buildInExtensions, ...globalExtensions, ...userExtensions]));
|
||||
const allExtensions = [...builtInExtensions, ...userExtensions, ...globalExtensions];
|
||||
console.log(allExtensions);
|
||||
|
||||
return response.send(allExtensions);
|
||||
|
Reference in New Issue
Block a user