@arkstack/console 0.1.27 → 0.1.28
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.js +54 -1
- package/dist/index.js +391 -8
- package/dist/prepare.js +26 -1
- package/package.json +3 -3
package/dist/app.js
CHANGED
|
@@ -1 +1,54 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path, { isAbsolute, join } from "node:path";
|
|
2
|
+
import { CliApp } from "resora";
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
|
|
5
|
+
//#region dist/app.js
|
|
6
|
+
const resolveStubsDir = (config, options, core) => {
|
|
7
|
+
const configuredDir = config?.localStubsDir;
|
|
8
|
+
if (configuredDir) return isAbsolute(configuredDir) ? configuredDir : join(process.cwd(), configuredDir);
|
|
9
|
+
if (!options?.stubsDir) {
|
|
10
|
+
const driver = core?.getDriver().name ?? "h3";
|
|
11
|
+
let stubsDir = path.resolve(process.cwd(), `node_modules/@arkstack/driver-${driver}/stubs`);
|
|
12
|
+
if (!existsSync(stubsDir)) stubsDir = path.resolve(process.cwd(), "stubs");
|
|
13
|
+
return stubsDir;
|
|
14
|
+
}
|
|
15
|
+
return options?.stubsDir;
|
|
16
|
+
};
|
|
17
|
+
var ArkstackConsoleApp = class extends CliApp {
|
|
18
|
+
core;
|
|
19
|
+
options;
|
|
20
|
+
constructor(core, options) {
|
|
21
|
+
super();
|
|
22
|
+
this.core = core;
|
|
23
|
+
this.options = options;
|
|
24
|
+
}
|
|
25
|
+
makeController = (name, opts) => {
|
|
26
|
+
const normalized = name.endsWith("Controller") ? name.replace(/controller/i, "") : name;
|
|
27
|
+
let controllerName = normalized.endsWith("Controller") ? normalized : `${normalized}Controller`;
|
|
28
|
+
const outputPath = join(path.resolve(process.cwd(), "src", "app/http/controllers"), `${controllerName}.${opts?.ext ?? "ts"}`);
|
|
29
|
+
const stubsDir = resolveStubsDir(this.config, this.options, this.core);
|
|
30
|
+
if (!stubsDir) {
|
|
31
|
+
console.error("Error: stubsDir is not configured. Set stubsDir in resora.config.js.");
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
const stubPath = join(stubsDir, opts.model ? this.config.stubs.model : opts.api ? this.config.stubs.api : this.config.stubs.controller);
|
|
35
|
+
if (!existsSync(stubPath)) {
|
|
36
|
+
console.error(`Error: Stub file ${stubPath} not found.`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
controllerName = controllerName.split("/").pop();
|
|
40
|
+
this.generateFile(stubPath, outputPath, {
|
|
41
|
+
ControllerName: controllerName,
|
|
42
|
+
Model: opts.model?.pascalCase(),
|
|
43
|
+
ModelName: opts.model?.camelCase(),
|
|
44
|
+
Name: controllerName.replace(/controller/i, "")
|
|
45
|
+
}, opts);
|
|
46
|
+
return outputPath;
|
|
47
|
+
};
|
|
48
|
+
normalizePath = (p) => {
|
|
49
|
+
return p.replace(process.cwd(), "");
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { ArkstackConsoleApp, resolveStubsDir };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,112 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{ArkstackConsoleApp
|
|
2
|
+
import { ArkstackConsoleApp } from "./app.js";
|
|
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 { resolve } from "path";
|
|
10
|
+
import { writeFile } from "fs/promises";
|
|
11
|
+
import { CliApp as CliApp$1, MakeFactoryCommand, MakeMigrationCommand, MakeModelCommand, MakeSeederCommand, MigrateCommand, MigrateRollbackCommand, MigrationHistoryCommand, ModelsSyncCommand, SeedCommand } from "arkormx";
|
|
12
|
+
import chalk from "chalk";
|
|
13
|
+
import { loadPrototypes } from "@arkstack/common";
|
|
14
|
+
|
|
15
|
+
//#region dist/commands/BuildCommand.js
|
|
16
|
+
var BuildCommand = class extends Command {
|
|
17
|
+
signature = "build";
|
|
18
|
+
description = "Build the application for production";
|
|
19
|
+
async handle() {
|
|
20
|
+
await new Promise((resolve, reject) => {
|
|
21
|
+
const child = spawn(process.platform === "win32" ? "pnpm.cmd" : "pnpm", ["exec", "tsdown"], {
|
|
22
|
+
cwd: process.cwd(),
|
|
23
|
+
stdio: "inherit",
|
|
24
|
+
env: Object.assign({}, process.env, { NODE_ENV: "production" })
|
|
25
|
+
});
|
|
26
|
+
child.on("error", (error) => {
|
|
27
|
+
reject(error);
|
|
28
|
+
});
|
|
29
|
+
child.on("exit", (code) => {
|
|
30
|
+
if (code === 0 || code === null) {
|
|
31
|
+
resolve();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
reject(/* @__PURE__ */ new Error(`tsdown exited with code ${code}`));
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region dist/commands/DevCommand.js
|
|
42
|
+
var DevCommand = class extends Command {
|
|
43
|
+
signature = "dev";
|
|
44
|
+
description = "Run the development server";
|
|
45
|
+
async handle() {
|
|
46
|
+
await new Promise((resolve, reject) => {
|
|
47
|
+
const child = spawn(process.platform === "win32" ? "pnpm.cmd" : "pnpm", [
|
|
48
|
+
"exec",
|
|
49
|
+
"tsdown",
|
|
50
|
+
"--log-level",
|
|
51
|
+
"silent"
|
|
52
|
+
], {
|
|
53
|
+
cwd: process.cwd(),
|
|
54
|
+
stdio: "inherit"
|
|
55
|
+
});
|
|
56
|
+
child.on("error", (error) => {
|
|
57
|
+
reject(error);
|
|
58
|
+
});
|
|
59
|
+
child.on("exit", (code) => {
|
|
60
|
+
if (code === 0 || code === null) {
|
|
61
|
+
resolve();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
reject(/* @__PURE__ */ new Error(`tsdown exited with code ${code}`));
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region dist/commands/MakeCommand.js
|
|
72
|
+
var MakeCommand = class extends Command {
|
|
73
|
+
signature = `make:command
|
|
3
74
|
{name : name of the command to create}
|
|
4
|
-
`;
|
|
5
|
-
|
|
75
|
+
`;
|
|
76
|
+
description = "Creates a new console command class.";
|
|
77
|
+
async handle() {
|
|
78
|
+
const name = String(this.argument("name")).replace(/\s+/g, "").replace(/\.js$/, "").trim();
|
|
79
|
+
if (!name) return void this.error("Command name is required");
|
|
80
|
+
const stubContent = this.stub(name);
|
|
81
|
+
const filePath = resolve(process.cwd(), "src", `app/console/commands/${name}.js`);
|
|
82
|
+
await writeFile(filePath, stubContent, { flag: "wx" });
|
|
83
|
+
this.success(`Command ${name} created successfully at ${filePath}`);
|
|
84
|
+
}
|
|
85
|
+
stub(name) {
|
|
86
|
+
name = name.endsWith("Command") ? name : `${name}Command`;
|
|
87
|
+
name = name.split("/").pop().split(".").shift();
|
|
88
|
+
const signature = `app:${name.toLowerCase()}`;
|
|
89
|
+
const description = `Description for ${signature} command`;
|
|
90
|
+
return [
|
|
91
|
+
"import { Command } from '@h3ravel/musket'",
|
|
92
|
+
"",
|
|
93
|
+
`export class ${name} extends Command {`,
|
|
94
|
+
` signature = '${signature}'`,
|
|
95
|
+
"",
|
|
96
|
+
` description = '${description}'`,
|
|
97
|
+
"",
|
|
98
|
+
" async handle () {",
|
|
99
|
+
" // Command logic goes here",
|
|
100
|
+
" }",
|
|
101
|
+
"}"
|
|
102
|
+
].join("\n");
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region dist/commands/MakeController.js
|
|
108
|
+
var MakeController = class extends Command {
|
|
109
|
+
signature = `make:controller
|
|
6
110
|
{name : name of the controller to create}
|
|
7
111
|
{--api : make an API controller}
|
|
8
112
|
{--m|model? : name of model to attach to controller}
|
|
@@ -10,22 +114,301 @@ import{ArkstackConsoleApp as e}from"./app.js";import{fileURLToPath as t,pathToFi
|
|
|
10
114
|
{--s|seeder : Create a seeder file for the model (only if --model is specified)}
|
|
11
115
|
{--x|migration : Create a migration file for the model (only if --model is specified)}
|
|
12
116
|
{--force : force overwrite if controller already exists}
|
|
13
|
-
`;
|
|
117
|
+
`;
|
|
118
|
+
description = "Create a new controller file";
|
|
119
|
+
async handle() {
|
|
120
|
+
this.app.command = this;
|
|
121
|
+
if (!this.argument("name")) return void this.error("Error: Controller name is required.");
|
|
122
|
+
const name = this.app.makeController(this.argument("name"), this.options());
|
|
123
|
+
const app = new CliApp$1();
|
|
124
|
+
const model = this.option("model") ? app.makeModel(this.argument("model"), {
|
|
125
|
+
...this.options(),
|
|
126
|
+
force: false
|
|
127
|
+
}) : null;
|
|
128
|
+
this.success("Controller created successfully!");
|
|
129
|
+
[
|
|
130
|
+
["Controller", name],
|
|
131
|
+
model ? ["Model", model.model.path] : "",
|
|
132
|
+
model ? [`Prisma schema ${model.prisma.updated ? "(updated)" : "(already up to date)"}`, model?.prisma.path] : "",
|
|
133
|
+
model?.factory ? ["Factory", model.factory.path] : "",
|
|
134
|
+
model?.seeder ? ["Seeder", model.seeder.path] : "",
|
|
135
|
+
model?.migration ? ["Migration", model.migration.path] : ""
|
|
136
|
+
].filter(Boolean).map(([name, path]) => this.success(app.splitLogger(name, path)));
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region dist/commands/MakeFactoryCommand.js
|
|
142
|
+
var MakeFactoryCommand$1 = class extends MakeFactoryCommand {
|
|
143
|
+
async handle() {
|
|
144
|
+
this.app.command = this;
|
|
145
|
+
this.app = new CliApp$1();
|
|
146
|
+
return super.handle();
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region dist/commands/MakeFullResource.js
|
|
152
|
+
var MakeFullResource = class extends Command {
|
|
153
|
+
signature = `make:full-resource
|
|
14
154
|
{prefix : prefix of the resources to create, "Admin" will create AdminResource, AdminCollection and AdminController}
|
|
15
155
|
{--m|model? : name of model to attach to the generated controller (will be created if it doesn't exist)}
|
|
16
156
|
{--f|factory : Create and link a factory}
|
|
17
157
|
{--s|seeder : Create a seeder file for the model (only if --model is specified)}
|
|
18
158
|
{--x|migration : Create a migration file for the model (only if --model is specified)}
|
|
19
159
|
{--force : force overwrite if resources already exist}
|
|
20
|
-
`;
|
|
160
|
+
`;
|
|
161
|
+
description = "Create a full new set of API resources (Controller, Resource, Collection)";
|
|
162
|
+
async handle() {
|
|
163
|
+
this.app.command = this;
|
|
164
|
+
const res = this.app.makeResource(this.argument("prefix"), { force: this.option("force") });
|
|
165
|
+
const col = this.app.makeResource(this.argument("prefix") + "Collection", {
|
|
166
|
+
collection: true,
|
|
167
|
+
force: this.option("force")
|
|
168
|
+
});
|
|
169
|
+
const cont = this.app.makeController(this.argument("prefix"), Object.assign({}, this.options(), {
|
|
170
|
+
api: true,
|
|
171
|
+
force: this.option("force")
|
|
172
|
+
}));
|
|
173
|
+
const app = new CliApp$1();
|
|
174
|
+
const model = this.option("model") ? app.makeModel(this.argument("prefix"), {
|
|
175
|
+
...this.options(),
|
|
176
|
+
force: false
|
|
177
|
+
}) : null;
|
|
178
|
+
this.success("Created full resource set:");
|
|
179
|
+
[
|
|
180
|
+
["Resource", res.path],
|
|
181
|
+
["Collection", col.path],
|
|
182
|
+
["Controller", cont],
|
|
183
|
+
model ? ["Model", model.model.path] : "",
|
|
184
|
+
model ? [`Prisma schema ${model.prisma.updated ? "(updated)" : "(already up to date)"}`, model.prisma.path] : "",
|
|
185
|
+
model?.factory ? ["Factory", model.factory.path] : "",
|
|
186
|
+
model?.seeder ? ["Seeder", model.seeder.path] : "",
|
|
187
|
+
model?.migration ? ["Migration", model.migration.path] : ""
|
|
188
|
+
].filter(Boolean).map(([name, path]) => this.success(app.splitLogger(name, path)));
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region dist/commands/MakeMigrationCommand.js
|
|
194
|
+
var MakeMigrationCommand$1 = class extends MakeMigrationCommand {
|
|
195
|
+
async handle() {
|
|
196
|
+
this.app.command = this;
|
|
197
|
+
this.app = new CliApp$1();
|
|
198
|
+
return super.handle();
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region dist/commands/MakeModelCommand.js
|
|
204
|
+
var MakeModelCommand$1 = class extends MakeModelCommand {
|
|
205
|
+
async handle() {
|
|
206
|
+
this.app.command = this;
|
|
207
|
+
this.app = new CliApp$1();
|
|
208
|
+
return super.handle();
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region dist/commands/MakeResource.js
|
|
214
|
+
var MakeResource$1 = class extends MakeResource {};
|
|
215
|
+
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region dist/commands/MakeSeederCommand.js
|
|
218
|
+
var MakeSeederCommand$1 = class extends MakeSeederCommand {
|
|
219
|
+
async handle() {
|
|
220
|
+
this.app.command = this;
|
|
221
|
+
this.app = new CliApp$1();
|
|
222
|
+
return super.handle();
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region dist/commands/MigrateCommand.js
|
|
228
|
+
var MigrateCommand$1 = class extends MigrateCommand {
|
|
229
|
+
async handle() {
|
|
230
|
+
this.app.command = this;
|
|
231
|
+
this.app = new CliApp$1();
|
|
232
|
+
return super.handle();
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
//#endregion
|
|
237
|
+
//#region dist/commands/MigrateRollbackCommand.js
|
|
238
|
+
var MigrateRollbackCommand$1 = class extends MigrateRollbackCommand {
|
|
239
|
+
async handle() {
|
|
240
|
+
this.app.command = this;
|
|
241
|
+
this.app = new CliApp$1();
|
|
242
|
+
return super.handle();
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region dist/commands/MigrationHistoryCommand.js
|
|
248
|
+
var MigrationHistoryCommand$1 = class extends MigrationHistoryCommand {
|
|
249
|
+
async handle() {
|
|
250
|
+
this.app.command = this;
|
|
251
|
+
this.app = new CliApp$1();
|
|
252
|
+
return super.handle();
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region dist/commands/ModelsSyncCommand.js
|
|
258
|
+
var ModelsSyncCommand$1 = class extends ModelsSyncCommand {
|
|
259
|
+
async handle() {
|
|
260
|
+
this.app.command = this;
|
|
261
|
+
this.app = new CliApp$1();
|
|
262
|
+
return super.handle();
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region dist/commands/RouteList.js
|
|
268
|
+
var RouteList = class extends Command {
|
|
269
|
+
signature = `route:list
|
|
21
270
|
{--p|path? : Path to filter routes by}
|
|
22
271
|
{--m|method? : Method to filter routes by}
|
|
23
|
-
`;
|
|
24
|
-
|
|
272
|
+
`;
|
|
273
|
+
description = "List all registered routes";
|
|
274
|
+
async handle() {
|
|
275
|
+
const routes = await this.app.core.getRouter().list(this.options(), this.app.core.getAppInstance());
|
|
276
|
+
const filteredRoutes = this.filterRoutes(routes);
|
|
277
|
+
console.log(this.formatRoutes(filteredRoutes.reverse()));
|
|
278
|
+
this.newLine();
|
|
279
|
+
this.info(`Total routes: ${filteredRoutes.length}`);
|
|
280
|
+
}
|
|
281
|
+
filterRoutes(routes) {
|
|
282
|
+
const path = this.option("path");
|
|
283
|
+
const method = this.option("method");
|
|
284
|
+
if (!path && !method) return routes;
|
|
285
|
+
return routes.filter((route) => {
|
|
286
|
+
const pathMatches = path ? route.path.includes(path) : true;
|
|
287
|
+
const methodMatches = method ? route.methods.includes(method.toLowerCase()) : true;
|
|
288
|
+
return pathMatches && methodMatches;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
formatRoutes(routes) {
|
|
292
|
+
if (routes.length === 0) return "No routes registered.";
|
|
293
|
+
const rows = routes.map((route) => ({
|
|
294
|
+
method: route.methods.join(" | ").toUpperCase(),
|
|
295
|
+
path: route.path,
|
|
296
|
+
handler: route.controllerName ? `${route.controllerName} → ${route.actionName}` : route.actionName ?? "N/A"
|
|
297
|
+
}));
|
|
298
|
+
const methodWidth = Math.max(6, ...rows.map((row) => row.method.length));
|
|
299
|
+
const pathWidth = Math.max(4, ...rows.map((row) => row.path.length));
|
|
300
|
+
const handlerWidth = Math.max(7, ...rows.map((row) => row.handler.length));
|
|
301
|
+
return [
|
|
302
|
+
`${"METHOD".padEnd(methodWidth)} ${"PATH".padEnd(pathWidth)} ${"HANDLER".padEnd(handlerWidth)}`,
|
|
303
|
+
`${"-".repeat(methodWidth)} ${"-".repeat(pathWidth)} ${"-".repeat(handlerWidth)}`,
|
|
304
|
+
...rows.map((row) => `${this.formatMethod(row.method.padEnd(methodWidth))} ${chalk.blue(row.path.padEnd(pathWidth))} ${chalk.yellow(row.handler.padEnd(handlerWidth))}`)
|
|
305
|
+
].join("\n");
|
|
306
|
+
}
|
|
307
|
+
methodColor(method) {
|
|
308
|
+
switch (method) {
|
|
309
|
+
case "GET": return chalk.green(method);
|
|
310
|
+
case "POST": return chalk.blue(method);
|
|
311
|
+
case "PUT": return chalk.yellow(method);
|
|
312
|
+
case "DELETE": return chalk.red(method);
|
|
313
|
+
case "PATCH": return chalk.magenta(method);
|
|
314
|
+
case "OPTIONS": return chalk.cyan(method);
|
|
315
|
+
default: return chalk.gray(method);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
formatMethod(method) {
|
|
319
|
+
const methods = method.split(" | ");
|
|
320
|
+
if (methods.length > 1) return methods.map((m) => this.methodColor(m)).join(chalk.gray(" | "));
|
|
321
|
+
return this.methodColor(method.toUpperCase());
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region dist/commands/SeedCommand.js
|
|
327
|
+
var SeedCommand$1 = class extends SeedCommand {
|
|
328
|
+
async handle() {
|
|
329
|
+
this.app.command = this;
|
|
330
|
+
this.app = new CliApp$1();
|
|
331
|
+
return super.handle();
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region dist/logo.js
|
|
337
|
+
var logo_default = String.raw`
|
|
25
338
|
___ _ _
|
|
26
339
|
/ _ \ | | | |
|
|
27
340
|
/ /_\ \_ __ ___ ___| |_ __ _ ___| | __
|
|
28
341
|
| _ | '__/ __/ __| __/ _' |/ __| |/ /
|
|
29
342
|
| | | | | | (__\__ \ || (_| | (__| <
|
|
30
343
|
\_| |_/_| \___|___/\__\__,_|\___|_|\_\
|
|
31
|
-
`;
|
|
344
|
+
`;
|
|
345
|
+
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region dist/index.js
|
|
348
|
+
/**
|
|
349
|
+
* Loads the core application instance by importing the bootstrap file.
|
|
350
|
+
*
|
|
351
|
+
* @returns
|
|
352
|
+
*/
|
|
353
|
+
const loadCoreApp = async () => {
|
|
354
|
+
return (await import(pathToFileURL(join(process.cwd(), "dist/core/bootstrap.js")).href)).app;
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* Runs the console kernel, initializing the application and registering commands.
|
|
358
|
+
*
|
|
359
|
+
* @param options
|
|
360
|
+
*/
|
|
361
|
+
const runConsoleKernel = async (options = {}) => {
|
|
362
|
+
loadPrototypes();
|
|
363
|
+
const app = await loadCoreApp();
|
|
364
|
+
const stubsDir = process.env.ARKSTACK_STUBS_DIR;
|
|
365
|
+
await Kernel.init(await new ArkstackConsoleApp(app, { stubsDir }).loadConfig(), {
|
|
366
|
+
logo: options.logo ?? logo_default,
|
|
367
|
+
name: "Cmd",
|
|
368
|
+
baseCommands: [
|
|
369
|
+
RouteList,
|
|
370
|
+
MakeResource$1,
|
|
371
|
+
MakeController,
|
|
372
|
+
MakeFullResource,
|
|
373
|
+
DevCommand,
|
|
374
|
+
BuildCommand,
|
|
375
|
+
MakeFactoryCommand$1,
|
|
376
|
+
MakeMigrationCommand$1,
|
|
377
|
+
MakeModelCommand$1,
|
|
378
|
+
MakeSeederCommand$1,
|
|
379
|
+
MigrateCommand$1,
|
|
380
|
+
ModelsSyncCommand$1,
|
|
381
|
+
SeedCommand$1,
|
|
382
|
+
MakeCommand,
|
|
383
|
+
MigrateRollbackCommand$1,
|
|
384
|
+
MigrationHistoryCommand$1
|
|
385
|
+
],
|
|
386
|
+
discoveryPaths: [
|
|
387
|
+
join(process.cwd(), "src", "app/console/commands/*.js"),
|
|
388
|
+
join(process.cwd(), "src", "app/console/commands/*.js"),
|
|
389
|
+
join(process.cwd(), "src", "app/console/commands/*.mjs")
|
|
390
|
+
],
|
|
391
|
+
exceptionHandler(exception) {
|
|
392
|
+
throw exception;
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
/**
|
|
397
|
+
* Determines if the current module is being executed as the entry
|
|
398
|
+
* point of the application.
|
|
399
|
+
*
|
|
400
|
+
* @returns
|
|
401
|
+
*/
|
|
402
|
+
const isEntrypointExecution = () => {
|
|
403
|
+
const argvEntry = process.argv[1];
|
|
404
|
+
if (!argvEntry) return false;
|
|
405
|
+
try {
|
|
406
|
+
return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(argvEntry);
|
|
407
|
+
} catch {
|
|
408
|
+
return import.meta.url === pathToFileURL(argvEntry).href;
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
if (isEntrypointExecution()) await runConsoleKernel();
|
|
412
|
+
|
|
413
|
+
//#endregion
|
|
414
|
+
export { runConsoleKernel };
|
package/dist/prepare.js
CHANGED
|
@@ -1 +1,26 @@
|
|
|
1
|
-
import{spawn
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
|
|
4
|
+
//#region dist/prepare.js
|
|
5
|
+
const child = spawn(process.platform === "win32" ? "pnpm.cmd" : "pnpm", [
|
|
6
|
+
"exec",
|
|
7
|
+
"tsdown",
|
|
8
|
+
"--log-level=silent"
|
|
9
|
+
], {
|
|
10
|
+
cwd: process.cwd(),
|
|
11
|
+
stdio: "inherit",
|
|
12
|
+
env: Object.assign({}, process.env, { NODE_ENV: "production" })
|
|
13
|
+
});
|
|
14
|
+
child.on("error", (error) => {
|
|
15
|
+
throw error;
|
|
16
|
+
});
|
|
17
|
+
child.on("exit", (code) => {
|
|
18
|
+
if (code === 0 || code === null) {
|
|
19
|
+
console.log(chalk.green("Arkstak is ready for development!"));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
throw new Error(`tsdown exited with code ${code}`);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/console",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
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",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"@h3ravel/musket": "^0.10.1",
|
|
50
50
|
"chalk": "^5.6.2",
|
|
51
51
|
"resora": "^0.2.14",
|
|
52
|
-
"@arkstack/common": "^0.1.
|
|
53
|
-
"@arkstack/contract": "^0.1.
|
|
52
|
+
"@arkstack/common": "^0.1.28",
|
|
53
|
+
"@arkstack/contract": "^0.1.28"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "tsdown",
|