added publish (git add, git push)

This commit is contained in:
2021-01-07 22:54:41 +01:00
parent dcfaef47a6
commit 35138ec30b
5 changed files with 159 additions and 21 deletions

View File

@@ -57,8 +57,6 @@ class Model {
}
async dirGitStatus(list) {
let dirlist = [list[0]];
for (let i = 1; i < list.length; i++) {
if (Array.isArray(list[i])) {
await this.dirGitStatus(list[i]);
@@ -103,6 +101,52 @@ class Model {
});
}
async gitAddAll(dirTree) {
if (!dirTree) {
dirTree = await this.getDirTree();
}
for (let i = 1; i < dirTree.length; i++) {
if (Array.isArray(dirTree[i])) {
await this.gitAddAll(dirTree[i]);
} else {
await git.add({
fs,
dir,
filepath: dirTree[0].substring(1) + dirTree[i],
});
console.log(dirTree[0].substring(1) + dirTree[i]);
}
}
}
async gitCommit(msg) {
await git.commit({
fs,
dir,
message: msg,
author: {
name: localStorage.getItem("name"),
email: localStorage.getItem("email"),
},
});
}
async gitPush(gitUser, gitPass) {
let pushResult = await git.push({
fs,
http,
dir,
onAuth: (url) => {
const auth = {
username: gitUser,
password: gitPass,
};
return auth;
},
});
console.log(pushResult);
}
setRepo(repoURL) {
localStorage.setItem("repo", repoURL);
}