@reldens/cms 0.6.0 → 0.8.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.
Files changed (40) hide show
  1. package/admin/reldens-admin-client.css +29 -30
  2. package/admin/templates/dashboard.html +1 -1
  3. package/bin/reldens-cms.js +1 -1
  4. package/install/index.html +23 -9
  5. package/install/success.html +36 -0
  6. package/lib/admin-manager.js +41 -4
  7. package/lib/admin-templates-loader.js +37 -0
  8. package/lib/admin-translations.js +4 -218
  9. package/lib/allowed-extensions.js +11 -0
  10. package/lib/entities-loader.js +2 -6
  11. package/lib/frontend.js +25 -17
  12. package/lib/installer.js +144 -116
  13. package/lib/loaded-entities-processor.js +30 -0
  14. package/lib/manager.js +223 -56
  15. package/lib/mime-types.js +35 -0
  16. package/lib/templates-list.js +0 -9
  17. package/lib/templates-to-path-mapper.js +28 -0
  18. package/migrations/default-homepage.sql +10 -0
  19. package/migrations/install.sql +1 -23
  20. package/migrations/users-authentication.sql +16 -0
  21. package/package.json +2 -2
  22. package/templates/.env.dist +11 -11
  23. package/templates/assets/favicons/android-icon-144x144.png +0 -0
  24. package/templates/assets/favicons/android-icon-192x192.png +0 -0
  25. package/templates/assets/favicons/android-icon-512x512.png +0 -0
  26. package/templates/assets/favicons/apple-touch-icon.png +0 -0
  27. package/templates/assets/favicons/favicon-16x16.png +0 -0
  28. package/templates/assets/favicons/favicon-32x32.png +0 -0
  29. package/templates/assets/favicons/mstile-150x150.png +0 -0
  30. package/templates/assets/favicons/safari-pinned-tab.svg +121 -0
  31. package/templates/assets/web/loading.gif +0 -0
  32. package/templates/assets/web/reldens-your-logo-mage.png +0 -0
  33. package/templates/browserconfig.xml +9 -0
  34. package/templates/favicon.ico +0 -0
  35. package/templates/index.js.dist +2 -2
  36. package/templates/site.webmanifest +27 -0
  37. package/admin/templates/maps-wizard-maps-selection.html +0 -85
  38. package/admin/templates/maps-wizard.html +0 -341
  39. package/admin/templates/objects-import.html +0 -143
  40. package/admin/templates/skills-import.html +0 -201
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
 
@@ -65,12 +64,14 @@ class Frontend
65
64
  try {
66
65
  let route = await this.findRouteByPath(path);
67
66
  if(route){
67
+ Logger.debug('Found route for path: '+path, route);
68
68
  return await this.renderContentFromRoute(res, route);
69
69
  }
70
70
  let pathSegments = path.split('/').filter(segment => segment !== '');
71
71
  if(0 < pathSegments.length){
72
72
  let entityResult = await this.findEntityByPath(pathSegments);
73
73
  if(entityResult){
74
+ Logger.debug('Found entity for path segments: '+pathSegments.join('/'));
74
75
  return await this.renderContentFromEntity(
75
76
  res,
76
77
  entityResult.entity,
@@ -80,8 +81,10 @@ class Frontend
80
81
  }
81
82
  let templatePath = this.findTemplateByPath(path);
82
83
  if(templatePath){
84
+ Logger.debug('Found template for path: '+path+' at: '+templatePath);
83
85
  return await this.renderTemplateOnly(res, templatePath);
84
86
  }
87
+ Logger.debug('No template found for path: '+path+', rendering 404');
85
88
  return await this.renderNotFoundPage(res);
86
89
  } catch (error) {
87
90
  Logger.error('Request handling error: '+error.message);
@@ -91,32 +94,41 @@ class Frontend
91
94
 
92
95
  async findRouteByPath(path)
93
96
  {
94
- if('/' === path){
95
- path = '/home';
96
- }
97
97
  let routesEntity = this.dataServer.getEntity('routes');
98
98
  if(!routesEntity){
99
+ Logger.error('Routes entity not found in dataServer');
99
100
  return false;
100
101
  }
101
- return await routesEntity.loadOneBy('path', path);
102
+ let route = await routesEntity.loadOneBy('path', path);
103
+ if(route){
104
+ return route;
105
+ }
106
+ if('/' === path){
107
+ return await routesEntity.loadOneBy('path', '/home');
108
+ }
109
+ return false;
102
110
  }
103
111
 
104
112
  async findEntityByPath(pathSegments)
105
113
  {
106
114
  if(1 > pathSegments.length){
115
+ Logger.debug('No path segments provided');
107
116
  return false;
108
117
  }
109
118
  let entityName = pathSegments[0];
110
119
  let entityId = 2 > pathSegments.length ? false : pathSegments[1];
111
120
  if(!entityId){
121
+ Logger.debug('No entity ID in path segments');
112
122
  return false;
113
123
  }
114
124
  let entity = this.dataServer.getEntity(entityName);
115
125
  if(!entity){
126
+ Logger.debug('Entity not found: '+entityName);
116
127
  return false;
117
128
  }
118
129
  let loadedEntity = await entity.loadById(entityId);
119
130
  if(!loadedEntity){
131
+ Logger.debug('Entity not loaded by ID: '+entityId);
120
132
  return false;
121
133
  }
122
134
  return {
@@ -146,14 +158,17 @@ class Frontend
146
158
  async renderContentFromRoute(res, route)
147
159
  {
148
160
  if(!route.router || !route.content_id){
161
+ Logger.debug('Route missing router or content_id');
149
162
  return await this.renderNotFoundPage(res);
150
163
  }
151
164
  let entity = this.dataServer.getEntity(route.router);
152
165
  if(!entity){
166
+ Logger.debug('Entity not found: '+route.router);
153
167
  return await this.renderNotFoundPage(res);
154
168
  }
155
169
  let content = await entity.loadById(route.content_id);
156
170
  if(!content){
171
+ Logger.debug('Content not found for ID: '+route.content_id+' in entity: '+route.router);
157
172
  return await this.renderNotFoundPage(res);
158
173
  }
159
174
  let templateName = content.template || route.router;
@@ -161,12 +176,11 @@ class Frontend
161
176
  if(!FileHandler.exists(templatePath)){
162
177
  templatePath = FileHandler.joinPaths(this.templatesPath, 'page.html');
163
178
  if(!FileHandler.exists(templatePath)){
179
+ Logger.debug('Neither template found: '+templateName+'.html nor page.html');
164
180
  return await this.renderNotFoundPage(res);
165
181
  }
166
182
  }
167
- let template = FileHandler.readFile(templatePath, {
168
- encoding: this.encoding
169
- }).toString();
183
+ let template = FileHandler.readFile(templatePath).toString();
170
184
  let data = {
171
185
  ...route,
172
186
  ...content,
@@ -185,9 +199,7 @@ class Frontend
185
199
  return await this.renderNotFoundPage(res);
186
200
  }
187
201
  }
188
- let template = FileHandler.readFile(templatePath, {
189
- encoding: this.encoding
190
- }).toString();
202
+ let template = FileHandler.readFile(templatePath).toString();
191
203
  let data = {
192
204
  ...entity,
193
205
  title: entity.title || entity.name || entityName,
@@ -199,9 +211,7 @@ class Frontend
199
211
 
200
212
  async renderTemplateOnly(res, templatePath)
201
213
  {
202
- let template = FileHandler.readFile(templatePath, {
203
- encoding: this.encoding
204
- }).toString();
214
+ let template = FileHandler.readFile(templatePath).toString();
205
215
  let data = {
206
216
  title: 'Page Title',
207
217
  current_year: new Date().getFullYear()
@@ -216,9 +226,7 @@ class Frontend
216
226
  if(!FileHandler.exists(templatePath)){
217
227
  return res.status(404).send('Page not found');
218
228
  }
219
- let template = FileHandler.readFile(templatePath, {
220
- encoding: this.encoding
221
- }).toString();
229
+ let template = FileHandler.readFile(templatePath).toString();
222
230
  let data = {
223
231
  title: '404 - Page Not Found',
224
232
  current_year: new Date().getFullYear()
package/lib/installer.js CHANGED
@@ -7,7 +7,6 @@
7
7
  const { FileHandler, Encryptor } = require('@reldens/server-utils');
8
8
  const { DriversMap, EntitiesGenerator, PrismaSchemaGenerator } = require('@reldens/storage');
9
9
  const { EntitiesLoader } = require('./entities-loader');
10
- const { AdminEntitiesGenerator } = require('./admin-entities-generator');
11
10
  const { Logger, sc } = require('@reldens/utils');
12
11
  const mustache = require('mustache');
13
12
 
@@ -20,7 +19,11 @@ class Installer
20
19
  this.appServer = sc.get(props, 'appServer', false);
21
20
  this.appServerFactory = sc.get(props, 'appServerFactory', false);
22
21
  this.projectRoot = sc.get(props, 'projectRoot', './');
23
- this.encoding = sc.get(props, 'encoding', 'utf8');
22
+ this.projectTemplatesPath = FileHandler.joinPaths(this.projectRoot, 'templates');
23
+ this.projectPublicPath = FileHandler.joinPaths(this.projectRoot, 'public');
24
+ this.projectPublicAssetsPath = FileHandler.joinPaths(this.projectPublicPath, 'assets');
25
+ this.projectCssPath = FileHandler.joinPaths(this.projectPublicPath, 'css');
26
+ this.projectJsPath = FileHandler.joinPaths(this.projectPublicPath, 'js');
24
27
  this.installLockPath = FileHandler.joinPaths(this.projectRoot, 'install.lock');
25
28
  this.envFilePath = FileHandler.joinPaths(this.projectRoot, '.env');
26
29
  this.modulePath = FileHandler.joinPaths(__dirname, '..');
@@ -28,10 +31,11 @@ class Installer
28
31
  this.migrationsPath = FileHandler.joinPaths(this.modulePath, 'migrations');
29
32
  this.defaultTemplatesPath = FileHandler.joinPaths(this.modulePath, 'templates');
30
33
  this.moduleAdminPath = FileHandler.joinPaths(this.modulePath, 'admin');
34
+ this.moduleAdminAssetsPath = FileHandler.joinPaths(this.moduleAdminPath, 'assets');
35
+ this.moduleAdminTemplatesPath = FileHandler.joinPaths(this.moduleAdminPath, 'templates')
31
36
  this.indexTemplatePath = FileHandler.joinPaths(this.defaultTemplatesPath, 'index.js.dist');
32
37
  this.postInstallCallback = sc.get(props, 'postInstallCallback', false);
33
38
  this.entitiesLoader = new EntitiesLoader({projectRoot: this.projectRoot});
34
- this.adminEntitiesGenerator = new AdminEntitiesGenerator();
35
39
  }
36
40
 
37
41
  isInstalled()
@@ -99,10 +103,11 @@ class Installer
99
103
  'connection-failed': 'Database connection failed. Please check your credentials.',
100
104
  'raw-query-not-found': 'Query method not found in driver.',
101
105
  'sql-file-not-found': 'SQL installation file not found.',
102
- 'sql-tables-creation-failed': 'Failed to create database tables.',
106
+ 'sql-cms-tables-creation-failed': 'Failed to create CMS tables.',
107
+ 'sql-user-auth-creation-failed': 'Failed to create user authentication tables.',
103
108
  'sql-default-user-error': 'Failed to create default user.',
109
+ 'sql-default-homepage-error': 'Failed to create default homepage.',
104
110
  'installation-entities-generation-failed': 'Failed to generate entities.',
105
- 'installation-process-failed': 'Installation process failed.',
106
111
  'installation-entities-callback-failed': 'Failed to process entities for callback.',
107
112
  'configuration-error': 'Configuration error while completing installation.',
108
113
  'already-installed': 'The application is already installed.'
@@ -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);
@@ -148,67 +157,44 @@ class Installer
148
157
  Logger.error('Method "rawQuery" not found.');
149
158
  return res.redirect('/?error=raw-query-not-found');
150
159
  }
151
- let installSqlPath = FileHandler.joinPaths(this.migrationsPath, 'install.sql');
152
- if(!FileHandler.exists(installSqlPath)){
153
- Logger.error('SQL installation file not found.');
154
- return res.redirect('/?error=sql-file-not-found');
155
- }
156
- let queryTablesResult = await this.executeQueryFile(dbDriver, installSqlPath);
157
- if(!queryTablesResult){
158
- Logger.error('Tables creation failed.');
159
- return res.redirect('/?error=sql-tables-creation-failed');
160
- }
161
- Logger.info('Installed tables.');
162
- let defaultUserSqlPath = FileHandler.joinPaths(this.migrationsPath, 'default-user.sql');
163
- try {
164
- if(FileHandler.exists(defaultUserSqlPath)){
165
- let queryUserResult = await this.executeQueryFile(dbDriver, defaultUserSqlPath);
166
- if(!queryUserResult){
167
- Logger.error('Default user creation failed.', queryUserResult);
168
- return res.redirect('/?error=sql-default-user-error');
169
- }
170
- Logger.info('Created default user.');
171
- }
172
- let entitiesGenerationResult = await this.generateEntities(dbDriver);
173
- if(!entitiesGenerationResult){
174
- Logger.error('Entities generation error.');
175
- return res.redirect('/?error=installation-entities-generation-failed');
160
+ let executeFiles = {
161
+ 'install-cms-tables': 'install.sql',
162
+ 'install-user-auth': 'users-authentication.sql',
163
+ 'install-default-user': 'default-user.sql',
164
+ 'install-default-homepage': 'default-homepage.sql'
165
+ };
166
+ for(let checkboxName of Object.keys(executeFiles)){
167
+ let fileName = executeFiles[checkboxName];
168
+ let redirectError = await this.executeQueryFile(
169
+ sc.get(templateVariables, checkboxName, 'off'),
170
+ fileName,
171
+ dbDriver
172
+ );
173
+ if('' !== redirectError){
174
+ return res.redirect(redirectError);
176
175
  }
177
- Logger.info('Generated entities.');
178
- } catch (error) {
179
- Logger.error('Installation error: '+error.message);
180
- return res.redirect('/?error=installation-process-failed');
181
176
  }
177
+ let entitiesGenerationResult = await this.generateEntities(dbDriver);
178
+ if(!entitiesGenerationResult){
179
+ Logger.error('Entities generation error.');
180
+ return res.redirect('/?error=installation-entities-generation-failed');
181
+ }
182
+ Logger.info('Generated entities.');
182
183
  try {
183
- await this.createEnvFile(templateVariables);
184
+ let mappedVariablesForConfig = this.mapVariablesForConfig(templateVariables);
185
+ await this.createEnvFile(this.mapVariablesForTemplate(mappedVariablesForConfig));
184
186
  await this.prepareProjectDirectories();
185
187
  await this.copyAdminDirectory();
186
188
  await this.createIndexJsFile(templateVariables);
187
189
  if(sc.isFunction(this.postInstallCallback)){
188
- let loadedEntities = this.entitiesLoader.loadEntities(selectedDriver);
189
- if(loadedEntities.rawRegisteredEntities){
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
- });
190
+ if(this.appServer && sc.isFunction(this.appServer.close)){
191
+ await this.appServer.close();
211
192
  }
193
+ Logger.debug('Running postInstallCallback.');
194
+ await this.postInstallCallback({
195
+ loadedEntities: this.entitiesLoader.loadEntities(selectedDriver),
196
+ mappedVariablesForConfig
197
+ });
212
198
  }
213
199
  await this.createLockFile();
214
200
  Logger.info('Installation successful!');
@@ -219,18 +205,28 @@ class Installer
219
205
  }
220
206
  return res.send(successContent);
221
207
  } catch (error) {
222
- Logger.error('Configuration error: '+error.message);
223
- return res.redirect('/?error=configuration-error');
208
+ Logger.critical('Configuration error: '+error.message);
209
+ return res.redirect('/?error=installation-error');
224
210
  }
225
211
  }
226
212
 
227
- async executeQueryFile(dbDriver, filePath)
213
+ async executeQueryFile(isMarked, fileName, dbDriver)
228
214
  {
229
- let sqlContent = FileHandler.readFile(filePath);
230
- if(!sqlContent){
231
- throw new Error('Could not read SQL file: '+filePath);
215
+ if('on' !== isMarked){
216
+ return '';
232
217
  }
233
- return await dbDriver.rawQuery(sqlContent.toString());
218
+ let sqlFileContent = FileHandler.readFile(FileHandler.joinPaths(this.migrationsPath, fileName));
219
+ if(!sqlFileContent){
220
+ Logger.error('SQL file "'+fileName+'" not found.');
221
+ return '/?error=sql-file-not-found&file-name='+fileName;
222
+ }
223
+ let queryResult = await dbDriver.rawQuery(sqlFileContent.toString());
224
+ if(!queryResult){
225
+ Logger.error('SQL file "'+fileName+'" raw execution failed.');
226
+ return '/?error=sql-file-execution-error&file-name='+fileName;
227
+ }
228
+ Logger.info('SQL file "'+fileName+'" raw execution successfully.');
229
+ return '';
234
230
  }
235
231
 
236
232
  async generateEntities(server)
@@ -262,25 +258,48 @@ class Installer
262
258
  async createEnvFile(templateVariables)
263
259
  {
264
260
  let envTemplatePath = FileHandler.joinPaths(this.defaultTemplatesPath, '.env.dist');
265
- if(!FileHandler.exists(envTemplatePath)){
266
- Logger.error('ENV template not found: '+envTemplatePath);
261
+ let envTemplateContent = FileHandler.readFile(envTemplatePath);
262
+ if(!envTemplateContent){
263
+ Logger.error('Template ".env.dist" not found: '+envTemplatePath);
267
264
  return false;
268
265
  }
269
- let envTemplate = FileHandler.readFile(envTemplatePath);
270
- let envContent = mustache.render(envTemplate, {
271
- dbClient: templateVariables['db-client'],
272
- dbHost: templateVariables['db-host'],
273
- dbPort: templateVariables['db-port'],
274
- dbName: templateVariables['db-name'],
275
- dbUser: templateVariables['db-username'],
276
- dbPassword: templateVariables['db-password'],
277
- dbDriver: templateVariables['db-storage-driver'],
278
- adminPath: templateVariables['app-admin-path'],
279
- adminSecret: Encryptor.generateSecretKey(),
280
- host: templateVariables['app-host'],
281
- port: templateVariables['app-port']
282
- });
283
- return FileHandler.writeFile(this.envFilePath, envContent);
266
+ return FileHandler.writeFile(this.envFilePath, mustache.render(envTemplateContent, templateVariables));
267
+ }
268
+
269
+ mapVariablesForTemplate(configVariables)
270
+ {
271
+ return {
272
+ host: configVariables.host,
273
+ port: configVariables.port,
274
+ adminPath: configVariables.adminPath,
275
+ adminSecret: configVariables.adminSecret,
276
+ dbClient: configVariables.database.client,
277
+ dbHost: configVariables.database.host,
278
+ dbPort: configVariables.database.port,
279
+ dbName: configVariables.database.name,
280
+ dbUser: configVariables.database.user,
281
+ dbPassword: configVariables.database.password,
282
+ dbDriver: configVariables.database.driver
283
+ };
284
+ }
285
+
286
+ mapVariablesForConfig(templateVariables)
287
+ {
288
+ return {
289
+ host: sc.get(templateVariables, 'app-host', 'http://localhost'),
290
+ port: Number(sc.get(templateVariables, 'app-port', 8080)),
291
+ adminPath: sc.get(templateVariables, 'app-admin-path', '/reldens-admin'),
292
+ adminSecret: sc.get(templateVariables, 'app-admin-secret', Encryptor.generateSecretKey()),
293
+ database: {
294
+ client: sc.get(templateVariables, 'db-client', 'mysql'),
295
+ host: sc.get(templateVariables, 'db-host', 'localhost'),
296
+ port: Number(sc.get(templateVariables, 'db-port', 3306)),
297
+ name: sc.get(templateVariables, 'db-name', 'reldens_cms'),
298
+ user: sc.get(templateVariables, 'db-username', ''),
299
+ password: sc.get(templateVariables, 'db-password', ''),
300
+ driver: sc.get(templateVariables, 'db-storage-driver', 'prisma')
301
+ }
302
+ };
284
303
  }
285
304
 
286
305
  async createIndexJsFile(templateVariables)
@@ -316,40 +335,49 @@ class Installer
316
335
  Logger.error('Admin folder not found in module path: '+this.moduleAdminPath);
317
336
  return false;
318
337
  }
319
- FileHandler.copyFolderSync(this.moduleAdminPath, projectAdminPath);
338
+ let projectAdminTemplates = FileHandler.joinPaths(projectAdminPath, 'templates');
339
+ FileHandler.copyFolderSync(this.moduleAdminTemplatesPath, projectAdminTemplates);
340
+ FileHandler.copyFolderSync(this.moduleAdminAssetsPath, this.projectPublicAssetsPath);
341
+ FileHandler.copyFile(
342
+ FileHandler.joinPaths(this.moduleAdminPath, 'reldens-admin-client.css'),
343
+ FileHandler.joinPaths(this.projectCssPath, 'reldens-admin-client.css'),
344
+ );
345
+ FileHandler.copyFile(
346
+ FileHandler.joinPaths(this.moduleAdminPath, 'reldens-admin-client.js'),
347
+ FileHandler.joinPaths(this.projectJsPath, 'reldens-admin-client.js'),
348
+ );
320
349
  Logger.info('Admin folder copied to project root.');
321
350
  return true;
322
351
  }
323
352
 
324
353
  async prepareProjectDirectories()
325
354
  {
326
- let projectTemplatesPath = FileHandler.joinPaths(this.projectRoot, 'templates');
327
- FileHandler.createFolder(projectTemplatesPath);
328
- let projectPublicPath = FileHandler.joinPaths(this.projectRoot, 'public');
329
- FileHandler.createFolder(projectPublicPath);
330
- let projectCssPath = FileHandler.joinPaths(projectPublicPath, 'css');
331
- FileHandler.createFolder(projectCssPath);
332
- let projectJsPath = FileHandler.joinPaths(projectPublicPath, 'js');
333
- FileHandler.createFolder(projectJsPath);
334
- FileHandler.copyFile(
335
- FileHandler.joinPaths(this.defaultTemplatesPath, 'page.html'),
336
- FileHandler.joinPaths(projectTemplatesPath, 'page.html')
337
- );
338
- FileHandler.copyFile(
339
- FileHandler.joinPaths(this.defaultTemplatesPath, '404.html'),
340
- FileHandler.joinPaths(projectTemplatesPath, '404.html')
341
- );
342
- FileHandler.copyFile(
343
- FileHandler.joinPaths(this.defaultTemplatesPath, 'layout.html'),
344
- FileHandler.joinPaths(projectTemplatesPath, 'layout.html')
345
- );
355
+ FileHandler.createFolder(this.projectTemplatesPath);
356
+ FileHandler.createFolder(this.projectPublicPath);
357
+ FileHandler.createFolder(this.projectPublicAssetsPath);
358
+ FileHandler.createFolder(this.projectCssPath);
359
+ FileHandler.createFolder(this.projectJsPath);
360
+ let baseFiles = [
361
+ 'page.html',
362
+ '404.html',
363
+ 'layout.html',
364
+ 'browserconfig.xml',
365
+ 'favicon.ico',
366
+ 'site.webmanifest'
367
+ ];
368
+ for(let fileName of baseFiles){
369
+ FileHandler.copyFile(
370
+ FileHandler.joinPaths(this.defaultTemplatesPath, fileName),
371
+ FileHandler.joinPaths(this.projectTemplatesPath, fileName)
372
+ );
373
+ }
346
374
  FileHandler.copyFile(
347
375
  FileHandler.joinPaths(this.defaultTemplatesPath, 'css', 'styles.css'),
348
- FileHandler.joinPaths(projectCssPath, 'styles.css')
376
+ FileHandler.joinPaths(this.projectCssPath, 'styles.css')
349
377
  );
350
378
  FileHandler.copyFile(
351
379
  FileHandler.joinPaths(this.defaultTemplatesPath, 'js', 'scripts.js'),
352
- FileHandler.joinPaths(projectJsPath, 'scripts.js')
380
+ FileHandler.joinPaths(this.projectJsPath, 'scripts.js')
353
381
  );
354
382
  return true;
355
383
  }
@@ -357,16 +385,16 @@ class Installer
357
385
  fetchDefaults()
358
386
  {
359
387
  return {
360
- 'app-host': process.env.RELDENS_CMS_HOST || 'http://localhost',
361
- 'app-port': process.env.RELDENS_CMS_PORT || '8000',
362
- 'app-admin-path': process.env.RELDENS_CMS_ADMIN_PATH || '/reldens-admin',
363
- 'db-storage-driver': 'prisma',
364
- 'db-client': process.env.RELDENS_CMS_DB_CLIENT || 'mysql',
365
- 'db-host': process.env.RELDENS_CMS_DB_HOST || 'localhost',
366
- 'db-port': process.env.RELDENS_CMS_DB_PORT || '3306',
367
- 'db-name': process.env.RELDENS_CMS_DB_NAME || 'reldens_cms',
368
- 'db-username': process.env.RELDENS_CMS_DB_USER || '',
369
- 'db-password': process.env.RELDENS_CMS_DB_PASSWORD || ''
388
+ 'app-host': process.env.RELDENS_APP_HOST || 'http://localhost',
389
+ 'app-port': process.env.RELDENS_APP_PORT || '8080',
390
+ 'app-admin-path': process.env.RELDENS_ADMIN_ROUTE_PATH || '/reldens-admin',
391
+ 'db-storage-driver': process.env.RELDENS_STORAGE_DRIVER || 'prisma',
392
+ 'db-client': process.env.RELDENS_DB_CLIENT || 'mysql',
393
+ 'db-host': process.env.RELDENS_DB_HOST || 'localhost',
394
+ 'db-port': process.env.RELDENS_DB_PORT || '3306',
395
+ 'db-name': process.env.RELDENS_DB_NAME || 'reldens_cms',
396
+ 'db-username': process.env.RELDENS_DB_USER || '',
397
+ 'db-password': process.env.RELDENS_DB_PASSWORD || ''
370
398
  };
371
399
  }
372
400
  }
@@ -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();