@h3ravel/console 11.9.1 → 11.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/fire.cjs +3 -37
- package/bin/fire.js +3 -37
- package/dist/index.cjs +64 -602
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -151
- package/dist/index.d.ts +4 -151
- package/dist/index.js +53 -587
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -23,8 +23,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
let __h3ravel_shared = require("@h3ravel/shared");
|
|
25
25
|
__h3ravel_shared = __toESM(__h3ravel_shared);
|
|
26
|
-
let
|
|
27
|
-
|
|
26
|
+
let __h3ravel_musket = require("@h3ravel/musket");
|
|
27
|
+
__h3ravel_musket = __toESM(__h3ravel_musket);
|
|
28
28
|
let execa = require("execa");
|
|
29
29
|
execa = __toESM(execa);
|
|
30
30
|
let preferred_pm = require("preferred-pm");
|
|
@@ -35,19 +35,17 @@ let __h3ravel_support = require("@h3ravel/support");
|
|
|
35
35
|
__h3ravel_support = __toESM(__h3ravel_support);
|
|
36
36
|
let node_path = require("node:path");
|
|
37
37
|
node_path = __toESM(node_path);
|
|
38
|
-
let
|
|
39
|
-
|
|
38
|
+
let __h3ravel_core = require("@h3ravel/core");
|
|
39
|
+
__h3ravel_core = __toESM(__h3ravel_core);
|
|
40
40
|
let node_fs = require("node:fs");
|
|
41
41
|
node_fs = __toESM(node_fs);
|
|
42
42
|
let child_process = require("child_process");
|
|
43
43
|
child_process = __toESM(child_process);
|
|
44
44
|
let path = require("path");
|
|
45
45
|
path = __toESM(path);
|
|
46
|
-
let tsdown = require("tsdown");
|
|
47
|
-
tsdown = __toESM(tsdown);
|
|
48
46
|
|
|
49
47
|
//#region src/Commands/BuildCommand.ts
|
|
50
|
-
var BuildCommand = class BuildCommand extends
|
|
48
|
+
var BuildCommand = class BuildCommand extends __h3ravel_musket.Command {
|
|
51
49
|
/**
|
|
52
50
|
* The name and signature of the console command.
|
|
53
51
|
*
|
|
@@ -142,149 +140,9 @@ var BuildCommand = class BuildCommand extends __h3ravel_core.ConsoleCommand {
|
|
|
142
140
|
}
|
|
143
141
|
};
|
|
144
142
|
|
|
145
|
-
//#endregion
|
|
146
|
-
//#region src/Commands/Command.ts
|
|
147
|
-
var Command = class extends __h3ravel_core.ConsoleCommand {};
|
|
148
|
-
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region src/Commands/HelpCommand.ts
|
|
151
|
-
var HelpCommand = class extends Command {
|
|
152
|
-
/**
|
|
153
|
-
* The name and signature of the console command.
|
|
154
|
-
*
|
|
155
|
-
* @var string
|
|
156
|
-
*/
|
|
157
|
-
signature = `help
|
|
158
|
-
{command_name=help : The command name}
|
|
159
|
-
{--format=txt : The output format}
|
|
160
|
-
`;
|
|
161
|
-
/**
|
|
162
|
-
* The console command description.
|
|
163
|
-
*
|
|
164
|
-
* @var string
|
|
165
|
-
*/
|
|
166
|
-
description = "Display help for a command";
|
|
167
|
-
async handle() {
|
|
168
|
-
const cmd = this.argument("command_name");
|
|
169
|
-
if (!cmd) {
|
|
170
|
-
this.program.outputHelp();
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
const target = this.program.commands.find((c) => c.name() === cmd);
|
|
174
|
-
if (!target) {
|
|
175
|
-
this.error(`ERROR: Unknown command: ${__h3ravel_shared.Logger.log(cmd, ["italic", "grey"], false)}.`);
|
|
176
|
-
process.exit(1);
|
|
177
|
-
}
|
|
178
|
-
target.outputHelp();
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region src/logo.ts
|
|
184
|
-
const logo = String.raw`
|
|
185
|
-
111
|
|
186
|
-
111111111
|
|
187
|
-
1111111111 111111
|
|
188
|
-
111111 111 111111
|
|
189
|
-
111111 111 111111
|
|
190
|
-
11111 111 11111
|
|
191
|
-
1111111 111 1111111
|
|
192
|
-
111 11111 111 111111 111 1111 1111 11111111 1111
|
|
193
|
-
111 11111 1111 111111 111 1111 1111 1111 11111 1111
|
|
194
|
-
111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
|
|
195
|
-
111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
|
|
196
|
-
111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
|
|
197
|
-
111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
|
|
198
|
-
111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
|
|
199
|
-
1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
|
|
200
|
-
11011 111111 11 11111
|
|
201
|
-
111111 11101 111111
|
|
202
|
-
111111 111 111111
|
|
203
|
-
111111 111 111111
|
|
204
|
-
111111111
|
|
205
|
-
110
|
|
206
|
-
`;
|
|
207
|
-
const altLogo = String.raw`
|
|
208
|
-
_ _ _____ _
|
|
209
|
-
| | | |___ / _ __ __ ___ _____| |
|
|
210
|
-
| |_| | |_ \| '__/ _ \ \ / / _ \ |
|
|
211
|
-
| _ |___) | | | (_| |\ V / __/ |
|
|
212
|
-
|_| |_|____/|_| \__,_| \_/ \___|_|
|
|
213
|
-
|
|
214
|
-
`;
|
|
215
|
-
|
|
216
|
-
//#endregion
|
|
217
|
-
//#region src/Commands/ListCommand.ts
|
|
218
|
-
var ListCommand = class ListCommand extends Command {
|
|
219
|
-
/**
|
|
220
|
-
* The name and signature of the console command.
|
|
221
|
-
*
|
|
222
|
-
* @var string
|
|
223
|
-
*/
|
|
224
|
-
signature = "list";
|
|
225
|
-
/**
|
|
226
|
-
* The console command description.
|
|
227
|
-
*
|
|
228
|
-
* @var string
|
|
229
|
-
*/
|
|
230
|
-
description = "List all available commands";
|
|
231
|
-
async handle() {
|
|
232
|
-
const options = [{
|
|
233
|
-
short: "-h",
|
|
234
|
-
long: "--help",
|
|
235
|
-
description: "Display help for the given command. When no command is given display help for the list command"
|
|
236
|
-
}].concat(this.program.options).map((e) => {
|
|
237
|
-
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("");
|
|
238
|
-
});
|
|
239
|
-
/** Get the program commands */
|
|
240
|
-
const commands = this.program.commands.map((e) => {
|
|
241
|
-
return __h3ravel_shared.Logger.describe(__h3ravel_shared.Logger.log(" " + e.name(), "green", false), e.description(), 25, false).join("");
|
|
242
|
-
});
|
|
243
|
-
const list = ListCommand.groupItems(commands);
|
|
244
|
-
/** Ootput the app version */
|
|
245
|
-
__h3ravel_shared.Logger.log([["H3ravel Framework", "white"], [this.kernel.modulePackage.version, "green"]], " ");
|
|
246
|
-
console.log("");
|
|
247
|
-
console.log(altLogo);
|
|
248
|
-
console.log("");
|
|
249
|
-
__h3ravel_shared.Logger.log("Usage:", "yellow");
|
|
250
|
-
__h3ravel_shared.Logger.log(" command [options] [arguments]", "white");
|
|
251
|
-
console.log("");
|
|
252
|
-
/** Ootput the options */
|
|
253
|
-
__h3ravel_shared.Logger.log("Options:", "yellow");
|
|
254
|
-
console.log(options.join("\n").trim());
|
|
255
|
-
console.log("");
|
|
256
|
-
/** Ootput the commands */
|
|
257
|
-
__h3ravel_shared.Logger.log("Available Commands:", "yellow");
|
|
258
|
-
console.log(list.join("\n\n").trim());
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Group Commands based on thier names
|
|
262
|
-
*
|
|
263
|
-
* @param commands
|
|
264
|
-
* @returns
|
|
265
|
-
*/
|
|
266
|
-
static groupItems(commands, fmtd = false) {
|
|
267
|
-
const grouped = commands.reduce((acc, cmd) => {
|
|
268
|
-
/** strip colors before checking prefix */
|
|
269
|
-
const clean = cmd.replace(/\x1b\[\d+m/g, "");
|
|
270
|
-
const prefix = clean.includes(":") ? clean.split(":")[0].trim() : "__root__";
|
|
271
|
-
acc[prefix] ??= [];
|
|
272
|
-
/** keep original with colors */
|
|
273
|
-
acc[prefix].push(cmd);
|
|
274
|
-
return acc;
|
|
275
|
-
}, {});
|
|
276
|
-
return Object.entries(grouped).map(([group, cmds]) => {
|
|
277
|
-
const label = group === "__root__" ? "" : group;
|
|
278
|
-
let out = [__h3ravel_shared.Logger.log(label, "yellow", false), cmds.join("\n")].join("\n");
|
|
279
|
-
if (fmtd) out += "\n";
|
|
280
|
-
return out;
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
|
|
285
143
|
//#endregion
|
|
286
144
|
//#region src/Commands/MakeCommand.ts
|
|
287
|
-
var MakeCommand = class extends Command {
|
|
145
|
+
var MakeCommand = class extends __h3ravel_musket.Command {
|
|
288
146
|
/**
|
|
289
147
|
* The name and signature of the console command.
|
|
290
148
|
*
|
|
@@ -335,15 +193,15 @@ var MakeCommand = class extends Command {
|
|
|
335
193
|
const force = this.option("force");
|
|
336
194
|
const crtlrPath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
|
|
337
195
|
const stubPath = node_path.default.join(crtlrPath, `dist/stubs/controller${type}.stub`);
|
|
338
|
-
const path$
|
|
196
|
+
const path$4 = app_path(`Http/Controllers/${name}.ts`);
|
|
339
197
|
/** The Controller is scoped to a path make sure to create the associated directories */
|
|
340
|
-
if (name.includes("/")) await (0, node_fs_promises.mkdir)(__h3ravel_support.Str.beforeLast(path$
|
|
198
|
+
if (name.includes("/")) await (0, node_fs_promises.mkdir)(__h3ravel_support.Str.beforeLast(path$4, "/"), { recursive: true });
|
|
341
199
|
/** Check if the controller already exists */
|
|
342
|
-
if (!force && await __h3ravel_shared.FileSystem.fileExists(path$
|
|
200
|
+
if (!force && await __h3ravel_shared.FileSystem.fileExists(path$4)) __h3ravel_shared.Logger.error(`ERORR: ${name} controller already exists`);
|
|
343
201
|
let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
|
|
344
202
|
stub = stub.replace(/{{ name }}/g, name);
|
|
345
|
-
await (0, node_fs_promises.writeFile)(path$
|
|
346
|
-
__h3ravel_shared.Logger.split("INFO: Controller Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$
|
|
203
|
+
await (0, node_fs_promises.writeFile)(path$4, stub);
|
|
204
|
+
__h3ravel_shared.Logger.split("INFO: Controller Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$4), "gray", false));
|
|
347
205
|
}
|
|
348
206
|
makeResource() {
|
|
349
207
|
__h3ravel_shared.Logger.success("Resource support is not yet available");
|
|
@@ -360,19 +218,19 @@ var MakeCommand = class extends Command {
|
|
|
360
218
|
async makeView() {
|
|
361
219
|
const name = this.argument("name");
|
|
362
220
|
const force = this.option("force");
|
|
363
|
-
const path$
|
|
221
|
+
const path$4 = base_path(`src/resources/views/${name}.edge`);
|
|
364
222
|
/** The view is scoped to a path make sure to create the associated directories */
|
|
365
|
-
if (name.includes("/")) await (0, node_fs_promises.mkdir)(__h3ravel_support.Str.beforeLast(path$
|
|
223
|
+
if (name.includes("/")) await (0, node_fs_promises.mkdir)(__h3ravel_support.Str.beforeLast(path$4, "/"), { recursive: true });
|
|
366
224
|
/** Check if the view already exists */
|
|
367
|
-
if (!force && await __h3ravel_shared.FileSystem.fileExists(path$
|
|
368
|
-
await (0, node_fs_promises.writeFile)(path$
|
|
225
|
+
if (!force && await __h3ravel_shared.FileSystem.fileExists(path$4)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
|
|
226
|
+
await (0, node_fs_promises.writeFile)(path$4, `{{-- src/resources/views/${name}.edge --}}`);
|
|
369
227
|
__h3ravel_shared.Logger.split("INFO: View Created", __h3ravel_shared.Logger.log(`src/resources/views/${name}.edge`, "gray", false));
|
|
370
228
|
}
|
|
371
229
|
};
|
|
372
230
|
|
|
373
231
|
//#endregion
|
|
374
232
|
//#region src/Commands/PostinstallCommand.ts
|
|
375
|
-
var PostinstallCommand = class extends Command {
|
|
233
|
+
var PostinstallCommand = class extends __h3ravel_musket.Command {
|
|
376
234
|
/**
|
|
377
235
|
* The name and signature of the console command.
|
|
378
236
|
*
|
|
@@ -401,190 +259,38 @@ var PostinstallCommand = class extends Command {
|
|
|
401
259
|
};
|
|
402
260
|
|
|
403
261
|
//#endregion
|
|
404
|
-
//#region src/
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Check for nested options after '|'
|
|
438
|
-
*/
|
|
439
|
-
let description = rest;
|
|
440
|
-
let nestedOptions;
|
|
441
|
-
const pipeIndex = rest.indexOf("|");
|
|
442
|
-
if (pipeIndex !== -1) {
|
|
443
|
-
description = rest.substring(0, pipeIndex).trim();
|
|
444
|
-
/**
|
|
445
|
-
* nestedText should start with '{' and end with ')', clean it
|
|
446
|
-
* Also Remove trailing ')' if present
|
|
447
|
-
*/
|
|
448
|
-
const cleanedNestedText = rest.substring(pipeIndex + 1).trim().replace(/^\{/, "").trim();
|
|
449
|
-
/**
|
|
450
|
-
* Parse nested options recursively
|
|
451
|
-
*/
|
|
452
|
-
nestedOptions = Signature.parseOptions("{" + cleanedNestedText + "}");
|
|
453
|
-
} else
|
|
454
|
-
/**
|
|
455
|
-
* Trim the string
|
|
456
|
-
*/
|
|
457
|
-
description = description.trim();
|
|
458
|
-
let name = namePart;
|
|
459
|
-
let flags;
|
|
460
|
-
let choices = [];
|
|
461
|
-
let required = /[^a-zA-Z0-9_|-]/.test(name);
|
|
462
|
-
let multiple = false;
|
|
463
|
-
let placeholder;
|
|
464
|
-
let defaultValue;
|
|
465
|
-
/**
|
|
466
|
-
* Parse the command name
|
|
467
|
-
*/
|
|
468
|
-
if (name.includes("=")) {
|
|
469
|
-
const [rawName, rawDefault] = name.split("=");
|
|
470
|
-
name = rawName.trim();
|
|
471
|
-
const hold = rawName.trim().split("|");
|
|
472
|
-
const holder = (hold.at(1) ?? hold.at(0)).replace("--", "");
|
|
473
|
-
defaultValue = rawDefault.trim();
|
|
474
|
-
placeholder = defaultValue ? `[${holder}]` : `<${holder}>`;
|
|
475
|
-
required = false;
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Parse name modifiers (?, *, ?*)
|
|
479
|
-
*/
|
|
480
|
-
if (name.endsWith("?*")) {
|
|
481
|
-
required = false;
|
|
482
|
-
multiple = true;
|
|
483
|
-
name = name.slice(0, -2);
|
|
484
|
-
} else if (name.endsWith("*")) {
|
|
485
|
-
multiple = true;
|
|
486
|
-
name = name.slice(0, -1);
|
|
487
|
-
} else if (name.endsWith("?")) {
|
|
488
|
-
required = false;
|
|
489
|
-
name = name.slice(0, -1);
|
|
490
|
-
placeholder = `[${name.split("--").at(1)?.split("|").at(1) ?? name}]`;
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Check if it's a flag option (starts with --)
|
|
494
|
-
*/
|
|
495
|
-
const isFlag = name.startsWith("--");
|
|
496
|
-
if (isFlag) {
|
|
497
|
-
/**
|
|
498
|
-
* Parse flags and default values
|
|
499
|
-
*/
|
|
500
|
-
const flagParts = name.split("|").map((s) => s.trim());
|
|
501
|
-
flags = [];
|
|
502
|
-
for (let part of flagParts) {
|
|
503
|
-
if (part.startsWith("--") && part.slice(2).length === 1) part = "-" + part.slice(2);
|
|
504
|
-
else if (part.startsWith("-") && !part.startsWith("--") && part.slice(1).length > 1) part = "--" + part.slice(1);
|
|
505
|
-
else if (!part.startsWith("-") && part.slice(1).length > 1) part = "--" + part;
|
|
506
|
-
const eqIndex = part.indexOf("=");
|
|
507
|
-
if (eqIndex !== -1) {
|
|
508
|
-
flags.push(part.substring(0, eqIndex));
|
|
509
|
-
const val = part.substring(eqIndex + 1);
|
|
510
|
-
if (val === "*") defaultValue = [];
|
|
511
|
-
else if (val === "true" || val === "false" || !val && !required) defaultValue = val === "true";
|
|
512
|
-
else if (!isNaN(Number(val))) defaultValue = Number(val);
|
|
513
|
-
else defaultValue = val;
|
|
514
|
-
} else flags.push(part);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
const desc = description.match(/^([^:]+?)\s*:\s*\[?([\w\s,]+)\]?$/);
|
|
518
|
-
if (match) {
|
|
519
|
-
description = desc?.[1].trim() ?? description;
|
|
520
|
-
choices = desc?.[2].split(",").map((s) => s.trim()).filter(Boolean) ?? choices;
|
|
521
|
-
}
|
|
522
|
-
options.push({
|
|
523
|
-
name: isFlag ? flags[flags.length - 1] : name,
|
|
524
|
-
choices,
|
|
525
|
-
required,
|
|
526
|
-
multiple,
|
|
527
|
-
description,
|
|
528
|
-
flags,
|
|
529
|
-
shared,
|
|
530
|
-
isFlag,
|
|
531
|
-
isHidden,
|
|
532
|
-
placeholder,
|
|
533
|
-
defaultValue,
|
|
534
|
-
nestedOptions
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
return options;
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* Helper to parse a command's signature
|
|
541
|
-
*
|
|
542
|
-
* @param signature
|
|
543
|
-
* @param commandClass
|
|
544
|
-
* @returns
|
|
545
|
-
*/
|
|
546
|
-
static parseSignature(signature, commandClass) {
|
|
547
|
-
const lines = signature.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
|
|
548
|
-
const isHidden = ["#", "^"].includes(lines[0][0]) || /:[#^]/.test(lines[0]);
|
|
549
|
-
const baseCommand = lines[0].split("{")[0].trim().replace(/[^\w:-]/g, "");
|
|
550
|
-
const description = commandClass.getDescription();
|
|
551
|
-
const isNamespaceCommand = baseCommand.endsWith(":");
|
|
552
|
-
/**
|
|
553
|
-
* Join the rest lines to a single string for parsing
|
|
554
|
-
*/
|
|
555
|
-
const rest = lines.slice(1).join(" ");
|
|
556
|
-
/**
|
|
557
|
-
* Parse all top-level options/subcommands
|
|
558
|
-
*/
|
|
559
|
-
const allOptions = Signature.parseOptions(rest);
|
|
560
|
-
if (isNamespaceCommand)
|
|
561
|
-
/**
|
|
562
|
-
* Separate subcommands (those without flags) and base options (flags)
|
|
563
|
-
* Here we assume subcommands are those without flags (isFlag false)
|
|
564
|
-
* and base options are flags or options after subcommands
|
|
565
|
-
|
|
566
|
-
* For simplicity, treat all top-level options as subcommands
|
|
567
|
-
* and assume base command options come after subcommands in signature (not shown in example)
|
|
568
|
-
*/
|
|
569
|
-
return {
|
|
570
|
-
baseCommand: baseCommand.slice(0, -1),
|
|
571
|
-
isNamespaceCommand,
|
|
572
|
-
subCommands: allOptions.filter((e) => !e.flags && !e.isHidden),
|
|
573
|
-
description,
|
|
574
|
-
commandClass,
|
|
575
|
-
options: allOptions.filter((e) => !!e.flags),
|
|
576
|
-
isHidden
|
|
577
|
-
};
|
|
578
|
-
else return {
|
|
579
|
-
baseCommand,
|
|
580
|
-
isNamespaceCommand,
|
|
581
|
-
options: allOptions,
|
|
582
|
-
description,
|
|
583
|
-
commandClass,
|
|
584
|
-
isHidden
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
};
|
|
262
|
+
//#region src/logo.ts
|
|
263
|
+
const logo = String.raw`
|
|
264
|
+
111
|
|
265
|
+
111111111
|
|
266
|
+
1111111111 111111
|
|
267
|
+
111111 111 111111
|
|
268
|
+
111111 111 111111
|
|
269
|
+
11111 111 11111
|
|
270
|
+
1111111 111 1111111
|
|
271
|
+
111 11111 111 111111 111 1111 1111 11111111 1111
|
|
272
|
+
111 11111 1111 111111 111 1111 1111 1111 11111 1111
|
|
273
|
+
111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
|
|
274
|
+
111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
|
|
275
|
+
111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
|
|
276
|
+
111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
|
|
277
|
+
111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
|
|
278
|
+
1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
|
|
279
|
+
11011 111111 11 11111
|
|
280
|
+
111111 11101 111111
|
|
281
|
+
111111 111 111111
|
|
282
|
+
111111 111 111111
|
|
283
|
+
111111111
|
|
284
|
+
110
|
|
285
|
+
`;
|
|
286
|
+
const altLogo = String.raw`
|
|
287
|
+
_ _ _____ _
|
|
288
|
+
| | | |___ / _ __ __ ___ _____| |
|
|
289
|
+
| |_| | |_ \| '__/ _ \ \ / / _ \ |
|
|
290
|
+
| _ |___) | | | (_| |\ V / __/ |
|
|
291
|
+
|_| |_|____/|_| \__,_| \_/ \___|_|
|
|
292
|
+
|
|
293
|
+
`;
|
|
588
294
|
|
|
589
295
|
//#endregion
|
|
590
296
|
//#region ../../node_modules/.pnpm/@rollup+plugin-run@3.1.0_rollup@4.52.3/node_modules/@rollup/plugin-run/dist/es/index.js
|
|
@@ -697,262 +403,11 @@ const TsDownConfig = {
|
|
|
697
403
|
};
|
|
698
404
|
var TsdownConfig_default = TsDownConfig;
|
|
699
405
|
|
|
700
|
-
//#endregion
|
|
701
|
-
//#region src/Musket.ts
|
|
702
|
-
var Musket = class Musket {
|
|
703
|
-
commands = [];
|
|
704
|
-
constructor(app, kernel) {
|
|
705
|
-
this.app = app;
|
|
706
|
-
this.kernel = kernel;
|
|
707
|
-
}
|
|
708
|
-
async build() {
|
|
709
|
-
this.loadBaseCommands();
|
|
710
|
-
await this.loadDiscoveredCommands();
|
|
711
|
-
return await this.initialize();
|
|
712
|
-
}
|
|
713
|
-
loadBaseCommands() {
|
|
714
|
-
[
|
|
715
|
-
new HelpCommand(this.app, this.kernel),
|
|
716
|
-
new MakeCommand(this.app, this.kernel),
|
|
717
|
-
new ListCommand(this.app, this.kernel),
|
|
718
|
-
new PostinstallCommand(this.app, this.kernel),
|
|
719
|
-
new BuildCommand(this.app, this.kernel)
|
|
720
|
-
].forEach((e) => this.addCommand(e));
|
|
721
|
-
}
|
|
722
|
-
async loadDiscoveredCommands() {
|
|
723
|
-
const DIST_DIR = `/${env("DIST_DIR", ".h3ravel/serve")}/`.replaceAll("//", "");
|
|
724
|
-
const commands = [...this.app.registeredCommands.map((cmd) => new cmd(this.app, this.kernel))];
|
|
725
|
-
/**
|
|
726
|
-
* Musket Commands auto registration
|
|
727
|
-
*/
|
|
728
|
-
const providers_path = app_path("Console/Commands/*.js").replace("/src/", DIST_DIR);
|
|
729
|
-
/** Add the App Commands */
|
|
730
|
-
for await (const cmd of (0, node_fs_promises.glob)(providers_path)) {
|
|
731
|
-
const name = node_path.default.basename(cmd).replace(".js", "");
|
|
732
|
-
try {
|
|
733
|
-
const cmdClass = (await import(cmd))[name];
|
|
734
|
-
commands.push(new cmdClass(this.app, this.kernel));
|
|
735
|
-
} catch {}
|
|
736
|
-
}
|
|
737
|
-
commands.forEach((e) => this.addCommand(e));
|
|
738
|
-
}
|
|
739
|
-
addCommand(command) {
|
|
740
|
-
this.commands.push(Signature.parseSignature(command.getSignature(), command));
|
|
741
|
-
}
|
|
742
|
-
async initialize() {
|
|
743
|
-
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
744
|
-
await this.rebuild("help");
|
|
745
|
-
Object.keys(require.cache).forEach((key) => delete require.cache[key]);
|
|
746
|
-
}
|
|
747
|
-
/** Init the Musket Version */
|
|
748
|
-
const cliVersion = __h3ravel_shared.Logger.parse([["Musket CLI:", "white"], [this.kernel.consolePackage.version, "green"]], " ", false);
|
|
749
|
-
/** Init the App Version */
|
|
750
|
-
const localVersion = __h3ravel_shared.Logger.parse([["H3ravel Framework:", "white"], [this.kernel.modulePackage.version, "green"]], " ", false);
|
|
751
|
-
const additional = {
|
|
752
|
-
quiet: ["-q, --quiet", "Do not output any message except errors and warnings"],
|
|
753
|
-
silent: ["--silent", "Do not output any message"],
|
|
754
|
-
verbose: ["-v, --verbose [level]", "Increase the verbosity of messages: 1 for normal output, 2 and v for more verbose output and 3 and vv for debug"],
|
|
755
|
-
noInteraction: ["-n, --no-interaction", "Do not ask any interactive question"]
|
|
756
|
-
};
|
|
757
|
-
/**
|
|
758
|
-
* Init Commander
|
|
759
|
-
*/
|
|
760
|
-
commander.program.name("musket").version(`${cliVersion}\n${localVersion}`).description(altLogo).configureHelp({ showGlobalOptions: true }).addOption(new commander.Option(additional.quiet[0], additional.quiet[1])).addOption(new commander.Option(additional.silent[0], additional.silent[1]).implies({ quiet: true })).addOption(new commander.Option(additional.verbose[0], additional.verbose[1]).choices([
|
|
761
|
-
"1",
|
|
762
|
-
"2",
|
|
763
|
-
"3",
|
|
764
|
-
"v",
|
|
765
|
-
"vv"
|
|
766
|
-
]).default("1")).addOption(new commander.Option(additional.noInteraction[0], additional.noInteraction[1])).action(async () => {
|
|
767
|
-
const instance = new ListCommand(this.app, this.kernel);
|
|
768
|
-
instance.setInput(commander.program.opts(), commander.program.args, commander.program.registeredArguments, {}, commander.program);
|
|
769
|
-
await this.handle(instance);
|
|
770
|
-
});
|
|
771
|
-
/**
|
|
772
|
-
* Format the help command display
|
|
773
|
-
*/
|
|
774
|
-
commander.program.configureHelp({
|
|
775
|
-
styleTitle: (str) => __h3ravel_shared.Logger.log(str, "yellow", false),
|
|
776
|
-
styleOptionTerm: (str) => __h3ravel_shared.Logger.log(str, "green", false),
|
|
777
|
-
styleArgumentTerm: (str) => __h3ravel_shared.Logger.log(str, "green", false),
|
|
778
|
-
styleSubcommandTerm: (str) => __h3ravel_shared.Logger.log(str, "green", false),
|
|
779
|
-
formatItemList(heading, items) {
|
|
780
|
-
if (items.length < 1) return [];
|
|
781
|
-
if (!heading.includes("Commands:")) return items;
|
|
782
|
-
const c = (str) => str.replace(/[^A-Za-z0-9-,]/g, "").replace("32m", "");
|
|
783
|
-
let flags = items.filter((e) => c(e).startsWith("--") || c(e).includes(",--"));
|
|
784
|
-
if (flags.length > 0) flags = [__h3ravel_shared.Logger.log("\n" + heading + "\n", "yellow", false)].concat(flags);
|
|
785
|
-
const list = items.filter((e) => !c(e).startsWith("--") && !c(e).includes(",--"));
|
|
786
|
-
if (list.length < 1) return flags;
|
|
787
|
-
const _heading = c(heading).includes("Arguments") ? heading : "Available Commands:";
|
|
788
|
-
return flags.concat(__h3ravel_shared.Logger.log(`\n${_heading}`, "yellow", false), ListCommand.groupItems(list, true));
|
|
789
|
-
},
|
|
790
|
-
showGlobalOptions: true
|
|
791
|
-
});
|
|
792
|
-
/**
|
|
793
|
-
* Create the init Command
|
|
794
|
-
*/
|
|
795
|
-
commander.program.command("init").description("Initialize H3ravel.").action(async () => {
|
|
796
|
-
__h3ravel_shared.Logger.success("Initialized: H3ravel has been initialized!");
|
|
797
|
-
});
|
|
798
|
-
/**
|
|
799
|
-
* Loop through all the available commands
|
|
800
|
-
*/
|
|
801
|
-
for (let i = 0; i < this.commands.length; i++) {
|
|
802
|
-
const command = this.commands[i];
|
|
803
|
-
const instance = command.commandClass;
|
|
804
|
-
if (command.isNamespaceCommand && command.subCommands) {
|
|
805
|
-
/**
|
|
806
|
-
* Initialize the base command
|
|
807
|
-
*/
|
|
808
|
-
const cmd = command.isHidden ? commander.program : commander.program.command(command.baseCommand).description(command.description ?? "").action(async () => {
|
|
809
|
-
instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command, commander.program);
|
|
810
|
-
await this.handle(instance);
|
|
811
|
-
});
|
|
812
|
-
/**
|
|
813
|
-
* Add options to the base command if it has any
|
|
814
|
-
*/
|
|
815
|
-
if ((command.options?.length ?? 0) > 0) command.options?.filter((v, i$1, a) => a.findIndex((t) => t.name === v.name) === i$1).forEach((opt) => {
|
|
816
|
-
this.makeOption(opt, cmd);
|
|
817
|
-
});
|
|
818
|
-
/**
|
|
819
|
-
* Initialize the sub commands
|
|
820
|
-
*/
|
|
821
|
-
command.subCommands.filter((v, i$1, a) => !v.shared && a.findIndex((t) => t.name === v.name) === i$1).forEach((sub) => {
|
|
822
|
-
const cmd$1 = commander.program.command(`${command.baseCommand}:${sub.name}`).description(sub.description || "").action(async () => {
|
|
823
|
-
instance.setInput(cmd$1.opts(), cmd$1.args, cmd$1.registeredArguments, sub, commander.program);
|
|
824
|
-
await this.handle(instance);
|
|
825
|
-
});
|
|
826
|
-
/**
|
|
827
|
-
* Add the shared arguments here
|
|
828
|
-
*/
|
|
829
|
-
command.subCommands?.filter((e) => e.shared).forEach((opt) => {
|
|
830
|
-
this.makeOption(opt, cmd$1, false, sub);
|
|
831
|
-
});
|
|
832
|
-
/**
|
|
833
|
-
* Add the shared options here
|
|
834
|
-
*/
|
|
835
|
-
command.options?.filter((e) => e.shared).forEach((opt) => {
|
|
836
|
-
this.makeOption(opt, cmd$1, false, sub);
|
|
837
|
-
});
|
|
838
|
-
/**
|
|
839
|
-
* Add options to the sub command if it has any
|
|
840
|
-
*/
|
|
841
|
-
if (sub.nestedOptions) sub.nestedOptions.filter((v, i$1, a) => a.findIndex((t) => t.name === v.name) === i$1).forEach((opt) => {
|
|
842
|
-
this.makeOption(opt, cmd$1);
|
|
843
|
-
});
|
|
844
|
-
});
|
|
845
|
-
} else {
|
|
846
|
-
/**
|
|
847
|
-
* Initialize command with options
|
|
848
|
-
*/
|
|
849
|
-
const cmd = commander.program.command(command.baseCommand).description(command.description ?? "");
|
|
850
|
-
command?.options?.filter((v, i$1, a) => a.findIndex((t) => t.name === v.name) === i$1).forEach((opt) => {
|
|
851
|
-
this.makeOption(opt, cmd, true);
|
|
852
|
-
});
|
|
853
|
-
cmd.action(async () => {
|
|
854
|
-
instance.setInput(cmd.opts(), cmd.args, cmd.registeredArguments, command, commander.program);
|
|
855
|
-
await this.handle(instance);
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
/** Rebuild the app on every command except fire so we wont need TS */
|
|
860
|
-
commander.program.hook("preAction", async (_, cmd) => {
|
|
861
|
-
this.rebuild(cmd.name());
|
|
862
|
-
});
|
|
863
|
-
return commander.program;
|
|
864
|
-
}
|
|
865
|
-
async rebuild(name) {
|
|
866
|
-
if (name !== "fire" && name !== "build") await (0, tsdown.build)({
|
|
867
|
-
...TsdownConfig_default,
|
|
868
|
-
watch: false,
|
|
869
|
-
plugins: []
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
makeOption(opt, cmd, parse, parent) {
|
|
873
|
-
const description = opt.description?.replace(/\[(\w+)\]/g, (_, k) => parent?.[k] ?? `[${k}]`) ?? "";
|
|
874
|
-
const type = opt.name.replaceAll("-", "");
|
|
875
|
-
if (opt.isFlag) if (parse) {
|
|
876
|
-
let flags = opt.flags?.map((f) => f.length === 1 ? `-${f}` : `--${f.replace(/^-+/, "")}`).join(", ") ?? void 0;
|
|
877
|
-
if (opt.required && !opt.placeholder) flags += ` <${type}>`;
|
|
878
|
-
else if (opt.placeholder) flags += " " + opt.placeholder;
|
|
879
|
-
let optn = new commander.Option(flags || "", description).default(opt.defaultValue);
|
|
880
|
-
if (opt.choices && opt.choices.length) optn = optn.choices(opt.choices ?? []);
|
|
881
|
-
cmd.addOption(optn);
|
|
882
|
-
} else {
|
|
883
|
-
let flags = opt.flags?.join(", ") ?? "";
|
|
884
|
-
if (opt.required && !opt.placeholder) flags += ` <${type}>`;
|
|
885
|
-
else if (opt.placeholder) flags += " " + opt.placeholder;
|
|
886
|
-
let optn = new commander.Option(flags, description).default(opt.defaultValue);
|
|
887
|
-
if (opt.choices && opt.choices.length) optn = optn.choices(opt.choices ?? []);
|
|
888
|
-
cmd.addOption(optn);
|
|
889
|
-
}
|
|
890
|
-
else {
|
|
891
|
-
let name = opt.placeholder;
|
|
892
|
-
if (!name) name = opt.required ? `<${opt.name}>` : `[${opt.name}]`;
|
|
893
|
-
let arg = new commander.Argument(name, description);
|
|
894
|
-
if (opt.choices && opt.choices.length) arg = arg.choices(opt.choices ?? []);
|
|
895
|
-
if (opt.defaultValue) arg.default(opt.defaultValue);
|
|
896
|
-
cmd.addArgument(arg);
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
async handle(cmd) {
|
|
900
|
-
await new __h3ravel_core.ContainerResolver(this.app).resolveMethodParams(cmd, "handle");
|
|
901
|
-
}
|
|
902
|
-
static async parse(kernel) {
|
|
903
|
-
return (await new Musket(kernel.app, kernel).build()).exitOverride(() => {
|
|
904
|
-
__h3ravel_shared.Logger.log("Unknown command or argument.", "white");
|
|
905
|
-
__h3ravel_shared.Logger.log([
|
|
906
|
-
["Run", "white"],
|
|
907
|
-
["`musket --help`", ["grey", "italic"]],
|
|
908
|
-
["to see available commands.", "white"]
|
|
909
|
-
], " ");
|
|
910
|
-
}).parseAsync(process.argv).catch((e) => e);
|
|
911
|
-
}
|
|
912
|
-
};
|
|
913
|
-
|
|
914
|
-
//#endregion
|
|
915
|
-
//#region src/Kernel.ts
|
|
916
|
-
var Kernel = class Kernel extends __h3ravel_core.ConsoleKernel {
|
|
917
|
-
constructor(app) {
|
|
918
|
-
super(app);
|
|
919
|
-
this.app = app;
|
|
920
|
-
}
|
|
921
|
-
static init(app) {
|
|
922
|
-
const instance = new Kernel(app);
|
|
923
|
-
Promise.all([instance.loadRequirements()]).then(([e]) => e.run());
|
|
924
|
-
}
|
|
925
|
-
async run() {
|
|
926
|
-
await Musket.parse(this);
|
|
927
|
-
process.exit(0);
|
|
928
|
-
}
|
|
929
|
-
async loadRequirements() {
|
|
930
|
-
this.cwd = node_path.default.join(process.cwd(), this.basePath);
|
|
931
|
-
this.modulePath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/core", this.cwd) ?? "";
|
|
932
|
-
this.consolePath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/console", this.cwd) ?? "";
|
|
933
|
-
try {
|
|
934
|
-
this.modulePackage = await import(node_path.default.join(this.modulePath, "package.json"));
|
|
935
|
-
} catch {
|
|
936
|
-
this.modulePackage = { version: "N/A" };
|
|
937
|
-
}
|
|
938
|
-
try {
|
|
939
|
-
this.consolePackage = await import(node_path.default.join(this.consolePath, "package.json"));
|
|
940
|
-
} catch {
|
|
941
|
-
this.consolePackage = { version: "N/A" };
|
|
942
|
-
}
|
|
943
|
-
return this;
|
|
944
|
-
}
|
|
945
|
-
};
|
|
946
|
-
|
|
947
406
|
//#endregion
|
|
948
407
|
//#region src/Providers/ConsoleServiceProvider.ts
|
|
949
408
|
/**
|
|
950
409
|
* Handles CLI commands and tooling.
|
|
951
410
|
*
|
|
952
|
-
* Register DatabaseManager and QueryBuilder.
|
|
953
|
-
* Set up ORM models and relationships.
|
|
954
|
-
* Register migration and seeder commands.
|
|
955
|
-
*
|
|
956
411
|
* Auto-Registered when in CLI mode
|
|
957
412
|
*/
|
|
958
413
|
var ConsoleServiceProvider = class extends __h3ravel_core.ServiceProvider {
|
|
@@ -964,7 +419,22 @@ var ConsoleServiceProvider = class extends __h3ravel_core.ServiceProvider {
|
|
|
964
419
|
runsInConsole = true;
|
|
965
420
|
register() {}
|
|
966
421
|
boot() {
|
|
967
|
-
|
|
422
|
+
const DIST_DIR = `/${env("DIST_DIR", ".h3ravel/serve")}/`.replaceAll("//", "");
|
|
423
|
+
__h3ravel_musket.Kernel.init(this.app, {
|
|
424
|
+
logo: altLogo,
|
|
425
|
+
resolver: new __h3ravel_core.ContainerResolver(this.app).resolveMethodParams,
|
|
426
|
+
tsDownConfig: TsdownConfig_default,
|
|
427
|
+
packages: [{
|
|
428
|
+
name: "@h3ravel/core",
|
|
429
|
+
alias: "H3ravel Framework"
|
|
430
|
+
}, {
|
|
431
|
+
name: "@h3ravel/musket",
|
|
432
|
+
alias: "Musket CLI"
|
|
433
|
+
}],
|
|
434
|
+
cliName: "musket",
|
|
435
|
+
hideMusketInfo: true,
|
|
436
|
+
discoveryPaths: [app_path("Console/Commands/*.js").replace("/src/", DIST_DIR)]
|
|
437
|
+
});
|
|
968
438
|
process.on("SIGINT", () => {
|
|
969
439
|
process.exit(0);
|
|
970
440
|
});
|
|
@@ -976,16 +446,8 @@ var ConsoleServiceProvider = class extends __h3ravel_core.ServiceProvider {
|
|
|
976
446
|
|
|
977
447
|
//#endregion
|
|
978
448
|
exports.BuildCommand = BuildCommand;
|
|
979
|
-
exports.Command = Command;
|
|
980
449
|
exports.ConsoleServiceProvider = ConsoleServiceProvider;
|
|
981
|
-
exports.HelpCommand = HelpCommand;
|
|
982
|
-
exports.Kernel = Kernel;
|
|
983
|
-
exports.ListCommand = ListCommand;
|
|
984
450
|
exports.MakeCommand = MakeCommand;
|
|
985
|
-
exports.Musket = Musket;
|
|
986
451
|
exports.PostinstallCommand = PostinstallCommand;
|
|
987
|
-
exports.Signature = Signature;
|
|
988
452
|
exports.TsDownConfig = TsDownConfig;
|
|
989
|
-
exports.altLogo = altLogo;
|
|
990
|
-
exports.logo = logo;
|
|
991
453
|
//# sourceMappingURL=index.cjs.map
|