|
|
@ -1,11 +1,11 @@ |
|
|
|
import { Profile } from "@remixproject/plugin-utils"; |
|
|
|
import {Profile} from '@remixproject/plugin-utils' |
|
|
|
import { ElectronBasePlugin, ElectronBasePluginClient } from "@remixproject/plugin-electron" |
|
|
|
import {ElectronBasePlugin, ElectronBasePluginClient} from '@remixproject/plugin-electron' |
|
|
|
import fs from 'fs/promises' |
|
|
|
import fs from 'fs/promises' |
|
|
|
import git from 'isomorphic-git' |
|
|
|
import git from 'isomorphic-git' |
|
|
|
import http from 'isomorphic-git/http/web' |
|
|
|
import http from 'isomorphic-git/http/web' |
|
|
|
import { gitProxy } from "../tools/git"; |
|
|
|
import {gitProxy} from '../tools/git' |
|
|
|
import { isoGit } from "@remix-git" |
|
|
|
import {isoGit} from '@remix-git' |
|
|
|
import { branchDifference, branchInputType, cloneInputType, commitChange, commitInputType, compareBranchesInput, currentBranchInput, fetchInputType, initInputType, logInputType, pullInputType, pushInputType, remote, resolveRefInput, statusInput } from "@remix-api"; |
|
|
|
import {branchDifference, branchInputType, checkoutInputType, cloneInputType, commitChange, commitInputType, compareBranchesInput, currentBranchInput, fetchInputType, initInputType, logInputType, pullInputType, pushInputType, remote, resolveRefInput, statusInput} from '@remix-api' |
|
|
|
|
|
|
|
|
|
|
|
const profile: Profile = { |
|
|
|
const profile: Profile = { |
|
|
|
name: 'isogit', |
|
|
|
name: 'isogit', |
|
|
@ -13,7 +13,7 @@ const profile: Profile = { |
|
|
|
description: 'isogit plugin', |
|
|
|
description: 'isogit plugin', |
|
|
|
} |
|
|
|
} |
|
|
|
// used in e2e tests
|
|
|
|
// used in e2e tests
|
|
|
|
const useIsoGit = process.argv.includes('--use-isogit'); |
|
|
|
const useIsoGit = process.argv.includes('--use-isogit') |
|
|
|
export class IsoGitPlugin extends ElectronBasePlugin { |
|
|
|
export class IsoGitPlugin extends ElectronBasePlugin { |
|
|
|
clients: IsoGitPluginClient[] = [] |
|
|
|
clients: IsoGitPluginClient[] = [] |
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
@ -21,19 +21,18 @@ export class IsoGitPlugin extends ElectronBasePlugin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
startClone(webContentsId: any): void { |
|
|
|
startClone(webContentsId: any): void { |
|
|
|
const client = this.clients.find(c => c.webContentsId === webContentsId) |
|
|
|
const client = this.clients.find((c) => c.webContentsId === webContentsId) |
|
|
|
if (client) { |
|
|
|
if (client) { |
|
|
|
client.startClone() |
|
|
|
client.startClone() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const clientProfile: Profile = { |
|
|
|
const clientProfile: Profile = { |
|
|
|
name: 'isogit', |
|
|
|
name: 'isogit', |
|
|
|
displayName: 'isogit', |
|
|
|
displayName: 'isogit', |
|
|
|
description: 'isogit plugin', |
|
|
|
description: 'isogit plugin', |
|
|
|
methods: ['init', 'localStorageUsed', 'version', 'addremote', 'delremote', 'remotes', 'fetch', 'clone', 'export', 'import', 'status', 'log', 'commit', 'add', 'remove', 'rm', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pin', 'pull', 'pinList', 'unPin', 'setIpfsConfig', 'zip', 'setItem', 'getItem', 'openFolder', 'getCommitChanges', 'compareBranches', 'startClone', 'updateSubmodules'] |
|
|
|
methods: ['init', 'localStorageUsed', 'version', 'addremote', 'delremote', 'remotes', 'fetch', 'clone', 'export', 'import', 'status', 'log', 'commit', 'add', 'remove', 'rm', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pin', 'pull', 'pinList', 'unPin', 'setIpfsConfig', 'zip', 'setItem', 'getItem', 'openFolder', 'getCommitChanges', 'compareBranches', 'startClone', 'updateSubmodules'], |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
@ -44,10 +43,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
this.onload(async () => { |
|
|
|
this.onload(async () => { |
|
|
|
this.on('fs' as any, 'workingDirChanged', async (path: string) => { |
|
|
|
this.on('fs' as any, 'workingDirChanged', async (path: string) => { |
|
|
|
this.workingDir = path |
|
|
|
this.workingDir = path |
|
|
|
this.gitIsInstalled = await gitProxy.version() && !useIsoGit ? true : false |
|
|
|
this.gitIsInstalled = (await gitProxy.version()) && !useIsoGit ? true : false |
|
|
|
}) |
|
|
|
}) |
|
|
|
this.workingDir = await this.call('fs' as any, 'getWorkingDir') |
|
|
|
this.workingDir = await this.call('fs' as any, 'getWorkingDir') |
|
|
|
this.gitIsInstalled = await gitProxy.version() && !useIsoGit ? true : false |
|
|
|
this.gitIsInstalled = (await gitProxy.version()) && !useIsoGit ? true : false |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -68,7 +67,6 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
throw new Error('No working directory') |
|
|
|
throw new Error('No working directory') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (this.workingDir === '') { |
|
|
|
if (this.workingDir === '') { |
|
|
|
return [] |
|
|
|
return [] |
|
|
|
} |
|
|
|
} |
|
|
@ -79,8 +77,8 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const status = await git.statusMatrix({ |
|
|
|
const status = await git.statusMatrix({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
...cmd |
|
|
|
...cmd, |
|
|
|
}) |
|
|
|
}) |
|
|
|
//console.log('STATUS', status, await this.getGitConfig())
|
|
|
|
//console.log('STATUS', status, await this.getGitConfig())
|
|
|
|
return status |
|
|
|
return status |
|
|
@ -96,9 +94,9 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const log = await git.log({ |
|
|
|
const log = await git.log({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
...cmd, |
|
|
|
...cmd, |
|
|
|
depth: cmd.depth || 10 |
|
|
|
depth: cmd.depth || 10, |
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log('LOG') |
|
|
|
console.log('LOG') |
|
|
|
return log |
|
|
|
return log |
|
|
@ -110,22 +108,21 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const add = await git.add({ |
|
|
|
const add = await git.add({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
...cmd |
|
|
|
...cmd, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return add |
|
|
|
return add |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async rm(cmd: any) { |
|
|
|
async rm(cmd: any) { |
|
|
|
|
|
|
|
|
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
|
throw new Error('No working directory') |
|
|
|
throw new Error('No working directory') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const rm = await git.remove({ |
|
|
|
const rm = await git.remove({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
...cmd |
|
|
|
...cmd, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return rm |
|
|
|
return rm |
|
|
@ -142,15 +139,14 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const commit = await git.commit({ |
|
|
|
const commit = await git.commit({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
...cmd |
|
|
|
...cmd, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return commit |
|
|
|
return commit |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async init(input: initInputType) { |
|
|
|
async init(input: initInputType) { |
|
|
|
|
|
|
|
|
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
|
throw new Error('No working directory') |
|
|
|
throw new Error('No working directory') |
|
|
|
} |
|
|
|
} |
|
|
@ -159,8 +155,8 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
return status |
|
|
|
return status |
|
|
|
} |
|
|
|
} |
|
|
|
await git.init({ |
|
|
|
await git.init({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
defaultBranch: (input && input.defaultBranch) || 'main' |
|
|
|
defaultBranch: (input && input.defaultBranch) || 'main', |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -169,8 +165,8 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
return null |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
const branch = await git.branch({ |
|
|
|
const branch = await git.branch({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
...cmd |
|
|
|
...cmd, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return branch |
|
|
|
return branch |
|
|
@ -183,41 +179,42 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const resolveref = await git.resolveRef({ |
|
|
|
const resolveref = await git.resolveRef({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
...cmd |
|
|
|
...cmd, |
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log('RESOLVE REF', resolveref) |
|
|
|
console.log('RESOLVE REF', resolveref) |
|
|
|
return resolveref |
|
|
|
return resolveref |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async readblob(cmd: any) { |
|
|
|
async readblob(cmd: any) { |
|
|
|
|
|
|
|
|
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
|
throw new Error('No working directory') |
|
|
|
throw new Error('No working directory') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const readblob = await git.readBlob({ |
|
|
|
const readblob = await git.readBlob({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
...cmd |
|
|
|
...cmd, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return readblob |
|
|
|
return readblob |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async checkout(cmd: any) { |
|
|
|
async checkout(cmd: checkoutInputType) { |
|
|
|
|
|
|
|
console.log('CHECKOUT', cmd) |
|
|
|
|
|
|
|
|
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
|
throw new Error('No working directory') |
|
|
|
throw new Error('No working directory') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (this.gitIsInstalled) { |
|
|
|
|
|
|
|
return await gitProxy.checkout(this.workingDir, cmd) |
|
|
|
|
|
|
|
} else { |
|
|
|
const checkout = await git.checkout({ |
|
|
|
const checkout = await git.checkout({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
...cmd |
|
|
|
...cmd, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return checkout |
|
|
|
return checkout |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async push(input: pushInputType) { |
|
|
|
async push(input: pushInputType) { |
|
|
|
console.log('PUSH', input, this.gitIsInstalled) |
|
|
|
console.log('PUSH', input, this.gitIsInstalled) |
|
|
@ -231,7 +228,6 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
const push = await isoGit.push(input, await this.getGitConfig(), this) |
|
|
|
const push = await isoGit.push(input, await this.getGitConfig(), this) |
|
|
|
return push |
|
|
|
return push |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async pull(input: pullInputType) { |
|
|
|
async pull(input: pullInputType) { |
|
|
@ -256,7 +252,6 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
|
|
|
|
|
|
|
|
if (this.gitIsInstalled) { |
|
|
|
if (this.gitIsInstalled) { |
|
|
|
await gitProxy.fetch(this.workingDir, input) |
|
|
|
await gitProxy.fetch(this.workingDir, input) |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const fetch = await isoGit.fetch(input, await this.getGitConfig(), this) |
|
|
|
const fetch = await isoGit.fetch(input, await this.getGitConfig(), this) |
|
|
|
return fetch |
|
|
|
return fetch |
|
|
@ -264,7 +259,6 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async clone(cmd: cloneInputType) { |
|
|
|
async clone(cmd: cloneInputType) { |
|
|
|
|
|
|
|
|
|
|
|
if (this.gitIsInstalled) { |
|
|
|
if (this.gitIsInstalled) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
this.call('terminal' as any, 'log', 'Cloning using git... please wait.') |
|
|
|
this.call('terminal' as any, 'log', 'Cloning using git... please wait.') |
|
|
@ -285,27 +279,24 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async addremote(input: remote) { |
|
|
|
async addremote(input: remote) { |
|
|
|
|
|
|
|
|
|
|
|
const addremote = await git.addRemote({ |
|
|
|
const addremote = await git.addRemote({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
url: input.url, remote: input.name |
|
|
|
url: input.url, |
|
|
|
|
|
|
|
remote: input.name, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return addremote |
|
|
|
return addremote |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async delremote(input: remote) { |
|
|
|
async delremote(input: remote) { |
|
|
|
|
|
|
|
|
|
|
|
const delremote = await git.deleteRemote({ |
|
|
|
const delremote = await git.deleteRemote({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...(await this.getGitConfig()), |
|
|
|
remote: input.name |
|
|
|
remote: input.name, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return delremote |
|
|
|
return delremote |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async remotes() { |
|
|
|
async remotes() { |
|
|
|
console.log('REMOTES') |
|
|
|
console.log('REMOTES') |
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
@ -324,7 +315,6 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
return await isoGit.currentbranch(input, defaultConfig) |
|
|
|
return await isoGit.currentbranch(input, defaultConfig) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async branches(config: any) { |
|
|
|
async branches(config: any) { |
|
|
|
console.log('BRANCHES') |
|
|
|
console.log('BRANCHES') |
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
|
if (!this.workingDir || this.workingDir === '') { |
|
|
@ -335,7 +325,6 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
return await isoGit.branches(defaultConfig) |
|
|
|
return await isoGit.branches(defaultConfig) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async startClone() { |
|
|
|
async startClone() { |
|
|
|
this.call('filePanel' as any, 'clone') |
|
|
|
this.call('filePanel' as any, 'clone') |
|
|
|
} |
|
|
|
} |
|
|
@ -360,6 +349,3 @@ class IsoGitPluginClient extends ElectronBasePluginClient { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|