@h3ravel/console 11.11.0 → 11.11.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/bin/fire.cjs ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ const e=require(`./spawn-xwsneyuG.cjs`);require(`tsx/esm`);let t=require(`@h3ravel/core`);t=e.t(t);let n=require(`@h3ravel/shared`);n=e.t(n);let r=require(`@h3ravel/musket`);r=e.t(r);let i=require(`execa`);i=e.t(i);let a=require(`preferred-pm`);a=e.t(a);let o=require(`node:fs/promises`);o=e.t(o),require(`@h3ravel/support`);let s=require(`node:path`);s=e.t(s);let c=require(`node:fs`);c=e.t(c);let l=require(`child_process`);l=e.t(l);let u=require(`path`);u=e.t(u);const d=String.raw`
3
+ 111
4
+ 111111111
5
+ 1111111111 111111
6
+ 111111 111 111111
7
+ 111111 111 111111
8
+ 11111 111 11111
9
+ 1111111 111 1111111
10
+ 111 11111 111 111111 111 1111 1111 11111111 1111
11
+ 111 11111 1111 111111 111 1111 1111 1111 11111 1111
12
+ 111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
13
+ 111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
14
+ 111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
15
+ 111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
16
+ 111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
17
+ 1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
18
+ 11011 111111 11 11111
19
+ 111111 11101 111111
20
+ 111111 111 111111
21
+ 111111 111 111111
22
+ 111111111
23
+ 110
24
+ `,f=String.raw`
25
+ _ _ _____ _
26
+ | | | |___ / _ __ __ ___ _____| |
27
+ | |_| | |_ \| '__/ _ \ \ / / _ \ |
28
+ | _ |___) | | | (_| |\ V / __/ |
29
+ |_| |_|____/|_| \__,_| \_/ \___|_|
30
+
31
+ `;function p(e={}){let t,n,r=e.args||[],i=e.allowRestarts||!1,a=e.input,o=e.options||e;return delete o.args,delete o.allowRestarts,{name:`run`,buildStart(e){let n=a??e.input;if(typeof n==`string`&&(n=[n]),typeof n==`object`&&(n=Object.values(n)),n.length>1)throw Error("@rollup/plugin-run must have a single entry point; consider setting the `input` option");t=(0,u.resolve)(n[0])},generateBundle(e,t,n){n||this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`)},writeBundle(e,a){let s=(e,t)=>{n&&n.kill(),n=(0,l.fork)((0,u.join)(e,t),r,o)},c=e.dir||(0,u.dirname)(e.file),d=Object.keys(a).find(e=>{let n=a[e];return n.isEntry&&n.facadeModuleId===t});d?(s(c,d),i&&(process.stdin.resume(),process.stdin.setEncoding(`utf8`),process.stdin.on(`data`,e=>{let t=e.toString().trim().toLowerCase();t===`rs`||t===`restart`||e.toString().charCodeAt(0)===11?s(c,d):(t===`cls`||t===`clear`||e.toString().charCodeAt(0)===12)&&console.clear()}))):this.error(`@rollup/plugin-run could not find output chunk`)}}}const m=process.env.NODE_ENV||`development`;let h=m===`development`?`.h3ravel/serve`:`dist`;process.env.DIST_DIR&&(h=process.env.DIST_DIR);const g={outDir:h,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:m===`development`,minify:!!process.env.DIST_MINIFY,external:[/^@h3ravel\/.*/gi],clean:!0,shims:!0,copy:[{from:`public`,to:h},`src/resources`,`src/database`],env:m===`development`?{NODE_ENV:m,DIST_DIR:h}:{},watch:m===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,hooks(e){e.hook(`build:done`,async()=>{let e=[`database/migrations`,`database/factories`,`database/seeders`];for(let t=0;t<e.length;t++){let n=e[t];(0,c.existsSync)(s.default.join(h,n))&&await(0,o.rm)(s.default.join(h,n),{recursive:!0})}})},plugins:m===`development`&&process.env.CLI_BUILD!==`true`?[p({env:Object.assign({},process.env,{NODE_ENV:m,DIST_DIR:h}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]};var _=g,v=class extends t.ServiceProvider{static priority=992;static runsInConsole=!0;runsInConsole=!0;register(){}boot(){let e=`/${env(`DIST_DIR`,`.h3ravel/serve`)}/`.replaceAll(`//`,``);r.Kernel.init(this.app,{logo:f,resolver:new t.ContainerResolver(this.app).resolveMethodParams,tsDownConfig:_,packages:[{name:`@h3ravel/core`,alias:`H3ravel Framework`},{name:`@h3ravel/musket`,alias:`Musket CLI`}],cliName:`musket`,hideMusketInfo:!0,discoveryPaths:[app_path(`Console/Commands/*.js`).replace(`/src/`,e)]}),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}},y=class{async fire(){let e=process.env.DIST_DIR??`/.h3ravel/serve/`,n=[],r=new t.Application(process.cwd()),i=base_path(s.default.join(e,`bootstrap/providers.js`));n.push(...(await import(i)).default),n.push(v),await r.quickStartup(n,[`CoreServiceProvider`])}};new y().fire();
package/bin/fire.js ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ import"./spawn-Btvwwwha.js";import"tsx/esm";import{Application as e,ContainerResolver as t,ServiceProvider as n}from"@h3ravel/core";import{FileSystem as r}from"@h3ravel/shared";import{Kernel as i}from"@h3ravel/musket";import{execa as a}from"execa";import o from"preferred-pm";import{mkdir as s,rm as c,writeFile as l}from"node:fs/promises";import"@h3ravel/support";import u from"node:path";import{existsSync as d}from"node:fs";import{fork as f}from"child_process";import{dirname as p,join as m,resolve as h}from"path";String.raw`
3
+ 111
4
+ 111111111
5
+ 1111111111 111111
6
+ 111111 111 111111
7
+ 111111 111 111111
8
+ 11111 111 11111
9
+ 1111111 111 1111111
10
+ 111 11111 111 111111 111 1111 1111 11111111 1111
11
+ 111 11111 1111 111111 111 1111 1111 1111 11111 1111
12
+ 111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
13
+ 111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
14
+ 111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
15
+ 111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
16
+ 111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
17
+ 1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
18
+ 11011 111111 11 11111
19
+ 111111 11101 111111
20
+ 111111 111 111111
21
+ 111111 111 111111
22
+ 111111111
23
+ 110
24
+ `;const g=String.raw`
25
+ _ _ _____ _
26
+ | | | |___ / _ __ __ ___ _____| |
27
+ | |_| | |_ \| '__/ _ \ \ / / _ \ |
28
+ | _ |___) | | | (_| |\ V / __/ |
29
+ |_| |_|____/|_| \__,_| \_/ \___|_|
30
+
31
+ `;function _(e={}){let t,n,r=e.args||[],i=e.allowRestarts||!1,a=e.input,o=e.options||e;return delete o.args,delete o.allowRestarts,{name:`run`,buildStart(e){let n=a??e.input;if(typeof n==`string`&&(n=[n]),typeof n==`object`&&(n=Object.values(n)),n.length>1)throw Error("@rollup/plugin-run must have a single entry point; consider setting the `input` option");t=h(n[0])},generateBundle(e,t,n){n||this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`)},writeBundle(e,a){let s=(e,t)=>{n&&n.kill(),n=f(m(e,t),r,o)},c=e.dir||p(e.file),l=Object.keys(a).find(e=>{let n=a[e];return n.isEntry&&n.facadeModuleId===t});l?(s(c,l),i&&(process.stdin.resume(),process.stdin.setEncoding(`utf8`),process.stdin.on(`data`,e=>{let t=e.toString().trim().toLowerCase();t===`rs`||t===`restart`||e.toString().charCodeAt(0)===11?s(c,l):(t===`cls`||t===`clear`||e.toString().charCodeAt(0)===12)&&console.clear()}))):this.error(`@rollup/plugin-run could not find output chunk`)}}}const v=process.env.NODE_ENV||`development`;let y=v===`development`?`.h3ravel/serve`:`dist`;process.env.DIST_DIR&&(y=process.env.DIST_DIR);var b={outDir:y,entry:[`src/**/*.ts`],format:[`esm`],target:`node22`,sourcemap:v===`development`,minify:!!process.env.DIST_MINIFY,external:[/^@h3ravel\/.*/gi],clean:!0,shims:!0,copy:[{from:`public`,to:y},`src/resources`,`src/database`],env:v===`development`?{NODE_ENV:v,DIST_DIR:y}:{},watch:v===`development`&&process.env.CLI_BUILD!==`true`?[`.env`,`.env.*`,`src`,`../../packages`]:!1,dts:!1,logLevel:`silent`,nodeProtocol:!0,skipNodeModulesBundle:!0,hooks(e){e.hook(`build:done`,async()=>{let e=[`database/migrations`,`database/factories`,`database/seeders`];for(let t=0;t<e.length;t++){let n=e[t];d(u.join(y,n))&&await c(u.join(y,n),{recursive:!0})}})},plugins:v===`development`&&process.env.CLI_BUILD!==`true`?[_({env:Object.assign({},process.env,{NODE_ENV:v,DIST_DIR:y}),execArgv:[`-r`,`source-map-support/register`],allowRestarts:!1,input:process.cwd()+`/src/server.ts`})]:[]},x=class extends n{static priority=992;static runsInConsole=!0;runsInConsole=!0;register(){}boot(){let e=`/${env(`DIST_DIR`,`.h3ravel/serve`)}/`.replaceAll(`//`,``);i.init(this.app,{logo:g,resolver:new t(this.app).resolveMethodParams,tsDownConfig:b,packages:[{name:`@h3ravel/core`,alias:`H3ravel Framework`},{name:`@h3ravel/musket`,alias:`Musket CLI`}],cliName:`musket`,hideMusketInfo:!0,discoveryPaths:[app_path(`Console/Commands/*.js`).replace(`/src/`,e)]}),process.on(`SIGINT`,()=>{process.exit(0)}),process.on(`SIGTERM`,()=>{process.exit(0)})}};new class{async fire(){let t=process.env.DIST_DIR??`/.h3ravel/serve/`,n=[],r=new e(process.cwd()),i=base_path(u.join(t,`bootstrap/providers.js`));n.push(...(await import(i)).default),n.push(x),await r.quickStartup(n,[`CoreServiceProvider`])}}().fire();export{};
@@ -0,0 +1 @@
1
+ import{FileSystem as e,mainTsconfig as t}from"@h3ravel/shared";import{execa as n}from"execa";import r from"preferred-pm";import{mkdir as i,readdir as a,writeFile as o}from"node:fs/promises";import s,{join as c}from"node:path";new class{async spawn(l=`.h3ravel/serve`){let u=(await r(process.cwd()))?.name??`npm`,d=c(process.env.DIST_DIR??l);if(await e.fileExists(d)&&(await a(d)).length>0)return;await e.fileExists(s.join(d,`tsconfig.json`))||(await i(s.join(d.replace(`/serve`,``)),{recursive:!0}),await o(s.join(d.replace(`/serve`,``),`tsconfig.json`),JSON.stringify(t,null,2)));let f={EXTENDED_DEBUG:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:d,LOG_LEVEL:`silent`};await n(u,[`tsdown`,`--silent`,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:c(process.cwd()),env:Object.assign({},process.env,f)})}}().spawn();export{};
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@h3ravel/shared`);c=s(c);let l=require(`execa`);l=s(l);let u=require(`preferred-pm`);u=s(u);let d=require(`node:fs/promises`);d=s(d);let f=require(`node:path`);f=s(f);var p=class{async spawn(e=`.h3ravel/serve`){let t=(await(0,u.default)(process.cwd()))?.name??`npm`,n=(0,f.join)(process.env.DIST_DIR??e);if(await c.FileSystem.fileExists(n)&&(await(0,d.readdir)(n)).length>0)return;await c.FileSystem.fileExists(f.default.join(n,`tsconfig.json`))||(await(0,d.mkdir)(f.default.join(n.replace(`/serve`,``)),{recursive:!0}),await(0,d.writeFile)(f.default.join(n.replace(`/serve`,``),`tsconfig.json`),JSON.stringify(c.mainTsconfig,null,2)));let r={EXTENDED_DEBUG:`false`,CLI_BUILD:`true`,NODE_ENV:`production`,DIST_DIR:n,LOG_LEVEL:`silent`};await(0,l.execa)(t,[`tsdown`,`--silent`,`--config-loader`,`unconfig`,`-c`,`tsdown.default.config.ts`].filter(e=>e!==null),{stdout:`inherit`,stderr:`inherit`,cwd:(0,f.join)(process.cwd()),env:Object.assign({},process.env,r)})}};new p().spawn(),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
package/bin/spawn.cjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require(`./spawn-xwsneyuG.cjs`);
package/bin/spawn.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import"./spawn-Btvwwwha.js";export{};
package/dist/index.cjs ADDED
@@ -0,0 +1,520 @@
1
+ //#region rolldown:runtime
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 __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+ let __h3ravel_shared = require("@h3ravel/shared");
25
+ __h3ravel_shared = __toESM(__h3ravel_shared);
26
+ let __h3ravel_musket = require("@h3ravel/musket");
27
+ __h3ravel_musket = __toESM(__h3ravel_musket);
28
+ let execa = require("execa");
29
+ execa = __toESM(execa);
30
+ let preferred_pm = require("preferred-pm");
31
+ preferred_pm = __toESM(preferred_pm);
32
+ let node_fs_promises = require("node:fs/promises");
33
+ node_fs_promises = __toESM(node_fs_promises);
34
+ let __h3ravel_support = require("@h3ravel/support");
35
+ __h3ravel_support = __toESM(__h3ravel_support);
36
+ let node_path = require("node:path");
37
+ node_path = __toESM(node_path);
38
+ require("tsx/esm");
39
+ let __h3ravel_core = require("@h3ravel/core");
40
+ __h3ravel_core = __toESM(__h3ravel_core);
41
+ let node_fs = require("node:fs");
42
+ node_fs = __toESM(node_fs);
43
+ let child_process = require("child_process");
44
+ child_process = __toESM(child_process);
45
+ let path = require("path");
46
+ path = __toESM(path);
47
+
48
+ //#region src/Commands/BuildCommand.ts
49
+ var BuildCommand = class BuildCommand extends __h3ravel_musket.Command {
50
+ /**
51
+ * The name and signature of the console command.
52
+ *
53
+ * @var string
54
+ */
55
+ signature = `build
56
+ {--m|minify : Minify your bundle output}
57
+ {--d|dev : Build for dev but don't watch for changes}
58
+ `;
59
+ /**
60
+ * The console command description.
61
+ *
62
+ * @var string
63
+ */
64
+ description = "Build the app for production";
65
+ async handle() {
66
+ try {
67
+ await this.fire();
68
+ } catch (e) {
69
+ __h3ravel_shared.Logger.error(e);
70
+ }
71
+ }
72
+ async fire() {
73
+ const outDir$1 = this.option("dev") ? ".h3ravel/serve" : env("DIST_DIR", "dist");
74
+ const minify = this.option("minify");
75
+ const verbosity = this.getVerbosity();
76
+ const debug = verbosity > 0;
77
+ this.newLine();
78
+ await BuildCommand.build({
79
+ outDir: outDir$1,
80
+ minify,
81
+ verbosity,
82
+ debug,
83
+ mute: false
84
+ });
85
+ this.newLine();
86
+ }
87
+ /**
88
+ * build
89
+ */
90
+ static async build({ debug, minify, mute, verbosity, outDir: outDir$1 } = {
91
+ mute: false,
92
+ debug: false,
93
+ minify: false,
94
+ verbosity: 0,
95
+ outDir: "dist"
96
+ }) {
97
+ const pm = (await (0, preferred_pm.default)(base_path()))?.name ?? "pnpm";
98
+ const ENV_VARS = {
99
+ EXTENDED_DEBUG: debug ? "true" : "false",
100
+ CLI_BUILD: "true",
101
+ NODE_ENV: "production",
102
+ DIST_DIR: outDir$1,
103
+ DIST_MINIFY: minify,
104
+ LOG_LEVEL: [
105
+ "silent",
106
+ "info",
107
+ "warn",
108
+ "error"
109
+ ][verbosity]
110
+ };
111
+ const silent = ENV_VARS.LOG_LEVEL === "silent" ? "--silent" : null;
112
+ if (mute) return await (0, execa.execa)(pm, [
113
+ "tsdown",
114
+ silent,
115
+ "--config-loader",
116
+ "unconfig",
117
+ "-c",
118
+ "tsdown.default.config.ts"
119
+ ].filter((e) => e !== null), {
120
+ stdout: "inherit",
121
+ stderr: "inherit",
122
+ cwd: base_path(),
123
+ env: Object.assign({}, process.env, ENV_VARS)
124
+ });
125
+ const type = outDir$1 === "dist" ? "Production" : "Development";
126
+ return await __h3ravel_shared.TaskManager.advancedTaskRunner([[`Creating ${type} Bundle`, "STARTED"], [`${type} Bundle Created`, "COMPLETED"]], async () => {
127
+ await (0, execa.execa)(pm, [
128
+ "tsdown",
129
+ silent,
130
+ "--config-loader",
131
+ "unconfig",
132
+ "-c",
133
+ "tsdown.default.config.ts"
134
+ ].filter((e) => e !== null), {
135
+ stdout: "inherit",
136
+ stderr: "inherit",
137
+ cwd: base_path(),
138
+ env: Object.assign({}, process.env, ENV_VARS)
139
+ });
140
+ });
141
+ }
142
+ };
143
+
144
+ //#endregion
145
+ //#region src/Commands/MakeCommand.ts
146
+ var MakeCommand = class extends __h3ravel_musket.Command {
147
+ /**
148
+ * The name and signature of the console command.
149
+ *
150
+ * @var string
151
+ */
152
+ signature = `#make:
153
+ {controller : Create a new controller class.
154
+ | {--a|api : Exclude the create and edit methods from the controller}
155
+ | {--m|model= : Generate a resource controller for the given model}
156
+ | {--r|resource : Generate a resource controller class}
157
+ | {--force : Create the controller even if it already exists}
158
+ }
159
+ {resource : Create a new resource.
160
+ | {--c|collection : Create a resource collection}
161
+ | {--force : Create the resource even if it already exists}
162
+ }
163
+ {command : Create a new Musket command.
164
+ | {--command : The terminal command that will be used to invoke the class}
165
+ | {--force : Create the class even if the console command already exists}
166
+ }
167
+ {view : Create a new view.
168
+ | {--force : Create the view even if it already exists}
169
+ }
170
+ {^name : The name of the [name] to generate}
171
+ `;
172
+ /**
173
+ * The console command description.
174
+ *
175
+ * @var string
176
+ */
177
+ description = "Generate component classes";
178
+ async handle() {
179
+ const command = this.dictionary.baseCommand ?? this.dictionary.name;
180
+ if (!this.argument("name")) this.program.error("Please provide a valid name for the " + command);
181
+ await this[{
182
+ controller: "makeController",
183
+ resource: "makeResource",
184
+ view: "makeView",
185
+ command: "makeCommand"
186
+ }[command]]();
187
+ }
188
+ /**
189
+ * Create a new controller class.
190
+ */
191
+ async makeController() {
192
+ const type = this.option("api") ? "-resource" : "";
193
+ const name = this.argument("name");
194
+ const force = this.option("force");
195
+ const crtlrPath = __h3ravel_shared.FileSystem.findModulePkg("@h3ravel/http", this.kernel.cwd) ?? "";
196
+ const stubPath = node_path.default.join(crtlrPath, `dist/stubs/controller${type}.stub`);
197
+ const path$4 = app_path(`Http/Controllers/${name}.ts`);
198
+ /** The Controller is scoped to a path make sure to create the associated directories */
199
+ if (name.includes("/")) await (0, node_fs_promises.mkdir)(__h3ravel_support.Str.beforeLast(path$4, "/"), { recursive: true });
200
+ /** Check if the controller already exists */
201
+ if (!force && await __h3ravel_shared.FileSystem.fileExists(path$4)) __h3ravel_shared.Logger.error(`ERORR: ${name} controller already exists`);
202
+ let stub = await (0, node_fs_promises.readFile)(stubPath, "utf-8");
203
+ stub = stub.replace(/{{ name }}/g, name);
204
+ await (0, node_fs_promises.writeFile)(path$4, stub);
205
+ __h3ravel_shared.Logger.split("INFO: Controller Created", __h3ravel_shared.Logger.log(node_path.default.basename(path$4), "gray", false));
206
+ }
207
+ makeResource() {
208
+ __h3ravel_shared.Logger.success("Resource support is not yet available");
209
+ }
210
+ /**
211
+ * Create a new Musket command
212
+ */
213
+ makeCommand() {
214
+ __h3ravel_shared.Logger.success("Musket command creation is not yet available");
215
+ }
216
+ /**
217
+ * Create a new view.
218
+ */
219
+ async makeView() {
220
+ const name = this.argument("name");
221
+ const force = this.option("force");
222
+ const path$4 = base_path(`src/resources/views/${name}.edge`);
223
+ /** The view is scoped to a path make sure to create the associated directories */
224
+ if (name.includes("/")) await (0, node_fs_promises.mkdir)(__h3ravel_support.Str.beforeLast(path$4, "/"), { recursive: true });
225
+ /** Check if the view already exists */
226
+ if (!force && await __h3ravel_shared.FileSystem.fileExists(path$4)) __h3ravel_shared.Logger.error(`ERORR: ${name} view already exists`);
227
+ await (0, node_fs_promises.writeFile)(path$4, `{{-- src/resources/views/${name}.edge --}}`);
228
+ __h3ravel_shared.Logger.split("INFO: View Created", __h3ravel_shared.Logger.log(`src/resources/views/${name}.edge`, "gray", false));
229
+ }
230
+ };
231
+
232
+ //#endregion
233
+ //#region src/Commands/PostinstallCommand.ts
234
+ var PostinstallCommand = class extends __h3ravel_musket.Command {
235
+ /**
236
+ * The name and signature of the console command.
237
+ *
238
+ * @var string
239
+ */
240
+ signature = "postinstall";
241
+ /**
242
+ * The console command description.
243
+ *
244
+ * @var string
245
+ */
246
+ description = "Default post installation command";
247
+ async handle() {
248
+ this.createSqliteDB();
249
+ }
250
+ /**
251
+ * Create sqlite database if none exist
252
+ *
253
+ * @returns
254
+ */
255
+ async createSqliteDB() {
256
+ if (config("database.default") !== "sqlite") return;
257
+ if (!await __h3ravel_shared.FileSystem.fileExists(database_path())) await (0, node_fs_promises.mkdir)(database_path(), { recursive: true });
258
+ if (!await __h3ravel_shared.FileSystem.fileExists(database_path("db.sqlite"))) await (0, node_fs_promises.writeFile)(database_path("db.sqlite"), "");
259
+ }
260
+ };
261
+
262
+ //#endregion
263
+ //#region src/IO/app.ts
264
+ var app_default = class {
265
+ async fire() {
266
+ const DIST_DIR = process.env.DIST_DIR ?? "/.h3ravel/serve/";
267
+ const providers = [];
268
+ const app = new __h3ravel_core.Application(process.cwd());
269
+ /**
270
+ * Load Service Providers already registered by the app
271
+ */
272
+ const app_providers = base_path(node_path.default.join(DIST_DIR, "bootstrap/providers.js"));
273
+ providers.push(...(await import(app_providers)).default);
274
+ /** Add the ConsoleServiceProvider */
275
+ providers.push(ConsoleServiceProvider);
276
+ /** Register all the Service Providers */
277
+ await app.quickStartup(providers, ["CoreServiceProvider"]);
278
+ }
279
+ };
280
+
281
+ //#endregion
282
+ //#region src/fire.ts
283
+ new app_default().fire();
284
+
285
+ //#endregion
286
+ //#region src/IO/zero.ts
287
+ var zero_default = class {
288
+ /**
289
+ * Ensures that the app is pre built
290
+ *
291
+ * @returns
292
+ */
293
+ async spawn(DIST_DIR = ".h3ravel/serve") {
294
+ const pm = (await (0, preferred_pm.default)(process.cwd()))?.name ?? "npm";
295
+ const outDir$1 = (0, node_path.join)(process.env.DIST_DIR ?? DIST_DIR);
296
+ if (await __h3ravel_shared.FileSystem.fileExists(outDir$1) && (await (0, node_fs_promises.readdir)(outDir$1)).length > 0) return;
297
+ if (!await __h3ravel_shared.FileSystem.fileExists(node_path.default.join(outDir$1, "tsconfig.json"))) {
298
+ await (0, node_fs_promises.mkdir)(node_path.default.join(outDir$1.replace("/serve", "")), { recursive: true });
299
+ await (0, node_fs_promises.writeFile)(node_path.default.join(outDir$1.replace("/serve", ""), "tsconfig.json"), JSON.stringify(__h3ravel_shared.mainTsconfig, null, 2));
300
+ }
301
+ const ENV_VARS = {
302
+ EXTENDED_DEBUG: "false",
303
+ CLI_BUILD: "true",
304
+ NODE_ENV: "production",
305
+ DIST_DIR: outDir$1,
306
+ LOG_LEVEL: "silent"
307
+ };
308
+ await (0, execa.execa)(pm, [
309
+ "tsdown",
310
+ "--silent",
311
+ "--config-loader",
312
+ "unconfig",
313
+ "-c",
314
+ "tsdown.default.config.ts"
315
+ ].filter((e) => e !== null), {
316
+ stdout: "inherit",
317
+ stderr: "inherit",
318
+ cwd: (0, node_path.join)(process.cwd()),
319
+ env: Object.assign({}, process.env, ENV_VARS)
320
+ });
321
+ }
322
+ };
323
+
324
+ //#endregion
325
+ //#region src/logo.ts
326
+ const logo = String.raw`
327
+ 111
328
+ 111111111
329
+ 1111111111 111111
330
+ 111111 111 111111
331
+ 111111 111 111111
332
+ 11111 111 11111
333
+ 1111111 111 1111111
334
+ 111 11111 111 111111 111 1111 1111 11111111 1111
335
+ 111 11111 1111 111111 111 1111 1111 1111 11111 1111
336
+ 111 11111 11111 111 1111 1111 111111111111 111111111111 1111 1111111 1111
337
+ 111 111111 1111 111 111111111111 111111 11111 1111 111 1111 11111111 1111 1111
338
+ 111 111 11111111 111 1101 1101 111111111 11111111 1111 1111111111111111101
339
+ 111 1111111111111111 1111 111 1111 1111 111 11111011 1111 111 1111111 1101 1111
340
+ 111 11111 1110111111111111 111 1111 1111 1111111101 1111 111111111 1111011 111111111 1111
341
+ 1111111 111110111110 111 1111 1111 111111 1111 11011101 10111 11111 1111
342
+ 11011 111111 11 11111
343
+ 111111 11101 111111
344
+ 111111 111 111111
345
+ 111111 111 111111
346
+ 111111111
347
+ 110
348
+ `;
349
+ const altLogo = String.raw`
350
+ _ _ _____ _
351
+ | | | |___ / _ __ __ ___ _____| |
352
+ | |_| | |_ \| '__/ _ \ \ / / _ \ |
353
+ | _ |___) | | | (_| |\ V / __/ |
354
+ |_| |_|____/|_| \__,_| \_/ \___|_|
355
+
356
+ `;
357
+
358
+ //#endregion
359
+ //#region ../../node_modules/.pnpm/@rollup+plugin-run@3.1.0_rollup@4.52.3/node_modules/@rollup/plugin-run/dist/es/index.js
360
+ function run(opts = {}) {
361
+ let input;
362
+ let proc;
363
+ const args = opts.args || [];
364
+ const allowRestarts = opts.allowRestarts || false;
365
+ const overrideInput = opts.input;
366
+ const forkOptions = opts.options || opts;
367
+ delete forkOptions.args;
368
+ delete forkOptions.allowRestarts;
369
+ return {
370
+ name: "run",
371
+ buildStart(options) {
372
+ let inputs = overrideInput !== null && overrideInput !== void 0 ? overrideInput : options.input;
373
+ if (typeof inputs === "string") inputs = [inputs];
374
+ if (typeof inputs === "object") inputs = Object.values(inputs);
375
+ if (inputs.length > 1) throw new Error(`@rollup/plugin-run must have a single entry point; consider setting the \`input\` option`);
376
+ input = (0, path.resolve)(inputs[0]);
377
+ },
378
+ generateBundle(_outputOptions, _bundle, isWrite) {
379
+ if (!isWrite) this.error(`@rollup/plugin-run currently only works with bundles that are written to disk`);
380
+ },
381
+ writeBundle(outputOptions, bundle) {
382
+ const forkBundle = (dir$1, entryFileName$1) => {
383
+ if (proc) proc.kill();
384
+ proc = (0, child_process.fork)((0, path.join)(dir$1, entryFileName$1), args, forkOptions);
385
+ };
386
+ const dir = outputOptions.dir || (0, path.dirname)(outputOptions.file);
387
+ const entryFileName = Object.keys(bundle).find((fileName) => {
388
+ const chunk = bundle[fileName];
389
+ return chunk.isEntry && chunk.facadeModuleId === input;
390
+ });
391
+ if (entryFileName) {
392
+ forkBundle(dir, entryFileName);
393
+ if (allowRestarts) {
394
+ process.stdin.resume();
395
+ process.stdin.setEncoding("utf8");
396
+ process.stdin.on("data", (data) => {
397
+ const line = data.toString().trim().toLowerCase();
398
+ if (line === "rs" || line === "restart" || data.toString().charCodeAt(0) === 11) forkBundle(dir, entryFileName);
399
+ else if (line === "cls" || line === "clear" || data.toString().charCodeAt(0) === 12) console.clear();
400
+ });
401
+ }
402
+ } else this.error(`@rollup/plugin-run could not find output chunk`);
403
+ }
404
+ };
405
+ }
406
+
407
+ //#endregion
408
+ //#region src/TsdownConfig.ts
409
+ const env$1 = process.env.NODE_ENV || "development";
410
+ let outDir = env$1 === "development" ? ".h3ravel/serve" : "dist";
411
+ if (process.env.DIST_DIR) outDir = process.env.DIST_DIR;
412
+ const TsDownConfig = {
413
+ outDir,
414
+ entry: ["src/**/*.ts"],
415
+ format: ["esm"],
416
+ target: "node22",
417
+ sourcemap: env$1 === "development",
418
+ minify: !!process.env.DIST_MINIFY,
419
+ external: [/^@h3ravel\/.*/gi],
420
+ clean: true,
421
+ shims: true,
422
+ copy: [
423
+ {
424
+ from: "public",
425
+ to: outDir
426
+ },
427
+ "src/resources",
428
+ "src/database"
429
+ ],
430
+ env: env$1 === "development" ? {
431
+ NODE_ENV: env$1,
432
+ DIST_DIR: outDir
433
+ } : {},
434
+ watch: env$1 === "development" && process.env.CLI_BUILD !== "true" ? [
435
+ ".env",
436
+ ".env.*",
437
+ "src",
438
+ "../../packages"
439
+ ] : false,
440
+ dts: false,
441
+ logLevel: "silent",
442
+ nodeProtocol: true,
443
+ skipNodeModulesBundle: true,
444
+ hooks(e) {
445
+ e.hook("build:done", async () => {
446
+ const paths = [
447
+ "database/migrations",
448
+ "database/factories",
449
+ "database/seeders"
450
+ ];
451
+ for (let i = 0; i < paths.length; i++) {
452
+ const name = paths[i];
453
+ if ((0, node_fs.existsSync)(node_path.default.join(outDir, name))) await (0, node_fs_promises.rm)(node_path.default.join(outDir, name), { recursive: true });
454
+ }
455
+ });
456
+ },
457
+ plugins: env$1 === "development" && process.env.CLI_BUILD !== "true" ? [run({
458
+ env: Object.assign({}, process.env, {
459
+ NODE_ENV: env$1,
460
+ DIST_DIR: outDir
461
+ }),
462
+ execArgv: ["-r", "source-map-support/register"],
463
+ allowRestarts: false,
464
+ input: process.cwd() + "/src/server.ts"
465
+ })] : []
466
+ };
467
+ var TsdownConfig_default = TsDownConfig;
468
+
469
+ //#endregion
470
+ //#region src/Providers/ConsoleServiceProvider.ts
471
+ /**
472
+ * Handles CLI commands and tooling.
473
+ *
474
+ * Auto-Registered when in CLI mode
475
+ */
476
+ var ConsoleServiceProvider = class extends __h3ravel_core.ServiceProvider {
477
+ static priority = 992;
478
+ /**
479
+ * Indicate that this service provider only runs in console
480
+ */
481
+ static runsInConsole = true;
482
+ runsInConsole = true;
483
+ register() {}
484
+ boot() {
485
+ const DIST_DIR = `/${env("DIST_DIR", ".h3ravel/serve")}/`.replaceAll("//", "");
486
+ __h3ravel_musket.Kernel.init(this.app, {
487
+ logo: altLogo,
488
+ resolver: new __h3ravel_core.ContainerResolver(this.app).resolveMethodParams,
489
+ tsDownConfig: TsdownConfig_default,
490
+ packages: [{
491
+ name: "@h3ravel/core",
492
+ alias: "H3ravel Framework"
493
+ }, {
494
+ name: "@h3ravel/musket",
495
+ alias: "Musket CLI"
496
+ }],
497
+ cliName: "musket",
498
+ hideMusketInfo: true,
499
+ discoveryPaths: [app_path("Console/Commands/*.js").replace("/src/", DIST_DIR)]
500
+ });
501
+ process.on("SIGINT", () => {
502
+ process.exit(0);
503
+ });
504
+ process.on("SIGTERM", () => {
505
+ process.exit(0);
506
+ });
507
+ }
508
+ };
509
+
510
+ //#endregion
511
+ //#region src/spawn.ts
512
+ new zero_default().spawn();
513
+
514
+ //#endregion
515
+ exports.BuildCommand = BuildCommand;
516
+ exports.ConsoleServiceProvider = ConsoleServiceProvider;
517
+ exports.MakeCommand = MakeCommand;
518
+ exports.PostinstallCommand = PostinstallCommand;
519
+ exports.TsDownConfig = TsDownConfig;
520
+ //# sourceMappingURL=index.cjs.map