Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
bf80ca98
Commit
bf80ca98
authored
Apr 29, 2021
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed remixd set and createDir implementation, changed fileProvider's exist implementation
parent
3a1a03a8
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
61 additions
and
68 deletions
+61
-68
compiler-imports.js
apps/remix-ide/src/app/compiler/compiler-imports.js
+3
-3
contextView.js
apps/remix-ide/src/app/editor/contextView.js
+3
-2
fileManager.js
apps/remix-ide/src/app/files/fileManager.js
+1
-1
fileProvider.js
apps/remix-ide/src/app/files/fileProvider.js
+1
-2
remixDProvider.js
apps/remix-ide/src/app/files/remixDProvider.js
+4
-5
file-panel.js
apps/remix-ide/src/app/panels/file-panel.js
+1
-1
testTab.js
apps/remix-ide/src/app/tabs/testTab/testTab.js
+3
-1
renderer.js
apps/remix-ide/src/app/ui/renderer.js
+3
-2
helper.js
apps/remix-ide/src/lib/helper.js
+6
-8
file-explorer.tsx
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
+4
-2
remixdClient.ts
libs/remixd/src/services/remixdClient.ts
+32
-41
No files found.
apps/remix-ide/src/app/compiler/compiler-imports.js
View file @
bf80ca98
...
@@ -121,9 +121,7 @@ module.exports = class CompilerImports extends Plugin {
...
@@ -121,9 +121,7 @@ module.exports = class CompilerImports extends Plugin {
if
(
provider
.
type
===
'localhost'
&&
!
provider
.
isConnected
())
{
if
(
provider
.
type
===
'localhost'
&&
!
provider
.
isConnected
())
{
return
reject
(
new
Error
(
`file provider
${
provider
.
type
}
not available while trying to resolve
${
url
}
`
))
return
reject
(
new
Error
(
`file provider
${
provider
.
type
}
not available while trying to resolve
${
url
}
`
))
}
}
provider
.
exists
(
url
,
(
error
,
exist
)
=>
{
provider
.
exists
(
url
).
then
(
exist
=>
{
if
(
error
)
return
reject
(
error
)
/*
/*
if the path is absolute and the file does not exist, we can stop here
if the path is absolute and the file does not exist, we can stop here
Doesn't make sense to try to resolve "localhost/node_modules/localhost/node_modules/<path>" and we'll end in an infinite loop.
Doesn't make sense to try to resolve "localhost/node_modules/localhost/node_modules/<path>" and we'll end in an infinite loop.
...
@@ -162,6 +160,8 @@ module.exports = class CompilerImports extends Plugin {
...
@@ -162,6 +160,8 @@ module.exports = class CompilerImports extends Plugin {
if
(
error
)
return
reject
(
error
)
if
(
error
)
return
reject
(
error
)
resolve
(
content
)
resolve
(
content
)
})
})
}).
catch
(
error
=>
{
return
reject
(
error
)
})
})
}
}
})
})
...
...
apps/remix-ide/src/app/editor/contextView.js
View file @
bf80ca98
...
@@ -109,10 +109,11 @@ class ContextView {
...
@@ -109,10 +109,11 @@ class ContextView {
if
(
filename
!==
this
.
_deps
.
config
.
get
(
'currentFile'
))
{
if
(
filename
!==
this
.
_deps
.
config
.
get
(
'currentFile'
))
{
const
provider
=
this
.
_deps
.
fileManager
.
fileProviderOf
(
filename
)
const
provider
=
this
.
_deps
.
fileManager
.
fileProviderOf
(
filename
)
if
(
provider
)
{
if
(
provider
)
{
provider
.
exists
(
filename
,
(
error
,
exist
)
=>
{
provider
.
exists
(
filename
).
then
(
exist
=>
{
if
(
error
)
return
console
.
log
(
error
)
this
.
_deps
.
fileManager
.
open
(
filename
)
this
.
_deps
.
fileManager
.
open
(
filename
)
jumpToLine
(
lineColumn
)
jumpToLine
(
lineColumn
)
}).
catch
(
error
=>
{
if
(
error
)
return
console
.
log
(
error
)
})
})
}
}
}
else
{
}
else
{
...
...
apps/remix-ide/src/app/files/fileManager.js
View file @
bf80ca98
...
@@ -121,7 +121,7 @@ class FileManager extends Plugin {
...
@@ -121,7 +121,7 @@ class FileManager extends Plugin {
try
{
try
{
path
=
this
.
limitPluginScope
(
path
)
path
=
this
.
limitPluginScope
(
path
)
const
provider
=
this
.
fileProviderOf
(
path
)
const
provider
=
this
.
fileProviderOf
(
path
)
const
result
=
provider
.
exists
(
path
,
()
=>
{}
)
const
result
=
provider
.
exists
(
path
)
return
result
return
result
}
catch
(
e
)
{
}
catch
(
e
)
{
...
...
apps/remix-ide/src/app/files/fileProvider.js
View file @
bf80ca98
...
@@ -63,11 +63,10 @@ class FileProvider {
...
@@ -63,11 +63,10 @@ class FileProvider {
})
})
}
}
exists
(
path
,
cb
)
{
async
exists
(
path
)
{
// todo check the type (directory/file) as well #2386
// todo check the type (directory/file) as well #2386
// currently it is not possible to have a file and folder with same path
// currently it is not possible to have a file and folder with same path
const
ret
=
this
.
_exists
(
path
)
const
ret
=
this
.
_exists
(
path
)
if
(
cb
)
cb
(
null
,
ret
)
return
ret
return
ret
}
}
...
...
apps/remix-ide/src/app/files/remixDProvider.js
View file @
bf80ca98
...
@@ -74,16 +74,15 @@ module.exports = class RemixDProvider extends FileProvider {
...
@@ -74,16 +74,15 @@ module.exports = class RemixDProvider extends FileProvider {
})
})
}
}
exists
(
path
,
cb
)
{
exists
(
path
)
{
if
(
!
this
.
_isReady
)
return
cb
&&
cb
(
'provider not ready'
)
if
(
!
this
.
_isReady
)
throw
new
Error
(
'provider not ready'
)
const
unprefixedpath
=
this
.
removePrefix
(
path
)
const
unprefixedpath
=
this
.
removePrefix
(
path
)
return
this
.
_appManager
.
call
(
'remixd'
,
'exists'
,
{
path
:
unprefixedpath
})
return
this
.
_appManager
.
call
(
'remixd'
,
'exists'
,
{
path
:
unprefixedpath
})
.
then
((
result
)
=>
{
.
then
((
result
)
=>
{
if
(
cb
)
return
cb
(
null
,
result
)
return
result
return
result
})
.
catch
((
error
)
=>
{
})
if
(
cb
)
return
cb
(
error
)
.
catch
((
error
)
=>
{
throw
new
Error
(
error
)
throw
new
Error
(
error
)
})
})
}
}
...
...
apps/remix-ide/src/app/panels/file-panel.js
View file @
bf80ca98
...
@@ -229,7 +229,7 @@ module.exports = class Filepanel extends ViewPlugin {
...
@@ -229,7 +229,7 @@ module.exports = class Filepanel extends ViewPlugin {
/** these are called by the react component, action is already finished whent it's called */
/** these are called by the react component, action is already finished whent it's called */
async
setWorkspace
(
workspace
)
{
async
setWorkspace
(
workspace
)
{
this
.
_deps
.
fileManager
.
removeTabsOf
(
this
.
_deps
.
fileProviders
.
workspace
)
this
.
_deps
.
fileManager
.
closeAllFiles
(
)
if
(
workspace
.
isLocalhost
)
{
if
(
workspace
.
isLocalhost
)
{
this
.
call
(
'manager'
,
'activatePlugin'
,
'remixd'
)
this
.
call
(
'manager'
,
'activatePlugin'
,
'remixd'
)
}
else
if
(
await
this
.
call
(
'manager'
,
'isActive'
,
'remixd'
))
{
}
else
if
(
await
this
.
call
(
'manager'
,
'isActive'
,
'remixd'
))
{
...
...
apps/remix-ide/src/app/tabs/testTab/testTab.js
View file @
bf80ca98
...
@@ -18,7 +18,9 @@ class TestTabLogic {
...
@@ -18,7 +18,9 @@ class TestTabLogic {
// Checking to ignore the value which contains only whitespaces
// Checking to ignore the value which contains only whitespaces
if
(
!
path
||
!
(
/
\S
/
.
test
(
path
)))
return
if
(
!
path
||
!
(
/
\S
/
.
test
(
path
)))
return
const
fileProvider
=
this
.
fileManager
.
fileProviderOf
(
path
.
split
(
'/'
)[
0
])
const
fileProvider
=
this
.
fileManager
.
fileProviderOf
(
path
.
split
(
'/'
)[
0
])
fileProvider
.
exists
(
path
,
(
e
,
res
)
=>
{
if
(
!
res
)
fileProvider
.
createDir
(
path
)
})
fileProvider
.
exists
(
path
).
then
(
res
=>
{
if
(
!
res
)
fileProvider
.
createDir
(
path
)
})
}
}
pathExists
(
path
)
{
pathExists
(
path
)
{
...
...
apps/remix-ide/src/app/ui/renderer.js
View file @
bf80ca98
...
@@ -39,10 +39,11 @@ Renderer.prototype._errorClick = function (errFile, errLine, errCol) {
...
@@ -39,10 +39,11 @@ Renderer.prototype._errorClick = function (errFile, errLine, errCol) {
// TODO: refactor with this._components.contextView.jumpTo
// TODO: refactor with this._components.contextView.jumpTo
var
provider
=
self
.
_deps
.
fileManager
.
fileProviderOf
(
errFile
)
var
provider
=
self
.
_deps
.
fileManager
.
fileProviderOf
(
errFile
)
if
(
provider
)
{
if
(
provider
)
{
provider
.
exists
(
errFile
,
(
error
,
exist
)
=>
{
provider
.
exists
(
errFile
).
then
(
exist
=>
{
if
(
error
)
return
console
.
log
(
error
)
self
.
_deps
.
fileManager
.
open
(
errFile
)
self
.
_deps
.
fileManager
.
open
(
errFile
)
editor
.
gotoLine
(
errLine
,
errCol
)
editor
.
gotoLine
(
errLine
,
errCol
)
}).
catch
(
error
=>
{
if
(
error
)
return
console
.
log
(
error
)
})
})
}
}
}
else
{
}
else
{
...
...
apps/remix-ide/src/lib/helper.js
View file @
bf80ca98
...
@@ -36,14 +36,12 @@ module.exports = {
...
@@ -36,14 +36,12 @@ module.exports = {
async
.
whilst
(
async
.
whilst
(
()
=>
{
return
exist
},
()
=>
{
return
exist
},
(
callback
)
=>
{
(
callback
)
=>
{
fileProvider
.
exists
(
name
+
counter
+
prefix
+
'.'
+
ext
,
(
error
,
currentExist
)
=>
{
fileProvider
.
exists
(
name
+
counter
+
prefix
+
'.'
+
ext
).
then
(
currentExist
=>
{
if
(
error
)
{
exist
=
currentExist
callback
(
error
)
if
(
exist
)
counter
=
(
counter
|
0
)
+
1
}
else
{
callback
()
exist
=
currentExist
}).
catch
(
error
=>
{
if
(
exist
)
counter
=
(
counter
|
0
)
+
1
if
(
error
)
console
.
log
(
error
)
callback
()
}
})
})
},
},
(
error
)
=>
{
cb
(
error
,
name
+
counter
+
prefix
+
'.'
+
ext
)
}
(
error
)
=>
{
cb
(
error
,
name
+
counter
+
prefix
+
'.'
+
ext
)
}
...
...
libs/remix-ui/file-explorer/src/lib/file-explorer.tsx
View file @
bf80ca98
...
@@ -368,8 +368,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -368,8 +368,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
const
name
=
`
${
parentFolder
}
/
${
file
.
name
}
`
const
name
=
`
${
parentFolder
}
/
${
file
.
name
}
`
filesProvider
.
exists
(
name
,
(
error
,
exist
)
=>
{
filesProvider
.
exists
(
name
).
then
(
exist
=>
{
if
(
error
)
console
.
log
(
error
)
if
(
!
exist
)
{
if
(
!
exist
)
{
loadFile
(
name
)
loadFile
(
name
)
}
else
{
}
else
{
...
@@ -383,6 +382,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -383,6 +382,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
fn
:
()
=>
{}
fn
:
()
=>
{}
})
})
}
}
}).
catch
(
error
=>
{
if
(
error
)
console
.
log
(
error
)
})
})
})
})
}
}
...
@@ -730,6 +731,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
...
@@ -730,6 +731,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
}
const
renderFiles
=
(
file
:
File
,
index
:
number
)
=>
{
const
renderFiles
=
(
file
:
File
,
index
:
number
)
=>
{
if
(
!
file
||
!
file
.
path
||
typeof
file
===
'string'
||
typeof
file
===
'number'
||
typeof
file
===
'boolean'
)
return
const
labelClass
=
state
.
focusEdit
.
element
===
file
.
path
const
labelClass
=
state
.
focusEdit
.
element
===
file
.
path
?
'bg-light'
:
state
.
focusElement
.
findIndex
(
item
=>
item
.
key
===
file
.
path
)
!==
-
1
?
'bg-light'
:
state
.
focusElement
.
findIndex
(
item
=>
item
.
key
===
file
.
path
)
!==
-
1
?
'bg-secondary'
:
state
.
mouseOverElement
===
file
.
path
?
'bg-secondary'
:
state
.
mouseOverElement
===
file
.
path
...
...
libs/remixd/src/services/remixdClient.ts
View file @
bf80ca98
...
@@ -85,11 +85,10 @@ export class RemixdClient extends PluginClient {
...
@@ -85,11 +85,10 @@ export class RemixdClient extends PluginClient {
}
}
}
}
set
(
args
:
SharedFolderArgs
)
:
Promise
<
void
>
{
set
(
args
:
SharedFolderArgs
)
{
try
{
try
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
readOnly
)
return
reject
(
new
Error
(
'Cannot write file: read-only mode selected'
))
if
(
this
.
readOnly
)
return
reject
(
new
Error
(
'Cannot write file: read-only mode selected'
))
const
isFolder
=
args
.
path
.
endsWith
(
'/'
)
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
const
exists
=
fs
.
existsSync
(
path
)
const
exists
=
fs
.
existsSync
(
path
)
...
@@ -99,31 +98,25 @@ export class RemixdClient extends PluginClient {
...
@@ -99,31 +98,25 @@ export class RemixdClient extends PluginClient {
return
reject
(
new
Error
(
'trying to write "undefined" ! stopping.'
))
return
reject
(
new
Error
(
'trying to write "undefined" ! stopping.'
))
}
}
this
.
trackDownStreamUpdate
[
path
]
=
path
this
.
trackDownStreamUpdate
[
path
]
=
path
if
(
isFolder
)
{
if
(
!
exists
&&
args
.
path
.
indexOf
(
'/'
)
!==
-
1
)
{
fs
.
mkdirp
(
path
).
then
(()
=>
{
// the last element is the filename and we should remove it
let
splitPath
=
args
.
path
.
split
(
'/'
)
this
.
createDir
({
path
:
args
.
path
.
substr
(
0
,
args
.
path
.
lastIndexOf
(
'/'
))
})
}
splitPath
=
splitPath
.
filter
(
dir
=>
dir
)
try
{
const
dir
=
'/'
+
splitPath
.
join
(
'/'
)
fs
.
writeFile
(
path
,
args
.
content
,
'utf8'
,
(
error
:
Error
)
=>
{
if
(
error
)
{
this
.
emit
(
'folderAdded'
,
dir
)
console
.
log
(
error
)
resolve
()
return
reject
(
error
)
}).
catch
((
e
:
Error
)
=>
reject
(
e
))
}
resolve
(
true
)
})
}
catch
(
e
)
{
return
reject
(
e
)
}
if
(
!
exists
)
{
this
.
emit
(
'fileAdded'
,
args
.
path
)
}
else
{
}
else
{
fs
.
ensureFile
(
path
).
then
(()
=>
{
this
.
emit
(
'fileChanged'
,
args
.
path
)
fs
.
writeFile
(
path
,
args
.
content
,
'utf8'
,
(
error
:
Error
)
=>
{
if
(
error
)
{
console
.
log
(
error
)
return
reject
(
error
)
}
resolve
()
})
}).
catch
((
e
:
Error
)
=>
reject
(
e
))
if
(
!
exists
)
{
this
.
emit
(
'fileAdded'
,
args
.
path
)
}
else
{
this
.
emit
(
'fileChanged'
,
args
.
path
)
}
}
}
})
})
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -131,24 +124,22 @@ export class RemixdClient extends PluginClient {
...
@@ -131,24 +124,22 @@ export class RemixdClient extends PluginClient {
}
}
}
}
createDir
(
args
:
SharedFolderArgs
)
:
Promise
<
void
>
{
createDir
(
args
:
SharedFolderArgs
)
{
try
{
try
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
readOnly
)
return
reject
(
new
Error
(
'Cannot create folder: read-only mode selected'
))
if
(
this
.
readOnly
)
return
reject
(
new
Error
(
'Cannot create folder: read-only mode selected'
))
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
const
paths
=
args
.
path
.
split
(
'/'
).
filter
(
value
=>
value
)
const
exists
=
fs
.
existsSync
(
path
)
if
(
paths
.
length
&&
paths
[
0
]
===
''
)
paths
.
shift
()
let
currentCheck
=
''
if
(
exists
&&
!
isRealPath
(
path
))
return
reject
(
new
Error
(
''
))
paths
.
forEach
((
value
)
=>
{
this
.
trackDownStreamUpdate
[
path
]
=
path
currentCheck
=
currentCheck
?
currentCheck
+
'/'
+
value
:
value
fs
.
mkdirp
(
path
).
then
(()
=>
{
const
path
=
utils
.
absolutePath
(
currentCheck
,
this
.
currentSharedFolder
)
let
splitPath
=
args
.
path
.
split
(
'/'
)
if
(
!
fs
.
existsSync
(
path
))
{
fs
.
mkdirp
(
path
)
splitPath
=
splitPath
.
filter
(
dir
=>
dir
)
this
.
emit
(
'folderAdded'
,
currentCheck
)
const
dir
=
'/'
+
splitPath
.
join
(
'/'
)
}
})
this
.
emit
(
'folderAdded'
,
dir
)
resolve
(
true
)
resolve
()
}).
catch
((
e
:
Error
)
=>
reject
(
e
))
})
})
}
catch
(
error
)
{
}
catch
(
error
)
{
throw
new
Error
(
error
)
throw
new
Error
(
error
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment