@reldens/cms 0.5.0 → 0.6.0
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/README.md +1 -1
- package/admin/assets/admin/filters.png +0 -0
- package/admin/assets/admin/list.png +0 -0
- package/admin/reldens-admin-client.css +830 -0
- package/admin/reldens-admin-client.js +272 -0
- package/admin/templates/dashboard.html +1 -0
- package/admin/templates/default-copyright.html +5 -0
- package/admin/templates/edit.html +25 -0
- package/admin/templates/fields/edit/button.html +3 -0
- package/admin/templates/fields/edit/checkbox.html +1 -0
- package/admin/templates/fields/edit/file.html +2 -0
- package/admin/templates/fields/edit/radio.html +1 -0
- package/admin/templates/fields/edit/select.html +5 -0
- package/admin/templates/fields/edit/text.html +1 -0
- package/admin/templates/fields/edit/textarea.html +1 -0
- package/admin/templates/fields/view/boolean.html +1 -0
- package/admin/templates/fields/view/image.html +4 -0
- package/admin/templates/fields/view/images.html +7 -0
- package/admin/templates/fields/view/link.html +1 -0
- package/admin/templates/fields/view/links.html +6 -0
- package/admin/templates/fields/view/text.html +1 -0
- package/admin/templates/layout.html +37 -0
- package/admin/templates/list-content.html +70 -0
- package/admin/templates/list.html +35 -0
- package/admin/templates/login.html +19 -0
- package/admin/templates/management.html +22 -0
- package/admin/templates/maps-wizard-maps-selection.html +85 -0
- package/admin/templates/maps-wizard.html +341 -0
- package/admin/templates/objects-import.html +143 -0
- package/admin/templates/pagination-link.html +1 -0
- package/admin/templates/sidebar-header.html +4 -0
- package/admin/templates/sidebar-item.html +3 -0
- package/admin/templates/sidebar.html +11 -0
- package/admin/templates/skills-import.html +201 -0
- package/admin/templates/view.html +23 -0
- package/bin/reldens-cms.js +20 -8
- package/index.js +2 -2
- package/lib/entities-loader.js +45 -0
- package/lib/{storefront.js → frontend.js} +10 -6
- package/lib/installer.js +133 -45
- package/lib/manager.js +65 -26
- package/migrations/default-user.sql +2 -1
- package/package.json +2 -2
- package/templates/.env.dist +11 -11
- package/templates/css/styles.css +1 -1
- package/templates/index.js.dist +32 -0
- package/templates/js/scripts.js +1 -1
package/lib/manager.js
CHANGED
|
@@ -8,13 +8,14 @@ const { AppServerFactory, FileHandler, Encryptor } = require('@reldens/server-ut
|
|
|
8
8
|
const { DriversMap } = require('@reldens/storage');
|
|
9
9
|
const { AdminManager } = require('./admin-manager');
|
|
10
10
|
const { Installer } = require('./installer');
|
|
11
|
-
const {
|
|
12
|
-
const { Logger, sc } = require('@reldens/utils');
|
|
11
|
+
const { Frontend } = require('./frontend');
|
|
12
|
+
const { EventsManagerSingleton, Logger, sc } = require('@reldens/utils');
|
|
13
13
|
const dotenv = require('dotenv');
|
|
14
14
|
const mustache = require('mustache');
|
|
15
15
|
|
|
16
16
|
class Manager
|
|
17
17
|
{
|
|
18
|
+
|
|
18
19
|
constructor(props = {})
|
|
19
20
|
{
|
|
20
21
|
this.projectRoot = sc.get(props, 'projectRoot', './');
|
|
@@ -23,34 +24,40 @@ class Manager
|
|
|
23
24
|
dotenv.config({path: this.envFilePath});
|
|
24
25
|
this.config = this.loadConfigFromEnv();
|
|
25
26
|
this.entities = sc.get(props, 'entities', {});
|
|
27
|
+
this.rawEntities = sc.get(props, 'rawEntities', {});
|
|
28
|
+
this.entitiesConfig = sc.get(props, 'entitiesConfig', {});
|
|
29
|
+
this.entitiesTranslations = sc.get(props, 'entitiesTranslations', {});
|
|
26
30
|
this.authenticationMethod = sc.get(props, 'authenticationMethod', 'db-users');
|
|
27
31
|
this.authenticationCallback = sc.get(props, 'authenticationCallback', false);
|
|
32
|
+
this.events = sc.get(props, 'events', EventsManagerSingleton);
|
|
28
33
|
this.appServerFactory = new AppServerFactory();
|
|
29
34
|
this.installer = new Installer({
|
|
30
|
-
projectRoot: this.projectRoot
|
|
35
|
+
projectRoot: this.projectRoot,
|
|
36
|
+
postInstallCallback: this.initializeCmsAfterInstall.bind(this)
|
|
31
37
|
});
|
|
32
38
|
this.dataServer = false;
|
|
33
39
|
this.app = false;
|
|
34
40
|
this.appServer = false;
|
|
35
41
|
this.adminManager = false;
|
|
36
|
-
this.
|
|
42
|
+
this.frontend = false;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
loadConfigFromEnv()
|
|
40
46
|
{
|
|
47
|
+
let envVars = process.env;
|
|
41
48
|
return {
|
|
42
|
-
host:
|
|
43
|
-
port: Number(
|
|
44
|
-
adminPath:
|
|
45
|
-
adminSecret:
|
|
49
|
+
host: sc.get(envVars, 'RELDENS_CMS_HOST', 'http://localhost'),
|
|
50
|
+
port: Number(sc.get(envVars, 'RELDENS_CMS_PORT', 8000)),
|
|
51
|
+
adminPath: sc.get(envVars, 'RELDENS_CMS_ADMIN_PATH', '/reldens-admin'),
|
|
52
|
+
adminSecret: sc.get(envVars, 'RELDENS_CMS_ADMIN_SECRET', ''),
|
|
46
53
|
database: {
|
|
47
|
-
client:
|
|
48
|
-
host:
|
|
49
|
-
port: Number(
|
|
50
|
-
name:
|
|
51
|
-
user:
|
|
52
|
-
password:
|
|
53
|
-
driver:
|
|
54
|
+
client: sc.get(envVars, 'RELDENS_CMS_DB_CLIENT', 'mysql'),
|
|
55
|
+
host: sc.get(envVars, 'RELDENS_CMS_DB_HOST', 'localhost'),
|
|
56
|
+
port: Number(sc.get(envVars, 'RELDENS_CMS_DB_PORT', 3306)),
|
|
57
|
+
name: sc.get(envVars, 'RELDENS_CMS_DB_NAME', 'reldens_cms'),
|
|
58
|
+
user: sc.get(envVars, 'RELDENS_CMS_DB_USER', ''),
|
|
59
|
+
password: sc.get(envVars, 'RELDENS_CMS_DB_PASSWORD', ''),
|
|
60
|
+
driver: sc.get(envVars, 'RELDENS_CMS_DB_DRIVER', 'prisma')
|
|
54
61
|
}
|
|
55
62
|
};
|
|
56
63
|
}
|
|
@@ -71,7 +78,7 @@ class Manager
|
|
|
71
78
|
this.appServer = createdAppServer.appServer;
|
|
72
79
|
if(!this.isInstalled()){
|
|
73
80
|
Logger.info('CMS not installed, preparing setup');
|
|
74
|
-
await this.installer.prepareSetup(this.app, this.appServerFactory);
|
|
81
|
+
await this.installer.prepareSetup(this.app, this.appServer, this.appServerFactory);
|
|
75
82
|
await this.appServer.listen(this.config.port);
|
|
76
83
|
Logger.info('Installer running on '+this.config.host+':'+this.config.port);
|
|
77
84
|
return true;
|
|
@@ -79,7 +86,7 @@ class Manager
|
|
|
79
86
|
try {
|
|
80
87
|
await this.initializeDataServer();
|
|
81
88
|
await this.initializeAdminManager();
|
|
82
|
-
await this.
|
|
89
|
+
await this.initializeFrontend();
|
|
83
90
|
await this.appServer.listen(this.config.port);
|
|
84
91
|
Logger.info('CMS running on '+this.config.host+':'+this.config.port);
|
|
85
92
|
return true;
|
|
@@ -89,6 +96,32 @@ class Manager
|
|
|
89
96
|
}
|
|
90
97
|
}
|
|
91
98
|
|
|
99
|
+
async initializeCmsAfterInstall(entitiesData)
|
|
100
|
+
{
|
|
101
|
+
try {
|
|
102
|
+
if(entitiesData){
|
|
103
|
+
this.entities = sc.get(entitiesData, 'entities', this.entities);
|
|
104
|
+
this.rawEntities = sc.get(entitiesData, 'rawEntities', this.rawEntities);
|
|
105
|
+
this.entitiesConfig = sc.get(entitiesData, 'entitiesConfig', this.entitiesConfig);
|
|
106
|
+
this.entitiesTranslations = sc.get(entitiesData, 'entitiesTranslations', this.entitiesTranslations);
|
|
107
|
+
}
|
|
108
|
+
this.config = this.loadConfigFromEnv();
|
|
109
|
+
if(this.appServerFactory.error.message){
|
|
110
|
+
Logger.critical('App server creation failed: '+this.appServerFactory.error.message);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
await this.initializeDataServer();
|
|
114
|
+
await this.initializeAdminManager();
|
|
115
|
+
await this.initializeFrontend();
|
|
116
|
+
await this.appServer.listen(this.config.port);
|
|
117
|
+
Logger.info('CMS initialized after installation on '+this.config.host+':'+this.config.port);
|
|
118
|
+
return true;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
Logger.critical('Failed to initialize CMS after installation: '+error.message);
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
92
125
|
async initializeDataServer()
|
|
93
126
|
{
|
|
94
127
|
let dbConfig = {
|
|
@@ -99,15 +132,18 @@ class Manager
|
|
|
99
132
|
database: this.config.database.name,
|
|
100
133
|
user: this.config.database.user,
|
|
101
134
|
password: this.config.database.password
|
|
102
|
-
}
|
|
135
|
+
},
|
|
136
|
+
rawEntities: this.rawEntities
|
|
103
137
|
};
|
|
104
138
|
let DriverClass = DriversMap[this.config.database.driver];
|
|
105
139
|
if(!DriverClass){
|
|
106
|
-
|
|
140
|
+
Logger.critical('Invalid database driver: '+this.config.database.driver);
|
|
141
|
+
return false;
|
|
107
142
|
}
|
|
108
143
|
this.dataServer = new DriverClass(dbConfig);
|
|
109
144
|
if(!await this.dataServer.connect()){
|
|
110
|
-
|
|
145
|
+
Logger.critical('Failed to connect to database.');
|
|
146
|
+
return false;
|
|
111
147
|
}
|
|
112
148
|
await this.dataServer.generateEntities();
|
|
113
149
|
return true;
|
|
@@ -133,7 +169,7 @@ class Manager
|
|
|
133
169
|
};
|
|
134
170
|
}
|
|
135
171
|
let adminConfig = {
|
|
136
|
-
events:
|
|
172
|
+
events: this.events,
|
|
137
173
|
renderCallback: this.renderCallback.bind(this),
|
|
138
174
|
dataServer: this.dataServer,
|
|
139
175
|
authenticationCallback,
|
|
@@ -142,7 +178,9 @@ class Manager
|
|
|
142
178
|
secret: this.config.adminSecret,
|
|
143
179
|
rootPath: this.config.adminPath,
|
|
144
180
|
adminRoleId: 99,
|
|
145
|
-
entities: this.entities
|
|
181
|
+
entities: this.entities,
|
|
182
|
+
entitiesConfig: this.entitiesConfig,
|
|
183
|
+
translations: this.entitiesTranslations
|
|
146
184
|
};
|
|
147
185
|
this.adminManager = new AdminManager(adminConfig);
|
|
148
186
|
await this.adminManager.setupAdmin();
|
|
@@ -157,14 +195,15 @@ class Manager
|
|
|
157
195
|
return mustache.render(template, params);
|
|
158
196
|
}
|
|
159
197
|
|
|
160
|
-
async
|
|
198
|
+
async initializeFrontend()
|
|
161
199
|
{
|
|
162
|
-
this.
|
|
200
|
+
this.frontend = new Frontend({
|
|
163
201
|
app: this.app,
|
|
164
202
|
dataServer: this.dataServer,
|
|
165
|
-
projectRoot: this.projectRoot
|
|
203
|
+
projectRoot: this.projectRoot,
|
|
204
|
+
appServerFactory: this.appServerFactory
|
|
166
205
|
});
|
|
167
|
-
return await this.
|
|
206
|
+
return await this.frontend.initialize();
|
|
168
207
|
}
|
|
169
208
|
}
|
|
170
209
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
-- Default admin user:
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
REPLACE INTO `users` (`id`, `email`, `username`, `password`, `role_id`, `status`)
|
|
5
5
|
VALUES (
|
|
6
|
+
1,
|
|
6
7
|
'root@cms-admin.com',
|
|
7
8
|
'root',
|
|
8
9
|
'd35ed1c81c3ff00de15309fe40a90c32:a39a9231a69fefef274c13c1780a7447672a5fee8250ce22a51bb20275039dda63a54faa1e5fd775becb3ac424f571d5b996001305bb7d63e038111dce08d45b',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reldens/cms",
|
|
3
3
|
"scope": "@reldens",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0",
|
|
5
5
|
"description": "Reldens - CMS",
|
|
6
6
|
"author": "Damian A. Pastorini",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@reldens/server-utils": "^0.16.0",
|
|
36
|
-
"@reldens/storage": "^0.
|
|
36
|
+
"@reldens/storage": "^0.43.0",
|
|
37
37
|
"@reldens/utils": "^0.47.0",
|
|
38
38
|
"dotenv": "^16.5.0",
|
|
39
39
|
"mustache": "^4.2.0"
|
package/templates/.env.dist
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# Database Configuration
|
|
2
|
-
RELDENS_CMS_DB_CLIENT={{dbClient}}
|
|
3
|
-
RELDENS_CMS_DB_HOST={{dbHost}}
|
|
4
|
-
RELDENS_CMS_DB_PORT={{dbPort}}
|
|
5
|
-
RELDENS_CMS_DB_NAME={{dbName}}
|
|
6
|
-
RELDENS_CMS_DB_USER={{dbUser}}
|
|
7
|
-
RELDENS_CMS_DB_PASSWORD={{dbPassword}}
|
|
8
|
-
RELDENS_CMS_DB_DRIVER={{dbDriver}}
|
|
2
|
+
RELDENS_CMS_DB_CLIENT={{&dbClient}}
|
|
3
|
+
RELDENS_CMS_DB_HOST={{&dbHost}}
|
|
4
|
+
RELDENS_CMS_DB_PORT={{&dbPort}}
|
|
5
|
+
RELDENS_CMS_DB_NAME={{&dbName}}
|
|
6
|
+
RELDENS_CMS_DB_USER={{&dbUser}}
|
|
7
|
+
RELDENS_CMS_DB_PASSWORD={{&dbPassword}}
|
|
8
|
+
RELDENS_CMS_DB_DRIVER={{&dbDriver}}
|
|
9
9
|
|
|
10
10
|
# Admin Panel Configuration
|
|
11
|
-
RELDENS_CMS_ADMIN_PATH={{adminPath}}
|
|
12
|
-
RELDENS_CMS_ADMIN_SECRET={{adminSecret}}
|
|
11
|
+
RELDENS_CMS_ADMIN_PATH={{&adminPath}}
|
|
12
|
+
RELDENS_CMS_ADMIN_SECRET={{&adminSecret}}
|
|
13
13
|
|
|
14
14
|
# Server Configuration
|
|
15
|
-
RELDENS_CMS_HOST={{host}}
|
|
16
|
-
RELDENS_CMS_PORT={{port}}
|
|
15
|
+
RELDENS_CMS_HOST={{&host}}
|
|
16
|
+
RELDENS_CMS_PORT={{&port}}
|
package/templates/css/styles.css
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - CMS
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { Manager } = require('@reldens/cms');
|
|
8
|
+
const { Logger } = require('@reldens/utils');
|
|
9
|
+
const { rawRegisteredEntities, entitiesConfig, entitiesTranslations } = require('./generated-entities/models/{{driverKey}}/registered-models-{{driverKey}}');
|
|
10
|
+
|
|
11
|
+
let args = process.argv.slice(2);
|
|
12
|
+
let projectRoot = args[0] || process.cwd();
|
|
13
|
+
|
|
14
|
+
let manager = new Manager({
|
|
15
|
+
projectRoot,
|
|
16
|
+
entities: rawRegisteredEntities,
|
|
17
|
+
entitiesConfig,
|
|
18
|
+
entitiesTranslations
|
|
19
|
+
});
|
|
20
|
+
Logger.debug('Reldens CMS Manager instance created.', {configuration: manager.config});
|
|
21
|
+
|
|
22
|
+
manager.start().then((result) => {
|
|
23
|
+
if(!result){
|
|
24
|
+
Logger.info('Reldens CMS started by command failed.');
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
Logger.info('Reldens CMS started by command.');
|
|
28
|
+
return true;
|
|
29
|
+
}).catch((error) => {
|
|
30
|
+
Logger.error('Failed to start CMS: '+error.message);
|
|
31
|
+
process.exit();
|
|
32
|
+
});
|
package/templates/js/scripts.js
CHANGED