mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #3173 from ceruleandeep/redesign-extension-manager
Redesign extension manager
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -50,3 +50,5 @@ public/css/user.css
|
|||||||
/default/scaffold
|
/default/scaffold
|
||||||
public/scripts/extensions/third-party
|
public/scripts/extensions/third-party
|
||||||
/certs
|
/certs
|
||||||
|
.aider*
|
||||||
|
.env
|
||||||
|
@@ -770,7 +770,7 @@ async function showExtensionsDetails() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the click event for the update button of an extension.
|
* Handles the click event for the update button of an extension.
|
||||||
* This function makes a POST request to '/update_extension' with the extension's name.
|
* This function makes a POST request to '/api/extensions/update' with the extension's name.
|
||||||
* If the extension is already up to date, it displays a success message.
|
* If the extension is already up to date, it displays a success message.
|
||||||
* If the extension is not up to date, it updates the extension and displays a success message with the new commit hash.
|
* If the extension is not up to date, it updates the extension and displays a success message with the new commit hash.
|
||||||
*/
|
*/
|
||||||
@@ -783,8 +783,11 @@ async function onUpdateClick() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(this).find('i').addClass('fa-spin');
|
const icon = $(this).find('i');
|
||||||
|
icon.addClass('fa-spin');
|
||||||
await updateExtension(extensionName, false);
|
await updateExtension(extensionName, false);
|
||||||
|
// updateExtension eats the error, but we can at least stop the spinner
|
||||||
|
icon.removeClass('fa-spin');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -803,10 +806,17 @@ async function updateExtension(extensionName, quiet) {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const text = await response.text();
|
||||||
|
toastr.error(text || response.statusText, t`Extension update failed`, { timeOut: 5000 });
|
||||||
|
console.error('Extension update failed', response.status, response.statusText, text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
showExtensionsDetails();
|
await showExtensionsDetails();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.isUpToDate) {
|
if (data.isUpToDate) {
|
||||||
|
@@ -224,12 +224,20 @@ router.post('/version', jsonParser, async (request, response) => {
|
|||||||
return response.status(404).send(`Directory does not exist at ${extensionPath}`);
|
return response.status(404).send(`Directory does not exist at ${extensionPath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let currentCommitHash;
|
||||||
|
try {
|
||||||
|
currentCommitHash = await git.cwd(extensionPath).revparse(['HEAD']);
|
||||||
|
} catch (error) {
|
||||||
|
// it is not a git repo, or has no commits yet, or is a bare repo
|
||||||
|
// not possible to update it, most likely can't get the branch name either
|
||||||
|
return response.send({ currentBranchName: null, currentCommitHash, isUpToDate: true, remoteUrl: null });
|
||||||
|
}
|
||||||
|
|
||||||
const currentBranch = await git.cwd(extensionPath).branch();
|
const currentBranch = await git.cwd(extensionPath).branch();
|
||||||
// get only the working branch
|
// get only the working branch
|
||||||
const currentBranchName = currentBranch.current;
|
const currentBranchName = currentBranch.current;
|
||||||
await git.cwd(extensionPath).fetch('origin');
|
await git.cwd(extensionPath).fetch('origin');
|
||||||
const currentCommitHash = await git.cwd(extensionPath).revparse(['HEAD']);
|
console.log(extensionName, currentBranchName, currentCommitHash);
|
||||||
console.log(currentBranch, currentCommitHash);
|
|
||||||
const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath);
|
const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath);
|
||||||
|
|
||||||
return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl });
|
return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl });
|
||||||
|
Reference in New Issue
Block a user