feat: 优化调整 Gist 同步逻辑; 增加 GitLab Snippet 同步

This commit is contained in:
xream
2024-01-20 05:33:31 +08:00
parent 099ae5ad83
commit b3de7a4bc5
8 changed files with 302 additions and 80 deletions

View File

@@ -35,13 +35,14 @@ export default function register($app) {
async function restoreArtifacts(_, res) {
$.info('开始恢复远程配置...');
try {
const { gistToken } = $.read(SETTINGS_KEY);
const { gistToken, syncPlatform } = $.read(SETTINGS_KEY);
if (!gistToken) {
return Promise.reject('未设置 GitHub Token');
}
const manager = new Gist({
token: gistToken,
key: ARTIFACT_REPOSITORY_KEY,
syncPlatform,
});
try {
@@ -243,13 +244,14 @@ function validateArtifactName(name) {
}
async function syncToGist(files) {
const { gistToken } = $.read(SETTINGS_KEY);
const { gistToken, syncPlatform } = $.read(SETTINGS_KEY);
if (!gistToken) {
return Promise.reject('未设置 GitHub Token');
}
const manager = new Gist({
token: gistToken,
key: ARTIFACT_REPOSITORY_KEY,
syncPlatform,
});
return manager.upload(files);
}