mwalajs 1.1.2 → 1.1.4

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 (62) hide show
  1. package/LICENSE +20 -20
  2. package/bin/backupnewclean.js +162 -162
  3. package/bin/mwala copy.mjs +177 -212
  4. package/bin/mwala.mjs +420 -345
  5. package/config/createTablesetdb.mjs +38 -38
  6. package/config/createdatabase copy.mjs +157 -362
  7. package/config/createdatabase.mjs +204 -204
  8. package/config/serverConfig.mjs +1 -1
  9. package/controllers/fileController.mjs +15 -15
  10. package/controllers/homeController.mjs +28 -28
  11. package/createProject.mjs +120 -120
  12. package/index.js +109 -109
  13. package/index.mjs +109 -109
  14. package/migrations/20250308115724_create_users.mjs +45 -45
  15. package/migrations/20250724111240_create_transactions.mjs +18 -18
  16. package/models/exampleModel.mjs +5 -5
  17. package/mwala +5 -5
  18. package/mwala.cmd +1 -1
  19. package/package.json +6 -5
  20. package/public/styles.css +115 -115
  21. package/routes/homeRoutes.mjs +12 -12
  22. package/setupMwalajs copy.mjs +58 -0
  23. package/ujasi/README.md +542 -0
  24. package/ujasi/app.mjs +33 -0
  25. package/ujasi/bin/backupnewclean.js +162 -0
  26. package/ujasi/bin/mwala.mjs +176 -0
  27. package/ujasi/config/createTablesetdb.mjs +38 -0
  28. package/ujasi/config/createdatabase.mjs +156 -0
  29. package/ujasi/config/serverConfig.mjs +1 -0
  30. package/ujasi/controllers/fileController.mjs +15 -0
  31. package/ujasi/controllers/homeController.mjs +28 -0
  32. package/ujasi/models/exampleModel.mjs +5 -0
  33. package/ujasi/mwalajs/index.js +109 -0
  34. package/ujasi/mwalajs/index.mjs +121 -0
  35. package/ujasi/mwalajs/package.json +16 -0
  36. package/ujasi/package.json +58 -0
  37. package/ujasi/public/styles.css +115 -0
  38. package/ujasi/routes/homeRoutes.mjs +12 -0
  39. package/ujasi/runMigrations.mjs +137 -0
  40. package/ujasi/setupMwalajs.mjs +58 -0
  41. package/ujasi/views/about.ejs +159 -0
  42. package/ujasi/views/index.ejs +227 -0
  43. package/ujasi/views/sitemap.xml +1 -0
  44. package/ujasi/views/steps.ejs +514 -0
  45. package/ujasi/views/welcome.ejs +257 -0
  46. package/views/about.ejs +159 -294
  47. package/views/index.ejs +179 -348
  48. package/views/sitemap.xml +1 -1
  49. package/views/steps.ejs +514 -240
  50. package/views/welcome.ejs +257 -315
  51. package/.automate/config.json +0 -10
  52. package/.env.backup-2025-12-04T08-55-09-593Z +0 -5
  53. package/public/images/hekima-mwala.jpg +0 -0
  54. package/public/images/hekima-mwala2.jpg +0 -0
  55. package/public/images/mwala3.jpg +0 -0
  56. package/public/images/mwalajs.jpg +0 -0
  57. package/public/images/mwalajs1.jpg +0 -0
  58. package/utils/dbUtils.mjs +0 -545
  59. package/views/mwalajs-framework-documentation.ejs +0 -778
  60. package/views/partials/footer.ejs +0 -102
  61. package/views/partials/header.ejs +0 -160
  62. package/views/steps copy.ejs +0 -243
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 HEKIMA MWALA
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2025 HEKIMA MWALA
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
@@ -1,162 +1,162 @@
1
-
2
- import { execSync } from 'child_process';
3
- import fs from 'fs';
4
- import path from 'path';
5
- import { fileURLToPath, pathToFileURL } from 'url';
6
-
7
- const __filename = fileURLToPath(import.meta.url);
8
- const __dirname = path.dirname(__filename);
9
-
10
- // Dynamically import modules using relative paths
11
- const { getDbConnection } = await import(pathToFileURL(path.join(__dirname, '../config/createdatabase.mjs')).href);
12
- const { createTable, dropTable, migrateAll, rollbackLastMigration } = await import(pathToFileURL(path.join(__dirname, '../runMigrations.mjs')).href);
13
- const { setupMwalajs } = await import(pathToFileURL(path.join(__dirname, '../setupMwalajs.mjs')).href);
14
-
15
- const args = process.argv.slice(2);
16
- const command = args[0];
17
-
18
- if (!command || command === 'help' || command === 'h') {
19
- console.log(`
20
- MwalaJS CLI - List of Commands:
21
-
22
- General:
23
- - mwala -v | --version → Show the version.
24
- - mwala help | h → Show this help.
25
-
26
- Project Management:
27
- - mwala create-project → Create a new MwalaJS project.
28
- - mwala init → Initialize MwalaJS.
29
-
30
- Running App:
31
- - mwala serve | app.mjs → Start the MwalaJS application.
32
-
33
- Database:
34
- - mwala create-db → Create the database.
35
- - mwala create-table <name> → Create a table.
36
- - mwala drop-table <name> → Drop a table.
37
- - mwala migrate all → Run all migrations.
38
- - mwala rollback all → Roll back last migration.
39
-
40
- Code Generation:
41
- - mwala generate model <name>
42
- - mwala generate controller <name>
43
- - mwala generate route <name>
44
- - mwala generate view <name>
45
- - mwala generate midware <name>
46
- `);
47
- process.exit(0);
48
- }
49
-
50
- switch (command) {
51
- case 'version':
52
- case '-v':
53
- case '--version':
54
- console.log('MwalaJS Version: 1.0.0');
55
- process.exit(0);
56
-
57
- case 'create-project':
58
- console.log('Project creation logic goes here.');
59
- // await createProject(); // Uncomment when implemented
60
- break;
61
-
62
- case 'serve':
63
- case 'app.mjs':
64
- try {
65
- execSync('node app.mjs', { stdio: 'inherit' });
66
- } catch (err) {
67
- console.error(`Failed to start app: ${err.message}`);
68
- process.exit(1);
69
- }
70
- break;
71
-
72
- case 'init':
73
- setupMwalajs();
74
- break;
75
-
76
- case 'generate': {
77
- const subCommand = args[1]?.toLowerCase();
78
- const name = args[2];
79
-
80
- if (!subCommand || !name) {
81
- console.error('Specify both type and name: mwala generate <type> <name>');
82
- process.exit(1);
83
- }
84
-
85
- const map = {
86
- model: 'models',
87
- controller: 'controllers',
88
- route: 'routes',
89
- view: 'views',
90
- midware: 'middlewares'
91
- };
92
-
93
- if (!map[subCommand]) {
94
- console.error(`Unknown type '${subCommand}'. Use: ${Object.keys(map).join(', ')}`);
95
- process.exit(1);
96
- }
97
-
98
- const filePath = path.join(process.cwd(), map[subCommand], `${name}.mjs`);
99
- if (fs.existsSync(filePath)) {
100
- console.log(`${subCommand} "${name}" already exists.`);
101
- process.exit(1);
102
- }
103
-
104
- const templates = {
105
- model: `export const ${name}Model = {};`,
106
- controller: `export const ${name}Controller = { get${name}Page: (req, res) => res.render('${name}', { title: '${name} Page' }) };`,
107
- route: `import mwalajs from 'mwalajs';\nimport { ${name}Controller } from '../controllers/${name}Controller.mjs';\nconst router = mwalajs.Router();\nrouter.get('/', ${name}Controller.get${name}Page);\nexport { router as ${name}Route };`,
108
- view: `<!DOCTYPE html>\n<html lang="en">\n<head><meta charset="UTF-8"><title>${name} Page</title></head>\n<body>\n<h1>${name} View Page</h1>\n</body>\n</html>`,
109
- midware: `export const ${name} = (req, res, next) => { next(); };`
110
- };
111
-
112
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
113
- fs.writeFileSync(filePath, templates[subCommand]);
114
- console.log(`${subCommand} "${name}" created at ${filePath}`);
115
- break;
116
- }
117
-
118
- case 'create-db':
119
- getDbConnection().then(() => console.log('Database created.')).catch(err => {
120
- console.error(`Database error: ${err.message}`);
121
- process.exit(1);
122
- });
123
- break;
124
-
125
- case 'create-table':
126
- if (!args[1]) {
127
- console.error('Specify table name.');
128
- process.exit(1);
129
- }
130
- createTable(args[1]);
131
- break;
132
-
133
- case 'drop-table':
134
- if (!args[1]) {
135
- console.error('Specify table name.');
136
- process.exit(1);
137
- }
138
- dropTable(args[1]);
139
- break;
140
-
141
- case 'migrate':
142
- if (args[1] === 'all') {
143
- migrateAll();
144
- } else {
145
- console.error('Use: mwala migrate all');
146
- process.exit(1);
147
- }
148
- break;
149
-
150
- case 'rollback':
151
- if (args[1] === 'all') {
152
- rollbackLastMigration();
153
- } else {
154
- console.error('Use: mwala rollback all');
155
- process.exit(1);
156
- }
157
- break;
158
-
159
- default:
160
- console.error(`Unknown command: "${command}". Run "mwala help" for options.`);
161
- process.exit(1);
162
- }
1
+
2
+ import { execSync } from 'child_process';
3
+ import fs from 'fs';
4
+ import path from 'path';
5
+ import { fileURLToPath, pathToFileURL } from 'url';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+
10
+ // Dynamically import modules using relative paths
11
+ const { getDbConnection } = await import(pathToFileURL(path.join(__dirname, '../config/createdatabase.mjs')).href);
12
+ const { createTable, dropTable, migrateAll, rollbackLastMigration } = await import(pathToFileURL(path.join(__dirname, '../runMigrations.mjs')).href);
13
+ const { setupMwalajs } = await import(pathToFileURL(path.join(__dirname, '../setupMwalajs.mjs')).href);
14
+
15
+ const args = process.argv.slice(2);
16
+ const command = args[0];
17
+
18
+ if (!command || command === 'help' || command === 'h') {
19
+ console.log(`
20
+ MwalaJS CLI - List of Commands:
21
+
22
+ General:
23
+ - mwala -v | --version → Show the version.
24
+ - mwala help | h → Show this help.
25
+
26
+ Project Management:
27
+ - mwala create-project → Create a new MwalaJS project.
28
+ - mwala init → Initialize MwalaJS.
29
+
30
+ Running App:
31
+ - mwala serve | app.mjs → Start the MwalaJS application.
32
+
33
+ Database:
34
+ - mwala create-db → Create the database.
35
+ - mwala create-table <name> → Create a table.
36
+ - mwala drop-table <name> → Drop a table.
37
+ - mwala migrate all → Run all migrations.
38
+ - mwala rollback all → Roll back last migration.
39
+
40
+ Code Generation:
41
+ - mwala generate model <name>
42
+ - mwala generate controller <name>
43
+ - mwala generate route <name>
44
+ - mwala generate view <name>
45
+ - mwala generate midware <name>
46
+ `);
47
+ process.exit(0);
48
+ }
49
+
50
+ switch (command) {
51
+ case 'version':
52
+ case '-v':
53
+ case '--version':
54
+ console.log('MwalaJS Version: 1.0.0');
55
+ process.exit(0);
56
+
57
+ case 'create-project':
58
+ console.log('Project creation logic goes here.');
59
+ // await createProject(); // Uncomment when implemented
60
+ break;
61
+
62
+ case 'serve':
63
+ case 'app.mjs':
64
+ try {
65
+ execSync('node app.mjs', { stdio: 'inherit' });
66
+ } catch (err) {
67
+ console.error(`Failed to start app: ${err.message}`);
68
+ process.exit(1);
69
+ }
70
+ break;
71
+
72
+ case 'init':
73
+ setupMwalajs();
74
+ break;
75
+
76
+ case 'generate': {
77
+ const subCommand = args[1]?.toLowerCase();
78
+ const name = args[2];
79
+
80
+ if (!subCommand || !name) {
81
+ console.error('Specify both type and name: mwala generate <type> <name>');
82
+ process.exit(1);
83
+ }
84
+
85
+ const map = {
86
+ model: 'models',
87
+ controller: 'controllers',
88
+ route: 'routes',
89
+ view: 'views',
90
+ midware: 'middlewares'
91
+ };
92
+
93
+ if (!map[subCommand]) {
94
+ console.error(`Unknown type '${subCommand}'. Use: ${Object.keys(map).join(', ')}`);
95
+ process.exit(1);
96
+ }
97
+
98
+ const filePath = path.join(process.cwd(), map[subCommand], `${name}.mjs`);
99
+ if (fs.existsSync(filePath)) {
100
+ console.log(`${subCommand} "${name}" already exists.`);
101
+ process.exit(1);
102
+ }
103
+
104
+ const templates = {
105
+ model: `export const ${name}Model = {};`,
106
+ controller: `export const ${name}Controller = { get${name}Page: (req, res) => res.render('${name}', { title: '${name} Page' }) };`,
107
+ route: `import mwalajs from 'mwalajs';\nimport { ${name}Controller } from '../controllers/${name}Controller.mjs';\nconst router = mwalajs.Router();\nrouter.get('/', ${name}Controller.get${name}Page);\nexport { router as ${name}Route };`,
108
+ view: `<!DOCTYPE html>\n<html lang="en">\n<head><meta charset="UTF-8"><title>${name} Page</title></head>\n<body>\n<h1>${name} View Page</h1>\n</body>\n</html>`,
109
+ midware: `export const ${name} = (req, res, next) => { next(); };`
110
+ };
111
+
112
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
113
+ fs.writeFileSync(filePath, templates[subCommand]);
114
+ console.log(`${subCommand} "${name}" created at ${filePath}`);
115
+ break;
116
+ }
117
+
118
+ case 'create-db':
119
+ getDbConnection().then(() => console.log('Database created.')).catch(err => {
120
+ console.error(`Database error: ${err.message}`);
121
+ process.exit(1);
122
+ });
123
+ break;
124
+
125
+ case 'create-table':
126
+ if (!args[1]) {
127
+ console.error('Specify table name.');
128
+ process.exit(1);
129
+ }
130
+ createTable(args[1]);
131
+ break;
132
+
133
+ case 'drop-table':
134
+ if (!args[1]) {
135
+ console.error('Specify table name.');
136
+ process.exit(1);
137
+ }
138
+ dropTable(args[1]);
139
+ break;
140
+
141
+ case 'migrate':
142
+ if (args[1] === 'all') {
143
+ migrateAll();
144
+ } else {
145
+ console.error('Use: mwala migrate all');
146
+ process.exit(1);
147
+ }
148
+ break;
149
+
150
+ case 'rollback':
151
+ if (args[1] === 'all') {
152
+ rollbackLastMigration();
153
+ } else {
154
+ console.error('Use: mwala rollback all');
155
+ process.exit(1);
156
+ }
157
+ break;
158
+
159
+ default:
160
+ console.error(`Unknown command: "${command}". Run "mwala help" for options.`);
161
+ process.exit(1);
162
+ }