Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
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
duniter
Commits
c3728e6d
Commit
c3728e6d
authored
6 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[enh] Precising Duniter exportable definitions
parent
0ffdf513
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/lib/common-libs/programOptions.ts
+3
-0
3 additions, 0 deletions
app/lib/common-libs/programOptions.ts
app/modules/DuniterModule.ts
+53
-0
53 additions, 0 deletions
app/modules/DuniterModule.ts
index.ts
+18
-6
18 additions, 6 deletions
index.ts
with
74 additions
and
6 deletions
app/lib/common-libs/programOptions.ts
+
3
−
0
View file @
c3728e6d
...
...
@@ -24,6 +24,9 @@ export interface ProgramOptions {
isSync
:
boolean
noSources
:
boolean
slow
?:
boolean
loglevel
?:
string
sqlTraces
?:
boolean
memory
?:
boolean
}
export
const
cliprogram
:
ProgramOptions
=
{
...
...
This diff is collapsed.
Click to expand it.
app/modules/DuniterModule.ts
0 → 100644
+
53
−
0
View file @
c3728e6d
import
{
Server
}
from
"
../../server
"
import
{
ConfDTO
}
from
"
../lib/dto/ConfDTO
"
import
{
ProgramOptions
}
from
"
../lib/common-libs/programOptions
"
import
{
ConfDAL
}
from
"
../lib/dal/fileDALs/ConfDAL
"
import
{
ReadableDuniterService
,
Stack
,
TransformableDuniterService
}
from
"
../../index
"
export
interface
DuniterModule
{
name
:
string
required
:
{
duniter
:
DuniterDependency
}
}
export
interface
DuniterDependency
{
cliOptions
?:
CliOption
[]
cli
?:
CliCommand
[]
config
?:
{
onLoading
:
(
conf
:
ConfDTO
,
program
:
ProgramOptions
,
logger
:
any
,
confDAL
:
ConfDAL
)
=>
void
beforeSave
:
(
conf
:
ConfDTO
,
program
:
ProgramOptions
,
logger
:
any
,
confDAL
:
ConfDAL
)
=>
void
}
onReset
?:
{
data
:
(
conf
:
ConfDTO
,
program
:
ProgramOptions
,
logger
:
any
,
confDAL
:
ConfDAL
)
=>
void
config
:
(
conf
:
ConfDTO
,
program
:
ProgramOptions
,
logger
:
any
,
confDAL
:
ConfDAL
)
=>
void
}
wizard
?:
{
[
k
:
string
]:
(
conf
:
ConfDTO
,
program
:
ProgramOptions
)
=>
Promise
<
void
>
}
service
?:
{
input
:
(
server
:
Server
,
conf
:
ConfDTO
,
logger
:
any
)
=>
ReadableDuniterService
process
:
(
server
:
Server
,
conf
:
ConfDTO
,
logger
:
any
)
=>
TransformableDuniterService
output
:
(
server
:
Server
,
conf
:
ConfDTO
,
logger
:
any
)
=>
TransformableDuniterService
neutral
:
(
server
:
Server
,
conf
:
ConfDTO
,
logger
:
any
)
=>
TransformableDuniterService
}
}
export
interface
CliOption
{
value
:
string
desc
:
string
parser
?:
(
parameter
:
string
)
=>
any
}
export
interface
CliCommand
{
name
:
string
desc
:
string
logs
?:
boolean
preventIfRunning
?:
boolean
onConfiguredExecute
?:
(
server
:
Server
,
conf
?:
ConfDTO
,
program
?:
ProgramOptions
,
params
?:
string
[],
wizardTasks
?:
any
,
stack
?:
Stack
)
=>
Promise
<
void
>
onDatabaseExecute
?:
(
server
:
Server
,
conf
?:
ConfDTO
,
program
?:
ProgramOptions
,
params
?:
string
[],
startServices
?:
()
=>
Promise
<
void
>
,
stopServices
?:
()
=>
Promise
<
void
>
,
stack
?:
Stack
)
=>
Promise
<
void
>
}
This diff is collapsed.
Click to expand it.
index.ts
+
18
−
6
View file @
c3728e6d
...
...
@@ -26,6 +26,8 @@ import {RouterDependency} from "./app/modules/router"
import
{
OtherConstants
}
from
"
./app/lib/other_constants
"
import
{
Directory
}
from
"
./app/lib/system/directory
"
import
{
Underscore
}
from
"
./app/lib/common-libs/underscore
"
import
{
CliCommand
,
DuniterDependency
,
DuniterModule
}
from
"
./app/modules/DuniterModule
"
import
{
ProgramOptions
}
from
"
./app/lib/common-libs/programOptions
"
const
path
=
require
(
'
path
'
);
const
constants
=
require
(
'
./app/lib/constants
'
);
...
...
@@ -179,7 +181,7 @@ export interface DuniterService {
export
interface
ReadableDuniterService
extends
DuniterService
,
stream
.
Readable
{}
export
interface
TransformableDuniterService
extends
DuniterService
,
stream
.
Transform
{}
class
Stack
{
export
class
Stack
{
private
injectedServices
=
false
...
...
@@ -192,7 +194,7 @@ class Stack {
private
PROCESS
:
any
private
loaded
:
any
private
wizardTasks
:
any
private
definitions
:
an
y
[]
=
[]
private
definitions
:
DuniterDependenc
y
[]
=
[]
private
streams
:
{
input
:
ReadableDuniterService
[]
process
:
TransformableDuniterService
[]
...
...
@@ -205,7 +207,7 @@ class Stack {
neutral
:
[]
}
constructor
(
private
dependencies
:
any
[])
{
constructor
(
private
dependencies
:
DuniterModule
[])
{
this
.
cli
=
ExecuteCommand
()
this
.
configLoadingCallbacks
=
[]
this
.
configBeforeSaveCallbacks
=
[]
...
...
@@ -227,7 +229,7 @@ class Stack {
return
this
.
loaded
[
name
]
}
registerDependency
(
requiredObject
:
any
,
name
:
string
)
{
registerDependency
(
requiredObject
:
{
duniter
:
DuniterDependency
}
,
name
:
string
)
{
if
(
name
&&
this
.
loaded
[
name
])
{
// Do not try to load it twice
return
;
...
...
@@ -286,8 +288,8 @@ class Stack {
};
async
processCommand
(...
args
:
any
[])
{
const
command
=
args
[
0
];
const
program
=
args
[
1
];
const
command
:
CliCommand
=
args
[
0
];
const
program
:
ProgramOptions
=
args
[
1
];
const
params
=
args
.
slice
(
2
);
params
.
pop
();
// Don't need the command argument
...
...
@@ -393,6 +395,8 @@ class Stack {
if
(
!
command
.
onDatabaseExecute
)
{
return
res
}
}
else
if
(
!
command
.
onDatabaseExecute
)
{
throw
`Command
${
command
.
name
}
does not implement onConfiguredExecute nor onDatabaseExecute.`
}
// Second possible class of commands: post-service
await
server
.
initDAL
(
conf
);
...
...
@@ -602,3 +606,11 @@ class ProcessStream extends stream.Transform {
done
&&
done
();
};
}
export
const
Duniter
=
{
run
(
modules
:
DuniterModule
[]
=
[],
args
?:
string
[])
{
return
Stacks
.
autoStack
(
modules
).
executeStack
(
args
||
process
.
argv
)
}
}
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