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
f636f7ee
Commit
f636f7ee
authored
Jul 16, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use proper javascript object for scripting
parent
c745cdb0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
45 deletions
+8
-45
editor-panel.js
src/app/panels/editor-panel.js
+1
-3
terminal.js
src/app/panels/terminal.js
+3
-1
cmdInterpreter.js
src/lib/cmdInterpreter.js
+0
-27
cmdInterpreterAPI.js
src/lib/cmdInterpreterAPI.js
+4
-14
No files found.
src/app/panels/editor-panel.js
View file @
f636f7ee
...
@@ -7,7 +7,6 @@ var Terminal = require('./terminal')
...
@@ -7,7 +7,6 @@ var Terminal = require('./terminal')
var
Editor
=
require
(
'../editor/editor'
)
var
Editor
=
require
(
'../editor/editor'
)
var
globalRegistry
=
require
(
'../../global/registry'
)
var
globalRegistry
=
require
(
'../../global/registry'
)
var
CommandInterpreter
=
require
(
'../../lib/cmdInterpreter'
)
var
ContextualListener
=
require
(
'../editor/contextualListener'
)
var
ContextualListener
=
require
(
'../editor/contextualListener'
)
var
ContextView
=
require
(
'../editor/contextView'
)
var
ContextView
=
require
(
'../editor/contextView'
)
var
styles
=
require
(
'./styles/editor-panel-styles'
)
var
styles
=
require
(
'./styles/editor-panel-styles'
)
...
@@ -47,8 +46,7 @@ class EditorPanel {
...
@@ -47,8 +46,7 @@ class EditorPanel {
contextualListener
:
contextualListener
,
contextualListener
:
contextualListener
,
contextView
:
new
ContextView
({
contextualListener
:
contextualListener
,
editor
:
editor
}),
contextView
:
new
ContextView
({
contextualListener
:
contextualListener
,
editor
:
editor
}),
terminal
:
new
Terminal
({
terminal
:
new
Terminal
({
udapp
:
self
.
_deps
.
udapp
,
udapp
:
self
.
_deps
.
udapp
cmdInterpreter
:
new
CommandInterpreter
()
},
},
{
{
getPosition
:
(
event
)
=>
{
getPosition
:
(
event
)
=>
{
...
...
src/app/panels/terminal.js
View file @
f636f7ee
...
@@ -8,6 +8,7 @@ var remixLib = require('remix-lib')
...
@@ -8,6 +8,7 @@ var remixLib = require('remix-lib')
var
EventManager
=
remixLib
.
EventManager
var
EventManager
=
remixLib
.
EventManager
var
Web3
=
require
(
'web3'
)
var
Web3
=
require
(
'web3'
)
var
CommandInterpreterAPI
=
require
(
'../../lib/cmdInterpreterAPI'
)
var
executionContext
=
require
(
'../../execution-context'
)
var
executionContext
=
require
(
'../../execution-context'
)
var
Dropdown
=
require
(
'../ui/dropdown'
)
var
Dropdown
=
require
(
'../ui/dropdown'
)
...
@@ -37,6 +38,7 @@ class Terminal {
...
@@ -37,6 +38,7 @@ class Terminal {
}
}
self
.
_view
=
{
el
:
null
,
bar
:
null
,
input
:
null
,
term
:
null
,
journal
:
null
,
cli
:
null
}
self
.
_view
=
{
el
:
null
,
bar
:
null
,
input
:
null
,
term
:
null
,
journal
:
null
,
cli
:
null
}
self
.
_components
=
{}
self
.
_components
=
{}
self
.
_components
.
cmdInterpreter
=
new
CommandInterpreterAPI
(
this
)
self
.
_components
.
dropdown
=
new
Dropdown
({
self
.
_components
.
dropdown
=
new
Dropdown
({
options
:
[
options
:
[
'only remix transactions'
,
'only remix transactions'
,
...
@@ -74,7 +76,6 @@ class Terminal {
...
@@ -74,7 +76,6 @@ class Terminal {
self
.
registerCommand
(
'script'
,
function
execute
(
args
,
scopedCommands
,
append
)
{
self
.
registerCommand
(
'script'
,
function
execute
(
args
,
scopedCommands
,
append
)
{
var
script
=
String
(
args
[
0
])
var
script
=
String
(
args
[
0
])
scopedCommands
.
log
(
`>
${
script
}
`
)
scopedCommands
.
log
(
`>
${
script
}
`
)
if
(
self
.
_opts
.
cmdInterpreter
&&
self
.
_opts
.
cmdInterpreter
.
interpret
(
script
))
return
self
.
_shell
(
script
,
scopedCommands
,
function
(
error
,
output
)
{
self
.
_shell
(
script
,
scopedCommands
,
function
(
error
,
output
)
{
if
(
error
)
scopedCommands
.
error
(
error
)
if
(
error
)
scopedCommands
.
error
(
error
)
else
scopedCommands
.
log
(
output
)
else
scopedCommands
.
log
(
output
)
...
@@ -561,6 +562,7 @@ class Terminal {
...
@@ -561,6 +562,7 @@ class Terminal {
function
domTerminalFeatures
(
self
,
scopedCommands
)
{
function
domTerminalFeatures
(
self
,
scopedCommands
)
{
return
{
return
{
remix
:
self
.
_components
.
cmdInterpreter
,
web3
:
executionContext
.
getProvider
()
!==
'vm'
?
new
Web3
(
executionContext
.
web3
().
currentProvider
)
:
null
,
web3
:
executionContext
.
getProvider
()
!==
'vm'
?
new
Web3
(
executionContext
.
web3
().
currentProvider
)
:
null
,
console
:
{
console
:
{
log
:
function
()
{
scopedCommands
.
log
.
apply
(
scopedCommands
,
arguments
)
},
log
:
function
()
{
scopedCommands
.
log
.
apply
(
scopedCommands
,
arguments
)
},
...
...
src/lib/cmdInterpreter.js
deleted
100644 → 0
View file @
c745cdb0
'use strict'
var
remixLib
=
require
(
'remix-lib'
)
var
EventManager
=
remixLib
.
EventManager
var
CommandInterpreterAPI
=
require
(
'./cmdInterpreterAPI'
)
class
CmdInterpreter
{
constructor
()
{
this
.
event
=
new
EventManager
()
this
.
api
=
new
CommandInterpreterAPI
(
this
)
}
interpret
(
cmd
,
cb
)
{
if
(
!
cmd
)
return
false
var
accept
=
commandsRegEx
.
exec
(
cmd
)
if
(
accept
)
{
var
param
=
accept
[
2
]
if
(
param
)
param
=
param
.
trim
()
this
.
api
[
accept
[
1
]](
param
,
cb
)
return
accept
[
1
]
}
return
null
}
}
var
commandsRegEx
=
/^remix:
(
debug|loadgist|setproviderurl|loadurl|batch
)(
.*
)
/
module
.
exports
=
CmdInterpreter
src/lib/cmdInterpreterAPI.js
View file @
f636f7ee
...
@@ -8,12 +8,12 @@ var toolTip = require('../app/ui/tooltip')
...
@@ -8,12 +8,12 @@ var toolTip = require('../app/ui/tooltip')
var
globalRegistry
=
require
(
'../global/registry'
)
var
globalRegistry
=
require
(
'../global/registry'
)
class
CmdInterpreterAPI
{
class
CmdInterpreterAPI
{
constructor
(
cmdInterpreter
,
localRegistry
)
{
constructor
(
terminal
,
localRegistry
)
{
const
self
=
this
const
self
=
this
self
.
event
=
new
EventManager
()
self
.
event
=
new
EventManager
()
self
.
_components
=
{}
self
.
_components
=
{}
self
.
_components
.
registry
=
localRegistry
||
globalRegistry
self
.
_components
.
registry
=
localRegistry
||
globalRegistry
self
.
_components
.
cmdInterpreter
=
cmdInterpreter
self
.
_components
.
terminal
=
terminal
self
.
_deps
=
{
self
.
_deps
=
{
app
:
self
.
_components
.
registry
.
get
(
'app'
).
api
,
app
:
self
.
_components
.
registry
.
get
(
'app'
).
api
,
editor
:
self
.
_components
.
registry
.
get
(
'editor'
).
api
editor
:
self
.
_components
.
registry
.
get
(
'editor'
).
api
...
@@ -60,7 +60,7 @@ class CmdInterpreterAPI {
...
@@ -60,7 +60,7 @@ class CmdInterpreterAPI {
if
(
cb
)
cb
()
if
(
cb
)
cb
()
})
})
}
}
batch
(
url
,
cb
)
{
exeCurrent
(
cb
)
{
const
self
=
this
const
self
=
this
var
content
=
self
.
_deps
.
editor
.
currentContent
()
var
content
=
self
.
_deps
.
editor
.
currentContent
()
if
(
!
content
)
{
if
(
!
content
)
{
...
@@ -68,17 +68,7 @@ class CmdInterpreterAPI {
...
@@ -68,17 +68,7 @@ class CmdInterpreterAPI {
if
(
cb
)
cb
()
if
(
cb
)
cb
()
return
return
}
}
var
split
=
content
.
split
(
'
\
n'
)
self
.
_components
.
terminal
.
commands
.
script
(
content
)
async
.
eachSeries
(
split
,
(
value
,
cb
)
=>
{
if
(
!
self
.
_components
.
cmdInterpreter
.
interpret
(
value
,
(
error
)
=>
{
error
?
cb
(
`Cannot run
${
value
}
. stopping`
)
:
cb
()
}))
{
cb
(
`Cannot interpret
${
value
}
. stopping`
)
}
},
(
error
)
=>
{
if
(
error
)
toolTip
(
error
)
if
(
cb
)
cb
()
})
}
}
}
}
...
...
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