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
c767a1d1
Commit
c767a1d1
authored
Oct 17, 2021
by
bunsenstraat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor plugin
parent
350af625
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
81 deletions
+93
-81
Client.ts
apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts
+0
-9
app.tsx
apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx
+69
-53
logger.tsx
apps/remix-ide-e2e/src/local-plugin/src/app/logger.tsx
+6
-6
plugin_api.ts
apps/remix-ide-e2e/src/tests/plugin_api.ts
+18
-13
No files found.
apps/remix-ide-e2e/src/local-plugin/src/app/Client.ts
View file @
c767a1d1
...
@@ -66,15 +66,6 @@ export class WorkSpacePlugin extends PluginClient {
...
@@ -66,15 +66,6 @@ export class WorkSpacePlugin extends PluginClient {
console.log("comp fin",x)
console.log("comp fin",x)
})
})
*/
*/
await
this
.
setCallBacks
()
this
.
on
(
'solidity'
,
'compilationFinished'
,
function
(
target
,
source
,
version
,
data
)
{
console
.
log
(
'compile finished'
,
target
,
source
,
version
,
data
)
}
)
})
})
.
catch
(
async
(
e
)
=>
{
.
catch
(
async
(
e
)
=>
{
console
.
log
(
'ERROR CONNECTING'
,
e
)
console
.
log
(
'ERROR CONNECTING'
,
e
)
...
...
apps/remix-ide-e2e/src/local-plugin/src/app/app.tsx
View file @
c767a1d1
import
React
,
{
useState
}
from
'react'
import
React
,
{
use
Effect
,
useRef
,
use
State
}
from
'react'
import
{
WorkSpacePlugin
}
from
'./Client'
import
{
WorkSpacePlugin
}
from
'./Client'
import
{
Logger
}
from
'./logger'
import
{
Logger
}
from
'./logger'
import
{
useBehaviorSubject
}
from
'./usesubscribe/index'
import
{
filePanelProfile
}
from
'@remixproject/plugin-api/lib/file-system/file-panel/profile'
import
{
filSystemProfile
}
from
'@remixproject/plugin-api/lib/file-system/file-manager/profile'
import
{
dGitProfile
}
from
'@remixproject/plugin-api/lib/dgit/profile'
import
{
editorProfile
}
from
'@remixproject/plugin-api/lib/editor/profile'
import
{
settingsProfile
}
from
'@remixproject/plugin-api/lib/settings/profile'
import
{
networkProfile
}
from
'@remixproject/plugin-api/lib/network/profile'
import
{
terminalProfile
}
from
'@remixproject/plugin-api/lib/terminal/profile'
import
{
udappProfile
}
from
'@remixproject/plugin-api/lib/udapp'
import
{
compilerProfile
}
from
'@remixproject/plugin-api/lib/compiler'
import
{
contentImportProfile
}
from
'@remixproject/plugin-api/lib/content-import'
import
{
unitTestProfile
}
from
'@remixproject/plugin-api/lib/unit-testing'
import
{
windowProfile
}
from
'@remixproject/plugin-api/lib/window'
import
{
pluginManagerProfile
}
from
'@remixproject/plugin-api/lib/plugin-manager'
import
{
IFileSystem
}
from
'@remixproject/plugin-api'
import
{
Profile
}
from
'@remixproject/plugin-utils'
export
const
client
=
new
WorkSpacePlugin
()
export
const
client
=
new
WorkSpacePlugin
()
function
App
()
{
function
App
()
{
const
[
payload
,
setPayload
]
=
useState
<
string
>
(
''
)
const
[
payload
,
setPayload
]
=
useState
<
string
>
(
''
)
const
[
result
,
setResult
]
=
useState
<
string
>
()
const
[
append
,
setAppend
]
=
useState
<
boolean
>
(
false
)
const
[
append
,
setAppend
]
=
useState
<
boolean
>
(
false
)
const
[
log
,
setLog
]
=
useState
<
any
>
()
const
[
profiles
,
setProfiles
]
=
useState
<
any
[]
>
([
pluginManagerProfile
,
filePanelProfile
,
filSystemProfile
,
dGitProfile
,
networkProfile
,
settingsProfile
,
editorProfile
,
terminalProfile
,
compilerProfile
,
udappProfile
,
contentImportProfile
,
unitTestProfile
,
windowProfile
])
const
handleChange
=
({
target
}:
any
)
=>
{
const
handleChange
=
({
target
}:
any
)
=>
{
setPayload
(
target
.
value
)
setPayload
(
target
.
value
)
}
}
useEffect
(()
=>
{
client
.
onload
(
async
()
=>
{
const
customProfiles
=
[
'solidity'
]
for
(
const
name
of
customProfiles
)
{
const
p
=
await
client
.
call
(
'manager'
,
'getProfile'
,
name
)
setProfiles
(
profiles
=>
[
p
,
...
profiles
])
}
profiles
.
map
((
profile
:
Profile
)
=>
{
if
(
profile
.
events
)
{
profile
.
events
.
map
((
event
:
string
)
=>
{
console
.
log
(
profile
.
name
,
event
)
client
.
on
(
profile
.
name
as
any
,
event
,
(...
args
:
any
)
=>
{
console
.
log
(
event
,
args
)
})
})
}
})
})
},
[])
const
setAppendChange
=
({
target
}:
any
)
=>
{
const
setAppendChange
=
({
target
}:
any
)
=>
{
console
.
log
(
'append'
,
target
.
checked
)
console
.
log
(
'append'
,
target
.
checked
)
setAppend
(
target
.
checked
)
setAppend
(
target
.
checked
)
}
}
const
clientMethod
=
async
(
profile
:
Profile
,
method
:
string
)
=>
{
try
{
let
ob
:
any
=
null
try
{
ob
=
JSON
.
parse
(
payload
)
}
catch
(
e
)
{}
const
send
=
ob
||
[
payload
]
const
result
=
await
client
.
call
(
profile
.
name
as
any
,
method
,
...
send
)
setLog
(
result
)
}
catch
(
e
)
{
setLog
(
e
.
message
)
}
}
return
(
return
(
<
div
className=
"App"
>
<
div
className=
"App container-fluid"
>
<
div
>
v5
</
div
>
<
h5
>
PLUGIN API TESTER
</
h5
>
<
Logger
append=
{
append
}
></
Logger
>
<
Logger
log=
{
log
}
append=
{
append
}
></
Logger
>
<
input
id=
'appendToLog'
type=
'checkbox'
onChange=
{
setAppendChange
}
/><
label
>
append logs
</
label
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
zip
()
}
>
zip
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
ipfspush
()
}
>
ipfs push
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
ipfspull
(
payload
)
}
>
ipfs pull
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
ipfsConfig
()
}
>
ipfs config
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
getAccounts
()
}
>
get accounts
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
setSettings
()
}
>
set settings to injected
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
getSettings
()
}
>
get settings
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
soltest
()
}
>
run sol test
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
highlight
(
payload
)
}
>
highlight
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
addAnnotation
(
payload
)
}
>
annotation
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
clearAnnotations
(
payload
)
}
>
clear annotation
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
open
(
payload
)
}
>
openfile
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
readddir
(
payload
)
}
>
readdir
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
write
(
payload
)
}
>
write
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
switchfile
(
payload
)
}
>
switch to file
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
getcurrentfile
()
}
>
getcurrentfile
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
importcontent
(
payload
)
}
>
import content resolve
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
fetch
(
payload
)
}
>
api test fetch
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
axios
(
payload
)
}
>
api test axios
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
activate
(
payload
)
}
>
activate
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
deactivate
(
payload
)
}
>
deactivate
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
getresult
()
}
>
get compilation result
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
getcompilerconfig
()
}
>
get compiler config
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
getWorkSpace
()
}
>
get workspace
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
getWorkSpaces
()
}
>
get workspaces
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
createWorkSpace
(
payload
)
}
>
create workspace
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitinit
(
payload
)
}
>
git init
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitstatus
(
payload
)
}
>
git status
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitlog
()
}
>
git log
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitcommit
()
}
>
git commit
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitadd
(
payload
)
}
>
git add
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitremove
(
payload
)
}
>
git rm
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitlsfiles
()
}
>
git ls files
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitreadblob
(
payload
)
}
>
git read blob
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitresolveref
()
}
>
git resolve head
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitbranches
()
}
>
git branches
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitbranch
(
payload
)
}
>
git create branch
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitcheckout
(
payload
)
}
>
git checkout
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
gitcurrentbranch
()
}
>
git current branch
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
changetoinjected
()
}
>
change to injected
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
pinatapush
()
}
>
pinata write
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
pinlist
()
}
>
pinata list
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
setCallBacks
()
}
>
callbacks
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
log
(
''
)
}
>
log
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
activatePlugin
(
payload
)
}
>
activate
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
deActivatePlugin
(
payload
)
}
>
deactivate
</
button
>
<
button
className=
'btn btn-primary btn-sm'
onClick=
{
async
()
=>
await
client
.
debug
(
payload
)
}
>
debug
</
button
>
<
input
<
input
className=
'form-control w-100'
type=
"text"
type=
"text"
id=
"payload"
id=
"payload"
placeholder=
"Enter payload here..."
placeholder=
"Enter payload here..."
value=
{
payload
}
value=
{
payload
}
onChange=
{
handleChange
}
onChange=
{
handleChange
}
/>
/>
<
input
className=
''
id=
'appendToLog'
type=
'checkbox'
onChange=
{
setAppendChange
}
/><
label
>
Append logs
</
label
>
{
profiles
.
map
((
profile
:
Profile
)
=>
{
const
methods
=
profile
.
methods
.
map
((
method
:
string
)
=>
{
return
<
button
data
-
id=
{
`${profile.name}:${method}`
}
key=
{
method
}
className=
'btn btn-primary btn-sm ml-1 mb-1'
onClick=
{
async
()
=>
await
clientMethod
(
profile
,
method
)
}
>
{
method
}
</
button
>
})
return
<
div
key=
{
profile
.
name
}
className=
'small'
><
label
>
{
profile
.
name
}
</
label
><
br
></
br
>
{
methods
}
</
div
>
})
}
</
div
>
</
div
>
)
)
}
}
...
...
apps/remix-ide-e2e/src/local-plugin/src/app/logger.tsx
View file @
c767a1d1
import
React
,
{
useEffect
,
useState
}
from
'react'
import
React
,
{
useEffect
,
useState
}
from
'react'
import
{
useBehaviorSubject
}
from
'./usesubscribe/index'
import
{
client
}
from
'./app'
import
{
client
}
from
'./app'
interface
loggerProps
{
interface
loggerProps
{
append
:
boolean
append
:
boolean
,
log
:
any
}
}
export
const
Logger
:
React
.
FC
<
loggerProps
>
=
(
props
)
=>
{
export
const
Logger
:
React
.
FC
<
loggerProps
>
=
(
props
)
=>
{
const
log
=
useBehaviorSubject
(
client
.
feedback
)
const
[
value
,
setValue
]
=
useState
<
string
>
(
''
)
const
[
value
,
setValue
]
=
useState
<
string
>
(
''
)
useEffect
(()
=>
{
useEffect
(()
=>
{
setValue
(
value
=>
{
setValue
(
value
=>
{
const
addValue
=
typeof
log
===
'string'
?
log
:
JSON
.
stringify
(
log
)
const
addValue
=
typeof
props
.
log
===
'string'
?
props
.
log
:
JSON
.
stringify
(
props
.
log
)
return
props
.
append
?
`
${
value
}
${
addValue
}
`
:
addValue
return
props
.
append
?
`
${
value
}
${
addValue
}
`
:
addValue
})
})
},
[
log
])
},
[
props
])
return
(<
div
id=
'log'
>
{
value
}
</
div
>)
return
(<
div
className=
"jumbotron text-break"
>
{
value
}
</
div
>)
}
}
apps/remix-ide-e2e/src/tests/plugin_api.ts
View file @
c767a1d1
...
@@ -18,8 +18,13 @@ const getBrowserLogs = function (browser: NightwatchBrowser) {
...
@@ -18,8 +18,13 @@ const getBrowserLogs = function (browser: NightwatchBrowser) {
console
.
log
(
logEntries
)
console
.
log
(
logEntries
)
})
})
}
}
/*
const
assertLog
=
function
(
browser
:
NightwatchBrowser
,
buttonText
:
string
,
msg
:
any
,
payload
:
string
)
{
* PLUGINACTION
* buttonText: which button to click
* msg: what to expect from the log
* payload: extra param for the call
*/
const
pluginAction
=
function
(
browser
:
NightwatchBrowser
,
buttonText
:
string
,
msg
:
any
,
payload
:
string
)
{
if
(
payload
)
{
if
(
payload
)
{
browser
.
clearValue
(
'//*[@id="payload"]'
).
setValue
(
'//*[@id="payload"]'
,
payload
).
pause
(
1000
)
browser
.
clearValue
(
'//*[@id="payload"]'
).
setValue
(
'//*[@id="payload"]'
,
payload
).
pause
(
1000
)
}
}
...
@@ -82,22 +87,22 @@ module.exports = {
...
@@ -82,22 +87,22 @@ module.exports = {
},
},
'Should get current workspace'
:
function
(
browser
:
NightwatchBrowser
)
{
'Should get current workspace'
:
function
(
browser
:
NightwatchBrowser
)
{
assertLog
(
browser
,
'get workspace'
,
{
name
:
'default_workspace'
,
isLocalhost
:
false
,
absolutePath
:
'.workspaces/default_workspace'
},
null
)
pluginAction
(
browser
,
'get workspace'
,
{
name
:
'default_workspace'
,
isLocalhost
:
false
,
absolutePath
:
'.workspaces/default_workspace'
},
null
)
},
},
'Should get current files'
:
function
(
browser
:
NightwatchBrowser
)
{
'Should get current files'
:
function
(
browser
:
NightwatchBrowser
)
{
assertLog
(
browser
,
'readdir'
,
{
contracts
:
{
isDirectory
:
true
},
scripts
:
{
isDirectory
:
true
},
tests
:
{
isDirectory
:
true
},
'README.txt'
:
{
isDirectory
:
false
}
},
null
)
pluginAction
(
browser
,
'readdir'
,
{
contracts
:
{
isDirectory
:
true
},
scripts
:
{
isDirectory
:
true
},
tests
:
{
isDirectory
:
true
},
'README.txt'
:
{
isDirectory
:
false
}
},
null
)
},
},
'Should throw error on current file'
:
function
(
browser
:
NightwatchBrowser
)
{
'Should throw error on current file'
:
function
(
browser
:
NightwatchBrowser
)
{
assertLog
(
browser
,
'getcurrentfile'
,
'Error from IDE : Error: No such file or directory No file selected'
,
null
)
pluginAction
(
browser
,
'getcurrentfile'
,
'Error from IDE : Error: No such file or directory No file selected'
,
null
)
},
},
'Should open readme.txt'
:
function
(
browser
:
NightwatchBrowser
)
{
'Should open readme.txt'
:
function
(
browser
:
NightwatchBrowser
)
{
assertLog
(
browser
,
'openfile'
,
null
,
'README.txt'
)
pluginAction
(
browser
,
'openfile'
,
null
,
'README.txt'
)
},
},
'Should have current file'
:
function
(
browser
:
NightwatchBrowser
)
{
'Should have current file'
:
function
(
browser
:
NightwatchBrowser
)
{
assertLog
(
browser
,
'getcurrentfile'
,
'README.txt'
,
null
)
pluginAction
(
browser
,
'getcurrentfile'
,
'README.txt'
,
null
)
},
},
'Should activate solidityUnitTesting'
:
function
(
browser
:
NightwatchBrowser
)
{
'Should activate solidityUnitTesting'
:
function
(
browser
:
NightwatchBrowser
)
{
assertLog
(
browser
,
'activate'
,
null
,
'solidityUnitTesting'
)
pluginAction
(
browser
,
'activate'
,
null
,
'solidityUnitTesting'
)
browser
.
frameParent
()
browser
.
frameParent
()
assertPluginIsActive
(
browser
,
'solidityUnitTesting'
)
assertPluginIsActive
(
browser
,
'solidityUnitTesting'
)
// @ts-ignore
// @ts-ignore
...
@@ -105,13 +110,13 @@ module.exports = {
...
@@ -105,13 +110,13 @@ module.exports = {
},
},
'Should switch to file'
:
function
(
browser
:
NightwatchBrowser
)
{
'Should switch to file'
:
function
(
browser
:
NightwatchBrowser
)
{
assertLog
(
browser
,
'switch to file'
,
null
,
'contracts/1_Storage.sol'
)
pluginAction
(
browser
,
'switch to file'
,
null
,
'contracts/1_Storage.sol'
)
assertLog
(
browser
,
'getcurrentfile'
,
'contracts/1_Storage.sol'
,
null
)
pluginAction
(
browser
,
'getcurrentfile'
,
'contracts/1_Storage.sol'
,
null
)
assertLog
(
browser
,
'switch to file'
,
null
,
'README.txt'
)
pluginAction
(
browser
,
'switch to file'
,
null
,
'README.txt'
)
assertLog
(
browser
,
'getcurrentfile'
,
'README.txt'
,
null
)
pluginAction
(
browser
,
'getcurrentfile'
,
'README.txt'
,
null
)
},
},
'Should write to file'
:
function
(
browser
:
NightwatchBrowser
)
{
'Should write to file'
:
function
(
browser
:
NightwatchBrowser
)
{
assertLog
(
browser
,
'write'
,
'README.txt'
,
null
)
pluginAction
(
browser
,
'write'
,
'README.txt'
,
null
)
}
}
}
}
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