@reldens/cms 0.7.0 → 0.9.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/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
 
@@ -104,10 +103,11 @@ class Installer
104
103
  'connection-failed': 'Database connection failed. Please check your credentials.',
105
104
  'raw-query-not-found': 'Query method not found in driver.',
106
105
  'sql-file-not-found': 'SQL installation file not found.',
107
- '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.',
108
108
  'sql-default-user-error': 'Failed to create default user.',
109
+ 'sql-default-homepage-error': 'Failed to create default homepage.',
109
110
  'installation-entities-generation-failed': 'Failed to generate entities.',
110
- 'installation-process-failed': 'Installation process failed.',
111
111
  'installation-entities-callback-failed': 'Failed to process entities for callback.',
112
112
  'configuration-error': 'Configuration error while completing installation.',
113
113
  'already-installed': 'The application is already installed.'
@@ -157,39 +157,32 @@ class Installer
157
157
  Logger.error('Method "rawQuery" not found.');
158
158
  return res.redirect('/?error=raw-query-not-found');
159
159
  }
160
- let installSqlPath = FileHandler.joinPaths(this.migrationsPath, 'install.sql');
161
- if(!FileHandler.exists(installSqlPath)){
162
- Logger.error('SQL installation file not found.');
163
- return res.redirect('/?error=sql-file-not-found');
164
- }
165
- let queryTablesResult = await this.executeQueryFile(dbDriver, installSqlPath);
166
- if(!queryTablesResult){
167
- Logger.error('Tables creation failed.');
168
- return res.redirect('/?error=sql-tables-creation-failed');
169
- }
170
- Logger.info('Installed tables.');
171
- let defaultUserSqlPath = FileHandler.joinPaths(this.migrationsPath, 'default-user.sql');
172
- try {
173
- if(FileHandler.exists(defaultUserSqlPath)){
174
- let queryUserResult = await this.executeQueryFile(dbDriver, defaultUserSqlPath);
175
- if(!queryUserResult){
176
- Logger.error('Default user creation failed.', queryUserResult);
177
- return res.redirect('/?error=sql-default-user-error');
178
- }
179
- Logger.info('Created default user.');
180
- }
181
- let entitiesGenerationResult = await this.generateEntities(dbDriver);
182
- if(!entitiesGenerationResult){
183
- Logger.error('Entities generation error.');
184
- 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);
185
175
  }
186
- Logger.info('Generated entities.');
187
- } catch (error) {
188
- Logger.error('Installation error: '+error.message);
189
- return res.redirect('/?error=installation-process-failed');
190
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.');
191
183
  try {
192
- await this.createEnvFile(templateVariables);
184
+ let mappedVariablesForConfig = this.mapVariablesForConfig(templateVariables);
185
+ await this.createEnvFile(this.mapVariablesForTemplate(mappedVariablesForConfig));
193
186
  await this.prepareProjectDirectories();
194
187
  await this.copyAdminDirectory();
195
188
  await this.createIndexJsFile(templateVariables);
@@ -198,7 +191,10 @@ class Installer
198
191
  await this.appServer.close();
199
192
  }
200
193
  Logger.debug('Running postInstallCallback.');
201
- await this.postInstallCallback(this.entitiesLoader.loadEntities(selectedDriver));
194
+ await this.postInstallCallback({
195
+ loadedEntities: this.entitiesLoader.loadEntities(selectedDriver),
196
+ mappedVariablesForConfig
197
+ });
202
198
  }
203
199
  await this.createLockFile();
204
200
  Logger.info('Installation successful!');
@@ -214,13 +210,23 @@ class Installer
214
210
  }
215
211
  }
216
212
 
217
- async executeQueryFile(dbDriver, filePath)
213
+ async executeQueryFile(isMarked, fileName, dbDriver)
218
214
  {
219
- let sqlContent = FileHandler.readFile(filePath);
220
- if(!sqlContent){
221
- throw new Error('Could not read SQL file: '+filePath);
215
+ if('on' !== isMarked){
216
+ return '';
222
217
  }
223
- 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 '';
224
230
  }
225
231
 
226
232
  async generateEntities(server)
@@ -252,25 +258,48 @@ class Installer
252
258
  async createEnvFile(templateVariables)
253
259
  {
254
260
  let envTemplatePath = FileHandler.joinPaths(this.defaultTemplatesPath, '.env.dist');
255
- if(!FileHandler.exists(envTemplatePath)){
256
- 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);
257
264
  return false;
258
265
  }
259
- let envTemplate = FileHandler.readFile(envTemplatePath);
260
- let envContent = mustache.render(envTemplate, {
261
- dbClient: templateVariables['db-client'],
262
- dbHost: templateVariables['db-host'],
263
- dbPort: templateVariables['db-port'],
264
- dbName: templateVariables['db-name'],
265
- dbUser: templateVariables['db-username'],
266
- dbPassword: templateVariables['db-password'],
267
- dbDriver: templateVariables['db-storage-driver'],
268
- adminPath: templateVariables['app-admin-path'],
269
- adminSecret: Encryptor.generateSecretKey(),
270
- host: templateVariables['app-host'],
271
- port: templateVariables['app-port']
272
- });
273
- 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
+ };
274
303
  }
275
304
 
276
305
  async createIndexJsFile(templateVariables)
@@ -328,18 +357,20 @@ class Installer
328
357
  FileHandler.createFolder(this.projectPublicAssetsPath);
329
358
  FileHandler.createFolder(this.projectCssPath);
330
359
  FileHandler.createFolder(this.projectJsPath);
331
- FileHandler.copyFile(
332
- FileHandler.joinPaths(this.defaultTemplatesPath, 'page.html'),
333
- FileHandler.joinPaths(this.projectTemplatesPath, 'page.html')
334
- );
335
- FileHandler.copyFile(
336
- FileHandler.joinPaths(this.defaultTemplatesPath, '404.html'),
337
- FileHandler.joinPaths(this.projectTemplatesPath, '404.html')
338
- );
339
- FileHandler.copyFile(
340
- FileHandler.joinPaths(this.defaultTemplatesPath, 'layout.html'),
341
- FileHandler.joinPaths(this.projectTemplatesPath, 'layout.html')
342
- );
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
+ }
343
374
  FileHandler.copyFile(
344
375
  FileHandler.joinPaths(this.defaultTemplatesPath, 'css', 'styles.css'),
345
376
  FileHandler.joinPaths(this.projectCssPath, 'styles.css')
@@ -354,16 +385,16 @@ class Installer
354
385
  fetchDefaults()
355
386
  {
356
387
  return {
357
- 'app-host': process.env.RELDENS_CMS_HOST || 'http://localhost',
358
- 'app-port': process.env.RELDENS_CMS_PORT || '8000',
359
- 'app-admin-path': process.env.RELDENS_CMS_ADMIN_PATH || '/reldens-admin',
360
- 'db-storage-driver': 'prisma',
361
- 'db-client': process.env.RELDENS_CMS_DB_CLIENT || 'mysql',
362
- 'db-host': process.env.RELDENS_CMS_DB_HOST || 'localhost',
363
- 'db-port': process.env.RELDENS_CMS_DB_PORT || '3306',
364
- 'db-name': process.env.RELDENS_CMS_DB_NAME || 'reldens_cms',
365
- 'db-username': process.env.RELDENS_CMS_DB_USER || '',
366
- '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 || ''
367
398
  };
368
399
  }
369
400
  }
package/lib/manager.js CHANGED
@@ -51,35 +51,98 @@ class Manager
51
51
  this.companyName = sc.get(props, 'companyName', 'Reldens - CMS');
52
52
  this.logo = sc.get(props, 'logo', '/assets/web/reldens-your-logo-mage.png');
53
53
  this.favicon = sc.get(props, 'favicon', '/assets/web/favicon.ico');
54
+ this.app = sc.get(props, 'app', false);
55
+ this.appServer = sc.get(props, 'appServer', false);
56
+ this.dataServer = sc.get(props, 'dataServer', false);
57
+ this.adminManager = sc.get(props, 'adminManager', false);
58
+ this.frontend = sc.get(props, 'frontend', false);
54
59
  this.appServerFactory = new AppServerFactory();
55
60
  this.adminEntitiesGenerator = new AdminEntitiesGenerator();
56
61
  this.installer = new Installer({
57
62
  projectRoot: this.projectRoot,
58
63
  postInstallCallback: this.initializeCmsAfterInstall.bind(this)
59
64
  });
60
- this.dataServer = false;
61
- this.app = false;
62
- this.appServer = false;
63
- this.adminManager = false;
64
- this.frontend = false;
65
+ this.useProvidedServer = this.validateProvidedServer();
66
+ this.useProvidedDataServer = this.validateProvidedDataServer();
67
+ this.useProvidedAdminManager = this.validateProvidedAdminManager();
68
+ this.useProvidedFrontend = this.validateProvidedFrontend();
69
+ }
70
+
71
+ validateProvidedServer()
72
+ {
73
+ if(!this.app){
74
+ return false;
75
+ }
76
+ if(!this.appServer){
77
+ return false;
78
+ }
79
+ if('function' !== typeof this.app.use){
80
+ Logger.critical('Invalid app instance provided - missing use method.');
81
+ return false;
82
+ }
83
+ if('function' !== typeof this.appServer.listen){
84
+ Logger.critical('Invalid appServer instance provided - missing listen method.');
85
+ return false;
86
+ }
87
+ return true;
88
+ }
89
+
90
+ validateProvidedDataServer()
91
+ {
92
+ if(!this.dataServer){
93
+ return false;
94
+ }
95
+ if('function' !== typeof this.dataServer.connect){
96
+ Logger.critical('Invalid dataServer instance provided - missing connect method.');
97
+ return false;
98
+ }
99
+ if('function' !== typeof this.dataServer.generateEntities){
100
+ Logger.critical('Invalid dataServer instance provided - missing generateEntities method.');
101
+ return false;
102
+ }
103
+ return true;
104
+ }
105
+
106
+ validateProvidedAdminManager()
107
+ {
108
+ if(!this.adminManager){
109
+ return false;
110
+ }
111
+ if('function' !== typeof this.adminManager.setupAdmin){
112
+ Logger.critical('Invalid adminManager instance provided - missing setupAdmin method.');
113
+ return false;
114
+ }
115
+ return true;
116
+ }
117
+
118
+ validateProvidedFrontend()
119
+ {
120
+ if(!this.frontend){
121
+ return false;
122
+ }
123
+ if('function' !== typeof this.frontend.initialize){
124
+ Logger.critical('Invalid frontend instance provided - missing initialize method.');
125
+ return false;
126
+ }
127
+ return true;
65
128
  }
66
129
 
67
130
  loadConfigFromEnv()
68
131
  {
69
132
  let envVars = process.env;
70
133
  return {
71
- host: sc.get(envVars, 'RELDENS_CMS_HOST', 'http://localhost'),
72
- port: Number(sc.get(envVars, 'RELDENS_CMS_PORT', 8000)),
73
- adminPath: sc.get(envVars, 'RELDENS_CMS_ADMIN_PATH', '/reldens-admin'),
74
- adminSecret: sc.get(envVars, 'RELDENS_CMS_ADMIN_SECRET', ''),
134
+ host: sc.get(envVars, 'RELDENS_APP_HOST', 'http://localhost'),
135
+ port: Number(sc.get(envVars, 'RELDENS_APP_PORT', 8080)),
136
+ adminPath: sc.get(envVars, 'RELDENS_ADMIN_ROUTE_PATH', '/reldens-admin'),
137
+ adminSecret: sc.get(envVars, 'RELDENS_ADMIN_SECRET', ''),
75
138
  database: {
76
- client: sc.get(envVars, 'RELDENS_CMS_DB_CLIENT', 'mysql'),
77
- host: sc.get(envVars, 'RELDENS_CMS_DB_HOST', 'localhost'),
78
- port: Number(sc.get(envVars, 'RELDENS_CMS_DB_PORT', 3306)),
79
- name: sc.get(envVars, 'RELDENS_CMS_DB_NAME', 'reldens_cms'),
80
- user: sc.get(envVars, 'RELDENS_CMS_DB_USER', ''),
81
- password: sc.get(envVars, 'RELDENS_CMS_DB_PASSWORD', ''),
82
- driver: sc.get(envVars, 'RELDENS_CMS_DB_DRIVER', 'prisma')
139
+ client: sc.get(envVars, 'RELDENS_DB_CLIENT', 'mysql'),
140
+ host: sc.get(envVars, 'RELDENS_DB_HOST', 'localhost'),
141
+ port: Number(sc.get(envVars, 'RELDENS_DB_PORT', 3306)),
142
+ name: sc.get(envVars, 'RELDENS_DB_NAME', 'reldens_cms'),
143
+ user: sc.get(envVars, 'RELDENS_DB_USER', ''),
144
+ password: sc.get(envVars, 'RELDENS_DB_PASSWORD', ''),
145
+ driver: sc.get(envVars, 'RELDENS_STORAGE_DRIVER', 'prisma')
83
146
  }
84
147
  };
85
148
  }
@@ -91,17 +154,21 @@ class Manager
91
154
 
92
155
  async start()
93
156
  {
94
- let createdAppServer = this.appServerFactory.createAppServer();
95
- if(this.appServerFactory.error.message){
96
- Logger.error('App server error: '+this.appServerFactory.error.message);
97
- return false;
157
+ if(!this.useProvidedServer){
158
+ let createdAppServer = this.appServerFactory.createAppServer();
159
+ if(this.appServerFactory.error.message){
160
+ Logger.error('App server error: '+this.appServerFactory.error.message);
161
+ return false;
162
+ }
163
+ this.app = createdAppServer.app;
164
+ this.appServer = createdAppServer.appServer;
98
165
  }
99
- this.app = createdAppServer.app;
100
- this.appServer = createdAppServer.appServer;
101
166
  if(!this.isInstalled()){
102
167
  Logger.info('CMS not installed, preparing setup');
103
168
  await this.installer.prepareSetup(this.app, this.appServer, this.appServerFactory);
104
- await this.appServer.listen(this.config.port);
169
+ if(!this.useProvidedServer){
170
+ await this.appServer.listen(this.config.port);
171
+ }
105
172
  Logger.info('Installer running on '+this.config.host+':'+this.config.port);
106
173
  return true;
107
174
  }
@@ -115,14 +182,14 @@ class Manager
115
182
  }
116
183
  }
117
184
 
118
- async initializeCmsAfterInstall(loadEntities)
185
+ async initializeCmsAfterInstall(props)
119
186
  {
120
187
  try {
121
- this.rawRegisteredEntities = loadEntities.rawRegisteredEntities;
122
- this.entitiesTranslations = loadEntities.entitiesTranslations;
123
- this.entitiesConfig = loadEntities.entitiesConfig;
124
- this.dataServer.rawEntities = loadEntities.rawRegisteredEntities;
125
- this.config = this.loadConfigFromEnv();
188
+ //Logger.debug('Loaded entities post install.', props.loadedEntities);
189
+ this.rawRegisteredEntities = props.loadedEntities.rawRegisteredEntities;
190
+ this.entitiesTranslations = props.loadedEntities.entitiesTranslations;
191
+ this.entitiesConfig = props.loadedEntities.entitiesConfig;
192
+ this.config = props.mappedVariablesForConfig;
126
193
  await this.initializeServices();
127
194
  Logger.info('CMS initialized after installation on '+this.config.host+':'+this.config.port);
128
195
  return true;
@@ -134,28 +201,68 @@ class Manager
134
201
 
135
202
  async initializeServices()
136
203
  {
137
- await this.initializeDataServer();
138
- if (0 === Object.keys(this.adminEntities).length){
139
- if(0 === Object.keys(this.processedEntities).length){
140
- this.processedEntities = LoadedEntitiesProcessor.process(
141
- this.rawRegisteredEntities,
142
- this.entitiesTranslations,
143
- this.entitiesConfig
144
- );
204
+ if(!this.useProvidedDataServer){
205
+ if(!await this.initializeDataServer()){
206
+ return false;
207
+ }
208
+ }
209
+ if(!this.loadProcessedEntities()){
210
+ return false;
211
+ }
212
+ if(!await this.generateAdminEntities()){
213
+ return false;
214
+ }
215
+ if(!this.useProvidedAdminManager){
216
+ if(!await this.initializeAdminManager()){
217
+ return false;
145
218
  }
146
- if(!this.processedEntities.entities){
147
- Logger.critical('Processed entities undefined.');
219
+ }
220
+ if(!this.useProvidedFrontend){
221
+ if(!await this.initializeFrontend()){
148
222
  return false;
149
223
  }
150
- await this.dataServer.generateEntities();
151
- this.adminEntities = this.adminEntitiesGenerator.generate(
152
- this.processedEntities.entities,
153
- this.dataServer.entityManager.entities
224
+ }
225
+ if(!this.useProvidedServer){
226
+ await this.appServer.listen(this.config.port);
227
+ }
228
+ return true;
229
+ }
230
+
231
+ loadProcessedEntities()
232
+ {
233
+ if(0 === Object.keys(this.processedEntities).length){
234
+ this.processedEntities = LoadedEntitiesProcessor.process(
235
+ this.rawRegisteredEntities,
236
+ this.entitiesTranslations,
237
+ this.entitiesConfig
154
238
  );
155
239
  }
156
- await this.initializeAdminManager();
157
- await this.initializeFrontend();
158
- await this.appServer.listen(this.config.port);
240
+ if(!this.processedEntities?.entities){
241
+ Logger.critical('Processed entities undefined.');
242
+ return false;
243
+ }
244
+ return true;
245
+ }
246
+
247
+ async generateAdminEntities()
248
+ {
249
+ if(0 < Object.keys(this.adminEntities).length){
250
+ return true;
251
+ }
252
+ if(!this.dataServer.rawEntities && this.rawRegisteredEntities){
253
+ this.dataServer.rawEntities = this.rawRegisteredEntities;
254
+ }
255
+ Logger.debug('Generate entities count: '+Object.keys(this.rawRegisteredEntities).length);
256
+ await this.dataServer.generateEntities();
257
+ this.adminEntities = this.adminEntitiesGenerator.generate(
258
+ this.processedEntities.entities,
259
+ this.dataServer.entityManager.entities
260
+ );
261
+ if(0 === Object.keys(this.adminEntities).length){
262
+ Logger.warning('Admin entities not found.');
263
+ return false;
264
+ }
265
+ return true;
159
266
  }
160
267
 
161
268
  async initializeDataServer()
@@ -181,6 +288,7 @@ class Manager
181
288
  Logger.critical('Failed to connect to database.');
182
289
  return false;
183
290
  }
291
+ Logger.debug('Entities count: '+Object.keys(this.rawRegisteredEntities).length);
184
292
  await this.dataServer.generateEntities();
185
293
  return true;
186
294
  }
@@ -0,0 +1,10 @@
1
+
2
+ -- Default homepage:
3
+
4
+ -- Create a default homepage route if not exists
5
+ REPLACE INTO `cms_pages` (`id`, `title`, `content`, `template`, `created_at`) VALUES
6
+ (1, 'Home', '<h1>Welcome to Reldens CMS</h1><p>This is your homepage. Edit this content in the admin panel.</p>', 'page', NOW());
7
+
8
+ -- Create a default route to the homepage
9
+ REPLACE INTO `routes` (`id`, `path`, `router`, `content_id`, `title`, `meta_description`, `status`, `created_at`) VALUES
10
+ (1, '/home', 'cmsPages', 1, 'Home', 'Welcome to Reldens CMS', 'published', NOW());
@@ -1,19 +1,5 @@
1
1
 
2
- -- Install SQL for Reldens CMS
3
-
4
- CREATE TABLE IF NOT EXISTS `users` (
5
- `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
6
- `email` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
7
- `username` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
8
- `password` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
9
- `role_id` INT(10) UNSIGNED NOT NULL,
10
- `status` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
11
- `created_at` TIMESTAMP NOT NULL DEFAULT (NOW()),
12
- `updated_at` TIMESTAMP NOT NULL DEFAULT (NOW()) ON UPDATE CURRENT_TIMESTAMP,
13
- PRIMARY KEY (`id`) USING BTREE,
14
- UNIQUE KEY `email` (`email`) USING BTREE,
15
- UNIQUE KEY `username` (`username`) USING BTREE
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
2
+ -- Install Reldens CMS
17
3
 
18
4
  CREATE TABLE IF NOT EXISTS `routes` (
19
5
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@@ -74,11 +60,3 @@ CREATE TABLE IF NOT EXISTS `entities_meta` (
74
60
  PRIMARY KEY (`id`) USING BTREE,
75
61
  UNIQUE KEY `entity_meta` (`entity_name`, `entity_id`, `meta_key`) USING BTREE
76
62
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
77
-
78
- -- Create a default homepage route if not exists
79
- INSERT IGNORE INTO `cms_pages` (`id`, `title`, `content`, `template`, `created_at`) VALUES
80
- (1, 'Home', '<h1>Welcome to Reldens CMS</h1><p>This is your homepage. Edit this content in the admin panel.</p>', 'page', NOW());
81
-
82
- -- Create a default route to the homepage
83
- INSERT IGNORE INTO `routes` (`path`, `router`, `content_id`, `title`, `meta_description`, `status`, `created_at`) VALUES
84
- ('/home', 'cms_pages', 1, 'Home', 'Welcome to Reldens CMS', 'published', NOW());
@@ -0,0 +1,16 @@
1
+
2
+ -- Default db-users authentication:
3
+
4
+ CREATE TABLE IF NOT EXISTS `users` (
5
+ `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
6
+ `email` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
7
+ `username` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
8
+ `password` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
9
+ `role_id` INT(10) UNSIGNED NOT NULL,
10
+ `status` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
11
+ `created_at` TIMESTAMP NOT NULL DEFAULT (NOW()),
12
+ `updated_at` TIMESTAMP NOT NULL DEFAULT (NOW()) ON UPDATE CURRENT_TIMESTAMP,
13
+ PRIMARY KEY (`id`) USING BTREE,
14
+ UNIQUE KEY `email` (`email`) USING BTREE,
15
+ UNIQUE KEY `username` (`username`) USING BTREE
16
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reldens/cms",
3
3
  "scope": "@reldens",
4
- "version": "0.7.0",
4
+ "version": "0.9.0",
5
5
  "description": "Reldens - CMS",
6
6
  "author": "Damian A. Pastorini",
7
7
  "license": "MIT",
@@ -32,8 +32,8 @@
32
32
  "url": "https://github.com/damian-pastorini/reldens-cms/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@reldens/server-utils": "^0.16.0",
36
- "@reldens/storage": "^0.44.0",
35
+ "@reldens/server-utils": "^0.17.0",
36
+ "@reldens/storage": "^0.45.0",
37
37
  "@reldens/utils": "^0.47.0",
38
38
  "dotenv": "^16.5.0",
39
39
  "mustache": "^4.2.0"
@@ -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_DB_CLIENT={{&dbClient}}
3
+ RELDENS_DB_HOST={{&dbHost}}
4
+ RELDENS_DB_PORT={{&dbPort}}
5
+ RELDENS_DB_NAME={{&dbName}}
6
+ RELDENS_DB_USER={{&dbUser}}
7
+ RELDENS_DB_PASSWORD={{&dbPassword}}
8
+ RELDENS_DB_DRIVER={{&dbDriver}}
9
9
 
10
10
  # Admin Panel Configuration
11
- RELDENS_CMS_ADMIN_PATH={{&adminPath}}
12
- RELDENS_CMS_ADMIN_SECRET={{&adminSecret}}
11
+ RELDENS_ADMIN_ROUTE_PATH={{&adminPath}}
12
+ RELDENS_ADMIN_SECRET={{&adminSecret}}
13
13
 
14
14
  # Server Configuration
15
- RELDENS_CMS_HOST={{&host}}
16
- RELDENS_CMS_PORT={{&port}}
15
+ RELDENS_APP_HOST={{&host}}
16
+ RELDENS_APP_PORT={{&port}}