@h3ravel/console 11.0.7 → 11.1.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-7OrjoB1C.d.cts +22 -0
  4. package/dist/Utils-B1kpj9-1.cjs +130 -0
  5. package/dist/Utils-B1kpj9-1.cjs.map +1 -0
  6. package/dist/Utils-DAJvoXlr.js +86 -0
  7. package/dist/Utils-DAJvoXlr.js.map +1 -0
  8. package/dist/Utils-DxnHOGMz.d.ts +22 -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 +885 -933
  14. package/dist/index.cjs.map +1 -0
  15. package/dist/index.d.cts +270 -290
  16. package/dist/index.d.ts +270 -290
  17. package/dist/index.js +899 -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,319 +1,173 @@
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);
1
+ const require_Utils = require('./Utils-B1kpj9-1.cjs');
2
+ let path = require("path");
3
+ path = require_Utils.__toESM(path);
4
+ let preferred_pm = require("preferred-pm");
5
+ preferred_pm = require_Utils.__toESM(preferred_pm);
6
+ let execa = require("execa");
7
+ execa = require_Utils.__toESM(execa);
8
+ let node_fs_promises = require("node:fs/promises");
9
+ node_fs_promises = require_Utils.__toESM(node_fs_promises);
10
+ let chalk = require("chalk");
11
+ chalk = require_Utils.__toESM(chalk);
12
+ let dayjs = require("dayjs");
13
+ dayjs = require_Utils.__toESM(dayjs);
14
+ let node_fs = require("node:fs");
15
+ node_fs = require_Utils.__toESM(node_fs);
16
+ let node_path = require("node:path");
17
+ node_path = require_Utils.__toESM(node_path);
18
+ let __h3ravel_arquebus_migrations = require("@h3ravel/arquebus/migrations");
19
+ __h3ravel_arquebus_migrations = require_Utils.__toESM(__h3ravel_arquebus_migrations);
20
+ let __h3ravel_database = require("@h3ravel/database");
21
+ __h3ravel_database = require_Utils.__toESM(__h3ravel_database);
22
+ let __h3ravel_core = require("@h3ravel/core");
23
+ __h3ravel_core = require_Utils.__toESM(__h3ravel_core);
24
+ require("@h3ravel/console");
25
+ require("@h3ravel/http");
26
+ require("@h3ravel/router");
27
+ require("@h3ravel/cache");
28
+ require("@h3ravel/queue");
29
+ require("@h3ravel/mail");
30
+ require("@h3ravel/config");
31
+ let __h3ravel_shared = require("@h3ravel/shared");
32
+ __h3ravel_shared = require_Utils.__toESM(__h3ravel_shared);
33
+ let commander = require("commander");
34
+ commander = require_Utils.__toESM(commander);
35
+ let child_process = require("child_process");
36
+ child_process = require_Utils.__toESM(child_process);
30
37
 
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);
46
-
47
- // src/Commands/Command.ts
38
+ //#region src/Commands/Command.ts
48
39
  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
- }
40
+ constructor(app, kernel) {
41
+ this.app = app;
42
+ this.kernel = kernel;
43
+ }
44
+ /**
45
+ * The name and signature of the console command.
46
+ *
47
+ * @var string
48
+ */
49
+ signature;
50
+ /**
51
+ * A dictionary of signatures or what not.
52
+ *
53
+ * @var object
54
+ */
55
+ dictionary = {};
56
+ /**
57
+ * The console command description.
58
+ *
59
+ * @var string
60
+ */
61
+ description;
62
+ /**
63
+ * The console command input.
64
+ *
65
+ * @var object
66
+ */
67
+ input = {
68
+ options: {},
69
+ arguments: {}
70
+ };
71
+ /**
72
+ * Execute the console command.
73
+ */
74
+ async handle(..._args) {}
75
+ setApplication(app) {
76
+ this.app = app;
77
+ }
78
+ setInput(options, args, regArgs, dictionary) {
79
+ this.dictionary = dictionary;
80
+ this.input.options = options;
81
+ this.input.arguments = regArgs.map((e, i) => ({ [e.name()]: args[i] })).reduce((e, x) => Object.assign(e, x), {});
82
+ }
83
+ getSignature() {
84
+ return this.signature;
85
+ }
86
+ getDescription() {
87
+ return this.description;
88
+ }
89
+ option(key, def) {
90
+ return this.input.options[key] ?? def;
91
+ }
92
+ options(key) {
93
+ if (key) return this.input.options[key];
94
+ return this.input.options;
95
+ }
96
+ argument(key, def) {
97
+ return this.input.arguments[key] ?? def;
98
+ }
99
+ arguments() {
100
+ return this.input.arguments;
101
+ }
121
102
  };
122
103
 
123
- // src/Utils.ts
124
- var import_promises = require("fs/promises");
125
- var import_chalk = __toESM(require("chalk"), 1);
126
-
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");
144
-
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
- }
265
- };
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
- }
104
+ //#endregion
105
+ //#region src/Commands/FireCommand.ts
106
+ var FireCommand = class extends Command {
107
+ /**
108
+ * The name and signature of the console command.
109
+ *
110
+ * @var string
111
+ */
112
+ signature = `fire:
113
+ {--a|host=localhost : The host address to serve the application on}
114
+ {--p|port=3000 : The port to serve the application on}
115
+ {--t|tries=10 : The max number of ports to attempt to serve from}
116
+ {--d|debug : Show extra debug info, like registered service providers and more}
117
+ `;
118
+ /**
119
+ * The console command description.
120
+ *
121
+ * @var string
122
+ */
123
+ description = "Fire up the developement server";
124
+ async handle() {
125
+ try {
126
+ await this.fire();
127
+ } catch (e) {
128
+ this.kernel.output.error(e);
129
+ }
130
+ }
131
+ async fire() {
132
+ const outDir$1 = ".h3ravel/serve";
133
+ const pm = (await (0, preferred_pm.default)(base_path()))?.name ?? "pnpm";
134
+ const port = this.option("port");
135
+ const host = this.option("host");
136
+ const tries = this.option("tries");
137
+ const ENV_VARS = {
138
+ EXTENDED_DEBUG: this.option("debug") ? "true" : "false",
139
+ CLI_BUILD: "false",
140
+ NODE_ENV: "development",
141
+ SRC_PATH: outDir$1,
142
+ HOSTNAME: host,
143
+ RETRIES: tries,
144
+ PORT: port
145
+ };
146
+ await (0, execa.execa)(pm, [
147
+ "tsdown",
148
+ "--silent",
149
+ "--config-loader",
150
+ "unconfig",
151
+ "-c",
152
+ "tsdown.default.config.ts"
153
+ ], {
154
+ stdout: "inherit",
155
+ stderr: "inherit",
156
+ cwd: base_path(),
157
+ env: Object.assign({}, process.env, ENV_VARS)
158
+ });
159
+ }
299
160
  };
300
161
 
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);
162
+ //#endregion
163
+ //#region src/Commands/MakeCommand.ts
307
164
  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:
165
+ /**
166
+ * The name and signature of the console command.
167
+ *
168
+ * @var string
169
+ */
170
+ signature = `#make:
317
171
  {controller : Generates a new controller class. | {--a|api : Generate an API resource controller} | {--force : Overide existing controller.} }
318
172
  {resource : Generates a new API resource class.}
319
173
  {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} }
@@ -322,651 +176,749 @@ var MakeCommand = class extends Command {
322
176
  {model : Generates a new Arquebus model class. | {--t|type=ts : The file type to generate}}
323
177
  {^name : The name of the [name] to generate}
324
178
  `;
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
- }
179
+ /**
180
+ * The console command description.
181
+ *
182
+ * @var string
183
+ */
184
+ description = "Generate component classes";
185
+ async handle() {
186
+ const command = this.dictionary.baseCommand;
187
+ const methods = {
188
+ controller: "makeController",
189
+ resource: "makeResource",
190
+ migration: "makeMigration",
191
+ factory: "makeFactory",
192
+ seeder: "makeSeeder",
193
+ model: "makeModel"
194
+ };
195
+ try {
196
+ await this?.[methods[command]]();
197
+ } catch (e) {
198
+ this.kernel.output.error(e);
199
+ }
200
+ }
201
+ /**
202
+ * Generate a new controller class.
203
+ */
204
+ async makeController() {
205
+ const type = this.option("api") ? "-resource" : "";
206
+ const name = this.argument("name");
207
+ const force = this.option("force");
208
+ const path$5 = node_path.default.join(app_path("Http/Controllers"), name + ".ts");
209
+ const crtlrPath = require_Utils.Utils.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
210
+ const stubPath = node_path.default.join(crtlrPath, `dist/stubs/controller${type}.stub`);
211
+ if (!force && (0, node_fs.existsSync)(path$5)) this.kernel.output.error(`ERORR: ${name} controller already exists`);
212
+ let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
213
+ stub = stub.replace(/{{ name }}/g, name);
214
+ await (0, node_fs_promises.writeFile)(path$5, stub);
215
+ this.kernel.output.split(`INFO: Controller Created`, chalk.default.gray(node_path.default.basename(path$5)));
216
+ }
217
+ makeResource() {
218
+ this.kernel.output.success(`Resource support is not yet available`);
219
+ }
220
+ /**
221
+ * Generate a new database migration class
222
+ */
223
+ async makeMigration() {
224
+ const name = this.argument("name");
225
+ const datePrefix = (0, dayjs.default)().format("YYYY_MM_DD_HHmmss");
226
+ const path$5 = node_path.default.join(database_path("migrations"), `${datePrefix}_${name}.ts`);
227
+ const crtlrPath = require_Utils.Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
228
+ let create = this.option("create", false);
229
+ let table = this.option("table");
230
+ if (!table && typeof create === "string") {
231
+ table = create;
232
+ create = true;
233
+ }
234
+ if (!table) {
235
+ const guessed = require_Utils.TableGuesser.guess(name);
236
+ table = guessed[0];
237
+ create = !!guessed[1];
238
+ }
239
+ const stubPath = node_path.default.join(crtlrPath, this.getMigrationStubName(table, create));
240
+ let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
241
+ if (table !== null) stub = stub.replace(/DummyTable|{{\s*table\s*}}/g, table);
242
+ this.kernel.output.info("INFO: Creating Migration");
243
+ await this.kernel.ensureDirectoryExists(node_path.default.dirname(path$5));
244
+ await (0, node_fs_promises.writeFile)(path$5, stub);
245
+ this.kernel.output.split(`INFO: Migration Created`, chalk.default.gray(node_path.default.basename(path$5)));
246
+ }
247
+ makeFactory() {
248
+ this.kernel.output.success(`Factory support is not yet available`);
249
+ }
250
+ makeSeeder() {
251
+ this.kernel.output.success(`Seeder support is not yet available`);
252
+ }
253
+ /**
254
+ * Generate a new Arquebus model class
255
+ */
256
+ async makeModel() {
257
+ const type = this.option("type", "ts");
258
+ const name = this.argument("name");
259
+ const path$5 = node_path.default.join(app_path("Models"), name.toLowerCase() + "." + type);
260
+ const crtlrPath = require_Utils.Utils.findModulePkg("@h3ravel/database", this.kernel.cwd) ?? "";
261
+ const stubPath = node_path.default.join(crtlrPath, `dist/stubs/model-${type}.stub`);
262
+ let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
263
+ stub = stub.replace(/{{ name }}/g, name);
264
+ await (0, node_fs_promises.writeFile)(path$5, stub);
265
+ this.kernel.output.split(`INFO: Model Created`, chalk.default.gray(node_path.default.basename(path$5)));
266
+ }
267
+ /**
268
+ * Ge the database migration file name
269
+ *
270
+ * @param table
271
+ * @param create
272
+ * @param type
273
+ * @returns
274
+ */
275
+ getMigrationStubName(table, create = false, type = "ts") {
276
+ let stub;
277
+ if (!table) stub = `migration-${type}.stub`;
278
+ else if (create) stub = `migration.create-${type}.stub`;
279
+ else stub = `migration.update-${type}.stub`;
280
+ return "dist/stubs/" + stub;
281
+ }
436
282
  };
437
283
 
438
- // src/Commands/MigrateCommand.ts
284
+ //#endregion
285
+ //#region src/Commands/MigrateCommand.ts
439
286
  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:
287
+ /**
288
+ * The current database connection
289
+ */
290
+ connection;
291
+ /**
292
+ * The base path for all database operations
293
+ */
294
+ databasePath = database_path();
295
+ /**
296
+ * The name and signature of the console command.
297
+ *
298
+ * @var string
299
+ */
300
+ signature = `migrate:
449
301
  {fresh : Drop all tables and re-run all migrations.}
450
302
  {install : Create the migration repository.}
451
303
  {refresh : Reset and re-run all migrations.}
452
304
  {reset : Rollback all database migrations.}
453
305
  {rollback : Rollback the last database migration.}
454
306
  {status : Show the status of each migration.}
455
- {publish : Publish any migration files from installed packages.}
307
+ {publish : Publish any migration files from installed packages. | {package : The package to publish migrations from}}
456
308
  {^--s|seed : Seed the database}
309
+ {^--c|connection=mysql : The database connection to use}
457
310
  `;
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
- }
311
+ /**
312
+ * The console command description.
313
+ *
314
+ * @var string
315
+ */
316
+ description = "Run all pending migrations.";
317
+ /**
318
+ * Execute the console command.
319
+ */
320
+ async handle() {
321
+ const command = this.dictionary.name ?? this.dictionary.baseCommand;
322
+ this.connection = Object.entries((0, __h3ravel_database.arquebusConfig)(config("database"))).find(([client]) => client === config("database.default"))?.at(1);
323
+ this.connection.migrations = {
324
+ path: "migrations",
325
+ table: "migrations"
326
+ };
327
+ await this?.[{
328
+ migrate: "migrateRun",
329
+ fresh: "migrateFresh",
330
+ install: "migrateInstall",
331
+ refresh: "migrateRefresh",
332
+ reset: "migrateReset",
333
+ rollback: "migrateRollback",
334
+ status: "migrateStatus",
335
+ publish: "migratePublish"
336
+ }[command]]();
337
+ }
338
+ /**
339
+ * Run all pending migrations.
340
+ */
341
+ async migrateRun() {
342
+ try {
343
+ await new __h3ravel_arquebus_migrations.Migrate(this.databasePath).run(this.connection, this.options(), true);
344
+ } catch (e) {
345
+ this.kernel.output.error("ERROR: " + e);
346
+ }
347
+ }
348
+ /**
349
+ * Drop all tables and re-run all migrations.
350
+ */
351
+ async migrateFresh() {
352
+ try {
353
+ await new __h3ravel_arquebus_migrations.Migrate(this.databasePath).fresh(this.connection, this.options(), true);
354
+ } catch (e) {
355
+ this.kernel.output.error("ERROR: " + e);
356
+ }
357
+ }
358
+ /**
359
+ * Create the migration repository.
360
+ */
361
+ async migrateInstall() {
362
+ try {
363
+ const migrate = new __h3ravel_arquebus_migrations.Migrate(this.databasePath);
364
+ const { migrator } = await migrate.setupConnection(this.connection);
365
+ await migrate.prepareDatabase(migrator);
366
+ this.kernel.output.success(`Migration repository installed.`);
367
+ } catch (e) {
368
+ this.kernel.output.error("ERROR: " + e);
369
+ }
370
+ }
371
+ /**
372
+ * Reset and re-run all migrations.
373
+ */
374
+ async migrateRefresh() {
375
+ try {
376
+ await new __h3ravel_arquebus_migrations.Migrate(this.databasePath).refresh(this.connection, this.options(), true);
377
+ } catch (e) {
378
+ this.kernel.output.error("ERROR: " + e);
379
+ }
380
+ }
381
+ /**
382
+ * Rollback all database migrations.
383
+ */
384
+ async migrateReset() {
385
+ try {
386
+ await new __h3ravel_arquebus_migrations.Migrate(this.databasePath).reset(this.connection, this.options(), true);
387
+ } catch (e) {
388
+ this.kernel.output.error("ERROR: " + e);
389
+ }
390
+ }
391
+ /**
392
+ * Rollback the last database migration.
393
+ */
394
+ async migrateRollback() {
395
+ try {
396
+ await new __h3ravel_arquebus_migrations.Migrate(this.databasePath).rollback(this.connection, this.options(), true);
397
+ } catch (e) {
398
+ this.kernel.output.error("ERROR: " + e);
399
+ }
400
+ }
401
+ /**
402
+ * Show the status of each migration.
403
+ */
404
+ async migrateStatus() {
405
+ const migrations = await new __h3ravel_arquebus_migrations.Migrate(this.databasePath, void 0, (msg, sts) => {
406
+ const hint = this.kernel.output.parse([[" Did you forget to run", "white"], ["`musket migrate:install`?", "grey"]], " ", false);
407
+ if (sts) this.kernel.output[sts](msg + hint, sts === "error", true);
408
+ }).status(this.connection, this.options(), true);
409
+ try {
410
+ if (migrations.length > 0) {
411
+ this.kernel.output.twoColumnLog("Migration name", "Batch / Status");
412
+ migrations.forEach((migration) => {
413
+ const status = migration.ran ? `[${migration.batch}] ${chalk.default.green("Ran")}` : chalk.default.yellow("Pending");
414
+ this.kernel.output.twoColumnLog(migration.name, status);
415
+ });
416
+ } else this.kernel.output.info("No migrations found");
417
+ } catch (e) {
418
+ this.kernel.output.error(["ERROR: " + e, "Did you run musket migrate:install"]);
419
+ }
420
+ }
421
+ /**
422
+ * Publish any migration files from installed packages.
423
+ */
424
+ async migratePublish() {
425
+ const name = this.argument("package");
426
+ try {
427
+ /** Find the requested package */
428
+ const packagePath = require_Utils.Utils.findModulePkg(name) ?? null;
429
+ if (!packagePath) throw new Error("Package not found");
430
+ /** Get the package,json and instanciate the migration creator */
431
+ const pkgJson = await import(node_path.default.join(packagePath, "package.json"));
432
+ const creator = new __h3ravel_arquebus_migrations.MigrationCreator(node_path.default.join(packagePath, pkgJson.migrations ?? "migrations"));
433
+ const info = this.kernel.output.parse([[" Publishing migrations from", "white"], [`${pkgJson.name}@${pkgJson.version}`, chalk.default.italic.gray]], " ", false);
434
+ this.kernel.output.info(`INFO: ${info}`);
435
+ try {
436
+ /** Publish any existing migrations */
437
+ await creator.publish(this.databasePath, (fileName) => {
438
+ this.kernel.output.twoColumnLog(fileName, chalk.default.green("PUBLISHED"));
439
+ });
440
+ } catch {
441
+ this.kernel.output.error([`ERROR: ${name} has no publishable migrations.`]);
442
+ }
443
+ } catch (e) {
444
+ const hint = this.kernel.output.parse([[" Did you forget to run", "white"], [`\`${await require_Utils.Utils.installCommand(name)}\``, "grey"]], " ", false);
445
+ const error = this.kernel.output.parse([
446
+ ["Package `", "white"],
447
+ [name, "grey"],
448
+ ["` not found", "white"]
449
+ ], "", false);
450
+ this.kernel.output.error([
451
+ "ERROR: " + error,
452
+ hint + "?",
453
+ String(e)
454
+ ]);
455
+ }
456
+ }
530
457
  };
531
458
 
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
- }
459
+ //#endregion
460
+ //#region src/Signature.ts
461
+ var Signature = class Signature {
462
+ /**
463
+ * Helper to parse options inside a block of text
464
+ *
465
+ * @param block
466
+ * @returns
467
+ */
468
+ static parseOptions(block) {
469
+ const options = [];
470
+ /**
471
+ * Match { ... } blocks at top level
472
+ */
473
+ const regex = /\{([^{}]+(?:\{[^{}]*\}[^{}]*)*)\}/g;
474
+ let match;
475
+ while ((match = regex.exec(block)) !== null) {
476
+ const shared = "^" === match[1][0] || /:[#^]/.test(match[1]);
477
+ const isHidden = (["#", "^"].includes(match[1][0]) || /:[#^]/.test(match[1])) && !shared;
478
+ const content = match[1].trim().replace(/[#^]/, "");
479
+ /**
480
+ * Split by first ':' to separate name and description+nested
481
+ */
482
+ const colonIndex = content.indexOf(":");
483
+ if (colonIndex === -1) {
484
+ /**
485
+ * No description, treat whole as name
486
+ */
487
+ options.push({ name: content });
488
+ continue;
489
+ }
490
+ const namePart = content.substring(0, colonIndex).trim();
491
+ let rest = content.substring(colonIndex + 1).trim();
492
+ /**
493
+ * Check for nested options after '|'
494
+ */
495
+ let description = rest;
496
+ let nestedOptions;
497
+ const pipeIndex = rest.indexOf("|");
498
+ if (pipeIndex !== -1) {
499
+ description = rest.substring(0, pipeIndex).trim();
500
+ /**
501
+ * nestedText should start with '{' and end with ')', clean it
502
+ * Also Remove trailing ')' if present
503
+ */
504
+ const cleanedNestedText = rest.substring(pipeIndex + 1).trim().replace(/^\{/, "").trim();
505
+ /**
506
+ * Parse nested options recursively
507
+ */
508
+ nestedOptions = Signature.parseOptions("{" + cleanedNestedText + "}");
509
+ } else
510
+ /**
511
+ * Trim the string
512
+ */
513
+ description = description.trim();
514
+ /**
515
+ * Parse name modifiers (?, *, ?*)
516
+ */
517
+ let name = namePart;
518
+ let required = /[^a-zA-Z0-9_|-]/.test(name);
519
+ let multiple = false;
520
+ if (name.endsWith("?*")) {
521
+ required = false;
522
+ multiple = true;
523
+ name = name.slice(0, -2);
524
+ } else if (name.endsWith("*")) {
525
+ multiple = true;
526
+ name = name.slice(0, -1);
527
+ } else if (name.endsWith("?")) {
528
+ required = false;
529
+ name = name.slice(0, -1);
530
+ }
531
+ /**
532
+ * Check if it's a flag option (starts with --)
533
+ */
534
+ const isFlag = name.startsWith("--");
535
+ let flags;
536
+ let defaultValue;
537
+ if (isFlag) {
538
+ /**
539
+ * Parse flags and default values
540
+ */
541
+ const flagParts = name.split("|").map((s) => s.trim());
542
+ flags = [];
543
+ for (let part of flagParts) {
544
+ if (part.startsWith("--") && part.slice(2).length === 1) part = "-" + part.slice(2);
545
+ else if (part.startsWith("-") && !part.startsWith("--") && part.slice(1).length > 1) part = "--" + part.slice(1);
546
+ else if (!part.startsWith("-") && part.slice(1).length > 1) part = "--" + part;
547
+ const eqIndex = part.indexOf("=");
548
+ if (eqIndex !== -1) {
549
+ flags.push(part.substring(0, eqIndex));
550
+ const val = part.substring(eqIndex + 1);
551
+ if (val === "*") defaultValue = [];
552
+ else if (val === "true" || val === "false" || !val && !required) defaultValue = val === "true";
553
+ else if (!isNaN(Number(val))) defaultValue = Number(val);
554
+ else defaultValue = val;
555
+ } else flags.push(part);
556
+ }
557
+ }
558
+ options.push({
559
+ name: isFlag ? flags[flags.length - 1] : name,
560
+ required,
561
+ multiple,
562
+ description,
563
+ flags,
564
+ shared,
565
+ isFlag,
566
+ isHidden,
567
+ defaultValue,
568
+ nestedOptions
569
+ });
570
+ }
571
+ return options;
572
+ }
573
+ /**
574
+ * Helper to parse a command's signature
575
+ *
576
+ * @param signature
577
+ * @param commandClass
578
+ * @returns
579
+ */
580
+ static parseSignature(signature, commandClass) {
581
+ const lines = signature.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
582
+ const isHidden = ["#", "^"].includes(lines[0][0]) || /:[#^]/.test(lines[0]);
583
+ const baseCommand = lines[0].replace(/[^\w=:-]/g, "");
584
+ const description = commandClass.getDescription();
585
+ const isNamespaceCommand = baseCommand.endsWith(":");
586
+ /**
587
+ * Join the rest lines to a single string for parsing
588
+ */
589
+ const rest = lines.slice(1).join(" ");
590
+ /**
591
+ * Parse all top-level options/subcommands
592
+ */
593
+ const allOptions = Signature.parseOptions(rest);
594
+ if (isNamespaceCommand)
595
+ /**
596
+ * Separate subcommands (those without flags) and base options (flags)
597
+ * Here we assume subcommands are those without flags (isFlag false)
598
+ * and base options are flags or options after subcommands
599
+
600
+ * For simplicity, treat all top-level options as subcommands
601
+ * and assume base command options come after subcommands in signature (not shown in example)
602
+ */
603
+ return {
604
+ baseCommand: baseCommand.slice(0, -1),
605
+ isNamespaceCommand,
606
+ subCommands: allOptions.filter((e) => !e.flags && !e.isHidden),
607
+ description,
608
+ commandClass,
609
+ options: allOptions.filter((e) => !!e.flags),
610
+ isHidden
611
+ };
612
+ else return {
613
+ baseCommand,
614
+ isNamespaceCommand,
615
+ options: allOptions,
616
+ description,
617
+ commandClass,
618
+ isHidden
619
+ };
620
+ }
583
621
  };
584
622
 
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
- }
623
+ //#endregion
624
+ //#region src/Musket.ts
625
+ /**
626
+ * Musket is H3ravel's CLI tool
627
+ */
628
+ var Musket = class Musket {
629
+ output = __h3ravel_shared.Logger.log();
630
+ commands = [];
631
+ constructor(app, kernel) {
632
+ this.app = app;
633
+ this.kernel = kernel;
634
+ }
635
+ async build() {
636
+ this.loadBaseCommands();
637
+ await this.loadDiscoveredCommands();
638
+ return this.initialize();
639
+ }
640
+ loadBaseCommands() {
641
+ [
642
+ new FireCommand(this.app, this.kernel),
643
+ new MakeCommand(this.app, this.kernel),
644
+ new MigrateCommand(this.app, this.kernel)
645
+ ].forEach((e) => this.addCommand(e));
646
+ }
647
+ async loadDiscoveredCommands() {
648
+ const commands = [...this.app.registeredCommands.map((cmd) => new cmd(this.app, this.kernel))];
649
+ /**
650
+ * Musket Commands auto registration
651
+ */
652
+ const providers_path = app_path("Console/Commands/*.js").replace("/src/", "/.h3ravel/serve/");
653
+ /** Add the App Commands */
654
+ for await (const cmd of (0, node_fs_promises.glob)(providers_path)) {
655
+ const name = node_path.default.basename(cmd).replace(".js", "");
656
+ try {
657
+ const cmdClass = (await import(cmd))[name];
658
+ commands.push(new cmdClass(this.app, this.kernel));
659
+ } catch {}
660
+ }
661
+ commands.forEach((e) => this.addCommand(e));
662
+ }
663
+ addCommand(command) {
664
+ this.commands.push(Signature.parseSignature(command.getSignature(), command));
665
+ }
666
+ initialize() {
667
+ const cliVersion = ["H3ravel Version:", chalk.default.green(this.kernel.consolePackage.version)].join(" ");
668
+ const localVersion = ["Musket Version:", chalk.default.green(this.kernel.modulePackage.version || "None")].join(" ");
669
+ commander.program.name("musket").version(`${cliVersion}\n${localVersion}`);
670
+ commander.program.command("init").description("Initialize H3ravel.").action(async () => {
671
+ this.output.success(`Initialized: H3ravel has been initialized!`);
672
+ });
673
+ for (let i = 0; i < this.commands.length; i++) {
674
+ const command = this.commands[i];
675
+ const instance = command.commandClass;
676
+ if (command.isNamespaceCommand && command.subCommands) {
677
+ /**
678
+ * Initialize the base command
679
+ */
680
+ const cmd = command.isHidden ? commander.program : commander.program.command(command.baseCommand).description(command.description ?? "").action(async () => {
681
+ instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command);
682
+ await instance.handle();
683
+ });
684
+ /**
685
+ * Add options to the base command if it has any
686
+ */
687
+ if ((command.options?.length ?? 0) > 0) command.options?.filter((v, i$1, a) => a.findIndex((t) => t.name === v.name) === i$1).forEach((opt) => {
688
+ this.makeOption(opt, cmd);
689
+ });
690
+ /**
691
+ * Initialize the sub commands
692
+ */
693
+ command.subCommands.filter((v, i$1, a) => !v.shared && a.findIndex((t) => t.name === v.name) === i$1).forEach((sub) => {
694
+ const cmd$1 = commander.program.command(`${command.baseCommand}:${sub.name}`).description(sub.description || "").action(async () => {
695
+ instance.setInput(cmd$1.opts(), cmd$1.args, cmd$1.registeredArguments, sub);
696
+ await instance.handle();
697
+ });
698
+ /**
699
+ * Add the shared arguments here
700
+ */
701
+ command.subCommands?.filter((e) => e.shared).forEach((opt) => {
702
+ this.makeOption(opt, cmd$1, false, sub);
703
+ });
704
+ /**
705
+ * Add the shared options here
706
+ */
707
+ command.options?.filter((e) => e.shared).forEach((opt) => {
708
+ this.makeOption(opt, cmd$1, false, sub);
709
+ });
710
+ /**
711
+ * Add options to the sub command if it has any
712
+ */
713
+ if (sub.nestedOptions) sub.nestedOptions.filter((v, i$1, a) => a.findIndex((t) => t.name === v.name) === i$1).forEach((opt) => {
714
+ this.makeOption(opt, cmd$1);
715
+ });
716
+ });
717
+ } else {
718
+ /**
719
+ * Initialize command with options
720
+ */
721
+ const cmd = commander.program.command(command.baseCommand).description(command.description ?? "");
722
+ command?.options?.filter((v, i$1, a) => a.findIndex((t) => t.name === v.name) === i$1).forEach((opt) => {
723
+ this.makeOption(opt, cmd, true);
724
+ });
725
+ cmd.action(async () => {
726
+ instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command);
727
+ await instance.handle();
728
+ });
729
+ }
730
+ }
731
+ return commander.program;
732
+ }
733
+ makeOption(opt, cmd, parse, parent) {
734
+ const description = opt.description?.replace(/\[(\w+)\]/g, (_, k) => parent?.[k] ?? `[${k}]`) ?? "";
735
+ const type = opt.name.replaceAll("-", "");
736
+ if (opt.isFlag) if (parse) {
737
+ const flags = opt.flags?.map((f) => f.length === 1 ? `-${f}` : `--${f}`).join(", ").replaceAll("----", "--").replaceAll("---", "-");
738
+ cmd.option(flags || "", description, String(opt.defaultValue) || void 0);
739
+ } else cmd.option(opt.flags?.join(", ") + (opt.required ? ` <${type}>` : ""), description, opt.defaultValue);
740
+ else cmd.argument(opt.required ? `<${opt.name}>` : `[${opt.name}]`, description, opt.defaultValue);
741
+ }
742
+ static async parse(kernel) {
743
+ return (await new Musket(kernel.app, kernel).build()).parseAsync();
744
+ }
742
745
  };
743
746
 
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
- }
747
+ //#endregion
748
+ //#region src/Kernel.ts
749
+ var Kernel = class Kernel {
750
+ cwd;
751
+ output = __h3ravel_shared.Logger.log();
752
+ basePath = "";
753
+ modulePath;
754
+ consolePath;
755
+ modulePackage;
756
+ consolePackage;
757
+ constructor(app) {
758
+ this.app = app;
759
+ }
760
+ static init(app) {
761
+ const instance = new Kernel(app);
762
+ Promise.all([instance.loadRequirements()]).then(([e]) => e.run());
763
+ }
764
+ async run() {
765
+ await Musket.parse(this);
766
+ process.exit(0);
767
+ }
768
+ async ensureDirectoryExists(dir) {
769
+ await (0, node_fs_promises.mkdir)(dir, { recursive: true });
770
+ }
771
+ async loadRequirements() {
772
+ this.cwd = node_path.default.join(process.cwd(), this.basePath);
773
+ this.modulePath = require_Utils.Utils.findModulePkg("@h3ravel/core", this.cwd) ?? "";
774
+ this.consolePath = require_Utils.Utils.findModulePkg("@h3ravel/console", this.cwd) ?? "";
775
+ try {
776
+ this.modulePackage = await import(node_path.default.join(this.modulePath, "package.json"));
777
+ } catch {
778
+ this.modulePackage = { version: "N/A" };
779
+ }
780
+ try {
781
+ this.consolePackage = await import(node_path.default.join(this.consolePath, "package.json"));
782
+ } catch {
783
+ this.consolePackage = { version: "N/A" };
784
+ }
785
+ return this;
786
+ }
853
787
  };
854
788
 
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
- }
789
+ //#endregion
790
+ //#region src/Providers/ConsoleServiceProvider.ts
791
+ /**
792
+ * Handles CLI commands and tooling.
793
+ *
794
+ * Register DatabaseManager and QueryBuilder.
795
+ * Set up ORM models and relationships.
796
+ * Register migration and seeder commands.
797
+ *
798
+ * Auto-Registered when in CLI mode
799
+ */
800
+ var ConsoleServiceProvider = class extends __h3ravel_core.ServiceProvider {
801
+ static priority = 992;
802
+ /**
803
+ * Indicate that this service provider only runs in console
804
+ */
805
+ static console = true;
806
+ register() {}
807
+ boot() {
808
+ Kernel.init(this.app);
809
+ process.on("SIGINT", () => {
810
+ process.exit(0);
811
+ });
812
+ process.on("SIGTERM", () => {
813
+ process.exit(0);
814
+ });
815
+ }
908
816
  };
909
817
 
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
- }
929
- };
930
-
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
- ];
818
+ //#endregion
819
+ //#region ../../node_modules/.pnpm/@rollup+plugin-run@3.1.0/node_modules/@rollup/plugin-run/dist/es/index.js
820
+ function run(opts = {}) {
821
+ let input;
822
+ let proc;
823
+ const args = opts.args || [];
824
+ const allowRestarts = opts.allowRestarts || false;
825
+ const overrideInput = opts.input;
826
+ const forkOptions = opts.options || opts;
827
+ delete forkOptions.args;
828
+ delete forkOptions.allowRestarts;
829
+ return {
830
+ name: "run",
831
+ buildStart(options) {
832
+ let inputs = overrideInput !== null && overrideInput !== void 0 ? overrideInput : options.input;
833
+ if (typeof inputs === "string") inputs = [inputs];
834
+ if (typeof inputs === "object") inputs = Object.values(inputs);
835
+ if (inputs.length > 1) throw new Error(`@rollup/plugin-run must have a single entry point; consider setting the \`input\` option`);
836
+ input = (0, path.resolve)(inputs[0]);
837
+ },
838
+ generateBundle(_outputOptions, _bundle, isWrite) {
839
+ if (!isWrite) this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`);
840
+ },
841
+ writeBundle(outputOptions, bundle) {
842
+ const forkBundle = (dir$1, entryFileName$1) => {
843
+ if (proc) proc.kill();
844
+ proc = (0, child_process.fork)((0, path.join)(dir$1, entryFileName$1), args, forkOptions);
845
+ };
846
+ const dir = outputOptions.dir || (0, path.dirname)(outputOptions.file);
847
+ const entryFileName = Object.keys(bundle).find((fileName) => {
848
+ const chunk = bundle[fileName];
849
+ return chunk.isEntry && chunk.facadeModuleId === input;
850
+ });
851
+ if (entryFileName) {
852
+ forkBundle(dir, entryFileName);
853
+ if (allowRestarts) {
854
+ process.stdin.resume();
855
+ process.stdin.setEncoding("utf8");
856
+ process.stdin.on("data", (data) => {
857
+ const line = data.toString().trim().toLowerCase();
858
+ if (line === "rs" || line === "restart" || data.toString().charCodeAt(0) === 11) forkBundle(dir, entryFileName);
859
+ else if (line === "cls" || line === "clear" || data.toString().charCodeAt(0) === 12) console.clear();
860
+ });
861
+ }
862
+ } else this.error(`@rollup/plugin-run could not find output chunk`);
863
+ }
864
+ };
865
+ }
943
866
 
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
- }
867
+ //#endregion
868
+ //#region src/TsdownConfig.ts
869
+ const env = process.env.NODE_ENV || "development";
870
+ const outDir = env === "development" ? ".h3ravel/serve" : "dist";
871
+ const TsDownConfig = {
872
+ outDir,
873
+ entry: ["src/**/*.ts"],
874
+ format: ["esm"],
875
+ target: "node22",
876
+ sourcemap: env === "development",
877
+ clean: true,
878
+ shims: true,
879
+ copy: [
880
+ {
881
+ from: "public",
882
+ to: outDir
883
+ },
884
+ "src/resources",
885
+ "src/database"
886
+ ],
887
+ env: env === "development" ? {
888
+ NODE_ENV: env,
889
+ SRC_PATH: outDir
890
+ } : {},
891
+ watch: env === "development" && process.env.CLI_BUILD !== "true" ? [
892
+ ".env",
893
+ ".env.*",
894
+ "src",
895
+ "../../packages"
896
+ ] : false,
897
+ dts: false,
898
+ logLevel: "silent",
899
+ nodeProtocol: true,
900
+ skipNodeModulesBundle: true,
901
+ plugins: env === "development" && process.env.CLI_BUILD !== "true" ? [run({
902
+ env: Object.assign({}, process.env, {
903
+ NODE_ENV: env,
904
+ SRC_PATH: outDir
905
+ }),
906
+ execArgv: ["-r", "source-map-support/register"],
907
+ allowRestarts: false,
908
+ input: process.cwd() + "/src/server.ts"
909
+ })] : []
955
910
  };
956
911
 
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
- });
912
+ //#endregion
913
+ exports.Command = Command;
914
+ exports.ConsoleServiceProvider = ConsoleServiceProvider;
915
+ exports.FireCommand = FireCommand;
916
+ exports.Kernel = Kernel;
917
+ exports.MakeCommand = MakeCommand;
918
+ exports.MigrateCommand = MigrateCommand;
919
+ exports.Musket = Musket;
920
+ exports.Signature = Signature;
921
+ exports.TableGuesser = require_Utils.TableGuesser;
922
+ exports.TsDownConfig = TsDownConfig;
923
+ exports.Utils = require_Utils.Utils;
924
+ //# sourceMappingURL=index.cjs.map