mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Improve plugin settings
This commit is contained in:
4 files changed
+210
-116
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { join } from 'path-browserify';
|
||||
import matter from 'gray-matter';
|
||||
import type { JSRuntimeFS } from './JSRuntime';
|
||||
import * as git from 'isomorphic-git';
|
||||
|
||||
export interface Skill {
|
||||
/** Skill name (alphanumeric lowercase only) */
|
||||
@@ -19,6 +20,12 @@ export interface SkillFrontmatter {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface PluginGitInfo {
|
||||
commitHash: string;
|
||||
commitDate: Date;
|
||||
commitMessage: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a skill name (alphanumeric lowercase with hyphens)
|
||||
*/
|
||||
@@ -142,6 +149,36 @@ export async function readSkillContent(fs: JSRuntimeFS, skill: Skill): Promise<s
|
||||
return await fs.readFile(skillFilePath, 'utf8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get git information for a plugin
|
||||
*/
|
||||
export async function getPluginGitInfo(fs: JSRuntimeFS, pluginsPath: string, pluginName: string): Promise<PluginGitInfo | null> {
|
||||
const pluginPath = join(pluginsPath, pluginName);
|
||||
|
||||
try {
|
||||
// Get the latest commit
|
||||
const commits = await git.log({
|
||||
fs,
|
||||
dir: pluginPath,
|
||||
depth: 1,
|
||||
});
|
||||
|
||||
if (commits.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const commit = commits[0];
|
||||
|
||||
return {
|
||||
commitHash: commit.oid,
|
||||
commitDate: new Date(commit.commit.committer.timestamp * 1000),
|
||||
commitMessage: commit.commit.message,
|
||||
};
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a plugin directory
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user