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
eaefa3ca
Commit
eaefa3ca
authored
Jun 10, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified api calls
parent
2f05d081
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
34 deletions
+57
-34
remixDProvider.js
apps/remix-ide/src/app/files/remixDProvider.js
+56
-33
remixd-handle.js
apps/remix-ide/src/app/files/remixd-handle.js
+1
-1
No files found.
apps/remix-ide/src/app/files/remixDProvider.js
View file @
eaefa3ca
...
@@ -60,7 +60,8 @@ module.exports = class RemixDProvider {
...
@@ -60,7 +60,8 @@ module.exports = class RemixDProvider {
}
}
init
(
cb
)
{
init
(
cb
)
{
this
.
_appManager
.
call
(
'remixd'
,
'folderIsReadOnly'
,
{}).
then
((
result
)
=>
{
this
.
_appManager
.
call
(
'remixd'
,
'folderIsReadOnly'
,
{})
.
then
((
result
)
=>
{
this
.
_isReady
=
true
this
.
_isReady
=
true
this
.
_readOnlyMode
=
result
this
.
_readOnlyMode
=
result
cb
&&
cb
()
cb
&&
cb
()
...
@@ -82,7 +83,8 @@ module.exports = class RemixDProvider {
...
@@ -82,7 +83,8 @@ module.exports = class RemixDProvider {
exists
(
path
,
cb
)
{
exists
(
path
,
cb
)
{
const
unprefixedpath
=
this
.
removePrefix
(
path
)
const
unprefixedpath
=
this
.
removePrefix
(
path
)
return
this
.
_appManager
.
call
(
'remixd'
,
'exists'
,
{
path
:
unprefixedpath
}).
then
((
result
)
=>
{
return
this
.
_appManager
.
call
(
'remixd'
,
'exists'
,
{
path
:
unprefixedpath
})
.
then
((
result
)
=>
{
return
cb
(
null
,
result
)
return
cb
(
null
,
result
)
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
return
cb
(
error
)
return
cb
(
error
)
...
@@ -99,10 +101,11 @@ module.exports = class RemixDProvider {
...
@@ -99,10 +101,11 @@ module.exports = class RemixDProvider {
get
(
path
,
cb
)
{
get
(
path
,
cb
)
{
var
unprefixedpath
=
this
.
removePrefix
(
path
)
var
unprefixedpath
=
this
.
removePrefix
(
path
)
this
.
_appManager
.
call
(
'remixd'
,
'get'
,
{
path
:
unprefixedpath
}).
then
((
file
)
=>
{
this
.
_appManager
.
call
(
'remixd'
,
'get'
,
{
path
:
unprefixedpath
})
.
then
((
file
)
=>
{
this
.
filesContent
[
path
]
=
file
.
content
this
.
filesContent
[
path
]
=
file
.
content
if
(
file
.
readonly
)
{
this
.
_readOnlyFiles
[
path
]
=
1
}
if
(
file
.
readonly
)
{
this
.
_readOnlyFiles
[
path
]
=
1
}
cb
(
error
,
file
.
content
)
cb
(
null
,
file
.
content
)
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
// display the last known content.
// display the last known content.
// TODO should perhaps better warn the user that the file is not synced.
// TODO should perhaps better warn the user that the file is not synced.
...
@@ -117,47 +120,52 @@ module.exports = class RemixDProvider {
...
@@ -117,47 +120,52 @@ module.exports = class RemixDProvider {
const
path
=
this
.
type
+
'/'
+
unprefixedpath
const
path
=
this
.
type
+
'/'
+
unprefixedpath
this
.
event
.
trigger
(
'fileChanged'
,
[
path
])
this
.
event
.
trigger
(
'fileChanged'
,
[
path
])
}).
catch
((
error
)
=>
{
if
(
cb
)
cb
(
error
)
})
})
return
true
}
}
isReadOnly
(
path
)
{
isReadOnly
(
path
)
{
return
this
.
_readOnlyMode
||
this
.
_readOnlyFiles
[
path
]
===
1
return
this
.
_readOnlyMode
||
this
.
_readOnlyFiles
[
path
]
===
1
}
}
async
remove
(
path
)
{
remove
(
path
)
{
var
unprefixedpath
=
this
.
removePrefix
(
path
)
const
unprefixedpath
=
this
.
removePrefix
(
path
)
const
callId
=
await
this
.
_appManager
.
call
(
'remixd'
,
'remove'
,
{
path
:
unprefixedpath
},
(
error
,
result
)
=>
{
if
(
error
)
console
.
log
(
error
)
this
.
_appManager
.
call
(
'remixd'
,
'remove'
,
{
path
:
unprefixedpath
})
var
path
=
this
.
type
+
'/'
+
unprefixedpath
.
then
(
result
=>
{
console
.
log
(
'result: '
,
result
)
const
path
=
this
.
type
+
'/'
+
unprefixedpath
delete
this
.
filesContent
[
path
]
delete
this
.
filesContent
[
path
]
this
.
init
(()
=>
{
this
.
init
(()
=>
{
this
.
event
.
trigger
(
'fileRemoved'
,
[
path
])
this
.
event
.
trigger
(
'fileRemoved'
,
[
path
])
})
})
}).
catch
(
error
=>
{
if
(
error
)
console
.
log
(
error
)
})
})
return
await
this
.
_appManager
.
receiveResponse
(
callId
)
}
}
rename
(
oldPath
,
newPath
,
isFolder
)
{
rename
(
oldPath
,
newPath
,
isFolder
)
{
var
unprefixedoldPath
=
this
.
removePrefix
(
oldPath
)
const
unprefixedoldPath
=
this
.
removePrefix
(
oldPath
)
var
unprefixednewPath
=
this
.
removePrefix
(
newPath
)
const
unprefixednewPath
=
this
.
removePrefix
(
newPath
)
this
.
_appManager
.
call
(
'remixd'
,
'rename'
,
{
oldPath
:
unprefixedoldPath
,
newPath
:
unprefixednewPath
},
(
error
,
result
)
=>
{
if
(
error
)
{
return
this
.
_appManager
.
call
(
'remixd'
,
'rename'
,
{
oldPath
:
unprefixedoldPath
,
newPath
:
unprefixednewPath
})
console
.
log
(
error
)
.
then
(
result
=>
{
if
(
this
.
error
[
error
.
code
])
error
=
this
.
error
[
error
.
code
]
const
newPath
=
this
.
type
+
'/'
+
unprefixednewPath
this
.
event
.
trigger
(
'fileRenamedError'
,
[
this
.
error
[
error
.
code
]])
const
oldPath
=
this
.
type
+
'/'
+
unprefixedoldPath
}
else
{
var
newPath
=
this
.
type
+
'/'
+
unprefixednewPath
var
oldPath
=
this
.
type
+
'/'
+
unprefixedoldPath
this
.
filesContent
[
newPath
]
=
this
.
filesContent
[
oldPath
]
this
.
filesContent
[
newPath
]
=
this
.
filesContent
[
oldPath
]
delete
this
.
filesContent
[
oldPath
]
delete
this
.
filesContent
[
oldPath
]
this
.
init
(()
=>
{
this
.
init
(()
=>
{
this
.
event
.
trigger
(
'fileRenamed'
,
[
oldPath
,
newPath
,
isFolder
])
this
.
event
.
trigger
(
'fileRenamed'
,
[
oldPath
,
newPath
,
isFolder
])
})
})
}
return
result
})
}).
catch
(
error
=>
{
return
true
console
.
log
(
error
)
if
(
this
.
error
[
error
.
code
])
error
=
this
.
error
[
error
.
code
]
this
.
event
.
trigger
(
'fileRenamedError'
,
[
this
.
error
[
error
.
code
]])
})
}
}
isExternalFolder
(
path
)
{
isExternalFolder
(
path
)
{
...
@@ -180,9 +188,8 @@ module.exports = class RemixDProvider {
...
@@ -180,9 +188,8 @@ module.exports = class RemixDProvider {
async
isDirectory
(
path
)
{
async
isDirectory
(
path
)
{
const
unprefixedpath
=
this
.
removePrefix
(
path
)
const
unprefixedpath
=
this
.
removePrefix
(
path
)
const
callId
=
await
this
.
_appManager
.
call
(
'remixd'
,
'isDirectory'
,
{
path
:
unprefixedpath
})
return
await
this
.
_
remixd
.
receiveResponse
(
callId
)
return
await
this
.
_
appManager
.
call
(
'remixd'
,
'isDirectory'
,
{
path
:
unprefixedpath
}
)
}
}
async
isFile
(
path
)
{
async
isFile
(
path
)
{
...
@@ -192,26 +199,42 @@ module.exports = class RemixDProvider {
...
@@ -192,26 +199,42 @@ module.exports = class RemixDProvider {
}
}
}
}
function
remixapi
(
appManager
,
self
)
{
function
remixapi
(
appManager
,
remixd
)
{
const
read
=
(
path
,
callback
)
=>
{
const
read
=
(
path
,
callback
)
=>
{
path
=
''
+
(
path
||
''
)
path
=
''
+
(
path
||
''
)
path
=
pathtool
.
join
(
'./'
,
path
)
path
=
pathtool
.
join
(
'./'
,
path
)
appManager
.
call
(
'remixd'
,
'get'
,
{
path
},
(
error
,
content
)
=>
callback
(
error
,
content
))
appManager
.
call
(
'remixd'
,
'get'
,
{
path
}).
then
((
content
)
=>
{
callback
(
null
,
content
)
}).
catch
((
error
)
=>
{
callback
(
error
)
})
}
}
const
write
=
(
path
,
content
,
callback
)
=>
{
const
write
=
(
path
,
content
,
callback
)
=>
{
path
=
''
+
(
path
||
''
)
path
=
''
+
(
path
||
''
)
path
=
pathtool
.
join
(
'./'
,
path
)
path
=
pathtool
.
join
(
'./'
,
path
)
appManager
.
call
(
'remixd'
,
'set'
,
{
path
,
content
},
(
error
,
result
)
=>
callback
(
error
,
result
))
appManager
.
call
(
'remixd'
,
'set'
,
{
path
,
content
}).
then
((
result
)
=>
{
callback
(
null
,
result
)
}).
catch
((
error
)
=>
{
callback
(
error
)
})
}
}
const
rename
=
(
path
,
newpath
,
callback
)
=>
{
const
rename
=
(
path
,
newpath
,
callback
)
=>
{
path
=
''
+
(
path
||
''
)
path
=
''
+
(
path
||
''
)
path
=
pathtool
.
join
(
'./'
,
path
)
path
=
pathtool
.
join
(
'./'
,
path
)
appManager
.
call
(
'remixd'
,
'rename'
,
{
oldPath
:
path
,
newPath
:
newpath
},
(
error
,
result
)
=>
callback
(
error
,
result
))
appManager
.
call
(
'remixd'
,
'rename'
,
{
oldPath
:
path
,
newPath
:
newpath
}).
then
((
result
)
=>
{
callback
(
null
,
result
)
}).
catch
((
error
)
=>
{
callback
(
error
)
})
}
}
const
remove
=
(
path
,
callback
)
=>
{
const
remove
=
(
path
,
callback
)
=>
{
path
=
''
+
(
path
||
''
)
path
=
''
+
(
path
||
''
)
path
=
pathtool
.
join
(
'./'
,
path
)
path
=
pathtool
.
join
(
'./'
,
path
)
appManager
.
call
(
'remixd'
,
'remove'
,
{
path
},
(
error
,
result
)
=>
callback
(
error
,
result
))
appManager
.
call
(
'remixd'
,
'remove'
,
{
path
}).
then
((
result
)
=>
{
callback
(
null
,
result
)
}).
catch
((
error
)
=>
{
callback
(
error
)
})
}
}
const
dir
=
(
path
,
callback
)
=>
{
const
dir
=
(
path
,
callback
)
=>
{
path
=
''
+
(
path
||
''
)
path
=
''
+
(
path
||
''
)
...
@@ -223,6 +246,6 @@ function remixapi (appManager, self) {
...
@@ -223,6 +246,6 @@ function remixapi (appManager, self) {
})
})
}
}
const
exit
=
()
=>
{
remixd
.
close
()
}
const
exit
=
()
=>
{
remixd
.
close
()
}
const
api
=
{
read
,
write
,
rename
,
remove
,
dir
,
exit
,
event
:
self
.
event
}
const
api
=
{
read
,
write
,
rename
,
remove
,
dir
,
exit
,
event
:
remixd
.
event
}
return
api
return
api
}
}
apps/remix-ide/src/app/files/remixd-handle.js
View file @
eaefa3ca
...
@@ -21,7 +21,7 @@ var css = csjs`
...
@@ -21,7 +21,7 @@ var css = csjs`
const
profile
=
{
const
profile
=
{
name
:
'remixd'
,
name
:
'remixd'
,
url
:
'ws://127.0.0.1:65520'
,
url
:
'ws://127.0.0.1:65520'
,
methods
:
[
'folderIsReadOnly'
,
'resolveDirectory'
,
'get'
,
'exists'
,
'isFile'
],
methods
:
[
'folderIsReadOnly'
,
'resolveDirectory'
,
'get'
,
'exists'
,
'isFile'
,
'set'
,
'rename'
,
'remove'
,
'isDirectory'
,
'list'
],
events
:
[],
events
:
[],
description
:
'Using Remixd daemon, allow to access file system'
,
description
:
'Using Remixd daemon, allow to access file system'
,
kind
:
'other'
,
kind
:
'other'
,
...
...
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