Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
duniter-ui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
modules
duniter-ui
Commits
02ef7c55
Commit
02ef7c55
authored
5 years ago
by
Baptiste Lemoine
Browse files
Options
Downloads
Patches
Plain Diff
doc readme
parent
3b74afe4
No related branches found
Branches containing commit
No related tags found
1 merge request
!28
Traduction Française de duniter-ui
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+6
-1
6 additions, 1 deletion
README.md
index.js
+82
-78
82 additions, 78 deletions
index.js
package.json
+1
-0
1 addition, 0 deletions
package.json
with
89 additions
and
79 deletions
README.md
+
6
−
1
View file @
02ef7c55
...
...
@@ -8,9 +8,10 @@ Duniter graphical interface. This is a developement package which is embedded in
> Requires [Yarn](https://classic.yarnpkg.com/en/docs/install/)
```
bash
npm i
-g
nvm yarn
nvm
install
9
nvm use 9
yarn
yarn
--pure-lockfile
```
## Run
...
...
@@ -18,3 +19,7 @@ yarn
```
bash
node run.js direct_webstart
```
or
```
bash
node_modules/brunch/bin/brunch watch
--server
```
This diff is collapsed.
Click to expand it.
index.js
+
82
−
78
View file @
02ef7c55
"
use strict
"
;
'
use strict
'
;
const
_
=
require
(
'
underscore
'
)
const
_
=
require
(
'
underscore
'
)
;
const
co
=
require
(
'
co
'
);
const
fs
=
require
(
'
fs
'
);
const
bodyParser
=
require
(
'
body-parser
'
);
const
http
=
require
(
'
http
'
);
const
http
=
require
(
'
http
'
);
const
express
=
require
(
'
express
'
);
const
path
=
require
(
'
path
'
);
const
path
=
require
(
'
path
'
);
const
cors
=
require
(
'
cors
'
);
const
fileUpload
=
require
(
'
express-fileupload
'
);
const
webminController
=
require
(
'
./server/controller/webmin.js
'
);
...
...
@@ -23,34 +23,34 @@ module.exports = {
// Webmin options
{
value
:
'
--webmhost <host>
'
,
desc
:
'
Local network interface to connect to (IP)
'
},
{
value
:
'
--webmport <port>
'
,
desc
:
'
Local network port to connect
'
,
parser
:
parseInt
}
{
value
:
'
--webmport <port>
'
,
desc
:
'
Local network port to connect
'
,
parser
:
parseInt
}
,
],
cli
:
[{
name
:
'
webstart
'
,
desc
:
'
Starts Duniter as a daemon (background task).
'
,
logs
:
false
,
onConfiguredExecute
:
(
server
,
conf
,
program
,
params
)
=>
co
(
function
*
()
{
yield
server
.
checkConfig
()
const
daemon
=
server
.
getDaemon
(
'
direct_webstart
'
,
'
webstart
'
)
yield
startDaemon
(
program
,
daemon
)
})
name
:
'
webstart
'
,
desc
:
'
Starts Duniter as a daemon (background task).
'
,
logs
:
false
,
onConfiguredExecute
:
(
server
,
conf
,
program
,
params
)
=>
co
(
function
*
()
{
yield
server
.
checkConfig
()
;
const
daemon
=
server
.
getDaemon
(
'
direct_webstart
'
,
'
webstart
'
)
;
yield
startDaemon
(
program
,
daemon
)
;
})
,
},
{
name
:
'
webrestart
'
,
desc
:
'
Stops Duniter daemon and restart it with its web interface.
'
,
logs
:
false
,
onConfiguredExecute
:
(
server
,
conf
,
program
,
params
)
=>
co
(
function
*
()
{
yield
server
.
checkConfig
()
const
daemon
=
server
.
getDaemon
(
'
direct_webstart
'
,
'
webrestart
'
)
yield
stopDaemon
(
daemon
)
yield
startDaemon
(
program
,
daemon
)
})
name
:
'
webrestart
'
,
desc
:
'
Stops Duniter daemon and restart it with its web interface.
'
,
logs
:
false
,
onConfiguredExecute
:
(
server
,
conf
,
program
,
params
)
=>
co
(
function
*
()
{
yield
server
.
checkConfig
()
;
const
daemon
=
server
.
getDaemon
(
'
direct_webstart
'
,
'
webrestart
'
)
;
yield
stopDaemon
(
daemon
)
;
yield
startDaemon
(
program
,
daemon
)
;
})
,
},
{
name
:
'
direct_webstart
'
,
desc
:
'
Do a webstart
'
,
onDatabaseExecute
:
(
server
,
conf
,
program
,
params
,
startServices
,
stopServices
,
stack
)
=>
co
(
function
*
(){
name
:
'
direct_webstart
'
,
desc
:
'
Do a webstart
'
,
onDatabaseExecute
:
(
server
,
conf
,
program
,
params
,
startServices
,
stopServices
,
stack
)
=>
co
(
function
*
()
{
try
{
...
...
@@ -73,35 +73,36 @@ module.exports = {
app
.
use
(
fileUpload
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
extended
:
true
,
}));
app
.
use
(
bodyParser
.
json
());
const
wbmin
=
webminController
(
server
,
startServices
,
stopServices
,
listDuniterPlugins
,
stack
);
const
httpServer
=
http
.
createServer
(
app
);
httpServer
.
listen
(
PORT
,
HOTE
);
server
.
logger
.
info
(
"
Web administration accessible at following address: http://%s:%s
"
,
HOTE
,
PORT
);
server
.
logger
.
info
(
'
Web administration accessible at following address: http://%s:%s
'
,
HOTE
,
PORT
);
require
(
'
./server/lib/routes
'
).
webmin
(
wbmin
,
app
);
require
(
'
./server/lib/routes
'
).
webminWS
(
wbmin
)(
httpServer
);
const
uiDeps
=
listDuniterUIPlugins
()
const
uiDeps
=
listDuniterUIPlugins
()
;
for
(
const
dep
of
uiDeps
)
{
// Eventual HTTP routing
if
(
dep
.
required
.
duniterUI
.
route
)
{
const
subApp
=
express
()
dep
.
required
.
duniterUI
.
route
(
subApp
,
server
,
conf
,
program
,
params
)
app
.
use
(
'
/modules/
'
,
subApp
)
const
subApp
=
express
()
;
dep
.
required
.
duniterUI
.
route
(
subApp
,
server
,
conf
,
program
,
params
)
;
app
.
use
(
'
/modules/
'
,
subApp
)
;
}
}
const
currentBlock
=
yield
server
.
dal
.
getCurrentBlockOrNull
()
const
currentBlock
=
yield
server
.
dal
.
getCurrentBlockOrNull
()
;
if
(
currentBlock
)
{
yield
wbmin
.
startAllServices
()
yield
wbmin
.
startAllServices
()
;
}
// Never ending promise
return
new
Promise
((
resolve
)
=>
{});
return
new
Promise
((
resolve
)
=>
{
});
/****************************************/
...
...
@@ -109,30 +110,30 @@ module.exports = {
console
.
error
(
e
);
process
.
exit
(
1
);
}
})
}]
}
})
,
}]
,
}
,
};
function
startDaemon
(
program
,
daemon
)
{
return
co
(
function
*
()
{
return
co
(
function
*
()
{
const
PORT
=
program
.
webmport
||
922
0
const
PORT
=
program
.
webmport
||
922
1
;
const
isPortAlreadyTaken
=
yield
new
Promise
((
resolve
)
=>
{
isPortTaken
(
PORT
,
(
err
,
taken
)
=>
err
?
reject
(
err
)
:
resolve
(
taken
))
})
isPortTaken
(
PORT
,
(
err
,
taken
)
=>
err
?
reject
(
err
)
:
resolve
(
taken
))
;
})
;
if
(
isPortAlreadyTaken
)
{
console
.
error
(
'
Port
'
+
PORT
+
'
already used.
'
)
process
.
exit
(
3
)
console
.
error
(
'
Port
'
+
PORT
+
'
already used.
'
)
;
process
.
exit
(
3
)
;
}
return
new
Promise
((
resolve
,
reject
)
=>
daemon
.
start
((
err
)
=>
{
if
(
err
)
return
reject
(
err
)
resolve
()
}))
})
if
(
err
)
return
reject
(
err
)
;
resolve
()
;
}))
;
})
;
}
/**
...
...
@@ -143,67 +144,70 @@ function startDaemon(program, daemon) {
* @param fn
*/
function
isPortTaken
(
port
,
fn
)
{
const
net
=
require
(
'
net
'
)
const
net
=
require
(
'
net
'
)
;
const
tester
=
net
.
createServer
()
.
once
(
'
error
'
,
function
(
err
)
{
if
(
err
.
code
!=
'
EADDRINUSE
'
)
return
fn
(
err
)
fn
(
null
,
true
)
if
(
err
.
code
!=
'
EADDRINUSE
'
)
return
fn
(
err
)
;
fn
(
null
,
true
)
;
})
.
once
(
'
listening
'
,
function
()
{
tester
.
once
(
'
close
'
,
function
()
{
fn
(
null
,
false
)
})
.
close
()
.
once
(
'
listening
'
,
function
()
{
tester
.
once
(
'
close
'
,
function
()
{
fn
(
null
,
false
);
})
.
close
();
})
.
listen
(
port
)
.
listen
(
port
)
;
}
function
stopDaemon
(
daemon
)
{
return
new
Promise
((
resolve
,
reject
)
=>
daemon
.
stop
((
err
)
=>
{
err
&&
console
.
error
(
err
);
if
(
err
)
return
reject
(
err
)
resolve
()
}))
if
(
err
)
return
reject
(
err
)
;
resolve
()
;
}))
;
}
function
listDuniterPlugins
()
{
return
listPlugins
(
r
=>
!!
r
.
duniter
||
!!
r
.
duniterUI
)
return
listPlugins
(
r
=>
!!
r
.
duniter
||
!!
r
.
duniterUI
)
;
}
function
listDuniterUIPlugins
()
{
return
listPlugins
(
r
=>
!!
r
.
duniterUI
)
return
listPlugins
(
r
=>
!!
r
.
duniterUI
)
;
}
function
listPlugins
(
conditionTest
)
{
const
uiDependencies
=
[]
const
pathToPackageJSON
=
path
.
resolve
(
'
./package.json
'
)
const
pkgJSON
=
JSON
.
parse
(
fs
.
readFileSync
(
pathToPackageJSON
,
'
utf8
'
))
const
peerDeps
=
pkgJSON
.
peerDependencies
||
{}
const
allDeps
=
_
.
extend
(
pkgJSON
.
dependencies
||
{},
pkgJSON
.
devDependencies
||
{})
const
deps
=
Object
.
keys
(
allDeps
)
const
uiDependencies
=
[]
;
const
pathToPackageJSON
=
path
.
resolve
(
'
./package.json
'
)
;
const
pkgJSON
=
JSON
.
parse
(
fs
.
readFileSync
(
pathToPackageJSON
,
'
utf8
'
))
;
const
peerDeps
=
pkgJSON
.
peerDependencies
||
{}
;
const
allDeps
=
_
.
extend
(
pkgJSON
.
dependencies
||
{},
pkgJSON
.
devDependencies
||
{})
;
const
deps
=
Object
.
keys
(
allDeps
)
;
for
(
const
dep
of
deps
)
{
try
{
const
required
=
require
(
dep
)
const
required
=
require
(
dep
)
;
if
(
required
&&
conditionTest
(
required
))
{
uiDependencies
.
push
({
name
:
dep
,
name
:
dep
,
version
:
allDeps
[
dep
],
locked
:
!!
peerDeps
[
dep
],
required
})
locked
:
!!
peerDeps
[
dep
],
required
,
})
;
}
}
catch
(
e
)
{}
}
catch
(
e
)
{
}
}
// Special: self dependency (if local package is also a module)
if
(
pkgJSON
.
main
&&
pkgJSON
.
main
.
match
(
/
\.
js/
))
{
// With NW.js, the main is an index.html file, which causes a bug
const
dep
=
pkgJSON
.
name
const
required
=
require
(
path
.
resolve
(
'
./
'
+
pkgJSON
.
main
))
const
dep
=
pkgJSON
.
name
;
const
required
=
require
(
path
.
resolve
(
'
./
'
+
pkgJSON
.
main
))
;
if
(
required
&&
conditionTest
(
required
))
{
uiDependencies
.
push
({
name
:
dep
,
name
:
dep
,
version
:
'
local
'
,
locked
:
true
,
required
})
locked
:
true
,
required
,
})
;
}
}
return
uiDependencies
return
uiDependencies
;
}
This diff is collapsed.
Click to expand it.
package.json
+
1
−
0
View file @
02ef7c55
...
...
@@ -7,6 +7,7 @@
"b"
:
"brunch build"
,
"watch"
:
"brunch watch"
,
"start"
:
"cd cesium && npm start"
,
"webstart"
:
"node run.js direct_webstart"
,
"test"
:
"mocha --growl tests/"
},
"repository"
:
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment