resolveDirectory

pull/1647/head
bunsenstraat 3 years ago
parent d21a0c4de1
commit af3fffd3ce
  1. 3
      apps/remix-ide-e2e/src/commands/executeScript.ts
  2. 2
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  3. 18
      apps/remix-ide/src/app/files/fileProvider.js
  4. 4
      apps/remix-ide/src/app/ui/landing-page/landing-page.js
  5. 8
      apps/remix-ide/src/publishToStorage.js
  6. 4
      apps/remix-ide/src/remixAppManager.js
  7. 2
      libs/remix-core-plugin/src/lib/compiler-content-imports.ts
  8. 6
      libs/remix-ui/workspace/src/lib/actions/events.ts
  9. 4
      libs/remix-ui/workspace/src/lib/providers/FileSystemProvider.tsx

@ -4,9 +4,8 @@ import EventEmitter from 'events'
class ExecuteScript extends EventEmitter {
command (this: NightwatchBrowser, script: string): NightwatchBrowser {
this.api
.clearEditableContent('*[data-id="terminalCliInput"]')
.clearValue('*[data-id="terminalCliInput"]')
.click('*[data-id="terminalCli"]')
.setValue('*[data-id="terminalCliInput"]', [this.api.Keys.CONTROL, 'a', this.api.Keys.DELETE])
.sendKeys('*[data-id="terminalCliInput"]', script)
.sendKeys('*[data-id="terminalCliInput"]', this.api.Keys.ENTER)
.sendKeys('*[data-id="terminalCliInput"]', this.api.Keys.ENTER)

@ -4,7 +4,7 @@ import init from '../helpers/init'
module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done, 'http://127.0.0.1:8080?plugins=solidity,udapp', false)
init(browser, done, 'http://localhost:8080?plugins=solidity,udapp', false)
},
'Should execution a simple console command': function (browser: NightwatchBrowser) {

@ -1,6 +1,7 @@
'use strict'
import { CompilerImports } from '@remix-project/core-plugin'
import { ConsoleLogs } from 'libs/remix-lib/src/helpers/hhconsoleSigs'
const EventManager = require('events')
const modalDialogCustom = require('../ui/modal-dialog-custom')
const tooltip = require('../ui/tooltip')
@ -57,11 +58,11 @@ class FileProvider {
this.getNormalizedName(value),
true,
(loadingMsg) => { tooltip(loadingMsg) },
(error, content, cleanUrl, type, url) => {
async (error, content, cleanUrl, type, url) => {
if (error) {
modalDialogCustom.alert(error)
} else {
this.addExternal(type + '/' + cleanUrl, content, url)
await this.addExternal(type + '/' + cleanUrl, content, url)
}
}
)
@ -134,9 +135,11 @@ class FileProvider {
if (!await window.remixFileSystem.exists(currentCheck)) {
try {
await window.remixFileSystem.mkdir(currentCheck)
console.log('folder add', currentCheck, this._normalizePath(currentCheck))
this.event.emit('folderAdded', this._normalizePath(currentCheck))
console.log("folderd added")
} catch (error) {
console.log(error)
}
}
}
@ -144,9 +147,9 @@ class FileProvider {
}
// this will not add a folder as readonly but keep the original url to be able to restore it later
addExternal (path, content, url) {
async addExternal (path, content, url) {
if (url) this.addNormalizedName(path, url)
return this.set(path, content)
return await this.set(path, content)
}
isReadOnly (path) {
@ -277,18 +280,21 @@ class FileProvider {
path = this.removePrefix(path)
if (path.indexOf('/') !== 0) path = '/' + path
try {
console.log('res dir', path)
const files = await window.remixFileSystem.readdir(path)
const ret = {}
console.log(files)
if (files) {
for (let element of files) {
path = path.replace(/^\/|\/$/g, '') // remove first and last slash
element = element.replace(/^\/|\/$/g, '') // remove first and last slash
const absPath = (path === '/' ? '' : path) + '/' + element
console.log("stat ", absPath, await window.remixFileSystem.stat(absPath))
ret[absPath.indexOf('/') === 0 ? absPath.substr(1, absPath.length) : absPath] = { isDirectory: (await window.remixFileSystem.stat(absPath)).isDirectory() }
// ^ ret does not accept path starting with '/'
}
}
console.log("return", ret)
if (cb) cb(null, ret)
return ret
} catch (error) {

@ -255,12 +255,12 @@ export class LandingPage extends ViewPlugin {
contentImport.import(
target,
(loadingMsg) => { tooltip(loadingMsg) },
(error, content, cleanUrl, type, url) => {
async (error, content, cleanUrl, type, url) => {
if (error) {
modalDialogCustom.alert(title, error.message || error)
} else {
try {
fileProviders.workspace.addExternal(type + '/' + cleanUrl, content, url)
await fileProviders.workspace.addExternal(type + '/' + cleanUrl, content, url)
this.verticalIcons.select('filePanel')
} catch (e) {
modalDialogCustom.alert(title, e.message)

@ -21,8 +21,8 @@ export default function publish (storage, fileProvider, fileManager, contract) {
})}</div>`
modalDialogCustom.alert(`Published ${contract.name}'s Metadata`, yo`<span>Metadata of "${contract.name.toLowerCase()}" was published successfully.<br> <pre>${result}</pre> </span>`)
}
}, (item) => { // triggered each time there's a new verified publish (means hash correspond)
fileProvider.addExternal('swarm/' + item.hash, item.content)
}, async (item) => { // triggered each time there's a new verified publish (means hash correspond)
await fileProvider.addExternal('swarm/' + item.hash, item.content)
})
} else {
publishOnIpfs(contract, fileManager, function (err, uploaded) {
@ -38,8 +38,8 @@ export default function publish (storage, fileProvider, fileManager, contract) {
})}</div>`
modalDialogCustom.alert(`Published ${contract.name}'s Metadata`, yo`<span>Metadata of "${contract.name.toLowerCase()}" was published successfully.<br> <pre>${result}</pre> </span>`)
}
}, (item) => { // triggered each time there's a new verified publish (means hash correspond)
fileProvider.addExternal('ipfs/' + item.hash, item.content)
}, async (item) => { // triggered each time there's a new verified publish (means hash correspond)
await fileProvider.addExternal('ipfs/' + item.hash, item.content)
})
}
}

@ -155,6 +155,10 @@ export class RemixAppManager extends PluginManager {
pattern: [],
sticky: true
})
//await this.call('filePanel', 'deleteWorkspace', `default_workspace`)
console.log("----------------------------------------------")
await this.call('filePanel', 'createWorkspace', `workspace_${Date.now()}`, true)
await this.call('fileManager', 'setFile', `one/two/files.js` ,"test")
}
}

@ -97,7 +97,7 @@ export class CompilerImports extends Plugin {
try {
const provider = await this.call('fileManager', 'getProviderOf', null)
const path = targetPath || type + '/' + cleanUrl
if (provider) provider.addExternal('.deps/' + path, content, url)
if (provider) await provider.addExternal('.deps/' + path, content, url)
} catch (err) {
console.error(err)
}

@ -140,19 +140,21 @@ const fileAdded = async (filePath: string) => {
}
const folderAdded = async (folderPath: string) => {
console.log('folder add event', folderPath)
const provider = plugin.fileManager.currentFileProvider()
const path = extractParentFromKey(folderPath) || provider.workspace || provider.type || ''
let path = extractParentFromKey(folderPath) || provider.workspace || provider.type || ''
const promise = new Promise((resolve) => {
provider.resolveDirectory(path, (error, fileTree) => {
if (error) console.error(error)
console.log('resolve', JSON.stringify(fileTree))
resolve(fileTree)
})
})
promise.then((files) => {
folderPath = folderPath.replace(/^\/+/, '')
console.log('folderd add success', path, folderPath, JSON.stringify(files))
dispatch(folderAddedSuccess(path, folderPath, files))
}).catch((error) => {
console.error(error)

@ -190,6 +190,10 @@ export const FileSystemProvider = (props: WorkspaceProps) => {
})
}
useEffect(() => {
console.log(JSON.stringify(fs.browser.files))
},[JSON.stringify(fs.browser.files).length])
const value = {
fs,
modal,

Loading…
Cancel
Save