@reldens/cms 0.6.0 → 0.7.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/admin/reldens-admin-client.css +1 -1
- package/admin/templates/dashboard.html +1 -1
- package/bin/reldens-cms.js +1 -1
- package/install/index.html +0 -7
- package/install/success.html +30 -0
- package/lib/admin-manager.js +1 -1
- package/lib/admin-templates-loader.js +37 -0
- package/lib/admin-translations.js +4 -218
- package/lib/allowed-extensions.js +11 -0
- package/lib/entities-loader.js +3 -6
- package/lib/frontend.js +4 -13
- package/lib/installer.js +39 -42
- package/lib/loaded-entities-processor.js +30 -0
- package/lib/manager.js +92 -33
- package/lib/mime-types.js +35 -0
- package/lib/templates-list.js +0 -9
- package/lib/templates-to-path-mapper.js +28 -0
- package/package.json +2 -2
- package/templates/assets/web/loading.gif +0 -0
- package/templates/assets/web/reldens-your-logo-mage.png +0 -0
- package/templates/index.js.dist +2 -2
- package/admin/templates/maps-wizard-maps-selection.html +0 -85
- package/admin/templates/maps-wizard.html +0 -341
- package/admin/templates/objects-import.html +0 -143
- package/admin/templates/skills-import.html +0 -201
|
@@ -1 +1 @@
|
|
|
1
|
-
Welcome to the Reldens
|
|
1
|
+
Welcome to the Reldens CMS!
|
package/bin/reldens-cms.js
CHANGED
|
@@ -23,7 +23,7 @@ let started = manager.start().then((result) => {
|
|
|
23
23
|
Logger.info('Reldens CMS started by command.');
|
|
24
24
|
return true;
|
|
25
25
|
}).catch((error) => {
|
|
26
|
-
Logger.
|
|
26
|
+
Logger.critical('Failed to start CMS:', error);
|
|
27
27
|
process.exit();
|
|
28
28
|
});
|
|
29
29
|
|
package/install/index.html
CHANGED
|
@@ -34,13 +34,6 @@
|
|
|
34
34
|
<p class="error installation-process-failed">There was an error during the installation process.</p>
|
|
35
35
|
</div>
|
|
36
36
|
<h3 class="form-title">- Database Configuration -</h3>
|
|
37
|
-
<div class="db-basic-config-notice">
|
|
38
|
-
<span>Default configuration:</span>
|
|
39
|
-
<ul>
|
|
40
|
-
<li>Client: mysql - Port: 3306</li>
|
|
41
|
-
<li>Database Driver: prisma</li>
|
|
42
|
-
</ul>
|
|
43
|
-
</div>
|
|
44
37
|
<div class="input-box db-storage-driver">
|
|
45
38
|
<label for="db-storage-driver">Storage Driver</label>
|
|
46
39
|
<select name="db-storage-driver" id="db-storage-driver" class="required" required>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Reldens CMS - Installation</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
6
|
+
<link rel="stylesheet" href="/install-assets/css/installer.css">
|
|
7
|
+
<script src="/install-assets/js/installer.js"></script>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div class="wrapper">
|
|
11
|
+
<div class="header">
|
|
12
|
+
<h1 class="title">
|
|
13
|
+
<strong>Reldens CMS</strong> - Installation
|
|
14
|
+
</h1>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="content">
|
|
17
|
+
<div class="forms-container">
|
|
18
|
+
<div class="row">
|
|
19
|
+
Installation completed!
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="footer">
|
|
24
|
+
<div class="copyright">
|
|
25
|
+
© 2025 Reldens CMS
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</body>
|
|
30
|
+
</html>
|
package/lib/admin-manager.js
CHANGED
|
@@ -54,7 +54,7 @@ class AdminManager
|
|
|
54
54
|
|
|
55
55
|
async setupAdmin()
|
|
56
56
|
{
|
|
57
|
-
if
|
|
57
|
+
if(this.validator instanceof ValidatorInterface && !this.validator.validate(this)){
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
60
|
this.resourcesByReference = {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - AdminTemplatesLoader
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { Logger, sc } = require('@reldens/utils');
|
|
8
|
+
const { FileHandler } = require('@reldens/server-utils');
|
|
9
|
+
|
|
10
|
+
class AdminTemplatesLoader
|
|
11
|
+
{
|
|
12
|
+
|
|
13
|
+
async fetchAdminFilesContents(adminTemplates)
|
|
14
|
+
{
|
|
15
|
+
let adminFilesContents = {};
|
|
16
|
+
for(let template of Object.keys(adminTemplates)){
|
|
17
|
+
let templateData = adminTemplates[template];
|
|
18
|
+
if(sc.isObject(templateData)){
|
|
19
|
+
let subFoldersContents = await this.fetchAdminFilesContents(templateData);
|
|
20
|
+
if(!subFoldersContents){
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
adminFilesContents[template] = subFoldersContents;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if(!FileHandler.isFile(templateData)){
|
|
27
|
+
Logger.critical('Admin template file not found.', template);
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
adminFilesContents[template] = await FileHandler.fetchFileContents(templateData);
|
|
31
|
+
}
|
|
32
|
+
return adminFilesContents;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports.AdminTemplatesLoader = new AdminTemplatesLoader();
|
|
@@ -12,8 +12,8 @@ class AdminTranslations
|
|
|
12
12
|
// @TODO - BETA - Fix translations, use snippets, include new snippets under the basic config script.
|
|
13
13
|
let adminTranslations = {
|
|
14
14
|
messages: {
|
|
15
|
-
loginWelcome: '
|
|
16
|
-
reldensTitle: 'Reldens -
|
|
15
|
+
loginWelcome: 'CMS - Login',
|
|
16
|
+
reldensTitle: 'Reldens - CMS',
|
|
17
17
|
reldensSlogan: 'You can do it',
|
|
18
18
|
reldensDiscordTitle: 'Join our Discord server!',
|
|
19
19
|
reldensDiscordText: 'Talk with the creators and other Reldens users',
|
|
@@ -24,229 +24,15 @@ class AdminTranslations
|
|
|
24
24
|
reldensLoading: 'Loading...'
|
|
25
25
|
},
|
|
26
26
|
labels: {
|
|
27
|
-
navigation: 'Reldens -
|
|
27
|
+
navigation: 'Reldens - CMS',
|
|
28
28
|
adminVersion: 'Admin: {{version}}',
|
|
29
29
|
loginWelcome: 'Reldens',
|
|
30
30
|
pages: 'Server Management',
|
|
31
31
|
management: 'Management',
|
|
32
|
-
mapsWizard: 'Maps Generation and Import',
|
|
33
|
-
objectsImport: 'Objects Import',
|
|
34
|
-
skillsImport: 'Skills Import',
|
|
35
32
|
shuttingDown: 'Server is shutting down in:',
|
|
36
33
|
submitShutdownLabel: 'Shutdown Server',
|
|
37
34
|
submitCancelLabel: 'Cancel Server Shutdown',
|
|
38
|
-
}
|
|
39
|
-
active_from: 'Active From',
|
|
40
|
-
active_to: 'Active To',
|
|
41
|
-
ads_id: 'Ads ID',
|
|
42
|
-
ads_type: 'Ads Type',
|
|
43
|
-
affectedProperty: 'Affected Property',
|
|
44
|
-
aimProperties: 'Aim Properties',
|
|
45
|
-
allowEffectBelowZero: 'Allow Effect Below Zero',
|
|
46
|
-
allowSelfTarget: 'Allow Self Target',
|
|
47
|
-
also_show_in_type: 'Also Show In Type',
|
|
48
|
-
animationData: 'Animation Data',
|
|
49
|
-
animationKey: 'Animation Key',
|
|
50
|
-
applyDirectDamage: 'Apply Direct Damage',
|
|
51
|
-
asset_file: 'Asset File',
|
|
52
|
-
asset_key: 'Asset Key',
|
|
53
|
-
asset_type: 'Asset Type',
|
|
54
|
-
attackProperties: 'Attack Properties',
|
|
55
|
-
audio_id: 'Audio ID',
|
|
56
|
-
audio_key: 'Audio Key',
|
|
57
|
-
autoFillExperienceMultiplier: 'Auto Fill Experience Multiplier',
|
|
58
|
-
autoFillRanges: 'Auto Fill Ranges',
|
|
59
|
-
autoValidation: 'Auto Validation',
|
|
60
|
-
auto_remove_requirement: 'Auto Remove Requirement',
|
|
61
|
-
banner_data: 'Banner Data',
|
|
62
|
-
base_value: 'Base Value',
|
|
63
|
-
bottom: 'Bottom',
|
|
64
|
-
castTime: 'Cast Time',
|
|
65
|
-
category_id: 'Category ID',
|
|
66
|
-
category_key: 'Category Key',
|
|
67
|
-
category_label: 'Category Label',
|
|
68
|
-
chat_player_id: 'Chat Player ID',
|
|
69
|
-
chat_private_player_id: 'Chat Private Player',
|
|
70
|
-
chat_room: 'Chat Room',
|
|
71
|
-
chat_type: 'Chat Type',
|
|
72
|
-
clan_id: 'Clan ID',
|
|
73
|
-
classKey: 'Class Key',
|
|
74
|
-
class_path: 'Class Path',
|
|
75
|
-
class_path_id: 'Class Path ID',
|
|
76
|
-
class_path_level: 'Level Key',
|
|
77
|
-
class_path_level_skill: 'Skill',
|
|
78
|
-
class_path_owner: 'Class Path Owner',
|
|
79
|
-
class_type: 'Class Type',
|
|
80
|
-
client_key: 'Client Key',
|
|
81
|
-
client_params: 'Client Params',
|
|
82
|
-
code: 'Code',
|
|
83
|
-
conditional: 'Conditional',
|
|
84
|
-
config: 'Config',
|
|
85
|
-
country_code: 'Country Code',
|
|
86
|
-
created_at: 'Created At',
|
|
87
|
-
criticalAffected: 'Critical Affected',
|
|
88
|
-
criticalChance: 'Critical Chance',
|
|
89
|
-
criticalFixedValue: 'Critical FixedValue',
|
|
90
|
-
criticalMultiplier: 'Critical Multiplier',
|
|
91
|
-
currentExp: 'Current Exp',
|
|
92
|
-
currentLevel: 'Current Level',
|
|
93
|
-
customData: 'Custom Data',
|
|
94
|
-
damageAffected: 'Damage Affected',
|
|
95
|
-
defenseProperties: 'Defense Properties',
|
|
96
|
-
description: 'Description',
|
|
97
|
-
dir: 'Dir',
|
|
98
|
-
direction: 'Direction',
|
|
99
|
-
drop_quantity: 'Drop Quantity',
|
|
100
|
-
drop_rate: 'Drop Rate',
|
|
101
|
-
dodgeFullEnabled: 'Dodge Full Enabled',
|
|
102
|
-
dodgeOverAimSuccess: 'Dodge Over Aim Success',
|
|
103
|
-
dodgeProperties: 'Dodge Properties',
|
|
104
|
-
duration: 'Duration',
|
|
105
|
-
email: 'Email',
|
|
106
|
-
enabled: 'Enabled',
|
|
107
|
-
ended_at: 'Ended At',
|
|
108
|
-
event_data: 'Event Data',
|
|
109
|
-
event_key: 'Event Key',
|
|
110
|
-
experience: 'Experience',
|
|
111
|
-
execTimeOut: 'Exec Time Out',
|
|
112
|
-
extra_params: 'Extra Params',
|
|
113
|
-
file: 'File',
|
|
114
|
-
files_name: 'Files Name',
|
|
115
|
-
from_room_id: 'From Room ID',
|
|
116
|
-
group_id: 'Group ID',
|
|
117
|
-
handler_key: 'Handler Key',
|
|
118
|
-
has_drop_body: 'Has Drop Body',
|
|
119
|
-
height: 'Height',
|
|
120
|
-
hitDamage: 'Hit Damage',
|
|
121
|
-
id: 'ID',
|
|
122
|
-
instances_limit: 'Instances Limit',
|
|
123
|
-
is_active: 'Is Active',
|
|
124
|
-
is_default: 'Is Default',
|
|
125
|
-
is_enabled: 'Is Enabled',
|
|
126
|
-
is_unique: 'Is Unique',
|
|
127
|
-
item_id: 'Item ID',
|
|
128
|
-
item_key: 'Item Key',
|
|
129
|
-
items_limit: 'Items Limit',
|
|
130
|
-
key: 'Key',
|
|
131
|
-
kill_npc_id: 'Kill NPC ID',
|
|
132
|
-
kill_player_id: 'Kill Player ID',
|
|
133
|
-
kill_time: 'Kill Time',
|
|
134
|
-
label: 'Label',
|
|
135
|
-
label_level: 'Label Level',
|
|
136
|
-
language_code: 'Language Code',
|
|
137
|
-
last_npc_kill_time: 'Last NPC Kill Time',
|
|
138
|
-
last_player_kill_time: 'Last Player Kill Time',
|
|
139
|
-
layer: 'Layer',
|
|
140
|
-
layer_name: 'Layer Name',
|
|
141
|
-
level: 'Level',
|
|
142
|
-
level_id: 'Level ID',
|
|
143
|
-
level_owner: 'Level Owner',
|
|
144
|
-
level_set: 'Level Set',
|
|
145
|
-
level_set_id: 'Level Set ID',
|
|
146
|
-
levels_set_id: 'Levels Set ID',
|
|
147
|
-
limit_per_item: 'Limit Per Item',
|
|
148
|
-
locale: 'Locale',
|
|
149
|
-
locale_id: 'Locale ID',
|
|
150
|
-
login_count: 'Login Count',
|
|
151
|
-
login_date: 'Login Date',
|
|
152
|
-
logout_date: 'Logout Date',
|
|
153
|
-
map_filename: 'Map Filename',
|
|
154
|
-
marker_key: 'Marker Key',
|
|
155
|
-
maxProperty: 'Max Property',
|
|
156
|
-
maxValue: 'Max Value',
|
|
157
|
-
message: 'Message',
|
|
158
|
-
message_time: 'Message Time',
|
|
159
|
-
message_type: 'Message Type',
|
|
160
|
-
magnitude: 'Magnitude',
|
|
161
|
-
minProperty: 'Min Property',
|
|
162
|
-
minValue: 'Min Value',
|
|
163
|
-
modifier_id: 'Modifier ID',
|
|
164
|
-
name: 'Name',
|
|
165
|
-
next_room_id: 'Next Room ID',
|
|
166
|
-
npcs_kills_count: 'NPCs Kills Count',
|
|
167
|
-
objectHeight: 'Object Height',
|
|
168
|
-
objectWidth: 'Object Width',
|
|
169
|
-
object_asset_id: 'Object Asset ID',
|
|
170
|
-
object_class_key: 'Object Class Key',
|
|
171
|
-
object_id: 'Object ID',
|
|
172
|
-
obtained_score: 'Obtained Score',
|
|
173
|
-
operation: 'Operation',
|
|
174
|
-
owner_id: 'Owner ID',
|
|
175
|
-
parent_group: 'Parent Group',
|
|
176
|
-
parent_skill: 'Parent Skill',
|
|
177
|
-
path: 'Path',
|
|
178
|
-
password: 'Password',
|
|
179
|
-
player_id: 'Player ID',
|
|
180
|
-
played_time: 'Played Time',
|
|
181
|
-
players_kill_count: 'Players Kills Count',
|
|
182
|
-
players_kills_count: 'Players Kills Count',
|
|
183
|
-
points: 'Points',
|
|
184
|
-
position: 'Position',
|
|
185
|
-
position_bottom: 'Position Bottom',
|
|
186
|
-
position_left: 'Position Left',
|
|
187
|
-
position_right: 'Position Right',
|
|
188
|
-
position_top: 'Position Top',
|
|
189
|
-
private_params: 'Private Params',
|
|
190
|
-
private_player_id: 'Private Player ID',
|
|
191
|
-
property_key: 'Property Key',
|
|
192
|
-
provider_id: 'Provider ID',
|
|
193
|
-
qty: 'Qty',
|
|
194
|
-
qty_limit: 'Qty Limit',
|
|
195
|
-
range: 'Range',
|
|
196
|
-
rangeAutomaticValidation: 'Range Automatic Validation',
|
|
197
|
-
rangePropertyX: 'Range Property X',
|
|
198
|
-
rangePropertyY: 'Range Property Y',
|
|
199
|
-
rangeTargetPropertyX: 'Range Target Property X',
|
|
200
|
-
rangeTargetPropertyY: 'Range Target Property Y',
|
|
201
|
-
remaining_uses: 'Remaining Uses',
|
|
202
|
-
required_experience: 'Required Experience',
|
|
203
|
-
required_item_key: 'Required Item Key',
|
|
204
|
-
required_quantity: 'Required Quantity',
|
|
205
|
-
respawn_time: 'Respawn Time',
|
|
206
|
-
replay: 'Replay',
|
|
207
|
-
reward_item_is_required: 'Reward Item Is Required',
|
|
208
|
-
reward_item_key: 'Reward Item Key',
|
|
209
|
-
reward_quantity: 'Reward Quantity',
|
|
210
|
-
rewards_events_id: 'Rewards Events ID',
|
|
211
|
-
role_id: 'Role ID',
|
|
212
|
-
room_class_key: 'Room Class Key',
|
|
213
|
-
room_id: 'Room ID',
|
|
214
|
-
scene_images: 'Scene Images',
|
|
215
|
-
scope: 'Scope',
|
|
216
|
-
server_url: 'Server URL',
|
|
217
|
-
show_in_general: 'Show In General',
|
|
218
|
-
show_tab: 'Show Tab',
|
|
219
|
-
single_audio: 'Single Audio',
|
|
220
|
-
skill: 'Skill',
|
|
221
|
-
skillDelay: 'Skill Delay',
|
|
222
|
-
skill_id: 'Skill ID',
|
|
223
|
-
sort: 'Sort',
|
|
224
|
-
start: 'Start',
|
|
225
|
-
started_at: 'Started At',
|
|
226
|
-
state: 'State',
|
|
227
|
-
stat_id: 'Stat ID',
|
|
228
|
-
status: 'Status',
|
|
229
|
-
target_id: 'Target ID',
|
|
230
|
-
target_key: 'Target Key',
|
|
231
|
-
target_label: 'Target Label',
|
|
232
|
-
tile_index: 'Tile Index',
|
|
233
|
-
title: 'Title',
|
|
234
|
-
top: 'Top',
|
|
235
|
-
total_score: 'Total Score',
|
|
236
|
-
type: 'Type',
|
|
237
|
-
type_id: 'Type ID',
|
|
238
|
-
updated_at: 'Updated At',
|
|
239
|
-
useTimeOut: 'Use Time Out',
|
|
240
|
-
user_id: 'User ID',
|
|
241
|
-
username: 'Username',
|
|
242
|
-
usesLimit: 'Uses Limit',
|
|
243
|
-
uses_limit: 'Uses Limit',
|
|
244
|
-
validateTargetOnHit: 'Validate Target On Hit',
|
|
245
|
-
value: 'Value',
|
|
246
|
-
was_given: 'Was Given',
|
|
247
|
-
width: 'Width',
|
|
248
|
-
x: 'X',
|
|
249
|
-
y: 'Y'
|
|
35
|
+
}
|
|
250
36
|
};
|
|
251
37
|
for(let i of Object.keys(translations)){
|
|
252
38
|
if(!adminTranslations[i]){
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - AllowedExtensions
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
module.exports.AllowedExtensions = {
|
|
8
|
+
audio: ['.aac', '.mid', '.midi', '.mp3', '.ogg', '.oga', '.opus', '.wav', '.weba', '.3g2'],
|
|
9
|
+
image: ['.jpg', '.jpeg', '.png', '.gif', '.svg', '.webp'],
|
|
10
|
+
text: ['.json', '.jsonld', '.txt']
|
|
11
|
+
};
|
package/lib/entities-loader.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
const { LoadedEntitiesProcessor } = require('./loaded-entities-processor');
|
|
7
8
|
const { FileHandler } = require('@reldens/server-utils');
|
|
8
9
|
const { Logger, sc } = require('@reldens/utils');
|
|
9
10
|
|
|
@@ -28,12 +29,8 @@ class EntitiesLoader
|
|
|
28
29
|
return {};
|
|
29
30
|
}
|
|
30
31
|
try {
|
|
31
|
-
let
|
|
32
|
-
return
|
|
33
|
-
entities: loadedEntities.entitiesConfig,
|
|
34
|
-
entitiesRaw: loadedEntities.rawRegisteredEntities,
|
|
35
|
-
translations: loadedEntities.entitiesTranslations,
|
|
36
|
-
}
|
|
32
|
+
let {rawRegisteredEntities, entitiesConfig, entitiesTranslations} = require(entitiesPath);
|
|
33
|
+
return LoadedEntitiesProcessor.process(rawRegisteredEntities, entitiesTranslations, entitiesConfig);
|
|
37
34
|
} catch(error){
|
|
38
35
|
Logger.error('Failed to load generated entities: ' + error.message);
|
|
39
36
|
}
|
package/lib/frontend.js
CHANGED
|
@@ -19,7 +19,6 @@ class Frontend
|
|
|
19
19
|
this.projectRoot = sc.get(props, 'projectRoot', './');
|
|
20
20
|
this.templatesPath = FileHandler.joinPaths(this.projectRoot, 'templates');
|
|
21
21
|
this.publicPath = FileHandler.joinPaths(this.projectRoot, 'public');
|
|
22
|
-
this.encoding = sc.get(props, 'encoding', 'utf8');
|
|
23
22
|
this.error = false;
|
|
24
23
|
}
|
|
25
24
|
|
|
@@ -164,9 +163,7 @@ class Frontend
|
|
|
164
163
|
return await this.renderNotFoundPage(res);
|
|
165
164
|
}
|
|
166
165
|
}
|
|
167
|
-
let template = FileHandler.readFile(templatePath
|
|
168
|
-
encoding: this.encoding
|
|
169
|
-
}).toString();
|
|
166
|
+
let template = FileHandler.readFile(templatePath).toString();
|
|
170
167
|
let data = {
|
|
171
168
|
...route,
|
|
172
169
|
...content,
|
|
@@ -185,9 +182,7 @@ class Frontend
|
|
|
185
182
|
return await this.renderNotFoundPage(res);
|
|
186
183
|
}
|
|
187
184
|
}
|
|
188
|
-
let template = FileHandler.readFile(templatePath
|
|
189
|
-
encoding: this.encoding
|
|
190
|
-
}).toString();
|
|
185
|
+
let template = FileHandler.readFile(templatePath).toString();
|
|
191
186
|
let data = {
|
|
192
187
|
...entity,
|
|
193
188
|
title: entity.title || entity.name || entityName,
|
|
@@ -199,9 +194,7 @@ class Frontend
|
|
|
199
194
|
|
|
200
195
|
async renderTemplateOnly(res, templatePath)
|
|
201
196
|
{
|
|
202
|
-
let template = FileHandler.readFile(templatePath
|
|
203
|
-
encoding: this.encoding
|
|
204
|
-
}).toString();
|
|
197
|
+
let template = FileHandler.readFile(templatePath).toString();
|
|
205
198
|
let data = {
|
|
206
199
|
title: 'Page Title',
|
|
207
200
|
current_year: new Date().getFullYear()
|
|
@@ -216,9 +209,7 @@ class Frontend
|
|
|
216
209
|
if(!FileHandler.exists(templatePath)){
|
|
217
210
|
return res.status(404).send('Page not found');
|
|
218
211
|
}
|
|
219
|
-
let template = FileHandler.readFile(templatePath
|
|
220
|
-
encoding: this.encoding
|
|
221
|
-
}).toString();
|
|
212
|
+
let template = FileHandler.readFile(templatePath).toString();
|
|
222
213
|
let data = {
|
|
223
214
|
title: '404 - Page Not Found',
|
|
224
215
|
current_year: new Date().getFullYear()
|
package/lib/installer.js
CHANGED
|
@@ -20,7 +20,11 @@ class Installer
|
|
|
20
20
|
this.appServer = sc.get(props, 'appServer', false);
|
|
21
21
|
this.appServerFactory = sc.get(props, 'appServerFactory', false);
|
|
22
22
|
this.projectRoot = sc.get(props, 'projectRoot', './');
|
|
23
|
-
this.
|
|
23
|
+
this.projectTemplatesPath = FileHandler.joinPaths(this.projectRoot, 'templates');
|
|
24
|
+
this.projectPublicPath = FileHandler.joinPaths(this.projectRoot, 'public');
|
|
25
|
+
this.projectPublicAssetsPath = FileHandler.joinPaths(this.projectPublicPath, 'assets');
|
|
26
|
+
this.projectCssPath = FileHandler.joinPaths(this.projectPublicPath, 'css');
|
|
27
|
+
this.projectJsPath = FileHandler.joinPaths(this.projectPublicPath, 'js');
|
|
24
28
|
this.installLockPath = FileHandler.joinPaths(this.projectRoot, 'install.lock');
|
|
25
29
|
this.envFilePath = FileHandler.joinPaths(this.projectRoot, '.env');
|
|
26
30
|
this.modulePath = FileHandler.joinPaths(__dirname, '..');
|
|
@@ -28,10 +32,11 @@ class Installer
|
|
|
28
32
|
this.migrationsPath = FileHandler.joinPaths(this.modulePath, 'migrations');
|
|
29
33
|
this.defaultTemplatesPath = FileHandler.joinPaths(this.modulePath, 'templates');
|
|
30
34
|
this.moduleAdminPath = FileHandler.joinPaths(this.modulePath, 'admin');
|
|
35
|
+
this.moduleAdminAssetsPath = FileHandler.joinPaths(this.moduleAdminPath, 'assets');
|
|
36
|
+
this.moduleAdminTemplatesPath = FileHandler.joinPaths(this.moduleAdminPath, 'templates')
|
|
31
37
|
this.indexTemplatePath = FileHandler.joinPaths(this.defaultTemplatesPath, 'index.js.dist');
|
|
32
38
|
this.postInstallCallback = sc.get(props, 'postInstallCallback', false);
|
|
33
39
|
this.entitiesLoader = new EntitiesLoader({projectRoot: this.projectRoot});
|
|
34
|
-
this.adminEntitiesGenerator = new AdminEntitiesGenerator();
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
isInstalled()
|
|
@@ -136,7 +141,11 @@ class Installer
|
|
|
136
141
|
debug: false
|
|
137
142
|
};
|
|
138
143
|
if('prisma' === selectedDriver){
|
|
139
|
-
await this.generatePrismaSchema(dbConfig);
|
|
144
|
+
let generatedPrismaSchema = await this.generatePrismaSchema(dbConfig);
|
|
145
|
+
if(!generatedPrismaSchema){
|
|
146
|
+
Logger.error('Could not generated Prisma schema.');
|
|
147
|
+
return res.redirect('/?error=prisma-schema-generation-error');
|
|
148
|
+
}
|
|
140
149
|
Logger.info('Generated Prisma schema.');
|
|
141
150
|
}
|
|
142
151
|
let dbDriver = new driverClass(dbConfig);
|
|
@@ -185,30 +194,11 @@ class Installer
|
|
|
185
194
|
await this.copyAdminDirectory();
|
|
186
195
|
await this.createIndexJsFile(templateVariables);
|
|
187
196
|
if(sc.isFunction(this.postInstallCallback)){
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
dbDriver.rawEntities = {};
|
|
191
|
-
let entityNames = Object.keys(loadedEntities.rawRegisteredEntities);
|
|
192
|
-
for(let i = 0; i < entityNames.length; i++){
|
|
193
|
-
let entityName = entityNames[i];
|
|
194
|
-
dbDriver.rawEntities[entityName] = loadedEntities.rawRegisteredEntities[entityName];
|
|
195
|
-
}
|
|
196
|
-
await dbDriver.generateEntities();
|
|
197
|
-
let adminEntities = this.adminEntitiesGenerator.generate(
|
|
198
|
-
loadedEntities.rawRegisteredEntities,
|
|
199
|
-
dbDriver.entityManager.entities
|
|
200
|
-
);
|
|
201
|
-
if(this.appServer && sc.isFunction(this.appServer.close)){
|
|
202
|
-
await this.appServer.close();
|
|
203
|
-
}
|
|
204
|
-
Logger.debug('Running postInstallCallback.');
|
|
205
|
-
await this.postInstallCallback({
|
|
206
|
-
entities: adminEntities,
|
|
207
|
-
rawEntities: loadedEntities.rawRegisteredEntities,
|
|
208
|
-
entitiesConfig: loadedEntities.entitiesConfig || {},
|
|
209
|
-
entitiesTranslations: loadedEntities.entitiesTranslations || {}
|
|
210
|
-
});
|
|
197
|
+
if(this.appServer && sc.isFunction(this.appServer.close)){
|
|
198
|
+
await this.appServer.close();
|
|
211
199
|
}
|
|
200
|
+
Logger.debug('Running postInstallCallback.');
|
|
201
|
+
await this.postInstallCallback(this.entitiesLoader.loadEntities(selectedDriver));
|
|
212
202
|
}
|
|
213
203
|
await this.createLockFile();
|
|
214
204
|
Logger.info('Installation successful!');
|
|
@@ -219,8 +209,8 @@ class Installer
|
|
|
219
209
|
}
|
|
220
210
|
return res.send(successContent);
|
|
221
211
|
} catch (error) {
|
|
222
|
-
Logger.
|
|
223
|
-
return res.redirect('/?error=
|
|
212
|
+
Logger.critical('Configuration error: '+error.message);
|
|
213
|
+
return res.redirect('/?error=installation-error');
|
|
224
214
|
}
|
|
225
215
|
}
|
|
226
216
|
|
|
@@ -316,40 +306,47 @@ class Installer
|
|
|
316
306
|
Logger.error('Admin folder not found in module path: '+this.moduleAdminPath);
|
|
317
307
|
return false;
|
|
318
308
|
}
|
|
319
|
-
FileHandler.
|
|
309
|
+
let projectAdminTemplates = FileHandler.joinPaths(projectAdminPath, 'templates');
|
|
310
|
+
FileHandler.copyFolderSync(this.moduleAdminTemplatesPath, projectAdminTemplates);
|
|
311
|
+
FileHandler.copyFolderSync(this.moduleAdminAssetsPath, this.projectPublicAssetsPath);
|
|
312
|
+
FileHandler.copyFile(
|
|
313
|
+
FileHandler.joinPaths(this.moduleAdminPath, 'reldens-admin-client.css'),
|
|
314
|
+
FileHandler.joinPaths(this.projectCssPath, 'reldens-admin-client.css'),
|
|
315
|
+
);
|
|
316
|
+
FileHandler.copyFile(
|
|
317
|
+
FileHandler.joinPaths(this.moduleAdminPath, 'reldens-admin-client.js'),
|
|
318
|
+
FileHandler.joinPaths(this.projectJsPath, 'reldens-admin-client.js'),
|
|
319
|
+
);
|
|
320
320
|
Logger.info('Admin folder copied to project root.');
|
|
321
321
|
return true;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
async prepareProjectDirectories()
|
|
325
325
|
{
|
|
326
|
-
|
|
327
|
-
FileHandler.createFolder(
|
|
328
|
-
|
|
329
|
-
FileHandler.createFolder(
|
|
330
|
-
|
|
331
|
-
FileHandler.createFolder(projectCssPath);
|
|
332
|
-
let projectJsPath = FileHandler.joinPaths(projectPublicPath, 'js');
|
|
333
|
-
FileHandler.createFolder(projectJsPath);
|
|
326
|
+
FileHandler.createFolder(this.projectTemplatesPath);
|
|
327
|
+
FileHandler.createFolder(this.projectPublicPath);
|
|
328
|
+
FileHandler.createFolder(this.projectPublicAssetsPath);
|
|
329
|
+
FileHandler.createFolder(this.projectCssPath);
|
|
330
|
+
FileHandler.createFolder(this.projectJsPath);
|
|
334
331
|
FileHandler.copyFile(
|
|
335
332
|
FileHandler.joinPaths(this.defaultTemplatesPath, 'page.html'),
|
|
336
|
-
FileHandler.joinPaths(projectTemplatesPath, 'page.html')
|
|
333
|
+
FileHandler.joinPaths(this.projectTemplatesPath, 'page.html')
|
|
337
334
|
);
|
|
338
335
|
FileHandler.copyFile(
|
|
339
336
|
FileHandler.joinPaths(this.defaultTemplatesPath, '404.html'),
|
|
340
|
-
FileHandler.joinPaths(projectTemplatesPath, '404.html')
|
|
337
|
+
FileHandler.joinPaths(this.projectTemplatesPath, '404.html')
|
|
341
338
|
);
|
|
342
339
|
FileHandler.copyFile(
|
|
343
340
|
FileHandler.joinPaths(this.defaultTemplatesPath, 'layout.html'),
|
|
344
|
-
FileHandler.joinPaths(projectTemplatesPath, 'layout.html')
|
|
341
|
+
FileHandler.joinPaths(this.projectTemplatesPath, 'layout.html')
|
|
345
342
|
);
|
|
346
343
|
FileHandler.copyFile(
|
|
347
344
|
FileHandler.joinPaths(this.defaultTemplatesPath, 'css', 'styles.css'),
|
|
348
|
-
FileHandler.joinPaths(projectCssPath, 'styles.css')
|
|
345
|
+
FileHandler.joinPaths(this.projectCssPath, 'styles.css')
|
|
349
346
|
);
|
|
350
347
|
FileHandler.copyFile(
|
|
351
348
|
FileHandler.joinPaths(this.defaultTemplatesPath, 'js', 'scripts.js'),
|
|
352
|
-
FileHandler.joinPaths(projectJsPath, 'scripts.js')
|
|
349
|
+
FileHandler.joinPaths(this.projectJsPath, 'scripts.js')
|
|
353
350
|
);
|
|
354
351
|
return true;
|
|
355
352
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Reldens - LoadedEntitiesProcessor
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { sc } = require('@reldens/utils');
|
|
8
|
+
|
|
9
|
+
class LoadedEntitiesProcessor
|
|
10
|
+
{
|
|
11
|
+
|
|
12
|
+
process(rawRegisteredEntities, entitiesTranslations, entitiesConfig)
|
|
13
|
+
{
|
|
14
|
+
let exportedEntitiesList = Object.keys(rawRegisteredEntities);
|
|
15
|
+
if(0 === exportedEntitiesList.length){
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
let entities = {};
|
|
19
|
+
for (let i of exportedEntitiesList) {
|
|
20
|
+
entities[i] = {
|
|
21
|
+
rawEntity: rawRegisteredEntities[i],
|
|
22
|
+
config: sc.isFunction(entitiesConfig) ? entitiesConfig(props)[i] : entitiesConfig[i]
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {entities, entitiesRaw: rawRegisteredEntities, translations: entitiesTranslations};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports.LoadedEntitiesProcessor = new LoadedEntitiesProcessor();
|