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
c9203f54
Commit
c9203f54
authored
Jun 09, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified exposed apis
parent
fc080222
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
34 deletions
+44
-34
remixd.ts
bin/remixd.ts
+1
-1
remixdClient.ts
src/services/remixdClient.ts
+38
-31
index.ts
types/index.ts
+5
-2
No files found.
bin/remixd.ts
View file @
c9203f54
#!/usr/bin/env node
#!/usr/bin/env node
import
WebSocket
from
'../src/websocket'
import
WebSocket
from
'../src/websocket'
import
*
as
servicesList
from
'../src/serviceList'
import
*
as
servicesList
from
'../src/serviceList'
import
*
as
WS
from
'ws
'
import
{
WS
}
from
'../types/index
'
const
program
=
require
(
'commander'
)
const
program
=
require
(
'commander'
)
...
...
src/services/remixdClient.ts
View file @
c9203f54
import
*
as
WS
from
'ws'
import
{
PluginClient
}
from
'@remixproject/plugin'
import
{
PluginClient
}
from
'@remixproject/plugin'
import
{
SharedFolderArgs
,
TrackDownStreamUpdate
}
from
'../../types'
import
{
SharedFolderArgs
,
TrackDownStreamUpdate
,
WS
}
from
'../../types'
import
*
as
utils
from
'../utils'
import
*
as
utils
from
'../utils'
const
isbinaryfile
=
require
(
'isbinaryfile'
)
const
isbinaryfile
=
require
(
'isbinaryfile'
)
const
fs
=
require
(
'fs-extra'
)
const
fs
=
require
(
'fs-extra'
)
export
class
RemixdClient
extends
PluginClient
{
export
class
RemixdClient
extends
PluginClient
{
methods
:
[
'folderIsReadOnly'
,
'resolveDirectory'
]
methods
:
[
'folderIsReadOnly'
,
'resolveDirectory'
,
'get'
,
'exists'
,
'isFile'
]
trackDownStreamUpdate
:
TrackDownStreamUpdate
trackDownStreamUpdate
:
TrackDownStreamUpdate
websocket
:
WS
websocket
:
WS
currentSharedFolder
:
string
currentSharedFolder
:
string
...
@@ -45,31 +44,36 @@ export class RemixdClient extends PluginClient {
...
@@ -45,31 +44,36 @@ export class RemixdClient extends PluginClient {
return
this
.
readOnly
return
this
.
readOnly
}
}
get
(
args
:
SharedFolderArgs
,
cb
:
Function
)
{
get
(
args
:
SharedFolderArgs
)
{
console
.
log
(
'called on server'
)
return
new
Promise
((
resolve
,
reject
)
=>
{
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
if
(
!
fs
.
existsSync
(
path
))
{
if
(
!
fs
.
existsSync
(
path
))
{
return
cb
(
'File not found '
+
path
)
reject
(
'File not found '
+
path
)
}
if
(
!
isRealPath
(
path
,
cb
))
return
isbinaryfile
(
path
,
(
error
:
Error
,
isBinary
:
boolean
)
=>
{
if
(
error
)
console
.
log
(
error
)
if
(
isBinary
)
{
cb
(
null
,
{
content
:
'<binary content not displayed>'
,
readonly
:
true
})
}
else
{
fs
.
readFile
(
path
,
'utf8'
,
(
error
:
Error
,
data
:
string
)
=>
{
if
(
error
)
console
.
log
(
error
)
cb
(
error
,
{
content
:
data
,
readonly
:
false
})
})
}
}
if
(
!
isRealPath
(
path
))
return
isbinaryfile
(
path
,
(
error
:
Error
,
isBinary
:
boolean
)
=>
{
if
(
error
)
console
.
log
(
error
)
if
(
isBinary
)
{
resolve
({
content
:
'<binary content not displayed>'
,
readonly
:
true
})
}
else
{
fs
.
readFile
(
path
,
'utf8'
,
(
error
:
Error
,
data
:
string
)
=>
{
if
(
error
)
console
.
log
(
error
)
resolve
({
content
:
data
,
readonly
:
false
})
})
}
})
})
})
}
}
exists
(
args
:
SharedFolderArgs
,
cb
:
Function
)
{
exists
(
args
:
SharedFolderArgs
)
{
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
try
{
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
cb
(
null
,
fs
.
existsSync
(
path
))
return
fs
.
existsSync
(
path
)
}
catch
(
error
)
{
throw
new
Error
(
error
)
}
}
}
set
(
args
:
SharedFolderArgs
,
cb
:
Function
)
{
set
(
args
:
SharedFolderArgs
,
cb
:
Function
)
{
...
@@ -77,7 +81,7 @@ export class RemixdClient extends PluginClient {
...
@@ -77,7 +81,7 @@ export class RemixdClient extends PluginClient {
const
isFolder
=
args
.
path
.
endsWith
(
'/'
)
const
isFolder
=
args
.
path
.
endsWith
(
'/'
)
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
if
(
fs
.
existsSync
(
path
)
&&
!
isRealPath
(
path
,
cb
))
return
if
(
fs
.
existsSync
(
path
)
&&
!
isRealPath
(
path
))
return
if
(
args
.
content
===
'undefined'
)
{
// no !!!!!
if
(
args
.
content
===
'undefined'
)
{
// no !!!!!
console
.
log
(
'trying to write "undefined" ! stopping.'
)
console
.
log
(
'trying to write "undefined" ! stopping.'
)
return
return
...
@@ -104,7 +108,7 @@ export class RemixdClient extends PluginClient {
...
@@ -104,7 +108,7 @@ export class RemixdClient extends PluginClient {
}
}
const
newpath
=
utils
.
absolutePath
(
args
.
newPath
,
this
.
currentSharedFolder
)
const
newpath
=
utils
.
absolutePath
(
args
.
newPath
,
this
.
currentSharedFolder
)
if
(
!
isRealPath
(
oldpath
,
cb
))
return
if
(
!
isRealPath
(
oldpath
))
return
fs
.
move
(
oldpath
,
newpath
,
(
error
:
Error
,
data
:
string
)
=>
{
fs
.
move
(
oldpath
,
newpath
,
(
error
:
Error
,
data
:
string
)
=>
{
if
(
error
)
console
.
log
(
error
)
if
(
error
)
console
.
log
(
error
)
cb
(
error
,
data
)
cb
(
error
,
data
)
...
@@ -118,7 +122,7 @@ export class RemixdClient extends PluginClient {
...
@@ -118,7 +122,7 @@ export class RemixdClient extends PluginClient {
if
(
!
fs
.
existsSync
(
path
))
{
if
(
!
fs
.
existsSync
(
path
))
{
return
cb
(
'File not found '
+
path
)
return
cb
(
'File not found '
+
path
)
}
}
if
(
!
isRealPath
(
path
,
cb
))
return
if
(
!
isRealPath
(
path
))
return
fs
.
remove
(
path
,
(
error
:
Error
)
=>
{
fs
.
remove
(
path
,
(
error
:
Error
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
...
@@ -134,21 +138,25 @@ export class RemixdClient extends PluginClient {
...
@@ -134,21 +138,25 @@ export class RemixdClient extends PluginClient {
cb
(
null
,
fs
.
statSync
(
path
).
isDirectory
())
cb
(
null
,
fs
.
statSync
(
path
).
isDirectory
())
}
}
isFile
(
args
:
SharedFolderArgs
,
cb
:
Function
)
{
isFile
(
args
:
SharedFolderArgs
)
{
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
try
{
const
path
=
utils
.
absolutePath
(
args
.
path
,
this
.
currentSharedFolder
)
cb
(
null
,
fs
.
statSync
(
path
).
isFile
())
return
fs
.
statSync
(
path
).
isFile
()
}
catch
(
error
)
{
throw
new
Error
(
error
)
}
}
}
}
}
function
isRealPath
(
path
:
string
,
cb
:
Function
)
{
function
isRealPath
(
path
:
string
)
{
const
realPath
=
fs
.
realpathSync
(
path
)
const
realPath
=
fs
.
realpathSync
(
path
)
const
isRealPath
=
path
===
realPath
const
isRealPath
=
path
===
realPath
const
mes
=
'[WARN] Symbolic link modification not allowed : '
+
path
+
' | '
+
realPath
const
mes
=
'[WARN] Symbolic link modification not allowed : '
+
path
+
' | '
+
realPath
if
(
!
isRealPath
)
{
if
(
!
isRealPath
)
{
console
.
log
(
'
\
x1b[33m%s
\
x1b[0m'
,
mes
)
console
.
log
(
'
\
x1b[33m%s
\
x1b[0m'
,
mes
)
throw
new
Error
(
mes
)
}
}
if
(
cb
&&
!
isRealPath
)
cb
(
mes
)
return
isRealPath
return
isRealPath
}
}
\ No newline at end of file
types/index.ts
View file @
c9203f54
import
*
as
ServiceList
from
'../src/serviceList'
import
*
as
ServiceList
from
'../src/serviceList'
import
*
as
Websocket
from
'ws'
type
ServiceListKeys
=
keyof
typeof
ServiceList
;
type
ServiceListKeys
=
keyof
typeof
ServiceList
;
...
@@ -26,4 +27,6 @@ export type ResolveDirectory = {
...
@@ -26,4 +27,6 @@ export type ResolveDirectory = {
export
type
TrackDownStreamUpdate
=
KeyPairString
export
type
TrackDownStreamUpdate
=
KeyPairString
export
type
SharedFolderArgs
=
FolderArgs
&
KeyPairString
export
type
SharedFolderArgs
=
FolderArgs
&
KeyPairString
\ No newline at end of file
export
type
WS
=
typeof
Websocket
\ No newline at end of file
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