@bejibun/core 0.1.46 → 0.1.47

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/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  ---
5
5
 
6
+ ## [v0.1.47](https://github.com/crenata/bejibun-core/compare/v0.1.44...v0.1.47) - 2025-10-26
7
+
8
+ ### 🩹 Fixes
9
+
10
+ ### 📖 Changes
11
+ What's New :
12
+ - Adding `make:command <file>` to create a new command file
13
+ - Adding `make:controller <file>` to create a new controller file
14
+ - Adding `make:middleware <file>` to create a new middleware file
15
+
16
+ ### ❤️Contributors
17
+ - Havea Crenata ([@crenata](https://github.com/crenata))
18
+ - Ghulje ([@ghulje](https://github.com/ghulje))
19
+
20
+ **Full Changelog**: https://github.com/crenata/bejibun-core/blob/master/CHANGELOG.md
21
+
22
+ ---
23
+
6
24
  ## [v0.1.44](https://github.com/crenata/bejibun-core/compare/v0.1.43...v0.1.44) - 2025-10-22
7
25
 
8
26
  ### 🩹 Fixes
package/README.md CHANGED
@@ -41,6 +41,9 @@ Commands:
41
41
  install <packages...> Install package dependencies
42
42
  maintenance:down [options] Turn app into maintenance mode
43
43
  maintenance:up Turn app into live mode
44
+ make:command <file> Create a new command file
45
+ make:controller <file> Create a new controller file
46
+ make:middleware <file> Create a new middleware file
44
47
  make:migration <file> Create a new migration file
45
48
  make:seeder <file> Create a new seeder file
46
49
  migrate:fresh [options] Rollback all migrations and re-run migrations
@@ -0,0 +1,27 @@
1
+ export default class MakeCommandCommand {
2
+ /**
3
+ * The name and signature of the console command.
4
+ *
5
+ * @var $signature string
6
+ */
7
+ protected $signature: string;
8
+ /**
9
+ * The console command description.
10
+ *
11
+ * @var $description string
12
+ */
13
+ protected $description: string;
14
+ /**
15
+ * The options or optional flag of the console command.
16
+ *
17
+ * @var $options Array<Array<any>>
18
+ */
19
+ protected $options: Array<Array<any>>;
20
+ /**
21
+ * The arguments of the console command.
22
+ *
23
+ * @var $arguments Array<Array<string>>
24
+ */
25
+ protected $arguments: Array<Array<string>>;
26
+ handle(options: any, args: string): Promise<void>;
27
+ }
@@ -0,0 +1,51 @@
1
+ import App from "@bejibun/app";
2
+ import Logger from "@bejibun/logger";
3
+ import { isEmpty } from "@bejibun/utils";
4
+ import Str from "@bejibun/utils/facades/Str";
5
+ import path from "path";
6
+ export default class MakeCommandCommand {
7
+ /**
8
+ * The name and signature of the console command.
9
+ *
10
+ * @var $signature string
11
+ */
12
+ $signature = "make:command";
13
+ /**
14
+ * The console command description.
15
+ *
16
+ * @var $description string
17
+ */
18
+ $description = "Create a new command file";
19
+ /**
20
+ * The options or optional flag of the console command.
21
+ *
22
+ * @var $options Array<Array<any>>
23
+ */
24
+ $options = [];
25
+ /**
26
+ * The arguments of the console command.
27
+ *
28
+ * @var $arguments Array<Array<string>>
29
+ */
30
+ $arguments = [
31
+ ["<file>", "The name of the command file"]
32
+ ];
33
+ async handle(options, args) {
34
+ if (isEmpty(args)) {
35
+ Logger.setContext("APP").error("There is no filename provided.");
36
+ return;
37
+ }
38
+ const file = args;
39
+ const commandsDirectory = "commands";
40
+ const template = Bun.file(path.resolve(__dirname, `../../stubs/${commandsDirectory}/TemplateCommand.ts`));
41
+ if (!await template.exists()) {
42
+ Logger.setContext("APP").error("Whoops, something went wrong, the command template not found.");
43
+ return;
44
+ }
45
+ const name = Str.toPascalCase(file.replace(/\s+/g, "").replace(/command/gi, ""));
46
+ const destination = `${name}Command.ts`;
47
+ const content = await template.text();
48
+ await Bun.write(App.Path.commandsPath(destination), content.replace(/template/gi, name));
49
+ Logger.setContext("APP").info(`Command [commands/${destination}] created successfully.`);
50
+ }
51
+ }
@@ -0,0 +1,27 @@
1
+ export default class MakeControllerCommand {
2
+ /**
3
+ * The name and signature of the console command.
4
+ *
5
+ * @var $signature string
6
+ */
7
+ protected $signature: string;
8
+ /**
9
+ * The console command description.
10
+ *
11
+ * @var $description string
12
+ */
13
+ protected $description: string;
14
+ /**
15
+ * The options or optional flag of the console command.
16
+ *
17
+ * @var $options Array<Array<any>>
18
+ */
19
+ protected $options: Array<Array<any>>;
20
+ /**
21
+ * The arguments of the console command.
22
+ *
23
+ * @var $arguments Array<Array<string>>
24
+ */
25
+ protected $arguments: Array<Array<string>>;
26
+ handle(options: any, args: string): Promise<void>;
27
+ }
@@ -0,0 +1,51 @@
1
+ import App from "@bejibun/app";
2
+ import Logger from "@bejibun/logger";
3
+ import { isEmpty } from "@bejibun/utils";
4
+ import Str from "@bejibun/utils/facades/Str";
5
+ import path from "path";
6
+ export default class MakeControllerCommand {
7
+ /**
8
+ * The name and signature of the console command.
9
+ *
10
+ * @var $signature string
11
+ */
12
+ $signature = "make:controller";
13
+ /**
14
+ * The console command description.
15
+ *
16
+ * @var $description string
17
+ */
18
+ $description = "Create a new controller file";
19
+ /**
20
+ * The options or optional flag of the console command.
21
+ *
22
+ * @var $options Array<Array<any>>
23
+ */
24
+ $options = [];
25
+ /**
26
+ * The arguments of the console command.
27
+ *
28
+ * @var $arguments Array<Array<string>>
29
+ */
30
+ $arguments = [
31
+ ["<file>", "The name of the controller file"]
32
+ ];
33
+ async handle(options, args) {
34
+ if (isEmpty(args)) {
35
+ Logger.setContext("APP").error("There is no filename provided.");
36
+ return;
37
+ }
38
+ const file = args;
39
+ const controllersDirectory = "controllers";
40
+ const template = Bun.file(path.resolve(__dirname, `../../stubs/${controllersDirectory}/TemplateController.ts`));
41
+ if (!await template.exists()) {
42
+ Logger.setContext("APP").error("Whoops, something went wrong, the controller template not found.");
43
+ return;
44
+ }
45
+ const name = Str.toPascalCase(file.replace(/\s+/g, "").replace(/controller/gi, ""));
46
+ const destination = `${name}Controller.ts`;
47
+ const content = await template.text();
48
+ await Bun.write(App.Path.controllersPath(destination), content.replace(/template/gi, name));
49
+ Logger.setContext("APP").info(`Controller [app/controllers/${destination}] created successfully.`);
50
+ }
51
+ }
@@ -0,0 +1,27 @@
1
+ export default class MakeMiddlewareCommand {
2
+ /**
3
+ * The name and signature of the console command.
4
+ *
5
+ * @var $signature string
6
+ */
7
+ protected $signature: string;
8
+ /**
9
+ * The console command description.
10
+ *
11
+ * @var $description string
12
+ */
13
+ protected $description: string;
14
+ /**
15
+ * The options or optional flag of the console command.
16
+ *
17
+ * @var $options Array<Array<any>>
18
+ */
19
+ protected $options: Array<Array<any>>;
20
+ /**
21
+ * The arguments of the console command.
22
+ *
23
+ * @var $arguments Array<Array<string>>
24
+ */
25
+ protected $arguments: Array<Array<string>>;
26
+ handle(options: any, args: string): Promise<void>;
27
+ }
@@ -0,0 +1,51 @@
1
+ import App from "@bejibun/app";
2
+ import Logger from "@bejibun/logger";
3
+ import { isEmpty } from "@bejibun/utils";
4
+ import Str from "@bejibun/utils/facades/Str";
5
+ import path from "path";
6
+ export default class MakeMiddlewareCommand {
7
+ /**
8
+ * The name and signature of the console command.
9
+ *
10
+ * @var $signature string
11
+ */
12
+ $signature = "make:middleware";
13
+ /**
14
+ * The console command description.
15
+ *
16
+ * @var $description string
17
+ */
18
+ $description = "Create a new middleware file";
19
+ /**
20
+ * The options or optional flag of the console command.
21
+ *
22
+ * @var $options Array<Array<any>>
23
+ */
24
+ $options = [];
25
+ /**
26
+ * The arguments of the console command.
27
+ *
28
+ * @var $arguments Array<Array<string>>
29
+ */
30
+ $arguments = [
31
+ ["<file>", "The name of the middleware file"]
32
+ ];
33
+ async handle(options, args) {
34
+ if (isEmpty(args)) {
35
+ Logger.setContext("APP").error("There is no filename provided.");
36
+ return;
37
+ }
38
+ const file = args;
39
+ const middlewaresDirectory = "middlewares";
40
+ const template = Bun.file(path.resolve(__dirname, `../../stubs/${middlewaresDirectory}/TemplateMiddleware.ts`));
41
+ if (!await template.exists()) {
42
+ Logger.setContext("APP").error("Whoops, something went wrong, the middleware template not found.");
43
+ return;
44
+ }
45
+ const name = Str.toPascalCase(file.replace(/\s+/g, "").replace(/middleware/gi, ""));
46
+ const destination = `${name}Middleware.ts`;
47
+ const content = await template.text();
48
+ await Bun.write(App.Path.middlewaresPath(destination), content.replace(/template/gi, name));
49
+ Logger.setContext("APP").info(`Middleware [app/middlewares/${destination}] created successfully.`);
50
+ }
51
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bejibun/core",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "author": "Havea Crenata <havea.crenata@gmail.com>",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,9 +9,9 @@
9
9
  "main": "index.js",
10
10
  "module": "index.js",
11
11
  "dependencies": {
12
- "@bejibun/app": "^0.1.19",
12
+ "@bejibun/app": "^0.1.20",
13
13
  "@bejibun/cors": "^0.1.14",
14
- "@bejibun/database": "^0.1.14",
14
+ "@bejibun/database": "^0.1.16",
15
15
  "@bejibun/logger": "^0.1.19",
16
16
  "@bejibun/utils": "^0.1.17",
17
17
  "@vinejs/vine": "^3.0.1",
@@ -39,10 +39,12 @@
39
39
  "license": "MIT",
40
40
  "scripts": {
41
41
  "alias": "bunx tsc-alias -p tsconfig.json",
42
- "copy": "cp -rf src/types dist",
42
+ "clean-stubs": "rm -rf stubs",
43
+ "stubs": "cp -rf src/stubs dist",
44
+ "types": "cp -rf src/types dist",
43
45
  "rsync": "rsync -a dist/ ./",
44
46
  "clean": "rm -rf dist",
45
- "build": "bunx tsc -p tsconfig.json && bun run copy && bun run alias && bun run rsync && bun run clean",
47
+ "build": "bun run clean-stubs && bunx tsc -p tsconfig.json && bun run types && bun run alias && bun run stubs && bun run rsync && bun run clean",
46
48
  "deploy": "bun run build && bun publish --access public"
47
49
  },
48
50
  "type": "module",
@@ -0,0 +1,33 @@
1
+ export default class TemplateCommand {
2
+ /**
3
+ * The name and signature of the console command.
4
+ *
5
+ * @var $signature string
6
+ */
7
+ protected $signature: string = "your:command";
8
+
9
+ /**
10
+ * The console command description.
11
+ *
12
+ * @var $description string
13
+ */
14
+ protected $description: string = "Your command description";
15
+
16
+ /**
17
+ * The options or optional flag of the console command.
18
+ *
19
+ * @var $options Array<Array<any>>
20
+ */
21
+ protected $options: Array<Array<any>> = [];
22
+
23
+ /**
24
+ * The arguments of the console command.
25
+ *
26
+ * @var $arguments Array<Array<any>>
27
+ */
28
+ protected $arguments: Array<Array<any>> = [];
29
+
30
+ public async handle(options: any, args: any): Promise<void> {
31
+ // Your code goes here
32
+ }
33
+ }
@@ -0,0 +1,23 @@
1
+ import BaseController from "@bejibun/core/bases/BaseController";
2
+
3
+ export default class TemplateController extends BaseController {
4
+ public async index(request: Bun.BunRequest): Promise<Response> {
5
+ return super.response.setData().send();
6
+ }
7
+
8
+ public async store(request: Bun.BunRequest): Promise<Response> {
9
+ return super.response.setData().send();
10
+ }
11
+
12
+ public async show(request: Bun.BunRequest): Promise<Response> {
13
+ return super.response.setData().send();
14
+ }
15
+
16
+ public async update(request: Bun.BunRequest): Promise<Response> {
17
+ return super.response.setData().send();
18
+ }
19
+
20
+ public async destroy(request: Bun.BunRequest): Promise<Response> {
21
+ return super.response.setData().send();
22
+ }
23
+ }
@@ -0,0 +1,11 @@
1
+ import type {HandlerType} from "@bejibun/core/types";
2
+
3
+ export default class TemplateMiddleware {
4
+ public handle(handler: HandlerType): HandlerType {
5
+ return async (request: Bun.BunRequest) => {
6
+ // Your code goes here
7
+
8
+ return handler(request);
9
+ };
10
+ }
11
+ }
package/tsconfig.json CHANGED
@@ -13,5 +13,6 @@
13
13
  "paths": {
14
14
  "@/*": ["src/*"]
15
15
  }
16
- }
16
+ },
17
+ "exclude": ["src/stubs"]
17
18
  }