@h3ravel/console 11.0.7 → 11.2.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 (119) hide show
  1. package/bin/fire.cjs +2 -0
  2. package/bin/fire.js +2 -0
  3. package/dist/Utils-CpiQZ3n9.cjs +122 -0
  4. package/dist/Utils-CpiQZ3n9.cjs.map +1 -0
  5. package/dist/Utils-Dvclc4Pc.js +73 -0
  6. package/dist/Utils-Dvclc4Pc.js.map +1 -0
  7. package/dist/Utils-cBgwEyTl.d.ts +20 -0
  8. package/dist/Utils-rIdzILgO.d.cts +20 -0
  9. package/dist/Utils.cjs +3 -217
  10. package/dist/Utils.d.cts +2 -0
  11. package/dist/Utils.d.ts +2 -0
  12. package/dist/Utils.js +3 -9
  13. package/dist/index.cjs +790 -949
  14. package/dist/index.cjs.map +1 -0
  15. package/dist/index.d.cts +173 -295
  16. package/dist/index.d.ts +173 -295
  17. package/dist/index.js +789 -44
  18. package/dist/index.js.map +1 -0
  19. package/package.json +35 -23
  20. package/bin/chunk-6Z5DP356.js +0 -1
  21. package/bin/lexer-DQCqS3nf-XQPNMZG6.js +0 -4
  22. package/bin/run.cjs +0 -26
  23. package/bin/run.js +0 -26
  24. package/dist/Commands/Command.cjs +0 -104
  25. package/dist/Commands/Command.js +0 -7
  26. package/dist/Commands/MakeCommand.cjs +0 -433
  27. package/dist/Commands/MakeCommand.js +0 -9
  28. package/dist/Commands/MigrateCommand.cjs +0 -200
  29. package/dist/Commands/MigrateCommand.js +0 -8
  30. package/dist/Commands/ServeCommand.cjs +0 -159
  31. package/dist/Commands/ServeCommand.js +0 -8
  32. package/dist/Contracts/ICommand.cjs +0 -18
  33. package/dist/Contracts/ICommand.js +0 -1
  34. package/dist/IO/app.cjs +0 -946
  35. package/dist/IO/app.js +0 -17
  36. package/dist/IO/providers.cjs +0 -930
  37. package/dist/IO/providers.js +0 -16
  38. package/dist/Kernel.cjs +0 -890
  39. package/dist/Kernel.js +0 -14
  40. package/dist/Musket.cjs +0 -835
  41. package/dist/Musket.js +0 -13
  42. package/dist/Providers/ConsoleServiceProvider.cjs +0 -912
  43. package/dist/Providers/ConsoleServiceProvider.js +0 -15
  44. package/dist/Signature.cjs +0 -172
  45. package/dist/Signature.js +0 -7
  46. package/dist/chunk-23QH5R54.js +0 -27
  47. package/dist/chunk-2O2AYFAG.js +0 -63
  48. package/dist/chunk-3ASEWMRX.js +0 -37
  49. package/dist/chunk-3FVPHQCH.js +0 -151
  50. package/dist/chunk-3RX6CLNR.js +0 -32
  51. package/dist/chunk-3VCNSA6P.js +0 -14
  52. package/dist/chunk-3WHUADTN.js +0 -6
  53. package/dist/chunk-6OCHCPBP.js +0 -36
  54. package/dist/chunk-6OIH6FS4.js +0 -32
  55. package/dist/chunk-7EWRZPTX.js +0 -63
  56. package/dist/chunk-7PUQ5ZIN.js +0 -6
  57. package/dist/chunk-A5AONVOH.js +0 -6
  58. package/dist/chunk-ADIVRUAJ.js +0 -27
  59. package/dist/chunk-CCEWV2BR.js +0 -39
  60. package/dist/chunk-CTQ6DUT2.js +0 -8
  61. package/dist/chunk-DXQTBFGG.js +0 -31
  62. package/dist/chunk-E4SSLXFT.js +0 -63
  63. package/dist/chunk-E5XIGIEX.js +0 -14
  64. package/dist/chunk-EIOQKTRM.js +0 -104
  65. package/dist/chunk-FOSDCKCR.js +0 -106
  66. package/dist/chunk-G4OE26TZ.js +0 -33
  67. package/dist/chunk-GVGO5OAK.js +0 -8
  68. package/dist/chunk-GXRCTWKL.js +0 -16
  69. package/dist/chunk-HVKW7JK4.js +0 -8
  70. package/dist/chunk-IGEFNODG.js +0 -22
  71. package/dist/chunk-JXL4VJHZ.js +0 -36
  72. package/dist/chunk-K3GOQSS3.js +0 -6
  73. package/dist/chunk-KCJKQP37.js +0 -133
  74. package/dist/chunk-KMIFCLXG.js +0 -16
  75. package/dist/chunk-KZA3MC77.js +0 -151
  76. package/dist/chunk-LLL3V7LB.js +0 -6
  77. package/dist/chunk-LQ6DL2HS.js +0 -68
  78. package/dist/chunk-M4ZRDJJ2.js +0 -68
  79. package/dist/chunk-MAQAT3PU.js +0 -32
  80. package/dist/chunk-MPXPSSLJ.js +0 -133
  81. package/dist/chunk-NADN2PHB.js +0 -0
  82. package/dist/chunk-NFRXMBRP.js +0 -24
  83. package/dist/chunk-NVPKTRMT.js +0 -7
  84. package/dist/chunk-O45AB4MX.js +0 -83
  85. package/dist/chunk-ORPRWIQ2.js +0 -33
  86. package/dist/chunk-P7M5PEDY.js +0 -18
  87. package/dist/chunk-PBNCVQZC.js +0 -6
  88. package/dist/chunk-PMV4TMFS.js +0 -151
  89. package/dist/chunk-POF4JGTX.js +0 -186
  90. package/dist/chunk-PYSJMSNM.js +0 -27
  91. package/dist/chunk-Q3OMG6YH.js +0 -186
  92. package/dist/chunk-QCNBVSFO.js +0 -68
  93. package/dist/chunk-QMEO4OUR.js +0 -151
  94. package/dist/chunk-QSQNELZQ.js +0 -83
  95. package/dist/chunk-RRP7K5LI.js +0 -36
  96. package/dist/chunk-SHUYVCID.js +0 -6
  97. package/dist/chunk-SP4JKAUC.js +0 -63
  98. package/dist/chunk-T6OOKENF.js +0 -6
  99. package/dist/chunk-TBDROT3I.js +0 -6356
  100. package/dist/chunk-TH2RWMWA.js +0 -133
  101. package/dist/chunk-TJZCDDEV.js +0 -36
  102. package/dist/chunk-TN5SV7LF.js +0 -133
  103. package/dist/chunk-U6TOLKGJ.js +0 -22
  104. package/dist/chunk-UCOXL3OM.js +0 -0
  105. package/dist/chunk-URLTFJET.js +0 -68
  106. package/dist/chunk-UWCTG2LX.js +0 -24
  107. package/dist/chunk-WO2BXMBQ.js +0 -6
  108. package/dist/chunk-XAWZUZVP.js +0 -32
  109. package/dist/chunk-XCOSZXAE.js +0 -133
  110. package/dist/chunk-XD2Q7LWE.js +0 -24
  111. package/dist/chunk-XSL373TG.js +0 -36
  112. package/dist/chunk-XUYTJO6X.js +0 -104
  113. package/dist/chunk-YAYU7VOK.js +0 -8
  114. package/dist/chunk-YRUCICBV.js +0 -24
  115. package/dist/chunk-Z5XE72Q5.js +0 -68
  116. package/dist/chunk-ZTIO25VB.js +0 -8
  117. package/dist/lexer-DQCqS3nf-6W2BHF4T.js +0 -68
  118. package/dist/run.cjs +0 -943
  119. package/dist/run.js +0 -14
package/dist/index.cjs CHANGED
@@ -1,972 +1,813 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
-
31
- // src/index.ts
32
- var index_exports = {};
33
- __export(index_exports, {
34
- Command: () => Command,
35
- ConsoleServiceProvider: () => ConsoleServiceProvider,
36
- Kernel: () => Kernel,
37
- MakeCommand: () => MakeCommand,
38
- MigrateCommand: () => MigrateCommand,
39
- Musket: () => Musket,
40
- ServeCommand: () => ServeCommand,
41
- Signature: () => Signature,
42
- TableGuesser: () => TableGuesser,
43
- Utils: () => Utils
44
- });
45
- module.exports = __toCommonJS(index_exports);
1
+ const require_Utils = require('./Utils-CpiQZ3n9.cjs');
2
+ let fs_promises = require("fs/promises");
3
+ fs_promises = require_Utils.__toESM(fs_promises);
4
+ let path = require("path");
5
+ path = require_Utils.__toESM(path);
6
+ let __h3ravel_core = require("@h3ravel/core");
7
+ __h3ravel_core = require_Utils.__toESM(__h3ravel_core);
8
+ let __h3ravel_shared = require("@h3ravel/shared");
9
+ __h3ravel_shared = require_Utils.__toESM(__h3ravel_shared);
10
+ let node_fs_promises = require("node:fs/promises");
11
+ node_fs_promises = require_Utils.__toESM(node_fs_promises);
12
+ let __h3ravel_support = require("@h3ravel/support");
13
+ __h3ravel_support = require_Utils.__toESM(__h3ravel_support);
14
+ let dayjs = require("dayjs");
15
+ dayjs = require_Utils.__toESM(dayjs);
16
+ let node_fs = require("node:fs");
17
+ node_fs = require_Utils.__toESM(node_fs);
18
+ let node_path = require("node:path");
19
+ node_path = require_Utils.__toESM(node_path);
20
+ require("@h3ravel/console");
21
+ require("@h3ravel/http");
22
+ require("@h3ravel/router");
23
+ require("@h3ravel/database");
24
+ require("@h3ravel/cache");
25
+ require("@h3ravel/queue");
26
+ require("@h3ravel/mail");
27
+ require("@h3ravel/config");
28
+ let commander = require("commander");
29
+ commander = require_Utils.__toESM(commander);
30
+ let child_process = require("child_process");
31
+ child_process = require_Utils.__toESM(child_process);
32
+ let tsdown = require("tsdown");
33
+ tsdown = require_Utils.__toESM(tsdown);
46
34
 
47
- // src/Commands/Command.ts
48
- var Command = class {
49
- static {
50
- __name(this, "Command");
51
- }
52
- app;
53
- kernel;
54
- constructor(app, kernel) {
55
- this.app = app;
56
- this.kernel = kernel;
57
- }
58
- /**
59
- * The name and signature of the console command.
60
- *
61
- * @var string
62
- */
63
- signature;
64
- /**
65
- * A dictionary of signatures or what not.
66
- *
67
- * @var object
68
- */
69
- dictionary = {};
70
- /**
71
- * The console command description.
72
- *
73
- * @var string
74
- */
75
- description;
76
- /**
77
- * The console command input.
78
- *
79
- * @var object
80
- */
81
- input = {
82
- options: {},
83
- arguments: {}
84
- };
85
- /**
86
- * Execute the console command.
87
- */
88
- async handle(..._args) {
89
- }
90
- setApplication(app) {
91
- this.app = app;
92
- }
93
- setInput(options, args, regArgs, dictionary) {
94
- this.dictionary = dictionary;
95
- this.input.options = options;
96
- this.input.arguments = regArgs.map((e, i) => ({
97
- [e.name()]: args[i]
98
- })).reduce((e, x) => Object.assign(e, x), {});
99
- }
100
- getSignature() {
101
- return this.signature;
102
- }
103
- getDescription() {
104
- return this.description;
105
- }
106
- option(key, def) {
107
- return this.input.options[key] ?? def;
108
- }
109
- options(key) {
110
- if (key) {
111
- return this.input.options[key];
112
- }
113
- return this.input.options;
114
- }
115
- argument(key, def) {
116
- return this.input.arguments[key] ?? def;
117
- }
118
- arguments() {
119
- return this.input.arguments;
120
- }
121
- };
35
+ //#region src/Commands/Command.ts
36
+ var Command = class extends __h3ravel_core.ConsoleCommand {};
122
37
 
123
- // src/Utils.ts
124
- var import_promises = require("fs/promises");
125
- var import_chalk = __toESM(require("chalk"), 1);
38
+ //#endregion
39
+ //#region src/logo.ts
40
+ const logo = String.raw`
41
+ 111
42
+ 111111111
43
+ 1111111111 111111
44
+ 111111 111 111111
45
+ 111111 111 111111
46
+ 11111 111 11111
47
+ 1111111 111 1111111
48
+ 111 11111 111 111111 111 1111 1111 11111111 1111
49
+ 111 11111 1111 111111 111 1111 1111 1111 11111 1111
50
+ 111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
51
+ 111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
52
+ 111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
53
+ 111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
54
+ 111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
55
+ 1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
56
+ 11011 111111 11 11111
57
+ 111111 11101 111111
58
+ 111111 111 111111
59
+ 111111 111 111111
60
+ 111111111
61
+ 110
62
+ `;
63
+ const altLogo = String.raw`
64
+ _ _ _____ _
65
+ | | | |___ / _ __ __ ___ _____| |
66
+ | |_| | |_ \| '__/ _ \ \ / / _ \ |
67
+ | _ |___) | | | (_| |\ V / __/ |
68
+ |_| |_|____/|_| \__,_| \_/ \___|_|
126
69
 
127
- // ../../node_modules/.pnpm/escalade@3.2.0/node_modules/escalade/sync/index.mjs
128
- var import_path = require("path");
129
- var import_fs = require("fs");
130
- function sync_default(start, callback) {
131
- let dir = (0, import_path.resolve)(".", start);
132
- let tmp, stats = (0, import_fs.statSync)(dir);
133
- if (!stats.isDirectory()) {
134
- dir = (0, import_path.dirname)(dir);
135
- }
136
- while (true) {
137
- tmp = callback(dir, (0, import_fs.readdirSync)(dir));
138
- if (tmp) return (0, import_path.resolve)(dir, tmp);
139
- dir = (0, import_path.dirname)(tmp = dir);
140
- if (tmp === dir) break;
141
- }
142
- }
143
- __name(sync_default, "default");
70
+ `;
144
71
 
145
- // src/Utils.ts
146
- var import_path2 = __toESM(require("path"), 1);
147
- var join = import_path2.default.join;
148
- var Utils = class {
149
- static {
150
- __name(this, "Utils");
151
- }
152
- /**
153
- * Wraps text with chalk
154
- *
155
- * @param txt
156
- * @param color
157
- * @returns
158
- */
159
- static textFormat(txt, color) {
160
- return String(txt).split(":").map((e, i, a) => i == 0 && a.length > 1 ? color(" " + e + ": ") : e).join("");
161
- }
162
- /**
163
- * Ouput formater object
164
- *
165
- * @returns
166
- */
167
- static output() {
168
- return {
169
- success: /* @__PURE__ */ __name((msg, exit = false) => {
170
- console.log(import_chalk.default.green("\u2713"), this.textFormat(msg, import_chalk.default.bgGreen), "\n");
171
- if (exit) process.exit(0);
172
- }, "success"),
173
- info: /* @__PURE__ */ __name((msg, exit = false) => {
174
- console.log(import_chalk.default.blue("\u2139"), this.textFormat(msg, import_chalk.default.bgBlue), "\n");
175
- if (exit) process.exit(0);
176
- }, "info"),
177
- error: /* @__PURE__ */ __name((msg, exit = true) => {
178
- if (msg instanceof Error) {
179
- if (msg.message) {
180
- console.error(import_chalk.default.red("\u2716"), this.textFormat("ERROR:" + msg.message, import_chalk.default.bgRed));
181
- }
182
- console.error(import_chalk.default.red(`${msg.detail ? `${msg.detail}
183
- ` : ""}${msg.stack}`), "\n");
184
- } else {
185
- console.error(import_chalk.default.red("\u2716"), this.textFormat(msg, import_chalk.default.bgRed), "\n");
186
- }
187
- if (exit) process.exit(1);
188
- }, "error"),
189
- split: /* @__PURE__ */ __name((name, value, status, exit = false) => {
190
- status ??= "info";
191
- const color = {
192
- success: import_chalk.default.bgGreen,
193
- info: import_chalk.default.bgBlue,
194
- error: import_chalk.default.bgRed
195
- };
196
- const regex = /\x1b\[\d+m/g;
197
- const width = Math.min(process.stdout.columns, 100);
198
- const dots = Math.max(width - name.replace(regex, "").length - value.replace(regex, "").length - 10, 0);
199
- console.log(this.textFormat(name, color[status]), import_chalk.default.gray(".".repeat(dots)), value);
200
- if (exit) process.exit(0);
201
- }, "split"),
202
- quiet: /* @__PURE__ */ __name(() => {
203
- process.exit(0);
204
- }, "quiet")
205
- };
206
- }
207
- static findModulePkg(moduleId, cwd) {
208
- const parts = moduleId.replace(/\\/g, "/").split("/");
209
- let packageName = "";
210
- if (parts.length > 0 && parts[0][0] === "@") {
211
- packageName += parts.shift() + "/";
212
- }
213
- packageName += parts.shift();
214
- const packageJson = import_path2.default.join(cwd ?? process.cwd(), "node_modules", packageName);
215
- const resolved = this.findUpConfig(packageJson, "package", [
216
- "json"
217
- ]);
218
- if (!resolved) {
219
- return;
220
- }
221
- return import_path2.default.join(import_path2.default.dirname(resolved), parts.join("/"));
222
- }
223
- static async getMigrationPaths(cwd, migrator, defaultPath, path3) {
224
- if (path3) {
225
- return [
226
- join(cwd, path3)
227
- ];
228
- }
229
- return [
230
- ...migrator.getPaths(),
231
- join(cwd, defaultPath)
232
- ];
233
- }
234
- static twoColumnDetail(name, value) {
235
- const regex = /\x1b\[\d+m/g;
236
- const width = Math.min(process.stdout.columns, 100);
237
- const dots = Math.max(width - name.replace(regex, "").length - value.replace(regex, "").length - 10, 0);
238
- return console.log(name, import_chalk.default.gray(".".repeat(dots)), value);
239
- }
240
- /**
241
- * Check if file exists
242
- *
243
- * @param path
244
- * @returns
245
- */
246
- static async fileExists(path3) {
247
- try {
248
- await (0, import_promises.access)(path3);
249
- return true;
250
- } catch {
251
- return false;
252
- }
253
- }
254
- static findUpConfig(cwd, name, extensions) {
255
- return sync_default(cwd, (_dir, names) => {
256
- for (const ext of extensions) {
257
- const filename = `${name}.${ext}`;
258
- if (names.includes(filename)) {
259
- return filename;
260
- }
261
- }
262
- return false;
263
- });
264
- }
72
+ //#endregion
73
+ //#region src/Commands/ListCommand.ts
74
+ var ListCommand = class extends Command {
75
+ /**
76
+ * The name and signature of the console command.
77
+ *
78
+ * @var string
79
+ */
80
+ signature = "list";
81
+ /**
82
+ * The console command description.
83
+ *
84
+ * @var string
85
+ */
86
+ description = "List all available commands";
87
+ async handle() {
88
+ const options = [{
89
+ short: "-h",
90
+ long: "--help",
91
+ description: "Display help for the given command. When no command is given display help for the list command"
92
+ }].concat(this.program.options).map((e) => {
93
+ return __h3ravel_shared.Logger.describe(__h3ravel_shared.Logger.log(" " + [e.short, e.long].filter((e$1) => !!e$1).join(", "), "green", false), e.description, 25, false).join("");
94
+ });
95
+ const grouped = this.program.commands.map((e) => {
96
+ return __h3ravel_shared.Logger.describe(__h3ravel_shared.Logger.log(" " + e.name(), "green", false), e.description(), 25, false).join("");
97
+ }).reduce((acc, cmd) => {
98
+ /** strip colors before checking prefix */
99
+ const clean = cmd.replace(/\x1b\[\d+m/g, "");
100
+ const prefix = clean.includes(":") ? clean.split(":")[0].trim() : "__root__";
101
+ acc[prefix] ??= [];
102
+ /** keep original with colors */
103
+ acc[prefix].push(cmd);
104
+ return acc;
105
+ }, {});
106
+ const list = Object.entries(grouped).map(([group, cmds]) => {
107
+ const label = group === "__root__" ? "" : group;
108
+ return [__h3ravel_shared.Logger.log(label, "yellow", false), cmds.join("\n")].join("\n");
109
+ });
110
+ /** Ootput the app version */
111
+ __h3ravel_shared.Logger.log([["H3ravel Framework", "white"], [this.kernel.modulePackage.version, "green"]], " ");
112
+ console.log("");
113
+ console.log(altLogo);
114
+ console.log("");
115
+ __h3ravel_shared.Logger.log("Usage:", "yellow");
116
+ __h3ravel_shared.Logger.log(" command [options] [arguments]", "white");
117
+ console.log("");
118
+ /** Ootput the options */
119
+ __h3ravel_shared.Logger.log("Options:", "yellow");
120
+ console.log(options.join("\n").trim());
121
+ console.log("");
122
+ /** Ootput the commands */
123
+ __h3ravel_shared.Logger.log("Available Commands:", "yellow");
124
+ console.log(list.join("\n\n").trim());
125
+ }
265
126
  };
266
- var TableGuesser = class TableGuesser2 {
267
- static {
268
- __name(this, "TableGuesser");
269
- }
270
- static CREATE_PATTERNS = [
271
- /^create_(\w+)_table$/,
272
- /^create_(\w+)$/
273
- ];
274
- static CHANGE_PATTERNS = [
275
- /.+_(to|from|in)_(\w+)_table$/,
276
- /.+_(to|from|in)_(\w+)$/
277
- ];
278
- static guess(migration) {
279
- for (const pattern of TableGuesser2.CREATE_PATTERNS) {
280
- const matches = migration.match(pattern);
281
- if (matches) {
282
- return [
283
- matches[1],
284
- true
285
- ];
286
- }
287
- }
288
- for (const pattern of TableGuesser2.CHANGE_PATTERNS) {
289
- const matches = migration.match(pattern);
290
- if (matches) {
291
- return [
292
- matches[2],
293
- false
294
- ];
295
- }
296
- }
297
- return [];
298
- }
127
+
128
+ //#endregion
129
+ //#region ../filesystem/dist/index.js
130
+ var Helpers = class {
131
+ static findModulePkg(moduleId, cwd) {
132
+ const parts = moduleId.replace(/\\/g, "/").split("/");
133
+ let packageName = "";
134
+ if (parts.length > 0 && parts[0][0] === "@") packageName += parts.shift() + "/";
135
+ packageName += parts.shift();
136
+ const packageJson = path.default.join(cwd ?? process.cwd(), "node_modules", packageName);
137
+ const resolved = this.findUpConfig(packageJson, "package", ["json"]);
138
+ if (!resolved) return;
139
+ return path.default.join(path.default.dirname(resolved), parts.join("/"));
140
+ }
141
+ /**
142
+ * Check if file exists
143
+ *
144
+ * @param path
145
+ * @returns
146
+ */
147
+ static async fileExists(path$1$1) {
148
+ try {
149
+ await (0, fs_promises.access)(path$1$1);
150
+ return true;
151
+ } catch {
152
+ return false;
153
+ }
154
+ }
155
+ static findUpConfig(cwd, name, extensions) {
156
+ return require_Utils.sync_default(cwd, (_dir, names) => {
157
+ for (const ext of extensions) {
158
+ const filename = `${name}.${ext}`;
159
+ if (names.includes(filename)) return filename;
160
+ }
161
+ return false;
162
+ });
163
+ }
299
164
  };
300
165
 
301
- // src/Commands/MakeCommand.ts
302
- var import_promises2 = require("fs/promises");
303
- var import_chalk2 = __toESM(require("chalk"), 1);
304
- var import_dayjs = __toESM(require("dayjs"), 1);
305
- var import_node_fs = require("fs");
306
- var import_node_path = __toESM(require("path"), 1);
166
+ //#endregion
167
+ //#region src/Commands/MakeCommand.ts
307
168
  var MakeCommand = class extends Command {
308
- static {
309
- __name(this, "MakeCommand");
310
- }
311
- /**
312
- * The name and signature of the console command.
313
- *
314
- * @var string
315
- */
316
- signature = `#make:
317
- {controller : Generates a new controller class. | {--a|api : Generate an API resource controller} | {--force : Overide existing controller.} }
318
- {resource : Generates a new API resource class.}
319
- {migration : Generates a new database migration class. | {--l|type=ts : The file type to generate} | {--t|table : The table to migrate} | {--c|create : The table to be created} }
320
- {factory : Generates a new database factory class.}
321
- {seeder : Generates a new database seeder class.}
322
- {model : Generates a new Arquebus model class. | {--t|type=ts : The file type to generate}}
169
+ /**
170
+ * The name and signature of the console command.
171
+ *
172
+ * @var string
173
+ */
174
+ signature = `#make:
175
+ {controller : Create a new controller class.
176
+ | {--a|api : Exclude the create and edit methods from the controller}
177
+ | {--m|model= : Generate a resource controller for the given model}
178
+ | {--r|resource : Generate a resource controller class}
179
+ | {--force : Create the controller even if it already exists}
180
+ }
181
+ {resource : Create a new resource.
182
+ | {--c|collection : Create a resource collection}
183
+ | {--force : Create the resource even if it already exists}
184
+ }
185
+ {migration : Generates a new database migration class.
186
+ | {--l|type=ts : The file type to generate}
187
+ | {--t|table : The table to migrate}
188
+ | {--c|create : The table to be created}
189
+ }
190
+ {factory : Create a new model factory.}
191
+ {seeder : Create a new seeder class.}
192
+ {view : Create a new view.
193
+ | {--force : Create the view even if it already exists}
194
+ }
195
+ {model : Create a new Eloquent model class.
196
+ | {--api : Indicates if the generated controller should be an API resource controller}
197
+ | {--c|controller : Create a new controller for the model}
198
+ | {--f|factory : Create a new factory for the model}
199
+ | {--m|migration : Create a new migration file for the model}
200
+ | {--r|resource : Indicates if the generated controller should be a resource controller}
201
+ | {--a|all : Generate a migration, seeder, factory, policy, resource controller, and form request classes for the model}
202
+ | {--s|seed : Create a new seeder for the model}
203
+ | {--t|type=ts : The file type to generate}
204
+ | {--force : Create the model even if it already exists}
205
+ }
323
206
  {^name : The name of the [name] to generate}
324
207
  `;
325
- /**
326
- * The console command description.
327
- *
328
- * @var string
329
- */
330
- description = "Generate component classes";
331
- async handle() {
332
- const command = this.dictionary.baseCommand;
333
- const methods = {
334
- controller: "makeController",
335
- resource: "makeResource",
336
- migration: "makeMigration",
337
- factory: "makeFactory",
338
- seeder: "makeSeeder",
339
- model: "makeModel"
340
- };
341
- try {
342
- await this?.[methods[command]]();
343
- } catch (e) {
344
- this.kernel.output.error(e);
345
- }
346
- }
347
- /**
348
- * Generate a new controller class.
349
- */
350
- async makeController() {
351
- const type = this.option("api") ? "-resource" : "";
352
- const name = this.argument("name");
353
- const force = this.option("force");
354
- const path3 = import_node_path.default.join(app_path("Http/Controllers"), name + ".ts");
355
- const dbPath = Utils.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
356
- const stubPath = import_node_path.default.join(dbPath, `dist/stubs/controller${type}.stub`);
357
- if (!force && (0, import_node_fs.existsSync)(path3)) {
358
- this.kernel.output.error(`ERORR: ${name} controller already exists`);
359
- }
360
- let stub = await (0, import_promises2.readFile)(stubPath, "utf-8");
361
- stub = stub.replace(/{{ name }}/g, name);
362
- await (0, import_promises2.writeFile)(path3, stub);
363
- this.kernel.output.split(`INFO: Controller Created`, import_chalk2.default.gray(import_node_path.default.basename(path3)));
364
- }
365
- makeResource() {
366
- this.kernel.output.success(`Resource support is not yet available`);
367
- }
368
- /**
369
- * Generate a new database migration class
370
- */
371
- async makeMigration() {
372
- const name = this.argument("name");
373
- const datePrefix = (0, import_dayjs.default)().format("YYYY_MM_DD_HHmmss");
374
- const path3 = import_node_path.default.join(database_path("migrations"), `${datePrefix}_${name}.ts`);
375
- const dbPath = Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
376
- let create = this.option("create", false);
377
- let table = this.option("table");
378
- if (!table && typeof create === "string") {
379
- table = create;
380
- create = true;
381
- }
382
- if (!table) {
383
- const guessed = TableGuesser.guess(name);
384
- table = guessed[0];
385
- create = !!guessed[1];
386
- }
387
- const stubPath = import_node_path.default.join(dbPath, this.getMigrationStubName(table, create));
388
- let stub = await (0, import_promises2.readFile)(stubPath, "utf-8");
389
- if (table !== null) {
390
- stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
391
- }
392
- this.kernel.output.info("INFO: Creating Migration");
393
- await this.kernel.ensureDirectoryExists(import_node_path.default.dirname(path3));
394
- await (0, import_promises2.writeFile)(path3, stub);
395
- this.kernel.output.split(`INFO: Migration Created`, import_chalk2.default.gray(import_node_path.default.basename(path3)));
396
- }
397
- makeFactory() {
398
- this.kernel.output.success(`Factory support is not yet available`);
399
- }
400
- makeSeeder() {
401
- this.kernel.output.success(`Seeder support is not yet available`);
402
- }
403
- /**
404
- * Generate a new Arquebus model class
405
- */
406
- async makeModel() {
407
- const type = this.option("type", "ts");
408
- const name = this.argument("name");
409
- const path3 = import_node_path.default.join(app_path("Models"), name.toLowerCase() + "." + type);
410
- const dbPath = Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
411
- const stubPath = import_node_path.default.join(dbPath, `dist/stubs/model-${type}.stub`);
412
- let stub = await (0, import_promises2.readFile)(stubPath, "utf-8");
413
- stub = stub.replace(/{{ name }}/g, name);
414
- await (0, import_promises2.writeFile)(path3, stub);
415
- this.kernel.output.split(`INFO: Model Created`, import_chalk2.default.gray(import_node_path.default.basename(path3)));
416
- }
417
- /**
418
- * Ge the database migration file name
419
- *
420
- * @param table
421
- * @param create
422
- * @param type
423
- * @returns
424
- */
425
- getMigrationStubName(table, create = false, type = "ts") {
426
- let stub;
427
- if (!table) {
428
- stub = `migration-${type}.stub`;
429
- } else if (create) {
430
- stub = `migration.create-${type}.stub`;
431
- } else {
432
- stub = `migration.update-${type}.stub`;
433
- }
434
- return "dist/stubs/" + stub;
435
- }
208
+ /**
209
+ * The console command description.
210
+ *
211
+ * @var string
212
+ */
213
+ description = "Generate component classes";
214
+ async handle() {
215
+ const command = this.dictionary.baseCommand ?? this.dictionary.name;
216
+ const methods = {
217
+ controller: "makeController",
218
+ resource: "makeResource",
219
+ migration: "makeMigration",
220
+ factory: "makeFactory",
221
+ seeder: "makeSeeder",
222
+ model: "makeModel",
223
+ view: "makeView"
224
+ };
225
+ try {
226
+ await this?.[methods[command]]();
227
+ } catch (e) {
228
+ __h3ravel_shared.Logger.error(e);
229
+ }
230
+ }
231
+ /**
232
+ * Create a new controller class.
233
+ */
234
+ async makeController() {
235
+ const type = this.option("api") ? "-resource" : "";
236
+ const name = this.argument("name");
237
+ const force = this.option("force");
238
+ const path$5 = node_path.default.join(app_path("Http/Controllers"), name + ".ts");
239
+ const crtlrPath = Helpers.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
240
+ const stubPath = node_path.default.join(crtlrPath, `dist/stubs/controller${type}.stub`);
241
+ /** Check if the controller already exists */
242
+ if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} controller already exists`);
243
+ let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
244
+ stub = stub.replace(/{{ name }}/g, name);
245
+ await (0, node_fs_promises.writeFile)(path$5, stub);
246
+ __h3ravel_shared.Logger.split("INFO: Controller Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
247
+ }
248
+ makeResource() {
249
+ __h3ravel_shared.Logger.success("Resource support is not yet available");
250
+ }
251
+ /**
252
+ * Generate a new database migration class
253
+ */
254
+ async makeMigration() {
255
+ const name = this.argument("name");
256
+ const datePrefix = (0, dayjs.default)().format("YYYY_MM_DD_HHmmss");
257
+ const path$5 = node_path.default.join(database_path("migrations"), `${datePrefix}_${name}.ts`);
258
+ const crtlrPath = require_Utils.Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
259
+ let create = this.option("create", false);
260
+ let table = this.option("table");
261
+ if (!table && typeof create === "string") {
262
+ table = create;
263
+ create = true;
264
+ }
265
+ if (!table) {
266
+ const guessed = require_Utils.TableGuesser.guess(name);
267
+ table = guessed[0];
268
+ create = !!guessed[1];
269
+ }
270
+ const stubPath = node_path.default.join(crtlrPath, this.getMigrationStubName(table, create));
271
+ let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
272
+ if (table !== null) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
273
+ __h3ravel_shared.Logger.info("INFO: Creating Migration");
274
+ await this.kernel.ensureDirectoryExists(node_path.default.dirname(path$5));
275
+ await (0, node_fs_promises.writeFile)(path$5, stub);
276
+ __h3ravel_shared.Logger.split("INFO: Migration Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
277
+ }
278
+ /**
279
+ * Create a new model factory
280
+ */
281
+ makeFactory() {
282
+ __h3ravel_shared.Logger.success("Factory support is not yet available");
283
+ }
284
+ /**
285
+ * Create a new seeder class
286
+ */
287
+ makeSeeder() {
288
+ __h3ravel_shared.Logger.success("Seeder support is not yet available");
289
+ }
290
+ /**
291
+ * Generate a new Arquebus model class
292
+ */
293
+ async makeModel() {
294
+ const type = this.option("type", "ts");
295
+ const name = this.argument("name");
296
+ const force = this.argument("force");
297
+ const path$5 = node_path.default.join(app_path("Models"), name.toLowerCase(), "." + type);
298
+ /** Check if the model already exists */
299
+ if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
300
+ const crtlrPath = require_Utils.Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
301
+ const stubPath = node_path.default.join(crtlrPath, `dist/stubs/model-${type}.stub`);
302
+ let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
303
+ stub = stub.replace(/{{ name }}/g, name);
304
+ await (0, node_fs_promises.writeFile)(path$5, stub);
305
+ __h3ravel_shared.Logger.split("INFO: Model Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$5), "gray", false));
306
+ }
307
+ /**
308
+ * Create a new view.
309
+ */
310
+ async makeView() {
311
+ const name = this.argument("name");
312
+ const force = this.option("force");
313
+ const path$5 = node_path.default.join(base_path("src/resources/views"), name + ".edge");
314
+ if (name.includes("/")) await (0, node_fs_promises.mkdir)((0, __h3ravel_support.beforeLast)(path$5, "/"), { recursive: true });
315
+ /** Check if the view already exists */
316
+ if (!force && (0, node_fs.existsSync)(path$5)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
317
+ await (0, node_fs_promises.writeFile)(path$5, `{{-- src/resources/views/${name}.edge --}}`);
318
+ __h3ravel_shared.Logger.split("INFO: View Created", __h3ravel_shared.Logger.log(`src/resources/views/${name}.edge`, "gray", false));
319
+ }
320
+ /**
321
+ * Ge the database migration file name
322
+ *
323
+ * @param table
324
+ * @param create
325
+ * @param type
326
+ * @returns
327
+ */
328
+ getMigrationStubName(table, create = false, type = "ts") {
329
+ let stub;
330
+ if (!table) stub = `migration-${type}.stub`;
331
+ else if (create) stub = `migration.create-${type}.stub`;
332
+ else stub = `migration.update-${type}.stub`;
333
+ return "dist/stubs/" + stub;
334
+ }
436
335
  };
437
336
 
438
- // src/Commands/MigrateCommand.ts
439
- var MigrateCommand = class extends Command {
440
- static {
441
- __name(this, "MigrateCommand");
442
- }
443
- /**
444
- * The name and signature of the console command.
445
- *
446
- * @var string
447
- */
448
- signature = `migrate:
449
- {fresh : Drop all tables and re-run all migrations.}
450
- {install : Create the migration repository.}
451
- {refresh : Reset and re-run all migrations.}
452
- {reset : Rollback all database migrations.}
453
- {rollback : Rollback the last database migration.}
454
- {status : Show the status of each migration.}
455
- {publish : Publish any migration files from installed packages.}
456
- {^--s|seed : Seed the database}
457
- `;
458
- /**
459
- * The console command description.
460
- *
461
- * @var string
462
- */
463
- description = "Run all pending migrations.";
464
- /**
465
- * Execute the console command.
466
- */
467
- async handle() {
468
- const command = this.dictionary.name ?? this.dictionary.baseCommand;
469
- const methods = {
470
- migrate: "migrateRun",
471
- fresh: "migrateFresh",
472
- install: "migrateInstall",
473
- refresh: "migrateRefresh",
474
- reset: "migrateReset",
475
- rollback: "migrateRollback",
476
- status: "migrateStatus",
477
- publish: "migratePublish"
478
- };
479
- await this?.[methods[command]]();
480
- }
481
- /**
482
- * Run all pending migrations.
483
- */
484
- async migrateRun() {
485
- this.kernel.output.success(`Running migrations are not yet supported.`);
486
- }
487
- /**
488
- * Drop all tables and re-run all migrations.
489
- */
490
- async migrateFresh() {
491
- this.kernel.output.success(`Drop all tables and re-run all migrations.`);
492
- }
493
- /**
494
- * Create the migration repository.
495
- */
496
- async migrateInstall() {
497
- this.kernel.output.success(`Create the migration repository.`);
498
- }
499
- /**
500
- * Reset and re-run all migrations.
501
- */
502
- async migrateRefresh() {
503
- this.kernel.output.success(`Resetting and re-running migrations is not yet supported.`);
504
- }
505
- /**
506
- * Rollback all database migrations.
507
- */
508
- async migrateReset() {
509
- this.kernel.output.success(`Rolling back all migration is not yet supported.`);
510
- }
511
- /**
512
- * Rollback the last database migration.
513
- */
514
- async migrateRollback() {
515
- this.kernel.output.success(`Rolling back the last migration is not yet supported.`);
516
- }
517
- /**
518
- * Show the status of each migration.
519
- */
520
- async migrateStatus() {
521
- const path3 = app_path();
522
- this.kernel.output.success(`Show the status of each migration.`);
523
- }
524
- /**
525
- * Publish any migration files from installed packages.
526
- */
527
- async migratePublish() {
528
- this.kernel.output.success(`Publish any migration files from installed packages.`);
529
- }
530
- };
531
-
532
- // src/Commands/ServeCommand.ts
533
- var import_node_child_process = require("child_process");
534
- var ServeCommand = class extends Command {
535
- static {
536
- __name(this, "ServeCommand");
537
- }
538
- /**
539
- * The name and signature of the console command.
540
- *
541
- * @var string
542
- */
543
- signature = "serve";
544
- /**
545
- * The console command description.
546
- *
547
- * @var string
548
- */
549
- description = "Start the Developement Server";
550
- async handle() {
551
- try {
552
- await this.serve();
553
- } catch (e) {
554
- this.kernel.output.error(e);
555
- }
556
- }
557
- async serve() {
558
- const child = (0, import_node_child_process.spawn)("tsup-node", {
559
- stdio: "inherit",
560
- shell: true,
561
- env: Object.assign({}, process.env, {
562
- NODE_ENV: "development"
563
- }),
564
- detached: false
565
- });
566
- const cleanup = /* @__PURE__ */ __name(() => {
567
- console.log(111111);
568
- if (child.pid) {
569
- process.kill(child.pid, "SIGTERM");
570
- }
571
- }, "cleanup");
572
- process.on("SIGINT", () => child.kill("SIGINT"));
573
- process.on("SIGTERM", () => child.kill("SIGTERM"));
574
- process.on("SIGINT", () => {
575
- cleanup();
576
- process.exit(0);
577
- });
578
- process.on("SIGTERM", () => {
579
- cleanup();
580
- process.exit(0);
581
- });
582
- }
337
+ //#endregion
338
+ //#region src/Signature.ts
339
+ var Signature = class Signature {
340
+ /**
341
+ * Helper to parse options inside a block of text
342
+ *
343
+ * @param block
344
+ * @returns
345
+ */
346
+ static parseOptions(block) {
347
+ const options = [];
348
+ /**
349
+ * Match { ... } blocks at top level
350
+ */
351
+ const regex = /\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g;
352
+ let match;
353
+ while ((match = regex.exec(block)) !== null) {
354
+ const shared = "^" === match[1][0] || /:[#^]/.test(match[1]);
355
+ const isHidden = (["#", "^"].includes(match[1][0]) || /:[#^]/.test(match[1])) && !shared;
356
+ const content = match[1].trim().replace(/[#^]/, "");
357
+ /**
358
+ * Split by first ':' to separate name and description+nested
359
+ */
360
+ const colonIndex = content.indexOf(":");
361
+ if (colonIndex === -1) {
362
+ /**
363
+ * No description, treat whole as name
364
+ */
365
+ options.push({ name: content });
366
+ continue;
367
+ }
368
+ const namePart = content.substring(0, colonIndex).trim();
369
+ let rest = content.substring(colonIndex + 1).trim();
370
+ /**
371
+ * Check for nested options after '|'
372
+ */
373
+ let description = rest;
374
+ let nestedOptions;
375
+ const pipeIndex = rest.indexOf("|");
376
+ if (pipeIndex !== -1) {
377
+ description = rest.substring(0, pipeIndex).trim();
378
+ /**
379
+ * nestedText should start with '{' and end with ')', clean it
380
+ * Also Remove trailing ')' if present
381
+ */
382
+ const cleanedNestedText = rest.substring(pipeIndex + 1).trim().replace(/^\{/, "").trim();
383
+ /**
384
+ * Parse nested options recursively
385
+ */
386
+ nestedOptions = Signature.parseOptions("{" + cleanedNestedText + "}");
387
+ } else
388
+ /**
389
+ * Trim the string
390
+ */
391
+ description = description.trim();
392
+ /**
393
+ * Parse name modifiers (?, *, ?*)
394
+ */
395
+ let name = namePart;
396
+ let required = /[^a-zA-Z0-9_|-]/.test(name);
397
+ let multiple = false;
398
+ if (name.endsWith("?*")) {
399
+ required = false;
400
+ multiple = true;
401
+ name = name.slice(0, -2);
402
+ } else if (name.endsWith("*")) {
403
+ multiple = true;
404
+ name = name.slice(0, -1);
405
+ } else if (name.endsWith("?")) {
406
+ required = false;
407
+ name = name.slice(0, -1);
408
+ }
409
+ /**
410
+ * Check if it's a flag option (starts with --)
411
+ */
412
+ const isFlag = name.startsWith("--");
413
+ let flags;
414
+ let defaultValue;
415
+ if (isFlag) {
416
+ /**
417
+ * Parse flags and default values
418
+ */
419
+ const flagParts = name.split("|").map((s) => s.trim());
420
+ flags = [];
421
+ for (let part of flagParts) {
422
+ if (part.startsWith("--") && part.slice(2).length === 1) part = "-" + part.slice(2);
423
+ else if (part.startsWith("-") && !part.startsWith("--") && part.slice(1).length > 1) part = "--" + part.slice(1);
424
+ else if (!part.startsWith("-") && part.slice(1).length > 1) part = "--" + part;
425
+ const eqIndex = part.indexOf("=");
426
+ if (eqIndex !== -1) {
427
+ flags.push(part.substring(0, eqIndex));
428
+ const val = part.substring(eqIndex + 1);
429
+ if (val === "*") defaultValue = [];
430
+ else if (val === "true" || val === "false" || !val && !required) defaultValue = val === "true";
431
+ else if (!isNaN(Number(val))) defaultValue = Number(val);
432
+ else defaultValue = val;
433
+ } else flags.push(part);
434
+ }
435
+ }
436
+ options.push({
437
+ name: isFlag ? flags[flags.length - 1] : name,
438
+ required,
439
+ multiple,
440
+ description,
441
+ flags,
442
+ shared,
443
+ isFlag,
444
+ isHidden,
445
+ defaultValue,
446
+ nestedOptions
447
+ });
448
+ }
449
+ return options;
450
+ }
451
+ /**
452
+ * Helper to parse a command's signature
453
+ *
454
+ * @param signature
455
+ * @param commandClass
456
+ * @returns
457
+ */
458
+ static parseSignature(signature, commandClass) {
459
+ const lines = signature.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
460
+ const isHidden = ["#", "^"].includes(lines[0][0]) || /:[#^]/.test(lines[0]);
461
+ const baseCommand = lines[0].replace(/[^\w=:-]/g, "");
462
+ const description = commandClass.getDescription();
463
+ const isNamespaceCommand = baseCommand.endsWith(":");
464
+ /**
465
+ * Join the rest lines to a single string for parsing
466
+ */
467
+ const rest = lines.slice(1).join(" ");
468
+ /**
469
+ * Parse all top-level options/subcommands
470
+ */
471
+ const allOptions = Signature.parseOptions(rest);
472
+ if (isNamespaceCommand)
473
+ /**
474
+ * Separate subcommands (those without flags) and base options (flags)
475
+ * Here we assume subcommands are those without flags (isFlag false)
476
+ * and base options are flags or options after subcommands
477
+
478
+ * For simplicity, treat all top-level options as subcommands
479
+ * and assume base command options come after subcommands in signature (not shown in example)
480
+ */
481
+ return {
482
+ baseCommand: baseCommand.slice(0, -1),
483
+ isNamespaceCommand,
484
+ subCommands: allOptions.filter((e) => !e.flags && !e.isHidden),
485
+ description,
486
+ commandClass,
487
+ options: allOptions.filter((e) => !!e.flags),
488
+ isHidden
489
+ };
490
+ else return {
491
+ baseCommand,
492
+ isNamespaceCommand,
493
+ options: allOptions,
494
+ description,
495
+ commandClass,
496
+ isHidden
497
+ };
498
+ }
583
499
  };
584
500
 
585
- // src/IO/app.ts
586
- var import_core2 = require("@h3ravel/core");
587
-
588
- // src/IO/providers.ts
589
- var import_http = require("@h3ravel/http");
590
- var import_router = require("@h3ravel/router");
591
- var import_database = require("@h3ravel/database");
592
- var import_cache = require("@h3ravel/cache");
593
- var import_queue = require("@h3ravel/queue");
594
- var import_mail = require("@h3ravel/mail");
595
- var import_config = require("@h3ravel/config");
596
-
597
- // src/Providers/ConsoleServiceProvider.ts
598
- var import_node_events = require("events");
599
-
600
- // src/Signature.ts
601
- var Signature = class _Signature {
602
- static {
603
- __name(this, "Signature");
604
- }
605
- /**
606
- * Helper to parse options inside a block of text
607
- *
608
- * @param block
609
- * @returns
610
- */
611
- static parseOptions(block) {
612
- const options = [];
613
- const regex = /\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g;
614
- let match;
615
- while ((match = regex.exec(block)) !== null) {
616
- const shared = "^" === match[1][0] || /:[#^]/.test(match[1]);
617
- const isHidden = ([
618
- "#",
619
- "^"
620
- ].includes(match[1][0]) || /:[#^]/.test(match[1])) && !shared;
621
- const content = match[1].trim().replace(/[#^]/, "");
622
- const colonIndex = content.indexOf(":");
623
- if (colonIndex === -1) {
624
- options.push({
625
- name: content
626
- });
627
- continue;
628
- }
629
- const namePart = content.substring(0, colonIndex).trim();
630
- let rest = content.substring(colonIndex + 1).trim();
631
- let description = rest;
632
- let nestedOptions;
633
- const pipeIndex = rest.indexOf("|");
634
- if (pipeIndex !== -1) {
635
- description = rest.substring(0, pipeIndex).trim();
636
- const nestedText = rest.substring(pipeIndex + 1).trim();
637
- const cleanedNestedText = nestedText.replace(/^\{/, "").trim();
638
- nestedOptions = _Signature.parseOptions("{" + cleanedNestedText + "}");
639
- } else {
640
- description = description.trim();
641
- }
642
- let name = namePart;
643
- let required = /[^a-zA-Z0-9_|-]/.test(name);
644
- let multiple = false;
645
- if (name.endsWith("?*")) {
646
- required = false;
647
- multiple = true;
648
- name = name.slice(0, -2);
649
- } else if (name.endsWith("*")) {
650
- multiple = true;
651
- name = name.slice(0, -1);
652
- } else if (name.endsWith("?")) {
653
- required = false;
654
- name = name.slice(0, -1);
655
- }
656
- const isFlag = name.startsWith("--");
657
- let flags;
658
- let defaultValue;
659
- if (isFlag) {
660
- const flagParts = name.split("|").map((s) => s.trim());
661
- flags = [];
662
- for (let part of flagParts) {
663
- if (part.startsWith("--") && part.slice(2).length === 1) {
664
- part = "-" + part.slice(2);
665
- } else if (part.startsWith("-") && !part.startsWith("--") && part.slice(1).length > 1) {
666
- part = "--" + part.slice(1);
667
- } else if (!part.startsWith("-") && part.slice(1).length > 1) {
668
- part = "--" + part;
669
- }
670
- const eqIndex = part.indexOf("=");
671
- if (eqIndex !== -1) {
672
- flags.push(part.substring(0, eqIndex));
673
- const val = part.substring(eqIndex + 1);
674
- if (val === "*") {
675
- defaultValue = [];
676
- } else if (val === "true" || val === "false" || !val && !required) {
677
- defaultValue = val === "true";
678
- } else if (!isNaN(Number(val))) {
679
- defaultValue = Number(val);
680
- } else {
681
- defaultValue = val;
682
- }
683
- } else {
684
- flags.push(part);
685
- }
686
- }
687
- }
688
- options.push({
689
- name: isFlag ? flags[flags.length - 1] : name,
690
- required,
691
- multiple,
692
- description,
693
- flags,
694
- shared,
695
- isFlag,
696
- isHidden,
697
- defaultValue,
698
- nestedOptions
699
- });
700
- }
701
- return options;
702
- }
703
- /**
704
- * Helper to parse a command's signature
705
- *
706
- * @param signature
707
- * @param commandClass
708
- * @returns
709
- */
710
- static parseSignature(signature, commandClass) {
711
- const lines = signature.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
712
- const isHidden = [
713
- "#",
714
- "^"
715
- ].includes(lines[0][0]) || /:[#^]/.test(lines[0]);
716
- const baseCommand = lines[0].replace(/[^\w=:-]/g, "");
717
- const description = commandClass.getDescription();
718
- const isNamespaceCommand = baseCommand.endsWith(":");
719
- const rest = lines.slice(1).join(" ");
720
- const allOptions = _Signature.parseOptions(rest);
721
- if (isNamespaceCommand) {
722
- return {
723
- baseCommand: baseCommand.slice(0, -1),
724
- isNamespaceCommand,
725
- subCommands: allOptions.filter((e) => !e.flags && !e.isHidden),
726
- description,
727
- commandClass,
728
- options: allOptions.filter((e) => !!e.flags),
729
- isHidden
730
- };
731
- } else {
732
- return {
733
- baseCommand,
734
- isNamespaceCommand,
735
- options: allOptions,
736
- description,
737
- commandClass,
738
- isHidden
739
- };
740
- }
741
- }
742
- };
501
+ //#endregion
502
+ //#region ../../node_modules/.pnpm/@rollup+plugin-run@3.1.0/node_modules/@rollup/plugin-run/dist/es/index.js
503
+ function run(opts = {}) {
504
+ let input;
505
+ let proc;
506
+ const args = opts.args || [];
507
+ const allowRestarts = opts.allowRestarts || false;
508
+ const overrideInput = opts.input;
509
+ const forkOptions = opts.options || opts;
510
+ delete forkOptions.args;
511
+ delete forkOptions.allowRestarts;
512
+ return {
513
+ name: "run",
514
+ buildStart(options) {
515
+ let inputs = overrideInput !== null && overrideInput !== void 0 ? overrideInput : options.input;
516
+ if (typeof inputs === "string") inputs = [inputs];
517
+ if (typeof inputs === "object") inputs = Object.values(inputs);
518
+ if (inputs.length > 1) throw new Error(`@rollup/plugin-run must have a single entry point; consider setting the \`input\` option`);
519
+ input = (0, path.resolve)(inputs[0]);
520
+ },
521
+ generateBundle(_outputOptions, _bundle, isWrite) {
522
+ if (!isWrite) this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`);
523
+ },
524
+ writeBundle(outputOptions, bundle) {
525
+ const forkBundle = (dir$1, entryFileName$1) => {
526
+ if (proc) proc.kill();
527
+ proc = (0, child_process.fork)((0, path.join)(dir$1, entryFileName$1), args, forkOptions);
528
+ };
529
+ const dir = outputOptions.dir || (0, path.dirname)(outputOptions.file);
530
+ const entryFileName = Object.keys(bundle).find((fileName) => {
531
+ const chunk = bundle[fileName];
532
+ return chunk.isEntry && chunk.facadeModuleId === input;
533
+ });
534
+ if (entryFileName) {
535
+ forkBundle(dir, entryFileName);
536
+ if (allowRestarts) {
537
+ process.stdin.resume();
538
+ process.stdin.setEncoding("utf8");
539
+ process.stdin.on("data", (data) => {
540
+ const line = data.toString().trim().toLowerCase();
541
+ if (line === "rs" || line === "restart" || data.toString().charCodeAt(0) === 11) forkBundle(dir, entryFileName);
542
+ else if (line === "cls" || line === "clear" || data.toString().charCodeAt(0) === 12) console.clear();
543
+ });
544
+ }
545
+ } else this.error(`@rollup/plugin-run could not find output chunk`);
546
+ }
547
+ };
548
+ }
743
549
 
744
- // src/Musket.ts
745
- var import_chalk3 = __toESM(require("chalk"), 1);
746
- var import_commander = require("commander");
747
- var Musket = class _Musket {
748
- static {
749
- __name(this, "Musket");
750
- }
751
- app;
752
- kernel;
753
- output = Utils.output();
754
- commands = [];
755
- constructor(app, kernel) {
756
- this.app = app;
757
- this.kernel = kernel;
758
- }
759
- async build() {
760
- this.loadBaseCommands();
761
- await this.loadDiscoveredCommands();
762
- return this.initialize();
763
- }
764
- loadBaseCommands() {
765
- const commands = [
766
- new ServeCommand(this.app, this.kernel),
767
- new MakeCommand(this.app, this.kernel),
768
- new MigrateCommand(this.app, this.kernel)
769
- ];
770
- commands.forEach((e) => this.addCommand(e));
771
- }
772
- async loadDiscoveredCommands() {
773
- const commands = [];
774
- commands.forEach((e) => this.addCommand(e));
775
- }
776
- addCommand(command) {
777
- this.commands.push(Signature.parseSignature(command.getSignature(), command));
778
- }
779
- initialize() {
780
- const cliVersion = [
781
- "H3ravel Version:",
782
- import_chalk3.default.green(this.kernel.consolePackage.version)
783
- ].join(" ");
784
- const localVersion = [
785
- "Musket Version:",
786
- import_chalk3.default.green(this.kernel.modulePackage.version || "None")
787
- ].join(" ");
788
- import_commander.program.name("musket").version(`${cliVersion}
789
- ${localVersion}`);
790
- import_commander.program.command("init").description("Initialize H3ravel.").action(async () => {
791
- this.output.success(`Initialized: H3ravel has been initialized!`);
792
- });
793
- for (let i = 0; i < this.commands.length; i++) {
794
- const command = this.commands[i];
795
- const instance = command.commandClass;
796
- if (command.isNamespaceCommand && command.subCommands) {
797
- const cmd = command.isHidden ? import_commander.program : import_commander.program.command(command.baseCommand).description(command.description ?? "").action(async () => {
798
- instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command);
799
- await instance.handle();
800
- });
801
- if ((command.options?.length ?? 0) > 0) {
802
- command.options?.filter((v, i2, a) => a.findIndex((t) => t.name === v.name) === i2).forEach((opt) => {
803
- this.makeOption(opt, cmd);
804
- });
805
- }
806
- command.subCommands.filter((v, i2, a) => !v.shared && a.findIndex((t) => t.name === v.name) === i2).forEach((sub) => {
807
- const cmd2 = import_commander.program.command(`${command.baseCommand}:${sub.name}`).description(sub.description || "").action(async () => {
808
- instance.setInput(cmd2.opts(), cmd2.args, cmd2.registeredArguments, sub);
809
- await instance.handle();
810
- });
811
- command.subCommands?.filter((e) => e.shared).forEach((opt) => {
812
- this.makeOption(opt, cmd2, false, sub);
813
- });
814
- command.options?.filter((e) => e.shared).forEach((opt) => {
815
- this.makeOption(opt, cmd2, false, sub);
816
- });
817
- if (sub.nestedOptions) {
818
- sub.nestedOptions.filter((v, i2, a) => a.findIndex((t) => t.name === v.name) === i2).forEach((opt) => {
819
- this.makeOption(opt, cmd2);
820
- });
821
- }
822
- });
823
- } else {
824
- const cmd = import_commander.program.command(command.baseCommand).description(command.description ?? "");
825
- command?.options?.filter((v, i2, a) => a.findIndex((t) => t.name === v.name) === i2).forEach((opt) => {
826
- this.makeOption(opt, cmd, true);
827
- });
828
- cmd.action(async () => {
829
- instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command);
830
- await instance.handle();
831
- });
832
- }
833
- }
834
- return import_commander.program;
835
- }
836
- makeOption(opt, cmd, parse, parent) {
837
- const description = opt.description?.replace(/\[(\w+)\]/g, (_, k) => parent?.[k] ?? `[${k}]`) ?? "";
838
- const type = opt.name.replaceAll("-", "");
839
- if (opt.isFlag) {
840
- if (parse) {
841
- const flags = opt.flags?.map((f) => f.length === 1 ? `-${f}` : `--${f}`).join(", ");
842
- cmd.option(flags || "", description, String(opt.defaultValue) || void 0);
843
- } else {
844
- cmd.option(opt.flags?.join(", ") + (opt.required ? ` <${type}>` : ""), description, opt.defaultValue);
845
- }
846
- } else {
847
- cmd.argument(opt.required ? `<${opt.name}>` : `[${opt.name}]`, description, opt.defaultValue);
848
- }
849
- }
850
- static async parse(kernel) {
851
- return (await new _Musket(kernel.app, kernel).build()).parseAsync();
852
- }
550
+ //#endregion
551
+ //#region src/TsdownConfig.ts
552
+ const env = process.env.NODE_ENV || "development";
553
+ const outDir = env === "development" ? ".h3ravel/serve" : "dist";
554
+ const TsDownConfig = {
555
+ outDir,
556
+ entry: ["src/**/*.ts"],
557
+ format: ["esm"],
558
+ target: "node22",
559
+ sourcemap: env === "development",
560
+ clean: true,
561
+ shims: true,
562
+ copy: [
563
+ {
564
+ from: "public",
565
+ to: outDir
566
+ },
567
+ "src/resources",
568
+ "src/database"
569
+ ],
570
+ env: env === "development" ? {
571
+ NODE_ENV: env,
572
+ SRC_PATH: outDir
573
+ } : {},
574
+ watch: env === "development" && process.env.CLI_BUILD !== "true" ? [
575
+ ".env",
576
+ ".env.*",
577
+ "src",
578
+ "../../packages"
579
+ ] : false,
580
+ dts: false,
581
+ logLevel: "silent",
582
+ nodeProtocol: true,
583
+ skipNodeModulesBundle: true,
584
+ plugins: env === "development" && process.env.CLI_BUILD !== "true" ? [run({
585
+ env: Object.assign({}, process.env, {
586
+ NODE_ENV: env,
587
+ SRC_PATH: outDir
588
+ }),
589
+ execArgv: ["-r", "source-map-support/register"],
590
+ allowRestarts: false,
591
+ input: process.cwd() + "/src/server.ts"
592
+ })] : []
853
593
  };
594
+ var TsdownConfig_default = TsDownConfig;
854
595
 
855
- // src/Kernel.ts
856
- var import_promises3 = require("fs/promises");
857
- var import_node_path2 = __toESM(require("path"), 1);
858
- var Kernel = class _Kernel {
859
- static {
860
- __name(this, "Kernel");
861
- }
862
- app;
863
- cwd;
864
- output = Utils.output();
865
- basePath = "";
866
- modulePath;
867
- consolePath;
868
- modulePackage;
869
- consolePackage;
870
- constructor(app, basePath) {
871
- this.app = app;
872
- }
873
- static init(app) {
874
- const instance = new _Kernel(app);
875
- Promise.all([
876
- instance.loadRequirements()
877
- ]).then(([e]) => e.run());
878
- }
879
- async run() {
880
- await Musket.parse(this);
881
- process.exit(0);
882
- }
883
- async ensureDirectoryExists(dir) {
884
- await (0, import_promises3.mkdir)(dir, {
885
- recursive: true
886
- });
887
- }
888
- async loadRequirements() {
889
- this.cwd = import_node_path2.default.join(process.cwd(), this.basePath);
890
- this.modulePath = Utils.findModulePkg("@h3ravel/core", this.cwd) ?? "";
891
- this.consolePath = Utils.findModulePkg("@h3ravel/console", this.cwd) ?? "";
892
- try {
893
- this.modulePackage = await import(import_node_path2.default.join(this.modulePath, "package.json"));
894
- } catch {
895
- this.modulePackage = {
896
- version: "N/A"
897
- };
898
- }
899
- try {
900
- this.consolePackage = await import(import_node_path2.default.join(this.consolePath, "package.json"));
901
- } catch {
902
- this.consolePackage = {
903
- version: "N/A"
904
- };
905
- }
906
- return this;
907
- }
596
+ //#endregion
597
+ //#region src/Musket.ts
598
+ /**
599
+ * Musket is H3ravel's CLI tool
600
+ */
601
+ var Musket = class Musket {
602
+ commands = [];
603
+ constructor(app, kernel) {
604
+ this.app = app;
605
+ this.kernel = kernel;
606
+ }
607
+ async build() {
608
+ this.loadBaseCommands();
609
+ await this.loadDiscoveredCommands();
610
+ return this.initialize();
611
+ }
612
+ loadBaseCommands() {
613
+ [new MakeCommand(this.app, this.kernel), new ListCommand(this.app, this.kernel)].forEach((e) => this.addCommand(e));
614
+ }
615
+ async loadDiscoveredCommands() {
616
+ const commands = [...this.app.registeredCommands.map((cmd) => new cmd(this.app, this.kernel))];
617
+ /**
618
+ * Musket Commands auto registration
619
+ */
620
+ const providers_path = app_path("Console/Commands/*.js").replace("/src/", "/.h3ravel/serve/");
621
+ /** Add the App Commands */
622
+ for await (const cmd of (0, node_fs_promises.glob)(providers_path)) {
623
+ const name = node_path.default.basename(cmd).replace(".js", "");
624
+ try {
625
+ const cmdClass = (await import(cmd))[name];
626
+ commands.push(new cmdClass(this.app, this.kernel));
627
+ } catch {}
628
+ }
629
+ commands.forEach((e) => this.addCommand(e));
630
+ }
631
+ addCommand(command) {
632
+ this.commands.push(Signature.parseSignature(command.getSignature(), command));
633
+ }
634
+ initialize() {
635
+ /** Init the Musket Version */
636
+ const cliVersion = __h3ravel_shared.Logger.parse([["Musket CLI:", "white"], [this.kernel.consolePackage.version, "green"]], " ", false);
637
+ /** Init the App Version */
638
+ const localVersion = __h3ravel_shared.Logger.parse([["H3ravel Framework:", "white"], [this.kernel.modulePackage.version, "green"]], " ", false);
639
+ const additional = {
640
+ quiet: ["-q, --quiet", "Do not output any message"],
641
+ silent: ["--silent", "Do not output any message"],
642
+ verbose: ["-v, --verbose <number>", "Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug"],
643
+ interaction: ["-n, --no-interaction", "Do not ask any interactive question"]
644
+ };
645
+ /** Init Commander */
646
+ commander.program.name("musket").version(`${cliVersion}\n${localVersion}`).addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).option(additional.quiet[0], additional.quiet[1]).option(additional.verbose[0], additional.verbose[1]).option(additional.interaction[0], additional.interaction[1]).description(altLogo).action(async () => {
647
+ const instance = new ListCommand(this.app, this.kernel);
648
+ instance.setInput(commander.program.opts(), commander.program.args, commander.program.registeredArguments, {}, commander.program);
649
+ instance.handle();
650
+ });
651
+ /** Create the init Command */
652
+ commander.program.command("init").description("Initialize H3ravel.").action(async () => {
653
+ __h3ravel_shared.Logger.success("Initialized: H3ravel has been initialized!");
654
+ });
655
+ /** Loop through all the available commands */
656
+ for (let i = 0; i < this.commands.length; i++) {
657
+ const command = this.commands[i];
658
+ const instance = command.commandClass;
659
+ if (command.isNamespaceCommand && command.subCommands) {
660
+ /**
661
+ * Initialize the base command
662
+ */
663
+ const cmd = command.isHidden ? commander.program : commander.program.command(command.baseCommand).description(command.description ?? "").addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).option(additional.quiet[0], additional.quiet[1]).option(additional.verbose[0], additional.verbose[1]).option(additional.interaction[0], additional.interaction[1]).action(async () => {
664
+ instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command, commander.program);
665
+ await instance.handle();
666
+ });
667
+ /**
668
+ * Add options to the base command if it has any
669
+ */
670
+ if ((command.options?.length ?? 0) > 0) command.options?.filter((v, i$1, a) => a.findIndex((t) => t.name === v.name) === i$1).forEach((opt) => {
671
+ this.makeOption(opt, cmd);
672
+ });
673
+ /**
674
+ * Initialize the sub commands
675
+ */
676
+ command.subCommands.filter((v, i$1, a) => !v.shared && a.findIndex((t) => t.name === v.name) === i$1).forEach((sub) => {
677
+ const cmd$1 = commander.program.command(`${command.baseCommand}:${sub.name}`).description(sub.description || "").addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).option(additional.quiet[0], additional.quiet[1]).option(additional.verbose[0], additional.verbose[1]).option(additional.interaction[0], additional.interaction[1]).action(async () => {
678
+ instance.setInput(cmd$1.opts(), cmd$1.args, cmd$1.registeredArguments, sub, commander.program);
679
+ await instance.handle();
680
+ });
681
+ /**
682
+ * Add the shared arguments here
683
+ */
684
+ command.subCommands?.filter((e) => e.shared).forEach((opt) => {
685
+ this.makeOption(opt, cmd$1, false, sub);
686
+ });
687
+ /**
688
+ * Add the shared options here
689
+ */
690
+ command.options?.filter((e) => e.shared).forEach((opt) => {
691
+ this.makeOption(opt, cmd$1, false, sub);
692
+ });
693
+ /**
694
+ * Add options to the sub command if it has any
695
+ */
696
+ if (sub.nestedOptions) sub.nestedOptions.filter((v, i$1, a) => a.findIndex((t) => t.name === v.name) === i$1).forEach((opt) => {
697
+ this.makeOption(opt, cmd$1);
698
+ });
699
+ });
700
+ } else {
701
+ /**
702
+ * Initialize command with options
703
+ */
704
+ const cmd = commander.program.command(command.baseCommand).description(command.description ?? "").addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).option(additional.quiet[0], additional.quiet[1]).option(additional.verbose[0], additional.verbose[1]).option(additional.interaction[0], additional.interaction[1]);
705
+ command?.options?.filter((v, i$1, a) => a.findIndex((t) => t.name === v.name) === i$1).forEach((opt) => {
706
+ this.makeOption(opt, cmd, true);
707
+ });
708
+ cmd.action(async () => {
709
+ instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command, commander.program);
710
+ await instance.handle();
711
+ });
712
+ }
713
+ }
714
+ /** Rebuild the app on every command except fire so we wont need TS */
715
+ commander.program.hook("preAction", async (_, cmd) => {
716
+ if (cmd.name() !== "fire") await (0, tsdown.build)({
717
+ ...TsdownConfig_default,
718
+ watch: false,
719
+ plugins: []
720
+ });
721
+ });
722
+ return commander.program;
723
+ }
724
+ makeOption(opt, cmd, parse, parent) {
725
+ const description = opt.description?.replace(/\[(\w+)\]/g, (_, k) => parent?.[k] ?? `[${k}]`) ?? "";
726
+ const type = opt.name.replaceAll("-", "");
727
+ if (opt.isFlag) if (parse) {
728
+ const flags = opt.flags?.map((f) => f.length === 1 ? `-${f}` : `--${f}`).join(", ").replaceAll("----", "--").replaceAll("---", "-");
729
+ cmd.option(flags || "", description, String(opt.defaultValue) || void 0);
730
+ } else cmd.option(opt.flags?.join(", ") + (opt.required ? ` <${type}>` : ""), description, opt.defaultValue);
731
+ else cmd.argument(opt.required ? `<${opt.name}>` : `[${opt.name}]`, description, opt.defaultValue);
732
+ }
733
+ static async parse(kernel) {
734
+ return (await new Musket(kernel.app, kernel).build()).parseAsync();
735
+ }
908
736
  };
909
737
 
910
- // src/Providers/ConsoleServiceProvider.ts
911
- var import_core = require("@h3ravel/core");
912
- var ConsoleServiceProvider = class extends import_core.ServiceProvider {
913
- static {
914
- __name(this, "ConsoleServiceProvider");
915
- }
916
- static priority = 992;
917
- register() {
918
- }
919
- boot() {
920
- Kernel.init(this.app);
921
- new import_node_events.EventEmitter().once("SIGINT", () => process.exit(0));
922
- process.on("SIGINT", () => {
923
- process.exit(0);
924
- });
925
- process.on("SIGTERM", () => {
926
- process.exit(0);
927
- });
928
- }
738
+ //#endregion
739
+ //#region src/Kernel.ts
740
+ var Kernel = class Kernel extends __h3ravel_core.ConsoleKernel {
741
+ constructor(app) {
742
+ super(app);
743
+ this.app = app;
744
+ }
745
+ static init(app) {
746
+ const instance = new Kernel(app);
747
+ Promise.all([instance.loadRequirements()]).then(([e]) => e.run());
748
+ }
749
+ async run() {
750
+ await Musket.parse(this);
751
+ process.exit(0);
752
+ }
753
+ async loadRequirements() {
754
+ this.cwd = node_path.default.join(process.cwd(), this.basePath);
755
+ this.modulePath = Helpers.findModulePkg("@h3ravel/core", this.cwd) ?? "";
756
+ this.consolePath = Helpers.findModulePkg("@h3ravel/console", this.cwd) ?? "";
757
+ try {
758
+ this.modulePackage = await import(node_path.default.join(this.modulePath, "package.json"));
759
+ } catch {
760
+ this.modulePackage = { version: "N/A" };
761
+ }
762
+ try {
763
+ this.consolePackage = await import(node_path.default.join(this.consolePath, "package.json"));
764
+ } catch {
765
+ this.consolePackage = { version: "N/A" };
766
+ }
767
+ return this;
768
+ }
929
769
  };
930
770
 
931
- // src/IO/providers.ts
932
- var providers_default = [
933
- import_http.HttpServiceProvider,
934
- import_config.ConfigServiceProvider,
935
- import_router.RouteServiceProvider,
936
- import_router.AssetsServiceProvider,
937
- import_database.DatabaseServiceProvider,
938
- import_cache.CacheServiceProvider,
939
- import_queue.QueueServiceProvider,
940
- import_mail.MailServiceProvider,
941
- ConsoleServiceProvider
942
- ];
943
-
944
- // src/IO/app.ts
945
- var app_default = class {
946
- static {
947
- __name(this, "default");
948
- }
949
- async bootstrap() {
950
- const app = new import_core2.Application(process.cwd());
951
- app.registerProviders(providers_default);
952
- await app.registerConfiguredProviders();
953
- await app.boot();
954
- }
771
+ //#endregion
772
+ //#region src/Providers/ConsoleServiceProvider.ts
773
+ /**
774
+ * Handles CLI commands and tooling.
775
+ *
776
+ * Register DatabaseManager and QueryBuilder.
777
+ * Set up ORM models and relationships.
778
+ * Register migration and seeder commands.
779
+ *
780
+ * Auto-Registered when in CLI mode
781
+ */
782
+ var ConsoleServiceProvider = class extends __h3ravel_core.ServiceProvider {
783
+ static priority = 992;
784
+ /**
785
+ * Indicate that this service provider only runs in console
786
+ */
787
+ static console = true;
788
+ register() {}
789
+ boot() {
790
+ Kernel.init(this.app);
791
+ process.on("SIGINT", () => {
792
+ process.exit(0);
793
+ });
794
+ process.on("SIGTERM", () => {
795
+ process.exit(0);
796
+ });
797
+ }
955
798
  };
956
799
 
957
- // src/run.ts
958
- var import_esm = require("tsx/esm");
959
- new app_default().bootstrap();
960
- // Annotate the CommonJS export names for ESM import in node:
961
- 0 && (module.exports = {
962
- Command,
963
- ConsoleServiceProvider,
964
- Kernel,
965
- MakeCommand,
966
- MigrateCommand,
967
- Musket,
968
- ServeCommand,
969
- Signature,
970
- TableGuesser,
971
- Utils
972
- });
800
+ //#endregion
801
+ exports.Command = Command;
802
+ exports.ConsoleServiceProvider = ConsoleServiceProvider;
803
+ exports.Kernel = Kernel;
804
+ exports.ListCommand = ListCommand;
805
+ exports.MakeCommand = MakeCommand;
806
+ exports.Musket = Musket;
807
+ exports.Signature = Signature;
808
+ exports.TableGuesser = require_Utils.TableGuesser;
809
+ exports.TsDownConfig = TsDownConfig;
810
+ exports.Utils = require_Utils.Utils;
811
+ exports.altLogo = altLogo;
812
+ exports.logo = logo;
813
+ //# sourceMappingURL=index.cjs.map