diff --git a/apps/remix-ide/src/app/files/dgitProvider.ts b/apps/remix-ide/src/app/files/dgitProvider.ts index 87cb4c3c8c..51d6a7f32d 100644 --- a/apps/remix-ide/src/app/files/dgitProvider.ts +++ b/apps/remix-ide/src/app/files/dgitProvider.ts @@ -19,10 +19,12 @@ import { Octokit, App } from "octokit" import { OctokitResponse } from '@octokit/types' import { Endpoints } from "@octokit/types" import { IndexedDBStorage } from './filesystems/indexedDB' -import { GitHubUser, branch, commitChange, remote, pagedCommits, remoteCommitsInputType, cloneInputType, fetchInputType, pullInputType, pushInputType, currentBranchInput, branchInputType, addInput, rmInput, resolveRefInput, readBlobInput, repositoriesInput, commitInput, branchDifference, compareBranchesInput, initInput, userEmails, checkoutInput } from '@remix-ui/git' +import { GitHubUser, branch, commitChange, remote, userEmails } from '@remix-ui/git' +import { checkoutInputType, statusInput, logInputType, author, pagedCommits, remoteCommitsInputType, cloneInputType, fetchInputType, pullInputType, pushInputType, currentBranchInput, branchInputType, addInputType, rmInputType, resolveRefInput, readBlobInput, repositoriesInput, commitInputType, branchDifference, compareBranchesInput, initInputType} from '@remix-api' import { LibraryProfile, StatusEvents } from '@remixproject/plugin-utils' import { ITerminal } from '@remixproject/plugin-api/src/lib/terminal' import { partial } from 'lodash' +import { CustomRemixApi } from '@remix-api' declare global { interface Window { remixFileSystemCallback: IndexedDBStorage; remixFileSystem: any; } @@ -34,11 +36,11 @@ const profile: LibraryProfile = { description: 'Decentralized git provider', icon: 'assets/img/fileManager.webp', version: '0.0.1', - methods: ['init', 'localStorageUsed', 'addremote', 'delremote', 'remotes', 'fetch', 'clone', 'export', 'import', 'status', 'log', 'commit', 'add', 'remove', 'reset', 'rm', 'lsfiles', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pull', 'setIpfsConfig', 'zip', 'setItem', 'getItem', 'version', 'updateSubmodules' + methods: ['init', 'localStorageUsed', 'addremote', 'delremote', 'remotes', 'fetch', 'clone', 'export', 'import', 'status', 'log', 'commit', 'add', 'remove', 'rm', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pull', 'setIpfsConfig', 'zip', 'setItem', 'getItem', 'version', 'updateSubmodules' , 'getGitHubUser', 'remotebranches', 'remotecommits', 'repositories', 'getCommitChanges', 'compareBranches'], kind: 'file-system' } -class DGitProvider extends Plugin { +class DGitProvider extends Plugin { ipfsconfig: { host: string; port: number; protocol: string; ipfsurl: string } globalIPFSConfig: { host: string; port: number; protocol: string; ipfsurl: string } remixIPFS: { host: string; port: number; protocol: string; ipfsurl: string } @@ -141,7 +143,7 @@ class DGitProvider extends Plugin { } async getCommandUser(input) { - const author = { + const author: author = { name: '', email: '' } @@ -167,7 +169,7 @@ class DGitProvider extends Plugin { return author } - async init(input?: initInput): Promise { + async init(input?: initInputType): Promise { if ((Registry.getInstance().get('platform').api.isDesktop())) { await this.call('isogit', 'init', { defaultBranch: (input && input.defaultBranch) || 'main' @@ -192,7 +194,7 @@ class DGitProvider extends Plugin { return version } - async status(cmd): Promise> { + async status(cmd: statusInput): Promise> { if ((Registry.getInstance().get('platform').api.isDesktop())) { const status = await this.call('isogit', 'status', cmd) @@ -208,7 +210,7 @@ class DGitProvider extends Plugin { return status } - async add(cmd: addInput): Promise { + async add(cmd: addInputType): Promise { if ((Registry.getInstance().get('platform').api.isDesktop())) { await this.call('isogit', 'add', cmd) @@ -222,7 +224,7 @@ class DGitProvider extends Plugin { this.emit('add') } - async rm(cmd: rmInput) { + async rm(cmd: rmInputType) { if ((Registry.getInstance().get('platform').api.isDesktop())) { await this.call('isogit', 'rm', cmd) @@ -236,21 +238,7 @@ class DGitProvider extends Plugin { } } - async reset(cmd) { - - if ((Registry.getInstance().get('platform').api.isDesktop())) { - await this.call('isogit', 'reset', cmd) - } else { - await git.resetIndex({ - ...await this.addIsomorphicGitConfigFS(), - ...cmd - }) - this.emit('rm') - - } - } - - async checkout(cmd: checkoutInput): Promise { + async checkout(cmd: checkoutInputType): Promise { if ((Registry.getInstance().get('platform').api.isDesktop())) { await this.call('isogit', 'checkout', cmd) @@ -291,12 +279,11 @@ class DGitProvider extends Plugin { this.emit('checkout') } - async log(cmd: { ref: string }): Promise { + async log(cmd: logInputType): Promise { if ((Registry.getInstance().get('platform').api.isDesktop())) { const status = await this.call('isogit', 'log', { ...cmd, - depth: 10 }) return status @@ -310,6 +297,9 @@ class DGitProvider extends Plugin { } async compareBranches({ branch, remote }: compareBranchesInput): Promise { + if ((Registry.getInstance().get('platform').api.isDesktop())) { + return await this.call('isogit', 'compareBranches', { branch, remote }) + } // Get current branch commits const headCommits = await git.log({ ...await this.addIsomorphicGitConfigFS(), @@ -339,6 +329,11 @@ class DGitProvider extends Plugin { } async getCommitChanges(commitHash1: string, commitHash2: string): Promise { + if ((Registry.getInstance().get('platform').api.isDesktop())) { + const result = this.call('isogit', 'getCommitChanges', commitHash1, commitHash2 ) + return result + } + const result: commitChange[] = await git.walk({ ...await this.addIsomorphicGitConfigFS(), trees: [git.TREE({ ref: commitHash1 }), git.TREE({ ref: commitHash2 })], @@ -388,14 +383,14 @@ class DGitProvider extends Plugin { return result } - async remotes(config): Promise { + async remotes(): Promise { if ((Registry.getInstance().get('platform').api.isDesktop())) { - return await this.call('isogit', 'remotes', config) + return await this.call('isogit', 'remotes') } let remotes: remote[] = [] try { - remotes = (await git.listRemotes({ ...config ? config : await this.addIsomorphicGitConfigFS() })).map((remote) => { return { name: remote.remote, url: remote.url } } + remotes = (await git.listRemotes({ ...await this.addIsomorphicGitConfigFS() })).map((remote) => { return { name: remote.remote, url: remote.url } } ) } catch (e) { // do nothing @@ -423,15 +418,15 @@ class DGitProvider extends Plugin { return status } - async currentbranch(config: currentBranchInput): Promise { + async currentbranch(input: currentBranchInput): Promise { if ((Registry.getInstance().get('platform').api.isDesktop())) { - return await this.call('isogit', 'currentbranch') + return await this.call('isogit', 'currentbranch', input) } try { const defaultConfig = await this.addIsomorphicGitConfigFS() - const cmd = config ? defaultConfig ? { ...defaultConfig, ...config } : config : defaultConfig + const cmd = input ? defaultConfig ? { ...defaultConfig, ...input } : input : defaultConfig const name = await git.currentBranch(cmd) let remote: remote = undefined try { @@ -463,13 +458,15 @@ class DGitProvider extends Plugin { async branches(config): Promise { if ((Registry.getInstance().get('platform').api.isDesktop())) { - return await this.call('isogit', 'branches') + const branches = await this.call('isogit', 'branches') + console.log(branches) + return branches } try { const defaultConfig = await this.addIsomorphicGitConfigFS() const cmd = config ? defaultConfig ? { ...defaultConfig, ...config } : config : defaultConfig - const remotes = await this.remotes(config) + const remotes = await this.remotes() let branches: branch[] = [] branches = (await git.listBranches(cmd)).map((branch) => { return { remote: undefined, name: branch } }) for (const remote of remotes) { @@ -484,7 +481,7 @@ class DGitProvider extends Plugin { } } - async commit(cmd: commitInput): Promise { + async commit(cmd: commitInputType): Promise { if ((Registry.getInstance().get('platform').api.isDesktop())) { try { @@ -511,19 +508,6 @@ class DGitProvider extends Plugin { } } - async lsfiles(cmd) { - - if ((Registry.getInstance().get('platform').api.isDesktop())) { - return await this.call('isogit', 'lsfiles', cmd) - } - - const filesInStaging = await git.listFiles({ - ...await this.addIsomorphicGitConfigFS(), - ...cmd - }) - return filesInStaging - } - async resolveref(cmd: resolveRefInput): Promise { if ((Registry.getInstance().get('platform').api.isDesktop())) { @@ -569,7 +553,7 @@ class DGitProvider extends Plugin { async addremote(input: remote): Promise { if ((Registry.getInstance().get('platform').api.isDesktop())) { - await this.call('isogit', 'addremote', { url: input.url, remote: input.name }) + await this.call('isogit', 'addremote', input) return } await git.addRemote({ ...await this.addIsomorphicGitConfigFS(), url: input.url, remote: input.name }) @@ -577,7 +561,7 @@ class DGitProvider extends Plugin { async delremote(input: remote) { if ((Registry.getInstance().get('platform').api.isDesktop())) { - await this.call('isogit', 'delremote', { remote: input.name }) + await this.call('isogit', 'delremote', input) return } await git.deleteRemote({ ...await this.addIsomorphicGitConfigFS(), remote: input.name }) @@ -608,6 +592,7 @@ class DGitProvider extends Plugin { } catch (e) { this.call('notification', 'alert', { id: 'dgitAlert', + title: 'Error Cloning', message: 'Unexpected error while cloning the repository: \n' + e.toString(), }) } @@ -791,7 +776,10 @@ class DGitProvider extends Plugin { input, } if ((Registry.getInstance().get('platform').api.isDesktop())) { - return await this.call('isogit', 'push', cmd) + return await this.call('isogit', 'push', { + ...input, + author: await this.getCommandUser(input), + }) } else { const cmd2 = { @@ -820,7 +808,10 @@ class DGitProvider extends Plugin { } let result if ((Registry.getInstance().get('platform').api.isDesktop())) { - result = await this.call('isogit', 'pull', cmd) + result = await this.call('isogit', 'pull', { + ...input, + author: await this.getCommandUser(input), + }) } else { const cmd2 = { @@ -852,7 +843,10 @@ class DGitProvider extends Plugin { let result if ((Registry.getInstance().get('platform').api.isDesktop())) { - result = await this.call('isogit', 'fetch', cmd) + result = await this.call('isogit', 'fetch', { + ...input, + author: await this.getCommandUser(input), + }) } else { const cmd2 = { ...cmd, @@ -1072,6 +1066,7 @@ class DGitProvider extends Plugin { } async remotecommits(input: remoteCommitsInputType): Promise { + console.log('remotecommits', input) const octokit = new Octokit({ auth: input.token }) diff --git a/apps/remixdesktop/package.json b/apps/remixdesktop/package.json index c6411f2dcd..6e440b2ecb 100644 --- a/apps/remixdesktop/package.json +++ b/apps/remixdesktop/package.json @@ -1,7 +1,7 @@ { "name": "remixdesktop", "version": "1.0.7-insiders", - "main": "build/main.js", + "main": "build/apps/remixdesktop/src/main.js", "license": "MIT", "type": "commonjs", "description": "Remix IDE Desktop", diff --git a/apps/remixdesktop/src/main.ts b/apps/remixdesktop/src/main.ts index 65cd68d61e..d06f3d62f0 100644 --- a/apps/remixdesktop/src/main.ts +++ b/apps/remixdesktop/src/main.ts @@ -145,6 +145,9 @@ HelpMenu(commandKeys, execCommand), if (!isE2E || isE2ELocal) Menu.setApplicationMenu(Menu.buildFromTemplate(menu)) +ipcMain.handle('logger', async (...args) => { + console.log('log:', ...args) +}) ipcMain.handle('config:isPackaged', async () => { return isPackaged diff --git a/apps/remixdesktop/src/plugins/appUpdater.ts b/apps/remixdesktop/src/plugins/appUpdater.ts index e7a6ff56d8..7f21fd962c 100644 --- a/apps/remixdesktop/src/plugins/appUpdater.ts +++ b/apps/remixdesktop/src/plugins/appUpdater.ts @@ -78,14 +78,11 @@ const clientProfile: Profile = { class AppUpdaterPluginClient extends ElectronBasePluginClient { constructor(webContentsId: number, profile: Profile) { - console.log('AppUpdaterPluginClient') super(webContentsId, profile) } async onActivation(): Promise { - console.log('onActivation', 'appUpdaterPluginClient') this.onload(async () => { - console.log('onload', 'appUpdaterPluginClient') this.emit('loaded') if(isE2E) return await this.checkForUpdates() diff --git a/apps/remixdesktop/src/plugins/fsPlugin.ts b/apps/remixdesktop/src/plugins/fsPlugin.ts index 0f45727066..bbf96e0856 100644 --- a/apps/remixdesktop/src/plugins/fsPlugin.ts +++ b/apps/remixdesktop/src/plugins/fsPlugin.ts @@ -33,7 +33,6 @@ const getBaseName = (pathName: string): string => { } function onlyUnique(value: recentFolder, index: number, self: recentFolder[]) { - console.log(index, value) return self.findIndex((rc, index) => rc.path === value.path) === index } diff --git a/apps/remixdesktop/src/plugins/isoGitPlugin.ts b/apps/remixdesktop/src/plugins/isoGitPlugin.ts index 3aaf610305..4aef5b9f36 100644 --- a/apps/remixdesktop/src/plugins/isoGitPlugin.ts +++ b/apps/remixdesktop/src/plugins/isoGitPlugin.ts @@ -1,12 +1,11 @@ -import { PluginClient } from "@remixproject/plugin"; import { Profile } from "@remixproject/plugin-utils"; import { ElectronBasePlugin, ElectronBasePluginClient } from "@remixproject/plugin-electron" import fs from 'fs/promises' import git from 'isomorphic-git' -import { dialog } from "electron"; import http from 'isomorphic-git/http/web' import { gitProxy } from "../tools/git"; -import { remote } from "../types"; +import { isoGit } from "@remix-git" +import { branch, branchDifference, branchInputType, cloneInputType, commitChange, commitInputType, compareBranchesInput, currentBranchInput, fetchInputType, initInputType, logInputType, pullInputType, pushInputType, remote, resolveRefInput, statusInput } from "@remix-api"; const profile: Profile = { name: 'isogit', @@ -48,7 +47,7 @@ const clientProfile: Profile = { name: 'isogit', displayName: 'isogit', description: 'isogit plugin', - methods: ['init', 'localStorageUsed', 'version', 'addremote', 'delremote', 'remotes', 'fetch', 'clone', 'export', 'import', 'status', 'log', 'commit', 'add', 'remove', 'reset', 'rm', 'lsfiles', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pin', 'pull', 'pinList', 'unPin', 'setIpfsConfig', 'zip', 'setItem', 'getItem', 'openFolder'] + 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'] } class IsoGitPluginClient extends ElectronBasePluginClient { @@ -77,8 +76,8 @@ class IsoGitPluginClient extends ElectronBasePluginClient { } } - async status(cmd: any) { - + async status(cmd: statusInput) { + console.log('status', cmd) if (!this.workingDir || this.workingDir === '') { throw new Error('No working directory') } @@ -101,8 +100,8 @@ class IsoGitPluginClient extends ElectronBasePluginClient { return status } - async log(cmd: any) { - + async log(cmd: logInputType) { + console.log('LOG', cmd) /* we will use isomorphic git for now if(this.gitIsInstalled){ const log = await gitProxy.log(this.workingDir, cmd.ref) @@ -150,28 +149,13 @@ class IsoGitPluginClient extends ElectronBasePluginClient { return rm } - async reset(cmd: any) { - - if (!this.workingDir || this.workingDir === '') { - throw new Error('No working directory') - } - - const reset = await git.resetIndex({ - ...await this.getGitConfig(), - ...cmd - }) - - return reset - } - - - async commit(cmd: any) { + async commit(cmd: commitInputType) { if (!this.workingDir || this.workingDir === '') { throw new Error('No working directory') } if (this.gitIsInstalled) { - const status = await gitProxy.commit(this.workingDir, cmd.message) + const status = await gitProxy.commit(this.workingDir, cmd) return status } @@ -183,7 +167,7 @@ class IsoGitPluginClient extends ElectronBasePluginClient { return commit } - async init(input: any) { + async init(input: initInputType) { if (!this.workingDir || this.workingDir === '') { throw new Error('No working directory') @@ -194,11 +178,11 @@ class IsoGitPluginClient extends ElectronBasePluginClient { } await git.init({ ...await this.getGitConfig(), - defaultBranch: (input && input.branch) || 'main' + defaultBranch: (input && input.defaultBranch) || 'main' }) } - async branch(cmd: any) { + async branch(cmd: branchInputType) { if (!this.workingDir || this.workingDir === '') { return null } @@ -210,18 +194,8 @@ class IsoGitPluginClient extends ElectronBasePluginClient { return branch } - async lsfiles(cmd: any) { - if (!this.workingDir || this.workingDir === '') { - return [] - } - const lsfiles = await git.listFiles({ - ...await this.getGitConfig(), - ...cmd - }) - return lsfiles - } - - async resolveref(cmd: any) { + async resolveref(cmd: resolveRefInput) { + console.log('RESOLVE REF', cmd) if (!this.workingDir || this.workingDir === '') { return null } @@ -230,7 +204,7 @@ class IsoGitPluginClient extends ElectronBasePluginClient { ...await this.getGitConfig(), ...cmd }) - + console.log('RESOLVE REF', resolveref) return resolveref } @@ -263,38 +237,38 @@ class IsoGitPluginClient extends ElectronBasePluginClient { return checkout } - async push(cmd: any) { + async push(cmd: pushInputType) { if (!this.workingDir || this.workingDir === '') { throw new Error('No working directory') } if (this.gitIsInstalled) { - await gitProxy.push(this.workingDir, cmd.remote, cmd.ref, cmd.remoteRef, cmd.force) + await gitProxy.push(this.workingDir, cmd) } else { - + /* const push = await git.push({ ...await this.getGitConfig(), ...cmd, ...parseInput(cmd.input) }) - return push + return push*/ } } - async pull(cmd: any) { + async pull(cmd: pullInputType) { if (!this.workingDir || this.workingDir === '') { throw new Error('No working directory') } if (this.gitIsInstalled) { - await gitProxy.pull(this.workingDir, cmd.remote, cmd.ref, cmd.remoteRef) + await gitProxy.pull(this.workingDir, cmd) } else { - + /* const pull = await git.pull({ ...await this.getGitConfig(), ...cmd, @@ -302,41 +276,42 @@ class IsoGitPluginClient extends ElectronBasePluginClient { }) return pull - + */ } } - async fetch(cmd: any) { - + async fetch(cmd: fetchInputType) { + console.log('FETCH', cmd) if (!this.workingDir || this.workingDir === '') { throw new Error('No working directory') } if (this.gitIsInstalled) { - await gitProxy.fetch(this.workingDir, cmd.remote, cmd.remoteRef) + await gitProxy.fetch(this.workingDir, cmd) } else { - + /* const fetch = await git.fetch({ ...await this.getGitConfig(), ...cmd, ...parseInput(cmd.input) }) - + */ return fetch } } - async clone(cmd: any) { + async clone(cmd: cloneInputType) { if (this.gitIsInstalled) { try { - await gitProxy.clone(cmd.url, cmd.dir) + await gitProxy.clone(cmd) } catch (e) { throw e } } else { try { + /* this.call('terminal' as any, 'log', 'Cloning using builtin git... please wait.') const clone = await git.clone({ ...await this.getGitConfig(), @@ -346,6 +321,7 @@ class IsoGitPluginClient extends ElectronBasePluginClient { }) return clone + */ } catch (e) { console.log('CLONE ERROR', e) throw e @@ -353,21 +329,21 @@ class IsoGitPluginClient extends ElectronBasePluginClient { } } - async addremote(cmd: any) { + async addremote(input: remote) { const addremote = await git.addRemote({ ...await this.getGitConfig(), - ...cmd + url: input.url, remote: input.name }) return addremote } - async delremote(cmd: any) { + async delremote(input: remote) { const delremote = await git.deleteRemote({ ...await this.getGitConfig(), - ...cmd + remote: input.name }) return delremote @@ -375,53 +351,83 @@ class IsoGitPluginClient extends ElectronBasePluginClient { - remotes = async () => { + async remotes () { + console.log('REMOTES') if (!this.workingDir || this.workingDir === '') { return [] } let remotes: remote[] = [] - remotes = (await git.listRemotes({ ...await this.getGitConfig() })).map((remote) => { return { name: remote.remote, url: remote.url } } - ) + try { + remotes = (await git.listRemotes({ ...await this.getGitConfig() })).map((remote) => { return { name: remote.remote, url: remote.url } } + ) + } catch (e) { + // do nothing + } + console.log('REMOTES', remotes) return remotes } - async currentbranch() { + async currentbranch(input: currentBranchInput) { + console.log('CURRENT BRANCH', input) if (!this.workingDir || this.workingDir === '') { return '' } + try { const defaultConfig = await this.getGitConfig() - const name = await git.currentBranch(defaultConfig) + console.log(isoGit) + const cmd = input ? defaultConfig ? { ...defaultConfig, ...input } : input : defaultConfig + + const name = await git.currentBranch(cmd) + let remote: remote = undefined + try { + const remoteName = await git.getConfig({ + ...defaultConfig, + path: `branch.${name}.remote` + }) + if (remoteName) { + const remoteUrl = await git.getConfig({ + ...defaultConfig, + path: `remote.${remoteName}.url` + }) + remote = { name: remoteName, url: remoteUrl } + } - return name + } catch (e) { + // do nothing + } + console.log('NAME', name) + console.log('REMOTE', remote) + + return { + remote: remote, + name: name || '' + } } catch (e) { - return '' + return undefined } } - async branches() { + async branches(config: any) { + console.log('BRANCHES') if (!this.workingDir || this.workingDir === '') { return [] } try { - let cmd: any = { ...await this.getGitConfig() } + const defaultConfig = await this.getGitConfig() + const cmd = config ? defaultConfig ? { ...defaultConfig, ...config } : config : defaultConfig const remotes = await this.remotes() - let branches = [] + let branches: branch[] = [] branches = (await git.listBranches(cmd)).map((branch) => { return { remote: undefined, name: branch } }) for (const remote of remotes) { - cmd = { - ...cmd, - remote: remote.name - } - - const remotebranches = (await git.listBranches(cmd)).map((branch) => { return { remote: remote.name, name: branch } }) + cmd.remote = remote.name + const remotebranches = (await git.listBranches(cmd)).map((branch) => { return { remote: remote, name: branch } }) branches = [...branches, ...remotebranches] - } - return branches } catch (e) { + console.log(e) return [] } } @@ -431,6 +437,86 @@ class IsoGitPluginClient extends ElectronBasePluginClient { this.call('filePanel' as any, 'clone') } + async getCommitChanges(commitHash1: string, commitHash2: string): Promise { + const result: commitChange[] = await git.walk({ + ...await this.getGitConfig(), + trees: [git.TREE({ ref: commitHash1 }), git.TREE({ ref: commitHash2 })], + map: async function (filepath, [A, B]) { + + if (filepath === '.') { + return + } + try { + if ((A && await A.type()) === 'tree' || B && (await B.type()) === 'tree') { + return + } + } catch (e) { + // ignore + } + + // generate ids + const Aoid = A && await A.oid() || undefined + const Boid = B && await B.oid() || undefined + + const commitChange: Partial = { + hashModified: commitHash1, + hashOriginal: commitHash2, + path: filepath, + } + + // determine modification type + if (Aoid !== Boid) { + commitChange.type = "modified" + } + if (Aoid === undefined) { + commitChange.type = "deleted" + } + if (Boid === undefined || !commitHash2) { + commitChange.type = "added" + } + if (Aoid === undefined && Boid === undefined) { + commitChange.type = "unknown" + } + if (commitChange.type) + return commitChange + else + return undefined + }, + }) + + return result + } + + async compareBranches({ branch, remote }: compareBranchesInput): Promise { + + // Get current branch commits + const headCommits = await git.log({ + ...await this.getGitConfig(), + ref: branch.name, + }); + + // Get remote branch commits + const remoteCommits = await git.log({ + ...await this.getGitConfig(), + ref: `${remote.name}/${branch.name}`, + }); + + // Convert arrays of commit objects to sets of commit SHAs + const headCommitSHAs = new Set(headCommits.map(commit => commit.oid)); + const remoteCommitSHAs = new Set(remoteCommits.map(commit => commit.oid)); + + // Filter out commits that are only in the remote branch + const uniqueRemoteCommits = remoteCommits.filter(commit => !headCommitSHAs.has(commit.oid)); + + // filter out commits that are only in the local branch + const uniqueHeadCommits = headCommits.filter(commit => !remoteCommitSHAs.has(commit.oid)); + + return { + uniqueHeadCommits, + uniqueRemoteCommits, + }; + } + } diff --git a/apps/remixdesktop/src/preload.ts b/apps/remixdesktop/src/preload.ts index 356e262347..50c2fd4e84 100644 --- a/apps/remixdesktop/src/preload.ts +++ b/apps/remixdesktop/src/preload.ts @@ -28,10 +28,17 @@ contextBridge.exposeInMainWorld('electronAPI', { plugins: exposedPLugins.map(name => { return { name, - on: (cb:any) => ipcRenderer.on(`${name}:send`, cb), + on: (cb:any) => { + if(name === 'isogit') console.log('isogit', cb) + ipcRenderer.on(`${name}:send`, cb) + }, send: (message: Partial) => { + //if(name === 'isogit') console.log(name, message) + //if(name === 'isogit') ipcRenderer.invoke(`logger`, name, message) ipcRenderer.send(`${name}:on:${webContentsId}`, message) } } }) + + }) \ No newline at end of file diff --git a/apps/remixdesktop/src/tools/git.ts b/apps/remixdesktop/src/tools/git.ts index 841ba952b0..5f8676122b 100644 --- a/apps/remixdesktop/src/tools/git.ts +++ b/apps/remixdesktop/src/tools/git.ts @@ -1,6 +1,7 @@ import { exec } from 'child_process'; import { CommitObject, ReadCommitResult } from 'isomorphic-git'; import { promisify } from 'util'; +import { cloneInputType, commitInputType, fetchInputType, pullInputType, pushInputType } from "@remix-api"; const execAsync = promisify(exec); const statusTransFormMatrix = (status: string) => { @@ -37,27 +38,56 @@ export const gitProxy = { } }, + async defaultRemoteName(path: string) { + try { + const { stdout } = await execAsync('git remote', { cwd: path }); + const remotes = stdout.trim().split('\n'); + return remotes[0]; + } catch (error) { + throw new Error(`Failed to get the default remote name: ${error.message}`); + } + }, - clone: async (url: string, path: string) => { - const { stdout, stderr } = await execAsync(`git clone ${url} "${path}"`); + clone: async (input: cloneInputType) => { + const { stdout, stderr } = await execAsync(`git clone ${input.url} "${input.dir}"`); }, - async push(path: string, remote: string, src: string, branch: string, force: boolean = false) { - const { stdout, stderr } = await execAsync(`git push ${force ? ' -f' : ''} ${remote} ${src}:${branch}`, { cwd: path }); + async push(path: string, input: pushInputType) { + if(!input.remote || !input.remote.name) { + input.remote = { name: await gitProxy.defaultRemoteName(path), url: '' } + } + const { stdout, stderr } = await execAsync(`git push ${input.force ? ' -f' : ''} ${input.remote.name} ${input.ref.name}:${input.remoteRef.name}`, { cwd: path }); }, - async pull(path: string, remote: string, src: string, branch: string) { - const { stdout, stderr } = await execAsync(`git pull ${remote} ${src}:${branch}`, { cwd: path }); + async pull(path: string, input: pullInputType) { + if(!input.remote || !input.remote.name) { + input.remote = { name: await gitProxy.defaultRemoteName(path), url: '' } + } + const { stdout, stderr } = await execAsync(`git pull ${input.remote.name} ${input.ref.name}:${input.remoteRef.name}`, { cwd: path }); }, - async fetch(path: string, remote: string, branch: string) { - const { stdout, stderr } = await execAsync(`git fetch ${remote} ${branch}`, { cwd: path }); + async fetch(path: string, input: fetchInputType) { + if(!input.remote || !input.remote.name) { + input.remote = { name: await gitProxy.defaultRemoteName(path), url: '' } + } + console.log('fetch', input, path, `git fetch ${input.remote.name} ${(input.ref && input.ref.name) ? input.ref.name : ''}`); + try { + const { stdout, stderr } = await execAsync(`git fetch ${input.remote.name} ${(input.ref && input.ref.name) ? input.ref.name : ''}`, { cwd: path }); + if (stdout) { + console.log('stdout:', stdout); + } + if (stderr) { + console.error('stderr:', stderr); + } + } catch (error) { + console.error('Error during fetch:', error); + } }, - async commit(path: string, message: string) { + async commit(path: string, input: commitInputType) { - await execAsync(`git commit -m '${message}'`, { cwd: path }); + await execAsync(`git commit -m '${input.message}'`, { cwd: path }); const { stdout, stderr } = await execAsync(`git rev-parse HEAD`, { cwd: path }); return stdout; @@ -103,7 +133,7 @@ export const gitProxy = { return 0 }) - + console.log('files', files) return files }, diff --git a/apps/remixdesktop/src/types/index.ts b/apps/remixdesktop/src/types/index.ts index 8c0087b62e..e69de29bb2 100644 --- a/apps/remixdesktop/src/types/index.ts +++ b/apps/remixdesktop/src/types/index.ts @@ -1,9 +0,0 @@ -export type branch = { - name: string - remote: remote -} - -export type remote = { - name: string - url: string -} \ No newline at end of file diff --git a/apps/remixdesktop/tsconfig.json b/apps/remixdesktop/tsconfig.json index ac23558de2..66bf3b35e4 100644 --- a/apps/remixdesktop/tsconfig.json +++ b/apps/remixdesktop/tsconfig.json @@ -9,13 +9,29 @@ "noImplicitAny": false, "sourceMap": true, "baseUrl": ".", - "outDir": "build", + "outDir": "./build", "moduleResolution": "node", "resolveJsonModule": true, "paths": { - "*": ["node_modules/*"] + "*": [ + "node_modules/*" + ], + "@remix-api": [ + "../../libs/remix-api/src/lib/types/git.ts" + ], + "@remix-git": [ + "../../libs/remix-git/src/index.ts", + ], }, - "typeRoots": ["src/**/*.d.ts", "node_modules/@types", "test/**/*.d.ts", "../remix-ide-e2e/src/**/*.d.ts"] + "typeRoots": [ + "src/**/*.d.ts", + "node_modules/@types", + "test/**/*.d.ts", + "../remix-ide-e2e/src/**/*.d.ts" + ] }, - "include": ["src/**/*"] + "include": [ + "src/**/*", + "../../libs/remix-git/src/index.ts" + ] } \ No newline at end of file diff --git a/libs/remix-api/src/index.ts b/libs/remix-api/src/index.ts index 71e343fc8a..96515e169f 100644 --- a/libs/remix-api/src/index.ts +++ b/libs/remix-api/src/index.ts @@ -1 +1,2 @@ -export * from './lib/remix-api' \ No newline at end of file +export * from './lib/remix-api' +export * from './lib/types/git' \ No newline at end of file diff --git a/libs/remix-api/src/lib/plugins/fileSystem-api.ts b/libs/remix-api/src/lib/plugins/fileSystem-api.ts index cba69f007e..84210f2f7d 100644 --- a/libs/remix-api/src/lib/plugins/fileSystem-api.ts +++ b/libs/remix-api/src/lib/plugins/fileSystem-api.ts @@ -1,10 +1,13 @@ -import { commitChange } from "@remix-ui/git"; +import { commitChange } from "@remix-api"; import { IFileSystem } from "@remixproject/plugin-api" // Extended interface with 'diff' method export interface IExtendedFileSystem extends IFileSystem { methods: IFileSystem['methods'] & { + /** Compare the differences between two files */ diff(change: commitChange): Promise + refresh(): Promise + hasGitSubmodules(): Promise isGitRepo(): Promise }; } \ No newline at end of file diff --git a/libs/remix-api/src/lib/plugins/fs-api.ts b/libs/remix-api/src/lib/plugins/fs-api.ts new file mode 100644 index 0000000000..3cded01b06 --- /dev/null +++ b/libs/remix-api/src/lib/plugins/fs-api.ts @@ -0,0 +1,11 @@ +import { StatusEvents } from "@remixproject/plugin-utils"; + +export interface IFs { + events: { + workingDirChanged(path: string): Promise, + } & StatusEvents, + methods: { + selectFolder(path?: string, title?: string, button?: string): Promise + openWindow(path?: string): Promise, + } +} \ No newline at end of file diff --git a/libs/remix-api/src/lib/plugins/git-api.ts b/libs/remix-api/src/lib/plugins/git-api.ts new file mode 100644 index 0000000000..228b0ccc07 --- /dev/null +++ b/libs/remix-api/src/lib/plugins/git-api.ts @@ -0,0 +1,43 @@ +import { StatusEvents } from "@remixproject/plugin-utils" +import { ReadBlobResult, ReadCommitResult, StatusRow } from "isomorphic-git" +import { commitChange, repositoriesInput, repository, cloneInputType, branchesInputType, branch, remote, logInputType, remoteCommitsInputType, pagedCommits, fetchInputType, pullInputType, pushInputType, currentBranchInput, branchInputType, checkoutInputType, addInputType, rmInputType, resolveRefInput, readBlobInput, commitInputType, statusInput, compareBranchesInput, branchDifference, initInputType, updateSubmodulesInput } from "../types/git" + +export interface IGitApi { + events: { + "checkout": () => void + "clone": () => void + "add": () => void + "rm": () => void + "commit": () => void + "branch": () => void + "init": () => void + } & StatusEvents, + methods: { + getCommitChanges(oid1: string, oid2: string): Promise + repositories(input: repositoriesInput): Promise + clone(input: cloneInputType): Promise + branches(input?: branchesInputType): Promise, + remotes(): Promise, + log(input: logInputType): Promise, + remotecommits(input: remoteCommitsInputType): Promise + fetch(input: fetchInputType): Promise + pull(input: pullInputType): Promise + push(input: pushInputType): Promise + currentbranch(input?: currentBranchInput): Promise + branch(input: branchInputType): Promise + checkout(input: checkoutInputType): Promise + add(input: addInputType): Promise + rm(input: rmInputType): Promise + resolveref(input: resolveRefInput): Promise + readblob(input: readBlobInput): Promise + commit(input: commitInputType): Promise + addremote(input: remote): Promise + delremote(input: remote): Promise + status(input?: statusInput): Promise> + compareBranches(input: compareBranchesInput): Promise + init(input?: initInputType): Promise + updateSubmodules: (input: updateSubmodulesInput) => Promise + version: () => Promise + } +} + diff --git a/libs/remix-api/src/lib/plugins/terminal-api.ts b/libs/remix-api/src/lib/plugins/terminal-api.ts new file mode 100644 index 0000000000..e7fc77bab5 --- /dev/null +++ b/libs/remix-api/src/lib/plugins/terminal-api.ts @@ -0,0 +1,10 @@ +import { ITerminal } from "@remixproject/plugin-api/src/lib/terminal" +import { StatusEvents } from "@remixproject/plugin-utils" + +export interface IExtendedTerminalApi extends ITerminal { + events: { + } & StatusEvents + methods: ITerminal['methods'] & { + logHtml(html: string): void + } +} \ No newline at end of file diff --git a/libs/remix-api/src/lib/remix-api.ts b/libs/remix-api/src/lib/remix-api.ts index 2dff94abdc..c2805a602d 100644 --- a/libs/remix-api/src/lib/remix-api.ts +++ b/libs/remix-api/src/lib/remix-api.ts @@ -1,13 +1,14 @@ -import { IGitApi } from "@remix-ui/git" import { IRemixApi } from "@remixproject/plugin-api" import { StatusEvents } from "@remixproject/plugin-utils" import { IConfigApi } from "./plugins/config-api" import { IFileDecoratorApi } from "./plugins/filedecorator-api" import { IExtendedFileSystem } from "./plugins/fileSystem-api" +import { IFs } from "./plugins/fs-api" +import { IGitApi } from "./plugins/git-api" import { INotificationApi } from "./plugins/notification-api" import { ISettings } from "./plugins/settings-api" +import { IExtendedTerminalApi } from "./plugins/terminal-api" import { IFilePanelApi } from "./plugins/filePanel-api" -import { Plugin } from "@remixproject/engine" export interface ICustomRemixApi extends IRemixApi { dgitApi: IGitApi @@ -16,6 +17,9 @@ export interface ICustomRemixApi extends IRemixApi { settings: ISettings fileDecorator: IFileDecoratorApi fileManager: IExtendedFileSystem + isogit: IGitApi, + terminal: IExtendedTerminalApi + fs: IFs filePanel: IFilePanelApi } diff --git a/libs/remix-api/src/lib/types/git.ts b/libs/remix-api/src/lib/types/git.ts new file mode 100644 index 0000000000..7482e95a1d --- /dev/null +++ b/libs/remix-api/src/lib/types/git.ts @@ -0,0 +1,189 @@ +import { ReadCommitResult } from "isomorphic-git" + +export type branchDifference = { + uniqueHeadCommits: ReadCommitResult[], + uniqueRemoteCommits: ReadCommitResult[], +} + + +export type commitChange = { + type: commitChangeType + path: string, + hashModified: string, + hashOriginal: string, + original?: string, + modified?: string, + readonly?: boolean +} + +export type commitChangeTypes = { + "deleted": "D" + "modified": "M" + "added": "A", + "unknown": "?" +} + +export type pagedCommits = { + page: number, + perPage: number, + total: number, + hasNextPage: boolean, + commits: ReadCommitResult[] +} + +export enum syncStatus { + "sync" = "sync", + "publishBranch" = "publishBranch", + "none" = "none", +} + +export type repository = { + name: string + html_url: string + owner: { + login: string + }, + full_name: string + default_branch: string + id: number + url: string +} + +export type branch = { + name: string + remote: remote +} + +export type remote = { + name: string + url: string +} + +export type remoteBranch = { + name: string +} + +export type commitChangeType = keyof commitChangeTypes + +export type initInputType = { + defaultBranch: string +} + +export type author = { + name: string, + email: string +} + +export type updateSubmodulesInput = { + dir?: string + token?: string +} + +export type remoteCommitsInputType = { + owner: string, repo: string, token: string, branch: string, length: number, page: number +} + +export type compareBranchesInput = { + branch: branch, remote: remote +} + +export type fetchInputType = { + remote: remote, + ref?: branch, + remoteRef?: branch, + depth?: number, + singleBranch?: boolean, + relative?: boolean, + quiet?: boolean + author?: author +} + +export type logInputType = { + ref: string, + depth?: number, +} + +export type pullInputType = { + remote: remote, + ref: branch, + remoteRef?: branch + author?: author +} + +export type pushInputType = { + remote: remote, + ref: branch, + remoteRef?: branch, + force?: boolean, + author?: author +} + +export type branchInputType = { + ref: string, + checkout?: boolean + refresh?: boolean + force?: boolean +} + +export type currentBranchInput = { + fs: any, + dir: string +} + +export type checkoutInputType = { + ref: string, + force?: boolean, + remote?: string + refresh?: boolean + fetch?: boolean +} + +export type addInputType = { + filepath: string | string[] +} + +export type rmInputType = { + filepath: string +} + +export type resolveRefInput = { + ref: string +} + +export type readBlobInput = { + oid: string, + filepath: string +} + +export type commitInputType = { + author: { + name: string, + email: string, + }, + message: string, +} + +export type branchesInputType = { + fs?: any + dir?: string +} + +export interface cloneInputType { + url: string, + branch?: string, + depth?: number, + singleBranch?: boolean + workspaceName?: string + workspaceExists?: boolean + token?: string + dir?: string // where the clone should happen on desktop +} + +export interface repositoriesInput { token: string, page?: number, per_page?: number } + +export interface statusInput { ref: string, filepaths?: string[] } + +export type isoGitConfig = { + fs: any, + dir: string, +} \ No newline at end of file diff --git a/libs/remix-git/index.ts b/libs/remix-git/index.ts new file mode 100644 index 0000000000..ae218b1ee3 --- /dev/null +++ b/libs/remix-git/index.ts @@ -0,0 +1 @@ +export * from './src/index' \ No newline at end of file diff --git a/libs/remix-git/src/index.ts b/libs/remix-git/src/index.ts new file mode 100644 index 0000000000..9ba55884b0 --- /dev/null +++ b/libs/remix-git/src/index.ts @@ -0,0 +1,42 @@ +import { currentBranchInput, isoGitConfig, remote } from "@remix-api" +import git from 'isomorphic-git' + +const currentbranch = async (input: currentBranchInput, defaultConfig: isoGitConfig ) => { + console.log('CURRENT BRANCH', input) + + try { + const cmd = input ? defaultConfig ? { ...defaultConfig, ...input } : input : defaultConfig + + const name = await git.currentBranch(cmd) + let remote: remote = undefined + try { + const remoteName = await git.getConfig({ + ...defaultConfig, + path: `branch.${name}.remote` + }) + if (remoteName) { + const remoteUrl = await git.getConfig({ + ...defaultConfig, + path: `remote.${remoteName}.url` + }) + remote = { name: remoteName, url: remoteUrl } + } + + } catch (e) { + // do nothing + } + console.log('NAME', name) + console.log('REMOTE', remote) + + return { + remote: remote, + name: name || '' + } + } catch (e) { + return undefined + } + } + + export const isoGit = { + currentbranch + } \ No newline at end of file diff --git a/libs/remix-ui/editor/src/lib/remix-plugin-types.ts b/libs/remix-ui/editor/src/lib/remix-plugin-types.ts index 9e55e5b55d..6f605f829a 100644 --- a/libs/remix-ui/editor/src/lib/remix-plugin-types.ts +++ b/libs/remix-ui/editor/src/lib/remix-plugin-types.ts @@ -380,7 +380,6 @@ declare interface IDgitSystem { status(cmd: any): any[]; rm(cmd: any): string; log(cmd: any): any[]; - lsfiles(cmd: any): any[]; readblob(cmd: any): { oid: string, blob: Uint8Array } resolveref(cmd: any): string branch(cmd: any): void diff --git a/libs/remix-ui/git/src/components/buttons/sourceControlBase.tsx b/libs/remix-ui/git/src/components/buttons/sourceControlBase.tsx index 7856059c2c..64d36df050 100644 --- a/libs/remix-ui/git/src/components/buttons/sourceControlBase.tsx +++ b/libs/remix-ui/git/src/components/buttons/sourceControlBase.tsx @@ -5,7 +5,7 @@ import { ReadCommitResult } from "isomorphic-git" import React, { createContext, useEffect, useState } from "react" import { FormattedMessage } from "react-intl" import { gitActionsContext } from "../../state/context" -import { branch, remote } from "../../types" +import { branch, remote } from "@remix-api" import { gitPluginContext } from "../gitui" import GitUIButton from "./gituibutton" diff --git a/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx b/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx index b01cc67a40..22879e9a94 100644 --- a/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx +++ b/libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx @@ -4,7 +4,7 @@ import { CustomTooltip } from "@remix-ui/helper" import React, { useEffect, useState } from "react" import { FormattedMessage } from "react-intl" import { gitActionsContext } from "../../state/context" -import { branch, remote } from "../../types" +import { branch, remote } from "@remix-api" import { gitPluginContext } from "../gitui" import GitUIButton from "./gituibutton" import { syncStateContext } from "./sourceControlBase" diff --git a/libs/remix-ui/git/src/components/github/repositoryselect.tsx b/libs/remix-ui/git/src/components/github/repositoryselect.tsx index c4f9da7864..6d8aabb91b 100644 --- a/libs/remix-ui/git/src/components/github/repositoryselect.tsx +++ b/libs/remix-ui/git/src/components/github/repositoryselect.tsx @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'; import { Button } from 'react-bootstrap'; import Select from 'react-select'; import { gitActionsContext } from '../../state/context'; -import { repository } from '../../types'; +import { repository } from '@remix-api'; import { selectStyles, selectTheme } from '../../types/styles'; import { gitPluginContext } from '../gitui'; import { TokenWarning } from '../panels/tokenWarning'; diff --git a/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx b/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx index 6183cccaa4..497f5b6e1f 100644 --- a/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx +++ b/libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from "react"; import { gitActionsContext } from "../../state/context"; -import { repository } from "../../types"; +import { repository } from "@remix-api"; import { gitPluginContext } from "../gitui"; import RepositorySelect from "./repositoryselect"; import { BranchSelect } from "./branchselect"; diff --git a/libs/remix-ui/git/src/components/navigation/branchedetails.tsx b/libs/remix-ui/git/src/components/navigation/branchedetails.tsx index ee3ee88e24..40a40c5b70 100644 --- a/libs/remix-ui/git/src/components/navigation/branchedetails.tsx +++ b/libs/remix-ui/git/src/components/navigation/branchedetails.tsx @@ -2,7 +2,7 @@ import { faCaretUp, faCaretDown, faCaretRight, faArrowUp, faArrowDown, faArrowRo import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import React, { useContext, useEffect } from "react"; import { gitActionsContext } from "../../state/context"; -import { branch } from "../../types"; +import { branch } from "@remix-api"; import GitUIButton from "../buttons/gituibutton"; import { gitPluginContext } from "../gitui"; diff --git a/libs/remix-ui/git/src/components/navigation/commits.tsx b/libs/remix-ui/git/src/components/navigation/commits.tsx index a3cbcb1d2f..a3c59950e3 100644 --- a/libs/remix-ui/git/src/components/navigation/commits.tsx +++ b/libs/remix-ui/git/src/components/navigation/commits.tsx @@ -4,7 +4,7 @@ import { CustomTooltip } from "@remix-ui/helper"; import React, { useEffect } from "react"; import { FormattedMessage } from "react-intl"; import { pluginActionsContext } from "../../state/context"; -import { branch, remote } from "../../types"; +import { branch, remote } from "@remix-api"; import { SourceControlBase } from "../buttons/sourceControlBase"; import { SourceControlButtons } from "../buttons/sourcecontrolbuttons"; import { gitPluginContext } from "../gitui"; diff --git a/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx b/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx index 89d8955414..5648390c98 100644 --- a/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx +++ b/libs/remix-ui/git/src/components/navigation/remotesdetails.tsx @@ -3,7 +3,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { CustomTooltip } from "@remix-ui/helper"; import React, { useContext, useEffect } from "react"; import { gitActionsContext } from "../../state/context"; -import { branch, remote } from "../../types"; +import { remote } from "@remix-api"; import GitUIButton from "../buttons/gituibutton"; import { gitPluginContext } from "../gitui"; diff --git a/libs/remix-ui/git/src/components/panels/branches.tsx b/libs/remix-ui/git/src/components/panels/branches.tsx index 503bea1202..2978e56e1b 100644 --- a/libs/remix-ui/git/src/components/panels/branches.tsx +++ b/libs/remix-ui/git/src/components/panels/branches.tsx @@ -1,7 +1,6 @@ import React, { useEffect, useState } from "react"; import { Alert } from "react-bootstrap"; import { gitActionsContext } from "../../state/context"; -import { remote } from "../../types"; import GitUIButton from "../buttons/gituibutton"; import { gitPluginContext } from "../gitui"; import { LocalBranchDetails } from "./branches/localbranchdetails"; diff --git a/libs/remix-ui/git/src/components/panels/branches/branchdifferencedetails.tsx b/libs/remix-ui/git/src/components/panels/branches/branchdifferencedetails.tsx index 62ce46a696..d50ad0d511 100644 --- a/libs/remix-ui/git/src/components/panels/branches/branchdifferencedetails.tsx +++ b/libs/remix-ui/git/src/components/panels/branches/branchdifferencedetails.tsx @@ -3,7 +3,7 @@ import { Accordion } from "react-bootstrap"; import React, { useEffect, useState } from "react"; import { CommitDetails } from "../commits/commitdetails"; import { CommitsNavigation } from "../../navigation/commits"; -import { branch, remote } from "../../../types"; +import { branch, remote } from "@remix-api"; import { gitActionsContext } from "../../../state/context"; import { gitPluginContext } from "../../gitui"; diff --git a/libs/remix-ui/git/src/components/panels/branches/branchdifferences.tsx b/libs/remix-ui/git/src/components/panels/branches/branchdifferences.tsx index 846d0230d1..86d4584724 100644 --- a/libs/remix-ui/git/src/components/panels/branches/branchdifferences.tsx +++ b/libs/remix-ui/git/src/components/panels/branches/branchdifferences.tsx @@ -1,4 +1,4 @@ -import { branch, remote } from "../../../types"; +import { branch, remote } from "@remix-api"; import React, { useEffect, useState } from "react"; import { gitPluginContext } from "../../gitui"; import { CommitDetails } from "../commits/commitdetails"; diff --git a/libs/remix-ui/git/src/components/panels/branches/localbranchdetails.tsx b/libs/remix-ui/git/src/components/panels/branches/localbranchdetails.tsx index c3fe63e752..6608bd2ff3 100644 --- a/libs/remix-ui/git/src/components/panels/branches/localbranchdetails.tsx +++ b/libs/remix-ui/git/src/components/panels/branches/localbranchdetails.tsx @@ -4,7 +4,7 @@ import { Accordion } from "react-bootstrap"; import { CommitDetailsNavigation } from "../../navigation/commitdetails"; import { gitActionsContext } from "../../../state/context"; import { gitPluginContext } from "../../gitui"; -import { branch } from "../../../types"; +import { branch } from "@remix-api"; import { BrancheDetailsNavigation } from "../../navigation/branchedetails"; import { CommitDetailsItems } from "../commits/commitdetailsitem"; import { CommitDetails } from "../commits/commitdetails"; diff --git a/libs/remix-ui/git/src/components/panels/branches/remotebranchedetails.tsx b/libs/remix-ui/git/src/components/panels/branches/remotebranchedetails.tsx index 1b21e1eb76..9e4f2ed06b 100644 --- a/libs/remix-ui/git/src/components/panels/branches/remotebranchedetails.tsx +++ b/libs/remix-ui/git/src/components/panels/branches/remotebranchedetails.tsx @@ -4,7 +4,7 @@ import { Accordion } from "react-bootstrap"; import { CommitDetailsNavigation } from "../../navigation/commitdetails"; import { gitActionsContext } from "../../../state/context"; import { gitPluginContext } from "../../gitui"; -import { branch } from "../../../types"; +import { branch } from "@remix-api"; import { BrancheDetailsNavigation } from "../../navigation/branchedetails"; import { CommitDetailsItems } from "../commits/commitdetailsitem"; import { CommitDetails } from "../commits/commitdetails"; diff --git a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx index fa21eb7d4f..14f522c25f 100644 --- a/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx +++ b/libs/remix-ui/git/src/components/panels/commands/pushpull.tsx @@ -4,7 +4,7 @@ import { gitPluginContext } from "../../gitui"; import { selectStyles, selectTheme } from "../../../types/styles"; import Select, { Options, OptionsOrGroups } from 'react-select' import GitUIButton from "../../buttons/gituibutton"; -import { remote } from "../../../types"; +import { remote } from "@remix-api"; import { relative } from "path"; export const PushPull = () => { diff --git a/libs/remix-ui/git/src/components/panels/commits/commitdetailsitem.tsx b/libs/remix-ui/git/src/components/panels/commits/commitdetailsitem.tsx index 7115347618..fd111b47e6 100644 --- a/libs/remix-ui/git/src/components/panels/commits/commitdetailsitem.tsx +++ b/libs/remix-ui/git/src/components/panels/commits/commitdetailsitem.tsx @@ -1,4 +1,4 @@ -import { branch, commitChange } from "../../../types"; +import { branch, commitChange } from "@remix-api"; import React from "react"; import path from "path"; import { gitActionsContext, pluginActionsContext } from "../../../state/context"; diff --git a/libs/remix-ui/git/src/components/panels/remoteselect.tsx b/libs/remix-ui/git/src/components/panels/remoteselect.tsx index f2eedadfb3..97e2abd64b 100644 --- a/libs/remix-ui/git/src/components/panels/remoteselect.tsx +++ b/libs/remix-ui/git/src/components/panels/remoteselect.tsx @@ -5,7 +5,7 @@ import { gitPluginContext } from "../gitui"; import { default as dateFormat } from "dateformat"; import { RemotesDetailsNavigation } from "../navigation/remotesdetails"; import { Accordion } from "react-bootstrap"; -import { remote } from "../../types"; +import { remote } from "@remix-api"; import { RemoteBranchDetails } from "./branches/remotebranchedetails"; export interface RemoteSelectProps { diff --git a/libs/remix-ui/git/src/components/panels/remotesimport.tsx b/libs/remix-ui/git/src/components/panels/remotesimport.tsx index 646546c1a4..a456de8fe4 100644 --- a/libs/remix-ui/git/src/components/panels/remotesimport.tsx +++ b/libs/remix-ui/git/src/components/panels/remotesimport.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from "react"; import { Alert, Button } from "react-bootstrap"; import { gitActionsContext } from "../../state/context"; -import { repository } from "../../types"; +import { repository } from "@remix-api"; import { gitPluginContext } from "../gitui"; import Select from 'react-select' import { selectStyles, selectTheme } from "../../types/styles"; diff --git a/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolitem.tsx b/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolitem.tsx index 64617b17e1..27f87d1c04 100644 --- a/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolitem.tsx +++ b/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolitem.tsx @@ -1,4 +1,4 @@ -import { commitChange, fileStatusResult, sourceControlGroup } from "../../../types"; +import { fileStatusResult, sourceControlGroup } from "../../../types"; import React from "react"; import path from "path"; import { gitActionsContext, pluginActionsContext } from "../../../state/context"; @@ -6,6 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faGlobe } from "@fortawesome/free-solid-svg-icons"; import { SourceControlItemButtons } from "./sourcontrolitembuttons"; import { removeSlash } from "../../../utils"; +import { commitChange } from "@remix-api"; export interface SourceControlItemProps { file: fileStatusResult; diff --git a/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcontrolitembuttons.tsx b/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcontrolitembuttons.tsx index d1ba05ef1f..572180329c 100644 --- a/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcontrolitembuttons.tsx +++ b/libs/remix-ui/git/src/components/panels/sourcecontrol/sourcontrolitembuttons.tsx @@ -1,4 +1,4 @@ -import { commitChange, fileStatusResult, sourceControlGroup } from "../../../types"; +import { fileStatusResult, sourceControlGroup } from "../../../types"; import React from "react"; import path from "path"; import { gitActionsContext, pluginActionsContext } from "../../../state/context"; diff --git a/libs/remix-ui/git/src/index.ts b/libs/remix-ui/git/src/index.ts index 677c174059..57959fe7e1 100644 --- a/libs/remix-ui/git/src/index.ts +++ b/libs/remix-ui/git/src/index.ts @@ -1,4 +1,4 @@ export * from './types' export { GitUI } from './components/gitui' -export { commitChange, commitChangeType, remote, branch } from './types' +export { commitChange, commitChangeType, remote, branch } from '@remix-api' export * from './types/styles' \ No newline at end of file diff --git a/libs/remix-ui/git/src/lib/gitactions.ts b/libs/remix-ui/git/src/lib/gitactions.ts index 314d9143e5..3362e00d8d 100644 --- a/libs/remix-ui/git/src/lib/gitactions.ts +++ b/libs/remix-ui/git/src/lib/gitactions.ts @@ -1,13 +1,13 @@ import { ReadBlobResult, ReadCommitResult } from "isomorphic-git"; import React from "react"; import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails, setCurrenHead } from "../state/gitpayload"; -import { GitHubUser, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository, userEmails } from '../types'; +import { GitHubUser, gitActionDispatch, statusMatrixType, gitState, gitLog, fileStatusResult, userEmails } from '../types'; import { removeSlash } from "../utils"; import { disableCallBacks, enableCallBacks } from "./listeners"; import { ModalTypes } from "@remix-ui/app"; import { setFileDecorators } from "./pluginActions"; import { Plugin } from "@remixproject/engine"; -import { CustomRemixApi } from "@remix-api"; +import { addInputType, branch, branchDifference, checkoutInputType, cloneInputType, commitChange, CustomRemixApi, fetchInputType, pullInputType, pushInputType, remote, rmInputType } from "@remix-api"; import { file } from "jszip"; export const fileStatuses = [ @@ -54,7 +54,7 @@ export const getBranches = async () => { } export const getRemotes = async () => { - const remotes: remote[] = await plugin.call('dgitApi', "remotes"); + const remotes: remote[] = await plugin.call('dgitApi', 'remotes'); dispatch(setRemotes(remotes)); } @@ -226,7 +226,7 @@ export const addall = async (files: fileStatusResult[]) => { } } -export const add = async (filepath: addInput) => { +export const add = async (filepath: addInputType) => { try { if (typeof filepath.filepath === "string") { filepath.filepath = removeSlash(filepath.filepath) @@ -252,7 +252,7 @@ const getLastCommmit = async () => { } } -export const rm = async (args: rmInput) => { +export const rm = async (args: rmInputType) => { await plugin.call('dgitApi', 'rm', { filepath: removeSlash(args.filepath), }); @@ -288,7 +288,7 @@ export const checkoutfile = async (filename: string) => { } } -export const checkout = async (cmd: checkoutInput) => { +export const checkout = async (cmd: checkoutInputType) => { await disableCallBacks(); await plugin.call('fileManager', 'closeAllFiles') @@ -705,6 +705,7 @@ export const diff = async (commitChange: commitChange) => { } export const getCommitChanges = async (oid1: string, oid2: string, branch?: branch, remote?: remote) => { + console.log('getCommitChanges', oid1, oid2, branch, remote) try { let log try { @@ -717,6 +718,7 @@ export const getCommitChanges = async (oid1: string, oid2: string, branch?: bran console.log(e, 'log error') } if (log) { + console.log('log', log) const foundCommit = log.find((commit: ReadCommitResult) => commit.oid === oid2) if (!foundCommit && remote) { diff --git a/libs/remix-ui/git/src/lib/listeners.ts b/libs/remix-ui/git/src/lib/listeners.ts index 66c94bdd8d..871458c8fb 100644 --- a/libs/remix-ui/git/src/lib/listeners.ts +++ b/libs/remix-ui/git/src/lib/listeners.ts @@ -65,7 +65,20 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch { + loadFileQueue.enqueue(async () => { + loadFiles() + }) + loadFileQueue.enqueue(async () => { + gitlog() + }) + loadFileQueue.enqueue(async () => { + getBranches() + }) + loadFileQueue.enqueue(async () => { + getRemotes() + }) + }) plugin.on("filePanel", "setWorkspace", async (x: any) => { gitDispatch(setCanUseApp(x && !x.isLocalhost && x.name)) loadFileQueue.enqueue(async () => { diff --git a/libs/remix-ui/git/src/lib/pluginActions.ts b/libs/remix-ui/git/src/lib/pluginActions.ts index ece2b3953a..94d9d6bcf5 100644 --- a/libs/remix-ui/git/src/lib/pluginActions.ts +++ b/libs/remix-ui/git/src/lib/pluginActions.ts @@ -1,9 +1,9 @@ -import { commitChange, fileStatusResult, gitActionDispatch, gitState } from "../types" +import { fileStatusResult, gitActionDispatch, gitState } from "../types" import { fileDecoration, fileDecorationType } from "@remix-ui/file-decorators" import { removeSlash } from "../utils" import { getFilesByStatus } from "./fileHelpers" -import { CustomRemixApi } from "@remix-api"; +import { commitChange, CustomRemixApi } from "@remix-api"; import { Plugin } from "@remixproject/engine"; let plugin: Plugin, gitDispatch: React.Dispatch, loaderDispatch: React.Dispatch diff --git a/libs/remix-ui/git/src/state/actions.ts b/libs/remix-ui/git/src/state/actions.ts index 4d35aa1b8c..3c2049771d 100644 --- a/libs/remix-ui/git/src/state/actions.ts +++ b/libs/remix-ui/git/src/state/actions.ts @@ -1,6 +1,6 @@ import { ReadCommitResult } from "isomorphic-git" -import { branch, branchDifference, commitChange, fileStatusResult, GitHubUser, gitLog, pagedCommits, remote, remoteBranch, repository, userEmails } from "../types" - +import { fileStatusResult, GitHubUser, gitLog, userEmails } from "../types" +import { branch, branchDifference, commitChange, pagedCommits, remote, remoteBranch, repository } from '@remix-api' export interface ActionPayloadTypes { FILE_STATUS: fileStatusResult[], FILE_STATUS_MERGE: fileStatusResult[] diff --git a/libs/remix-ui/git/src/state/context.tsx b/libs/remix-ui/git/src/state/context.tsx index 4608406a7f..ed58ac1a3f 100644 --- a/libs/remix-ui/git/src/state/context.tsx +++ b/libs/remix-ui/git/src/state/context.tsx @@ -1,12 +1,13 @@ +import { branch, addInputType, checkoutInputType, cloneInputType, commitChange, fetchInputType, pullInputType, pushInputType, remote, rmInputType } from "@remix-api" import { ReadCommitResult } from "isomorphic-git" import React from "react" -import { addInput, branch, checkoutInput, cloneInputType, commitChange, fetchInputType, fileStatusResult, gitLog, gitState, pullInputType, pushInputType, remote, rmInput } from "../types" +import { fileStatusResult, gitLog, gitState } from "../types" export interface gitActions { removeRemote(remote: remote): void clone(input: cloneInputType): Promise - add(input: addInput): Promise - rm(input: rmInput): Promise + add(input: addInputType): Promise + rm(input: rmInputType): Promise commit(message: string): Promise addall(files: fileStatusResult[]): Promise push(input: pushInputType): Promise @@ -14,7 +15,7 @@ export interface gitActions { fetch(input: fetchInputType): Promise repositories(): Promise checkoutfile(file: string): Promise - checkout(input: checkoutInput): Promise + checkout(input: checkoutInputType): Promise createBranch(branch: string): Promise remoteBranches(owner: string, repo: string): Promise getCommitChanges(oid1: string, oid2: string, branch?: branch, remote?: remote): Promise diff --git a/libs/remix-ui/git/src/state/gitpayload.ts b/libs/remix-ui/git/src/state/gitpayload.ts index c075331d6e..338dbd017a 100644 --- a/libs/remix-ui/git/src/state/gitpayload.ts +++ b/libs/remix-ui/git/src/state/gitpayload.ts @@ -1,6 +1,6 @@ import { ReadCommitResult } from "isomorphic-git" -import { GitHubUser, branch, commitChange, fileStatusResult, remote, pagedCommits, branchDifference, gitLog, repository, userEmails } from "../types" -import { Endpoints } from "@octokit/types" +import { GitHubUser, fileStatusResult, gitLog, userEmails } from "../types" +import { repository, pagedCommits, branch, remote, commitChange, branchDifference } from "@remix-api" export const fileStatus = (files: fileStatusResult[]) => { return { diff --git a/libs/remix-ui/git/src/state/gitreducer.tsx b/libs/remix-ui/git/src/state/gitreducer.tsx index 674e1e69a5..1b41ffd43c 100644 --- a/libs/remix-ui/git/src/state/gitreducer.tsx +++ b/libs/remix-ui/git/src/state/gitreducer.tsx @@ -1,6 +1,6 @@ -import { ReadCommitResult } from "isomorphic-git" -import { allChangedButNotStagedFiles, getFilesByStatus, getFilesWithNotModifiedStatus } from "../lib/fileHelpers" -import { branch, commitChange, defaultGitState, fileStatusResult, gitState, setRemoteBranchCommitsAction, setLocalBranchCommitsAction, setBranchDifferencesAction, setDefaultRemoteAction, setRemotesAction, setUpstreamAction } from "../types" +import { commitChange } from "@remix-api" +import { allChangedButNotStagedFiles, getFilesByStatus } from "../lib/fileHelpers" +import { defaultGitState, fileStatusResult, gitState } from "../types" import { Actions } from "./actions" export const gitReducer = (state: gitState = defaultGitState, action: Actions): gitState => { diff --git a/libs/remix-ui/git/src/types/index.ts b/libs/remix-ui/git/src/types/index.ts index 9ed9a292ed..efe0553066 100644 --- a/libs/remix-ui/git/src/types/index.ts +++ b/libs/remix-ui/git/src/types/index.ts @@ -1,156 +1,9 @@ import { Endpoints } from "@octokit/types" -import { IRemixApi } from "@remixproject/plugin-api" -import { LibraryProfile, StatusEvents } from "@remixproject/plugin-utils" -import { CommitObject, ReadBlobResult, ReadCommitResult, StatusRow } from "isomorphic-git" +import { branch, branchDifference, commitChange, pagedCommits, remote, remoteBranch, repository, syncStatus } from "@remix-api" +import { ReadCommitResult } from "isomorphic-git" export type GitHubUser = Partial export type userEmails = Endpoints["GET /user/emails"]["response"]["data"] -export interface IGitApi { - events: { - "checkout": () => void - "clone": () => void - "add": () => void - "rm": () => void - "commit": () => void - "branch": () => void - "init": () => void - } & StatusEvents, - methods: { - getCommitChanges(oid1: string, oid2: string): Promise - repositories(input: repositoriesInput): Promise - clone(input: cloneInputType): Promise - branches(input?: branchesInput): Promise, - remotes(): Promise, - log(cmd: { ref: string }): Promise, - remotecommits(input: remoteCommitsInputType): Promise - fetch(input: fetchInputType): Promise - pull(input: pullInputType): Promise - push(input: pushInputType): Promise - currentbranch(input?: currentBranchInput): Promise - branch(input: branchInputType): Promise - checkout(input: checkoutInput): Promise - add(input: addInput): Promise - rm(input: rmInput): Promise - resolveref(input: resolveRefInput): Promise - readblob(input: readBlobInput): Promise - commit(input: commitInput): Promise - addremote(input: remote): Promise - delremote(input: remote): Promise - status(input?: statusInput): Promise> - compareBranches(input: compareBranchesInput): Promise - init(input?: initInput): Promise - updateSubmodules: (input: updateSubmodulesInput) => Promise - } -} - -export type initInput = { - defaultBranch: string -} - -export type updateSubmodulesInput = { - dir?: string - token?: string -} - -export type remoteCommitsInputType = { - owner: string, repo: string, token: string, branch: string, length: number, page: number -} - -export type compareBranchesInput = { - branch: branch, remote: remote -} - -export type fetchInputType = { - remote: remote, - ref?: branch, - remoteRef?: branch, - depth?: number, - singleBranch?: boolean, - relative?: boolean, - quiet?: boolean -} - -export type pullInputType = { - remote: remote, ref: branch, remoteRef?: branch -} - -export type pushInputType = { - remote: remote, ref: branch, remoteRef?: branch, force?: boolean -} - -export type branchInputType = { - ref: string, - checkout?: boolean - refresh?: boolean - force?: boolean -} - -export type currentBranchInput = { - fs: any, - dir: string -} - -export type checkoutInput = { - ref: string, - force?: boolean, - remote?: string - refresh?: boolean - fetch?: boolean -} - -export type addInput = { - filepath: string | string[] -} - -export type rmInput = { - filepath: string -} - -export type resolveRefInput = { - ref: string -} - -export type readBlobInput = { - oid: string, - filepath: string -} - -export type commitInput = { - author: { - name: string, - email: string, - }, - message: string, -} - -export type branchesInput = { - fs?: any - dir?: string -} - -export interface cloneInputType { - url: string, - branch?: string, - depth?: number, - singleBranch?: boolean - workspaceName?: string - workspaceExists?: boolean - token?: string -} - -export interface repositoriesInput { token: string, page?: number, per_page?: number } - -export interface statusInput { ref: string, filepaths?: string[] } - -export const dGitProfile: LibraryProfile = { - name: 'dgitApi', - methods: ['clone', 'branches', 'remotes', 'getCommitChanges', 'log', 'remotecommits'], -} - -export interface customGitApi extends IRemixApi { - dgit: IGitApi -} - export type gitState = { currentBranch: branch currentHead: string @@ -193,19 +46,6 @@ export type gitLog = { export type remoteBranchIdentifier = `${string}/${string}` -export type branchDifference = { - uniqueHeadCommits: ReadCommitResult[], - uniqueRemoteCommits: ReadCommitResult[], -} - -export type pagedCommits = { - page: number, - perPage: number, - total: number, - hasNextPage: boolean, - commits: ReadCommitResult[] -} - export type loaderState = { branches: boolean remotes: boolean @@ -214,57 +54,6 @@ export type loaderState = { plugin: boolean } -export type commitChangeTypes = { - "deleted": "D" - "modified": "M" - "added": "A", - "unknown": "?" -} - -export enum syncStatus { - "sync" = "sync", - "publishBranch" = "publishBranch", - "none" = "none", -} - -export type commitChangeType = keyof commitChangeTypes - -export type commitChange = { - type: commitChangeType - path: string, - hashModified: string, - hashOriginal: string, - original?: string, - modified?: string, - readonly?: boolean -} - -export type repository = { - name: string - html_url: string - owner: { - login: string - }, - full_name: string - default_branch: string - id: number - url: string -} - -export type branch = { - name: string - remote: remote -} - -export type remote = { - name: string - url: string -} - -export type remoteBranch = { - name: string -} - export const defaultGitState: gitState = { currentBranch: { name: "", remote: { name: "", url: "" } }, currentHead: "", diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 74b024f98b..ca828cddcb 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -42,10 +42,10 @@ import { ROOT_PATH, slitherYml, solTestYml, tsSolTestYml } from '../utils/consta import { IndexedDBStorage } from '../../../../../../apps/remix-ide/src/app/files/filesystems/indexedDB' import { getUncommittedFiles } from '../utils/gitStatusFilter' import { AppModal, ModalTypes } from '@remix-ui/app' -import { branch, cloneInputType, IGitApi } from '@remix-ui/git' + import * as templates from '@remix-project/remix-ws-templates' import { Plugin } from "@remixproject/engine"; -import { CustomRemixApi } from '@remix-api' +import { CustomRemixApi, branch, cloneInputType } from '@remix-api' declare global { interface Window { @@ -204,6 +204,7 @@ export const createWorkspace = async ( }, 5000) } else if (!isEmpty && !(isGitRepo && createCommit)) await loadWorkspacePreset(workspaceTemplateName, opts) cb && cb(null, workspaceName) + if (workspaceTemplateName === 'semaphore' || workspaceTemplateName === 'hashchecker' || workspaceTemplateName === 'rln') { const isCircomActive = await plugin.call('manager', 'isActive', 'circuit-compiler') if (!isCircomActive) await plugin.call('manager', 'activatePlugin', 'circuit-compiler') @@ -508,6 +509,7 @@ export const switchToWorkspace = async (name: string) => { await plugin.fileProviders.workspace.setWorkspace(name) await plugin.setWorkspace({ name, isLocalhost: false }) const isGitRepo = await plugin.fileManager.isGitRepo() + dispatch(setMode('browser')) dispatch(setCurrentWorkspace({ name, isGitRepo })) dispatch(setReadOnlyMode(false)) @@ -665,10 +667,9 @@ export const cloneRepository = async (url: string) => { dispatch(cloneRepositoryRequest()) promise .then(async () => { - if (!plugin.registry.get('platform').api.isDesktop()) { - const isActive = await plugin.call('manager', 'isActive', 'dgit') - if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') - } + const isActive = await plugin.call('manager', 'isActive', 'dgit') + + if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') await fetchWorkspaceDirectory(ROOT_PATH) const workspacesPath = plugin.fileProviders.workspace.workspacesPath const branches = await getGitRepoBranches(workspacesPath + '/' + repoName) @@ -753,7 +754,7 @@ export const getGitRepoCurrentBranch = async (workspaceName: string) => { } export const showAllBranches = async () => { - if (plugin.registry.get('platform').api.isDesktop()) return + const isActive = await plugin.call('manager', 'isActive', 'dgit') if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit') plugin.call('menuicons', 'select', 'dgit')