@arkstack/console 0.1.5 → 0.1.7
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/dist/app.d.ts +1 -2
- package/dist/app.js +1 -49
- package/dist/index.d.ts +1 -2
- package/dist/index.js +6 -328
- package/dist/prepare.d.ts +1 -0
- package/dist/prepare.js +1 -0
- package/package.json +5 -4
- package/dist/app.js.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/app.d.ts
CHANGED
|
@@ -15,5 +15,4 @@ declare class ArkstackConsoleApp<TCore> extends CliApp {
|
|
|
15
15
|
normalizePath: (p: string) => string;
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
18
|
-
export { ArkstackConsoleApp, ConsoleAppOptions, resolveStubsDir };
|
|
19
|
-
//# sourceMappingURL=app.d.ts.map
|
|
18
|
+
export { ArkstackConsoleApp, ConsoleAppOptions, resolveStubsDir };
|
package/dist/app.js
CHANGED
|
@@ -1,49 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CliApp } from "resora";
|
|
3
|
-
import { existsSync } from "node:fs";
|
|
4
|
-
|
|
5
|
-
//#region dist/app.js
|
|
6
|
-
const resolveStubsDir = (config, options) => {
|
|
7
|
-
const configuredDir = config?.localStubsDir;
|
|
8
|
-
if (configuredDir) return isAbsolute(configuredDir) ? configuredDir : join(process.cwd(), configuredDir);
|
|
9
|
-
return options?.stubsDir;
|
|
10
|
-
};
|
|
11
|
-
var ArkstackConsoleApp = class extends CliApp {
|
|
12
|
-
core;
|
|
13
|
-
options;
|
|
14
|
-
constructor(core, options) {
|
|
15
|
-
super();
|
|
16
|
-
this.core = core;
|
|
17
|
-
this.options = options;
|
|
18
|
-
}
|
|
19
|
-
makeController = (name, opts) => {
|
|
20
|
-
const normalized = name.endsWith("Controller") ? name.replace(/controller/i, "") : name;
|
|
21
|
-
const controllersDir = path.resolve(process.cwd(), "src", "app/http/controllers");
|
|
22
|
-
const controllerName = normalized.endsWith("Controller") ? normalized : `${normalized}Controller`;
|
|
23
|
-
const outputPath = join(controllersDir, `${controllerName}.${opts?.ext ?? "ts"}`);
|
|
24
|
-
const stubsDir = resolveStubsDir(this.config, this.options);
|
|
25
|
-
if (!stubsDir) {
|
|
26
|
-
console.error("Error: stubsDir is not configured. Set stubsDir in resora.config.js.");
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
const stubPath = join(stubsDir, opts.model ? this.config.stubs.model : opts.api ? this.config.stubs.api : this.config.stubs.controller);
|
|
30
|
-
if (!existsSync(stubPath)) {
|
|
31
|
-
console.error(`Error: Stub file ${stubPath} not found.`);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
this.generateFile(stubPath, outputPath, {
|
|
35
|
-
ControllerName: controllerName,
|
|
36
|
-
Model: opts.model?.pascalCase(),
|
|
37
|
-
ModelName: opts.model?.camelCase(),
|
|
38
|
-
Name: controllerName.replace(/controller/i, "")
|
|
39
|
-
}, opts);
|
|
40
|
-
return outputPath;
|
|
41
|
-
};
|
|
42
|
-
normalizePath = (p) => {
|
|
43
|
-
return p.replace(process.cwd(), "");
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { ArkstackConsoleApp, resolveStubsDir };
|
|
49
|
-
//# sourceMappingURL=app.js.map
|
|
1
|
+
import e,{isAbsolute as t,join as n}from"node:path";import{CliApp as r}from"resora";import{existsSync as i}from"node:fs";const a=(e,r)=>{let i=e?.localStubsDir;return i?t(i)?i:n(process.cwd(),i):r?.stubsDir};var o=class extends r{core;options;constructor(e,t){super(),this.core=e,this.options=t}makeController=(t,r)=>{let o=t.endsWith(`Controller`)?t.replace(/controller/i,``):t,s=e.resolve(process.cwd(),`src`,`app/http/controllers`),c=o.endsWith(`Controller`)?o:`${o}Controller`,l=n(s,`${c}.${r?.ext??`ts`}`),u=a(this.config,this.options);u||(console.error(`Error: stubsDir is not configured. Set stubsDir in resora.config.js.`),process.exit(1));let d=n(u,r.model?this.config.stubs.model:r.api?this.config.stubs.api:this.config.stubs.controller);return i(d)||(console.error(`Error: Stub file ${d} not found.`),process.exit(1)),this.generateFile(d,l,{ControllerName:c,Model:r.model?.pascalCase(),ModelName:r.model?.camelCase(),Name:c.replace(/controller/i,``)},r),l};normalizePath=e=>e.replace(process.cwd(),``)};export{o as ArkstackConsoleApp,a as resolveStubsDir};
|
package/dist/index.d.ts
CHANGED
|
@@ -9,5 +9,4 @@ interface RunConsoleOptions {
|
|
|
9
9
|
*/
|
|
10
10
|
declare const runConsoleKernel: (options?: RunConsoleOptions) => Promise<void>;
|
|
11
11
|
//#endregion
|
|
12
|
-
export { RunConsoleOptions, runConsoleKernel };
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
|
12
|
+
export { RunConsoleOptions, runConsoleKernel };
|
package/dist/index.js
CHANGED
|
@@ -1,74 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { MakeResource } from "resora";
|
|
6
|
-
import { realpathSync } from "node:fs";
|
|
7
|
-
import { Command, Kernel } from "@h3ravel/musket";
|
|
8
|
-
import { spawn } from "node:child_process";
|
|
9
|
-
import { CliApp as CliApp$1, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, ModelsSyncCommand, SeedCommand } from "arkormx";
|
|
10
|
-
import chalk from "chalk";
|
|
11
|
-
import { loadPrototypes } from "@arkstack/common";
|
|
12
|
-
|
|
13
|
-
//#region dist/commands/BuildCommand.js
|
|
14
|
-
var BuildCommand = class extends Command {
|
|
15
|
-
signature = "build";
|
|
16
|
-
description = "Build the application for production";
|
|
17
|
-
async handle() {
|
|
18
|
-
await new Promise((resolve, reject) => {
|
|
19
|
-
const child = spawn(process.platform === "win32" ? "pnpm.cmd" : "pnpm", ["exec", "tsdown"], {
|
|
20
|
-
cwd: process.cwd(),
|
|
21
|
-
stdio: "inherit",
|
|
22
|
-
env: Object.assign({}, process.env, { NODE_ENV: "production" })
|
|
23
|
-
});
|
|
24
|
-
child.on("error", (error) => {
|
|
25
|
-
reject(error);
|
|
26
|
-
});
|
|
27
|
-
child.on("exit", (code) => {
|
|
28
|
-
if (code === 0 || code === null) {
|
|
29
|
-
resolve();
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
reject(/* @__PURE__ */ new Error(`tsdown exited with code ${code}`));
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region dist/commands/DevCommand.js
|
|
40
|
-
var DevCommand = class extends Command {
|
|
41
|
-
signature = "dev";
|
|
42
|
-
description = "Run the development server";
|
|
43
|
-
async handle() {
|
|
44
|
-
await new Promise((resolve, reject) => {
|
|
45
|
-
const child = spawn(process.platform === "win32" ? "pnpm.cmd" : "pnpm", [
|
|
46
|
-
"exec",
|
|
47
|
-
"tsdown",
|
|
48
|
-
"--log-level",
|
|
49
|
-
"silent"
|
|
50
|
-
], {
|
|
51
|
-
cwd: process.cwd(),
|
|
52
|
-
stdio: "inherit"
|
|
53
|
-
});
|
|
54
|
-
child.on("error", (error) => {
|
|
55
|
-
reject(error);
|
|
56
|
-
});
|
|
57
|
-
child.on("exit", (code) => {
|
|
58
|
-
if (code === 0 || code === null) {
|
|
59
|
-
resolve();
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
reject(/* @__PURE__ */ new Error(`tsdown exited with code ${code}`));
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region dist/commands/MakeController.js
|
|
70
|
-
var MakeController = class extends Command {
|
|
71
|
-
signature = `make:controller
|
|
2
|
+
import{ArkstackConsoleApp as e}from"./app.js";import{fileURLToPath as t,pathToFileURL as n}from"node:url";import{join as r}from"node:path";import{MakeResource as i}from"resora";import{realpathSync as a}from"node:fs";import{Command as o,Kernel as s}from"@h3ravel/musket";import{spawn as c}from"node:child_process";import{CliApp as l,MakeFactoryCommand as u,MakeMigrationCommand as d,MakeModelCommand as f,MakeSeederCommand as p,MigrateCommand as m,ModelsSyncCommand as h,SeedCommand as g}from"arkormx";import _ from"chalk";import{loadPrototypes as v}from"@arkstack/common";var y=class extends o{signature=`build`;description=`Build the application for production`;async handle(){await new Promise((e,t)=>{let n=c(process.platform===`win32`?`pnpm.cmd`:`pnpm`,[`exec`,`tsdown`],{cwd:process.cwd(),stdio:`inherit`,env:Object.assign({},process.env,{NODE_ENV:`production`})});n.on(`error`,e=>{t(e)}),n.on(`exit`,n=>{if(n===0||n===null){e();return}t(Error(`tsdown exited with code ${n}`))})})}},b=class extends o{signature=`dev`;description=`Run the development server`;async handle(){await new Promise((e,t)=>{let n=c(process.platform===`win32`?`pnpm.cmd`:`pnpm`,[`exec`,`tsdown`,`--log-level`,`silent`],{cwd:process.cwd(),stdio:`inherit`});n.on(`error`,e=>{t(e)}),n.on(`exit`,n=>{if(n===0||n===null){e();return}t(Error(`tsdown exited with code ${n}`))})})}},x=class extends o{signature=`make:controller
|
|
72
3
|
{name : name of the controller to create}
|
|
73
4
|
{--api : make an API controller}
|
|
74
5
|
{--m|model? : name of model to attach to controller}
|
|
@@ -76,275 +7,22 @@ var MakeController = class extends Command {
|
|
|
76
7
|
{--s|seeder : Create a seeder file for the model (only if --model is specified)}
|
|
77
8
|
{--x|migration : Create a migration file for the model (only if --model is specified)}
|
|
78
9
|
{--force : force overwrite if controller already exists}
|
|
79
|
-
`;
|
|
80
|
-
description = "Create a new controller file";
|
|
81
|
-
async handle() {
|
|
82
|
-
this.app.command = this;
|
|
83
|
-
if (!this.argument("name")) return void this.error("Error: Controller name is required.");
|
|
84
|
-
const name = this.app.makeController(this.argument("name"), this.options());
|
|
85
|
-
const app = new CliApp$1();
|
|
86
|
-
const model = this.option("model") ? app.makeModel(this.argument("model"), {
|
|
87
|
-
...this.options(),
|
|
88
|
-
force: false
|
|
89
|
-
}) : null;
|
|
90
|
-
this.success("Controller created successfully!");
|
|
91
|
-
[
|
|
92
|
-
["Controller", name],
|
|
93
|
-
model ? ["Model", model.model.path] : "",
|
|
94
|
-
model ? [`Prisma schema ${model.prisma.updated ? "(updated)" : "(already up to date)"}`, model?.prisma.path] : "",
|
|
95
|
-
model?.factory ? ["Factory", model.factory.path] : "",
|
|
96
|
-
model?.seeder ? ["Seeder", model.seeder.path] : "",
|
|
97
|
-
model?.migration ? ["Migration", model.migration.path] : ""
|
|
98
|
-
].filter(Boolean).map(([name, path]) => this.success(app.splitLogger(name, path)));
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
//#endregion
|
|
103
|
-
//#region dist/commands/MakeFactoryCommand.js
|
|
104
|
-
var MakeFactoryCommand$1 = class extends MakeFactoryCommand {
|
|
105
|
-
async handle() {
|
|
106
|
-
this.app.command = this;
|
|
107
|
-
this.app = new CliApp$1();
|
|
108
|
-
return super.handle();
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region dist/commands/MakeFullResource.js
|
|
114
|
-
var MakeFullResource = class extends Command {
|
|
115
|
-
signature = `make:full-resource
|
|
10
|
+
`;description=`Create a new controller file`;async handle(){if(this.app.command=this,!this.argument(`name`))return void this.error(`Error: Controller name is required.`);let e=this.app.makeController(this.argument(`name`),this.options()),t=new l,n=this.option(`model`)?t.makeModel(this.argument(`model`),{...this.options(),force:!1}):null;this.success(`Controller created successfully!`),[[`Controller`,e],n?[`Model`,n.model.path]:``,n?[`Prisma schema ${n.prisma.updated?`(updated)`:`(already up to date)`}`,n?.prisma.path]:``,n?.factory?[`Factory`,n.factory.path]:``,n?.seeder?[`Seeder`,n.seeder.path]:``,n?.migration?[`Migration`,n.migration.path]:``].filter(Boolean).map(([e,n])=>this.success(t.splitLogger(e,n)))}},S=class extends u{async handle(){return this.app.command=this,this.app=new l,super.handle()}},C=class extends o{signature=`make:full-resource
|
|
116
11
|
{prefix : prefix of the resources to create, "Admin" will create AdminResource, AdminCollection and AdminController}
|
|
117
12
|
{--m|model? : name of model to attach to the generated controller (will be created if it doesn't exist)}
|
|
118
13
|
{--f|factory : Create and link a factory}
|
|
119
14
|
{--s|seeder : Create a seeder file for the model (only if --model is specified)}
|
|
120
15
|
{--x|migration : Create a migration file for the model (only if --model is specified)}
|
|
121
16
|
{--force : force overwrite if resources already exist}
|
|
122
|
-
`;
|
|
123
|
-
description = "Create a full new set of API resources (Controller, Resource, Collection)";
|
|
124
|
-
async handle() {
|
|
125
|
-
this.app.command = this;
|
|
126
|
-
const res = this.app.makeResource(this.argument("prefix"), { force: this.option("force") });
|
|
127
|
-
const col = this.app.makeResource(this.argument("prefix") + "Collection", {
|
|
128
|
-
collection: true,
|
|
129
|
-
force: this.option("force")
|
|
130
|
-
});
|
|
131
|
-
const cont = this.app.makeController(this.argument("prefix"), Object.assign({}, this.options(), {
|
|
132
|
-
api: true,
|
|
133
|
-
force: this.option("force")
|
|
134
|
-
}));
|
|
135
|
-
const app = new CliApp$1();
|
|
136
|
-
const model = this.option("model") ? app.makeModel(this.argument("prefix"), {
|
|
137
|
-
...this.options(),
|
|
138
|
-
force: false
|
|
139
|
-
}) : null;
|
|
140
|
-
this.success("Created full resource set:");
|
|
141
|
-
[
|
|
142
|
-
["Resource", res.path],
|
|
143
|
-
["Collection", col.path],
|
|
144
|
-
["Controller", cont],
|
|
145
|
-
model ? ["Model", model.model.path] : "",
|
|
146
|
-
model ? [`Prisma schema ${model.prisma.updated ? "(updated)" : "(already up to date)"}`, model.prisma.path] : "",
|
|
147
|
-
model?.factory ? ["Factory", model.factory.path] : "",
|
|
148
|
-
model?.seeder ? ["Seeder", model.seeder.path] : "",
|
|
149
|
-
model?.migration ? ["Migration", model.migration.path] : ""
|
|
150
|
-
].filter(Boolean).map(([name, path]) => this.success(app.splitLogger(name, path)));
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
//#endregion
|
|
155
|
-
//#region dist/commands/MakeMigrationCommand.js
|
|
156
|
-
var MakeMigrationCommand$1 = class extends MakeMigrationCommand {
|
|
157
|
-
async handle() {
|
|
158
|
-
this.app.command = this;
|
|
159
|
-
this.app = new CliApp$1();
|
|
160
|
-
return super.handle();
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
//#endregion
|
|
165
|
-
//#region dist/commands/MakeModelCommand.js
|
|
166
|
-
var MakeModelCommand$1 = class extends MakeModelCommand {
|
|
167
|
-
async handle() {
|
|
168
|
-
this.app.command = this;
|
|
169
|
-
this.app = new CliApp$1();
|
|
170
|
-
return super.handle();
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region dist/commands/MakeResource.js
|
|
176
|
-
var MakeResource$1 = class extends MakeResource {};
|
|
177
|
-
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region dist/commands/MakeSeederCommand.js
|
|
180
|
-
var MakeSeederCommand$1 = class extends MakeSeederCommand {
|
|
181
|
-
async handle() {
|
|
182
|
-
this.app.command = this;
|
|
183
|
-
this.app = new CliApp$1();
|
|
184
|
-
return super.handle();
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
//#endregion
|
|
189
|
-
//#region dist/commands/MigrateCommand.js
|
|
190
|
-
var MigrateCommand$1 = class extends MigrateCommand {
|
|
191
|
-
async handle() {
|
|
192
|
-
this.app.command = this;
|
|
193
|
-
this.app = new CliApp$1();
|
|
194
|
-
return super.handle();
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
//#endregion
|
|
199
|
-
//#region dist/commands/ModelsSyncCommand.js
|
|
200
|
-
var ModelsSyncCommand$1 = class extends ModelsSyncCommand {
|
|
201
|
-
async handle() {
|
|
202
|
-
this.app.command = this;
|
|
203
|
-
this.app = new CliApp$1();
|
|
204
|
-
return super.handle();
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
//#endregion
|
|
209
|
-
//#region dist/commands/RouteList.js
|
|
210
|
-
var RouteList = class extends Command {
|
|
211
|
-
signature = `route:list
|
|
17
|
+
`;description=`Create a full new set of API resources (Controller, Resource, Collection)`;async handle(){this.app.command=this;let e=this.app.makeResource(this.argument(`prefix`),{force:this.option(`force`)}),t=this.app.makeResource(this.argument(`prefix`)+`Collection`,{collection:!0,force:this.option(`force`)}),n=this.app.makeController(this.argument(`prefix`),Object.assign({},this.options(),{api:!0,force:this.option(`force`)})),r=new l,i=this.option(`model`)?r.makeModel(this.argument(`prefix`),{...this.options(),force:!1}):null;this.success(`Created full resource set:`),[[`Resource`,e.path],[`Collection`,t.path],[`Controller`,n],i?[`Model`,i.model.path]:``,i?[`Prisma schema ${i.prisma.updated?`(updated)`:`(already up to date)`}`,i.prisma.path]:``,i?.factory?[`Factory`,i.factory.path]:``,i?.seeder?[`Seeder`,i.seeder.path]:``,i?.migration?[`Migration`,i.migration.path]:``].filter(Boolean).map(([e,t])=>this.success(r.splitLogger(e,t)))}},w=class extends d{async handle(){return this.app.command=this,this.app=new l,super.handle()}},T=class extends f{async handle(){return this.app.command=this,this.app=new l,super.handle()}},E=class extends i{},D=class extends p{async handle(){return this.app.command=this,this.app=new l,super.handle()}},O=class extends m{async handle(){return this.app.command=this,this.app=new l,super.handle()}},k=class extends h{async handle(){return this.app.command=this,this.app=new l,super.handle()}},A=class extends o{signature=`route:list
|
|
212
18
|
{--p|path? : Path to filter routes by}
|
|
213
19
|
{--m|method? : Method to filter routes by}
|
|
214
|
-
`;
|
|
215
|
-
|
|
216
|
-
async handle() {
|
|
217
|
-
const routes = await this.app.core.getRouter().list(this.options(), this.app.core.getAppInstance());
|
|
218
|
-
const filteredRoutes = this.filterRoutes(routes);
|
|
219
|
-
console.log(this.formatRoutes(filteredRoutes.reverse()));
|
|
220
|
-
this.newLine();
|
|
221
|
-
this.info(`Total routes: ${filteredRoutes.length}`);
|
|
222
|
-
}
|
|
223
|
-
filterRoutes(routes) {
|
|
224
|
-
const path = this.option("path");
|
|
225
|
-
const method = this.option("method");
|
|
226
|
-
if (!path && !method) return routes;
|
|
227
|
-
return routes.filter((route) => {
|
|
228
|
-
const pathMatches = path ? route.path.includes(path) : true;
|
|
229
|
-
const methodMatches = method ? route.methods.includes(method.toLowerCase()) : true;
|
|
230
|
-
return pathMatches && methodMatches;
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
formatRoutes(routes) {
|
|
234
|
-
if (routes.length === 0) return "No routes registered.";
|
|
235
|
-
const rows = routes.map((route) => ({
|
|
236
|
-
method: route.methods.join(" | ").toUpperCase(),
|
|
237
|
-
path: route.path,
|
|
238
|
-
handler: route.controllerName ? `${route.controllerName} → ${route.actionName}` : route.actionName ?? "N/A"
|
|
239
|
-
}));
|
|
240
|
-
const methodWidth = Math.max(6, ...rows.map((row) => row.method.length));
|
|
241
|
-
const pathWidth = Math.max(4, ...rows.map((row) => row.path.length));
|
|
242
|
-
const handlerWidth = Math.max(7, ...rows.map((row) => row.handler.length));
|
|
243
|
-
return [
|
|
244
|
-
`${"METHOD".padEnd(methodWidth)} ${"PATH".padEnd(pathWidth)} ${"HANDLER".padEnd(handlerWidth)}`,
|
|
245
|
-
`${"-".repeat(methodWidth)} ${"-".repeat(pathWidth)} ${"-".repeat(handlerWidth)}`,
|
|
246
|
-
...rows.map((row) => `${this.formatMethod(row.method.padEnd(methodWidth))} ${chalk.blue(row.path.padEnd(pathWidth))} ${chalk.yellow(row.handler.padEnd(handlerWidth))}`)
|
|
247
|
-
].join("\n");
|
|
248
|
-
}
|
|
249
|
-
methodColor(method) {
|
|
250
|
-
switch (method) {
|
|
251
|
-
case "GET": return chalk.green(method);
|
|
252
|
-
case "POST": return chalk.blue(method);
|
|
253
|
-
case "PUT": return chalk.yellow(method);
|
|
254
|
-
case "DELETE": return chalk.red(method);
|
|
255
|
-
case "PATCH": return chalk.magenta(method);
|
|
256
|
-
case "OPTIONS": return chalk.cyan(method);
|
|
257
|
-
default: return chalk.gray(method);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
formatMethod(method) {
|
|
261
|
-
const methods = method.split(" | ");
|
|
262
|
-
if (methods.length > 1) return methods.map((m) => this.methodColor(m)).join(chalk.gray(" | "));
|
|
263
|
-
return this.methodColor(method.toUpperCase());
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
//#endregion
|
|
268
|
-
//#region dist/commands/SeedCommand.js
|
|
269
|
-
var SeedCommand$1 = class extends SeedCommand {
|
|
270
|
-
async handle() {
|
|
271
|
-
this.app.command = this;
|
|
272
|
-
this.app = new CliApp$1();
|
|
273
|
-
return super.handle();
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
//#endregion
|
|
278
|
-
//#region dist/logo.js
|
|
279
|
-
var logo_default = String.raw`
|
|
20
|
+
`;description=`List all registered routes`;async handle(){let e=await this.app.core.getRouter().list(this.options(),this.app.core.getAppInstance()),t=this.filterRoutes(e);console.log(this.formatRoutes(t.reverse())),this.newLine(),this.info(`Total routes: ${t.length}`)}filterRoutes(e){let t=this.option(`path`),n=this.option(`method`);return!t&&!n?e:e.filter(e=>{let r=t?e.path.includes(t):!0,i=n?e.methods.includes(n.toLowerCase()):!0;return r&&i})}formatRoutes(e){if(e.length===0)return`No routes registered.`;let t=e.map(e=>({method:e.methods.join(` | `).toUpperCase(),path:e.path,handler:e.controllerName?`${e.controllerName} → ${e.actionName}`:e.actionName??`N/A`})),n=Math.max(6,...t.map(e=>e.method.length)),r=Math.max(4,...t.map(e=>e.path.length)),i=Math.max(7,...t.map(e=>e.handler.length));return[`${`METHOD`.padEnd(n)} ${`PATH`.padEnd(r)} ${`HANDLER`.padEnd(i)}`,`${`-`.repeat(n)} ${`-`.repeat(r)} ${`-`.repeat(i)}`,...t.map(e=>`${this.formatMethod(e.method.padEnd(n))} ${_.blue(e.path.padEnd(r))} ${_.yellow(e.handler.padEnd(i))}`)].join(`
|
|
21
|
+
`)}methodColor(e){switch(e){case`GET`:return _.green(e);case`POST`:return _.blue(e);case`PUT`:return _.yellow(e);case`DELETE`:return _.red(e);case`PATCH`:return _.magenta(e);case`OPTIONS`:return _.cyan(e);default:return _.gray(e)}}formatMethod(e){let t=e.split(` | `);return t.length>1?t.map(e=>this.methodColor(e)).join(_.gray(` | `)):this.methodColor(e.toUpperCase())}},j=class extends g{async handle(){return this.app.command=this,this.app=new l,super.handle()}},M=String.raw`
|
|
280
22
|
___ _ _
|
|
281
23
|
/ _ \ | | | |
|
|
282
24
|
/ /_\ \_ __ ___ ___| |_ __ _ ___| | __
|
|
283
25
|
| _ | '__/ __/ __| __/ _' |/ __| |/ /
|
|
284
26
|
| | | | | | (__\__ \ || (_| | (__| <
|
|
285
27
|
\_| |_/_| \___|___/\__\__,_|\___|_|\_\
|
|
286
|
-
`;
|
|
287
|
-
|
|
288
|
-
//#endregion
|
|
289
|
-
//#region dist/index.js
|
|
290
|
-
/**
|
|
291
|
-
* Loads the core application instance by importing the bootstrap file.
|
|
292
|
-
*
|
|
293
|
-
* @returns
|
|
294
|
-
*/
|
|
295
|
-
const loadCoreApp = async () => {
|
|
296
|
-
return (await import(pathToFileURL(join(process.cwd(), "dist/core/bootstrap.js")).href)).app;
|
|
297
|
-
};
|
|
298
|
-
/**
|
|
299
|
-
* Runs the console kernel, initializing the application and registering commands.
|
|
300
|
-
*
|
|
301
|
-
* @param options
|
|
302
|
-
*/
|
|
303
|
-
const runConsoleKernel = async (options = {}) => {
|
|
304
|
-
loadPrototypes();
|
|
305
|
-
const app = await loadCoreApp();
|
|
306
|
-
const stubsDir = process.env.ARKSTACK_STUBS_DIR;
|
|
307
|
-
await Kernel.init(await new ArkstackConsoleApp(app, { stubsDir }).loadConfig(), {
|
|
308
|
-
logo: options.logo ?? logo_default,
|
|
309
|
-
name: "Cmd",
|
|
310
|
-
baseCommands: [
|
|
311
|
-
RouteList,
|
|
312
|
-
MakeResource$1,
|
|
313
|
-
MakeController,
|
|
314
|
-
MakeFullResource,
|
|
315
|
-
DevCommand,
|
|
316
|
-
BuildCommand,
|
|
317
|
-
MakeFactoryCommand$1,
|
|
318
|
-
MakeMigrationCommand$1,
|
|
319
|
-
MakeModelCommand$1,
|
|
320
|
-
MakeSeederCommand$1,
|
|
321
|
-
MigrateCommand$1,
|
|
322
|
-
ModelsSyncCommand$1,
|
|
323
|
-
SeedCommand$1
|
|
324
|
-
],
|
|
325
|
-
discoveryPaths: [join(process.cwd(), "dist/app/console/commands/*.js")],
|
|
326
|
-
exceptionHandler(exception) {
|
|
327
|
-
throw exception;
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
};
|
|
331
|
-
/**
|
|
332
|
-
* Determines if the current module is being executed as the entry
|
|
333
|
-
* point of the application.
|
|
334
|
-
*
|
|
335
|
-
* @returns
|
|
336
|
-
*/
|
|
337
|
-
const isEntrypointExecution = () => {
|
|
338
|
-
const argvEntry = process.argv[1];
|
|
339
|
-
if (!argvEntry) return false;
|
|
340
|
-
try {
|
|
341
|
-
return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(argvEntry);
|
|
342
|
-
} catch {
|
|
343
|
-
return import.meta.url === pathToFileURL(argvEntry).href;
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
if (isEntrypointExecution()) await runConsoleKernel();
|
|
347
|
-
|
|
348
|
-
//#endregion
|
|
349
|
-
export { runConsoleKernel };
|
|
350
|
-
//# sourceMappingURL=index.js.map
|
|
28
|
+
`;const N=async()=>(await import(n(r(process.cwd(),`dist/core/bootstrap.js`)).href)).app,P=async(t={})=>{v();let n=await N(),i=process.env.ARKSTACK_STUBS_DIR;await s.init(await new e(n,{stubsDir:i}).loadConfig(),{logo:t.logo??M,name:`Cmd`,baseCommands:[A,E,x,C,b,y,S,w,T,D,O,k,j],discoveryPaths:[r(process.cwd(),`dist/app/console/commands/*.js`)],exceptionHandler(e){throw e}})};(()=>{let e=process.argv[1];if(!e)return!1;try{return a(t(import.meta.url))===a(e)}catch{return import.meta.url===n(e).href}})()&&await P();export{P as runConsoleKernel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/prepare.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawn as e}from"node:child_process";import t from"chalk";const n=e(process.platform===`win32`?`pnpm.cmd`:`pnpm`,[`exec`,`tsdown`,`--log-level=silent`],{cwd:process.cwd(),stdio:`inherit`,env:Object.assign({},process.env,{NODE_ENV:`production`})});n.on(`error`,e=>{throw e}),n.on(`exit`,e=>{if(e===0||e===null){console.log(t.green(`Arkstak is ready for development!`));return}throw Error(`tsdown exited with code ${e}`)});export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/console",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Console package for Arkstack providing console-specific implementations of core Arkstack features such as routing, middleware, and database integration.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"bin": {
|
|
31
|
-
"ark": "./dist/index.js"
|
|
31
|
+
"ark": "./dist/index.js",
|
|
32
|
+
"prepare": "./dist/prepare.js"
|
|
32
33
|
},
|
|
33
34
|
"exports": {
|
|
34
35
|
".": {
|
|
@@ -48,8 +49,8 @@
|
|
|
48
49
|
"@h3ravel/musket": "^0.10.1",
|
|
49
50
|
"chalk": "^5.6.2",
|
|
50
51
|
"resora": "^0.2.6",
|
|
51
|
-
"@arkstack/common": "^0.1.
|
|
52
|
-
"@arkstack/contract": "^0.1.
|
|
52
|
+
"@arkstack/common": "^0.1.7",
|
|
53
|
+
"@arkstack/contract": "^0.1.7"
|
|
53
54
|
},
|
|
54
55
|
"scripts": {
|
|
55
56
|
"build": "tsdown",
|
package/dist/app.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","names":[],"sources":["../src/app.ts"],"sourcesContent":["// oxlint-disable typescript/no-explicit-any\nimport path, { isAbsolute, join } from 'node:path'\n\nimport { CliApp } from 'resora'\nimport { existsSync } from 'node:fs'\n\nexport interface ConsoleAppOptions {\n stubsDir?: string;\n}\n\nexport const resolveStubsDir = (\n config: { localStubsDir?: string } | undefined,\n options?: ConsoleAppOptions,\n) => {\n const configuredDir = config?.localStubsDir\n\n if (configuredDir) {\n return isAbsolute(configuredDir)\n ? configuredDir\n : join(process.cwd(), configuredDir)\n }\n\n return options?.stubsDir\n}\n\nexport class ArkstackConsoleApp<TCore> extends CliApp {\n core: TCore\n private readonly options: ConsoleAppOptions\n\n constructor(\n core: TCore,\n options: ConsoleAppOptions,\n ) {\n super()\n this.core = core\n this.options = options\n }\n\n makeController = (name: string, opts: any) => {\n const normalized = name.endsWith('Controller') ? name.replace(/controller/i, '') : name\n\n const controllersDir = path.resolve(process.cwd(), 'src', 'app/http/controllers')\n const controllerName = normalized.endsWith('Controller') ? normalized : `${normalized}Controller`\n const fileName = `${controllerName}.${opts?.ext ?? 'ts'}`\n const outputPath = join(controllersDir, fileName)\n const stubsDir = resolveStubsDir(this.config as any, this.options)\n if (!stubsDir) {\n console.error('Error: stubsDir is not configured. Set stubsDir in resora.config.js.')\n process.exit(1)\n }\n\n const stubPath = join(\n stubsDir,\n opts.model\n ? (this.config.stubs as any).model\n : opts.api\n ? (this.config.stubs as any).api\n : (this.config.stubs as any).controller,\n )\n\n if (!existsSync(stubPath)) {\n console.error(`Error: Stub file ${stubPath} not found.`)\n process.exit(1)\n }\n\n this.generateFile(\n stubPath,\n outputPath,\n {\n ControllerName: controllerName,\n Model: opts.model?.pascalCase(),\n ModelName: opts.model?.camelCase(),\n Name: controllerName.replace(/controller/i, ''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AAQ,QAAQ,KAAK,EAAE,GAAG"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["CliApp","MakeFactoryCommand","Command","CliApp","CliApp","MakeMigrationCommand","Command","CliApp","MakeModelCommand","Command","CliApp","MakeResource","MakeResourceBase","MakeSeederCommand","Command","CliApp","MigrateCommand","Command","CliApp","ModelsSyncCommand","Command","CliApp","SeedCommand","Command","CliApp","logo","MakeResource","MakeFactoryCommand","MakeMigrationCommand","MakeModelCommand","MakeSeederCommand","MigrateCommand","ModelsSyncCommand","SeedCommand"],"sources":["../src/commands/BuildCommand.ts","../src/commands/DevCommand.ts","../src/commands/MakeController.ts","../src/commands/MakeFactoryCommand.ts","../src/commands/MakeFullResource.ts","../src/commands/MakeMigrationCommand.ts","../src/commands/MakeModelCommand.ts","../src/commands/MakeResource.ts","../src/commands/MakeSeederCommand.ts","../src/commands/MigrateCommand.ts","../src/commands/ModelsSyncCommand.ts","../src/commands/RouteList.ts","../src/commands/SeedCommand.ts","../src/logo.ts","../src/index.ts"],"sourcesContent":["import { Command } from '@h3ravel/musket'\nimport { spawn } from 'node:child_process'\n\nexport class BuildCommand extends Command {\n protected signature = 'build'\n\n protected description = 'Build the application for production'\n\n async handle () {\n await new Promise<void>((resolve, reject) => {\n const command = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'\n const child = spawn(command, ['exec', 'tsdown'], {\n cwd: process.cwd(),\n stdio: 'inherit',\n env: Object.assign({}, process.env, {\n NODE_ENV: 'production',\n }),\n })\n\n child.on('error', (error) => {\n reject(error)\n })\n\n child.on('exit', (code) => {\n if (code === 0 || code === null) {\n resolve()\n \nreturn\n }\n\n reject(new Error(`tsdown exited with code ${code}`))\n })\n })\n }\n}\n","import { Command } from '@h3ravel/musket'\nimport { spawn } from 'node:child_process'\n\nexport class DevCommand extends Command {\n protected signature = 'dev'\n\n protected description = 'Run the development server'\n\n async handle () {\n await new Promise<void>((resolve, reject) => {\n const command = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm'\n const child = spawn(command, ['exec', 'tsdown', '--log-level', 'silent'], {\n cwd: process.cwd(),\n stdio: 'inherit',\n })\n\n child.on('error', (error) => {\n reject(error)\n })\n\n child.on('exit', (code) => {\n if (code === 0 || code === null) {\n resolve()\n \nreturn\n }\n\n reject(new Error(`tsdown exited with code ${code}`))\n })\n })\n }\n}\n","import { ArkstackConsoleApp } from '../app'\nimport { CliApp } from 'arkormx'\nimport { Command } from '@h3ravel/musket'\n\n// oxlint-disable-next-line typescript/no-explicit-any\nexport class MakeController extends Command<ArkstackConsoleApp<any>> {\n protected signature = `make:controller\n {name : name of the controller to create}\n {--api : make an API controller}\n {--m|model? : name of model to attach to controller}\n {--f|factory : Create and link a factory}\n {--s|seeder : Create a seeder file for the model (only if --model is specified)}\n {--x|migration : Create a migration file for the model (only if --model is specified)}\n {--force : force overwrite if controller already exists}\n `\n\n protected description = 'Create a new controller file'\n\n async handle () {\n this.app.command = this\n\n if (!this.argument('name')) return void this.error('Error: Controller name is required.')\n\n const name = this.app.makeController(this.argument('name'), this.options())\n\n const app = new CliApp()\n\n const model = this.option('model')\n ? app.makeModel(this.argument('model'), { ...this.options(), force: false })\n : null\n\n this.success('Controller created successfully!');\n\n [\n ['Controller', name],\n model ? ['Model', model.model.path] : '',\n model ? [`Prisma schema ${model.prisma.updated ? '(updated)' : '(already up to date)'}`, model?.prisma.path] : '',\n model?.factory ? ['Factory', model.factory.path] : '',\n model?.seeder ? ['Seeder', model.seeder.path] : '',\n model?.migration ? ['Migration', model.migration.path] : ''\n ].filter(Boolean).map(([name, path]) => this.success(app.splitLogger(name!, path!)))\n }\n}\n","import { CliApp, MakeFactoryCommand as Command } from 'arkormx'\n\nexport class MakeFactoryCommand extends Command {\n async handle () {\n this.app.command = this\n\n this.app = new CliApp()\n\n return super.handle()\n }\n}\n","import { ArkstackConsoleApp } from '../app'\nimport { CliApp } from 'arkormx'\nimport { Command } from '@h3ravel/musket'\n\n// oxlint-disable-next-line typescript/no-explicit-any\nexport class MakeFullResource extends Command<ArkstackConsoleApp<any>> {\n protected signature = `make:full-resource\n {prefix : prefix of the resources to create, \"Admin\" will create AdminResource, AdminCollection and AdminController}\n {--m|model? : name of model to attach to the generated controller (will be created if it doesn't exist)}\n {--f|factory : Create and link a factory}\n {--s|seeder : Create a seeder file for the model (only if --model is specified)}\n {--x|migration : Create a migration file for the model (only if --model is specified)}\n {--force : force overwrite if resources already exist}\n `\n\n protected description =\n 'Create a full new set of API resources (Controller, Resource, Collection)'\n\n async handle () {\n this.app.command = this\n\n const res = this.app.makeResource(this.argument('prefix'), {\n force: this.option('force')\n })\n\n const col = this.app.makeResource(this.argument('prefix') + 'Collection', {\n collection: true,\n force: this.option('force'),\n })\n\n const cont = this.app.makeController(\n this.argument('prefix'),\n Object.assign({}, this.options(), { api: true, force: this.option('force') }),\n )\n\n const app = new CliApp()\n\n const model = this.option('model')\n ? app.makeModel(this.argument('prefix'), { ...this.options(), force: false })\n : null\n\n this.success('Created full resource set:');\n\n [\n ['Resource', res.path],\n ['Collection', col.path],\n ['Controller', cont],\n model ? ['Model', model.model.path] : '',\n model ? [`Prisma schema ${model.prisma.updated ? '(updated)' : '(already up to date)'}`, model.prisma.path] : '',\n model?.factory ? ['Factory', model.factory.path] : '',\n model?.seeder ? ['Seeder', model.seeder.path] : '',\n model?.migration ? ['Migration', model.migration.path] : ''\n ].filter(Boolean).map(([name, path]) => this.success(app.splitLogger(name!, path!)))\n }\n}\n","import { CliApp, MakeMigrationCommand as Command } from 'arkormx'\n\nexport class MakeMigrationCommand extends Command {\n async handle () {\n this.app.command = this\n\n this.app = new CliApp()\n\n return super.handle()\n }\n}\n","import { CliApp, MakeModelCommand as Command } from 'arkormx'\n\nexport class MakeModelCommand extends Command {\n async handle () {\n this.app.command = this\n\n this.app = new CliApp()\n\n return super.handle()\n }\n}\n","import { MakeResource as MakeResourceBase } from 'resora'\n\nexport class MakeResource extends MakeResourceBase {\n}\n","import { CliApp, MakeSeederCommand as Command } from 'arkormx'\n\nexport class MakeSeederCommand extends Command {\n async handle () {\n this.app.command = this\n\n this.app = new CliApp()\n\n return super.handle()\n }\n}\n","import { CliApp, MigrateCommand as Command } from 'arkormx'\n\nexport class MigrateCommand extends Command {\n async handle () {\n this.app.command = this\n\n this.app = new CliApp()\n\n return super.handle()\n }\n}\n","import { CliApp, ModelsSyncCommand as Command } from 'arkormx'\n\nexport class ModelsSyncCommand extends Command {\n async handle () {\n this.app.command = this\n\n this.app = new CliApp()\n\n return super.handle()\n }\n}\n","import { ArkstackConsoleApp } from '../app'\nimport type { ArkstackRouterAwareCore } from '@arkstack/contract'\nimport { Command } from '@h3ravel/musket'\nimport type { Route } from 'clear-router'\nimport chalk from 'chalk'\n\ntype App = ArkstackConsoleApp<ArkstackRouterAwareCore<unknown, Route[]>>;\n\nexport class RouteList extends Command<App> {\n protected signature = `route:list\n {--p|path? : Path to filter routes by}\n {--m|method? : Method to filter routes by}\n `\n\n protected description = 'List all registered routes'\n\n async handle () {\n const routes = await this.app.core.getRouter().list(this.options(), this.app.core.getAppInstance())\n const filteredRoutes = this.filterRoutes(routes)\n\n console.log(this.formatRoutes(filteredRoutes.reverse()))\n this.newLine()\n this.info(`Total routes: ${filteredRoutes.length}`)\n }\n\n private filterRoutes (routes: Route[]) {\n const path = this.option('path')\n const method = this.option('method')\n\n if (!path && !method) {\n return routes\n }\n\n return routes.filter((route) => {\n const pathMatches = path ? route.path.includes(path) : true\n const methodMatches = method ? route.methods.includes(method.toLowerCase()) : true\n\n return pathMatches && methodMatches\n })\n }\n\n private formatRoutes (routes: Route[]) {\n if (routes.length === 0) {\n return 'No routes registered.'\n }\n\n const rows = routes.map((route) => ({\n method: route.methods.join(' | ').toUpperCase(),\n path: route.path,\n handler: route.controllerName ? `${route.controllerName} → ${route.actionName}` : route.actionName ?? 'N/A',\n }))\n\n const methodWidth = Math.max('METHOD'.length, ...rows.map((row) => row.method.length))\n const pathWidth = Math.max('PATH'.length, ...rows.map((row) => row.path.length))\n const handlerWidth = Math.max('HANDLER'.length, ...rows.map((row) => row.handler.length))\n\n const header = `${'METHOD'.padEnd(methodWidth)} ${'PATH'.padEnd(pathWidth)} ${'HANDLER'.padEnd(handlerWidth)}`\n const divider = `${'-'.repeat(methodWidth)} ${'-'.repeat(pathWidth)} ${'-'.repeat(handlerWidth)}`\n const body = rows.map(\n (row) => `${this.formatMethod(row.method.padEnd(methodWidth))} ${chalk.blue(row.path.padEnd(pathWidth))} ${chalk.yellow(row.handler.padEnd(handlerWidth))}`\n )\n\n return [header, divider, ...body].join('\\n')\n }\n\n private methodColor (method: string) {\n switch (method) {\n case 'GET':\n return chalk.green(method)\n case 'POST':\n return chalk.blue(method)\n case 'PUT':\n return chalk.yellow(method)\n case 'DELETE':\n return chalk.red(method)\n case 'PATCH':\n return chalk.magenta(method)\n case 'OPTIONS':\n return chalk.cyan(method)\n default:\n return chalk.gray(method)\n }\n }\n\n private formatMethod (method: string) {\n const methods = method.split(' | ')\n if (methods.length > 1) {\n return methods.map((m) => this.methodColor(m)).join(chalk.gray(' | '))\n }\n\n return this.methodColor(method.toUpperCase())\n }\n}\n","import { CliApp, SeedCommand as Command } from 'arkormx'\n\nexport class SeedCommand extends Command {\n async handle () {\n this.app.command = this\n\n this.app = new CliApp()\n\n return super.handle()\n }\n}\n","export default String.raw`\n ___ _ _ \n / _ \\ | | | | \n/ /_\\ \\_ __ ___ ___| |_ __ _ ___| | __\n| _ | '__/ __/ __| __/ _' |/ __| |/ /\n| | | | | | (__\\__ \\ || (_| | (__| < \n\\_| |_/_| \\___|___/\\__\\__,_|\\___|_|\\_\\ \n`","#!/usr/bin/env node\n\nimport { fileURLToPath, pathToFileURL } from 'node:url'\n\nimport { ArkstackConsoleApp } from './app'\nimport { BuildCommand } from './commands/BuildCommand'\nimport { DevCommand } from './commands/DevCommand'\nimport { Kernel } from '@h3ravel/musket'\nimport { MakeController } from './commands/MakeController'\nimport { MakeFactoryCommand } from './commands/MakeFactoryCommand'\nimport { MakeFullResource } from './commands/MakeFullResource'\nimport { MakeMigrationCommand } from './commands/MakeMigrationCommand'\nimport { MakeModelCommand } from './commands/MakeModelCommand'\nimport { MakeResource } from './commands/MakeResource'\nimport { MakeSeederCommand } from './commands/MakeSeederCommand'\nimport { MigrateCommand } from './commands/MigrateCommand'\nimport { ModelsSyncCommand } from './commands/ModelsSyncCommand'\nimport { RouteList } from './commands/RouteList'\nimport { SeedCommand } from './commands/SeedCommand'\nimport { join } from 'node:path'\nimport { loadPrototypes } from '@arkstack/common'\nimport logo from './logo'\nimport { realpathSync } from 'node:fs'\n\nexport interface RunConsoleOptions {\n logo?: string;\n}\n\n/**\n * Loads the core application instance by importing the bootstrap file.\n * \n * @returns \n */\nconst loadCoreApp = async () => {\n const bootstrapPath = pathToFileURL(join(process.cwd(), 'src/core/bootstrap.ts')).href\n const module = await import(bootstrapPath)\n\n return module.app\n}\n\n/**\n * Runs the console kernel, initializing the application and registering commands.\n * \n * @param options \n */\nexport const runConsoleKernel = async (options: RunConsoleOptions = {}) => {\n loadPrototypes()\n\n const app = await loadCoreApp()\n const stubsDir = process.env.ARKSTACK_STUBS_DIR\n\n await Kernel.init(await new ArkstackConsoleApp(app, { stubsDir }).loadConfig(), {\n logo: options.logo ?? logo,\n name: 'Cmd',\n baseCommands: [\n RouteList,\n MakeResource,\n MakeController,\n MakeFullResource,\n DevCommand,\n BuildCommand,\n MakeFactoryCommand,\n MakeMigrationCommand,\n MakeModelCommand,\n MakeSeederCommand,\n MigrateCommand,\n ModelsSyncCommand,\n SeedCommand,\n ],\n discoveryPaths: [join(process.cwd(), 'src/app/console/commands/*.ts')],\n exceptionHandler (exception) {\n throw exception\n },\n })\n}\n\n/**\n * Determines if the current module is being executed as the entry \n * point of the application.\n * \n * @returns \n */\nconst isEntrypointExecution = () => {\n const argvEntry = process.argv[1]\n\n if (!argvEntry) {\n return false\n }\n\n try {\n const currentModulePath = realpathSync(fileURLToPath(import.meta.url))\n const entryPath = realpathSync(argvEntry)\n\n return currentModulePath === entryPath\n } catch {\n return import.meta.url === pathToFileURL(argvEntry).href\n }\n}\n\nif (isEntrypointExecution()) {\n await runConsoleKernel()\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAa,eAAb,cAAkC,QAAQ;CACtC,AAAU,YAAY;CAEtB,AAAU,cAAc;CAExB,MAAM,SAAU;AACZ,QAAM,IAAI,SAAe,SAAS,WAAW;GAEzC,MAAM,QAAQ,MADE,QAAQ,aAAa,UAAU,aAAa,QAC/B,CAAC,QAAQ,SAAS,EAAE;IAC7C,KAAK,QAAQ,KAAK;IAClB,OAAO;IACP,KAAK,OAAO,OAAO,EAAE,EAAE,QAAQ,KAAK,EAChC,UAAU,cACb,CAAC;IACL,CAAC;AAEF,SAAM,GAAG,UAAU,UAAU;AACzB,WAAO,MAAM;KACf;AAEF,SAAM,GAAG,SAAS,SAAS;AACvB,QAAI,SAAS,KAAK,SAAS,MAAM;AAC7B,cAAS;AAE7B;;AAGgB,2BAAO,IAAI,MAAM,2BAA2B,OAAO,CAAC;KACtD;IACJ;;;;;;AC7BV,IAAa,aAAb,cAAgC,QAAQ;CACpC,AAAU,YAAY;CAEtB,AAAU,cAAc;CAExB,MAAM,SAAU;AACZ,QAAM,IAAI,SAAe,SAAS,WAAW;GAEzC,MAAM,QAAQ,MADE,QAAQ,aAAa,UAAU,aAAa,QAC/B;IAAC;IAAQ;IAAU;IAAe;IAAS,EAAE;IACtE,KAAK,QAAQ,KAAK;IAClB,OAAO;IACV,CAAC;AAEF,SAAM,GAAG,UAAU,UAAU;AACzB,WAAO,MAAM;KACf;AAEF,SAAM,GAAG,SAAS,SAAS;AACvB,QAAI,SAAS,KAAK,SAAS,MAAM;AAC7B,cAAS;AAE7B;;AAGgB,2BAAO,IAAI,MAAM,2BAA2B,OAAO,CAAC;KACtD;IACJ;;;;;;ACxBV,IAAa,iBAAb,cAAoC,QAAiC;CACjE,AAAU,YAAY;;;;;;;;;CAUtB,AAAU,c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