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 {
if
(
provider
.
type
===
'localhost'
&&
!
provider
.
isConnected
())
{
return
reject
(
new
Error
(
`file provider
${
provider
.
type
}
not available while trying to resolve
${
url
}
`
))
}
provider
.
exists
(
url
,
(
error
,
exist
)
=>
{
if
(
error
)
return
reject
(
error
)
provider
.
exists
(
url
).
then
(
exist
=>
{
/*
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.
...
...
@@ -162,6 +160,8 @@ module.exports = class CompilerImports extends Plugin {
if
(
error
)
return
reject
(
error
)
resolve
(
content
)
})
}).
catch
(
error
=>
{
return
reject
(
error
)
})
}
})
...
...
apps/remix-ide/src/app/editor/contextView.js
View file @
bf80ca98
...
...
@@ -109,10 +109,11 @@ class ContextView {
if
(
filename
!==
this
.
_deps
.
config
.
get
(
'currentFile'
))
{
const
provider
=
this
.
_deps
.
fileManager
.
fileProviderOf
(
filename
)
if
(
provider
)
{
provider
.
exists
(
filename
,
(
error
,
exist
)
=>
{
if
(
error
)
return
console
.
log
(
error
)
provider
.
exists
(
filename
).
then
(
exist
=>
{
this
.
_deps
.
fileManager
.
open
(
filename
)
jumpToLine
(
lineColumn
)
}).
catch
(
error
=>
{
if
(
error
)
return
console
.
log
(
error
)
})
}
}
else
{
...
...
apps/remix-ide/src/app/files/fileManager.js
View file @
bf80ca98
...
...
@@ -121,7 +121,7 @@ class FileManager extends Plugin {
try
{
path
=
this
.
limitPluginScope
(
path
)
const
provider
=
this
.
fileProviderOf
(
path
)
const
result
=
provider
.
exists
(
path
,
()
=>
{}
)
const
result
=
provider
.
exists
(
path
)
return
result
}
catch
(
e
)
{
...
...
apps/remix-ide/src/app/files/fileProvider.js
View file @
bf80ca98
...
...
@@ -63,11 +63,10 @@ class FileProvider {
})
}
exists
(
path
,
cb
)
{
async
exists
(
path
)
{
// todo check the type (directory/file) as well #2386
// currently it is not possible to have a file and folder with same path
const
ret
=
this
.
_exists
(
path
)
if
(
cb
)
cb
(
null
,
ret
)
return
ret
}
...
...
apps/remix-ide/src/app/files/remixDProvider.js
View file @
bf80ca98
...
...
@@ -74,16 +74,15 @@ module.exports = class RemixDProvider extends FileProvider {
})
}
exists
(
path
,
cb
)
{
if
(
!
this
.
_isReady
)
return
cb
&&
cb
(
'provider not ready'
)
exists
(
path
)
{
if
(
!
this
.
_isReady
)
throw
new
Error
(
'provider not ready'
)
const
unprefixedpath
=
this
.
removePrefix
(
path
)
return
this
.
_appManager
.
call
(
'remixd'
,
'exists'
,
{
path
:
unprefixedpath
})
.
then
((
result
)
=>
{
if
(
cb
)
return
cb
(
null
,
result
)
return
result
})
.
catch
((
error
)
=>
{
if
(
cb
)
return
cb
(
error
)
})
.
catch
((
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 {
/** these are called by the react component, action is already finished whent it's called */
async
setWorkspace
(
workspace
)
{
this
.
_deps
.
fileManager
.
removeTabsOf
(
this
.
_deps
.
fileProviders
.
workspace
)
this
.
_deps
.
fileManager
.
closeAllFiles
(
)
if
(
workspace
.
isLocalhost
)
{
this
.
call
(
'manager'
,
'activatePlugin'
,
'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 {
// Checking to ignore the value which contains only whitespaces
if
(
!
path
||
!
(
/
\S
/
.
test
(
path
)))
return
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
)
{
...
...
apps/remix-ide/src/app/ui/renderer.js
View file @
bf80ca98
...
...
@@ -39,10 +39,11 @@ Renderer.prototype._errorClick = function (errFile, errLine, errCol) {
// TODO: refactor with this._components.contextView.jumpTo
var
provider
=
self
.
_deps
.
fileManager
.
fileProviderOf
(
errFile
)
if
(
provider
)
{
provider
.
exists
(
errFile
,
(
error
,
exist
)
=>
{
if
(
error
)
return
console
.
log
(
error
)
provider
.
exists
(
errFile
).
then
(
exist
=>
{
self
.
_deps
.
fileManager
.
open
(
errFile
)
editor
.
gotoLine
(
errLine
,
errCol
)
}).
catch
(
error
=>
{
if
(
error
)
return
console
.
log
(
error
)
})
}
}
else
{
...
...
apps/remix-ide/src/lib/helper.js
View file @
bf80ca98
...
...
@@ -36,14 +36,12 @@ module.exports = {
async
.
whilst
(
()
=>
{
return
exist
},
(
callback
)
=>
{
fileProvider
.
exists
(
name
+
counter
+
prefix
+
'.'
+
ext
,
(
error
,
currentExist
)
=>
{
if
(
error
)
{
callback
(
error
)
}
else
{
exist
=
currentExist
if
(
exist
)
counter
=
(
counter
|
0
)
+
1
callback
()
}
fileProvider
.
exists
(
name
+
counter
+
prefix
+
'.'
+
ext
).
then
(
currentExist
=>
{
exist
=
currentExist
if
(
exist
)
counter
=
(
counter
|
0
)
+
1
callback
()
}).
catch
(
error
=>
{
if
(
error
)
console
.
log
(
error
)
})
},
(
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) => {
}
const
name
=
`
${
parentFolder
}
/
${
file
.
name
}
`
filesProvider
.
exists
(
name
,
(
error
,
exist
)
=>
{
if
(
error
)
console
.
log
(
error
)
filesProvider
.
exists
(
name
).
then
(
exist
=>
{
if
(
!
exist
)
{
loadFile
(
name
)
}
else
{
...
...
@@ -383,6 +382,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
fn
:
()
=>
{}
})
}
}).
catch
(
error
=>
{
if
(
error
)
console
.
log
(
error
)
})
})
}
...
...
@@ -730,6 +731,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
}
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
?
'bg-light'
:
state
.
focusElement
.
findIndex
(
item
=>
item
.
key
===
file
.
path
)
!==
-
1
?
'bg-secondary'
:
state
.
mouseOverElement
===
file
.
path
...
...
libs/remixd/src/services/remixdClient.ts
View file @
bf80ca98
...
...
@@ -85,11 +85,10 @@ export class RemixdClient extends PluginClient {
}
}
set
(
args
:
SharedFolderArgs
)
:
Promise
<
void
>
{
set
(
args
:
SharedFolderArgs
)
{
try
{
return
new
Promise
((
resolve
,
reject
)
=>
{
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
exists
=
fs
.
existsSync
(
path
)
...
...
@@ -99,31 +98,25 @@ export class RemixdClient extends PluginClient {
return
reject
(
new
Error
(
'trying to write "undefined" ! stopping.'
))
}
this
.
trackDownStreamUpdate
[
path
]
=
path
if
(
isFolder
)
{
fs
.
mkdirp
(
path
).
then
(()
=>
{
let
splitPath
=
args
.
path
.
split
(
'/'
)
splitPath
=
splitPath
.
filter
(
dir
=>
dir
)
const
dir
=
'/'
+
splitPath
.
join
(
'/'
)
this
.
emit
(
'folderAdded'
,
dir
)
resolve
()
}).
catch
((
e
:
Error
)
=>
reject
(
e
))
if
(
!
exists
&&
args
.
path
.
indexOf
(
'/'
)
!==
-
1
)
{
// the last element is the filename and we should remove it
this
.
createDir
({
path
:
args
.
path
.
substr
(
0
,
args
.
path
.
lastIndexOf
(
'/'
))
})
}
try
{
fs
.
writeFile
(
path
,
args
.
content
,
'utf8'
,
(
error
:
Error
)
=>
{
if
(
error
)
{
console
.
log
(
error
)
return
reject
(
error
)
}
resolve
(
true
)
})
}
catch
(
e
)
{
return
reject
(
e
)
}
if
(
!
exists
)
{
this
.
emit
(
'fileAdded'
,
args
.
path
)
}
else
{
fs
.
ensureFile
(
path
).
then
(()
=>
{
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
)
}
this
.
emit
(
'fileChanged'
,
args
.
path
)
}
})
}
catch
(
error
)
{
...
...
@@ -131,24 +124,22 @@ export class RemixdClient extends PluginClient {
}
}
createDir
(
args
:
SharedFolderArgs
)
:
Promise
<
void
>
{
createDir
(
args
:
SharedFolderArgs
)
{
try
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
readOnly
)
return
reject
(
new
Error
(
'Cannot create folder: read-only mode selected'
))
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
const
exists
=
fs
.
existsSync
(
path
)
if
(
exists
&&
!
isRealPath
(
path
))
return
reject
(
new
Error
(
''
))
this
.
trackDownStreamUpdate
[
path
]
=
path
fs
.
mkdirp
(
path
).
then
(()
=>
{
let
splitPath
=
args
.
path
.
split
(
'/'
)
splitPath
=
splitPath
.
filter
(
dir
=>
dir
)
const
dir
=
'/'
+
splitPath
.
join
(
'/'
)
this
.
emit
(
'folderAdded'
,
dir
)
resolve
()
}).
catch
((
e
:
Error
)
=>
reject
(
e
))
const
paths
=
args
.
path
.
split
(
'/'
).
filter
(
value
=>
value
)
if
(
paths
.
length
&&
paths
[
0
]
===
''
)
paths
.
shift
()
let
currentCheck
=
''
paths
.
forEach
((
value
)
=>
{
currentCheck
=
currentCheck
?
currentCheck
+
'/'
+
value
:
value
const
path
=
utils
.
absolutePath
(
currentCheck
,
this
.
currentSharedFolder
)
if
(
!
fs
.
existsSync
(
path
))
{
fs
.
mkdirp
(
path
)
this
.
emit
(
'folderAdded'
,
currentCheck
)
}
})
resolve
(
true
)
})
}
catch
(
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