blacksmith-organization-system 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +83 -0
- package/config/README.md +0 -0
- package/docs/README.md +15 -0
- package/docs/devlog.md +20 -0
- package/invoke-api.js +0 -0
- package/invoke-cli.js +105 -0
- package/invoke-desktop.js +0 -0
- package/invoke-exec.js +0 -0
- package/invoke-webapp.js +0 -0
- package/main.js +33 -0
- package/package.json +38 -0
- package/shell-procedures/deploy-new-workshop.sh +15 -0
- package/shell-procedures/new-project.sh +0 -0
- package/shell-procedures/new-sheme.sh +0 -0
- package/shell-procedures/new-superproject.sh +6 -0
- package/shell-procedures/open-project.sh +0 -0
- package/shell-procedures/pack-backup.sh +22 -0
- package/shell-procedures/project-to-sarcophag.sh +0 -0
- package/shell-procedures/publicate.sh +0 -0
- package/shell-procedures/pull-archive.sh +0 -0
- package/shell-procedures/purge-workshop.sh +4 -0
- package/shell-procedures/push-to-bos-server.sh +0 -0
- package/shell-procedures/start-cli-interface.sh +1 -0
- package/shell-procedures/sweep-into-throwbox.sh +0 -0
- package/shell-procedures/synchronize.sh +7 -0
- package/system/bridges/README.md +4 -0
- package/system/bridges/main.js +41 -0
- package/system/commands/README.md +0 -0
- package/system/commands/debug.js +20 -0
- package/system/commands/exit.js +19 -0
- package/system/core/README.md +0 -0
- package/system/core/basic-subject-model.js +200 -0
- package/system/core/config-controll.js +51 -0
- package/system/core/contain-controll.js +28 -0
- package/system/core/event-controll.js +12 -0
- package/system/core/extending-mod.js +145 -0
- package/system/core/main.js +184 -0
- package/system/core/raport-controll.js +10 -0
- package/system/core/static-extender.js +19 -0
- package/system/factors/README.md +0 -0
- package/system/factors/bridge-factory.js +5 -0
- package/system/factors/command-factory.js +45 -0
- package/system/factors/config-factory.js +6 -0
- package/system/factors/controller-factory.js +5 -0
- package/system/factors/interface-factory.js +70 -0
- package/system/factors/model-factory.js +0 -0
- package/system/interfaces/README.md +28 -0
- package/system/interfaces/cli/index.js +96 -0
- package/system/interfaces/cli/init.js +47 -0
- package/system/interfaces/cli/loop.js +7 -0
- package/system/interfaces/cli/on-close.js +17 -0
- package/system/interfaces/cli/on-line.js +24 -0
- package/system/interfaces/cli/on-resume.js +15 -0
- package/system/interfaces/cli/setup.js +8 -0
- package/system/models/README.md +47 -0
- package/system/models/archive/README.md +0 -0
- package/system/models/archive/actions/README.md +0 -0
- package/system/models/archive/class.js +23 -0
- package/system/models/archive/events/README.md +0 -0
- package/system/models/archive/index.json +18 -0
- package/system/models/archive/listeners/README.md +0 -0
- package/system/models/archive/methods/README.md +0 -0
- package/system/models/forge/README.md +0 -0
- package/system/models/forge/actions/README.md +0 -0
- package/system/models/forge/class.js +23 -0
- package/system/models/forge/events/README.md +0 -0
- package/system/models/forge/index.json +18 -0
- package/system/models/forge/listeners/README.md +0 -0
- package/system/models/forge/methods/README.md +0 -0
- package/system/models/project/README.md +0 -0
- package/system/models/project/actions/README.md +0 -0
- package/system/models/project/class.js +23 -0
- package/system/models/project/events/README.md +0 -0
- package/system/models/project/index.json +18 -0
- package/system/models/project/listeners/README.md +0 -0
- package/system/models/project/methods/README.md +0 -0
- package/system/models/sarcophag/README.md +0 -0
- package/system/models/sarcophag/actions/README.md +0 -0
- package/system/models/sarcophag/class.js +22 -0
- package/system/models/sarcophag/events/README.md +0 -0
- package/system/models/sarcophag/index.json +18 -0
- package/system/models/sarcophag/listeners/README.md +0 -0
- package/system/models/sarcophag/methods/README.md +0 -0
- package/system/models/sheme/README.md +0 -0
- package/system/models/sheme/actions/README.md +0 -0
- package/system/models/sheme/class.js +23 -0
- package/system/models/sheme/events/README.md +0 -0
- package/system/models/sheme/index.json +18 -0
- package/system/models/sheme/listeners/README.md +0 -0
- package/system/models/sheme/methods/README.md +0 -0
- package/system/models/superproject/README.md +0 -0
- package/system/models/superproject/actions/README.md +0 -0
- package/system/models/superproject/class.js +23 -0
- package/system/models/superproject/events/README.md +0 -0
- package/system/models/superproject/index.json +18 -0
- package/system/models/superproject/listeners/README.md +0 -0
- package/system/models/superproject/methods/README.md +0 -0
- package/system/models/throwbox/README.md +0 -0
- package/system/models/throwbox/actions/README.md +0 -0
- package/system/models/throwbox/class.js +23 -0
- package/system/models/throwbox/events/README.md +0 -0
- package/system/models/throwbox/index.json +18 -0
- package/system/models/throwbox/listeners/README.md +0 -0
- package/system/models/throwbox/methods/README.md +0 -0
- package/system/models/workshop/README.md +0 -0
- package/system/models/workshop/actions/README.md +0 -0
- package/system/models/workshop/class.js +22 -0
- package/system/models/workshop/events/README.md +0 -0
- package/system/models/workshop/index.json +18 -0
- package/system/models/workshop/listeners/README.md +0 -0
- package/system/models/workshop/methods/README.md +0 -0
- package/system/resources/textarts/big-logo-title.txt +24 -0
- package/system/resources/textarts/big-shortcut-logo-title.txt +10 -0
- package/system/resources/textarts/medium-logo-title.txt +13 -0
- package/system/resources/textarts/minimenu-header.ptxml +13 -0
- package/system/resources/textarts/minimenu-header.txt +11 -0
- package/system/resources/textarts/small-logo-title.txt +10 -0
- package/system/resources/textarts/wellcome.txt +10 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/*
|
|
2
|
+
blacksmith-organization-system
|
|
3
|
+
part of Anubis System
|
|
4
|
+
Sett Sarverott 2019
|
|
5
|
+
*/
|
|
6
|
+
module.exports=function(BOS){
|
|
7
|
+
return class BlacksmithSubject extends BOS{
|
|
8
|
+
//static counter=0;
|
|
9
|
+
//initializationOfObject(initOpts){
|
|
10
|
+
|
|
11
|
+
//}
|
|
12
|
+
//loadConfiguration(){
|
|
13
|
+
|
|
14
|
+
//}
|
|
15
|
+
//eventListenersSetup(){
|
|
16
|
+
|
|
17
|
+
//}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
const {BOS, SE}=require("./main.js");
|
|
23
|
+
const fs=require("fs");
|
|
24
|
+
const path=require("path");
|
|
25
|
+
class BlacksmithSubject extends BOS{
|
|
26
|
+
setup(dirpath, name=path.basename(dirpath)){
|
|
27
|
+
SE.SAFE_CREATE_DIR(dirpath);
|
|
28
|
+
//this.parrent=parrent;
|
|
29
|
+
this.status="forged";
|
|
30
|
+
this.name=name;
|
|
31
|
+
this.dirpath=dirpath;
|
|
32
|
+
//this.extensions=[];
|
|
33
|
+
//this.history=[];
|
|
34
|
+
this.mainWatchHook=null;
|
|
35
|
+
this.content=this.refreshContent();
|
|
36
|
+
//GITIGNORE READING NEEDED
|
|
37
|
+
//this.files=[];
|
|
38
|
+
this.watcher=function(){};
|
|
39
|
+
//GITIGNORE READING NEEDED
|
|
40
|
+
}
|
|
41
|
+
refreshContent(){
|
|
42
|
+
var content={};
|
|
43
|
+
content.files=fs.readdirSync(
|
|
44
|
+
this.dirpath,
|
|
45
|
+
{withFileTypes:true}
|
|
46
|
+
).map(function(file){
|
|
47
|
+
return {
|
|
48
|
+
name:file.name,
|
|
49
|
+
type:
|
|
50
|
+
(file.isFile())
|
|
51
|
+
?
|
|
52
|
+
"flie"
|
|
53
|
+
:
|
|
54
|
+
(
|
|
55
|
+
(file.isDirectory())?"dir":"else"
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
content.status=fs.statSync(this.dirpath);
|
|
60
|
+
return content;
|
|
61
|
+
}
|
|
62
|
+
mainWatch(command){
|
|
63
|
+
switch(command){
|
|
64
|
+
case "start":
|
|
65
|
+
var tmpThis=this;
|
|
66
|
+
this.mainWatchHook=fs.watch(this.dirpath,function(...args){
|
|
67
|
+
args.push(tmpThis.refreshContent);
|
|
68
|
+
tmpThis.watcher(...args);
|
|
69
|
+
});
|
|
70
|
+
break;
|
|
71
|
+
case "stop":
|
|
72
|
+
if(this.mainWatchHook)this.mainWatchHook.close();
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//GITIGNORE READING NEEDED
|
|
78
|
+
/*
|
|
79
|
+
readContent(dirpath=this.dirpath){
|
|
80
|
+
var filelistTmp=fs.readdirSync(dirpath, {withFileTypes:true});
|
|
81
|
+
var output=[];
|
|
82
|
+
for(var i in filelistTmp){
|
|
83
|
+
var tmpFile={
|
|
84
|
+
"name":filelistTmp[i].name,
|
|
85
|
+
"path":path.join(dirpath,filelistTmp[i].name)
|
|
86
|
+
};
|
|
87
|
+
fs.stat(tmpFile.path,function(err, data){
|
|
88
|
+
tmpFile.status=data;
|
|
89
|
+
});
|
|
90
|
+
if(filelistTmp[i].isDirectory()){
|
|
91
|
+
tmpFile.type="dir";
|
|
92
|
+
tmpFile.content=this.readContent(tmpFile.path);
|
|
93
|
+
}else if(filelistTmp[i].isFile()){
|
|
94
|
+
tmpFile.type="file";
|
|
95
|
+
var tmpThis=this;
|
|
96
|
+
tmpFile.listener=fs.watchFile(tmpFile.path, function(...args){
|
|
97
|
+
tmpThis.watcher(...args);
|
|
98
|
+
});
|
|
99
|
+
}else{
|
|
100
|
+
tmpFile.type="else";
|
|
101
|
+
}
|
|
102
|
+
output.push(tmpFile);
|
|
103
|
+
}
|
|
104
|
+
if(dirpath===this.dirpath)this.files=output;
|
|
105
|
+
return output;
|
|
106
|
+
//fs.watch(path, action);
|
|
107
|
+
}
|
|
108
|
+
*/
|
|
109
|
+
//GITIGNORE READING NEEDED
|
|
110
|
+
/*
|
|
111
|
+
open(){
|
|
112
|
+
this.emitter.emit('open');
|
|
113
|
+
}
|
|
114
|
+
create(){
|
|
115
|
+
this.emitter.emit('create');
|
|
116
|
+
}
|
|
117
|
+
save(){
|
|
118
|
+
this.emitter.emit('save');
|
|
119
|
+
}
|
|
120
|
+
close(){
|
|
121
|
+
this.emitter.emit('close');
|
|
122
|
+
}
|
|
123
|
+
delete(){
|
|
124
|
+
this.emitter.emit('delete');
|
|
125
|
+
}
|
|
126
|
+
move(){
|
|
127
|
+
this.emitter.emit('move');
|
|
128
|
+
}
|
|
129
|
+
list(){
|
|
130
|
+
this.emitter.emit('list');
|
|
131
|
+
}
|
|
132
|
+
upload(){
|
|
133
|
+
this.emitter.emit('upload');
|
|
134
|
+
}
|
|
135
|
+
change(){
|
|
136
|
+
this.emitter.emit('change');
|
|
137
|
+
}
|
|
138
|
+
/*loadStorybook(data){
|
|
139
|
+
var tmp=[];
|
|
140
|
+
for(var i in data){
|
|
141
|
+
var tmptmp=new Fileitem(data[i].path);
|
|
142
|
+
tmptmp.checksum=data[i].checksum;
|
|
143
|
+
tmp.push(tmptmp);
|
|
144
|
+
}
|
|
145
|
+
return tmp;
|
|
146
|
+
}
|
|
147
|
+
checkAgreement(data){
|
|
148
|
+
var tmp1=this.loadStorybook(data);
|
|
149
|
+
var tmp2=this.scanFiles();
|
|
150
|
+
for(var i in tmp1){
|
|
151
|
+
for(var i in tmp1){
|
|
152
|
+
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
scanFiles(){
|
|
157
|
+
var tmp=getFilelist(this.getPath());
|
|
158
|
+
var tmpFiles=[]
|
|
159
|
+
for(var i in tmp){
|
|
160
|
+
var tmptmp=new Fileitem(tmp[i]);
|
|
161
|
+
tmptmp.getChecksum();
|
|
162
|
+
tmpFiles.push(tmptmp);
|
|
163
|
+
}
|
|
164
|
+
return tmpFiles;
|
|
165
|
+
}*/
|
|
166
|
+
//open(){
|
|
167
|
+
//if(this.isOpened()){
|
|
168
|
+
|
|
169
|
+
// return false;
|
|
170
|
+
//}else{
|
|
171
|
+
|
|
172
|
+
//}
|
|
173
|
+
//if(this.watcher==null){
|
|
174
|
+
// var tmpThis=this;
|
|
175
|
+
// this.watcher=addChangeListener(this.getPath(), function(eventType, filename){
|
|
176
|
+
// tmpThis.onChange(eventType, filename);
|
|
177
|
+
// });
|
|
178
|
+
//}
|
|
179
|
+
//this.onOpen();
|
|
180
|
+
//}
|
|
181
|
+
/*
|
|
182
|
+
getWorkshop(){
|
|
183
|
+
if(this.parrent instanceof BOS.Workshop){
|
|
184
|
+
return this.parrent;
|
|
185
|
+
}else{
|
|
186
|
+
return this.parrent.parrent;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
getSuperproject(){
|
|
190
|
+
if(this.parrent instanceof BOS.Workshop){
|
|
191
|
+
return this;
|
|
192
|
+
}else{
|
|
193
|
+
return this.parrent;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
*/
|
|
197
|
+
/*
|
|
198
|
+
}
|
|
199
|
+
module.exports=BlacksmithSubject;
|
|
200
|
+
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//module.exports=
|
|
2
|
+
// (BOS) => class ConfigControll extends BOS.form.Controller
|
|
3
|
+
// {
|
|
4
|
+
//
|
|
5
|
+
// }
|
|
6
|
+
|
|
7
|
+
const os = require('os');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
|
|
10
|
+
const DEFAULT_CONFIG={
|
|
11
|
+
workshopPath:path.join(
|
|
12
|
+
os.homedir(),
|
|
13
|
+
".__WORKSHOP"
|
|
14
|
+
),
|
|
15
|
+
workshopName:"the-thought-forest",
|
|
16
|
+
host:os.hostname(),//setternet
|
|
17
|
+
user:os.userInfo().username,
|
|
18
|
+
basicShell:os.userInfo().shell,
|
|
19
|
+
instanceRole:["cli","server","desktop","webapp","command"][0],
|
|
20
|
+
encryptArchive:false,
|
|
21
|
+
autobackups:false,
|
|
22
|
+
autocommit:false,
|
|
23
|
+
monitPushingSuggestions:false,
|
|
24
|
+
autoversioning:false,
|
|
25
|
+
branchPerHost:false,
|
|
26
|
+
publishAuth:{
|
|
27
|
+
//gitConfigs:[],
|
|
28
|
+
//npmConfigs:[],
|
|
29
|
+
//ftpCreds...
|
|
30
|
+
},
|
|
31
|
+
logger:{
|
|
32
|
+
|
|
33
|
+
},
|
|
34
|
+
workTree:{
|
|
35
|
+
|
|
36
|
+
},
|
|
37
|
+
setternet:{
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const CONFIG_CONTROLL={
|
|
43
|
+
SETUP:{
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports=CONFIG_CONTROLL;
|
|
48
|
+
// (BOS) => class RaportControll extends BOS.form.Controller
|
|
49
|
+
// {
|
|
50
|
+
|
|
51
|
+
// }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//module.exports=
|
|
2
|
+
// (BOS) => class ContainControll extends BOS.form.Controller
|
|
3
|
+
// {
|
|
4
|
+
//
|
|
5
|
+
// }
|
|
6
|
+
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
const {loadJSON, changeCase, capitalFirst} = require('carnival-toolbox');
|
|
11
|
+
|
|
12
|
+
const CONTAIN_CONTROLL={
|
|
13
|
+
|
|
14
|
+
IsWorkshopDeployed(){
|
|
15
|
+
return fs.existsSync(
|
|
16
|
+
path.join(
|
|
17
|
+
os.homedir(),
|
|
18
|
+
".__WORKSHOP"
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports=CONTAIN_CONTROLL;
|
|
25
|
+
// (BOS) => class RaportControll extends BOS.form.Controller
|
|
26
|
+
// {
|
|
27
|
+
|
|
28
|
+
// }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//const {BOS}=require("./main.js");
|
|
2
|
+
//const events=require("events");
|
|
3
|
+
|
|
4
|
+
//class BOSlistener extends events.EventEmitter{};
|
|
5
|
+
|
|
6
|
+
//module.exports=function(){return new BOSlistener();}
|
|
7
|
+
|
|
8
|
+
//module.exports=
|
|
9
|
+
// (BOS) => class EventControll extends BOS.form.Controller
|
|
10
|
+
// {
|
|
11
|
+
//
|
|
12
|
+
// }
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
|
|
2
|
+
//const transform=require('carnival-toolbox').caseX.transform;
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const {changeCase, capitalFirst, debug} = require('carnival-toolbox');
|
|
6
|
+
|
|
7
|
+
const EXTENDER={
|
|
8
|
+
Update(updatePack, whoAmI=this){
|
|
9
|
+
Object.assign(
|
|
10
|
+
whoAmI,
|
|
11
|
+
updatePack
|
|
12
|
+
);
|
|
13
|
+
return whoAmI;
|
|
14
|
+
},
|
|
15
|
+
HookRef(contextRef, hookName, whoAmI=this){
|
|
16
|
+
Object.defineProperty(
|
|
17
|
+
whoAmI,
|
|
18
|
+
hookName,
|
|
19
|
+
{
|
|
20
|
+
get(){
|
|
21
|
+
return contextRef;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
return whoAmI;
|
|
26
|
+
},
|
|
27
|
+
LoadExt(...pathChain){
|
|
28
|
+
pathChain.push(`${pathChain.pop()}.js`);
|
|
29
|
+
//console.log(this);
|
|
30
|
+
const EXT=require(
|
|
31
|
+
this.PathTo(...pathChain)
|
|
32
|
+
);
|
|
33
|
+
this.Update(
|
|
34
|
+
EXT
|
|
35
|
+
);
|
|
36
|
+
return Object.keys(EXT);
|
|
37
|
+
},
|
|
38
|
+
LoadController(name){
|
|
39
|
+
debug.log("CONTROLER-LOAD:", [name]);
|
|
40
|
+
this.CONTROLLERS[name]=this.LoadExt("system", "core", name);
|
|
41
|
+
},
|
|
42
|
+
LoadInterface(name){
|
|
43
|
+
debug.log("INTERFACE-LOAD:", [name]);
|
|
44
|
+
//this.loadExt("system", "interfaces", name)
|
|
45
|
+
return require(
|
|
46
|
+
this.PathTo(
|
|
47
|
+
"system",
|
|
48
|
+
"interfaces",
|
|
49
|
+
`${name}`,
|
|
50
|
+
`index.js`
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
},
|
|
54
|
+
LoadBridge(name){
|
|
55
|
+
debug.log("BRIDGE-LOAD:", [name]);
|
|
56
|
+
//this.LoadExt("system", "bridge", name)
|
|
57
|
+
},
|
|
58
|
+
LoadAllControllers(){
|
|
59
|
+
const autolistControllers=fs.readdirSync(__dirname).filter(
|
|
60
|
+
(filename)=>filename.endsWith("-controll.js")
|
|
61
|
+
).map(
|
|
62
|
+
(name)=>path.basename(name, ".js")
|
|
63
|
+
);
|
|
64
|
+
for(var item of autolistControllers){
|
|
65
|
+
this.LoadController(item);
|
|
66
|
+
//console.log(item)
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
LoadAllFactors(){
|
|
70
|
+
const factoryScripts=fs.readdirSync(
|
|
71
|
+
this.PathTo("system","factors"),
|
|
72
|
+
{withFileTypes:true}
|
|
73
|
+
).filter(
|
|
74
|
+
(item)=>item.isFile()
|
|
75
|
+
).filter(
|
|
76
|
+
(item)=>item.name.endsWith("-factory.js")
|
|
77
|
+
).map(
|
|
78
|
+
(item)=>item.name
|
|
79
|
+
);
|
|
80
|
+
//this.FACTORS={};
|
|
81
|
+
//console.log(factoryScripts);
|
|
82
|
+
for(var script of factoryScripts){
|
|
83
|
+
debug.log("FACTOR-LOAD:", [script.split("-")[0]]);
|
|
84
|
+
this.FACTORS[
|
|
85
|
+
capitalFirst(script.split("-")[0])
|
|
86
|
+
]=require(this.PathTo("system","factors",script));
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
LoadCommand(name, script){
|
|
90
|
+
debug.log("COMMAND-LOAD:", [name,script]);
|
|
91
|
+
this.COMMANDS[name]=require(
|
|
92
|
+
this.PathTo( "system", "commands", script)
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
LoadAllCommands(){
|
|
96
|
+
const commandsScripts=fs.readdirSync(
|
|
97
|
+
this.PathTo("system", "commands"),
|
|
98
|
+
{withFileTypes:true}
|
|
99
|
+
).filter(
|
|
100
|
+
(script)=>script.isFile()
|
|
101
|
+
).filter(
|
|
102
|
+
(script)=>path.extname(script.name)==".js"
|
|
103
|
+
).map(
|
|
104
|
+
(script)=>script.name
|
|
105
|
+
);
|
|
106
|
+
for(var script of commandsScripts){
|
|
107
|
+
this.LoadCommand(
|
|
108
|
+
changeCase(
|
|
109
|
+
path.basename(script, ".js")
|
|
110
|
+
).from("kebabcase").to("camelcase").GO,
|
|
111
|
+
script
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
LoadAllModels(){
|
|
116
|
+
const models=this.ListModelsDir();
|
|
117
|
+
for(var model of models){
|
|
118
|
+
this.LoadModel(model);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
LoadModel(name){
|
|
122
|
+
debug.log("MODEL-LOAD:", [name]);
|
|
123
|
+
//console.log(name);
|
|
124
|
+
this.MODELS[name]=require(
|
|
125
|
+
this.PathTo( "system", "models", name, "class.js")
|
|
126
|
+
);
|
|
127
|
+
var modelname = changeCase(name).from("camelcase").to("pascalcase").GO;
|
|
128
|
+
this.HookRef(this.MODELS[name], modelname);
|
|
129
|
+
},
|
|
130
|
+
ListModelsDir(){
|
|
131
|
+
return fs.readdirSync(
|
|
132
|
+
this.PathTo("system", "models"),
|
|
133
|
+
{withFileTypes:true}
|
|
134
|
+
).filter(
|
|
135
|
+
(model)=>model.isDirectory()
|
|
136
|
+
).map(
|
|
137
|
+
(model)=>model.name
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
module.exports=function(BOS){
|
|
143
|
+
EXTENDER.Update(EXTENDER, BOS);
|
|
144
|
+
return BOS;
|
|
145
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/*
|
|
2
|
+
blacksmith-organization-system
|
|
3
|
+
part of Anubis System
|
|
4
|
+
Sett Sarverott 2019
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
//const SE=require("./static-extender.js");
|
|
8
|
+
|
|
9
|
+
const {caseX}=require('carnival-toolbox');
|
|
10
|
+
const child_process = require('child_process');
|
|
11
|
+
const os = require('os');
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const EventEmitter = require('events');
|
|
15
|
+
|
|
16
|
+
const CONTROLLERS = {}
|
|
17
|
+
const MODELS = {}
|
|
18
|
+
const ID_REJESTR = {}
|
|
19
|
+
const FACTORS = {}
|
|
20
|
+
const INTERFACES = {}
|
|
21
|
+
const COMMANDS = {}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class BlacksmithOrganizationSystem extends EventEmitter{
|
|
26
|
+
constructor(classname, modelDir){
|
|
27
|
+
this.type=classname.replace("Blacksmith","");
|
|
28
|
+
|
|
29
|
+
//this.readIndex();
|
|
30
|
+
//this.openManuals();
|
|
31
|
+
//this.eventEmitter=new eventEmitter();
|
|
32
|
+
|
|
33
|
+
this.loadMethods(modelDir);
|
|
34
|
+
this.loadExtenders(modelDir);
|
|
35
|
+
this.loadEvents(modelDir);
|
|
36
|
+
this.loadActions(modelDir);
|
|
37
|
+
this.loadListeners(modelDir);
|
|
38
|
+
}
|
|
39
|
+
//readIndex(){
|
|
40
|
+
|
|
41
|
+
//}
|
|
42
|
+
//openManuals(){
|
|
43
|
+
|
|
44
|
+
//}
|
|
45
|
+
static GetModelScripts(section, modelDir){
|
|
46
|
+
return fs.readdirSync(
|
|
47
|
+
path.join(
|
|
48
|
+
modelDir,
|
|
49
|
+
section
|
|
50
|
+
),
|
|
51
|
+
{withFileTypes:true}
|
|
52
|
+
).filter(
|
|
53
|
+
(script)=>script.isFile()&&script.name.endsWith(".js")
|
|
54
|
+
).map(
|
|
55
|
+
(direntItem)=>direntItem.name
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
loadEvents(modelDir){ // direct listeners and emitters of model
|
|
59
|
+
const modelScripts=BOS.GetModelScripts(
|
|
60
|
+
"events",
|
|
61
|
+
modelDir
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
loadActions(modelDir){// acts like deamons or child precesses
|
|
66
|
+
const modelScripts=BOS.GetModelScripts(
|
|
67
|
+
"actions",
|
|
68
|
+
modelDir
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
loadListeners(modelDir){// everything what that model listens
|
|
72
|
+
const modelScripts=BOS.GetModelScripts(
|
|
73
|
+
"listeners",
|
|
74
|
+
modelDir
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
loadMethods(modelDir){// synchronous, returns data
|
|
78
|
+
const modelScripts=BOS.GetModelScripts(
|
|
79
|
+
"methods",
|
|
80
|
+
modelDir
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
loadExtenders(modelDir){// extensionpacks for model
|
|
84
|
+
const modelScripts=BOS.GetModelScripts(
|
|
85
|
+
"extenders",
|
|
86
|
+
modelDir
|
|
87
|
+
);
|
|
88
|
+
for(var scriptName of modelScripts){
|
|
89
|
+
Object.assign(
|
|
90
|
+
this,
|
|
91
|
+
require(
|
|
92
|
+
path.join(
|
|
93
|
+
modelDir,
|
|
94
|
+
"extenders",
|
|
95
|
+
scriptName
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
static get Subject(){
|
|
102
|
+
return require("./basic-subject-model.js")(BOS);
|
|
103
|
+
}
|
|
104
|
+
static PathTo(...locationChain){
|
|
105
|
+
return path.join(__dirname, "..", "..", ...locationChain);
|
|
106
|
+
}
|
|
107
|
+
static get BOS(){
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
get BOS(){
|
|
111
|
+
return BOS;
|
|
112
|
+
}
|
|
113
|
+
static get INITIALIZE(){
|
|
114
|
+
return BOS.LOAD();
|
|
115
|
+
}
|
|
116
|
+
static BOX_EMPTY(boxHook){
|
|
117
|
+
return Object.keys(boxHook).length==0;
|
|
118
|
+
}
|
|
119
|
+
static LOAD(...limiter){
|
|
120
|
+
if(this.BOX_EMPTY(CONTROLLERS))this.LoadAllControllers();
|
|
121
|
+
if(this.BOX_EMPTY(MODELS))this.LoadAllModels();
|
|
122
|
+
if(this.BOX_EMPTY(FACTORS))this.LoadAllFactors();
|
|
123
|
+
if(this.BOX_EMPTY(COMMANDS))this.LoadAllCommands();
|
|
124
|
+
/*}
|
|
125
|
+
for(var i in loadList){
|
|
126
|
+
if(
|
|
127
|
+
(
|
|
128
|
+
limiter.length==0
|
|
129
|
+
||
|
|
130
|
+
limiter.includes(i)
|
|
131
|
+
)
|
|
132
|
+
&&
|
|
133
|
+
loadList[i][0])
|
|
134
|
+
){
|
|
135
|
+
this[
|
|
136
|
+
loadList[i][1]
|
|
137
|
+
]();
|
|
138
|
+
}
|
|
139
|
+
}*/
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
//static debugLog(...args){
|
|
143
|
+
// if(BOS.DEBUGGING)console.log(...args);
|
|
144
|
+
//}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
//BOS.DEBUGGING=false;
|
|
148
|
+
|
|
149
|
+
BOS=BlacksmithOrganizationSystem;
|
|
150
|
+
//BOS.INIT_BASE();
|
|
151
|
+
//BOS.TypeList=TYPES_LIST;
|
|
152
|
+
//BOS.IdRegistList=ID_REJESTR
|
|
153
|
+
|
|
154
|
+
const FORM=require('./extending-mod.js')(BOS);
|
|
155
|
+
BOS.Update({
|
|
156
|
+
CONTROLLERS,
|
|
157
|
+
MODELS,
|
|
158
|
+
ID_REJESTR,
|
|
159
|
+
FACTORS,
|
|
160
|
+
INTERFACES,
|
|
161
|
+
COMMANDS
|
|
162
|
+
});
|
|
163
|
+
//BOS.LOAD();
|
|
164
|
+
//BOS.loadInterface()
|
|
165
|
+
|
|
166
|
+
//
|
|
167
|
+
|
|
168
|
+
module.exports={
|
|
169
|
+
BOS,
|
|
170
|
+
get INITIALIZE(){
|
|
171
|
+
return BOS.INITIALIZE;
|
|
172
|
+
}
|
|
173
|
+
//CONTROLLERS,
|
|
174
|
+
//MODELS,
|
|
175
|
+
//ID_REJESTR,
|
|
176
|
+
//FACTORS,
|
|
177
|
+
//INTERFACES,
|
|
178
|
+
//COMMANDS
|
|
179
|
+
//ID_REJESTR
|
|
180
|
+
//FORM
|
|
181
|
+
|
|
182
|
+
//SE
|
|
183
|
+
//HOSTNAME
|
|
184
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const fs=require("fs");
|
|
2
|
+
module.exports={
|
|
3
|
+
SAFE_CREATE_DIR(path){
|
|
4
|
+
fs.mkdirSync(path,{recursive:true})
|
|
5
|
+
},
|
|
6
|
+
WRITE_OUTPUT_FILE(filepath, output, readable=false){
|
|
7
|
+
fs.writeFileSync(
|
|
8
|
+
filepath,
|
|
9
|
+
JSON.stringify(
|
|
10
|
+
...((readable)?[output, null, '\t']:[output])
|
|
11
|
+
)
|
|
12
|
+
);
|
|
13
|
+
},
|
|
14
|
+
READ_INPUT_FILE(filepath){
|
|
15
|
+
return JSON.parse(fs.readFileSync(
|
|
16
|
+
filepath
|
|
17
|
+
));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const {debug} = require('carnival-toolbox');
|
|
2
|
+
|
|
3
|
+
module.exports=class BOS_Command{
|
|
4
|
+
constructor(name){
|
|
5
|
+
this.name=name;
|
|
6
|
+
this.interfaces={};
|
|
7
|
+
this.CONTEXT={};
|
|
8
|
+
}
|
|
9
|
+
USAGE(interfaceName){
|
|
10
|
+
return {
|
|
11
|
+
interfaceName:interfaceName,
|
|
12
|
+
interfaces:this.interfaces,
|
|
13
|
+
get DEFINE(){
|
|
14
|
+
if(
|
|
15
|
+
!this.interfaces.hasOwnProperty(this.interfaceName)
|
|
16
|
+
)this.interfaces[this.interfaceName]={get:()=>null,set:(x)=>null};
|
|
17
|
+
return {
|
|
18
|
+
interfaceName:this.interfaceName,
|
|
19
|
+
interfaces:this.interfaces,
|
|
20
|
+
set METHOD(funct){
|
|
21
|
+
this.GET=()=>funct;
|
|
22
|
+
},
|
|
23
|
+
set SET(funct){
|
|
24
|
+
this.interfaces[this.interfaceName].set=funct;
|
|
25
|
+
},
|
|
26
|
+
set GET(funct){
|
|
27
|
+
this.interfaces[this.interfaceName].get=funct;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
get LOAD(){
|
|
32
|
+
return this.interfaces[this.interfaceName];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
INCLUDE_TO(context, interfaceName){
|
|
37
|
+
this.CONTEXT[interfaceName]=context;
|
|
38
|
+
debug.log(`---including command ${this.name} as usage by ${interfaceName} in context`)
|
|
39
|
+
Object.defineProperty(
|
|
40
|
+
context,
|
|
41
|
+
this.name,
|
|
42
|
+
this.USAGE(interfaceName).LOAD
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|